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

Upgrade-5: prover Refactor #1446

Merged
merged 18 commits into from
Nov 8, 2024
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
164 changes: 114 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ num-bigint.workspace = true

# da-compression
bitstream-io = "2.2.0"
zstd-encoder = { package = "encoder", git = "https://github.com/scroll-tech/da-codec.git", tag = "v0.1.0" }
zstd-encoder = { package = "encoder", git = "https://github.com/scroll-tech/da-codec.git", tag = "v0.1.2" }

[dev-dependencies]

Expand Down
4 changes: 2 additions & 2 deletions aggregator/src/blob_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ mod eip4844;
cfg_if! {
if #[cfg(feature = "da-avail")] {
// const DATA_AVAILABILITY: DataAvailability = DataAvailability::Avail;
pub use avail::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH};
pub use avail::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH, get_blob_bytes};
} else {
// const DATA_AVAILABILITY: DatayAvailability = DataAvailability::Eip4844;
pub use eip4844::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH};
pub use eip4844::{BlobConsistencyConfig, BlobConsistencyWitness, BLOB_WIDTH, get_blob_bytes};
}
}
5 changes: 5 additions & 0 deletions aggregator/src/blob_consistency/avail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ pub struct AssignedBarycentricEvaluationConfig {
/// 32 Assigned cells representing the LE-bytes of evaluation y.
pub(crate) y_le: Vec<AssignedValue<Fr>>,
}

/// Get the blob data bytes that will be populated in BlobDataConfig.
pub fn get_blob_bytes(_batch_bytes: &[u8]) -> Vec<u8> {
unimplemented!("trick for linting");
}
1 change: 0 additions & 1 deletion aggregator/src/blob_consistency/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ fn kzg_to_versioned_hash(commitment: &c_kzg::KzgCommitment) -> H256 {
H256::from_slice(&res[..])
}

#[cfg(test)]
/// Get the blob data bytes that will be populated in BlobDataConfig.
pub fn get_blob_bytes(batch_bytes: &[u8]) -> Vec<u8> {
let mut blob_bytes = crate::witgen::zstd_encode(batch_bytes);
Expand Down
1 change: 1 addition & 0 deletions aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ mod tests;
pub use self::core::extract_proof_and_instances_with_pairing_check;
pub use aggregation::*;
pub use batch::{BatchHash, BatchHeader};
pub use blob_consistency::get_blob_bytes;
pub use chunk::ChunkInfo;
pub use compression::*;
pub use constants::MAX_AGG_SNARKS;
Expand Down
4 changes: 4 additions & 0 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ serde.workspace = true
serde_derive = "1.0"
serde_json = { workspace = true, features = ["unbounded_depth"] }
serde_stacker.workspace = true
thiserror = "1.0"
sha2 ="0.10.2"
revm = { version = "17.1.0", default-features = false, features = ["std"] }

[dev-dependencies]
tempdir = "0.3"

[features]
default = ["scroll"]
parallel_syn = ["halo2_proofs/parallel_syn", "zkevm-circuits/parallel_syn"]
Expand Down
6 changes: 0 additions & 6 deletions prover/src/aggregator.rs

This file was deleted.

43 changes: 43 additions & 0 deletions prover/src/aggregator/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/// Errors encountered in the proof generation pipeline for batch and bundle proving.
#[derive(thiserror::Error, Debug)]
pub enum BatchProverError {
/// Represents a mismatch in the verifying key at the specified proof layer.
#[error("verifying key mismatch: layer={0}, expected={1}, found={2}")]
VerifyingKeyMismatch(crate::config::LayerId, String, String),
/// Verifying key for the specified layer was not found in the prover.
#[error("verifying key not found: layer={0}, expected={1}")]
VerifyingKeyNotFound(crate::config::LayerId, String),
/// Sanity check failure indicating that the [`Snark`][snark_verifier_sdk::Snark]
/// [`protocol`][snark_verifier::Protocol] did not match the expected protocols.
#[error("SNARK protocol mismatch: index={0}, expected={1}, found={2}")]
ChunkProtocolMismatch(usize, String, String),
/// Indicates that after generating an EVM verifier contract, the proof itself could not be
/// verified successfully, implying that this sanity check failed.
#[error("EVM verifier contract could not verify proof")]
SanityEVMVerifier,
/// Error indicating that the verification of batch proof failed.
#[error("proof verification failure")]
Verification,
/// Error indicating that the verifier contract's deployment code is not found.
#[error("EVM verifier deployment code not found!")]
VerifierCodeMissing,
/// Error indicating that in the final [`BundleProof`][crate::BundleProofV2] the number of
/// instances found does not match the number of instances expected.
#[error("number of instances in bundle proof mismatch! expected={0}, got={1}")]
PublicInputsMismatch(usize, usize),
/// This variant represents other errors.
#[error("custom: {0}")]
Custom(String),
}

impl From<String> for BatchProverError {
fn from(value: String) -> Self {
Self::Custom(value)
}
}

impl From<anyhow::Error> for BatchProverError {
fn from(value: anyhow::Error) -> Self {
Self::Custom(value.to_string())
}
}
20 changes: 20 additions & 0 deletions prover/src/aggregator/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
mod error;
pub use error::BatchProverError;

mod prover;
pub use prover::{check_chunk_hashes, Prover};

mod recursion;
pub use recursion::RecursionTask;

mod verifier;
pub use verifier::Verifier;

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

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

/// Alias for convenience.
pub type BatchVerifier<'a> = Verifier<'a>;
Loading
Loading