Skip to content

Commit 5ea2c1b

Browse files
RomanHodulakklkvr
andauthored
feat(optimism): Remove bounds on EthChainSpec and Hardforks for OpEngineValidator (#16574)
Co-authored-by: Arsenii Kulikov <[email protected]>
1 parent d1c293c commit 5ea2c1b

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

crates/optimism/node/src/engine.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use op_alloy_rpc_types_engine::{
55
OpExecutionData, OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4,
66
OpPayloadAttributes,
77
};
8-
use reth_chainspec::{EthChainSpec, Hardforks};
98
use reth_consensus::ConsensusError;
109
use reth_node_api::{
1110
payload::{
@@ -17,7 +16,7 @@ use reth_node_api::{
1716
PayloadValidator,
1817
};
1918
use reth_optimism_consensus::isthmus;
20-
use reth_optimism_forks::{OpHardfork, OpHardforks};
19+
use reth_optimism_forks::OpHardforks;
2120
use reth_optimism_payload_builder::{OpExecutionPayloadValidator, OpPayloadTypes};
2221
use reth_optimism_primitives::{OpBlock, ADDRESS_L2_TO_L1_MESSAGE_PASSER};
2322
use reth_primitives_traits::{Block, RecoveredBlock, SealedBlock, SignedTransaction};
@@ -67,16 +66,16 @@ where
6766

6867
/// Validator for Optimism engine API.
6968
#[derive(Debug, Clone)]
70-
pub struct OpEngineValidator<P, Tx, Chain> {
71-
inner: OpExecutionPayloadValidator<Chain>,
69+
pub struct OpEngineValidator<P, Tx, ChainSpec> {
70+
inner: OpExecutionPayloadValidator<ChainSpec>,
7271
provider: P,
7372
hashed_addr_l2tol1_msg_passer: B256,
7473
phantom: PhantomData<Tx>,
7574
}
7675

77-
impl<P, Tx, Chain> OpEngineValidator<P, Tx, Chain> {
76+
impl<P, Tx, ChainSpec> OpEngineValidator<P, Tx, ChainSpec> {
7877
/// Instantiates a new validator.
79-
pub fn new<KH: KeyHasher>(chain_spec: Arc<Chain>, provider: P) -> Self {
78+
pub fn new<KH: KeyHasher>(chain_spec: Arc<ChainSpec>, provider: P) -> Self {
8079
let hashed_addr_l2tol1_msg_passer = KH::hash_key(ADDRESS_L2_TO_L1_MESSAGE_PASSER);
8180
Self {
8281
inner: OpExecutionPayloadValidator::new(chain_spec),
@@ -87,22 +86,22 @@ impl<P, Tx, Chain> OpEngineValidator<P, Tx, Chain> {
8786
}
8887
}
8988

90-
impl<P, Tx, Chain> OpEngineValidator<P, Tx, Chain>
89+
impl<P, Tx, ChainSpec> OpEngineValidator<P, Tx, ChainSpec>
9190
where
92-
Chain: OpHardforks,
91+
ChainSpec: OpHardforks,
9392
{
9493
/// Returns the chain spec used by the validator.
9594
#[inline]
96-
fn chain_spec(&self) -> &Chain {
95+
fn chain_spec(&self) -> &ChainSpec {
9796
self.inner.chain_spec()
9897
}
9998
}
10099

101-
impl<P, Tx, Chain> PayloadValidator for OpEngineValidator<P, Tx, Chain>
100+
impl<P, Tx, ChainSpec> PayloadValidator for OpEngineValidator<P, Tx, ChainSpec>
102101
where
103102
P: StateProviderFactory + Unpin + 'static,
104103
Tx: SignedTransaction + Unpin + 'static,
105-
Chain: EthChainSpec + OpHardforks + Hardforks + 'static,
104+
ChainSpec: OpHardforks + Send + Sync + 'static,
106105
{
107106
type Block = alloy_consensus::Block<Tx>;
108107
type ExecutionData = OpExecutionData;
@@ -147,16 +146,16 @@ where
147146
}
148147
}
149148

150-
impl<Types, P, Tx, Chain> EngineValidator<Types> for OpEngineValidator<P, Tx, Chain>
149+
impl<Types, P, Tx, ChainSpec> EngineValidator<Types> for OpEngineValidator<P, Tx, ChainSpec>
151150
where
152151
Types: PayloadTypes<
153152
PayloadAttributes = OpPayloadAttributes,
154153
ExecutionData = <Self as PayloadValidator>::ExecutionData,
155154
BuiltPayload: BuiltPayload<Primitives: NodePrimitives<SignedTx = Tx>>,
156155
>,
157156
P: StateProviderFactory + Unpin + 'static,
158-
Tx: SignedTransaction + Unpin + 'static + Send + Sync,
159-
Chain: EthChainSpec + OpHardforks + Hardforks + 'static,
157+
Tx: SignedTransaction + Unpin + 'static,
158+
ChainSpec: OpHardforks + Send + Sync + 'static,
160159
{
161160
fn validate_version_specific_fields(
162161
&self,
@@ -231,13 +230,13 @@ where
231230
/// Canyon activates the Shanghai EIPs, see the Canyon specs for more details:
232231
/// <https://github.com/ethereum-optimism/optimism/blob/ab926c5fd1e55b5c864341c44842d6d1ca679d99/specs/superchain-upgrades.md#canyon>
233232
pub fn validate_withdrawals_presence(
234-
chain_spec: &(impl EthChainSpec + OpHardforks + Hardforks),
233+
chain_spec: impl OpHardforks,
235234
version: EngineApiMessageVersion,
236235
message_validation_kind: MessageValidationKind,
237236
timestamp: u64,
238237
has_withdrawals: bool,
239238
) -> Result<(), EngineObjectValidationError> {
240-
let is_shanghai = chain_spec.fork(OpHardfork::Canyon).active_at_timestamp(timestamp);
239+
let is_shanghai = chain_spec.is_canyon_active_at_timestamp(timestamp);
241240

242241
match version {
243242
EngineApiMessageVersion::V1 => {

0 commit comments

Comments
 (0)