Skip to content

Commit 9bb86d8

Browse files
committed
engine v2
1 parent 31f77fb commit 9bb86d8

5 files changed

Lines changed: 148 additions & 47 deletions

File tree

bin/reth/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ revm-primitives.workspace = true
120120
reth-db-common.workspace = true
121121
reth-db = { workspace = true, features = ["mdbx", "test-utils"] }
122122
serial_test.workspace = true
123+
reth-node-ethereum = { workspace = true, features = ["test-utils"] }
123124

124125
[features]
125126
default = ["jemalloc"]

bin/reth/src/commands/bitfinity_import.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ use reth_node_core::{args::BitfinityImportArgs, dirs::ChainPath};
2121
use reth_node_ethereum::{EthExecutorProvider, EthereumNode};
2222
use reth_node_events::node::NodeEvent;
2323
use reth_primitives::{EthPrimitives, SealedHeader};
24-
use reth_provider::providers::BlockchainProvider;
24+
use reth_provider::providers::BlockchainProvider2;
2525
use reth_provider::{
2626
BlockNumReader, CanonChainTracker, ChainSpecProvider, DatabaseProviderFactory, HeaderProvider,
2727
ProviderError, ProviderFactory,
2828
};
2929
use reth_prune::PruneModes;
3030
use reth_stages::{
31-
prelude::*, stages::{ExecutionStage, SenderRecoveryStage}, ExecutionStageThresholds, Pipeline, StageSet
31+
prelude::*,
32+
stages::{ExecutionStage, SenderRecoveryStage},
33+
ExecutionStageThresholds, Pipeline, StageSet,
3234
};
3335
use reth_static_file::StaticFileProducer;
3436
use std::{path::PathBuf, sync::Arc, time::Duration};
@@ -52,7 +54,8 @@ pub struct BitfinityImportCommand {
5254

5355
provider_factory: ProviderFactory<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
5456

55-
blockchain_provider: BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
57+
blockchain_provider:
58+
BlockchainProvider2<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
5659
}
5760

