Introduce Eth PayloadTypes Impl (#11519)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Steven
2024-10-07 10:30:57 -06:00
committed by GitHub
parent 8ca5ec9b72
commit 9a732f6b78
2 changed files with 27 additions and 7 deletions

View File

@ -26,21 +26,40 @@ use reth_payload_primitives::{
/// The types used in the default mainnet ethereum beacon consensus engine.
#[derive(Debug, Default, Clone, serde::Deserialize, serde::Serialize)]
#[non_exhaustive]
pub struct EthEngineTypes;
impl PayloadTypes for EthEngineTypes {
type BuiltPayload = EthBuiltPayload;
type PayloadAttributes = EthPayloadAttributes;
type PayloadBuilderAttributes = EthPayloadBuilderAttributes;
pub struct EthEngineTypes<T: PayloadTypes = EthPayloadTypes> {
_marker: std::marker::PhantomData<T>,
}
impl EngineTypes for EthEngineTypes {
impl<T: PayloadTypes> PayloadTypes for EthEngineTypes<T> {
type BuiltPayload = T::BuiltPayload;
type PayloadAttributes = T::PayloadAttributes;
type PayloadBuilderAttributes = T::PayloadBuilderAttributes;
}
impl<T: PayloadTypes> EngineTypes for EthEngineTypes<T>
where
T::BuiltPayload: TryInto<ExecutionPayloadV1>
+ TryInto<ExecutionPayloadEnvelopeV2>
+ TryInto<ExecutionPayloadEnvelopeV3>
+ TryInto<ExecutionPayloadEnvelopeV4>,
{
type ExecutionPayloadV1 = ExecutionPayloadV1;
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
type ExecutionPayloadV3 = ExecutionPayloadEnvelopeV3;
type ExecutionPayloadV4 = ExecutionPayloadEnvelopeV4;
}
/// A default payload type for [`EthEngineTypes`]
#[derive(Debug, Default, Clone, serde::Deserialize, serde::Serialize)]
#[non_exhaustive]
pub struct EthPayloadTypes;
impl PayloadTypes for EthPayloadTypes {
type BuiltPayload = EthBuiltPayload;
type PayloadAttributes = EthPayloadAttributes;
type PayloadBuilderAttributes = EthPayloadBuilderAttributes;
}
/// Validator for the ethereum engine API.
#[derive(Debug, Clone)]
pub struct EthereumEngineValidator {

View File

@ -40,6 +40,7 @@ pub trait NodeTypes: Send + Sync + Unpin + 'static {
pub trait NodeTypesWithEngine: NodeTypes {
/// The node's engine types, defining the interaction with the consensus engine.
type Engine: EngineTypes;
// type Engine: EngineTypes;
}
/// A helper trait that is downstream of the [`NodeTypesWithEngine`] trait and adds database to the