-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 VoteStateUpdates for outdated roots bigger than slots in existing VoteState #27323
Conversation
6554ad3
to
484cc9b
Compare
programs/vote/src/vote_state/mod.rs
Outdated
vote_state_update.root = Some(lockout.slot); | ||
break; | ||
} | ||
prev_slot = lockout.slot; |
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 the only purpose of prev_slot
to check that we're iterating from biggest to smallest? Isn't the order of vote_state
already checked elsewhere?
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.
Yeah I think vote_state_update
ordering is checked in check_update_vote_state_slots_are_valid
and returns SlotNotOrdered
if not, but the current vote_state
itself was never checked I think
programs/vote/src/vote_state/mod.rs
Outdated
// we use this mutable root to fold the root slot case into this loop for performance | ||
let mut check_root = vote_state_update.root; | ||
// Index into the new proposed vote state's slots, starting with the root if it exists then | ||
// we use this mutable root to fold checking the root slot into this the below loop |
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.
-this : we use this mutable root to fold checking the root slot into the below loop"
let current_vote_state_root = Some(0); | ||
let vote_state_update_slots_and_lockouts = vec![(5, 1)]; | ||
let vote_state_update_root = 4; | ||
let expected_root = Some(4); |
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 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.
some minor nits. looks good, nice tests.
Pull request has been modified.
assert!(vote_state.root_slot.unwrap() < earliest_slot_hash_in_history); | ||
check_root = None; | ||
if let Some(new_proposed_root) = root_to_check { | ||
if is_root_fix_enabled { |
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.
@AshwinSekar added check here and simplified the asserts
if earliest_slot_hash_in_history > new_proposed_root { | ||
vote_state_update.root = vote_state.root_slot; | ||
if is_root_fix_enabled { |
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.
@AshwinSekar added check here as well
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.
lgtm
…ing VoteState (backport #27323) (#27392) Handle VoteStateUpdates for outdated roots bigger than slots in existing VoteState (#27323) * Set root to latest vote in tower <= prposed vote state * fixup tests * PR comments * feature gate (cherry picked from commit ad6c2d8) Co-authored-by: carllin <[email protected]>
Problem
#27361
Summary of Changes
Set root to largest slot in VoteState less than the proposed root
Fixes #27348