diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f425f819..c26c8e9c2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 *When editing this file, please respect a line length of 100.* +## 2024-11-25 + +### Network + +#### Fixed + +- Make native kad bootstrap interval more random. So that when running multiple nodes + on one machine, there is no resource usage spike appears with fixed interval. + ## 2024-11-13 ### Network diff --git a/Cargo.lock b/Cargo.lock index 2c1b001aef..bf43ed80d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8590,7 +8590,7 @@ dependencies = [ [[package]] name = "sn_networking" -version = "0.19.4" +version = "0.19.5" dependencies = [ "aes-gcm-siv", "assert_fs", diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index a7d5bef282..468d89df44 100644 --- a/autonomi/Cargo.toml +++ b/autonomi/Cargo.toml @@ -38,7 +38,7 @@ rand = "0.8.5" rmp-serde = "1.1.1" self_encryption = "~0.30.0" serde = { version = "1.0.133", features = ["derive", "rc"] } -sn_networking = { path = "../sn_networking", version = "0.19.4" } +sn_networking = { path = "../sn_networking", version = "0.19.5" } sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.7" } sn_protocol = { version = "0.17.15", path = "../sn_protocol" } sn_registers = { path = "../sn_registers", version = "0.4.3" } diff --git a/nat-detection/Cargo.toml b/nat-detection/Cargo.toml index 182fb0c053..f3b903d4ed 100644 --- a/nat-detection/Cargo.toml +++ b/nat-detection/Cargo.toml @@ -32,7 +32,7 @@ libp2p = { version = "0.54.1", features = [ "upnp", ] } sn_build_info = { path = "../sn_build_info", version = "0.1.19" } -sn_networking = { path = "../sn_networking", version = "0.19.4" } +sn_networking = { path = "../sn_networking", version = "0.19.5" } sn_protocol = { path = "../sn_protocol", version = "0.17.15" } tokio = { version = "1.32.0", features = ["full"] } tracing = { version = "~0.1.26" } diff --git a/release-cycle-info b/release-cycle-info index b272dbda85..0109aac6b2 100644 --- a/release-cycle-info +++ b/release-cycle-info @@ -15,4 +15,4 @@ release-year: 2024 release-month: 11 release-cycle: 1 -release-cycle-counter: 5 +release-cycle-counter: 6 diff --git a/sn_build_info/src/release_info.rs b/sn_build_info/src/release_info.rs index 23ddb6c755..c79a7039a7 100644 --- a/sn_build_info/src/release_info.rs +++ b/sn_build_info/src/release_info.rs @@ -1,4 +1,4 @@ pub const RELEASE_YEAR: &str = "2024"; pub const RELEASE_MONTH: &str = "11"; pub const RELEASE_CYCLE: &str = "1"; -pub const RELEASE_CYCLE_COUNTER: &str = "5"; +pub const RELEASE_CYCLE_COUNTER: &str = "6"; diff --git a/sn_networking/Cargo.toml b/sn_networking/Cargo.toml index 1cdfa38c63..46fc407cc3 100644 --- a/sn_networking/Cargo.toml +++ b/sn_networking/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_networking" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.19.4" +version = "0.19.5" [features] default = [] diff --git a/sn_networking/src/driver.rs b/sn_networking/src/driver.rs index 43a5525ccf..69bb191333 100644 --- a/sn_networking/src/driver.rs +++ b/sn_networking/src/driver.rs @@ -47,6 +47,7 @@ use libp2p::{ use libp2p::{swarm::SwarmEvent, Transport as _}; #[cfg(feature = "open-metrics")] use prometheus_client::metrics::info::Info; +use rand::Rng; use sn_evm::PaymentQuote; use sn_protocol::{ messages::{ChunkProof, Nonce, Request, Response}, @@ -126,8 +127,9 @@ const NETWORKING_CHANNEL_SIZE: usize = 10_000; /// Time before a Kad query times out if no response is received const KAD_QUERY_TIMEOUT_S: Duration = Duration::from_secs(10); -/// Periodic bootstrap interval -const KAD_PERIODIC_BOOTSTRAP_INTERVAL_S: Duration = Duration::from_secs(180 * 60); +/// Interval to trigger native libp2p::kad bootstrap. +/// This is the max time it should take. Minimum interval at any node will be half this +const PERIODIC_KAD_BOOTSTRAP_INTERVAL_MAX_S: u64 = 21600; // Init during compilation, instead of runtime error that should never happen // Option::expect will be stabilised as const in the future (https://github.com/rust-lang/rust/issues/67441) @@ -345,6 +347,10 @@ impl NetworkBuilder { self, root_dir: PathBuf, ) -> Result<(Network, mpsc::Receiver, SwarmDriver)> { + let bootstrap_interval = rand::thread_rng().gen_range( + PERIODIC_KAD_BOOTSTRAP_INTERVAL_MAX_S / 2..PERIODIC_KAD_BOOTSTRAP_INTERVAL_MAX_S, + ); + let mut kad_cfg = kad::Config::new(KAD_STREAM_PROTOCOL_ID); let _ = kad_cfg .set_kbucket_inserts(libp2p::kad::BucketInserts::Manual) @@ -365,7 +371,7 @@ impl NetworkBuilder { // Records never expire .set_record_ttl(None) .set_replication_factor(REPLICATION_FACTOR) - .set_periodic_bootstrap_interval(Some(KAD_PERIODIC_BOOTSTRAP_INTERVAL_S)) + .set_periodic_bootstrap_interval(Some(Duration::from_secs(bootstrap_interval))) // Emit PUT events for validation prior to insertion into the RecordStore. // This is no longer needed as the record_storage::put now can carry out validation. // .set_record_filtering(KademliaStoreInserts::FilterBoth) diff --git a/sn_node/Cargo.toml b/sn_node/Cargo.toml index 0ced071299..64b295c87d 100644 --- a/sn_node/Cargo.toml +++ b/sn_node/Cargo.toml @@ -55,7 +55,7 @@ serde = { version = "1.0.133", features = ["derive", "rc"] } sn_build_info = { path = "../sn_build_info", version = "0.1.19" } sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.7" } sn_logging = { path = "../sn_logging", version = "0.2.40" } -sn_networking = { path = "../sn_networking", version = "0.19.4" } +sn_networking = { path = "../sn_networking", version = "0.19.5" } sn_protocol = { path = "../sn_protocol", version = "0.17.15" } sn_registers = { path = "../sn_registers", version = "0.4.3" } sn_transfers = { path = "../sn_transfers", version = "0.20.3" }