From 879892f15cb6c7a4c86fe5199808269874a76d2b Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Fri, 9 Aug 2024 13:33:17 +0530 Subject: [PATCH 1/4] handle case when contract creation was reverted --- .github/workflows/jerigon-native.yml | 35 ++++++++++++---------------- zero_bin/rpc/src/native/txn.rs | 19 ++++++++++++++- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/jerigon-native.yml b/.github/workflows/jerigon-native.yml index 8755c3187..78097c062 100644 --- a/.github/workflows/jerigon-native.yml +++ b/.github/workflows/jerigon-native.yml @@ -10,7 +10,6 @@ on: branches: - "**" - env: CARGO_TERM_COLOR: always REGISTRY: ghcr.io @@ -26,24 +25,24 @@ jobs: uses: actions/checkout@v4 - name: Checkout test-jerigon-network sources - uses: actions/checkout@v4 + uses: actions/checkout@v4 with: repository: 0xPolygonZero/jerigon-test-network - ref: 'feat/kurtosis-network' + ref: "feat/kurtosis-network" path: jerigon-test-network - name: Install nightly toolchain uses: dtolnay/rust-toolchain@nightly - + - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up rust cache uses: Swatinem/rust-cache@v2 @@ -58,41 +57,37 @@ jobs: #It is much easier to use cast tool in scripts so install foundry - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 + uses: foundry-rs/foundry-toolchain@v1 - name: Run cancun test network run: | docker pull ghcr.io/0xpolygonzero/erigon:feat-zero - kurtosis run --enclave cancun-testnet github.com/ethpandaops/ethereum-package@4.0.0 --args-file jerigon-test-network/network_params.yml + kurtosis run --enclave cancun-testnet github.com/ethpandaops/ethereum-package@4.0.0 --args-file jerigon-test-network/network_params.yml - name: Generate blocks with transactions run: | - ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" - cast rpc eth_blockNumber --rpc-url $ETH_RPC_URL - cd jerigon-test-network && set -a && source .env && set +a - bash ./tests/generate_transactions.sh - + ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" + cast rpc eth_blockNumber --rpc-url $ETH_RPC_URL + cd jerigon-test-network && set -a && source .env && set +a + bash ./tests/generate_transactions.sh + - name: Run prove blocks with native tracer in test_only mode run: | ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" cd zero_bin/tools ulimit -n 8192 - OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x5 0xf $ETH_RPC_URL native true 3000 100 test_only + OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x1 0xf $ETH_RPC_URL native true 3000 100 test_only echo "Proving blocks in test_only mode finished" - - name: Run prove blocks with native tracer in real mode run: | ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" cd zero_bin/tools rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out - OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x5 0x7 $ETH_RPC_URL native true 3000 100 + OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x1 0xf $ETH_RPC_URL native true 3000 100 echo "Proving blocks in real mode finished" - + - name: Shut down network run: | kurtosis enclave rm -f cancun-testnet kurtosis engine stop - - - diff --git a/zero_bin/rpc/src/native/txn.rs b/zero_bin/rpc/src/native/txn.rs index 7c3018f4d..4a31df819 100644 --- a/zero_bin/rpc/src/native/txn.rs +++ b/zero_bin/rpc/src/native/txn.rs @@ -64,6 +64,9 @@ where TransportT: Transport + Clone, { let (tx_receipt, pre_trace, diff_trace) = fetch_tx_data(provider, &tx.hash).await?; + + let tx_status = tx_receipt.status(); + let tx_receipt = tx_receipt.map_inner(rlp::map_receipt_envelope); let access_list = parse_access_list(tx.access_list.as_ref()); @@ -74,7 +77,7 @@ where gas_used: tx_receipt.gas_used as u64, }; - let (code_db, tx_traces) = match (pre_trace, diff_trace) { + let (code_db, mut tx_traces) = match (pre_trace, diff_trace) { ( GethTrace::PreStateTracer(PreStateFrame::Default(read)), GethTrace::PreStateTracer(PreStateFrame::Diff(diff)), @@ -82,6 +85,20 @@ where _ => unreachable!(), }; + // Handle case when transaction failed and a contract creation was reverted + if !tx_status && tx_receipt.contract_address.is_some() { + tx_traces.insert( + tx_receipt.contract_address.unwrap(), + TxnTrace { + balance: None, + nonce: None, + storage_read: None, + storage_written: None, + code_usage: None, + }, + ); + } + Ok(( code_db, TxnInfo { From 36e78f8f4f876c5d440f4f402faac4194ae811e2 Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Wed, 14 Aug 2024 15:08:59 +0530 Subject: [PATCH 2/4] fix review comments --- .github/workflows/jerigon-native.yml | 2 +- zero_bin/rpc/src/native/txn.rs | 2 -- zero_bin/tools/witness_native_1.json | 0 3 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 zero_bin/tools/witness_native_1.json diff --git a/.github/workflows/jerigon-native.yml b/.github/workflows/jerigon-native.yml index 78097c062..6c5967278 100644 --- a/.github/workflows/jerigon-native.yml +++ b/.github/workflows/jerigon-native.yml @@ -84,7 +84,7 @@ jobs: ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" cd zero_bin/tools rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out - OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x1 0xf $ETH_RPC_URL native true 3000 100 + OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x4 0x7 $ETH_RPC_URL native true 3000 100 echo "Proving blocks in real mode finished" - name: Shut down network diff --git a/zero_bin/rpc/src/native/txn.rs b/zero_bin/rpc/src/native/txn.rs index 4a31df819..90e57a988 100644 --- a/zero_bin/rpc/src/native/txn.rs +++ b/zero_bin/rpc/src/native/txn.rs @@ -64,9 +64,7 @@ where TransportT: Transport + Clone, { let (tx_receipt, pre_trace, diff_trace) = fetch_tx_data(provider, &tx.hash).await?; - let tx_status = tx_receipt.status(); - let tx_receipt = tx_receipt.map_inner(rlp::map_receipt_envelope); let access_list = parse_access_list(tx.access_list.as_ref()); diff --git a/zero_bin/tools/witness_native_1.json b/zero_bin/tools/witness_native_1.json new file mode 100644 index 000000000..e69de29bb From 0f6698a849c6583a82200e9659cb7f3be9728be3 Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Wed, 14 Aug 2024 15:26:23 +0530 Subject: [PATCH 3/4] Delete zero_bin/tools/witness_native_1.json --- zero_bin/tools/witness_native_1.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 zero_bin/tools/witness_native_1.json diff --git a/zero_bin/tools/witness_native_1.json b/zero_bin/tools/witness_native_1.json deleted file mode 100644 index e69de29bb..000000000 From 045878f0cb02b89c844105d69eeff693410e7e64 Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Thu, 15 Aug 2024 09:56:56 +0530 Subject: [PATCH 4/4] fix TxnTrace fedault --- trace_decoder/src/lib.rs | 2 +- zero_bin/rpc/src/native/txn.rs | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/trace_decoder/src/lib.rs b/trace_decoder/src/lib.rs index 42b83a69d..c1e6249e1 100644 --- a/trace_decoder/src/lib.rs +++ b/trace_decoder/src/lib.rs @@ -215,7 +215,7 @@ pub struct TxnMeta { /// /// Specifically, since we can not execute the txn before proof generation, we /// rely on a separate EVM to run the txn and supply this data for us. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, Default)] pub struct TxnTrace { /// If the balance changed, then the new balance will appear here. Will be /// `None` if no change. diff --git a/zero_bin/rpc/src/native/txn.rs b/zero_bin/rpc/src/native/txn.rs index 90e57a988..4e005e953 100644 --- a/zero_bin/rpc/src/native/txn.rs +++ b/zero_bin/rpc/src/native/txn.rs @@ -85,16 +85,7 @@ where // Handle case when transaction failed and a contract creation was reverted if !tx_status && tx_receipt.contract_address.is_some() { - tx_traces.insert( - tx_receipt.contract_address.unwrap(), - TxnTrace { - balance: None, - nonce: None, - storage_read: None, - storage_written: None, - code_usage: None, - }, - ); + tx_traces.insert(tx_receipt.contract_address.unwrap(), TxnTrace::default()); } Ok((