From 3cc42cc2f98ac9cc9841129147c7ccba2ed48178 Mon Sep 17 00:00:00 2001 From: greg7mdp Date: Thu, 7 Sep 2023 16:41:15 -0400 Subject: [PATCH] Update block deserialization to include newly renamed hs_commitment_extension. --- libraries/chain/block.cpp | 6 +++--- libraries/chain/include/eosio/chain/abi_serializer.hpp | 5 +++++ libraries/chain/include/eosio/chain/block.hpp | 8 ++++---- libraries/chain/include/eosio/chain/hotstuff.hpp | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libraries/chain/block.cpp b/libraries/chain/block.cpp index efd6678adc..55ec28a041 100644 --- a/libraries/chain/block.cpp +++ b/libraries/chain/block.cpp @@ -20,11 +20,11 @@ namespace eosio { namespace chain { } } - void qc_extension::reflector_init() { + void hs_commitment_extension::reflector_init() { static_assert( fc::raw::has_feature_reflector_init_on_unpacked_reflected_types, - "qc_extension expects FC to support reflector_init" ); + "hs_commitment_extension expects FC to support reflector_init" ); - #warning "Do validity checks on QC" + #warning "Do validity checks on hs_commitment" } flat_multimap signed_block::validate_and_extract_extensions()const { diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index d257ec725f..acfe59b2c1 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -690,6 +690,11 @@ namespace impl { std::get(block_exts.lower_bound(additional_block_signatures_extension::extension_id())->second); mvo("additional_signatures", additional_signatures); } + if ( block_exts.count(hs_commitment_extension::extension_id()) > 0) { + const auto& hs_commitment = + std::get(block_exts.lower_bound(hs_commitment_extension::extension_id())->second); + mvo("hotstuff_commitment", hs_commitment); + } out(name, std::move(mvo)); } diff --git a/libraries/chain/include/eosio/chain/block.hpp b/libraries/chain/include/eosio/chain/block.hpp index 36c858f94b..948f490cc3 100644 --- a/libraries/chain/include/eosio/chain/block.hpp +++ b/libraries/chain/include/eosio/chain/block.hpp @@ -71,13 +71,13 @@ namespace eosio { namespace chain { vector signatures; }; - struct qc_extension : fc::reflect_init { + struct hs_commitment_extension : fc::reflect_init { static constexpr uint16_t extension_id() { return 3; } static constexpr bool enforce_unique() { return true; } void reflector_init(); - quorum_certificate_message qc; + hs_commitment commitment; }; namespace detail { @@ -90,7 +90,7 @@ namespace eosio { namespace chain { using block_extension_types = detail::block_extension_types< additional_block_signatures_extension, - qc_extension + hs_commitment_extension >; using block_extension = block_extension_types::block_extension_t; @@ -131,4 +131,4 @@ FC_REFLECT(eosio::chain::transaction_receipt_header, (status)(cpu_usage_us)(net_ FC_REFLECT_DERIVED(eosio::chain::transaction_receipt, (eosio::chain::transaction_receipt_header), (trx) ) FC_REFLECT(eosio::chain::additional_block_signatures_extension, (signatures)); FC_REFLECT_DERIVED(eosio::chain::signed_block, (eosio::chain::signed_block_header), (transactions)(block_extensions) ) -FC_REFLECT(eosio::chain::qc_extension, (qc)); +FC_REFLECT(eosio::chain::hs_commitment_extension, (commitment)); diff --git a/libraries/chain/include/eosio/chain/hotstuff.hpp b/libraries/chain/include/eosio/chain/hotstuff.hpp index d48f3881fe..a84c259646 100644 --- a/libraries/chain/include/eosio/chain/hotstuff.hpp +++ b/libraries/chain/include/eosio/chain/hotstuff.hpp @@ -96,3 +96,4 @@ FC_REFLECT(eosio::chain::hs_proposal_message, (proposal_id)(block_id)(parent_id) FC_REFLECT(eosio::chain::hs_new_block_message, (block_id)(justify)); FC_REFLECT(eosio::chain::hs_new_view_message, (high_qc)); FC_REFLECT(eosio::chain::finalizer_state, (chained_mode)(b_leaf)(b_lock)(b_exec)(b_finality_violation)(block_exec)(pending_proposal_block)(v_height)(high_qc)(current_qc)(schedule)(proposals)); +FC_REFLECT(eosio::chain::hs_commitment,(b)(b1)(b2)(bstar));