-
Notifications
You must be signed in to change notification settings - Fork 46
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
Handle equivocations correctly #5
Conversation
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.
Just a minor Todo you've already marked yourself. Aside from that, it makes things a tad more complex to understand but looks good!
src/bitfield.rs
Outdated
let word_off = bit_idx / 64; | ||
let bit_off = bit_idx % 64; | ||
|
||
// TODO: if this isn't `Some`, something has gone really wrong. |
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, please log this with warning or higher. I don't think it can happen at the moment, but IMHO stuff in here should scream loudly if it assumptions are not met.
Closes #4
This introduces a
bitfield
module, which is used to lazily attach bitfields for equivocating (double-voting) validators as soon as we have an equivocating validator. The bitfields are uninitialized in the general case and are fast. The node-weight addition logic has been altered to avoid double-counting any equivocated votes.The second, and probably most error-prone thing this does is to alter the logic for determining if a round is completable. The completable check sometimes needs to determine if any descendents of a block could possibly get 2/3+ vote-weight, and this PR alters the logic there to account for possible equivocations on blocks (i.e. not discounting any vote-weight which has already been spent).