diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index b6fcda2834c..1dfd82865c5 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -121,6 +121,7 @@ reth-db-common.workspace = true reth-db = { workspace = true, features = ["mdbx", "test-utils"] } serial_test.workspace = true reth-discv5.workspace = true +reth-node-ethereum = { workspace = true, features = ["test-utils"] } [features] default = ["jemalloc"] diff --git a/bin/reth/src/commands/bitfinity_import.rs b/bin/reth/src/commands/bitfinity_import.rs index 55f9f9d9a41..0721266f2ed 100644 --- a/bin/reth/src/commands/bitfinity_import.rs +++ b/bin/reth/src/commands/bitfinity_import.rs @@ -21,14 +21,16 @@ use reth_node_core::{args::BitfinityImportArgs, dirs::ChainPath}; use reth_node_ethereum::{EthExecutorProvider, EthereumNode}; use reth_node_events::node::NodeEvent; use reth_primitives::{EthPrimitives, SealedHeader}; -use reth_provider::providers::BlockchainProvider; +use reth_provider::providers::BlockchainProvider2; use reth_provider::{ BlockNumReader, CanonChainTracker, ChainSpecProvider, DatabaseProviderFactory, HeaderProvider, ProviderError, ProviderFactory, }; use reth_prune::PruneModes; use reth_stages::{ - prelude::*, stages::{ExecutionStage, SenderRecoveryStage}, ExecutionStageThresholds, Pipeline, StageSet + prelude::*, + stages::{ExecutionStage, SenderRecoveryStage}, + ExecutionStageThresholds, Pipeline, StageSet, }; use reth_static_file::StaticFileProducer; use std::{path::PathBuf, sync::Arc, time::Duration}; @@ -52,7 +54,8 @@ pub struct BitfinityImportCommand { provider_factory: ProviderFactory>>, - blockchain_provider: BlockchainProvider>>, + blockchain_provider: + BlockchainProvider2>>, } /// Manually implement `Debug` for `ImportCommand` because `BlockchainProvider` doesn't implement it. @@ -77,7 +80,7 @@ impl BitfinityImportCommand { chain: Arc, bitfinity: BitfinityImportArgs, provider_factory: ProviderFactory>>, - blockchain_provider: BlockchainProvider< + blockchain_provider: BlockchainProvider2< NodeTypesWithDBAdapter>, >, ) -> Self { diff --git a/bin/reth/src/main.rs b/bin/reth/src/main.rs index 88d13499ea7..73b810d0208 100644 --- a/bin/reth/src/main.rs +++ b/bin/reth/src/main.rs @@ -96,18 +96,13 @@ fn main() { builder.launch_with(launcher) }) .await?; - handle.node_exit_future.await - } - true => { - info!(target: "reth::cli", "Running with legacy engine"); - let handle = builder.launch_node(EthereumNode::default()).await?; + let blockchain_provider = handle.node.provider.clone(); let config = handle.node.config.config.clone(); let chain = handle.node.chain_spec(); let datadir = handle.node.data_dir.clone(); let (provider_factory, bitfinity) = handle.bitfinity_import.clone().expect("Bitfinity import not configured"); - // Init bitfinity import let executor = { let import = BitfinityImportCommand::new( @@ -144,6 +139,11 @@ fn main() { handle.node_exit_future.await } + true => { + info!(target: "reth::cli", "Running with legacy engine"); + let handle = builder.launch_node(EthereumNode::default()).await?; + handle.node_exit_future.await + } } }) { diff --git a/bin/reth/tests/commands/bitfinity_import_it.rs b/bin/reth/tests/commands/bitfinity_import_it.rs index 9a173787a3e..2d967de33fd 100644 --- a/bin/reth/tests/commands/bitfinity_import_it.rs +++ b/bin/reth/tests/commands/bitfinity_import_it.rs @@ -1,5 +1,5 @@ //! -//! Integration tests for the bitfinity import command. +//! Integration tests for the bitfinity import command with BlockchainProvider2. //! These tests requires a running EVM node or EVM block extractor node at the specified URL. //! diff --git a/bin/reth/tests/commands/bitfinity_node_it.rs b/bin/reth/tests/commands/bitfinity_node_it.rs index d834a6429c6..83cb0a10187 100644 --- a/bin/reth/tests/commands/bitfinity_node_it.rs +++ b/bin/reth/tests/commands/bitfinity_node_it.rs @@ -1,5 +1,5 @@ //! -//! Integration tests for the bitfinity node command. +//! Integration tests for the bitfinity node command with BlockchainProvider2. //! use super::utils::*; @@ -17,20 +17,22 @@ use reth::{ dirs::{DataDirPath, MaybePlatformPath}, }; use reth_consensus::FullConsensus; +use reth_db::test_utils::TempDatabase; use reth_db::DatabaseEnv; use reth_db::{init_db, test_utils::tempdir_path}; use reth_discv5::discv5::enr::secp256k1::{Keypair, Secp256k1}; use reth_network::NetworkHandle; use reth_node_api::{FullNodeTypesAdapter, NodeTypesWithDBAdapter}; use reth_node_builder::components::Components; +use reth_node_builder::engine_tree_config::TreeConfig; use reth_node_builder::rpc::RpcAddOns; -use reth_node_builder::{NodeAdapter, NodeBuilder, NodeConfig, NodeHandle}; -use reth_node_ethereum::node::EthereumEngineValidatorBuilder; +use reth_node_builder::{EngineNodeLauncher, NodeAdapter, NodeBuilder, NodeConfig, NodeHandle}; +use reth_node_ethereum::node::{EthereumAddOns, EthereumEngineValidatorBuilder}; use reth_node_ethereum::{ BasicBlockExecutorProvider, EthEvmConfig, EthExecutionStrategyFactory, EthereumNode, }; use reth_primitives::{Transaction, TransactionSigned}; -use reth_provider::providers::BlockchainProvider; +use reth_provider::providers::BlockchainProvider2; use reth_rpc::EthApi; use reth_rpc_api::eth::helpers::bitfinity_tx_forwarder::{ BitfinityTransactionsForwarder, SharedQueue, TransactionsPriorityQueue, @@ -396,21 +398,28 @@ async fn start_reth_node( NodeAdapter< FullNodeTypesAdapter< EthereumNode, - Arc, - BlockchainProvider>>, + Arc>, + BlockchainProvider2< + NodeTypesWithDBAdapter>>, + >, >, Components< FullNodeTypesAdapter< EthereumNode, - Arc, - BlockchainProvider>>, + Arc>, + BlockchainProvider2< + NodeTypesWithDBAdapter>>, + >, >, reth_network::EthNetworkPrimitives, Pool< TransactionValidationTaskExecutor< EthTransactionValidator< - BlockchainProvider< - NodeTypesWithDBAdapter>, + BlockchainProvider2< + NodeTypesWithDBAdapter< + EthereumNode, + Arc>, + >, >, EthPooledTransaction, >, @@ -427,21 +436,28 @@ async fn start_reth_node( NodeAdapter< FullNodeTypesAdapter< EthereumNode, - Arc, - BlockchainProvider>>, + Arc>, + BlockchainProvider2< + NodeTypesWithDBAdapter>>, + >, >, Components< FullNodeTypesAdapter< EthereumNode, - Arc, - BlockchainProvider>>, + Arc>, + BlockchainProvider2< + NodeTypesWithDBAdapter>>, + >, >, reth_network::EthNetworkPrimitives, Pool< TransactionValidationTaskExecutor< EthTransactionValidator< - BlockchainProvider< - NodeTypesWithDBAdapter>, + BlockchainProvider2< + NodeTypesWithDBAdapter< + EthereumNode, + Arc>, + >, >, EthPooledTransaction, >, @@ -455,12 +471,17 @@ async fn start_reth_node( >, >, EthApi< - BlockchainProvider>>, + BlockchainProvider2< + NodeTypesWithDBAdapter>>, + >, Pool< TransactionValidationTaskExecutor< EthTransactionValidator< - BlockchainProvider< - NodeTypesWithDBAdapter>, + BlockchainProvider2< + NodeTypesWithDBAdapter< + EthereumNode, + Arc>, + >, >, EthPooledTransaction, >, @@ -504,10 +525,13 @@ async fn start_reth_node( Arc::new(init_db(data_dir.db(), Default::default()).unwrap()) }; + let exec = tasks.executor(); let node_handle = NodeBuilder::new(node_config) .with_database(database) - .with_launch_context(tasks.executor()) - .node(EthereumNode::default()) + .testing_node(exec) + .with_types_and_provider::>() + .with_components(EthereumNode::components()) + .with_add_ons(EthereumAddOns::default()) .on_rpc_started(|ctx, _| { // Add custom forwarder with transactions priority queue. let Some(queue) = queue else { return Ok(()) }; @@ -515,7 +539,14 @@ async fn start_reth_node( ctx.registry.eth_api().set_bitfinity_tx_forwarder(forwarder); Ok(()) }) - .launch() + .launch_with_fn(|builder| { + let launcher = EngineNodeLauncher::new( + builder.task_executor().clone(), + builder.config().datadir(), + TreeConfig::default(), + ); + builder.launch_with(launcher) + }) .await .unwrap(); diff --git a/bin/reth/tests/commands/utils.rs b/bin/reth/tests/commands/utils.rs index b87e45377a8..dea88e299e8 100644 --- a/bin/reth/tests/commands/utils.rs +++ b/bin/reth/tests/commands/utils.rs @@ -18,8 +18,6 @@ use reth::{ commands::bitfinity_import::BitfinityImportCommand, dirs::{ChainPath, DataDirPath, PlatformPath}, }; -use reth_beacon_consensus::EthBeaconConsensus; -use reth_blockchain_tree::{BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals}; use reth_chainspec::ChainSpec; use reth_db::{init_db, DatabaseEnv}; use reth_downloaders::bitfinity_evm_client::BitfinityEvmClient; @@ -29,7 +27,7 @@ use reth_node_api::NodeTypesWithDBAdapter; use reth_node_ethereum::EthereumNode; use reth_primitives::{BlockWithSenders, EthPrimitives, Receipt}; use reth_provider::{ - providers::{BlockchainProvider, StaticFileProvider}, + providers::{BlockchainProvider2, StaticFileProvider}, BlockNumReader, ExecutionOutcome, ProviderError, ProviderFactory, }; use reth_prune::PruneModes; @@ -74,7 +72,7 @@ pub struct ImportData { /// The provider factory. pub provider_factory: ProviderFactory, /// The blockchain provider. - pub blockchain_db: BlockchainProvider, + pub blockchain_db: BlockchainProvider2, /// The bitfinity import arguments. pub bitfinity_args: BitfinityImportArgs, } @@ -145,17 +143,7 @@ pub async fn bitfinity_import_config_data( reth_db_common::init::init_genesis(&provider_factory)?; - let consensus = Arc::new(EthBeaconConsensus::new(chain.clone())); - - let executor = MockExecutorProvider::default(); //EvmExecutorFac::new(self.chain.clone(), EthEvmConfig::default()); - - let blockchain_tree = - Arc::new(ShareableBlockchainTree::new(reth_blockchain_tree::BlockchainTree::new( - TreeExternals::new(provider_factory.clone(), consensus, executor), - BlockchainTreeConfig::default(), - )?)); - - let blockchain_db = BlockchainProvider::new(provider_factory.clone(), blockchain_tree)?; + let blockchain_db = BlockchainProvider2::new(provider_factory.clone())?; let bitfinity_args = BitfinityImportArgs { rpc_url: evm_datasource_url.to_string(),