mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(rpc): relax VaidationApi and EngineApi (#13241)
This commit is contained in:
@ -55,7 +55,7 @@ use reth_chainspec::{Chain, ChainSpec, ChainSpecProvider};
|
||||
use reth_node_api::{
|
||||
payload::{EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes},
|
||||
validate_version_specific_fields, AddOnsContext, EngineTypes, EngineValidator,
|
||||
FullNodeComponents, PayloadAttributes, PayloadBuilderAttributes,
|
||||
FullNodeComponents, PayloadAttributes, PayloadBuilderAttributes, PayloadValidator,
|
||||
};
|
||||
use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig};
|
||||
use reth_node_ethereum::{
|
||||
@ -189,12 +189,22 @@ impl CustomEngineValidator {
|
||||
}
|
||||
}
|
||||
|
||||
impl PayloadValidator for CustomEngineValidator {
|
||||
type Block = Block;
|
||||
|
||||
fn ensure_well_formed_payload(
|
||||
&self,
|
||||
payload: ExecutionPayload,
|
||||
sidecar: ExecutionPayloadSidecar,
|
||||
) -> Result<SealedBlockFor<Self::Block>, PayloadError> {
|
||||
self.inner.ensure_well_formed_payload(payload, sidecar)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> EngineValidator<T> for CustomEngineValidator
|
||||
where
|
||||
T: EngineTypes<PayloadAttributes = CustomPayloadAttributes>,
|
||||
{
|
||||
type Block = Block;
|
||||
|
||||
fn validate_version_specific_fields(
|
||||
&self,
|
||||
version: EngineApiMessageVersion,
|
||||
@ -220,14 +230,6 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ensure_well_formed_payload(
|
||||
&self,
|
||||
payload: ExecutionPayload,
|
||||
sidecar: ExecutionPayloadSidecar,
|
||||
) -> Result<SealedBlockFor<Self::Block>, PayloadError> {
|
||||
self.inner.ensure_well_formed_payload(payload, sidecar)
|
||||
}
|
||||
|
||||
fn validate_payload_attributes_against_header(
|
||||
&self,
|
||||
_attr: &<T as PayloadTypes>::PayloadAttributes,
|
||||
@ -246,7 +248,11 @@ pub struct CustomEngineValidatorBuilder;
|
||||
impl<N> EngineValidatorBuilder<N> for CustomEngineValidatorBuilder
|
||||
where
|
||||
N: FullNodeComponents<
|
||||
Types: NodeTypesWithEngine<Engine = CustomEngineTypes, ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<
|
||||
Engine = CustomEngineTypes,
|
||||
ChainSpec = ChainSpec,
|
||||
Primitives = EthPrimitives,
|
||||
>,
|
||||
>,
|
||||
{
|
||||
type Validator = CustomEngineValidator;
|
||||
|
||||
@ -34,7 +34,9 @@ use reth::rpc::builder::{
|
||||
// Configuring the network parts, ideally also wouldn't need to think about this.
|
||||
use myrpc_ext::{MyRpcExt, MyRpcExtApiServer};
|
||||
use reth::{blockchain_tree::noop::NoopBlockchainTree, tasks::TokioTaskExecutor};
|
||||
use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider, EthereumNode};
|
||||
use reth_node_ethereum::{
|
||||
node::EthereumEngineValidator, EthEvmConfig, EthExecutorProvider, EthereumNode,
|
||||
};
|
||||
use reth_provider::{test_utils::TestCanonStateSubscriptions, ChainSpecProvider};
|
||||
|
||||
// Custom rpc extension
|
||||
@ -70,11 +72,15 @@ async fn main() -> eyre::Result<()> {
|
||||
.with_evm_config(EthEvmConfig::new(spec.clone()))
|
||||
.with_events(TestCanonStateSubscriptions::default())
|
||||
.with_block_executor(EthExecutorProvider::ethereum(provider.chain_spec()))
|
||||
.with_consensus(EthBeaconConsensus::new(spec));
|
||||
.with_consensus(EthBeaconConsensus::new(spec.clone()));
|
||||
|
||||
// Pick which namespaces to expose.
|
||||
let config = TransportRpcModuleConfig::default().with_http([RethRpcModule::Eth]);
|
||||
let mut server = rpc_builder.build(config, Box::new(EthApi::with_spawner));
|
||||
let mut server = rpc_builder.build(
|
||||
config,
|
||||
Box::new(EthApi::with_spawner),
|
||||
Arc::new(EthereumEngineValidator::new(spec)),
|
||||
);
|
||||
|
||||
// Add a custom rpc namespace
|
||||
let custom_rpc = MyRpcExt { provider };
|
||||
|
||||
Reference in New Issue
Block a user