mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(sdk): introduce PrimitivesTy helper type (#13933)
This commit is contained in:
@ -11,7 +11,7 @@ use eyre::Ok;
|
||||
use futures_util::Future;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_network_api::test_utils::PeersHandleProvider;
|
||||
use reth_node_api::{Block, BlockBody, BlockTy, EngineTypes, FullNodeComponents};
|
||||
use reth_node_api::{Block, BlockBody, BlockTy, EngineTypes, FullNodeComponents, PrimitivesTy};
|
||||
use reth_node_builder::{rpc::RethRpcAddOns, FullNode, NodeTypes, NodeTypesWithEngine};
|
||||
use reth_node_core::primitives::SignedTransaction;
|
||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
|
||||
@ -41,7 +41,7 @@ where
|
||||
pub engine_api: EngineApiTestContext<
|
||||
<Node::Types as NodeTypesWithEngine>::Engine,
|
||||
<Node::Types as NodeTypes>::ChainSpec,
|
||||
<Node::Types as NodeTypes>::Primitives,
|
||||
PrimitivesTy<Node::Types>,
|
||||
>,
|
||||
/// Context for testing RPC features.
|
||||
pub rpc: RpcTestContext<Node, AddOns::EthApi>,
|
||||
|
||||
@ -8,7 +8,7 @@ use reth_ethereum_engine_primitives::{
|
||||
use reth_ethereum_payload_builder::EthereumBuilderConfig;
|
||||
use reth_evm::ConfigureEvmFor;
|
||||
use reth_evm_ethereum::EthEvmConfig;
|
||||
use reth_node_api::{FullNodeTypes, NodeTypesWithEngine, TxTy};
|
||||
use reth_node_api::{FullNodeTypes, NodeTypesWithEngine, PrimitivesTy, TxTy};
|
||||
use reth_node_builder::{
|
||||
components::PayloadServiceBuilder, BuilderContext, PayloadBuilderConfig, PayloadTypes,
|
||||
};
|
||||
@ -33,7 +33,7 @@ impl EthereumPayloadBuilder {
|
||||
where
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
||||
Node: FullNodeTypes<Types = Types>,
|
||||
Evm: ConfigureEvmFor<Types::Primitives>,
|
||||
Evm: ConfigureEvmFor<PrimitivesTy<Types>>,
|
||||
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{ExExContextDyn, ExExEvent, ExExNotifications, ExExNotificationsStream};
|
||||
use reth_exex_types::ExExHead;
|
||||
use reth_node_api::{FullNodeComponents, NodePrimitives, NodeTypes};
|
||||
use reth_node_api::{FullNodeComponents, NodePrimitives, NodeTypes, PrimitivesTy};
|
||||
use reth_node_core::node_config::NodeConfig;
|
||||
use reth_primitives::Head;
|
||||
use reth_provider::BlockReader;
|
||||
@ -62,7 +62,7 @@ where
|
||||
Node::Types: NodeTypes<Primitives: NodePrimitives>,
|
||||
{
|
||||
/// Returns dynamic version of the context
|
||||
pub fn into_dyn(self) -> ExExContextDyn<<Node::Types as NodeTypes>::Primitives> {
|
||||
pub fn into_dyn(self) -> ExExContextDyn<PrimitivesTy<Node::Types>> {
|
||||
ExExContextDyn::from(self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
use reth_chainspec::{EthChainSpec, Head};
|
||||
use reth_node_api::{FullNodeComponents, HeaderTy, NodePrimitives, NodeTypes};
|
||||
use reth_node_api::{FullNodeComponents, HeaderTy, NodePrimitives, NodeTypes, PrimitivesTy};
|
||||
use reth_node_core::node_config::NodeConfig;
|
||||
use reth_primitives::EthPrimitives;
|
||||
use reth_provider::BlockReader;
|
||||
@ -50,7 +50,7 @@ impl<N: NodePrimitives> Debug for ExExContextDyn<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Node> From<ExExContext<Node>> for ExExContextDyn<<Node::Types as NodeTypes>::Primitives>
|
||||
impl<Node> From<ExExContext<Node>> for ExExContextDyn<PrimitivesTy<Node::Types>>
|
||||
where
|
||||
Node: FullNodeComponents<Types: NodeTypes<Primitives: NodePrimitives>>,
|
||||
Node::Provider: Debug + BlockReader,
|
||||
|
||||
@ -10,7 +10,7 @@ use crate::{
|
||||
use reth_consensus::{ConsensusError, FullConsensus};
|
||||
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
||||
use reth_network::NetworkPrimitives;
|
||||
use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy};
|
||||
use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypesWithEngine, PrimitivesTy, TxTy};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
@ -405,12 +405,10 @@ where
|
||||
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
EVM: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>,
|
||||
Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
|
||||
Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives, Error = ConsensusError>
|
||||
+ Clone
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
EVM: ConfigureEvmFor<PrimitivesTy<Node::Types>>,
|
||||
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
|
||||
Cons:
|
||||
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
|
||||
{
|
||||
type Components = Components<Node, N, Pool, EVM, Executor, Cons>;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Consensus component for the node builder.
|
||||
use reth_consensus::{ConsensusError, FullConsensus};
|
||||
use reth_node_api::NodeTypes;
|
||||
use reth_node_api::PrimitivesTy;
|
||||
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
use std::future::Future;
|
||||
@ -8,7 +8,7 @@ use std::future::Future;
|
||||
/// A type that knows how to build the consensus implementation.
|
||||
pub trait ConsensusBuilder<Node: FullNodeTypes>: Send {
|
||||
/// The consensus implementation to build.
|
||||
type Consensus: FullConsensus<<Node::Types as NodeTypes>::Primitives, Error = ConsensusError>
|
||||
type Consensus: FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError>
|
||||
+ Clone
|
||||
+ Unpin
|
||||
+ 'static;
|
||||
@ -23,10 +23,8 @@ pub trait ConsensusBuilder<Node: FullNodeTypes>: Send {
|
||||
impl<Node, F, Fut, Consensus> ConsensusBuilder<Node> for F
|
||||
where
|
||||
Node: FullNodeTypes,
|
||||
Consensus: FullConsensus<<Node::Types as NodeTypes>::Primitives, Error = ConsensusError>
|
||||
+ Clone
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
Consensus:
|
||||
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
|
||||
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
|
||||
Fut: Future<Output = eyre::Result<Consensus>> + Send,
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! EVM component for the node builder.
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
||||
use reth_node_api::NodeTypes;
|
||||
use reth_node_api::PrimitivesTy;
|
||||
use std::future::Future;
|
||||
|
||||
/// A type that knows how to build the executor types.
|
||||
@ -9,10 +9,10 @@ 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: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>;
|
||||
type EVM: ConfigureEvmFor<PrimitivesTy<Node::Types>>;
|
||||
|
||||
/// The type that knows how to execute blocks.
|
||||
type Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>;
|
||||
type Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>;
|
||||
|
||||
/// Creates the EVM config.
|
||||
fn build_evm(
|
||||
@ -24,8 +24,8 @@ pub trait ExecutorBuilder<Node: FullNodeTypes>: Send {
|
||||
impl<Node, F, Fut, EVM, Executor> ExecutorBuilder<Node> for F
|
||||
where
|
||||
Node: FullNodeTypes,
|
||||
EVM: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>,
|
||||
Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
|
||||
EVM: ConfigureEvmFor<PrimitivesTy<Node::Types>>,
|
||||
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
|
||||
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
|
||||
Fut: Future<Output = eyre::Result<(EVM, Executor)>> + Send,
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
||||
use reth_network::{NetworkHandle, NetworkPrimitives};
|
||||
use reth_network_api::FullNetwork;
|
||||
use reth_node_api::{
|
||||
BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilder, TxTy,
|
||||
BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilder, PrimitivesTy, TxTy,
|
||||
};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||
@ -112,11 +112,9 @@ where
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>,
|
||||
Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
|
||||
Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives, Error = ConsensusError>
|
||||
+ Clone
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
|
||||
Cons:
|
||||
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
|
||||
{
|
||||
type Pool = Pool;
|
||||
type Evm = EVM;
|
||||
|
||||
@ -9,7 +9,7 @@ use reth_exex::{
|
||||
ExExContext, ExExHandle, ExExManager, ExExManagerHandle, ExExNotificationSource, Wal,
|
||||
DEFAULT_EXEX_MANAGER_CAPACITY,
|
||||
};
|
||||
use reth_node_api::{FullNodeComponents, NodeTypes};
|
||||
use reth_node_api::{FullNodeComponents, NodeTypes, PrimitivesTy};
|
||||
use reth_primitives::Head;
|
||||
use reth_provider::CanonStateSubscriptions;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
@ -42,7 +42,7 @@ impl<Node: FullNodeComponents + Clone> ExExLauncher<Node> {
|
||||
/// installed.
|
||||
pub async fn launch(
|
||||
self,
|
||||
) -> eyre::Result<Option<ExExManagerHandle<<Node::Types as NodeTypes>::Primitives>>> {
|
||||
) -> eyre::Result<Option<ExExManagerHandle<PrimitivesTy<Node::Types>>>> {
|
||||
let Self { head, extensions, components, config_container } = self;
|
||||
|
||||
if extensions.is_empty() {
|
||||
|
||||
@ -234,16 +234,19 @@ where
|
||||
}
|
||||
|
||||
/// Helper adapter type for accessing [`NodePrimitives::Block`] on [`NodeTypes`].
|
||||
pub type BlockTy<N> = <<N as NodeTypes>::Primitives as NodePrimitives>::Block;
|
||||
pub type BlockTy<N> = <PrimitivesTy<N> as NodePrimitives>::Block;
|
||||
|
||||
/// Helper adapter type for accessing [`NodePrimitives::BlockHeader`] on [`NodeTypes`].
|
||||
pub type HeaderTy<N> = <<N as NodeTypes>::Primitives as NodePrimitives>::BlockHeader;
|
||||
pub type HeaderTy<N> = <PrimitivesTy<N> as NodePrimitives>::BlockHeader;
|
||||
|
||||
/// Helper adapter type for accessing [`NodePrimitives::BlockBody`] on [`NodeTypes`].
|
||||
pub type BodyTy<N> = <<N as NodeTypes>::Primitives as NodePrimitives>::BlockBody;
|
||||
pub type BodyTy<N> = <PrimitivesTy<N> as NodePrimitives>::BlockBody;
|
||||
|
||||
/// Helper adapter type for accessing [`NodePrimitives::SignedTx`] on [`NodeTypes`].
|
||||
pub type TxTy<N> = <<N as NodeTypes>::Primitives as NodePrimitives>::SignedTx;
|
||||
pub type TxTy<N> = <PrimitivesTy<N> as NodePrimitives>::SignedTx;
|
||||
|
||||
/// Helper adapter type for accessing [`NodePrimitives::Receipt`] on [`NodeTypes`].
|
||||
pub type ReceiptTy<N> = <<N as NodeTypes>::Primitives as NodePrimitives>::Receipt;
|
||||
pub type ReceiptTy<N> = <PrimitivesTy<N> as NodePrimitives>::Receipt;
|
||||
|
||||
/// Helper type for getting the `Primitives` associated type from a [`NodeTypes`].
|
||||
pub type PrimitivesTy<N> = <N as NodeTypes>::Primitives;
|
||||
|
||||
@ -73,7 +73,7 @@ where
|
||||
Receipt = OpReceipt,
|
||||
SignedTx: OpTransaction,
|
||||
>,
|
||||
EvmConfig: Clone + Unpin + Sync + Send + 'static + ConfigureEvmFor<N>,
|
||||
EvmConfig: ConfigureEvmFor<N> + Clone + Unpin + Sync + Send + 'static,
|
||||
{
|
||||
type Primitives = N;
|
||||
type Strategy<DB: Database<Error: Into<ProviderError> + Display>> =
|
||||
|
||||
@ -11,7 +11,7 @@ use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGenera
|
||||
use reth_chainspec::{EthChainSpec, Hardforks};
|
||||
use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvmFor};
|
||||
use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, NetworkPrimitives, PeersInfo};
|
||||
use reth_node_api::{AddOnsContext, FullNodeComponents, NodeAddOns, TxTy};
|
||||
use reth_node_api::{AddOnsContext, FullNodeComponents, NodeAddOns, PrimitivesTy, TxTy};
|
||||
use reth_node_builder::{
|
||||
components::{
|
||||
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
|
||||
@ -484,7 +484,7 @@ where
|
||||
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
Evm: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>,
|
||||
Evm: ConfigureEvmFor<PrimitivesTy<Node::Types>>,
|
||||
{
|
||||
let payload_builder = reth_optimism_payload_builder::OpPayloadBuilder::with_builder_config(
|
||||
evm_config,
|
||||
|
||||
Reference in New Issue
Block a user