Skip to content

Commit

Permalink
feat: Add holocene to OP spec (#1794)
Browse files Browse the repository at this point in the history
* add holocene to spec

* add holocene in precompile

* add cfg optimism to HOLOCENE
  • Loading branch information
cody-wang-cb authored Sep 26, 2024
1 parent 95e53af commit fc1556f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl PrecompileSpecId {
#[cfg(feature = "optimism")]
BEDROCK | REGOLITH | CANYON => Self::BERLIN,
#[cfg(feature = "optimism")]
ECOTONE | FJORD | GRANITE => Self::CANCUN,
ECOTONE | FJORD | GRANITE | HOLOCENE => Self::CANCUN,
}
}
}
Expand Down
39 changes: 37 additions & 2 deletions crates/primitives/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ pub enum SpecId {
ECOTONE = 21,
FJORD = 22,
GRANITE = 23,
PRAGUE = 24,
PRAGUE_EOF = 25,
HOLOCENE = 24,
PRAGUE = 25,
PRAGUE_EOF = 26,
#[default]
LATEST = u8::MAX,
}
Expand Down Expand Up @@ -123,6 +124,8 @@ impl From<&str> for SpecId {
"Fjord" => SpecId::FJORD,
#[cfg(feature = "optimism")]
"Granite" => SpecId::GRANITE,
#[cfg(feature = "optimism")]
"Holocene" => SpecId::HOLOCENE,
_ => Self::LATEST,
}
}
Expand Down Expand Up @@ -163,6 +166,8 @@ impl From<SpecId> for &'static str {
SpecId::FJORD => "Fjord",
#[cfg(feature = "optimism")]
SpecId::GRANITE => "Granite",
#[cfg(feature = "optimism")]
SpecId::HOLOCENE => "Holocene",
SpecId::LATEST => "Latest",
}
}
Expand Down Expand Up @@ -226,6 +231,8 @@ spec!(ECOTONE, EcotoneSpec);
spec!(FJORD, FjordSpec);
#[cfg(feature = "optimism")]
spec!(GRANITE, GraniteSpec);
#[cfg(feature = "optimism")]
spec!(HOLOCENE, HoloceneSpec);

#[cfg(not(feature = "optimism"))]
#[macro_export]
Expand Down Expand Up @@ -389,6 +396,10 @@ macro_rules! spec_to_generic {
use $crate::GraniteSpec as SPEC;
$e
}
$crate::SpecId::HOLOCENE => {
use $crate::HoloceneSpec as SPEC;
$e
}
}
}};
}
Expand Down Expand Up @@ -431,6 +442,8 @@ mod tests {
spec_to_generic!(FJORD, assert_eq!(SPEC::SPEC_ID, FJORD));
#[cfg(feature = "optimism")]
spec_to_generic!(GRANITE, assert_eq!(SPEC::SPEC_ID, GRANITE));
#[cfg(feature = "optimism")]
spec_to_generic!(HOLOCENE, assert_eq!(SPEC::SPEC_ID, HOLOCENE));
spec_to_generic!(PRAGUE, assert_eq!(SPEC::SPEC_ID, PRAGUE));
spec_to_generic!(PRAGUE_EOF, assert_eq!(SPEC::SPEC_ID, PRAGUE_EOF));
spec_to_generic!(LATEST, assert_eq!(SPEC::SPEC_ID, LATEST));
Expand Down Expand Up @@ -581,4 +594,26 @@ mod optimism_tests {
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::FJORD));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::GRANITE));
}

#[test]
fn test_holocene_post_merge_hardforks() {
// from MERGE to HOLOCENE
for i in 15..=24 {
if let Some(spec) = SpecId::try_from_u8(i) {
assert!(HoloceneSpec::enabled(spec));
}
}
assert!(!HoloceneSpec::enabled(SpecId::LATEST));
}

#[test]
fn test_holocene_post_merge_hardforks_spec_id() {
// from MERGE to HOLOCENE
for i in 15..=24 {
if let Some(spec) = SpecId::try_from_u8(i) {
assert!(SpecId::enabled(SpecId::HOLOCENE, spec));
}
}
assert!(!SpecId::enabled(SpecId::HOLOCENE, SpecId::LATEST));
}
}

0 comments on commit fc1556f

Please sign in to comment.