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
2 changes: 1 addition & 1 deletion crates/circuits/batch-circuit/batch_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [1004888796, 1961080320, 797404739, 1164505978, 680915880, 815579773, 901008395, 1571321070];
pub const COMMIT: [u32; 8] = [1400913761, 1120536600, 55670230, 465644265, 1148889494, 843767345, 1745070471, 193928041];
2 changes: 1 addition & 1 deletion crates/circuits/bundle-circuit/bundle_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [938731734, 152130481, 1529869971, 1510773152, 1107646849, 1319186509, 1823457883, 138842638];
pub const COMMIT: [u32; 8] = [836552939, 1686806590, 135501859, 346088423, 1193474372, 757143280, 1995358180, 150494652];
2 changes: 1 addition & 1 deletion crates/circuits/chunk-circuit/chunk_exe_commit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
//! Generated by crates/build-guest. DO NOT EDIT!

pub const COMMIT: [u32; 8] = [763461005, 290791662, 1754272651, 657118785, 742388982, 1996019957, 1955972066, 390061593];
pub const COMMIT: [u32; 8] = [138721596, 243535334, 930392534, 379324085, 299238093, 1781158367, 1939995032, 1490622633];
2 changes: 1 addition & 1 deletion crates/integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ENV_OUTPUT_DIR: &str = "OUTPUT_DIR";

/// Enviroment settings for test: fork
pub fn testing_hardfork() -> ForkName {
ForkName::Galileo
testing_version().fork
}

