From c848b208b78bebce24e55dcfaafd0701d68d3356 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 1 May 2022 13:10:19 +0000 Subject: [PATCH] Check if quic is enabled before warming up quic connections (backport #24821) (#24869) * Check if quic is enabled before warming up quic connections (#24821) * Check if quic is enabled before warming up quic connections * fix after rebase * don't start warmup service if quic not enabled * fix test (cherry picked from commit 88c16c0176c09952bf7eae4093e970e4f8617703) # Conflicts: # core/src/tvu.rs # core/src/validator.rs * resolve merge conflicts Co-authored-by: Pankaj Garg --- core/src/tvu.rs | 20 +++++++++++++++----- core/src/validator.rs | 4 ++++ local-cluster/src/local_cluster.rs | 3 +++ test-validator/src/lib.rs | 1 + validator/src/main.rs | 1 + 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/core/src/tvu.rs b/core/src/tvu.rs index 5a4e8585c534b6..63f1f55b849c82 100644 --- a/core/src/tvu.rs +++ b/core/src/tvu.rs @@ -77,7 +77,7 @@ pub struct Tvu { accounts_hash_verifier: AccountsHashVerifier, cost_update_service: CostUpdateService, voting_service: VotingService, - warm_quic_cache_service: WarmQuicCacheService, + warm_quic_cache_service: Option, drop_bank_service: DropBankService, transaction_cost_metrics_service: TransactionCostMetricsService, } @@ -151,6 +151,7 @@ impl Tvu { block_metadata_notifier: Option, wait_to_vote_slot: Option, pruned_banks_receiver: DroppedSlotsReceiver, + use_quic: bool, ) -> Self { let TvuSockets { repair: repair_socket, @@ -287,9 +288,15 @@ impl Tvu { bank_forks.clone(), ); - let warm_quic_cache_service = - WarmQuicCacheService::new(cluster_info.clone(), poh_recorder.clone(), exit.clone()); - + let warm_quic_cache_service = if use_quic { + Some(WarmQuicCacheService::new( + cluster_info.clone(), + poh_recorder.clone(), + exit.clone(), + )) + } else { + None + }; let (cost_update_sender, cost_update_receiver) = unbounded(); let cost_update_service = CostUpdateService::new(blockstore.clone(), cost_model.clone(), cost_update_receiver); @@ -383,7 +390,9 @@ impl Tvu { self.accounts_hash_verifier.join()?; self.cost_update_service.join()?; self.voting_service.join()?; - self.warm_quic_cache_service.join()?; + if let Some(warmup_service) = self.warm_quic_cache_service { + warmup_service.join()?; + } self.drop_bank_service.join()?; self.transaction_cost_metrics_service.join()?; Ok(()) @@ -508,6 +517,7 @@ pub mod tests { None, None, pruned_banks_receiver, + false, // use_quic ); exit.store(true, Ordering::Relaxed); tvu.join().unwrap(); diff --git a/core/src/validator.rs b/core/src/validator.rs index d956578ab69dd8..9a288f09d778d4 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -369,6 +369,7 @@ impl Validator { should_check_duplicate_instance: bool, start_progress: Arc>, socket_addr_space: SocketAddrSpace, + use_quic: bool, ) -> Self { let id = identity_keypair.pubkey(); assert_eq!(id, node.info.id); @@ -931,6 +932,7 @@ impl Validator { block_metadata_notifier, config.wait_to_vote_slot, pruned_banks_receiver, + use_quic, ); let tpu = Tpu::new( @@ -1843,6 +1845,7 @@ mod tests { true, // should_check_duplicate_instance start_progress.clone(), SocketAddrSpace::Unspecified, + false, // use_quic ); assert_eq!( *start_progress.read().unwrap(), @@ -1924,6 +1927,7 @@ mod tests { true, // should_check_duplicate_instance Arc::new(RwLock::new(ValidatorStartProgress::default())), SocketAddrSpace::Unspecified, + false, // use_quic ) }) .collect(); diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index da1e8df0ec500c..a30380290e43cb 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -248,6 +248,7 @@ impl LocalCluster { true, // should_check_duplicate_instance Arc::new(RwLock::new(ValidatorStartProgress::default())), socket_addr_space, + false, // use_quic ); let mut validators = HashMap::new(); @@ -440,6 +441,7 @@ impl LocalCluster { true, // should_check_duplicate_instance Arc::new(RwLock::new(ValidatorStartProgress::default())), socket_addr_space, + false, // use_quic ); let validator_pubkey = validator_keypair.pubkey(); @@ -774,6 +776,7 @@ impl Cluster for LocalCluster { true, // should_check_duplicate_instance Arc::new(RwLock::new(ValidatorStartProgress::default())), socket_addr_space, + false, // use_quic ); cluster_validator_info.validator = Some(restarted_node); cluster_validator_info diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index 4047bc8fb4e252..c5ede9c3c78649 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -722,6 +722,7 @@ impl TestValidator { true, // should_check_duplicate_instance config.start_progress.clone(), socket_addr_space, + false, // use_quic )); // Needed to avoid panics in `solana-responder-gossip` in tests that create a number of diff --git a/validator/src/main.rs b/validator/src/main.rs index d15bb3a4f08a18..2d2cd2be2cf5a2 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -2857,6 +2857,7 @@ pub fn main() { should_check_duplicate_instance, start_progress, socket_addr_space, + tpu_use_quic, ); *admin_service_post_init.write().unwrap() = Some(admin_rpc_service::AdminRpcRequestMetadataPostInit {