diff --git a/.github/workflows/memcheck.yml b/.github/workflows/memcheck.yml index 2105f43b1b..4784b5d34b 100644 --- a/.github/workflows/memcheck.yml +++ b/.github/workflows/memcheck.yml @@ -99,7 +99,8 @@ jobs: mkdir $ANT_DATA_PATH/client ls -l $ANT_DATA_PATH ./target/release/ant --log-output-dest=data-dir --local file upload --public "./the-test-data.zip" > ./upload_output_second 2>&1 - rg 'Total cost: 0 AttoTokens' ./upload_output_second -c --stats + ./target/release/ant --log-output-dest=data-dir --local file upload --public "./the-test-data.zip" > ./upload_output_second 2>&1 + rg 'All chunks already exist on the network.' ./upload_output_second -c --stats env: ANT_LOG: "all" timeout-minutes: 25 diff --git a/Cargo.lock b/Cargo.lock index 724e4c6d1e..c5e8fd153b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -772,7 +772,7 @@ dependencies = [ [[package]] name = "ant-bootstrap" -version = "0.1.2" +version = "0.1.3" dependencies = [ "ant-logging", "ant-protocol", @@ -796,7 +796,7 @@ dependencies = [ [[package]] name = "ant-build-info" -version = "0.1.22" +version = "0.1.23" dependencies = [ "chrono", "tracing", @@ -805,7 +805,7 @@ dependencies = [ [[package]] name = "ant-cli" -version = "0.3.2" +version = "0.3.3" dependencies = [ "ant-bootstrap", "ant-build-info", @@ -836,7 +836,7 @@ dependencies = [ [[package]] name = "ant-evm" -version = "0.1.7" +version = "0.1.8" dependencies = [ "custom_debug", "evmlib", @@ -858,7 +858,7 @@ dependencies = [ [[package]] name = "ant-logging" -version = "0.2.43" +version = "0.2.44" dependencies = [ "chrono", "color-eyre", @@ -883,7 +883,7 @@ dependencies = [ [[package]] name = "ant-metrics" -version = "0.1.23" +version = "0.1.24" dependencies = [ "clap", "color-eyre", @@ -897,7 +897,7 @@ dependencies = [ [[package]] name = "ant-networking" -version = "0.3.2" +version = "0.3.3" dependencies = [ "aes-gcm-siv", "ant-bootstrap", @@ -938,7 +938,7 @@ dependencies = [ [[package]] name = "ant-node" -version = "0.3.2" +version = "0.3.3" dependencies = [ "ant-bootstrap", "ant-build-info", @@ -996,7 +996,7 @@ dependencies = [ [[package]] name = "ant-node-manager" -version = "0.11.6" +version = "0.11.7" dependencies = [ "ant-bootstrap", "ant-build-info", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "ant-node-rpc-client" -version = "0.6.39" +version = "0.6.40" dependencies = [ "ant-build-info", "ant-logging", @@ -1063,7 +1063,7 @@ dependencies = [ [[package]] name = "ant-protocol" -version = "0.3.2" +version = "0.3.3" dependencies = [ "ant-build-info", "ant-evm", @@ -1095,7 +1095,7 @@ dependencies = [ [[package]] name = "ant-registers" -version = "0.4.6" +version = "0.4.7" dependencies = [ "blsttc", "crdts", @@ -1132,7 +1132,7 @@ dependencies = [ [[package]] name = "ant-service-management" -version = "0.4.6" +version = "0.4.7" dependencies = [ "ant-bootstrap", "ant-evm", @@ -1159,7 +1159,7 @@ dependencies = [ [[package]] name = "ant-token-supplies" -version = "0.1.61" +version = "0.1.62" dependencies = [ "dirs-next", "reqwest 0.11.27", @@ -1568,7 +1568,7 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "autonomi" -version = "0.3.2" +version = "0.3.3" dependencies = [ "alloy", "ant-bootstrap", @@ -1593,6 +1593,7 @@ dependencies = [ "rmp-serde", "self_encryption", "serde", + "serial_test", "sha2", "test-utils", "thiserror 1.0.69", @@ -3156,7 +3157,7 @@ dependencies = [ [[package]] name = "evm-testnet" -version = "0.1.7" +version = "0.1.8" dependencies = [ "ant-evm", "clap", @@ -3167,7 +3168,7 @@ dependencies = [ [[package]] name = "evmlib" -version = "0.1.7" +version = "0.1.8" dependencies = [ "alloy", "dirs-next", @@ -5964,7 +5965,7 @@ dependencies = [ [[package]] name = "nat-detection" -version = "0.2.14" +version = "0.2.15" dependencies = [ "ant-build-info", "ant-networking", @@ -6081,7 +6082,7 @@ dependencies = [ [[package]] name = "node-launchpad" -version = "0.5.2" +version = "0.5.3" dependencies = [ "ant-bootstrap", "ant-build-info", @@ -7963,6 +7964,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scc" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640" +dependencies = [ + "sdd", +] + [[package]] name = "schnellru" version = "0.2.4" @@ -8006,6 +8016,12 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "sdd" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" + [[package]] name = "sec1" version = "0.7.3" @@ -8189,6 +8205,31 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "serial_test" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.94", +] + [[package]] name = "service-manager" version = "0.7.1" @@ -8632,7 +8673,7 @@ checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] name = "test-utils" -version = "0.4.14" +version = "0.4.15" dependencies = [ "bytes", "color-eyre", diff --git a/ant-bootstrap/Cargo.toml b/ant-bootstrap/Cargo.toml index ae02dca4e3..0937de2e51 100644 --- a/ant-bootstrap/Cargo.toml +++ b/ant-bootstrap/Cargo.toml @@ -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"] } diff --git a/ant-build-info/Cargo.toml b/ant-build-info/Cargo.toml index 6a7482355e..f664ce5419 100644 --- a/ant-build-info/Cargo.toml +++ b/ant-build-info/Cargo.toml @@ -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"] diff --git a/ant-build-info/src/release_info.rs b/ant-build-info/src/release_info.rs index 74f6d99021..c87bb79fe8 100644 --- a/ant-build-info/src/release_info.rs +++ b/ant-build-info/src/release_info.rs @@ -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"; diff --git a/ant-cli/Cargo.toml b/ant-cli/Cargo.toml index 5b7e369f66..09930fc2c6 100644 --- a/ant-cli/Cargo.toml +++ b/ant-cli/Cargo.toml @@ -3,7 +3,7 @@ authors = ["MaidSafe Developers "] 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" @@ -23,13 +23,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 = [ - "loud", -] } +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 = [ "loud" ] } clap = { version = "4.2.1", features = ["derive"] } color-eyre = "0.6.3" const-hex = "1.13.1" @@ -56,7 +54,7 @@ tracing = { version = "~0.1.26" } walkdir = "2.5.0" [dev-dependencies] -autonomi = { path = "../autonomi", version = "0.3.2"} +autonomi = { path = "../autonomi", version = "0.3.3" } criterion = "0.5.1" eyre = "0.6.8" rand = { version = "~0.8.5", features = ["small_rng"] } diff --git a/ant-cli/src/commands/file.rs b/ant-cli/src/commands/file.rs index 23ba6c7afe..b70df5e604 100644 --- a/ant-cli/src/commands/file.rs +++ b/ant-cli/src/commands/file.rs @@ -76,13 +76,17 @@ pub async fn upload(file: &str, public: bool, peers: NetworkPeers) -> Result<()> // get summary let summary = upload_summary_thread.await?; - if summary.record_count == 0 { + if summary.records_paid == 0 { println!("All chunks already exist on the network."); } else { println!("Successfully uploaded: {file}"); println!("At address: {local_addr}"); info!("Successfully uploaded: {file} at address: {local_addr}"); - println!("Number of chunks uploaded: {}", summary.record_count); + println!("Number of chunks uploaded: {}", summary.records_paid); + println!( + "Number of chunks already paid/uploaded: {}", + summary.records_already_paid + ); println!("Total cost: {} AttoTokens", summary.tokens_spent); } info!("Summary for upload of file {file} at {local_addr:?}: {summary:?}"); diff --git a/ant-cli/src/commands/register.rs b/ant-cli/src/commands/register.rs index 9b95fb7670..993617241b 100644 --- a/ant-cli/src/commands/register.rs +++ b/ant-cli/src/commands/register.rs @@ -99,7 +99,7 @@ pub async fn create(name: &str, value: &str, public: bool, peers: NetworkPeers) } let summary = upload_summary_thread.await?; - if summary.record_count == 0 { + if summary.records_paid == 0 { println!("✅ The register already exists on the network at address: {address}."); println!("No tokens were spent."); } else { diff --git a/ant-cli/src/utils.rs b/ant-cli/src/utils.rs index 5f031a3c24..19f02878f9 100644 --- a/ant-cli/src/utils.rs +++ b/ant-cli/src/utils.rs @@ -20,6 +20,7 @@ pub fn collect_upload_summary( let stats_thread = tokio::spawn(async move { let mut tokens_spent: Amount = Amount::from(0); let mut record_count = 0; + let mut records_already_paid = 0; loop { tokio::select! { @@ -27,7 +28,8 @@ pub fn collect_upload_summary( match event { Some(ClientEvent::UploadComplete(upload_summary)) => { tokens_spent += upload_summary.tokens_spent; - record_count += upload_summary.record_count; + record_count += upload_summary.records_paid; + records_already_paid += upload_summary.records_already_paid; } None => break, } @@ -41,14 +43,16 @@ pub fn collect_upload_summary( match event { ClientEvent::UploadComplete(upload_summary) => { tokens_spent += upload_summary.tokens_spent; - record_count += upload_summary.record_count; + record_count += upload_summary.records_paid; + records_already_paid += upload_summary.records_already_paid; } } } UploadSummary { tokens_spent, - record_count, + records_paid: record_count, + records_already_paid, } }); diff --git a/ant-evm/Cargo.toml b/ant-evm/Cargo.toml index 0a6656f6c0..6ccb20a4f4 100644 --- a/ant-evm/Cargo.toml +++ b/ant-evm/Cargo.toml @@ -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] external-signer = ["evmlib/external-signer"] @@ -15,7 +15,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"] } diff --git a/ant-logging/Cargo.toml b/ant-logging/Cargo.toml index 1f3af70840..73cf123b94 100644 --- a/ant-logging/Cargo.toml +++ b/ant-logging/Cargo.toml @@ -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" diff --git a/ant-metrics/Cargo.toml b/ant-metrics/Cargo.toml index 8e443c3abb..4457f887b7 100644 --- a/ant-metrics/Cargo.toml +++ b/ant-metrics/Cargo.toml @@ -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" diff --git a/ant-networking/Cargo.toml b/ant-networking/Cargo.toml index ca6dd480aa..efa470d678 100644 --- a/ant-networking/Cargo.toml +++ b/ant-networking/Cargo.toml @@ -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 = [] @@ -17,11 +17,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" bls = { package = "blsttc", version = "8.0.2" } bytes = { version = "1.0.1", features = ["serde"] } diff --git a/ant-networking/src/bootstrap.rs b/ant-networking/src/bootstrap.rs index ecdf71397c..84a9e73c51 100644 --- a/ant-networking/src/bootstrap.rs +++ b/ant-networking/src/bootstrap.rs @@ -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; @@ -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; @@ -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 diff --git a/ant-networking/src/event/swarm.rs b/ant-networking/src/event/swarm.rs index 34e7c6574f..e6eef4e576 100644 --- a/ant-networking/src/event/swarm.rs +++ b/ant-networking/src/event/swarm.rs @@ -549,7 +549,7 @@ impl SwarmDriver { error, } => { event_string = "Incoming ConnErr"; - // Only log as ERROR if the the connection is not adjacent to an already established connection id from + // Only log as ERROR if the connection is not adjacent to an already established connection id from // the same IP address. // // If a peer contains multiple transports/listen addrs, we might try to open multiple connections, diff --git a/ant-networking/src/metrics/bad_node.rs b/ant-networking/src/metrics/bad_node.rs index 311c0ca8aa..23d8a8afa1 100644 --- a/ant-networking/src/metrics/bad_node.rs +++ b/ant-networking/src/metrics/bad_node.rs @@ -46,7 +46,7 @@ struct ShunnedByCloseGroup { old_new_group_shunned_list: HashSet, } -/// A struct to record the the number of reports against our node across different time frames. +/// A struct to record the number of reports against our node across different time frames. struct ShunnedCountAcrossTimeFrames { metric: Family, shunned_report_tracker: Vec, diff --git a/ant-networking/src/network_discovery.rs b/ant-networking/src/network_discovery.rs index f00a75c2d8..39fa45e51c 100644 --- a/ant-networking/src/network_discovery.rs +++ b/ant-networking/src/network_discovery.rs @@ -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) -> 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::() % candidates.len(); candidates.get(random_index) diff --git a/ant-node-manager/Cargo.toml b/ant-node-manager/Cargo.toml index 3859f2e054..95430a7377 100644 --- a/ant-node-manager/Cargo.toml +++ b/ant-node-manager/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "ant-node-manager" readme = "README.md" repository = "https://github.com/maidsafe/autonomi" -version = "0.11.6" +version = "0.11.7" [[bin]] name = "antctl" @@ -29,13 +29,13 @@ tcp = [] websockets = [] [dependencies] -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-logging = { path = "../ant-logging", version = "0.2.43" } -ant-protocol = { path = "../ant-protocol", version = "0.3.2" } +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-logging = { path = "../ant-logging", version = "0.2.44" } +ant-protocol = { path = "../ant-protocol", version = "0.3.3" } ant-releases = { version = "0.4.0" } -ant-service-management = { path = "../ant-service-management", version = "0.4.6" } +ant-service-management = { path = "../ant-service-management", version = "0.4.7" } chrono = "~0.4.19" clap = { version = "4.4.6", features = ["derive", "env"] } colored = "2.0.4" diff --git a/ant-node-manager/src/add_services/config.rs b/ant-node-manager/src/add_services/config.rs index 7aac0eaeb6..b2037bbc86 100644 --- a/ant-node-manager/src/add_services/config.rs +++ b/ant-node-manager/src/add_services/config.rs @@ -85,7 +85,6 @@ pub struct InstallNodeServiceCtxBuilder { pub metrics_port: Option, pub node_ip: Option, pub node_port: Option, - pub owner: Option, pub peers_args: PeersArgs, pub rewards_address: RewardsAddress, pub rpc_socket_addr: SocketAddr, @@ -132,10 +131,6 @@ impl InstallNodeServiceCtxBuilder { args.push(OsString::from("--metrics-server-port")); args.push(OsString::from(metrics_port.to_string())); } - if let Some(owner) = self.owner { - args.push(OsString::from("--owner")); - args.push(OsString::from(owner)); - } if let Some(log_files) = self.max_archived_log_files { args.push(OsString::from("--max-archived-log-files")); args.push(OsString::from(log_files.to_string())); @@ -193,7 +188,6 @@ pub struct AddNodeServiceOptions { pub network_id: Option, pub node_ip: Option, pub node_port: Option, - pub owner: Option, pub peers_args: PeersArgs, pub rewards_address: RewardsAddress, pub rpc_address: Option, @@ -327,7 +321,6 @@ mod tests { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124") .unwrap(), @@ -363,7 +356,6 @@ mod tests { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124") .unwrap(), @@ -400,7 +392,6 @@ mod tests { network_id: Some(5), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124") .unwrap(), @@ -490,7 +481,6 @@ mod tests { builder.node_ip = Some(Ipv4Addr::new(192, 168, 1, 1)); builder.node_port = Some(12345); builder.metrics_port = Some(9090); - builder.owner = Some("test-owner".to_string()); builder.peers_args.addrs = vec![ "/ip4/127.0.0.1/tcp/8080".parse().unwrap(), "/ip4/192.168.1.1/tcp/8081".parse().unwrap(), @@ -531,8 +521,6 @@ mod tests { "12345", "--metrics-server-port", "9090", - "--owner", - "test-owner", "--max-archived-log-files", "10", "--max-log-files", diff --git a/ant-node-manager/src/add_services/mod.rs b/ant-node-manager/src/add_services/mod.rs index 76e8d46c12..842040b49c 100644 --- a/ant-node-manager/src/add_services/mod.rs +++ b/ant-node-manager/src/add_services/mod.rs @@ -78,16 +78,6 @@ pub async fn add_node( check_port_availability(port_option, &node_registry.nodes)?; } - let owner = match &options.owner { - Some(owner) => { - if owner.chars().any(|c| c.is_uppercase()) { - warn!("Owner name ({owner}) contains uppercase characters and will be converted to lowercase"); - } - Some(owner.to_lowercase()) - } - None => None, - }; - let antnode_file_name = options .antnode_src_path .file_name() @@ -213,7 +203,6 @@ pub async fn add_node( network_id: options.network_id, node_ip: options.node_ip, node_port, - owner: owner.clone(), peers_args: options.peers_args.clone(), rewards_address: options.rewards_address, rpc_socket_addr, @@ -254,7 +243,6 @@ pub async fn add_node( rewards_address: options.rewards_address, reward_balance: None, rpc_socket_addr, - owner: owner.clone(), peer_id: None, peers_args: options.peers_args.clone(), pid: None, diff --git a/ant-node-manager/src/add_services/tests.rs b/ant-node-manager/src/add_services/tests.rs index 58eaf31162..e1b2bea58a 100644 --- a/ant-node-manager/src/add_services/tests.rs +++ b/ant-node-manager/src/add_services/tests.rs @@ -142,7 +142,6 @@ async fn add_genesis_node_should_use_latest_version_and_add_one_service() -> Res network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -177,7 +176,6 @@ async fn add_genesis_node_should_use_latest_version_and_add_one_service() -> Res network_id: None, node_ip: None, node_port: None, - owner: None, peers_args, rpc_address: None, rpc_port: None, @@ -300,7 +298,6 @@ async fn add_genesis_node_should_return_an_error_if_there_is_already_a_genesis_n node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: peers_args.clone(), pid: None, @@ -347,7 +344,6 @@ async fn add_genesis_node_should_return_an_error_if_there_is_already_a_genesis_n network_id: None, node_ip: None, node_port: None, - owner: None, peers_args, rpc_address: Some(custom_rpc_address), rpc_port: None, @@ -437,7 +433,6 @@ async fn add_genesis_node_should_return_an_error_if_count_is_greater_than_1() -> network_id: None, node_ip: None, node_port: None, - owner: None, peers_args, rpc_address: None, rpc_port: None, @@ -534,7 +529,6 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), antnode_path: node_data_dir @@ -583,7 +577,6 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( name: "antnode2".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8083), @@ -632,7 +625,6 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( name: "antnode3".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8085), @@ -668,7 +660,6 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -815,7 +806,6 @@ async fn add_node_should_update_the_environment_variables_inside_node_registry() name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -850,7 +840,6 @@ async fn add_node_should_update_the_environment_variables_inside_node_registry() network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -946,7 +935,6 @@ async fn add_new_node_should_add_another_service() -> Result<()> { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -1006,7 +994,6 @@ async fn add_new_node_should_add_another_service() -> Result<()> { peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8083), - owner: None, antnode_path: node_data_dir .to_path_buf() .join("antnode2") @@ -1039,7 +1026,6 @@ async fn add_new_node_should_add_another_service() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -1203,7 +1189,6 @@ async fn add_node_should_create_service_file_with_first_arg() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rpc_address: None, rpc_port: None, @@ -1360,7 +1345,6 @@ async fn add_node_should_create_service_file_with_peers_args() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rpc_address: None, rpc_port: None, @@ -1512,7 +1496,6 @@ async fn add_node_should_create_service_file_with_local_arg() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rpc_address: None, rpc_port: None, @@ -1668,7 +1651,6 @@ async fn add_node_should_create_service_file_with_network_contacts_url_arg() -> network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rpc_address: None, rpc_port: None, @@ -1823,7 +1805,6 @@ async fn add_node_should_create_service_file_with_testnet_arg() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rpc_address: None, rpc_port: None, @@ -1975,7 +1956,6 @@ async fn add_node_should_create_service_file_with_ignore_cache_arg() -> Result<( network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rpc_address: None, rpc_port: None, @@ -2128,7 +2108,6 @@ async fn add_node_should_create_service_file_with_custom_bootstrap_cache_path() network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: peers_args.clone(), rpc_address: None, rpc_port: None, @@ -2274,7 +2253,6 @@ async fn add_node_should_create_service_file_with_network_id() -> Result<()> { network_id: Some(5), node_ip: None, node_port: None, - owner: None, peers_args: Default::default(), rpc_address: None, rpc_port: None, @@ -2418,7 +2396,6 @@ async fn add_node_should_use_custom_ip() -> Result<()> { network_id: None, node_ip: Some(custom_ip), node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -2516,7 +2493,6 @@ async fn add_node_should_use_custom_ports_for_one_service() -> Result<()> { name: "antnode1".to_string(), node_ip: None, node_port: Some(custom_port), - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -2552,7 +2528,6 @@ async fn add_node_should_use_custom_ports_for_one_service() -> Result<()> { network_id: None, node_ip: None, node_port: Some(PortRange::Single(custom_port)), - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -2810,7 +2785,6 @@ async fn add_node_should_use_a_custom_port_range() -> Result<()> { network_id: None, node_ip: None, node_port: Some(PortRange::Range(12000, 12002)), - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -2886,7 +2860,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_is_used() -> R node_ip: None, node_port: Some(12000), number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -2931,7 +2904,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_is_used() -> R network_id: None, node_ip: None, node_port: Some(PortRange::Single(12000)), - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3004,7 +2976,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_in_range_is_us network_id: None, node_ip: None, node_port: Some(12000), - owner: None, peers_args: PeersArgs::default(), number: 1, peer_id: None, @@ -3050,7 +3021,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_in_range_is_us network_id: None, node_ip: None, node_port: Some(PortRange::Range(12000, 12002)), - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3129,7 +3099,6 @@ async fn add_node_should_return_an_error_if_port_and_node_count_do_not_match() - network_id: None, node_ip: None, node_port: Some(PortRange::Range(12000, 12002)), - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3213,7 +3182,6 @@ async fn add_node_should_return_an_error_if_multiple_services_are_specified_with network_id: None, node_ip: None, node_port: Some(PortRange::Single(12000)), - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3359,7 +3327,6 @@ async fn add_node_should_set_random_ports_if_enable_metrics_server_is_true() -> network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3497,7 +3464,6 @@ async fn add_node_should_set_max_archived_log_files() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3636,7 +3602,6 @@ async fn add_node_should_set_max_log_files() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3889,7 +3854,6 @@ async fn add_node_should_use_a_custom_port_range_for_metrics_server() -> Result< network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -3962,7 +3926,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_is_use node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -4007,7 +3970,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_is_use network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -4082,7 +4044,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_in_ran node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -4127,7 +4088,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_in_ran network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -4363,7 +4323,6 @@ async fn add_node_should_use_a_custom_port_range_for_the_rpc_server() -> Result< network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: Some(PortRange::Range(20000, 20002)), @@ -4447,7 +4406,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_is_used() node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -4492,7 +4450,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_is_used() network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: Some(PortRange::Single(8081)), @@ -4567,7 +4524,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_in_range_i node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -4612,7 +4568,6 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_in_range_i network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: Some(PortRange::Range(8081, 8082)), @@ -4708,7 +4663,6 @@ async fn add_node_should_disable_upnp_and_home_network_if_nat_status_is_public() name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -4743,7 +4697,6 @@ async fn add_node_should_disable_upnp_and_home_network_if_nat_status_is_public() network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -4836,7 +4789,6 @@ async fn add_node_should_enable_upnp_if_nat_status_is_upnp() -> Result<()> { name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -4871,7 +4823,6 @@ async fn add_node_should_enable_upnp_if_nat_status_is_upnp() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -4964,7 +4915,6 @@ async fn add_node_should_enable_home_network_if_nat_status_is_private() -> Resul name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -4999,7 +4949,6 @@ async fn add_node_should_enable_home_network_if_nat_status_is_private() -> Resul network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -5086,7 +5035,6 @@ async fn add_node_should_return_an_error_if_nat_status_is_none_but_auto_set_nat_ network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -5708,7 +5656,6 @@ async fn add_node_should_not_delete_the_source_binary_if_path_arg_is_used() -> R name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -5744,7 +5691,6 @@ async fn add_node_should_not_delete_the_source_binary_if_path_arg_is_used() -> R network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -5838,7 +5784,6 @@ async fn add_node_should_apply_the_home_network_flag_if_it_is_used() -> Result<( name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -5874,7 +5819,6 @@ async fn add_node_should_apply_the_home_network_flag_if_it_is_used() -> Result<( network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -5968,7 +5912,6 @@ async fn add_node_should_add_the_node_in_user_mode() -> Result<()> { name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -6004,7 +5947,6 @@ async fn add_node_should_add_the_node_in_user_mode() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -6095,7 +6037,6 @@ async fn add_node_should_add_the_node_with_upnp_enabled() -> Result<()> { name: "antnode1".to_string(), node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rewards_address: RewardsAddress::from_str("0x03B770D9cD32077cC0bF330c13C114a87643B124")?, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -6131,7 +6072,6 @@ async fn add_node_should_add_the_node_with_upnp_enabled() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: None, peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, @@ -6168,145 +6108,6 @@ async fn add_node_should_add_the_node_with_upnp_enabled() -> Result<()> { Ok(()) } -#[tokio::test] -async fn add_node_should_assign_an_owner_in_lowercase() -> Result<()> { - let tmp_data_dir = assert_fs::TempDir::new()?; - let node_reg_path = tmp_data_dir.child("node_reg.json"); - - let latest_version = "0.96.4"; - let temp_dir = assert_fs::TempDir::new()?; - let node_data_dir = temp_dir.child("data"); - node_data_dir.create_dir_all()?; - let node_logs_dir = temp_dir.child("logs"); - node_logs_dir.create_dir_all()?; - let antnode_download_path = temp_dir.child(ANTNODE_FILE_NAME); - antnode_download_path.write_binary(b"fake antnode bin")?; - - let mut node_registry = NodeRegistry { - auditor: None, - daemon: None, - environment_variables: None, - faucet: None, - nat_status: None, - nodes: vec![], - save_path: node_reg_path.to_path_buf(), - }; - - let mut mock_service_control = MockServiceControl::new(); - let mut seq = Sequence::new(); - mock_service_control - .expect_get_available_port() - .times(1) - .returning(|| Ok(8081)) - .in_sequence(&mut seq); - - mock_service_control - .expect_install() - .with( - eq(ServiceInstallCtx { - args: vec![ - OsString::from("--rpc"), - OsString::from("127.0.0.1:8081"), - OsString::from("--root-dir"), - OsString::from( - node_data_dir - .to_path_buf() - .join("antnode1") - .to_string_lossy() - .to_string(), - ), - OsString::from("--log-output-dest"), - OsString::from( - node_logs_dir - .to_path_buf() - .join("antnode1") - .to_string_lossy() - .to_string(), - ), - OsString::from("--owner"), - OsString::from("discord_username"), - OsString::from("--rewards-address"), - OsString::from("0x03B770D9cD32077cC0bF330c13C114a87643B124"), - OsString::from("evm-custom"), - OsString::from("--rpc-url"), - OsString::from("http://localhost:8545/"), - OsString::from("--payment-token-address"), - OsString::from("0x5FbDB2315678afecb367f032d93F642f64180aa3"), - OsString::from("--data-payments-address"), - OsString::from("0x8464135c8F25Da09e49BC8782676a84730C318bC"), - ], - autostart: false, - contents: None, - environment: None, - label: "antnode1".parse()?, - program: node_data_dir - .to_path_buf() - .join("antnode1") - .join(ANTNODE_FILE_NAME), - username: Some(get_username()), - working_directory: None, - }), - eq(false), - ) - .times(1) - .returning(|_, _| Ok(())) - .in_sequence(&mut seq); - - add_node( - AddNodeServiceOptions { - auto_restart: false, - auto_set_nat_flags: false, - count: None, - delete_antnode_src: true, - enable_metrics_server: false, - env_variables: None, - home_network: false, - log_format: None, - max_archived_log_files: None, - max_log_files: None, - metrics_port: None, - network_id: None, - node_ip: None, - node_port: None, - owner: Some("Discord_Username".to_string()), - peers_args: PeersArgs::default(), - rpc_address: None, - rpc_port: None, - antnode_dir_path: temp_dir.to_path_buf(), - antnode_src_path: antnode_download_path.to_path_buf(), - service_data_dir_path: node_data_dir.to_path_buf(), - service_log_dir_path: node_logs_dir.to_path_buf(), - upnp: false, - user: Some(get_username()), - user_mode: false, - version: latest_version.to_string(), - evm_network: EvmNetwork::Custom(CustomNetwork { - rpc_url_http: "http://localhost:8545".parse()?, - payment_token_address: RewardsAddress::from_str( - "0x5FbDB2315678afecb367f032d93F642f64180aa3", - )?, - data_payments_address: RewardsAddress::from_str( - "0x8464135c8F25Da09e49BC8782676a84730C318bC", - )?, - }), - rewards_address: RewardsAddress::from_str( - "0x03B770D9cD32077cC0bF330c13C114a87643B124", - )?, - }, - &mut node_registry, - &mock_service_control, - VerbosityLevel::Normal, - ) - .await?; - - assert_eq!( - node_registry.nodes[0].owner, - Some("discord_username".to_string()) - ); - - Ok(()) -} - #[tokio::test] async fn add_node_should_auto_restart() -> Result<()> { let tmp_data_dir = assert_fs::TempDir::new()?; @@ -6362,8 +6163,6 @@ async fn add_node_should_auto_restart() -> Result<()> { .to_string_lossy() .to_string(), ), - OsString::from("--owner"), - OsString::from("discord_username"), OsString::from("--rewards-address"), OsString::from("0x03B770D9cD32077cC0bF330c13C114a87643B124"), OsString::from("evm-custom"), @@ -6407,7 +6206,6 @@ async fn add_node_should_auto_restart() -> Result<()> { network_id: None, node_ip: None, node_port: None, - owner: Some("discord_username".to_string()), peers_args: PeersArgs::default(), rpc_address: None, rpc_port: None, diff --git a/ant-node-manager/src/bin/cli/main.rs b/ant-node-manager/src/bin/cli/main.rs index b440cb09d8..fa6dbb71c7 100644 --- a/ant-node-manager/src/bin/cli/main.rs +++ b/ant-node-manager/src/bin/cli/main.rs @@ -191,15 +191,6 @@ pub enum SubCmd { /// services, which in this case would be 5. The range must also go from lower to higher. #[clap(long, value_parser = PortRange::parse)] node_port: Option, - /// Specify the owner for the node service. - /// - /// This is mainly used for the 'Beta Rewards' programme, for linking your Discord username - /// to the node. - /// - /// If the option is not used, the node will assign its own username and the service will - /// run as normal. - #[clap(long)] - owner: Option, /// Provide a path for the antnode binary to be used by the service. /// /// Useful for creating the service using a custom built binary. @@ -862,19 +853,6 @@ pub enum LocalSubCmd { node_version: Option, #[command(flatten)] peers: PeersArgs, - /// Specify the owner for each node in the local network - /// - /// The argument exists to support testing scenarios. - #[clap(long, conflicts_with = "owner_prefix")] - owner: Option, - /// Use this argument to launch each node in the network with an individual owner. - /// - /// Assigned owners will take the form "prefix_1", "prefix_2" etc., where "prefix" will be - /// replaced by the value specified by this argument. - /// - /// The argument exists to support testing scenarios. - #[clap(long, conflicts_with = "owner")] - owner_prefix: Option, /// Specify a port for the RPC service(s). /// /// If not used, ports will be selected at random. @@ -972,20 +950,6 @@ pub enum LocalSubCmd { /// The version and path arguments are mutually exclusive. #[clap(long, conflicts_with = "build")] node_version: Option, - /// Specify the owner for each node in the local network - /// - /// The argument exists to support testing scenarios. - #[clap(long, conflicts_with = "owner_prefix")] - owner: Option, - /// Use this argument to launch each node in the network with an individual owner. - /// - /// Assigned owners will take the form "prefix_1", "prefix_2" etc., where "prefix" will be - /// replaced by the value specified by this argument. - /// - /// The argument exists to support testing scenarios. - #[clap(long)] - #[clap(long, conflicts_with = "owner")] - owner_prefix: Option, /// Specify a port for the RPC service(s). /// /// If not used, ports will be selected at random. @@ -1083,7 +1047,6 @@ async fn main() -> Result<()> { network_id, node_ip, node_port, - owner, path, peers, rewards_address, @@ -1111,7 +1074,6 @@ async fn main() -> Result<()> { network_id, node_ip, node_port, - owner, peers, rewards_address, rpc_address, @@ -1223,8 +1185,6 @@ async fn main() -> Result<()> { node_port, node_version, log_format, - owner, - owner_prefix, peers, rpc_port, rewards_address, @@ -1246,8 +1206,6 @@ async fn main() -> Result<()> { node_port, node_version, log_format, - owner, - owner_prefix, peers, rpc_port, rewards_address, @@ -1269,8 +1227,6 @@ async fn main() -> Result<()> { node_path, node_port, node_version, - owner, - owner_prefix, rpc_port, rewards_address, evm_network, @@ -1292,8 +1248,6 @@ async fn main() -> Result<()> { node_port, node_version, log_format, - owner, - owner_prefix, rpc_port, rewards_address, evm_network, diff --git a/ant-node-manager/src/cmd/local.rs b/ant-node-manager/src/cmd/local.rs index 2f0b3b465b..736f7806f7 100644 --- a/ant-node-manager/src/cmd/local.rs +++ b/ant-node-manager/src/cmd/local.rs @@ -34,8 +34,6 @@ pub async fn join( node_port: Option, node_version: Option, log_format: Option, - owner: Option, - owner_prefix: Option, _peers_args: PeersArgs, rpc_port: Option, rewards_address: RewardsAddress, @@ -78,8 +76,6 @@ pub async fn join( metrics_port, node_count: count, node_port, - owner, - owner_prefix, peers: None, rpc_port, skip_validation, @@ -119,8 +115,6 @@ pub async fn run( node_port: Option, node_version: Option, log_format: Option, - owner: Option, - owner_prefix: Option, rpc_port: Option, rewards_address: RewardsAddress, evm_network: Option, @@ -188,8 +182,6 @@ pub async fn run( metrics_port, node_port, node_count: count, - owner, - owner_prefix, peers: None, rpc_port, skip_validation, diff --git a/ant-node-manager/src/cmd/node.rs b/ant-node-manager/src/cmd/node.rs index 5ab42c0ea8..3812834811 100644 --- a/ant-node-manager/src/cmd/node.rs +++ b/ant-node-manager/src/cmd/node.rs @@ -52,7 +52,6 @@ pub async fn add( network_id: Option, node_ip: Option, node_port: Option, - owner: Option, mut peers_args: PeersArgs, rewards_address: RewardsAddress, rpc_address: Option, @@ -129,7 +128,6 @@ pub async fn add( network_id, node_ip, node_port, - owner, peers_args, rewards_address, rpc_address, @@ -598,7 +596,6 @@ pub async fn maintain_n_running_nodes( network_id: Option, node_ip: Option, node_port: Option, - owner: Option, peers_args: PeersArgs, rewards_address: RewardsAddress, rpc_address: Option, @@ -703,7 +700,6 @@ pub async fn maintain_n_running_nodes( network_id, node_ip, Some(PortRange::Single(port)), - owner.clone(), peers_args.clone(), rewards_address, rpc_address, diff --git a/ant-node-manager/src/lib.rs b/ant-node-manager/src/lib.rs index 8b2aaee95b..e0d6d908d3 100644 --- a/ant-node-manager/src/lib.rs +++ b/ant-node-manager/src/lib.rs @@ -771,7 +771,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -885,7 +884,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -964,7 +962,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -1083,7 +1080,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -1175,7 +1171,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -1277,7 +1272,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -1378,7 +1372,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -1449,7 +1442,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -1512,7 +1504,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -1573,7 +1564,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -1637,7 +1627,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: None, peers_args: PeersArgs::default(), pid: None, @@ -1712,7 +1701,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -1852,7 +1840,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -1953,7 +1940,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -2099,7 +2085,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -2257,7 +2242,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -2410,7 +2394,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -2564,7 +2547,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -2743,7 +2725,6 @@ mod tests { node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -2915,7 +2896,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -3093,7 +3073,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -3254,7 +3233,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -3424,7 +3402,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -3604,7 +3581,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -3779,7 +3755,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -3949,7 +3924,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -4129,7 +4103,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -4290,7 +4263,6 @@ network_id: None, network_id: None, node_ip: None, node_port: None, - owner: None, number: 1, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", @@ -4456,7 +4428,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -4618,7 +4589,6 @@ network_id: None, number: 1, node_ip: Some(Ipv4Addr::new(192, 168, 1, 1)), node_port: None, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -4783,7 +4753,6 @@ network_id: None, number: 1, node_ip: None, node_port: Some(12000), - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -4944,7 +4913,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -5109,7 +5077,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -5272,7 +5239,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -5437,7 +5403,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -5483,171 +5448,6 @@ network_id: None, Ok(()) } - #[tokio::test] - async fn upgrade_should_retain_owner() -> Result<()> { - let current_version = "0.1.0"; - let target_version = "0.2.0"; - - let tmp_data_dir = assert_fs::TempDir::new()?; - let current_install_dir = tmp_data_dir.child("antnode_install"); - current_install_dir.create_dir_all()?; - - let current_node_bin = current_install_dir.child("antnode"); - current_node_bin.write_binary(b"fake antnode binary")?; - let target_node_bin = tmp_data_dir.child("antnode"); - target_node_bin.write_binary(b"fake antnode binary")?; - - let mut mock_service_control = MockServiceControl::new(); - let mut mock_rpc_client = MockRpcClient::new(); - - // before binary upgrade - mock_service_control - .expect_get_process_pid() - .with(eq(current_node_bin.to_path_buf().clone())) - .times(1) - .returning(|_| Ok(1000)); - mock_service_control - .expect_stop() - .with(eq("antnode1"), eq(false)) - .times(1) - .returning(|_, _| Ok(())); - - // after binary upgrade - mock_service_control - .expect_uninstall() - .with(eq("antnode1"), eq(false)) - .times(1) - .returning(|_, _| Ok(())); - mock_service_control - .expect_install() - .with( - eq(ServiceInstallCtx { - args: vec![ - OsString::from("--rpc"), - OsString::from("127.0.0.1:8081"), - OsString::from("--root-dir"), - OsString::from("/var/antctl/services/antnode1"), - OsString::from("--log-output-dest"), - OsString::from("/var/log/antnode/antnode1"), - OsString::from("--owner"), - OsString::from("discord_username"), - OsString::from("--rewards-address"), - OsString::from("0x03B770D9cD32077cC0bF330c13C114a87643B124"), - OsString::from("evm-arbitrum-one"), - ], - autostart: false, - contents: None, - environment: None, - label: "antnode1".parse()?, - program: current_node_bin.to_path_buf(), - username: Some("ant".to_string()), - working_directory: None, - }), - eq(false), - ) - .times(1) - .returning(|_, _| Ok(())); - - // after service restart - mock_service_control - .expect_start() - .with(eq("antnode1"), eq(false)) - .times(1) - .returning(|_, _| Ok(())); - mock_service_control - .expect_wait() - .with(eq(3000)) - .times(1) - .returning(|_| ()); - mock_service_control - .expect_get_process_pid() - .with(eq(current_node_bin.to_path_buf().clone())) - .times(1) - .returning(|_| Ok(100)); - - mock_rpc_client.expect_node_info().times(1).returning(|| { - Ok(NodeInfo { - pid: 2000, - peer_id: PeerId::from_str("12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR")?, - data_path: PathBuf::from("/var/antctl/services/antnode1"), - log_path: PathBuf::from("/var/log/antnode/antnode1"), - version: target_version.to_string(), - uptime: std::time::Duration::from_secs(1), // the service was just started - wallet_balance: 0, - }) - }); - mock_rpc_client - .expect_network_info() - .times(1) - .returning(|| { - Ok(NetworkInfo { - connected_peers: Vec::new(), - listeners: Vec::new(), - }) - }); - - let mut service_data = NodeServiceData { - auto_restart: false, - connected_peers: None, - data_dir_path: PathBuf::from("/var/antctl/services/antnode1"), - evm_network: EvmNetwork::ArbitrumOne, - home_network: false, - listen_addr: None, - log_dir_path: PathBuf::from("/var/log/antnode/antnode1"), - log_format: None, - max_archived_log_files: None, - max_log_files: None, - metrics_port: None, - network_id: None, - node_ip: None, - node_port: None, - number: 1, - owner: Some("discord_username".to_string()), - peer_id: Some(PeerId::from_str( - "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", - )?), - peers_args: PeersArgs::default(), - pid: Some(1000), - rewards_address: RewardsAddress::from_str( - "0x03B770D9cD32077cC0bF330c13C114a87643B124", - )?, - reward_balance: Some(AttoTokens::zero()), - rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), - antnode_path: current_node_bin.to_path_buf(), - service_name: "antnode1".to_string(), - status: ServiceStatus::Running, - upnp: false, - user: Some("ant".to_string()), - user_mode: false, - version: current_version.to_string(), - }; - let service = NodeService::new(&mut service_data, Box::new(mock_rpc_client)); - - let mut service_manager = ServiceManager::new( - service, - Box::new(mock_service_control), - VerbosityLevel::Normal, - ); - - service_manager - .upgrade(UpgradeOptions { - auto_restart: false, - env_variables: None, - force: false, - start_service: true, - target_bin_path: target_node_bin.to_path_buf(), - target_version: Version::parse(target_version).unwrap(), - }) - .await?; - - assert_eq!( - service_manager.service.service_data.owner, - Some("discord_username".to_string()) - ); - - Ok(()) - } - #[tokio::test] async fn upgrade_should_retain_auto_restart() -> Result<()> { let current_version = "0.1.0"; @@ -5694,8 +5494,6 @@ network_id: None, OsString::from("/var/antctl/services/antnode1"), OsString::from("--log-output-dest"), OsString::from("/var/log/antnode/antnode1"), - OsString::from("--owner"), - OsString::from("discord_username"), OsString::from("--rewards-address"), OsString::from("0x03B770D9cD32077cC0bF330c13C114a87643B124"), OsString::from("evm-arbitrum-one"), @@ -5767,7 +5565,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: Some("discord_username".to_string()), peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -5856,8 +5653,6 @@ network_id: None, OsString::from("/var/antctl/services/antnode1"), OsString::from("--log-output-dest"), OsString::from("/var/log/antnode/antnode1"), - OsString::from("--owner"), - OsString::from("discord_username"), OsString::from("--rewards-address"), OsString::from("0x03B770D9cD32077cC0bF330c13C114a87643B124"), OsString::from("evm-custom"), @@ -5943,7 +5738,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: Some("discord_username".to_string()), peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -6033,8 +5827,6 @@ network_id: None, OsString::from("/var/antctl/services/antnode1"), OsString::from("--log-output-dest"), OsString::from("/var/log/antnode/antnode1"), - OsString::from("--owner"), - OsString::from("discord_username"), OsString::from("--rewards-address"), OsString::from("0x03B770D9cD32077cC0bF330c13C114a87643B124"), OsString::from("evm-custom"), @@ -6120,7 +5912,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: Some("discord_username".to_string()), peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -6285,7 +6076,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peer_id: Some(PeerId::from_str( "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", )?), @@ -6370,7 +6160,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peers_args: PeersArgs::default(), peer_id: None, pid: None, @@ -6439,7 +6228,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peers_args: PeersArgs::default(), pid: Some(1000), peer_id: Some(PeerId::from_str( @@ -6523,7 +6311,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, peers_args: PeersArgs::default(), pid: Some(1000), peer_id: Some(PeerId::from_str( @@ -6602,7 +6389,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, pid: None, peers_args: PeersArgs::default(), peer_id: None, @@ -6679,7 +6465,6 @@ network_id: None, node_ip: None, node_port: None, number: 1, - owner: None, pid: None, peers_args: PeersArgs::default(), peer_id: None, diff --git a/ant-node-manager/src/local.rs b/ant-node-manager/src/local.rs index 6acd1d6531..a7ed6529cb 100644 --- a/ant-node-manager/src/local.rs +++ b/ant-node-manager/src/local.rs @@ -43,7 +43,6 @@ pub trait Launcher { log_format: Option, metrics_port: Option, node_port: Option, - owner: Option, rpc_socket_addr: SocketAddr, rewards_address: RewardsAddress, evm_network: Option, @@ -67,18 +66,12 @@ impl Launcher for LocalSafeLauncher { log_format: Option, metrics_port: Option, node_port: Option, - owner: Option, rpc_socket_addr: SocketAddr, rewards_address: RewardsAddress, evm_network: Option, ) -> Result<()> { let mut args = Vec::new(); - if let Some(owner) = owner { - args.push("--owner".to_string()); - args.push(owner); - } - if first { args.push("--first".to_string()) } @@ -218,8 +211,6 @@ pub struct LocalNetworkOptions { pub metrics_port: Option, pub node_port: Option, pub node_count: u16, - pub owner: Option, - pub owner_prefix: Option, pub peers: Option>, pub rpc_port: Option, pub skip_validation: bool, @@ -289,7 +280,6 @@ pub async fn run_network( let rpc_client = RpcClient::from_socket_addr(rpc_socket_addr); let number = (node_registry.nodes.len() as u16) + 1; - let owner = get_node_owner(&options.owner_prefix, &options.owner, &number); let node = run_node( RunNodeOptions { first: true, @@ -298,7 +288,6 @@ pub async fn run_network( interval: options.interval, log_format: options.log_format, number, - owner, rpc_socket_addr, rewards_address: options.rewards_address, evm_network: options.evm_network.clone(), @@ -337,7 +326,6 @@ pub async fn run_network( let rpc_client = RpcClient::from_socket_addr(rpc_socket_addr); let number = (node_registry.nodes.len() as u16) + 1; - let owner = get_node_owner(&options.owner_prefix, &options.owner, &number); let node = run_node( RunNodeOptions { first: false, @@ -346,7 +334,6 @@ pub async fn run_network( interval: options.interval, log_format: options.log_format, number, - owner, rpc_socket_addr, rewards_address: options.rewards_address, evm_network: options.evm_network.clone(), @@ -386,7 +373,6 @@ pub struct RunNodeOptions { pub metrics_port: Option, pub node_port: Option, pub number: u16, - pub owner: Option, pub rpc_socket_addr: SocketAddr, pub rewards_address: RewardsAddress, pub evm_network: Option, @@ -405,7 +391,6 @@ pub async fn run_node( run_options.log_format, run_options.metrics_port, run_options.node_port, - run_options.owner.clone(), run_options.rpc_socket_addr, run_options.rewards_address, run_options.evm_network.clone(), @@ -439,7 +424,6 @@ pub async fn run_node( node_ip: None, node_port: run_options.node_port, number: run_options.number, - owner: run_options.owner, peer_id: Some(peer_id), peers_args: PeersArgs { first: run_options.first, @@ -513,18 +497,6 @@ async fn validate_network(node_registry: &mut NodeRegistry, peers: Vec, - owner: &Option, - number: &u16, -) -> Option { - if let Some(prefix) = owner_prefix { - Some(format!("{}_{}", prefix, number)) - } else { - owner.clone() - } -} - #[cfg(test)] mod tests { use super::*; @@ -569,13 +541,12 @@ mod tests { eq(None), eq(None), eq(None), - eq(None), eq(rpc_socket_addr), eq(rewards_address), eq(None), ) .times(1) - .returning(|_, _, _, _, _, _, _, _| Ok(())); + .returning(|_, _, _, _, _, _, _| Ok(())); mock_launcher .expect_wait() .with(eq(100)) @@ -618,7 +589,6 @@ mod tests { metrics_port: None, node_port: None, number: 1, - owner: None, rpc_socket_addr, rewards_address, evm_network: None, diff --git a/ant-node-manager/src/rpc.rs b/ant-node-manager/src/rpc.rs index 1af38833ff..c47a0927ba 100644 --- a/ant-node-manager/src/rpc.rs +++ b/ant-node-manager/src/rpc.rs @@ -77,7 +77,6 @@ pub async fn restart_node_service( network_id: current_node_clone.network_id, node_ip: current_node_clone.node_ip, node_port: current_node_clone.get_antnode_port(), - owner: current_node_clone.owner.clone(), peers_args: current_node_clone.peers_args.clone(), rewards_address: current_node_clone.rewards_address, rpc_socket_addr: current_node_clone.rpc_socket_addr, @@ -193,7 +192,6 @@ pub async fn restart_node_service( network_id: current_node_clone.network_id, node_ip: current_node_clone.node_ip, node_port: None, - owner: None, peers_args: current_node_clone.peers_args.clone(), rewards_address: current_node_clone.rewards_address, rpc_socket_addr: current_node_clone.rpc_socket_addr, @@ -223,7 +221,6 @@ pub async fn restart_node_service( node_ip: current_node_clone.node_ip, node_port: None, number: new_node_number as u16, - owner: None, peer_id: None, peers_args: current_node_clone.peers_args.clone(), pid: None, diff --git a/ant-node-rpc-client/Cargo.toml b/ant-node-rpc-client/Cargo.toml index e33805c1fa..9c94237625 100644 --- a/ant-node-rpc-client/Cargo.toml +++ b/ant-node-rpc-client/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "ant-node-rpc-client" readme = "README.md" repository = "https://github.com/maidsafe/autonomi" -version = "0.6.39" +version = "0.6.40" [[bin]] name = "antnode_rpc_client" @@ -17,11 +17,11 @@ path = "src/main.rs" nightly = [] [dependencies] -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", features=["rpc"] } -ant-node = { path = "../ant-node", version = "0.3.2" } -ant-service-management = { path = "../ant-service-management", version = "0.4.6" } +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", features=["rpc"] } +ant-node = { path = "../ant-node", version = "0.3.3" } +ant-service-management = { path = "../ant-service-management", version = "0.4.7" } async-trait = "0.1" bls = { package = "blsttc", version = "8.0.1" } clap = { version = "4.2.1", features = ["derive"] } diff --git a/ant-node/Cargo.toml b/ant-node/Cargo.toml index 5ca35b65ca..10b7fe126c 100644 --- a/ant-node/Cargo.toml +++ b/ant-node/Cargo.toml @@ -2,7 +2,7 @@ authors = ["MaidSafe Developers "] description = "The Autonomi node binary" name = "ant-node" -version = "0.3.2" +version = "0.3.3" edition = "2021" license = "GPL-3.0" homepage = "https://maidsafe.net" @@ -23,14 +23,14 @@ otlp = ["ant-logging/otlp"] upnp = ["ant-networking/upnp"] [dependencies] -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-logging = { path = "../ant-logging", version = "0.2.43", features = ["process-metrics"] } -ant-networking = { path = "../ant-networking", version = "0.3.2" } -ant-protocol = { path = "../ant-protocol", version = "0.3.2" } -ant-registers = { path = "../ant-registers", version = "0.4.6" } -ant-service-management = { path = "../ant-service-management", 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-logging = { path = "../ant-logging", version = "0.2.44" } +ant-networking = { path = "../ant-networking", version = "0.3.3" } +ant-protocol = { path = "../ant-protocol", version = "0.3.3" } +ant-registers = { path = "../ant-registers", version = "0.4.7" } +ant-service-management = { path = "../ant-service-management", version = "0.4.7" } async-trait = "0.1" bls = { package = "blsttc", version = "8.0.1" } bytes = { version = "1.0.1", features = ["serde"] } @@ -80,10 +80,10 @@ walkdir = "~2.5.0" xor_name = "5.0.0" [dev-dependencies] -ant-protocol = { path = "../ant-protocol", version = "0.3.2", features = ["rpc"] } +ant-protocol = { path = "../ant-protocol", version = "0.3.3", features = ["rpc"] } assert_fs = "1.0.0" -evmlib = { path = "../evmlib", version = "0.1.7" } -autonomi = { path = "../autonomi", version = "0.3.2" } +evmlib = { path = "../evmlib", version = "0.1.8" } +autonomi = { path = "../autonomi", version = "0.3.3" } reqwest = { version = "0.12.2", default-features = false, features = [ "rustls-tls-manual-roots", ] } diff --git a/ant-node/src/bin/antnode/main.rs b/ant-node/src/bin/antnode/main.rs index 665b47518c..2be7543dae 100644 --- a/ant-node/src/bin/antnode/main.rs +++ b/ant-node/src/bin/antnode/main.rs @@ -177,10 +177,6 @@ struct Opt { #[clap(long)] rpc: Option, - /// Specify the owner(readable discord user name). - #[clap(long)] - owner: Option, - #[cfg(feature = "open-metrics")] /// Specify the port for the OpenMetrics server. /// @@ -312,8 +308,7 @@ fn main() -> Result<()> { if opt.peers.local { rt.spawn(init_metrics(std::process::id())); } - let initial_peres = rt.block_on(opt.peers.get_addrs(None, Some(100)))?; - debug!("Node's owner set to: {:?}", opt.owner); + let initial_peers = rt.block_on(opt.peers.get_addrs(None, Some(100)))?; let restart_options = rt.block_on(async move { let mut node_builder = NodeBuilder::new( keypair, @@ -325,7 +320,7 @@ fn main() -> Result<()> { #[cfg(feature = "upnp")] opt.upnp, ); - node_builder.initial_peers(initial_peres); + node_builder.initial_peers(initial_peers); node_builder.bootstrap_cache(bootstrap_cache); node_builder.is_behind_home_network(opt.home_network); #[cfg(feature = "open-metrics")] diff --git a/ant-node/tests/common/client.rs b/ant-node/tests/common/client.rs index faf8c1ae05..851edb53de 100644 --- a/ant-node/tests/common/client.rs +++ b/ant-node/tests/common/client.rs @@ -52,7 +52,7 @@ pub async fn get_client_and_funded_wallet() -> (Client, Wallet) { } /// Get the node count -/// If SN_INVENTORY flag is passed, the node count is obtained from the the droplet +/// If SN_INVENTORY flag is passed, the node count is obtained from the droplet /// else return the local node count pub fn get_node_count() -> usize { match DeploymentInventory::load() { diff --git a/ant-protocol/Cargo.toml b/ant-protocol/Cargo.toml index 1f83cfd8fb..47aeda2ad7 100644 --- a/ant-protocol/Cargo.toml +++ b/ant-protocol/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "ant-protocol" readme = "README.md" repository = "https://github.com/maidsafe/autonomi" -version = "0.3.2" +version = "0.3.3" [features] default = [] rpc = ["tonic", "prost"] [dependencies] -ant-build-info = { path = "../ant-build-info", version = "0.1.22" } -ant-evm = { path = "../ant-evm", version = "0.1.7" } -ant-registers = { path = "../ant-registers", version = "0.4.6" } +ant-build-info = { path = "../ant-build-info", version = "0.1.23" } +ant-evm = { path = "../ant-evm", version = "0.1.8" } +ant-registers = { path = "../ant-registers", version = "0.4.7" } bls = { package = "blsttc", version = "8.0.1" } bytes = { version = "1.0.1", features = ["serde"] } color-eyre = "0.6.3" diff --git a/ant-protocol/src/messages/query.rs b/ant-protocol/src/messages/query.rs index f38500bd41..d395274037 100644 --- a/ant-protocol/src/messages/query.rs +++ b/ant-protocol/src/messages/query.rs @@ -66,7 +66,7 @@ pub enum Query { }, /// Queries close_group peers whether the target peer is a bad_node CheckNodeInProblem(NetworkAddress), - /// Query the the peers in range to the target address, from the receiver's perspective. + /// Query the peers in range to the target address, from the receiver's perspective. /// In case none of the parameters provided, returns nothing. /// In case both of the parameters provided, `range` is preferred to be replied. GetClosestPeers { diff --git a/ant-registers/Cargo.toml b/ant-registers/Cargo.toml index e021f361cf..07771048ce 100644 --- a/ant-registers/Cargo.toml +++ b/ant-registers/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "ant-registers" readme = "README.md" repository = "https://github.com/maidsafe/autonomi" -version = "0.4.6" +version = "0.4.7" [features] test-utils = [] diff --git a/ant-service-management/Cargo.toml b/ant-service-management/Cargo.toml index 519045aed4..acc2fe7d36 100644 --- a/ant-service-management/Cargo.toml +++ b/ant-service-management/Cargo.toml @@ -7,13 +7,13 @@ license = "GPL-3.0" name = "ant-service-management" readme = "README.md" repository = "https://github.com/maidsafe/autonomi" -version = "0.4.6" +version = "0.4.7" [dependencies] -ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.2" } -ant-evm = { path = "../ant-evm", version = "0.1.7" } -ant-logging = { path = "../ant-logging", version = "0.2.43" } -ant-protocol = { path = "../ant-protocol", version = "0.3.2", features = ["rpc"] } +ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.3" } +ant-evm = { path = "../ant-evm", version = "0.1.8" } +ant-logging = { path = "../ant-logging", version = "0.2.44" } +ant-protocol = { path = "../ant-protocol", version = "0.3.3", features = ["rpc"] } async-trait = "0.1" dirs-next = "2.0.0" libp2p = { version = "0.54.1", features = ["kad"] } diff --git a/ant-service-management/src/node.rs b/ant-service-management/src/node.rs index 3c281ba4b7..cd92f6bac0 100644 --- a/ant-service-management/src/node.rs +++ b/ant-service-management/src/node.rs @@ -110,11 +110,6 @@ impl ServiceStateActions for NodeService<'_> { args.push(OsString::from(max_log_files.to_string())); } - if let Some(owner) = &self.service_data.owner { - args.push(OsString::from("--owner")); - args.push(OsString::from(owner)); - } - args.push(OsString::from("--rewards-address")); args.push(OsString::from( self.service_data.rewards_address.to_string(), @@ -288,8 +283,6 @@ pub struct NodeServiceData { pub max_log_files: Option, #[serde(default)] pub metrics_port: Option, - #[serde(default)] - pub owner: Option, pub network_id: Option, #[serde(default)] pub node_ip: Option, diff --git a/ant-token-supplies/Cargo.toml b/ant-token-supplies/Cargo.toml index a26791770b..66a3661079 100644 --- a/ant-token-supplies/Cargo.toml +++ b/ant-token-supplies/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "ant-token-supplies" readme = "README.md" repository = "https://github.com/maidsafe/autonomi" -version = "0.1.61" +version = "0.1.62" [dependencies] diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index b3de46555f..e4f9666014 100644 --- a/autonomi/Cargo.toml +++ b/autonomi/Cargo.toml @@ -3,7 +3,7 @@ authors = ["MaidSafe Developers "] description = "Autonomi client API" name = "autonomi" license = "GPL-3.0" -version = "0.3.2" +version = "0.3.3" edition = "2021" homepage = "https://maidsafe.net" readme = "README.md" @@ -26,11 +26,11 @@ extension-module = ["pyo3/extension-module"] loud = [] [dependencies] -ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.2" } -ant-evm = { path = "../ant-evm", version = "0.1.7" } -ant-networking = { path = "../ant-networking", version = "0.3.2" } -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-evm = { path = "../ant-evm", version = "0.1.8" } +ant-networking = { path = "../ant-networking", version = "0.3.3" } +ant-protocol = { path = "../ant-protocol", version = "0.3.3" } +ant-registers = { path = "../ant-registers", version = "0.4.7" } bip39 = "2.0.0" blst = "0.3.13" blstrs = "0.7.1" @@ -55,8 +55,9 @@ xor_name = "5.0.0" [dev-dependencies] alloy = { version = "0.7.3", default-features = false, features = ["contract", "json-rpc", "network", "node-bindings", "provider-http", "reqwest-rustls-tls", "rpc-client", "rpc-types", "signer-local", "std"] } -ant-logging = { path = "../ant-logging", version = "0.2.43" } +ant-logging = { path = "../ant-logging", version = "0.2.44" } eyre = "0.6.5" +serial_test = "3.2.0" sha2 = "0.10.6" # Do not specify the version field. Release process expects even the local dev deps to be published. # Removing the version field is a workaround. diff --git a/autonomi/src/client/data/mod.rs b/autonomi/src/client/data/mod.rs index d336c60dfc..5fc1eb3290 100644 --- a/autonomi/src/client/data/mod.rs +++ b/autonomi/src/client/data/mod.rs @@ -222,7 +222,7 @@ impl Client { // Pay for all chunks let xor_names: Vec<_> = chunks.iter().map(|chunk| *chunk.name()).collect(); info!("Paying for {} addresses", xor_names.len()); - let receipt = self + let (receipt, skipped_payments) = self .pay_for_content_addrs(xor_names.into_iter(), payment_option) .await .inspect_err(|err| error!("Error paying for data: {err:?}"))?; @@ -244,7 +244,7 @@ impl Client { return Err(last_chunk_fail.1); } - let record_count = chunks.len(); + let record_count = chunks.len().saturating_sub(skipped_payments); // Reporting if let Some(channel) = self.client_event_sender.as_ref() { @@ -254,7 +254,8 @@ impl Client { .sum::(); let summary = UploadSummary { - record_count, + records_paid: record_count, + records_already_paid: skipped_payments, tokens_spent, }; if let Err(err) = channel.send(ClientEvent::UploadComplete(summary)).await { diff --git a/autonomi/src/client/data/public.rs b/autonomi/src/client/data/public.rs index 8b434c5a98..fde2908964 100644 --- a/autonomi/src/client/data/public.rs +++ b/autonomi/src/client/data/public.rs @@ -59,7 +59,7 @@ impl Client { // Pay for all chunks + data map chunk info!("Paying for {} addresses", xor_names.len()); - let receipt = self + let (receipt, skipped_payments) = self .pay_for_content_addrs(xor_names.into_iter(), payment_option) .await .inspect_err(|err| error!("Error paying for data: {err:?}"))?; @@ -87,7 +87,7 @@ impl Client { return Err(last_chunk_fail.1); } - let record_count = chunks.len() + 1; + let record_count = (chunks.len() + 1) - skipped_payments; // Reporting if let Some(channel) = self.client_event_sender.as_ref() { @@ -97,7 +97,8 @@ impl Client { .sum::(); let summary = UploadSummary { - record_count, + records_paid: record_count, + records_already_paid: skipped_payments, tokens_spent, }; if let Err(err) = channel.send(ClientEvent::UploadComplete(summary)).await { diff --git a/autonomi/src/client/files/archive.rs b/autonomi/src/client/files/archive.rs index 18ecd1c735..19e9642191 100644 --- a/autonomi/src/client/files/archive.rs +++ b/autonomi/src/client/files/archive.rs @@ -166,6 +166,13 @@ impl Client { let bytes = archive .to_bytes() .map_err(|e| PutError::Serialization(format!("Failed to serialize archive: {e:?}")))?; + + #[cfg(feature = "loud")] + println!( + "Uploading private archive referencing {} files", + archive.map().len() + ); + let result = self.data_put(bytes, payment_option).await; debug!("Uploaded private archive {archive:?} to the network and address is {result:?}"); result diff --git a/autonomi/src/client/files/archive_public.rs b/autonomi/src/client/files/archive_public.rs index dd7cb046e2..bf8cb44bff 100644 --- a/autonomi/src/client/files/archive_public.rs +++ b/autonomi/src/client/files/archive_public.rs @@ -158,6 +158,13 @@ impl Client { let bytes = archive .to_bytes() .map_err(|e| PutError::Serialization(format!("Failed to serialize archive: {e:?}")))?; + + #[cfg(feature = "loud")] + println!( + "Uploading public archive referencing {} files", + archive.map().len() + ); + let result = self.data_put_public(bytes, wallet.into()).await; debug!("Uploaded archive {archive:?} to the network and the address is {result:?}"); result diff --git a/autonomi/src/client/graph.rs b/autonomi/src/client/graph.rs index cf78903209..b9fb0fcca2 100644 --- a/autonomi/src/client/graph.rs +++ b/autonomi/src/client/graph.rs @@ -68,7 +68,7 @@ impl Client { // pay for the transaction let xor_name = address.xorname(); debug!("Paying for transaction at address: {address:?}"); - let payment_proofs = self + let (payment_proofs, skipped_payments) = self .pay(std::iter::once(*xor_name), wallet) .await .inspect_err(|err| { @@ -124,7 +124,8 @@ impl Client { // send client event if let Some(channel) = self.client_event_sender.as_ref() { let summary = UploadSummary { - record_count: 1, + records_paid: 1usize.saturating_sub(skipped_payments), + records_already_paid: skipped_payments, tokens_spent: price.as_atto(), }; if let Err(err) = channel.send(ClientEvent::UploadComplete(summary)).await { diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 5073a2bd76..62d19a9dac 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -84,6 +84,16 @@ pub struct ClientConfig { pub evm_network: EvmNetwork, } +// impl Default for ClientConfig { +// fn default() -> Self { +// Self { +// local: false, +// peers: None, +// evm_network: EvmNetwork::try_from_env().unwrap_or_default(), +// } +// } +// } + /// Error returned by [`Client::init`]. #[derive(Debug, thiserror::Error)] pub enum ConnectError { @@ -139,7 +149,7 @@ impl Client { Self::init_with_config(ClientConfig { local, peers: Some(peers), - evm_network: Default::default(), + evm_network: EvmNetwork::new(local).unwrap_or_default(), }) .await } @@ -196,61 +206,6 @@ impl Client { }) } - /// Connect to the network. - /// - /// This will timeout after [`CONNECT_TIMEOUT_SECS`] secs. - /// - /// ```no_run - /// # use autonomi::client::Client; - /// # #[tokio::main] - /// # async fn main() -> Result<(), Box> { - /// let peers = ["/ip4/127.0.0.1/udp/1234/quic-v1".parse()?]; - /// #[allow(deprecated)] - /// let client = Client::connect(&peers).await?; - /// # Ok(()) - /// # } - /// ``` - #[deprecated( - since = "0.2.4", - note = "Use [`Client::init`] or [`Client::init_with_config`] instead" - )] - pub async fn connect(peers: &[Multiaddr]) -> Result { - // Any global address makes the client non-local - let local = !peers.iter().any(multiaddr_is_global); - - let (network, event_receiver) = build_client_and_run_swarm(local); - - // Spawn task to dial to the given peers - let network_clone = network.clone(); - let peers = peers.to_vec(); - let _handle = ant_networking::time::spawn(async move { - for addr in peers { - if let Err(err) = network_clone.dial(addr.clone()).await { - error!("Failed to dial addr={addr} with err: {err:?}"); - eprintln!("addr={addr} Failed to dial: {err:?}"); - }; - } - }); - - let (sender, receiver) = futures::channel::oneshot::channel(); - ant_networking::time::spawn(handle_event_receiver(event_receiver, sender)); - - receiver.await.expect("sender should not close")?; - debug!("Client is connected to the network"); - - // With the switch to the new bootstrap cache scheme, - // Seems the too many `initial dial`s could result in failure, - // when startup quoting/upload tasks got started up immediatly. - // Hence, put in a forced wait to allow `initial network discovery` to be completed. - ant_networking::time::sleep(Duration::from_secs(5)).await; - - Ok(Self { - network, - client_event_sender: Arc::new(None), - evm_network: Default::default(), - }) - } - /// Receive events from the client. pub fn enable_client_events(&mut self) -> mpsc::Receiver { let (client_event_sender, client_event_receiver) = @@ -353,6 +308,10 @@ pub enum ClientEvent { /// Summary of an upload operation. #[derive(Debug, Clone)] pub struct UploadSummary { - pub record_count: usize, + /// Records that were uploaded to the network + pub records_paid: usize, + /// Records that were already paid for so were not re-uploaded + pub records_already_paid: usize, + /// Total cost of the upload pub tokens_spent: Amount, } diff --git a/autonomi/src/client/payment.rs b/autonomi/src/client/payment.rs index 29a8f11576..b6dc4c936e 100644 --- a/autonomi/src/client/payment.rs +++ b/autonomi/src/client/payment.rs @@ -5,6 +5,8 @@ use ant_evm::{AttoTokens, EncodedPeerId, EvmWallet, ProofOfPayment}; use std::collections::HashMap; use xor_name::XorName; +use super::utils::AlreadyPaidAddressesCount; + /// Contains the proof of payments for each XOR address and the amount paid pub type Receipt = HashMap; @@ -65,13 +67,13 @@ impl Client { &self, content_addrs: impl Iterator + Clone, payment_option: PaymentOption, - ) -> Result { + ) -> Result<(Receipt, AlreadyPaidAddressesCount), PayError> { match payment_option { PaymentOption::Wallet(wallet) => { - let receipt = self.pay(content_addrs, &wallet).await?; - Ok(receipt) + let (receipt, skipped) = self.pay(content_addrs, &wallet).await?; + Ok((receipt, skipped)) } - PaymentOption::Receipt(receipt) => Ok(receipt), + PaymentOption::Receipt(receipt) => Ok((receipt, 0)), } } } diff --git a/autonomi/src/client/pointer.rs b/autonomi/src/client/pointer.rs index a5f95e18f8..eb65128eae 100644 --- a/autonomi/src/client/pointer.rs +++ b/autonomi/src/client/pointer.rs @@ -62,7 +62,7 @@ impl Client { // pay for the pointer storage let xor_name = *address.xorname(); debug!("Paying for pointer at address: {address:?}"); - let payment_proofs = self + let (payment_proofs, _skipped_payments) = self .pay(std::iter::once(xor_name), wallet) .await .inspect_err(|err| { diff --git a/autonomi/src/client/registers.rs b/autonomi/src/client/registers.rs index d28fbacf2f..ee8514e7b5 100644 --- a/autonomi/src/client/registers.rs +++ b/autonomi/src/client/registers.rs @@ -319,12 +319,12 @@ impl Client { let reg_xor = address.xorname(); debug!("Paying for register at address: {address}"); - let payment_proofs = self + let (payment_proofs, skipped_payments) = self .pay(std::iter::once(reg_xor), wallet) .await .inspect_err(|err| { - error!("Failed to pay for register at address: {address} : {err}") - })?; + error!("Failed to pay for register at address: {address} : {err}") + })?; let (proof, price) = if let Some((proof, price)) = payment_proofs.get(®_xor) { (proof, price) } else { @@ -373,7 +373,8 @@ impl Client { if let Some(channel) = self.client_event_sender.as_ref() { let summary = UploadSummary { - record_count: 1, + records_paid: 1usize.saturating_sub(skipped_payments), + records_already_paid: skipped_payments, tokens_spent: price.as_atto(), }; if let Err(err) = channel.send(ClientEvent::UploadComplete(summary)).await { diff --git a/autonomi/src/client/utils.rs b/autonomi/src/client/utils.rs index 2a8eb70e3e..ae0cac0b48 100644 --- a/autonomi/src/client/utils.rs +++ b/autonomi/src/client/utils.rs @@ -27,6 +27,8 @@ use super::{ }; use crate::self_encryption::DataMapLevel; +pub type AlreadyPaidAddressesCount = usize; + impl Client { /// Fetch and decrypt all chunks in the data map. pub(crate) async fn fetch_from_data_map(&self, data_map: &DataMap) -> Result { @@ -167,7 +169,7 @@ impl Client { &self, content_addrs: impl Iterator + Clone, wallet: &EvmWallet, - ) -> Result { + ) -> Result<(Receipt, AlreadyPaidAddressesCount), PayError> { let number_of_content_addrs = content_addrs.clone().count(); let quotes = self.get_store_quotes(content_addrs).await?; @@ -197,7 +199,7 @@ impl Client { let receipt = receipt_from_store_quotes(quotes); - Ok(receipt) + Ok((receipt, skipped_chunks)) } } diff --git a/autonomi/src/client/vault.rs b/autonomi/src/client/vault.rs index d57c197fc6..45fa3e2256 100644 --- a/autonomi/src/client/vault.rs +++ b/autonomi/src/client/vault.rs @@ -192,7 +192,7 @@ impl Client { info!("Writing to vault at {scratch_address:?}",); let record = if is_new { - let receipt = self + let (receipt, _skipped_payments) = self .pay_for_content_addrs(std::iter::once(scratch.xorname()), payment_option) .await .inspect_err(|err| { diff --git a/autonomi/tests/fs.rs b/autonomi/tests/fs.rs index 1bb4e3a7cf..9951872f8f 100644 --- a/autonomi/tests/fs.rs +++ b/autonomi/tests/fs.rs @@ -9,6 +9,7 @@ use ant_logging::LogBuilder; use autonomi::Client; use eyre::Result; +use serial_test::serial; use sha2::{Digest, Sha256}; use std::fs::File; use std::io::{BufReader, Read}; @@ -20,6 +21,7 @@ use walkdir::WalkDir; // With a local evm network, and local network, run: // EVM_NETWORK=local cargo test --package autonomi --test fs #[tokio::test] +#[serial] async fn dir_upload_download() -> Result<()> { let _log_appender_guard = LogBuilder::init_single_threaded_tokio_test("dir_upload_download", false); @@ -75,6 +77,7 @@ fn compute_dir_sha256(dir: &str) -> Result { } #[tokio::test] +#[serial] async fn file_into_vault() -> Result<()> { let _log_appender_guard = LogBuilder::init_single_threaded_tokio_test("file", false); diff --git a/evm-testnet/Cargo.toml b/evm-testnet/Cargo.toml index c843aefdad..fcff5a809b 100644 --- a/evm-testnet/Cargo.toml +++ b/evm-testnet/Cargo.toml @@ -6,13 +6,13 @@ homepage = "https://maidsafe.net" license = "GPL-3.0" name = "evm-testnet" repository = "https://github.com/maidsafe/autonomi" -version = "0.1.7" +version = "0.1.8" [dependencies] -ant-evm = { path = "../ant-evm", version = "0.1.7" } +ant-evm = { path = "../ant-evm", version = "0.1.8" } clap = { version = "4.5", features = ["derive"] } dirs-next = "~2.0.0" -evmlib = { path = "../evmlib", version = "0.1.7" } +evmlib = { path = "../evmlib", version = "0.1.8" } tokio = { version = "1.40", features = ["rt-multi-thread", "signal"] } [lints] diff --git a/evmlib/Cargo.toml b/evmlib/Cargo.toml index 188cc3b94e..b2c54fc328 100644 --- a/evmlib/Cargo.toml +++ b/evmlib/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://maidsafe.net" license = "GPL-3.0" name = "evmlib" repository = "https://github.com/maidsafe/safe_network" -version = "0.1.7" +version = "0.1.8" [features] external-signer = [] diff --git a/evmlib/src/lib.rs b/evmlib/src/lib.rs index 866f8fc47d..b92e7ad379 100644 --- a/evmlib/src/lib.rs +++ b/evmlib/src/lib.rs @@ -7,6 +7,7 @@ // permissions and limitations relating to use of the SAFE Network Software. use crate::common::Address; +use crate::utils::get_evm_network; use alloy::primitives::address; use alloy::transports::http::reqwest; use serde::{Deserialize, Serialize}; @@ -28,7 +29,7 @@ pub mod utils; pub mod wallet; /// Timeout for transactions -const TX_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60); +const TX_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(600); static PUBLIC_ARBITRUM_ONE_HTTP_RPC_URL: LazyLock = LazyLock::new(|| { "https://arb1.arbitrum.io/rpc" @@ -103,6 +104,12 @@ impl std::fmt::Display for Network { } impl Network { + pub fn new(local: bool) -> Result { + get_evm_network(local).inspect_err(|err| { + warn!("Failed to select EVM network from ENV: {err}"); + }) + } + pub fn new_custom(rpc_url: &str, payment_token_addr: &str, chunk_payments_addr: &str) -> Self { Self::Custom(CustomNetwork::new( rpc_url, diff --git a/nat-detection/Cargo.toml b/nat-detection/Cargo.toml index 4e8b4ccae9..4c2d0c784e 100644 --- a/nat-detection/Cargo.toml +++ b/nat-detection/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "nat-detection" readme = "README.md" repository = "https://github.com/maidsafe/autonomi" -version = "0.2.14" +version = "0.2.15" [[bin]] name = "nat-detection" @@ -17,9 +17,9 @@ path = "src/main.rs" nightly = [] [dependencies] -ant-build-info = { path = "../ant-build-info", version = "0.1.22" } -ant-networking = { path = "../ant-networking", version = "0.3.2" } -ant-protocol = { path = "../ant-protocol", version = "0.3.2" } +ant-build-info = { path = "../ant-build-info", version = "0.1.23" } +ant-networking = { path = "../ant-networking", version = "0.3.3" } +ant-protocol = { path = "../ant-protocol", version = "0.3.3" } clap = { version = "4.5.4", features = ["derive"] } clap-verbosity-flag = "2.2.0" color-eyre = { version = "0.6", default-features = false } diff --git a/node-launchpad/Cargo.toml b/node-launchpad/Cargo.toml index a6d0294f83..a3d00a2eb7 100644 --- a/node-launchpad/Cargo.toml +++ b/node-launchpad/Cargo.toml @@ -2,7 +2,7 @@ authors = ["MaidSafe Developers "] description = "TUI for running nodes on the Autonomi network" name = "node-launchpad" -version = "0.5.2" +version = "0.5.3" edition = "2021" license = "GPL-3.0" homepage = "https://maidsafe.net" @@ -18,13 +18,13 @@ path = "src/bin/tui/main.rs" nightly = [] [dependencies] -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-node-manager = { version = "0.11.6", path = "../ant-node-manager" } -ant-protocol = { path = "../ant-protocol", version = "0.3.2" } +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-node-manager = { version = "0.11.7", path = "../ant-node-manager" } +ant-protocol = { path = "../ant-protocol", version = "0.3.3" } ant-releases = { version = "0.4.0" } -ant-service-management = { version = "0.4.6", path = "../ant-service-management" } +ant-service-management = { version = "0.4.7", path = "../ant-service-management" } arboard = "3.4.1" atty = "0.2.14" better-panic = "0.3.0" diff --git a/node-launchpad/src/node_mgmt.rs b/node-launchpad/src/node_mgmt.rs index 18780b4f2b..7e41b19dbe 100644 --- a/node-launchpad/src/node_mgmt.rs +++ b/node-launchpad/src/node_mgmt.rs @@ -429,7 +429,6 @@ async fn scale_down_nodes(config: &NodeConfig, count: u16) { config.network_id, None, None, // We don't care about the port, as we are scaling down - config.owner.clone(), config.peers_args.clone(), RewardsAddress::from_str(config.rewards_address.as_str()).unwrap(), None, @@ -503,7 +502,6 @@ async fn add_nodes( config.network_id, None, port_range, - config.owner.clone(), config.peers_args.clone(), RewardsAddress::from_str(config.rewards_address.as_str()).unwrap(), None, diff --git a/release-cycle-info b/release-cycle-info index f06fab042a..1ec5651cc4 100644 --- a/release-cycle-info +++ b/release-cycle-info @@ -15,4 +15,4 @@ release-year: 2024 release-month: 12 release-cycle: 1 -release-cycle-counter: 7 +release-cycle-counter: 8 diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index e933b32b62..cdd2b5aa58 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -7,13 +7,13 @@ license = "GPL-3.0" name = "test-utils" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.4.14" +version = "0.4.15" [dependencies] bytes = { version = "1.0.1", features = ["serde"] } color-eyre = "0.6.3" dirs-next = "~2.0.0" -evmlib = { path = "../evmlib", version = "0.1.7" } +evmlib = { path = "../evmlib", version = "0.1.8" } libp2p = { version = "0.54.1", features = ["identify", "kad"] } rand = "0.8.5" serde = { version = "1.0.133", features = ["derive"] }