Skip to content

Commit

Permalink
Merge branch 'main' of github.com:AntelopeIO/spring into gh_534
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Aug 14, 2024
2 parents 12e9921 + 7beaa20 commit 2e6b5a9
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 92 deletions.
36 changes: 19 additions & 17 deletions libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ digest_type block_header_state::compute_base_digest() const {
assert(active_proposer_policy);
fc::raw::pack( enc, *active_proposer_policy );

// For things that are optionally present we should always pack the bool
// indicating if they are there.
fc::raw::pack( enc, latest_proposed_proposer_policy );
fc::raw::pack( enc, latest_pending_proposer_policy );

if (activated_protocol_features) {
fc::raw::pack( enc, *activated_protocol_features );
}
// Should be always present
assert(activated_protocol_features);
fc::raw::pack( enc, *activated_protocol_features );

return enc.result();
}
Expand Down Expand Up @@ -86,14 +88,14 @@ const proposer_policy_ptr& block_header_state::get_active_proposer_policy_for_bl
// must be the first block in a round after the current round
std::optional<uint32_t> prior_round_start_slot = detail::get_prior_round_start_slot(timestamp());
if (latest_proposed_proposer_policy && prior_round_start_slot &&
(*latest_proposed_proposer_policy)->proposal_time.slot < *prior_round_start_slot &&
(*latest_proposed_proposer_policy)->proposal_time <= core.last_final_block_timestamp()) {
return *latest_proposed_proposer_policy;
latest_proposed_proposer_policy->proposal_time.slot < *prior_round_start_slot &&
latest_proposed_proposer_policy->proposal_time <= core.last_final_block_timestamp()) {
return latest_proposed_proposer_policy;
}

if (latest_pending_proposer_policy &&
(*latest_pending_proposer_policy)->proposal_time <= core.last_final_block_timestamp()) {
return *latest_pending_proposer_policy;
latest_pending_proposer_policy->proposal_time <= core.last_final_block_timestamp()) {
return latest_pending_proposer_policy;
}

return active_proposer_policy;
Expand All @@ -111,7 +113,7 @@ const producer_authority& block_header_state::get_producer_for_block_at(block_ti

const producer_authority_schedule* block_header_state::pending_producers() const {
if (latest_pending_proposer_policy) {
return &(*latest_pending_proposer_policy)->proposer_schedule;
return &latest_pending_proposer_policy->proposer_schedule;
}
return nullptr;
}
Expand Down Expand Up @@ -142,10 +144,10 @@ const finalizer_policy& block_header_state::get_last_pending_finalizer_policy()
// The last proposed proposer policy, if none proposed then the active proposer policy
const proposer_policy& block_header_state::get_last_proposed_proposer_policy() const {
if (latest_proposed_proposer_policy) {
return *(*latest_proposed_proposer_policy);
return *latest_proposed_proposer_policy;
}
if (latest_pending_proposer_policy) {
return *(*latest_pending_proposer_policy);
return *latest_pending_proposer_policy;
}
assert(active_proposer_policy);
return *active_proposer_policy;
Expand Down Expand Up @@ -240,17 +242,17 @@ void evaluate_proposer_policies_for_promotion(const block_header_state& prev,
auto& new_policy = prev.get_active_proposer_policy_for_block_at(next.timestamp());
if (new_policy != next.active_proposer_policy) {
next.active_proposer_policy = new_policy;
if (next.latest_proposed_proposer_policy && new_policy == *next.latest_proposed_proposer_policy) {
next.latest_proposed_proposer_policy = std::nullopt;
next.latest_pending_proposer_policy = std::nullopt;
} else if (next.latest_pending_proposer_policy && new_policy == *next.latest_pending_proposer_policy)
next.latest_pending_proposer_policy = std::nullopt;
if (next.latest_proposed_proposer_policy && new_policy == next.latest_proposed_proposer_policy) {
next.latest_proposed_proposer_policy = nullptr;
next.latest_pending_proposer_policy = nullptr;
} else if (next.latest_pending_proposer_policy && new_policy == next.latest_pending_proposer_policy)
next.latest_pending_proposer_policy = nullptr;
}

if (detail::first_block_of_round(next.timestamp(), prev.timestamp()) &&
next.latest_proposed_proposer_policy && !next.latest_pending_proposer_policy) {
next.latest_pending_proposer_policy = next.latest_proposed_proposer_policy;
next.latest_proposed_proposer_policy = std::nullopt;
next.latest_proposed_proposer_policy = nullptr;
}
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ struct building_block {
auto get_next_sched = [&]() -> const producer_authority_schedule& {
// latest_proposed_proposer_policy is the last if it is present
if (parent.latest_proposed_proposer_policy) {
return (*parent.latest_proposed_proposer_policy)->proposer_schedule;
return parent.latest_proposed_proposer_policy->proposer_schedule;
}
// then the last is latest_pending_proposer_policy
if (parent.latest_pending_proposer_policy) {
return (*parent.latest_pending_proposer_policy)->proposer_schedule;
return parent.latest_pending_proposer_policy->proposer_schedule;
}
// none currently in-flight, use active
return active_proposer_policy->proposer_schedule;
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/include/eosio/chain/block_header_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ struct block_header_state {
active_proposer_policy is we should not promote the policy if the proposal_time
of the policy is greater than the last_final_block_timestamp of the previous block.
*/
std::optional<proposer_policy_ptr> latest_proposed_proposer_policy;
std::optional<proposer_policy_ptr> latest_pending_proposer_policy;
proposer_policy_ptr latest_proposed_proposer_policy;
proposer_policy_ptr latest_pending_proposer_policy;

// Track in-flight proposed finalizer policies.
// When the block associated with a proposed finalizer policy becomes final,
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/include/eosio/chain/snapshot_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ namespace eosio::chain::snapshot_detail {
finality_core core;
finalizer_policy_ptr active_finalizer_policy;
proposer_policy_ptr active_proposer_policy;
std::optional<proposer_policy_ptr> latest_proposed_proposer_policy;
std::optional<proposer_policy_ptr> latest_pending_proposer_policy;
proposer_policy_ptr latest_proposed_proposer_policy;
proposer_policy_ptr latest_pending_proposer_policy;
std::vector<std::pair<block_num_type, finalizer_policy_ptr>> proposed_finalizer_policies;
std::optional<std::pair<block_num_type, finalizer_policy_ptr>> pending_finalizer_policy;
uint32_t finalizer_policy_generation;
Expand Down
2 changes: 2 additions & 0 deletions plugins/chain_plugin/tracked_votes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace eosio::chain_apis {
// QC in the block and store it in last_votes.
void on_accepted_block( const chain::signed_block_ptr& block, const chain::block_id_type& id ) {
try {
if (!block->is_proper_svnn_block())
return;
if (!tracking_enabled && !chain::vote_logger.is_enabled(fc::log_level::info))
return;

Expand Down
Loading

0 comments on commit 2e6b5a9

Please sign in to comment.