feat: integrate NodeTypesWithDB (#10698)

Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
This commit is contained in:
Arsenii Kulikov
2024-09-05 19:17:28 +04:00
committed by GitHub
parent 5df03fb3c3
commit 5ecc9d2348
99 changed files with 1171 additions and 1143 deletions

View File

@ -12,6 +12,8 @@ reth-db.workspace = true
reth-primitives.workspace = true
reth-provider.workspace = true
reth-rpc-types.workspace = true
reth-node-ethereum.workspace = true
reth-node-types.workspace = true
eyre.workspace = true

View File

@ -1,4 +1,6 @@
use reth_chainspec::ChainSpecBuilder;
use reth_node_ethereum::EthereumNode;
use reth_node_types::NodeTypesWithDBAdapter;
use reth_primitives::{Address, B256};
use reth_provider::{
providers::StaticFileProvider, AccountReader, BlockReader, BlockSource, HeaderProvider,
@ -21,12 +23,13 @@ fn main() -> eyre::Result<()> {
// Instantiate a provider factory for Ethereum mainnet using the provided DB.
// TODO: Should the DB version include the spec so that you do not need to specify it here?
let spec = ChainSpecBuilder::mainnet().build();
let factory = ProviderFactory::new_with_database_path(
db_path,
spec.into(),
Default::default(),
StaticFileProvider::read_only(db_path.join("static_files"))?,
)?;
let factory =
ProviderFactory::<NodeTypesWithDBAdapter<EthereumNode, _>>::new_with_database_path(
db_path,
spec.into(),
Default::default(),
StaticFileProvider::read_only(db_path.join("static_files"))?,
)?;
// This call opens a RO transaction on the database. To write to the DB you'd need to call
// the `provider_rw` function and look for the `Writer` variants of the traits.

View File

@ -15,6 +15,7 @@
use std::{path::Path, sync::Arc};
use reth::{
api::NodeTypesWithDBAdapter,
providers::{
providers::{BlockchainProvider, StaticFileProvider},
ProviderFactory,
@ -23,7 +24,7 @@ use reth::{
utils::open_db_read_only,
};
use reth_chainspec::ChainSpecBuilder;
use reth_db::mdbx::DatabaseArguments;
use reth_db::{mdbx::DatabaseArguments, DatabaseEnv};
use reth_db_api::models::ClientVersion;
// Bringing up the RPC
@ -33,7 +34,7 @@ use reth::rpc::builder::{
// Configuring the network parts, ideally also wouldn't need to think about this.
use myrpc_ext::{MyRpcExt, MyRpcExtApiServer};
use reth::{blockchain_tree::noop::NoopBlockchainTree, tasks::TokioTaskExecutor};
use reth_node_ethereum::EthEvmConfig;
use reth_node_ethereum::{EthEvmConfig, EthereumNode};
use reth_provider::test_utils::TestCanonStateSubscriptions;
// Custom rpc extension
@ -49,7 +50,7 @@ async fn main() -> eyre::Result<()> {
DatabaseArguments::new(ClientVersion::default()),
)?);
let spec = Arc::new(ChainSpecBuilder::mainnet().build());
let factory = ProviderFactory::new(
let factory = ProviderFactory::<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>::new(
db.clone(),
spec.clone(),
StaticFileProvider::read_only(db_path.join("static_files"))?,