Skip to content

Commit fc1556f

Browse files
authored
feat: Add holocene to OP spec (#1794)
* add holocene to spec * add holocene in precompile * add cfg optimism to HOLOCENE
1 parent 95e53af commit fc1556f

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

crates/precompile/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl PrecompileSpecId {
297297
#[cfg(feature = "optimism")]
298298
BEDROCK | REGOLITH | CANYON => Self::BERLIN,
299299
#[cfg(feature = "optimism")]
300-
ECOTONE | FJORD | GRANITE => Self::CANCUN,
300+
ECOTONE | FJORD | GRANITE | HOLOCENE => Self::CANCUN,
301301
}
302302
}
303303
}

crates/primitives/src/specification.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ pub enum SpecId {
6666
ECOTONE = 21,
6767
FJORD = 22,
6868
GRANITE = 23,
69-
PRAGUE = 24,
70-
PRAGUE_EOF = 25,
69+
HOLOCENE = 24,
70+
PRAGUE = 25,
71+
PRAGUE_EOF = 26,
7172
#[default]
7273
LATEST = u8::MAX,
7374
}
@@ -123,6 +124,8 @@ impl From<&str> for SpecId {
123124
"Fjord" => SpecId::FJORD,
124125
#[cfg(feature = "optimism")]
125126
"Granite" => SpecId::GRANITE,
127+
#[cfg(feature = "optimism")]
128+
"Holocene" => SpecId::HOLOCENE,
126129
_ => Self::LATEST,
127130
}
128131
}
@@ -163,6 +166,8 @@ impl From<SpecId> for &'static str {
163166
SpecId::FJORD => "Fjord",
164167
#[cfg(feature = "optimism")]
165168
SpecId::GRANITE => "Granite",
169+
#[cfg(feature = "optimism")]
170+
SpecId::HOLOCENE => "Holocene",
166171
SpecId::LATEST => "Latest",
167172
}
168173
}
@@ -226,6 +231,8 @@ spec!(ECOTONE, EcotoneSpec);
226231
spec!(FJORD, FjordSpec);
227232
#[cfg(feature = "optimism")]
228233
spec!(GRANITE, GraniteSpec);
234+
#[cfg(feature = "optimism")]
235+
spec!(HOLOCENE, HoloceneSpec);
229236

230237
#[cfg(not(feature = "optimism"))]
231238
#[macro_export]
@@ -389,6 +396,10 @@ macro_rules! spec_to_generic {
389396
use $crate::GraniteSpec as SPEC;
390397
$e
391398
}
399+
$crate::SpecId::HOLOCENE => {
400+
use $crate::HoloceneSpec as SPEC;
401+
$e
402+
}
392403
}
393404
}};
394405
}
@@ -431,6 +442,8 @@ mod tests {
431442
spec_to_generic!(FJORD, assert_eq!(SPEC::SPEC_ID, FJORD));
432443
#[cfg(feature = "optimism")]
433444
spec_to_generic!(GRANITE, assert_eq!(SPEC::SPEC_ID, GRANITE));
445+
#[cfg(feature = "optimism")]
446+
spec_to_generic!(HOLOCENE, assert_eq!(SPEC::SPEC_ID, HOLOCENE));
434447
spec_to_generic!(PRAGUE, assert_eq!(SPEC::SPEC_ID, PRAGUE));
435448
spec_to_generic!(PRAGUE_EOF, assert_eq!(SPEC::SPEC_ID, PRAGUE_EOF));
436449
spec_to_generic!(LATEST, assert_eq!(SPEC::SPEC_ID, LATEST));
@@ -581,4 +594,26 @@ mod optimism_tests {
581594
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::FJORD));
582595
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::GRANITE));
583596
}
597+
598+
#[test]
599+
fn test_holocene_post_merge_hardforks() {
600+
// from MERGE to HOLOCENE
601+
for i in 15..=24 {
602+
if let Some(spec) = SpecId::try_from_u8(i) {
603+
assert!(HoloceneSpec::enabled(spec));
604+
}
605+
}
606+
assert!(!HoloceneSpec::enabled(SpecId::LATEST));
607+
}
608+
609+
#[test]
610+
fn test_holocene_post_merge_hardforks_spec_id() {
611+
// from MERGE to HOLOCENE
612+
for i in 15..=24 {
613+
if let Some(spec) = SpecId::try_from_u8(i) {
614+
assert!(SpecId::enabled(SpecId::HOLOCENE, spec));
615+
}
616+
}
617+
assert!(!SpecId::enabled(SpecId::HOLOCENE, SpecId::LATEST));
618+
}
584619
}

0 commit comments

Comments
 (0)