Skip to content

Commit 319a8dc

Browse files
authored
chore: relax ChainSpec impls (#18894)
1 parent 029509c commit 319a8dc

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

crates/chainspec/src/api.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::{ChainSpec, DepositContract};
22
use alloc::{boxed::Box, vec::Vec};
33
use alloy_chains::Chain;
4-
use alloy_consensus::Header;
54
use alloy_eips::{calc_next_block_base_fee, eip1559::BaseFeeParams, eip7840::BlobParams};
65
use alloy_genesis::Genesis;
76
use alloy_primitives::{B256, U256};
@@ -75,8 +74,8 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug {
7574
}
7675
}
7776

78-
impl EthChainSpec for ChainSpec {
79-
type Header = Header;
77+
impl<H: BlockHeader> EthChainSpec for ChainSpec<H> {
78+
type Header = H;
8079

8180
fn chain(&self) -> Chain {
8281
self.chain

crates/chainspec/src/spec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl From<ForkBaseFeeParams> for BaseFeeParamsKind {
266266
#[derive(Clone, Debug, PartialEq, Eq, From)]
267267
pub struct ForkBaseFeeParams(Vec<(Box<dyn Hardfork>, BaseFeeParams)>);
268268

269-
impl core::ops::Deref for ChainSpec {
269+
impl<H: BlockHeader> core::ops::Deref for ChainSpec<H> {
270270
type Target = ChainHardforks;
271271

272272
fn deref(&self) -> &Self::Target {
@@ -1033,7 +1033,7 @@ impl From<&Arc<ChainSpec>> for ChainSpecBuilder {
10331033
}
10341034
}
10351035

1036-
impl EthExecutorSpec for ChainSpec {
1036+
impl<H: BlockHeader> EthExecutorSpec for ChainSpec<H> {
10371037
fn deposit_contract_address(&self) -> Option<Address> {
10381038
self.deposit_contract.map(|deposit_contract| deposit_contract.address)
10391039
}

crates/ethereum/consensus/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ where
196196
#[cfg(test)]
197197
mod tests {
198198
use super::*;
199+
use alloy_consensus::Header;
199200
use alloy_primitives::B256;
200201
use reth_chainspec::{ChainSpec, ChainSpecBuilder};
201202
use reth_consensus_common::validation::validate_against_parent_gas_limit;
@@ -215,7 +216,7 @@ mod tests {
215216
let child = header_with_gas_limit((parent.gas_limit + 5) as u64);
216217

217218
assert_eq!(
218-
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::default()),
219+
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::<Header>::default()),
219220
Ok(())
220221
);
221222
}
@@ -226,7 +227,7 @@ mod tests {
226227
let child = header_with_gas_limit(MINIMUM_GAS_LIMIT - 1);
227228

228229
assert_eq!(
229-
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::default()),
230+
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::<Header>::default()),
230231
Err(ConsensusError::GasLimitInvalidMinimum { child_gas_limit: child.gas_limit as u64 })
231232
);
232233
}
@@ -239,7 +240,7 @@ mod tests {
239240
);
240241

241242
assert_eq!(
242-
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::default()),
243+
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::<Header>::default()),
243244
Err(ConsensusError::GasLimitInvalidIncrease {
244245
parent_gas_limit: parent.gas_limit,
245246
child_gas_limit: child.gas_limit,
@@ -253,7 +254,7 @@ mod tests {
253254
let child = header_with_gas_limit(parent.gas_limit - 5);
254255

255256
assert_eq!(
256-
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::default()),
257+
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::<Header>::default()),
257258
Ok(())
258259
);
259260
}
@@ -266,7 +267,7 @@ mod tests {
266267
);
267268

268269
assert_eq!(
269-
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::default()),
270+
validate_against_parent_gas_limit(&child, &parent, &ChainSpec::<Header>::default()),
270271
Err(ConsensusError::GasLimitInvalidDecrease {
271272
parent_gas_limit: parent.gas_limit,
272273
child_gas_limit: child.gas_limit,

0 commit comments

Comments
 (0)