Skip to content
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
586 changes: 311 additions & 275 deletions Cargo.lock

Large diffs are not rendered by default.

82 changes: 31 additions & 51 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,47 @@ version = "0.7.1"

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

# openvm host libs
openvm-benchmarks-prove = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-benchmarks-utils = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-build = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-circuit = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-continuations = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-instructions = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-native-circuit = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-native-compiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-native-recursion = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-native-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-rv32im-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-sdk = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false, features = [
openvm-benchmarks-prove = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-benchmarks-utils = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-build = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-circuit = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-continuations = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-instructions = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-native-circuit = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-native-compiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-native-recursion = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-native-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-rv32im-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }
openvm-sdk = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false, features = [
"parallel",
"evm-prove",
"legacy-v1-3-evm-verifier",
"tco",
"unprotected"
] }
openvm-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
openvm-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.2", default-features = false }

# more openvm related libs
openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.2.1" }
openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.2.2" }

sbv-core = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2" }
sbv-helpers = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2", features = ["dev"] }
Expand All @@ -80,11 +79,10 @@ alloy-consensus = "1.0"
alloy-provider = "1.0"
alloy-rpc-client = "1.0"
alloy-transport = "1.0"
alloy-primitives = { version = "1.4.1", default-features = false, features = [
alloy-primitives = { version = "1.4", default-features = false, features = [
"std",
"map-hashbrown",
"map-fxhash",
"rkyv",
] }
alloy-serde = { version = "1.0.13", default-features = false }
alloy-sol-types = { version = "1.3", default-features = false }
Expand All @@ -103,15 +101,14 @@ ecies = { git = "https://github.com/scroll-tech/ecies-rs" }
eyre = "0.6"
color-eyre = "0.6"
futures = "0.3"
halo2curves-axiom = { version = "0.5.3" }
halo2curves-axiom = { version = "0.7.2" }
itertools = "0.14"
hex-literal = { version = "0.4.1", default-features = false }
hex = "0.4"
metrics = "0.23.0"
metrics-util = "0.17"
metrics-tracing-context = "0.16.0"
rayon = "1.10"
rkyv = "0.8"
revm = "29"
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = { version = "1.0" }
Expand All @@ -133,7 +130,7 @@ sysinfo = { version = "0.35", default-features = false }
bytesize = "2.0.1"
url = "2.5.4"
tokio = "1"
axiom-sdk = { git = "https://github.com/axiom-crypto/axiom-api-cli.git", rev = "a460528" }
axiom-sdk = { git = "https://github.com/axiom-crypto/axiom-api-cli.git", branch = "develop" }
dotenvy = "0.15"
jiff = "0.2"

Expand Down Expand Up @@ -161,23 +158,6 @@ revm-precompile = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v
revm-primitives = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91" }
revm-state = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91" }

## FIXME: when openvm fixes https://github.com/openvm-org/openvm/pull/1937
#[patch.'https://github.com/openvm-org/openvm.git']
#openvm = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-algebra-complex-macros = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-custom-insn = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-sha2 = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-sha256-guest = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-p256 = { git = "https://github.com/lightsing/openvm.git", package = "p256", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-k256 = { git = "https://github.com/lightsing/openvm.git", package = "k256", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-pairing = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-keccak256-guest = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-algebra-guest = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-ecc-guest = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-bigint-guest = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-pairing-guest = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }
#openvm-rv32im-guest = { git = "https://github.com/lightsing/openvm.git", rev = "f834efa186784cfdb0401c8596e1264cc9030f97" }

[profile.maxperf]
inherits = "release"
lto = "fat"
Expand Down
1 change: 0 additions & 1 deletion crates/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ scroll-zkvm-types.workspace = true
scroll-zkvm-prover.workspace = true
scroll-zkvm-verifier.workspace = true

rkyv.workspace = true
sbv-primitives = { workspace = true }
sbv-utils = { workspace = true }
sbv-core = { workspace = true, features = ["scroll"] }
Expand Down
8 changes: 4 additions & 4 deletions crates/integration/src/axiom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use axiom_sdk::build::BuildSdk;
use axiom_sdk::config::ConfigSdk;
use axiom_sdk::input::Input;
use axiom_sdk::prove::{ProveArgs, ProveSdk};
use axiom_sdk::{AxiomConfig, AxiomSdk, ProgressCallback, ProofType, SaveOption};
use axiom_sdk::{AxiomConfig, AxiomSdk, ProgressCallback, ProofType};
use chrono::DateTime;
use openvm_sdk::commit::CommitBytes;
use openvm_sdk::types::{EvmProof, VersionedVmStarkProof};
Expand Down Expand Up @@ -95,9 +95,9 @@ impl TaskProver for AxiomProver {
let mhz = cycles as f64 / duration / 1e6f64;
tracing::info!("Proof generated in {duration:.2} seconds: {mhz:.2} MHz");

let proof_bytes =
self.sdk
.get_generated_proof(&status.id, &proof_type, SaveOption::DoNotSave)?;
let proof_bytes = self
.sdk
.get_generated_proof(&status.id, &proof_type, None)?;

match proof_type {
ProofType::Stark => {
Expand Down
18 changes: 6 additions & 12 deletions crates/integration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::axiom::AxiomProver;
use cargo_metadata::MetadataCommand;
use once_cell::sync::OnceCell;
use openvm_sdk::StdIn;
use openvm_sdk::{Sdk, StdIn};
use scroll_zkvm_prover::{
Prover,
setup::{read_app_config, read_app_exe},
Expand Down Expand Up @@ -121,18 +121,13 @@ pub trait PartialProvingTask: serde::Serialize {
fn identifier(&self) -> String;
fn fork_name(&self) -> ForkName;

fn legacy_rkyv_archive(&self) -> eyre::Result<Vec<u8>>;

fn archive(&self) -> eyre::Result<Vec<u8>>
where
Self: Sized,
{
let bytes: Vec<u8> = match GUEST_VERSION.as_ref() {
"0.5.2" => self.legacy_rkyv_archive()?,
_ => {
let config = bincode::config::standard();
bincode::serde::encode_to_vec(self, config)?
}
let bytes: Vec<u8> = {
let config = bincode::config::standard();
bincode::serde::encode_to_vec(self, config)?
};
Ok(bytes)
}
Expand Down Expand Up @@ -211,7 +206,6 @@ pub trait ProverTester {
let config = scroll_zkvm_prover::ProverConfig {
path_app_exe,
path_app_config,
is_openvm_v13: *GUEST_VERSION == "0.5.2",
..Default::default()
};
let prover = Prover::setup(config, Some(Self::NAME))?;
Expand Down Expand Up @@ -363,8 +357,8 @@ pub fn tester_execute<T: ProverTester>(
.map(|p| p.as_stark_proof().expect("must be stark proof")),
)?;

let ret =
scroll_zkvm_prover::utils::vm::execute_guest(app_config.app_vm_config, &app_exe, &stdin)?;
let sdk = Sdk::new(app_config)?;
let ret = scroll_zkvm_prover::utils::vm::execute_guest(&sdk, app_exe, &stdin)?;
Ok(ret)
}

Expand Down
8 changes: 1 addition & 7 deletions crates/integration/src/testers/batch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use scroll_zkvm_types::{
batch::{BatchHeader, BatchInfo, BatchWitness, LegacyBatchWitness, ReferenceHeader},
batch::{BatchHeader, BatchInfo, BatchWitness, ReferenceHeader},
chunk::ChunkInfo,
proof::ProofEnum,
public_inputs::{ForkName, Version},
Expand All @@ -23,12 +23,6 @@ impl PartialProvingTask for BatchWitness {
header_hash.to_string()
}

fn legacy_rkyv_archive(&self) -> eyre::Result<Vec<u8>> {
let witness_legacy = LegacyBatchWitness::from(self.clone());
let bytes = rkyv::to_bytes::<rkyv::rancor::Error>(&witness_legacy)?;
Ok(bytes.to_vec())
}

fn fork_name(&self) -> ForkName {
ForkName::from(self.fork_name.as_str())
}
Expand Down
8 changes: 1 addition & 7 deletions crates/integration/src/testers/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use scroll_zkvm_types::{
batch::BatchInfo,
bundle::{BundleInfo, BundleWitness, LegacyBundleWitness},
bundle::{BundleInfo, BundleWitness},
proof::ProofEnum,
public_inputs::ForkName,
};
Expand All @@ -21,12 +21,6 @@ impl PartialProvingTask for BundleWitness {
format!("{first}-{last}")
}

fn legacy_rkyv_archive(&self) -> eyre::Result<Vec<u8>> {
let witness_legacy = LegacyBundleWitness::from(self.clone());
let bytes = rkyv::to_bytes::<rkyv::rancor::Error>(&witness_legacy)?;
Ok(bytes.to_vec())
}

fn fork_name(&self) -> ForkName {
ForkName::from(self.fork_name.as_str())
}
Expand Down
31 changes: 7 additions & 24 deletions crates/integration/src/testers/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use crate::{
GUEST_VERSION, PartialProvingTask, ProverTester, TaskProver, prove_verify,
testdata_fork_directory, tester_execute, testers::PATH_TESTDATA, testing_hardfork,
testing_version, utils::metadata_from_chunk_witnesses,
PartialProvingTask, ProverTester, TaskProver, prove_verify, testdata_fork_directory,
tester_execute, testers::PATH_TESTDATA, testing_hardfork, testing_version,
utils::metadata_from_chunk_witnesses,
};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use sbv_core::BlockWitness;
use sbv_primitives::{B256, types::consensus::TxL1Message};
use scroll_zkvm_prover::utils::read_json;
use scroll_zkvm_prover::utils::vm::ExecutionResult;
use scroll_zkvm_types::chunk::ChunkWitnessUpgradeCompact;
use scroll_zkvm_types::{
chunk::{ChunkInfo, ChunkWitness, LegacyChunkWitness, SecretKey},
chunk::{ChunkInfo, ChunkWitness, SecretKey},
proof::ProofEnum,
public_inputs::{ForkName, Version},
};
Expand Down Expand Up @@ -61,29 +60,13 @@ impl PartialProvingTask for ChunkWitness {
format!("{first}-{last}")
}

fn legacy_rkyv_archive(&self) -> eyre::Result<Vec<u8>> {
let witness_legacy = LegacyChunkWitness::from(self.clone());
let bytes = rkyv::to_bytes::<rkyv::rancor::Error>(&witness_legacy)?;
Ok(bytes.to_vec())
}

fn archive(&self) -> eyre::Result<Vec<u8>>
where
Self: Sized,
{
let bytes: Vec<u8> = match GUEST_VERSION.as_ref() {
"0.5.2" => self.legacy_rkyv_archive()?,
"0.6.0-rc.6" => {
let config = bincode::config::standard();
bincode::serde::encode_to_vec(
ChunkWitnessUpgradeCompact::from(self.clone()),
config,
)?
}
_ => {
let config = bincode::config::standard();
bincode::serde::encode_to_vec(self, config)?
}
let bytes: Vec<u8> = {
let config = bincode::config::standard();
bincode::serde::encode_to_vec(self, config)?
};
Ok(bytes)
}
Expand Down
1 change: 0 additions & 1 deletion crates/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ version.workspace = true
scroll-zkvm-types.workspace = true
scroll-zkvm-verifier.workspace = true

rkyv.workspace = true
bincode_v1.workspace = true
tracing.workspace = true
openvm-circuit = { workspace = true }
Expand Down
27 changes: 4 additions & 23 deletions crates/prover/src/prover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ use openvm_native_circuit::NativeGpuBuilder as NativeBuilder;
use openvm_circuit::arch::instructions::exe::VmExe;
use openvm_sdk::{DefaultStarkEngine, config::SdkVmBuilder};
use openvm_sdk::{F, Sdk, StdIn, prover::StarkProver};
use scroll_zkvm_types::{
proof::OpenVmEvmProof, types_agg::ProgramCommitment, utils::serialize_vk,
zkvm::AGG_STARK_PROVING_KEY_V13,
};
use scroll_zkvm_types::{proof::OpenVmEvmProof, types_agg::ProgramCommitment, utils::serialize_vk};
use scroll_zkvm_verifier::verifier::{AGG_STARK_PROVING_KEY, UniversalVerifier};
use tracing::instrument;

Expand Down Expand Up @@ -49,8 +46,6 @@ pub struct ProverConfig {
pub path_app_config: PathBuf,
/// The maximum length for a single OpenVM segment.
pub segment_len: Option<usize>,
/// Use v1.3 openvm
pub is_openvm_v13: bool,
}

const DEFAULT_SEGMENT_SIZE: usize = (1 << 22) - 1000;
Expand Down Expand Up @@ -86,22 +81,10 @@ impl Prover {
segmentation_limits.max_trace_height = segment_len as u32;
segmentation_limits.max_cells = 1_200_000_000_usize; // For 24G vram

let mut sdk = Sdk::new(app_config).expect("sdk init failed");

let verifier_k = if self.config.is_openvm_v13 { 24 } else { 23 };
tracing::info!(
"changing openvm_sdk.halo2_config.verifier_k from {} to {}",
sdk.halo2_config().verifier_k,
verifier_k
);
sdk.halo2_config_mut().verifier_k = verifier_k;
let sdk = Sdk::new(app_config).expect("sdk init failed");

// 45s for first time
let sdk = sdk.with_agg_pk(if self.config.is_openvm_v13 {
AGG_STARK_PROVING_KEY_V13.clone()
} else {
AGG_STARK_PROVING_KEY.clone()
});
let sdk = sdk.with_agg_pk(AGG_STARK_PROVING_KEY.clone());
Ok(sdk)
})
}
Expand Down Expand Up @@ -173,10 +156,8 @@ impl Prover {
stdin: &StdIn,
) -> Result<crate::utils::vm::ExecutionResult, Error> {
let sdk = self.get_sdk()?;
let config = sdk.app_config();
let t = std::time::Instant::now();
let exec_result =
crate::utils::vm::execute_guest(config.app_vm_config.clone(), &self.app_exe, stdin)?;
let exec_result = crate::utils::vm::execute_guest(sdk, self.app_exe.clone(), stdin)?;
let execution_time_mills = t.elapsed().as_millis() as u64;
let execution_time_s = execution_time_mills as f32 / 1000.0f32;
let exec_speed = (exec_result.total_cycle as f32 / 1_000_000.0f32) / execution_time_s; // MHz
Expand Down
Loading