Skip to content

V0.5 #157

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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

V0.5 #157

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
132 changes: 68 additions & 64 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ version = "0.5.0"

[workspace.dependencies]
# openvm guest libs
openvm = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422" }
openvm-algebra-complex-macros = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-custom-insn = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-sha2 = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422" }
openvm-sha256-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-p256 = { git = "https://github.com/openvm-org/openvm.git", package = "p256", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", features = ["std"] }
openvm-k256 = { git = "https://github.com/openvm-org/openvm.git", package = "k256", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", features = ["std"] }
openvm-pairing = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422" }
openvm-keccak256-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-algebra-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-ecc-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-bigint-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-pairing-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm-rv32im-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422", default-features = false }
openvm = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0" }
openvm-algebra-complex-macros = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-custom-insn = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-sha2 = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0" }
openvm-sha256-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-p256 = { git = "https://github.com/openvm-org/openvm.git", package = "p256", rev = "5368d4756993fc1e51092499a816867cf4808de0", features = ["std"] }
openvm-k256 = { git = "https://github.com/openvm-org/openvm.git", package = "k256", rev = "5368d4756993fc1e51092499a816867cf4808de0", features = ["std"] }
openvm-pairing = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0" }
openvm-keccak256-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-algebra-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-ecc-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-bigint-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-pairing-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }
openvm-rv32im-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0", default-features = false }

# openvm guest libs
openvm-build = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.2.1-rc.1", default-features = false }
Expand All @@ -64,7 +64,7 @@ sbv-kv = { git = "https://github.com/scroll-tech/stateless-block-verifier", bran
sbv-trie = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "chore/openvm-1.3" }
sbv-precompile = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "chore/openvm-1.3" }

scroll-alloy-evm = { git = "https://github.com/scroll-tech/reth", rev = "aad1706d3deaf50e0b92a1d005f7228ac52082f8", default-features = false }
scroll-alloy-evm = { git = "https://github.com/scroll-tech/reth", rev = "090d7950d169abbfb896875a7b1ff3f8ca356ac8", default-features = false }


alloy-primitives = { version = "1.2", default-features = false, features = ["std", "map-hashbrown", "map-fxhash", "rkyv"] }
Expand Down
Binary file added bundle.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion crates/circuits/batch-circuit/batch_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [173805396, 1243397274, 1635463771, 787232164, 57491829, 161204565, 866161262, 1813585880];
pub const COMMIT: [u32; 8] = [929447834, 820187407, 1209145919, 270864530, 1042645838, 1882891518, 1322197458, 1528101909];
2 changes: 1 addition & 1 deletion crates/circuits/bundle-circuit/bundle_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [992613181, 1688971896, 479445636, 206599123, 396943442, 1557239147, 481575146, 757994261];
pub const COMMIT: [u32; 8] = [656901663, 1847532670, 51169052, 1776352742, 669705513, 1444764618, 1562590178, 774429438];
Binary file modified crates/circuits/bundle-circuit/digest_1
Binary file not shown.
4 changes: 2 additions & 2 deletions crates/circuits/chunk-circuit/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[patch.crates-io]
k256 = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422" }
p256 = { git = "https://github.com/openvm-org/openvm.git", rev = "4973d38cb3f2e14ebdd59e03802e65bb657ee422" }
k256 = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0" }
p256 = { git = "https://github.com/openvm-org/openvm.git", rev = "5368d4756993fc1e51092499a816867cf4808de0" }
2 changes: 1 addition & 1 deletion crates/circuits/chunk-circuit/chunk_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [203016858, 503038698, 949948540, 1451391779, 1211328446, 907710104, 1213472024, 1288489367];
pub const COMMIT: [u32; 8] = [1071419318, 13542696, 228098146, 1154682103, 1049712254, 1415629403, 1604860768, 985830407];
2 changes: 2 additions & 0 deletions crates/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ openvm-native-transpiler = { workspace = true, default-features = false }
openvm-transpiler = { workspace = true, default-features = false }

