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
1,798 changes: 1,405 additions & 393 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ members = [
"crates/integration",
"crates/build-guest",
"crates/tools/upload-axiom",
"crates/dogeos/circuits/chunk-circuit",
"crates/dogeos/circuits/batch-circuit",
"crates/dogeos/circuits/bundle-circuit",
"crates/dogeos/integration",
]
resolver = "2"

Expand Down Expand Up @@ -143,10 +147,18 @@ scroll-zkvm-types-circuit = { path = "crates/types/circuit" }
scroll-zkvm-types-chunk = { path = "crates/types/chunk" }
scroll-zkvm-types-batch = { path = "crates/types/batch" }
scroll-zkvm-types-bundle = { path = "crates/types/bundle" }
scroll-zkvm-integration = { path = "crates/integration" }
scroll-zkvm-integration = { path = "crates/integration", default-features = false }
scroll-zkvm-prover = { path = "crates/prover" }
scroll-zkvm-verifier = { path = "crates/verifier" }

# dogeos crates
bridge_core = { path = "../dogeos-core/crates/bridge_core", default-features = false }
bridge_protocol = { path = "../dogeos-core/crates/bridge_protocol", default-features = false }
bridge_adapters_zk = { path = "../dogeos-core/crates/bridge_adapters_zk", default-features = false }
bridge_steps_da = { path = "../dogeos-core/crates/bridge_steps_da", default-features = false }
bridge_steps_deposit = { path = "../dogeos-core/crates/bridge_steps_deposit", default-features = false }
bridge_transforms = { path = "../dogeos-core/crates/bridge_transforms", default-features = false }

[patch.crates-io]
revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91" }
revm-bytecode = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91" }
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export-onchain-verifier:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test onchain_verifier export_onchain_verifier -- --exact --nocapture

test-execute-chunk:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit test_execute -- --exact --nocapture
@cargo test $(CARGO_CONFIG_FLAG) --release -p dogeos-zkvm-integration --test chunk_circuit test_execute -- --exact --nocapture

test-execute-chunk-multi:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit test_execute_multi -- --exact --nocapture
Expand All @@ -76,7 +76,7 @@ test-cycle:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit test_cycle -- --exact --nocapture

test-execute-batch:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit test_e2e_execute -- --exact --nocapture
@cargo test $(CARGO_CONFIG_FLAG) --release -p dogeos-zkvm-integration --test batch_circuit test_e2e_execute -- --exact --nocapture

test-execute-batch-fast:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit test_execute -- --exact --nocapture
Expand All @@ -100,7 +100,7 @@ test-single-batch:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit setup_prove_verify_single -- --exact --nocapture

test-e2e-batch:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit e2e -- --exact --nocapture
@cargo test $(CARGO_CONFIG_FLAG) --release -p dogeos-zkvm-integration --test batch_circuit e2e -- --exact --nocapture

test-axiom-e2e-batch:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit axiom_e2e -- --exact --nocapture
Expand All @@ -112,7 +112,7 @@ test-bundle-local:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test bundle_circuit setup_prove_verify_local_task -- --exact --nocapture

test-e2e-bundle:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test bundle_circuit e2e -- --exact --nocapture
@cargo test $(CARGO_CONFIG_FLAG) --release -p dogeos-zkvm-integration --test bundle_circuit e2e -- --exact --nocapture

test-axiom-e2e-bundle:
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test bundle_circuit axiom_e2e -- --exact --nocapture
11 changes: 2 additions & 9 deletions crates/build-guest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ fn generate_app_assets(workspace_dir: &Path, release_output_dir: &PathBuf) -> Re
for project_name in projects_to_build {
let project_path = workspace_dir
.join("crates")
.join("dogeos")
.join("circuits")
.join(format!("{project_name}-circuit"));

Expand Down Expand Up @@ -176,15 +177,7 @@ fn generate_app_assets(workspace_dir: &Path, release_output_dir: &PathBuf) -> Re
"{LOG_PREFIX} Changed working directory to: {}",
project_path.display()
);
let guest_opts = GuestOptions {
features: if project_name == "chunk" && cfg!(feature = "scroll") {
vec!["scroll".to_string()]
} else {
vec![]
},
..Default::default()
};
let guest_opts = guest_opts.with_profile("maxperf".to_string());
let guest_opts = GuestOptions::default().with_profile("maxperf".to_string());
let sdk = Sdk::new(app_config)?;
let elf = sdk
.build(guest_opts, project_dir, &Default::default(), None)
Expand Down
1 change: 1 addition & 0 deletions crates/dogeos/circuits/batch-circuit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/openvm
26 changes: 26 additions & 0 deletions crates/dogeos/circuits/batch-circuit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "dogeos-zkvm-batch-circuit"
edition.workspace = true
readme.workspace = true
repository.workspace = true
version = "0.7.1"

