Skip to content
Draft
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,270 changes: 1,528 additions & 742 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 17 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,33 @@ prover-utils = { path = "crates/prover-utils" }
agglayer-telemetry = { git = "https://github.com/agglayer/agglayer.git", tag = "v0.4.4" }

# Interop dependencies
agglayer-elf-build = "0.13.0"
agglayer-evm-client = "0.13.0"
agglayer-interop = "0.13.0"
agglayer-interop-types = "0.13.0"
agglayer-primitives = "0.13.0"
agglayer-tries = "0.13.0"
unified-bridge = "0.13.0"
agglayer-elf-build = "0.14.0"
agglayer-evm-client = "0.14.0"
agglayer-interop = "0.14.0"
agglayer-interop-types = "0.14.0"
agglayer-primitives = "0.14.0"
agglayer-tries = "0.14.0"
unified-bridge = "0.14.0"

# Ecosystem dependencies
op-succinct-elfs = { git = "https://github.com/agglayer/op-succinct.git", tag = "v3.5.0-rc.1-agglayer" }
op-succinct-elfs = { git = "https://github.com/agglayer/op-succinct.git", branch = "release/3.7.x-agglayer" }

# SP1 dependencies
# Please check if the toolchain image at the top `scripts/make/Makefile.elf.toml` could also be
# updated whenever updating the below dependencies; as well as updating the proof-program binary
# crate dependencies.
p3-baby-bear = "=0.2.3-succinct"
p3-bn254-fr = "=0.2.3-succinct"
p3-field = "=0.2.3-succinct"
sp1-core-executor = "=5.2.4"
sp1-core-machine = "=5.2.4"
sp1-sdk = "=5.2.2"
sp1-prover = "=5.2.4"
sp1-zkvm = "=5.2.4"
p3-bn254-fr = "=0.3.2-succinct"
p3-field = "=0.3.2-succinct"
sp1-core-executor = "=6.0.2"
sp1-core-machine = "=6.0.2"
sp1-sdk = "=6.0.2"
sp1-prover = "=6.0.2"
sp1-zkvm = "=6.0.2"

