Skip to content

Commit

Permalink
GH-1523 Use 65536 for max_finalizers and 256 for max finalizer descri…
Browse files Browse the repository at this point in the history
…ption. Remove generation from finalizer_set used by CDT/ABI.
  • Loading branch information
heifner committed Aug 31, 2023
1 parent c6aa358 commit ef8069d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,7 @@ struct controller_impl {
void set_finalizers_impl(const finalizer_set& fin_set) {
// TODO store in chainbase
current_finalizer_set = fin_set;
++current_finalizer_set.generation;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/eosio/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ static_assert(maximum_tracked_dpos_confirmations >= ((max_producers * 2 / 3) + 1
/**
* Maximum number of finalizers in the finalizer set
*/
const static int max_finalizers = max_producers;
const static size_t max_finalizers = 64*1024;
const static size_t max_finalizer_description = 256;

/**
* The number of blocks produced per round is based upon all producers having a chance
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/include/eosio/chain/finalizer_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace eosio::chain {
finalizer_set& operator=(const finalizer_set&);
finalizer_set& operator=(finalizer_set&&);

uint32_t version = 0; ///< sequentially incrementing version number
uint64_t fthreshold = 0; // vote fweight threshold to finalize blocks
vector<finalizer_authority> finalizers; // Instant Finality voter set
uint32_t generation = 0; ///< sequentially incrementing version number
uint64_t fthreshold = 0; ///< vote fweight threshold to finalize blocks
std::vector<finalizer_authority> finalizers; ///< Instant Finality voter set

auto operator<=>(const finalizer_set&) const;
};
Expand All @@ -45,5 +45,5 @@ namespace eosio::chain {

} /// eosio::chain

FC_REFLECT( eosio::chain::finalizer_set, (version)(fthreshold)(finalizers) )
FC_REFLECT( eosio::chain::finalizer_set, (generation)(fthreshold)(finalizers) )
FC_REFLECT_DERIVED( eosio::chain::hs_finalizer_set_extension, (eosio::chain::finalizer_set), )
11 changes: 8 additions & 3 deletions libraries/chain/webassembly/privileged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,15 @@ namespace eosio { namespace chain { namespace webassembly {
EOS_ASSERT(!context.trx_context.is_read_only(), wasm_execution_error, "set_proposed_finalizers not allowed in a readonly transaction");
fc::datastream<const char*> ds( packed_finalizer_set.data(), packed_finalizer_set.size() );
finalizer_set finset;
fc::raw::unpack(ds, finset);
// contract finalizer_set does not include uint32_t generation
// struct abi_finalizer_set {
// uint64_t fthreshold
// vector<finalizer_authority> finalizers; }
fc::raw::unpack(ds, finset.fthreshold);
fc::raw::unpack(ds, finset.finalizers);

vector<finalizer_authority>& finalizers = finset.finalizers;

// TODO: check version and increment it or verify correct
EOS_ASSERT( finalizers.size() <= config::max_finalizers, wasm_execution_error, "Finalizer set exceeds the maximum finalizer count for this chain" );
EOS_ASSERT( finalizers.size() > 0, wasm_execution_error, "Finalizer set cannot be empty" );

Expand All @@ -169,7 +174,7 @@ namespace eosio { namespace chain { namespace webassembly {
for (const auto& f: finalizers) {
f_weight_sum += f.fweight;
unique_finalizer_keys.insert(f.public_key);
EOS_ASSERT( f.description.size() <= 256, wasm_execution_error, "Finalizer description greater than 256" );
EOS_ASSERT( f.description.size() <= config::max_finalizer_description, wasm_execution_error, "Finalizer description greater than 256" );
}

EOS_ASSERT( finalizers.size() == unique_finalizer_keys.size(), wasm_execution_error, "Duplicate finalizer bls key in finalizer set" );
Expand Down

0 comments on commit ef8069d

Please sign in to comment.