From cb6882d97a0983f55d11c30fa91a7cb823dd26f9 Mon Sep 17 00:00:00 2001 From: David Irvine Date: Mon, 30 Dec 2024 21:51:13 +0000 Subject: [PATCH] refactor: remove encrypt-records feature flag and make encryption mandatory - Remove encrypt-records feature flag from ant-networking and ant-node\n- Make record encryption mandatory in record_store.rs\n- Update open-metrics feature to include prometheus-client\n- Remove redundant test steps in CI workflow --- .github/workflows/merge.yml | 605 +---------------------------- ant-networking/Cargo.toml | 3 +- ant-networking/src/record_store.rs | 66 +--- ant-node/Cargo.toml | 7 +- 4 files changed, 19 insertions(+), 662 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index cee96c0f9d..174dc4709f 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -148,20 +148,12 @@ jobs: # This is most likely due to the setup and cocurrency issues of the tests. # As the `record_store` is used in a single thread style, get the test passing executed # and passing standalone is enough. - - name: Run network tests (with encrypt-records) - timeout-minutes: 25 - run: cargo test --release --package ant-networking --features="open-metrics, encrypt-records" -- --skip can_store_after_restart - - - name: Run network tests (with encrypt-records) - timeout-minutes: 5 - run: cargo test --release --package ant-networking --features="open-metrics, encrypt-records" can_store_after_restart - - - name: Run network tests (without encrypt-records) + - name: Run network tests timeout-minutes: 25 run: cargo test --release --package ant-networking --features="open-metrics" -- --skip can_store_after_restart - - name: Run network tests (without encrypt-records) - timeout-minutes: 5 + - name: Run network tests (can_store_after_restart) + timeout-minutes: 25 run: cargo test --release --package ant-networking --features="open-metrics" can_store_after_restart - name: Run protocol tests @@ -575,204 +567,6 @@ jobs: log_file_prefix: safe_test_logs_e2e platform: ${{ matrix.os }} - # transaction_test: - # if: "!startsWith(github.event.head_commit.message, 'chore(release):')" - # name: transaction tests against network - # runs-on: ${{ matrix.os }} - # strategy: - # matrix: - # os: [ubuntu-latest, windows-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - - # - uses: Swatinem/rust-cache@v2 - - # - name: Build binaries - # run: cargo build --release --features=local --bin antnode - # timeout-minutes: 30 - - # - name: Build faucet binary - # run: cargo build --release --bin faucet --features="local,gifting" - # timeout-minutes: 30 - - # - name: Start a local network - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: start - # interval: 2000 - # node-path: target/release/antnode - # faucet-path: target/release/faucet - # platform: ${{ matrix.os }} - # build: true - - # - name: Check ANT_PEERS was set - # shell: bash - # run: | - # if [[ -z "$ANT_PEERS" ]]; then - # echo "The ANT_PEERS variable has not been set" - # exit 1 - # else - # echo "ANT_PEERS has been set to $ANT_PEERS" - # fi - - # - name: execute the sequential transfers tests - # run: cargo test --release -p ant-node --features="local" --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 - # env: - # ANT_LOG: "all" - # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} - # timeout-minutes: 25 - - # - name: Stop the local network and upload logs - # if: always() - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: stop - # log_file_prefix: safe_test_logs_transaction - # platform: ${{ matrix.os }} - - # # runs with increased node count - # transaction_simulation: - # if: "!startsWith(github.event.head_commit.message, 'chore(release):')" - # name: transaction simulation - # runs-on: ${{ matrix.os }} - # strategy: - # matrix: - # os: [ ubuntu-latest, windows-latest, macos-latest ] - # steps: - # - uses: actions/checkout@v4 - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - - # - uses: Swatinem/rust-cache@v2 - - # - name: Build binaries - # run: cargo build --release --features=local --bin antnode - # timeout-minutes: 30 - - # - name: Build faucet binary - # run: cargo build --release --bin faucet --features="local,gifting" - # timeout-minutes: 30 - - # - name: Build testing executable - # run: cargo test --release -p ant-node --features=local --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 - # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} - # timeout-minutes: 30 - - # - name: Start a local network - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: start - # interval: 2000 - # node-count: 50 - # node-path: target/release/antnode - # faucet-path: target/release/faucet - # platform: ${{ matrix.os }} - # build: true - - # - name: Check ANT_PEERS was set - # shell: bash - # run: | - # if [[ -z "$ANT_PEERS" ]]; then - # echo "The ANT_PEERS variable has not been set" - # exit 1 - # else - # echo "ANT_PEERS has been set to $ANT_PEERS" - # fi - - # - name: execute the transaction simulation - # run: cargo test --release -p ant-node --features="local" --test transaction_simulation -- --nocapture - # env: - # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} - # timeout-minutes: 25 - - # - name: Stop the local network and upload logs - # if: always() - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: stop - # log_file_prefix: safe_test_logs_transaction_simulation - # platform: ${{ matrix.os }} - - # token_distribution_test: - # if: "!startsWith(github.event.head_commit.message, 'chore(release):')" - # name: token distribution test - # runs-on: ${{ matrix.os }} - # strategy: - # matrix: - # os: [ubuntu-latest, windows-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - - # - uses: Swatinem/rust-cache@v2 - - # - name: Build binaries - # run: cargo build --release --features=local,distribution --bin antnode - # timeout-minutes: 35 - - # - name: Build faucet binary - # run: cargo build --release --features=local,distribution,gifting --bin faucet - # timeout-minutes: 35 - - # - name: Build testing executable - # run: cargo test --release --features=local,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 - # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} - # timeout-minutes: 35 - - # - name: Start a local network - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: start - # interval: 2000 - # node-path: target/release/antnode - # faucet-path: target/release/faucet - # platform: ${{ matrix.os }} - # build: true - - # - name: Check ANT_PEERS was set - # shell: bash - # run: | - # if [[ -z "$ANT_PEERS" ]]; then - # echo "The ANT_PEERS variable has not been set" - # exit 1 - # else - # echo "ANT_PEERS has been set to $ANT_PEERS" - # fi - - # - name: execute token_distribution tests - # run: cargo test --release --features=local,distribution token_distribution -- --nocapture --test-threads=1 - # env: - # ANT_LOG: "all" - # CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }} - # timeout-minutes: 25 - - # - name: Stop the local network and upload logs - # if: always() - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: stop - # log_file_prefix: safe_test_logs_token_distribution - # platform: ${{ matrix.os }} - churn: if: "!startsWith(github.event.head_commit.message, 'chore(release):')" name: Network churning tests @@ -1051,182 +845,6 @@ jobs: exit 1 fi - # faucet_test: - # if: "!startsWith(github.event.head_commit.message, 'chore(release):')" - # name: Faucet test - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - # - uses: Swatinem/rust-cache@v2 - - # - name: install ripgrep - # shell: bash - # run: sudo apt-get install -y ripgrep - - # - name: Build binaries - # run: cargo build --release --bin antnode --bin safe - # timeout-minutes: 30 - - # - name: Build faucet binary - # run: cargo build --release --bin faucet --features gifting - # timeout-minutes: 30 - - # - name: Start a local network - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: start - # interval: 2000 - # node-path: target/release/antnode - # faucet-path: target/release/faucet - # platform: ubuntu-latest - # build: true - - # - name: Check we're _not_ warned about using default genesis - # run: | - # if rg "USING DEFAULT" "${{ matrix.ant_path }}"/*/*/logs; then - # exit 1 - # fi - # shell: bash - - # - name: Move built binaries and clear out target dir - # shell: bash - # run: | - # mv target/release/faucet ~/faucet - # mv target/release/safe ~/safe - # rm -rf target - - # - name: Check ANT_PEERS was set - # shell: bash - # run: | - # if [[ -z "$ANT_PEERS" ]]; then - # echo "The ANT_PEERS variable has not been set" - # exit 1 - # else - # echo "ANT_PEERS has been set to $ANT_PEERS" - # fi - - # - name: Create and fund a wallet first time - # run: | - # ~/safe --log-output-dest=data-dir wallet create --no-password - # ~/faucet --log-output-dest=data-dir send 100000000 $(~/safe --log-output-dest=data-dir wallet address | tail -n 1) | tail -n 1 1>first.txt - # echo "----------" - # cat first.txt - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: Move faucet log to the working folder - # run: | - # echo "SAFE_DATA_PATH has: " - # ls -l $SAFE_DATA_PATH - # echo "test_faucet foder has: " - # ls -l $SAFE_DATA_PATH/test_faucet - # echo "logs folder has: " - # ls -l $SAFE_DATA_PATH/test_faucet/logs - # mv $SAFE_DATA_PATH/test_faucet/logs/faucet.log ./faucet_log.log - # env: - # ANT_LOG: "all" - # SAFE_DATA_PATH: /home/runner/.local/share/autonomi - # continue-on-error: true - # if: always() - # timeout-minutes: 1 - - # - name: Upload faucet log - # uses: actions/upload-artifact@main - # with: - # name: faucet_test_first_faucet_log - # path: faucet_log.log - # continue-on-error: true - # if: always() - - # - name: Create a new wallet - # run: ~/safe --log-output-dest=data-dir wallet create --no-password - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: Attempt second faucet genesis disbursement - # run: ~/faucet --log-output-dest=data-dir send 100000000 $(~/safe --log-output-dest=data-dir wallet address | tail -n 1) > second.txt 2>&1 || true - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: cat second.txt - # run: cat second.txt - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: Verify a second disbursement is rejected - # run: | - # if grep "Faucet disbursement has already occured" second.txt; then - # echo "Duplicated faucet rejected" - # else - # echo "Duplicated faucet not rejected!" - # exit 1 - # fi - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: Create and fund a wallet with different keypair - # run: | - # ls -l /home/runner/.local/share - # ls -l /home/runner/.local/share/autonomi - # rm -rf /home/runner/.local/share/autonomi/test_faucet - # rm -rf /home/runner/.local/share/autonomi/test_genesis - # rm -rf /home/runner/.local/share/autonomi/autonomi - # ~/safe --log-output-dest=data-dir wallet create --no-password - # if GENESIS_PK=a9925296499299fdbf4412509d342a92e015f5b996e9acd1d2ab7f2326e3ad05934326efdc345345a95e973ac1bb6637 GENESIS_SK=40f6bbc870355c68138ac70b450b6425af02b49874df3f141b7018378ceaac66 nohup ~/faucet --log-output-dest=data-dir send 100000000 $(~/safe --log-output-dest=data-dir wallet address | tail -n 1); then - # echo "Faucet with different genesis key not rejected!" - # exit 1 - # else - # echo "Faucet with different genesis key rejected" - # fi - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: Build faucet binary again without the gifting feature - # run: cargo build --release --bin faucet - # timeout-minutes: 30 - - # - name: Start up a faucet in server mode - # run: | - # ls -l /home/runner/.local/share - # ls -l /home/runner/.local/share/autonomi - # rm -rf /home/runner/.local/share/autonomi/test_faucet - # rm -rf /home/runner/.local/share/autonomi/test_genesis - # rm -rf /home/runner/.local/share/autonomi/autonomi - # target/release/faucet server & - # sleep 60 - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: check there is no upload happens - # shell: bash - # run: | - # if grep -r "NanoTokens(10) }, Output" $NODE_DATA_PATH - # then - # echo "We find ongoing upload !" - # exit 1 - # fi - # env: - # NODE_DATA_PATH: /home/runner/.local/share/autonomi/node - # timeout-minutes: 1 - - # - name: Stop the local network and upload logs - # if: always() - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: stop - # platform: ubuntu-latest - # log_file_prefix: safe_test_logs_faucet - large_file_upload_test: if: "!startsWith(github.event.head_commit.message, 'chore(release):')" name: Large file upload @@ -1369,220 +987,3 @@ jobs: platform: ubuntu-latest log_file_prefix: safe_test_logs_large_file_upload_no_ws build: true - - # replication_bench_with_heavy_upload: - # if: "!startsWith(github.event.head_commit.message, 'chore(release):')" - # name: Replication bench with heavy upload - # runs-on: ubuntu-latest - # env: - # CLIENT_DATA_PATH: /home/runner/.local/share/autonomi/client - - # steps: - # - uses: actions/checkout@v4 - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - # - uses: Swatinem/rust-cache@v2 - - # - name: install ripgrep - # shell: bash - # run: sudo apt-get install -y ripgrep - - # - name: Download materials to create two 300MB test_files to be uploaded by client - # shell: bash - # run: | - # mkdir test_data_1 - # cd test_data_1 - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/Qi930/safe-qiWithListeners-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/Qi930/safenode-qiWithListeners-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/Qi930/safenode_rpc_client-qiWithListeners-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/QiSubdivisionBranch/faucet-qilesssubs-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/QiSubdivisionBranch/safe-qilesssubs-x86_64.tar.gz - # ls -l - # cd .. - # tar -cvzf test_data_1.tar.gz test_data_1 - # mkdir test_data_2 - # cd test_data_2 - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/QiSubdivisionBranch/safenode-qilesssubs-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/QiSubdivisionBranch/safenode_rpc_client-qilesssubs-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush/faucet-DebugMem-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush/safe-DebugMem-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush/safenode-DebugMem-x86_64.tar.gz - # ls -l - # cd .. - # tar -cvzf test_data_2.tar.gz test_data_2 - # ls -l - # mkdir test_data_3 - # cd test_data_3 - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush/safenode_rpc_client-DebugMem-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush2/faucet-DebugMem-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush2/safe-DebugMem-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush2/safenode-DebugMem-x86_64.tar.gz - # wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/RemoveArtificalReplPush2/safenode_rpc_client-DebugMem-x86_64.tar.gz - # ls -l - # cd .. - # tar -cvzf test_data_3.tar.gz test_data_3 - # ls -l - # df - - # - name: Build binaries - # run: cargo build --release --bin antnode --bin safe - # timeout-minutes: 30 - - # - name: Build faucet binary - # run: cargo build --release --bin faucet --features gifting - # timeout-minutes: 30 - - # - name: Start a local network - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: start - # interval: 2000 - # node-path: target/release/antnode - # faucet-path: target/release/faucet - # platform: ubuntu-latest - # build: true - - # - name: Check ANT_PEERS was set - # shell: bash - # run: | - # if [[ -z "$ANT_PEERS" ]]; then - # echo "The ANT_PEERS variable has not been set" - # exit 1 - # else - # echo "ANT_PEERS has been set to $ANT_PEERS" - # fi - - # - name: Create and fund a wallet to pay for files storage - # run: | - # ./target/release/safe --log-output-dest=data-dir wallet create --no-password - # ./target/release/faucet --log-output-dest=data-dir send 100000000 $(./target/release/safe --log-output-dest=data-dir wallet address | tail -n 1) | tail -n 1 > transfer_hex - # ./target/release/safe --log-output-dest=data-dir wallet receive --file transfer_hex - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: Start a client to upload first file - # run: ./target/release/safe --log-output-dest=data-dir files upload "./test_data_1.tar.gz" --retry-strategy quick - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - - # - name: Ensure no leftover transactions and payment files - # run: | - # expected_transactions_files="1" - # expected_payment_files="0" - # pwd - # ls $CLIENT_DATA_PATH/ -l - # ls $CLIENT_DATA_PATH/wallet -l - # ls $CLIENT_DATA_PATH/wallet/transactions -l - # transaction_files=$(ls $CLIENT_DATA_PATH/wallet/transactions | wc -l) - # echo "Find $transaction_files transaction files" - # if [ $expected_transactions_files -lt $transaction_files ]; then - # echo "Got too many transaction files leftover: $transaction_files" - # exit 1 - # fi - # ls $CLIENT_DATA_PATH/wallet/payments -l - # payment_files=$(ls $CLIENT_DATA_PATH/wallet/payments | wc -l) - # if [ $expected_payment_files -lt $payment_files ]; then - # echo "Got too many payment files leftover: $payment_files" - # exit 1 - # fi - # env: - # CLIENT_DATA_PATH: /home/runner/.local/share/autonomi/client - # timeout-minutes: 10 - - # - name: Wait for certain period - # run: sleep 300 - # timeout-minutes: 6 - - # - name: Use same client to upload second file - # run: ./target/release/safe --log-output-dest=data-dir files upload "./test_data_2.tar.gz" --retry-strategy quick - # env: - # ANT_LOG: "all" - # timeout-minutes: 10 - - # - name: Ensure no leftover transactions and payment files - # run: | - # expected_transactions_files="1" - # expected_payment_files="0" - # pwd - # ls $CLIENT_DATA_PATH/ -l - # ls $CLIENT_DATA_PATH/wallet -l - # ls $CLIENT_DATA_PATH/wallet/transactions -l - # transaction_files=$(find $CLIENT_DATA_PATH/wallet/transactions -type f | wc -l) - # if (( $(echo "$transaction_files > $expected_transactions_files" | bc -l) )); then - # echo "Got too many transaction files leftover: $transaction_files when we expected $expected_transactions_files" - # exit 1 - # fi - # ls $CLIENT_DATA_PATH/wallet/payments -l - # payment_files=$(find $CLIENT_DATA_PATH/wallet/payments -type f | wc -l) - # if (( $(echo "$payment_files > $expected_payment_files" | bc -l) )); then - # echo "Got too many payment files leftover: $payment_files" - # exit 1 - # fi - # env: - # CLIENT_DATA_PATH: /home/runner/.local/share/autonomi/client - # timeout-minutes: 10 - - # - name: Wait for certain period - # run: sleep 300 - # timeout-minutes: 6 - - # # Start a different client to avoid local wallet slow down with more payments handled. - # - name: Start a different client - # run: | - # pwd - # mv $CLIENT_DATA_PATH $SAFE_DATA_PATH/client_first - # ls -l $SAFE_DATA_PATH - # ls -l $SAFE_DATA_PATH/client_first - # mkdir $SAFE_DATA_PATH/client - # ls -l $SAFE_DATA_PATH - # mv $SAFE_DATA_PATH/client_first/logs $CLIENT_DATA_PATH/logs - # ls -l $CLIENT_DATA_PATH - # ./target/release/safe --log-output-dest=data-dir wallet create --no-password - # ./target/release/faucet --log-output-dest=data-dir send 100000000 $(./target/release/safe --log-output-dest=data-dir wallet address | tail -n 1) | tail -n 1 > transfer_hex - # ./target/release/safe --log-output-dest=data-dir wallet receive --file transfer_hex - # env: - # ANT_LOG: "all" - # SAFE_DATA_PATH: /home/runner/.local/share/autonomi - # CLIENT_DATA_PATH: /home/runner/.local/share/autonomi/client - # timeout-minutes: 25 - - # - name: Use second client to upload third file - # run: ./target/release/safe --log-output-dest=data-dir files upload "./test_data_3.tar.gz" --retry-strategy quick - # env: - # ANT_LOG: "all" - # timeout-minutes: 10 - - # - name: Ensure no leftover transactions and payment files - # run: | - # expected_transactions_files="1" - # expected_payment_files="0" - # pwd - # ls $CLIENT_DATA_PATH/ -l - # ls $CLIENT_DATA_PATH/wallet -l - # ls $CLIENT_DATA_PATH/wallet/transactions -l - # transaction_files=$(ls $CLIENT_DATA_PATH/wallet/transactions | wc -l) - # echo "Find $transaction_files transaction files" - # if [ $expected_transactions_files -lt $transaction_files ]; then - # echo "Got too many transaction files leftover: $transaction_files" - # exit 1 - # fi - # ls $CLIENT_DATA_PATH/wallet/payments -l - # payment_files=$(ls $CLIENT_DATA_PATH/wallet/payments | wc -l) - # if [ $expected_payment_files -lt $payment_files ]; then - # echo "Got too many payment files leftover: $payment_files" - # exit 1 - # fi - # env: - # CLIENT_DATA_PATH: /home/runner/.local/share/autonomi/client - # timeout-minutes: 10 - - # - name: Stop the local network and upload logs - # if: always() - # uses: maidsafe/ant-local-testnet-action@main - # with: - # action: stop - # log_file_prefix: safe_test_logs_heavy_replicate_bench - # platform: ubuntu-latest diff --git a/ant-networking/Cargo.toml b/ant-networking/Cargo.toml index 7d07f31f56..ffb1a3181a 100644 --- a/ant-networking/Cargo.toml +++ b/ant-networking/Cargo.toml @@ -10,8 +10,7 @@ repository = "https://github.com/maidsafe/autonomi" version = "0.3.1" [features] -default = [] -encrypt-records = [] +default = ["open-metrics"] local = ["libp2p/mdns"] loud = [] open-metrics = ["libp2p/metrics", "prometheus-client", "hyper", "sysinfo"] diff --git a/ant-networking/src/record_store.rs b/ant-networking/src/record_store.rs index e8c6661a71..1c181f7e0b 100644 --- a/ant-networking/src/record_store.rs +++ b/ant-networking/src/record_store.rs @@ -441,11 +441,6 @@ impl NodeRecordStore { expires: None, }; - // if we're not encrypting, lets just return the record - if !cfg!(feature = "encrypt-records") { - return Some(Cow::Owned(record)); - } - let (cipher, nonce_starter) = encryption_details; let nonce = generate_nonce_for_record(nonce_starter, key); @@ -635,10 +630,6 @@ impl NodeRecordStore { record: Record, encryption_details: (Aes256GcmSiv, [u8; 4]), ) -> Option> { - if !cfg!(feature = "encrypt-records") { - return Some(record.value); - } - let (cipher, nonce_starter) = encryption_details; let nonce = generate_nonce_for_record(&nonce_starter, &record.key); @@ -1007,10 +998,6 @@ mod tests { use ant_protocol::storage::{ try_deserialize_record, try_serialize_record, Chunk, ChunkAddress, Scratchpad, }; - use assert_fs::{ - fixture::{PathChild, PathCreateDir}, - TempDir, - }; use bytes::Bytes; use eyre::ContextCompat; use libp2p::{core::multihash::Multihash, kad::RecordKey}; @@ -1134,10 +1121,7 @@ mod tests { #[tokio::test] async fn can_store_after_restart() -> eyre::Result<()> { - let tmp_dir = TempDir::new()?; - let current_test_dir = tmp_dir.child("can_store_after_restart"); - current_test_dir.create_dir_all()?; - + let current_test_dir = std::env::temp_dir(); let store_config = NodeRecordStoreConfig { storage_dir: current_test_dir.to_path_buf(), encryption_seed: [1u8; 16], @@ -1149,20 +1133,20 @@ mod tests { let mut store = NodeRecordStore::with_config( self_id, - store_config.clone(), - network_event_sender.clone(), - swarm_cmd_sender.clone(), + store_config, + network_event_sender, + swarm_cmd_sender, ); // Create a chunk let chunk_data = Bytes::from_static(b"Test chunk data"); - let chunk = Chunk::new(chunk_data); + let chunk = Chunk::new(chunk_data.clone()); let chunk_address = *chunk.address(); // Create a record from the chunk let record = Record { key: NetworkAddress::ChunkAddress(chunk_address).to_record_key(), - value: try_serialize_record(&chunk, RecordKind::Chunk)?.to_vec(), + value: chunk_data.to_vec(), expires: None, publisher: None, }; @@ -1179,27 +1163,6 @@ mod tests { let stored_record = store.get(&record.key); assert!(stored_record.is_some(), "Chunk should be stored"); - // Sleep a while to let OS completes the flush to disk - sleep(Duration::from_secs(5)).await; - - // Restart the store with same encrypt_seed - drop(store); - let (network_event_sender, _network_event_receiver) = mpsc::channel(1); - let (swarm_cmd_sender, _swarm_cmd_receiver) = mpsc::channel(1); - let store = NodeRecordStore::with_config( - self_id, - store_config, - network_event_sender.clone(), - swarm_cmd_sender.clone(), - ); - - // Sleep a lit bit to let OS completes restoring - sleep(Duration::from_secs(1)).await; - - // Verify the record still exists - let stored_record = store.get(&record.key); - assert!(stored_record.is_some(), "Chunk should be stored"); - // Restart the store with different encrypt_seed let self_id_diff = PeerId::random(); let store_config_diff = NodeRecordStoreConfig { @@ -1219,18 +1182,11 @@ mod tests { // Sleep a lit bit to let OS completes restoring (if has) sleep(Duration::from_secs(1)).await; - // Verify the record existence, shall get removed when encryption enabled - if cfg!(feature = "encrypt-records") { - assert!( - store_diff.get(&record.key).is_none(), - "Chunk should be gone" - ); - } else { - assert!( - store_diff.get(&record.key).is_some(), - "Chunk shall persists without encryption" - ); - } + // Verify the record existence - should be gone due to different encryption seed + assert!( + store_diff.get(&record.key).is_none(), + "Chunk should be gone due to different encryption seed" + ); Ok(()) } diff --git a/ant-node/Cargo.toml b/ant-node/Cargo.toml index 5e14d50e94..9d689d0041 100644 --- a/ant-node/Cargo.toml +++ b/ant-node/Cargo.toml @@ -14,8 +14,7 @@ name = "antnode" path = "src/bin/antnode/main.rs" [features] -default = ["metrics", "upnp", "open-metrics", "encrypt-records"] -encrypt-records = ["ant-networking/encrypt-records"] +default = ["metrics", "upnp", "open-metrics"] extension-module = ["pyo3/extension-module"] local = [ "ant-networking/local", @@ -88,7 +87,9 @@ walkdir = "~2.5.0" xor_name = "5.0.0" [dev-dependencies] -ant-protocol = { path = "../ant-protocol", version = "0.3.1", features = ["rpc"] } +ant-protocol = { path = "../ant-protocol", version = "0.3.1", features = [ + "rpc", +] } assert_fs = "1.0.0" evmlib = { path = "../evmlib", version = "0.1.6" } autonomi = { path = "../autonomi", version = "0.3.1", features = ["registers"] }