-
Notifications
You must be signed in to change notification settings - Fork 295
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
VoteAccount: remove OnceLock around VoteState #2659
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2280,12 +2280,8 @@ impl Bank { | |
invalid_vote_keys.insert(vote_pubkey, InvalidCacheEntryReason::WrongOwner); | ||
return None; | ||
} | ||
let Ok(vote_state) = vote_account.vote_state().cloned() else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: in the let account = self.get_account_with_fixed_root(vote_pubkey)?;
if account.owner() == &solana_vote_program
&& VoteState::deserialize(account.data()).is_ok()
{
vote_accounts_cache_miss_count.fetch_add(1, Relaxed);
}
VoteAccount::try_from(account).ok() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code has been dead for a long time I think. We check that VoteAccounts contains all vote accounts at snapshot load time. We have the |
||
invalid_vote_keys.insert(vote_pubkey, InvalidCacheEntryReason::BadState); | ||
return None; | ||
}; | ||
let vote_with_stake_delegations = VoteWithStakeDelegations { | ||
vote_state: Arc::new(vote_state), | ||
vote_state: Arc::new(vote_account.vote_state().clone()), | ||
vote_account: AccountSharedData::from(vote_account), | ||
delegations: Vec::default(), | ||
}; | ||
|
@@ -2703,7 +2699,6 @@ impl Bank { | |
let vote_accounts = self.vote_accounts(); | ||
let recent_timestamps = vote_accounts.iter().filter_map(|(pubkey, (_, account))| { | ||
let vote_state = account.vote_state(); | ||
let vote_state = vote_state.as_ref().ok()?; | ||
let slot_delta = self.slot().checked_sub(vote_state.last_timestamp.slot)?; | ||
(slot_delta <= slots_per_epoch).then_some({ | ||
( | ||
|
@@ -2879,7 +2874,7 @@ impl Bank { | |
// up and can be used to set the collector id to the highest staked | ||
// node. If no staked nodes exist, allow fallback to an unstaked test | ||
// collector id during tests. | ||
let collector_id = self.stakes_cache.stakes().highest_staked_node(); | ||
let collector_id = self.stakes_cache.stakes().highest_staked_node().copied(); | ||
#[cfg(feature = "dev-context-only-utils")] | ||
let collector_id = collector_id.or(collector_id_for_tests); | ||
self.collector_id = | ||
|
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 PR is a bit noisy because there are a lot of changes like this: vote_state() used to return Result, but votes that failed to be parsed were never inserted into VoteAccounts. So effectively the Err branches were never entered, this PR removes them, but there's no actual logic change.