Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
87 changes: 42 additions & 45 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ openvm-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v
# more openvm related libs
openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.2.1" }

sbv-core = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91" }
sbv-helpers = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91", features = ["dev"] }
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91" }
sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91" }
sbv-trie = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91" }
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"] }
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2" }
sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2" }
sbv-trie = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91.2" }

alloy-consensus = "1.0"
alloy-provider = "1.0"
Expand Down
8 changes: 4 additions & 4 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::{Sdk, StdIn};
use openvm_sdk::StdIn;
use scroll_zkvm_prover::{
Prover,
setup::{read_app_config, read_app_exe},
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn testing_hardfork() -> ForkName {

/// Test settings (version).
pub fn testing_version() -> Version {
Version::galileo()
Version::galileo_v2()
}

pub fn testing_version_validium() -> Version {
Expand Down Expand Up @@ -367,8 +367,8 @@ pub fn tester_execute<T: ProverTester>(
.map(|p| p.as_stark_proof().expect("must be stark proof")),
)?;

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

Expand Down
11 changes: 11 additions & 0 deletions crates/integration/src/testers/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ pub fn preset_chunk() -> ChunkTaskGenerator {
ForkName::EuclidV2 => (Version::euclid_v2(), 1u64..=4u64),
ForkName::Feynman => (Version::feynman(), 16525000u64..=16525003u64),
ForkName::Galileo => (Version::galileo(), 20239156..=20239235),
// TODO(rohit): update after adding testdata.
ForkName::GalileoV2 => (Version::galileo_v2(), 20239156..=20239235),
};

ChunkTaskGenerator {
Expand Down Expand Up @@ -289,6 +291,15 @@ pub fn preset_chunk_multiple() -> Vec<ChunkTaskGenerator> {
],
Version::galileo(),
),
ForkName::GalileoV2 => (
// TODO(rohit): update after adding testdata.
vec![
20239220..=20239220,
20239221..=20239221,
20239222..=20239222,
],
Version::galileo_v2(),
),
};
create_canonical_tasks(version, block_range.into_iter())
.expect("must success for preset collections")
Expand Down
7 changes: 6 additions & 1 deletion crates/integration/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub fn build_batch_witnesses(
blob_data_proof: point_evaluations.map(|u| B256::new(u.to_be_bytes())),
})
}
ForkName::EuclidV2 | ForkName::Feynman | ForkName::Galileo => {
ForkName::EuclidV2 | ForkName::Feynman | ForkName::Galileo | ForkName::GalileoV2 => {
use scroll_zkvm_types::batch::BatchHeaderV7;
ReferenceHeader::V7_V8_V9(BatchHeaderV7 {
version: last_header.version,
Expand Down Expand Up @@ -431,6 +431,11 @@ fn test_build_and_parse_batch_task() -> eyre::Result<()> {
block_range: (20239156..=20239192).collect(),
..Default::default()
},
// TODO(rohit): update after adding testdata.
ForkName::GalileoV2 => ChunkTaskGenerator {
block_range: (20239156..=20239192).collect(),
..Default::default()
},
}
.get_or_build_witness()?;

Expand Down
9 changes: 9 additions & 0 deletions crates/integration/tests/batch_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ fn verify_batch_hash_invariant() -> eyre::Result<()> {
20239176..=20239192,
],
),
ForkName::GalileoV2 => (
Version::galileo_v2(),
// TODO(rohit): update after adding testdata.
vec![
20239156..=20239162,
20239163..=20239175,
20239176..=20239192,
],
),
};
let outcome_2 = create_canonical_tasks(version, block_range.into_iter())?;

Expand Down
2 changes: 2 additions & 0 deletions crates/integration/tests/bundle_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ fn e2e_inner(
ForkName::EuclidV2 => "2028510c403837c6ed77660fd92814ba61d7b746e7268cc8dfc14d163d45e6bd",
ForkName::Feynman => "80523a61b2b94b2922638ec90edd084b1022798e1e5539c3a079d2b0736e4f32",
ForkName::Galileo => "86290e8c329dd2ec430df4a8b2ae8396b3996b3e814afff24b7cedeb26387087",
// TODO(rohit): update after adding testdata.
ForkName::GalileoV2 => "86290e8c329dd2ec430df4a8b2ae8396b3996b3e814afff24b7cedeb26387087",
};
let expected_pi_hash = metadata.pi_hash_by_version(version);
// sanity check for pi of bundle hash, update the expected hash if block witness changed
Expand Down
4 changes: 3 additions & 1 deletion crates/prover/src/prover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ 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(sdk, self.app_exe.clone(), stdin)?;
let exec_result =
crate::utils::vm::execute_guest(config.app_vm_config.clone(), &self.app_exe, 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
31 changes: 26 additions & 5 deletions crates/prover/src/utils/vm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
use openvm_sdk::{Sdk, StdIn, types::ExecutableFormat};
use std::sync::Arc;

use openvm_circuit::{
arch::{VmExecutor, instructions::exe::VmExe},
system::{
memory::merkle::public_values::extract_public_values, program::trace::VmCommittedExe,
},
};
use openvm_sdk::{F, SC, StdIn, config::SdkVmConfig};

use crate::Error;

Expand All @@ -8,15 +16,28 @@ pub struct ExecutionResult {
pub public_values: Vec<u8>,
}

#[derive(Default)]
pub struct DebugInput {
pub mock_prove: bool,
pub commited_exe: Option<Arc<VmCommittedExe<SC>>>,
}

pub fn execute_guest(
sdk: &Sdk,
exe: impl Into<ExecutableFormat>,
vm_config: SdkVmConfig,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to downgrade the execute_guest. The issue about all 0 PI has been confirmed as limited (only raised when "legacy-v1-3 feature is applied and a guest built by openvm 1.3 is loaded. We can walk through this compatibility feature soon.

exe: &VmExe<F>,
stdin: &StdIn,
) -> Result<ExecutionResult, Error> {
let (public_values, (_cost, total_cycle)) = sdk
.execute_metered_cost(exe, stdin.clone())
let executor = VmExecutor::new(vm_config.clone()).expect("invalid config");
let instance = executor.instance(exe).expect("invalid exe");

let state = instance
.execute(stdin.clone(), None)
.map_err(|e| Error::GenProof(e.to_string()))?;
let total_cycle = state.instret();
let final_memory = state.memory;

let public_values: Vec<u8> =
extract_public_values(vm_config.as_ref().num_public_values, &final_memory.memory);
tracing::debug!(name: "public_values after guest execution", ?public_values);
if public_values.iter().all(|x| *x == 0) {
return Err(Error::GenProof("public_values are all 0s".to_string()));
Expand Down
5 changes: 5 additions & 0 deletions crates/types/base/src/fork_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum ForkName {
EuclidV2,
Feynman,
Galileo,
GalileoV2,
}

impl fmt::Display for ForkName {
Expand All @@ -32,6 +33,7 @@ impl fmt::Display for ForkName {
ForkName::EuclidV2 => "euclidv2",
ForkName::Feynman => "feynman",
ForkName::Galileo => "galileo",
ForkName::GalileoV2 => "galileov2",
};
write!(f, "{}", s)
}
Expand All @@ -45,6 +47,7 @@ impl ForkName {
ForkName::EuclidV2 => "euclidv2",
ForkName::Feynman => "feynman",
ForkName::Galileo => "galileo",
ForkName::GalileoV2 => "galileov2",
}
}
}
Expand All @@ -57,6 +60,7 @@ impl From<Option<&str>> for ForkName {
Some("euclidv2") => ForkName::EuclidV2,
Some("feynman") => ForkName::Feynman,
Some("galileo") => ForkName::Galileo,
Some("galileov2") => ForkName::GalileoV2,
Some(s) => unreachable!("hardfork not accepted: {s}"),
}
}
Expand All @@ -69,6 +73,7 @@ impl From<&str> for ForkName {
"euclidv2" => ForkName::EuclidV2,
"feynman" => ForkName::Feynman,
"galileo" => ForkName::Galileo,
"galileov2" => ForkName::GalileoV2,
s => unreachable!("hardfork not accepted: {s}"),
}
}
Expand Down
8 changes: 8 additions & 0 deletions crates/types/base/src/public_inputs/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ impl BatchInfo {
)
}

