From c17f6d4826a164b087fb407a0b44fe380094a8ec Mon Sep 17 00:00:00 2001 From: grumbach Date: Mon, 2 Dec 2024 17:04:57 +0900 Subject: [PATCH] chore: cleanup cashnotes and unused spend errors --- .github/workflows/merge.yml | 23 +++------- README.md | 24 ---------- ant-networking/src/driver.rs | 3 +- ant-node/src/error.rs | 33 -------------- ant-node/tests/common/client.rs | 74 ------------------------------- ant-node/tests/data_with_churn.rs | 2 +- ant-protocol/README.md | 2 +- ant-protocol/src/messages/cmd.rs | 2 +- 8 files changed, 10 insertions(+), 153 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index f306759803..be34025a8a 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -81,7 +81,7 @@ jobs: - name: Check documentation # Deny certain `rustdoc` lints that are unwanted with `RUSTDOCFLAGS`. See # https://doc.rust-lang.org/rustdoc/lints.html for lints that are 'warning' by default. - # + # # We exclude autonomi-cli because it is not published and conflicts with the `autonomi` crate name, # resulting in an error when building docs. run: RUSTDOCFLAGS="--deny=warnings" cargo doc --no-deps --workspace --exclude=autonomi-cli @@ -452,11 +452,11 @@ jobs: NUM_OF_PUBLIC_FILES_IN_VAULT="" NUM_OF_PRIVATE_FILES_IN_VAULT="" NUM_OF_REGISTERS_IN_VAULT="" - + ./target/release/ant --log-output-dest data-dir file list 2>&1 > file_list.txt - + ./target/release/ant register list | grep register > register_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]\+'` NUM_OF_REGISTERS=`cat register_list.txt | grep "register" | grep -o '[0-9]\+'` @@ -472,7 +472,7 @@ jobs: echo "Total Num of local public files is $NUM_OF_PUBLIC_FILES and in vault is $NUM_OF_PUBLIC_FILES_IN_VAULT" echo "Total Num of local private files is $NUM_OF_PRIVATE_FILES and in vault is $NUM_OF_PRIVATE_FILES_IN_VAULT" echo "Total Num of local registers is $NUM_OF_REGISTERS_first and in vault is $NUM_OF_REGISTERS_IN_VAULT" - + rm -rf file_list.txt register_list.txt vault_data.txt python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: local data and vault in network dont match, Local public Files: {sys.argv[1]} and vault public files: {sys.argv[2]} are Not Equal"' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT @@ -567,7 +567,7 @@ jobs: time ./target/release/ant --log-output-dest=data-dir file upload random_1GB.bin ./target/release/ant --log-output-dest=data-dir vault sync rm -rf random*.bin - rm -rf ${{ matrix.ant_path }}/autonomi + rm -rf ${{ matrix.ant_path }}/autonomi env: ANT_LOG: "v" timeout-minutes: 15 @@ -1147,17 +1147,6 @@ jobs: # continue-on-error: true # if: always() - # - name: Cleanup prior faucet and cashnotes - # 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 - # env: - # ANT_LOG: "all" - # timeout-minutes: 5 - # - name: Create a new wallet # run: ~/safe --log-output-dest=data-dir wallet create --no-password # env: diff --git a/README.md b/README.md index 014ea96496..bdd2312836 100644 --- a/README.md +++ b/README.md @@ -357,30 +357,6 @@ Node successfully received the request to try to update in 7s NOTE: it is preferable to use the node manager to control the node rather than RPC commands. -Listening to royalty payment events: - -``` -$ cargo run --bin antnode_rpc_client -- 127.0.0.1:34416 transfers -Listening to transfer notifications... (press Ctrl+C to exit) - -New transfer notification received for PublicKey(0c54..5952), containing 1 cash note/s. -CashNote received with UniquePubkey(PublicKey(19ee..1580)), value: 0.000000001 - -New transfer notification received for PublicKey(0c54..5952), containing 1 cash note/s. -CashNote received with UniquePubkey(PublicKey(19ee..1580)), value: 0.000000001 -``` - -The `transfers` command can provide a path for royalty payment cash notes: - -``` -$ cargo run --release --bin antnode_rpc_client -- 127.0.0.1:34416 transfers ./royalties-cash-notes -Listening to transfer notifications... (press Ctrl+C to exit) -Writing cash notes to: ./royalties-cash-notes -``` - -Each received cash note is written to a file in the directory above, under another directory -corresponding to the public address of the recipient. - ### Tear Down When you're finished experimenting, tear down the network: diff --git a/ant-networking/src/driver.rs b/ant-networking/src/driver.rs index a9792700da..70dce7729a 100644 --- a/ant-networking/src/driver.rs +++ b/ant-networking/src/driver.rs @@ -113,8 +113,7 @@ pub(crate) type BadNodes = BTreeMap, bool)>; /// What is the largest packet to send over the network. /// Records larger than this will be rejected. -// TODO: revisit once cashnote_redemption is in -pub const MAX_PACKET_SIZE: usize = 1024 * 1024 * 5; // the chunk size is 1mb, so should be higher than that to prevent failures, 5mb here to allow for CashNote storage +pub const MAX_PACKET_SIZE: usize = 1024 * 1024 * 5; // the chunk size is 1mb, so should be higher than that to prevent failures // Timeout for requests sent/received through the request_response behaviour. const REQUEST_TIMEOUT_DEFAULT_S: Duration = Duration::from_secs(30); diff --git a/ant-node/src/error.rs b/ant-node/src/error.rs index 86aba2df5c..a0aa2a6a48 100644 --- a/ant-node/src/error.rs +++ b/ant-node/src/error.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. -use ant_evm::AttoTokens; use ant_protocol::{NetworkAddress, PrettyPrintRecordKey}; use thiserror::Error; @@ -31,12 +30,6 @@ pub enum Error { #[error("Failed to parse NodeEvent")] NodeEventParsingFailed, - #[error("Failed to send a cmd to the node: {0}")] - NodeCmdFailed(String), - - #[error("Overflow occurred while adding values")] - NumericOverflow, - // ---------- Record Errors #[error("Record was not stored as no payment supplied: {0:?}")] InvalidPutWithoutPayment(PrettyPrintRecordKey<'static>), @@ -61,26 +54,6 @@ pub enum Error { InvalidQuoteSignature, #[error("The payment quote expired for {0:?}")] QuoteExpired(NetworkAddress), - /// Payment proof received has no inputs - #[error( - "Payment proof received with record:{0:?}. No payment for our node in its transaction" - )] - NoPaymentToOurNode(PrettyPrintRecordKey<'static>), - /// Missing network royalties payment - #[error("Missing network royalties payment in proof received with record: {0:?}.")] - NoNetworkRoyaltiesPayment(PrettyPrintRecordKey<'static>), - /// The amount paid by payment proof is not the required for the received content - #[error("The amount paid by payment proof is not the required for the received content, paid {paid}, expected {expected}")] - PaymentProofInsufficientAmount { - paid: AttoTokens, - expected: AttoTokens, - }, - #[error("A payment we received contains cash notes already confirmed to be spent")] - ReusedPayment, - - // ---------- Initialize Errors - #[error("Failed to generate a reward key")] - FailedToGenerateRewardKey, // ---------- Miscellaneous Errors #[error("Failed to obtain node's current port")] @@ -88,12 +61,6 @@ pub enum Error { /// The request is invalid or the arguments of the function are invalid #[error("Invalid request: {0}")] InvalidRequest(String), - /// Error occurred in an async thread - #[error("Error occured in async thread: {0}")] - JoinErrorInAsyncThread(String), - #[error("EVM Network error: {0}")] EvmNetwork(String), - #[error("Invalid quote timestamp: {0}")] - InvalidQuoteTimestamp(String), } diff --git a/ant-node/tests/common/client.rs b/ant-node/tests/common/client.rs index c6e9296416..55126c1fc8 100644 --- a/ant-node/tests/common/client.rs +++ b/ant-node/tests/common/client.rs @@ -232,80 +232,6 @@ impl WanNetwork { // .expect("Client shall be successfully created.") // } - // // Create a wallet at root_dir and fetch the amount from the faucet url - // async fn get_funded_wallet( - // client: &Client, - // root_dir: &Path, - // faucet_socket: String, - // initial_wallet: bool, - // ) -> Result { - // let _guard = FAUCET_WALLET_MUTEX.lock().await; - - // let requests_to_faucet = if initial_wallet { - // let requests_to_faucet = 3; - // assert_eq!( - // requests_to_faucet * 100 * 1_000_000_000, - // INITIAL_WALLET_BALANCE - // ); - // requests_to_faucet - // } else { - // let requests_to_faucet = 1; - // assert_eq!( - // requests_to_faucet * 100 * 1_000_000_000, - // ADD_FUNDS_TO_WALLET - // ); - // requests_to_faucet - // }; - - // let mut local_wallet = get_wallet(root_dir); - // let address_hex = hex::encode(local_wallet.address().to_bytes()); - - // println!( - // "Getting {} tokens from the faucet... num_requests:{requests_to_faucet}", - // NanoTokens::from(INITIAL_WALLET_BALANCE) - // ); - // info!( - // "Getting {} tokens from the faucet... num_requests:{requests_to_faucet}", - // NanoTokens::from(INITIAL_WALLET_BALANCE) - // ); - // for _ in 0..requests_to_faucet { - // let faucet_url = format!("http://{faucet_socket}/{address_hex}"); - - // // Get transfer from faucet - // let transfer = reqwest::get(&faucet_url).await?.text().await?; - // let transfer = match Transfer::from_hex(&transfer) { - // Ok(transfer) => transfer, - // Err(err) => { - // println!("Failed to parse transfer: {err:?}"); - // println!("Transfer: \"{transfer}\""); - // error!("Failed to parse transfer: {err:?}"); - // error!("Transfer: \"{transfer}\""); - // return Err(err.into()); - // } - // }; - // let cashnotes = match client.receive(&transfer, &local_wallet).await { - // Ok(cashnotes) => cashnotes, - // Err(err) => { - // println!("Failed to verify and redeem transfer: {err:?}"); - // error!("Failed to verify and redeem transfer: {err:?}"); - // return Err(err.into()); - // } - // }; - // info!("Successfully verified transfer."); - // local_wallet.deposit_and_store_to_disk(&cashnotes)?; - // } - // println!( - // "Successfully got {} after {requests_to_faucet} requests to the faucet", - // NanoTokens::from(INITIAL_WALLET_BALANCE) - // ); - // info!( - // "Successfully got {} after {requests_to_faucet} requests to the faucet", - // NanoTokens::from(INITIAL_WALLET_BALANCE) - // ); - - // Ok(local_wallet) - // } - // // Restart a remote antnode service by sending a RPC to the antctl daemon. // pub async fn restart_node( // peer_id: &PeerId, diff --git a/ant-node/tests/data_with_churn.rs b/ant-node/tests/data_with_churn.rs index ffe2a879ab..246901c937 100644 --- a/ant-node/tests/data_with_churn.rs +++ b/ant-node/tests/data_with_churn.rs @@ -121,7 +121,7 @@ async fn data_availability_during_churn() -> Result<()> { // Shared bucket where we keep track of content created/stored on the network let content = ContentList::default(); - // Spawn a task to create Registers and CashNotes at random locations, + // Spawn a task to create Registers at random locations, // at a higher frequency than the churning events let create_register_handle = if !chunks_only { let register_wallet = transfer_to_new_wallet(&main_wallet, TOKENS_TO_TRANSFER).await?; diff --git a/ant-protocol/README.md b/ant-protocol/README.md index 38a8cf25bb..3239f0f2be 100644 --- a/ant-protocol/README.md +++ b/ant-protocol/README.md @@ -71,7 +71,7 @@ The `storage` module handles the storage aspects of the protocol. ### API Calls - `ChunkAddress`: Address of a chunk in the network. -- `TransactionAddress`: Address of a CashNote's Spend in the network. +- `TransactionAddress`: Address of a Transaction in the network. - `Header`: Header information for storage items. ## Protobuf Definitions diff --git a/ant-protocol/src/messages/cmd.rs b/ant-protocol/src/messages/cmd.rs index cec0629259..5e8e78d7a4 100644 --- a/ant-protocol/src/messages/cmd.rs +++ b/ant-protocol/src/messages/cmd.rs @@ -11,7 +11,7 @@ use crate::{storage::RecordType, NetworkAddress}; pub use ant_evm::PaymentQuote; use serde::{Deserialize, Serialize}; -/// Data and CashNote cmds - recording transactions or creating, updating, and removing data. +/// Ant protocol cmds /// /// See the [`protocol`] module documentation for more details of the types supported by the Safe /// Network, and their semantics.