Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add holocene to OP spec #1794

Merged
merged 3 commits into from
Sep 26, 2024
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/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));
}
}