/// Public input hash for a batch (galileo or da-codec@v9) is defined as
///
/// Same as galileo.
pub fn pi_hash_galileo_v2(&self, version: Version) -> B256 {
self.pi_hash_galileo(version)
}

/// Public input hash for a L3 validium @ v1.
///
/// keccak(
Expand Down Expand Up @@ -179,6 +186,7 @@ impl MultiVersionPublicInputs for BatchInfo {
(Domain::Scroll, STFVersion::V7) => self.pi_hash_euclidv2(),
(Domain::Scroll, STFVersion::V8) => self.pi_hash_feynman(),
(Domain::Scroll, STFVersion::V9) => self.pi_hash_galileo(version),
(Domain::Scroll, STFVersion::V10) => self.pi_hash_galileo_v2(version),
(Domain::Validium, STFVersion::V1) => self.pi_hash_validium(version),
(domain, stf_version) => {
unreachable!("unsupported version=({domain:?}, {stf_version:?})")
Expand Down
7 changes: 7 additions & 0 deletions crates/types/base/src/public_inputs/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl BundleInfo {
self.pi_euclidv2()
}

pub fn pi_galileo_v2(&self) -> Vec<u8> {
self.pi_euclidv2()
}

pub fn pi_hash_versioned(&self, version: Version, pi: &[u8]) -> B256 {
keccak256(
std::iter::empty()
Expand Down Expand Up @@ -137,6 +141,9 @@ impl MultiVersionPublicInputs for BundleInfo {
(Domain::Scroll, STFVersion::V9) => {
self.pi_hash_versioned(version, self.pi_galileo().as_slice())
}
(Domain::Scroll, STFVersion::V10) => {
self.pi_hash_versioned(version, self.pi_galileo_v2().as_slice())
}
(Domain::Validium, STFVersion::V1) => {
self.pi_hash_versioned(version, self.pi_validium_v1().as_slice())
}
Expand Down
8 changes: 8 additions & 0 deletions crates/types/base/src/public_inputs/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ impl ChunkInfo {
)
}

/// Public input hash for a given chunk (galileo or da-codec@v9) is defined as
///
/// The same as galileo.
pub fn pi_hash_galileo_v2(&self, version: Version) -> B256 {
self.pi_hash_galileo(version)
}

/// Public input hash for a given chunk for L3 validium @ v1:
///
/// keccak(
Expand Down Expand Up @@ -373,6 +380,7 @@ impl MultiVersionPublicInputs for ChunkInfo {
(Domain::Scroll, STFVersion::V7) => self.pi_hash_euclidv2(),
(Domain::Scroll, STFVersion::V8) => self.pi_hash_feynman(),
(Domain::Scroll, STFVersion::V9) => self.pi_hash_galileo(version),
(Domain::Scroll, STFVersion::V10) => self.pi_hash_galileo_v2(version),
(Domain::Validium, STFVersion::V1) => self.pi_hash_validium(version),
(domain, stf_version) => {
unreachable!("unsupported version=({domain:?}, {stf_version:?})")
Expand Down
16 changes: 16 additions & 0 deletions crates/types/base/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub enum STFVersion {
V8 = 8,
/// Scroll@v9.
V9 = 9,
/// Scroll@v10.
V10 = 10,
}

impl From<u8> for STFVersion {
Expand All @@ -66,6 +68,7 @@ impl From<u8> for STFVersion {
7 => Self::V7,
8 => Self::V8,
9 => Self::V9,
10 => Self::V10,
value => unreachable!("unsupported stf-version={value}"),
}
}
Expand Down Expand Up @@ -153,6 +156,15 @@ impl Version {
}
}

pub const fn galileo_v2() -> Self {
Self {
domain: Domain::Scroll,
stf_version: STFVersion::V10,
fork: ForkName::GalileoV2,
codec: Codec::V7,
}
}

pub const fn validium_v1() -> Self {
Self {
domain: Domain::Validium,
Expand Down Expand Up @@ -187,6 +199,7 @@ impl From<u8> for Version {
(Domain::Scroll, STFVersion::V7) => Self::euclid_v2(),
(Domain::Scroll, STFVersion::V8) => Self::feynman(),
(Domain::Scroll, STFVersion::V9) => Self::galileo(),
(Domain::Scroll, STFVersion::V10) => Self::galileo_v2(),
(Domain::Validium, STFVersion::V1) => Self::validium_v1(),
(domain, stf_version) => {
unreachable!("unsupported version=({domain:?}, {stf_version:?})")
Expand All @@ -200,3 +213,6 @@ pub const VALIDIUM_V1: u8 = Version::validium_v1().as_version_byte();

/// Version byte for Galileo @ v9.
pub const SCROLL_GALILEO: u8 = Version::galileo().as_version_byte();

/// Version byte for GalileoV2 @ v10.
pub const SCROLL_GALILEO_V2: u8 = Version::galileo_v2().as_version_byte();
1 change: 1 addition & 0 deletions crates/types/chunk/src/scroll/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn execute(witness: ChunkWitness) -> Result<ChunkInfo, String> {
ForkName::EuclidV2 => Hardfork::EuclidV2,
ForkName::Feynman => Hardfork::Feynman,
ForkName::Galileo => Hardfork::Galileo,
ForkName::GalileoV2 => Hardfork::GalileoV2,
},
);

Expand Down
2 changes: 1 addition & 1 deletion release-fork
Original file line number Diff line number Diff line change
@@ -1 +1 @@
galileo
galileov2