From b4a2f123ab114c2f22c36f5d5082ab1bb7a7c2c4 Mon Sep 17 00:00:00 2001 From: grumbach Date: Fri, 3 Jan 2025 22:37:42 +0900 Subject: [PATCH 01/26] feat: remove feat flags --- ant-cli/Cargo.toml | 5 +---- ant-node/Cargo.toml | 2 +- autonomi/Cargo.toml | 10 ++-------- autonomi/src/client/files/mod.rs | 6 ------ autonomi/src/client/mod.rs | 4 ---- autonomi/tests/fs.rs | 3 --- autonomi/tests/register.rs | 1 - 7 files changed, 4 insertions(+), 27 deletions(-) diff --git a/ant-cli/Cargo.toml b/ant-cli/Cargo.toml index 7e009e48bd..5dad7ec94e 100644 --- a/ant-cli/Cargo.toml +++ b/ant-cli/Cargo.toml @@ -29,9 +29,6 @@ ant-build-info = { path = "../ant-build-info", version = "0.1.21" } ant-logging = { path = "../ant-logging", version = "0.2.42" } ant-protocol = { path = "../ant-protocol", version = "0.3.1" } autonomi = { path = "../autonomi", version = "0.3.1", features = [ - "fs", - "vault", - "registers", "loud", ] } clap = { version = "4.2.1", features = ["derive"] } @@ -60,7 +57,7 @@ tracing = { version = "~0.1.26" } walkdir = "2.5.0" [dev-dependencies] -autonomi = { path = "../autonomi", version = "0.3.1", features = ["fs"]} +autonomi = { path = "../autonomi", version = "0.3.1"} criterion = "0.5.1" eyre = "0.6.8" rand = { version = "~0.8.5", features = ["small_rng"] } diff --git a/ant-node/Cargo.toml b/ant-node/Cargo.toml index 9d689d0041..5cc0cc4c84 100644 --- a/ant-node/Cargo.toml +++ b/ant-node/Cargo.toml @@ -92,7 +92,7 @@ ant-protocol = { path = "../ant-protocol", version = "0.3.1", features = [ ] } assert_fs = "1.0.0" evmlib = { path = "../evmlib", version = "0.1.6" } -autonomi = { path = "../autonomi", version = "0.3.1", features = ["registers"] } +autonomi = { path = "../autonomi", version = "0.3.1" } reqwest = { version = "0.12.2", default-features = false, features = [ "rustls-tls-manual-roots", ] } diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index 57db0e6c6f..f8205ba3a6 100644 --- a/autonomi/Cargo.toml +++ b/autonomi/Cargo.toml @@ -15,22 +15,16 @@ crate-type = ["cdylib", "rlib"] [[example]] name = "data_and_archive" -required-features = ["full"] [[example]] name = "put_and_dir_upload" -required-features = ["full"] [features] -default = ["vault"] +default = [] external-signer = ["ant-evm/external-signer"] extension-module = ["pyo3/extension-module"] -fs = ["tokio/fs"] -full = ["vault", "fs"] local = ["ant-networking/local", "ant-evm/local"] loud = [] -registers = [] -vault = [] [dependencies] ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.1" } @@ -55,7 +49,7 @@ self_encryption = "~0.30.0" serde = { version = "1.0.133", features = ["derive", "rc"] } sha2 = "0.10.6" thiserror = "1.0.23" -tokio = { version = "1.35.0", features = ["sync"] } +tokio = { version = "1.35.0", features = ["sync", "fs"] } tracing = { version = "~0.1.26" } walkdir = "2.5.0" xor_name = "5.0.0" diff --git a/autonomi/src/client/files/mod.rs b/autonomi/src/client/files/mod.rs index a419ecfa04..e53be148bf 100644 --- a/autonomi/src/client/files/mod.rs +++ b/autonomi/src/client/files/mod.rs @@ -1,16 +1,10 @@ -#[cfg(feature = "fs")] use std::path::{Path, PathBuf}; pub mod archive; pub mod archive_public; -#[cfg(feature = "fs")] -#[cfg_attr(docsrs, doc(cfg(feature = "fs")))] pub mod fs; -#[cfg(feature = "fs")] -#[cfg_attr(docsrs, doc(cfg(feature = "fs")))] pub mod fs_public; -#[cfg(feature = "fs")] pub(crate) fn get_relative_file_path_from_abs_file_and_folder_path( abs_file_pah: &Path, abs_folder_path: &Path, diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index b6ddcfbbb9..9cfc7ed156 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -21,11 +21,7 @@ pub mod pointer; #[cfg(feature = "external-signer")] #[cfg_attr(docsrs, doc(cfg(feature = "external-signer")))] pub mod external_signer; -#[cfg(feature = "registers")] -#[cfg_attr(docsrs, doc(cfg(feature = "registers")))] pub mod registers; -#[cfg(feature = "vault")] -#[cfg_attr(docsrs, doc(cfg(feature = "vault")))] pub mod vault; // private module with utility functions diff --git a/autonomi/tests/fs.rs b/autonomi/tests/fs.rs index 926baeb4fd..040af8d725 100644 --- a/autonomi/tests/fs.rs +++ b/autonomi/tests/fs.rs @@ -6,8 +6,6 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -#![cfg(feature = "fs")] - use ant_logging::LogBuilder; use autonomi::Client; use eyre::Result; @@ -76,7 +74,6 @@ fn compute_dir_sha256(dir: &str) -> Result { Ok(format!("{:x}", hasher.finalize())) } -#[cfg(feature = "vault")] #[tokio::test] async fn file_into_vault() -> Result<()> { let _log_appender_guard = LogBuilder::init_single_threaded_tokio_test("file", false); diff --git a/autonomi/tests/register.rs b/autonomi/tests/register.rs index 0709779d5c..1ef2658b9c 100644 --- a/autonomi/tests/register.rs +++ b/autonomi/tests/register.rs @@ -6,7 +6,6 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -#![cfg(feature = "registers")] #![allow(deprecated)] use ant_logging::LogBuilder; From 4edfe6f1c06d27cc05b262fa593efd4e4eff6d15 Mon Sep 17 00:00:00 2001 From: grumbach Date: Fri, 3 Jan 2025 22:39:49 +0900 Subject: [PATCH 02/26] feat: remove feat flags from ci --- .github/workflows/merge.yml | 4 ++-- .github/workflows/nightly.yml | 2 +- autonomi/tests/fs.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index bc5d0d26e7..ef7edc55ac 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -125,11 +125,11 @@ jobs: - name: Run autonomi tests timeout-minutes: 25 - run: cargo test --release --package autonomi --features full,local --lib + run: cargo test --release --package autonomi --features local --lib - name: Run autonomi doc tests timeout-minutes: 25 - run: cargo test --release --package autonomi --features full,local --doc + run: cargo test --release --package autonomi --features local --doc - name: Run bootstrap tests timeout-minutes: 25 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 5c9553034d..cc9e6f690d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -246,7 +246,7 @@ jobs: - name: Run autonomi tests timeout-minutes: 25 - run: cargo test --release --package autonomi --lib --features="full,fs" + run: cargo test --release --package autonomi --lib --features="full" - name: Run bootstrap tests timeout-minutes: 25 diff --git a/autonomi/tests/fs.rs b/autonomi/tests/fs.rs index 040af8d725..88198c4cc6 100644 --- a/autonomi/tests/fs.rs +++ b/autonomi/tests/fs.rs @@ -18,7 +18,7 @@ use tokio::time::sleep; use walkdir::WalkDir; // With a local evm network, and local network, run: -// EVM_NETWORK=local cargo test --features="fs,local" --package autonomi --test file +// EVM_NETWORK=local cargo test --features="local" --package autonomi --test fs #[tokio::test] async fn dir_upload_download() -> Result<()> { let _log_appender_guard = From 0be759b63cdcf141f294a57e7890b49e105cc411 Mon Sep 17 00:00:00 2001 From: grumbach Date: Sat, 4 Jan 2025 03:15:14 +0900 Subject: [PATCH 03/26] feat: local as runtime opt --- .github/workflows/benchmark-prs.yml | 4 +- .../workflows/generate-benchmark-charts.yml | 4 +- .github/workflows/memcheck.yml | 2 +- .github/workflows/merge.yml | 48 +- .github/workflows/nightly.yml | 18 +- Cargo.lock | 491 +++++++++--------- README.md | 10 +- ant-bootstrap/src/cache_store.rs | 2 +- ant-bootstrap/src/initial_peers.rs | 2 +- ant-cli/Cargo.toml | 1 - ant-cli/src/main.rs | 6 +- ant-cli/src/opt.rs | 6 + ant-evm/Cargo.toml | 1 - ant-networking/Cargo.toml | 2 +- ant-networking/src/driver.rs | 8 +- ant-networking/src/event/mod.rs | 3 - ant-networking/src/event/swarm.rs | 33 +- ant-node-manager/src/cmd/mod.rs | 3 - ant-node/Cargo.toml | 6 - ant-node/src/bin/antnode/main.rs | 6 +- ant-node/src/node.rs | 4 +- autonomi/Cargo.toml | 1 - autonomi/README.md | 4 +- autonomi/src/client/mod.rs | 14 +- autonomi/tests/fs.rs | 2 +- evm-testnet/src/main.rs | 2 +- evmlib/Cargo.toml | 1 - evmlib/src/utils.rs | 6 +- 28 files changed, 331 insertions(+), 359 deletions(-) diff --git a/.github/workflows/benchmark-prs.yml b/.github/workflows/benchmark-prs.yml index eb27cf7ffc..d6cb7e1807 100644 --- a/.github/workflows/benchmark-prs.yml +++ b/.github/workflows/benchmark-prs.yml @@ -43,7 +43,7 @@ jobs: # it will be better to execute bench test with `local`, # to make the measurement results reflect speed improvement or regression more accurately. - name: Build binaries - run: cargo build --release --features local --bin antnode --bin ant + run: cargo build --release --bin antnode --bin ant timeout-minutes: 30 - name: Start a local network @@ -169,7 +169,7 @@ jobs: # # Criterion outputs the actual bench results to stderr "2>&1 tee output.txt" takes stderr, # # passes to tee which displays it in the terminal and writes to output.txt # run: | - # cargo criterion --features=local --message-format=json 2>&1 -p sn_cli | tee -a output.txt + # cargo criterion --message-format=json 2>&1 -p sn_cli | tee -a output.txt # cat output.txt | rg benchmark-complete | jq -s 'map({ # name: (.id | split("/"))[-1], # unit: "MiB/s", diff --git a/.github/workflows/generate-benchmark-charts.yml b/.github/workflows/generate-benchmark-charts.yml index 5ec91d7641..4566a37610 100644 --- a/.github/workflows/generate-benchmark-charts.yml +++ b/.github/workflows/generate-benchmark-charts.yml @@ -46,7 +46,7 @@ jobs: run: wget https://sn-node.s3.eu-west-2.amazonaws.com/the-test-data.zip - name: Build node and cli binaries - run: cargo build --release --features local --bin antnode --bin ant + run: cargo build --release --bin antnode --bin ant timeout-minutes: 30 - name: Start a local network @@ -67,7 +67,7 @@ jobs: # Criterion outputs the actual bench results to stderr "2>&1 tee output.txt" takes stderr, # passes to tee which displays it in the terminal and writes to output.txt run: | - cargo criterion --features=local --message-format=json 2>&1 -p autonomi-cli | tee -a output.txt + cargo criterion --message-format=json 2>&1 -p ant | tee -a output.txt cat output.txt | rg benchmark-complete | jq -s 'map({ name: (.id | split("/"))[-1], unit: "MiB/s", diff --git a/.github/workflows/memcheck.yml b/.github/workflows/memcheck.yml index 4853442936..b3f3ed3f50 100644 --- a/.github/workflows/memcheck.yml +++ b/.github/workflows/memcheck.yml @@ -36,7 +36,7 @@ jobs: run: sudo apt-get install -y ripgrep - name: Build binaries - run: cargo build --release --features local --bin antnode --bin ant + run: cargo build --release --bin antnode --bin ant timeout-minutes: 30 - name: Start a local network diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index ef7edc55ac..a6d9eae0a3 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -125,11 +125,11 @@ jobs: - name: Run autonomi tests timeout-minutes: 25 - run: cargo test --release --package autonomi --features local --lib + run: cargo test --release --package autonomi --lib - name: Run autonomi doc tests timeout-minutes: 25 - run: cargo test --release --package autonomi --features local --doc + run: cargo test --release --package autonomi --doc - name: Run bootstrap tests timeout-minutes: 25 @@ -202,7 +202,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Build binaries - run: cargo build --release --features local --bin antnode --bin ant + run: cargo build --release --bin antnode --bin ant timeout-minutes: 30 - name: Start a local network @@ -591,11 +591,11 @@ jobs: # - uses: Swatinem/rust-cache@v2 # - name: Build binaries - # run: cargo build --release --features=local --bin antnode + # run: cargo build --release --bin antnode # timeout-minutes: 30 # - name: Build faucet binary - # run: cargo build --release --bin faucet --features="local,gifting" + # run: cargo build --release --bin faucet --features="gifting" # timeout-minutes: 30 # - name: Start a local network @@ -619,14 +619,14 @@ jobs: # fi # - name: execute the sequential transfers tests - # run: cargo test --release -p ant-node --features="local" --test sequential_transfers -- --nocapture --test-threads=1 + # run: cargo test --release -p ant-node --test sequential_transfers -- --nocapture --test-threads=1 # env: # ANT_LOG: "all" # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} # timeout-minutes: 25 # - name: execute the storage payment tests - # run: cargo test --release -p ant-node --features="local" --test storage_payments -- --nocapture --test-threads=1 + # run: cargo test --release -p ant-node --test storage_payments -- --nocapture --test-threads=1 # env: # ANT_LOG: "all" # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} @@ -657,15 +657,15 @@ jobs: # - uses: Swatinem/rust-cache@v2 # - name: Build binaries - # run: cargo build --release --features=local --bin antnode + # run: cargo build --release --bin antnode # timeout-minutes: 30 # - name: Build faucet binary - # run: cargo build --release --bin faucet --features="local,gifting" + # run: cargo build --release --bin faucet --features="gifting" # timeout-minutes: 30 # - name: Build testing executable - # run: cargo test --release -p ant-node --features=local --test transaction_simulation --no-run + # run: cargo test --release -p ant-node --test transaction_simulation --no-run # env: # # only set the target dir for windows to bypass the linker issue. # # happens if we build the node manager via testnet action @@ -694,7 +694,7 @@ jobs: # fi # - name: execute the transaction simulation - # run: cargo test --release -p ant-node --features="local" --test transaction_simulation -- --nocapture + # run: cargo test --release -p ant-node --test transaction_simulation -- --nocapture # env: # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} # timeout-minutes: 25 @@ -723,15 +723,15 @@ jobs: # - uses: Swatinem/rust-cache@v2 # - name: Build binaries - # run: cargo build --release --features=local,distribution --bin antnode + # run: cargo build --release --features=distribution --bin antnode # timeout-minutes: 35 # - name: Build faucet binary - # run: cargo build --release --features=local,distribution,gifting --bin faucet + # run: cargo build --release --features=distribution,gifting --bin faucet # timeout-minutes: 35 # - name: Build testing executable - # run: cargo test --release --features=local,distribution --no-run + # run: cargo test --release --features=distribution --no-run # env: # # only set the target dir for windows to bypass the linker issue. # # happens if we build the node manager via testnet action @@ -759,7 +759,7 @@ jobs: # fi # - name: execute token_distribution tests - # run: cargo test --release --features=local,distribution token_distribution -- --nocapture --test-threads=1 + # run: cargo test --release --features=distribution token_distribution -- --nocapture --test-threads=1 # env: # ANT_LOG: "all" # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} @@ -797,11 +797,11 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Build binaries - run: cargo build --release --features local --bin antnode + run: cargo build --release --bin antnode timeout-minutes: 30 - name: Build churn tests - run: cargo test --release -p ant-node --features=local --test data_with_churn --no-run + run: cargo test --release -p ant-node --test data_with_churn --no-run env: # only set the target dir for windows to bypass the linker issue. # happens if we build the node manager via testnet action @@ -832,7 +832,7 @@ jobs: fi - name: Chunks data integrity during nodes churn - run: cargo test --release -p ant-node --features=local --test data_with_churn -- --nocapture + run: cargo test --release -p ant-node --test data_with_churn -- --nocapture env: TEST_DURATION_MINS: 5 TEST_TOTAL_CHURN_CYCLES: 15 @@ -944,11 +944,11 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Build binaries - run: cargo build --release --features local --bin antnode + run: cargo build --release --bin antnode timeout-minutes: 30 - name: Build data location and routing table tests - run: cargo test --release -p ant-node --features=local --test verify_data_location --test verify_routing_table --no-run + run: cargo test --release -p ant-node --test verify_data_location --test verify_routing_table --no-run env: # only set the target dir for windows to bypass the linker issue. # happens if we build the node manager via testnet action @@ -979,13 +979,13 @@ jobs: fi - name: Verify the routing tables of the nodes - run: cargo test --release -p ant-node --features "local" --test verify_routing_table -- --nocapture + run: cargo test --release -p ant-node --test verify_routing_table -- --nocapture env: CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} timeout-minutes: 5 - name: Verify the location of the data on the network - run: cargo test --release -p ant-node --features "local" --test verify_data_location -- --nocapture + run: cargo test --release -p ant-node --test verify_data_location -- --nocapture env: CHURN_COUNT: 6 ANT_LOG: "all" @@ -993,7 +993,7 @@ jobs: timeout-minutes: 25 - name: Verify the routing tables of the nodes - run: cargo test --release -p ant-node --features "local" --test verify_routing_table -- --nocapture + run: cargo test --release -p ant-node --test verify_routing_table -- --nocapture env: CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} timeout-minutes: 5 @@ -1267,7 +1267,7 @@ jobs: ls -l - name: Build binaries - run: cargo build --release --features local --bin antnode --bin ant + run: cargo build --release --bin antnode --bin ant timeout-minutes: 30 - name: Start a local network diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index cc9e6f690d..827f873505 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -32,7 +32,7 @@ jobs: continue-on-error: true - name: Build binaries - run: cargo build --release --features local --bin antnode --bin ant + run: cargo build --release --bin antnode --bin ant timeout-minutes: 30 - name: Start a local network @@ -311,11 +311,11 @@ jobs: continue-on-error: true - name: Build binaries - run: cargo build --release --features local --bin antnode + run: cargo build --release --bin antnode timeout-minutes: 30 - name: Build churn tests - run: cargo test --release -p ant-node --features=local --test data_with_churn --no-run + run: cargo test --release -p ant-node --test data_with_churn --no-run env: # only set the target dir for windows to bypass the linker issue. # happens if we build the node manager via testnet action @@ -332,7 +332,7 @@ jobs: build: true - name: Chunks data integrity during nodes churn (during 10min) (in theory) - run: cargo test --release -p ant-node --features=local --test data_with_churn -- --nocapture + run: cargo test --release -p ant-node --test data_with_churn -- --nocapture env: TEST_DURATION_MINS: 60 TEST_CHURN_CYCLES: 6 @@ -464,11 +464,11 @@ jobs: continue-on-error: true - name: Build binaries - run: cargo build --release --features local --bin antnode + run: cargo build --release --bin antnode timeout-minutes: 30 - name: Build data location and routing table tests - run: cargo test --release -p ant-node --features=local --test verify_data_location --test verify_routing_table --no-run + run: cargo test --release -p ant-node --test verify_data_location --test verify_routing_table --no-run env: # only set the target dir for windows to bypass the linker issue. # happens if we build the node manager via testnet action @@ -485,20 +485,20 @@ jobs: build: true - name: Verify the Routing table of the nodes - run: cargo test --release -p ant-node --features=local --test verify_routing_table -- --nocapture + run: cargo test --release -p ant-node --test verify_routing_table -- --nocapture env: CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} timeout-minutes: 5 - name: Verify the location of the data on the network - run: cargo test --release -p ant-node --features=local --test verify_data_location -- --nocapture + run: cargo test --release -p ant-node --test verify_data_location -- --nocapture env: ANT_LOG: "all" CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} timeout-minutes: 90 - name: Verify the routing tables of the nodes - run: cargo test --release -p ant-node --features=local --test verify_routing_table -- --nocapture + run: cargo test --release -p ant-node --test verify_routing_table -- --nocapture env: CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} timeout-minutes: 5 diff --git a/Cargo.lock b/Cargo.lock index 39fb541eb3..0e8339a23a 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 = 4 +version = 3 [[package]] name = "addr2line" @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.1.48" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0161082e0edd9013d23083465cc04b20e44b7a15646d36ba7b0cdb7cd6fe18f" +checksum = "d4e0f0136c085132939da6b753452ebed4efaa73fe523bb855b10c199c2ebfaf" dependencies = [ "alloy-primitives", "num_enum", @@ -199,14 +199,14 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] name = "alloy-core" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618bd382f0bc2ac26a7e4bfae01c9b015ca8f21b37ca40059ae35a7e62b3dc6" +checksum = "5e3fdddfc89197319b1be19875a70ced62a72bebb67e2276dad688cd59f40e70" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -217,9 +217,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41056bde53ae10ffbbf11618efbe1e0290859e5eab0fe9ef82ebdb62f12a866f" +checksum = "b0d2ea4d7f220a19c1f8c98822026d1d26a4b75a72e1a7308d02bab1f77c9a00" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -287,9 +287,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c357da577dfb56998d01f574d81ad7a1958d248740a7981b205d69d65a7da404" +checksum = "e79c6b4bcc1067a7394b5b2aec7da1bd829c8c476b796c73eb14da34392a07a7" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -307,7 +307,7 @@ dependencies = [ "alloy-sol-types", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.9", "tracing", ] @@ -333,7 +333,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] @@ -361,16 +361,16 @@ dependencies = [ "rand 0.8.5", "serde_json", "tempfile", - "thiserror 2.0.6", + "thiserror 2.0.9", "tracing", "url", ] [[package]] name = "alloy-primitives" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6259a506ab13e1d658796c31e6e39d2e2ee89243bcc505ddc613b35732e0a430" +checksum = "0540fd0355d400b59633c27bd4b42173e59943f28e9d3376b77a24771d432d04" dependencies = [ "alloy-rlp", "bytes", @@ -424,11 +424,11 @@ dependencies = [ "lru", "parking_lot", "pin-project", - "reqwest 0.12.9", + "reqwest 0.12.12", "schnellru", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.9", "tokio", "tracing", "url", @@ -454,7 +454,7 @@ checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -469,7 +469,7 @@ dependencies = [ "alloy-transport-http", "futures", "pin-project", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde", "serde_json", "tokio", @@ -557,7 +557,7 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] @@ -573,28 +573,28 @@ dependencies = [ "async-trait", "k256", "rand 0.8.5", - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] name = "alloy-sol-macro" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d64f851d95619233f74b310f12bcf16e0cbc27ee3762b6115c14a84809280a" +checksum = "c6d1a14b4a9f6078ad9132775a2ebb465b06b387d60f7413ddc86d7bf7453408" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf7ed1574b699f48bf17caab4e6e54c6d12bc3c006ab33d58b1e227c1c3559f" +checksum = "4436b4b96d265eb17daea26eb31525c3076d024d10901e446790afbd2f7eeaf5" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -604,16 +604,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c02997ccef5f34f9c099277d4145f183b422938ed5322dc57a089fe9b9ad9ee" +checksum = "e5f58698a18b96faa8513519de112b79a96010b4ff84264ce54a217c52a8e98b" dependencies = [ "alloy-json-abi", "const-hex", @@ -622,15 +622,15 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.90", + "syn 2.0.94", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce13ff37285b0870d0a0746992a4ae48efaf34b766ae4c2640fa15e5305f8e73" +checksum = "1f3d6d2c490f650c5abd65a9a583b09a8c8931c265d3a55b18a8e349dd6d9d84" dependencies = [ "serde", "winnow", @@ -638,9 +638,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1174cafd6c6d810711b4e00383037bdb458efc4fe3dbafafa16567e0320c54d8" +checksum = "c766e4979fc19d70057150befe8e3ea3f0c4cbc6839b8eaaa250803451692305" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -661,7 +661,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.9", "tokio", "tower 0.5.2", "tracing", @@ -677,7 +677,7 @@ checksum = "2e02ffd5d93ffc51d72786e607c97de3b60736ca3e636ead0ec1f7dce68ea3fd" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde_json", "tower 0.5.2", "tracing", @@ -686,9 +686,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a5fd8fea044cc9a8c8a50bb6f28e31f0385d820f116c5b98f6f4e55d6e5590b" +checksum = "6917c79e837aa7b77b7a6dae9f89cbe15313ac161c4d3cfaf8909ef21f3d22d8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -782,7 +782,7 @@ dependencies = [ "dirs-next", "futures", "libp2p", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde", "serde_json", "tempfile", @@ -914,7 +914,7 @@ dependencies = [ "futures", "hex", "hkdf", - "hyper 0.14.31", + "hyper 0.14.32", "itertools 0.12.1", "libp2p", "libp2p-identity", @@ -973,7 +973,7 @@ dependencies = [ "pyo3", "rand 0.8.5", "rayon", - "reqwest 0.12.9", + "reqwest 0.12.12", "rmp-serde", "self_encryption", "serde", @@ -1019,11 +1019,11 @@ dependencies = [ "libp2p-identity", "mockall 0.12.1", "nix 0.27.1", - "predicates 3.1.2", + "predicates 3.1.3", "prost 0.9.0", "rand 0.8.5", - "reqwest 0.12.9", - "semver 1.0.23", + "reqwest 0.12.12", + "semver 1.0.24", "serde", "serde_json", "service-manager", @@ -1120,8 +1120,8 @@ dependencies = [ "flate2", "lazy_static", "regex", - "reqwest 0.12.9", - "semver 1.0.23", + "reqwest 0.12.12", + "semver 1.0.24", "serde_json", "tar", "thiserror 1.0.69", @@ -1143,7 +1143,7 @@ dependencies = [ "libp2p-identity", "mockall 0.11.4", "prost 0.9.0", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "service-manager", @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arboard" @@ -1367,7 +1367,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "synstructure", ] @@ -1379,7 +1379,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -1402,7 +1402,7 @@ dependencies = [ "bstr", "doc-comment", "libc", - "predicates 3.1.2", + "predicates 3.1.3", "predicates-core", "predicates-tree", "wait-timeout", @@ -1417,7 +1417,7 @@ dependencies = [ "anstyle", "doc-comment", "globwalk", - "predicates 3.1.2", + "predicates 3.1.3", "predicates-core", "predicates-tree", "tempfile", @@ -1489,18 +1489,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -1556,7 +1556,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -1615,7 +1615,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.31", + "hyper 0.14.32", "itoa", "matchit", "memchr", @@ -1730,18 +1730,18 @@ dependencies = [ [[package]] name = "bit-set" -version = "0.5.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" -version = "0.6.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitcoin-internals" @@ -1919,9 +1919,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.11.1" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786a307d683a5bf92e6fd5fd69a7eb613751668d1d8d67d802846dfe367c62c8" +checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0" dependencies = [ "memchr", "regex-automata 0.4.9", @@ -1942,9 +1942,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" [[package]] name = "byteorder" @@ -2029,7 +2029,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "thiserror 1.0.69", @@ -2076,9 +2076,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.3" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" +checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" dependencies = [ "jobserver", "libc", @@ -2218,7 +2218,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -2277,19 +2277,19 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "colored" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] name = "compact_str" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644" +checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32" dependencies = [ "castaway", "cfg-if", @@ -2330,15 +2330,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.8" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" dependencies = [ - "encode_unicode 0.3.6", - "lazy_static", + "encode_unicode", "libc", - "unicode-width 0.1.14", - "windows-sys 0.52.0", + "once_cell", + "unicode-width 0.2.0", + "windows-sys 0.59.0", ] [[package]] @@ -2510,18 +2510,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -2538,9 +2538,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crossterm" @@ -2668,7 +2668,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -2689,7 +2689,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "synstructure", ] @@ -2714,7 +2714,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -2725,7 +2725,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -2860,7 +2860,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "unicode-xid", ] @@ -2967,7 +2967,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -3067,12 +3067,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "encode_unicode" version = "1.0.0" @@ -3097,7 +3091,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -3330,7 +3324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide 0.8.2", ] [[package]] @@ -3342,6 +3336,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "float-cmp" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -3350,9 +3353,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "foreign-types" @@ -3372,7 +3375,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -3500,7 +3503,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -3690,7 +3693,7 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d48b897b4bbc881aea994b4a5bbb340a04979d7be9089791304e04a9fbc66b53" dependencies = [ - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] @@ -3699,7 +3702,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6ffbeb3a5c0b8b84c3fe4133a6f8c82fa962f4caefe8d0762eced025d3eb4f7" dependencies = [ - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] @@ -3747,7 +3750,7 @@ dependencies = [ "bstr", "gix-path", "libc", - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] @@ -3900,7 +3903,7 @@ checksum = "999ce923619f88194171a67fb3e6d613653b8d4d6078b529b15a765da0edcc17" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -3970,7 +3973,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] @@ -3981,7 +3984,7 @@ checksum = "64a1e282216ec2ab2816cd57e6ed88f8009e634aec47562883c05ac8a7009a63" dependencies = [ "bstr", "gix-utils", - "thiserror 2.0.6", + "thiserror 2.0.9", ] [[package]] @@ -4137,9 +4140,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "globset" @@ -4422,11 +4425,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4547,9 +4550,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.31" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ "bytes", "futures-channel", @@ -4571,9 +4574,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -4596,7 +4599,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.32", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", @@ -4604,13 +4607,13 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http 1.2.0", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "rustls 0.23.20", "rustls-pki-types", @@ -4626,7 +4629,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.31", + "hyper 0.14.32", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -4643,7 +4646,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.1", + "hyper 1.5.2", "pin-project-lite", "socket2", "tokio", @@ -4789,7 +4792,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -4863,7 +4866,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.32", "log", "rand 0.8.5", "tokio", @@ -4917,7 +4920,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -4986,16 +4989,16 @@ dependencies = [ [[package]] name = "instability" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b829f37dead9dc39df40c2d3376c179fdfd2ac771f53f55d3c30dc096a3c0c6e" +checksum = "898e106451f7335950c9cc64f8ec67b5f65698679ac67ed00619aeef14e1cf75" dependencies = [ "darling", "indoc", "pretty_assertions", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -5145,21 +5148,15 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.168" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" - -[[package]] -name = "libm" -version = "0.2.11" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libp2p" @@ -5567,7 +5564,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -5799,9 +5796,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", "simd-adler32", @@ -5857,7 +5854,7 @@ dependencies = [ "fragile", "lazy_static", "mockall_derive 0.12.1", - "predicates 3.1.2", + "predicates 3.1.3", "predicates-tree", ] @@ -5882,7 +5879,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -6115,7 +6112,7 @@ dependencies = [ "prometheus-parse", "ratatui", "regex", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde", "serde_json", "signal-hook", @@ -6207,7 +6204,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -6237,7 +6233,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -6257,9 +6253,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nybbles" -version = "0.2.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f06be0417d97f81fe4e5c86d7d01b392655a9cac9c19a848aa033e18937b23" +checksum = "a3409fc85ac27b27d971ea7cd1aabafd2eefa6de7e481c8d4f707225c117e81a" dependencies = [ "alloy-rlp", "const-hex", @@ -6519,9 +6515,9 @@ dependencies = [ [[package]] name = "os_info" -version = "3.9.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ca711d8b83edbb00b44d504503cd247c9c0bd8b0fa2694f2a1a3d8165379ce" +checksum = "eb6651f4be5e39563c4fe5cc8326349eb99a25d805a3493f791d5bfd0269e430" dependencies = [ "log", "serde", @@ -6671,7 +6667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.6", + "thiserror 2.0.9", "ucd-trie", ] @@ -6695,7 +6691,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -6736,7 +6732,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -6810,15 +6806,15 @@ dependencies = [ [[package]] name = "png" -version = "0.17.15" +version = "0.17.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67582bd5b65bdff614270e2ea89a1cf15bef71245cc1e5f7ea126977144211d" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" dependencies = [ "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.8.0", + "miniz_oxide 0.8.2", ] [[package]] @@ -6887,7 +6883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" dependencies = [ "difflib", - "float-cmp", + "float-cmp 0.9.0", "itertools 0.10.5", "normalize-line-endings", "predicates-core", @@ -6896,13 +6892,13 @@ dependencies = [ [[package]] name = "predicates" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" dependencies = [ "anstyle", "difflib", - "float-cmp", + "float-cmp 0.10.0", "normalize-line-endings", "predicates-core", "regex", @@ -6910,15 +6906,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" [[package]] name = "predicates-tree" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" dependencies = [ "predicates-core", "termtree", @@ -6941,7 +6937,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46480520d1b77c9a3482d39939fcf96831537a250ec62d4fd8fbdf8e0302e781" dependencies = [ "csv", - "encode_unicode 1.0.0", + "encode_unicode", "is-terminal", "lazy_static", "term", @@ -6987,7 +6983,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -7025,7 +7021,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -7042,9 +7038,9 @@ dependencies = [ [[package]] name = "proptest" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" +checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" dependencies = [ "bit-set", "bit-vec", @@ -7183,7 +7179,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -7196,7 +7192,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -7261,7 +7257,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.20", "socket2", - "thiserror 2.0.6", + "thiserror 2.0.9", "tokio", "tracing", ] @@ -7280,7 +7276,7 @@ dependencies = [ "rustls 0.23.20", "rustls-pki-types", "slab", - "thiserror 2.0.6", + "thiserror 2.0.9", "tinyvec", "tracing", "web-time", @@ -7288,9 +7284,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52cd4b1eff68bf27940dd39811292c49e007f4d0b4c357358dc9b0197be6b527" +checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ "cfg_aliases", "libc", @@ -7302,9 +7298,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -7528,7 +7524,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.31", + "hyper 0.14.32", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -7557,9 +7553,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ "base64 0.22.1", "bytes", @@ -7568,8 +7564,8 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", - "hyper-rustls 0.27.3", + "hyper 1.5.2", + "hyper-rustls 0.27.5", "hyper-util", "ipnet", "js-sys", @@ -7588,6 +7584,7 @@ dependencies = [ "sync_wrapper 1.0.2", "tokio", "tokio-rustls 0.26.1", + "tower 0.5.2", "tower-service", "url", "wasm-bindgen", @@ -7809,7 +7806,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.23", + "semver 1.0.24", ] [[package]] @@ -7893,9 +7890,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" dependencies = [ "web-time", ] @@ -7923,9 +7920,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "rusty-fork" @@ -7967,9 +7964,9 @@ dependencies = [ [[package]] name = "schnellru" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" +checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" dependencies = [ "ahash", "cfg-if", @@ -8059,9 +8056,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" dependencies = [ "serde", ] @@ -8077,29 +8074,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" dependencies = [ "itoa", "memchr", @@ -8150,9 +8147,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "base64 0.22.1", "chrono", @@ -8168,14 +8165,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -8442,7 +8439,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -8464,9 +8461,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" dependencies = [ "proc-macro2", "quote", @@ -8475,14 +8472,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219389c1ebe89f8333df8bdfb871f6631c552ff399c23cac02480b6088aad8f0" +checksum = "c74af950d86ec0f5b2ae2d7f1590bbfbcf4603a0a15742d8f98132ac4fe3efd4" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -8508,7 +8505,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -8593,12 +8590,13 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand 2.3.0", + "getrandom 0.2.15", "once_cell", "rustix", "windows-sys 0.59.0", @@ -8627,9 +8625,9 @@ dependencies = [ [[package]] name = "termtree" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] name = "test-utils" @@ -8656,11 +8654,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.6" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" +checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ - "thiserror-impl 2.0.6", + "thiserror-impl 2.0.9", ] [[package]] @@ -8671,18 +8669,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] name = "thiserror-impl" -version = "2.0.6" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" +checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -8789,9 +8787,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "tinyvec_macros", ] @@ -8838,7 +8836,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -8972,7 +8970,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.31", + "hyper 0.14.32", "hyper-timeout", "percent-encoding", "pin-project", @@ -9004,7 +9002,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.31", + "hyper 0.14.32", "hyper-timeout", "percent-encoding", "pin-project", @@ -9059,6 +9057,7 @@ dependencies = [ "futures-util", "pin-project-lite", "sync_wrapper 1.0.2", + "tokio", "tower-layer", "tower-service", ] @@ -9107,7 +9106,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -9227,7 +9226,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -9297,9 +9296,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicase" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-bom" @@ -9562,7 +9561,7 @@ dependencies = [ "futures-util", "headers", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.32", "log", "mime", "mime_guess", @@ -9613,7 +9612,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "wasm-bindgen-shared", ] @@ -9648,7 +9647,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -10013,9 +10012,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" dependencies = [ "memchr", ] @@ -10049,7 +10048,7 @@ dependencies = [ "futures", "futures-timer", "http-types", - "hyper 0.14.31", + "hyper 0.14.32", "log", "once_cell", "regex", @@ -10242,7 +10241,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "synstructure", ] @@ -10264,7 +10263,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -10284,7 +10283,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", "synstructure", ] @@ -10305,7 +10304,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] @@ -10327,7 +10326,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.94", ] [[package]] diff --git a/README.md b/README.md index f2dee6452b..e110c4811d 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ To upload a file or a directory, you need to set the `SECRET_KEY` environment va > When running a local network, you can use the `SECRET_KEY` printed by the `evm-testnet` command [step 2](#2-run-a-local-evm-node) as it has all the money. ```bash -SECRET_KEY= cargo run --bin ant --features local -- file upload +SECRET_KEY= cargo run --bin ant -- --local file upload ``` The output will print out the address at which the content was uploaded. @@ -139,7 +139,7 @@ The output will print out the address at which the content was uploaded. Now to download the files again: ```bash -cargo run --bin ant --features local -- file download +cargo run --bin ant -- --local file download ``` ### Registers @@ -150,7 +150,7 @@ their use by two users to exchange text messages in a crude chat application. In the first terminal, using the registers example, Alice creates a register: ``` -cargo run --example registers --features=local -- --user alice --reg-nickname myregister +cargo run --example registers -- --local --user alice --reg-nickname myregister ``` Alice can now write a message to the register and see anything written by anyone else. For example @@ -193,7 +193,7 @@ message Alice has written, and he can write back by running this command with th from Alice. (Note that the command should all be on one line): ``` -cargo run --example registers --features=local -- --user bob --reg-address 50f4c9d55aa1f4fc19149a86e023cd189e509519788b4ad8625a1ce62932d1938cf4242e029cada768e7af0123a98c25973804d84ad397ca65cb89d6580d04ff07e5b196ea86f882b925be6ade06fc8d +cargo run --example registers -- --local --user bob --reg-address 50f4c9d55aa1f4fc19149a86e023cd189e509519788b4ad8625a1ce62932d1938cf4242e029cada768e7af0123a98c25973804d84ad397ca65cb89d6580d04ff07e5b196ea86f882b925be6ade06fc8d ``` After retrieving the register and displaying the message from Alice, Bob can reply and at any time, @@ -220,7 +220,7 @@ A second example, `register_inspect` allows you to view its structure and conten the above example you again provide the address of the register. For example: ``` -cargo run --example register_inspect --features=local -- --reg-address 50f4c9d55aa1f4fc19149a86e023cd189e509519788b4ad8625a1ce62932d1938cf4242e029cada768e7af0123a98c25973804d84ad397ca65cb89d6580d04ff07e5b196ea86f882b925be6ade06fc8d +cargo run --example register_inspect -- --local --reg-address 50f4c9d55aa1f4fc19149a86e023cd189e509519788b4ad8625a1ce62932d1938cf4242e029cada768e7af0123a98c25973804d84ad397ca65cb89d6580d04ff07e5b196ea86f882b925be6ade06fc8d ``` After printing a summary of the register, this example will display diff --git a/ant-bootstrap/src/cache_store.rs b/ant-bootstrap/src/cache_store.rs index 4f9a0fd495..d9d9bd131a 100644 --- a/ant-bootstrap/src/cache_store.rs +++ b/ant-bootstrap/src/cache_store.rs @@ -199,7 +199,7 @@ impl BootstrapCacheStore { } // If local mode is enabled, return empty store (will use mDNS) - if peers_arg.local || cfg!(feature = "local") { + if peers_arg.local { info!("Setting config to not write to cache, as 'local' mode is enabled"); store.config.disable_cache_writing = true; } diff --git a/ant-bootstrap/src/initial_peers.rs b/ant-bootstrap/src/initial_peers.rs index 27e59d899c..1a5b33ffe1 100644 --- a/ant-bootstrap/src/initial_peers.rs +++ b/ant-bootstrap/src/initial_peers.rs @@ -117,7 +117,7 @@ impl PeersArgs { } // If local mode is enabled, return empty store (will use mDNS) - if self.local || cfg!(feature = "local") { + if self.local { info!("Local mode enabled, using only local discovery."); return Ok(vec![]); } diff --git a/ant-cli/Cargo.toml b/ant-cli/Cargo.toml index 5dad7ec94e..8a25891372 100644 --- a/ant-cli/Cargo.toml +++ b/ant-cli/Cargo.toml @@ -15,7 +15,6 @@ path = "src/main.rs" [features] default = ["metrics"] -local = ["ant-bootstrap/local", "autonomi/local", "ant-logging/process-metrics"] metrics = ["ant-logging/process-metrics"] nightly = [] diff --git a/ant-cli/src/main.rs b/ant-cli/src/main.rs index 971c38fd6a..bc9a627500 100644 --- a/ant-cli/src/main.rs +++ b/ant-cli/src/main.rs @@ -24,7 +24,6 @@ pub use access::user_data; use clap::Parser; use color_eyre::Result; -#[cfg(feature = "local")] use ant_logging::metrics::init_metrics; use ant_logging::{LogBuilder, LogFormat, ReloadHandle, WorkerGuard}; use ant_protocol::version; @@ -73,8 +72,9 @@ async fn main() -> Result<()> { } let _log_guards = init_logging_and_metrics(&opt)?; - #[cfg(feature = "local")] - tokio::spawn(init_metrics(std::process::id())); + if opt.local { + tokio::spawn(init_metrics(std::process::id())); + } info!("\"{}\"", std::env::args().collect::>().join(" ")); let version = ant_build_info::git_info(); diff --git a/ant-cli/src/opt.rs b/ant-cli/src/opt.rs index 9d7e4edd9b..ef74118cd1 100644 --- a/ant-cli/src/opt.rs +++ b/ant-cli/src/opt.rs @@ -19,6 +19,12 @@ use std::time::Duration; #[command(disable_version_flag = true)] #[command(author, version, about, long_about = None)] pub(crate) struct Opt { + /// Specify whether the cli is operating with a local network. + /// + /// This is used to run the cli against a local test network. + #[clap(long, default_value_t = false)] + pub local: bool, + /// Available sub commands. #[clap(subcommand)] pub command: Option, diff --git a/ant-evm/Cargo.toml b/ant-evm/Cargo.toml index 6c88635a3c..72bdec0ecb 100644 --- a/ant-evm/Cargo.toml +++ b/ant-evm/Cargo.toml @@ -10,7 +10,6 @@ repository = "https://github.com/maidsafe/autonomi" version = "0.1.6" [features] -local = ["evmlib/local"] external-signer = ["evmlib/external-signer"] test-utils = [] diff --git a/ant-networking/Cargo.toml b/ant-networking/Cargo.toml index 6ed279891f..fdf537808c 100644 --- a/ant-networking/Cargo.toml +++ b/ant-networking/Cargo.toml @@ -11,7 +11,6 @@ version = "0.3.1" [features] default = [] -local = ["libp2p/mdns"] loud = [] open-metrics = ["libp2p/metrics", "prometheus-client", "hyper", "sysinfo"] upnp = ["libp2p/upnp"] @@ -39,6 +38,7 @@ itertools = "~0.12.1" libp2p = { version = "0.54.1", features = [ "tokio", "dns", + "mdns", "kad", "macros", "request-response", diff --git a/ant-networking/src/driver.rs b/ant-networking/src/driver.rs index 0ee325f6d5..d456bda114 100644 --- a/ant-networking/src/driver.rs +++ b/ant-networking/src/driver.rs @@ -44,7 +44,6 @@ use ant_protocol::{ use ant_registers::SignedRegister; use futures::future::Either; use futures::StreamExt; -#[cfg(feature = "local")] use libp2p::mdns; use libp2p::{core::muxing::StreamMuxerBox, relay}; use libp2p::{ @@ -254,7 +253,7 @@ pub(super) struct NodeBehaviour { pub(super) blocklist: libp2p::allow_block_list::Behaviour, pub(super) identify: libp2p::identify::Behaviour, - #[cfg(feature = "local")] + /// mDNS behaviour to use in local mode pub(super) mdns: mdns::tokio::Behaviour, #[cfg(feature = "upnp")] pub(super) upnp: libp2p::swarm::behaviour::toggle::Toggle, @@ -620,7 +619,6 @@ impl NetworkBuilder { } }; - #[cfg(feature = "local")] let mdns_config = mdns::Config { // lower query interval to speed up peer discovery // this increases traffic, but means we no longer have clients unable to connect @@ -629,7 +627,6 @@ impl NetworkBuilder { ..Default::default() }; - #[cfg(feature = "local")] let mdns = mdns::tokio::Behaviour::new(mdns_config, peer_id)?; let agent_version = if is_client { @@ -679,13 +676,12 @@ impl NetworkBuilder { blocklist: libp2p::allow_block_list::Behaviour::default(), relay_client: relay_behaviour, relay_server, + mdns, #[cfg(feature = "upnp")] upnp, request_response, kademlia, identify, - #[cfg(feature = "local")] - mdns, }; let swarm_config = libp2p::swarm::Config::with_tokio_executor() diff --git a/ant-networking/src/event/mod.rs b/ant-networking/src/event/mod.rs index ae6e2aefca..8489d47516 100644 --- a/ant-networking/src/event/mod.rs +++ b/ant-networking/src/event/mod.rs @@ -13,7 +13,6 @@ mod swarm; use crate::{driver::SwarmDriver, error::Result}; use core::fmt; use custom_debug::Debug as CustomDebug; -#[cfg(feature = "local")] use libp2p::mdns; use libp2p::{ kad::{Addresses, Record, RecordKey, K_VALUE}, @@ -46,7 +45,6 @@ pub(super) enum NodeEvent { Upnp(libp2p::upnp::Event), MsgReceived(libp2p::request_response::Event), Kademlia(libp2p::kad::Event), - #[cfg(feature = "local")] Mdns(Box), Identify(Box), RelayClient(Box), @@ -73,7 +71,6 @@ impl From for NodeEvent { } } -#[cfg(feature = "local")] impl From for NodeEvent { fn from(event: mdns::Event) -> Self { NodeEvent::Mdns(Box::new(event)) diff --git a/ant-networking/src/event/swarm.rs b/ant-networking/src/event/swarm.rs index d4385d0500..434b94f7fe 100644 --- a/ant-networking/src/event/swarm.rs +++ b/ant-networking/src/event/swarm.rs @@ -11,7 +11,6 @@ use crate::{ relay_manager::is_a_relayed_peer, time::Instant, NetworkEvent, Result, SwarmDriver, }; use ant_protocol::version::{IDENTIFY_NODE_VERSION_STR, IDENTIFY_PROTOCOL_STR}; -#[cfg(feature = "local")] use libp2p::mdns; #[cfg(feature = "open-metrics")] use libp2p::metrics::Recorder; @@ -287,26 +286,28 @@ impl SwarmDriver { libp2p::identify::Event::Error { .. } => debug!("identify: {iden:?}"), } } - #[cfg(feature = "local")] SwarmEvent::Behaviour(NodeEvent::Mdns(mdns_event)) => { event_string = "mdns"; - match *mdns_event { - mdns::Event::Discovered(list) => { - if self.local { - for (peer_id, addr) in list { - // The multiaddr does not contain the peer ID, so add it. - let addr = addr.with(Protocol::P2p(peer_id)); - - info!(%addr, "mDNS node discovered and dialing"); - - if let Err(err) = self.dial(addr.clone()) { - warn!(%addr, "mDNS node dial error: {err:?}"); + // mDNS is only relevant in local mode + if self.local { + match *mdns_event { + mdns::Event::Discovered(list) => { + if self.local { + for (peer_id, addr) in list { + // The multiaddr does not contain the peer ID, so add it. + let addr = addr.with(Protocol::P2p(peer_id)); + + info!(%addr, "mDNS node discovered and dialing"); + + if let Err(err) = self.dial(addr.clone()) { + warn!(%addr, "mDNS node dial error: {err:?}"); + } } } } - } - mdns::Event::Expired(peer) => { - debug!("mdns peer {peer:?} expired"); + mdns::Event::Expired(peer) => { + debug!("mdns peer {peer:?} expired"); + } } } } diff --git a/ant-node-manager/src/cmd/mod.rs b/ant-node-manager/src/cmd/mod.rs index 45138e640d..20a25fd99a 100644 --- a/ant-node-manager/src/cmd/mod.rs +++ b/ant-node-manager/src/cmd/mod.rs @@ -181,9 +181,6 @@ fn build_binary(bin_type: &ReleaseType) -> Result { if cfg!(feature = "otlp") { args.extend(["--features", "otlp"]); } - if cfg!(feature = "local") { - args.extend(["--features", "local"]); - } if cfg!(feature = "websockets") { args.extend(["--features", "websockets"]); } diff --git a/ant-node/Cargo.toml b/ant-node/Cargo.toml index 5cc0cc4c84..a3f6f9d014 100644 --- a/ant-node/Cargo.toml +++ b/ant-node/Cargo.toml @@ -16,12 +16,6 @@ path = "src/bin/antnode/main.rs" [features] default = ["metrics", "upnp", "open-metrics"] extension-module = ["pyo3/extension-module"] -local = [ - "ant-networking/local", - "ant-evm/local", - "ant-bootstrap/local", - "ant-logging/process-metrics", -] loud = ["ant-networking/loud"] # loud mode: print important messages to console metrics = [] nightly = [] diff --git a/ant-node/src/bin/antnode/main.rs b/ant-node/src/bin/antnode/main.rs index 3397d81461..65ae7f6c45 100644 --- a/ant-node/src/bin/antnode/main.rs +++ b/ant-node/src/bin/antnode/main.rs @@ -15,7 +15,6 @@ mod subcommands; use crate::subcommands::EvmNetworkCommand; use ant_bootstrap::{BootstrapCacheConfig, BootstrapCacheStore, PeersArgs}; use ant_evm::{get_evm_network_from_env, EvmNetwork, RewardsAddress}; -#[cfg(feature = "local")] use ant_logging::metrics::init_metrics; use ant_logging::{Level, LogFormat, LogOutputDest, ReloadHandle}; use ant_node::{Marker, NodeBuilder, NodeEvent, NodeEventsReceiver}; @@ -306,8 +305,9 @@ fn main() -> Result<()> { // Create a tokio runtime per `run_node` attempt, this ensures // any spawned tasks are closed before we would attempt to run // another process with these args. - #[cfg(feature = "local")] - rt.spawn(init_metrics(std::process::id())); + 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 restart_options = rt.block_on(async move { diff --git a/ant-node/src/node.rs b/ant-node/src/node.rs index 3877a31a18..da962bbcff 100644 --- a/ant-node/src/node.rs +++ b/ant-node/src/node.rs @@ -192,6 +192,7 @@ impl NodeBuilder { let node_events_channel = NodeEventsChannel::default(); let node = NodeInner { + local: self.local, network: network.clone(), events_channel: node_events_channel.clone(), initial_peers: self.initial_peers, @@ -228,6 +229,7 @@ pub(crate) struct Node { /// The actual implementation of the Node. The other is just a wrapper around this, so that we don't expose /// the Arc from the interface. struct NodeInner { + local: bool, events_channel: NodeEventsChannel, // Peers that are dialed at startup of node. initial_peers: Vec, @@ -456,7 +458,7 @@ impl Node { } NetworkEvent::NewListenAddr(_) => { event_header = "NewListenAddr"; - if !cfg!(feature = "local") { + if !self.inner.local { let network = self.network().clone(); let peers = self.initial_peers().clone(); let _handle = spawn(async move { diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index f8205ba3a6..696fcc74e2 100644 --- a/autonomi/Cargo.toml +++ b/autonomi/Cargo.toml @@ -23,7 +23,6 @@ name = "put_and_dir_upload" default = [] external-signer = ["ant-evm/external-signer"] extension-module = ["pyo3/extension-module"] -local = ["ant-networking/local", "ant-evm/local"] loud = [] [dependencies] diff --git a/autonomi/README.md b/autonomi/README.md index 72be58b39d..4c19a3e7c4 100644 --- a/autonomi/README.md +++ b/autonomi/README.md @@ -73,7 +73,7 @@ To run the tests, we can run a local network: 3. Then run the tests with the `local` feature and pass the EVM params again: ```sh - EVM_NETWORK=local cargo test --features local --package autonomi + EVM_NETWORK=local cargo test --package autonomi ``` ### Using a live testnet or mainnet @@ -89,7 +89,7 @@ cargo run --bin antctl --features local -- local run --build --clean --rewards-a 2. Then pass the private key of the wallet, and ensure it has enough gas and payment tokens on the network (in this case Arbitrum One): ```sh -EVM_NETWORK=arbitrum-one EVM_PRIVATE_KEY= cargo test --package autonomi --features local +EVM_NETWORK=arbitrum-one EVM_PRIVATE_KEY= cargo test --package autonomi ``` ## Using funds from the Deployer Wallet diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 9cfc7ed156..697e405bbb 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -67,7 +67,7 @@ pub struct Client { } /// Configuration for [`Client::init_with_config`]. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct ClientConfig { /// Whether we're expected to connect to a local network. /// @@ -80,18 +80,6 @@ pub struct ClientConfig { pub peers: Option>, } -impl Default for ClientConfig { - fn default() -> Self { - Self { - #[cfg(feature = "local")] - local: true, - #[cfg(not(feature = "local"))] - local: false, - peers: None, - } - } -} - /// Error returned by [`Client::init`]. #[derive(Debug, thiserror::Error)] pub enum ConnectError { diff --git a/autonomi/tests/fs.rs b/autonomi/tests/fs.rs index 88198c4cc6..1bb4e3a7cf 100644 --- a/autonomi/tests/fs.rs +++ b/autonomi/tests/fs.rs @@ -18,7 +18,7 @@ use tokio::time::sleep; use walkdir::WalkDir; // With a local evm network, and local network, run: -// EVM_NETWORK=local cargo test --features="local" --package autonomi --test fs +// EVM_NETWORK=local cargo test --package autonomi --test fs #[tokio::test] async fn dir_upload_download() -> Result<()> { let _log_appender_guard = diff --git a/evm-testnet/src/main.rs b/evm-testnet/src/main.rs index f865cb8983..e07864700a 100644 --- a/evm-testnet/src/main.rs +++ b/evm-testnet/src/main.rs @@ -164,7 +164,7 @@ impl TestnetData { ); std::fs::write(&csv_path, csv).expect("Could not write to evm_testnet_data.csv file"); println!("EVM testnet data saved to: {csv_path:?}"); - println!("When running the Node or CLI with --feature=local, it will automatically use this network by loading the EVM Network's info from the CSV file."); + println!("When running the Node or CLI in local mode, it will automatically use this network by loading the EVM Network's info from the CSV file."); println!(); } diff --git a/evmlib/Cargo.toml b/evmlib/Cargo.toml index 7c7ee7dbd4..5cedbcc15d 100644 --- a/evmlib/Cargo.toml +++ b/evmlib/Cargo.toml @@ -9,7 +9,6 @@ repository = "https://github.com/maidsafe/safe_network" version = "0.1.6" [features] -local = [] external-signer = [] [dependencies] diff --git a/evmlib/src/utils.rs b/evmlib/src/utils.rs index 4e3133713f..eb5d9ca724 100644 --- a/evmlib/src/utils.rs +++ b/evmlib/src/utils.rs @@ -93,16 +93,12 @@ pub fn get_evm_network_from_env() -> Result { }) .collect::, Error>>(); - let mut use_local_evm = std::env::var("EVM_NETWORK") + let use_local_evm = std::env::var("EVM_NETWORK") .map(|v| v == "local") .unwrap_or(false); if use_local_evm { info!("Using local EVM network as EVM_NETWORK is set to 'local'"); } - if cfg!(feature = "local") { - use_local_evm = true; - info!("Using local EVM network as 'local' feature flag is enabled"); - } let use_arbitrum_one = std::env::var("EVM_NETWORK") .map(|v| v == "arbitrum-one") From cee5d51e7172d823b8c8f0ac3ff6fc8e58366271 Mon Sep 17 00:00:00 2001 From: grumbach Date: Sat, 4 Jan 2025 03:53:58 +0900 Subject: [PATCH 04/26] feat: cli local setup --- ant-cli/src/access/network.rs | 32 +++++++++++++++++++++++++++++--- ant-cli/src/actions/connect.rs | 15 +++++++++++---- ant-cli/src/commands.rs | 2 +- ant-cli/src/commands/file.rs | 8 ++++---- ant-cli/src/commands/register.rs | 10 +++++----- ant-cli/src/commands/vault.rs | 10 +++++----- ant-cli/src/main.rs | 2 +- ant-cli/src/opt.rs | 6 ------ ant-evm/src/lib.rs | 2 +- ant-node/src/bin/antnode/main.rs | 18 +++++++++++------- evmlib/src/utils.rs | 2 +- 11 files changed, 69 insertions(+), 38 deletions(-) diff --git a/ant-cli/src/access/network.rs b/ant-cli/src/access/network.rs index 8c428e06d3..f69c7a3351 100644 --- a/ant-cli/src/access/network.rs +++ b/ant-cli/src/access/network.rs @@ -12,9 +12,35 @@ use color_eyre::eyre::Context; use color_eyre::Result; use color_eyre::Section; -pub async fn get_peers(peers: PeersArgs) -> Result> { - peers.get_addrs(None, Some(100)).await +pub enum NetworkPeers { + Local(Vec), + Public(Vec), +} + +impl NetworkPeers { + pub fn peers(&self) -> &Vec { + match self { + NetworkPeers::Local(addrs) => addrs, + NetworkPeers::Public(addrs) => addrs, + } + } + + pub fn is_local(&self) -> bool { + matches!(self, NetworkPeers::Local(_)) + } +} + +pub async fn get_peers(peers: PeersArgs) -> Result { + let addrs = peers.get_addrs(None, Some(100)).await .wrap_err("Please provide valid Network peers to connect to") .with_suggestion(|| format!("make sure you've provided network peers using the --peers option or the {ANT_PEERS_ENV} env var")) - .with_suggestion(|| "a peer address looks like this: /ip4/42.42.42.42/udp/4242/quic-v1/p2p/B64nodePeerIDvdjb3FAJF4ks3moreBase64CharsHere") + .with_suggestion(|| "a peer address looks like this: /ip4/42.42.42.42/udp/4242/quic-v1/p2p/B64nodePeerIDvdjb3FAJF4ks3moreBase64CharsHere")?; + + let net = if peers.local { + NetworkPeers::Local(addrs) + } else { + NetworkPeers::Public(addrs) + }; + + Ok(net) } diff --git a/ant-cli/src/actions/connect.rs b/ant-cli/src/actions/connect.rs index cba9ac217a..091c87e1c8 100644 --- a/ant-cli/src/actions/connect.rs +++ b/ant-cli/src/actions/connect.rs @@ -7,22 +7,29 @@ // permissions and limitations relating to use of the SAFE Network Software. use autonomi::Client; -use autonomi::Multiaddr; use color_eyre::eyre::bail; use color_eyre::eyre::Result; use indicatif::ProgressBar; use std::time::Duration; -pub async fn connect_to_network(peers: Vec) -> Result { +use crate::network::NetworkPeers; + +pub async fn connect_to_network(peers: NetworkPeers) -> Result { let progress_bar = ProgressBar::new_spinner(); progress_bar.enable_steady_tick(Duration::from_millis(120)); progress_bar.set_message("Connecting to The Autonomi Network..."); let new_style = progress_bar.style().tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈🔗"); progress_bar.set_style(new_style); - progress_bar.set_message("Connecting to The Autonomi Network..."); + let res = if peers.is_local() { + progress_bar.set_message("Connecting to a local Autonomi Network..."); + Client::init_local().await + } else { + progress_bar.set_message("Connecting to The Autonomi Network..."); + Client::init_with_peers(peers.peers().to_vec()).await + }; - match Client::init_with_peers(peers).await { + match res { Ok(client) => { info!("Connected to the Network"); progress_bar.finish_with_message("Connected to the Network"); diff --git a/ant-cli/src/commands.rs b/ant-cli/src/commands.rs index ff065a06c0..c3a22e8939 100644 --- a/ant-cli/src/commands.rs +++ b/ant-cli/src/commands.rs @@ -215,7 +215,7 @@ pub async fn handle_subcommand(opt: Opt) -> Result<()> { VaultCmd::Cost => vault::cost(peers.await?).await, VaultCmd::Create => vault::create(peers.await?).await, VaultCmd::Load => vault::load(peers.await?).await, - VaultCmd::Sync { force } => vault::sync(peers.await?, force).await, + VaultCmd::Sync { force } => vault::sync(force, peers.await?).await, }, Some(SubCmd::Wallet { command }) => match command { WalletCmd::Create { diff --git a/ant-cli/src/commands/file.rs b/ant-cli/src/commands/file.rs index 146133e348..5f9c966c8e 100644 --- a/ant-cli/src/commands/file.rs +++ b/ant-cli/src/commands/file.rs @@ -6,16 +6,16 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. +use crate::network::NetworkPeers; use crate::utils::collect_upload_summary; use crate::wallet::load_wallet; use autonomi::client::address::addr_to_str; -use autonomi::Multiaddr; use color_eyre::eyre::Context; use color_eyre::eyre::Result; use color_eyre::Section; use std::path::PathBuf; -pub async fn cost(file: &str, peers: Vec) -> Result<()> { +pub async fn cost(file: &str, peers: NetworkPeers) -> Result<()> { let client = crate::actions::connect_to_network(peers).await?; println!("Getting upload cost..."); @@ -31,7 +31,7 @@ pub async fn cost(file: &str, peers: Vec) -> Result<()> { Ok(()) } -pub async fn upload(file: &str, public: bool, peers: Vec) -> Result<()> { +pub async fn upload(file: &str, public: bool, peers: NetworkPeers) -> Result<()> { let wallet = load_wallet()?; let mut client = crate::actions::connect_to_network(peers).await?; let event_receiver = client.enable_client_events(); @@ -101,7 +101,7 @@ pub async fn upload(file: &str, public: bool, peers: Vec) -> Result<( Ok(()) } -pub async fn download(addr: &str, dest_path: &str, peers: Vec) -> Result<()> { +pub async fn download(addr: &str, dest_path: &str, peers: NetworkPeers) -> Result<()> { let mut client = crate::actions::connect_to_network(peers).await?; crate::actions::download(addr, dest_path, &mut client).await } diff --git a/ant-cli/src/commands/register.rs b/ant-cli/src/commands/register.rs index 5598fc0544..9e84d607b4 100644 --- a/ant-cli/src/commands/register.rs +++ b/ant-cli/src/commands/register.rs @@ -8,13 +8,13 @@ #![allow(deprecated)] +use crate::network::NetworkPeers; use crate::utils::collect_upload_summary; use crate::wallet::load_wallet; use autonomi::client::registers::RegisterAddress; use autonomi::client::registers::RegisterPermissions; use autonomi::client::registers::RegisterSecretKey; use autonomi::Client; -use autonomi::Multiaddr; use color_eyre::eyre::eyre; use color_eyre::eyre::Context; use color_eyre::eyre::Result; @@ -39,7 +39,7 @@ pub fn generate_key(overwrite: bool) -> Result<()> { Ok(()) } -pub async fn cost(name: &str, peers: Vec) -> Result<()> { +pub async fn cost(name: &str, peers: NetworkPeers) -> Result<()> { let register_key = crate::keys::get_register_signing_key() .wrap_err("The register key is required to perform this action")?; let client = crate::actions::connect_to_network(peers).await?; @@ -53,7 +53,7 @@ pub async fn cost(name: &str, peers: Vec) -> Result<()> { Ok(()) } -pub async fn create(name: &str, value: &str, public: bool, peers: Vec) -> Result<()> { +pub async fn create(name: &str, value: &str, public: bool, peers: NetworkPeers) -> Result<()> { let wallet = load_wallet()?; let register_key = crate::keys::get_register_signing_key() .wrap_err("The register key is required to perform this action")?; @@ -119,7 +119,7 @@ pub async fn create(name: &str, value: &str, public: bool, peers: Vec Ok(()) } -pub async fn edit(address: String, name: bool, value: &str, peers: Vec) -> Result<()> { +pub async fn edit(address: String, name: bool, value: &str, peers: NetworkPeers) -> Result<()> { let register_key = crate::keys::get_register_signing_key() .wrap_err("The register key is required to perform this action")?; let client = crate::actions::connect_to_network(peers).await?; @@ -157,7 +157,7 @@ pub async fn edit(address: String, name: bool, value: &str, peers: Vec) -> Result<()> { +pub async fn get(address: String, name: bool, peers: NetworkPeers) -> Result<()> { let register_key = crate::keys::get_register_signing_key() .wrap_err("The register key is required to perform this action")?; let client = crate::actions::connect_to_network(peers).await?; diff --git a/ant-cli/src/commands/vault.rs b/ant-cli/src/commands/vault.rs index 14e5b6350b..b1ad37257b 100644 --- a/ant-cli/src/commands/vault.rs +++ b/ant-cli/src/commands/vault.rs @@ -6,13 +6,13 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. +use crate::network::NetworkPeers; use crate::wallet::load_wallet; -use autonomi::Multiaddr; use color_eyre::eyre::Context; use color_eyre::eyre::Result; use color_eyre::Section; -pub async fn cost(peers: Vec) -> Result<()> { +pub async fn cost(peers: NetworkPeers) -> Result<()> { let client = crate::actions::connect_to_network(peers).await?; let vault_sk = crate::keys::get_vault_secret_key()?; @@ -27,7 +27,7 @@ pub async fn cost(peers: Vec) -> Result<()> { Ok(()) } -pub async fn create(peers: Vec) -> Result<()> { +pub async fn create(peers: NetworkPeers) -> Result<()> { let client = crate::actions::connect_to_network(peers).await?; let wallet = load_wallet()?; let vault_sk = crate::keys::get_vault_secret_key()?; @@ -55,7 +55,7 @@ pub async fn create(peers: Vec) -> Result<()> { Ok(()) } -pub async fn sync(peers: Vec, force: bool) -> Result<()> { +pub async fn sync(force: bool, peers: NetworkPeers) -> Result<()> { let client = crate::actions::connect_to_network(peers).await?; let vault_sk = crate::keys::get_vault_secret_key()?; let wallet = load_wallet()?; @@ -89,7 +89,7 @@ pub async fn sync(peers: Vec, force: bool) -> Result<()> { Ok(()) } -pub async fn load(peers: Vec) -> Result<()> { +pub async fn load(peers: NetworkPeers) -> Result<()> { let client = crate::actions::connect_to_network(peers).await?; let vault_sk = crate::keys::get_vault_secret_key()?; diff --git a/ant-cli/src/main.rs b/ant-cli/src/main.rs index bc9a627500..e0fe5cf644 100644 --- a/ant-cli/src/main.rs +++ b/ant-cli/src/main.rs @@ -72,7 +72,7 @@ async fn main() -> Result<()> { } let _log_guards = init_logging_and_metrics(&opt)?; - if opt.local { + if opt.peers.local { tokio::spawn(init_metrics(std::process::id())); } diff --git a/ant-cli/src/opt.rs b/ant-cli/src/opt.rs index ef74118cd1..9d7e4edd9b 100644 --- a/ant-cli/src/opt.rs +++ b/ant-cli/src/opt.rs @@ -19,12 +19,6 @@ use std::time::Duration; #[command(disable_version_flag = true)] #[command(author, version, about, long_about = None)] pub(crate) struct Opt { - /// Specify whether the cli is operating with a local network. - /// - /// This is used to run the cli against a local test network. - #[clap(long, default_value_t = false)] - pub local: bool, - /// Available sub commands. #[clap(subcommand)] pub command: Option, diff --git a/ant-evm/src/lib.rs b/ant-evm/src/lib.rs index ece2c36083..678db86c72 100644 --- a/ant-evm/src/lib.rs +++ b/ant-evm/src/lib.rs @@ -19,7 +19,7 @@ pub use evmlib::cryptography; #[cfg(feature = "external-signer")] pub use evmlib::external_signer; pub use evmlib::utils; -pub use evmlib::utils::get_evm_network_from_env; +pub use evmlib::utils::{get_evm_network_from_env, local_evm_network_from_csv}; pub use evmlib::utils::{DATA_PAYMENTS_ADDRESS, PAYMENT_TOKEN_ADDRESS, RPC_URL}; pub use evmlib::wallet::Error as EvmWalletError; pub use evmlib::wallet::Wallet as EvmWallet; diff --git a/ant-node/src/bin/antnode/main.rs b/ant-node/src/bin/antnode/main.rs index 65ae7f6c45..fab6abcfb6 100644 --- a/ant-node/src/bin/antnode/main.rs +++ b/ant-node/src/bin/antnode/main.rs @@ -14,7 +14,7 @@ mod subcommands; use crate::subcommands::EvmNetworkCommand; use ant_bootstrap::{BootstrapCacheConfig, BootstrapCacheStore, PeersArgs}; -use ant_evm::{get_evm_network_from_env, EvmNetwork, RewardsAddress}; +use ant_evm::{get_evm_network_from_env, local_evm_network_from_csv, EvmNetwork, RewardsAddress}; use ant_logging::metrics::init_metrics; use ant_logging::{Level, LogFormat, LogOutputDest, ReloadHandle}; use ant_node::{Marker, NodeBuilder, NodeEvent, NodeEventsReceiver}; @@ -262,12 +262,16 @@ fn main() -> Result<()> { return Ok(()); } - let evm_network: EvmNetwork = opt - .evm_network - .as_ref() - .cloned() - .map(|v| Ok(v.into())) - .unwrap_or_else(get_evm_network_from_env)?; + let evm_network: EvmNetwork = if opt.peers.local { + println!("Running node in local mode"); + local_evm_network_from_csv()? + } else { + opt.evm_network + .as_ref() + .cloned() + .map(|v| Ok(v.into())) + .unwrap_or_else(get_evm_network_from_env)? + }; println!("EVM network: {evm_network:?}"); let node_socket_addr = SocketAddr::new(opt.ip, opt.port); diff --git a/evmlib/src/utils.rs b/evmlib/src/utils.rs index eb5d9ca724..422125fb5a 100644 --- a/evmlib/src/utils.rs +++ b/evmlib/src/utils.rs @@ -132,7 +132,7 @@ pub fn get_evm_network_from_env() -> Result { } /// Get the `Network::Custom` from the local EVM testnet CSV file -fn local_evm_network_from_csv() -> Result { +pub fn local_evm_network_from_csv() -> Result { // load the csv let csv_path = get_evm_testnet_csv_path()?; From 924daff36d2b0b236e7571ed0fabba0f8af32661 Mon Sep 17 00:00:00 2001 From: grumbach Date: Sat, 4 Jan 2025 03:56:35 +0900 Subject: [PATCH 05/26] chore: keep old order --- ant-networking/src/driver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ant-networking/src/driver.rs b/ant-networking/src/driver.rs index d456bda114..8037f78a29 100644 --- a/ant-networking/src/driver.rs +++ b/ant-networking/src/driver.rs @@ -676,12 +676,12 @@ impl NetworkBuilder { blocklist: libp2p::allow_block_list::Behaviour::default(), relay_client: relay_behaviour, relay_server, - mdns, #[cfg(feature = "upnp")] upnp, request_response, kademlia, identify, + mdns, }; let swarm_config = libp2p::swarm::Config::with_tokio_executor() From ce9e9a72d27c20479f3f2c4457af4413460cfbb1 Mon Sep 17 00:00:00 2001 From: grumbach Date: Tue, 7 Jan 2025 01:43:01 +0900 Subject: [PATCH 06/26] chore: fix cli wallet error management --- ant-bootstrap/src/initial_peers.rs | 2 +- ant-cli/src/access/keys.rs | 7 ++- ant-cli/src/commands/file.rs | 2 +- ant-cli/src/commands/register.rs | 2 +- ant-cli/src/commands/vault.rs | 4 +- ant-cli/src/commands/wallet.rs | 7 +-- ant-cli/src/wallet/encryption.rs | 23 +++++----- ant-cli/src/wallet/error.rs | 31 ------------- ant-cli/src/wallet/fs.rs | 70 ++++++++++++++---------------- ant-cli/src/wallet/mod.rs | 9 ++-- autonomi/src/client/mod.rs | 9 ++-- test-utils/src/evm.rs | 9 ++-- 12 files changed, 66 insertions(+), 109 deletions(-) delete mode 100644 ant-cli/src/wallet/error.rs diff --git a/ant-bootstrap/src/initial_peers.rs b/ant-bootstrap/src/initial_peers.rs index 1a5b33ffe1..00241bb7af 100644 --- a/ant-bootstrap/src/initial_peers.rs +++ b/ant-bootstrap/src/initial_peers.rs @@ -53,7 +53,7 @@ pub struct PeersArgs { /// a bootstrap cache JSON file. #[clap(long, conflicts_with = "first", value_delimiter = ',')] pub network_contacts_url: Vec, - /// Set to indicate this is a local network. You could also set the `local` feature flag to set this to true. + /// Set to indicate this is a local network. /// /// This would use mDNS for peer discovery. #[clap(long, conflicts_with = "network_contacts_url", default_value = "false")] diff --git a/ant-cli/src/access/keys.rs b/ant-cli/src/access/keys.rs index cfaa5284b7..9bb3ba2ad5 100644 --- a/ant-cli/src/access/keys.rs +++ b/ant-cli/src/access/keys.rs @@ -9,7 +9,7 @@ use crate::wallet::load_wallet_private_key; use autonomi::client::registers::RegisterSecretKey; use autonomi::client::vault::VaultSecretKey; -use autonomi::{get_evm_network_from_env, Wallet}; +use autonomi::{Network, Wallet}; use color_eyre::eyre::{eyre, Context, Result}; use color_eyre::Section; use std::env; @@ -22,11 +22,10 @@ const REGISTER_SIGNING_KEY_ENV: &str = "REGISTER_SIGNING_KEY"; const REGISTER_SIGNING_KEY_FILE: &str = "register_signing_key"; /// EVM wallet -pub fn load_evm_wallet_from_env() -> Result { +pub fn load_evm_wallet_from_env(evm_network: &Network) -> Result { let secret_key = get_secret_key_from_env().wrap_err("The secret key is required to perform this action")?; - let network = get_evm_network_from_env()?; - let wallet = Wallet::new_from_private_key(network, &secret_key) + let wallet = Wallet::new_from_private_key(evm_network.clone(), &secret_key) .wrap_err("Failed to load EVM wallet from key")?; Ok(wallet) } diff --git a/ant-cli/src/commands/file.rs b/ant-cli/src/commands/file.rs index 5f9c966c8e..23ba6c7afe 100644 --- a/ant-cli/src/commands/file.rs +++ b/ant-cli/src/commands/file.rs @@ -32,8 +32,8 @@ pub async fn cost(file: &str, peers: NetworkPeers) -> Result<()> { } pub async fn upload(file: &str, public: bool, peers: NetworkPeers) -> Result<()> { - let wallet = load_wallet()?; let mut client = crate::actions::connect_to_network(peers).await?; + let wallet = load_wallet(&client.evm_network)?; let event_receiver = client.enable_client_events(); let (upload_summary_thread, upload_completed_tx) = collect_upload_summary(event_receiver); diff --git a/ant-cli/src/commands/register.rs b/ant-cli/src/commands/register.rs index 9e84d607b4..9b95fb7670 100644 --- a/ant-cli/src/commands/register.rs +++ b/ant-cli/src/commands/register.rs @@ -54,10 +54,10 @@ pub async fn cost(name: &str, peers: NetworkPeers) -> Result<()> { } pub async fn create(name: &str, value: &str, public: bool, peers: NetworkPeers) -> Result<()> { - let wallet = load_wallet()?; let register_key = crate::keys::get_register_signing_key() .wrap_err("The register key is required to perform this action")?; let mut client = crate::actions::connect_to_network(peers).await?; + let wallet = load_wallet(&client.evm_network)?; let event_receiver = client.enable_client_events(); let (upload_summary_thread, upload_completed_tx) = collect_upload_summary(event_receiver); diff --git a/ant-cli/src/commands/vault.rs b/ant-cli/src/commands/vault.rs index b1ad37257b..2c8ac619ba 100644 --- a/ant-cli/src/commands/vault.rs +++ b/ant-cli/src/commands/vault.rs @@ -29,7 +29,7 @@ pub async fn cost(peers: NetworkPeers) -> Result<()> { pub async fn create(peers: NetworkPeers) -> Result<()> { let client = crate::actions::connect_to_network(peers).await?; - let wallet = load_wallet()?; + let wallet = load_wallet(&client.evm_network)?; let vault_sk = crate::keys::get_vault_secret_key()?; println!("Retrieving local user data..."); @@ -58,7 +58,7 @@ pub async fn create(peers: NetworkPeers) -> Result<()> { pub async fn sync(force: bool, peers: NetworkPeers) -> Result<()> { let client = crate::actions::connect_to_network(peers).await?; let vault_sk = crate::keys::get_vault_secret_key()?; - let wallet = load_wallet()?; + let wallet = load_wallet(&client.evm_network)?; println!("Fetching vault from network..."); let net_user_data = client diff --git a/ant-cli/src/commands/wallet.rs b/ant-cli/src/commands/wallet.rs index b1a2caf70b..5f123dcb68 100644 --- a/ant-cli/src/commands/wallet.rs +++ b/ant-cli/src/commands/wallet.rs @@ -6,10 +6,10 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use crate::wallet::fs::{select_wallet, select_wallet_private_key, store_private_key}; +use crate::wallet::fs::{select_wallet_private_key, store_private_key}; use crate::wallet::input::request_password; use crate::wallet::DUMMY_NETWORK; -use autonomi::Wallet; +use autonomi::{get_evm_network_from_env, Wallet}; use color_eyre::eyre::eyre; use color_eyre::Result; use prettytable::{Cell, Row, Table}; @@ -81,7 +81,8 @@ pub fn export() -> Result<()> { } pub async fn balance() -> Result<()> { - let wallet = select_wallet()?; + let network = get_evm_network_from_env().unwrap_or_default(); + let wallet = crate::wallet::load_wallet(&network)?; let token_balance = wallet.balance_of_tokens().await?; let gas_balance = wallet.balance_of_gas_tokens().await?; diff --git a/ant-cli/src/wallet/encryption.rs b/ant-cli/src/wallet/encryption.rs index 88f53afa15..1ea081e088 100644 --- a/ant-cli/src/wallet/encryption.rs +++ b/ant-cli/src/wallet/encryption.rs @@ -6,7 +6,8 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use crate::wallet::error::Error; +use color_eyre::eyre::eyre; +use color_eyre::Result; use rand::Rng; use ring::aead::{BoundKey, Nonce, NonceSequence}; use ring::error::Unspecified; @@ -28,7 +29,7 @@ impl NonceSequence for NonceSeq { } } -pub fn encrypt_private_key(private_key: &str, password: &str) -> Result { +pub fn encrypt_private_key(private_key: &str, password: &str) -> Result { // Generate a random salt // Salt is used to ensure unique derived keys even for identical passwords let mut salt = [0u8; SALT_LENGTH]; @@ -55,7 +56,7 @@ pub fn encrypt_private_key(private_key: &str, password: &str) -> Result Result Result Result { +pub fn decrypt_private_key(encrypted_data: &str, password: &str) -> Result { let encrypted_data = hex::decode(encrypted_data) - .map_err(|_| Error::FailedToDecryptKey(String::from("Encrypted data is invalid")))?; + .map_err(|_| eyre!("Failed to decrypt key: Encrypted data is invalid"))?; let salt: [u8; SALT_LENGTH] = encrypted_data[..SALT_LENGTH] .try_into() - .map_err(|_| Error::FailedToDecryptKey(String::from("Could not find salt")))?; + .map_err(|_| eyre!("Failed to decrypt key: Could not find salt"))?; let nonce: [u8; NONCE_LENGTH] = encrypted_data[SALT_LENGTH..SALT_LENGTH + NONCE_LENGTH] .try_into() - .map_err(|_| Error::FailedToDecryptKey(String::from("Could not find nonce")))?; + .map_err(|_| eyre!("Failed to decrypt key: Could not find nonce"))?; let encrypted_private_key = &encrypted_data[SALT_LENGTH + NONCE_LENGTH..]; @@ -106,7 +107,7 @@ pub fn decrypt_private_key(encrypted_data: &str, password: &str) -> Result Result = OnceLock::new(); /// Creates the wallets folder if it is missing and returns the folder path. -pub(crate) fn get_client_wallet_dir_path() -> Result { - let mut home_dirs = dirs_next::data_dir().ok_or(Error::WalletsFolderNotFound)?; - home_dirs.push("autonomi"); - home_dirs.push("client"); +pub(crate) fn get_client_wallet_dir_path() -> Result { + let mut home_dirs = crate::access::data_dir::get_client_data_dir_path() + .wrap_err("Failed to get wallet directory")?; home_dirs.push("wallets"); - std::fs::create_dir_all(home_dirs.as_path()).map_err(|_| Error::FailedToCreateWalletsFolder)?; + std::fs::create_dir_all(home_dirs.as_path()) + .wrap_err("Failed to create wallets folder, make sure you have the correct permissions")?; Ok(home_dirs) } @@ -41,9 +41,9 @@ pub(crate) fn get_client_wallet_dir_path() -> Result { pub(crate) fn store_private_key( private_key: &str, encryption_password: Option, -) -> Result { +) -> Result { let wallet = Wallet::new_from_private_key(DUMMY_NETWORK, private_key) - .map_err(|_| Error::InvalidPrivateKey)?; + .map_err(|_| eyre!("Private key is invalid"))?; // Wallet address let wallet_address = wallet.address().to_string(); @@ -56,15 +56,13 @@ pub(crate) fn store_private_key( let file_name = format!("{wallet_address}{ENCRYPTED_PRIVATE_KEY_EXT}"); let file_path = wallets_folder.join(file_name); - std::fs::write(file_path.clone(), encrypted_key) - .map_err(|err| Error::FailedToStorePrivateKey(err.to_string()))?; + std::fs::write(file_path.clone(), encrypted_key).wrap_err("Failed to store private key")?; Ok(file_path.into_os_string()) } else { let file_path = wallets_folder.join(wallet_address); - std::fs::write(file_path.clone(), private_key) - .map_err(|err| Error::FailedToStorePrivateKey(err.to_string()))?; + std::fs::write(file_path.clone(), private_key).wrap_err("Failed to store private key")?; Ok(file_path.into_os_string()) } @@ -73,7 +71,7 @@ pub(crate) fn store_private_key( /// Loads the private key (hex-encoded) from disk. /// /// If the private key file is encrypted, the function will prompt for the decryption password in the CLI. -pub(crate) fn load_private_key(wallet_address: &str) -> Result { +pub(crate) fn load_private_key(wallet_address: &str) -> Result { let wallets_folder = get_client_wallet_dir_path()?; let mut file_name = wallet_address.to_string(); @@ -93,46 +91,42 @@ pub(crate) fn load_private_key(wallet_address: &str) -> Result { let file_path = wallets_folder.join(file_name); - let mut file = std::fs::File::open(&file_path).map_err(|_| Error::PrivateKeyFileNotFound)?; + let mut file = + std::fs::File::open(&file_path).map_err(|e| eyre!("Private key file not found: {e}"))?; let mut buffer = String::new(); file.read_to_string(&mut buffer) - .map_err(|_| Error::InvalidPrivateKeyFile)?; + .map_err(|_| eyre!("Invalid private key file"))?; // If the file is encrypted, prompt for the password and decrypt the key. if is_encrypted { let password = get_password_input("Enter password to decrypt wallet:"); decrypt_private_key(&buffer, &password) + .map_err(|e| eyre!("Failed to decrypt private key: {e}")) } else { Ok(buffer) } } -pub(crate) fn load_wallet_from_address(wallet_address: &str) -> Result { - let network = get_evm_network_from_env().expect("Could not load EVM network from environment"); +pub(crate) fn load_wallet_from_address(wallet_address: &str, network: &Network) -> Result { let private_key = load_private_key(wallet_address)?; - let wallet = - Wallet::new_from_private_key(network, &private_key).expect("Could not initialize wallet"); + let wallet = Wallet::new_from_private_key(network.clone(), &private_key) + .map_err(|e| eyre!("Could not initialize wallet: {e}"))?; Ok(wallet) } -pub(crate) fn select_wallet() -> Result { - // try if there is a wallet set in the ENV first - if let Ok(env_wallet) = load_evm_wallet_from_env() { - return Ok(env_wallet); - } - - let wallet_address = select_wallet_address()?; - load_wallet_from_address(&wallet_address) +pub(crate) fn select_wallet_from_disk(network: &Network) -> Result { + let wallet_address = select_local_wallet_address()?; + load_wallet_from_address(&wallet_address, network) } -pub(crate) fn select_wallet_private_key() -> Result { - let wallet_address = select_wallet_address()?; +pub(crate) fn select_wallet_private_key() -> Result { + let wallet_address = select_local_wallet_address()?; load_private_key(&wallet_address) } -pub(crate) fn select_wallet_address() -> Result { +pub(crate) fn select_local_wallet_address() -> Result { // Try if a wallet address was already selected this session if let Some(wallet_address) = SELECTED_WALLET_ADDRESS.get() { return Ok(wallet_address.clone()); @@ -142,7 +136,7 @@ pub(crate) fn select_wallet_address() -> Result { let wallet_files = get_wallet_files(&wallets_folder)?; let wallet_address = match wallet_files.len() { - 0 => Err(Error::NoWalletsFound), + 0 => bail!("No local wallets found."), 1 => Ok(filter_wallet_file_extension(&wallet_files[0])), _ => get_wallet_selection(wallet_files), }?; @@ -152,15 +146,15 @@ pub(crate) fn select_wallet_address() -> Result { .to_string()) } -fn get_wallet_selection(wallet_files: Vec) -> Result { +fn get_wallet_selection(wallet_files: Vec) -> Result { list_wallets(&wallet_files); let selected_index = get_wallet_selection_input("Select by index:") .parse::() - .map_err(|_| Error::InvalidSelection)?; + .map_err(|_| eyre!("Invalid wallet selection input"))?; if selected_index < 1 || selected_index > wallet_files.len() { - return Err(Error::InvalidSelection); + bail!("Invalid wallet selection input"); } Ok(filter_wallet_file_extension( @@ -192,9 +186,9 @@ fn list_wallets(wallet_files: &[String]) { table.printstd(); } -fn get_wallet_files(wallets_folder: &PathBuf) -> Result, Error> { +fn get_wallet_files(wallets_folder: &PathBuf) -> Result> { let wallet_files = std::fs::read_dir(wallets_folder) - .map_err(|_| Error::WalletsFolderNotFound)? + .map_err(|e| eyre!("Failed to read wallets folder: {e}"))? .filter_map(Result::ok) .filter_map(|dir_entry| dir_entry.file_name().into_string().ok()) .filter(|file_name| { diff --git a/ant-cli/src/wallet/mod.rs b/ant-cli/src/wallet/mod.rs index ae95594a1b..b24ecf9d97 100644 --- a/ant-cli/src/wallet/mod.rs +++ b/ant-cli/src/wallet/mod.rs @@ -7,24 +7,23 @@ // permissions and limitations relating to use of the SAFE Network Software. use crate::keys::{get_secret_key_from_env, load_evm_wallet_from_env}; -use crate::wallet::fs::{select_wallet, select_wallet_private_key}; +use crate::wallet::fs::{select_wallet_from_disk, select_wallet_private_key}; use autonomi::{Network, Wallet}; pub(crate) mod encryption; -pub(crate) mod error; pub(crate) mod fs; pub(crate) mod input; pub const DUMMY_NETWORK: Network = Network::ArbitrumSepolia; /// Load wallet from ENV or disk -pub(crate) fn load_wallet() -> color_eyre::Result { +pub(crate) fn load_wallet(evm_network: &Network) -> color_eyre::Result { // First try wallet from ENV - if let Ok(wallet) = load_evm_wallet_from_env() { + if let Ok(wallet) = load_evm_wallet_from_env(evm_network) { return Ok(wallet); } - let wallet = select_wallet()?; + let wallet = select_wallet_from_disk(evm_network)?; Ok(wallet) } diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 697e405bbb..45f16a3f47 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -63,7 +63,8 @@ pub use ant_protocol::CLOSE_GROUP_SIZE; pub struct Client { pub(crate) network: Network, pub(crate) client_event_sender: Arc>>, - pub(crate) evm_network: EvmNetwork, + /// The EVM network to use for the client. + pub evm_network: EvmNetwork, } /// Configuration for [`Client::init_with_config`]. @@ -92,7 +93,7 @@ pub enum ConnectError { TimedOutWithIncompatibleProtocol(HashSet, String), /// An error occurred while bootstrapping the client. - #[error("Failed to bootstrap the client")] + #[error("Failed to bootstrap the client: {0}")] Bootstrap(#[from] ant_bootstrap::Error), } @@ -254,10 +255,6 @@ impl Client { client_event_receiver } - - pub fn set_evm_network(&mut self, evm_network: EvmNetwork) { - self.evm_network = evm_network; - } } fn build_client_and_run_swarm(local: bool) -> (Network, mpsc::Receiver) { diff --git a/test-utils/src/evm.rs b/test-utils/src/evm.rs index 05eb710bde..989da8b1a4 100644 --- a/test-utils/src/evm.rs +++ b/test-utils/src/evm.rs @@ -10,12 +10,11 @@ use color_eyre::{ eyre::{bail, Context}, Result, }; -use evmlib::{utils::get_evm_network_from_env, wallet::Wallet, Network}; +use evmlib::{utils::local_evm_network_from_csv, wallet::Wallet, Network}; use std::env; pub fn get_funded_wallet() -> evmlib::wallet::Wallet { - let network = - get_evm_network_from_env().expect("Failed to get EVM network from environment variables"); + let network = local_evm_network_from_csv().expect("Failed to get local EVM network from CSV"); if matches!(network, Network::ArbitrumOne) { panic!("You're trying to use ArbitrumOne network. Use a custom network for testing."); } @@ -29,8 +28,8 @@ pub fn get_funded_wallet() -> evmlib::wallet::Wallet { } pub fn get_new_wallet() -> Result { - let network = get_evm_network_from_env() - .wrap_err("Failed to get EVM network from environment variables")?; + let network = + local_evm_network_from_csv().wrap_err("Failed to get local EVM network from CSV")?; if matches!(network, Network::ArbitrumOne) { bail!("You're trying to use ArbitrumOne network. Use a custom network for testing."); } From 854582a434dc12c8e64bd06a5eff04d16b5d83e4 Mon Sep 17 00:00:00 2001 From: grumbach Date: Tue, 7 Jan 2025 02:08:43 +0900 Subject: [PATCH 07/26] feat: local mode in config --- autonomi/src/client/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 45f16a3f47..2f11877623 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -160,6 +160,7 @@ impl Client { let peers_args = PeersArgs { disable_mainnet_contacts: config.local, addrs: config.peers.unwrap_or_default(), + local: config.local, ..Default::default() }; From 010b6db1b47a784521b1a5df09c6eb5b84dc03cb Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Tue, 7 Jan 2025 10:55:30 +0100 Subject: [PATCH 08/26] fix(node): evm network initialization logic --- ant-node/src/bin/antnode/main.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ant-node/src/bin/antnode/main.rs b/ant-node/src/bin/antnode/main.rs index fab6abcfb6..2ee4cc6d34 100644 --- a/ant-node/src/bin/antnode/main.rs +++ b/ant-node/src/bin/antnode/main.rs @@ -262,16 +262,17 @@ fn main() -> Result<()> { return Ok(()); } - let evm_network: EvmNetwork = if opt.peers.local { - println!("Running node in local mode"); - local_evm_network_from_csv()? - } else { - opt.evm_network - .as_ref() - .cloned() - .map(|v| Ok(v.into())) - .unwrap_or_else(get_evm_network_from_env)? - }; + let evm_network: EvmNetwork = match opt.evm_network.as_ref() { + Some(evm_network) => Ok(evm_network.clone().into()), + None => match get_evm_network_from_env() { + Ok(evm_network) => Ok(evm_network), + Err(_) if opt.peers.local => Ok(local_evm_network_from_csv()?), + Err(_) => Err(eyre!( + "EVM network not specified. Please specify a network using the subcommand or by setting the `EVM_NETWORK` environment variable." + )), + }, + }?; + println!("EVM network: {evm_network:?}"); let node_socket_addr = SocketAddr::new(opt.ip, opt.port); From f3cf215ae5e4e51bf0712ffb9341d9ca9199f03e Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 00:29:23 +0900 Subject: [PATCH 09/26] chore: remove expects --- ant-cli/src/commands/wallet.rs | 6 +++--- ant-cli/src/wallet/encryption.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ant-cli/src/commands/wallet.rs b/ant-cli/src/commands/wallet.rs index 5f123dcb68..4bfe385b26 100644 --- a/ant-cli/src/commands/wallet.rs +++ b/ant-cli/src/commands/wallet.rs @@ -22,7 +22,7 @@ pub fn create(no_password: bool, password: Option) -> Result<()> { let wallet_private_key = Wallet::random_private_key(); let wallet_address = Wallet::new_from_private_key(DUMMY_NETWORK, &wallet_private_key) - .expect("Infallible") + .map_err(|e| eyre!("Unexpected error: Failed to create wallet from private key: {e}"))? .address() .to_string(); @@ -48,7 +48,7 @@ pub fn import( let maybe_encryption_password = maybe_request_password(no_password, password)?; let wallet_address = Wallet::new_from_private_key(DUMMY_NETWORK, &wallet_private_key) - .expect("Infallible") + .map_err(|e| eyre!("Unexpected error: Failed to create wallet from private key: {e}"))? .address() .to_string(); @@ -70,7 +70,7 @@ pub fn export() -> Result<()> { let wallet_private_key = select_wallet_private_key()?; let wallet_address = Wallet::new_from_private_key(DUMMY_NETWORK, &wallet_private_key) - .expect("Infallible") + .map_err(|e| eyre!("Failed to create wallet from private key loaded from disk: {e}"))? .address() .to_string(); diff --git a/ant-cli/src/wallet/encryption.rs b/ant-cli/src/wallet/encryption.rs index 1ea081e088..bbad0cc2f7 100644 --- a/ant-cli/src/wallet/encryption.rs +++ b/ant-cli/src/wallet/encryption.rs @@ -123,7 +123,8 @@ pub fn decrypt_private_key(encrypted_data: &str, password: &str) -> Result Date: Tue, 7 Jan 2025 16:17:25 +0100 Subject: [PATCH 10/26] chore: set default evm network to Arbitrum Sepolia --- evmlib/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmlib/src/lib.rs b/evmlib/src/lib.rs index e2715c0ed6..480ac8270b 100644 --- a/evmlib/src/lib.rs +++ b/evmlib/src/lib.rs @@ -78,8 +78,8 @@ impl CustomNetwork { #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub enum Network { - #[default] ArbitrumOne, + #[default] ArbitrumSepolia, Custom(CustomNetwork), } From 904b20139f742977e059e2caa45e62e930475553 Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Tue, 7 Jan 2025 16:18:30 +0100 Subject: [PATCH 11/26] Merge pull request maidsafe#2609 --- autonomi/src/client/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 2f11877623..39940c41e2 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -79,6 +79,9 @@ pub struct ClientConfig { /// /// If not provided, the client will use the default bootstrap peers. pub peers: Option>, + + /// EVM network to use for quotations and payments. + pub evm_network: EvmNetwork, } /// Error returned by [`Client::init`]. @@ -136,6 +139,7 @@ impl Client { Self::init_with_config(ClientConfig { local, peers: Some(peers), + evm_network: Default::default(), }) .await } From 339b13f2de9c75a83b0492f3d2c3c8fe972cf4f1 Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Tue, 7 Jan 2025 17:57:16 +0100 Subject: [PATCH 12/26] refactor: get evm network from single source --- ant-cli/src/actions/connect.rs | 24 ++++++++++++++++++------ ant-cli/src/commands.rs | 2 +- ant-cli/src/commands/wallet.rs | 7 ++++--- ant-cli/src/evm_network.rs | 24 ++++++++++++++++++++++++ ant-cli/src/main.rs | 1 + autonomi/src/client/mod.rs | 2 +- autonomi/src/lib.rs | 1 + 7 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 ant-cli/src/evm_network.rs diff --git a/ant-cli/src/actions/connect.rs b/ant-cli/src/actions/connect.rs index 091c87e1c8..5ae12694ad 100644 --- a/ant-cli/src/actions/connect.rs +++ b/ant-cli/src/actions/connect.rs @@ -6,14 +6,14 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use autonomi::Client; +use crate::evm_network::get_evm_network; +use crate::network::NetworkPeers; +use autonomi::{Client, ClientConfig}; use color_eyre::eyre::bail; use color_eyre::eyre::Result; use indicatif::ProgressBar; use std::time::Duration; -use crate::network::NetworkPeers; - pub async fn connect_to_network(peers: NetworkPeers) -> Result { let progress_bar = ProgressBar::new_spinner(); progress_bar.enable_steady_tick(Duration::from_millis(120)); @@ -21,14 +21,26 @@ pub async fn connect_to_network(peers: NetworkPeers) -> Result { let new_style = progress_bar.style().tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈🔗"); progress_bar.set_style(new_style); - let res = if peers.is_local() { + let local = peers.is_local(); + + let peers_opt = if local { progress_bar.set_message("Connecting to a local Autonomi Network..."); - Client::init_local().await + None } else { progress_bar.set_message("Connecting to The Autonomi Network..."); - Client::init_with_peers(peers.peers().to_vec()).await + Some(peers.peers().to_vec()) }; + let evm_network = get_evm_network(local)?; + + let config = ClientConfig { + local, + peers: peers_opt, + evm_network, + }; + + let res = Client::init_with_config(config).await; + match res { Ok(client) => { info!("Connected to the Network"); diff --git a/ant-cli/src/commands.rs b/ant-cli/src/commands.rs index 1bedd25f31..515a1470d8 100644 --- a/ant-cli/src/commands.rs +++ b/ant-cli/src/commands.rs @@ -228,7 +228,7 @@ pub async fn handle_subcommand(opt: Opt) -> Result<()> { password, } => wallet::import(private_key, no_password, password), WalletCmd::Export => wallet::export(), - WalletCmd::Balance => wallet::balance().await, + WalletCmd::Balance => wallet::balance(peers.await?.is_local()).await, }, None => { // If no subcommand is given, default to clap's error behaviour. diff --git a/ant-cli/src/commands/wallet.rs b/ant-cli/src/commands/wallet.rs index 4bfe385b26..c11bc41802 100644 --- a/ant-cli/src/commands/wallet.rs +++ b/ant-cli/src/commands/wallet.rs @@ -6,10 +6,11 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. +use crate::evm_network::get_evm_network; use crate::wallet::fs::{select_wallet_private_key, store_private_key}; use crate::wallet::input::request_password; use crate::wallet::DUMMY_NETWORK; -use autonomi::{get_evm_network_from_env, Wallet}; +use autonomi::Wallet; use color_eyre::eyre::eyre; use color_eyre::Result; use prettytable::{Cell, Row, Table}; @@ -80,8 +81,8 @@ pub fn export() -> Result<()> { Ok(()) } -pub async fn balance() -> Result<()> { - let network = get_evm_network_from_env().unwrap_or_default(); +pub async fn balance(local: bool) -> Result<()> { + let network = get_evm_network(local)?; let wallet = crate::wallet::load_wallet(&network)?; let token_balance = wallet.balance_of_tokens().await?; diff --git a/ant-cli/src/evm_network.rs b/ant-cli/src/evm_network.rs new file mode 100644 index 0000000000..48998f1c0f --- /dev/null +++ b/ant-cli/src/evm_network.rs @@ -0,0 +1,24 @@ +use autonomi::{get_evm_network_from_env, local_evm_network_from_csv, Network}; +use color_eyre::eyre::Result; + +use std::sync::OnceLock; + +static EVM_NETWORK: OnceLock = OnceLock::new(); + +pub(crate) fn get_evm_network(local: bool) -> Result { + if let Some(network) = EVM_NETWORK.get() { + return Ok(network.clone()); + } + + let res = match get_evm_network_from_env() { + Ok(evm_network) => Ok(evm_network), + Err(_) if local => Ok(local_evm_network_from_csv()?), + Err(_) => Ok(Default::default()), + }; + + if let Ok(network) = res.as_ref() { + let _ = EVM_NETWORK.set(network.clone()); + } + + res +} diff --git a/ant-cli/src/main.rs b/ant-cli/src/main.rs index e0fe5cf644..b7f6bc8fcb 100644 --- a/ant-cli/src/main.rs +++ b/ant-cli/src/main.rs @@ -12,6 +12,7 @@ extern crate tracing; mod access; mod actions; mod commands; +mod evm_network; mod opt; mod utils; mod wallet; diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 39940c41e2..5073a2bd76 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -192,7 +192,7 @@ impl Client { Ok(Self { network, client_event_sender: Arc::new(None), - evm_network: Default::default(), + evm_network: config.evm_network, }) } diff --git a/autonomi/src/lib.rs b/autonomi/src/lib.rs index 99bb92e51d..bfb1d705b2 100644 --- a/autonomi/src/lib.rs +++ b/autonomi/src/lib.rs @@ -66,6 +66,7 @@ pub mod client; pub mod self_encryption; pub use ant_evm::get_evm_network_from_env; +pub use ant_evm::local_evm_network_from_csv; pub use ant_evm::Amount; pub use ant_evm::EvmNetwork as Network; pub use ant_evm::EvmWallet as Wallet; From c0d6bfdb528cd2964f0f339c235e741535d713f6 Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 02:01:46 +0900 Subject: [PATCH 13/26] feat: remove local from antctl too --- ant-node-manager/Cargo.toml | 1 - .../src/bin/cli/subcommands/evm_network.rs | 12 +++--------- evmlib/src/utils.rs | 13 ------------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/ant-node-manager/Cargo.toml b/ant-node-manager/Cargo.toml index 1cb7610d70..3859f2e054 100644 --- a/ant-node-manager/Cargo.toml +++ b/ant-node-manager/Cargo.toml @@ -20,7 +20,6 @@ path = "src/bin/daemon/main.rs" [features] chaos = [] default = ["quic"] -local = [] nightly = [] open-metrics = [] otlp = [] diff --git a/ant-node-manager/src/bin/cli/subcommands/evm_network.rs b/ant-node-manager/src/bin/cli/subcommands/evm_network.rs index 2d795846cf..94a144f0b3 100644 --- a/ant-node-manager/src/bin/cli/subcommands/evm_network.rs +++ b/ant-node-manager/src/bin/cli/subcommands/evm_network.rs @@ -6,9 +6,9 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use ant_evm::{utils::get_evm_network_from_env, EvmNetwork}; +use ant_evm::{utils::local_evm_network_from_csv, EvmNetwork}; use clap::Subcommand; -use color_eyre::{eyre::Result, Section}; +use color_eyre::Result; #[derive(Subcommand, Clone, Debug)] #[allow(clippy::enum_variant_names)] @@ -46,13 +46,7 @@ impl TryInto for EvmNetworkCommand { Self::EvmArbitrumOne => Ok(EvmNetwork::ArbitrumOne), Self::EvmArbitrumSepolia => Ok(EvmNetwork::ArbitrumSepolia), Self::EvmLocal => { - if !cfg!(feature = "local") { - return Err(color_eyre::eyre::eyre!( - "The 'local' feature flag is not enabled." - )) - .suggestion("Enable the 'local' feature flag to use the local EVM testnet."); - } - let network = get_evm_network_from_env()?; + let network = local_evm_network_from_csv()?; Ok(network) } Self::EvmCustom { diff --git a/evmlib/src/utils.rs b/evmlib/src/utils.rs index 422125fb5a..b63a0292e4 100644 --- a/evmlib/src/utils.rs +++ b/evmlib/src/utils.rs @@ -57,19 +57,6 @@ pub fn get_evm_testnet_csv_path() -> Result { Ok(file) } -/// Create a custom `Network` from the given values -pub fn get_evm_network( - rpc_url: &str, - payment_token_address: &str, - data_payments_address: &str, -) -> Network { - Network::Custom(CustomNetwork::new( - rpc_url, - payment_token_address, - data_payments_address, - )) -} - /// Get the `Network` from environment variables. /// /// Returns an error if we cannot obtain the network from any means. From ede5f34148ca3cba5c5caa705577552b95c31797 Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 02:14:41 +0900 Subject: [PATCH 14/26] chore: small cleanups --- README.md | 6 +++--- ant-cli/src/actions/mod.rs | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e110c4811d..a1e582d5b3 100644 --- a/README.md +++ b/README.md @@ -110,15 +110,15 @@ This creates a CSV file with the EVM network params in your data directory. `--rewards-address` _is the address where you will receive your node earnings on._ ```bash -cargo run --bin antctl --features local -- local run --build --clean --rewards-address +cargo run --bin antctl -- local run --build --clean --rewards-address ``` -The EVM Network parameters are loaded from the CSV file in your data directory automatically when the `local` feature flag is enabled (`--features=local`). +The EVM Network parameters are loaded from the CSV file in your data directory automatically when the `local` option is passed to the `antctl` command. ##### 4. Verify node status ```bash -cargo run --bin antctl --features local -- status +cargo run --bin antctl -- status ``` The Antctl `run` command starts the node processes. The `status` command should show twenty-five diff --git a/ant-cli/src/actions/mod.rs b/ant-cli/src/actions/mod.rs index 8b4662c3d9..94b4b3d6ee 100644 --- a/ant-cli/src/actions/mod.rs +++ b/ant-cli/src/actions/mod.rs @@ -12,5 +12,4 @@ mod progress_bar; pub use connect::connect_to_network; pub use download::download; - pub use progress_bar::get_progress_bar; From 178a06459121020feb116afe29cc9c3e527a7980 Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 02:36:16 +0900 Subject: [PATCH 15/26] fix: enable feature gated logging option --- ant-cli/src/evm_network.rs | 6 ++++-- ant-node/Cargo.toml | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ant-cli/src/evm_network.rs b/ant-cli/src/evm_network.rs index 48998f1c0f..34e09ecc0f 100644 --- a/ant-cli/src/evm_network.rs +++ b/ant-cli/src/evm_network.rs @@ -1,5 +1,5 @@ use autonomi::{get_evm_network_from_env, local_evm_network_from_csv, Network}; -use color_eyre::eyre::Result; +use color_eyre::eyre::{Context, Result}; use std::sync::OnceLock; @@ -12,7 +12,9 @@ pub(crate) fn get_evm_network(local: bool) -> Result { let res = match get_evm_network_from_env() { Ok(evm_network) => Ok(evm_network), - Err(_) if local => Ok(local_evm_network_from_csv()?), + Err(_) if local => { + Ok(local_evm_network_from_csv().wrap_err("Failed to get local EVM network")?) + } Err(_) => Ok(Default::default()), }; diff --git a/ant-node/Cargo.toml b/ant-node/Cargo.toml index d2c73991dd..5ca35b65ca 100644 --- a/ant-node/Cargo.toml +++ b/ant-node/Cargo.toml @@ -14,10 +14,9 @@ name = "antnode" path = "src/bin/antnode/main.rs" [features] -default = ["metrics", "upnp", "open-metrics"] +default = ["upnp", "open-metrics"] extension-module = ["pyo3/extension-module"] loud = ["ant-networking/loud"] # loud mode: print important messages to console -metrics = [] nightly = [] open-metrics = ["ant-networking/open-metrics", "prometheus-client"] otlp = ["ant-logging/otlp"] @@ -27,7 +26,7 @@ upnp = ["ant-networking/upnp"] 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-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" } From 51f00b66d7936f554578ee7dd4f183678ec3416c Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 02:52:38 +0900 Subject: [PATCH 16/26] fix: adapt e2e ci tests --- .github/workflows/benchmark-prs.yml | 2 +- .../workflows/generate-benchmark-charts.yml | 2 +- .github/workflows/memcheck.yml | 6 +- .github/workflows/merge.yml | 70 +++++++++---------- 4 files changed, 38 insertions(+), 42 deletions(-) diff --git a/.github/workflows/benchmark-prs.yml b/.github/workflows/benchmark-prs.yml index d6cb7e1807..ecd90a480c 100644 --- a/.github/workflows/benchmark-prs.yml +++ b/.github/workflows/benchmark-prs.yml @@ -71,7 +71,7 @@ jobs: - name: Start a client instance to compare memory usage shell: bash - run: ./target/release/ant --log-output-dest=data-dir file upload "./the-test-data.zip" + run: ./target/release/ant --log-output-dest=data-dir --local file upload "./the-test-data.zip" env: ANT_LOG: "all" timeout-minutes: 5 diff --git a/.github/workflows/generate-benchmark-charts.yml b/.github/workflows/generate-benchmark-charts.yml index 4566a37610..ac23f9a044 100644 --- a/.github/workflows/generate-benchmark-charts.yml +++ b/.github/workflows/generate-benchmark-charts.yml @@ -100,7 +100,7 @@ jobs: - name: Start a client instance to compare memory usage shell: bash - run: cargo run --bin ant --release -- --log-output-dest data-dir file upload the-test-data.zip + run: cargo run --bin ant --release -- --log-output-dest data-dir --local file upload the-test-data.zip env: ANT_LOG: "all" diff --git a/.github/workflows/memcheck.yml b/.github/workflows/memcheck.yml index b3f3ed3f50..82135f5322 100644 --- a/.github/workflows/memcheck.yml +++ b/.github/workflows/memcheck.yml @@ -70,7 +70,7 @@ jobs: shell: bash - name: File upload - run: ./target/release/ant --log-output-dest=data-dir file upload --public "./the-test-data.zip" > ./upload_output 2>&1 + run: ./target/release/ant --log-output-dest=data-dir --local file upload --public "./the-test-data.zip" > ./upload_output 2>&1 env: ANT_LOG: "v" timeout-minutes: 15 @@ -99,7 +99,7 @@ jobs: mkdir $ANT_DATA_PATH/client ls -l $ANT_DATA_PATH cp ./the-test-data.zip ./the-test-data_1.zip - ./target/release/ant --log-output-dest=data-dir file upload "./the-test-data_1.zip" > ./second_upload 2>&1 + ./target/release/ant --log-output-dest=data-dir --local file upload "./the-test-data_1.zip" > ./second_upload 2>&1 env: ANT_LOG: "all" timeout-minutes: 25 @@ -146,7 +146,7 @@ jobs: if: always() - name: File Download - run: ./target/release/ant --log-output-dest=data-dir file download ${{ env.UPLOAD_ADDRESS }} ./downloaded_resources + run: ./target/release/ant --log-output-dest=data-dir --local file download ${{ env.UPLOAD_ADDRESS }} ./downloaded_resources env: ANT_LOG: "v" timeout-minutes: 2 diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index a6d9eae0a3..c41a65a72c 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -86,10 +86,6 @@ jobs: # resulting in an error when building docs. run: RUSTDOCFLAGS="--deny=warnings" cargo doc --no-deps --workspace --exclude=autonomi-cli - - name: Check local is not a default feature - shell: bash - run: if [[ ! $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].features.default[]? | select(. == "local")') ]]; then echo "local is not a default feature in any package."; else echo "local is a default feature in at least one package." && exit 1; fi - - name: Clean out the target directory run: cargo clean @@ -249,13 +245,13 @@ jobs: shell: pwsh - name: Get file cost - run: ./target/release/ant --log-output-dest=data-dir file cost "./resources" + run: ./target/release/ant --log-output-dest=data-dir --local file cost "./resources" env: ANT_LOG: "v" timeout-minutes: 15 - name: File upload - run: ./target/release/ant --log-output-dest=data-dir file upload "./resources" > ./upload_output 2>&1 + run: ./target/release/ant --log-output-dest=data-dir --local file upload "./resources" > ./upload_output 2>&1 env: ANT_LOG: "v" timeout-minutes: 15 @@ -275,16 +271,16 @@ jobs: shell: pwsh - name: File Download - run: ./target/release/ant --log-output-dest=data-dir file download ${{ env.UPLOAD_ADDRESS }} ./downloaded_resources + run: ./target/release/ant --log-output-dest=data-dir --local file download ${{ env.UPLOAD_ADDRESS }} ./downloaded_resources env: ANT_LOG: "v" timeout-minutes: 5 - name: Generate register signing key - run: ./target/release/ant --log-output-dest=data-dir register generate-key + run: ./target/release/ant --log-output-dest=data-dir --local register generate-key - name: Create register (writeable by owner) - run: ./target/release/ant --log-output-dest=data-dir register create baobao 123 > ./register_create_output 2>&1 + run: ./target/release/ant --log-output-dest=data-dir --local register create baobao 123 > ./register_create_output 2>&1 env: ANT_LOG: "v" timeout-minutes: 10 @@ -304,25 +300,25 @@ jobs: shell: pwsh - name: Get register - run: ./target/release/ant --log-output-dest=data-dir register get ${{ env.REGISTER_ADDRESS }} + run: ./target/release/ant --log-output-dest=data-dir --local register get ${{ env.REGISTER_ADDRESS }} env: ANT_LOG: "v" timeout-minutes: 5 - name: Edit register - run: ./target/release/ant --log-output-dest=data-dir register edit ${{ env.REGISTER_ADDRESS }} 456 + run: ./target/release/ant --log-output-dest=data-dir --local register edit ${{ env.REGISTER_ADDRESS }} 456 env: ANT_LOG: "v" timeout-minutes: 10 - name: Get register (after edit) - run: ./target/release/ant --log-output-dest=data-dir register get ${{ env.REGISTER_ADDRESS }} + run: ./target/release/ant --log-output-dest=data-dir --local register get ${{ env.REGISTER_ADDRESS }} env: ANT_LOG: "v" timeout-minutes: 5 - name: Create Public Register (writeable by anyone) - run: ./target/release/ant --log-output-dest=data-dir register create bao 111 --public > ./register_public_create_output 2>&1 + run: ./target/release/ant --log-output-dest=data-dir --local register create bao 111 --public > ./register_public_create_output 2>&1 env: ANT_LOG: "v" timeout-minutes: 5 @@ -342,13 +338,13 @@ jobs: shell: pwsh - name: Get Public Register (current key is the owner) - run: ./target/release/ant --log-output-dest=data-dir register get ${{ env.PUBLIC_REGISTER_ADDRESS }} + run: ./target/release/ant --log-output-dest=data-dir --local register get ${{ env.PUBLIC_REGISTER_ADDRESS }} env: ANT_LOG: "v" timeout-minutes: 5 - name: Edit Public Register (current key is the owner) - run: ./target/release/ant --log-output-dest=data-dir register edit ${{ env.PUBLIC_REGISTER_ADDRESS }} 222 + run: ./target/release/ant --log-output-dest=data-dir --local register edit ${{ env.PUBLIC_REGISTER_ADDRESS }} 222 env: ANT_LOG: "v" timeout-minutes: 10 @@ -361,19 +357,19 @@ jobs: run: ./target/release/ant --log-output-dest data-dir register generate-key - name: Get Public Register (new signing key is not the owner) - run: ./target/release/ant --log-output-dest data-dir register get ${{ env.PUBLIC_REGISTER_ADDRESS }} + run: ./target/release/ant --log-output-dest data-dir --local register get ${{ env.PUBLIC_REGISTER_ADDRESS }} env: ANT_LOG: "v" timeout-minutes: 2 - name: Edit Public Register (new signing key is not the owner) - run: ./target/release/ant --log-output-dest data-dir register edit ${{ env.PUBLIC_REGISTER_ADDRESS }} 333 + run: ./target/release/ant --log-output-dest data-dir --local register edit ${{ env.PUBLIC_REGISTER_ADDRESS }} 333 env: ANT_LOG: "v" timeout-minutes: 10 - name: Get Public Register (new signing key is not the owner) - run: ./target/release/ant --log-output-dest data-dir register get ${{ env.PUBLIC_REGISTER_ADDRESS }} + run: ./target/release/ant --log-output-dest data-dir --local register get ${{ env.PUBLIC_REGISTER_ADDRESS }} env: ANT_LOG: "v" timeout-minutes: 2 @@ -385,25 +381,25 @@ jobs: timeout-minutes: 2 - name: file upload - run: ./target/release/ant --log-output-dest data-dir file upload random.txt + run: ./target/release/ant --log-output-dest data-dir --local file upload random.txt env: ANT_LOG: "v" timeout-minutes: 2 - name: create a local register - run: ./target/release/ant --log-output-dest data-dir register create sample_new_register 1234 + run: ./target/release/ant --log-output-dest data-dir --local register create sample_new_register 1234 env: ANT_LOG: "v" timeout-minutes: 2 - name: Estimate cost to create a vault - run: ./target/release/ant --log-output-dest data-dir vault cost + run: ./target/release/ant --log-output-dest data-dir --local vault cost env: ANT_LOG: "v" timeout-minutes: 2 - name: create a vault with existing user data as above - run: ./target/release/ant --log-output-dest data-dir vault create + run: ./target/release/ant --log-output-dest data-dir --local vault create env: ANT_LOG: "v" timeout-minutes: 2 @@ -414,9 +410,9 @@ jobs: set -e for i in {1..50}; do dd if=/dev/urandom of=random_file_$i.bin bs=1M count=1 status=none - ./target/release/ant --log-output-dest data-dir file upload random_file_$i.bin --public - ./target/release/ant --log-output-dest data-dir file upload random_file_$i.bin - ./target/release/ant --log-output-dest data-dir register create $i random_file_$i.bin + ./target/release/ant --log-output-dest data-dir --local file upload random_file_$i.bin --public + ./target/release/ant --log-output-dest data-dir --local file upload random_file_$i.bin + ./target/release/ant --log-output-dest data-dir --local register create $i random_file_$i.bin done env: ANT_LOG: "v" @@ -433,9 +429,9 @@ jobs: [System.IO.File]::WriteAllBytes($fileName, $byteArray) # Run autonomi commands - ./target/release/ant --log-output-dest data-dir file upload "random_file_$i.bin" --public - ./target/release/ant --log-output-dest data-dir file upload "random_file_$i.bin" - ./target/release/ant --log-output-dest data-dir register create $i "random_file_$i.bin" + ./target/release/ant --log-output-dest data-dir --local file upload "random_file_$i.bin" --public + ./target/release/ant --log-output-dest data-dir --local file upload "random_file_$i.bin" + ./target/release/ant --log-output-dest data-dir --local register create $i "random_file_$i.bin" } env: ANT_LOG: "v" @@ -463,11 +459,11 @@ jobs: NUM_OF_PUBLIC_FILES_IN_VAULT="" NUM_OF_PRIVATE_FILES_IN_VAULT="" - ./target/release/ant --log-output-dest data-dir file list 2>&1 > file_list.txt + ./target/release/ant --log-output-dest data-dir --local file list 2>&1 > file_list.txt NUM_OF_PUBLIC_FILES=`cat file_list.txt | grep "public" | grep -o '[0-9]\+'` NUM_OF_PRIVATE_FILES=`cat file_list.txt | grep "private" | grep -o '[0-9]\+'` - ./target/release/ant --log-output-dest data-dir vault load 2>&1 > vault_data.txt + ./target/release/ant --log-output-dest data-dir --local vault load 2>&1 > vault_data.txt NUM_OF_PUBLIC_FILES_IN_VAULT=`cat vault_data.txt | grep "public" | grep -o '[0-9]\+'` NUM_OF_PRIVATE_FILES_IN_VAULT=`cat vault_data.txt| grep "private" | grep -o '[0-9]\+'` @@ -489,8 +485,8 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - ./target/release/ant --log-output-dest data-dir file list > file_list.txt 2>&1 - ./target/release/ant --log-output-dest data-dir vault load > vault_data.txt 2>&1 + ./target/release/ant --log-output-dest data-dir --local file list > file_list.txt 2>&1 + ./target/release/ant --log-output-dest data-dir --local vault load > vault_data.txt 2>&1 env: ANT_LOG: "v" timeout-minutes: 15 @@ -556,11 +552,11 @@ jobs: python3 -c "with open('random_1GB.bin', 'wb') as f: f.write(bytearray([0xff] * 1000 * 1024 * 1024))" ./target/release/ant --log-output-dest=data-dir file list - time ./target/release/ant --log-output-dest=data-dir file upload random_1MB.bin - time ./target/release/ant --log-output-dest=data-dir file upload random_10MB.bin - time ./target/release/ant --log-output-dest=data-dir file upload random_100MB.bin - time ./target/release/ant --log-output-dest=data-dir file upload random_1GB.bin - ./target/release/ant --log-output-dest=data-dir vault sync + time ./target/release/ant --log-output-dest=data-dir --local file upload random_1MB.bin + time ./target/release/ant --log-output-dest=data-dir --local file upload random_10MB.bin + time ./target/release/ant --log-output-dest=data-dir --local file upload random_100MB.bin + time ./target/release/ant --log-output-dest=data-dir --local file upload random_1GB.bin + ./target/release/ant --log-output-dest=data-dir --local vault sync rm -rf random*.bin rm -rf ${{ matrix.ant_path }}/autonomi env: From 46de2683fff8392c03754f8e34b6af14232a6345 Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 03:20:16 +0900 Subject: [PATCH 17/26] feat: centralize evm network selection code --- ant-cli/src/actions/connect.rs | 3 +- ant-cli/src/commands/wallet.rs | 2 +- ant-cli/src/evm_network.rs | 26 --------------- ant-cli/src/main.rs | 1 - ant-evm/src/lib.rs | 2 +- .../src/bin/cli/subcommands/evm_network.rs | 4 +-- ant-node/src/bin/antnode/main.rs | 7 ++-- autonomi/src/lib.rs | 3 +- autonomi/tests/wallet.rs | 6 ++-- evmlib/src/utils.rs | 32 +++++++++++++++++-- test-utils/src/evm.rs | 12 +++---- 11 files changed, 46 insertions(+), 52 deletions(-) delete mode 100644 ant-cli/src/evm_network.rs diff --git a/ant-cli/src/actions/connect.rs b/ant-cli/src/actions/connect.rs index 5ae12694ad..118b2df60d 100644 --- a/ant-cli/src/actions/connect.rs +++ b/ant-cli/src/actions/connect.rs @@ -6,9 +6,8 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use crate::evm_network::get_evm_network; use crate::network::NetworkPeers; -use autonomi::{Client, ClientConfig}; +use autonomi::{get_evm_network, Client, ClientConfig}; use color_eyre::eyre::bail; use color_eyre::eyre::Result; use indicatif::ProgressBar; diff --git a/ant-cli/src/commands/wallet.rs b/ant-cli/src/commands/wallet.rs index c11bc41802..9e76128bbe 100644 --- a/ant-cli/src/commands/wallet.rs +++ b/ant-cli/src/commands/wallet.rs @@ -6,10 +6,10 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use crate::evm_network::get_evm_network; use crate::wallet::fs::{select_wallet_private_key, store_private_key}; use crate::wallet::input::request_password; use crate::wallet::DUMMY_NETWORK; +use autonomi::get_evm_network; use autonomi::Wallet; use color_eyre::eyre::eyre; use color_eyre::Result; diff --git a/ant-cli/src/evm_network.rs b/ant-cli/src/evm_network.rs deleted file mode 100644 index 34e09ecc0f..0000000000 --- a/ant-cli/src/evm_network.rs +++ /dev/null @@ -1,26 +0,0 @@ -use autonomi::{get_evm_network_from_env, local_evm_network_from_csv, Network}; -use color_eyre::eyre::{Context, Result}; - -use std::sync::OnceLock; - -static EVM_NETWORK: OnceLock = OnceLock::new(); - -pub(crate) fn get_evm_network(local: bool) -> Result { - if let Some(network) = EVM_NETWORK.get() { - return Ok(network.clone()); - } - - let res = match get_evm_network_from_env() { - Ok(evm_network) => Ok(evm_network), - Err(_) if local => { - Ok(local_evm_network_from_csv().wrap_err("Failed to get local EVM network")?) - } - Err(_) => Ok(Default::default()), - }; - - if let Ok(network) = res.as_ref() { - let _ = EVM_NETWORK.set(network.clone()); - } - - res -} diff --git a/ant-cli/src/main.rs b/ant-cli/src/main.rs index b7f6bc8fcb..e0fe5cf644 100644 --- a/ant-cli/src/main.rs +++ b/ant-cli/src/main.rs @@ -12,7 +12,6 @@ extern crate tracing; mod access; mod actions; mod commands; -mod evm_network; mod opt; mod utils; mod wallet; diff --git a/ant-evm/src/lib.rs b/ant-evm/src/lib.rs index 678db86c72..e8d5e92784 100644 --- a/ant-evm/src/lib.rs +++ b/ant-evm/src/lib.rs @@ -19,7 +19,7 @@ pub use evmlib::cryptography; #[cfg(feature = "external-signer")] pub use evmlib::external_signer; pub use evmlib::utils; -pub use evmlib::utils::{get_evm_network_from_env, local_evm_network_from_csv}; +pub use evmlib::utils::get_evm_network; pub use evmlib::utils::{DATA_PAYMENTS_ADDRESS, PAYMENT_TOKEN_ADDRESS, RPC_URL}; pub use evmlib::wallet::Error as EvmWalletError; pub use evmlib::wallet::Wallet as EvmWallet; diff --git a/ant-node-manager/src/bin/cli/subcommands/evm_network.rs b/ant-node-manager/src/bin/cli/subcommands/evm_network.rs index 10028ed468..59d6078ad3 100644 --- a/ant-node-manager/src/bin/cli/subcommands/evm_network.rs +++ b/ant-node-manager/src/bin/cli/subcommands/evm_network.rs @@ -6,7 +6,7 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use ant_evm::{utils::local_evm_network_from_csv, EvmNetwork}; +use ant_evm::{get_evm_network, EvmNetwork}; use clap::Subcommand; use color_eyre::Result; @@ -50,7 +50,7 @@ impl TryInto for EvmNetworkCommand { Self::EvmArbitrumSepolia => Ok(EvmNetwork::ArbitrumSepolia), Self::EvmArbitrumSepoliaTest => Ok(EvmNetwork::ArbitrumSepoliaTest), Self::EvmLocal => { - let network = local_evm_network_from_csv()?; + let network = get_evm_network(true)?; Ok(network) } Self::EvmCustom { diff --git a/ant-node/src/bin/antnode/main.rs b/ant-node/src/bin/antnode/main.rs index 2ee4cc6d34..665b47518c 100644 --- a/ant-node/src/bin/antnode/main.rs +++ b/ant-node/src/bin/antnode/main.rs @@ -14,7 +14,7 @@ mod subcommands; use crate::subcommands::EvmNetworkCommand; use ant_bootstrap::{BootstrapCacheConfig, BootstrapCacheStore, PeersArgs}; -use ant_evm::{get_evm_network_from_env, local_evm_network_from_csv, EvmNetwork, RewardsAddress}; +use ant_evm::{get_evm_network, EvmNetwork, RewardsAddress}; use ant_logging::metrics::init_metrics; use ant_logging::{Level, LogFormat, LogOutputDest, ReloadHandle}; use ant_node::{Marker, NodeBuilder, NodeEvent, NodeEventsReceiver}; @@ -264,9 +264,8 @@ fn main() -> Result<()> { let evm_network: EvmNetwork = match opt.evm_network.as_ref() { Some(evm_network) => Ok(evm_network.clone().into()), - None => match get_evm_network_from_env() { - Ok(evm_network) => Ok(evm_network), - Err(_) if opt.peers.local => Ok(local_evm_network_from_csv()?), + None => match get_evm_network(opt.peers.local) { + Ok(net) => Ok(net), Err(_) => Err(eyre!( "EVM network not specified. Please specify a network using the subcommand or by setting the `EVM_NETWORK` environment variable." )), diff --git a/autonomi/src/lib.rs b/autonomi/src/lib.rs index bfb1d705b2..fe741c8003 100644 --- a/autonomi/src/lib.rs +++ b/autonomi/src/lib.rs @@ -65,8 +65,7 @@ extern crate tracing; pub mod client; pub mod self_encryption; -pub use ant_evm::get_evm_network_from_env; -pub use ant_evm::local_evm_network_from_csv; +pub use ant_evm::utils::get_evm_network; pub use ant_evm::Amount; pub use ant_evm::EvmNetwork as Network; pub use ant_evm::EvmWallet as Wallet; diff --git a/autonomi/tests/wallet.rs b/autonomi/tests/wallet.rs index 33880ca5ab..6347edaae7 100644 --- a/autonomi/tests/wallet.rs +++ b/autonomi/tests/wallet.rs @@ -6,7 +6,7 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use ant_evm::get_evm_network_from_env; +use ant_evm::get_evm_network; use ant_evm::EvmWallet; use ant_evm::{Amount, RewardsAddress}; use ant_logging::LogBuilder; @@ -17,7 +17,7 @@ use test_utils::evm::get_funded_wallet; async fn from_private_key() { let private_key = "0xdb1049e76a813c94be0df47ec3e20533ca676b1b9fef2ddbce9daa117e4da4aa"; let network = - get_evm_network_from_env().expect("Could not get EVM network from environment variables"); + get_evm_network(true).expect("Could not get EVM network from environment variables"); let wallet = EvmWallet::new_from_private_key(network, private_key).unwrap(); assert_eq!( @@ -31,7 +31,7 @@ async fn send_tokens() { let _log_appender_guard = LogBuilder::init_single_threaded_tokio_test("wallet", false); let network = - get_evm_network_from_env().expect("Could not get EVM network from environment variables"); + get_evm_network(true).expect("Could not get EVM network from environment variables"); let wallet = get_funded_wallet(); let receiving_wallet = EvmWallet::new_with_random_wallet(network); diff --git a/evmlib/src/utils.rs b/evmlib/src/utils.rs index 1717b2d517..40c92ca648 100644 --- a/evmlib/src/utils.rs +++ b/evmlib/src/utils.rs @@ -47,6 +47,34 @@ pub fn dummy_hash() -> Hash { Hash::new(rand::rngs::OsRng.gen()) } +use std::sync::OnceLock; + +static EVM_NETWORK: OnceLock = OnceLock::new(); + +/// Initialize the EVM Network parameters from environment variables or local CSV file. +/// +/// It will first try to get the network from the environment variables. +/// If it fails and `local` is true, it will try to get the network from the local CSV file. +/// If both fail, it will return the default network. +pub fn get_evm_network(local: bool) -> Result { + if let Some(network) = EVM_NETWORK.get() { + return Ok(network.clone()); + } + + let res = match get_evm_network_from_env() { + Ok(evm_network) => Ok(evm_network), + Err(_) if local => Ok(local_evm_network_from_csv() + .map_err(|e| Error::FailedToGetEvmNetwork(e.to_string()))?), + Err(_) => Ok(Network::default()), + }; + + if let Ok(network) = res.as_ref() { + let _ = EVM_NETWORK.set(network.clone()); + } + + res +} + pub fn get_evm_testnet_csv_path() -> Result { let file = data_dir() .ok_or(Error::FailedToGetEvmNetwork( @@ -60,7 +88,7 @@ pub fn get_evm_testnet_csv_path() -> Result { /// Get the `Network` from environment variables. /// /// Returns an error if we cannot obtain the network from any means. -pub fn get_evm_network_from_env() -> Result { +fn get_evm_network_from_env() -> Result { let evm_vars = [ env::var(RPC_URL) .ok() @@ -126,7 +154,7 @@ pub fn get_evm_network_from_env() -> Result { } /// Get the `Network::Custom` from the local EVM testnet CSV file -pub fn local_evm_network_from_csv() -> Result { +fn local_evm_network_from_csv() -> Result { // load the csv let csv_path = get_evm_testnet_csv_path()?; diff --git a/test-utils/src/evm.rs b/test-utils/src/evm.rs index 989da8b1a4..e3db3dd2ba 100644 --- a/test-utils/src/evm.rs +++ b/test-utils/src/evm.rs @@ -6,15 +6,12 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use color_eyre::{ - eyre::{bail, Context}, - Result, -}; -use evmlib::{utils::local_evm_network_from_csv, wallet::Wallet, Network}; +use color_eyre::{eyre::bail, Result}; +use evmlib::{utils::get_evm_network, wallet::Wallet, Network}; use std::env; pub fn get_funded_wallet() -> evmlib::wallet::Wallet { - let network = local_evm_network_from_csv().expect("Failed to get local EVM network from CSV"); + let network = get_evm_network(true).expect("Failed to get local EVM network from CSV"); if matches!(network, Network::ArbitrumOne) { panic!("You're trying to use ArbitrumOne network. Use a custom network for testing."); } @@ -28,8 +25,7 @@ pub fn get_funded_wallet() -> evmlib::wallet::Wallet { } pub fn get_new_wallet() -> Result { - let network = - local_evm_network_from_csv().wrap_err("Failed to get local EVM network from CSV")?; + let network = get_evm_network(true).expect("Failed to get local EVM network from CSV"); if matches!(network, Network::ArbitrumOne) { bail!("You're trying to use ArbitrumOne network. Use a custom network for testing."); } From d77b844fd1d3d03e27d4db4570982fb0136a370a Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 23:09:04 +0900 Subject: [PATCH 18/26] fix: remove duplicate if local --- ant-networking/src/event/swarm.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ant-networking/src/event/swarm.rs b/ant-networking/src/event/swarm.rs index 434b94f7fe..34e7c6574f 100644 --- a/ant-networking/src/event/swarm.rs +++ b/ant-networking/src/event/swarm.rs @@ -292,16 +292,14 @@ impl SwarmDriver { if self.local { match *mdns_event { mdns::Event::Discovered(list) => { - if self.local { - for (peer_id, addr) in list { - // The multiaddr does not contain the peer ID, so add it. - let addr = addr.with(Protocol::P2p(peer_id)); + for (peer_id, addr) in list { + // The multiaddr does not contain the peer ID, so add it. + let addr = addr.with(Protocol::P2p(peer_id)); - info!(%addr, "mDNS node discovered and dialing"); + info!(%addr, "mDNS node discovered and dialing"); - if let Err(err) = self.dial(addr.clone()) { - warn!(%addr, "mDNS node dial error: {err:?}"); - } + if let Err(err) = self.dial(addr.clone()) { + warn!(%addr, "mDNS node dial error: {err:?}"); } } } From 540906c26b4528e9487f03030bea22fe41ee0111 Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 14:11:45 +0100 Subject: [PATCH 19/26] test: fix networking async test --- ant-networking/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ant-networking/src/lib.rs b/ant-networking/src/lib.rs index 413c7eb730..2d558fd9f6 100644 --- a/ant-networking/src/lib.rs +++ b/ant-networking/src/lib.rs @@ -1322,8 +1322,8 @@ pub(crate) fn send_network_swarm_cmd( mod tests { use super::*; - #[test] - fn test_network_sign_verify() -> eyre::Result<()> { + #[tokio::test] + async fn test_network_sign_verify() -> eyre::Result<()> { let (network, _, _) = NetworkBuilder::new(Keypair::generate_ed25519(), false).build_client()?; let msg = b"test message"; From f71cec80ed9a42a7ee4cf5e2faa341190a8d944c Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 14:34:51 +0100 Subject: [PATCH 20/26] refactor: base evm network on local setting --- autonomi/src/client/mod.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 62d19a9dac..72e0d27876 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -71,8 +71,6 @@ pub struct Client { #[derive(Debug, Clone, Default)] pub struct ClientConfig { /// Whether we're expected to connect to a local network. - /// - /// If `local` feature is enabled, [`ClientConfig::default()`] will set this to `true`. pub local: bool, /// List of peers to connect to. @@ -84,15 +82,15 @@ 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(), -// } -// } -// } +impl ClientConfig { + fn local(peers: Option>) -> Self { + Self { + local: true, + peers, + evm_network: EvmNetwork::new(true).unwrap_or_default(), + } + } +} /// Error returned by [`Client::init`]. #[derive(Debug, thiserror::Error)] @@ -122,11 +120,7 @@ impl Client { /// /// See [`Client::init_with_config`]. pub async fn init_local() -> Result { - Self::init_with_config(ClientConfig { - local: true, - ..Default::default() - }) - .await + Self::init_with_config(ClientConfig::local(None)).await } /// Initialize a client that bootstraps from a list of peers. From 189c5beaeb6273f6ee138c3baa8d365c798fbfb2 Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 14:37:06 +0100 Subject: [PATCH 21/26] ci: fix double upload --- .github/workflows/memcheck.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/memcheck.yml b/.github/workflows/memcheck.yml index 4784b5d34b..480ca3624d 100644 --- a/.github/workflows/memcheck.yml +++ b/.github/workflows/memcheck.yml @@ -99,7 +99,6 @@ 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 - ./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" From f1bcad1287125616b4ec804dfc7c21ca35eb12a1 Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 15:06:08 +0100 Subject: [PATCH 22/26] fix: enable process-metrics feature --- ant-node/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ant-node/Cargo.toml b/ant-node/Cargo.toml index 10b7fe126c..37203c57fd 100644 --- a/ant-node/Cargo.toml +++ b/ant-node/Cargo.toml @@ -26,7 +26,7 @@ upnp = ["ant-networking/upnp"] 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-logging = { path = "../ant-logging", version = "0.2.44", features = [ "process-metrics" ] } 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" } From fc61526205db4247a36b6cda332aad256139e2bd Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 15:08:24 +0100 Subject: [PATCH 23/26] ci: fix local vault sync --- .github/workflows/merge.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index c41a65a72c..261a81c092 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -438,13 +438,13 @@ jobs: timeout-minutes: 25 - name: sync the vault - run: ./target/release/ant --log-output-dest data-dir vault sync + run: ./target/release/ant --log-output-dest data-dir --local vault sync env: ANT_LOG: "v" timeout-minutes: 2 - name: load the vault from network - run: ./target/release/ant --log-output-dest data-dir vault load + run: ./target/release/ant --log-output-dest data-dir --local vault load env: ANT_LOG: "v" timeout-minutes: 2 From 5e9a669eec2cc74e8ee4b7979a7af3c255f9940c Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 15:11:54 +0100 Subject: [PATCH 24/26] ci: add --local flags to ant --- .github/workflows/merge.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 261a81c092..4025a9cf32 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -533,7 +533,7 @@ jobs: timeout-minutes: 2 - name: load an existing vault from the network - run: ./target/release/ant --log-output-dest=data-dir vault load + run: ./target/release/ant --log-output-dest data-dir --local vault load env: ANT_LOG: "v" timeout-minutes: 2 @@ -551,7 +551,7 @@ jobs: # 1 GB python3 -c "with open('random_1GB.bin', 'wb') as f: f.write(bytearray([0xff] * 1000 * 1024 * 1024))" - ./target/release/ant --log-output-dest=data-dir file list + ./target/release/ant --log-output-dest=data-dir --local file list time ./target/release/ant --log-output-dest=data-dir --local file upload random_1MB.bin time ./target/release/ant --log-output-dest=data-dir --local file upload random_10MB.bin time ./target/release/ant --log-output-dest=data-dir --local file upload random_100MB.bin @@ -1306,7 +1306,7 @@ jobs: shell: bash - name: File upload - run: ./target/release/ant --log-output-dest data-dir file upload "./test_data_1.tar.gz" > ./upload_output 2>&1 + run: ./target/release/ant --log-output-dest data-dir --local file upload "./test_data_1.tar.gz" > ./upload_output 2>&1 env: ANT_LOG: "v" timeout-minutes: 15 @@ -1323,7 +1323,7 @@ jobs: shell: bash - name: File Download - run: ./target/release/ant --log-output-dest data-dir file download ${{ env.UPLOAD_ADDRESS }} ./downloaded_resources > ./download_output 2>&1 + run: ./target/release/ant --log-output-dest data-dir --local file download ${{ env.UPLOAD_ADDRESS }} ./downloaded_resources > ./download_output 2>&1 env: ANT_LOG: "v" timeout-minutes: 5 From 9db51004ba74f6324b7d637f5e81156406aa5b1f Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 15:15:30 +0100 Subject: [PATCH 25/26] feat: enable mDNS behavior only with --local --- ant-networking/src/driver.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ant-networking/src/driver.rs b/ant-networking/src/driver.rs index 8037f78a29..1498554479 100644 --- a/ant-networking/src/driver.rs +++ b/ant-networking/src/driver.rs @@ -44,7 +44,6 @@ use ant_protocol::{ use ant_registers::SignedRegister; use futures::future::Either; use futures::StreamExt; -use libp2p::mdns; use libp2p::{core::muxing::StreamMuxerBox, relay}; use libp2p::{ identity::Keypair, @@ -57,6 +56,7 @@ use libp2p::{ }, Multiaddr, PeerId, }; +use libp2p::{mdns, swarm::behaviour::toggle::Toggle}; use libp2p::{swarm::SwarmEvent, Transport as _}; #[cfg(feature = "open-metrics")] use prometheus_client::metrics::info::Info; @@ -254,9 +254,9 @@ pub(super) struct NodeBehaviour { libp2p::allow_block_list::Behaviour, pub(super) identify: libp2p::identify::Behaviour, /// mDNS behaviour to use in local mode - pub(super) mdns: mdns::tokio::Behaviour, + pub(super) mdns: Toggle, #[cfg(feature = "upnp")] - pub(super) upnp: libp2p::swarm::behaviour::toggle::Toggle, + pub(super) upnp: Toggle, pub(super) relay_client: libp2p::relay::client::Behaviour, pub(super) relay_server: libp2p::relay::Behaviour, pub(super) kademlia: kad::Behaviour, @@ -619,15 +619,21 @@ impl NetworkBuilder { } }; - let mdns_config = mdns::Config { - // lower query interval to speed up peer discovery - // this increases traffic, but means we no longer have clients unable to connect - // after a few minutes - query_interval: Duration::from_secs(5), - ..Default::default() - }; + let mdns = if self.local { + debug!("Enabling mDNS behavior (because of local mode)"); - let mdns = mdns::tokio::Behaviour::new(mdns_config, peer_id)?; + let mdns_config = mdns::Config { + // lower query interval to speed up peer discovery this + // increases traffic, but means we no longer have clients + // unable to connect after a few minutes + query_interval: Duration::from_secs(5), + ..Default::default() + }; + Some(mdns::tokio::Behaviour::new(mdns_config, peer_id)?) + } else { + None + } + .into(); // Into `Toggle` let agent_version = if is_client { IDENTIFY_CLIENT_VERSION_STR From fa5b005391d629b928e505c7a4e0b2bf8d9d4b84 Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 16:25:27 +0100 Subject: [PATCH 26/26] docs: remove reference to --local in README.md --- autonomi/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autonomi/README.md b/autonomi/README.md index 4c19a3e7c4..7c1dc7f8c4 100644 --- a/autonomi/README.md +++ b/autonomi/README.md @@ -66,12 +66,12 @@ To run the tests, we can run a local network: cargo run --bin evm-testnet ``` -2. Run a local network with the `local` feature and use the local EVM node. +2. Run a local network and use the local EVM node. ```sh - cargo run --bin antctl --features local -- local run --build --clean --rewards-address evm-local + cargo run --bin antctl -- local run --build --clean --rewards-address evm-local ``` -3. Then run the tests with the `local` feature and pass the EVM params again: +3. Then run the tests and pass the EVM params again: ```sh EVM_NETWORK=local cargo test --package autonomi ``` @@ -80,10 +80,10 @@ To run the tests, we can run a local network: Using the hardcoded `Arbitrum One` option as an example, but you can also use the command flags of the steps above and point it to a live network. -1. Run a local network with the `local` feature: +1. Run a local network: ```sh -cargo run --bin antctl --features local -- local run --build --clean --rewards-address evm-arbitrum-one +cargo run --bin antctl -- local run --build --clean --rewards-address evm-arbitrum-one ``` 2. Then pass the private key of the wallet, and ensure it has enough gas and payment tokens on the network (in this case Arbitrum One):