alloy-primitives.workspace = true
base64.workspace = true
cargo_metadata.workspace = true
eyre.workspace = true
rayon.workspace = true
serde.workspace = true
vm-zstd = { workspace = true, features = ["zstd"] }

chrono = "0.4"
Expand Down
7 changes: 3 additions & 4 deletions crates/integration/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ impl From<&BatchHeaderV> for LastHeader {
fn from(value: &BatchHeaderV) -> Self {
match value {
BatchHeaderV::V6(h) => h.into(),
BatchHeaderV::V7(h) => h.into(),
BatchHeaderV::V8(h) => h.into(),
BatchHeaderV::V7_8(h) => h.into(),
}
}
}
Expand Down Expand Up @@ -293,7 +292,7 @@ pub fn build_batch_task(
ForkName::EuclidV2 => {
use scroll_zkvm_types::batch::BatchHeaderV7;
let _ = x + z;
BatchHeaderV::V7(BatchHeaderV7 {
BatchHeaderV::V7_8(BatchHeaderV7 {
version: last_header.version,
batch_index: last_header.batch_index + 1,
parent_batch_hash: last_header.batch_hash,
Expand All @@ -303,7 +302,7 @@ pub fn build_batch_task(
ForkName::Feynman => {
use scroll_zkvm_types::batch::BatchHeaderV8;
let _ = x + z;
BatchHeaderV::V8(BatchHeaderV8 {
BatchHeaderV::V7_8(BatchHeaderV8 {
version: last_header.version,
batch_index: last_header.batch_index + 1,
parent_batch_hash: last_header.batch_hash,
Expand Down
66 changes: 66 additions & 0 deletions crates/integration/tests/bundle_circuit.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use openvm_sdk::commit::AppExecutionCommit;
use sbv_primitives::B256;
use scroll_zkvm_integration::{
ProverTester, prove_verify_multi, prove_verify_single_evm,
Expand All @@ -10,6 +11,7 @@ use scroll_zkvm_integration::{
};
use scroll_zkvm_prover::{
AsRootProof, BatchProof, ChunkProof, IntoEvmProof,
setup::{read_app_config, read_app_exe},
task::{bundle::BundleProvingTask, chunk::ChunkProvingTask},
utils::{read_json_deep, write_json},
};
Expand All @@ -31,6 +33,70 @@ fn load_recent_batch_proofs() -> eyre::Result<BundleProvingTask> {
Ok(task)
}

#[test]
fn print_vks() -> eyre::Result<()> {
#[derive(Default, Debug, serde::Serialize)]
struct VKDump {
pub chunk_vk: String,
pub batch_vk: String,
pub bundle_vk: String,
}
let [chunk_vk, batch_vk, bundle_vk] = ["chunk", "batch", "bundle"].map(|circuit| {
let dev_mode = true;
let (path_app_exe, path_app_config) = if dev_mode {
(
format!("../../crates/circuits/{circuit}-circuit/openvm/app.vmexe").into(),
format!("../../crates/circuits/{circuit}-circuit/openvm.toml").into(),
)
} else {
let version = "0.5.0";
(
format!("../../{version}/{circuit}/app.vmexe").into(),
format!("../../{version}/{circuit}/openvm.toml").into(),
)
};

let config = scroll_zkvm_prover::ProverConfig {
path_app_exe,
path_app_config,
..Default::default()
};

let app_exe = read_app_exe(&config.path_app_exe).unwrap();
let app_config = read_app_config(&config.path_app_config).unwrap();
let sdk = openvm_sdk::Sdk::new();
let app_pk = sdk.app_keygen(app_config).unwrap();
let app_committed_exe = sdk
.commit_app_exe(app_pk.app_fri_params(), app_exe)
.unwrap();
let commits = AppExecutionCommit::compute(
&app_pk.app_vm_pk.vm_config,
&app_committed_exe,
&app_pk.leaf_committed_exe,
);

let exe = commits.app_exe_commit.to_u32_digest();
let leaf = commits.app_vm_commit.to_u32_digest();

let app_vk = scroll_zkvm_types::types_agg::ProgramCommitment { exe, leaf }.serialize();

use base64::{Engine, prelude::BASE64_STANDARD};
let app_vk = BASE64_STANDARD.encode(app_vk);
println!("{circuit}: {app_vk}");
app_vk
});

let dump = VKDump {
chunk_vk,
batch_vk,
bundle_vk,
};

let f = std::fs::File::create("openVmVk.json")?;
serde_json::to_writer(f, &dump)?;
Ok(())
}

#[test]
fn setup_prove_verify() -> eyre::Result<()> {
BundleProverTester::setup()?;
Expand Down
125 changes: 44 additions & 81 deletions crates/prover/src/task/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ use crate::{
#[serde(untagged)]
pub enum BatchHeaderV {
V6(BatchHeaderV6),
V7(BatchHeaderV7),
V8(BatchHeaderV8),
V7_8(BatchHeaderV7),
}

impl From<BatchHeaderV> for ReferenceHeader {
fn from(value: BatchHeaderV) -> Self {
match value {
BatchHeaderV::V6(h) => ReferenceHeader::V6(h),
BatchHeaderV::V7(h) => ReferenceHeader::V7(h),
BatchHeaderV::V8(h) => ReferenceHeader::V8(h),
BatchHeaderV::V7_8(h) => ReferenceHeader::V7(h),
}
}
}
Expand All @@ -43,8 +41,7 @@ impl BatchHeaderV {
pub fn batch_hash(&self) -> B256 {
match self {
BatchHeaderV::V6(h) => h.batch_hash(),
BatchHeaderV::V7(h) => h.batch_hash(),
BatchHeaderV::V8(h) => h.batch_hash(),
BatchHeaderV::V7_8(h) => h.batch_hash(),
}
}

Expand All @@ -57,15 +54,15 @@ impl BatchHeaderV {

pub fn must_v7_header(&self) -> &BatchHeaderV7 {
match self {
BatchHeaderV::V7(h) => h,
_ => panic!("try to pick v7 header"),
BatchHeaderV::V7_8(h) => h,
_ => panic!("try to pick other header"),
}
}

pub fn must_v8_header(&self) -> &BatchHeaderV8 {
match self {
BatchHeaderV::V8(h) => h,
_ => panic!("try to pick v8 header"),
BatchHeaderV::V7_8(h) => h,
_ => panic!("try to pick other header"),
}
}
}
Expand Down Expand Up @@ -120,35 +117,28 @@ impl ProvingTask for BatchProvingTask {
<EnvelopeV6 as Envelope>::from_slice(self.blob_bytes.as_slice())
.challenge_digest(versioned_hash)
}
BatchHeaderV::V7(_) => {
assert_eq!(
fork_name,
ForkName::EuclidV2,
"hardfork mismatch for da-codec@v7 header: found={fork_name:?}, expected={:?}",
ForkName::EuclidV2,
);
let padded_blob_bytes = {
let mut padded_blob_bytes = self.blob_bytes.to_vec();
padded_blob_bytes.resize(N_BLOB_BYTES, 0);
padded_blob_bytes
};
<EnvelopeV7 as Envelope>::from_slice(padded_blob_bytes.as_slice())
.challenge_digest(versioned_hash)
}
BatchHeaderV::V8(_) => {
assert_eq!(
fork_name,
ForkName::Feynman,
"hardfork mismatch for da-codec@v8 header: found={fork_name:?}, expected={:?}",
ForkName::Feynman,
);
BatchHeaderV::V7_8(_) => {
let padded_blob_bytes = {
let mut padded_blob_bytes = self.blob_bytes.to_vec();
padded_blob_bytes.resize(N_BLOB_BYTES, 0);
padded_blob_bytes
};
<EnvelopeV8 as Envelope>::from_slice(padded_blob_bytes.as_slice())
.challenge_digest(versioned_hash)

match fork_name {
ForkName::EuclidV2 => {
<EnvelopeV7 as Envelope>::from_slice(padded_blob_bytes.as_slice())
.challenge_digest(versioned_hash)
}
ForkName::Feynman => {
<EnvelopeV8 as Envelope>::from_slice(padded_blob_bytes.as_slice())
.challenge_digest(versioned_hash)
}
f => unreachable!(
"hardfork mismatch for da-codec@v7 header: found={}, expected={:?}",
f,
[ForkName::EuclidV2, ForkName::Feynman],
),
}
}
};

Expand All @@ -174,7 +164,11 @@ impl ProvingTask for BatchProvingTask {
kzg_proof: kzg_proof.into_inner(),
};

let reference_header = self.batch_header.clone().into();
let reference_header = match fork_name {
ForkName::EuclidV1 => ReferenceHeader::V6(*self.batch_header.must_v6_header()),
ForkName::EuclidV2 => ReferenceHeader::V7(*self.batch_header.must_v7_header()),
ForkName::Feynman => ReferenceHeader::V8(*self.batch_header.must_v8_header()),
};

let witness = BatchWitness {
fork_name,
Expand Down Expand Up @@ -246,52 +240,21 @@ impl From<&BatchProvingTask> for BatchInfo {
);
(h.parent_batch_hash, Default::default(), Default::default())
}
BatchHeaderV::V7(h) => {
assert_eq!(
fork_name,
ForkName::EuclidV2,
"hardfork mismatch for da-codec@v7 header: found={fork_name:?}, expected={:?}",
ForkName::EuclidV2,
);
(
h.parent_batch_hash,
task.chunk_proofs
.first()
.expect("at least one chunk in batch")
.metadata
.chunk_info
.prev_msg_queue_hash,
task.chunk_proofs
.last()
.expect("at least one chunk in batch")
.metadata
.chunk_info
.post_msg_queue_hash,
)
}
BatchHeaderV::V8(h) => {
assert_eq!(
fork_name,
ForkName::Feynman,
"hardfork mismatch for da-codec@v8 header: found={fork_name:?}, expected={:?}",
ForkName::Feynman,
);
(
h.parent_batch_hash,
task.chunk_proofs
.first()
.expect("at least one chunk in batch")
.metadata
.chunk_info
.prev_msg_queue_hash,
task.chunk_proofs
.last()
.expect("at least one chunk in batch")
.metadata
.chunk_info
.post_msg_queue_hash,
)
}
BatchHeaderV::V7_8(h) => (
h.parent_batch_hash,
task.chunk_proofs
.first()
.expect("at least one chunk in batch")
.metadata
.chunk_info
.prev_msg_queue_hash,
task.chunk_proofs
.last()
.expect("at least one chunk in batch")
.metadata
.chunk_info
.post_msg_queue_hash,
),
};

let batch_hash = task.batch_header.batch_hash();
Expand Down
6 changes: 1 addition & 5 deletions crates/prover/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ impl ProvingTask for UniversalProvingTask {
}

for proof in &self.aggregated_proofs {
let streams = if self.fork_name() >= ForkName::Feynman {
proof.proofs[0].write()
} else {
proof.write()
};
let streams = proof.proofs[0].write();
for s in &streams {
stdin.write_field(s);
}
Expand Down
2 changes: 1 addition & 1 deletion download-release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# release version
SCROLL_ZKVM_VERSION=0.5.0
SCROLL_ZKVM_VERSION=0.5.2
if [ -z "${SCROLL_ZKVM_VERSION}" ]; then
echo "SCROLL_ZKVM_VERSION not set"
exit 1
Expand Down
Loading