mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: make InvalidBlockHook generic over NodePrimitives (#13105)
This commit is contained in:
@ -26,6 +26,5 @@ reth-node-types.workspace = true
|
||||
reth-node-core.workspace = true
|
||||
|
||||
alloy-rpc-types-engine.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
eyre.workspace = true
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
//! Traits for configuring a node.
|
||||
|
||||
use crate::ConfigureEvm;
|
||||
use alloy_consensus::Header;
|
||||
use alloy_rpc_types_engine::JwtSecret;
|
||||
use reth_beacon_consensus::BeaconConsensusEngineHandle;
|
||||
use reth_consensus::FullConsensus;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_network_api::FullNetwork;
|
||||
use reth_node_core::node_config::NodeConfig;
|
||||
use reth_node_types::{NodeTypes, NodeTypesWithDB, NodeTypesWithEngine, TxTy};
|
||||
use reth_node_types::{HeaderTy, NodeTypes, NodeTypesWithDB, NodeTypesWithEngine, TxTy};
|
||||
use reth_payload_builder_primitives::PayloadBuilder;
|
||||
use reth_provider::FullProvider;
|
||||
use reth_tasks::TaskExecutor;
|
||||
@ -50,7 +49,7 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
|
||||
type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Self::Types>>> + Unpin;
|
||||
|
||||
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
|
||||
type Evm: ConfigureEvm<Header = Header>;
|
||||
type Evm: ConfigureEvm<Header = HeaderTy<Self::Types>>;
|
||||
|
||||
/// The type that knows how to execute blocks.
|
||||
type Executor: BlockExecutorProvider<Primitives = <Self::Types as NodeTypes>::Primitives>;
|
||||
|
||||
@ -7,10 +7,9 @@ use crate::{
|
||||
},
|
||||
BuilderContext, ConfigureEvm, FullNodeTypes,
|
||||
};
|
||||
use alloy_consensus::Header;
|
||||
use reth_consensus::FullConsensus;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_node_api::{NodeTypes, NodeTypesWithEngine, TxTy};
|
||||
use reth_node_api::{HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
@ -378,7 +377,7 @@ where
|
||||
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
EVM: ConfigureEvm<Header = Header>,
|
||||
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>>,
|
||||
Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
|
||||
Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static,
|
||||
{
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
//! EVM component for the node builder.
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
use alloy_consensus::Header;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_node_api::ConfigureEvm;
|
||||
use reth_node_api::{ConfigureEvm, HeaderTy};
|
||||
use std::future::Future;
|
||||
|
||||
/// A type that knows how to build the executor types.
|
||||
@ -10,7 +9,7 @@ pub trait ExecutorBuilder<Node: FullNodeTypes>: Send {
|
||||
/// The EVM config to use.
|
||||
///
|
||||
/// This provides the node with the necessary configuration to configure an EVM.
|
||||
type EVM: ConfigureEvm<Header = Header>;
|
||||
type EVM: ConfigureEvm<Header = HeaderTy<Node::Types>>;
|
||||
|
||||
/// The type that knows how to execute blocks.
|
||||
type Executor: BlockExecutorProvider<
|
||||
@ -27,7 +26,7 @@ pub trait ExecutorBuilder<Node: FullNodeTypes>: Send {
|
||||
impl<Node, F, Fut, EVM, Executor> ExecutorBuilder<Node> for F
|
||||
where
|
||||
Node: FullNodeTypes,
|
||||
EVM: ConfigureEvm<Header = Header>,
|
||||
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>>,
|
||||
Executor:
|
||||
BlockExecutorProvider<Primitives = <Node::Types as reth_node_api::NodeTypes>::Primitives>,
|
||||
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
|
||||
|
||||
@ -22,12 +22,11 @@ pub use payload::*;
|
||||
pub use pool::*;
|
||||
|
||||
use crate::{ConfigureEvm, FullNodeTypes};
|
||||
use alloy_consensus::Header;
|
||||
use reth_consensus::FullConsensus;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_network::NetworkHandle;
|
||||
use reth_network_api::FullNetwork;
|
||||
use reth_node_api::{NodeTypes, NodeTypesWithEngine, TxTy};
|
||||
use reth_node_api::{HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||
|
||||
@ -41,7 +40,7 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
|
||||
type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<T::Types>>> + Unpin;
|
||||
|
||||
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
|
||||
type Evm: ConfigureEvm<Header = Header>;
|
||||
type Evm: ConfigureEvm<Header = HeaderTy<T::Types>>;
|
||||
|
||||
/// The type that knows how to execute blocks.
|
||||
type Executor: BlockExecutorProvider<Primitives = <T::Types as NodeTypes>::Primitives>;
|
||||
@ -100,7 +99,7 @@ where
|
||||
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
EVM: ConfigureEvm<Header = Header>,
|
||||
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>>,
|
||||
Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
|
||||
Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static,
|
||||
{
|
||||
@ -140,7 +139,7 @@ impl<Node, Pool, EVM, Executor, Cons> Clone for Components<Node, Pool, EVM, Exec
|
||||
where
|
||||
Node: FullNodeTypes,
|
||||
Pool: TransactionPool,
|
||||
EVM: ConfigureEvm<Header = Header>,
|
||||
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>>,
|
||||
Executor: BlockExecutorProvider,
|
||||
Cons: Clone,
|
||||
{
|
||||
|
||||
@ -22,7 +22,9 @@ use reth_evm::noop::NoopBlockExecutorProvider;
|
||||
use reth_fs_util as fs;
|
||||
use reth_invalid_block_hooks::InvalidBlockWitnessHook;
|
||||
use reth_network_p2p::headers::client::HeadersClient;
|
||||
use reth_node_api::{FullNodePrimitives, FullNodeTypes, NodeTypes, NodeTypesWithDB};
|
||||
use reth_node_api::{
|
||||
FullNodePrimitives, FullNodeTypes, NodePrimitives, NodeTypes, NodeTypesWithDB,
|
||||
};
|
||||
use reth_node_core::{
|
||||
args::InvalidBlockHookType,
|
||||
dirs::{ChainPath, DataDirPath},
|
||||
@ -39,7 +41,7 @@ use reth_node_metrics::{
|
||||
server::{MetricServer, MetricServerConfig},
|
||||
version::VersionInfo,
|
||||
};
|
||||
use reth_primitives::Head;
|
||||
use reth_primitives::{Head, TransactionSigned};
|
||||
use reth_provider::{
|
||||
providers::{ProviderNodeTypes, StaticFileProvider},
|
||||
BlockHashReader, BlockNumReader, ChainSpecProvider, ProviderError, ProviderFactory,
|
||||
@ -870,11 +872,16 @@ impl<T, CB>
|
||||
Attached<WithConfigs<<T::Types as NodeTypes>::ChainSpec>, WithComponents<T, CB>>,
|
||||
>
|
||||
where
|
||||
T: FullNodeTypes<Provider: StateProviderFactory + ChainSpecProvider, Types: ProviderNodeTypes>,
|
||||
T: FullNodeTypes<
|
||||
Provider: StateProviderFactory + ChainSpecProvider,
|
||||
Types: ProviderNodeTypes<Primitives: NodePrimitives<SignedTx = TransactionSigned>>,
|
||||
>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
{
|
||||
/// Returns the [`InvalidBlockHook`] to use for the node.
|
||||
pub fn invalid_block_hook(&self) -> eyre::Result<Box<dyn InvalidBlockHook>> {
|
||||
pub fn invalid_block_hook(
|
||||
&self,
|
||||
) -> eyre::Result<Box<dyn InvalidBlockHook<<T::Types as NodeTypes>::Primitives>>> {
|
||||
let Some(ref hook) = self.node_config().debug.invalid_block_hook else {
|
||||
return Ok(Box::new(NoopInvalidBlockHook::default()))
|
||||
};
|
||||
@ -898,7 +905,7 @@ where
|
||||
InvalidBlockHookType::PreState | InvalidBlockHookType::Opcode => {
|
||||
eyre::bail!("invalid block hook {hook:?} is not implemented yet")
|
||||
}
|
||||
} as Box<dyn InvalidBlockHook>)
|
||||
} as Box<dyn InvalidBlockHook<_>>)
|
||||
})
|
||||
.collect::<Result<_, _>>()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user