Skip to content

Commit

Permalink
feat: remove ant-peers-acquisition and use ant-bootstrap instead
Browse files Browse the repository at this point in the history
- This also removes the `network-contact` feature flag.
- The flag was used to indicate if we should connect to the mainnet or
  the testnet, which can easily be done with PeersArgs::testnet flag
  • Loading branch information
RolandSherwin committed Dec 4, 2024
1 parent 5937cce commit 3f4b9d6
Show file tree
Hide file tree
Showing 31 changed files with 49 additions and 387 deletions.
25 changes: 2 additions & 23 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ members = [
"ant-node",
"ant-node-manager",
"ant-node-rpc-client",
"ant-peers-acquisition",
"ant-protocol",
"ant-registers",
"ant-service-management",
Expand Down
8 changes: 4 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ build-release-artifacts arch nightly="false":
cargo binstall --no-confirm cross
cross build --release --target $arch --bin nat-detection $nightly_feature
cross build --release --target $arch --bin node-launchpad $nightly_feature
cross build --release --features network-contacts,websockets --target $arch --bin ant $nightly_feature
cross build --release --features network-contacts,websockets --target $arch --bin antnode $nightly_feature
cross build --release --features websockets --target $arch --bin ant $nightly_feature
cross build --release --features websockets --target $arch --bin antnode $nightly_feature
cross build --release --target $arch --bin antctl $nightly_feature
cross build --release --target $arch --bin antctld $nightly_feature
cross build --release --target $arch --bin antnode_rpc_client $nightly_feature
else
cargo build --release --target $arch --bin nat-detection $nightly_feature
cargo build --release --target $arch --bin node-launchpad $nightly_feature
cargo build --release --features network-contacts,websockets --target $arch --bin ant $nightly_feature
cargo build --release --features network-contacts,websockets --target $arch --bin antnode $nightly_feature
cargo build --release --features websockets --target $arch --bin ant $nightly_feature
cargo build --release --features websockets --target $arch --bin antnode $nightly_feature
cargo build --release --target $arch --bin antctl $nightly_feature
cargo build --release --target $arch --bin antctld $nightly_feature
cargo build --release --target $arch --bin antnode_rpc_client $nightly_feature
Expand Down
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,20 @@ You should build from the `stable` branch, as follows:

```
git checkout stable
cargo build --release --features network-contacts --bin antnode
cargo build --release --bin antnode
```

#### Running the Node

To run a node and receive rewards, you need to specify your Ethereum address as a parameter. Rewards are paid to the specified address.

```
cargo run --release --bin antnode --features network-contacts -- --rewards-address <YOUR_ETHEREUM_ADDRESS_TO_RECEIVE_REWARDS>
cargo run --release --bin antnode -- --rewards-address <YOUR_ETHEREUM_ADDRESS_TO_RECEIVE_REWARDS>
```

More options about EVM Network below.

### For Developers

#### Build

You can build `autonomi` and `antnode` with the `network-contacts` feature:

```
cargo build --release --features network-contacts --bin autonomi
cargo build --release --features network-contacts --bin antnode
```


#### Main Crates

- [Autonomi API](https://github.com/maidsafe/autonomi/blob/main/autonomi/README.md) The client APIs
Expand Down Expand Up @@ -97,8 +86,8 @@ WASM support for the autonomi API is currently under active development. More do
used by the autonomi network.
- [Registers](https://github.com/maidsafe/autonomi/blob/main/ant-registers/README.md) The
registers crate, used for the Register CRDT data type on the network.
- [Peers Acquisition](https://github.com/maidsafe/autonomi/blob/main/ant-peers-acquisition/README.md)
The peers acquisition crate, or: how the network layer discovers bootstrap peers.
- [Bootstrap](https://github.com/maidsafe/autonomi/blob/main/ant-bootstrap/README.md)
The network bootstrap cache or: how the network layer discovers bootstrap peers.
- [Build Info](https://github.com/maidsafe/autonomi/blob/main/ant-build-info/README.md) Small
helper used to get the build/commit versioning info for debug purposes.

Expand Down
4 changes: 1 addition & 3 deletions ant-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ path = "src/main.rs"

[features]
default = ["metrics"]
local = ["ant-peers-acquisition/local", "autonomi/local"]
local = ["ant-bootstrap/local", "autonomi/local"]
metrics = ["ant-logging/process-metrics"]
network-contacts = ["ant-peers-acquisition/network-contacts"]
websockets = ["autonomi/websockets"]

[[bench]]
Expand All @@ -28,7 +27,6 @@ harness = false
ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.0" }
ant-build-info = { path = "../ant-build-info", version = "0.1.19" }
ant-logging = { path = "../ant-logging", version = "0.2.40" }
ant-peers-acquisition = { path = "../ant-peers-acquisition", version = "0.5.7" }
autonomi = { path = "../autonomi", version = "0.2.4", features = [
"data",
"fs",
Expand Down
2 changes: 1 addition & 1 deletion ant-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async fn main() -> Result<()> {

fn init_logging_and_metrics(opt: &Opt) -> Result<(ReloadHandle, Option<WorkerGuard>)> {
let logging_targets = vec![
("ant_bootstrap".to_string(), Level::DEBUG),
("ant_build_info".to_string(), Level::TRACE),
("ant_evm".to_string(), Level::TRACE),
("ant_networking".to_string(), Level::INFO),
Expand All @@ -59,7 +60,6 @@ fn init_logging_and_metrics(opt: &Opt) -> Result<(ReloadHandle, Option<WorkerGua
("autonomi".to_string(), Level::TRACE),
("evmlib".to_string(), Level::TRACE),
("ant_logging".to_string(), Level::TRACE),
("ant_peers_acquisition".to_string(), Level::TRACE),
("ant_protocol".to_string(), Level::TRACE),
];
let mut log_builder = LogBuilder::new(logging_targets);
Expand Down
1 change: 0 additions & 1 deletion ant-logging/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ fn get_logging_targets(logging_env_value: &str) -> Result<Vec<(String, Level)>>
("ant_logging".to_string(), Level::TRACE),
("ant_node_manager".to_string(), Level::TRACE),
("ant_node_rpc_client".to_string(), Level::TRACE),
("ant_peers_acquisition".to_string(), Level::TRACE),
("ant_protocol".to_string(), Level::TRACE),
("ant_registers".to_string(), Level::INFO),
("ant_service_management".to_string(), Level::TRACE),
Expand Down
3 changes: 1 addition & 2 deletions ant-node-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ path = "src/bin/daemon/main.rs"
chaos = []
default = ["quic"]
local = []
network-contacts = []
nightly = []
open-metrics = []
otlp = []
Expand All @@ -31,10 +30,10 @@ tcp = []
websockets = []

[dependencies]
ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.0" }
ant-build-info = { path = "../ant-build-info", version = "0.1.19" }
ant-evm = { path = "../ant-evm", version = "0.1.4" }
ant-logging = { path = "../ant-logging", version = "0.2.40" }
ant-peers-acquisition = { path = "../ant-peers-acquisition", version = "0.5.7" }
ant-protocol = { path = "../ant-protocol", version = "0.17.15" }
ant-releases = { git = "https://github.com/jacderida/ant-releases.git", branch = "chore-rename_binaries" }
ant-service-management = { path = "../ant-service-management", version = "0.4.3" }
Expand Down
4 changes: 2 additions & 2 deletions ant-node-manager/src/bin/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
mod subcommands;

use crate::subcommands::evm_network::EvmNetworkCommand;
use ant_bootstrap::PeersArgs;
use ant_evm::RewardsAddress;
use ant_logging::{LogBuilder, LogFormat};
use ant_node_manager::{
add_services::config::PortRange,
cmd::{self},
VerbosityLevel, DEFAULT_NODE_STARTUP_CONNECTION_TIMEOUT_S,
};
use ant_peers_acquisition::PeersArgs;
use clap::{Parser, Subcommand};
use color_eyre::{eyre::eyre, Result};
use libp2p::Multiaddr;
Expand Down Expand Up @@ -1381,9 +1381,9 @@ async fn main() -> Result<()> {

fn get_log_builder(level: Level) -> Result<LogBuilder> {
let logging_targets = vec![
("ant_bootstrap".to_string(), level),
("evmlib".to_string(), level),
("evm-testnet".to_string(), level),
("ant_peers_acquisition".to_string(), level),
("ant_node_manager".to_string(), level),
("antctl".to_string(), level),
("antctld".to_string(), level),
Expand Down
2 changes: 1 addition & 1 deletion ant-node-manager/src/cmd/auditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
config::{self, is_running_as_root},
print_banner, ServiceManager, VerbosityLevel,
};
use ant_peers_acquisition::PeersArgs;
use ant_bootstrap::PeersArgs;
use ant_service_management::{auditor::AuditorService, control::ServiceController, NodeRegistry};
use color_eyre::{eyre::eyre, Result};
use std::path::PathBuf;
Expand Down
2 changes: 1 addition & 1 deletion ant-node-manager/src/cmd/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
config::{self, is_running_as_root},
print_banner, ServiceManager, VerbosityLevel,
};
use ant_peers_acquisition::PeersArgs;
use ant_bootstrap::PeersArgs;
use ant_service_management::{control::ServiceController, FaucetService, NodeRegistry};
use color_eyre::{eyre::eyre, Result};
use std::path::PathBuf;
Expand Down
6 changes: 3 additions & 3 deletions ant-node-manager/src/cmd/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use crate::{
local::{kill_network, run_network, LocalNetworkOptions},
print_banner, status_report, VerbosityLevel,
};
use ant_bootstrap::PeersArgs;
use ant_evm::{EvmNetwork, RewardsAddress};
use ant_logging::LogFormat;
use ant_peers_acquisition::PeersArgs;
use ant_releases::{AntReleaseRepoActions, ReleaseType};
use ant_service_management::{
control::ServiceController, get_local_node_registry_path, NodeRegistry,
Expand Down Expand Up @@ -72,10 +72,10 @@ pub async fn join(

// If no peers are obtained we will attempt to join the existing local network, if one
// is running.
let peers = match peers_args.get_peers().await {
let peers = match peers_args.get_addrs().await {
Ok(peers) => Some(peers),
Err(err) => match err {
ant_peers_acquisition::error::Error::PeersNotObtained => {
ant_bootstrap::error::Error::NoBootstrapPeersFound => {
warn!("PeersNotObtained, peers is set to None");
None
}
Expand Down
3 changes: 0 additions & 3 deletions ant-node-manager/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ fn build_binary(bin_type: &ReleaseType) -> Result<PathBuf> {
if cfg!(feature = "local") {
args.extend(["--features", "local"]);
}
if cfg!(feature = "network-contacts") {
args.extend(["--features", "network-contacts"]);
}
if cfg!(feature = "websockets") {
args.extend(["--features", "websockets"]);
}
Expand Down
8 changes: 6 additions & 2 deletions ant-node-manager/src/cmd/nat_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use crate::{
config::get_node_registry_path, helpers::download_and_extract_release, VerbosityLevel,
};
use ant_peers_acquisition::get_peers_from_url;
use ant_bootstrap::ContactsFetcher;
use ant_releases::{AntReleaseRepoActions, ReleaseType};
use ant_service_management::{NatDetectionStatus, NodeRegistry};
use color_eyre::eyre::{bail, OptionExt, Result};
Expand All @@ -35,7 +35,11 @@ pub async fn run_nat_detection(
let servers = match servers {
Some(servers) => servers,
None => {
let servers = get_peers_from_url(NAT_DETECTION_SERVERS_LIST_URL.parse()?).await?;
let mut contacts_fetcher = ContactsFetcher::new()?;
contacts_fetcher.ignore_peer_id(true);
contacts_fetcher.insert_endpoint(NAT_DETECTION_SERVERS_LIST_URL.parse()?);

let servers = contacts_fetcher.fetch_addrs().await?;

servers
.choose_multiple(&mut rand::thread_rng(), 10)
Expand Down
8 changes: 4 additions & 4 deletions ant-node-manager/src/cmd/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use crate::{
helpers::{download_and_extract_release, get_bin_version},
print_banner, refresh_node_registry, status_report, ServiceManager, VerbosityLevel,
};
use ant_bootstrap::PeersArgs;
use ant_evm::{EvmNetwork, RewardsAddress};
use ant_logging::LogFormat;
use ant_peers_acquisition::PeersArgs;
use ant_releases::{AntReleaseRepoActions, ReleaseType};
use ant_service_management::{
control::{ServiceControl, ServiceController},
Expand Down Expand Up @@ -117,13 +117,13 @@ pub async fn add(
// If the `antnode` binary we're using has `network-contacts` enabled (which is the case for released binaries),
// it's fine if the service definition doesn't call `antnode` with a `--peer` argument.
let is_first = peers_args.first;
let bootstrap_peers = match peers_args.get_peers_exclude_network_contacts().await {
let bootstrap_peers = match peers_args.get_addrs().await {
Ok(peers) => {
info!("Obtained peers of length {}", peers.len());
peers
peers.into_iter().take(10).collect::<Vec<_>>()
}
Err(err) => match err {
ant_peers_acquisition::error::Error::PeersNotObtained => {
ant_bootstrap::error::Error::NoBootstrapPeersFound => {
info!("No bootstrap peers obtained, setting empty vec.");
Vec::new()
}
Expand Down
1 change: 0 additions & 1 deletion ant-node-rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ nightly = []
[dependencies]
ant-build-info = { path = "../ant-build-info", version = "0.1.19" }
ant-logging = { path = "../ant-logging", version = "0.2.40" }
ant-peers-acquisition = { path = "../ant-peers-acquisition", version = "0.5.7" }
ant-protocol = { path = "../ant-protocol", version = "0.17.15", features=["rpc"] }
ant-node = { path = "../ant-node", version = "0.112.6" }
ant-service-management = { path = "../ant-service-management", version = "0.4.3" }
Expand Down
4 changes: 1 addition & 3 deletions ant-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ path = "src/bin/antnode/main.rs"
default = ["metrics", "upnp", "open-metrics", "encrypt-records"]
encrypt-records = ["ant-networking/encrypt-records"]
extension-module = ["pyo3/extension-module"]
local = ["ant-networking/local", "ant-evm/local"]
local = ["ant-networking/local", "ant-evm/local", "ant-bootstrap/local"]
loud = ["ant-networking/loud"] # loud mode: print important messages to console
metrics = ["ant-logging/process-metrics"]
network-contacts = ["ant-peers-acquisition/network-contacts"]
nightly = []
open-metrics = ["ant-networking/open-metrics", "prometheus-client"]
otlp = ["ant-logging/otlp"]
Expand All @@ -33,7 +32,6 @@ ant-build-info = { path = "../ant-build-info", version = "0.1.19" }
ant-evm = { path = "../ant-evm", version = "0.1.4" }
ant-logging = { path = "../ant-logging", version = "0.2.40" }
ant-networking = { path = "../ant-networking", version = "0.19.5" }
ant-peers-acquisition = { path = "../ant-peers-acquisition", version = "0.5.7" }
ant-protocol = { path = "../ant-protocol", version = "0.17.15" }
ant-registers = { path = "../ant-registers", version = "0.4.3" }
ant-service-management = { path = "../ant-service-management", version = "0.4.3" }
Expand Down
2 changes: 1 addition & 1 deletion ant-node/src/bin/antnode/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,12 @@ fn monitor_node_events(mut node_events_rx: NodeEventsReceiver, ctrl_tx: mpsc::Se

fn init_logging(opt: &Opt, peer_id: PeerId) -> Result<(String, ReloadHandle, Option<WorkerGuard>)> {
let logging_targets = vec![
("ant_bootstrap".to_string(), Level::INFO),
("ant_build_info".to_string(), Level::DEBUG),
("ant_evm".to_string(), Level::DEBUG),
("ant_logging".to_string(), Level::DEBUG),
("ant_networking".to_string(), Level::INFO),
("ant_node".to_string(), Level::DEBUG),
("ant_peers_acquisition".to_string(), Level::DEBUG),
("ant_protocol".to_string(), Level::DEBUG),
("ant_registers".to_string(), Level::DEBUG),
("antnode".to_string(), Level::DEBUG),
Expand Down
Loading

0 comments on commit 3f4b9d6

Please sign in to comment.