ReplayStage no longer relies on Validator to reset the poh recorder at start

This commit is contained in:
Michael Vines 2022-04-20 17:53:29 -07:00
parent 84e3342612
commit d0a8a16a57
2 changed files with 30 additions and 34 deletions

View File

@ -433,6 +433,14 @@ impl ReplayStage {
last_print_time: Instant::now(), last_print_time: Instant::now(),
}; };
Self::reset_poh_recorder(
&my_pubkey,
&blockstore,
&bank_forks.read().unwrap().working_bank(),
&poh_recorder,
&leader_schedule_cache,
);
loop { loop {
// Stop getting entries if we get exit signal // Stop getting entries if we get exit signal
if exit.load(Ordering::Relaxed) { if exit.load(Ordering::Relaxed) {

View File

@ -49,7 +49,7 @@ use {
solana_measure::measure::Measure, solana_measure::measure::Measure,
solana_metrics::{datapoint_info, poh_timing_point::PohTimingSender}, solana_metrics::{datapoint_info, poh_timing_point::PohTimingSender},
solana_poh::{ solana_poh::{
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS}, poh_recorder::PohRecorder,
poh_service::{self, PohService}, poh_service::{self, PohService},
}, },
solana_rpc::{ solana_rpc::{
@ -692,11 +692,11 @@ impl Validator {
None None
}; };
let bank = Arc::clone(&bank_forks.read().unwrap().working_bank());
info!("Starting validator with working bank slot {}", bank.slot());
let mut block_commitment_cache = BlockCommitmentCache::default(); let mut block_commitment_cache = BlockCommitmentCache::default();
block_commitment_cache.initialize_slots(bank.slot(), bank_forks.read().unwrap().root()); block_commitment_cache.initialize_slots(
bank_forks.read().unwrap().working_bank().slot(),
bank_forks.read().unwrap().root(),
);
let block_commitment_cache = Arc::new(RwLock::new(block_commitment_cache)); let block_commitment_cache = Arc::new(RwLock::new(block_commitment_cache));
let optimistically_confirmed_bank = let optimistically_confirmed_bank =
@ -723,36 +723,24 @@ impl Validator {
max_slots.clone(), max_slots.clone(),
); );
info!(
"Starting PoH: epoch={} slot={} tick_height={} blockhash={} leader={:?}",
bank.epoch(),
bank.slot(),
bank.tick_height(),
bank.last_blockhash(),
leader_schedule_cache.slot_leader_at(bank.slot(), Some(&bank))
);
let poh_config = Arc::new(genesis_config.poh_config.clone()); let poh_config = Arc::new(genesis_config.poh_config.clone());
let (poh_recorder, entry_receiver, record_receiver) = PohRecorder::new_with_clear_signal( let (poh_recorder, entry_receiver, record_receiver) = {
bank.tick_height(), let bank = &bank_forks.read().unwrap().working_bank();
bank.last_blockhash(), PohRecorder::new_with_clear_signal(
bank.clone(), bank.tick_height(),
leader_schedule_cache.next_leader_slot( bank.last_blockhash(),
bank.clone(),
None,
bank.ticks_per_slot(),
&id, &id,
bank.slot(), &blockstore,
&bank, blockstore.get_new_shred_signal(0),
Some(&blockstore), &leader_schedule_cache,
GRACE_TICKS_FACTOR * MAX_GRACE_SLOTS, &poh_config,
), Some(poh_timing_point_sender),
bank.ticks_per_slot(), exit.clone(),
&id, )
&blockstore, };
blockstore.get_new_shred_signal(0),
&leader_schedule_cache,
&poh_config,
Some(poh_timing_point_sender),
exit.clone(),
);
let poh_recorder = Arc::new(Mutex::new(poh_recorder)); let poh_recorder = Arc::new(Mutex::new(poh_recorder));
let rpc_override_health_check = Arc::new(AtomicBool::new(false)); let rpc_override_health_check = Arc::new(AtomicBool::new(false));
@ -898,7 +886,7 @@ impl Validator {
poh_recorder.clone(), poh_recorder.clone(),
&poh_config, &poh_config,
&exit, &exit,
bank.ticks_per_slot(), bank_forks.read().unwrap().root_bank().ticks_per_slot(),
config.poh_pinned_cpu_core, config.poh_pinned_cpu_core,
config.poh_hashes_per_batch, config.poh_hashes_per_batch,
record_receiver, record_receiver,