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

Only track/log votes on recent blocks #512

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions plugins/chain_plugin/tracked_votes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ namespace eosio::chain_apis {
if (!_update_vote_block_metrics && !tracking_enabled && !chain::vote_logger.is_enabled(fc::log_level::info))
return;

// do not bother tracking/logging when syncing or replaying
auto now = fc::time_point::now();
if (now - block->timestamp > fc::minutes(5) && (block->block_num() % 1000 != 0))
return;

if (!block->contains_extension(chain::quorum_certificate_extension::extension_id())) {
fc_ilog(chain::vote_logger, "Block ${id}... #${n} @ ${t} produced by ${p}, latency: ${l}ms has no votes",
("id", id.str().substr(8, 16))("n", block->block_num())("t", block->timestamp)("p", block->producer)
("l", (fc::time_point::now() - block->timestamp).count() / 1000));
("l", (now - block->timestamp).count() / 1000));
return;
}

Expand Down Expand Up @@ -95,23 +100,20 @@ namespace eosio::chain_apis {
const chain::qc_vote_metrics_t::fin_auth_set_t& missing_votes,
uint32_t missed_block_num) const {
if (chain::vote_logger.is_enabled(fc::log_level::info)) {
auto now = fc::time_point::now();
if (now - block->timestamp < fc::minutes(5) || (block->block_num() % 1000 == 0)) {
std::string not_voted;
for (const auto& f : missing_votes) {
if (controller.is_node_finalizer_key(f.fin_auth->public_key)) {
fc_wlog(chain::vote_logger, "Local finalizer ${f} did not vote in block ${n} : ${id} for block ${m_n}",
("f", f.fin_auth->description)("n", block->block_num())("id", id.str().substr(8,16))("m_n", missed_block_num));
}
not_voted += f.fin_auth->description;
not_voted += ',';
}
if (!not_voted.empty()) {
not_voted.resize(not_voted.size() - 1); // remove ','
fc_ilog(chain::vote_logger, "Block ${id}... #${n} @ ${t} produced by ${p}, latency: ${l}ms has no votes for block #${m_n} from finalizers: ${v}",
("id", id.str().substr(8, 16))("n", block->block_num())("t", block->timestamp)("p", block->producer)
("l", (now - block->timestamp).count() / 1000)("v", not_voted)("m_n", missed_block_num));
std::string not_voted;
for (const auto& f : missing_votes) {
if (controller.is_node_finalizer_key(f.fin_auth->public_key)) {
fc_wlog(chain::vote_logger, "Local finalizer ${f} did not vote in block ${n} : ${id} for block ${m_n}",
("f", f.fin_auth->description)("n", block->block_num())("id", id.str().substr(8,16))("m_n", missed_block_num));
}
not_voted += f.fin_auth->description;
not_voted += ',';
}
if (!not_voted.empty()) {
not_voted.resize(not_voted.size() - 1); // remove ','
fc_ilog(chain::vote_logger, "Block ${id}... #${n} @ ${t} produced by ${p}, latency: ${l}ms has no votes for block #${m_n} from finalizers: ${v}",
("id", id.str().substr(8, 16))("n", block->block_num())("t", block->timestamp)("p", block->producer)
("l", (fc::time_point::now() - block->timestamp).count() / 1000)("v", not_voted)("m_n", missed_block_num));
}
}
}
Expand Down