From b7f7b4332db69c56ebb1405dddde39ef90618929 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 20 Sep 2023 13:20:49 +0800 Subject: [PATCH] Delete `StorageTrace` from `ChunkProof`. (#964) --- prover/src/lib.rs | 2 +- prover/src/proof/chunk.rs | 6 ---- prover/src/zkevm/circuit.rs | 2 +- prover/src/zkevm/circuit/l1_builder.rs | 8 ++---- prover/src/zkevm/circuit/l2_builder.rs | 39 ++------------------------ prover/src/zkevm/prover.rs | 12 ++------ 6 files changed, 8 insertions(+), 61 deletions(-) diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 9821a51e9a..a398b2cf7e 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -12,7 +12,7 @@ pub mod utils; pub mod zkevm; pub use common::{ChunkHash, CompressionCircuit}; -pub use eth_types::l2_types::{BlockTrace, StorageTrace}; +pub use eth_types::l2_types::BlockTrace; pub use proof::{BatchProof, ChunkProof, EvmProof, Proof}; pub use snark_verifier_sdk::{CircuitExt, Snark}; pub use types::WitnessBlock; diff --git a/prover/src/proof/chunk.rs b/prover/src/proof/chunk.rs index 54d2c5841a..b3ed4f80bf 100644 --- a/prover/src/proof/chunk.rs +++ b/prover/src/proof/chunk.rs @@ -2,7 +2,6 @@ use super::{dump_as_json, dump_data, dump_vk, from_json_file, Proof}; use crate::types::base64; use aggregator::ChunkHash; use anyhow::Result; -use eth_types::l2_types::StorageTrace; use halo2_proofs::{halo2curves::bn256::G1Affine, plonk::ProvingKey}; use serde_derive::{Deserialize, Serialize}; use snark_verifier::Protocol; @@ -10,8 +9,6 @@ use snark_verifier_sdk::Snark; #[derive(Clone, Debug, Default, Deserialize, Serialize)] pub struct ChunkProof { - #[serde(with = "base64")] - pub storage_trace: Vec, #[serde(with = "base64")] pub protocol: Vec, #[serde(flatten)] @@ -23,16 +20,13 @@ pub struct ChunkProof { impl ChunkProof { pub fn new( snark: Snark, - storage_trace: StorageTrace, pk: Option<&ProvingKey>, chunk_hash: Option, ) -> Result { - let storage_trace = serde_json::to_vec(&storage_trace)?; let protocol = serde_json::to_vec(&snark.protocol)?; let proof = Proof::new(snark.proof, &snark.instances, pk); Ok(Self { - storage_trace, protocol, proof, chunk_hash, diff --git a/prover/src/zkevm/circuit.rs b/prover/src/zkevm/circuit.rs index 913134c4ef..9b17b70502 100644 --- a/prover/src/zkevm/circuit.rs +++ b/prover/src/zkevm/circuit.rs @@ -15,7 +15,7 @@ mod super_circuit; pub use self::builder::{ block_traces_to_witness_block, block_traces_to_witness_block_with_updated_state, calculate_row_usage_of_trace, calculate_row_usage_of_witness_block, check_batch_capacity, - get_super_circuit_params, normalize_withdraw_proof, validite_block_traces, + get_super_circuit_params, validite_block_traces, }; pub use super_circuit::SuperCircuit; diff --git a/prover/src/zkevm/circuit/l1_builder.rs b/prover/src/zkevm/circuit/l1_builder.rs index 1484e9bfb5..06bb0714db 100644 --- a/prover/src/zkevm/circuit/l1_builder.rs +++ b/prover/src/zkevm/circuit/l1_builder.rs @@ -1,8 +1,8 @@ use anyhow::Result; use bus_mapping::circuit_input_builder::{CircuitInputBuilder, CircuitsParams}; -use eth_types::l2_types::{BlockTrace, StorageTrace}; +use eth_types::l2_types::BlockTrace; use halo2_proofs::halo2curves::bn256::Fr; -use zkevm_circuits::{evm_circuit::witness::Block, witness::WithdrawProof}; +use zkevm_circuits::evm_circuit::witness::Block; pub fn get_super_circuit_params() -> CircuitsParams { unimplemented!("Must build with feature scroll") @@ -39,7 +39,3 @@ pub fn block_traces_to_witness_block_with_updated_state( ) -> Result> { unimplemented!("Must build with feature scroll") } - -pub fn normalize_withdraw_proof(_proof: &WithdrawProof) -> StorageTrace { - unimplemented!("Must build with feature scroll") -} diff --git a/prover/src/zkevm/circuit/l2_builder.rs b/prover/src/zkevm/circuit/l2_builder.rs index b5a7358659..ab6ab90552 100644 --- a/prover/src/zkevm/circuit/l2_builder.rs +++ b/prover/src/zkevm/circuit/l2_builder.rs @@ -5,19 +5,15 @@ use bus_mapping::{ circuit_input_builder::{self, CircuitInputBuilder, CircuitsParams, PrecompileEcParams}, state_db::{CodeDB, StateDB}, }; -use eth_types::{ - l2_types::{BlockTrace, StorageTrace}, - ToBigEndian, ToWord, H256, -}; +use eth_types::{l2_types::BlockTrace, ToWord, H256}; use halo2_proofs::halo2curves::bn256::Fr; use itertools::Itertools; use mpt_zktrie::state::ZktrieState; use once_cell::sync::Lazy; -use std::{collections::HashMap, time::Instant}; +use std::time::Instant; use zkevm_circuits::{ evm_circuit::witness::{block_apply_mpt_state, block_convert_with_l1_queue_index, Block}, util::SubCircuit, - witness::WithdrawProof, }; static CHAIN_ID: Lazy = Lazy::new(|| read_env_var("CHAIN_ID", 53077)); @@ -353,34 +349,3 @@ pub fn block_traces_to_witness_block_with_updated_state( ); Ok(witness_block) } - -pub fn normalize_withdraw_proof(proof: &WithdrawProof) -> StorageTrace { - let address = *bus_mapping::l2_predeployed::message_queue::ADDRESS; - let key = *bus_mapping::l2_predeployed::message_queue::WITHDRAW_TRIE_ROOT_SLOT; - StorageTrace { - // Not typo! We are preparing `StorageTrace` for the dummy padding chunk - // So `post_state_root` of prev chunk will be `root_before` for new chunk - root_before: H256::from(proof.state_root.to_be_bytes()), - root_after: H256::from(proof.state_root.to_be_bytes()), - proofs: Some(HashMap::from([( - address, - proof - .account_proof - .iter() - .map(|b| b.clone().into()) - .collect(), - )])), - storage_proofs: HashMap::from([( - address, - HashMap::from([( - key, - proof - .storage_proof - .iter() - .map(|b| b.clone().into()) - .collect(), - )]), - )]), - deletion_proofs: Default::default(), - } -} diff --git a/prover/src/zkevm/prover.rs b/prover/src/zkevm/prover.rs index 20a12b58cf..6d634d91ec 100644 --- a/prover/src/zkevm/prover.rs +++ b/prover/src/zkevm/prover.rs @@ -4,7 +4,6 @@ use crate::{ consts::CHUNK_VK_FILENAME, io::try_to_read, utils::chunk_trace_to_witness_block, - zkevm::circuit::normalize_withdraw_proof, ChunkProof, }; use aggregator::ChunkHash; @@ -79,15 +78,8 @@ impl Prover { None => { let chunk_hash = ChunkHash::from_witness_block(&witness_block, false); - let storage_trace = - normalize_withdraw_proof(&witness_block.mpt_updates.withdraw_proof); - - let result = ChunkProof::new( - snark, - storage_trace, - self.inner.pk(LayerId::Layer2.id()), - Some(chunk_hash), - ); + let result = + ChunkProof::new(snark, self.inner.pk(LayerId::Layer2.id()), Some(chunk_hash)); if let (Some(output_dir), Ok(proof)) = (output_dir, &result) { proof.dump(output_dir, &name)?;