Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Make goto_end_of_slot() take Arc<Bank> #33650

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -8486,8 +8486,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>) {
Copy link
Contributor Author

@ryoqun ryoqun Oct 11, 2023

Choose a reason for hiding this comment

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

yes, taking ownership of Arc<Bank> is intentional for upcoming changes. strictly speaking, implied cloning isn't needed, however i leaned towards coding simplicity over perfection.

after all, this isn't part of hot path, rather a tiny and aged test helper function... who cares for additional clones for it? ;)

let mut tick_hash = bank.last_blockhash();
loop {
tick_hash = hashv(&[tick_hash.as_ref(), &[42]]);
Expand Down
Loading