From 949def878ce40d16375f1940ea83551c56e2945a Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Fri, 4 Feb 2022 15:12:46 +0200 Subject: [PATCH] fix: bump flood ban messages config --- applications/launchpad/backend/assets/config.toml | 4 ++-- applications/launchpad/docker_rig/config.toml | 4 ++-- common/config/presets/base_node.toml | 12 ++++++------ common/src/configuration/utils.rs | 8 ++++---- comms/dht/src/config.rs | 10 +++++++--- comms/dht/src/connectivity/mod.rs | 7 +++++-- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/applications/launchpad/backend/assets/config.toml b/applications/launchpad/backend/assets/config.toml index c0219f3e6d..dc360f5ae5 100644 --- a/applications/launchpad/backend/assets/config.toml +++ b/applications/launchpad/backend/assets/config.toml @@ -46,7 +46,7 @@ track_reorgs = true [base_node.dibbler] db_type = "lmdb" -flood_ban_max_msg_count = 10000 +flood_ban_max_msg_count = 100_000 allow_test_addresses = false use_libtor = false base_node_identity_file = "/var/tari/base_node/config/dibbler/tari_base_node_id.json" @@ -65,7 +65,7 @@ grpc_base_node_address = "0.0.0.0:18142" [base_node.igor] db_type = "lmdb" -flood_ban_max_msg_count = 10000 +flood_ban_max_msg_count = 100_000 allow_test_addresses = false use_libtor = false base_node_identity_file = "/var/tari/base_node/config/igor/base_node_id.json" diff --git a/applications/launchpad/docker_rig/config.toml b/applications/launchpad/docker_rig/config.toml index aeca39bbbf..b53f2ec91e 100644 --- a/applications/launchpad/docker_rig/config.toml +++ b/applications/launchpad/docker_rig/config.toml @@ -42,7 +42,7 @@ track_reorgs = true [base_node.dibbler] db_type = "lmdb" -flood_ban_max_msg_count = 10000 +flood_ban_max_msg_count = 100_000 data_dir = "/blockchain/dibbler" force_sync_peers = [] allow_test_addresses = false @@ -64,7 +64,7 @@ console_wallet_tor_identity_file = "config/dibbler/console_wallet_tor.json" [base_node.igor] db_type = "lmdb" -flood_ban_max_msg_count = 10000 +flood_ban_max_msg_count = 100_000 data_dir = "/blockchain/igor" force_sync_peers = [] allow_test_addresses = false diff --git a/common/config/presets/base_node.toml b/common/config/presets/base_node.toml index 4748f37d7d..0efbabd79d 100644 --- a/common/config/presets/base_node.toml +++ b/common/config/presets/base_node.toml @@ -53,9 +53,9 @@ db_type = "lmdb" # is "0", which indicates an archival node without any pruning. #pruning_horizon = 0 -# The amount of messages that will be permitted in the flood ban timespan of 100s (Default dibbler = 1000, -# default mainnet = 10000) -flood_ban_max_msg_count = 10000 +# The amount of messages that will be permitted in the flood ban timespan of 100s (Default dibbler = 100000, +# default mainnet = 100000) +flood_ban_max_msg_count = 100_000 # The relative path to store persistent data data_dir = "dibbler" @@ -223,9 +223,9 @@ db_type = "lmdb" # is "0", which indicates an archival node without any pruning. #pruning_horizon = 0 -# The amount of messages that will be permitted in the flood ban timespan of 100s (Default weatherwax = 1000, -# default mainnet = 10000) -flood_ban_max_msg_count = 10000 +# The amount of messages that will be permitted in the flood ban timespan of 100s (Default igor = 100000, +# default mainnet = 100000) +flood_ban_max_msg_count = 100_000 # The relative path to store persistent data data_dir = "igor" diff --git a/common/src/configuration/utils.rs b/common/src/configuration/utils.rs index c3ba451f18..8d15322bbd 100644 --- a/common/src/configuration/utils.rs +++ b/common/src/configuration/utils.rs @@ -162,7 +162,7 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { cfg.set_default("base_node.mainnet.grpc_base_node_address", "127.0.0.1:18142") .unwrap(); cfg.set_default("wallet.grpc_address", "127.0.0.1:18143").unwrap(); - cfg.set_default("base_node.mainnet.flood_ban_max_msg_count", 10000) + cfg.set_default("base_node.mainnet.flood_ban_max_msg_count", 100_000) .unwrap(); //---------------------------------- Weatherwax Defaults --------------------------------------------// @@ -175,7 +175,7 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { cfg.set_default("base_node.weatherwax.pruning_horizon", 0).unwrap(); cfg.set_default("base_node.weatherwax.pruned_mode_cleanup_interval", 50) .unwrap(); - cfg.set_default("base_node.weatherwax.flood_ban_max_msg_count", 10000) + cfg.set_default("base_node.weatherwax.flood_ban_max_msg_count", 100_000) .unwrap(); cfg.set_default("base_node.weatherwax.peer_seeds", Vec::::new()) .unwrap(); @@ -220,7 +220,7 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { cfg.set_default("base_node.igor.pruning_horizon", 0).unwrap(); cfg.set_default("base_node.igor.pruned_mode_cleanup_interval", 50) .unwrap(); - cfg.set_default("base_node.igor.flood_ban_max_msg_count", 10000) + cfg.set_default("base_node.igor.flood_ban_max_msg_count", 100_000) .unwrap(); cfg.set_default("base_node.igor.grpc_enabled", false).unwrap(); cfg.set_default("base_node.igor.grpc_base_node_address", "127.0.0.1:18142") @@ -236,7 +236,7 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { } fn set_common_network_defaults(cfg: &mut Config) { - for network in ["mainnet", "weatherwax", "igor", "localnet"] { + for network in ["mainnet", "dibbler", "igor", "localnet"] { let key = format!("base_node.{}.dns_seeds_name_server", network); cfg.set_default(&key, "1.1.1.1:853/cloudflare-dns.com").unwrap(); diff --git a/comms/dht/src/config.rs b/comms/dht/src/config.rs index 8340d7cd13..6993756ba3 100644 --- a/comms/dht/src/config.rs +++ b/comms/dht/src/config.rs @@ -83,11 +83,14 @@ pub struct DhtConfig { /// Length of time to ban a peer if the peer misbehaves at the DHT-level. /// Default: 6 hrs pub ban_duration: Duration, + /// Length of time to ban a peer for a "short" duration. + /// Default: 30 mins + pub ban_duration_short: Duration, /// This allows the use of test addresses in the network. /// Default: false pub allow_test_addresses: bool, - /// The maximum number of messages over `flood_ban_timespan` to allow before banning the peer (for `ban_duration`) - /// Default: 1000 messages + /// The maximum number of messages over `flood_ban_timespan` to allow before banning the peer (for + /// `ban_duration_short`) Default: 100_000 messages pub flood_ban_max_msg_count: usize, /// The timespan over which to calculate the max message rate. /// `flood_ban_max_count / flood_ban_timespan (as seconds) = avg. messages per second over the timespan` @@ -151,8 +154,9 @@ impl Default for DhtConfig { join_cooldown_interval: Duration::from_secs(10 * 60), network_discovery: Default::default(), ban_duration: Duration::from_secs(6 * 60 * 60), + ban_duration_short: Duration::from_secs(60 * 60), allow_test_addresses: false, - flood_ban_max_msg_count: 10000, + flood_ban_max_msg_count: 100_000, flood_ban_timespan: Duration::from_secs(100), offline_peer_cooldown: Duration::from_secs(2 * 60 * 60), } diff --git a/comms/dht/src/connectivity/mod.rs b/comms/dht/src/connectivity/mod.rs index a3d8042521..4afc7dab30 100644 --- a/comms/dht/src/connectivity/mod.rs +++ b/comms/dht/src/connectivity/mod.rs @@ -266,8 +266,11 @@ impl DhtConnectivity { self.connectivity .ban_peer_until( peer, - self.config.ban_duration, - "Exceeded maximum message rate".to_string(), + self.config.ban_duration_short, + format!( + "Exceeded maximum message rate. Config: {}/{:#?}. Rate: {:.2} m/s", + self.config.flood_ban_max_msg_count, self.config.flood_ban_timespan, mps + ), ) .await?; }