From 48283161c37cbb285f7df3ba82d4606e2ea94b62 Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Thu, 15 Oct 2020 20:54:21 +0000 Subject: [PATCH] passes through feature-set to gossip requests handling (#12878) * passes through feature-set to down to gossip requests handling * takes the feature-set from root_bank instead of working_bank --- core/src/cluster_info.rs | 27 ++++++++++++++++++++++++--- runtime/src/feature_set.rs | 5 +++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/core/src/cluster_info.rs b/core/src/cluster_info.rs index 58bb1c2cc7..273752e779 100644 --- a/core/src/cluster_info.rs +++ b/core/src/cluster_info.rs @@ -52,6 +52,7 @@ use solana_perf::packet::{ }; use solana_rayon_threadlimit::get_thread_count; use solana_runtime::bank_forks::BankForks; +use solana_runtime::feature_set::{self, FeatureSet}; use solana_sdk::hash::Hash; use solana_sdk::{ clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH}, @@ -1651,6 +1652,7 @@ impl ClusterInfo { stakes: &HashMap, packets: Packets, response_sender: &PacketSender, + feature_set: Option<&FeatureSet>, epoch_time_ms: u64, ) { // iter over the packets, collect pulls separately and process everything else @@ -1781,7 +1783,7 @@ impl ClusterInfo { self.stats .pull_requests_count .add_relaxed(gossip_pull_data.len() as u64); - let rsp = self.handle_pull_requests(recycler, gossip_pull_data, stakes); + let rsp = self.handle_pull_requests(recycler, gossip_pull_data, stakes, feature_set); if let Some(rsp) = rsp { let _ignore_disconnect = response_sender.send(rsp); } @@ -1809,7 +1811,13 @@ impl ClusterInfo { recycler: &PacketsRecycler, requests: Vec, stakes: &HashMap, + feature_set: Option<&FeatureSet>, ) -> Option { + if matches!(feature_set, Some(feature_set) if + feature_set.is_active(&feature_set::pull_request_ping_pong_check::id())) + { + // TODO: add ping-pong check on pull-request addresses. + } // split the requests into addrs and filters let mut caller_and_filters = vec![]; let mut addrs = vec![]; @@ -2114,12 +2122,13 @@ impl ClusterInfo { recycler: &PacketsRecycler, response_sender: &PacketSender, stakes: HashMap, + feature_set: Option<&FeatureSet>, epoch_time_ms: u64, ) { let sender = response_sender.clone(); thread_pool.install(|| { requests.into_par_iter().for_each_with(sender, |s, reqs| { - self.handle_packets(&recycler, &stakes, reqs, s, epoch_time_ms) + self.handle_packets(&recycler, &stakes, reqs, s, feature_set, epoch_time_ms) }); }); } @@ -2153,13 +2162,25 @@ impl ClusterInfo { } let (stakes, epoch_time_ms) = Self::get_stakes_and_epoch_time(bank_forks); - + // Using root_bank instead of working_bank here so that an enbaled + // feature does not roll back (if the feature happens to get enabled in + // a minority fork). + let feature_set = bank_forks.map(|bank_forks| { + bank_forks + .read() + .unwrap() + .root_bank() + .deref() + .feature_set + .clone() + }); self.process_packets( requests, thread_pool, recycler, response_sender, stakes, + feature_set.as_deref(), epoch_time_ms, ); diff --git a/runtime/src/feature_set.rs b/runtime/src/feature_set.rs index 7e08111c91..2450035ab2 100644 --- a/runtime/src/feature_set.rs +++ b/runtime/src/feature_set.rs @@ -69,6 +69,10 @@ pub mod pubkey_log_syscall_enabled { solana_sdk::declare_id!("MoqiU1vryuCGQSxFKA1SZ316JdLEFFhoAu6cKUNk7dN"); } +pub mod pull_request_ping_pong_check { + solana_sdk::declare_id!("5RzEHTnf6D7JPZCvwEzjM19kzBsyjSU3HoMfXaQmVgnZ"); +} + lazy_static! { /// Map of feature identifiers to user-visible description pub static ref FEATURE_NAMES: HashMap = [ @@ -88,6 +92,7 @@ lazy_static! { (timestamp_correction::id(), "correct bank timestamps"), (cumulative_rent_related_fixes::id(), "rent fixes (#10206, #10468, #11342)"), (pubkey_log_syscall_enabled::id(), "pubkey log syscall"), + (pull_request_ping_pong_check::id(), "ping-pong packet check #12794"), /*************** ADD NEW FEATURES HERE ***************/ ] .iter()