Skip to content

Commit

Permalink
Merge pull request #370 from AntelopeIO/gh_362
Browse files Browse the repository at this point in the history
Use correct block id when logging new proposed finalizer policies.
  • Loading branch information
greg7mdp authored Jul 17, 2024
2 parents 943d213 + aee6735 commit c2cffd8
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,19 @@ void finish_next(const block_header_state& prev,

next_header_state.last_pending_finalizer_policy_digest = fc::sha256::hash(next_header_state.get_last_pending_finalizer_policy());

finalizer_policy new_finalizer_policy;

if (f_ext.new_finalizer_policy_diff) {
finalizer_policy new_finalizer_policy = prev.get_last_proposed_finalizer_policy().apply_diff(*f_ext.new_finalizer_policy_diff);
new_finalizer_policy = prev.get_last_proposed_finalizer_policy().apply_diff(*f_ext.new_finalizer_policy_diff);

// a new `finalizer_policy` was proposed in the previous block, and is present in the previous
// block's header extensions.
// Add this new proposal to the `proposed_finalizer_policies` which tracks the in-flight proposals,
// and log that proposal (debug level).
// a new `finalizer_policy` was proposed in this block, and is present in the finality_extension for
// this new block.
// Add this new proposal to the `proposed_finalizer_policies` which tracks the in-flight proposals.
// ------------------------------------------------------------------------------------------------
if (log)
dlog("New finalizer policy proposed in block ${id}..: ${pol}",
("id", prev.block_id.str().substr(8,16))("pol", new_finalizer_policy));
assert(new_finalizer_policy.generation > prev.finalizer_policy_generation);
next_header_state.finalizer_policy_generation = new_finalizer_policy.generation;
next_header_state.proposed_finalizer_policies.emplace_back(
std::make_pair(next_header_state.block_num(),
std::make_shared<finalizer_policy>(std::move(new_finalizer_policy))));
std::make_pair(next_header_state.block_num(), std::make_shared<finalizer_policy>(new_finalizer_policy)));
} else {
next_header_state.finalizer_policy_generation = prev.finalizer_policy_generation;
}
Expand All @@ -259,14 +257,22 @@ void finish_next(const block_header_state& prev,
// -----------------------------------
next_header_state.block_id = next_header_state.header.calculate_id();

// Now that we have the block id of the new block, log what changed.
// -----------------------------------------------------------------
if (next_header_state.active_finalizer_policy != prev.active_finalizer_policy) {
const auto& act = next_header_state.active_finalizer_policy;
if (log) {
if (log) {
auto& id = next_header_state.block_id;

// Now that we have the block id of the new block, log what changed.
// -----------------------------------------------------------------
if (f_ext.new_finalizer_policy_diff) {
dlog("New finalizer policy proposed in block ${n}:${id}: ${pol}",
("n",block_header::num_from_id(id))("id", id)("pol", new_finalizer_policy));
}

if (next_header_state.active_finalizer_policy != prev.active_finalizer_policy) {
const auto& act = next_header_state.active_finalizer_policy;
ilog("Finalizer policy generation change: ${old_gen} -> ${new_gen}",
("old_gen", prev.active_finalizer_policy->generation)("new_gen",act->generation));
ilog("New finalizer policy becoming active in block ${id}: ${pol}",("id", next_header_state.block_id)("pol", *act));
ilog("New finalizer policy becoming active in block ${n}:${id}: ${pol}",
("n",block_header::num_from_id(id))("id", id)("pol", *act));
}
}
}
Expand Down

0 comments on commit c2cffd8

Please sign in to comment.