diff --git a/Cargo.lock b/Cargo.lock index 913a0907..6d07f494 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2423,6 +2423,7 @@ dependencies = [ "mock", "rand", "rand_xorshift", + "rlp", "serde", "serde_json", "snark-verifier", diff --git a/prover/Cargo.toml b/prover/Cargo.toml index d4f8119a..ce5cfa5f 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -31,6 +31,7 @@ zkevm_common = { path = "../common" } itertools = "0.10.3" clap = { version = "4.0.14", features = ["derive", "env"] } hex = "0.4.3" +rlp = "0.5.2" # autogen mock = { git = "https://github.com/taikoxyz/zkevm-circuits.git", branch = "taiko-pi-test", optional = true } diff --git a/prover/src/circuit_witness.rs b/prover/src/circuit_witness.rs index ed4dafde..c7b1048c 100644 --- a/prover/src/circuit_witness.rs +++ b/prover/src/circuit_witness.rs @@ -11,6 +11,7 @@ use eth_types::H256; use eth_types::{geth_types, Bytes}; use ethers_providers::Http; use halo2_proofs::halo2curves::bn256::Fr; +use rlp::Rlp; use std::str::FromStr; use zkevm_circuits::evm_circuit; use zkevm_circuits::pi_circuit::PublicData; @@ -23,6 +24,7 @@ pub struct CircuitWitness { pub block: bus_mapping::circuit_input_builder::Block, pub code_db: bus_mapping::state_db::CodeDB, pub txs_rlp: Bytes, + pub l1_txs: Vec, } impl CircuitWitness { @@ -61,6 +63,7 @@ impl CircuitWitness { block: builder.block, code_db: builder.code_db, txs_rlp: Bytes::default(), + l1_txs: vec![], }) } @@ -78,6 +81,7 @@ impl CircuitWitness { &hex::decode(propose_tx_hash).expect("parse propose tx hash"), ); let txs_rlp = get_txs_rlp(&l1_geth_client, propose_tx_hash).await?; + let l1_txs = Rlp::new(&txs_rlp).as_list().expect("invalid txs rlp"); let l2_url = Http::from_str(l2_rpc_url)?; let l2_geth_client = GethClient::new(l2_url); @@ -85,14 +89,13 @@ impl CircuitWitness { let block = l2_geth_client .get_block_by_number((*block_num).into()) .await?; - let circuit_config = - crate::match_circuit_params_txs!(block.transactions.len(), CIRCUIT_CONFIG, { - return Err(format!( - "No circuit parameters found for block with gas used={}", - block.gas_used - ) - .into()); - }); + let circuit_config = crate::match_circuit_params_txs!(l1_txs.len(), CIRCUIT_CONFIG, { + return Err(format!( + "No circuit parameters found for block with gas used={}", + block.gas_used + ) + .into()); + }); let circuit_params = CircuitsParams { max_txs: circuit_config.max_txs, max_calldata: circuit_config.max_calldata, @@ -109,6 +112,7 @@ impl CircuitWitness { block: builder.block, code_db: builder.code_db, txs_rlp, + l1_txs, }) } diff --git a/prover/src/server.rs b/prover/src/server.rs index 92579bed..d8041625 100644 --- a/prover/src/server.rs +++ b/prover/src/server.rs @@ -195,7 +195,7 @@ async fn handle_method( .map_err(|e| e.to_string())?; let circuit_config = - crate::match_circuit_params!(witness.gas_used(), CIRCUIT_CONFIG, { + crate::match_circuit_params_txs!(witness.l1_txs.len(), CIRCUIT_CONFIG, { return Err(format!( "No circuit parameters found for block with gas={}", witness.gas_used() diff --git a/prover/src/shared_state.rs b/prover/src/shared_state.rs index 650c19f5..0b6142c0 100644 --- a/prover/src/shared_state.rs +++ b/prover/src/shared_state.rs @@ -425,7 +425,7 @@ impl SharedState { .map_err(|e| e.to_string())?; let (config, circuit_proof, aggregation_proof) = crate::match_circuit_params_txs!( - witness.txs().len(), + witness.l1_txs.len(), { match task_options_copy.circuit.as_str() { "pi" => {