Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup cashnotes and unused spend errors #2473

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]\+'`
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 0 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions ant-networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ pub(crate) type BadNodes = BTreeMap<PeerId, (Vec<(NodeIssue, Instant)>, 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);
Expand Down
33 changes: 0 additions & 33 deletions ant-node/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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>),
Expand All @@ -61,39 +54,13 @@ 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")]
FailedToGetNodePort,
/// 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),
}
74 changes: 0 additions & 74 deletions ant-node/tests/common/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HotWallet> {
// 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,
Expand Down
2 changes: 1 addition & 1 deletion ant-node/tests/data_with_churn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion ant-protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ant-protocol/src/messages/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading