mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: move EngineValidator setup to RpcAddOns (#11850)
This commit is contained in:
@ -34,12 +34,15 @@ use alloy_rpc_types::{
|
||||
use reth::{
|
||||
api::PayloadTypes,
|
||||
builder::{
|
||||
components::{ComponentsBuilder, EngineValidatorBuilder, PayloadServiceBuilder},
|
||||
components::{ComponentsBuilder, PayloadServiceBuilder},
|
||||
node::{NodeTypes, NodeTypesWithEngine},
|
||||
rpc::{EngineValidatorBuilder, RpcAddOns},
|
||||
BuilderContext, FullNodeTypes, Node, NodeAdapter, NodeBuilder, NodeComponentsBuilder,
|
||||
PayloadBuilderConfig,
|
||||
},
|
||||
network::NetworkHandle,
|
||||
providers::{CanonStateSubscriptions, StateProviderFactory},
|
||||
rpc::eth::EthApi,
|
||||
tasks::TaskManager,
|
||||
transaction_pool::TransactionPool,
|
||||
};
|
||||
@ -50,13 +53,13 @@ use reth_basic_payload_builder::{
|
||||
use reth_chainspec::{Chain, ChainSpec, ChainSpecProvider};
|
||||
use reth_node_api::{
|
||||
payload::{EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes},
|
||||
validate_version_specific_fields, EngineTypes, EngineValidator, PayloadAttributes,
|
||||
PayloadBuilderAttributes,
|
||||
validate_version_specific_fields, AddOnsContext, EngineTypes, EngineValidator,
|
||||
FullNodeComponents, PayloadAttributes, PayloadBuilderAttributes,
|
||||
};
|
||||
use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig};
|
||||
use reth_node_ethereum::{
|
||||
node::{
|
||||
EthereumAddOns, EthereumConsensusBuilder, EthereumExecutorBuilder, EthereumNetworkBuilder,
|
||||
EthereumConsensusBuilder, EthereumExecutorBuilder, EthereumNetworkBuilder,
|
||||
EthereumPoolBuilder,
|
||||
},
|
||||
EthEvmConfig,
|
||||
@ -202,12 +205,14 @@ pub struct CustomEngineValidatorBuilder;
|
||||
|
||||
impl<N> EngineValidatorBuilder<N> for CustomEngineValidatorBuilder
|
||||
where
|
||||
N: FullNodeTypes<Types: NodeTypesWithEngine<Engine = CustomEngineTypes, ChainSpec = ChainSpec>>,
|
||||
N: FullNodeComponents<
|
||||
Types: NodeTypesWithEngine<Engine = CustomEngineTypes, ChainSpec = ChainSpec>,
|
||||
>,
|
||||
{
|
||||
type Validator = CustomEngineValidator;
|
||||
|
||||
async fn build_validator(self, ctx: &BuilderContext<N>) -> eyre::Result<Self::Validator> {
|
||||
Ok(CustomEngineValidator { chain_spec: ctx.chain_spec() })
|
||||
async fn build(self, ctx: &AddOnsContext<'_, N>) -> eyre::Result<Self::Validator> {
|
||||
Ok(CustomEngineValidator { chain_spec: ctx.config.chain.clone() })
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,6 +231,18 @@ impl NodeTypesWithEngine for MyCustomNode {
|
||||
type Engine = CustomEngineTypes;
|
||||
}
|
||||
|
||||
/// Custom addons configuring RPC types
|
||||
pub type MyNodeAddOns<N> = RpcAddOns<
|
||||
N,
|
||||
EthApi<
|
||||
<N as FullNodeTypes>::Provider,
|
||||
<N as FullNodeComponents>::Pool,
|
||||
NetworkHandle,
|
||||
<N as FullNodeComponents>::Evm,
|
||||
>,
|
||||
CustomEngineValidatorBuilder,
|
||||
>;
|
||||
|
||||
/// Implement the Node trait for the custom node
|
||||
///
|
||||
/// This provides a preset configuration for the node
|
||||
@ -240,9 +257,8 @@ where
|
||||
EthereumNetworkBuilder,
|
||||
EthereumExecutorBuilder,
|
||||
EthereumConsensusBuilder,
|
||||
CustomEngineValidatorBuilder,
|
||||
>;
|
||||
type AddOns = EthereumAddOns<
|
||||
type AddOns = MyNodeAddOns<
|
||||
NodeAdapter<N, <Self::ComponentsBuilder as NodeComponentsBuilder<N>>::Components>,
|
||||
>;
|
||||
|
||||
@ -254,11 +270,10 @@ where
|
||||
.network(EthereumNetworkBuilder::default())
|
||||
.executor(EthereumExecutorBuilder::default())
|
||||
.consensus(EthereumConsensusBuilder::default())
|
||||
.engine_validator(CustomEngineValidatorBuilder::default())
|
||||
}
|
||||
|
||||
fn add_ons(&self) -> Self::AddOns {
|
||||
EthereumAddOns::default()
|
||||
MyNodeAddOns::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user