diff --git a/Cargo.lock b/Cargo.lock index 34d7480a4e3..a1f4a28abd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9682,6 +9682,7 @@ dependencies = [ "alloy-consensus", "alloy-genesis", "alloy-network", + "alloy-op-hardforks", "alloy-primitives", "alloy-rpc-types-engine", "alloy-rpc-types-eth", diff --git a/crates/optimism/node/Cargo.toml b/crates/optimism/node/Cargo.toml index 0576b3897f5..d8495d9201b 100644 --- a/crates/optimism/node/Cargo.toml +++ b/crates/optimism/node/Cargo.toml @@ -84,6 +84,7 @@ reth-rpc-eth-types.workspace = true alloy-network.workspace = true futures.workspace = true op-alloy-network.workspace = true +alloy-op-hardforks.workspace = true [features] default = ["reth-codec"] diff --git a/crates/optimism/node/src/engine.rs b/crates/optimism/node/src/engine.rs index 11737f65ce7..3b2254f17ef 100644 --- a/crates/optimism/node/src/engine.rs +++ b/crates/optimism/node/src/engine.rs @@ -299,39 +299,13 @@ mod test { use super::*; use crate::engine; + use alloy_op_hardforks::BASE_SEPOLIA_JOVIAN_TIMESTAMP; use alloy_primitives::{b64, Address, B256, B64}; use alloy_rpc_types_engine::PayloadAttributes; - use reth_chainspec::{ChainSpec, ForkCondition, Hardfork}; - use reth_optimism_chainspec::{OpChainSpec, BASE_SEPOLIA}; - use reth_optimism_forks::OpHardfork; + use reth_optimism_chainspec::BASE_SEPOLIA; use reth_provider::noop::NoopProvider; use reth_trie_common::KeccakKeyHasher; - const JOVIAN_TIMESTAMP: u64 = 1744909000; - - fn get_chainspec() -> Arc { - let mut base_sepolia_spec = BASE_SEPOLIA.inner.clone(); - - // TODO: Remove this once we know the Jovian timestamp - base_sepolia_spec - .hardforks - .insert(OpHardfork::Jovian.boxed(), ForkCondition::Timestamp(JOVIAN_TIMESTAMP)); - - Arc::new(OpChainSpec { - inner: ChainSpec { - chain: base_sepolia_spec.chain, - genesis: base_sepolia_spec.genesis, - genesis_header: base_sepolia_spec.genesis_header, - paris_block_and_final_difficulty: base_sepolia_spec - .paris_block_and_final_difficulty, - hardforks: base_sepolia_spec.hardforks, - base_fee_params: base_sepolia_spec.base_fee_params, - prune_delete_limit: 10000, - ..Default::default() - }, - }) - } - const fn get_attributes( eip_1559_params: Option, min_base_fee: Option, @@ -355,8 +329,10 @@ mod test { #[test] fn test_well_formed_attributes_pre_holocene() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); let attributes = get_attributes(None, None, 1732633199); let result = as EngineApiValidator< @@ -369,8 +345,10 @@ mod test { #[test] fn test_well_formed_attributes_holocene_no_eip1559_params() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); let attributes = get_attributes(None, None, 1732633200); let result = as EngineApiValidator< @@ -383,8 +361,10 @@ mod test { #[test] fn test_well_formed_attributes_holocene_eip1559_params_zero_denominator() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); let attributes = get_attributes(Some(b64!("0000000000000008")), None, 1732633200); let result = as EngineApiValidator< @@ -397,8 +377,10 @@ mod test { #[test] fn test_well_formed_attributes_holocene_valid() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); let attributes = get_attributes(Some(b64!("0000000800000008")), None, 1732633200); let result = as EngineApiValidator< @@ -411,8 +393,10 @@ mod test { #[test] fn test_well_formed_attributes_holocene_valid_all_zero() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); let attributes = get_attributes(Some(b64!("0000000000000000")), None, 1732633200); let result = as EngineApiValidator< @@ -425,9 +409,12 @@ mod test { #[test] fn test_well_formed_attributes_jovian_valid() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); - let attributes = get_attributes(Some(b64!("0000000000000000")), Some(1), JOVIAN_TIMESTAMP); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); + let attributes = + get_attributes(Some(b64!("0000000000000000")), Some(1), BASE_SEPOLIA_JOVIAN_TIMESTAMP); let result = as EngineApiValidator< OpEngineTypes, @@ -440,9 +427,11 @@ mod test { /// After Jovian (and holocene), eip1559 params must be Some #[test] fn test_malformed_attributes_jovian_with_eip_1559_params_none() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); - let attributes = get_attributes(None, Some(1), JOVIAN_TIMESTAMP); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); + let attributes = get_attributes(None, Some(1), BASE_SEPOLIA_JOVIAN_TIMESTAMP); let result = as EngineApiValidator< OpEngineTypes, @@ -455,8 +444,10 @@ mod test { /// Before Jovian, min base fee must be None #[test] fn test_malformed_attributes_pre_jovian_with_min_base_fee() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); let attributes = get_attributes(Some(b64!("0000000000000000")), Some(1), 1732633200); let result = as EngineApiValidator< @@ -470,9 +461,12 @@ mod test { /// After Jovian, min base fee must be Some #[test] fn test_malformed_attributes_post_jovian_with_min_base_fee_none() { - let validator = - OpEngineValidator::new::(get_chainspec(), NoopProvider::default()); - let attributes = get_attributes(Some(b64!("0000000000000000")), None, JOVIAN_TIMESTAMP); + let validator = OpEngineValidator::new::( + BASE_SEPOLIA.clone(), + NoopProvider::default(), + ); + let attributes = + get_attributes(Some(b64!("0000000000000000")), None, BASE_SEPOLIA_JOVIAN_TIMESTAMP); let result = as EngineApiValidator< OpEngineTypes,