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,
}
#[derive(Default)]
#[derive(Default, Debug)]
pub struct StakeLockout {
lockout: u64,
stake: u64,

View File

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