chore(sdk): Define NodePrimitives::Block (#11399)

This commit is contained in:
Emilia Hane
2024-10-18 11:23:25 +02:00
committed by GitHub
parent 5859f93c56
commit cb604826b7
5 changed files with 38 additions and 11 deletions

2
Cargo.lock generated
View File

@ -8026,6 +8026,8 @@ dependencies = [
"reth-chainspec",
"reth-db-api",
"reth-engine-primitives",
"reth-primitives",
"reth-primitives-traits",
]
[[package]]

View File

@ -11,7 +11,9 @@ use reth_ethereum_engine_primitives::{
};
use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_network::NetworkHandle;
use reth_node_api::{ConfigureEvm, EngineValidator, FullNodeComponents, NodeTypesWithDB};
use reth_node_api::{
ConfigureEvm, EngineValidator, FullNodeComponents, NodePrimitives, NodeTypesWithDB,
};
use reth_node_builder::{
components::{
ComponentsBuilder, ConsensusBuilder, EngineValidatorBuilder, ExecutorBuilder,
@ -22,7 +24,7 @@ use reth_node_builder::{
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::Header;
use reth_primitives::{Block, Header};
use reth_provider::CanonStateSubscriptions;
use reth_rpc::EthApi;
use reth_tracing::tracing::{debug, info};
@ -33,6 +35,14 @@ use reth_transaction_pool::{
use crate::{EthEngineTypes, EthEvmConfig};
/// Ethereum primitive types.
#[derive(Debug)]
pub struct EthPrimitives;
impl NodePrimitives for EthPrimitives {
type Block = Block;
}
/// Type configuration for a regular Ethereum node.
#[derive(Debug, Default, Clone, Copy)]
#[non_exhaustive]
@ -69,7 +79,7 @@ impl EthereumNode {
}
impl NodeTypes for EthereumNode {
type Primitives = ();
type Primitives = EthPrimitives;
type ChainSpec = ChainSpec;
}

View File

@ -15,3 +15,5 @@ workspace = true
reth-chainspec.workspace = true
reth-db-api.workspace = true
reth-engine-primitives.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true

View File

@ -8,6 +8,8 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
pub use reth_primitives_traits::{Block, BlockBody};
use std::marker::PhantomData;
use reth_chainspec::EthChainSpec;
@ -18,11 +20,14 @@ use reth_db_api::{
use reth_engine_primitives::EngineTypes;
/// Configures all the primitive types of the node.
// TODO(mattsse): this is currently a placeholder
pub trait NodePrimitives {}
pub trait NodePrimitives {
/// Block primitive.
type Block;
}
// TODO(mattsse): Placeholder
impl NodePrimitives for () {}
impl NodePrimitives for () {
type Block = reth_primitives::Block;
}
/// The type that configures the essential types of an Ethereum-like node.
///

View File

@ -6,7 +6,7 @@ use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGenera
use reth_chainspec::{EthChainSpec, Hardforks};
use reth_evm::ConfigureEvm;
use reth_network::{NetworkConfig, NetworkHandle, NetworkManager};
use reth_node_api::{EngineValidator, FullNodeComponents, NodeAddOns};
use reth_node_api::{EngineValidator, FullNodeComponents, NodeAddOns, NodePrimitives};
use reth_node_builder::{
components::{
ComponentsBuilder, ConsensusBuilder, EngineValidatorBuilder, ExecutorBuilder,
@ -21,7 +21,7 @@ use reth_optimism_consensus::OptimismBeaconConsensus;
use reth_optimism_evm::{OpExecutorProvider, OptimismEvmConfig};
use reth_optimism_rpc::OpEthApi;
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::Header;
use reth_primitives::{Block, Header};
use reth_provider::CanonStateSubscriptions;
use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::{
@ -36,6 +36,14 @@ use crate::{
OptimismEngineTypes,
};
/// Optimism primitive types.
#[derive(Debug)]
pub struct OpPrimitives;
impl NodePrimitives for OpPrimitives {
type Block = Block;
}
/// Type configuration for a regular Optimism node.
#[derive(Debug, Default, Clone)]
#[non_exhaustive]
@ -113,7 +121,7 @@ where
}
impl NodeTypes for OptimismNode {
type Primitives = ();
type Primitives = OpPrimitives;
type ChainSpec = OpChainSpec;
}