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

Handle VoteStateUpdates for outdated roots bigger than slots in existing VoteState #27323

Merged
merged 4 commits into from
Aug 25, 2022

Conversation

carllin
Copy link
Contributor

@carllin carllin commented Aug 23, 2022

Problem

#27361

Summary of Changes

Set root to largest slot in VoteState less than the proposed root

Fixes #27348

@carllin carllin requested a review from AshwinSekar August 23, 2022 04:41
@carllin carllin force-pushed the FixVotes branch 3 times, most recently from 6554ad3 to 484cc9b Compare August 23, 2022 05:24
vote_state_update.root = Some(lockout.slot);
break;
}
prev_slot = lockout.slot;
Copy link
Contributor

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?

Copy link
Contributor Author

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

// 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
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

AshwinSekar
AshwinSekar previously approved these changes Aug 23, 2022
Copy link
Contributor

@AshwinSekar AshwinSekar left a 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.

@mergify mergify bot dismissed AshwinSekar’s stale review August 24, 2022 06:50

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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

Copy link
Contributor

@AshwinSekar AshwinSekar left a comment

Choose a reason for hiding this comment

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

lgtm

@carllin carllin merged commit ad6c2d8 into solana-labs:master Aug 25, 2022
mergify bot pushed a commit that referenced this pull request Aug 25, 2022
…ing VoteState (#27323)

* Set root to latest vote in tower <= prposed vote state

* fixup tests

* PR comments

* feature gate

(cherry picked from commit ad6c2d8)

# Conflicts:
#	programs/vote/src/vote_state/mod.rs
#	sdk/src/feature_set.rs
mergify bot pushed a commit that referenced this pull request Aug 25, 2022
…ing VoteState (#27323)

* Set root to latest vote in tower <= prposed vote state

* fixup tests

* PR comments

* feature gate

(cherry picked from commit ad6c2d8)

# Conflicts:
#	programs/vote/src/vote_state/mod.rs
#	sdk/src/feature_set.rs
carllin added a commit that referenced this pull request Aug 25, 2022
…ing VoteState (#27323)

* Set root to latest vote in tower <= prposed vote state

* fixup tests

* PR comments

* feature gate

(cherry picked from commit ad6c2d8)
mergify bot added a commit that referenced this pull request Aug 26, 2022
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LockoutsConflict in handling VoteStateUpdates with old roots
2 participants