chore: move nodetypes to node-api (#7268)

This commit is contained in:
Matthias Seitz
2024-03-21 14:35:37 +01:00
committed by GitHub
parent 0da7b7c314
commit 31b94581f9
6 changed files with 30 additions and 20 deletions

View File

@ -24,3 +24,6 @@ pub mod evm;
pub use evm::{ConfigureEvm, ConfigureEvmEnv};
pub mod primitives;
pub mod node;
pub use node::NodeTypes;

View File

@ -0,0 +1,19 @@
//! Traits for configuring a node
use crate::{primitives::NodePrimitives, ConfigureEvm, EngineTypes};
/// The type that configures the essential types of an ethereum like node.
///
/// This includes the primitive types of a node, the engine API types for communication with the
/// consensus layer, and the EVM configuration type for setting up the Ethereum Virtual Machine.
pub trait NodeTypes: Send + Sync + 'static {
/// The node's primitive types, defining basic operations and structures.
type Primitives: NodePrimitives;
/// The node's engine types, defining the interaction with the consensus engine.
type Engine: EngineTypes;
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
type Evm: ConfigureEvm;
/// Returns the node's evm config.
fn evm_config(&self) -> Self::Evm;
}

View File

@ -8,7 +8,7 @@ use crate::{
NodeComponentsBuilder, PoolBuilder,
},
hooks::NodeHooks,
node::{FullNode, FullNodeTypes, FullNodeTypesAdapter, NodeTypes},
node::{FullNode, FullNodeTypes, FullNodeTypesAdapter},
rpc::{RethRpcServerHandles, RpcContext, RpcHooks},
Node, NodeHandle,
};
@ -28,6 +28,7 @@ use reth_db::{
};
use reth_interfaces::p2p::either::EitherDownloader;
use reth_network::{NetworkBuilder, NetworkConfig, NetworkEvents, NetworkHandle};
use reth_node_api::NodeTypes;
use reth_node_core::{
cli::config::{PayloadBuilderConfig, RethRpcConfig, RethTransactionPoolConfig},
dirs::{ChainPath, DataDirPath, MaybePlatformPath},

View File

@ -1,11 +1,8 @@
//! Traits for the builder
use crate::{
components::NodeComponents,
node::{FullNodeTypes, NodeTypes},
BuilderContext,
};
use crate::{components::NodeComponents, node::FullNodeTypes, BuilderContext};
use reth_network::NetworkHandle;
use reth_node_api::NodeTypes;
use reth_payload_builder::PayloadBuilderHandle;
use reth_tasks::TaskExecutor;
use reth_transaction_pool::TransactionPool;

View File

@ -34,3 +34,6 @@ pub use reth_node_core::cli::config::{
// re-export the core config for convenience
pub use reth_node_core::node_config::NodeConfig;
// re-export API types for convenience
pub use reth_node_api::*;

View File

@ -5,7 +5,7 @@ use crate::{
};
use reth_db::database::Database;
use reth_network::NetworkHandle;
use reth_node_api::{evm::ConfigureEvm, primitives::NodePrimitives, EngineTypes};
pub use reth_node_api::NodeTypes;
use reth_node_core::{
dirs::{ChainPath, DataDirPath},
node_config::NodeConfig,
@ -34,19 +34,6 @@ pub trait Node<N>: NodeTypes + Clone {
) -> ComponentsBuilder<N, Self::PoolBuilder, Self::PayloadBuilder, Self::NetworkBuilder>;
}
/// The type that configures stateless node types, the node's primitive types.
pub trait NodeTypes: Send + Sync + 'static {
/// The node's primitive types, defining basic operations and structures.
type Primitives: NodePrimitives;
/// The node's engine types, defining the interaction with the consensus engine.
type Engine: EngineTypes;
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
type Evm: ConfigureEvm;
/// Returns the node's evm config.
fn evm_config(&self) -> Self::Evm;
}
/// A helper type that is downstream of the node types and adds stateful components to the node.
pub trait FullNodeTypes: NodeTypes + 'static {
/// Underlying database type.