From 8d323e83de57de809c6057e0b3f81eb5938ce517 Mon Sep 17 00:00:00 2001 From: Cody Wang Date: Mon, 23 Sep 2024 17:05:54 -0400 Subject: [PATCH 1/3] add holocene to spec --- crates/primitives/src/specification.rs | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/crates/primitives/src/specification.rs b/crates/primitives/src/specification.rs index ac3c5a3ede..e1b6e9da27 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/primitives/src/specification.rs @@ -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, } @@ -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, } } @@ -163,6 +166,8 @@ impl From for &'static str { SpecId::FJORD => "Fjord", #[cfg(feature = "optimism")] SpecId::GRANITE => "Granite", + #[cfg(feature = "optimism")] + SpecId::HOLOCENE => "Holocene", SpecId::LATEST => "Latest", } } @@ -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] @@ -389,6 +396,10 @@ macro_rules! spec_to_generic { use $crate::GraniteSpec as SPEC; $e } + $crate::SpecId::HOLOCENE => { + use $crate::HoloceneSpec as SPEC; + $e + } } }}; } @@ -431,6 +442,7 @@ 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)); + 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)); @@ -581,4 +593,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)); + } } From 86bb202379fc52cf2bdabc3f821187fc3b5f7b97 Mon Sep 17 00:00:00 2001 From: Cody Wang Date: Mon, 23 Sep 2024 18:15:45 -0400 Subject: [PATCH 2/3] add holocene in precompile --- crates/precompile/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 488983bcb1..1167028e9f 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -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, } } } From 54390105c0fd672161a61881c0f1092b66438c05 Mon Sep 17 00:00:00 2001 From: Cody Wang Date: Tue, 24 Sep 2024 19:06:31 -0400 Subject: [PATCH 3/3] add cfg optimism to HOLOCENE --- crates/primitives/src/specification.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/primitives/src/specification.rs b/crates/primitives/src/specification.rs index e1b6e9da27..13ade0f4d6 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/primitives/src/specification.rs @@ -442,6 +442,7 @@ 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));