diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index b9e4042a62..1fa7cbb1aa 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -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; } /** diff --git a/libraries/chain/include/eosio/chain/config.hpp b/libraries/chain/include/eosio/chain/config.hpp index c3f91d9cbe..a841c53f7a 100644 --- a/libraries/chain/include/eosio/chain/config.hpp +++ b/libraries/chain/include/eosio/chain/config.hpp @@ -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 diff --git a/libraries/chain/include/eosio/chain/finalizer_set.hpp b/libraries/chain/include/eosio/chain/finalizer_set.hpp index b3399f4228..cfc8207ac8 100644 --- a/libraries/chain/include/eosio/chain/finalizer_set.hpp +++ b/libraries/chain/include/eosio/chain/finalizer_set.hpp @@ -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; }; @@ -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), ) \ No newline at end of file diff --git a/libraries/chain/webassembly/privileged.cpp b/libraries/chain/webassembly/privileged.cpp index 5b036e832b..9872905313 100644 --- a/libraries/chain/webassembly/privileged.cpp +++ b/libraries/chain/webassembly/privileged.cpp @@ -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" ); @@ -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" );