Skip to content

Commit

Permalink
Merge pull request #5 from mickvandijke/feat-upgradable-smart-contrac…
Browse files Browse the repository at this point in the history
…ts-and-updated-quotation-flow-rebased

merge main
  • Loading branch information
mickvandijke authored Dec 11, 2024
2 parents abf651c + 72fa1a9 commit 80191e8
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 133 deletions.
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 @@ -456,11 +456,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 @@ -476,7 +476,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 @@ -571,7 +571,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 @@ -1151,17 +1151,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 @@ -339,30 +339,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
12 changes: 0 additions & 12 deletions ant-node/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,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 Down Expand Up @@ -87,12 +81,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),
}
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 @@ -10,7 +10,7 @@
use crate::{storage::RecordType, NetworkAddress};
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
1 change: 0 additions & 1 deletion autonomi/src/client/rate_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ impl RateLimiter {
let interval = Duration::from_millis(interval_in_ms);

if elapsed_time < interval {
println!("Waiting for: {:?}", interval - elapsed_time);
sleep(interval - elapsed_time).await;
}
}
Expand Down

0 comments on commit 80191e8

Please sign in to comment.