Skip to content

Commit

Permalink
Update block deserialization to include newly renamed hs_commitment_e…
Browse files Browse the repository at this point in the history
…xtension.
  • Loading branch information
greg7mdp committed Sep 7, 2023
1 parent bbee27c commit 3cc42cc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions libraries/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t, block_extension> signed_block::validate_and_extract_extensions()const {
Expand Down
5 changes: 5 additions & 0 deletions libraries/chain/include/eosio/chain/abi_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ namespace impl {
std::get<additional_block_signatures_extension>(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<hs_commitment_extension>(block_exts.lower_bound(hs_commitment_extension::extension_id())->second);
mvo("hotstuff_commitment", hs_commitment);
}

out(name, std::move(mvo));
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/include/eosio/chain/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ namespace eosio { namespace chain {
vector<signature_type> 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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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));
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/hotstuff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

0 comments on commit 3cc42cc

Please sign in to comment.