feat(rpc): relax VaidationApi and EngineApi (#13241)

This commit is contained in:
Arsenii Kulikov
2024-12-10 01:48:29 +04:00
committed by GitHub
parent af5dc60867
commit eb6080863b
20 changed files with 259 additions and 193 deletions

View File

@ -18,7 +18,7 @@ pub use alloy_rpc_types_engine::{
};
pub use payload::{EthBuiltPayload, EthPayloadBuilderAttributes};
use reth_chainspec::ChainSpec;
use reth_engine_primitives::{EngineTypes, EngineValidator};
use reth_engine_primitives::{EngineTypes, EngineValidator, PayloadValidator};
use reth_payload_primitives::{
validate_version_specific_fields, EngineApiMessageVersion, EngineObjectValidationError,
PayloadOrAttributes, PayloadTypes,
@ -82,12 +82,22 @@ impl EthereumEngineValidator {
}
}
impl PayloadValidator for EthereumEngineValidator {
type Block = Block;
fn ensure_well_formed_payload(
&self,
payload: ExecutionPayload,
sidecar: ExecutionPayloadSidecar,
) -> Result<SealedBlock, PayloadError> {
self.inner.ensure_well_formed_payload(payload, sidecar)
}
}
impl<Types> EngineValidator<Types> for EthereumEngineValidator
where
Types: EngineTypes<PayloadAttributes = EthPayloadAttributes>,
{
type Block = Block;
fn validate_version_specific_fields(
&self,
version: EngineApiMessageVersion,
@ -103,12 +113,4 @@ where
) -> Result<(), EngineObjectValidationError> {
validate_version_specific_fields(self.chain_spec(), version, attributes.into())
}
fn ensure_well_formed_payload(
&self,
payload: ExecutionPayload,
sidecar: ExecutionPayloadSidecar,
) -> Result<SealedBlock, PayloadError> {
self.inner.ensure_well_formed_payload(payload, sidecar)
}
}

View File

@ -6,14 +6,13 @@ use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGenera
use reth_beacon_consensus::EthBeaconConsensus;
use reth_chainspec::ChainSpec;
use reth_ethereum_engine_primitives::{
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes, EthereumEngineValidator,
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
};
use reth_evm::execute::BasicBlockExecutorProvider;
use reth_evm_ethereum::execute::EthExecutionStrategyFactory;
use reth_network::{NetworkHandle, PeersInfo};
use reth_node_api::{
AddOnsContext, ConfigureEvm, EngineValidator, FullNodeComponents, HeaderTy, NodeTypesWithDB,
TxTy,
AddOnsContext, ConfigureEvm, FullNodeComponents, HeaderTy, NodeTypesWithDB, TxTy,
};
use reth_node_builder::{
components::{
@ -37,6 +36,8 @@ use reth_trie_db::MerklePatriciaTrie;
use crate::{EthEngineTypes, EthEvmConfig};
pub use reth_ethereum_engine_primitives::EthereumEngineValidator;
/// Type configuration for a regular Ethereum node.
#[derive(Debug, Default, Clone, Copy)]
#[non_exhaustive]
@ -353,9 +354,12 @@ pub struct EthereumEngineValidatorBuilder;
impl<Node, Types> EngineValidatorBuilder<Node> for EthereumEngineValidatorBuilder
where
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
Types: NodeTypesWithEngine<
ChainSpec = ChainSpec,
Engine = EthEngineTypes,
Primitives = EthPrimitives,
>,
Node: FullNodeComponents<Types = Types>,
EthereumEngineValidator: EngineValidator<Types::Engine>,
{
type Validator = EthereumEngineValidator;