refactor: reduce Hardforks trait usage (#13728)

This commit is contained in:
Arsenii Kulikov
2025-01-08 17:02:49 +03:00
committed by GitHub
parent 9d51260fbc
commit 8f2ecc44e8
17 changed files with 126 additions and 76 deletions

View File

@ -14,7 +14,6 @@ workspace = true
[dependencies]
# reth
reth-chainspec.workspace = true
reth-primitives.workspace = true
reth-rpc-api.workspace = true
reth-storage-api.workspace = true
reth-payload-builder.workspace = true
@ -49,9 +48,10 @@ parking_lot.workspace = true
[dev-dependencies]
reth-ethereum-engine-primitives.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
reth-primitives.workspace = true
reth-payload-builder = { workspace = true, features = ["test-utils"] }
reth-tokio-util.workspace = true
reth-testing-utils.workspace = true
alloy-rlp.workspace = true
assert_matches.workspace = true
assert_matches.workspace = true

View File

@ -16,14 +16,13 @@ use alloy_rpc_types_engine::{
use async_trait::async_trait;
use jsonrpsee_core::RpcResult;
use parking_lot::Mutex;
use reth_chainspec::{EthereumHardforks, Hardforks};
use reth_chainspec::{EthereumHardfork, EthereumHardforks};
use reth_engine_primitives::{BeaconConsensusEngineHandle, EngineTypes, EngineValidator};
use reth_payload_builder::PayloadStore;
use reth_payload_primitives::{
validate_payload_timestamp, EngineApiMessageVersion, PayloadBuilderAttributes,
PayloadOrAttributes,
};
use reth_primitives::EthereumHardfork;
use reth_rpc_api::EngineApiServer;
use reth_rpc_types_compat::engine::payload::convert_to_payload_body_v1;
use reth_storage_api::{BlockReader, HeaderProvider, StateProviderFactory};
@ -615,7 +614,7 @@ where
let merge_terminal_td = self
.inner
.chain_spec
.fork(EthereumHardfork::Paris)
.ethereum_fork_activation(EthereumHardfork::Paris)
.ttd()
.expect("the engine API should not be running for chains w/o paris");
@ -1024,7 +1023,7 @@ mod tests {
use super::*;
use alloy_rpc_types_engine::{ClientCode, ClientVersionV1};
use assert_matches::assert_matches;
use reth_chainspec::{ChainSpec, MAINNET};
use reth_chainspec::{ChainSpec, EthereumHardfork, MAINNET};
use reth_engine_primitives::BeaconEngineMessage;
use reth_ethereum_engine_primitives::{EthEngineTypes, EthereumEngineValidator};
use reth_payload_builder::test_utils::spawn_test_payload_service;

View File

@ -114,7 +114,10 @@ where
.chain_spec
.get_final_paris_total_difficulty()
.is_some(),
terminal_total_difficulty: self.chain_spec.fork(EthereumHardfork::Paris).ttd(),
terminal_total_difficulty: self
.chain_spec
.ethereum_fork_activation(EthereumHardfork::Paris)
.ttd(),
deposit_contract_address: self.chain_spec.deposit_contract().map(|dc| dc.address),
..self.chain_spec.genesis().config.clone()
};
@ -125,7 +128,7 @@ where
$(
// don't overwrite if already set
if $config.$field.is_none() {
$config.$field = match self.chain_spec.fork(EthereumHardfork::$fork) {
$config.$field = match self.chain_spec.ethereum_fork_activation(EthereumHardfork::$fork) {
ForkCondition::Block(block) => Some(block),
ForkCondition::TTD { fork_block, .. } => fork_block,
ForkCondition::Timestamp(ts) => Some(ts),