Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use last_pending_finalizer_policy_start_timestamp instead of last_pending_finalizer_policy_start_num #414

Merged
merged 9 commits into from
Jul 26, 2024
8 changes: 4 additions & 4 deletions libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ digest_type block_header_state::compute_finality_digest() const {

// compute commitments related to finalizer policy transitions
level_2_commitments_t level_2_commitments {
.last_pending_fin_pol_digest = last_pending_finalizer_policy_digest,
.last_pending_fin_pol_start_num = last_pending_finalizer_policy_start_num,
.l3_commitments_digest = fc::sha256::hash(level_3_commitments)
.last_pending_fin_pol_digest = last_pending_finalizer_policy_digest,
.last_pending_fin_pol_start_timestamp = last_pending_finalizer_policy_start_timestamp,
.l3_commitments_digest = fc::sha256::hash(level_3_commitments)
};

assert(active_finalizer_policy);
Expand Down Expand Up @@ -173,7 +173,7 @@ void evaluate_finalizer_policies_for_promotion(const block_header_state& prev,
// promote the target to pending
auto block_num = next_header_state.block_num();
next_pending.emplace(block_num, target->second);
next_header_state.last_pending_finalizer_policy_start_num = block_num;
next_header_state.last_pending_finalizer_policy_start_timestamp = next_header_state.timestamp();
} else {
// leave the target alone in the proposed policies
next_proposed.emplace_back(*target);
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ block_state_ptr block_state::create_if_genesis_block(const block_state_legacy& b
result.core = finality_core::create_core_for_genesis_block(genesis_block_ref);

result.last_pending_finalizer_policy_digest = fc::sha256::hash(*result.active_finalizer_policy);
result.last_pending_finalizer_policy_start_num = bsp.block_num();
result.last_pending_finalizer_policy_start_timestamp = bsp.timestamp();
result.active_proposer_policy = std::make_shared<proposer_policy>();
result.active_proposer_policy->active_time = bsp.timestamp();
result.active_proposer_policy->proposer_schedule = bsp.active_schedule;
Expand Down Expand Up @@ -155,7 +155,7 @@ block_state::block_state(snapshot_detail::snapshot_block_state_v7&& sbs)
.pending_finalizer_policy = std::move(sbs.pending_finalizer_policy),
.finalizer_policy_generation = sbs.finalizer_policy_generation,
.last_pending_finalizer_policy_digest = sbs.last_pending_finalizer_policy_digest,
.last_pending_finalizer_policy_start_num = sbs.last_pending_finalizer_policy_start_num
.last_pending_finalizer_policy_start_timestamp = sbs.last_pending_finalizer_policy_start_timestamp
}
, strong_digest(compute_finality_digest())
, weak_digest(create_weak_digest(strong_digest))
Expand Down
22 changes: 11 additions & 11 deletions libraries/chain/include/eosio/chain/block_header_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ constexpr uint32_t light_header_protocol_version_minor = 0;

// commitments used in the context of finality violation proofs
struct level_3_commitments_t {
digest_type reversible_blocks_mroot{};
digest_type reversible_blocks_mroot;
block_num_type latest_qc_claim_block_num{0};
digest_type latest_qc_claim_finality_digest;
block_timestamp_type latest_qc_claim_timestamp;
block_timestamp_type timestamp; // This is the timestamp of the current block.
digest_type base_digest{};
digest_type base_digest;
};

// commitments used in the context of finalizer policy transitions
struct level_2_commitments_t {
digest_type last_pending_fin_pol_digest{};
block_num_type last_pending_fin_pol_start_num{0};
digest_type l3_commitments_digest{};
digest_type last_pending_fin_pol_digest;
block_timestamp_type last_pending_fin_pol_start_timestamp;
digest_type l3_commitments_digest;
};

// finality digest
Expand All @@ -43,8 +43,8 @@ struct finality_digest_data_v1 {
uint32_t minor_version{light_header_protocol_version_minor};
uint32_t active_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{};
digest_type finality_tree_digest;
digest_type l2_commitments_digest;
};

// ------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -115,10 +115,10 @@ struct block_header_state {
// in the history of the blockchain so far that is not in proposed state (so either pending or active state)
digest_type last_pending_finalizer_policy_digest;

// Block number at which the last pending finalizer policy first was promoted to pending.
// If the last pending finalizer policy is the current active finalizer policy, then it is the block number at which
// Timestamp of the block at which the last pending finalizer policy first was promoted to pending.
// If the last pending finalizer policy is the current active finalizer policy, then it is the timestamp of the block at which
// that active finalizer policy first was promoted to pending. Savanna genesis block it is the genesis block number.
block_num_type last_pending_finalizer_policy_start_num {0};
block_timestamp_type last_pending_finalizer_policy_start_timestamp;
heifner marked this conversation as resolved.
Show resolved Hide resolved

// ------ data members caching information available elsewhere ----------------------
header_extension_multimap header_exts; // redundant with the data stored in header
Expand Down Expand Up @@ -182,5 +182,5 @@ FC_REFLECT( eosio::chain::block_header_state, (block_id)(header)
(last_pending_finalizer_policy_digest))

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::level_2_commitments_t, (last_pending_fin_pol_digest)(last_pending_fin_pol_start_timestamp)(l3_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) )
6 changes: 3 additions & 3 deletions libraries/chain/include/eosio/chain/snapshot_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace eosio::chain::snapshot_detail {
std::optional<std::pair<block_num_type, finalizer_policy_ptr>> pending_finalizer_policy;
uint32_t finalizer_policy_generation;
digest_type last_pending_finalizer_policy_digest;
block_num_type last_pending_finalizer_policy_start_num;
block_timestamp_type last_pending_finalizer_policy_start_timestamp;

// from block_state
std::optional<valid_t> valid;
Expand All @@ -127,7 +127,7 @@ namespace eosio::chain::snapshot_detail {
, pending_finalizer_policy(bs.pending_finalizer_policy)
, finalizer_policy_generation(bs.finalizer_policy_generation)
, last_pending_finalizer_policy_digest(bs.last_pending_finalizer_policy_digest)
, last_pending_finalizer_policy_start_num(bs.last_pending_finalizer_policy_start_num)
, last_pending_finalizer_policy_start_timestamp(bs.last_pending_finalizer_policy_start_timestamp)
, valid(bs.valid)
{}
};
Expand Down Expand Up @@ -205,7 +205,7 @@ FC_REFLECT( eosio::chain::snapshot_detail::snapshot_block_state_v7,
(pending_finalizer_policy)
(finalizer_policy_generation)
(last_pending_finalizer_policy_digest)
(last_pending_finalizer_policy_start_num)
(last_pending_finalizer_policy_start_timestamp)
(valid)
)

Expand Down
Loading
Loading