Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions crates/ethereum/node/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use reth_chainspec::ChainSpec;
use reth_engine_primitives::{EngineTypes, EngineValidator, PayloadValidator};
use reth_ethereum_payload_builder::EthereumExecutionPayloadValidator;
use reth_payload_primitives::{
validate_version_specific_fields, EngineApiMessageVersion, EngineObjectValidationError,
NewPayloadError, PayloadOrAttributes,
validate_execution_requests, validate_version_specific_fields, EngineApiMessageVersion,
EngineObjectValidationError, NewPayloadError, PayloadOrAttributes,
};
use reth_primitives::{Block, RecoveredBlock};
use std::sync::Arc;
Expand Down Expand Up @@ -56,6 +56,11 @@ where
version: EngineApiMessageVersion,
payload_or_attrs: PayloadOrAttributes<'_, Self::ExecutionData, EthPayloadAttributes>,
) -> Result<(), EngineObjectValidationError> {
payload_or_attrs
.execution_requests()
.map(|requests| validate_execution_requests(requests))
.transpose()?;

validate_version_specific_fields(self.chain_spec(), version, payload_or_attrs)
}

Expand Down
30 changes: 29 additions & 1 deletion crates/payload/primitives/src/payload.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::{MessageValidationKind, PayloadAttributes};
use alloc::vec::Vec;
use alloy_eips::eip4895::Withdrawal;
use alloy_eips::{
eip4895::Withdrawal,
eip7685::{Requests, RequestsOrHash},
};
use alloy_primitives::B256;
use alloy_rpc_types_engine::ExecutionData;
use core::fmt::Debug;
Expand Down Expand Up @@ -164,3 +167,28 @@ impl ExecutionPayload for op_alloy_rpc_types_engine::OpExecutionData {
self.payload.as_v1().gas_used
}
}

/// Special implementation for Ethereum types that provides additional helper methods
impl<'a, Attributes> PayloadOrAttributes<'a, ExecutionData, Attributes>
where
Attributes: PayloadAttributes,
{
/// Return the execution requests from the payload, if available.
///
/// This will return `Some(requests)` only if:
/// - The payload is an `ExecutionData` (not `PayloadAttributes`)
/// - The payload has Prague payload fields
/// - The Prague fields contain requests (not a hash)
///
/// Returns `None` in all other cases.
pub fn execution_requests(&self) -> Option<&Requests> {
if let Self::ExecutionPayload(payload) = self {
payload.sidecar.prague().and_then(|prague_fields| match &prague_fields.requests {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's also fn requests -> Option<&Requests> I believe

Copy link
Member Author

Choose a reason for hiding this comment

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

awesome thx! changes to use it here 3cc6d1b

RequestsOrHash::Requests(requests) => Some(requests),
_ => None,
})
} else {
None
}
}
}
Loading