Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes outdated check for merkle shreds #33088

Merged
merged 1 commit into from
Aug 31, 2023
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
44 changes: 4 additions & 40 deletions core/src/shred_fetch_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ use {
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::shred::{should_discard_shred, ShredFetchStats},
solana_perf::packet::{PacketBatch, PacketBatchRecycler, PacketFlags, PACKETS_PER_BATCH},
solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_runtime::bank_forks::BankForks,
solana_sdk::{
clock::{Slot, DEFAULT_MS_PER_SLOT},
feature_set,
clock::DEFAULT_MS_PER_SLOT,
packet::{Meta, PACKET_DATA_SIZE},
pubkey::Pubkey,
},
solana_streamer::streamer::{self, PacketBatchReceiver, StreamerReceiveStats},
solana_turbine::cluster_nodes::check_feature_activation,
std::{
net::{SocketAddr, UdpSocket},
sync::{
Expand Down Expand Up @@ -93,19 +91,10 @@ impl ShredFetchStage {

// Limit shreds to 2 epochs away.
let max_slot = last_slot + 2 * slots_per_epoch;
let should_drop_merkle_shreds =
|shred_slot| should_drop_merkle_shreds(shred_slot, &root_bank);
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,
should_drop_merkle_shreds,
&mut stats,
)
|| should_discard_shred(packet, last_root, max_slot, shred_version, &mut stats)
{
packet.meta_mut().set_discard(true);
} else {
Expand Down Expand Up @@ -295,19 +284,6 @@ fn receive_quic_datagrams(
}
}

#[must_use]
fn should_drop_merkle_shreds(shred_slot: Slot, root_bank: &Bank) -> bool {
check_feature_activation(
&feature_set::keep_merkle_shreds::id(),
shred_slot,
root_bank,
) && !check_feature_activation(
&feature_set::drop_merkle_shreds::id(),
shred_slot,
root_bank,
)
}

#[cfg(test)]
mod tests {
use {
Expand Down Expand Up @@ -348,7 +324,6 @@ mod tests {
last_root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats,
));
let coding = solana_ledger::shred::Shredder::generate_coding_shreds(
Expand All @@ -362,7 +337,6 @@ mod tests {
last_root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats,
));
}
Expand All @@ -384,7 +358,6 @@ mod tests {
last_root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats,
));
assert_eq!(stats.index_overrun, 1);
Expand All @@ -406,18 +379,12 @@ mod tests {
3,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats,
));
assert_eq!(stats.slot_out_of_range, 1);

assert!(should_discard_shred(
&packet,
last_root,
max_slot,
345, // shred_version
|_| false, // should_drop_merkle_shreds
&mut stats,
&packet, last_root, max_slot, /*shred_version:*/ 345, &mut stats,
));
assert_eq!(stats.shred_version_mismatch, 1);

Expand All @@ -427,7 +394,6 @@ mod tests {
last_root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats,
));

Expand All @@ -449,7 +415,6 @@ mod tests {
last_root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats,
));

Expand All @@ -461,7 +426,6 @@ mod tests {
last_root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats,
));
}
Expand Down
18 changes: 0 additions & 18 deletions ledger/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,6 @@ pub fn should_discard_shred(
root: Slot,
max_slot: Slot,
shred_version: u16,
should_drop_merkle_shreds: impl Fn(Slot) -> bool,
stats: &mut ShredFetchStats,
) -> bool {
debug_assert!(root < max_slot);
Expand Down Expand Up @@ -970,15 +969,9 @@ pub fn should_discard_shred(
match shred_variant {
ShredVariant::LegacyCode | ShredVariant::LegacyData => (),
ShredVariant::MerkleCode(_) => {
if should_drop_merkle_shreds(slot) {
return true;
}
stats.num_shreds_merkle_code = stats.num_shreds_merkle_code.saturating_add(1);
}
ShredVariant::MerkleData(_) => {
if should_drop_merkle_shreds(slot) {
return true;
}
stats.num_shreds_merkle_data = stats.num_shreds_merkle_data.saturating_add(1);
}
}
Expand Down Expand Up @@ -1178,7 +1171,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(stats, ShredFetchStats::default());
Expand All @@ -1189,7 +1181,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 1);
Expand All @@ -1200,7 +1191,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 2);
Expand All @@ -1211,7 +1201,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 3);
Expand All @@ -1222,7 +1211,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(stats.index_overrun, 4);
Expand All @@ -1233,7 +1221,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(stats.bad_parent_offset, 1);
Expand All @@ -1254,7 +1241,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));

Expand All @@ -1274,7 +1260,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(1, stats.index_out_of_bounds);
Expand All @@ -1295,7 +1280,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
packet.buffer_mut()[OFFSET_OF_SHRED_VARIANT] = u8::MAX;
Expand All @@ -1305,7 +1289,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(1, stats.bad_shred_type);
Expand All @@ -1317,7 +1300,6 @@ mod tests {
root,
max_slot,
shred_version,
|_| false, // should_drop_merkle_shreds
&mut stats
));
assert_eq!(1, stats.bad_shred_type);
Expand Down
10 changes: 0 additions & 10 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,6 @@ pub mod disable_turbine_fanout_experiments {
solana_sdk::declare_id!("Gz1aLrbeQ4Q6PTSafCZcGWZXz91yVRi7ASFzFEr1U4sa");
}

pub mod drop_merkle_shreds {
steviez marked this conversation as resolved.
Show resolved Hide resolved
solana_sdk::declare_id!("84zy5N23Q9vTZuLc9h1HWUtyM9yCFV2SCmyP9W9C3yHZ");
}

pub mod keep_merkle_shreds {
solana_sdk::declare_id!("HyNQzc7TMNmRhpVHXqDGjpsHzeQie82mDQXSF9hj7nAH");
}

pub mod move_serialized_len_ptr_in_cpi {
solana_sdk::declare_id!("74CoWuBmt3rUVUrCb2JiSTvh6nXyBWUsK4SaMj3CtE3T");
}
Expand Down Expand Up @@ -833,8 +825,6 @@ lazy_static! {
(commission_updates_only_allowed_in_first_half_of_epoch::id(), "validator commission updates are only allowed in the first half of an epoch #29362"),
(enable_turbine_fanout_experiments::id(), "enable turbine fanout experiments #29393"),
(disable_turbine_fanout_experiments::id(), "disable turbine fanout experiments #29393"),
(drop_merkle_shreds::id(), "drop merkle shreds #29711"),
(keep_merkle_shreds::id(), "keep merkle shreds #29711"),
(move_serialized_len_ptr_in_cpi::id(), "cpi ignore serialized_len_ptr #29592"),
(update_hashes_per_tick::id(), "Update desired hashes per tick on epoch boundary"),
(enable_big_mod_exp_syscall::id(), "add big_mod_exp syscall #28503"),
Expand Down
2 changes: 1 addition & 1 deletion turbine/src/cluster_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ fn enable_turbine_fanout_experiments(shred_slot: Slot, root_bank: &Bank) -> bool

// Returns true if the feature is effective for the shred slot.
#[must_use]
pub fn check_feature_activation(feature: &Pubkey, shred_slot: Slot, root_bank: &Bank) -> bool {
fn check_feature_activation(feature: &Pubkey, shred_slot: Slot, root_bank: &Bank) -> bool {
match root_bank.feature_set.activated_slot(feature) {
None => false,
Some(feature_slot) => {
Expand Down