Skip to content

Commit

Permalink
fix some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Jul 10, 2024
1 parent 96ce62b commit 65730f3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
3 changes: 2 additions & 1 deletion crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub struct StageConfig {
pub sender_recovery: SenderRecoveryConfig,
/// Execution stage configuration.
pub execution: ExecutionConfig,
/// Prune stage configuration.
pub prune: PruneStageConfig,
/// Account Hashing stage configuration.
pub account_hashing: HashingConfig,
Expand Down Expand Up @@ -233,7 +234,7 @@ impl From<ExecutionConfig> for ExecutionStageThresholds {
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
#[serde(default)]
pub struct PruneStageConfig {
/// The maximum number of entries to rune before committing progress to the database.
/// The maximum number of entries to prune before committing progress to the database.
pub commit_threshold: usize,
}

Expand Down
10 changes: 6 additions & 4 deletions crates/prune/prune/src/pruner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,12 @@ impl<S, DB: Database> Pruner<S, DB> {
}

impl<DB: Database> Pruner<WithoutProviderFactory, DB> {
/// Run the pruner. This will only prune data up to the highest finished `ExEx` height, if there
/// are no `ExEx`s, .
/// Run the pruner with the given provider. This will only prune data up to the highest finished
/// ExEx height, if there are no ExExes.
///
/// Returns a [`PruneProgress`], indicating whether pruning is finished, or there is more data
/// to prune.
#[allow(clippy::doc_markdown)]
pub fn run(
&mut self,
provider: &DatabaseProviderRW<DB>,
Expand All @@ -387,11 +388,12 @@ impl<DB: Database> Pruner<WithoutProviderFactory, DB> {
}

impl<DB: Database> Pruner<WithProviderFactory<DB>, DB> {
/// Run the pruner. This will only prune data up to the highest finished `ExEx` height, if there
/// are no `ExEx`s, .
/// Run the pruner. This will only prune data up to the highest finished ExEx height, if there
/// are no ExExes.
///
/// Returns a [`PruneProgress`], indicating whether pruning is finished, or there is more data
/// to prune.
#[allow(clippy::doc_markdown)]
pub fn run(&mut self, tip_block_number: BlockNumber) -> PrunerResult {
let provider = self.state.0.provider_rw()?;
let result = self.run_with_provider(&provider, tip_block_number);
Expand Down
21 changes: 19 additions & 2 deletions crates/stages/stages/src/stages/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ use reth_stages_api::{
};
use tracing::info;

/// The prune stage that runs the pruner with the provided prune modes.
///
/// There are two main reasons to have this stage when running a full node:
/// - Sender Recovery stage inserts a lot of data into the database that's only needed for the
/// Execution stage. Pruner will clean up the unneeded recovered senders.
/// - Pruning during the live sync can take a significant amount of time, especially history
/// segments. If we can prune as much data as possible in one go before starting the live sync, we
/// should do it.
///
/// `commit_threshold` is the maximum number of entries to prune before committing
/// progress to the database.
#[derive(Debug)]
pub struct PruneStage {
prune_modes: PruneModes,
commit_threshold: usize,
}

impl PruneStage {
/// Crate new prune stage with the given prune modes and commit threshold.
pub const fn new(prune_modes: PruneModes, commit_threshold: usize) -> Self {
Self { prune_modes, commit_threshold }
}
Expand Down Expand Up @@ -78,17 +90,22 @@ mod tests {
#[derive(Default)]
struct FinishTestRunner {
db: TestStageDB,
prune_modes: PruneModes,
commit_threshold: usize,
}

impl StageTestRunner for FinishTestRunner {
type S = FinishStage;
type S = PruneStage;

fn db(&self) -> &TestStageDB {
&self.db
}

fn stage(&self) -> Self::S {
FinishStage
PruneStage {
prune_modes: self.prune_modes.clone(),
commit_threshold: self.commit_threshold,
}
}
}

Expand Down
14 changes: 1 addition & 13 deletions crates/stages/types/src/id.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
/// Stage IDs for all known stages.
///
/// For custom stages, use [`StageId::Other`]
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum StageId {
/// Static File stage in the process.
#[deprecated(
note = "Static Files are generated outside of the pipeline and do not require a separate stage"
)]
StaticFile,
/// Header stage in the process.
Headers,
/// Bodies stage in the process.
Bodies,
/// Sender recovery stage in the process.
SenderRecovery,
/// Execution stage in the process.
Execution,
Prune,
/// Merkle unwind stage in the process.
MerkleUnwind,
/// Account hashing stage in the process.
AccountHashing,
/// Storage hashing stage in the process.
StorageHashing,
/// Merkle execute stage in the process.
MerkleExecute,
/// Transaction lookup stage in the process.
TransactionLookup,
/// Index storage history stage in the process.
IndexStorageHistory,
/// Index account history stage in the process.
IndexAccountHistory,
/// Finish stage in the process.
Finish,
/// Other custom stage with a provided string identifier.
Other(&'static str),
Expand Down

0 comments on commit 65730f3

Please sign in to comment.