From 2aa93e995869286d0869f0e9bbcd54213c2e0772 Mon Sep 17 00:00:00 2001 From: Brennan Date: Sun, 3 Nov 2024 07:59:45 -0800 Subject: [PATCH] increase minimum shred filtering distance (#3430) --- core/src/shred_fetch_stage.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/shred_fetch_stage.rs b/core/src/shred_fetch_stage.rs index 6d4e6172af46b2..6f3e8889423bf4 100644 --- a/core/src/shred_fetch_stage.rs +++ b/core/src/shred_fetch_stage.rs @@ -30,6 +30,12 @@ use { }; const PACKET_COALESCE_DURATION: Duration = Duration::from_millis(1); +// When running with very short epochs (e.g. for testing), we want to avoid +// filtering out shreds that we actually need. This value was chosen empirically +// because it's large enough to protect against observed short epoch problems +// while being small enough to keep the overhead small on deduper, blockstore, +// etc. +const MAX_SHRED_DISTANCE_MINIMUM: u64 = 500; pub(crate) struct ShredFetchStage { thread_hdls: Vec>, @@ -107,8 +113,9 @@ impl ShredFetchStage { } } - // Limit shreds to 2 epochs away. - let max_slot = last_slot + 2 * slots_per_epoch; + // Filter out shreds that are way too far in the future to avoid the + // overhead of having to hold onto them. + let max_slot = last_slot + MAX_SHRED_DISTANCE_MINIMUM.max(2 * slots_per_epoch); let enable_chained_merkle_shreds = |shred_slot| { cluster_type == ClusterType::Development || check_feature_activation(