Skip to content

Commit

Permalink
Addressed some feedback from Alessandro
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Jan 7, 2025
1 parent f29f0b4 commit a8cc8e9
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 86 deletions.
4 changes: 2 additions & 2 deletions core/src/tpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Tpu {
tpu_enable_udp: bool,
tpu_quic_server_config: QuicServerParams,
tpu_fwd_quic_server_config: QuicServerParams,
voe_quic_server_config: QuicServerParams,
vote_quic_server_config: QuicServerParams,
prioritization_fee_cache: &Arc<PrioritizationFeeCache>,
block_production_method: BlockProductionMethod,
enable_block_production_forwarding: bool,
Expand Down Expand Up @@ -174,7 +174,7 @@ impl Tpu {
vote_packet_sender.clone(),
exit.clone(),
staked_nodes.clone(),
voe_quic_server_config,
vote_quic_server_config,
)
.unwrap();

Expand Down
52 changes: 27 additions & 25 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,31 +494,33 @@ pub struct ValidatorTpuConfig {
pub vote_quic_server_config: QuicServerParams,
}

/// A convenient function to build a ValidatorTpuConfig for testing with good
/// default.
pub fn build_validator_tpu_config_for_test(tpu_enable_udp: bool) -> ValidatorTpuConfig {
let tpu_quic_server_config = QuicServerParams {
max_connections_per_ipaddr_per_min: 32,
..Default::default()
};
impl ValidatorTpuConfig {
/// A convenient function to build a ValidatorTpuConfig for testing with good
/// default.
pub fn new_for_tests(tpu_enable_udp: bool) -> Self {
let tpu_quic_server_config = QuicServerParams {
max_connections_per_ipaddr_per_min: 32,
..Default::default()
};

let tpu_fwd_quic_server_config = QuicServerParams {
max_connections_per_ipaddr_per_min: 32,
max_unstaked_connections: 0,
..Default::default()
};
let tpu_fwd_quic_server_config = QuicServerParams {
max_connections_per_ipaddr_per_min: 32,
max_unstaked_connections: 0,
..Default::default()
};

// vote and tpu_fwd share the same characteristics -- disallow non-staked connections:
let vote_quic_server_config = tpu_fwd_quic_server_config.clone();

// vote and tpu_fwd share the same characteristics -- disallow non-staked connections:
let vote_quic_server_config = tpu_fwd_quic_server_config.clone();

ValidatorTpuConfig {
use_quic: DEFAULT_TPU_USE_QUIC,
vote_use_quic: DEFAULT_VOTE_USE_QUIC,
tpu_connection_pool_size: DEFAULT_TPU_CONNECTION_POOL_SIZE,
tpu_enable_udp,
tpu_quic_server_config,
tpu_fwd_quic_server_config,
vote_quic_server_config,
ValidatorTpuConfig {
use_quic: DEFAULT_TPU_USE_QUIC,
vote_use_quic: DEFAULT_VOTE_USE_QUIC,
tpu_connection_pool_size: DEFAULT_TPU_CONNECTION_POOL_SIZE,
tpu_enable_udp,
tpu_quic_server_config,
tpu_fwd_quic_server_config,
vote_quic_server_config,
}
}
}

Expand Down Expand Up @@ -2800,7 +2802,7 @@ mod tests {
None, // rpc_to_plugin_manager_receiver
start_progress.clone(),
SocketAddrSpace::Unspecified,
build_validator_tpu_config_for_test(DEFAULT_TPU_ENABLE_UDP),
ValidatorTpuConfig::new_for_tests(DEFAULT_TPU_ENABLE_UDP),
Arc::new(RwLock::new(None)),
)
.expect("assume successful validator start");
Expand Down Expand Up @@ -3016,7 +3018,7 @@ mod tests {
None, // rpc_to_plugin_manager_receiver
Arc::new(RwLock::new(ValidatorStartProgress::default())),
SocketAddrSpace::Unspecified,
build_validator_tpu_config_for_test(DEFAULT_TPU_ENABLE_UDP),
ValidatorTpuConfig::new_for_tests(DEFAULT_TPU_ENABLE_UDP),
Arc::new(RwLock::new(None)),
)
.expect("assume successful validator start")
Expand Down
10 changes: 4 additions & 6 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use {
solana_client::connection_cache::ConnectionCache,
solana_core::{
consensus::tower_storage::FileTowerStorage,
validator::{
build_validator_tpu_config_for_test, Validator, ValidatorConfig, ValidatorStartProgress,
},
validator::{Validator, ValidatorConfig, ValidatorStartProgress, ValidatorTpuConfig},
},
solana_gossip::{
cluster_info::Node,
Expand Down Expand Up @@ -345,7 +343,7 @@ impl LocalCluster {
socket_addr_space,
// We are turning tpu_enable_udp to true in order to prevent concurrent local cluster tests
// to use the same QUIC ports due to SO_REUSEPORT.
build_validator_tpu_config_for_test(true),
ValidatorTpuConfig::new_for_tests(true),
Arc::new(RwLock::new(None)),
)
.expect("assume successful validator start");
Expand Down Expand Up @@ -549,7 +547,7 @@ impl LocalCluster {
None, // rpc_to_plugin_manager_receiver
Arc::new(RwLock::new(ValidatorStartProgress::default())),
socket_addr_space,
build_validator_tpu_config_for_test(DEFAULT_TPU_ENABLE_UDP),
ValidatorTpuConfig::new_for_tests(DEFAULT_TPU_ENABLE_UDP),
Arc::new(RwLock::new(None)),
)
.expect("assume successful validator start");
Expand Down Expand Up @@ -1079,7 +1077,7 @@ impl Cluster for LocalCluster {
None, // rpc_to_plugin_manager_receiver
Arc::new(RwLock::new(ValidatorStartProgress::default())),
socket_addr_space,
build_validator_tpu_config_for_test(DEFAULT_TPU_ENABLE_UDP),
ValidatorTpuConfig::new_for_tests(DEFAULT_TPU_ENABLE_UDP),
Arc::new(RwLock::new(None)),
)
.expect("assume successful validator start");
Expand Down
6 changes: 2 additions & 4 deletions test-validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use {
solana_core::{
admin_rpc_post_init::AdminRpcRequestMetadataPostInit,
consensus::tower_storage::TowerStorage,
validator::{
build_validator_tpu_config_for_test, Validator, ValidatorConfig, ValidatorStartProgress,
},
validator::{Validator, ValidatorConfig, ValidatorStartProgress, ValidatorTpuConfig},
},
solana_feature_set::FEATURE_NAMES,
solana_geyser_plugin_manager::{
Expand Down Expand Up @@ -1045,7 +1043,7 @@ impl TestValidator {
rpc_to_plugin_manager_receiver,
config.start_progress.clone(),
socket_addr_space,
build_validator_tpu_config_for_test(config.tpu_enable_udp),
ValidatorTpuConfig::new_for_tests(config.tpu_enable_udp),
config.admin_rpc_service_post_init.clone(),
)?);

Expand Down
4 changes: 2 additions & 2 deletions validator/src/admin_rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ mod tests {
},
solana_core::{
consensus::tower_storage::NullTowerStorage,
validator::{build_validator_tpu_config_for_test, Validator, ValidatorConfig},
validator::{Validator, ValidatorConfig, ValidatorTpuConfig},
},
solana_gossip::cluster_info::{ClusterInfo, Node},
solana_inline_spl::token,
Expand Down Expand Up @@ -1395,7 +1395,7 @@ mod tests {
None, // rpc_to_plugin_manager_receiver
start_progress.clone(),
SocketAddrSpace::Unspecified,
build_validator_tpu_config_for_test(DEFAULT_TPU_ENABLE_UDP),
ValidatorTpuConfig::new_for_tests(DEFAULT_TPU_ENABLE_UDP),
post_init,
)
.expect("assume successful validator start");
Expand Down
40 changes: 20 additions & 20 deletions validator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,37 +917,37 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> {
.help("Controls the max concurrent connections per IpAddr."),
)
.arg(
Arg::with_name("max_tpu_staked_connections")
.long("max-tpu-staked-connections")
Arg::with_name("tpu_max_staked_connections")
.long("tpu-max-staked-connections")
.takes_value(true)
.default_value(&default_args.max_tpu_staked_connections)
.default_value(&default_args.tpu_max_staked_connections)
.validator(is_parsable::<u32>)
.hidden(hidden_unless_forced())
.help("Controls the max concurrent connections for TPU from staked nodes."),
)
.arg(
Arg::with_name("max_tpu_unstaked_connections")
.long("max-tpu-unstaked-connections")
Arg::with_name("tpu_max_unstaked_connections")
.long("tpu-max-unstaked-connections")
.takes_value(true)
.default_value(&default_args.max_tpu_unstaked_connections)
.default_value(&default_args.tpu_max_unstaked_connections)
.validator(is_parsable::<u32>)
.hidden(hidden_unless_forced())
.help("Controls the max concurrent connections fort TPU from unstaked nodes."),
)
.arg(
Arg::with_name("max_fwd_staked_connections")
.long("max-fwd-staked-connections")
Arg::with_name("tpu_max_fwd_staked_connections")
.long("tpu-max-fwd-staked-connections")
.takes_value(true)
.default_value(&default_args.max_fwd_staked_connections)
.default_value(&default_args.tpu_max_fwd_staked_connections)
.validator(is_parsable::<u32>)
.hidden(hidden_unless_forced())
.help("Controls the max concurrent connections for TPU-forward from staked nodes."),
)
.arg(
Arg::with_name("max_fwd_unstaked_connections")
.long("max-fwd-unstaked-connections")
Arg::with_name("tpu_max_fwd_unstaked_connections")
.long("tpu-max-fwd-unstaked-connections")
.takes_value(true)
.default_value(&default_args.max_fwd_unstaked_connections)
.default_value(&default_args.tpu_max_fwd_unstaked_connections)
.validator(is_parsable::<u32>)
.hidden(hidden_unless_forced())
.help("Controls the max concurrent connections for TPU-forward from unstaked nodes."),
Expand Down Expand Up @@ -2363,10 +2363,10 @@ pub struct DefaultArgs {

pub tpu_max_connections_per_peer: String,
pub tpu_max_connections_per_ipaddr_per_minute: String,
pub max_tpu_staked_connections: String,
pub max_tpu_unstaked_connections: String,
pub max_fwd_staked_connections: String,
pub max_fwd_unstaked_connections: String,
pub tpu_max_staked_connections: String,
pub tpu_max_unstaked_connections: String,
pub tpu_max_fwd_staked_connections: String,
pub tpu_max_fwd_unstaked_connections: String,
pub tpu_max_streams_per_ms: String,

pub num_quic_endpoints: String,
Expand Down Expand Up @@ -2465,12 +2465,12 @@ impl DefaultArgs {
DEFAULT_MAX_CONNECTIONS_PER_IPADDR_PER_MINUTE.to_string(),
vote_use_quic: DEFAULT_VOTE_USE_QUIC.to_string(),
tpu_max_connections_per_peer: DEFAULT_MAX_QUIC_CONNECTIONS_PER_PEER.to_string(),
max_tpu_staked_connections: DEFAULT_MAX_STAKED_CONNECTIONS.to_string(),
max_tpu_unstaked_connections: DEFAULT_MAX_UNSTAKED_CONNECTIONS.to_string(),
max_fwd_staked_connections: DEFAULT_MAX_STAKED_CONNECTIONS
tpu_max_staked_connections: DEFAULT_MAX_STAKED_CONNECTIONS.to_string(),
tpu_max_unstaked_connections: DEFAULT_MAX_UNSTAKED_CONNECTIONS.to_string(),
tpu_max_fwd_staked_connections: DEFAULT_MAX_STAKED_CONNECTIONS
.saturating_add(DEFAULT_MAX_UNSTAKED_CONNECTIONS)
.to_string(),
max_fwd_unstaked_connections: 0.to_string(),
tpu_max_fwd_unstaked_connections: 0.to_string(),
tpu_max_streams_per_ms: DEFAULT_MAX_STREAMS_PER_MS.to_string(),
num_quic_endpoints: DEFAULT_QUIC_ENDPOINTS.to_string(),
rpc_max_request_body_size: MAX_REQUEST_BODY_SIZE.to_string(),
Expand Down
21 changes: 11 additions & 10 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1965,13 +1965,14 @@ pub fn main() {

let tpu_max_connections_per_peer =
value_t_or_exit!(matches, "tpu_max_connections_per_peer", u64);
let max_tpu_staked_connections = value_t_or_exit!(matches, "max_tpu_staked_connections", u64);
let max_tpu_unstaked_connections =
value_t_or_exit!(matches, "max_tpu_unstaked_connections", u64);
let tpu_max_staked_connections = value_t_or_exit!(matches, "tpu_max_staked_connections", u64);
let tpu_max_unstaked_connections =
value_t_or_exit!(matches, "tpu_max_unstaked_connections", u64);

let max_fwd_staked_connections = value_t_or_exit!(matches, "max_fwd_staked_connections", u64);
let max_fwd_unstaked_connections =
value_t_or_exit!(matches, "max_fwd_unstaked_connections", u64);
let tpu_max_fwd_staked_connections =
value_t_or_exit!(matches, "tpu_max_fwd_staked_connections", u64);
let tpu_max_fwd_unstaked_connections =
value_t_or_exit!(matches, "tpu_max_fwd_unstaked_connections", u64);

let tpu_max_connections_per_ipaddr_per_minute: u64 =
value_t_or_exit!(matches, "tpu_max_connections_per_ipaddr_per_minute", u64);
Expand Down Expand Up @@ -2082,8 +2083,8 @@ pub fn main() {

let tpu_quic_server_config = QuicServerParams {
max_connections_per_peer: tpu_max_connections_per_peer.try_into().unwrap(),
max_staked_connections: max_tpu_staked_connections.try_into().unwrap(),
max_unstaked_connections: max_tpu_unstaked_connections.try_into().unwrap(),
max_staked_connections: tpu_max_staked_connections.try_into().unwrap(),
max_unstaked_connections: tpu_max_unstaked_connections.try_into().unwrap(),
max_streams_per_ms,
max_connections_per_ipaddr_per_min: tpu_max_connections_per_ipaddr_per_minute,
coalesce: tpu_coalesce,
Expand All @@ -2092,8 +2093,8 @@ pub fn main() {

let tpu_fwd_quic_server_config = QuicServerParams {
max_connections_per_peer: tpu_max_connections_per_peer.try_into().unwrap(),
max_staked_connections: max_fwd_staked_connections.try_into().unwrap(),
max_unstaked_connections: max_fwd_unstaked_connections.try_into().unwrap(),
max_staked_connections: tpu_max_fwd_staked_connections.try_into().unwrap(),
max_unstaked_connections: tpu_max_fwd_unstaked_connections.try_into().unwrap(),
max_streams_per_ms,
max_connections_per_ipaddr_per_min: tpu_max_connections_per_ipaddr_per_minute,
coalesce: tpu_coalesce,
Expand Down
16 changes: 7 additions & 9 deletions vortexor/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ use {
solana_clap_utils::input_validators::{is_keypair_or_ask_keyword, is_parsable},
solana_net_utils::{MINIMUM_VALIDATOR_PORT_RANGE_WIDTH, VALIDATOR_PORT_RANGE},
solana_sdk::quic::QUIC_PORT_OFFSET,
solana_streamer::{
nonblocking::quic::{
DEFAULT_MAX_CONNECTIONS_PER_IPADDR_PER_MINUTE, DEFAULT_MAX_STREAMS_PER_MS,
},
quic::{MAX_STAKED_CONNECTIONS, MAX_UNSTAKED_CONNECTIONS},
solana_streamer::quic::{
DEFAULT_MAX_CONNECTIONS_PER_IPADDR_PER_MINUTE, DEFAULT_MAX_STAKED_CONNECTIONS,
DEFAULT_MAX_STREAMS_PER_MS, DEFAULT_MAX_UNSTAKED_CONNECTIONS,
},
};

Expand All @@ -33,10 +31,10 @@ impl Default for DefaultArgs {
bind_address: "0.0.0.0".to_string(),
dynamic_port_range: format!("{}-{}", VALIDATOR_PORT_RANGE.0, VALIDATOR_PORT_RANGE.1),
max_connections_per_peer: DEFAULT_MAX_QUIC_CONNECTIONS_PER_PEER.to_string(),
max_tpu_staked_connections: MAX_STAKED_CONNECTIONS.to_string(),
max_tpu_unstaked_connections: MAX_UNSTAKED_CONNECTIONS.to_string(),
max_fwd_staked_connections: MAX_STAKED_CONNECTIONS
.saturating_add(MAX_UNSTAKED_CONNECTIONS)
max_tpu_staked_connections: DEFAULT_MAX_STAKED_CONNECTIONS.to_string(),
max_tpu_unstaked_connections: DEFAULT_MAX_UNSTAKED_CONNECTIONS.to_string(),
max_fwd_staked_connections: DEFAULT_MAX_STAKED_CONNECTIONS
.saturating_add(DEFAULT_MAX_UNSTAKED_CONNECTIONS)
.to_string(),
max_fwd_unstaked_connections: 0.to_string(),
max_streams_per_ms: DEFAULT_MAX_STREAMS_PER_MS.to_string(),
Expand Down
16 changes: 8 additions & 8 deletions vortexor/tests/vortexor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use {
solana_net_utils::VALIDATOR_PORT_RANGE,
solana_sdk::{net::DEFAULT_TPU_COALESCE, pubkey::Pubkey, signature::Keypair, signer::Signer},
solana_streamer::{
nonblocking::{
quic::{DEFAULT_MAX_CONNECTIONS_PER_IPADDR_PER_MINUTE, DEFAULT_MAX_STREAMS_PER_MS},
testing_utilities::check_multiple_streams,
nonblocking::testing_utilities::check_multiple_streams,
quic::{
DEFAULT_MAX_CONNECTIONS_PER_IPADDR_PER_MINUTE, DEFAULT_MAX_STAKED_CONNECTIONS,
DEFAULT_MAX_STREAMS_PER_MS, DEFAULT_MAX_UNSTAKED_CONNECTIONS,
},
quic::{MAX_STAKED_CONNECTIONS, MAX_UNSTAKED_CONNECTIONS},
streamer::StakedNodes,
},
solana_vortexor::{
Expand Down Expand Up @@ -54,10 +54,10 @@ async fn test_vortexor() {
tpu_sender,
tpu_fwd_sender,
DEFAULT_MAX_QUIC_CONNECTIONS_PER_PEER.try_into().unwrap(),
MAX_STAKED_CONNECTIONS.try_into().unwrap(),
MAX_UNSTAKED_CONNECTIONS.try_into().unwrap(),
MAX_STAKED_CONNECTIONS
.saturating_add(MAX_UNSTAKED_CONNECTIONS)
DEFAULT_MAX_STAKED_CONNECTIONS.try_into().unwrap(),
DEFAULT_MAX_UNSTAKED_CONNECTIONS.try_into().unwrap(),
DEFAULT_MAX_STAKED_CONNECTIONS
.saturating_add(DEFAULT_MAX_UNSTAKED_CONNECTIONS)
.try_into()
.unwrap(), // max_fwd_staked_connections
0, // max_fwd_unstaked_connections
Expand Down

0 comments on commit a8cc8e9

Please sign in to comment.