Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions core/src/shred_fetch_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
bytes::Bytes,
crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender},
itertools::Itertools,
solana_feature_set::FeatureSet,
solana_feature_set::{self as feature_set, FeatureSet},
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::shred::{self, should_discard_shred, ShredFetchStats},
solana_perf::packet::{
Expand Down Expand Up @@ -52,7 +52,6 @@ struct RepairContext {

impl ShredFetchStage {
// updates packets received on a channel and sends them on another channel
#[allow(unused_variables, unused_assignments)]
fn modify_packets(
recvr: PacketBatchReceiver,
sendr: Sender<PacketBatch>,
Expand Down Expand Up @@ -137,10 +136,25 @@ impl ShredFetchStage {
// 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 drop_unchained_merkle_shreds = |shred_slot| {
check_feature_activation(
&feature_set::drop_unchained_merkle_shreds::id(),
shred_slot,
&feature_set,
&epoch_schedule,
)
};
let turbine_disabled = turbine_disabled.load(Ordering::Relaxed);
for packet in packet_batch.iter_mut().filter(|p| !p.meta().discard()) {
if turbine_disabled
|| should_discard_shred(packet, last_root, max_slot, shred_version, &mut stats)
|| should_discard_shred(
packet,
last_root,
max_slot,
shred_version,
drop_unchained_merkle_shreds,
&mut stats,
)
{
packet.meta_mut().set_discard(true);
} else {
Expand Down Expand Up @@ -413,7 +427,6 @@ pub(crate) fn receive_quic_datagrams(

// Returns true if the feature is effective for the shred slot.
#[must_use]
#[allow(dead_code)]
fn check_feature_activation(
feature: &Pubkey,
shred_slot: Slot,
Expand Down
22 changes: 22 additions & 0 deletions ledger/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ pub fn should_discard_shred(
root: Slot,
max_slot: Slot,
shred_version: u16,
drop_unchained_merkle_shreds: impl Fn(Slot) -> bool,
stats: &mut ShredFetchStats,
) -> bool {
debug_assert!(root < max_slot);
Expand Down Expand Up @@ -914,13 +915,19 @@ pub fn should_discard_shred(
return true;
}
ShredVariant::MerkleCode { chained: false, .. } => {
if drop_unchained_merkle_shreds(slot) {
return true;
}
stats.num_shreds_merkle_code = stats.num_shreds_merkle_code.saturating_add(1);
}
ShredVariant::MerkleCode { chained: true, .. } => {
stats.num_shreds_merkle_code_chained =
stats.num_shreds_merkle_code_chained.saturating_add(1);
}
ShredVariant::MerkleData { chained: false, .. } => {
if drop_unchained_merkle_shreds(slot) {
return true;
}
stats.num_shreds_merkle_data = stats.num_shreds_merkle_data.saturating_add(1);
}
ShredVariant::MerkleData { chained: true, .. } => {
Expand Down Expand Up @@ -1194,6 +1201,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
}
Expand All @@ -1206,6 +1214,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 1);
Expand All @@ -1216,6 +1225,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 2);
Expand All @@ -1226,6 +1236,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 3);
Expand All @@ -1236,6 +1247,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 4);
Expand All @@ -1246,6 +1258,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.bad_parent_offset, 1);
Expand All @@ -1257,6 +1270,7 @@ mod tests {
root,
max_slot,
shred_version.wrapping_add(1),
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.shred_version_mismatch, 1);
Expand All @@ -1268,6 +1282,7 @@ mod tests {
parent_slot + 1, // root
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.slot_out_of_range, 1);
Expand All @@ -1289,6 +1304,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.slot_out_of_range, 1);
Expand All @@ -1310,6 +1326,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.bad_parent_offset, 1);
Expand All @@ -1330,6 +1347,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.index_out_of_bounds, 1);
Expand All @@ -1346,6 +1364,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
}
Expand All @@ -1356,6 +1375,7 @@ mod tests {
root,
max_slot,
shred_version.wrapping_add(1),
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.shred_version_mismatch, 1);
Expand All @@ -1367,6 +1387,7 @@ mod tests {
slot, // root
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.slot_out_of_range, 1);
Expand All @@ -1387,6 +1408,7 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // drop_unchained_merkle_shreds
&mut stats
));
assert_eq!(stats.index_out_of_bounds, 1);
Expand Down
5 changes: 5 additions & 0 deletions sdk/feature-set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,10 @@ pub mod raise_block_limits_to_50m {
solana_pubkey::declare_id!("5oMCU3JPaFLr8Zr4ct7yFA7jdk6Mw1RmB8K4u9ZbS42z");
}

pub mod drop_unchained_merkle_shreds {
solana_pubkey::declare_id!("3A9WtMU4aHuryD3VN7SFKdfXto8HStLb1Jj6HjkgfnGL");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: AHashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -1155,6 +1159,7 @@ lazy_static! {
(reserve_minimal_cus_for_builtin_instructions::id(), "Reserve minimal CUs for builtin instructions SIMD-170 #2562"),
(raise_block_limits_to_50m::id(), "Raise block limit to 50M SIMD-0207"),
(fix_alt_bn128_multiplication_input_length::id(), "fix alt_bn128 multiplication input length SIMD-0222 #3686"),
(drop_unchained_merkle_shreds::id(), "drops unchained Merkle shreds #2149"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down