Skip to content

Commit 4d9af18

Browse files
roynalnarutonoel2004lispc
authored
Re-introduce ReferenceHeader::V8 for backwards compatibility with 0.5.2 (#226)
* fix: re-introduce ReferenceHeader::V8 for backwards compatibility * for automatically set is_openvm_v13 flag in verifier, also recognize 0.5.6 release files * chore: fmt * chore: commitments --------- Co-authored-by: Ho <fan@scroll.io> Co-authored-by: Zhuo Zhang <mycinbrin@gmail.com>
1 parent 074f736 commit 4d9af18

File tree

7 files changed

+31
-6
lines changed

7 files changed

+31
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#![cfg_attr(rustfmt, rustfmt_skip)]
22
//! Generated by crates/build-guest. DO NOT EDIT!
33
4-
pub const COMMIT: [u32; 8] = [1400913761, 1120536600, 55670230, 465644265, 1148889494, 843767345, 1745070471, 193928041];
4+
pub const COMMIT: [u32; 8] = [1322080380, 1651942255, 463083856, 1076384953, 571197325, 1702971627, 375491115, 829280832];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#![cfg_attr(rustfmt, rustfmt_skip)]
22
//! Generated by crates/build-guest. DO NOT EDIT!
33
4-
pub const COMMIT: [u32; 8] = [836552939, 1686806590, 135501859, 346088423, 1193474372, 757143280, 1995358180, 150494652];
4+
pub const COMMIT: [u32; 8] = [1144920578, 672155974, 440997509, 565686465, 150547879, 714324919, 1665603288, 907252136];

crates/integration/src/testers/batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ impl PartialProvingTask for BatchWitness {
1717
let header_hash = match &self.reference_header {
1818
ReferenceHeader::V6(h) => h.batch_hash(),
1919
ReferenceHeader::V7_V8_V9(h) => h.batch_hash(),
20+
ReferenceHeader::V8(_) => unreachable!("Unexpected ReferenceHeader::V8 0.7.0 onwards"),
2021
ReferenceHeader::Validium(h) => h.batch_hash(),
2122
};
2223
header_hash.to_string()

crates/integration/src/utils/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ impl From<&ReferenceHeader> for LastHeader {
7070
match value {
7171
ReferenceHeader::V6(h) => h.into(),
7272
ReferenceHeader::V7_V8_V9(h) => h.into(),
73+
ReferenceHeader::V8(_) => {
74+
unreachable!("Unexpected ReferenceHeader::V8 from 0.7.0 onwards")
75+
}
7376
ReferenceHeader::Validium(h) => h.into(),
7477
}
7578
}
@@ -450,6 +453,7 @@ fn test_build_and_parse_batch_task() -> eyre::Result<()> {
450453
let enveloped = batch::EnvelopeV7::from_slice(&task_wit.blob_bytes);
451454
<batch::PayloadV7 as Payload>::from_envelope(&enveloped).validate(h, infos);
452455
}
456+
ReferenceHeader::V8(_) => unreachable!("Unexpected ReferenceHeader::V8 from 0.7.0 onwards"),
453457
ReferenceHeader::Validium(_h) => {
454458
todo!()
455459
}

crates/types/batch/src/header/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ pub enum ReferenceHeader {
5656
/// Since the codec implementation is unchanged across STF-versions v7, v8 and v9, we define a
5757
/// single variant to cover all those cases.
5858
V7_V8_V9(v7::BatchHeaderV7),
59+
/// Batch header v8 for backwards compatibility to support Feynman (0.5.2).
60+
V8(v7::BatchHeaderV7),
5961
/// Represents batch header utilised in L3 validium.
6062
Validium(validium::BatchHeaderValidium),
6163
}
64+
65+
impl ReferenceHeader {
66+
/// Consumes the reference header that is expected to be [`Self::V7_V8_V9`] and transforms it
67+
/// to [`Self::V8`] for backwards compatibilty support for [`Version::feynman`].
68+
pub fn into_v8_feynman(self) -> Self {
69+
match self {
70+
Self::V7_V8_V9(h) => Self::V8(h),
71+
_ => unreachable!("Expect ReferenceHeader::V7_V8_V9 from 0.7.0 onwards"),
72+
}
73+
}
74+
}

crates/types/batch/src/witness.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ impl From<BatchWitness> for LegacyBatchWitness {
182182
chunk_infos: value.chunk_infos.into_iter().map(|c| c.into()).collect(),
183183
blob_bytes: value.blob_bytes,
184184
point_eval_witness: point_eval_witness.clone().into(),
185-
reference_header: value.reference_header,
185+
reference_header: match value.fork_name {
186+
ForkName::Feynman => value.reference_header.into_v8_feynman(),
187+
_ => unreachable!("0.5.2 expects fork=Feynman"),
188+
},
186189
fork_name: value.fork_name,
187190
}
188191
}
@@ -221,6 +224,9 @@ impl From<&BatchWitness> for BatchInfo {
221224
};
222225
BatchInfoBuilderV7::build(witness.version, args)
223226
}
227+
ReferenceHeader::V8(_) => {
228+
unreachable!("Unexpected ReferenceHeader::V8 from 0.7.0 onwards");
229+
}
224230
ReferenceHeader::Validium(header) => ValidiumBatchInfoBuilder::build(
225231
ValidiumBuilderArgs::new(witness.version, *header, chunk_infos),
226232
),

crates/verifier/src/verifier.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ impl UniversalVerifier {
5252
// TODO: clean this after we get rid of openvm v1.3.
5353
let is_openvm_v13 = {
5454
let hash = sha256::digest(&evm_verifier);
55-
// from 0.5.2 release files
56-
let is_openvm_v13 =
57-
hash == ("4f1b70db9fade2ce7425924dc662d75c5a315f3a611ed8cadd68b516407a4cf1");
55+
// from 0.5.2 and 0.5.6 release files
56+
let is_openvm_v13 = hash
57+
== ("4f1b70db9fade2ce7425924dc662d75c5a315f3a611ed8cadd68b516407a4cf1")
58+
|| hash == ("d1f7a8066bd45c1bb82b73c7a7138d5793589fb8c6b2eb3c74b94db63109501d");
5859
println!(
5960
"is_openvm_v13: {}, verifier.bin sha256sum: {}",
6061
is_openvm_v13, hash

0 commit comments

Comments
 (0)