Skip to content

Commit

Permalink
GH-2125 Cleanup logging
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Mar 9, 2024
1 parent 9fbfb3f commit bb53cc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
7 changes: 1 addition & 6 deletions libraries/chain/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ block_state::block_state(const block_header_state& bhs, deque<transaction_metada
block->transactions = std::move(trx_receipts);

if( qc ) {
ilog("integrate qc ${qcbn} strong=${s} into block ${bn}", ("qcbn", qc->block_num)("s", qc->qc.is_strong())("bn", block_num()));
dlog("integrate qc ${qc} into block ${bn} ${id}", ("qc", qc->to_qc_claim())("bn", block_num())("id", id()));
emplace_extension(block->block_extensions, quorum_certificate_extension::extension_id(), fc::raw::pack( *qc ));
}

Expand Down Expand Up @@ -176,12 +176,9 @@ void block_state::verify_qc(const valid_quorum_certificate& qc) const {
std::optional<quorum_certificate> block_state::get_best_qc() const {
// if pending_qc does not have a valid QC, consider valid_qc only
if( !pending_qc.is_quorum_met() ) {
ilog("pending_qc quorum not met for ${bn}", ("bn", block_num()));
if( valid_qc ) {
ilog("valid_qc for ${bn} : ${id}", ("bn", block_num())("id", id()));
return quorum_certificate{ block_num(), *valid_qc };
} else {
ilog("no valid_qc for ${bn} : ${id}", ("bn", block_num())("id", id()));
return std::nullopt;
}
}
Expand All @@ -191,10 +188,8 @@ std::optional<quorum_certificate> block_state::get_best_qc() const {

// if valid_qc does not have value, consider valid_qc_from_pending only
if( !valid_qc ) {
ilog("no valid_qc using pending for block ${bn}", ("bn", block_num()));
return quorum_certificate{ block_num(), valid_qc_from_pending };
}
ilog("comparing valid_qc ${vs} and pending qc ${ps} for block ${bn}", ("bn", block_num())("vs", valid_qc->is_strong())("ps", valid_qc_from_pending.is_strong()));

// Both valid_qc and valid_qc_from_pending have value. Compare them and select a better one.
// Strong beats weak. Tie break by valid_qc.
Expand Down
16 changes: 7 additions & 9 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,10 @@ struct building_block {
"most recent ancestor QC block number (${a}) cannot be greater than parent's block number (${p})",
("a", qc->block_num)("p", block_header::num_from_id(parent_id())) );
auto qc_claim = qc->to_qc_claim();
ilog("integrate qc is_needed qc: ${qc}, strong=${s}", ("qc", qc->block_num)("s", qc->qc.is_strong()));
if( bb.parent.is_needed(qc_claim) ) {
ilog("integrate qc and qc claim ${qc} into block ${bn}", ("qc", qc_claim)("bn", block_header::num_from_id(parent_id())+1));
qc_data = qc_data_t{ *qc, qc_claim };
} else {
// no new qc info, repeat existing
ilog("integrate only qc claim ${qc} into block ${bn}", ("qc", qc_claim)("bn", block_header::num_from_id(parent_id())+1));
qc_data = qc_data_t{ {}, bb.parent.core.latest_qc_claim() };
}
break;
Expand Down Expand Up @@ -3457,21 +3454,22 @@ struct controller_impl {

const auto claimed = fetch_bsp_on_branch_by_num( bsp_in->previous(), qc_ext.qc.block_num );
if( !claimed ) {
ilog("qc not found in forkdb, qc: ${qbn}, strong=${s}", ("qbn", qc_ext.qc.block_num)("s", received_qc.is_strong()));
dlog("qc not found in forkdb, qc: ${qc} for block ${bn} ${id}, previous ${p}",
("qc", qc_ext.qc.to_qc_claim())("bn", bsp_in->block_num())("id", bsp_in->id())("p", bsp_in->previous()));
return;
}

// Don't save the QC from block extension if the claimed block has a better valid_qc.
if (claimed->valid_qc && (claimed->valid_qc->is_strong() || received_qc.is_weak())) {
ilog("qc not better, claimed->valid: ${qbn}, strong=${s}, received: ${rbn}, strong=${rs}",
("qbn", claimed->block_num())("s", claimed->valid_qc->is_strong())
("rbn", qc_ext.qc.block_num)("rs", received_qc.is_strong()));
dlog("qc not better, claimed->valid: ${qbn} ${qid}, strong=${s}, received: ${rqc}, for block ${bn} ${id}",
("qbn", claimed->block_num())("qid", claimed->id())("s", claimed->valid_qc->is_strong())
("rqc", qc_ext.qc.to_qc_claim())("bn", bsp_in->block_num())("id", bsp_in->id()));
return;
}

// Save the QC. This is safe as the function is called by push_block & accept_block from application thread.
ilog("setting valid qc: ${rbn}, strong=${rs} into block ${bn} : ${id}",
("rbn", qc_ext.qc.block_num)("rs", received_qc.is_strong())("bn", claimed->block_num())("id", claimed->id()));
dlog("setting valid qc: ${rqc} into claimed block ${bn} : ${id}",
("rqc", qc_ext.qc.to_qc_claim())("rs", received_qc.is_strong())("bn", claimed->block_num())("id", claimed->id()));
claimed->valid_qc = received_qc;

// advance LIB if QC is strong
Expand Down

0 comments on commit bb53cc1

Please sign in to comment.