Skip to content

Commit

Permalink
Merge branch 'rc-2024.12.1-hotfix4' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jacderida committed Jan 9, 2025
2 parents 70154a0 + c1ae933 commit b536775
Show file tree
Hide file tree
Showing 25 changed files with 140 additions and 109 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ant-bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ license = "GPL-3.0"
name = "ant-bootstrap"
readme = "README.md"
repository = "https://github.com/maidsafe/autonomi"
version = "0.1.2"
version = "0.1.3"

[features]
local = []

[dependencies]
ant-logging = { path = "../ant-logging", version = "0.2.43" }
ant-protocol = { path = "../ant-protocol", version = "0.3.2" }
ant-logging = { path = "../ant-logging", version = "0.2.44" }
ant-protocol = { path = "../ant-protocol", version = "0.3.3" }
atomic-write-file = "0.2.2"
chrono = { version = "0.4", features = ["serde"] }
clap = { version = "4.2.1", features = ["derive", "env"] }
Expand Down
2 changes: 1 addition & 1 deletion ant-build-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPL-3.0"
name = "ant-build-info"
readme = "README.md"
repository = "https://github.com/maidsafe/autonomi"
version = "0.1.22"
version = "0.1.23"
build = "build.rs"
include = ["Cargo.toml", "src/**/*", "build.rs"]

Expand Down
2 changes: 1 addition & 1 deletion ant-build-info/src/release_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub const RELEASE_YEAR: &str = "2024";
pub const RELEASE_MONTH: &str = "12";
pub const RELEASE_CYCLE: &str = "1";
pub const RELEASE_CYCLE_COUNTER: &str = "7";
pub const RELEASE_CYCLE_COUNTER: &str = "8";
14 changes: 7 additions & 7 deletions ant-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["MaidSafe Developers <dev@maidsafe.net>"]
name = "ant-cli"
description = "CLI client for the Autonomi network"
license = "GPL-3.0"
version = "0.3.2"
version = "0.3.3"
edition = "2021"
homepage = "https://maidsafe.net"
readme = "README.md"
Expand All @@ -24,11 +24,11 @@ name = "files"
harness = false

