瀏覽代碼

adds feature-gate code to enforce retransmitter signature verification (#1840)

behzad nouri 1 年之前
父節點
當前提交
79cb077f10
共有 2 個文件被更改,包括 20 次插入1 次删除
  1. 5 0
      sdk/src/feature_set.rs
  2. 15 1
      turbine/src/sigverify_shreds.rs

+ 5 - 0
sdk/src/feature_set.rs

@@ -828,6 +828,10 @@ pub mod zk_elgamal_proof_program_enabled {
     solana_sdk::declare_id!("zkhiy5oLowR7HY4zogXjCjeMXyruLqBwSWH21qcFtnv");
 }
 
+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> = [
@@ -1030,6 +1034,7 @@ 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"),
+        (verify_retransmitter_signature::id(), "Verify retransmitter signature #1840"),
         /*************** ADD NEW FEATURES HERE ***************/
     ]
     .iter()

+ 15 - 1
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<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