feat: make NodeConfig generic over ChainSpec (#11039)

This commit is contained in:
Arsenii Kulikov
2024-09-19 19:05:09 +03:00
committed by GitHub
parent 65fb29c773
commit c3d090adf4
16 changed files with 186 additions and 106 deletions

View File

@ -1,6 +1,7 @@
use crate::ChainSpec;
use crate::{ChainSpec, DepositContract};
use alloy_chains::Chain;
use alloy_eips::eip1559::BaseFeeParams;
use alloy_primitives::B256;
use core::fmt::Debug;
/// Trait representing type configuring a chain spec.
@ -14,6 +15,15 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug + 'static {
/// Get the [`BaseFeeParams`] for the chain at the given timestamp.
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams;
/// Returns the deposit contract data for the chain, if it's present
fn deposit_contract(&self) -> Option<&DepositContract>;
/// The genesis hash.
fn genesis_hash(&self) -> B256;
/// The delete limit for pruner, per run.
fn prune_delete_limit(&self) -> usize;
}
impl EthChainSpec for ChainSpec {
@ -24,4 +34,16 @@ impl EthChainSpec for ChainSpec {
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams {
self.base_fee_params_at_timestamp(timestamp)
}
fn deposit_contract(&self) -> Option<&DepositContract> {
self.deposit_contract.as_ref()
}
fn genesis_hash(&self) -> B256 {
self.genesis_hash()
}
fn prune_delete_limit(&self) -> usize {
self.prune_delete_limit
}
}