[dependencies]
ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.2" }
ant-build-info = { path = "../ant-build-info", version = "0.1.22" }
ant-logging = { path = "../ant-logging", version = "0.2.43" }
ant-protocol = { path = "../ant-protocol", version = "0.3.2" }
autonomi = { path = "../autonomi", version = "0.3.2", features = [
ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.3" }
ant-build-info = { path = "../ant-build-info", version = "0.1.23" }
ant-logging = { path = "../ant-logging", version = "0.2.44" }
ant-protocol = { path = "../ant-protocol", version = "0.3.3" }
autonomi = { path = "../autonomi", version = "0.3.3", features = [
"fs",
"vault",
"registers",
Expand Down Expand Up @@ -60,7 +60,7 @@ tracing = { version = "~0.1.26" }
walkdir = "2.5.0"

[dev-dependencies]
autonomi = { path = "../autonomi", version = "0.3.2", features = ["fs"]}
autonomi = { path = "../autonomi", version = "0.3.3", features = ["fs"]}
criterion = "0.5.1"
eyre = "0.6.8"
rand = { version = "~0.8.5", features = ["small_rng"] }
Expand Down
4 changes: 2 additions & 2 deletions ant-evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPL-3.0"
name = "ant-evm"
readme = "README.md"
repository = "https://github.com/maidsafe/autonomi"
version = "0.1.7"
version = "0.1.8"

[features]
local = ["evmlib/local"]
Expand All @@ -16,7 +16,7 @@ test-utils = []

[dependencies]
custom_debug = "~0.6.1"
evmlib = { path = "../evmlib", version = "0.1.7" }
evmlib = { path = "../evmlib", version = "0.1.8" }
hex = "~0.4.3"
lazy_static = "~1.4.0"
libp2p = { version = "0.54.1", features = ["identify", "kad"] }
Expand Down
2 changes: 1 addition & 1 deletion ant-logging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPL-3.0"
name = "ant-logging"
readme = "README.md"
repository = "https://github.com/maidsafe/autonomi"
version = "0.2.43"
version = "0.2.44"

[dependencies]
chrono = "~0.4.19"
Expand Down
2 changes: 1 addition & 1 deletion ant-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPL-3.0"
name = "ant-metrics"
readme = "README.md"
repository = "https://github.com/maidsafe/autonomi"
version = "0.1.23"
version = "0.1.24"

[[bin]]
path = "src/main.rs"
Expand Down
12 changes: 6 additions & 6 deletions ant-networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPL-3.0"
name = "ant-networking"
readme = "README.md"
repository = "https://github.com/maidsafe/autonomi"
version = "0.3.2"
version = "0.3.3"

[features]
default = []
Expand All @@ -20,11 +20,11 @@ upnp = ["libp2p/upnp"]

[dependencies]
aes-gcm-siv = "0.11.1"
ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.2" }
ant-build-info = { path = "../ant-build-info", version = "0.1.22" }
ant-evm = { path = "../ant-evm", version = "0.1.7" }
ant-protocol = { path = "../ant-protocol", version = "0.3.2" }
ant-registers = { path = "../ant-registers", version = "0.4.6" }
ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.3" }
ant-build-info = { path = "../ant-build-info", version = "0.1.23" }
ant-evm = { path = "../ant-evm", version = "0.1.8" }
ant-protocol = { path = "../ant-protocol", version = "0.3.3" }
ant-registers = { path = "../ant-registers", version = "0.4.7" }
async-trait = "0.1"
bytes = { version = "1.0.1", features = ["serde"] }
custom_debug = "~0.6.1"
Expand Down
27 changes: 25 additions & 2 deletions ant-networking/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// permissions and limitations relating to use of the SAFE Network Software.

use crate::{driver::PendingGetClosestType, SwarmDriver};
use libp2p::kad::K_VALUE;
use rand::{rngs::OsRng, Rng};
use tokio::time::Duration;

Expand All @@ -25,7 +26,7 @@ const NETWORK_DISCOVER_CONNECTED_PEERS_STEP: u32 = 5;
const LAST_PEER_ADDED_TIME_LIMIT: Duration = Duration::from_secs(180);

/// A minimum interval to prevent network discovery got triggered too often
const LAST_NETWORK_DISCOVER_TRIGGERED_TIME_LIMIT: Duration = Duration::from_secs(30);
const LAST_NETWORK_DISCOVER_TRIGGERED_TIME_LIMIT: Duration = Duration::from_secs(90);

/// The network discovery interval to use if we haven't added any new peers in a while.
const NO_PEER_ADDED_SLOWDOWN_INTERVAL_MAX_S: u64 = 600;
Expand All @@ -50,8 +51,30 @@ impl SwarmDriver {

pub(crate) fn trigger_network_discovery(&mut self) {
let now = Instant::now();

// Find the farthest bucket that is not full. This is used to skip refreshing the RT of farthest full buckets.
let mut farthest_unfilled_bucket = 0;
for kbucket in self.swarm.behaviour_mut().kademlia.kbuckets() {
let Some(ilog2) = kbucket.range().0.ilog2() else {
continue;
};
if kbucket.num_entries() < K_VALUE.get() && ilog2 > farthest_unfilled_bucket {
farthest_unfilled_bucket = ilog2;
}
}
let farthest_unfilled_bucket = if farthest_unfilled_bucket == 0 {
None
} else {
Some(farthest_unfilled_bucket)
};

let addrs = self.network_discovery.candidates(farthest_unfilled_bucket);
info!(
"Triggering network discovery with {} candidates. Farthest non full bucket: {farthest_unfilled_bucket:?}",
addrs.len()
);
// Fetches the candidates and also generates new candidates
for addr in self.network_discovery.candidates() {
for addr in addrs {
// The query_id is tracked here. This is to update the candidate list of network_discovery with the newly
// found closest peers. It may fill up the candidate list of closer buckets which are harder to generate.
let query_id = self
Expand Down
14 changes: 11 additions & 3 deletions ant-networking/src/network_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,22 @@ impl NetworkDiscovery {
}

/// Returns one random candidate per bucket. Also tries to refresh the candidate list.
/// Todo: Limit the candidates to return. Favor the closest buckets.
pub(crate) fn candidates(&mut self) -> Vec<&NetworkAddress> {
/// Set the farthest_bucket to get candidates that are closer than or equal to the farthest_bucket.
pub(crate) fn candidates(&mut self, farthest_bucket: Option<u32>) -> Vec<&NetworkAddress> {
self.try_refresh_candidates();

let mut rng = thread_rng();
let mut op = Vec::with_capacity(self.candidates.len());

let candidates = self.candidates.values().filter_map(|candidates| {
let candidates = self.candidates.iter().filter_map(|(ilog2, candidates)| {
if let Some(farthest_bucket) = farthest_bucket {
if *ilog2 > farthest_bucket {
debug!(
"Skipping candidates for ilog2: {ilog2} as it is greater than farthest_bucket: {farthest_bucket}"
);
return None;
}
}
// get a random index each time
let random_index = rng.gen::<usize>() % candidates.len();
candidates.get(random_index)
Expand Down
Loading

0 comments on commit b536775

Please sign in to comment.