Skip to content

Commit 5640663

Browse files
committed
fix building
1 parent 3414b2e commit 5640663

File tree

14 files changed

+55
-183
lines changed

14 files changed

+55
-183
lines changed

aggregator/src/blob_consistency.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ mod eip4844;
1919
cfg_if! {
2020
if #[cfg(feature = "da-avail")] {
2121
// const DATA_AVAILABILITY: DataAvailability = DataAvailability::Avail;
22-
pub use avail::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH};
22+
pub use avail::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH, get_blob_bytes};
2323
} else {
2424
// const DATA_AVAILABILITY: DatayAvailability = DataAvailability::Eip4844;
25-
pub use eip4844::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH};
25+
pub use eip4844::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH, get_blob_bytes};
2626
}
2727
}

aggregator/src/blob_consistency/avail.rs

+5
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,8 @@ pub struct AssignedBarycentricEvaluationConfig {
9898
/// 32 Assigned cells representing the LE-bytes of evaluation y.
9999
pub(crate) y_le: Vec<AssignedValue<Fr>>,
100100
}
101+
102+
/// Get the blob data bytes that will be populated in BlobDataConfig.
103+
pub fn get_blob_bytes(_batch_bytes: &[u8]) -> Vec<u8> {
104+
unimplemented!("trick for linting");
105+
}

aggregator/src/blob_consistency/eip4844.rs

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ fn kzg_to_versioned_hash(commitment: &c_kzg::KzgCommitment) -> H256 {
8484
H256::from_slice(&res[..])
8585
}
8686

87-
#[cfg(test)]
8887
/// Get the blob data bytes that will be populated in BlobDataConfig.
8988
pub fn get_blob_bytes(batch_bytes: &[u8]) -> Vec<u8> {
9089
let mut blob_bytes = crate::witgen::zstd_encode(batch_bytes);

aggregator/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ mod tests;
2727
pub use self::core::extract_proof_and_instances_with_pairing_check;
2828
pub use aggregation::*;
2929
pub use batch::{BatchHash, BatchHeader};
30+
pub use blob_consistency::get_blob_bytes;
3031
pub use chunk::ChunkInfo;
3132
pub use compression::*;
3233
pub use constants::MAX_AGG_SNARKS;

prover/src/aggregator/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod verifier;
1111
pub use verifier::Verifier;
1212

1313
/// Re-export some types from the [`aggregator`] crate.
14-
pub use aggregator::{BatchData, BatchHash, BatchHeader, MAX_AGG_SNARKS};
14+
pub use aggregator::{get_blob_bytes, BatchData, BatchHash, BatchHeader, MAX_AGG_SNARKS};
1515

1616
/// Alias for convenience.
1717
pub type BatchProver<'a> = Prover<'a>;

prover/src/aggregator/prover.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
types::BundleProvingTask,
1717
utils::{force_to_read, try_to_read},
1818
BatchProofV2, BatchProofV2Metadata, BatchProvingTask, BundleProofV2, ChunkKind, ChunkProof,
19-
ParamsMap, ProverError,
19+
ChunkProofV2, ParamsMap, ProverError,
2020
};
2121