/// Test settings (version).
Expand Down
3 changes: 1 addition & 2 deletions crates/integration/src/testers/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ impl PartialProvingTask for BatchWitness {
fn identifier(&self) -> String {
let header_hash = match &self.reference_header {
ReferenceHeader::V6(h) => h.batch_hash(),
ReferenceHeader::V7(h) => h.batch_hash(),
ReferenceHeader::V8(h) => h.batch_hash(),
ReferenceHeader::V7_V8_V9(h) => h.batch_hash(),
ReferenceHeader::Validium(h) => h.batch_hash(),
};
header_hash.to_string()
Expand Down
27 changes: 5 additions & 22 deletions crates/integration/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ impl Default for LastHeader {
// create a default LastHeader according to the dummy value
// being set in the e2e test in scroll-prover:
// https://github.com/scroll-tech/scroll-prover/blob/82f8ed3fabee5c3001b0b900cda1608413e621f8/integration/tests/e2e_tests.rs#L203C1-L207C8

Self {
batch_index: 123,
version: testing_hardfork().to_protocol_version(),
version: testing_version().as_version_byte(),
batch_hash: B256::new([
0xab, 0xac, 0xad, 0xae, 0xaf, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
Expand All @@ -70,8 +69,7 @@ impl From<&ReferenceHeader> for LastHeader {
fn from(value: &ReferenceHeader) -> Self {
match value {
ReferenceHeader::V6(h) => h.into(),
ReferenceHeader::V7(h) => h.into(),
ReferenceHeader::V8(h) => h.into(),
ReferenceHeader::V7_V8_V9(h) => h.into(),
ReferenceHeader::Validium(h) => h.into(),
}
}
Expand Down Expand Up @@ -297,20 +295,9 @@ pub fn build_batch_witnesses(
blob_data_proof: point_evaluations.map(|u| B256::new(u.to_be_bytes())),
})
}
ForkName::EuclidV2 => {
ForkName::EuclidV2 | ForkName::Feynman | ForkName::Galileo => {
use scroll_zkvm_types::batch::BatchHeaderV7;
let _ = x + z;
ReferenceHeader::V7(BatchHeaderV7 {
version: last_header.version,
batch_index: last_header.batch_index + 1,
parent_batch_hash: last_header.batch_hash,
blob_versioned_hash,
})
}
ForkName::Feynman | ForkName::Galileo => {
use scroll_zkvm_types::batch::BatchHeaderV8;
let _ = x + z;
ReferenceHeader::V8(BatchHeaderV8 {
ReferenceHeader::V7_V8_V9(BatchHeaderV7 {
version: last_header.version,
batch_index: last_header.batch_index + 1,
parent_batch_hash: last_header.batch_hash,
Expand Down Expand Up @@ -459,14 +446,10 @@ fn test_build_and_parse_batch_task() -> eyre::Result<()> {
let enveloped = batch::EnvelopeV6::from_slice(&task_wit.blob_bytes);
<batch::PayloadV6 as Payload>::from_envelope(&enveloped).validate(h, infos);
}
ReferenceHeader::V7(h) => {
ReferenceHeader::V7_V8_V9(h) => {
let enveloped = batch::EnvelopeV7::from_slice(&task_wit.blob_bytes);
<batch::PayloadV7 as Payload>::from_envelope(&enveloped).validate(h, infos);
}
ReferenceHeader::V8(h) => {
let enveloped = batch::EnvelopeV8::from_slice(&task_wit.blob_bytes);
<batch::PayloadV8 as Payload>::from_envelope(&enveloped).validate(h, infos);
}
ReferenceHeader::Validium(_h) => {
todo!()
}
Expand Down
9 changes: 0 additions & 9 deletions crates/types/base/src/fork_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ impl ForkName {
ForkName::Galileo => "galileo",
}
}
/// Convert ForkName to its protocol version
pub fn to_protocol_version(&self) -> u8 {
match self {
ForkName::EuclidV1 => 6,
ForkName::EuclidV2 => 7,
ForkName::Feynman => 8,
ForkName::Galileo => 9,
}
}
}

impl From<Option<&str>> for ForkName {
Expand Down
1 change: 0 additions & 1 deletion crates/types/base/src/public_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub trait PublicInputs {

/// helper trait to extend PublicInputs
pub trait MultiVersionPublicInputs {
fn pi_hash_by_fork(&self, fork_name: ForkName) -> B256;
fn pi_hash_by_version(&self, version: Version) -> B256;
fn validate(&self, prev_pi: &Self, version: Version);
}
Expand Down
16 changes: 4 additions & 12 deletions crates/types/base/src/public_inputs/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl BatchInfo {
.collect::<Vec<u8>>(),
)
}

/// Public input hash for a L3 validium @ v1.
///
/// keccak(
Expand Down Expand Up @@ -172,20 +173,11 @@ impl BatchInfo {
pub type VersionedBatchInfo = (BatchInfo, Version);

impl MultiVersionPublicInputs for BatchInfo {
fn pi_hash_by_fork(&self, fork_name: ForkName) -> B256 {
match fork_name {
ForkName::EuclidV1 => self.pi_hash_euclidv1(),
ForkName::EuclidV2 => self.pi_hash_euclidv2(),
ForkName::Feynman => self.pi_hash_feynman(),
_ => unreachable!("Fork > Feynman should use `pi_hash_by_version`"),
}
}

fn pi_hash_by_version(&self, version: Version) -> B256 {
match (version.domain, version.stf_version) {
(Domain::Scroll, STFVersion::V6) => self.pi_hash_by_fork(ForkName::EuclidV1),
(Domain::Scroll, STFVersion::V7) => self.pi_hash_by_fork(ForkName::EuclidV2),
(Domain::Scroll, STFVersion::V8) => self.pi_hash_by_fork(ForkName::Feynman),
(Domain::Scroll, STFVersion::V6) => self.pi_hash_euclidv1(),
(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::Validium, STFVersion::V1) => self.pi_hash_validium(version),
(domain, stf_version) => {
Expand Down
53 changes: 11 additions & 42 deletions crates/types/base/src/public_inputs/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_primitives::B256;

use crate::{
public_inputs::{ForkName, MultiVersionPublicInputs},
public_inputs::MultiVersionPublicInputs,
utils::keccak256,
version::{Domain, STFVersion, Version},
};
Expand Down Expand Up @@ -94,36 +94,21 @@ impl BundleInfo {
keccak256(self.pi_euclidv2())
}

pub fn pi_hash_feynman(&self) -> B256 {
let protocol_version =
B256::left_padding_from(&ForkName::Feynman.to_protocol_version().to_be_bytes());
let pi: Vec<u8> = std::iter::empty()
.chain(protocol_version.as_slice())
.chain(self.pi_euclidv2().as_slice())
.cloned()
.collect();
keccak256(pi)
pub fn pi_feynman(&self) -> Vec<u8> {
self.pi_euclidv2()
}

pub fn pi_galileo(&self) -> Vec<u8> {
std::iter::empty()
.chain(self.chain_id.to_be_bytes().as_slice())
.chain(self.msg_queue_hash.as_slice())
.chain(self.num_batches.to_be_bytes().as_slice())
.chain(self.prev_state_root.as_slice())
.chain(self.prev_batch_hash.as_slice())
.chain(self.post_state_root.as_slice())
.chain(self.batch_hash.as_slice())
.chain(self.withdraw_root.as_slice())
.cloned()
.collect()
self.pi_euclidv2()
}

pub fn pi_hash_versioned(&self, version: Version, pi: &[u8]) -> B256 {
let version_byte = version.as_version_byte();
keccak256(
std::iter::empty()
.chain(B256::left_padding_from(&version_byte.to_be_bytes()).as_slice())
.chain(
B256::left_padding_from(version.as_version_byte().to_be_bytes().as_slice())
.as_slice(),
)
.chain(pi)
.cloned()
.collect::<Vec<u8>>(),
Expand All @@ -137,34 +122,18 @@ impl BundleInfo {
.cloned()
.collect()
}

pub fn pi_hash(&self, fork_name: ForkName) -> B256 {
match fork_name {
ForkName::EuclidV1 => self.pi_hash_euclidv1(),
ForkName::EuclidV2 => self.pi_hash_euclidv2(),
ForkName::Feynman => self.pi_hash_feynman(),
_ => unreachable!("Fork > Feynman should use `pi_hash_by_version`"),
}
}
}

pub type VersionedBundleInfo = (BundleInfo, Version);

impl MultiVersionPublicInputs for BundleInfo {
fn pi_hash_by_fork(&self, fork_name: ForkName) -> B256 {
match fork_name {
ForkName::EuclidV1 => self.pi_hash_euclidv1(),
ForkName::EuclidV2 => self.pi_hash_euclidv2(),
ForkName::Feynman => self.pi_hash_feynman(),
_ => unreachable!("Fork > Feynman should use `pi_hash_by_version`"),
}
}

fn pi_hash_by_version(&self, version: Version) -> B256 {
match (version.domain, version.stf_version) {
(Domain::Scroll, STFVersion::V6) => self.pi_hash_euclidv1(),
(Domain::Scroll, STFVersion::V7) => self.pi_hash_euclidv2(),
(Domain::Scroll, STFVersion::V8) => self.pi_hash_feynman(),
(Domain::Scroll, STFVersion::V8) => {
self.pi_hash_versioned(version, self.pi_feynman().as_slice())
}
(Domain::Scroll, STFVersion::V9) => {
self.pi_hash_versioned(version, self.pi_galileo().as_slice())
}
Expand Down
30 changes: 11 additions & 19 deletions crates/types/base/src/public_inputs/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ impl ChunkInfo {
)
}

/// Feynman chunk public inputs are the same as EuclidV2.
pub fn pi_hash_feynman(&self) -> B256 {
self.pi_hash_euclidv2()
}

/// Public input hash for a given chunk (galileo or da-codec@v9) is defined as
///
/// keccak(
Expand Down Expand Up @@ -358,28 +363,15 @@ impl ChunkInfo {
pub type VersionedChunkInfo = (ChunkInfo, Version);

impl MultiVersionPublicInputs for ChunkInfo {
/// Compute the public input hash for the chunk.
fn pi_hash_by_fork(&self, fork_name: ForkName) -> B256 {
match fork_name {
ForkName::EuclidV1 => {
assert_ne!(self.data_hash, B256::ZERO, "v6 must has valid data hash");
self.pi_hash_euclidv1()
}
ForkName::EuclidV2 => self.pi_hash_euclidv2(),
ForkName::Feynman => {
// Feynman fork uses the same hash as EuclidV2
self.pi_hash_euclidv2()
}
_ => unreachable!("Fork > Feynman should use `pi_hash_by_version`"),
}
}

/// Compute the public input hash for the chunk given the version tuple.
fn pi_hash_by_version(&self, version: Version) -> B256 {
match (version.domain, version.stf_version) {
(Domain::Scroll, STFVersion::V6) => self.pi_hash_by_fork(ForkName::EuclidV1),
(Domain::Scroll, STFVersion::V7) => self.pi_hash_by_fork(ForkName::EuclidV2),
(Domain::Scroll, STFVersion::V8) => self.pi_hash_by_fork(ForkName::Feynman),
(Domain::Scroll, STFVersion::V6) => {
assert_ne!(self.data_hash, B256::ZERO, "v6 must have valid data_hash");
self.pi_hash_euclidv1()
}
(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::Validium, STFVersion::V1) => self.pi_hash_validium(version),
(domain, stf_version) => {
Expand Down
15 changes: 8 additions & 7 deletions crates/types/base/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,18 @@ pub enum Codec {
/// da-codec@v6.
V6,
/// da-codec@v7.
///
/// Between EuclidV2, Feynman and Galileo hardforks, i.e. STF versions 7, 8 and 9, the da-codec
/// implementation remains unchanged. As a result, we use the Codec::V7 for each of those
/// hardforks.
V7,
/// da-codec@v8.
V8,
}

impl From<Codec> for u8 {
fn from(value: Codec) -> Self {
match value {
Codec::V6 => 6,
Codec::V7 => 7,
Codec::V8 => 8,
}
}
}
Expand Down Expand Up @@ -139,7 +140,7 @@ impl Version {
domain: Domain::Scroll,
stf_version: STFVersion::V8,
fork: ForkName::Feynman,
codec: Codec::V8,
codec: Codec::V7,
}
}

Expand All @@ -148,7 +149,7 @@ impl Version {
domain: Domain::Scroll,
stf_version: STFVersion::V9,
fork: ForkName::Galileo,
codec: Codec::V8,
codec: Codec::V7,
}
}

Expand All @@ -157,7 +158,7 @@ impl Version {
domain: Domain::Validium,
stf_version: STFVersion::V1,
fork: ForkName::Feynman,
codec: Codec::V8,
codec: Codec::V7,
}
}

Expand All @@ -172,7 +173,7 @@ impl Version {

impl Default for Version {
fn default() -> Self {
Self::feynman()
Self::galileo()
}
}

Expand Down
8 changes: 1 addition & 7 deletions crates/types/batch/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ pub use v6::BatchInfoBuilderV6;
pub mod v7;
pub use v7::BatchInfoBuilderV7;

pub mod v8;
pub use v8::BatchInfoBuilderV8;

pub mod validium;

use types_base::public_inputs::{batch::BatchInfo, chunk::ChunkInfo};

use crate::{
BatchHeader, BatchHeaderV6, BatchHeaderV7, BatchHeaderV8, PointEvalWitness, payload::Payload,
};
use crate::{BatchHeader, BatchHeaderV6, BatchHeaderV7, PointEvalWitness, payload::Payload};

pub struct BuilderArgs<Header: BatchHeader> {
pub header: Header,
Expand All @@ -24,7 +19,6 @@ pub struct BuilderArgs<Header: BatchHeader> {

pub type BuilderArgsV6 = BuilderArgs<BatchHeaderV6>;
pub type BuilderArgsV7 = BuilderArgs<BatchHeaderV7>;
pub type BuilderArgsV8 = BuilderArgs<BatchHeaderV8>;

pub trait BatchInfoBuilder {
type Payload: Payload;
Expand Down
7 changes: 0 additions & 7 deletions crates/types/batch/src/builder/v8.rs

This file was deleted.

Loading