Skip to content

Commit 86158b5

Browse files
committed
add sanity checks between infra/circuits
1 parent 9f8a697 commit 86158b5

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

prover/src/aggregator/prover.rs

+34-6
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,44 @@ impl Prover {
146146

147147
// Load or generate aggregation snark (layer-3).
148148
let batch_header = BatchHeader::construct_from_chunks(
149-
batch.version,
150-
batch.batch_index,
151-
batch.l1_message_popped,
152-
batch.total_l1_message_popped,
153-
batch.parent_batch_hash,
154-
batch.last_block_timestamp,
149+
batch.batch_header.version,
150+
batch.batch_header.batch_index,
151+
batch.batch_header.l1_message_popped,
152+
batch.batch_header.total_l1_message_popped,
153+
batch.batch_header.parent_batch_hash,
154+
batch.batch_header.last_block_timestamp,
155155
&chunk_hashes,
156156
);
157+
158+
// sanity check between:
159+
// - BatchHeader supplied from infra
160+
// - BatchHeader re-constructed by circuits
161+
//
162+
// for the fields data_hash, z, y, blob_versioned_hash.
163+
assert_eq!(
164+
batch_header.data_hash, batch.batch_header.data_hash,
165+
"BatchHeader(sanity) mismatch data_hash expected={}, got={}",
166+
batch.batch_header.data_hash, batch_header.data_hash
167+
);
168+
assert_eq!(
169+
batch_header.blob_data_proof[0], batch.batch_header.blob_data_proof[0],
170+
"BatchHeader(sanity) mismatch blob data proof (z) expected={}, got={}",
171+
batch.batch_header.blob_data_proof[0], batch_header.blob_data_proof[0],
172+
);
173+
assert_eq!(
174+
batch_header.blob_data_proof[1], batch.batch_header.blob_data_proof[1],
175+
"BatchHeader(sanity) mismatch blob data proof (y) expected={}, got={}",
176+
batch.batch_header.blob_data_proof[1], batch_header.blob_data_proof[1],
177+
);
178+
assert_eq!(
179+
batch_header.blob_versioned_hash, batch.batch_header.blob_versioned_hash,
180+
"BatchHeader(sanity) mismatch blob versioned hash expected={}, got={}",
181+
batch.batch_header.blob_versioned_hash, batch_header.blob_versioned_hash,
182+
);
183+
157184
let batch_hash = batch_header.batch_hash();
158185
let batch_info: BatchHash<N_SNARKS> = BatchHash::construct(&chunk_hashes, batch_header);
186+
159187
let layer3_snark = self.prover_impl.load_or_gen_agg_snark(
160188
name,
161189
LayerId::Layer3.id(),

prover/src/types.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use aggregator::ChunkInfo;
2-
use eth_types::{l2_types::BlockTrace, H256};
1+
use aggregator::{BatchHeader, ChunkInfo, MAX_AGG_SNARKS};
2+
use eth_types::l2_types::BlockTrace;
33
use serde::{Deserialize, Serialize};
44
use zkevm_circuits::evm_circuit::witness::Block;
55

@@ -43,13 +43,8 @@ impl ChunkProvingTask {
4343

4444
#[derive(Debug, Clone, Deserialize, Serialize)]
4545
pub struct BatchProvingTask {
46-
pub version: u8,
47-
pub batch_index: u64,
48-
pub l1_message_popped: u64,
49-
pub total_l1_message_popped: u64,
50-
pub parent_batch_hash: H256,
51-
pub last_block_timestamp: u64,
5246
pub chunk_proofs: Vec<ChunkProof>,
47+
pub batch_header: BatchHeader<MAX_AGG_SNARKS>,
5348
}
5449

5550
impl BatchProvingTask {

0 commit comments

Comments
 (0)