Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PayloadOrAttributes generic over ExecutionData #14666

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yohkaz
Copy link
Contributor

@yohkaz yohkaz commented Feb 23, 2025

Closes #14651

@@ -25,6 +23,9 @@ use reth_primitives::{NodePrimitives, RecoveredBlock, SealedBlock};
use reth_primitives_traits::Block;
use serde::{de::DeserializeOwned, Serialize};

// Re-export [`ExecutionPayload`] moved to `reth_payload_primitives`
Copy link
Contributor Author

@yohkaz yohkaz Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ExecutionPayload trait was moved to the reth_payload_primitives crate.
Importing the trait from the reth_engine_primitives crate to the reth_payload_primitives crate creates a cyclic dependency.
I'm re-exporting it here, to avoid the potential breaking change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good thinking, reth-engine-primitives has reth-payload-primitives as dep, so makes more sense to move it into reth-payload-primitives for now

@@ -25,6 +23,9 @@ use reth_primitives::{NodePrimitives, RecoveredBlock, SealedBlock};
use reth_primitives_traits::Block;
use serde::{de::DeserializeOwned, Serialize};

// Re-export [`ExecutionPayload`] moved to `reth_payload_primitives`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good thinking, reth-engine-primitives has reth-payload-primitives as dep, so makes more sense to move it into reth-payload-primitives for now

@@ -302,10 +302,10 @@ impl MessageValidationKind {
/// either an execution payload, or payload attributes.
///
/// The version is provided by the [`EngineApiMessageVersion`] argument.
pub fn validate_version_specific_fields<Type, T>(
pub fn validate_version_specific_fields<Payload: ExecutionPayload, Type, T>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better move this trait bound down into where clause on this method

Comment on lines +9 to +30
/// An execution payload.
pub trait ExecutionPayload:
Serialize + DeserializeOwned + Debug + Clone + Send + Sync + 'static
{
/// Returns the parent hash of the block.
fn parent_hash(&self) -> B256;

/// Returns the hash of the block.
fn block_hash(&self) -> B256;

/// Returns the number of the block.
fn block_number(&self) -> u64;

/// Returns the withdrawals for the payload, if it exists.
fn withdrawals(&self) -> Option<&Vec<Withdrawal>>;

/// Return the parent beacon block root for the payload, if it exists.
fn parent_beacon_block_root(&self) -> Option<B256>;

/// Returns the timestamp to be used in the payload.
fn timestamp(&self) -> u64;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs implementation for OpExecutionPayload too, think @mattsse wants an op feature to be added for this reason for now to feature gate the impl of this trait under the impl for ExecutionData

/// The parent beacon block root
parent_beacon_block_root: Option<B256>,
},
pub enum PayloadOrAttributes<'a, Payload: ExecutionPayload, Attributes> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub enum PayloadOrAttributes<'a, Payload: ExecutionPayload, Attributes> {
pub enum PayloadOrAttributes<'a, Payload, Attributes> {

no need to add this trait bound on the type definition since none of the fields is an associated type of this trait. for example if you had some field as Payload::SomeAssociatedType then you would need the trait bound here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make PayloadOrAttributes generic over ExecutionData
2 participants