[dependencies]
scroll-zkvm-types-circuit.workspace = true
scroll-zkvm-types-batch.workspace = true

openvm = { workspace = true, features = ["std"] }
openvm-algebra-guest.workspace = true
openvm-pairing = { workspace = true, features = ["bls12_381"] }
openvm-keccak256-guest.workspace = true
openvm-sha256-guest.workspace = true
openvm-ecc-guest = { workspace = true, features = ["halo2curves"] }

alloy-primitives = { workspace = true, features = ["native-keccak"] }
bincode.workspace = true
itertools.workspace = true

[features]
default = []

[dev-dependencies]
4 changes: 4 additions & 0 deletions crates/dogeos/circuits/batch-circuit/batch_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [123293429, 661502243, 1332640210, 533174887, 1591197618, 1101567153, 1899493398, 49094928];
4 changes: 4 additions & 0 deletions crates/dogeos/circuits/batch-circuit/batch_vm_commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [1143979762, 1252839784, 728295280, 80130475, 1981604375, 1538642995, 55047256, 1521517292];
35 changes: 35 additions & 0 deletions crates/dogeos/circuits/batch-circuit/openvm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[app_fri_params.fri_params]
log_blowup = 1
log_final_poly_len = 0
num_queries = 100
proof_of_work_bits = 16

[app_vm_config.rv32i]

[app_vm_config.rv32m]

[app_vm_config.io]

[app_vm_config.keccak]

[app_vm_config.castf]

