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

IF: Missing vote logging and Prometheus logging of votes #63

Merged
merged 9 commits into from
Apr 24, 2024

Conversation

heifner
Copy link
Member

@heifner heifner commented Apr 23, 2024

Adds info level logging of expected votes not incorporated into blocks. Example:

info  2024-04-23T20:27:31.840 nodeos    producer_plugin.cpp:658       log_missing_votes    ] Block 179:df4235f559ce7978 has no votes from finalizers: ["finalizer #4"]

Adds warn level logging of expected votes not incorporated into a configured finalizer block. Example:

warn  2024-04-23T20:27:31.840 nodeos    producer_plugin.cpp:651       log_missing_votes    ] Local finalizer finalizer #4 did not vote on block 179:df4235f559ce7978

Add Prometheus logging of votes incorporated into blocks. Example:

# HELP nodeos_block_num current block number
# TYPE nodeos_block_num gauge
nodeos_block_num 501
# HELP nodeos_block_votes votes incorporated into a block, -1 weak, 1 strong, 0 no vote
# TYPE nodeos_block_votes gauge
nodeos_block_votes{producer="finalizer #4"} 1
nodeos_block_votes{producer="finalizer #3"} 1
nodeos_block_votes{producer="finalizer #2"} 1
nodeos_block_votes{producer="finalizer #1"} 1

Resolves #8

void log_missing_votes(const signed_block_ptr& block, const block_id_type& id,
const finalizer_policy_ptr& active_finalizer_policy,
const valid_quorum_certificate& qc) {
if (vote_logger.is_enabled(fc::log_level::info)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of those two nested ifs, you can return is vote_logger is not enabled or minutes not passed, to reduce two nesting levels. But it is just a style. No need to change.

@@ -63,7 +63,40 @@ namespace eosio { namespace chain {
}

return results;
}

// Does not validate ordering, assumes validate_and_extract_extensions() has been called in verify_qc_claim()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have an assert to make sure the assumption (pre-condition) is valid?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought about adding an assert, but did not want different behavior. Since assert is compiled out, might as well add it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think assert is worthy to add, since now we have one CICD enabled it.

@@ -69,6 +69,8 @@ namespace eosio::chain {
std::optional<block_extension> signed_block::extract_extension(uint16_t extension_id)const {
using decompose_t = block_extension_types::decompose_t;

assert(std::ranges::is_sorted(block_extensions)); // currently all extensions are unique so default compare works
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Now it is clear the for loop is correct.

@heifner heifner merged commit 54812d4 into savanna Apr 24, 2024
36 checks passed
@heifner heifner deleted the GH-8-finalizer-log branch April 24, 2024 15:22
Comment on lines +678 to +695
if (qc._strong_votes) {
add_votes(*qc._strong_votes, m.strong_votes);
}
if (qc._weak_votes) {
add_votes(*qc._weak_votes, m.weak_votes);
}
if (m.strong_votes.size() + m.weak_votes.size() != active_finalizer_policy->finalizers.size()) {
fc::dynamic_bitset not_voted(active_finalizer_policy->finalizers.size());
if (qc._strong_votes) {
not_voted = *qc._strong_votes;
}
if (qc._weak_votes) {
assert(not_voted.size() == qc._weak_votes->size());
not_voted |= *qc._weak_votes;
}
not_voted.flip();
add_votes(not_voted, m.no_votes);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (qc._strong_votes) {
add_votes(*qc._strong_votes, m.strong_votes);
}
if (qc._weak_votes) {
add_votes(*qc._weak_votes, m.weak_votes);
}
if (m.strong_votes.size() + m.weak_votes.size() != active_finalizer_policy->finalizers.size()) {
fc::dynamic_bitset not_voted(active_finalizer_policy->finalizers.size());
if (qc._strong_votes) {
not_voted = *qc._strong_votes;
}
if (qc._weak_votes) {
assert(not_voted.size() == qc._weak_votes->size());
not_voted |= *qc._weak_votes;
}
not_voted.flip();
add_votes(not_voted, m.no_votes);
}
fc::dynamic_bitset not_voted(active_finalizer_policy->finalizers.size());
if (qc._strong_votes) {
add_votes(*qc._strong_votes, m.strong_votes);
not_voted |= *qc._strong_votes;
}
if (qc._weak_votes) {
add_votes(*qc._weak_votes, m.weak_votes);
not_voted |= *qc._weak_votes;
}
not_voted.flip();
add_votes(not_voted, m.no_votes);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry, it is already merged!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merged version is more efficient in that it doesn't do the not_voted in the common case of no weak votes.

Copy link
Contributor

@greg7mdp greg7mdp Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still does it in the likely case where all the finalizers did not vote, i.e. m.strong_votes.size() != active_finalizer_policy->finalizers.size()

Copy link
Member Author

@heifner heifner Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be no QC if no votes at all.

Copy link
Contributor

@greg7mdp greg7mdp Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the policy size is 21 finalizers, and we have 16 strong votes, and no weak votes, you still compute the not_voted, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. 16 strong + 0 week != 21, so will calculate the not_voted.

@ericpassmore
Copy link
Contributor

ericpassmore commented Apr 29, 2024

Note:start
group: IF
category: CHORE
summary: Add info, warn, and Prometheus logging of votes that are not incorporated into block or configured finalizer block.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn finalizer in logs if they are not finalizing blocks
4 participants