From e2568f3c0c43b04297424d9075bbbe8922dd4260 Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Mon, 30 Sep 2024 11:38:54 +0200 Subject: [PATCH 1/2] chore(autonomi): update default features --- autonomi/Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index e6161232d5..8e6dc03f72 100644 --- a/autonomi/Cargo.toml +++ b/autonomi/Cargo.toml @@ -10,14 +10,14 @@ readme = "README.md" repository = "https://github.com/maidsafe/safe_network" [features] -default = ["data"] -full = ["data", "files", "fs", "registers", "transfers", "vault", "native-payments"] -data = ["transfers"] +default = ["evm-payments", "data"] +full = ["data", "registers", "vault", "evm-payments"] +data = [] vault = ["data"] -files = ["transfers", "data"] +files = ["fs", "data"] fs = [] local = ["sn_networking/local-discovery"] -registers = ["transfers"] +registers = [] transfers = [] native-payments = [] evm-payments = [] From 039dc8774de9bfb81096af1da28bc9024b886b23 Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Mon, 30 Sep 2024 12:54:44 +0200 Subject: [PATCH 2/2] docs(autonomi): update README.md --- autonomi/README.md | 94 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 6 deletions(-) diff --git a/autonomi/README.md b/autonomi/README.md index e3b2291766..465ddc707c 100644 --- a/autonomi/README.md +++ b/autonomi/README.md @@ -7,19 +7,101 @@ Connect to and build on the Autonomi network. ## Usage -See [docs.rs/autonomi](https://docs.rs/autonomi) for usage examples. +Add the autonomi crate to your `Cargo.toml`: + +```toml +[dependencies] +autonomi = { path = "../autonomi", version = "0.1.0" } +``` ## Running tests -Run a local network with the `local-discovery` feature: +### Using a local EVM testnet + +1. If you haven't, install Foundry, to be able to run Anvil + nodes: https://book.getfoundry.sh/getting-started/installation +2. Run a local EVM node: + +```sh +cargo run --bin evm_testnet -- --royalties-wallet +``` + +Take note of the console output for the next step (`RPC URL`, `Payment token address` & `Chunk payments address`). + +3. Run a local network with the `local-discovery` feature and pass the EVM params: + +```sh +cargo run --bin=safenode-manager --features=local-discovery -- local run --build --clean --rewards-address evm-custom --rpc-url --payment-token-address --chunk-payments-address +``` + +4. Then run the tests with the `local` feature and pass the EVM params again: + +```sh +$ RPC_URL= PAYMENT_TOKEN_ADDRESS= CHUNK_PAYMENTS_ADDRESS= cargo test --package=autonomi --features=local +# Or with logs +$ RUST_LOG=autonomi RPC_URL= PAYMENT_TOKEN_ADDRESS= CHUNK_PAYMENTS_ADDRESS= cargo test --package=autonomi --features=local -- --nocapture +``` + +### Using a live testnet or mainnet + +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-discovery` feature: ```sh -cargo run --bin=safenode-manager --features=local-discovery -- local run --build --clean +cargo run --bin=safenode-manager --features=local-discovery -- local run --build --clean --rewards-address evm-arbitrum-one ``` -Then run the tests with the `local` feature: +2. Then run the tests with the `local` feature. Make sure that the wallet of the private key you pass has enough gas and + payment tokens on the network (in this case Arbitrum One): + ```sh -$ cargo test --package=autonomi --features=local +$ EVM_NETWORK=arbitrum-one PRIVATE_KEY= cargo test --package=autonomi --features=local # Or with logs -$ RUST_LOG=autonomi cargo test --package=autonomi --features=local -- --nocapture +$ RUST_LOG=autonomi EVM_NETWORK=arbitrum-one PRIVATE_KEY= cargo test --package=autonomi --features=local -- --nocapture +``` + +## Faucet (local) + +There is no faucet server, but instead you can use the `Deployer wallet private key` printed in the EVM node output to +initialise a wallet from with almost infinite gas and payment tokens. Example: + +```rust +let rpc_url = "http://localhost:54370/"; +let payment_token_address = "0x5FbDB2315678afecb367f032d93F642f64180aa3"; +let chunk_payments_address = "0x8464135c8F25Da09e49BC8782676a84730C318bC"; +let private_key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"; + +let network = Network::Custom(CustomNetwork::new( +rpc_url, +payment_token_address, +chunk_payments_address, +)); + +let deployer_wallet = Wallet::new_from_private_key(network, private_key).unwrap(); +let receiving_wallet = Wallet::new_with_random_wallet(network); + +// Send 10 payment tokens (atto) +let _ = deployer_wallet +.transfer_tokens(receiving_wallet.address(), Amount::from(10)) +.await; +``` + +Alternatively, you can provide the wallet address that should own all the gas and payment tokens to the EVM testnet +startup command using the `--genesis-wallet` flag: + +```sh +cargo run --bin evm_testnet -- --royalties-wallet --genesis-wallet ``` + +```shell +************************* +* Ethereum node started * +************************* +RPC URL: http://localhost:60093/ +Payment token address: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +Chunk payments address: 0x8464135c8F25Da09e49BC8782676a84730C318bC +Deployer wallet private key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +Genesis wallet balance: (tokens: 20000000000000000000000000, gas: 9998998011366954730202) +``` \ No newline at end of file