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

v2.0: adds feature-gate code to enforce retransmitter signature verification (backport of #1840) #2415

Merged
merged 2 commits into from
Aug 14, 2024
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
5 changes: 5 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,10 @@ pub mod ed25519_precompile_verify_strict {
solana_sdk::declare_id!("ed9tNscbWLYBooxWA7FE2B5KHWs8A6sxfY8EzezEcoo");
}

pub mod verify_retransmitter_signature {
solana_sdk::declare_id!("BZ5g4hRbu5hLQQBdPyo2z9icGyJ8Khiyj3QS6dhWijTb");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -1041,6 +1045,7 @@ lazy_static! {
(zk_elgamal_proof_program_enabled::id(), "Enable ZkElGamalProof program SIMD-0153"),
(move_stake_and_move_lamports_ixs::id(), "Enable MoveStake and MoveLamports stake program instructions #1610"),
(ed25519_precompile_verify_strict::id(), "Use strict verification in ed25519 precompile SIMD-0152"),
(verify_retransmitter_signature::id(), "Verify retransmitter signature #1840"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down
16 changes: 15 additions & 1 deletion turbine/src/sigverify_shreds.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::{
cluster_nodes::{self, ClusterNodesCache},
cluster_nodes::{self, check_feature_activation, ClusterNodesCache},
retransmit_stage::RetransmitStage,
},
crossbeam_channel::{Receiver, RecvTimeoutError, SendError, Sender},
Expand All @@ -19,6 +19,7 @@ use {
},
solana_sdk::{
clock::Slot,
feature_set,
pubkey::Pubkey,
signature::{Keypair, Signer},
},
Expand Down Expand Up @@ -201,6 +202,19 @@ fn run_shred_sigverify<const K: usize>(
stats
.num_invalid_retransmitter
.fetch_add(1, Ordering::Relaxed);
if shred::layout::get_slot(shred)
.map(|slot| {
check_feature_activation(
&feature_set::verify_retransmitter_signature::id(),
slot,
&root_bank,
)
})
.unwrap_or_default()
{
packet.meta_mut().set_discard(true);
return;
}
}
// We can ignore Error::InvalidShredVariant because that
// basically means that the shred is of a variant which
Expand Down