From 8f24ceffbda0fdbca6ada9da0c5b2d4f58ecfae3 Mon Sep 17 00:00:00 2001 From: Jason Davis Date: Tue, 6 Dec 2022 15:48:32 -0600 Subject: [PATCH] Removed Arcs from PohConfig parameters and pass the struct by reference only --- core/src/banking_stage.rs | 20 +++++++------- core/src/replay_stage.rs | 2 +- core/src/validator.rs | 2 +- poh/src/poh_recorder.rs | 52 ++++++++++++++++++------------------- poh/src/poh_service.rs | 6 ++--- rpc/src/cluster_tpu_info.rs | 2 +- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index dd54e279d8..e04bef4ed8 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -2392,7 +2392,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -2618,7 +2618,7 @@ mod tests { &pubkey, &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -2755,7 +2755,7 @@ mod tests { &pubkey, &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -2829,7 +2829,7 @@ mod tests { &pubkey, &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -2983,7 +2983,7 @@ mod tests { &pubkey, &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -3061,7 +3061,7 @@ mod tests { &solana_sdk::pubkey::new_rand(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -3128,7 +3128,7 @@ mod tests { &Pubkey::new_unique(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -3334,7 +3334,7 @@ mod tests { &pubkey, &blockstore, &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -3503,7 +3503,7 @@ mod tests { &Pubkey::new_unique(), &blockstore, &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); let recorder = poh_recorder.recorder(); @@ -3610,7 +3610,7 @@ mod tests { &solana_sdk::pubkey::new_rand(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), exit, ); let poh_recorder = Arc::new(RwLock::new(poh_recorder)); diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index cef9e8480c..241603146d 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -3719,7 +3719,7 @@ pub(crate) mod tests { &Pubkey::default(), &blockstore, &leader_schedule_cache, - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::new(false)), ) .0, diff --git a/core/src/validator.rs b/core/src/validator.rs index ca903c01db..e4460f4570 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -715,7 +715,7 @@ impl Validator { max_slots.clone(), ); - let poh_config = Arc::new(genesis_config.poh_config.clone()); + let poh_config = genesis_config.poh_config.clone(); let startup_verification_complete; let (poh_recorder, entry_receiver, record_receiver) = { let bank = &bank_forks.read().unwrap().working_bank(); diff --git a/poh/src/poh_recorder.rs b/poh/src/poh_recorder.rs index 76c1eec2bb..6e06454858 100644 --- a/poh/src/poh_recorder.rs +++ b/poh/src/poh_recorder.rs @@ -225,7 +225,7 @@ pub struct PohRecorder { id: Pubkey, blockstore: Arc, leader_schedule_cache: Arc, - poh_config: Arc, + poh_config: PohConfig, ticks_per_slot: u64, target_ns_per_tick: u64, record_lock_contention_us: u64, @@ -827,7 +827,7 @@ impl PohRecorder { blockstore: &Arc, clear_bank_signal: Option>, leader_schedule_cache: &Arc, - poh_config: &Arc, + poh_config: &PohConfig, poh_timing_point_sender: Option, is_exited: Arc, ) -> (Self, Receiver, Receiver) { @@ -898,7 +898,7 @@ impl PohRecorder { id: &Pubkey, blockstore: &Arc, leader_schedule_cache: &Arc, - poh_config: &Arc, + poh_config: &PohConfig, is_exited: Arc, ) -> (Self, Receiver, Receiver) { Self::new_with_clear_signal( @@ -960,7 +960,7 @@ pub fn create_test_recorder( None => Arc::new(LeaderScheduleCache::new_from_bank(bank)), }; let exit = Arc::new(AtomicBool::new(false)); - let poh_config = Arc::new(poh_config.unwrap_or_default()); + let poh_config = poh_config.unwrap_or_default(); let (mut poh_recorder, entry_receiver, record_receiver) = PohRecorder::new( bank.tick_height(), bank.last_blockhash(), @@ -1019,7 +1019,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::default()), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); poh_recorder.tick(); @@ -1049,7 +1049,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::default()), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); poh_recorder.tick(); @@ -1078,7 +1078,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::default()), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); poh_recorder.tick(); @@ -1107,7 +1107,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1137,7 +1137,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank0)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1200,7 +1200,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1249,7 +1249,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank0)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1292,7 +1292,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1334,7 +1334,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank0)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1390,7 +1390,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1430,7 +1430,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1502,7 +1502,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank0)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1558,7 +1558,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::default()), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); poh_recorder.tick(); @@ -1587,7 +1587,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::default()), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); poh_recorder.tick(); @@ -1618,7 +1618,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::default()), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); poh_recorder.tick(); @@ -1652,7 +1652,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1684,7 +1684,7 @@ mod tests { &Arc::new(blockstore), Some(sender), &Arc::new(LeaderScheduleCache::default()), - &Arc::new(PohConfig::default()), + &PohConfig::default(), None, Arc::new(AtomicBool::default()), ); @@ -1719,7 +1719,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1767,7 +1767,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &leader_schedule_cache, - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1830,7 +1830,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank0)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -1991,7 +1991,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); @@ -2043,7 +2043,7 @@ mod tests { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), ); //create a new bank diff --git a/poh/src/poh_service.rs b/poh/src/poh_service.rs index 2b71c6ab61..34d773cfec 100644 --- a/poh/src/poh_service.rs +++ b/poh/src/poh_service.rs @@ -96,7 +96,7 @@ impl PohTiming { impl PohService { pub fn new( poh_recorder: Arc>, - poh_config: &Arc, + poh_config: &PohConfig, poh_exit: &Arc, ticks_per_slot: u64, pinned_cpu_core: usize, @@ -414,11 +414,11 @@ mod tests { let default_target_tick_duration = timing::duration_as_us(&PohConfig::default().target_tick_duration); let target_tick_duration = Duration::from_micros(default_target_tick_duration); - let poh_config = Arc::new(PohConfig { + let poh_config = PohConfig { hashes_per_tick: Some(clock::DEFAULT_HASHES_PER_TICK), target_tick_duration, target_tick_count: None, - }); + }; let exit = Arc::new(AtomicBool::new(false)); let ticks_per_slot = bank.ticks_per_slot(); diff --git a/rpc/src/cluster_tpu_info.rs b/rpc/src/cluster_tpu_info.rs index 7e1982cf50..2d0b8b8d4a 100644 --- a/rpc/src/cluster_tpu_info.rs +++ b/rpc/src/cluster_tpu_info.rs @@ -108,7 +108,7 @@ mod test { &Pubkey::default(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), - &Arc::new(PohConfig::default()), + &PohConfig::default(), Arc::new(AtomicBool::default()), );