feat: add EtlConfig as well as setting the directory to datadir (#7124)

Co-authored-by: Mikhail Sozin <mikhail.sozin@chainstack.com>
Co-authored-by: Misha <mikawamp@gmail.com>
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
This commit is contained in:
joshieDo
2024-03-13 16:06:50 +00:00
committed by GitHub
parent 5d6ac4c815
commit 28f3a2e2d9
18 changed files with 118 additions and 43 deletions

View File

@ -127,7 +127,7 @@ impl Command {
header_downloader,
body_downloader,
factory.clone(),
stage_conf.etl.etl_file_size,
stage_conf.etl.clone(),
)
.set(SenderRecoveryStage {
commit_threshold: stage_conf.sender_recovery.commit_threshold,

View File

@ -179,8 +179,6 @@ impl ImportCommand {
let max_block = file_client.max_block().unwrap_or(0);
let etl_file_size = config.stages.etl.etl_file_size;
let mut pipeline = Pipeline::builder()
.with_tip_sender(tip_tx)
// we want to sync all blocks the file client provides or 0 if empty
@ -193,7 +191,7 @@ impl ImportCommand {
header_downloader,
body_downloader,
factory.clone(),
etl_file_size,
config.stages.etl,
)
.set(SenderRecoveryStage {
commit_threshold: config.stages.sender_recovery.commit_threshold,

View File

@ -14,7 +14,7 @@ use crate::{
};
use clap::Parser;
use reth_beacon_consensus::BeaconConsensus;
use reth_config::Config;
use reth_config::{config::EtlConfig, Config};
use reth_db::init_db;
use reth_downloaders::bodies::bodies::BodiesDownloaderBuilder;
use reth_node_ethereum::EthEvmConfig;
@ -86,6 +86,10 @@ pub struct Command {
#[arg(long)]
etl_file_size: Option<usize>,
/// Directory where to collect ETL files
#[arg(long)]
etl_dir: Option<PathBuf>,
/// Normally, running the stage requires unwinding for stages that already
/// have been run, in order to not rewrite to the same database slots.
///
@ -155,7 +159,12 @@ impl Command {
let batch_size = self.batch_size.unwrap_or(self.to - self.from + 1);
let etl_file_size = self.etl_file_size.unwrap_or(500 * 1024 * 1024);
let etl_config = EtlConfig::new(
Some(
self.etl_dir.unwrap_or_else(|| EtlConfig::from_datadir(&data_dir.data_dir_path())),
),
self.etl_file_size.unwrap_or(EtlConfig::default_file_size()),
);
let (mut exec_stage, mut unwind_stage): (Box<dyn Stage<_>>, Option<Box<dyn Stage<_>>>) =
match self.stage {
@ -235,7 +244,7 @@ impl Command {
)
}
StageEnum::TxLookup => {
(Box::new(TransactionLookupStage::new(batch_size, etl_file_size, None)), None)
(Box::new(TransactionLookupStage::new(batch_size, etl_config, None)), None)
}
StageEnum::AccountHashing => {
(Box::new(AccountHashingStage::new(1, batch_size)), None)