5861
/// Manually implement `Debug` for `ImportCommand` because `BlockchainProvider` doesn't implement it.
@@ -77,7 +80,7 @@ impl BitfinityImportCommand {
7780
chain: Arc<ChainSpec>,
7881
bitfinity: BitfinityImportArgs,
7982
provider_factory: ProviderFactory<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
80-
blockchain_provider: BlockchainProvider<
83+
blockchain_provider: BlockchainProvider2<
8184
NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>,
8285
>,
8386
) -> Self {

bin/reth/src/main.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,31 @@ fn main() {
9191
builder.launch_with(launcher)
9292
})
9393
.await?;
94-
handle.node_exit_future.await
95-
}
96-
true => {
97-
info!(target: "reth::cli", "Running with legacy engine");
98-
let handle = builder.launch_node(EthereumNode::default()).await?;
94+
9995
let blockchain_provider = handle.node.provider.clone();
10096
let config = handle.node.config.config.clone();
10197
let chain = handle.node.chain_spec();
10298
let datadir = handle.node.data_dir.clone();
103-
let (provider_factory, bitfinity) = handle.bitfinity_import.clone().expect("Bitfinity import not configured");
99+
let (provider_factory, bitfinity) = handle.bitfinity_import.clone().expect("Bitfinity import not configured");
104100

105101
// Init bitfinity import
106-
{
107-
let import = BitfinityImportCommand::new(
108-
config,
109-
datadir,
110-
chain,
111-
bitfinity,
112-
provider_factory,
113-
blockchain_provider,
114-
);
115-
let _import_handle = import.schedule_execution().await?;
116-
};
102+
let import = BitfinityImportCommand::new(
103+
config,
104+
datadir,
105+
chain,
106+
bitfinity.clone(),
107+
provider_factory,
108+
blockchain_provider,
109+
);
110+
let _import_handle = import.schedule_execution().await?;
117111

118112
handle.node_exit_future.await
119113
}
114+
true => {
115+
info!(target: "reth::cli", "Running with legacy engine");
116+
let handle = builder.launch_node(EthereumNode::default()).await?;
117+
handle.node_exit_future.await
118+
}
120119
}
121120
})
122121
{

bin/reth/tests/commands/bitfinity_node_it.rs

Lines changed: 119 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ use reth::{
1717
dirs::{DataDirPath, MaybePlatformPath},
1818
};
1919
use reth_consensus::FullConsensus;
20+
use reth_db::test_utils::TempDatabase;
2021
use reth_db::DatabaseEnv;
2122
use reth_db::{init_db, test_utils::tempdir_path};
2223
use reth_network::NetworkHandle;
2324
use reth_node_api::{FullNodeTypesAdapter, NodeTypesWithDBAdapter};
2425
use reth_node_builder::components::Components;
26+
use reth_node_builder::engine_tree_config::TreeConfig;
2527
use reth_node_builder::rpc::RpcAddOns;
26-
use reth_node_builder::{NodeAdapter, NodeBuilder, NodeConfig, NodeHandle};
27-
use reth_node_ethereum::node::EthereumEngineValidatorBuilder;
28+
use reth_node_builder::{EngineNodeLauncher, NodeAdapter, NodeBuilder, NodeConfig, NodeHandle};
29+
use reth_node_ethereum::node::{EthereumAddOns, EthereumEngineValidatorBuilder};
2830
use reth_node_ethereum::{
2931
BasicBlockExecutorProvider, EthEvmConfig, EthExecutionStrategyFactory, EthereumNode,
3032
};
31-
use reth_provider::providers::BlockchainProvider;
33+
use reth_provider::providers::BlockchainProvider2;
3234
use reth_rpc::EthApi;
3335
use reth_tasks::TaskManager;
3436
use reth_transaction_pool::blobstore::DiskFileBlobStore;
@@ -207,7 +209,107 @@ async fn start_reth_node(
207209
import_data: Option<ImportData>,
208210
) -> (
209211
EthJsonRpcClient<ReqwestClient>,
210-
NodeHandle<NodeAdapter<FullNodeTypesAdapter<EthereumNode, Arc<DatabaseEnv>, BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>>, Components<FullNodeTypesAdapter<EthereumNode, Arc<DatabaseEnv>, BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>>, reth_network::EthNetworkPrimitives, Pool<TransactionValidationTaskExecutor<EthTransactionValidator<BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>, EthPooledTransaction>>, CoinbaseTipOrdering<EthPooledTransaction>, DiskFileBlobStore>, EthEvmConfig, BasicBlockExecutorProvider<EthExecutionStrategyFactory>, Arc<dyn FullConsensus>>>, RpcAddOns<NodeAdapter<FullNodeTypesAdapter<EthereumNode, Arc<DatabaseEnv>, BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>>, Components<FullNodeTypesAdapter<EthereumNode, Arc<DatabaseEnv>, BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>>, reth_network::EthNetworkPrimitives, Pool<TransactionValidationTaskExecutor<EthTransactionValidator<BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>, EthPooledTransaction>>, CoinbaseTipOrdering<EthPooledTransaction>, DiskFileBlobStore>, EthEvmConfig, BasicBlockExecutorProvider<EthExecutionStrategyFactory>, Arc<dyn FullConsensus>>>, EthApi<BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>, Pool<TransactionValidationTaskExecutor<EthTransactionValidator<BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>, EthPooledTransaction>>, CoinbaseTipOrdering<EthPooledTransaction>, DiskFileBlobStore>, NetworkHandle, EthEvmConfig>, EthereumEngineValidatorBuilder>>,
212+
NodeHandle<
213+
NodeAdapter<
214+
FullNodeTypesAdapter<
215+
EthereumNode,
216+
Arc<TempDatabase<DatabaseEnv>>,
217+
BlockchainProvider2<
218+
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
219+
>,
220+
>,
221+
Components<
222+
FullNodeTypesAdapter<
223+
EthereumNode,
224+
Arc<TempDatabase<DatabaseEnv>>,
225+
BlockchainProvider2<
226+
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
227+
>,
228+
>,
229+
reth_network::EthNetworkPrimitives,
230+
Pool<
231+
TransactionValidationTaskExecutor<
232+
EthTransactionValidator<
233+
BlockchainProvider2<
234+
NodeTypesWithDBAdapter<
235+
EthereumNode,
236+
Arc<TempDatabase<DatabaseEnv>>,
237+
>,
238+
>,
239+
EthPooledTransaction,
240+
>,
241+
>,
242+
CoinbaseTipOrdering<EthPooledTransaction>,
243+
DiskFileBlobStore,
244+
>,
245+
EthEvmConfig,
246+
BasicBlockExecutorProvider<EthExecutionStrategyFactory>,
247+
Arc<dyn FullConsensus>,
248+
>,
249+
>,
250+
RpcAddOns<
251+
NodeAdapter<
252+
FullNodeTypesAdapter<
253+
EthereumNode,
254+
Arc<TempDatabase<DatabaseEnv>>,
255+
BlockchainProvider2<
256+
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
257+
>,
258+
>,
259+
Components<
260+
FullNodeTypesAdapter<
261+
EthereumNode,
262+
Arc<TempDatabase<DatabaseEnv>>,
263+
BlockchainProvider2<
264+
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
265+
>,
266+
>,
267+
reth_network::EthNetworkPrimitives,
268+
Pool<
269+
TransactionValidationTaskExecutor<
270+
EthTransactionValidator<
271+
BlockchainProvider2<
272+
NodeTypesWithDBAdapter<
273+
EthereumNode,
274+
Arc<TempDatabase<DatabaseEnv>>,
275+
>,
276+
>,
277+
EthPooledTransaction,
278+
>,
279+
>,
280+
CoinbaseTipOrdering<EthPooledTransaction>,
281+
DiskFileBlobStore,
282+
>,
283+
EthEvmConfig,
284+
BasicBlockExecutorProvider<EthExecutionStrategyFactory>,
285+
Arc<dyn FullConsensus>,
286+
>,
287+
>,
288+
EthApi<
289+
BlockchainProvider2<
290+
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
291+
>,
292+
Pool<
293+
TransactionValidationTaskExecutor<
294+
EthTransactionValidator<
295+
BlockchainProvider2<
296+
NodeTypesWithDBAdapter<
297+
EthereumNode,
298+
Arc<TempDatabase<DatabaseEnv>>,
299+
>,
300+
>,
301+
EthPooledTransaction,
302+
>,
303+
>,
304+
CoinbaseTipOrdering<EthPooledTransaction>,
305+
DiskFileBlobStore,
306+
>,
307+
NetworkHandle,
308+
EthEvmConfig,
309+
>,
310+
EthereumEngineValidatorBuilder,
311+
>,
312+
>,
211313
) {
212314
let tasks = TaskManager::current();
213315

@@ -240,10 +342,21 @@ async fn start_reth_node(
240342
Arc::new(init_db(data_dir.db(), Default::default()).unwrap())
241343
};
242344

345+
let exec = tasks.executor();
243346
let node_handle = NodeBuilder::new(node_config)
244347
.with_database(database)
245-
.with_launch_context(tasks.executor())
246-
.launch_node(EthereumNode::default())
348+
.testing_node(exec)
349+
.with_types_and_provider::<EthereumNode, BlockchainProvider2<_>>()
350+
.with_components(EthereumNode::components())
351+
.with_add_ons(EthereumAddOns::default())
352+
.launch_with_fn(|builder| {
353+
let launcher = EngineNodeLauncher::new(
354+
builder.task_executor().clone(),
355+
builder.config().datadir(),
356+
TreeConfig::default(),
357+
);
358+
builder.launch_with(launcher)
359+
})
247360
.await
248361
.unwrap();
249362

bin/reth/tests/commands/utils.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//!
22
//! Utils for bitfinity integration tests
3-
//!
3+
//!
44
use std::{
55
fmt::{Debug, Display, Formatter},
66
path::PathBuf,
@@ -18,20 +18,16 @@ use reth::{
1818
commands::bitfinity_import::BitfinityImportCommand,
1919
dirs::{ChainPath, DataDirPath, PlatformPath},
2020
};
21-
use reth_beacon_consensus::EthBeaconConsensus;
22-
use reth_blockchain_tree::{BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals};
2321
use reth_chainspec::ChainSpec;
2422
use reth_db::{init_db, DatabaseEnv};
2523
use reth_downloaders::bitfinity_evm_client::BitfinityEvmClient;
2624
use reth_errors::BlockExecutionError;
27-
use reth_evm::execute::{
28-
BatchExecutor, BlockExecutionOutput, BlockExecutorProvider, Executor,
29-
};
25+
use reth_evm::execute::{BatchExecutor, BlockExecutionOutput, BlockExecutorProvider, Executor};
3026
use reth_node_api::NodeTypesWithDBAdapter;
3127
use reth_node_ethereum::EthereumNode;
3228
use reth_primitives::{BlockWithSenders, EthPrimitives, Receipt};
3329
use reth_provider::{
34-
providers::{BlockchainProvider, StaticFileProvider},
30+
providers::{BlockchainProvider2, StaticFileProvider},
3531
BlockNumReader, ExecutionOutcome, ProviderError, ProviderFactory,
3632
};
3733
use reth_prune::PruneModes;
@@ -64,7 +60,6 @@ pub fn init_logs() -> eyre::Result<Option<FileWorkerGuard>> {
6460
/// Type alias for the node types.
6561
pub type NodeTypes = NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>;
6662

67-
6863
#[derive(Clone)]
6964
/// Data needed for the import tests.
7065
pub struct ImportData {
@@ -77,7 +72,7 @@ pub struct ImportData {
7772
/// The provider factory.
7873
pub provider_factory: ProviderFactory<NodeTypes>,
7974
/// The blockchain provider.
80-
pub blockchain_db: BlockchainProvider<NodeTypes>,
75+
pub blockchain_db: BlockchainProvider2<NodeTypes>,
8176
/// The bitfinity import arguments.
8277
pub bitfinity_args: BitfinityImportArgs,
8378
}
@@ -148,17 +143,7 @@ pub async fn bitfinity_import_config_data(
148143

149144
reth_db_common::init::init_genesis(&provider_factory)?;
150145

151-
let consensus = Arc::new(EthBeaconConsensus::new(chain.clone()));
152-
153-
let executor = MockExecutorProvider::default(); //EvmExecutorFac::new(self.chain.clone(), EthEvmConfig::default());
154-
155-
let blockchain_tree =
156-
Arc::new(ShareableBlockchainTree::new(reth_blockchain_tree::BlockchainTree::new(
157-
TreeExternals::new(provider_factory.clone(), consensus, executor),
158-
BlockchainTreeConfig::default(),
159-
)?));
160-
161-
let blockchain_db = BlockchainProvider::new(provider_factory.clone(), blockchain_tree)?;
146+
let blockchain_db = BlockchainProvider2::new(provider_factory.clone())?;
162147

163148
let bitfinity_args = BitfinityImportArgs {
164149
rpc_url: evm_datasource_url.to_string(),

0 commit comments

Comments
 (0)