2222
/// Prover capable of generating [`BatchProof`] and [`BundleProof`].
@@ -197,8 +197,8 @@ impl<'params> Prover<'params> {
197197
let bundle_snarks = bundle
198198
.batch_proofs
199199
.iter()
200-
.map(|proof| proof.into())
201-
.collect::<Vec<_>>();
200+
.map(Snark::try_from)
201+
.collect::<Result<Vec<Snark>, _>>()?;
202202

203203
// Load from disk or generate a layer-5 Recursive Circuit SNARK.
204204
let layer5_snark = self
@@ -266,11 +266,16 @@ impl<'params> Prover<'params> {
266266
self.check_protocol_of_chunks(&batch.chunk_proofs)?;
267267

268268
// Split chunk info and snarks from the batch proving task.
269-
let (mut chunk_infos, mut layer2_snarks): (Vec<_>, Vec<_>) = batch
269+
let mut chunk_infos = batch
270+
.chunk_proofs
271+
.iter()
272+
.map(|proof| proof.inner.chunk_info().clone())
273+
.collect::<Vec<_>>();
274+
let mut layer2_snarks = batch
270275
.chunk_proofs
271276
.iter()
272-
.map(|proof| (proof.chunk_info.clone(), proof.to_snark()))
273-
.unzip();
277+
.map(Snark::try_from)
278+
.collect::<Result<Vec<Snark>, ProverError>>()?;
274279

275280
// Pad the SNARKs with the last SNARK until we have MAX_AGG_SNARKS number of SNARKs.
276281
if num_chunks < MAX_AGG_SNARKS {
@@ -372,15 +377,15 @@ impl<'params> Prover<'params> {
372377
/// Sanity check: validate that the SNARK [`protocol`][snark_verifier::Protocol] for the SNARKs
373378
/// being aggregated by the [`BatchCircuit`][aggregator::BatchCircuit] match the expected SNARK
374379
/// protocols conditional to the chunk proof generation route utilised, i.e. halo2 or sp1.
375-
fn check_protocol_of_chunks(&self, chunk_proofs: &[ChunkProof]) -> Result<(), ProverError> {
380+
fn check_protocol_of_chunks(&self, chunk_proofs: &[ChunkProofV2]) -> Result<(), ProverError> {
376381
for (i, proof) in chunk_proofs.iter().enumerate() {
377-
let expected = match proof.chunk_kind {
382+
let expected = match proof.inner.chunk_kind() {
378383
ChunkKind::Halo2 => &self.halo2_protocol,
379384
ChunkKind::Sp1 => &self.sp1_protocol,
380385
};
381-
if proof.protocol.ne(expected) {
386+
if proof.inner.protocol().ne(expected) {
382387
let expected_digest = format!("{:x}", Sha256::digest(expected));
383-
let found_digest = format!("{:x}", Sha256::digest(&proof.protocol));
388+
let found_digest = format!("{:x}", Sha256::digest(proof.inner.protocol()));
384389
log::error!(
385390
"BatchProver: SNARK protocol mismatch! index={}, expected={}, found={}",
386391
i,

prover/src/inner/mod.rs

-5
This file was deleted.

prover/src/inner/prover/mock.rs

-43
This file was deleted.

prover/src/inner/prover/mod.rs

-70
This file was deleted.

prover/src/inner/verifier.rs

-42
This file was deleted.

prover/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
4040
mod aggregator;
4141
pub use aggregator::{
42-
check_chunk_hashes, BatchData, BatchHash, BatchHeader, BatchProver, BatchProverError,
43-
BatchVerifier, RecursionTask, MAX_AGG_SNARKS,
42+
check_chunk_hashes, get_blob_bytes, BatchData, BatchHash, BatchHeader, BatchProver,
43+
BatchProverError, BatchVerifier, RecursionTask, MAX_AGG_SNARKS,
4444
};
4545

4646
mod common;
@@ -68,7 +68,11 @@ mod utils;
6868
pub use utils::*;
6969

7070
mod zkevm;
71-
pub use zkevm::{ChunkProver, ChunkProverError, ChunkVerifier, CircuitCapacityChecker};
71+
pub use zkevm::{
72+
circuit::calculate_row_usage_of_witness_block, circuit::chunk_trace_to_witness_block,
73+
ChunkProver, ChunkProverError, ChunkVerifier, CircuitCapacityChecker, RowUsage,
74+
SubCircuitRowUsage,
75+
};
7276

7377
/// Re-export the eth-types crate.
7478
pub use eth_types;

prover/src/proof/chunk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{utils::read_json_deep, zkevm::SubCircuitRowUsage};
1212
use super::{dump_as_json, dump_data, dump_vk, InnerProof};
1313

1414
/// The innermost SNARK belongs to the following variants.
15-
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
15+
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
1616
pub enum ChunkKind {
1717
/// halo2-based SuperCircuit.
1818
Halo2,

prover/src/proof/proof_v2.rs

+12
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ impl ChunkProofV2Metadata {
265265
row_usage,
266266
})
267267
}
268+
/// Get the chunk info embedded
269+
pub fn chunk_info(&self) -> &ChunkInfo {
270+
&self.chunk_info
271+
}
272+
/// Get the chunk kind
273+
pub fn chunk_kind(&self) -> ChunkKind {
274+
self.chunk_kind
275+
}
276+
/// Get the chunk protocol
277+
pub fn protocol(&self) -> &Vec<u8> {
278+
&self.protocol
279+
}
268280
}
269281

270282
impl Proof for ChunkProofV2Metadata {

prover/src/types.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use eth_types::{base64, l2_types::BlockTrace};
33
use serde::{Deserialize, Serialize};
44
use zkevm_circuits::evm_circuit::witness::Block;
55

6-
use crate::{BatchProof, ChunkProof};
6+
use crate::{BatchProofV2, ChunkProofV2};
77

88
/// Alias for convenience.
99
pub type WitnessBlock = Block;
@@ -63,7 +63,7 @@ impl ChunkProvingTask {
6363
#[derive(Debug, Clone, Deserialize, Serialize)]
6464
pub struct BatchProvingTask {
6565
/// Chunk proofs for the contiguous list of chunks within the batch.
66-
pub chunk_proofs: Vec<ChunkProof>,
66+
pub chunk_proofs: Vec<ChunkProofV2>,
6767
/// The [`BatchHeader`], as computed on-chain for this batch.
6868
///
6969
/// Ref: https://github.com/scroll-tech/scroll-contracts/blob/2ac4f3f7e090d7127db4b13b3627cb3ce2d762bc/src/libraries/codec/BatchHeaderV3Codec.sol
@@ -83,7 +83,8 @@ impl BatchProvingTask {
8383
self.chunk_proofs
8484
.last()
8585
.unwrap()
86-
.chunk_info
86+
.inner
87+
.chunk_info()
8788
.public_input_hash()
8889
.to_low_u64_le()
8990
.to_string()
@@ -94,7 +95,7 @@ impl BatchProvingTask {
9495
#[derive(Debug, Clone, Deserialize, Serialize)]
9596
pub struct BundleProvingTask {
9697
/// The [`BatchProofs`][BatchProof] for the contiguous list of batches to be bundled together.
97-
pub batch_proofs: Vec<BatchProof>,
98+
pub batch_proofs: Vec<BatchProofV2>,
9899
}
99100

100101
impl BundleProvingTask {
@@ -103,6 +104,11 @@ impl BundleProvingTask {
103104
/// This is used as a file descriptor to save to (load from) disk in order to avoid proof
104105
/// generation if the same proof/SNARK is already found on disk.
105106
pub fn identifier(&self) -> String {
106-
self.batch_proofs.last().unwrap().batch_hash.to_string()
107+
self.batch_proofs
108+
.last()
109+
.unwrap()
110+
.inner
111+
.batch_hash
112+
.to_string()
107113
}
108114
}

0 commit comments

Comments
 (0)