From 7a2d98b4254d76fa1b12bc1bae049be60a37aab6 Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Mon, 18 Nov 2024 16:44:56 +0530 Subject: [PATCH 1/2] add zeth support in rpc type --- zero/src/rpc/mod.rs | 5 +++++ zero/src/rpc/zeth.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 zero/src/rpc/zeth.rs diff --git a/zero/src/rpc/mod.rs b/zero/src/rpc/mod.rs index b972bc501..0c3af3f1d 100644 --- a/zero/src/rpc/mod.rs +++ b/zero/src/rpc/mod.rs @@ -25,6 +25,7 @@ use crate::prover::BlockProverInput; pub mod jerigon; pub mod native; pub mod retry; +pub mod zeth; use crate::provider::CachedProvider; @@ -37,6 +38,7 @@ const PREVIOUS_HASHES_COUNT: usize = 256; pub enum RpcType { Jerigon, Native, + Zeth, } /// Obtain the prover input for one block @@ -56,6 +58,9 @@ where RpcType::Native => { native::block_prover_input(cached_provider, block_id, checkpoint_block_number).await } + RpcType::Zeth => { + zeth::block_prover_input(cached_provider, block_id, checkpoint_block_number).await + } } } diff --git a/zero/src/rpc/zeth.rs b/zero/src/rpc/zeth.rs new file mode 100644 index 000000000..5a8e10f42 --- /dev/null +++ b/zero/src/rpc/zeth.rs @@ -0,0 +1,45 @@ +use alloy::{providers::Provider, rpc::types::eth::BlockId, transports::Transport}; +use serde::Deserialize; +use trace_decoder::{BlockTrace, TxnInfo}; + +use super::fetch_other_block_data; +use crate::prover::BlockProverInput; +use crate::provider::CachedProvider; + +/// Transaction traces retrieved from Erigon zeroTracer. +#[derive(Debug, Deserialize)] +pub struct ZeroTxResult { + #[serde(rename(deserialize = "txHash"))] + pub tx_hash: alloy::primitives::TxHash, + pub result: TxnInfo, +} + +pub async fn block_prover_input( + cached_provider: std::sync::Arc>, + target_block_id: BlockId, + checkpoint_block_number: u64, +) -> anyhow::Result +where + ProviderT: Provider, + TransportT: Transport + Clone, +{ + let block_number = match target_block_id { + BlockId::Number(block_number) => block_number, + _ => return Err(anyhow::anyhow!("block number expected")), + }; + + let block_trace = cached_provider + .get_provider() + .await? + .raw_request::<_, BlockTrace>("zero_getBlockTraceByNumber".into(), vec![block_number]) + .await?; + + let other_data = + fetch_other_block_data(cached_provider, target_block_id, checkpoint_block_number).await?; + println!("block_prover_input: {:?}", block_trace); + // Assemble + Ok(BlockProverInput { + block_trace, + other_data, + }) +} From cce32b17181dddbe6e77612d7afea636f079d1a5 Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Mon, 18 Nov 2024 21:34:58 +0530 Subject: [PATCH 2/2] add ci --- .github/workflows/zeth-integration.yml | 60 ++++++++++++++++++++++++++ zero/src/rpc/zeth.rs | 14 +----- 2 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/zeth-integration.yml diff --git a/.github/workflows/zeth-integration.yml b/.github/workflows/zeth-integration.yml new file mode 100644 index 000000000..f5e2f947a --- /dev/null +++ b/.github/workflows/zeth-integration.yml @@ -0,0 +1,60 @@ +--- +# Zeth Integration + +name: Zeth Integration + +on: + push: + branches: [develop, main] + pull_request: + branches: + - "**" + workflow_dispatch: + branches: + - "**" + +env: + CARGO_TERM_COLOR: always + +jobs: + zeth_integration: + name: Zeth Integration + runs-on: zero-ci + timeout-minutes: 30 + steps: + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - name: Clone Repositories + uses: actions/checkout@v4 + with: + repository: 0xPolygonZero/zeth + ref: "arpit/1" + path: zeth + + - name: Run zeth network + run: | + cd zeth + touch polygon-zero.db + cargo run -- node --dev --http.api all & + # TODO - @temaniarpit27 - This is a hack to wait for the network to start + echo "Zeth network started, Sleeping for sometime to let the network start" + sleep 120 + + - name: Generate txn + run: | + cast send --async --legacy \ + --from "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" \ + --private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \ + --rpc-url http://localhost:8545 --gas-limit 100000 --value 1 "0x852DA15b70a3e197d1D668a9a481B1F4c2168a5D" + + - name: Checkout + uses: actions/checkout@v4 + with: + path: zk_evm + + - name: Run prove blocks with zero tracer in test_only mode + run: | + cd zk_evm + OUTPUT_TO_TERMINAL=true ./scripts/prove_rpc.sh 1 1 http://localhost:8545 zeth 0 3000 100 test_only + echo "Proving blocks in test_only mode finished" diff --git a/zero/src/rpc/zeth.rs b/zero/src/rpc/zeth.rs index 5a8e10f42..c4760d98a 100644 --- a/zero/src/rpc/zeth.rs +++ b/zero/src/rpc/zeth.rs @@ -1,19 +1,10 @@ use alloy::{providers::Provider, rpc::types::eth::BlockId, transports::Transport}; -use serde::Deserialize; -use trace_decoder::{BlockTrace, TxnInfo}; +use trace_decoder::BlockTrace; use super::fetch_other_block_data; use crate::prover::BlockProverInput; use crate::provider::CachedProvider; -/// Transaction traces retrieved from Erigon zeroTracer. -#[derive(Debug, Deserialize)] -pub struct ZeroTxResult { - #[serde(rename(deserialize = "txHash"))] - pub tx_hash: alloy::primitives::TxHash, - pub result: TxnInfo, -} - pub async fn block_prover_input( cached_provider: std::sync::Arc>, target_block_id: BlockId, @@ -36,8 +27,7 @@ where let other_data = fetch_other_block_data(cached_provider, target_block_id, checkpoint_block_number).await?; - println!("block_prover_input: {:?}", block_trace); - // Assemble + Ok(BlockProverInput { block_trace, other_data,