diff --git a/libraries/chain/block_header_state.cpp b/libraries/chain/block_header_state.cpp index ce8554dead..0f1d44250b 100644 --- a/libraries/chain/block_header_state.cpp +++ b/libraries/chain/block_header_state.cpp @@ -62,10 +62,10 @@ digest_type block_header_state::compute_finality_digest() const { assert(active_finalizer_policy); finality_digest_data_v1 finality_digest_data { - .active_finalizer_policy_generation = active_finalizer_policy->generation, - .pending_finalizer_policy_generation = get_last_pending_finalizer_policy().generation, - .finality_tree_digest = finality_mroot(), - .l2_commitments_digest = fc::sha256::hash(level_2_commitments) + .active_finalizer_policy_generation = active_finalizer_policy->generation, + .last_pending_finalizer_policy_generation = get_last_pending_finalizer_policy().generation, + .finality_tree_digest = finality_mroot(), + .l2_commitments_digest = fc::sha256::hash(level_2_commitments) }; return fc::sha256::hash(finality_digest_data); diff --git a/libraries/chain/block_state.cpp b/libraries/chain/block_state.cpp index ac088ed23f..1c0016e97f 100644 --- a/libraries/chain/block_state.cpp +++ b/libraries/chain/block_state.cpp @@ -287,15 +287,15 @@ finality_data_t block_state::get_finality_data() { return { // major_version and minor_version take the default values set by finality_data_t definition - .active_finalizer_policy_generation = active_finalizer_policy->generation, - .action_mroot = action_mroot, - .reversible_blocks_mroot = core.get_reversible_blocks_mroot(), - .latest_qc_claim_block_num = latest_qc_claim_block_num, - .latest_qc_claim_finality_digest = blk_ref.finality_digest, - .latest_qc_claim_timestamp = blk_ref.timestamp, - .base_digest = *base_digest, - .pending_finalizer_policy = std::move(pending_fin_pol), - .pending_finalizer_policy_generation = get_last_pending_finalizer_policy().generation + .active_finalizer_policy_generation = active_finalizer_policy->generation, + .action_mroot = action_mroot, + .reversible_blocks_mroot = core.get_reversible_blocks_mroot(), + .latest_qc_claim_block_num = latest_qc_claim_block_num, + .latest_qc_claim_finality_digest = blk_ref.finality_digest, + .latest_qc_claim_timestamp = blk_ref.timestamp, + .base_digest = *base_digest, + .pending_finalizer_policy = std::move(pending_fin_pol), + .last_pending_finalizer_policy_generation = get_last_pending_finalizer_policy().generation }; } diff --git a/libraries/chain/include/eosio/chain/block_header_state.hpp b/libraries/chain/include/eosio/chain/block_header_state.hpp index aeb55bb9a2..d9c6fed8b3 100644 --- a/libraries/chain/include/eosio/chain/block_header_state.hpp +++ b/libraries/chain/include/eosio/chain/block_header_state.hpp @@ -42,11 +42,7 @@ struct finality_digest_data_v1 { uint32_t major_version{light_header_protocol_version_major}; uint32_t minor_version{light_header_protocol_version_minor}; uint32_t active_finalizer_policy_generation{0}; - - // Hold the generation number of pending_finalizer_policy if it exists, - // otherwise hold the same value as active_finalizer_policy_generation - uint32_t pending_finalizer_policy_generation{0}; - + uint32_t last_pending_finalizer_policy_generation{0}; // use active_finalizer_policy_generation if pending_finalizer_policy does not exist digest_type finality_tree_digest{}; digest_type l2_commitments_digest{}; }; @@ -187,4 +183,4 @@ FC_REFLECT( eosio::chain::block_header_state, (block_id)(header) FC_REFLECT( eosio::chain::level_3_commitments_t, (reversible_blocks_mroot)(latest_qc_claim_block_num )(latest_qc_claim_finality_digest)(latest_qc_claim_timestamp)(timestamp)(base_digest)) FC_REFLECT( eosio::chain::level_2_commitments_t, (last_pending_fin_pol_digest)(last_pending_fin_pol_start_num)(l3_commitments_digest) ) -FC_REFLECT( eosio::chain::finality_digest_data_v1, (major_version)(minor_version)(active_finalizer_policy_generation)(pending_finalizer_policy_generation)(finality_tree_digest)(l2_commitments_digest) ) +FC_REFLECT( eosio::chain::finality_digest_data_v1, (major_version)(minor_version)(active_finalizer_policy_generation)(last_pending_finalizer_policy_generation)(finality_tree_digest)(l2_commitments_digest) ) diff --git a/libraries/chain/include/eosio/chain/block_state.hpp b/libraries/chain/include/eosio/chain/block_state.hpp index f371c3ad1b..09f20999c1 100644 --- a/libraries/chain/include/eosio/chain/block_state.hpp +++ b/libraries/chain/include/eosio/chain/block_state.hpp @@ -65,9 +65,7 @@ struct finality_data_t { // Use string format for public key in the policy for easier uses. std::optional pending_finalizer_policy; - // Hold the generation number of pending_finalizer_policy if it exists, - // otherwise hold the same value as active_finalizer_policy_generation - uint32_t pending_finalizer_policy_generation{0}; + uint32_t last_pending_finalizer_policy_generation{0}; // // use active_finalizer_policy_generation if pending_finalizer_policy does not exist }; struct block_state : public block_header_state { // block_header_state provides parent link @@ -194,5 +192,5 @@ using block_state_pair = std::pair, blo // not exporting pending_qc or valid_qc FC_REFLECT( eosio::chain::valid_t::finality_leaf_node_t, (major_version)(minor_version)(block_num)(timestamp)(parent_timestamp)(finality_digest)(action_mroot) ) FC_REFLECT( eosio::chain::valid_t, (validation_tree)(validation_mroots)) -FC_REFLECT( eosio::chain::finality_data_t, (major_version)(minor_version)(active_finalizer_policy_generation)(action_mroot)(reversible_blocks_mroot)(latest_qc_claim_block_num)(latest_qc_claim_finality_digest)(latest_qc_claim_timestamp)(base_digest)(pending_finalizer_policy)(pending_finalizer_policy_generation) ) +FC_REFLECT( eosio::chain::finality_data_t, (major_version)(minor_version)(active_finalizer_policy_generation)(action_mroot)(reversible_blocks_mroot)(latest_qc_claim_block_num)(latest_qc_claim_finality_digest)(latest_qc_claim_timestamp)(base_digest)(pending_finalizer_policy)(last_pending_finalizer_policy_generation) ) FC_REFLECT_DERIVED( eosio::chain::block_state, (eosio::chain::block_header_state), (block)(strong_digest)(weak_digest)(aggregating_qc)(valid)(validated) ) diff --git a/libraries/state_history/abi.cpp b/libraries/state_history/abi.cpp index 7910d96d36..095b150886 100644 --- a/libraries/state_history/abi.cpp +++ b/libraries/state_history/abi.cpp @@ -614,7 +614,7 @@ extern const char* const state_history_plugin_abi = R"({ { "name": "latest_qc_claim_timestamp", "type": "block_timestamp_type" }, { "name": "base_digest", "type": "checksum256" }, { "name": "pending_finalizer_policy", "type": "finalizer_policy_with_string_key?" }, - { "name": "pending_finalizer_policy_generation", "type": "uint32" } + { "name": "last_pending_finalizer_policy_generation", "type": "uint32" } ] } ], diff --git a/unittests/finality_proof.hpp b/unittests/finality_proof.hpp index 098eb019e5..fe65c58337 100644 --- a/unittests/finality_proof.hpp +++ b/unittests/finality_proof.hpp @@ -244,10 +244,10 @@ namespace finality_proof { // compute digest for verification purposes digest_type finality_digest = fc::sha256::hash(finality_digest_data_v1{ - .active_finalizer_policy_generation = is_genesis ? 1 : active_finalizer_policy.generation, - .pending_finalizer_policy_generation = is_genesis ? 1 : last_pending_finalizer_policy.generation, - .finality_tree_digest = finality_root, - .l2_commitments_digest = level_2_commitments_digest + .active_finalizer_policy_generation = is_genesis ? 1 : active_finalizer_policy.generation, + .last_pending_finalizer_policy_generation = is_genesis ? 1 : last_pending_finalizer_policy.generation, + .finality_tree_digest = finality_root, + .l2_commitments_digest = level_2_commitments_digest }); // compute finality leaf