From e25812a4106e9ae7b1f3dd2dc608e80ee9de688d Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Thu, 27 Jun 2024 14:00:24 +0000 Subject: [PATCH 1/2] adds feature-gate code to enforce retransmitter signature verification (#1840) (cherry picked from commit 79cb077f10cccbdd6a56ee5c7ed95d47fba30cbd) # Conflicts: # sdk/src/feature_set.rs --- sdk/src/feature_set.rs | 9 +++++++++ turbine/src/sigverify_shreds.rs | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index c0ff5eec0c892c..29d6277fe6c447 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -829,12 +829,17 @@ pub mod zk_elgamal_proof_program_enabled { solana_sdk::declare_id!("zkhiy5oLowR7HY4zogXjCjeMXyruLqBwSWH21qcFtnv"); } +<<<<<<< HEAD pub mod move_stake_and_move_lamports_ixs { solana_sdk::declare_id!("7bTK6Jis8Xpfrs8ZoUfiMDPazTcdPcTWheZFJTA5Z6X4"); } pub mod ed25519_precompile_verify_strict { solana_sdk::declare_id!("ed9tNscbWLYBooxWA7FE2B5KHWs8A6sxfY8EzezEcoo"); +======= +pub mod verify_retransmitter_signature { + solana_sdk::declare_id!("BZ5g4hRbu5hLQQBdPyo2z9icGyJ8Khiyj3QS6dhWijTb"); +>>>>>>> 79cb077f10 (adds feature-gate code to enforce retransmitter signature verification (#1840)) } lazy_static! { @@ -1039,8 +1044,12 @@ lazy_static! { (enable_get_epoch_stake_syscall::id(), "Enable syscall: sol_get_epoch_stake #884"), (migrate_address_lookup_table_program_to_core_bpf::id(), "Migrate Address Lookup Table program to Core BPF #1651"), (zk_elgamal_proof_program_enabled::id(), "Enable ZkElGamalProof program SIMD-0153"), +<<<<<<< HEAD (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"), +>>>>>>> 79cb077f10 (adds feature-gate code to enforce retransmitter signature verification (#1840)) /*************** ADD NEW FEATURES HERE ***************/ ] .iter() diff --git a/turbine/src/sigverify_shreds.rs b/turbine/src/sigverify_shreds.rs index 88eaecd006764d..320b95ac24188e 100644 --- a/turbine/src/sigverify_shreds.rs +++ b/turbine/src/sigverify_shreds.rs @@ -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}, @@ -19,6 +19,7 @@ use { }, solana_sdk::{ clock::Slot, + feature_set, pubkey::Pubkey, signature::{Keypair, Signer}, }, @@ -201,6 +202,19 @@ fn run_shred_sigverify( 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 From c8edd762f55ac9de338943101e047a05d6561564 Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Fri, 2 Aug 2024 13:05:39 -0500 Subject: [PATCH 2/2] resolves merge conflicts --- sdk/src/feature_set.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index 29d6277fe6c447..21c48305498923 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -829,17 +829,16 @@ pub mod zk_elgamal_proof_program_enabled { solana_sdk::declare_id!("zkhiy5oLowR7HY4zogXjCjeMXyruLqBwSWH21qcFtnv"); } -<<<<<<< HEAD pub mod move_stake_and_move_lamports_ixs { solana_sdk::declare_id!("7bTK6Jis8Xpfrs8ZoUfiMDPazTcdPcTWheZFJTA5Z6X4"); } pub mod ed25519_precompile_verify_strict { solana_sdk::declare_id!("ed9tNscbWLYBooxWA7FE2B5KHWs8A6sxfY8EzezEcoo"); -======= +} + pub mod verify_retransmitter_signature { solana_sdk::declare_id!("BZ5g4hRbu5hLQQBdPyo2z9icGyJ8Khiyj3QS6dhWijTb"); ->>>>>>> 79cb077f10 (adds feature-gate code to enforce retransmitter signature verification (#1840)) } lazy_static! { @@ -1044,12 +1043,9 @@ lazy_static! { (enable_get_epoch_stake_syscall::id(), "Enable syscall: sol_get_epoch_stake #884"), (migrate_address_lookup_table_program_to_core_bpf::id(), "Migrate Address Lookup Table program to Core BPF #1651"), (zk_elgamal_proof_program_enabled::id(), "Enable ZkElGamalProof program SIMD-0153"), -<<<<<<< HEAD (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"), ->>>>>>> 79cb077f10 (adds feature-gate code to enforce retransmitter signature verification (#1840)) /*************** ADD NEW FEATURES HERE ***************/ ] .iter()