-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
…nfigured finalizer
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)) { |
There was a problem hiding this comment.
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 if
s, 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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
Note:start |
Adds
info
level logging of expected votes not incorporated into blocks. Example:Adds
warn
level logging of expected votes not incorporated into a configured finalizer block. Example:Add Prometheus logging of votes incorporated into blocks. Example:
Resolves #8