Skip to content

Commit

Permalink
core: disable quic servers on mainnet-beta
Browse files Browse the repository at this point in the history
(cherry picked from commit a5f290a)

# Conflicts:
#	core/src/validator.rs
#	local-cluster/src/validator_configs.rs
#	validator/src/main.rs
  • Loading branch information
t-nelson authored and mergify[bot] committed Jun 18, 2022
1 parent 9b2420f commit f3f2590
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 31 deletions.
69 changes: 39 additions & 30 deletions core/src/tpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ pub struct Tpu {
banking_stage: BankingStage,
cluster_info_vote_listener: ClusterInfoVoteListener,
broadcast_stage: BroadcastStage,
tpu_quic_t: thread::JoinHandle<()>,
tpu_forwards_quic_t: thread::JoinHandle<()>,
tpu_quic_t: Option<thread::JoinHandle<()>>,
tpu_forwards_quic_t: Option<thread::JoinHandle<()>>,
find_packet_sender_stake_stage: FindPacketSenderStakeStage,
vote_find_packet_sender_stake_stage: FindPacketSenderStakeStage,
staked_nodes_updater_service: StakedNodesUpdaterService,
Expand Down Expand Up @@ -99,6 +99,7 @@ impl Tpu {
cost_model: &Arc<RwLock<CostModel>>,
connection_cache: &Arc<ConnectionCache>,
keypair: &Keypair,
enable_quic_servers: bool,
) -> Self {
let TpuSockets {
transactions: transactions_sockets,
Expand Down Expand Up @@ -156,33 +157,37 @@ impl Tpu {
let (verified_sender, verified_receiver) = unbounded();

let stats = Arc::new(StreamStats::default());
let tpu_quic_t = spawn_server(
transactions_quic_sockets,
keypair,
cluster_info.my_contact_info().tpu.ip(),
packet_sender,
exit.clone(),
MAX_QUIC_CONNECTIONS_PER_IP,
staked_nodes.clone(),
MAX_STAKED_CONNECTIONS,
MAX_UNSTAKED_CONNECTIONS,
stats.clone(),
)
.unwrap();
let tpu_quic_t = enable_quic_servers.then(|| {
spawn_server(
transactions_quic_sockets,
keypair,
cluster_info.my_contact_info().tpu.ip(),
packet_sender,
exit.clone(),
MAX_QUIC_CONNECTIONS_PER_IP,
staked_nodes.clone(),
MAX_STAKED_CONNECTIONS,
MAX_UNSTAKED_CONNECTIONS,
stats.clone(),
)
.unwrap()
});

let tpu_forwards_quic_t = spawn_server(
transactions_forwards_quic_sockets,
keypair,
cluster_info.my_contact_info().tpu_forwards.ip(),
forwarded_packet_sender,
exit.clone(),
MAX_QUIC_CONNECTIONS_PER_IP,
staked_nodes,
MAX_STAKED_CONNECTIONS.saturating_add(MAX_UNSTAKED_CONNECTIONS),
0, // Prevent unstaked nodes from forwarding transactions
stats,
)
.unwrap();
let tpu_forwards_quic_t = enable_quic_servers.then(|| {
spawn_server(
transactions_forwards_quic_sockets,
keypair,
cluster_info.my_contact_info().tpu_forwards.ip(),
forwarded_packet_sender,
exit.clone(),
MAX_QUIC_CONNECTIONS_PER_IP,
staked_nodes,
MAX_STAKED_CONNECTIONS.saturating_add(MAX_UNSTAKED_CONNECTIONS),
0, // Prevent unstaked nodes from forwarding transactions
stats,
)
.unwrap()
});

let sigverify_stage = {
let verifier = TransactionSigVerifier::new(verified_sender);
Expand Down Expand Up @@ -284,8 +289,12 @@ impl Tpu {
self.vote_find_packet_sender_stake_stage.join(),
self.staked_nodes_updater_service.join(),
];
self.tpu_quic_t.join()?;
self.tpu_forwards_quic_t.join()?;
if let Some(tpu_quic_t) = self.tpu_quic_t {
tpu_quic_t.join()?;
}
if let Some(tpu_forwards_quic_t) = self.tpu_forwards_quic_t {
tpu_forwards_quic_t.join()?;
}
let broadcast_result = self.broadcast_stage.join();
for result in results {
result?;
Expand Down
25 changes: 24 additions & 1 deletion core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ use {
clock::Slot,
epoch_schedule::MAX_LEADER_SCHEDULE_EPOCH_OFFSET,
exit::Exit,
genesis_config::GenesisConfig,
genesis_config::{ClusterType, GenesisConfig},
hash::Hash,
pubkey::Pubkey,
shred_version::compute_shred_version,
Expand Down Expand Up @@ -172,6 +172,11 @@ pub struct ValidatorConfig {
pub accounts_shrink_ratio: AccountShrinkThreshold,
pub wait_to_vote_slot: Option<Slot>,
pub ledger_column_options: LedgerColumnOptions,
<<<<<<< HEAD
=======
pub runtime_config: RuntimeConfig,
pub enable_quic_servers: bool,
>>>>>>> a5f290a66 (core: disable quic servers on mainnet-beta)
}

impl Default for ValidatorConfig {
Expand Down Expand Up @@ -235,6 +240,11 @@ impl Default for ValidatorConfig {
accounts_db_config: None,
wait_to_vote_slot: None,
ledger_column_options: LedgerColumnOptions::default(),
<<<<<<< HEAD
=======
runtime_config: RuntimeConfig::default(),
enable_quic_servers: false,
>>>>>>> a5f290a66 (core: disable quic servers on mainnet-beta)
}
}
}
Expand Down Expand Up @@ -947,6 +957,18 @@ impl Validator {
&connection_cache,
);

let enable_quic_servers = if genesis_config.cluster_type == ClusterType::MainnetBeta {
config.enable_quic_servers
} else {
if config.enable_quic_servers {
warn!(
"ignoring --enable-quic-servers. QUIC is always enabled for cluster type: {:?}",
genesis_config.cluster_type
);
}
true
};

let tpu = Tpu::new(
&cluster_info,
&poh_recorder,
Expand Down Expand Up @@ -978,6 +1000,7 @@ impl Validator {
&cost_model,
&connection_cache,
&identity_keypair,
enable_quic_servers,
);

datapoint_info!(
Expand Down
5 changes: 5 additions & 0 deletions local-cluster/src/validator_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
accounts_db_config: config.accounts_db_config.clone(),
wait_to_vote_slot: config.wait_to_vote_slot,
ledger_column_options: config.ledger_column_options.clone(),
<<<<<<< HEAD
=======
runtime_config: config.runtime_config.clone(),
enable_quic_servers: config.enable_quic_servers,
>>>>>>> a5f290a66 (core: disable quic servers on mainnet-beta)
}
}

Expand Down
14 changes: 14 additions & 0 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,11 @@ pub fn main() {
.takes_value(false)
.help("Use QUIC to send transactions."),
)
.arg(
Arg::with_name("enable_quic_servers")
.hidden(true)
.long("enable-quic-servers")
)
.arg(
Arg::with_name("tpu_connection_pool_size")
.long("tpu-connection-pool-size")
Expand Down Expand Up @@ -2165,6 +2170,7 @@ pub fn main() {
let accounts_shrink_optimize_total_space =
value_t_or_exit!(matches, "accounts_shrink_optimize_total_space", bool);
let tpu_use_quic = matches.is_present("tpu_use_quic");
let enable_quic_servers = matches.is_present("enable_quic_servers");
let tpu_connection_pool_size = value_t_or_exit!(matches, "tpu_connection_pool_size", usize);

let shrink_ratio = value_t_or_exit!(matches, "accounts_shrink_ratio", f64);
Expand Down Expand Up @@ -2502,6 +2508,14 @@ pub fn main() {
tpu_coalesce_ms,
no_wait_for_vote_to_start_leader: matches.is_present("no_wait_for_vote_to_start_leader"),
accounts_shrink_ratio,
<<<<<<< HEAD
=======
runtime_config: RuntimeConfig {
bpf_jit: !matches.is_present("no_bpf_jit"),
..RuntimeConfig::default()
},
enable_quic_servers,
>>>>>>> a5f290a66 (core: disable quic servers on mainnet-beta)
..ValidatorConfig::default()
};

Expand Down

0 comments on commit f3f2590

Please sign in to comment.