mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(chainspec): add Chainspec::blob_fee_params_at_timestamp (#14049)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -2,10 +2,11 @@ use crate::{ChainSpec, DepositContract};
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use alloy_chains::Chain;
|
||||
use alloy_consensus::Header;
|
||||
use alloy_eips::eip1559::BaseFeeParams;
|
||||
use alloy_eips::{eip1559::BaseFeeParams, eip7840::BlobParams};
|
||||
use alloy_genesis::Genesis;
|
||||
use alloy_primitives::B256;
|
||||
use core::fmt::{Debug, Display};
|
||||
use reth_ethereum_forks::EthereumHardforks;
|
||||
use reth_network_peers::NodeRecord;
|
||||
|
||||
/// Trait representing type configuring a chain spec.
|
||||
@ -31,6 +32,9 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug {
|
||||
/// Get the [`BaseFeeParams`] for the chain at the given timestamp.
|
||||
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams;
|
||||
|
||||
/// Get the [`BlobParams`] for the given timestamp
|
||||
fn blob_params_at_timestamp(&self, timestamp: u64) -> Option<BlobParams>;
|
||||
|
||||
/// Returns the deposit contract data for the chain, if it's present
|
||||
fn deposit_contract(&self) -> Option<&DepositContract>;
|
||||
|
||||
@ -78,6 +82,16 @@ impl EthChainSpec for ChainSpec {
|
||||
self.base_fee_params_at_timestamp(timestamp)
|
||||
}
|
||||
|
||||
fn blob_params_at_timestamp(&self, timestamp: u64) -> Option<BlobParams> {
|
||||
if self.is_prague_active_at_timestamp(timestamp) {
|
||||
Some(self.blob_params.prague)
|
||||
} else if self.is_cancun_active_at_timestamp(timestamp) {
|
||||
Some(self.blob_params.cancun)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn deposit_contract(&self) -> Option<&DepositContract> {
|
||||
self.deposit_contract.as_ref()
|
||||
}
|
||||
|
||||
@ -413,6 +413,17 @@ impl ChainSpec {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the [`BlobParams`] for the given timestamp.
|
||||
///
|
||||
/// Note: This always return [`BlobParams::cancun`] pre prague.
|
||||
pub fn blob_fee_params_at_timestamp(&self, timestamp: u64) -> BlobParams {
|
||||
if self.is_prague_active_at_timestamp(timestamp) {
|
||||
self.blob_params.prague
|
||||
} else {
|
||||
self.blob_params.cancun
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the hash of the genesis block.
|
||||
pub fn genesis_hash(&self) -> B256 {
|
||||
*self.genesis_hash.get_or_init(|| self.genesis_header().hash_slow())
|
||||
|
||||
Reference in New Issue
Block a user