mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
feat(api,rpc): improve engine API abstraction (#6871)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -6,6 +6,7 @@ use reth_primitives::{ChainSpec, Hardfork};
|
||||
/// Contains traits to abstract over payload attributes types and default implementations of the
|
||||
/// [PayloadAttributes] trait for ethereum mainnet and optimism types.
|
||||
pub mod traits;
|
||||
use serde::{de::DeserializeOwned, ser::Serialize};
|
||||
pub use traits::{BuiltPayload, PayloadAttributes, PayloadBuilderAttributes};
|
||||
|
||||
/// Contains error types used in the traits defined in this crate.
|
||||
@@ -18,7 +19,7 @@ pub use payload::PayloadOrAttributes;
|
||||
|
||||
/// The types that are used by the engine API.
|
||||
pub trait EngineTypes:
|
||||
serde::de::DeserializeOwned + fmt::Debug + Unpin + Send + Sync + Clone
|
||||
serde::de::DeserializeOwned + Serialize + fmt::Debug + Unpin + Send + Sync + Clone
|
||||
{
|
||||
/// The RPC payload attributes type the CL node emits via the engine API.
|
||||
type PayloadAttributes: PayloadAttributes + Unpin;
|
||||
@@ -29,7 +30,19 @@ pub trait EngineTypes:
|
||||
+ Unpin;
|
||||
|
||||
/// The built payload type.
|
||||
type BuiltPayload: BuiltPayload + Clone + Unpin;
|
||||
type BuiltPayload: BuiltPayload
|
||||
+ Clone
|
||||
+ Unpin
|
||||
+ TryInto<Self::ExecutionPayloadV1>
|
||||
+ TryInto<Self::ExecutionPayloadV2>
|
||||
+ TryInto<Self::ExecutionPayloadV3>;
|
||||
|
||||
/// Execution Payload V1 type.
|
||||
type ExecutionPayloadV1: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
|
||||
/// Execution Payload V2 type.
|
||||
type ExecutionPayloadV2: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
|
||||
/// Execution Payload V3 type.
|
||||
type ExecutionPayloadV3: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
|
||||
|
||||
/// Validates the presence or exclusion of fork-specific fields based on the payload attributes
|
||||
/// and the message version.
|
||||
|
||||
@@ -4,12 +4,8 @@ use reth_primitives::{
|
||||
Address, ChainSpec, Header, SealedBlock, Withdrawals, B256, U256,
|
||||
};
|
||||
use reth_rpc_types::{
|
||||
engine::{
|
||||
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, OptimismPayloadAttributes,
|
||||
PayloadAttributes as EthPayloadAttributes, PayloadId,
|
||||
},
|
||||
engine::{OptimismPayloadAttributes, PayloadAttributes as EthPayloadAttributes, PayloadId},
|
||||
withdrawal::Withdrawal,
|
||||
ExecutionPayloadV1,
|
||||
};
|
||||
|
||||
/// Represents a built payload type that contains a built [SealedBlock] and can be converted into
|
||||
@@ -20,15 +16,6 @@ pub trait BuiltPayload: Send + Sync + std::fmt::Debug {
|
||||
|
||||
/// Returns the fees collected for the built block
|
||||
fn fees(&self) -> U256;
|
||||
|
||||
/// Converts the type into the response expected by `engine_getPayloadV1`
|
||||
fn into_v1_payload(self) -> ExecutionPayloadV1;
|
||||
|
||||
/// Converts the type into the response expected by `engine_getPayloadV2`
|
||||
fn into_v2_payload(self) -> ExecutionPayloadEnvelopeV2;
|
||||
|
||||
/// Converts the type into the response expected by `engine_getPayloadV3`
|
||||
fn into_v3_payload(self) -> ExecutionPayloadEnvelopeV3;
|
||||
}
|
||||
|
||||
/// This can be implemented by types that describe a currently running payload job.
|
||||
|
||||
Reference in New Issue
Block a user