Skip to content
Open
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
74 changes: 74 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ members = [
"crates/trie/sparse",
"crates/trie/sparse-parallel/",
"crates/trie/trie",
"crates/triedb/",
"examples/beacon-api-sidecar-fetcher/",
"examples/beacon-api-sse/",
"examples/bsc-p2p",
Expand Down Expand Up @@ -461,6 +462,7 @@ reth-trie-db = { path = "crates/trie/db" }
reth-trie-parallel = { path = "crates/trie/parallel" }
reth-trie-sparse = { path = "crates/trie/sparse", default-features = false }
reth-trie-sparse-parallel = { path = "crates/trie/sparse-parallel" }
reth-triedb = { path = "crates/triedb" }
reth-zstd-compressors = { path = "crates/storage/zstd-compressors", default-features = false }
reth-ress-protocol = { path = "crates/ress/protocol" }
reth-ress-provider = { path = "crates/ress/provider" }
Expand Down
11 changes: 8 additions & 3 deletions crates/cli/commands/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use reth_node_core::{
dirs::{ChainPath, DataDirPath},
};
use reth_provider::{
providers::{BlockchainProvider, NodeTypesForProvider, StaticFileProvider},
providers::{BlockchainProvider, NodeTypesForProvider, StaticFileProvider, TrieDbProvider},
ProviderFactory, StaticFileProviderFactory,
};
use reth_stages::{sets::DefaultStages, Pipeline, PipelineTarget};
Expand Down Expand Up @@ -69,10 +69,12 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain());
let db_path = data_dir.db();
let sf_path = data_dir.static_files();
let tdb_path = data_dir.triedb();

if access.is_read_write() {
reth_fs_util::create_dir_all(&db_path)?;
reth_fs_util::create_dir_all(&sf_path)?;
reth_fs_util::create_dir_all(&tdb_path)?;
}

let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
Expand All @@ -91,7 +93,7 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
config.stages.era = config.stages.era.with_datadir(data_dir.data_dir());
}

info!(target: "reth::cli", ?db_path, ?sf_path, "Opening storage");
info!(target: "reth::cli", ?db_path, ?sf_path, ?tdb_path, "Opening storage");
let (db, sfp) = match access {
AccessRights::RW => (
Arc::new(init_db(db_path, self.db.database_args())?),
Expand All @@ -102,8 +104,9 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
StaticFileProvider::read_only(sf_path, false)?,
),
};
let tdb = TrieDbProvider::open(tdb_path)?;

let provider_factory = self.create_provider_factory(&config, db, sfp)?;
let provider_factory = self.create_provider_factory(&config, db, sfp, tdb)?;
if access.is_read_write() {
debug!(target: "reth::cli", chain=%self.chain.chain(), genesis=?self.chain.genesis_hash(), "Initializing genesis");
init_genesis(&provider_factory)?;
Expand All @@ -122,6 +125,7 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
config: &Config,
db: Arc<DatabaseEnv>,
static_file_provider: StaticFileProvider<N::Primitives>,
triedb_provider: TrieDbProvider,
) -> eyre::Result<ProviderFactory<NodeTypesWithDBAdapter<N, Arc<DatabaseEnv>>>>
where
C: ChainSpecParser<ChainSpec = N::ChainSpec>,
Expand All @@ -132,6 +136,7 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
db,
self.chain.clone(),
static_file_provider,
triedb_provider,
)
.with_prune_modes(prune_modes.clone());

