Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use StageConfig for more reth node methods #5663

Merged
merged 2 commits into from
Dec 2, 2023
Merged
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
51 changes: 26 additions & 25 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ use reth_beacon_consensus::{
use reth_blockchain_tree::{
config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree,
};
use reth_config::{config::PruneConfig, Config};
use reth_config::{
config::{PruneConfig, StageConfig},
Config,
};
use reth_db::{database::Database, init_db, DatabaseEnv};
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
Expand Down Expand Up @@ -419,7 +422,7 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {

let mut pipeline = self
.build_networked_pipeline(
&config,
&config.stages,
client.clone(),
Arc::clone(&consensus),
provider_factory,
Expand All @@ -439,7 +442,7 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
} else {
let pipeline = self
.build_networked_pipeline(
&config,
&config.stages,
network_client.clone(),
Arc::clone(&consensus),
provider_factory,
Expand Down Expand Up @@ -604,7 +607,7 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
#[allow(clippy::too_many_arguments)]
async fn build_networked_pipeline<DB, Client>(
&self,
config: &Config,
config: &StageConfig,
client: Client,
consensus: Arc<dyn Consensus>,
provider_factory: ProviderFactory<DB>,
Expand All @@ -618,11 +621,11 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
Client: HeadersClient + BodiesClient + Clone + 'static,
{
// building network downloaders using the fetch client
let header_downloader = ReverseHeadersDownloaderBuilder::from(config.stages.headers)
let header_downloader = ReverseHeadersDownloaderBuilder::from(config.headers)
.build(client.clone(), Arc::clone(&consensus))
.into_task_with(task_executor);

let body_downloader = BodiesDownloaderBuilder::from(config.stages.bodies)
let body_downloader = BodiesDownloaderBuilder::from(config.bodies)
.build(client, Arc::clone(&consensus), provider_factory.clone())
.into_task_with(task_executor);

Expand Down Expand Up @@ -863,7 +866,7 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
async fn build_pipeline<DB, H, B>(
&self,
provider_factory: ProviderFactory<DB>,
config: &Config,
config: &StageConfig,
header_downloader: H,
body_downloader: B,
consensus: Arc<dyn Consensus>,
Expand All @@ -877,8 +880,6 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
H: HeaderDownloader + 'static,
B: BodyDownloader + 'static,
{
let stage_config = &config.stages;

let mut builder = Pipeline::builder();

if let Some(max_block) = max_block {
Expand Down Expand Up @@ -923,47 +924,47 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
)
.set(
TotalDifficultyStage::new(consensus)
.with_commit_threshold(stage_config.total_difficulty.commit_threshold),
.with_commit_threshold(config.total_difficulty.commit_threshold),
)
.set(SenderRecoveryStage {
commit_threshold: stage_config.sender_recovery.commit_threshold,
commit_threshold: config.sender_recovery.commit_threshold,
})
.set(
ExecutionStage::new(
factory,
ExecutionStageThresholds {
max_blocks: stage_config.execution.max_blocks,
max_changes: stage_config.execution.max_changes,
max_cumulative_gas: stage_config.execution.max_cumulative_gas,
max_blocks: config.execution.max_blocks,
max_changes: config.execution.max_changes,
max_cumulative_gas: config.execution.max_cumulative_gas,
},
stage_config
config
.merkle
.clean_threshold
.max(stage_config.account_hashing.clean_threshold)
.max(stage_config.storage_hashing.clean_threshold),
.max(config.account_hashing.clean_threshold)
.max(config.storage_hashing.clean_threshold),
prune_modes.clone(),
)
.with_metrics_tx(metrics_tx),
)
.set(AccountHashingStage::new(
stage_config.account_hashing.clean_threshold,
stage_config.account_hashing.commit_threshold,
config.account_hashing.clean_threshold,
config.account_hashing.commit_threshold,
))
.set(StorageHashingStage::new(
stage_config.storage_hashing.clean_threshold,
stage_config.storage_hashing.commit_threshold,
config.storage_hashing.clean_threshold,
config.storage_hashing.commit_threshold,
))
.set(MerkleStage::new_execution(stage_config.merkle.clean_threshold))
.set(MerkleStage::new_execution(config.merkle.clean_threshold))
.set(TransactionLookupStage::new(
stage_config.transaction_lookup.commit_threshold,
config.transaction_lookup.commit_threshold,
prune_modes.transaction_lookup,
))
.set(IndexAccountHistoryStage::new(
stage_config.index_account_history.commit_threshold,
config.index_account_history.commit_threshold,
prune_modes.account_history,
))
.set(IndexStorageHistoryStage::new(
stage_config.index_storage_history.commit_threshold,
config.index_storage_history.commit_threshold,
prune_modes.storage_history,
)),
)
Expand Down