feat: integrate request validation in EnginveValidator (#13858)

Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
DevOrbitlabs
2025-01-23 23:11:30 +07:00
committed by GitHub
parent 187634fd2f
commit 9039909a78
11 changed files with 47 additions and 29 deletions

View File

@ -24,6 +24,7 @@ reth-errors.workspace = true
alloy-primitives.workspace = true
alloy-consensus.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-eips.workspace = true
# async
tokio = { workspace = true, features = ["sync"] }
@ -36,13 +37,14 @@ thiserror.workspace = true
[features]
default = ["std"]
std = [
"reth-execution-types/std",
"reth-primitives/std",
"reth-primitives-traits/std",
"alloy-primitives/std",
"alloy-consensus/std",
"alloy-rpc-types-engine/std",
"futures/std",
"serde/std",
"thiserror/std",
"reth-execution-types/std",
"reth-primitives/std",
"reth-primitives-traits/std",
"alloy-primitives/std",
"alloy-consensus/std",
"alloy-rpc-types-engine/std",
"futures/std",
"serde/std",
"thiserror/std",
"alloy-eips/std"
]

View File

@ -11,6 +11,7 @@
extern crate alloc;
use reth_payload_primitives::{BuiltPayload, PayloadAttributes};
mod error;
use core::fmt;
@ -31,15 +32,16 @@ pub use event::*;
mod invalid_block_hook;
pub use invalid_block_hook::InvalidBlockHook;
pub use reth_payload_primitives::{
BuiltPayload, EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes,
PayloadTypes,
use reth_payload_primitives::{
validate_execution_requests, EngineApiMessageVersion, EngineObjectValidationError,
InvalidPayloadAttributesError, PayloadOrAttributes, PayloadTypes,
};
use reth_payload_primitives::{InvalidPayloadAttributesError, PayloadAttributes};
use reth_primitives::{NodePrimitives, SealedBlock};
use reth_primitives_traits::Block;
use serde::{de::DeserializeOwned, ser::Serialize};
use alloy_eips::eip7685::Requests;
/// This type defines the versioned types of the engine API.
///
/// This includes the execution payload types and payload attributes that are used to trigger a
@ -117,6 +119,14 @@ pub trait PayloadValidator: fmt::Debug + Send + Sync + Unpin + 'static {
/// Type that validates the payloads processed by the engine.
pub trait EngineValidator<Types: EngineTypes>: PayloadValidator {
/// Validates the execution requests according to [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685).
fn validate_execution_requests(
&self,
requests: &Requests,
) -> Result<(), EngineObjectValidationError> {
validate_execution_requests(requests)
}
/// Validates the presence or exclusion of fork-specific fields based on the payload attributes
/// and the message version.
fn validate_version_specific_fields(