Skip to content

Commit

Permalink
Check if quic is enabled before warming up quic connections (backport #…
Browse files Browse the repository at this point in the history
…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 88c16c0)

# Conflicts:
#	core/src/tvu.rs
#	core/src/validator.rs

* resolve merge conflicts

Co-authored-by: Pankaj Garg <[email protected]>
  • Loading branch information
mergify[bot] and pgarg66 authored May 1, 2022
1 parent 9bbb00b commit c848b20
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
20 changes: 15 additions & 5 deletions core/src/tvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<WarmQuicCacheService>,
drop_bank_service: DropBankService,
transaction_cost_metrics_service: TransactionCostMetricsService,
}
Expand Down Expand Up @@ -151,6 +151,7 @@ impl Tvu {
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
wait_to_vote_slot: Option<Slot>,
pruned_banks_receiver: DroppedSlotsReceiver,
use_quic: bool,
) -> Self {
let TvuSockets {
repair: repair_socket,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -508,6 +517,7 @@ pub mod tests {
None,
None,
pruned_banks_receiver,
false, // use_quic
);
exit.store(true, Ordering::Relaxed);
tvu.join().unwrap();
Expand Down
4 changes: 4 additions & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ impl Validator {
should_check_duplicate_instance: bool,
start_progress: Arc<RwLock<ValidatorStartProgress>>,
socket_addr_space: SocketAddrSpace,
use_quic: bool,
) -> Self {
let id = identity_keypair.pubkey();
assert_eq!(id, node.info.id);
Expand Down Expand Up @@ -931,6 +932,7 @@ impl Validator {
block_metadata_notifier,
config.wait_to_vote_slot,
pruned_banks_receiver,
use_quic,
);

let tpu = Tpu::new(
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -1924,6 +1927,7 @@ mod tests {
true, // should_check_duplicate_instance
Arc::new(RwLock::new(ValidatorStartProgress::default())),
SocketAddrSpace::Unspecified,
false, // use_quic
)
})
.collect();
Expand Down
3 changes: 3 additions & 0 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test-validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c848b20

Please sign in to comment.