From 543aad36c2702e188be4f48f45f1ee6034b5cd74 Mon Sep 17 00:00:00 2001 From: Brian Bland Date: Mon, 3 Jun 2024 10:38:50 -0700 Subject: [PATCH 1/2] Move canyon before ecotone --- crates/primitives/src/chain/spec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/primitives/src/chain/spec.rs b/crates/primitives/src/chain/spec.rs index 537ad6a520e8..759b590b2929 100644 --- a/crates/primitives/src/chain/spec.rs +++ b/crates/primitives/src/chain/spec.rs @@ -1631,8 +1631,8 @@ impl DepositContract { struct OptimismGenesisInfo { bedrock_block: Option, regolith_time: Option, - ecotone_time: Option, canyon_time: Option, + ecotone_time: Option, base_fee_params: BaseFeeParamsKind, } From d411964525cff7c096e6a1e85a4b369305e7c964 Mon Sep 17 00:00:00 2001 From: Brian Bland Date: Mon, 3 Jun 2024 10:43:10 -0700 Subject: [PATCH 2/2] op: Add fjordTime genesis config --- crates/primitives/src/chain/spec.rs | 52 +++++++++++++++++++++------- crates/primitives/src/revm/config.rs | 9 +++-- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/crates/primitives/src/chain/spec.rs b/crates/primitives/src/chain/spec.rs index 759b590b2929..84e7b9ba8cfd 100644 --- a/crates/primitives/src/chain/spec.rs +++ b/crates/primitives/src/chain/spec.rs @@ -1052,6 +1052,8 @@ impl From for ChainSpec { (Hardfork::Canyon, optimism_genesis_info.canyon_time), #[cfg(feature = "optimism")] (Hardfork::Ecotone, optimism_genesis_info.ecotone_time), + #[cfg(feature = "optimism")] + (Hardfork::Fjord, optimism_genesis_info.fjord_time), ]; let time_hardforks = time_hardfork_opts @@ -1302,6 +1304,14 @@ impl ChainSpecBuilder { self } + /// Enable Fjord at genesis + #[cfg(feature = "optimism")] + pub fn fjord_activated(mut self) -> Self { + self = self.ecotone_activated(); + self.hardforks.insert(Hardfork::Fjord, ForkCondition::Timestamp(0)); + self + } + /// Build the resulting [`ChainSpec`]. /// /// # Panics @@ -1633,6 +1643,7 @@ struct OptimismGenesisInfo { regolith_time: Option, canyon_time: Option, ecotone_time: Option, + fjord_time: Option, base_fee_params: BaseFeeParamsKind, } @@ -1699,6 +1710,11 @@ impl OptimismGenesisInfo { .extra_fields .get("ecotoneTime") .and_then(|value| value.as_u64()), + fjord_time: genesis + .config + .extra_fields + .get("fjordTime") + .and_then(|value| value.as_u64()), base_fee_params, } } @@ -3308,9 +3324,10 @@ Post-merge hard forks (timestamp based): "regolithTime": 20, "canyonTime": 30, "ecotoneTime": 40, + "fjordTime": 50, "optimism": { - "eip1559Elasticity": 50, - "eip1559Denominator": 60 + "eip1559Elasticity": 60, + "eip1559Denominator": 70 } } } @@ -3325,13 +3342,15 @@ Post-merge hard forks (timestamp based): assert_eq!(actual_canyon_timestamp, Some(serde_json::Value::from(30)).as_ref()); let actual_ecotone_timestamp = genesis.config.extra_fields.get("ecotoneTime"); assert_eq!(actual_ecotone_timestamp, Some(serde_json::Value::from(40)).as_ref()); + let actual_fjord_timestamp = genesis.config.extra_fields.get("fjordTime"); + assert_eq!(actual_fjord_timestamp, Some(serde_json::Value::from(50)).as_ref()); let optimism_object = genesis.config.extra_fields.get("optimism").unwrap(); assert_eq!( optimism_object, &serde_json::json!({ - "eip1559Elasticity": 50, - "eip1559Denominator": 60, + "eip1559Elasticity": 60, + "eip1559Denominator": 70, }) ); @@ -3339,18 +3358,20 @@ Post-merge hard forks (timestamp based): assert_eq!( chain_spec.base_fee_params, - BaseFeeParamsKind::Constant(BaseFeeParams::new(60, 50)) + BaseFeeParamsKind::Constant(BaseFeeParams::new(70, 60)) ); assert!(!chain_spec.is_fork_active_at_block(Hardfork::Bedrock, 0)); assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Regolith, 0)); assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Canyon, 0)); assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Ecotone, 0)); + assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Fjord, 0)); assert!(chain_spec.is_fork_active_at_block(Hardfork::Bedrock, 10)); assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Regolith, 20)); assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Canyon, 30)); assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Ecotone, 40)); + assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Fjord, 50)); } #[cfg(feature = "optimism")] @@ -3363,10 +3384,11 @@ Post-merge hard forks (timestamp based): "regolithTime": 20, "canyonTime": 30, "ecotoneTime": 40, + "fjordTime": 50, "optimism": { - "eip1559Elasticity": 50, - "eip1559Denominator": 60, - "eip1559DenominatorCanyon": 70 + "eip1559Elasticity": 60, + "eip1559Denominator": 70, + "eip1559DenominatorCanyon": 80 } } } @@ -3381,14 +3403,16 @@ Post-merge hard forks (timestamp based): assert_eq!(actual_canyon_timestamp, Some(serde_json::Value::from(30)).as_ref()); let actual_ecotone_timestamp = genesis.config.extra_fields.get("ecotoneTime"); assert_eq!(actual_ecotone_timestamp, Some(serde_json::Value::from(40)).as_ref()); + let actual_fjord_timestamp = genesis.config.extra_fields.get("fjordTime"); + assert_eq!(actual_fjord_timestamp, Some(serde_json::Value::from(50)).as_ref()); let optimism_object = genesis.config.extra_fields.get("optimism").unwrap(); assert_eq!( optimism_object, &serde_json::json!({ - "eip1559Elasticity": 50, - "eip1559Denominator": 60, - "eip1559DenominatorCanyon": 70 + "eip1559Elasticity": 60, + "eip1559Denominator": 70, + "eip1559DenominatorCanyon": 80 }) ); @@ -3398,8 +3422,8 @@ Post-merge hard forks (timestamp based): chain_spec.base_fee_params, BaseFeeParamsKind::Variable( vec![ - (Hardfork::London, BaseFeeParams::new(60, 50)), - (Hardfork::Canyon, BaseFeeParams::new(70, 50)), + (Hardfork::London, BaseFeeParams::new(70, 60)), + (Hardfork::Canyon, BaseFeeParams::new(80, 60)), ] .into() ) @@ -3409,10 +3433,12 @@ Post-merge hard forks (timestamp based): assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Regolith, 0)); assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Canyon, 0)); assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Ecotone, 0)); + assert!(!chain_spec.is_fork_active_at_timestamp(Hardfork::Fjord, 0)); assert!(chain_spec.is_fork_active_at_block(Hardfork::Bedrock, 10)); assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Regolith, 20)); assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Canyon, 30)); assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Ecotone, 40)); + assert!(chain_spec.is_fork_active_at_timestamp(Hardfork::Fjord, 50)); } } diff --git a/crates/primitives/src/revm/config.rs b/crates/primitives/src/revm/config.rs index d3fed4061739..9297f71a6ef0 100644 --- a/crates/primitives/src/revm/config.rs +++ b/crates/primitives/src/revm/config.rs @@ -36,7 +36,9 @@ pub fn revm_spec_by_timestamp_after_merge( pub fn revm_spec(chain_spec: &ChainSpec, block: Head) -> revm_primitives::SpecId { #[cfg(feature = "optimism")] if chain_spec.is_optimism() { - if chain_spec.fork(Hardfork::Ecotone).active_at_head(&block) { + if chain_spec.fork(Hardfork::Fjord).active_at_head(&block) { + return revm_primitives::FJORD + } else if chain_spec.fork(Hardfork::Ecotone).active_at_head(&block) { return revm_primitives::ECOTONE } else if chain_spec.fork(Hardfork::Canyon).active_at_head(&block) { return revm_primitives::CANYON @@ -149,7 +151,10 @@ mod tests { let cs = ChainSpecBuilder::mainnet().chain(crate::Chain::from_id(10)); f(cs).build() } - + assert_eq!( + revm_spec(&op_cs(|cs| cs.fjord_activated()), Head::default()), + revm_primitives::FJORD + ); assert_eq!( revm_spec(&op_cs(|cs| cs.ecotone_activated()), Head::default()), revm_primitives::ECOTONE