diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 0a381e90b694f8..4a360fc0b0b8d2 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -39,8 +39,8 @@ use { vote_error::VoteError, vote_instruction, vote_state::{ - process_slot_vote_unchecked, BlockTimestamp, Lockout, TowerSync, Vote, - VoteState1_14_11, VoteStateUpdate, MAX_LOCKOUT_HISTORY, + BlockTimestamp, Lockout, TowerSync, Vote, VoteState1_14_11, VoteStateUpdate, + MAX_LOCKOUT_HISTORY, }, }, std::{ @@ -406,10 +406,10 @@ impl Tower { continue; } trace!("{} {} with stake {}", vote_account_pubkey, key, voted_stake); - let mut vote_state = account.vote_state().clone(); + let mut vote_state = TowerVoteState::from(account.vote_state().clone()); for vote in &vote_state.votes { lockout_intervals - .entry(vote.lockout.last_locked_out_slot()) + .entry(vote.last_locked_out_slot()) .or_default() .push((vote.slot(), key)); } @@ -450,7 +450,7 @@ impl Tower { ); } - process_slot_vote_unchecked(&mut vote_state, bank_slot); + vote_state.process_next_vote_slot(bank_slot); for vote in &vote_state.votes { vote_slots.insert(vote.slot()); @@ -1795,7 +1795,7 @@ pub mod test { }, solana_vote::vote_account::VoteAccount, solana_vote_program::vote_state::{ - Vote, VoteState, VoteStateVersions, MAX_LOCKOUT_HISTORY, + process_slot_vote_unchecked, Vote, VoteState, VoteStateVersions, MAX_LOCKOUT_HISTORY, }, std::{ collections::{HashMap, VecDeque}, diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index 7a6eda12d39c34..15d5621d235e9e 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -3624,7 +3624,7 @@ impl ReplayStage { let Some(vote_account) = bank.get_vote_account(my_vote_pubkey) else { return; }; - let mut bank_vote_state = vote_account.vote_state().clone(); + let mut bank_vote_state = TowerVoteState::from(vote_account.vote_state().clone()); if bank_vote_state.last_voted_slot() <= tower.vote_state.last_voted_slot() { return; } @@ -3673,8 +3673,8 @@ impl ReplayStage { } } - tower.vote_state.root_slot = bank_vote_state.root_slot; - tower.vote_state.votes = bank_vote_state.votes.into_iter().map(Into::into).collect(); + // adopt the bank vote state + tower.vote_state = bank_vote_state; let last_voted_slot = tower.vote_state.last_voted_slot().unwrap_or( // If our local root is higher than the highest slot in `bank_vote_state` due to diff --git a/core/src/vote_simulator.rs b/core/src/vote_simulator.rs index 375e669b5a4e0c..27f42c59243e65 100644 --- a/core/src/vote_simulator.rs +++ b/core/src/vote_simulator.rs @@ -8,6 +8,7 @@ use { heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, progress_map::{ForkProgress, ProgressMap}, + tower_vote_state::TowerVoteState, Tower, }, repair::cluster_slot_state_verifier::{ @@ -27,7 +28,7 @@ use { }, solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey, signature::Signer}, solana_vote::vote_transaction, - solana_vote_program::vote_state::{process_vote_unchecked, Lockout, TowerSync}, + solana_vote_program::vote_state::{Lockout, TowerSync}, std::{ collections::{HashMap, HashSet, VecDeque}, sync::{Arc, RwLock}, @@ -102,17 +103,11 @@ impl VoteSimulator { let tower_sync = if let Some(vote_account) = parent_bank.get_vote_account(&keypairs.vote_keypair.pubkey()) { - let mut vote_state = vote_account.vote_state().clone(); - process_vote_unchecked( - &mut vote_state, - solana_vote_program::vote_state::Vote::new( - vec![parent], - parent_bank.hash(), - ), - ) - .unwrap(); + let mut vote_state = + TowerVoteState::from(vote_account.vote_state().clone()); + vote_state.process_next_vote_slot(parent); TowerSync::new( - vote_state.votes.iter().map(|vote| vote.lockout).collect(), + vote_state.votes, vote_state.root_slot, parent_bank.hash(), Hash::default(),