hang out on progress until fork is confirmed

This commit is contained in:
Anatoly Yakovenko
2019-03-27 05:21:19 -07:00
committed by Grimes
parent 6bfe497ab5
commit 0346b9cb5c
2 changed files with 15 additions and 13 deletions

View File

@ -21,7 +21,7 @@ pub struct EpochStakes {
delegate_id: Pubkey, delegate_id: Pubkey,
} }
#[derive(Default)] #[derive(Default, Debug)]
pub struct StakeLockout { pub struct StakeLockout {
lockout: u64, lockout: u64,
stake: u64, stake: u64,

View File

@ -58,7 +58,6 @@ struct ForkProgress {
last_entry: Hash, last_entry: Hash,
num_blobs: usize, num_blobs: usize,
started_ms: u64, started_ms: u64,
supermajority_confirmed_ms: u64,
} }
impl ForkProgress { impl ForkProgress {
pub fn new(last_entry: Hash) -> Self { pub fn new(last_entry: Hash) -> Self {
@ -66,7 +65,6 @@ impl ForkProgress {
last_entry, last_entry,
num_blobs: 0, num_blobs: 0,
started_ms: timing::timestamp(), started_ms: timing::timestamp(),
supermajority_confirmed_ms: 0,
} }
} }
} }
@ -380,7 +378,7 @@ impl ReplayStage {
} }
let max_tick_height = (*bank_slot + 1) * bank.ticks_per_slot() - 1; let max_tick_height = (*bank_slot + 1) * bank.ticks_per_slot() - 1;
if bank.tick_height() == max_tick_height { if bank.tick_height() == max_tick_height {
Self::process_completed_bank(my_id, bank, progress, slot_full_sender); Self::process_completed_bank(my_id, bank, slot_full_sender);
} }
} }
Ok(()) Ok(())
@ -460,20 +458,26 @@ impl ReplayStage {
stake_lockouts: &HashMap<u64, StakeLockout>, stake_lockouts: &HashMap<u64, StakeLockout>,
progress: &mut HashMap<u64, ForkProgress>, progress: &mut HashMap<u64, ForkProgress>,
) { ) {
for (slot, prog) in progress.iter_mut() { progress.retain(|slot, prog| {
if prog.supermajority_confirmed_ms == 0 let duration = timing::timestamp() - prog.started_ms;
&& locktower.is_slot_confirmed(*slot, stake_lockouts) if locktower.is_slot_confirmed(*slot, stake_lockouts) {
{
prog.supermajority_confirmed_ms = timing::timestamp();
let duration = prog.supermajority_confirmed_ms - prog.started_ms;
info!("validator fork confirmed {} {}", *slot, duration); info!("validator fork confirmed {} {}", *slot, duration);
solana_metrics::submit( solana_metrics::submit(
influxdb::Point::new(&"validator-confirmation") influxdb::Point::new(&"validator-confirmation")
.add_field("duration_ms", influxdb::Value::Integer(duration as i64)) .add_field("duration_ms", influxdb::Value::Integer(duration as i64))
.to_owned(), .to_owned(),
); );
false
} else {
debug!(
"validator fork not confirmed {} {} {:?}",
*slot,
duration,
stake_lockouts.get(slot)
);
true
} }
} });
} }
fn load_blocktree_entries( fn load_blocktree_entries(
@ -540,12 +544,10 @@ impl ReplayStage {
fn process_completed_bank( fn process_completed_bank(
my_id: &Pubkey, my_id: &Pubkey,
bank: Arc<Bank>, bank: Arc<Bank>,
progress: &mut HashMap<u64, ForkProgress>,
slot_full_sender: &Sender<(u64, Pubkey)>, slot_full_sender: &Sender<(u64, Pubkey)>,
) { ) {
bank.freeze(); bank.freeze();
info!("bank frozen {}", bank.slot()); info!("bank frozen {}", bank.slot());
progress.remove(&bank.slot());
if let Err(e) = slot_full_sender.send((bank.slot(), bank.collector_id())) { if let Err(e) = slot_full_sender.send((bank.slot(), bank.collector_id())) {
trace!("{} slot_full alert failed: {:?}", my_id, e); trace!("{} slot_full alert failed: {:?}", my_id, e);
} }