From 7d29c5c0929472a1044db1c0a7c8e9eebc51123f Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 24 Apr 2024 12:24:36 -0500 Subject: [PATCH 1/6] Use string for variant format of fc::dynamic_bitset --- .../libfc/include/fc/variant_dynamic_bitset.hpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp index ce2acb68a3..004d0fc218 100644 --- a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp +++ b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp @@ -12,19 +12,13 @@ namespace fc if ( num_blocks > MAX_NUM_ARRAY_ELEMENTS ) throw std::range_error( "number of blocks of dynamic_bitset cannot be greather than MAX_NUM_ARRAY_ELEMENTS" ); - std::vector blocks(num_blocks); - boost::to_block_range(bs, blocks.begin()); - v = fc::mutable_variant_object("size", bs.size()) - ("bits", blocks); + std::string s; + to_string(bs, s); + v = std::move(s); } inline void from_variant( const fc::variant& v, fc::dynamic_bitset& bs ) { - fc::dynamic_bitset::size_type size; - std::vector blocks; - - from_variant(v["size"], size); - from_variant(v["bits"], blocks); - bs = { blocks.cbegin(), blocks.cend() }; - bs.resize(size); + std::string s = v.get_string(); + bs = fc::dynamic_bitset(s); } } // namespace fc From 470fe51e9c6ac9dc477a87ad475ba95a0992fce5 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 24 Apr 2024 12:47:20 -0500 Subject: [PATCH 2/6] Reverse the string for more logical ordering --- libraries/libfc/include/fc/variant_dynamic_bitset.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp index 004d0fc218..0635135e76 100644 --- a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp +++ b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp @@ -14,11 +14,18 @@ namespace fc std::string s; to_string(bs, s); + // From boost::dynamic_bitset docs: + // A character in the string is '1' if the corresponding bit is set, and '0' if it is not. Character + // position i in the string corresponds to bit position b.size() - 1 - i. + // reverse so the ith string charactor corresponds to the ith dynamic_bitset entry + std::ranges::reverse(s); v = std::move(s); } inline void from_variant( const fc::variant& v, fc::dynamic_bitset& bs ) { std::string s = v.get_string(); + // see comment above + std::ranges::reverse(s); bs = fc::dynamic_bitset(s); } } // namespace fc From e0490ad5460e2483c62011925a36e39063f97a25 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 24 Apr 2024 12:49:39 -0500 Subject: [PATCH 3/6] Fix spelling --- libraries/libfc/include/fc/variant_dynamic_bitset.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp index 0635135e76..76de18de9c 100644 --- a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp +++ b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp @@ -17,7 +17,7 @@ namespace fc // From boost::dynamic_bitset docs: // A character in the string is '1' if the corresponding bit is set, and '0' if it is not. Character // position i in the string corresponds to bit position b.size() - 1 - i. - // reverse so the ith string charactor corresponds to the ith dynamic_bitset entry + // reverse so the ith string character corresponds to the ith dynamic_bitset entry std::ranges::reverse(s); v = std::move(s); } From 40436ddffd24096ba764fc15d44457ec6874c14a Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 24 Apr 2024 17:38:55 -0500 Subject: [PATCH 4/6] Decision to use boost string format for order of 0,1 --- libraries/libfc/include/fc/variant_dynamic_bitset.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp index 76de18de9c..e671035da1 100644 --- a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp +++ b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp @@ -17,15 +17,11 @@ namespace fc // From boost::dynamic_bitset docs: // A character in the string is '1' if the corresponding bit is set, and '0' if it is not. Character // position i in the string corresponds to bit position b.size() - 1 - i. - // reverse so the ith string character corresponds to the ith dynamic_bitset entry - std::ranges::reverse(s); v = std::move(s); } inline void from_variant( const fc::variant& v, fc::dynamic_bitset& bs ) { std::string s = v.get_string(); - // see comment above - std::ranges::reverse(s); bs = fc::dynamic_bitset(s); } } // namespace fc From 05aa152d2d5030ef83584544cbf9437b8621ffe4 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 24 Apr 2024 17:40:42 -0500 Subject: [PATCH 5/6] Remove unneeded include --- libraries/libfc/include/fc/variant_dynamic_bitset.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp index e671035da1..3862553b88 100644 --- a/libraries/libfc/include/fc/variant_dynamic_bitset.hpp +++ b/libraries/libfc/include/fc/variant_dynamic_bitset.hpp @@ -3,8 +3,6 @@ #include #include -#include "variant_object.hpp" - namespace fc { inline void to_variant( const fc::dynamic_bitset& bs, fc::variant& v ) { From 41bee81787e594c798948c13f84c4470556aaa41 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 24 Apr 2024 17:58:46 -0500 Subject: [PATCH 6/6] Rename reflected types so their JSON representation does not include _ prefix --- libraries/chain/block_state.cpp | 14 +-- libraries/chain/controller.cpp | 8 +- .../chain/finality/quorum_certificate.cpp | 118 +++++++++--------- .../chain/finality/quorum_certificate.hpp | 53 ++++---- plugins/producer_plugin/producer_plugin.cpp | 26 ++-- 5 files changed, 109 insertions(+), 110 deletions(-) diff --git a/libraries/chain/block_state.cpp b/libraries/chain/block_state.cpp index 44300e20d9..c7cb850ff0 100644 --- a/libraries/chain/block_state.cpp +++ b/libraries/chain/block_state.cpp @@ -222,8 +222,8 @@ void block_state::verify_qc(const valid_quorum_certificate& qc) const { }; // compute strong and weak accumulated weights - auto strong_weights = qc._strong_votes ? weights( *qc._strong_votes ) : 0; - auto weak_weights = qc._weak_votes ? weights( *qc._weak_votes ) : 0; + auto strong_weights = qc.strong_votes ? weights( *qc.strong_votes ) : 0; + auto weak_weights = qc.weak_votes ? weights( *qc.weak_votes ) : 0; // verfify quorum is met if( qc.is_strong() ) { @@ -259,18 +259,18 @@ void block_state::verify_qc(const valid_quorum_certificate& qc) const { }; // aggregate public keys and digests for strong and weak votes - if( qc._strong_votes ) { - pubkeys.emplace_back(aggregate_pubkeys(*qc._strong_votes)); + if( qc.strong_votes ) { + pubkeys.emplace_back(aggregate_pubkeys(*qc.strong_votes)); digests.emplace_back(std::vector{strong_digest.data(), strong_digest.data() + strong_digest.data_size()}); } - if( qc._weak_votes ) { - pubkeys.emplace_back(aggregate_pubkeys(*qc._weak_votes)); + if( qc.weak_votes ) { + pubkeys.emplace_back(aggregate_pubkeys(*qc.weak_votes)); digests.emplace_back(std::vector{weak_digest.begin(), weak_digest.end()}); } // validate aggregated signature - EOS_ASSERT( bls12_381::aggregate_verify(pubkeys, digests, qc._sig.jacobian_montgomery_le()), + EOS_ASSERT( bls12_381::aggregate_verify(pubkeys, digests, qc.sig.jacobian_montgomery_le()), invalid_qc_claim, "signature validation failed" ); } diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 657cf2eb7a..14d78eee12 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -3721,10 +3721,10 @@ struct controller_impl { ("n1", qc_proof.block_num)("n2", new_qc_claim.block_num)("b", block_num) ); // Verify claimed strictness is the same as in proof - EOS_ASSERT( qc_proof.qc.is_strong() == new_qc_claim.is_strong_qc, + EOS_ASSERT( qc_proof.data.is_strong() == new_qc_claim.is_strong_qc, invalid_qc_claim, "QC is_strong (${s1}) in block extension does not match is_strong_qc (${s2}) in header extension. Block number: ${b}", - ("s1", qc_proof.qc.is_strong())("s2", new_qc_claim.is_strong_qc)("b", block_num) ); + ("s1", qc_proof.data.is_strong())("s2", new_qc_claim.is_strong_qc)("b", block_num) ); // find the claimed block's block state on branch of id auto bsp = fetch_bsp_on_branch_by_num( prev.id(), new_qc_claim.block_num ); @@ -3734,7 +3734,7 @@ struct controller_impl { ("q", new_qc_claim.block_num)("b", block_num) ); // verify the QC proof against the claimed block - bsp->verify_qc(qc_proof.qc); + bsp->verify_qc(qc_proof.data); } // thread safe, expected to be called from thread other than the main thread @@ -3843,7 +3843,7 @@ struct controller_impl { return; } const auto& qc_ext = std::get(block_exts.lower_bound(qc_ext_id)->second); - const auto& received_qc = qc_ext.qc.qc; + const auto& received_qc = qc_ext.qc.data; const auto claimed = fetch_bsp_on_branch_by_num( bsp_in->previous(), qc_ext.qc.block_num ); if( !claimed ) { diff --git a/libraries/chain/finality/quorum_certificate.cpp b/libraries/chain/finality/quorum_certificate.cpp index ab1576d66d..5059d18d29 100644 --- a/libraries/chain/finality/quorum_certificate.cpp +++ b/libraries/chain/finality/quorum_certificate.cpp @@ -22,38 +22,38 @@ inline std::vector bitset_to_vector(const vote_bitset& bs) { } bool pending_quorum_certificate::has_voted(size_t index) const { - return _strong_votes.has_voted(index) || _weak_votes.has_voted(index); + return strong_votes.has_voted(index) || weak_votes.has_voted(index); } bool pending_quorum_certificate::has_voted_no_lock(bool strong, size_t index) const { if (strong) { - return _strong_votes.has_voted(index); + return strong_votes.has_voted(index); } - return _weak_votes.has_voted(index); + return weak_votes.has_voted(index); } void pending_quorum_certificate::votes_t::reflector_init() { - _processed = std::vector>(_bitset.size()); - for (size_t i = 0; i < _bitset.size(); ++i) { - if (_bitset[i]) { - _processed[i].store(true, std::memory_order_relaxed); + processed = std::vector>(bitset.size()); + for (size_t i = 0; i < bitset.size(); ++i) { + if (bitset[i]) { + processed[i].store(true, std::memory_order_relaxed); } } } bool pending_quorum_certificate::votes_t::has_voted(size_t index) const { - assert(index < _processed.size()); - return _processed[index].load(std::memory_order_relaxed); + assert(index < processed.size()); + return processed[index].load(std::memory_order_relaxed); } -vote_status pending_quorum_certificate::votes_t::add_vote(size_t index, const bls_signature& sig) { - if (_bitset[index]) { // check here as could have come in while unlocked +vote_status pending_quorum_certificate::votes_t::add_vote(size_t index, const bls_signature& signature) { + if (bitset[index]) { // check here as could have come in while unlocked return vote_status::duplicate; // shouldn't be already present } - _processed[index].store(true, std::memory_order_relaxed); - _bitset.set(index); - _sig.aggregate(sig); // works even if _sig is default initialized (fp2::zero()) + processed[index].store(true, std::memory_order_relaxed); + bitset.set(index); + sig.aggregate(signature); // works even if _sig is default initialized (fp2::zero()) return vote_status::success; } @@ -63,10 +63,10 @@ pending_quorum_certificate::pending_quorum_certificate() pending_quorum_certificate::pending_quorum_certificate(size_t num_finalizers, uint64_t quorum, uint64_t max_weak_sum_before_weak_final) : _mtx(std::make_unique()) - , _quorum(quorum) - , _max_weak_sum_before_weak_final(max_weak_sum_before_weak_final) - , _weak_votes(num_finalizers) - , _strong_votes(num_finalizers) { + , quorum(quorum) + , max_weak_sum_before_weak_final(max_weak_sum_before_weak_final) + , weak_votes(num_finalizers) + , strong_votes(num_finalizers) { } bool pending_quorum_certificate::is_quorum_met() const { @@ -76,24 +76,24 @@ bool pending_quorum_certificate::is_quorum_met() const { // called by add_vote, already protected by mutex vote_status pending_quorum_certificate::add_strong_vote(size_t index, const bls_signature& sig, uint64_t weight) { - if (auto s = _strong_votes.add_vote(index, sig); s != vote_status::success) { + if (auto s = strong_votes.add_vote(index, sig); s != vote_status::success) { return s; } - _strong_sum += weight; + strong_sum += weight; - switch (_state) { + switch (pending_state) { case state_t::unrestricted: case state_t::restricted: - if (_strong_sum >= _quorum) { - assert(_state != state_t::restricted); - _state = state_t::strong; - } else if (_weak_sum + _strong_sum >= _quorum) - _state = (_state == state_t::restricted) ? state_t::weak_final : state_t::weak_achieved; + if (strong_sum >= quorum) { + assert(pending_state != state_t::restricted); + pending_state = state_t::strong; + } else if (weak_sum + strong_sum >= quorum) + pending_state = (pending_state == state_t::restricted) ? state_t::weak_final : state_t::weak_achieved; break; case state_t::weak_achieved: - if (_strong_sum >= _quorum) - _state = state_t::strong; + if (strong_sum >= quorum) + pending_state = state_t::strong; break; case state_t::weak_final: @@ -106,27 +106,27 @@ vote_status pending_quorum_certificate::add_strong_vote(size_t index, const bls_ // called by add_vote, already protected by mutex vote_status pending_quorum_certificate::add_weak_vote(size_t index, const bls_signature& sig, uint64_t weight) { - if (auto s = _weak_votes.add_vote(index, sig); s != vote_status::success) + if (auto s = weak_votes.add_vote(index, sig); s != vote_status::success) return s; - _weak_sum += weight; + weak_sum += weight; - switch (_state) { + switch (pending_state) { case state_t::unrestricted: case state_t::restricted: - if (_weak_sum + _strong_sum >= _quorum) - _state = state_t::weak_achieved; - - if (_weak_sum > _max_weak_sum_before_weak_final) { - if (_state == state_t::weak_achieved) - _state = state_t::weak_final; - else if (_state == state_t::unrestricted) - _state = state_t::restricted; + if (weak_sum + strong_sum >= quorum) + pending_state = state_t::weak_achieved; + + if (weak_sum > max_weak_sum_before_weak_final) { + if (pending_state == state_t::weak_achieved) + pending_state = state_t::weak_final; + else if (pending_state == state_t::unrestricted) + pending_state = state_t::restricted; } break; case state_t::weak_achieved: - if (_weak_sum >= _max_weak_sum_before_weak_final) - _state = state_t::weak_final; + if (weak_sum >= max_weak_sum_before_weak_final) + pending_state = state_t::weak_final; break; case state_t::weak_final: @@ -152,10 +152,10 @@ vote_status pending_quorum_certificate::add_vote(uint32_t connection_id, block_n } std::unique_lock g(*_mtx); - state_t pre_state = _state; + state_t pre_state = pending_state; vote_status s = strong ? add_strong_vote(index, sig, weight) : add_weak_vote(index, sig, weight); - state_t post_state = _state; + state_t post_state = pending_state; g.unlock(); fc_dlog(vote_logger, "connection - ${c} block_num: ${bn}, vote strong: ${sv}, status: ${s}, pre-state: ${pre}, post-state: ${state}, quorum_met: ${q}", @@ -167,14 +167,14 @@ vote_status pending_quorum_certificate::add_vote(uint32_t connection_id, block_n valid_quorum_certificate pending_quorum_certificate::to_valid_quorum_certificate() const { valid_quorum_certificate valid_qc; - if( _state == state_t::strong ) { - valid_qc._strong_votes = _strong_votes._bitset; - valid_qc._sig = _strong_votes._sig; + if( pending_state == state_t::strong ) { + valid_qc.strong_votes = strong_votes.bitset; + valid_qc.sig = strong_votes.sig; } else if (is_quorum_met_no_lock()) { - valid_qc._strong_votes = _strong_votes._bitset; - valid_qc._weak_votes = _weak_votes._bitset; - valid_qc._sig = _strong_votes._sig; - valid_qc._sig.aggregate(_weak_votes._sig); + valid_qc.strong_votes = strong_votes.bitset; + valid_qc.weak_votes = weak_votes.bitset; + valid_qc.sig = strong_votes.sig; + valid_qc.sig.aggregate(weak_votes.sig); } else assert(0); // this should be called only when we have a valid qc. @@ -185,8 +185,8 @@ std::optional pending_quorum_certificate::get_best_qc(block_ std::lock_guard g(*_mtx); // if pending_qc does not have a valid QC, consider valid_qc only if( !is_quorum_met_no_lock() ) { - if( _valid_qc ) { - return std::optional{quorum_certificate{ block_num, *_valid_qc }}; + if( valid_qc ) { + return std::optional{quorum_certificate{ block_num, *valid_qc }}; } else { return std::nullopt; } @@ -196,31 +196,31 @@ std::optional pending_quorum_certificate::get_best_qc(block_ valid_quorum_certificate valid_qc_from_pending = to_valid_quorum_certificate(); // if valid_qc does not have value, consider valid_qc_from_pending only - if( !_valid_qc ) { + if( !valid_qc ) { return std::optional{quorum_certificate{ block_num, valid_qc_from_pending }}; } // Both valid_qc and valid_qc_from_pending have value. Compare them and select a better one. // Strong beats weak. Tie break by valid_qc. const auto& best_qc = - _valid_qc->is_strong() == valid_qc_from_pending.is_strong() ? - *_valid_qc : // tie broken by valid_qc - _valid_qc->is_strong() ? *_valid_qc : valid_qc_from_pending; // strong beats weak + valid_qc->is_strong() == valid_qc_from_pending.is_strong() ? + *valid_qc : // tie broken by valid_qc + valid_qc->is_strong() ? *valid_qc : valid_qc_from_pending; // strong beats weak return std::optional{quorum_certificate{ block_num, best_qc }}; } void pending_quorum_certificate::set_valid_qc(const valid_quorum_certificate& qc) { std::lock_guard g(*_mtx); - _valid_qc = qc; + valid_qc = qc; } bool pending_quorum_certificate::valid_qc_is_strong() const { std::lock_guard g(*_mtx); - return _valid_qc && _valid_qc->is_strong(); + return valid_qc && valid_qc->is_strong(); } bool pending_quorum_certificate::is_quorum_met_no_lock() const { - return is_quorum_met(_state); + return is_quorum_met(pending_state); } } // namespace eosio::chain diff --git a/libraries/chain/include/eosio/chain/finality/quorum_certificate.hpp b/libraries/chain/include/eosio/chain/finality/quorum_certificate.hpp index 0f8fdf0b92..2803718d6f 100644 --- a/libraries/chain/include/eosio/chain/finality/quorum_certificate.hpp +++ b/libraries/chain/include/eosio/chain/finality/quorum_certificate.hpp @@ -5,8 +5,7 @@ #include #include #include - -#include +#include #include @@ -31,21 +30,21 @@ namespace eosio::chain { // valid_quorum_certificate struct valid_quorum_certificate { - bool is_weak() const { return !!_weak_votes; } - bool is_strong() const { return !_weak_votes; } + bool is_weak() const { return !!weak_votes; } + bool is_strong() const { return !weak_votes; } - std::optional _strong_votes; - std::optional _weak_votes; - bls_aggregate_signature _sig; + std::optional strong_votes; + std::optional weak_votes; + bls_aggregate_signature sig; }; // quorum_certificate struct quorum_certificate { uint32_t block_num; - valid_quorum_certificate qc; + valid_quorum_certificate data; qc_claim_t to_qc_claim() const { - return {.block_num = block_num, .is_strong_qc = qc.is_strong()}; + return {.block_num = block_num, .is_strong_qc = data.is_strong()}; } }; @@ -75,15 +74,15 @@ namespace eosio::chain { friend struct fc::has_reflector_init; friend class pending_quorum_certificate; - vote_bitset _bitset; - bls_aggregate_signature _sig; - std::vector> _processed; // avoid locking mutex for _bitset duplicate check + vote_bitset bitset; + bls_aggregate_signature sig; + std::vector> processed; // avoid locking mutex for _bitset duplicate check void reflector_init(); public: explicit votes_t(size_t num_finalizers) - : _bitset(num_finalizers) - , _processed(num_finalizers) {} + : bitset(num_finalizers) + , processed(num_finalizers) {} // thread safe bool has_voted(size_t index) const; @@ -114,7 +113,7 @@ namespace eosio::chain { // thread safe bool has_voted(size_t index) const; - state_t state() const { std::lock_guard g(*_mtx); return _state; }; + state_t state() const { std::lock_guard g(*_mtx); return pending_state; }; std::optional get_best_qc(block_num_type block_num) const; void set_valid_qc(const valid_quorum_certificate& qc); @@ -123,14 +122,14 @@ namespace eosio::chain { friend struct fc::reflector; friend class qc_chain; std::unique_ptr _mtx; - std::optional _valid_qc; // best qc received from the network inside block extension - uint64_t _quorum {0}; - uint64_t _max_weak_sum_before_weak_final {0}; // max weak sum before becoming weak_final - state_t _state { state_t::unrestricted }; - uint64_t _strong_sum {0}; // accumulated sum of strong votes so far - uint64_t _weak_sum {0}; // accumulated sum of weak votes so far - votes_t _weak_votes {0}; - votes_t _strong_votes {0}; + std::optional valid_qc; // best qc received from the network inside block extension + uint64_t quorum {0}; + uint64_t max_weak_sum_before_weak_final {0}; // max weak sum before becoming weak_final + state_t pending_state { state_t::unrestricted }; + uint64_t strong_sum {0}; // accumulated sum of strong votes so far + uint64_t weak_sum {0}; // accumulated sum of weak votes so far + votes_t weak_votes {0}; + votes_t strong_votes {0}; // called by add_vote, already protected by mutex vote_status add_strong_vote(size_t index, @@ -150,8 +149,8 @@ namespace eosio::chain { FC_REFLECT_ENUM(eosio::chain::vote_status, (success)(duplicate)(unknown_public_key)(invalid_signature)(unknown_block)(max_exceeded)) -FC_REFLECT(eosio::chain::valid_quorum_certificate, (_strong_votes)(_weak_votes)(_sig)); -FC_REFLECT(eosio::chain::pending_quorum_certificate, (_valid_qc)(_quorum)(_max_weak_sum_before_weak_final)(_state)(_strong_sum)(_weak_sum)(_weak_votes)(_strong_votes)); +FC_REFLECT(eosio::chain::valid_quorum_certificate, (strong_votes)(weak_votes)(sig)); +FC_REFLECT(eosio::chain::pending_quorum_certificate, (valid_qc)(quorum)(max_weak_sum_before_weak_final)(pending_state)(strong_sum)(weak_sum)(weak_votes)(strong_votes)); FC_REFLECT_ENUM(eosio::chain::pending_quorum_certificate::state_t, (unrestricted)(restricted)(weak_achieved)(weak_final)(strong)); -FC_REFLECT(eosio::chain::pending_quorum_certificate::votes_t, (_bitset)(_sig)); -FC_REFLECT(eosio::chain::quorum_certificate, (block_num)(qc)); +FC_REFLECT(eosio::chain::pending_quorum_certificate::votes_t, (bitset)(sig)); +FC_REFLECT(eosio::chain::quorum_certificate, (block_num)(data)); diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 1075c15144..6120703399 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -639,12 +639,12 @@ class producer_plugin_impl : public std::enable_shared_from_thisfinalizers; assert(votes.size() == finalizers.size()); for (size_t i = 0; i < votes.size(); ++i) { - if (!votes[i] && !check_weak(qc._weak_votes, i)) { + if (!votes[i] && !check_weak(qc.weak_votes, i)) { not_voted.push_back(finalizers[i].description); if (_finalizers.contains(finalizers[i].public_key)) { fc_wlog(vote_logger, "Local finalizer ${f} did not vote on block ${n}:${id}", @@ -675,20 +675,20 @@ class producer_plugin_impl : public std::enable_shared_from_thisfinalizers.size()) { fc::dynamic_bitset not_voted(active_finalizer_policy->finalizers.size()); - if (qc._strong_votes) { - not_voted = *qc._strong_votes; + if (qc.strong_votes) { + not_voted = *qc.strong_votes; } - if (qc._weak_votes) { - assert(not_voted.size() == qc._weak_votes->size()); - not_voted |= *qc._weak_votes; + if (qc.weak_votes) { + assert(not_voted.size() == qc.weak_votes->size()); + not_voted |= *qc.weak_votes; } not_voted.flip(); add_votes(not_voted, m.no_votes); @@ -709,7 +709,7 @@ class producer_plugin_impl : public std::enable_shared_from_thiscontains_extension(quorum_certificate_extension::extension_id())) { if (const auto& active_finalizers = chain.head_active_finalizer_policy()) { const auto& qc_ext = block->extract_extension(); - const auto& qc = qc_ext.qc.qc; + const auto& qc = qc_ext.qc.data; log_missing_votes(block, id, active_finalizers, qc); update_vote_block_metrics(block->block_num(), active_finalizers, qc); }