feat(pruning): prune Receipts during pipeline (#3585)

This commit is contained in:
joshieDo
2023-07-11 11:51:34 +01:00
committed by GitHub
parent 467f6f9199
commit 65b07b981e
18 changed files with 241 additions and 86 deletions

View File

@@ -159,10 +159,11 @@ impl ImportCommand {
let (tip_tx, tip_rx) = watch::channel(H256::zero());
let factory = reth_revm::Factory::new(self.chain.clone());
let max_block = file_client.max_block().unwrap_or(0);
let mut pipeline = Pipeline::builder()
.with_tip_sender(tip_tx)
// we want to sync all blocks the file client provides or 0 if empty
.with_max_block(file_client.max_block().unwrap_or(0))
.with_max_block(max_block)
.add_stages(
DefaultStages::new(
HeaderSyncMode::Tip(tip_rx),
@@ -184,6 +185,7 @@ impl ImportCommand {
max_blocks: config.stages.execution.max_blocks,
max_changes: config.stages.execution.max_changes,
},
config.prune.map(|prune| prune.parts).unwrap_or_default(),
)),
)
.build(db, self.chain.clone());

View File

@@ -142,6 +142,7 @@ impl Command {
.set(ExecutionStage::new(
factory,
ExecutionStageThresholds { max_blocks: None, max_changes: None },
config.prune.map(|prune| prune.parts).unwrap_or_default(),
)),
)
.build(db, self.chain.clone());

View File

@@ -8,7 +8,7 @@ use reth_db::{cursor::DbCursorRO, init_db, tables, transaction::DbTx};
use reth_primitives::{
fs,
stage::{StageCheckpoint, StageId},
ChainSpec,
ChainSpec, PruneTargets,
};
use reth_provider::{ProviderFactory, StageCheckpointReader};
use reth_stages::{
@@ -96,6 +96,7 @@ impl Command {
let mut execution_stage = ExecutionStage::new(
factory,
ExecutionStageThresholds { max_blocks: Some(1), max_changes: None },
PruneTargets::all(),
);
let mut account_hashing_stage = AccountHashingStage::default();

View File

@@ -109,7 +109,7 @@ pub fn insert_genesis_state<DB: Database>(
state.change_storage(0, *address, storage_changes);
}
}
state.write_to_db(tx)?;
state.write_to_db(tx, 0)?;
Ok(())
}

View File

@@ -719,6 +719,7 @@ impl Command {
max_blocks: stage_config.execution.max_blocks,
max_changes: stage_config.execution.max_changes,
},
config.prune.map(|prune| prune.parts).unwrap_or_default(),
)
.with_metrics_tx(metrics_tx),
)

View File

@@ -2,7 +2,7 @@ use super::setup;
use crate::utils::DbTool;
use eyre::Result;
use reth_db::{database::Database, table::TableImporter, tables, DatabaseEnv};
use reth_primitives::{stage::StageCheckpoint, BlockNumber, ChainSpec};
use reth_primitives::{stage::StageCheckpoint, BlockNumber, ChainSpec, PruneTargets};
use reth_provider::ProviderFactory;
use reth_stages::{
stages::{
@@ -70,6 +70,7 @@ async fn unwind_and_copy<DB: Database>(
let mut exec_stage = ExecutionStage::new(
reth_revm::Factory::new(db_tool.chain.clone()),
ExecutionStageThresholds { max_blocks: Some(u64::MAX), max_changes: None },
PruneTargets::all(),
);
exec_stage

View File

@@ -202,6 +202,7 @@ impl Command {
max_blocks: Some(batch_size),
max_changes: None,
},
config.prune.map(|prune| prune.parts).unwrap_or_default(),
)),
None,
)