diff --git a/Cargo.lock b/Cargo.lock index f73e8a9262..155c0de02c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8779,7 +8779,7 @@ dependencies = [ [[package]] name = "scroll-zkvm-prover" version = "0.7.0" -source = "git+https://github.com/scroll-tech/zkvm-prover?branch=feat%2Fgalileo#90e7ede94329e73ca2c79c956caf1f9490732d41" +source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.4#db70d808b717aeaebb066cb1603e14d3b10e51c7" dependencies = [ "base64 0.22.1", "bincode 1.3.3", @@ -8806,7 +8806,7 @@ dependencies = [ [[package]] name = "scroll-zkvm-types" version = "0.7.0" -source = "git+https://github.com/scroll-tech/zkvm-prover?branch=feat%2Fgalileo#90e7ede94329e73ca2c79c956caf1f9490732d41" +source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.4#db70d808b717aeaebb066cb1603e14d3b10e51c7" dependencies = [ "alloy-primitives", "base64 0.22.1", @@ -8830,7 +8830,7 @@ dependencies = [ [[package]] name = "scroll-zkvm-types-base" version = "0.7.0" -source = "git+https://github.com/scroll-tech/zkvm-prover?branch=feat%2Fgalileo#90e7ede94329e73ca2c79c956caf1f9490732d41" +source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.4#db70d808b717aeaebb066cb1603e14d3b10e51c7" dependencies = [ "alloy-primitives", "alloy-serde 1.0.41", @@ -8843,7 +8843,7 @@ dependencies = [ [[package]] name = "scroll-zkvm-types-batch" version = "0.7.0" -source = "git+https://github.com/scroll-tech/zkvm-prover?branch=feat%2Fgalileo#90e7ede94329e73ca2c79c956caf1f9490732d41" +source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.4#db70d808b717aeaebb066cb1603e14d3b10e51c7" dependencies = [ "alloy-primitives", "c-kzg", @@ -8865,7 +8865,7 @@ dependencies = [ [[package]] name = "scroll-zkvm-types-bundle" version = "0.7.0" -source = "git+https://github.com/scroll-tech/zkvm-prover?branch=feat%2Fgalileo#90e7ede94329e73ca2c79c956caf1f9490732d41" +source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.4#db70d808b717aeaebb066cb1603e14d3b10e51c7" dependencies = [ "rkyv", "scroll-zkvm-types-base", @@ -8875,7 +8875,7 @@ dependencies = [ [[package]] name = "scroll-zkvm-types-chunk" version = "0.7.0" -source = "git+https://github.com/scroll-tech/zkvm-prover?branch=feat%2Fgalileo#90e7ede94329e73ca2c79c956caf1f9490732d41" +source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.4#db70d808b717aeaebb066cb1603e14d3b10e51c7" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -8900,7 +8900,7 @@ dependencies = [ [[package]] name = "scroll-zkvm-verifier" version = "0.7.0" -source = "git+https://github.com/scroll-tech/zkvm-prover?branch=feat%2Fgalileo#90e7ede94329e73ca2c79c956caf1f9490732d41" +source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.4#db70d808b717aeaebb066cb1603e14d3b10e51c7" dependencies = [ "bincode 1.3.3", "eyre", diff --git a/Cargo.toml b/Cargo.toml index 792dfc4ffa..197077e996 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,9 +17,9 @@ repository = "https://github.com/scroll-tech/scroll" version = "4.7.1" [workspace.dependencies] -scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", branch = "feat/galileo" } -scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", branch = "feat/galileo" } -scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", branch = "feat/galileo" } +scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0-rc.4" } +scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0-rc.4" } +scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0-rc.4" } sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91", features = ["scroll", "rkyv"] } sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91" } diff --git a/crates/libzkp/src/lib.rs b/crates/libzkp/src/lib.rs index f873bc5861..99609ee02f 100644 --- a/crates/libzkp/src/lib.rs +++ b/crates/libzkp/src/lib.rs @@ -7,7 +7,7 @@ pub use verifier::{TaskType, VerifierConfig}; mod utils; use sbv_primitives::B256; -use scroll_zkvm_types::utils::vec_as_base64; +use scroll_zkvm_types::{utils::vec_as_base64, version::Version}; use serde::{Deserialize, Serialize}; use serde_json::value::RawValue; use std::{collections::HashMap, path::Path, sync::OnceLock}; @@ -138,35 +138,56 @@ pub fn gen_universal_task( let mut task = serde_json::from_str::(task_json)?; // normailze fork name field in task task.fork_name = task.fork_name.to_lowercase(); + let version = Version::from(task.version); // always respect the fork_name_str (which has been normalized) being passed // if the fork_name wrapped in task is not match, consider it a malformed task if fork_name_str != task.fork_name.as_str() { eyre::bail!("fork name in chunk task not match the calling arg, expected {fork_name_str}, get {}", task.fork_name); } + if fork_name_str != version.fork.as_str() { + eyre::bail!( + "given task version, expected fork={fork_name_str}, got={version_fork}", + version_fork = version.fork.as_str() + ); + } let (pi_hash, metadata, u_task) = - utils::panic_catch(move || gen_universal_chunk_task(task, fork_name_str.into())) + utils::panic_catch(move || gen_universal_chunk_task(task)) .map_err(|e| eyre::eyre!("caught panic in chunk task{e}"))??; (pi_hash, AnyMetaData::Chunk(metadata), u_task) } x if x == TaskType::Batch as i32 => { let mut task = serde_json::from_str::(task_json)?; task.fork_name = task.fork_name.to_lowercase(); + let version = Version::from(task.version); if fork_name_str != task.fork_name.as_str() { eyre::bail!("fork name in batch task not match the calling arg, expected {fork_name_str}, get {}", task.fork_name); } + if fork_name_str != version.fork.as_str() { + eyre::bail!( + "given task version, expected fork={fork_name_str}, got={version_fork}", + version_fork = version.fork.as_str() + ); + } let (pi_hash, metadata, u_task) = - utils::panic_catch(move || gen_universal_batch_task(task, fork_name_str.into())) + utils::panic_catch(move || gen_universal_batch_task(task)) .map_err(|e| eyre::eyre!("caught panic in chunk task{e}"))??; (pi_hash, AnyMetaData::Batch(metadata), u_task) } x if x == TaskType::Bundle as i32 => { let mut task = serde_json::from_str::(task_json)?; task.fork_name = task.fork_name.to_lowercase(); + let version = Version::from(task.version); if fork_name_str != task.fork_name.as_str() { eyre::bail!("fork name in bundle task not match the calling arg, expected {fork_name_str}, get {}", task.fork_name); } + if fork_name_str != version.fork.as_str() { + eyre::bail!( + "given task version, expected fork={fork_name_str}, got={version_fork}", + version_fork = version.fork.as_str() + ); + } let (pi_hash, metadata, u_task) = - utils::panic_catch(move || gen_universal_bundle_task(task, fork_name_str.into())) + utils::panic_catch(move || gen_universal_bundle_task(task)) .map_err(|e| eyre::eyre!("caught panic in chunk task{e}"))??; (pi_hash, AnyMetaData::Bundle(metadata), u_task) } @@ -233,9 +254,11 @@ pub fn verifier_init(config: &str) -> eyre::Result<()> { ); ( config.fork_name.to_lowercase(), - config.features.as_ref() - .map(|features| FeatureOptions::new(features.as_str())) - .unwrap_or_default() + config + .features + .as_ref() + .map(|features| FeatureOptions::new(features.as_str())) + .unwrap_or_default(), ) }))) .map_err(|c| eyre::eyre!("Fail to init additional features: {c:?}"))?; diff --git a/crates/libzkp/src/proofs.rs b/crates/libzkp/src/proofs.rs index f57d3fdf05..e6f66b19ae 100644 --- a/crates/libzkp/src/proofs.rs +++ b/crates/libzkp/src/proofs.rs @@ -140,8 +140,6 @@ impl ProofMetadata for ChunkProofMetadata { pub struct BatchProofMetadata { /// The batch information describing the list of chunks. pub batch_info: BatchInfo, - /// The [`scroll_zkvm_types::batch::BatchHeader`]'s digest. - pub batch_hash: B256, } impl ProofMetadata for BatchProofMetadata { diff --git a/crates/libzkp/src/tasks.rs b/crates/libzkp/src/tasks.rs index bce064da30..f80e58def8 100644 --- a/crates/libzkp/src/tasks.rs +++ b/crates/libzkp/src/tasks.rs @@ -14,7 +14,7 @@ use crate::{ utils::panic_catch, }; use sbv_primitives::B256; -use scroll_zkvm_types::public_inputs::{ForkName, MultiVersionPublicInputs, Version}; +use scroll_zkvm_types::public_inputs::{MultiVersionPublicInputs, Version}; fn encode_task_to_witness(task: &T) -> eyre::Result> { let config = bincode::config::standard(); @@ -61,7 +61,6 @@ impl ProvintTaskExt { /// Generate required staff for chunk proving pub fn gen_universal_chunk_task( task: ChunkProvingTask, - _: ForkName, ) -> eyre::Result<(B256, ChunkProofMetadata, ProvingTask)> { let chunk_total_gas = task.stats().total_gas_used; let (chunk_info, pi_hash) = task.precheck_and_build_metadata()?; @@ -79,17 +78,12 @@ pub fn gen_universal_chunk_task( /// Generate required staff for batch proving pub fn gen_universal_batch_task( task: BatchProvingTask, - _: ForkName, ) -> eyre::Result<(B256, BatchProofMetadata, ProvingTask)> { - let (batch_info, batch_hash) = task.precheck_and_build_metadata()?; + let (batch_info, batch_pi_hash) = task.precheck_and_build_metadata()?; let proving_task = task.try_into()?; - Ok(( - batch_hash, - BatchProofMetadata { - batch_info, - batch_hash, - }, + batch_pi_hash, + BatchProofMetadata { batch_info }, proving_task, )) } @@ -97,11 +91,9 @@ pub fn gen_universal_batch_task( /// Generate required staff for bundle proving pub fn gen_universal_bundle_task( task: BundleProvingTask, - _: ForkName, ) -> eyre::Result<(B256, BundleProofMetadata, ProvingTask)> { let (bundle_info, bundle_pi_hash) = task.precheck_and_build_metadata()?; let proving_task = task.try_into()?; - Ok(( bundle_pi_hash, BundleProofMetadata { diff --git a/crates/libzkp/src/tasks/batch.rs b/crates/libzkp/src/tasks/batch.rs index e02b3f073c..146e5a023f 100644 --- a/crates/libzkp/src/tasks/batch.rs +++ b/crates/libzkp/src/tasks/batch.rs @@ -3,12 +3,12 @@ use eyre::Result; use sbv_primitives::{B256, U256}; use scroll_zkvm_types::{ batch::{ - build_point_eval_witness, BatchHeader, BatchHeaderV6, BatchHeaderV7, BatchHeaderV8, - BatchHeaderValidium, BatchInfo, BatchWitness, Envelope, EnvelopeV6, EnvelopeV7, EnvelopeV8, - LegacyBatchWitness, ReferenceHeader, N_BLOB_BYTES, + build_point_eval_witness, BatchHeader, BatchHeaderV6, BatchHeaderV7, BatchHeaderValidium, + BatchInfo, BatchWitness, Envelope, EnvelopeV6, EnvelopeV7, LegacyBatchWitness, + ReferenceHeader, N_BLOB_BYTES, }, chunk::ChunkInfo, - public_inputs::{ForkName, Version, MultiVersionPublicInputs}, + public_inputs::{ForkName, MultiVersionPublicInputs, Version}, task::ProvingTask, utils::{to_rkyv_bytes, RancorError}, version::{Codec, Domain, STFVersion}, @@ -34,6 +34,7 @@ pub struct BatchHeaderValidiumWithHash { /// defination, i.e. v6- v8 (current), and validium #[derive(Clone, serde::Deserialize, serde::Serialize)] #[serde(untagged)] +#[allow(non_camel_case_types)] pub enum BatchHeaderV { /// Header for validium mode. Validium(BatchHeaderValidiumWithHash), @@ -43,14 +44,14 @@ pub enum BatchHeaderV { /// /// Since the codec essentially is unchanged for the above STF versions, we do not define new /// variants, instead re-using the [`BatchHeaderV7`] variant. - V7_8_9(BatchHeaderV7), + V7_V8_V9(BatchHeaderV7), } impl core::fmt::Display for BatchHeaderV { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { BatchHeaderV::V6(_) => write!(f, "V6"), - BatchHeaderV::V7_8_9(_) => write!(f, "V7_8_9"), + BatchHeaderV::V7_V8_V9(_) => write!(f, "V7_V8_V9"), BatchHeaderV::Validium(_) => write!(f, "Validium"), } } @@ -60,7 +61,7 @@ impl BatchHeaderV { pub fn batch_hash(&self) -> B256 { match self { BatchHeaderV::V6(h) => h.batch_hash(), - BatchHeaderV::V7_8_9(h) => h.batch_hash(), + BatchHeaderV::V7_V8_V9(h) => h.batch_hash(), BatchHeaderV::Validium(h) => h.header.batch_hash(), } } @@ -72,17 +73,10 @@ impl BatchHeaderV { } } - pub fn must_v7_header(&self) -> &BatchHeaderV7 { + pub fn must_v7_v8_v9_header(&self) -> &BatchHeaderV7 { match self { - BatchHeaderV::V7_8_9(h) => h, - _ => unreachable!("A header of {} is considered to be v7", self), - } - } - - pub fn must_v8_header(&self) -> &BatchHeaderV8 { - match self { - BatchHeaderV::V7_8_9(h) => h, - _ => unreachable!("A header of {} is considered to be v8", self), + BatchHeaderV::V7_V8_V9(h) => h, + _ => unreachable!("A header of {} is considered to be in [v7, v8, v9]", self), } } @@ -162,10 +156,8 @@ impl BatchProvingTask { version.fork, ForkName::EuclidV1, ), - BatchHeaderV::V7_8_9(_) => assert!( - version.fork == ForkName::EuclidV2 || - version.fork == ForkName::Feynman || - version.fork == ForkName::Galileo, + BatchHeaderV::V7_V8_V9(_) => assert!( + matches!(version.fork, ForkName::EuclidV2 | ForkName::Feynman | ForkName::Galileo), "hardfork mismatch for da-codec@v7/8/9 header: found={}, expected={:?}", version.fork, [ForkName::EuclidV2, ForkName::Feynman, ForkName::Galileo], @@ -192,8 +184,6 @@ impl BatchProvingTask { } Codec::V7 => ::from_slice(padded_blob_bytes.as_slice()) .challenge_digest(versioned_hash), - Codec::V8 => ::from_slice(padded_blob_bytes.as_slice()) - .challenge_digest(versioned_hash), }; let (proof, _) = point_eval::get_kzg_proof(&blob, challenge_digest); @@ -242,9 +232,6 @@ impl BatchProvingTask { (Domain::Scroll, STFVersion::V6) => { ReferenceHeader::V6(*self.batch_header.must_v6_header()) } - (Domain::Scroll, STFVersion::V7) => { - ReferenceHeader::V7(*self.batch_header.must_v7_header()) - } // The da-codec for STF versions v7, v8, v9 is identical. In zkvm-prover we do not // create additional variants to indicate the identical behaviour of codec. Instead we // add a separate variant for the STF version. @@ -255,8 +242,8 @@ impl BatchProvingTask { // hard-fork (feynman or galileo) and the codec from the version byte. // // Refer [`scroll_zkvm_types::public_inputs::Version`]. - (Domain::Scroll, STFVersion::V8) | (Domain::Scroll, STFVersion::V9) => { - ReferenceHeader::V8(*self.batch_header.must_v8_header()) + (Domain::Scroll, STFVersion::V7 | STFVersion::V8 | STFVersion::V9) => { + ReferenceHeader::V7_V8_V9(*self.batch_header.must_v7_v8_v9_header()) } (Domain::Validium, STFVersion::V1) => { ReferenceHeader::Validium(*self.batch_header.must_validium_header()) diff --git a/crates/libzkp/src/tasks/bundle.rs b/crates/libzkp/src/tasks/bundle.rs index c42595bea7..1ea0d2710a 100644 --- a/crates/libzkp/src/tasks/bundle.rs +++ b/crates/libzkp/src/tasks/bundle.rs @@ -2,7 +2,7 @@ use eyre::Result; use sbv_primitives::B256; use scroll_zkvm_types::{ bundle::{BundleInfo, BundleWitness, LegacyBundleWitness}, - public_inputs::{Version, MultiVersionPublicInputs}, + public_inputs::{MultiVersionPublicInputs, Version}, task::ProvingTask, utils::{to_rkyv_bytes, RancorError}, }; @@ -33,11 +33,13 @@ impl BundleProvingTask { .first() .expect(BUNDLE_SANITY_MSG) .metadata + .batch_info .batch_hash, self.batch_proofs .last() .expect(BUNDLE_SANITY_MSG) .metadata + .batch_info .batch_hash, ); diff --git a/crates/libzkp/src/tasks/chunk.rs b/crates/libzkp/src/tasks/chunk.rs index 4469eb9345..e857eb8e9c 100644 --- a/crates/libzkp/src/tasks/chunk.rs +++ b/crates/libzkp/src/tasks/chunk.rs @@ -3,9 +3,9 @@ use sbv_core::BlockWitness; use sbv_primitives::{types::consensus::BlockHeader, B256}; use scroll_zkvm_types::{ chunk::{execute, ChunkInfo, ChunkWitness, LegacyChunkWitness, ValidiumInputs}, + public_inputs::{MultiVersionPublicInputs, Version}, task::ProvingTask, utils::{to_rkyv_bytes, RancorError}, - public_inputs::{Version, MultiVersionPublicInputs}, }; use super::chunk_interpreter::*;