sp1-cc-host-executor = { git = "https://github.com/succinctlabs/sp1-contract-call/", tag = "reth-1.9.1b", features = [
sp1-cc-host-executor = { git = "https://github.com/succinctlabs/sp1-contract-call/", rev = "ec4767a28e7b41514a822c3f62f7d6bd4f4a596f", features = [
"optimism",
] }
sp1-cc-client-executor = { git = "https://github.com/succinctlabs/sp1-contract-call/", tag = "reth-1.9.1b", features = [
sp1-cc-client-executor = { git = "https://github.com/succinctlabs/sp1-contract-call/", rev = "ec4767a28e7b41514a822c3f62f7d6bd4f4a596f", features = [
"optimism",
] }

Expand Down
2 changes: 0 additions & 2 deletions crates/aggchain-proof-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ futures.workspace = true
thiserror.workspace = true
tower = { workspace = true, features = ["timeout"] }
serde = { workspace = true, features = ["derive"] }
sp1-core-executor.workspace = true
sp1-prover.workspace = true
sp1-sdk.workspace = true
tracing.workspace = true

Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 10 additions & 5 deletions crates/aggchain-proof-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use aggchain_proof_contracts::{
use aggchain_proof_core::{
bridge::{inserted_ger::InsertedGER, BridgeWitness},
full_execution_proof::{
AggchainParamsValues, AggregationProofPublicValues, BabyBearDigest, ClaimRoot, FepInputs,
AggchainParamsValues, AggregationProofPublicValues, ClaimRoot, FepInputs, KoalaBearDigest,
},
proof::{AggchainProofWitness, IMPORTED_BRIDGE_EXIT_COMMITMENT_VERSION},
};
Expand Down Expand Up @@ -72,7 +72,7 @@ pub enum FepVerification {
Proof {
/// Aggregated full execution proof for the number of aggregated block
/// spans.
aggregation_proof: Box<sp1_core_executor::SP1ReduceProof<sp1_prover::InnerSC>>,
aggregation_proof: Box<sp1_sdk::SP1ProofWithPublicValues>,

/// Aggregation proof's public values produced by the prover. Used to
/// verify the proof.
Expand Down Expand Up @@ -528,7 +528,7 @@ impl<ContractsClient> AggchainProofBuilder<ContractsClient> {
signature_optimistic_mode: request.fep_verification.optimistic_mode_signature(),
l1_info_tree_leaf,
l1_head_inclusion_proof: request.aggchain_proof_inputs.l1_info_tree_merkle_proof,
aggregation_vkey_hash: BabyBearDigest(aggregation_vkey.hash_babybear()),
aggregation_vkey_hash: KoalaBearDigest(aggregation_vkey.hash_u32()),
range_vkey_commitment: RANGE_VKEY_COMMITMENT,
};

Expand Down Expand Up @@ -592,12 +592,17 @@ impl<ContractsClient> AggchainProofBuilder<ContractsClient> {
aggregation_proof, ..
} = request.fep_verification
{
let aggregation_proof = aggregation_proof
.proof
.clone()
.try_as_compressed()
.ok_or(Error::GeneratedProofIsNotCompressed)?;
stdin.write_proof(*aggregation_proof, aggregation_vkey.vk.clone());
}
stdin
Ok::<_, Error>(stdin)
})
.context("Failed to build SP1 stdin")
.map_err(Error::Other)?;
.map_err(Error::Other)??;

info!(last_proven_block=%request.aggchain_proof_inputs.last_proven_block,
end_block=%request.end_block,
Expand Down
4 changes: 2 additions & 2 deletions crates/aggchain-proof-contracts/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ pub struct L2OutputAtBlock {
pub struct OpSuccinctConfig {
/// The verification key hash of the aggregation SP1 program.
pub aggregation_vkey_hash: Digest,
/// The 32 byte commitment to the BabyBear representation of the
/// The 32 byte commitment to the KoalaBear representation of the
/// verification key of the range SP1 program. Specifically, this
/// verification key is the output of converting the [u32; 8] range
/// BabyBear verification key to a [u8; 32] array.
/// KoalaBear verification key to a [u8; 32] array.
pub range_vkey_commitment: Digest,
/// The hash of the chain's rollup config, which ensures the proofs
/// submitted are for the correct chain. This is used to prevent replay
Expand Down
2 changes: 1 addition & 1 deletion crates/aggchain-proof-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ k256.workspace = true
serde.workspace = true
serde_with.workspace = true
sha2.workspace = true
p3-baby-bear = { workspace = true, features = ["nightly-features"] }
p3-bn254-fr.workspace = true
p3-field.workspace = true
sp1-cc-client-executor.workspace = true
Expand All @@ -35,6 +34,7 @@ tiny-keccak.workspace = true
alloy = { workspace = true, features = ["sol-types", "genesis"] }
dotenvy.workspace = true
mockall.workspace = true
proposer-elfs.workspace = true
serde_json.workspace = true
sp1-cc-host-executor.workspace = true
sp1-sdk.workspace = true
Expand Down
35 changes: 24 additions & 11 deletions crates/aggchain-proof-core/src/full_execution_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use agglayer_primitives::{
};
use alloy_primitives::{FixedBytes, B256, U256};
use alloy_sol_types::{sol, SolValue};
use p3_baby_bear::BabyBear;
use p3_bn254_fr::Bn254Fr;
use p3_field::{AbstractField, PrimeField, PrimeField32};
use p3_field::{AbstractField, PrimeField};
use serde::{Deserialize, Serialize};
use sha2::{Digest as Sha256Digest, Sha256};
use unified_bridge::{L1InfoTreeLeaf, MerkleProof};
Expand Down Expand Up @@ -49,22 +48,22 @@ impl From<ClaimRoot> for L2PreRoot {
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct BabyBearDigest(pub [BabyBear; 8]);
pub struct KoalaBearDigest(pub HashU32);

impl BabyBearDigest {
impl KoalaBearDigest {
pub fn to_hash_u32(&self) -> HashU32 {
self.0.map(|n| n.as_canonical_u32())
self.0
}

pub fn to_hash_bn254(&self) -> [u8; 32] {
let vkey_digest_bn254: Bn254Fr = {
let mut result = Bn254Fr::zero();
for word in self.0.iter() {
// Since BabyBear prime is less than 2^31, we can shift by 31 bits each time and
// still be within the Bn254Fr field, so we don't have to
for word in self.0 {
// Since KoalaBear prime is less than 2^31, we can shift by 31 bits each time
// and still be within the Bn254Fr field, so we don't have to
// truncate the top 3 bits.
result *= Bn254Fr::from_canonical_u64(1 << 31);
result += Bn254Fr::from_canonical_u32(word.as_canonical_u32());
result += Bn254Fr::from_canonical_u32(word);
}
result
};
Expand All @@ -91,8 +90,8 @@ pub struct FepInputs {
pub new_withdrawal_storage_root: Digest,
pub new_block_hash: Digest,

/// Aggregation vkey hash babybear.
pub aggregation_vkey_hash: BabyBearDigest,
/// Aggregation vkey hash koalabear.
pub aggregation_vkey_hash: KoalaBearDigest,

/// Range vkey commitment.
pub range_vkey_commitment: [u8; 32],
Expand Down Expand Up @@ -321,8 +320,22 @@ pub(crate) fn compute_output_root(

#[cfg(test)]
mod tests {
use sp1_sdk::HashableKey as _;

use crate::full_execution_proof::compute_output_root;

#[test]
fn test_koalabear_digest_round_trip_with_aggregation_vkey() {
let aggregation_vkey = proposer_elfs::aggregation::VKEY.vkey();
let koalabear_digest = super::KoalaBearDigest(aggregation_vkey.hash_u32());

assert_eq!(
aggregation_vkey.bytes32_raw(),
koalabear_digest.to_hash_bn254()
);
assert_eq!(aggregation_vkey.hash_u32(), koalabear_digest.to_hash_u32());
}

#[test]
fn test_compute_output_root_expected_value() {
// Provided inputs from the rpc endpoint: optimism_outputAtBlock
Expand Down
Loading
Loading