Expand Down
3 changes: 2 additions & 1 deletion crates/cli/commands/src/stage/dump/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use reth_evm::ConfigureEvm;
use reth_node_builder::NodeTypesWithDB;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, StaticFileProvider, TrieDbProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{stages::ExecutionStage, Stage, StageCheckpoint, UnwindInput};
Expand Down Expand Up @@ -42,6 +42,7 @@ where
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
TrieDbProvider::open(output_datadir.triedb())?,
),
to,
from,
Expand Down
3 changes: 2 additions & 1 deletion crates/cli/commands/src/stage/dump/hashing_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use reth_db_api::{database::Database, table::TableImporter, tables};
use reth_db_common::DbTool;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, StaticFileProvider, TrieDbProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{stages::AccountHashingStage, Stage, StageCheckpoint, UnwindInput};
Expand Down Expand Up @@ -39,6 +39,7 @@ pub(crate) async fn dump_hashing_account_stage<N: ProviderNodeTypes<DB = Arc<Dat
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
TrieDbProvider::open(output_datadir.triedb())?,
),
to,
from,
Expand Down
3 changes: 2 additions & 1 deletion crates/cli/commands/src/stage/dump/hashing_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use reth_db_api::{database::Database, table::TableImporter, tables};
use reth_db_common::DbTool;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, StaticFileProvider, TrieDbProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{stages::StorageHashingStage, Stage, StageCheckpoint, UnwindInput};
Expand All @@ -29,6 +29,7 @@ pub(crate) async fn dump_hashing_storage_stage<N: ProviderNodeTypes<DB = Arc<Dat
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
TrieDbProvider::open(output_datadir.triedb())?,
),
to,
from,
Expand Down
3 changes: 2 additions & 1 deletion crates/cli/commands/src/stage/dump/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use reth_evm::ConfigureEvm;
use reth_exex::ExExManagerHandle;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, StaticFileProvider, TrieDbProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{
Expand Down Expand Up @@ -62,6 +62,7 @@ where
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
TrieDbProvider::open(output_datadir.triedb())?,
),
to,
from,
Expand Down
11 changes: 9 additions & 2 deletions crates/e2e-test-utils/src/setup_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use reth_node_builder::{EngineNodeLauncher, Node, NodeBuilder, NodeConfig, NodeH
use reth_node_core::args::{DiscoveryArgs, NetworkArgs, RpcServerArgs};
use reth_node_ethereum::EthereumNode;
use reth_provider::{
providers::BlockchainProvider, DatabaseProviderFactory, ProviderFactory, StageCheckpointReader,
StaticFileProviderFactory,
providers::{BlockchainProvider, TrieDbProvider},
DatabaseProviderFactory, ProviderFactory, StageCheckpointReader, StaticFileProviderFactory,
};
use reth_rpc_server_types::RpcModuleSelection;
use reth_stages_types::StageId;
Expand Down Expand Up @@ -109,6 +109,7 @@ pub async fn setup_engine_with_chain_import(

// Create database path and static files path
let db_path = datadir.join("db");
let triedb_path = datadir.join("triedb");
let static_files_path = datadir.join("static_files");

// Initialize the database using init_db (same as CLI import command)
Expand All @@ -125,6 +126,7 @@ pub async fn setup_engine_with_chain_import(
db.clone(),
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_write(static_files_path.clone())?,
TrieDbProvider::open(triedb_path)?,
);

// Initialize genesis if needed
Expand Down Expand Up @@ -310,6 +312,7 @@ mod tests {
let datadir = temp_dir.path().join("datadir");
std::fs::create_dir_all(&datadir).unwrap();
let db_path = datadir.join("db");
let triedb_path = datadir.join("triedb");
let static_files_path = datadir.join("static_files");

// Import the chain
Expand All @@ -324,6 +327,7 @@ mod tests {
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_write(static_files_path.clone())
.unwrap(),
TrieDbProvider::open(&triedb_path).unwrap(),
);

// Initialize genesis
Expand Down Expand Up @@ -384,6 +388,7 @@ mod tests {
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_only(static_files_path, false)
.unwrap(),
TrieDbProvider::open(triedb_path).unwrap(),
);

let provider = provider_factory.database_provider_ro().unwrap();
Expand Down Expand Up @@ -464,6 +469,7 @@ mod tests {
let datadir = temp_dir.path().join("datadir");
std::fs::create_dir_all(&datadir).unwrap();
let db_path = datadir.join("db");
let triedb_path = datadir.join("triedb");
let db_env = reth_db::init_db(&db_path, DatabaseArguments::default()).unwrap();
let db = Arc::new(reth_db::test_utils::TempDatabase::new(db_env, db_path));

Expand All @@ -475,6 +481,7 @@ mod tests {
db.clone(),
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_write(static_files_path).unwrap(),
TrieDbProvider::open(triedb_path).unwrap(),
);

// Initialize genesis
Expand Down
Loading
Loading