Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
11 changes: 7 additions & 4 deletions bin/reth/src/commands/bitfinity_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -52,7 +54,8 @@ pub struct BitfinityImportCommand {

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

blockchain_provider: BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
blockchain_provider:
BlockchainProvider2<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
}

/// Manually implement `Debug` for `ImportCommand` because `BlockchainProvider` doesn't implement it.
Expand All @@ -77,7 +80,7 @@ impl BitfinityImportCommand {
chain: Arc<ChainSpec>,
bitfinity: BitfinityImportArgs,
provider_factory: ProviderFactory<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
blockchain_provider: BlockchainProvider<
blockchain_provider: BlockchainProvider2<
NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>,
>,
) -> Self {
Expand Down
12 changes: 6 additions & 6 deletions bin/reth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
}
})
{
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/tests/commands/bitfinity_import_it.rs
Original file line number Diff line number Diff line change
@@ -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.
//!

Expand Down
75 changes: 53 additions & 22 deletions bin/reth/tests/commands/bitfinity_node_it.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//!
//! Integration tests for the bitfinity node command.
//! Integration tests for the bitfinity node command with BlockchainProvider2.
//!

use super::utils::*;
Expand All @@ -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,
Expand Down Expand Up @@ -396,21 +398,28 @@ async fn start_reth_node(
NodeAdapter<
FullNodeTypesAdapter<
EthereumNode,
Arc<DatabaseEnv>,
BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
Arc<TempDatabase<DatabaseEnv>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
>,
>,
Components<
FullNodeTypesAdapter<
EthereumNode,
Arc<DatabaseEnv>,
BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
Arc<TempDatabase<DatabaseEnv>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
>,
>,
reth_network::EthNetworkPrimitives,
Pool<
TransactionValidationTaskExecutor<
EthTransactionValidator<
BlockchainProvider<
NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<
EthereumNode,
Arc<TempDatabase<DatabaseEnv>>,
>,
>,
EthPooledTransaction,
>,
Expand All @@ -427,21 +436,28 @@ async fn start_reth_node(
NodeAdapter<
FullNodeTypesAdapter<
EthereumNode,
Arc<DatabaseEnv>,
BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
Arc<TempDatabase<DatabaseEnv>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
>,
>,
Components<
FullNodeTypesAdapter<
EthereumNode,
Arc<DatabaseEnv>,
BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
Arc<TempDatabase<DatabaseEnv>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
>,
>,
reth_network::EthNetworkPrimitives,
Pool<
TransactionValidationTaskExecutor<
EthTransactionValidator<
BlockchainProvider<
NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<
EthereumNode,
Arc<TempDatabase<DatabaseEnv>>,
>,
>,
EthPooledTransaction,
>,
Expand All @@ -455,12 +471,17 @@ async fn start_reth_node(
>,
>,
EthApi<
BlockchainProvider<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<EthereumNode, Arc<TempDatabase<DatabaseEnv>>>,
>,
Pool<
TransactionValidationTaskExecutor<
EthTransactionValidator<
BlockchainProvider<
NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>,
BlockchainProvider2<
NodeTypesWithDBAdapter<
EthereumNode,
Arc<TempDatabase<DatabaseEnv>>,
>,
>,
EthPooledTransaction,
>,
Expand Down Expand Up @@ -504,18 +525,28 @@ 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::<EthereumNode, BlockchainProvider2<_>>()
.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(()) };
let forwarder = BitfinityTransactionsForwarder::new(queue);
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();

Expand Down
18 changes: 3 additions & 15 deletions bin/reth/tests/commands/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -74,7 +72,7 @@ pub struct ImportData {
/// The provider factory.
pub provider_factory: ProviderFactory<NodeTypes>,
/// The blockchain provider.
pub blockchain_db: BlockchainProvider<NodeTypes>,
pub blockchain_db: BlockchainProvider2<NodeTypes>,
/// The bitfinity import arguments.
pub bitfinity_args: BitfinityImportArgs,
}
Expand Down Expand Up @@ -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(),
Expand Down
Loading