Skip to content

Commit

Permalink
fix(base-node): disable SAF auto requests (#3919)
Browse files Browse the repository at this point in the history
Description
---
- disables auto SAF requests for base node
- fix typo

Motivation and Context
---
There is currently no use-case for the base node to request SAF messages, this PR will slightly reduce network wide traffic and processing.

How Has This Been Tested?
---
  • Loading branch information
sdbondi authored Mar 25, 2022
1 parent dd544cb commit b34503b
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 28 deletions.
4 changes: 2 additions & 2 deletions applications/launchpad/docker_rig/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ tor_control_address = "/ip4/127.0.0.1/tcp/9051"
# - allowing wallets to locally connect to their base node, rather than through tor, when used in conjunction with `tor_proxy_bypass_addresses`
# - multiple P2P addresses, one public over DNS and one private over TOR
# - a "bridge" between TOR and TCP-only nodes
# auxilary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"
# auxiliary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"

# When these addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is made
# direcly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported.
Expand Down Expand Up @@ -263,7 +263,7 @@ tor_onion_port = 18141
# - allowing wallets to locally connect to their base node, rather than through tor, when used in conjunction with `tor_proxy_bypass_addresses`
# - multiple P2P addresses, one public over DNS and one private over TOR
# - a "bridge" between TOR and TCP-only nodes
# auxilary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"
# auxiliary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"

# When these addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is made
# direcly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported.
Expand Down
4 changes: 3 additions & 1 deletion applications/tari_base_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ where B: BlockchainBackend + 'static
network: self.config.network,
node_identity: self.node_identity.clone(),
transport_type: create_transport_type(self.config),
auxilary_tcp_listener_address: self.config.auxilary_tcp_listener_address.clone(),
auxiliary_tcp_listener_address: self.config.auxiliary_tcp_listener_address.clone(),
datastore_path: self.config.comms_peer_db_path.clone(),
peer_database_name: "peers".to_string(),
max_concurrent_inbound_tasks: 50,
Expand All @@ -268,6 +268,8 @@ where B: BlockchainBackend + 'static
flood_ban_max_msg_count: self.config.flood_ban_max_msg_count,
saf_config: SafConfig {
msg_validity: self.config.saf_expiry_duration,
// Base node does not ever need to request SAF messages
auto_request: false,
..Default::default()
},
dedup_cache_capacity: self.config.dht_dedup_cache_capacity,
Expand Down
4 changes: 3 additions & 1 deletion applications/tari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub async fn init_wallet(
node_identity,
user_agent: format!("tari/wallet/{}", env!("CARGO_PKG_VERSION")),
transport_type,
auxilary_tcp_listener_address: None,
auxiliary_tcp_listener_address: None,
datastore_path: config.console_wallet_peer_db_path.clone(),
peer_database_name: "peers".to_string(),
max_concurrent_inbound_tasks: 10,
Expand All @@ -400,6 +400,8 @@ pub async fn init_wallet(
flood_ban_max_msg_count: config.flood_ban_max_msg_count,
saf_config: SafConfig {
msg_validity: config.saf_expiry_duration,
// Ensure that SAF messages are requested automatically
auto_request: true,
..Default::default()
},
dedup_cache_capacity: config.dht_dedup_cache_capacity,
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_validator_node/src/comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn create_comms_config(config: &GlobalConfig, node_identity: Arc<NodeIdentity>)
dns_seeds: config.dns_seeds.clone(),
dns_seeds_name_server: config.dns_seeds_name_server.clone(),
dns_seeds_use_dnssec: config.dns_seeds_use_dnssec,
auxilary_tcp_listener_address: config.auxilary_tcp_listener_address.clone(),
auxiliary_tcp_listener_address: config.auxiliary_tcp_listener_address.clone(),
}
}

Expand Down
6 changes: 3 additions & 3 deletions base_layer/p2p/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub struct P2pConfig {
/// The address to bind on using the TCP transport _in addition to_ the primary transport. This is typically useful
/// for direct comms between a wallet and base node. If this is set to None, no listener will be bound.
/// Default: None
pub auxilary_tcp_listener_address: Option<Multiaddr>,
pub auxiliary_tcp_listener_address: Option<Multiaddr>,
}

/// Initialize Tari Comms configured for tests
Expand Down Expand Up @@ -351,8 +351,8 @@ async fn configure_comms_and_dht(
.with_dial_backoff(ConstantBackoff::new(Duration::from_millis(500)))
.with_peer_storage(peer_database, Some(file_lock));

let mut comms = match config.auxilary_tcp_listener_address {
Some(ref addr) => builder.with_auxilary_tcp_listener_address(addr.clone()).build()?,
let mut comms = match config.auxiliary_tcp_listener_address {
Some(ref addr) => builder.with_auxiliary_tcp_listener_address(addr.clone()).build()?,
None => builder.build()?,
};

Expand Down
2 changes: 1 addition & 1 deletion base_layer/wallet/tests/contacts_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn setup_contacts_service<T: ContactsBackend + 'static>(
transport_type: TransportType::Memory {
listener_address: node_identity.public_address(),
},
auxilary_tcp_listener_address: None,
auxiliary_tcp_listener_address: None,
datastore_path: tempdir().unwrap().into_path(),
peer_database_name: random::string(8),
max_concurrent_inbound_tasks: 10,
Expand Down
4 changes: 2 additions & 2 deletions base_layer/wallet/tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async fn create_wallet(
transport_type: TransportType::Memory {
listener_address: node_identity.public_address(),
},
auxilary_tcp_listener_address: None,
auxiliary_tcp_listener_address: None,
datastore_path: data_path.to_path_buf(),
peer_database_name: random::string(8),
max_concurrent_inbound_tasks: 10,
Expand Down Expand Up @@ -712,7 +712,7 @@ async fn test_import_utxo() {
listener_address: "/ip4/127.0.0.1/tcp/0".parse().unwrap(),
tor_socks_config: None,
},
auxilary_tcp_listener_address: None,
auxiliary_tcp_listener_address: None,
datastore_path: temp_dir.path().to_path_buf(),
peer_database_name: random::string(8),
max_concurrent_inbound_tasks: 10,
Expand Down
4 changes: 3 additions & 1 deletion base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3222,7 +3222,7 @@ pub unsafe extern "C" fn comms_config_create(
network: selected_network,
node_identity: Arc::new(node_identity),
transport_type: (*transport_type).clone(),
auxilary_tcp_listener_address: None,
auxiliary_tcp_listener_address: None,
datastore_path,
peer_database_name: database_name_string,
max_concurrent_inbound_tasks: 25,
Expand All @@ -3234,6 +3234,8 @@ pub unsafe extern "C" fn comms_config_create(
auto_join: true,
saf_config: SafConfig {
msg_validity: Duration::from_secs(saf_message_duration_in_secs),
// Ensure that SAF messages are requested automatically
auto_request: true,
..Default::default()
},
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions common/config/presets/base_node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ base_node_tor_identity_file = "config/base_node_tor.json"
# - allowing wallets to locally connect to their base node, rather than through tor, when used in conjunction with `tor_proxy_bypass_addresses`
# - multiple P2P addresses, one public over DNS and one private over TOR
# - a "bridge" between TOR and TCP-only nodes
# auxilary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"
# auxiliary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"

# When these addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is made
# direcly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported.
Expand Down Expand Up @@ -318,7 +318,7 @@ base_node_tor_identity_file = "config/base_node_tor.json"
# - allowing wallets to locally connect to their base node, rather than through tor, when used in conjunction with `tor_proxy_bypass_addresses`
# - multiple P2P addresses, one public over DNS and one private over TOR
# - a "bridge" between TOR and TCP-only nodes
# auxilary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"
# auxiliary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"

# When these addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is made
# direcly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported.
Expand Down
4 changes: 2 additions & 2 deletions common/config/presets/console_wallet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ tor_control_address = "/ip4/127.0.0.1/tcp/9051"
# - allowing wallets to locally connect to their base node, rather than through tor, when used in conjunction with `tor_proxy_bypass_addresses`
# - multiple P2P addresses, one public over DNS and one private over TOR
# - a "bridge" between TOR and TCP-only nodes
# auxilary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"
# auxiliary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"

# When these addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is made
# direcly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported.
Expand Down Expand Up @@ -205,7 +205,7 @@ tor_control_address = "/ip4/127.0.0.1/tcp/9051"
# - allowing wallets to locally connect to their base node, rather than through tor, when used in conjunction with `tor_proxy_bypass_addresses`
# - multiple P2P addresses, one public over DNS and one private over TOR
# - a "bridge" between TOR and TCP-only nodes
# auxilary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"
# auxiliary_tcp_listener_address = "/ip4/127.0.0.1/tcp/9998"

# When these addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is made
# direcly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported.
Expand Down
8 changes: 4 additions & 4 deletions common/src/configuration/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct GlobalConfig {
pub autoupdate_dns_hosts: Vec<String>,
pub autoupdate_hashes_sig_url: String,
pub autoupdate_hashes_url: String,
pub auxilary_tcp_listener_address: Option<Multiaddr>,
pub auxiliary_tcp_listener_address: Option<Multiaddr>,
pub base_node_bypass_range_proof_verification: bool,
pub base_node_config: Option<BaseNodeConfig>,
pub base_node_event_channel_size: usize,
Expand Down Expand Up @@ -321,8 +321,8 @@ fn convert_node_config(
// Transport
let comms_transport = network_transport_config(&cfg, application, net_str)?;

let key = config_string("base_node", net_str, "auxilary_tcp_listener_address");
let auxilary_tcp_listener_address = optional(cfg.get_str(&key))?
let key = config_string("base_node", net_str, "auxiliary_tcp_listener_address");
let auxiliary_tcp_listener_address = optional(cfg.get_str(&key))?
.map(|addr| {
addr.parse::<Multiaddr>()
.map_err(|e| ConfigurationError::new(&key, Some(addr), &e.to_string()))
Expand Down Expand Up @@ -829,7 +829,7 @@ fn convert_node_config(
autoupdate_dns_hosts,
autoupdate_hashes_sig_url,
autoupdate_hashes_url,
auxilary_tcp_listener_address,
auxiliary_tcp_listener_address,
base_node_bypass_range_proof_verification,
base_node_config,
base_node_event_channel_size,
Expand Down
4 changes: 2 additions & 2 deletions comms/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ impl CommsBuilder {
self
}

pub fn with_auxilary_tcp_listener_address(mut self, listener_address: Multiaddr) -> Self {
self.connection_manager_config.auxilary_tcp_listener_address = Some(listener_address);
pub fn with_auxiliary_tcp_listener_address(mut self, listener_address: Multiaddr) -> Self {
self.connection_manager_config.auxiliary_tcp_listener_address = Some(listener_address);
self
}

Expand Down
8 changes: 4 additions & 4 deletions comms/src/connection_manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct ConnectionManagerConfig {
pub liveness_cidr_allowlist: Vec<cidr::AnyIpCidr>,
/// If set, an additional TCP-only p2p listener will be started. This is useful for local wallet connections.
/// Default: None (disabled)
pub auxilary_tcp_listener_address: Option<Multiaddr>,
pub auxiliary_tcp_listener_address: Option<Multiaddr>,
}

impl Default for ConnectionManagerConfig {
Expand All @@ -133,7 +133,7 @@ impl Default for ConnectionManagerConfig {
liveness_max_sessions: 0,
time_to_first_byte: Duration::from_secs(45),
liveness_cidr_allowlist: vec![cidr::AnyIpCidr::V4("127.0.0.1/32".parse().unwrap())],
auxilary_tcp_listener_address: None,
auxiliary_tcp_listener_address: None,
}
}
}
Expand All @@ -150,7 +150,7 @@ impl ListenerInfo {
&self.bind_address
}

pub fn auxilary_bind_address(&self) -> Option<&Multiaddr> {
pub fn auxiliary_bind_address(&self) -> Option<&Multiaddr> {
self.aux_bind_address.as_ref()
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ where
shutdown_signal.clone(),
);

let aux_listener = config.auxilary_tcp_listener_address.take().map(|addr| {
let aux_listener = config.auxiliary_tcp_listener_address.take().map(|addr| {
PeerListener::new(
config.clone(),
addr,
Expand Down
4 changes: 2 additions & 2 deletions comms/src/connection_manager/tests/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async fn dial_success_aux_tcp_listener() {
node_identity: node_identity1.clone(),
..Default::default()
};
config.connection_manager_config.auxilary_tcp_listener_address =
config.connection_manager_config.auxiliary_tcp_listener_address =
Some("/ip4/127.0.0.1/tcp/0".parse().unwrap());
config.connection_manager_config.network_info.user_agent = "node1".to_string();
config
Expand All @@ -238,7 +238,7 @@ async fn dial_success_aux_tcp_listener() {
.wait_until_listening()
.await
.unwrap()
.auxilary_bind_address()
.auxiliary_bind_address()
.unwrap()
.clone();

Expand Down

0 comments on commit b34503b

Please sign in to comment.