Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prover): delete StorageTrace from ChunkProof #964

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 0 additions & 6 deletions prover/src/proof/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ 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;
use snark_verifier_sdk::Snark;

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct ChunkProof {
#[serde(with = "base64")]
pub storage_trace: Vec<u8>,
#[serde(with = "base64")]
pub protocol: Vec<u8>,
#[serde(flatten)]
Expand All @@ -23,16 +20,13 @@ pub struct ChunkProof {
impl ChunkProof {
pub fn new(
snark: Snark,
storage_trace: StorageTrace,
pk: Option<&ProvingKey<G1Affine>>,
chunk_hash: Option<ChunkHash>,
) -> Result<Self> {
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,
Expand Down
2 changes: 1 addition & 1 deletion prover/src/zkevm/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 2 additions & 6 deletions prover/src/zkevm/circuit/l1_builder.rs
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -39,7 +39,3 @@ pub fn block_traces_to_witness_block_with_updated_state(
) -> Result<Block<Fr>> {
unimplemented!("Must build with feature scroll")
}

pub fn normalize_withdraw_proof(_proof: &WithdrawProof) -> StorageTrace {
unimplemented!("Must build with feature scroll")
}
39 changes: 2 additions & 37 deletions prover/src/zkevm/circuit/l2_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64> = Lazy::new(|| read_env_var("CHAIN_ID", 53077));
Expand Down Expand Up @@ -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(),
}
}
12 changes: 2 additions & 10 deletions prover/src/zkevm/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)?;
Expand Down