From c706f9b2cd194f44bffa78e64e84550a75211ab2 Mon Sep 17 00:00:00 2001 From: carllin Date: Tue, 26 Nov 2019 16:21:02 -0800 Subject: [PATCH] Change from using fixed number of ticks in delay calculation (#7152) automerge --- ledger/src/blocktree.rs | 7 ++++--- sdk/src/clock.rs | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ledger/src/blocktree.rs b/ledger/src/blocktree.rs index a52e45c86..e08c8d551 100644 --- a/ledger/src/blocktree.rs +++ b/ledger/src/blocktree.rs @@ -28,7 +28,7 @@ use solana_measure::measure::Measure; use solana_metrics::{datapoint_debug, datapoint_error}; use solana_rayon_threadlimit::get_thread_count; use solana_sdk::{ - clock::{Slot, UnixTimestamp, DEFAULT_TICKS_PER_SECOND}, + clock::{Slot, UnixTimestamp, DEFAULT_TICKS_PER_SECOND, MS_PER_TICK}, genesis_config::GenesisConfig, hash::Hash, signature::{Keypair, KeypairUtil, Signature}, @@ -58,7 +58,8 @@ thread_local!(static PAR_THREAD_POOL: RefCell = RefCell::new(rayon:: .unwrap())); pub const MAX_COMPLETED_SLOTS_IN_CHANNEL: usize = 100_000; -pub const MAX_TURBINE_PROPAGATION_DELAY_TICKS: u64 = 16; +pub const MAX_TURBINE_PROPAGATION_IN_MS: u64 = 100; +pub const MAX_TURBINE_DELAY_IN_TICKS: u64 = MAX_TURBINE_PROPAGATION_IN_MS / MS_PER_TICK; pub type CompletedSlotsReceiver = Receiver>; @@ -1082,7 +1083,7 @@ impl Blocktree { &db_iterator.value().expect("couldn't read value"), )); - if ticks_since_first_insert < reference_tick + MAX_TURBINE_PROPAGATION_DELAY_TICKS { + if ticks_since_first_insert < reference_tick + MAX_TURBINE_DELAY_IN_TICKS { // The higher index holes have not timed out yet break 'outer; } diff --git a/sdk/src/clock.rs b/sdk/src/clock.rs index 0121dc038..617fb3d5e 100644 --- a/sdk/src/clock.rs +++ b/sdk/src/clock.rs @@ -4,6 +4,8 @@ // rate at any given time should be expected to drift pub const DEFAULT_TICKS_PER_SECOND: u64 = 160; +pub const MS_PER_TICK: u64 = 1000 / DEFAULT_TICKS_PER_SECOND; + // At 160 ticks/s, 64 ticks per slot implies that leader rotation and voting will happen // every 400 ms. A fast voting cadence ensures faster finality and convergence pub const DEFAULT_TICKS_PER_SLOT: u64 = 64;