diff --git a/Cargo.lock b/Cargo.lock index 5f45f8c0..9c159ba4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -366,7 +366,6 @@ dependencies = [ "paste", "proptest", "rand 0.9.2", - "rkyv", "ruint", "rustc-hash 2.1.1", "serde", @@ -1486,29 +1485,6 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" -[[package]] -name = "bytecheck" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0caa33a2c0edca0419d15ac723dff03f1956f7978329b1e3b5fdaaaed9d3ca8b" -dependencies = [ - "bytecheck_derive", - "ptr_meta", - "rancor", - "simdutf8", -] - -[[package]] -name = "bytecheck_derive" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89385e82b5d1821d2219e0b095efa2cc1f246cbf99080f3be46a1a85c0d392d9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.110", -] - [[package]] name = "bytemuck" version = "1.24.0" @@ -4139,26 +4115,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "munge" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e17401f259eba956ca16491461b6e8f72913a0a114e39736ce404410f915a0c" -dependencies = [ - "munge_macro", -] - -[[package]] -name = "munge_macro" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4568f25ccbd45ab5d5603dc34318c1ec56b117531781260002151b8530a9f931" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.110", -] - [[package]] name = "native-tls" version = "0.2.14" @@ -6424,26 +6380,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ptr_meta" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9a0cf95a1196af61d4f1cbdab967179516d9a4a4312af1f31948f8f6224a79" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7347867d0a7e1208d93b46767be83e2b8f978c3dad35f775ac8d8847551d6fe1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.110", -] - [[package]] name = "quanta" version = "0.12.6" @@ -6496,15 +6432,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "rancor" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a063ea72381527c2a0561da9c80000ef822bdd7c3241b1cc1b12100e3df081ee" -dependencies = [ - "ptr_meta", -] - [[package]] name = "rand" version = "0.8.5" @@ -6683,15 +6610,6 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" -[[package]] -name = "rend" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadadef317c2f20755a64d7fdc48f9e7178ee6b0e1f7fce33fa60f1d68a276e6" -dependencies = [ - "bytecheck", -] - [[package]] name = "reqwest" version = "0.12.24" @@ -8029,36 +7947,6 @@ dependencies = [ "thiserror 2.0.17", ] -[[package]] -name = "rkyv" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35a640b26f007713818e9a9b65d34da1cf58538207b052916a83d80e43f3ffa4" -dependencies = [ - "bytecheck", - "bytes", - "hashbrown 0.15.5", - "indexmap 2.12.0", - "munge", - "ptr_meta", - "rancor", - "rend", - "rkyv_derive", - "tinyvec", - "uuid", -] - -[[package]] -name = "rkyv_derive" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd83f5f173ff41e00337d97f6572e416d022ef8a19f371817259ae960324c482" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.110", -] - [[package]] name = "rlp" version = "0.5.2" @@ -8112,7 +8000,6 @@ dependencies = [ "proptest", "rand 0.8.5", "rand 0.9.2", - "rkyv", "rlp", "ruint-macro", "serde_core", @@ -8256,7 +8143,6 @@ dependencies = [ "itertools 0.14.0", "reth-primitives-traits", "reth-stateless", - "rkyv", "sbv-helpers", "sbv-primitives", "sbv-trie", @@ -8300,7 +8186,6 @@ dependencies = [ "reth-scroll-primitives", "revm 30.1.1", "revm-scroll", - "rkyv", "sbv-helpers", "scroll-alloy-consensus", "scroll-alloy-evm", @@ -8554,7 +8439,6 @@ dependencies = [ "rayon", "regex", "revm 29.0.1", - "rkyv", "sbv-core", "sbv-primitives", "sbv-utils", @@ -8587,7 +8471,6 @@ dependencies = [ "openvm-native-recursion", "openvm-sdk", "openvm-stark-sdk", - "rkyv", "scroll-zkvm-types", "scroll-zkvm-verifier", "serde", @@ -8627,7 +8510,6 @@ version = "0.7.0" dependencies = [ "alloy-primitives", "alloy-serde 1.1.1", - "rkyv", "serde", "sha2 0.10.9", "sha3", @@ -8647,7 +8529,6 @@ dependencies = [ "openvm-pairing", "openvm-pairing-guest", "openvm-sha2", - "rkyv", "sbv-primitives", "scroll-zkvm-types-base", "serde", @@ -8658,7 +8539,6 @@ dependencies = [ name = "scroll-zkvm-types-bundle" version = "0.7.0" dependencies = [ - "rkyv", "scroll-zkvm-types-base", "serde", ] @@ -8677,7 +8557,6 @@ dependencies = [ "openvm-pairing", "openvm-sha2", "p256 0.13.2 (git+https://github.com/openvm-org/openvm.git?tag=v1.4.1)", - "rkyv", "sbv-core", "sbv-helpers", "sbv-primitives", @@ -9119,12 +8998,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" -[[package]] -name = "simdutf8" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" - [[package]] name = "siphasher" version = "1.0.1" @@ -9623,21 +9496,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "tinyvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.48.0" @@ -10065,16 +9923,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "1.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "valuable" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 47fca197..f6bbfe72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,6 @@ openvm-rv32im-transpiler = { git = "https://github.com/openvm-org/openvm.git", t openvm-sdk = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false, features = [ "parallel", "evm-prove", - "legacy-v1-3", "tco", "unprotected" ] } @@ -84,7 +83,6 @@ alloy-primitives = { version = "1.4.1", 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 } @@ -111,7 +109,6 @@ 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" } @@ -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" diff --git a/crates/integration/Cargo.toml b/crates/integration/Cargo.toml index 7c4d2857..5f7c9099 100644 --- a/crates/integration/Cargo.toml +++ b/crates/integration/Cargo.toml @@ -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"] } diff --git a/crates/integration/src/lib.rs b/crates/integration/src/lib.rs index c639e545..8ede0c2b 100644 --- a/crates/integration/src/lib.rs +++ b/crates/integration/src/lib.rs @@ -120,18 +120,13 @@ pub trait PartialProvingTask: serde::Serialize { fn identifier(&self) -> String; fn fork_name(&self) -> ForkName; - fn legacy_rkyv_archive(&self) -> eyre::Result>; - fn archive(&self) -> eyre::Result> where Self: Sized, { - let bytes: Vec = 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 = { + let config = bincode::config::standard(); + bincode::serde::encode_to_vec(self, config)? }; Ok(bytes) } @@ -210,7 +205,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))?; diff --git a/crates/integration/src/testers/batch.rs b/crates/integration/src/testers/batch.rs index cc923883..1be26650 100644 --- a/crates/integration/src/testers/batch.rs +++ b/crates/integration/src/testers/batch.rs @@ -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}, @@ -23,12 +23,6 @@ impl PartialProvingTask for BatchWitness { header_hash.to_string() } - fn legacy_rkyv_archive(&self) -> eyre::Result> { - let witness_legacy = LegacyBatchWitness::from(self.clone()); - let bytes = rkyv::to_bytes::(&witness_legacy)?; - Ok(bytes.to_vec()) - } - fn fork_name(&self) -> ForkName { ForkName::from(self.fork_name.as_str()) } diff --git a/crates/integration/src/testers/bundle.rs b/crates/integration/src/testers/bundle.rs index c957410b..e5a9a67f 100644 --- a/crates/integration/src/testers/bundle.rs +++ b/crates/integration/src/testers/bundle.rs @@ -1,6 +1,6 @@ use scroll_zkvm_types::{ batch::BatchInfo, - bundle::{BundleInfo, BundleWitness, LegacyBundleWitness}, + bundle::{BundleInfo, BundleWitness}, proof::ProofEnum, public_inputs::ForkName, }; @@ -21,12 +21,6 @@ impl PartialProvingTask for BundleWitness { format!("{first}-{last}") } - fn legacy_rkyv_archive(&self) -> eyre::Result> { - let witness_legacy = LegacyBundleWitness::from(self.clone()); - let bytes = rkyv::to_bytes::(&witness_legacy)?; - Ok(bytes.to_vec()) - } - fn fork_name(&self) -> ForkName { ForkName::from(self.fork_name.as_str()) } diff --git a/crates/integration/src/testers/chunk.rs b/crates/integration/src/testers/chunk.rs index ca4d583a..3fe4249e 100644 --- a/crates/integration/src/testers/chunk.rs +++ b/crates/integration/src/testers/chunk.rs @@ -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}, }; @@ -61,29 +60,13 @@ impl PartialProvingTask for ChunkWitness { format!("{first}-{last}") } - fn legacy_rkyv_archive(&self) -> eyre::Result> { - let witness_legacy = LegacyChunkWitness::from(self.clone()); - let bytes = rkyv::to_bytes::(&witness_legacy)?; - Ok(bytes.to_vec()) - } - fn archive(&self) -> eyre::Result> where Self: Sized, { - let bytes: Vec = 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 = { + let config = bincode::config::standard(); + bincode::serde::encode_to_vec(self, config)? }; Ok(bytes) } diff --git a/crates/prover/Cargo.toml b/crates/prover/Cargo.toml index 01262aa4..e7328670 100644 --- a/crates/prover/Cargo.toml +++ b/crates/prover/Cargo.toml @@ -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 } diff --git a/crates/prover/src/prover/mod.rs b/crates/prover/src/prover/mod.rs index 020b0f65..4eb396d7 100644 --- a/crates/prover/src/prover/mod.rs +++ b/crates/prover/src/prover/mod.rs @@ -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; @@ -49,8 +46,6 @@ pub struct ProverConfig { pub path_app_config: PathBuf, /// The maximum length for a single OpenVM segment. pub segment_len: Option, - /// Use v1.3 openvm - pub is_openvm_v13: bool, } const DEFAULT_SEGMENT_SIZE: usize = (1 << 22) - 1000; @@ -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) }) } diff --git a/crates/types/base/Cargo.toml b/crates/types/base/Cargo.toml index 9b3ee832..3f08337e 100644 --- a/crates/types/base/Cargo.toml +++ b/crates/types/base/Cargo.toml @@ -10,7 +10,6 @@ version.workspace = true [dependencies] alloy-primitives = { workspace = true } alloy-serde.workspace = true -rkyv.workspace = true serde.workspace = true sha3 = "0.10.8" sha2 = "0.10.8" diff --git a/crates/types/base/src/aggregation.rs b/crates/types/base/src/aggregation.rs index 827fcb51..fe7cc94e 100644 --- a/crates/types/base/src/aggregation.rs +++ b/crates/types/base/src/aggregation.rs @@ -1,14 +1,5 @@ /// Represents an openvm program commitments and public values. -#[derive( - Clone, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct AggregationInput { /// Public values. pub public_values: Vec, @@ -17,18 +8,7 @@ pub struct AggregationInput { } /// Represent the commitment needed to verify a [`RootProof`]. -#[derive( - Copy, - Clone, - Debug, - Default, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug, Copy, Clone))] +#[derive(Copy, Clone, Debug, Default, serde::Deserialize, serde::Serialize)] pub struct ProgramCommitment { /// The commitment to the child program exe. pub exe: [u32; 8], @@ -36,15 +16,6 @@ pub struct ProgramCommitment { pub vm: [u32; 8], } -impl From<&ArchivedProgramCommitment> for ProgramCommitment { - fn from(archived: &ArchivedProgramCommitment) -> Self { - Self { - exe: archived.exe.map(|u32_le| u32_le.to_native()), - vm: archived.vm.map(|u32_le| u32_le.to_native()), - } - } -} - /// Number of public-input values, i.e. [u32; N]. /// /// Note that the actual value for each u32 is a byte. diff --git a/crates/types/base/src/fork_name.rs b/crates/types/base/src/fork_name.rs index 854d4d38..172d9372 100644 --- a/crates/types/base/src/fork_name.rs +++ b/crates/types/base/src/fork_name.rs @@ -10,13 +10,9 @@ use std::fmt; Eq, PartialOrd, Ord, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, serde::Deserialize, serde::Serialize, )] -#[rkyv(derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord))] pub enum ForkName { #[default] EuclidV1, diff --git a/crates/types/base/src/public_inputs/batch.rs b/crates/types/base/src/public_inputs/batch.rs index 882d4799..aa992900 100644 --- a/crates/types/base/src/public_inputs/batch.rs +++ b/crates/types/base/src/public_inputs/batch.rs @@ -7,43 +7,25 @@ use crate::{ }; /// Represents public-input values for a batch. -#[derive( - Clone, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct BatchInfo { /// The state root before applying the batch. - #[rkyv()] pub parent_state_root: B256, /// The batch hash of the parent batch. - #[rkyv()] pub parent_batch_hash: B256, /// The state root after applying txs in the batch. - #[rkyv()] pub state_root: B256, /// The batch header hash of the batch. - #[rkyv()] pub batch_hash: B256, /// The EIP-155 chain ID of all txs in the batch. - #[rkyv()] pub chain_id: u64, /// The withdraw root of the last block in the last chunk in the batch. - #[rkyv()] pub withdraw_root: B256, /// The L1 msg queue hash at the end of the previous batch. - #[rkyv()] pub prev_msg_queue_hash: B256, /// The L1 msg queue hash at the end of the current batch. - #[rkyv()] pub post_msg_queue_hash: B256, /// Optional encryption key, used in case of domain=Validium. - #[rkyv()] pub encryption_key: Option>, } @@ -211,56 +193,3 @@ impl MultiVersionPublicInputs for BatchInfo { } } } - -/// Represents public-input values for a legacy batch, i.e. pre-validium support. -#[derive( - Clone, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] -pub struct LegacyBatchInfo { - /// The state root before applying the batch. - #[rkyv()] - pub parent_state_root: B256, - /// The batch hash of the parent batch. - #[rkyv()] - pub parent_batch_hash: B256, - /// The state root after applying txs in the batch. - #[rkyv()] - pub state_root: B256, - /// The batch header hash of the batch. - #[rkyv()] - pub batch_hash: B256, - /// The EIP-155 chain ID of all txs in the batch. - #[rkyv()] - pub chain_id: u64, - /// The withdraw root of the last block in the last chunk in the batch. - #[rkyv()] - pub withdraw_root: B256, - /// The L1 msg queue hash at the end of the previous batch. - #[rkyv()] - pub prev_msg_queue_hash: B256, - /// The L1 msg queue hash at the end of the current batch. - #[rkyv()] - pub post_msg_queue_hash: B256, -} - -impl From for LegacyBatchInfo { - fn from(value: BatchInfo) -> Self { - Self { - parent_state_root: value.parent_state_root, - parent_batch_hash: value.parent_batch_hash, - state_root: value.state_root, - batch_hash: value.batch_hash, - chain_id: value.chain_id, - withdraw_root: value.withdraw_root, - prev_msg_queue_hash: value.prev_msg_queue_hash, - post_msg_queue_hash: value.post_msg_queue_hash, - } - } -} diff --git a/crates/types/base/src/public_inputs/bundle.rs b/crates/types/base/src/public_inputs/bundle.rs index b9076d59..960e02bb 100644 --- a/crates/types/base/src/public_inputs/bundle.rs +++ b/crates/types/base/src/public_inputs/bundle.rs @@ -150,48 +150,3 @@ impl MultiVersionPublicInputs for BundleInfo { unreachable!("bundle is the last layer and is not aggregated by any other circuit"); } } - -/// Represents fields required to compute the public-inputs digest of a legacy bundle, i.e. -/// pre-valdium bundle. -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -pub struct LegacyBundleInfo { - /// The EIP-155 chain ID of all txs in the bundle. - pub chain_id: u64, - /// The L1 msg queue hash at the end of the last batch in the bundle. - /// Not a phase 1 field so we make it omitable - #[serde(default)] - pub msg_queue_hash: B256, - /// The number of batches bundled together in the bundle. - pub num_batches: u32, - /// The last finalized on-chain state root. - pub prev_state_root: B256, - /// The last finalized on-chain batch hash. - pub prev_batch_hash: B256, - /// The state root after applying every batch in the bundle. - /// - /// Upon verification of the EVM-verifiable bundle proof, this state root will be finalized - /// on-chain. - pub post_state_root: B256, - /// The batch hash of the last batch in the bundle. - /// - /// Upon verification of the EVM-verifiable bundle proof, this batch hash will be finalized - /// on-chain. - pub batch_hash: B256, - /// The withdrawals root at the last block in the last chunk in the last batch in the bundle. - pub withdraw_root: B256, -} - -impl From for LegacyBundleInfo { - fn from(value: BundleInfo) -> Self { - Self { - chain_id: value.chain_id, - msg_queue_hash: value.msg_queue_hash, - num_batches: value.num_batches, - prev_state_root: value.prev_state_root, - prev_batch_hash: value.prev_batch_hash, - post_state_root: value.post_state_root, - batch_hash: value.batch_hash, - withdraw_root: value.withdraw_root, - } - } -} diff --git a/crates/types/base/src/public_inputs/chunk.rs b/crates/types/base/src/public_inputs/chunk.rs index 26dbda09..7dccf963 100644 --- a/crates/types/base/src/public_inputs/chunk.rs +++ b/crates/types/base/src/public_inputs/chunk.rs @@ -11,17 +11,7 @@ pub const SIZE_BLOCK_CTX: usize = 52; /// Represents the version 2 of block context. /// /// The difference between v2 and v1 is that the block number field has been removed since v2. -#[derive( - Debug, - Clone, - PartialEq, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] pub struct BlockContextV2 { /// The timestamp of the block. pub timestamp: u64, @@ -35,18 +25,6 @@ pub struct BlockContextV2 { pub num_l1_msgs: u16, } -impl From<&ArchivedBlockContextV2> for BlockContextV2 { - fn from(archived: &ArchivedBlockContextV2) -> Self { - Self { - timestamp: archived.timestamp.into(), - base_fee: archived.base_fee.into(), - gas_limit: archived.gas_limit.into(), - num_txs: archived.num_txs.into(), - num_l1_msgs: archived.num_l1_msgs.into(), - } - } -} - impl From<&[u8]> for BlockContextV2 { fn from(bytes: &[u8]) -> Self { assert_eq!(bytes.len(), SIZE_BLOCK_CTX); @@ -115,54 +93,6 @@ pub struct ChunkInfo { pub encryption_key: Option>, } -/// Represents header-like information for the chunk. -#[derive( - Debug, - Clone, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] -pub struct LegacyChunkInfo { - /// The EIP-155 chain ID for all txs in the chunk. - #[rkyv()] - pub chain_id: u64, - /// The state root before applying the chunk. - #[rkyv()] - pub prev_state_root: B256, - /// The state root after applying the chunk. - #[rkyv()] - pub post_state_root: B256, - /// The withdrawals root after applying the chunk. - #[rkyv()] - pub withdraw_root: B256, - /// Digest of L1 message txs force included in the chunk. - /// It is a legacy field and can be omitted in new defination - #[rkyv()] - #[serde(default)] - pub data_hash: B256, - /// Digest of L2 tx data flattened over all L2 txs in the chunk. - #[rkyv()] - pub tx_data_digest: B256, - /// The L1 msg queue hash at the end of the previous chunk. - #[rkyv()] - pub prev_msg_queue_hash: B256, - /// The L1 msg queue hash at the end of the current chunk. - #[rkyv()] - pub post_msg_queue_hash: B256, - /// The length of rlp encoded L2 tx bytes flattened over all L2 txs in the chunk. - #[rkyv()] - pub tx_data_length: u64, - /// The block number of the first block in the chunk. - #[rkyv()] - pub initial_block_number: u64, - /// The block contexts of the blocks in the chunk. - #[rkyv()] - pub block_ctxs: Vec, -} impl std::fmt::Display for ChunkInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { // Create a wrapper struct that implements Debug @@ -193,24 +123,6 @@ impl std::fmt::Display for ChunkInfo { } } -impl From for LegacyChunkInfo { - fn from(value: ChunkInfo) -> Self { - Self { - chain_id: value.chain_id, - prev_state_root: value.prev_state_root, - post_state_root: value.post_state_root, - withdraw_root: value.withdraw_root, - data_hash: value.data_hash, - tx_data_digest: value.tx_data_digest, - prev_msg_queue_hash: value.prev_msg_queue_hash, - post_msg_queue_hash: value.post_msg_queue_hash, - tx_data_length: value.tx_data_length, - initial_block_number: value.initial_block_number, - block_ctxs: value.block_ctxs, - } - } -} - impl ChunkInfo { /// Public input hash for a given chunk (euclidv1 or da-codec@v6) is defined as /// diff --git a/crates/types/base/src/utils/mod.rs b/crates/types/base/src/utils/mod.rs index 80ac09b7..8d4665d6 100644 --- a/crates/types/base/src/utils/mod.rs +++ b/crates/types/base/src/utils/mod.rs @@ -1,3 +1,2 @@ mod hash; pub use hash::{keccak256, keccak256_rv32, sha256_rv32}; -pub use rkyv::{rancor::Error as RancorError, to_bytes as to_rkyv_bytes}; diff --git a/crates/types/batch/Cargo.toml b/crates/types/batch/Cargo.toml index 108d0c5b..e2836f22 100644 --- a/crates/types/batch/Cargo.toml +++ b/crates/types/batch/Cargo.toml @@ -9,7 +9,6 @@ version.workspace = true [dependencies] alloy-primitives = { workspace = true } -rkyv.workspace = true serde.workspace = true itertools.workspace = true vm-zstd = { workspace = true } diff --git a/crates/types/batch/src/header/mod.rs b/crates/types/batch/src/header/mod.rs index ccea3256..81c579d3 100644 --- a/crates/types/batch/src/header/mod.rs +++ b/crates/types/batch/src/header/mod.rs @@ -38,16 +38,7 @@ pub trait ValidiumBatchHeader: BatchHeader { /// Reference header indicate the version of batch header base on which batch hash /// should be calculated. -#[derive( - Clone, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub enum ReferenceHeader { /// Represents DA-codec v6. V6(v6::BatchHeaderV6), diff --git a/crates/types/batch/src/header/v6.rs b/crates/types/batch/src/header/v6.rs index d8f21247..c44862f7 100644 --- a/crates/types/batch/src/header/v6.rs +++ b/crates/types/batch/src/header/v6.rs @@ -3,45 +3,25 @@ use alloy_primitives::B256; use types_base::utils::keccak256; /// Represents the header summarising the batch of chunks as per DA-codec v6. -#[derive( - Clone, - Copy, - Debug, - Default, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Clone, Copy, Debug, Default, serde::Deserialize, serde::Serialize)] pub struct BatchHeaderV6 { /// The DA-codec version for the batch. - #[rkyv()] pub version: u8, /// The index of the batch - #[rkyv()] pub batch_index: u64, /// Number of L1 messages popped in the batch - #[rkyv()] pub l1_message_popped: u64, /// Number of total L1 messages popped after the batch - #[rkyv()] pub total_l1_message_popped: u64, /// The parent batch hash - #[rkyv()] pub parent_batch_hash: B256, /// The timestamp of the last block in this batch - #[rkyv()] pub last_block_timestamp: u64, /// The data hash of the batch - #[rkyv()] pub data_hash: B256, /// The versioned hash of the blob with this batch's data - #[rkyv()] pub blob_versioned_hash: B256, /// The blob data proof: z (32), y (32) - #[rkyv()] pub blob_data_proof: [B256; 2], } diff --git a/crates/types/batch/src/header/v7.rs b/crates/types/batch/src/header/v7.rs index bb05b1ad..69379cf8 100644 --- a/crates/types/batch/src/header/v7.rs +++ b/crates/types/batch/src/header/v7.rs @@ -4,30 +4,15 @@ use super::BatchHeader; use types_base::utils::keccak256; /// Represents the header summarising the batch of chunks as per DA-codec v7. -#[derive( - Clone, - Copy, - Debug, - Default, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Clone, Copy, Debug, Default, serde::Deserialize, serde::Serialize)] pub struct BatchHeaderV7 { /// The DA-codec version for the batch. - #[rkyv()] pub version: u8, /// The index of the batch - #[rkyv()] pub batch_index: u64, /// The parent batch hash - #[rkyv()] pub parent_batch_hash: B256, /// The versioned hash of the blob with this batch's data - #[rkyv()] pub blob_versioned_hash: B256, } diff --git a/crates/types/batch/src/header/validium.rs b/crates/types/batch/src/header/validium.rs index 6c8ded07..5d182710 100644 --- a/crates/types/batch/src/header/validium.rs +++ b/crates/types/batch/src/header/validium.rs @@ -4,56 +4,29 @@ use types_base::utils::keccak256; use super::{BatchHeader, ValidiumBatchHeader}; /// Batch header used in L3 validium. -#[derive( - Clone, - Copy, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Clone, Copy, Debug, serde::Deserialize, serde::Serialize)] pub enum BatchHeaderValidium { /// L3 validium @ v1 batch header. V1(BatchHeaderValidiumV1), } /// Represents the batch header summarising a L3 validium batch. -#[derive( - Clone, - Copy, - Debug, - Default, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] +#[derive(Clone, Copy, Debug, Default, serde::Deserialize, serde::Serialize)] pub struct BatchHeaderValidiumV1 { /// The DA-codec version for the batch. - #[rkyv()] pub version: u8, /// The index of the batch - #[rkyv()] pub batch_index: u64, /// The parent batch hash - #[rkyv()] pub parent_batch_hash: B256, /// The state root after applying the batch. - #[rkyv()] pub post_state_root: B256, /// The withdraw root post the batch. - #[rkyv()] pub withdraw_root: B256, /// A commitment that binds the batch to its payload. It also serves provability based on the /// finalised L2 data. /// /// We utilise the last L3 block's blockhash as commitment. - #[rkyv()] pub commitment: B256, } diff --git a/crates/types/batch/src/lib.rs b/crates/types/batch/src/lib.rs index 85795e1e..89d36ae0 100644 --- a/crates/types/batch/src/lib.rs +++ b/crates/types/batch/src/lib.rs @@ -1,8 +1,8 @@ mod header; pub use header::{ - ArchivedReferenceHeader, BatchHeader, ReferenceHeader, - v6::{ArchivedBatchHeaderV6, BatchHeaderV6}, - v7::{ArchivedBatchHeaderV7, BatchHeaderV7}, + BatchHeader, ReferenceHeader, + v6::BatchHeaderV6, + v7::BatchHeaderV7, validium::{BatchHeaderValidium, BatchHeaderValidiumV1}, }; @@ -17,9 +17,6 @@ pub mod blob_consistency; mod builder; mod witness; -pub use witness::{ - ArchivedLegacyBatchWitness, BatchWitness, Bytes48, LegacyBatchWitness, PointEvalWitness, - build_point_eval_witness, -}; +pub use witness::{BatchWitness, Bytes48, PointEvalWitness, build_point_eval_witness}; pub mod utils; diff --git a/crates/types/batch/src/witness.rs b/crates/types/batch/src/witness.rs index e8096df0..9eca85cb 100644 --- a/crates/types/batch/src/witness.rs +++ b/crates/types/batch/src/witness.rs @@ -1,11 +1,7 @@ use halo2curves_axiom::CurveAffine; use types_base::{ aggregation::{AggregationInput, ProofCarryingWitness}, - public_inputs::{ - ForkName, - batch::BatchInfo, - chunk::{ChunkInfo, LegacyChunkInfo}, - }, + public_inputs::{ForkName, batch::BatchInfo, chunk::ChunkInfo}, }; use crate::{ @@ -53,41 +49,6 @@ pub struct PointEvalWitness { pub kzg_proof_y: Bytes48, } -/// Witness required by applying point evaluation -#[derive( - Clone, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] -pub struct LegacyPointEvalWitness { - /// kzg commitment - #[rkyv()] - #[serde(with = "array48")] - pub kzg_commitment: Bytes48, - /// kzg proof - #[rkyv()] - #[serde(with = "array48")] - pub kzg_proof: Bytes48, -} - -impl From for LegacyPointEvalWitness { - fn from(value: PointEvalWitness) -> Self { - Self { - kzg_commitment: build_point(value.kzg_commitment_x, value.kzg_commitment_y) - .unwrap() - .to_compressed_be(), - kzg_proof: build_point(value.kzg_proof_x, value.kzg_proof_y) - .unwrap() - .to_compressed_be(), - } - } -} - pub fn build_point_eval_witness(kzg_commitment: Bytes48, kzg_proof: Bytes48) -> PointEvalWitness { use halo2curves_axiom::bls12_381::G1Affine; let kzg_commitment = G1Affine::from_compressed_be(&kzg_commitment).expect("invalid"); @@ -142,55 +103,6 @@ pub struct BatchWitness { pub fork_name: ForkName, } -/// Witness to the batch circuit. -#[derive( - Clone, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] -pub struct LegacyBatchWitness { - /// Flattened root proofs from all chunks in the batch. - #[rkyv()] - pub chunk_proofs: Vec, - /// Chunk infos. - #[rkyv()] - pub chunk_infos: Vec, - /// Blob bytes. - #[rkyv()] - pub blob_bytes: Vec, - /// Witness for point evaluation - #[rkyv()] - pub point_eval_witness: LegacyPointEvalWitness, - /// Header for reference. - #[rkyv()] - pub reference_header: ReferenceHeader, - /// The code version specify the chain spec - #[rkyv()] - pub fork_name: ForkName, -} - -impl From for LegacyBatchWitness { - fn from(value: BatchWitness) -> Self { - let point_eval_witness = value.point_eval_witness.expect("should not be none"); - Self { - chunk_proofs: value.chunk_proofs, - chunk_infos: value.chunk_infos.into_iter().map(|c| c.into()).collect(), - blob_bytes: value.blob_bytes, - point_eval_witness: point_eval_witness.clone().into(), - reference_header: match value.fork_name { - ForkName::Feynman => value.reference_header.into_v8_feynman(), - _ => unreachable!("0.5.2 expects fork=Feynman"), - }, - fork_name: value.fork_name, - } - } -} - impl ProofCarryingWitness for BatchWitness { fn get_proofs(&self) -> Vec { self.chunk_proofs.clone() diff --git a/crates/types/bundle/Cargo.toml b/crates/types/bundle/Cargo.toml index 0304e485..4a8fc4aa 100644 --- a/crates/types/bundle/Cargo.toml +++ b/crates/types/bundle/Cargo.toml @@ -8,7 +8,6 @@ repository.workspace = true version.workspace = true [dependencies] -rkyv.workspace = true serde.workspace = true types-base = { path = "../base", package = "scroll-zkvm-types-base"} diff --git a/crates/types/bundle/src/lib.rs b/crates/types/bundle/src/lib.rs index 622170a7..ec12827d 100644 --- a/crates/types/bundle/src/lib.rs +++ b/crates/types/bundle/src/lib.rs @@ -1,2 +1,2 @@ mod witness; -pub use witness::{ArchivedLegacyBundleWitness, BundleWitness, LegacyBundleWitness}; +pub use witness::BundleWitness; diff --git a/crates/types/bundle/src/witness.rs b/crates/types/bundle/src/witness.rs index 71417ac6..20e31252 100644 --- a/crates/types/bundle/src/witness.rs +++ b/crates/types/bundle/src/witness.rs @@ -1,10 +1,7 @@ use types_base::{ aggregation::{AggregationInput, ProofCarryingWitness}, fork_name::ForkName, - public_inputs::{ - batch::{BatchInfo, LegacyBatchInfo}, - bundle::BundleInfo, - }, + public_inputs::{batch::BatchInfo, bundle::BundleInfo}, }; /// The witness for the bundle circuit. @@ -20,39 +17,6 @@ pub struct BundleWitness { pub fork_name: ForkName, } -/// The witness for the bundle circuit. -#[derive( - Clone, - Debug, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, - serde::Deserialize, - serde::Serialize, -)] -#[rkyv(derive(Debug))] -pub struct LegacyBundleWitness { - /// Batch proofs being aggregated in the bundle. - #[rkyv()] - pub batch_proofs: Vec, - /// Public-input values for the corresponding batch proofs. - #[rkyv()] - pub batch_infos: Vec, - /// The code version specify the chain spec - #[rkyv()] - pub fork_name: ForkName, -} - -impl From for LegacyBundleWitness { - fn from(value: BundleWitness) -> Self { - Self { - batch_proofs: value.batch_proofs, - batch_infos: value.batch_infos.into_iter().map(|c| c.into()).collect(), - fork_name: value.fork_name, - } - } -} - impl ProofCarryingWitness for BundleWitness { fn get_proofs(&self) -> Vec { self.batch_proofs.clone() diff --git a/crates/types/chunk/Cargo.toml b/crates/types/chunk/Cargo.toml index 0d758c68..3b1731b4 100644 --- a/crates/types/chunk/Cargo.toml +++ b/crates/types/chunk/Cargo.toml @@ -13,10 +13,8 @@ alloy-consensus = { workspace = true, features = ["crypto-backend"] } alloy-sol-types.workspace = true ecies.workspace = true itertools.workspace = true -#revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74", default-features=false, features = ["kzg-rs", "libsecp256k1"] } -rkyv.workspace = true sbv-helpers.workspace = true -sbv-core = { workspace = true, features = ["rkyv"] } +sbv-core = { workspace = true, features = [] } sbv-trie = { workspace = true } sbv-primitives = { workspace = true, features = ["hardforks", "evm-types", "revm-types", "reth-evm-types"] } serde.workspace = true diff --git a/crates/types/chunk/src/lib.rs b/crates/types/chunk/src/lib.rs index b47e7996..c7240a4b 100644 --- a/crates/types/chunk/src/lib.rs +++ b/crates/types/chunk/src/lib.rs @@ -1,6 +1,5 @@ mod crypto; pub use crypto::Crypto; -//pub use witness::{ChunkWitness, LegacyChunkWitness, ValidiumInputs}; #[cfg(feature = "scroll")] mod scroll; diff --git a/crates/types/chunk/src/scroll.rs b/crates/types/chunk/src/scroll.rs index 4e0ad631..4e241894 100644 --- a/crates/types/chunk/src/scroll.rs +++ b/crates/types/chunk/src/scroll.rs @@ -5,4 +5,4 @@ mod execute; pub use execute::execute; mod witness; -pub use witness::{ChunkWitness, ChunkWitnessUpgradeCompact, LegacyChunkWitness, ValidiumInputs}; +pub use witness::{ChunkWitness, ValidiumInputs}; diff --git a/crates/types/chunk/src/scroll/witness.rs b/crates/types/chunk/src/scroll/witness.rs index dff158a5..64e88a90 100644 --- a/crates/types/chunk/src/scroll/witness.rs +++ b/crates/types/chunk/src/scroll/witness.rs @@ -1,7 +1,6 @@ use super::types::validium::SecretKey; use alloy_primitives::B256; -use sbv_core::{verifier::StateCommitMode, witness::BlockWitness}; -use sbv_primitives::U256; +use sbv_core::witness::BlockWitness; use sbv_primitives::types::consensus::TxL1Message; use sbv_primitives::types::evm::ScrollTxCompressionInfos; use std::collections::HashSet; @@ -34,47 +33,6 @@ pub struct ValidiumInputs { pub secret_key: Box<[u8]>, } -/// The witness type accepted by last version chunk-circuit. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ChunkWitnessUpgradeCompact { - /// Version byte as per [version][types_base::version]. - pub version: u8, - /// The block witness for each block in the chunk. - pub blocks: Vec, - /// The on-chain rolling L1 message queue hash before enqueueing any L1 msg tx from the chunk. - pub prev_msg_queue_hash: B256, - /// The code version specify the chain spec - pub fork_name: ForkName, - /// The compression ratios for each block in the chunk. - pub compression_ratios: Vec>, - /// Validium encrypted txs and secret key if this is a validium chain. - pub validium: Option, -} - -/// The witness type accepted by the chunk-circuit. -#[derive( - Clone, - Debug, - serde::Deserialize, - serde::Serialize, - rkyv::Archive, - rkyv::Deserialize, - rkyv::Serialize, -)] -#[rkyv(derive(Debug))] -pub struct LegacyChunkWitness { - /// The block witness for each block in the chunk. - pub blocks: Vec, - /// The on-chain rolling L1 message queue hash before enqueueing any L1 msg tx from the chunk. - pub prev_msg_queue_hash: B256, - /// The code version specify the chain spec - pub fork_name: ForkName, - /// The compression ratios for each block in the chunk. - pub compression_ratios: Vec>, - /// The mode of state commitment for the chunk. - pub state_commit_mode: StateCommitMode, -} - #[derive(Clone, Debug)] pub struct ChunkDetails { pub num_blocks: usize, @@ -191,40 +149,3 @@ impl TryFrom for ChunkInfo { crate::execute(value) } } - -impl From for LegacyChunkWitness { - fn from(value: ChunkWitness) -> Self { - LegacyChunkWitness { - blocks: value - .blocks - .into_iter() - .map(|block| block.into_legacy()) - .collect(), - prev_msg_queue_hash: value.prev_msg_queue_hash, - fork_name: value.fork_name, - compression_ratios: value - .compression_infos - .iter() - .map(|compression_infos| compression_infos.iter().map(|v| v.0).collect()) - .collect(), - state_commit_mode: StateCommitMode::Auto, - } - } -} - -impl From for ChunkWitnessUpgradeCompact { - fn from(value: ChunkWitness) -> Self { - ChunkWitnessUpgradeCompact { - version: value.version, - blocks: value.blocks, - prev_msg_queue_hash: value.prev_msg_queue_hash, - fork_name: value.fork_name, - compression_ratios: value - .compression_infos - .iter() - .map(|compression_infos| compression_infos.iter().map(|v| v.0).collect()) - .collect(), - validium: value.validium, - } - } -} diff --git a/crates/types/src/zkvm.rs b/crates/types/src/zkvm.rs index b89e4482..cbf97a5c 100644 --- a/crates/types/src/zkvm.rs +++ b/crates/types/src/zkvm.rs @@ -1,69 +1,11 @@ -// This should be removed after we fully migrated to openvm 1.4 after protocol upgrade. use once_cell::sync::Lazy; use openvm_sdk::Sdk; use openvm_sdk::keygen::AggProvingKey; -use std::sync::Arc; - -mod openvm_private_patch { - // copied from openvm/crates/sdk/src/keygen/perm.rs - use std::cmp::Reverse; - - /// Permutation of the AIR IDs to order them by forced trace heights. - pub(crate) struct AirIdPermutation { - pub perm: Vec, - } - - impl AirIdPermutation { - pub fn compute(heights: &[u32]) -> AirIdPermutation { - let mut height_with_air_id: Vec<_> = heights.iter().copied().enumerate().collect(); - height_with_air_id.sort_by_key(|(_, h)| Reverse(*h)); - AirIdPermutation { - perm: height_with_air_id - .into_iter() - .map(|(a_id, _)| a_id) - .collect(), - } - } - /// arr[i] <- arr[perm[i]] - pub(crate) fn permute(&self, arr: &mut [T]) { - debug_assert_eq!(arr.len(), self.perm.len()); - let mut perm = self.perm.clone(); - for i in 0..perm.len() { - if perm[i] != i { - let mut curr = i; - loop { - let target = perm[curr]; - perm[curr] = curr; - if perm[target] == target { - break; - } - arr.swap(curr, target); - curr = target; - } - } - } - } - } -} /// Proving key for STARK aggregation. Primarily used to aggregate /// [continuation proofs][openvm_sdk::prover::vm::ContinuationVmProof]. -pub static AGG_STARK_PROVING_KEY: Lazy = Lazy::new(|| build_agg_pk(false)); -pub static AGG_STARK_PROVING_KEY_V13: Lazy = Lazy::new(|| build_agg_pk(true)); - -fn build_agg_pk(legacy_v13: bool) -> AggProvingKey { - let mut agg_pk = Sdk::riscv32().agg_pk().clone(); - if !legacy_v13 { - // it is a bit confusing.. - // we plan to enable `feature = "legacy-v1-3-evm-verifier"`, - // so here we need to mimic v14 behavior - let root_air_perm = - openvm_private_patch::AirIdPermutation::compute(&agg_pk.root_verifier_pk.air_heights); - let vm_pk = Arc::get_mut(&mut agg_pk.root_verifier_pk.vm_pk).unwrap(); - for thc in &mut vm_pk.vm_pk.trace_height_constraints { - root_air_perm.permute(&mut thc.coefficients); - } - } +pub static AGG_STARK_PROVING_KEY: Lazy = Lazy::new(|| build_agg_pk()); - agg_pk +fn build_agg_pk() -> AggProvingKey { + Sdk::riscv32().agg_pk().clone() } diff --git a/crates/verifier/src/verifier.rs b/crates/verifier/src/verifier.rs index 38aca119..8e37342e 100644 --- a/crates/verifier/src/verifier.rs +++ b/crates/verifier/src/verifier.rs @@ -5,12 +5,11 @@ use scroll_zkvm_types::proof::OpenVmEvmProof; use scroll_zkvm_types::{proof::StarkProof, utils::serialize_vk}; use std::path::Path; -pub use scroll_zkvm_types::zkvm::{AGG_STARK_PROVING_KEY, AGG_STARK_PROVING_KEY_V13}; +pub use scroll_zkvm_types::zkvm::AGG_STARK_PROVING_KEY; pub struct UniversalVerifier { pub evm_verifier: Vec, pub loaded_agg_vk: AggVerifyingKey, - pub is_openvm_v13: bool, } impl UniversalVerifier { @@ -49,34 +48,16 @@ impl UniversalVerifier { let path_agg_vk = path_verifier.as_ref().join("root_verifier_vk"); let evm_verifier = std::fs::read(path_verifier_code)?; - // TODO: clean this after we get rid of openvm v1.3. - let is_openvm_v13 = { - let hash = sha256::digest(&evm_verifier); - // from 0.5.2 and 0.5.6 release files - let is_openvm_v13 = hash - == ("4f1b70db9fade2ce7425924dc662d75c5a315f3a611ed8cadd68b516407a4cf1") - || hash == ("d1f7a8066bd45c1bb82b73c7a7138d5793589fb8c6b2eb3c74b94db63109501d"); - println!( - "is_openvm_v13: {}, verifier.bin sha256sum: {}", - is_openvm_v13, hash - ); - is_openvm_v13 - }; let loaded_agg_vk = openvm_sdk::fs::read_object_from_file(path_agg_vk).unwrap_or_else( |_|{ tracing::warn!("root_Verifier_vk is not avaliable in disk, try to calculate it on-the-fly, which may be time consuming ..."); - if is_openvm_v13 { - AGG_STARK_PROVING_KEY_V13.get_agg_vk() - } else { - AGG_STARK_PROVING_KEY.get_agg_vk() - } + AGG_STARK_PROVING_KEY.get_agg_vk() } ); Ok(Self { evm_verifier, loaded_agg_vk, - is_openvm_v13, }) }