Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions antd/Cargo.lock

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

1 change: 1 addition & 0 deletions antd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ thiserror = "2"
futures = "0.3"
rand = "0.8"
postcard = { version = "1.1.3", features = ["use-std"] }
toml = "0.8"

[build-dependencies]
tonic-build = "0.12"
22 changes: 22 additions & 0 deletions antd/resources/bootstrap_peers.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Autonomi Network — Bootstrap Peers (compiled-in default for antd)
#
# This file is embedded into the antd binary via include_str! and used as a
# last-resort fallback when no peers are supplied via:
# 1. --peers / ANTD_PEERS (CLI/env)
# 2. %APPDATA%/ant/bootstrap_peers.toml (Linux: ~/.config/ant/) — the file
# ant-client's installer drops in
#
# Vendored from ant-client `resources/bootstrap_peers.toml`. Refresh on each
# antd release if upstream rotates the list.
#
# Format: "ip:port" socket addresses. Port range for ant-node: 10000-10999.

peers = [
"207.148.94.42:10000",
"45.77.50.10:10000",
"66.135.23.83:10000",
"149.248.9.2:10000",
"49.12.119.240:10000",
"5.161.25.133:10000",
"18.228.202.183:10000",
]
14 changes: 14 additions & 0 deletions antd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}

// Last-resort fallback: peers vendored into the binary at compile time.
// Lets a fresh release binary reach mainnet without any prior ant-client
// installer step. CLI/env/file all take precedence over this.
if bootstrap_peers.is_empty() && config.network != "local" {
let compiled_in = peers::compiled_in_default_peers();
if !compiled_in.is_empty() {
tracing::info!(
count = compiled_in.len(),
"loaded compiled-in default bootstrap peers (no CLI/env/file peers were supplied)"
);
bootstrap_peers = compiled_in;
}
}

if bootstrap_peers.is_empty() {
if config.network != "local" {
tracing::warn!(
Expand Down
45 changes: 45 additions & 0 deletions antd/src/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ use std::net::SocketAddr;

use ant_core::data::MultiAddr;

/// Mainnet bootstrap peers vendored from `ant-client/resources/bootstrap_peers.toml`.
/// Used as a last-resort fallback when neither CLI/env nor the on-disk
/// `bootstrap_peers.toml` provided any peers, so a fresh release binary can
/// reach mainnet without manual setup.
const COMPILED_IN_BOOTSTRAP_PEERS_TOML: &str = include_str!("../resources/bootstrap_peers.toml");

#[derive(serde::Deserialize)]
struct BootstrapConfig {
peers: Vec<String>,
}

/// Convert a [`SocketAddr`] (as read from ant-client's `bootstrap_peers.toml`)
/// into the libp2p-style `/ip4/<ip>/udp/<port>/quic` multiaddr string that
/// saorsa-core expects, then parse it into a [`MultiAddr`].
Expand Down Expand Up @@ -44,6 +55,24 @@ pub fn load_from_ant_client_config() -> (Vec<MultiAddr>, Option<std::path::PathB
(peers, path)
}

/// Last-resort fallback: parse the bootstrap_peers.toml that was vendored into
/// the binary at compile time and return MultiAddrs. Returns an empty vector if
/// the embedded file is malformed (which would be a build-time regression).
pub fn compiled_in_default_peers() -> Vec<MultiAddr> {
match toml::from_str::<BootstrapConfig>(COMPILED_IN_BOOTSTRAP_PEERS_TOML) {
Ok(cfg) => cfg
.peers
.iter()
.filter_map(|s| s.parse::<SocketAddr>().ok())
.filter_map(|sa| socket_addr_to_multiaddr(&sa))
.collect(),
Err(e) => {
tracing::warn!(error = %e, "failed to parse compiled-in bootstrap_peers.toml");
Vec::new()
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -71,4 +100,20 @@ mod tests {
"unexpected multiaddr: {as_str}"
);
}

#[test]
fn compiled_in_default_peers_parses_and_yields_multiaddrs() {
let peers = compiled_in_default_peers();
assert!(
!peers.is_empty(),
"embedded bootstrap_peers.toml produced zero peers"
);
for ma in &peers {
let as_str = format!("{ma}");
assert!(
as_str.contains("/udp/") && as_str.contains("/quic"),
"unexpected multiaddr shape: {as_str}"
);
}
}
}
Loading