diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs index 03ac2dafb4..df4b2bd98e 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs @@ -181,7 +181,7 @@ struct DsnArgs { #[arg(long)] reserved_peers: Vec, /// Defines max established incoming connection limit. - #[arg(long, default_value_t = 50)] + #[arg(long, default_value_t = 300)] in_connections: u32, /// Defines max established outgoing swarm connection limit. #[arg(long, default_value_t = 100)] @@ -192,9 +192,6 @@ struct DsnArgs { /// Defines max pending outgoing swarm connection limit. #[arg(long, default_value_t = 100)] pending_out_connections: u32, - /// Defines target total (in and out) connection number that should be maintained. - #[arg(long, default_value_t = 15)] - target_connections: u32, /// Known external addresses #[arg(long, alias = "external-address")] external_addresses: Vec, diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs index cf275e7975..d3340b74b5 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs @@ -25,6 +25,8 @@ use tracing::{debug, error, info, Instrument}; /// /// Must be the same as RPC limit since all requests go to the node anyway. const SEGMENT_HEADER_NUMBER_LIMIT: u64 = MAX_SEGMENT_HEADERS_PER_REQUEST as u64; +/// Should be sufficient number of target connections for everyone, limits are higher +const TARGET_CONNECTIONS: u32 = 15; #[allow(clippy::type_complexity, clippy::too_many_arguments)] pub(super) fn configure_dsn( @@ -40,7 +42,6 @@ pub(super) fn configure_dsn( out_connections, pending_in_connections, pending_out_connections, - target_connections, external_addresses, disable_bootstrap_on_start, }: DsnArgs, @@ -190,11 +191,11 @@ pub(super) fn configure_dsn( special_connected_peers_handler: Some(Arc::new(PeerInfo::is_farmer)), // Do not have any target for general peers general_connected_peers_target: 0, - special_connected_peers_target: target_connections, + special_connected_peers_target: TARGET_CONNECTIONS, // Allow up to quarter of incoming connections to be maintained general_connected_peers_limit: in_connections / 4, // Allow to maintain some extra farmer connections beyond direct interest too - special_connected_peers_limit: target_connections + in_connections / 4, + special_connected_peers_limit: TARGET_CONNECTIONS + in_connections / 4, bootstrap_addresses: bootstrap_nodes, kademlia_mode: KademliaMode::Dynamic, external_addresses, diff --git a/crates/subspace-node/src/bin/subspace-node.rs b/crates/subspace-node/src/bin/subspace-node.rs index 4836b507a5..b822c6e66d 100644 --- a/crates/subspace-node/src/bin/subspace-node.rs +++ b/crates/subspace-node/src/bin/subspace-node.rs @@ -514,7 +514,6 @@ fn main() -> Result<(), Error> { max_out_connections: cli.dsn_out_connections, max_pending_in_connections: cli.dsn_pending_in_connections, max_pending_out_connections: cli.dsn_pending_out_connections, - target_connections: cli.dsn_target_connections, external_addresses: cli.dsn_external_addresses, // Override initial Kademlia bootstrapping with --dev disable_bootstrap_on_start: cli.dsn_disable_bootstrap_on_start diff --git a/crates/subspace-node/src/lib.rs b/crates/subspace-node/src/lib.rs index 24c4186793..a465e47931 100644 --- a/crates/subspace-node/src/lib.rs +++ b/crates/subspace-node/src/lib.rs @@ -258,10 +258,6 @@ pub struct Cli { #[arg(long, default_value_t = 150)] pub dsn_pending_out_connections: u32, - /// Defines target total (in and out) connection number for DSN that should be maintained. - #[arg(long, default_value_t = 15)] - pub dsn_target_connections: u32, - /// Determines whether we allow keeping non-global (private, shared, loopback..) addresses /// in Kademlia DHT for the DSN. #[arg(long, default_value_t = false)] diff --git a/crates/subspace-service/src/dsn.rs b/crates/subspace-service/src/dsn.rs index 536e818ce6..a93e0eeb80 100644 --- a/crates/subspace-service/src/dsn.rs +++ b/crates/subspace-service/src/dsn.rs @@ -19,6 +19,8 @@ use thiserror::Error; use tracing::{debug, error, trace}; const SEGMENT_HEADERS_NUMBER_LIMIT: u64 = 1000; +/// Should be sufficient number of target connections for everyone, limits are higher +const TARGET_CONNECTIONS: u32 = 15; /// Errors that might happen during DSN configuration. #[derive(Debug, Error)] @@ -64,9 +66,6 @@ pub struct DsnConfig { /// Defines max pending outgoing swarm connection limit. pub max_pending_out_connections: u32, - /// Defines target total (in and out) connection number for DSN that should be maintained. - pub target_connections: u32, - /// Known external addresses pub external_addresses: Vec, @@ -181,10 +180,9 @@ where max_pending_outgoing_connections: dsn_config.max_pending_out_connections, // Maintain proactive connections with all peers general_connected_peers_handler: Some(Arc::new(|_| true)), - general_connected_peers_target: dsn_config.target_connections, + general_connected_peers_target: TARGET_CONNECTIONS, // Allow to maintain some extra general connections beyond direct interest too - general_connected_peers_limit: dsn_config.target_connections - + dsn_config.max_in_connections / 4, + general_connected_peers_limit: TARGET_CONNECTIONS + dsn_config.max_in_connections / 4, reserved_peers: dsn_config.reserved_peers, bootstrap_addresses: dsn_config.bootstrap_nodes, external_addresses: dsn_config.external_addresses,