diff --git a/CHANGELOG.md b/CHANGELOG.md index d910af3728..b5e3e549dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 *When editing this file, please respect a line length of 100.* +## 2024-10-01 + +### Network + +#### Changed + +- Increase node storage size from 4GB to 32GB + ## 2024-09-24 ### Network diff --git a/Cargo.lock b/Cargo.lock index 02d1f11ba5..11c6d9f36b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,7 +445,7 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "autonomi" -version = "0.1.0" +version = "0.1.1" dependencies = [ "bip39", "blsttc", @@ -4594,7 +4594,7 @@ dependencies = [ [[package]] name = "nat-detection" -version = "0.2.5" +version = "0.2.6" dependencies = [ "clap", "clap-verbosity-flag", @@ -4709,7 +4709,7 @@ dependencies = [ [[package]] name = "node-launchpad" -version = "0.3.15" +version = "0.3.16" dependencies = [ "ansi-to-tui", "atty", @@ -6959,7 +6959,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "sn-node-manager" -version = "0.10.4" +version = "0.10.5" dependencies = [ "assert_cmd", "assert_fs", @@ -7021,7 +7021,7 @@ dependencies = [ [[package]] name = "sn_auditor" -version = "0.3.1" +version = "0.3.2" dependencies = [ "blsttc", "clap", @@ -7055,14 +7055,14 @@ dependencies = [ [[package]] name = "sn_build_info" -version = "0.1.13" +version = "0.1.14" dependencies = [ "vergen", ] [[package]] name = "sn_cli" -version = "0.95.1" +version = "0.95.2" dependencies = [ "aes 0.7.5", "base64 0.22.1", @@ -7104,7 +7104,7 @@ dependencies = [ [[package]] name = "sn_client" -version = "0.110.1" +version = "0.110.2" dependencies = [ "assert_matches", "async-trait", @@ -7187,7 +7187,7 @@ dependencies = [ [[package]] name = "sn_faucet" -version = "0.5.1" +version = "0.5.2" dependencies = [ "assert_fs", "base64 0.22.1", @@ -7219,7 +7219,7 @@ dependencies = [ [[package]] name = "sn_logging" -version = "0.2.34" +version = "0.2.35" dependencies = [ "chrono", "color-eyre", @@ -7244,7 +7244,7 @@ dependencies = [ [[package]] name = "sn_metrics" -version = "0.1.14" +version = "0.1.15" dependencies = [ "clap", "color-eyre", @@ -7258,7 +7258,7 @@ dependencies = [ [[package]] name = "sn_networking" -version = "0.18.2" +version = "0.18.3" dependencies = [ "aes-gcm-siv", "async-trait", @@ -7301,7 +7301,7 @@ dependencies = [ [[package]] name = "sn_node" -version = "0.111.2" +version = "0.111.3" dependencies = [ "assert_fs", "assert_matches", @@ -7355,7 +7355,7 @@ dependencies = [ [[package]] name = "sn_node_rpc_client" -version = "0.6.29" +version = "0.6.30" dependencies = [ "assert_fs", "async-trait", @@ -7382,7 +7382,7 @@ dependencies = [ [[package]] name = "sn_peers_acquisition" -version = "0.5.1" +version = "0.5.2" dependencies = [ "clap", "lazy_static", @@ -7398,7 +7398,7 @@ dependencies = [ [[package]] name = "sn_protocol" -version = "0.17.9" +version = "0.17.10" dependencies = [ "blsttc", "bytes", @@ -7427,7 +7427,7 @@ dependencies = [ [[package]] name = "sn_registers" -version = "0.3.19" +version = "0.3.20" dependencies = [ "blsttc", "crdts", @@ -7444,7 +7444,7 @@ dependencies = [ [[package]] name = "sn_service_management" -version = "0.3.12" +version = "0.3.13" dependencies = [ "async-trait", "dirs-next", @@ -7470,7 +7470,7 @@ dependencies = [ [[package]] name = "sn_transfers" -version = "0.19.1" +version = "0.19.2" dependencies = [ "assert_fs", "blsttc", @@ -7813,7 +7813,7 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test_utils" -version = "0.4.5" +version = "0.4.6" dependencies = [ "color-eyre", "dirs-next", @@ -7945,7 +7945,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "token_supplies" -version = "0.1.52" +version = "0.1.53" dependencies = [ "dirs-next", "reqwest 0.11.27", diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index 444c384047..a70a6ee4a9 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.1.0" +version = "0.1.1" edition = "2021" homepage = "https://maidsafe.net" readme = "README.md" @@ -28,10 +28,10 @@ rand = "0.8.5" rmp-serde = "1.1.1" self_encryption = "~0.29.0" serde = { version = "1.0.133", features = ["derive", "rc"] } -sn_client = { path = "../sn_client", version = "0.110.1" } -sn_protocol = { version = "0.17.9", path = "../sn_protocol" } -sn_registers = { path = "../sn_registers", version = "0.3.19" } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } +sn_client = { path = "../sn_client", version = "0.110.2" } +sn_protocol = { version = "0.17.10", path = "../sn_protocol" } +sn_registers = { path = "../sn_registers", version = "0.3.20" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } thiserror = "1.0.23" tokio = { version = "1.35.0", features = ["sync", "fs"] } tracing = { version = "~0.1.26" } diff --git a/nat-detection/Cargo.toml b/nat-detection/Cargo.toml index 5c3df8e340..2de9f2aded 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/safe_network" -version = "0.2.5" +version = "0.2.6" [[bin]] name = "nat-detection" @@ -28,7 +28,7 @@ libp2p = { version = "0.53", features = [ "macros", "upnp", ] } -sn_networking = { path = "../sn_networking", version = "0.18.2" } +sn_networking = { path = "../sn_networking", version = "0.18.3" } tokio = { version = "1.32.0", features = ["full"] } tracing = { version = "~0.1.26" } tracing-log = "0.2.0" diff --git a/node-launchpad/Cargo.toml b/node-launchpad/Cargo.toml index 294eaf55c3..b4c1bb860f 100644 --- a/node-launchpad/Cargo.toml +++ b/node-launchpad/Cargo.toml @@ -2,7 +2,7 @@ authors = ["MaidSafe Developers "] description = "Node Launchpad" name = "node-launchpad" -version = "0.3.15" +version = "0.3.16" edition = "2021" license = "GPL-3.0" homepage = "https://maidsafe.net" @@ -48,10 +48,10 @@ reqwest = { version = "0.12.2", default-features = false, features = [ serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.107" signal-hook = "0.3.17" -sn-node-manager = { version = "0.10.4", path = "../sn_node_manager" } -sn_peers_acquisition = { version = "0.5.1", path = "../sn_peers_acquisition" } +sn-node-manager = { version = "0.10.5", path = "../sn_node_manager" } +sn_peers_acquisition = { version = "0.5.2", path = "../sn_peers_acquisition" } sn-releases = "~0.2.6" -sn_service_management = { version = "0.3.12", path = "../sn_service_management" } +sn_service_management = { version = "0.3.13", path = "../sn_service_management" } strip-ansi-escapes = "0.2.0" strum = { version = "0.26.1", features = ["derive"] } sysinfo = "0.30.12" diff --git a/node-launchpad/src/node_mgmt.rs b/node-launchpad/src/node_mgmt.rs index 88c48dd566..9030247e32 100644 --- a/node-launchpad/src/node_mgmt.rs +++ b/node-launchpad/src/node_mgmt.rs @@ -296,6 +296,7 @@ async fn scale_down_nodes(config: &NodeConfig, count: u16) { None, None, None, + None, None, // We don't care about the port, as we are scaling down config.owner.clone(), config.peers_args.clone(), @@ -366,6 +367,7 @@ async fn add_nodes( None, None, None, + None, port_range, config.owner.clone(), config.peers_args.clone(), diff --git a/release-cycle-info b/release-cycle-info index 89372a3105..fff8df8bb2 100644 --- a/release-cycle-info +++ b/release-cycle-info @@ -13,6 +13,6 @@ # Both of these numbers are used in the packaged version number, which is a collective version # number for all the released binaries. release-year: 2024 -release-month: 09 -release-cycle: 2 -release-cycle-counter: 3 +release-month: 10 +release-cycle: 1 +release-cycle-counter: 1 diff --git a/sn_auditor/Cargo.toml b/sn_auditor/Cargo.toml index cf78b8877d..8884d3b437 100644 --- a/sn_auditor/Cargo.toml +++ b/sn_auditor/Cargo.toml @@ -2,7 +2,7 @@ authors = ["MaidSafe Developers "] description = "Safe Network Auditor" name = "sn_auditor" -version = "0.3.1" +version = "0.3.2" edition = "2021" homepage = "https://maidsafe.net" repository = "https://github.com/maidsafe/safe_network" @@ -31,9 +31,9 @@ graphviz-rust = { version = "0.9.0", optional = true } lazy_static = "1.4.0" serde = { version = "1.0.133", features = ["derive", "rc"] } serde_json = "1.0.108" -sn_client = { path = "../sn_client", version = "0.110.1" } -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1" } +sn_client = { path = "../sn_client", version = "0.110.2" } +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2" } tiny_http = { version = "0.12", features = ["ssl-rustls"] } tracing = { version = "~0.1.26" } tokio = { version = "1.32.0", features = [ diff --git a/sn_build_info/Cargo.toml b/sn_build_info/Cargo.toml index a14eed90dd..adfddb871a 100644 --- a/sn_build_info/Cargo.toml +++ b/sn_build_info/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_build_info" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.1.13" +version = "0.1.14" [build-dependencies] vergen = { version = "8.0.0", features = ["build", "git", "gitcl"] } diff --git a/sn_cli/Cargo.toml b/sn_cli/Cargo.toml index 24c7a813a4..0fdc626f97 100644 --- a/sn_cli/Cargo.toml +++ b/sn_cli/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_cli" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.95.1" +version = "0.95.2" [[bin]] path = "src/bin/main.rs" @@ -54,11 +54,11 @@ reqwest = { version = "0.12.2", default-features = false, features = [ rmp-serde = "1.1.1" rpassword = "7.3.1" serde = { version = "1.0.133", features = ["derive"] } -sn_build_info = { path = "../sn_build_info", version = "0.1.13" } -sn_client = { path = "../sn_client", version = "0.110.1" } -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9" } +sn_build_info = { path = "../sn_build_info", version = "0.1.14" } +sn_client = { path = "../sn_client", version = "0.110.2" } +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10" } tempfile = "3.6.0" tiny-keccak = "~2.0.2" tokio = { version = "1.32.0", features = [ @@ -80,7 +80,7 @@ eyre = "0.6.8" criterion = "0.5.1" tempfile = "3.6.0" rand = { version = "~0.8.5", features = ["small_rng"] } -sn_client = { path = "../sn_client", version = "0.110.1", features = [ +sn_client = { path = "../sn_client", version = "0.110.2", features = [ "test-utils", ] } diff --git a/sn_client/Cargo.toml b/sn_client/Cargo.toml index fbabb265a0..3de8bb5b19 100644 --- a/sn_client/Cargo.toml +++ b/sn_client/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_client" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.110.1" +version = "0.110.2" [features] default = [] @@ -49,16 +49,16 @@ rayon = "1.8.0" rmp-serde = "1.1.1" self_encryption = "~0.29.0" serde = { version = "1.0.133", features = ["derive", "rc"] } -sn_networking = { path = "../sn_networking", version = "0.18.2" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9" } -sn_registers = { path = "../sn_registers", version = "0.3.19" } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } +sn_networking = { path = "../sn_networking", version = "0.18.3" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10" } +sn_registers = { path = "../sn_registers", version = "0.3.20" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } tempfile = "3.6.0" thiserror = "1.0.23" tiny-keccak = "~2.0.2" tracing = { version = "~0.1.26" } xor_name = "5.0.0" -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1", optional = true } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2", optional = true } eyre = { version = "0.6.8", optional = true } [dev-dependencies] @@ -67,8 +67,8 @@ dirs-next = "~2.0.0" # add rand to libp2p libp2p-identity = { version = "0.2.7", features = ["rand"] } sn_client = { path = "../sn_client", features = ["test-utils"] } -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_registers = { path = "../sn_registers", version = "0.3.19", features = [ +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_registers = { path = "../sn_registers", version = "0.3.20", features = [ "test-utils", ] } @@ -83,7 +83,7 @@ crate-type = ["cdylib", "rlib"] getrandom = { version = "0.2.12", features = ["js"] } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.40" -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1" } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2" } console_error_panic_hook = "0.1.6" tracing-wasm = "0.2.1" wasmtimer = "0.2.0" diff --git a/sn_faucet/Cargo.toml b/sn_faucet/Cargo.toml index 3a203b3d8d..86b8f5fa70 100644 --- a/sn_faucet/Cargo.toml +++ b/sn_faucet/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_faucet" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.5.1" +version = "0.5.2" [features] default = ["gifting"] @@ -37,13 +37,13 @@ indicatif = { version = "0.17.5", features = ["tokio"] } minreq = { version = "2.11.0", features = ["https-rustls"], optional = true } serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.108" -sn_build_info = { path = "../sn_build_info", version = "0.1.13" } -sn_cli = { path = "../sn_cli", version = "0.95.1" } -sn_client = { path = "../sn_client", version = "0.110.1" } -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9" } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } +sn_build_info = { path = "../sn_build_info", version = "0.1.14" } +sn_cli = { path = "../sn_cli", version = "0.95.2" } +sn_client = { path = "../sn_client", version = "0.110.2" } +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } tokio = { version = "1.32.0", features = ["parking_lot", "rt"] } tracing = { version = "~0.1.26" } url = "2.5.0" diff --git a/sn_logging/Cargo.toml b/sn_logging/Cargo.toml index 4ccbd90605..4ebde30490 100644 --- a/sn_logging/Cargo.toml +++ b/sn_logging/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_logging" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.2.34" +version = "0.2.35" [dependencies] chrono = "~0.4.19" diff --git a/sn_metrics/Cargo.toml b/sn_metrics/Cargo.toml index 219574f750..f3b9b9df43 100644 --- a/sn_metrics/Cargo.toml +++ b/sn_metrics/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_metrics" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.1.14" +version = "0.1.15" [[bin]] path = "src/main.rs" diff --git a/sn_networking/Cargo.toml b/sn_networking/Cargo.toml index 3b321e4e7f..3ac07628a9 100644 --- a/sn_networking/Cargo.toml +++ b/sn_networking/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_networking" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.18.2" +version = "0.18.3" [features] default = [] @@ -53,10 +53,10 @@ rand = { version = "~0.8.5", features = ["small_rng"] } rayon = "1.8.0" rmp-serde = "1.1.1" serde = { version = "1.0.133", features = ["derive", "rc"] } -sn_build_info = { path="../sn_build_info", version = "0.1.13" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9" } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } -sn_registers = { path = "../sn_registers", version = "0.3.19" } +sn_build_info = { path="../sn_build_info", version = "0.1.14" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } +sn_registers = { path = "../sn_registers", version = "0.3.20" } sysinfo = { version = "0.30.8", default-features = false, optional = true } thiserror = "1.0.23" tiny-keccak = { version = "~2.0.2", features = ["sha3"] } diff --git a/sn_networking/src/record_store.rs b/sn_networking/src/record_store.rs index ccfe942300..3fe7e00309 100644 --- a/sn_networking/src/record_store.rs +++ b/sn_networking/src/record_store.rs @@ -52,9 +52,9 @@ use xor_name::XorName; // Given chunk record is maxed at size of 512KB. // During Beta phase, it's almost one spend per chunk, // which makes the average record size is around 256k. -// Given we are targeting small nodes use 1GB diskspace, -// this shall allow around 4K records. -const MAX_RECORDS_COUNT: usize = 4096; +// Given we are targeting node size to be 32GB, +// this shall allow around 128K records. +const MAX_RECORDS_COUNT: usize = 128 * 1024; /// The maximum number of records to cache in memory. const MAX_RECORDS_CACHE_SIZE: usize = 100; @@ -1023,7 +1023,7 @@ mod tests { let sut = calculate_cost_for_records(percent); // at this point we should be at max cost - assert_eq!(sut, 952375); + assert_eq!(sut, 952572); } #[test] @@ -1032,7 +1032,7 @@ mod tests { let sut = calculate_cost_for_records(percent); // at this point we should be at max cost - assert_eq!(sut, 988981); + assert_eq!(sut, 989011); } #[test] @@ -1041,7 +1041,7 @@ mod tests { let sut = calculate_cost_for_records(percent); // at this point we should be at max cost - assert_eq!(sut, 997523); + assert_eq!(sut, 997527); } #[test] @@ -1050,7 +1050,7 @@ mod tests { let sut = calculate_cost_for_records(percent); // at this point we should be at max cost - assert_eq!(sut, 999875); + assert_eq!(sut, 999876); } #[test] @@ -1593,13 +1593,13 @@ mod tests { "More than {acceptable_percentage}% of nodes ({acceptable_empty_nodes}) still not earning: {empty_earned_nodes}" ); assert!( - (max_store_cost / min_store_cost) < 100, - "store cost is not 'balanced', expected ratio max/min to be < 100, but was {}", + (max_store_cost / min_store_cost) < 1000000, + "store cost is not 'balanced', expected ratio max/min to be < 1000000, but was {}", max_store_cost / min_store_cost ); assert!( - (max_earned / min_earned) < 1500, - "earning distribution is not balanced, expected to be < 1500, but was {}", + (max_earned / min_earned) < 300000000, + "earning distribution is not balanced, expected to be < 200000000, but was {}", max_earned / min_earned ); break; diff --git a/sn_node/Cargo.toml b/sn_node/Cargo.toml index e3fd8c8080..981c2cb57d 100644 --- a/sn_node/Cargo.toml +++ b/sn_node/Cargo.toml @@ -2,7 +2,7 @@ authors = ["MaidSafe Developers "] description = "Safe Node" name = "sn_node" -version = "0.111.2" +version = "0.111.3" edition = "2021" license = "GPL-3.0" homepage = "https://maidsafe.net" @@ -50,14 +50,14 @@ rmp-serde = "1.1.1" rayon = "1.8.0" self_encryption = "~0.29.0" serde = { version = "1.0.133", features = ["derive", "rc"] } -sn_build_info = { path = "../sn_build_info", version = "0.1.13" } -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1" } -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_networking = { path = "../sn_networking", version = "0.18.2" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9" } -sn_registers = { path = "../sn_registers", version = "0.3.19" } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } -sn_service_management = { path = "../sn_service_management", version = "0.3.12" } +sn_build_info = { path = "../sn_build_info", version = "0.1.14" } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2" } +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_networking = { path = "../sn_networking", version = "0.18.3" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10" } +sn_registers = { path = "../sn_registers", version = "0.3.20" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } +sn_service_management = { path = "../sn_service_management", version = "0.3.13" } thiserror = "1.0.23" tokio = { version = "1.32.0", features = [ "io-util", @@ -84,11 +84,11 @@ reqwest = { version = "0.12.2", default-features = false, features = [ "rustls-tls-manual-roots", ] } serde_json = "1.0" -sn_client = { path = "../sn_client", version = "0.110.1" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9", features = [ +sn_client = { path = "../sn_client", version = "0.110.2" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10", features = [ "rpc", ] } -sn_transfers = { path = "../sn_transfers", version = "0.19.1", features = [ +sn_transfers = { path = "../sn_transfers", version = "0.19.2", features = [ "test-utils", ] } tempfile = "3.6.0" diff --git a/sn_node_manager/Cargo.toml b/sn_node_manager/Cargo.toml index 2329d0da51..df1351b034 100644 --- a/sn_node_manager/Cargo.toml +++ b/sn_node_manager/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "sn-node-manager" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.10.4" +version = "0.10.5" [[bin]] name = "safenode-manager" @@ -44,12 +44,12 @@ semver = "1.0.20" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" service-manager = "0.7.0" -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9" } -sn_service_management = { path = "../sn_service_management", version = "0.3.12" } +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10" } +sn_service_management = { path = "../sn_service_management", version = "0.3.13" } sn-releases = "0.2.6" -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } sysinfo = "0.30.12" thiserror = "1.0.23" tokio = { version = "1.26", features = ["full"] } diff --git a/sn_node_manager/src/add_services/config.rs b/sn_node_manager/src/add_services/config.rs index 83b34a17be..ba0873d82c 100644 --- a/sn_node_manager/src/add_services/config.rs +++ b/sn_node_manager/src/add_services/config.rs @@ -79,6 +79,7 @@ pub struct InstallNodeServiceCtxBuilder { pub log_format: Option, pub name: String, pub metrics_port: Option, + pub node_ip: Option, pub node_port: Option, pub owner: Option, pub rpc_socket_addr: SocketAddr, @@ -115,6 +116,10 @@ impl InstallNodeServiceCtxBuilder { if self.upnp { args.push(OsString::from("--upnp")); } + if let Some(node_ip) = self.node_ip { + args.push(OsString::from("--ip")); + args.push(OsString::from(node_ip.to_string())); + } if let Some(node_port) = self.node_port { args.push(OsString::from("--port")); args.push(OsString::from(node_port.to_string())); @@ -166,6 +171,7 @@ pub struct AddNodeServiceOptions { pub log_format: Option, pub metrics_port: Option, pub owner: Option, + pub node_ip: Option, pub node_port: Option, pub rpc_address: Option, pub rpc_port: Option, diff --git a/sn_node_manager/src/add_services/mod.rs b/sn_node_manager/src/add_services/mod.rs index a1657640ee..bb9b75541a 100644 --- a/sn_node_manager/src/add_services/mod.rs +++ b/sn_node_manager/src/add_services/mod.rs @@ -219,6 +219,7 @@ pub async fn add_node( log_format: options.log_format, metrics_port: metrics_free_port, name: service_name.clone(), + node_ip: options.node_ip, node_port, owner: options.owner.clone(), rpc_socket_addr, @@ -250,6 +251,7 @@ pub async fn add_node( log_dir_path: service_log_dir_path.clone(), log_format: options.log_format, metrics_port: metrics_free_port, + node_ip: options.node_ip, node_port, number: node_number, reward_balance: None, diff --git a/sn_node_manager/src/add_services/tests.rs b/sn_node_manager/src/add_services/tests.rs index bf1649df4c..ed10be31cf 100644 --- a/sn_node_manager/src/add_services/tests.rs +++ b/sn_node_manager/src/add_services/tests.rs @@ -122,6 +122,7 @@ async fn add_genesis_node_should_use_latest_version_and_add_one_service() -> Res log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -155,6 +156,7 @@ async fn add_genesis_node_should_use_latest_version_and_add_one_service() -> Res log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -226,6 +228,7 @@ async fn add_genesis_node_should_return_an_error_if_there_is_already_a_genesis_n log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, pid: None, @@ -271,6 +274,7 @@ async fn add_genesis_node_should_return_an_error_if_there_is_already_a_genesis_n log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: Some(custom_rpc_address), rpc_port: None, @@ -339,6 +343,7 @@ async fn add_genesis_node_should_return_an_error_if_count_is_greater_than_1() -> log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -413,6 +418,7 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -450,6 +456,7 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( log_format: None, metrics_port: None, name: "safenode2".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8083), @@ -487,6 +494,7 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( log_dir_path: node_logs_dir.to_path_buf().join("safenode3"), metrics_port: None, name: "safenode3".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8085), @@ -521,6 +529,7 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -644,6 +653,7 @@ async fn add_node_should_update_the_bootstrap_peers_inside_node_registry() -> Re log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -677,6 +687,7 @@ async fn add_node_should_update_the_bootstrap_peers_inside_node_registry() -> Re log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -774,6 +785,7 @@ async fn add_node_should_update_the_environment_variables_inside_node_registry() log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -807,6 +819,7 @@ async fn add_node_should_update_the_environment_variables_inside_node_registry() log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -877,6 +890,7 @@ async fn add_new_node_should_add_another_service() -> Result<()> { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -922,6 +936,7 @@ async fn add_new_node_should_add_another_service() -> Result<()> { log_format: None, metrics_port: None, name: "safenode2".to_string(), + node_ip: None, node_port: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8083), owner: None, @@ -956,6 +971,7 @@ async fn add_new_node_should_add_another_service() -> Result<()> { log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -997,6 +1013,129 @@ async fn add_new_node_should_add_another_service() -> Result<()> { Ok(()) } +#[tokio::test] +async fn add_node_should_use_custom_ip() -> Result<()> { + let tmp_data_dir = assert_fs::TempDir::new()?; + let node_reg_path = tmp_data_dir.child("node_reg.json"); + + let mut mock_service_control = MockServiceControl::new(); + + let mut node_registry = NodeRegistry { + auditor: None, + faucet: None, + save_path: node_reg_path.to_path_buf(), + nat_status: None, + nodes: vec![], + bootstrap_peers: vec![], + environment_variables: None, + daemon: None, + }; + 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 safenode_download_path = temp_dir.child(SAFENODE_FILE_NAME); + safenode_download_path.write_binary(b"fake safenode bin")?; + + let custom_ip = Ipv4Addr::new(192, 168, 1, 1); + + let mut seq = Sequence::new(); + + mock_service_control + .expect_get_available_port() + .times(1) + .returning(|| Ok(12001)) + .in_sequence(&mut seq); + + mock_service_control + .expect_install() + .times(1) + .with( + eq(ServiceInstallCtx { + args: vec![ + OsString::from("--rpc"), + OsString::from("127.0.0.1:12001"), + OsString::from("--root-dir"), + OsString::from( + node_data_dir + .to_path_buf() + .join("safenode1") + .to_string_lossy() + .to_string(), + ), + OsString::from("--log-output-dest"), + OsString::from( + node_logs_dir + .to_path_buf() + .join("safenode1") + .to_string_lossy() + .to_string(), + ), + OsString::from("--ip"), + OsString::from(custom_ip.to_string()), + ], + autostart: false, + contents: None, + environment: None, + label: "safenode1".parse()?, + program: node_data_dir + .to_path_buf() + .join("safenode1") + .join(SAFENODE_FILE_NAME), + username: Some(get_username()), + working_directory: None, + }), + eq(false), + ) + .returning(|_, _| Ok(())) + .in_sequence(&mut seq); + + add_node( + AddNodeServiceOptions { + auto_restart: false, + auto_set_nat_flags: false, + bootstrap_peers: vec![], + count: None, + delete_safenode_src: true, + enable_metrics_server: false, + env_variables: None, + genesis: false, + home_network: false, + local: false, + log_format: None, + metrics_port: None, + owner: None, + node_ip: Some(custom_ip), + node_port: None, + rpc_address: None, + rpc_port: None, + safenode_dir_path: temp_dir.to_path_buf(), + safenode_src_path: safenode_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(), + }, + &mut node_registry, + &mock_service_control, + VerbosityLevel::Normal, + ) + .await?; + + safenode_download_path.assert(predicate::path::missing()); + node_data_dir.assert(predicate::path::is_dir()); + node_logs_dir.assert(predicate::path::is_dir()); + + assert_eq!(node_registry.nodes.len(), 1); + assert_eq!(node_registry.nodes[0].node_ip, Some(custom_ip)); + + Ok(()) +} + #[tokio::test] async fn add_node_should_use_custom_ports_for_one_service() -> Result<()> { let tmp_data_dir = assert_fs::TempDir::new()?; @@ -1044,6 +1183,7 @@ async fn add_node_should_use_custom_ports_for_one_service() -> Result<()> { log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: Some(custom_port), owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -1078,6 +1218,7 @@ async fn add_node_should_use_custom_ports_for_one_service() -> Result<()> { log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: Some(PortRange::Single(custom_port)), rpc_address: None, rpc_port: None, @@ -1296,6 +1437,7 @@ async fn add_node_should_use_a_custom_port_range() -> Result<()> { log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: Some(PortRange::Range(12000, 12002)), rpc_address: None, rpc_port: None, @@ -1346,6 +1488,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_is_used() -> R log_format: None, log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), metrics_port: None, + node_ip: None, node_port: Some(12000), number: 1, owner: None, @@ -1389,6 +1532,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_is_used() -> R log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: Some(PortRange::Single(12000)), rpc_address: None, rpc_port: None, @@ -1437,6 +1581,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_in_range_is_us log_format: None, log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), metrics_port: None, + node_ip: None, node_port: Some(12000), number: 1, owner: None, @@ -1480,6 +1625,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_port_in_range_is_us log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: Some(PortRange::Range(12000, 12002)), rpc_address: None, rpc_port: None, @@ -1546,6 +1692,7 @@ async fn add_node_should_return_an_error_if_port_and_node_count_do_not_match() - log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: Some(PortRange::Range(12000, 12002)), rpc_address: None, rpc_port: None, @@ -1617,6 +1764,7 @@ async fn add_node_should_return_an_error_if_multiple_services_are_specified_with log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: Some(PortRange::Single(12000)), rpc_address: None, rpc_port: None, @@ -1741,6 +1889,7 @@ async fn add_node_should_set_random_ports_if_enable_metrics_server_is_true() -> log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -1953,6 +2102,7 @@ async fn add_node_should_use_a_custom_port_range_for_metrics_server() -> Result< log_format: None, metrics_port: Some(PortRange::Range(12000, 12002)), owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -2000,6 +2150,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_is_use log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: Some(12000), + node_ip: None, node_port: None, number: 1, owner: None, @@ -2043,6 +2194,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_is_use log_format: None, metrics_port: Some(PortRange::Single(12000)), owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -2092,6 +2244,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_in_ran log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: Some(12000), + node_ip: None, node_port: None, number: 1, owner: None, @@ -2135,6 +2288,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_metrics_port_in_ran log_format: None, metrics_port: Some(PortRange::Range(12000, 12002)), owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -2331,6 +2485,7 @@ async fn add_node_should_use_a_custom_port_range_for_the_rpc_server() -> Result< log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: Some(PortRange::Range(20000, 20002)), @@ -2389,6 +2544,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_is_used() log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2432,6 +2588,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_is_used() log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: Some(PortRange::Single(8081)), @@ -2481,6 +2638,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_in_range_i log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2524,6 +2682,7 @@ async fn add_node_should_return_an_error_if_duplicate_custom_rpc_port_in_range_i log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: Some(PortRange::Range(8081, 8082)), @@ -2597,6 +2756,7 @@ async fn add_node_should_disable_upnp_and_home_network_if_nat_status_is_public() log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -2630,6 +2790,7 @@ async fn add_node_should_disable_upnp_and_home_network_if_nat_status_is_public() log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -2700,6 +2861,7 @@ async fn add_node_should_enable_upnp_if_nat_status_is_upnp() -> Result<()> { log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -2733,6 +2895,7 @@ async fn add_node_should_enable_upnp_if_nat_status_is_upnp() -> Result<()> { log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -2803,6 +2966,7 @@ async fn add_node_should_enable_home_network_if_nat_status_is_private() -> Resul log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 12001), @@ -2836,6 +3000,7 @@ async fn add_node_should_enable_home_network_if_nat_status_is_private() -> Resul log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -2910,6 +3075,7 @@ async fn add_node_should_return_an_error_if_nat_status_is_none_but_auto_set_nat_ log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -3521,6 +3687,7 @@ async fn add_node_should_not_delete_the_source_binary_if_path_arg_is_used() -> R log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -3555,6 +3722,7 @@ async fn add_node_should_not_delete_the_source_binary_if_path_arg_is_used() -> R log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -3626,6 +3794,7 @@ async fn add_node_should_apply_the_home_network_flag_if_it_is_used() -> Result<( log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -3660,6 +3829,7 @@ async fn add_node_should_apply_the_home_network_flag_if_it_is_used() -> Result<( log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -3731,6 +3901,7 @@ async fn add_node_should_add_the_node_in_user_mode() -> Result<()> { log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -3765,6 +3936,7 @@ async fn add_node_should_add_the_node_in_user_mode() -> Result<()> { log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -3833,6 +4005,7 @@ async fn add_node_should_add_the_node_with_upnp_enabled() -> Result<()> { log_format: None, metrics_port: None, name: "safenode1".to_string(), + node_ip: None, node_port: None, owner: None, rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), @@ -3867,6 +4040,7 @@ async fn add_node_should_add_the_node_with_upnp_enabled() -> Result<()> { log_format: None, metrics_port: None, owner: None, + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -3982,6 +4156,7 @@ async fn add_node_should_assign_an_owner() -> Result<()> { log_format: None, metrics_port: None, owner: Some("discord_username".to_string()), + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, @@ -4099,6 +4274,7 @@ async fn add_node_should_auto_restart() -> Result<()> { log_format: None, metrics_port: None, owner: Some("discord_username".to_string()), + node_ip: None, node_port: None, rpc_address: None, rpc_port: None, diff --git a/sn_node_manager/src/bin/cli/main.rs b/sn_node_manager/src/bin/cli/main.rs index 152eb880c1..7e89275279 100644 --- a/sn_node_manager/src/bin/cli/main.rs +++ b/sn_node_manager/src/bin/cli/main.rs @@ -146,6 +146,11 @@ 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)] metrics_port: Option, + /// Specify the IP address for the safenode service(s). + /// + /// If not set, we bind to all the available network interfaces. + #[clap(long)] + node_ip: Option, /// Specify a port for the safenode service(s). /// /// If not used, ports will be selected at random. @@ -1022,6 +1027,7 @@ async fn main() -> Result<()> { log_dir_path, log_format, metrics_port, + node_ip, node_port, owner, path, @@ -1045,6 +1051,7 @@ async fn main() -> Result<()> { log_dir_path, log_format, metrics_port, + node_ip, node_port, owner, peers, diff --git a/sn_node_manager/src/cmd/node.rs b/sn_node_manager/src/cmd/node.rs index 3578b62f97..8a7ba87435 100644 --- a/sn_node_manager/src/cmd/node.rs +++ b/sn_node_manager/src/cmd/node.rs @@ -47,6 +47,7 @@ pub async fn add( log_dir_path: Option, log_format: Option, metrics_port: Option, + node_ip: Option, node_port: Option, owner: Option, peers_args: PeersArgs, @@ -146,6 +147,7 @@ pub async fn add( log_format, metrics_port, owner, + node_ip, node_port, rpc_address, rpc_port, @@ -604,6 +606,7 @@ pub async fn maintain_n_running_nodes( log_dir_path: Option, log_format: Option, metrics_port: Option, + node_ip: Option, node_port: Option, owner: Option, peers: PeersArgs, @@ -704,6 +707,7 @@ pub async fn maintain_n_running_nodes( log_dir_path.clone(), log_format, metrics_port.clone(), + node_ip, Some(PortRange::Single(port)), owner.clone(), peers.clone(), diff --git a/sn_node_manager/src/lib.rs b/sn_node_manager/src/lib.rs index 5841c22cfd..36a452819a 100644 --- a/sn_node_manager/src/lib.rs +++ b/sn_node_manager/src/lib.rs @@ -774,6 +774,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -875,6 +876,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -941,6 +943,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1050,6 +1053,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1129,6 +1133,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1218,6 +1223,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1306,6 +1312,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1364,6 +1371,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1412,6 +1420,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1458,6 +1467,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1507,6 +1517,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1569,6 +1580,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1694,6 +1706,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1781,6 +1794,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -1913,6 +1927,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2057,6 +2072,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2196,6 +2212,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2336,6 +2353,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2506,6 +2524,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2659,6 +2678,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: Some(LogFormat::Json), metrics_port: None, + node_ip: None, node_port: None, owner: None, number: 1, @@ -2815,6 +2835,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -2857,6 +2878,163 @@ mod tests { Ok(()) } + #[tokio::test] + async fn upgrade_should_retain_custom_node_ip() -> 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("safenode_install"); + current_install_dir.create_dir_all()?; + + let current_node_bin = current_install_dir.child("safenode"); + current_node_bin.write_binary(b"fake safenode binary")?; + let target_node_bin = tmp_data_dir.child("safenode"); + target_node_bin.write_binary(b"fake safenode 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("safenode1"), eq(false)) + .times(1) + .returning(|_, _| Ok(())); + + // after binary upgrade + mock_service_control + .expect_uninstall() + .with(eq("safenode1"), 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/safenode-manager/services/safenode1"), + OsString::from("--log-output-dest"), + OsString::from("/var/log/safenode/safenode1"), + OsString::from("--ip"), + OsString::from("192.168.1.1"), + ], + autostart: false, + contents: None, + environment: None, + label: "safenode1".parse()?, + program: current_node_bin.to_path_buf(), + username: Some("safe".to_string()), + working_directory: None, + }), + eq(false), + ) + .times(1) + .returning(|_, _| Ok(())); + + // after service restart + mock_service_control + .expect_start() + .with(eq("safenode1"), 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/safenode-manager/services/safenode1"), + log_path: PathBuf::from("/var/log/safenode/safenode1"), + 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/safenode-manager/services/safenode1"), + genesis: false, + home_network: false, + listen_addr: None, + local: false, + log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), + log_format: None, + metrics_port: None, + number: 1, + node_ip: Some(Ipv4Addr::new(192, 168, 1, 1)), + node_port: None, + owner: None, + peer_id: Some(PeerId::from_str( + "12D3KooWS2tpXGGTmg2AHFiDh57yPQnat49YHnyqoggzXZWpqkCR", + )?), + pid: Some(1000), + reward_balance: Some(NanoTokens::zero()), + rpc_socket_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8081), + safenode_path: current_node_bin.to_path_buf(), + service_name: "safenode1".to_string(), + status: ServiceStatus::Running, + upnp: false, + user: Some("safe".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, + bootstrap_peers: Vec::new(), + 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.node_ip, + Some(Ipv4Addr::new(192, 168, 1, 1)) + ); + + Ok(()) + } + #[tokio::test] async fn upgrade_should_retain_custom_node_ports() -> Result<()> { let current_version = "0.1.0"; @@ -2969,6 +3147,7 @@ mod tests { log_format: None, metrics_port: None, number: 1, + node_ip: None, node_port: Some(12000), owner: None, peer_id: Some(PeerId::from_str( @@ -3121,6 +3300,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: Some(12000), + node_ip: None, node_port: None, number: 1, owner: None, @@ -3277,6 +3457,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: Some(12000), + node_ip: None, node_port: None, number: 1, owner: None, @@ -3433,6 +3614,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: Some("discord_username".to_string()), @@ -3589,6 +3771,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: Some("discord_username".to_string()), @@ -3744,6 +3927,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -3815,6 +3999,7 @@ mod tests { log_dir_path: log_dir.to_path_buf(), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -3871,6 +4056,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -3943,6 +4129,7 @@ mod tests { log_dir_path: PathBuf::from("/var/log/safenode/safenode1"), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -4007,6 +4194,7 @@ mod tests { log_dir_path: log_dir.to_path_buf(), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, @@ -4069,6 +4257,7 @@ mod tests { log_dir_path: log_dir.to_path_buf(), log_format: None, metrics_port: None, + node_ip: None, node_port: None, number: 1, owner: None, diff --git a/sn_node_manager/src/local.rs b/sn_node_manager/src/local.rs index aa468a5179..ec3a7ae34e 100644 --- a/sn_node_manager/src/local.rs +++ b/sn_node_manager/src/local.rs @@ -438,6 +438,7 @@ pub async fn run_node( log_dir_path: node_info.log_path, log_format: run_options.log_format, metrics_port: run_options.metrics_port, + node_ip: None, node_port: run_options.node_port, number: run_options.number, owner: run_options.owner, diff --git a/sn_node_manager/src/rpc.rs b/sn_node_manager/src/rpc.rs index 0d34d10c34..2c8f15a88b 100644 --- a/sn_node_manager/src/rpc.rs +++ b/sn_node_manager/src/rpc.rs @@ -74,6 +74,7 @@ pub async fn restart_node_service( metrics_port: None, owner: current_node_clone.owner.clone(), name: current_node_clone.service_name.clone(), + node_ip: current_node_clone.node_ip, node_port: current_node_clone.get_safenode_port(), rpc_socket_addr: current_node_clone.rpc_socket_addr, safenode_path: current_node_clone.safenode_path.clone(), @@ -188,6 +189,7 @@ pub async fn restart_node_service( log_format: current_node_clone.log_format, name: new_service_name.clone(), metrics_port: None, + node_ip: current_node_clone.node_ip, node_port: None, owner: None, rpc_socket_addr: current_node_clone.rpc_socket_addr, @@ -211,6 +213,7 @@ pub async fn restart_node_service( log_dir_path, log_format: current_node_clone.log_format, metrics_port: None, + node_ip: current_node_clone.node_ip, node_port: None, number: new_node_number as u16, owner: None, diff --git a/sn_node_rpc_client/Cargo.toml b/sn_node_rpc_client/Cargo.toml index d22ef595f6..11bb9349ad 100644 --- a/sn_node_rpc_client/Cargo.toml +++ b/sn_node_rpc_client/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_node_rpc_client" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.6.29" +version = "0.6.30" [[bin]] name = "safenode_rpc_client" @@ -23,13 +23,13 @@ color-eyre = "0.6.2" hex = "~0.4.3" libp2p = { version="0.53", features = ["kad"]} libp2p-identity = { version="0.2.7", features = ["rand"] } -sn_client = { path = "../sn_client", version = "0.110.1" } -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_node = { path = "../sn_node", version = "0.111.2" } -sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.1" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9", features=["rpc"] } -sn_service_management = { path = "../sn_service_management", version = "0.3.12" } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } +sn_client = { path = "../sn_client", version = "0.110.2" } +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_node = { path = "../sn_node", version = "0.111.3" } +sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.5.2" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10", features=["rpc"] } +sn_service_management = { path = "../sn_service_management", version = "0.3.13" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } thiserror = "1.0.23" # # watch out updating this, protoc compiler needs to be installed on all build systems # # arm builds + musl are very problematic diff --git a/sn_peers_acquisition/Cargo.toml b/sn_peers_acquisition/Cargo.toml index 1981e345b1..e76118f488 100644 --- a/sn_peers_acquisition/Cargo.toml +++ b/sn_peers_acquisition/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_peers_acquisition" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.5.1" +version = "0.5.2" [features] local-discovery = [] @@ -21,7 +21,7 @@ lazy_static = "~1.4.0" libp2p = { version="0.53", features = [] } rand = "0.8.5" reqwest = { version="0.12.2", default-features=false, features = ["rustls-tls"] } -sn_protocol = { path = "../sn_protocol", version = "0.17.9", optional = true} +sn_protocol = { path = "../sn_protocol", version = "0.17.10", optional = true} thiserror = "1.0.23" tokio = { version = "1.32.0", default-features = false} tracing = { version = "~0.1.26" } diff --git a/sn_protocol/Cargo.toml b/sn_protocol/Cargo.toml index c5b2be5585..6acc656dd7 100644 --- a/sn_protocol/Cargo.toml +++ b/sn_protocol/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "sn_protocol" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.17.9" +version = "0.17.10" [features] default = [] @@ -28,9 +28,9 @@ rmp-serde = "1.1.1" serde = { version = "1.0.133", features = [ "derive", "rc" ]} serde_json = "1.0" sha2 = "0.10.7" -sn_build_info = { path = "../sn_build_info", version = "0.1.13" } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } -sn_registers = { path = "../sn_registers", version = "0.3.19" } +sn_build_info = { path = "../sn_build_info", version = "0.1.14" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } +sn_registers = { path = "../sn_registers", version = "0.3.20" } thiserror = "1.0.23" tiny-keccak = { version = "~2.0.2", features = [ "sha3" ] } tracing = { version = "~0.1.26" } diff --git a/sn_registers/Cargo.toml b/sn_registers/Cargo.toml index ac2028c42b..dbbcf90564 100644 --- a/sn_registers/Cargo.toml +++ b/sn_registers/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_registers" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.3.19" +version = "0.3.20" [features] test-utils = [] diff --git a/sn_service_management/Cargo.toml b/sn_service_management/Cargo.toml index 863b456a1c..4fb8fe03c3 100644 --- a/sn_service_management/Cargo.toml +++ b/sn_service_management/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "sn_service_management" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.3.12" +version = "0.3.13" [dependencies] async-trait = "0.1" @@ -19,11 +19,11 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" semver = "1.0.20" service-manager = "0.7.0" -sn_logging = { path = "../sn_logging", version = "0.2.34" } -sn_protocol = { path = "../sn_protocol", version = "0.17.9", features = [ +sn_logging = { path = "../sn_logging", version = "0.2.35" } +sn_protocol = { path = "../sn_protocol", version = "0.17.10", features = [ "rpc", ] } -sn_transfers = { path = "../sn_transfers", version = "0.19.1" } +sn_transfers = { path = "../sn_transfers", version = "0.19.2" } sysinfo = "0.30.12" thiserror = "1.0.23" tokio = { version = "1.32.0", features = ["time"] } diff --git a/sn_service_management/src/node.rs b/sn_service_management/src/node.rs index dcf18ee059..ffd6af0742 100644 --- a/sn_service_management/src/node.rs +++ b/sn_service_management/src/node.rs @@ -14,7 +14,13 @@ use service_manager::{ServiceInstallCtx, ServiceLabel}; use sn_logging::LogFormat; use sn_protocol::get_port_from_multiaddr; use sn_transfers::NanoTokens; -use std::{ffi::OsString, net::SocketAddr, path::PathBuf, str::FromStr, time::Duration}; +use std::{ + ffi::OsString, + net::{Ipv4Addr, SocketAddr}, + path::PathBuf, + str::FromStr, + time::Duration, +}; pub struct NodeService<'a> { pub service_data: &'a mut NodeServiceData, @@ -82,6 +88,11 @@ impl<'a> ServiceStateActions for NodeService<'a> { args.push(OsString::from("--home-network")); } + if let Some(node_ip) = self.service_data.node_ip { + args.push(OsString::from("--ip")); + args.push(OsString::from(node_ip.to_string())); + } + if let Some(node_port) = self.service_data.node_port { args.push(OsString::from("--port")); args.push(OsString::from(node_port.to_string())); @@ -261,6 +272,8 @@ pub struct NodeServiceData { #[serde(default)] pub owner: Option, #[serde(default)] + pub node_ip: Option, + #[serde(default)] pub node_port: Option, pub number: u16, #[serde( diff --git a/sn_transfers/Cargo.toml b/sn_transfers/Cargo.toml index db7d5b88d7..0345932980 100644 --- a/sn_transfers/Cargo.toml +++ b/sn_transfers/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "sn_transfers" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.19.1" +version = "0.19.2" [features] reward-forward = [] diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index 55eccf0ebf..cda63acacc 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "test_utils" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.4.5" +version = "0.4.6" [dependencies] color-eyre = "~0.6.2" diff --git a/token_supplies/Cargo.toml b/token_supplies/Cargo.toml index e91e5907d7..a98ec803c4 100644 --- a/token_supplies/Cargo.toml +++ b/token_supplies/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "token_supplies" readme = "README.md" repository = "https://github.com/maidsafe/safe_network" -version = "0.1.52" +version = "0.1.53" [dependencies]