[app_vm_config.modular]
supported_moduli = [
"4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787",
"52435875175126190479447740508185965837690552500527637822603658699938581184513",
]
[app_vm_config.native]
[app_vm_config.pairing]
supported_curves = ["Bls12_381"]
[app_vm_config.sha256]
[app_vm_config.fp2]
supported_moduli = [
["Bls12_381Fp2","4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787"]
]
[[app_vm_config.ecc.supported_curves]]
struct_name = "Bls12_381G1Affine"
modulus = "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787"
scalar = "52435875175126190479447740508185965837690552500527637822603658699938581184513"
a = "0"
b = "4"
4 changes: 4 additions & 0 deletions crates/dogeos/circuits/batch-circuit/openvm_init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file is automatically generated by cargo openvm. Do not rename or edit.
openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", "52435875175126190479447740508185965837690552500527637822603658699938581184513" }
openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } }
openvm_ecc_guest::sw_macros::sw_init! { "Bls12_381G1Affine" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod chunk_exe_commit;
mod chunk_vm_commit;

pub const EXE_COMMIT: [u32; 8] = chunk_exe_commit::COMMIT;
pub const VM_COMMIT: [u32; 8] = chunk_vm_commit::COMMIT;
103 changes: 103 additions & 0 deletions crates/dogeos/circuits/batch-circuit/src/circuit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
use alloy_primitives::B256;
use scroll_zkvm_types_batch::dogeos::{DogeOsBatchWitness};
use scroll_zkvm_types_circuit::{
AggCircuit, AggregationInput, Circuit, ProgramCommitment,
io::read_witnesses,
public_inputs::{
Version,
dogeos::{
batch::{DogeOsBatchInfo, VersionedDogeOsBatchInfo},
chunk::VersionedDogeOsChunkInfo,
},
},
};
use itertools::Itertools;

use crate::child_commitments;

#[allow(unused_imports, clippy::single_component_path_imports)]
use {
openvm_algebra_guest::{IntMod, field::FieldExtension},
openvm_ecc_guest::AffinePoint,
openvm_keccak256_guest, // trigger extern native-keccak256
openvm_pairing::bls12_381::{Bls12_381, Bls12_381G1Affine, Fp, Fp2},
openvm_sha256_guest,
};
use scroll_zkvm_types_circuit::public_inputs::dogeos::chunk::DogeOsChunkInfo;

openvm::init!();

pub struct BatchCircuit;

impl Circuit for BatchCircuit {
type Witness = DogeOsBatchWitness;

type PublicInputs = VersionedDogeOsBatchInfo;

fn read_witness_bytes() -> Vec<u8> {
read_witnesses()
}

fn deserialize_witness(witness_bytes: &[u8]) -> Self::Witness {
let config = bincode::config::standard();
let (witness, _): (Self::Witness, _) =
bincode::serde::decode_from_slice(witness_bytes, config)
.expect("BatchCircuit: deserialisation of witness bytes failed");
witness
}

fn validate(witness: Self::Witness) -> Self::PublicInputs {
let version = Version::from(witness.inner.version);
assert_eq!(version.fork, witness.inner.fork_name);

(DogeOsBatchInfo::from(&witness), version)
}
}

impl AggCircuit for BatchCircuit {
type AggregatedPublicInputs = VersionedDogeOsChunkInfo;

fn verify_commitments(commitment: &ProgramCommitment) {
assert_eq!(
commitment.vm,
child_commitments::VM_COMMIT,
"mismatch chunk-proof leaf commitment: expected={:?}, got={:?}",
child_commitments::VM_COMMIT,
commitment.vm,
);
assert_eq!(
commitment.exe,
child_commitments::EXE_COMMIT,
"mismatch chunk-proof exe commitment: expected={:?}, got={:?}",
child_commitments::EXE_COMMIT,
commitment.exe,
);
}

fn aggregated_public_inputs(witness: &Self::Witness) -> Vec<Self::AggregatedPublicInputs> {
let version = Version::from(witness.inner.version);
witness
.inner
.chunk_infos
.iter()
.cloned()
.zip_eq(witness.extras.chunk_info_extras.iter().cloned())
.map(DogeOsChunkInfo::from)
.map(|chunk_info| (chunk_info, version))
.collect()
}

fn aggregated_pi_hashes(proofs: &[AggregationInput]) -> Vec<B256> {
proofs
.iter()
.map(|proof| {
let transformed = proof
.public_values
.iter()
.map(|&val| u8::try_from(val).expect("0 < public value < 256"))
.collect::<Vec<u8>>();
B256::from_slice(transformed.as_slice())
})
.collect()
}
}
35 changes: 35 additions & 0 deletions crates/dogeos/circuits/batch-circuit/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use scroll_zkvm_types_circuit::{AggCircuit, Circuit};

mod circuit;
use circuit::BatchCircuit as C;

mod child_commitments;

openvm::entry!(main);

fn main() {
// Read witness bytes from openvm StdIn.
let witness_bytes = C::read_witness_bytes();

// Deserialize witness bytes to the witness data type.
let witness = C::deserialize_witness(&witness_bytes);

// Verify the root proofs being aggregated in the circuit.
let agg_proofs = C::verify_proofs(&witness);

// Get the public-input values of the proofs being aggregated from witness.
let agg_pis = C::aggregated_public_inputs(&witness);

// Derive the digests of the public-input values of proofs being aggregated.
let agg_pi_hashes = C::aggregated_pi_hashes(&agg_proofs);

// Validate that the pi hashes derived from the root proofs are in fact the digests of the
// public-input values of the previous circuit layer.
C::validate_aggregated_pi(&agg_pis, &agg_pi_hashes);

// Validate the witness for the current circuit layer.
let public_inputs = C::validate(witness);

// Reveal the public-input values of the current circuit layer.
C::reveal_pi(&public_inputs);
}
1 change: 1 addition & 0 deletions crates/dogeos/circuits/bundle-circuit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/openvm
19 changes: 19 additions & 0 deletions crates/dogeos/circuits/bundle-circuit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "dogeos-zkvm-bundle-circuit"
edition.workspace = true
readme.workspace = true
repository.workspace = true
version = "0.7.1"

[dependencies]
bincode.workspace = true
scroll-zkvm-types-circuit.workspace = true
scroll-zkvm-types-bundle.workspace = true

openvm = { workspace = true, features = ["std"] }
openvm-keccak256-guest.workspace = true

alloy-primitives = { workspace = true }

[features]
default = []
4 changes: 4 additions & 0 deletions crates/dogeos/circuits/bundle-circuit/bundle_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [1427402185, 1459064843, 317464538, 1274190978, 466682983, 1321271389, 1187009604, 1464042898];
4 changes: 4 additions & 0 deletions crates/dogeos/circuits/bundle-circuit/bundle_vm_commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [702922786, 974900043, 1870917533, 1628966797, 1650497578, 697799835, 298481193, 1937656708];
17 changes: 17 additions & 0 deletions crates/dogeos/circuits/bundle-circuit/openvm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[app_fri_params.fri_params]
log_blowup = 1
log_final_poly_len = 0
num_queries = 100
proof_of_work_bits = 16

[app_vm_config.rv32i]

[app_vm_config.rv32m]

[app_vm_config.io]

[app_vm_config.keccak]

[app_vm_config.castf]

[app_vm_config.native]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mod batch_exe_commit;
mod batch_vm_commit;
pub const EXE_COMMIT: [u32; 8] = batch_exe_commit::COMMIT;
pub const VM_COMMIT: [u32; 8] = batch_vm_commit::COMMIT;
Loading