diff --git a/.env.local b/.env.local index 420cf24..ea8e043 100644 --- a/.env.local +++ b/.env.local @@ -1,7 +1,8 @@ -ROLLUP_HTTP_SERVER_URL=http://127.0.0.1:8080/host-runner +ROLLUP_HTTP_SERVER_URL=http://127.0.0.1:8080/graphql GRPC_SERVER_URL="[::1]:50051" ETH_RPC_URL="http://127.0.0.1:8545" ETH_CHAIN_ID=31337 SIGNER_PK="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" INPUTBOX_CONTRACT_ADDRESS="0x59b22D57D4f067708AB0c00552767405926dc768" +ETH_DEPOSIT_ADDR="0xFfdbe43d4c855BF7e0f105c400A50857f53AB044" DAPP_ADDRESS="0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e" diff --git a/README.md b/README.md index bda8f3f..9766dd1 100644 --- a/README.md +++ b/README.md @@ -168,20 +168,25 @@ This cross-compiles for risvc using docker. ### Setup -#### Terminal 1 - Rollup Node - -##### Local Mode +#### Option 1 - Local Mode This runs CarteZcash locally rather than inside the Cartesi machine. This is a bit faster and easier to debug. Start the Sunodo services (Anvil, cartesi node, subsquid, etc) with: ```shell -run-nobackend # or cartesi run --no-backend +just run-nobackend # or cartesi run --no-backend +``` + +in another shell run the dApp in local mode + +```shell just run-local ``` -##### Cartesi Machine Mode +This command runs the program in fullnode mode so there is no need to run another process. + +#### Option 1 - Cartesi Machine Mode If you want to see it running in the Cartesi machine for real then build and run with @@ -190,17 +195,17 @@ cartesi build cartesi run ``` -#### Terminal 2 - Proxy +We also need to run a fullnode process. The full node is required to cache blockchain state and serve data to wallets. -Start the proxy with service with +In another shell start the fullnode with service with: ```shell -just run-proxy +just run-fullnode ``` This is set up to work correctly with the default cartesi configuration of addresses and ports -#### Terminal 3 - Wallet +#### Terminal 2 - Wallet Install and start a Zingo CLI wallet based off the Cartezcash fork with: @@ -221,7 +226,12 @@ just start-wallet-2 #### Deposit into L2 -First lets deposit some 1 Eth from the L1 anvil testnet into the L2. To do this get the hex encoded transparent address of the wallet by running `addresses` in zingo-wallet +First lets deposit some 1 Eth from the L1 anvil testnet into the L2. To do this get the hex encoded transparent address of the wallet by running + +```shell +>> addresses +``` +in zingo-wallet which should respond with something like: ``` (mainnet) Block:0 (type 'help') >> addresses @@ -258,7 +268,7 @@ You should see the transparent balance update! #### Shield funds -Now to shield these funds so they are private. From the Wallet CLI run +Now to shield these funds so they are private. From the Zingo Wallet CLI run ```shell >> shield all diff --git a/fly.fullnode.toml b/fly.fullnode.toml index 91aaa5e..be21e89 100644 --- a/fly.fullnode.toml +++ b/fly.fullnode.toml @@ -25,3 +25,4 @@ ETH_CHAIN_ID="11155111" INPUTBOX_CONTRACT_ADDRESS="0x59b22D57D4f067708AB0c00552767405926dc768" ETH_RPC_URL="https://eth-sepolia.g.alchemy.com/v2/demo" DAPP_ADDRESS = "0x589DAc2C23C2bc1b60112eD66049ECba90e7AD3e" +ETH_DEPOSIT_ADDR="0xFfdbe43d4c855BF7e0f105c400A50857f53AB044" diff --git a/justfile b/justfile index 5d5aa35..d8c5c8b 100644 --- a/justfile +++ b/justfile @@ -51,6 +51,9 @@ start-wallet: restart-wallet: zingo-cli --data-dir ./walletdata --server localhost:50051 +start-wallet-testnet: + zingo-cli --server https://cartezcash-fullnode.fly.dev:443 --birthday 0 + start-wallet-2: zingo-cli --data-dir ./walletdata2 --server localhost:50051 --from "february day pink knee nut struggle poem silver hawk voice stay rule food cabbage eight phrase parent spider forget laundry wagon dwarf improve flee" --birthday 0 restart-wallet-2: diff --git a/src/main.rs b/src/main.rs index d2d7acd..bc89ab1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,8 @@ use tower_cartesi::{Request as RollAppRequest, Response}; use futures_util::future::FutureExt; +const DAPP_RELAY_CONTRACT_ADDRESS: &str = "f5de34d6bbc0446e2a45719e718efebaae179dae"; + #[cfg(feature = "lightwalletd")] use cartezcash_lightwalletd::{ proto::service::compact_tx_streamer_server::CompactTxStreamerServer, @@ -146,8 +148,12 @@ impl Service for CarteZcashApp { fn call(&mut self, req: RollAppRequest) -> Self::Future { match req { RollAppRequest::AdvanceState { metadata, payload } => { - // if the payload is 20 bytes, it is the dapp address. Handle it then exit early - if payload.len() == 20 { + // if sent by this address the message is relaying the dApp address. Handle accordingly + if metadata.msg_sender + == ethereum_types::Address::from_slice( + &hex::decode(DAPP_RELAY_CONTRACT_ADDRESS).unwrap(), + ) + { let dapp_address = ethereum_types::Address::from_slice(&payload); tracing::info!("Received dapp address: {:?}", dapp_address); self.dapp_address = Some(dapp_address); diff --git a/wallets/zingo-wallet.dat b/wallets/zingo-wallet.dat new file mode 100644 index 0000000..bc53f31 Binary files /dev/null and b/wallets/zingo-wallet.dat differ