Skip to content

Commit

Permalink
Make goto_end_of_slot() take Arc<Bank> (solana-labs#33650)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun authored Oct 13, 2023
1 parent 47540af commit 53925b6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 56 deletions.
4 changes: 2 additions & 2 deletions runtime/benches/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn bench_bank_async_process_native_loader_transactions(bencher: &mut Bencher) {
fn bench_bank_update_recent_blockhashes(bencher: &mut Bencher) {
let (genesis_config, _mint_keypair) = create_genesis_config(100);
let mut bank = Arc::new(Bank::new_for_benches(&genesis_config));
goto_end_of_slot(Arc::get_mut(&mut bank).unwrap());
goto_end_of_slot(bank.clone());
let genesis_hash = bank.last_blockhash();
// Prime blockhash_queue
for i in 0..(MAX_RECENT_BLOCKHASHES + 1) {
Expand All @@ -193,7 +193,7 @@ fn bench_bank_update_recent_blockhashes(bencher: &mut Bencher) {
&Pubkey::default(),
(i + 1) as u64,
));
goto_end_of_slot(Arc::get_mut(&mut bank).unwrap());
goto_end_of_slot(bank.clone());
}
// Verify blockhash_queue is full (genesis hash has been kicked out)
assert!(!bank.is_hash_valid_for_age(&genesis_hash, MAX_RECENT_BLOCKHASHES));
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8508,8 +8508,9 @@ pub mod test_utils {
super::Bank,
solana_sdk::{hash::hashv, pubkey::Pubkey},
solana_vote_program::vote_state::{self, BlockTimestamp, VoteStateVersions},
std::sync::Arc,
};
pub fn goto_end_of_slot(bank: &Bank) {
pub fn goto_end_of_slot(bank: Arc<Bank>) {
let mut tick_hash = bank.last_blockhash();
loop {
tick_hash = hashv(&[tick_hash.as_ref(), &[42]]);
Expand Down
Loading

0 comments on commit 53925b6

Please sign in to comment.