Skip to content

Commit

Permalink
rename stages
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Feb 26, 2024
1 parent ef0726e commit abe4e69
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 86 deletions.
4 changes: 2 additions & 2 deletions bin/reth/src/commands/stage/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ impl Command {
tx.clear::<tables::AccountsHistory>()?;
tx.clear::<tables::StoragesHistory>()?;
tx.put::<tables::StageCheckpoints>(
StageId::IndexAccountHistory.to_string(),
StageId::IndexAccountsHistory.to_string(),
Default::default(),
)?;
tx.put::<tables::StageCheckpoints>(
StageId::IndexStorageHistory.to_string(),
StageId::IndexStoragesHistory.to_string(),
Default::default(),
)?;
}
Expand Down
6 changes: 3 additions & 3 deletions bin/reth/src/commands/stage/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use reth_provider::{ProviderFactory, StageCheckpointReader, StageCheckpointWrite
use reth_stages::{
stages::{
AccountHashingStage, BodyStage, ExecutionStage, ExecutionStageThresholds,
IndexAccountHistoryStage, IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage,
IndexAccountsHistoryStage, IndexStoragesHistoryStage, MerkleStage, SenderRecoveryStage,
StorageHashingStage, TransactionLookupStage,
},
ExecInput, ExecOutput, Stage, StageExt, UnwindInput, UnwindOutput,
Expand Down Expand Up @@ -234,8 +234,8 @@ impl Command {
Box::new(MerkleStage::default_execution()),
Some(Box::new(MerkleStage::default_unwind())),
),
StageEnum::AccountHistory => (Box::<IndexAccountHistoryStage>::default(), None),
StageEnum::StorageHistory => (Box::<IndexStorageHistoryStage>::default(), None),
StageEnum::AccountHistory => (Box::<IndexAccountsHistoryStage>::default(), None),
StageEnum::StorageHistory => (Box::<IndexStoragesHistoryStage>::default(), None),
_ => return Ok(()),
};
if let Some(unwind_stage) = &unwind_stage {
Expand Down
8 changes: 4 additions & 4 deletions crates/node-core/src/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ use reth_revm::EvmProcessorFactory;
use reth_stages::{
prelude::*,
stages::{
AccountHashingStage, ExecutionStage, ExecutionStageThresholds, IndexAccountHistoryStage,
IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage, StorageHashingStage,
AccountHashingStage, ExecutionStage, ExecutionStageThresholds, IndexAccountsHistoryStage,
IndexStoragesHistoryStage, MerkleStage, SenderRecoveryStage, StorageHashingStage,
TotalDifficultyStage, TransactionLookupStage,
},
MetricEvent,
Expand Down Expand Up @@ -878,11 +878,11 @@ impl NodeConfig {
stage_config.transaction_lookup.commit_threshold,
prune_modes.transaction_lookup,
))
.set(IndexAccountHistoryStage::new(
.set(IndexAccountsHistoryStage::new(
stage_config.index_account_history.commit_threshold,
prune_modes.account_history,
))
.set(IndexStorageHistoryStage::new(
.set(IndexStoragesHistoryStage::new(
stage_config.index_storage_history.commit_threshold,
prune_modes.storage_history,
)),
Expand Down
16 changes: 8 additions & 8 deletions crates/primitives/src/stage/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub enum StageId {
/// Transaction lookup stage in the process.
TransactionLookup,
/// Index storage history stage in the process.
IndexStorageHistory,
IndexStoragesHistory,
/// Index account history stage in the process.
IndexAccountHistory,
IndexAccountsHistory,
/// Finish stage in the process.
Finish,
/// Other custom stage with a provided string identifier.
Expand All @@ -46,8 +46,8 @@ impl StageId {
StageId::StorageHashing,
StageId::MerkleExecute,
StageId::TransactionLookup,
StageId::IndexStorageHistory,
StageId::IndexAccountHistory,
StageId::IndexStoragesHistory,
StageId::IndexAccountsHistory,
StageId::Finish,
];

Expand All @@ -64,8 +64,8 @@ impl StageId {
StageId::StorageHashing => "StorageHashing",
StageId::MerkleExecute => "MerkleExecute",
StageId::TransactionLookup => "TransactionLookup",
StageId::IndexAccountHistory => "IndexAccountHistory",
StageId::IndexStorageHistory => "IndexStorageHistory",
StageId::IndexAccountsHistory => "IndexAccountHistory",
StageId::IndexStoragesHistory => "IndexStorageHistory",
StageId::Finish => "Finish",
StageId::Other(s) => s,
}
Expand Down Expand Up @@ -103,8 +103,8 @@ mod tests {
assert_eq!(StageId::AccountHashing.to_string(), "AccountHashing");
assert_eq!(StageId::StorageHashing.to_string(), "StorageHashing");
assert_eq!(StageId::MerkleExecute.to_string(), "MerkleExecute");
assert_eq!(StageId::IndexAccountHistory.to_string(), "IndexAccountHistory");
assert_eq!(StageId::IndexStorageHistory.to_string(), "IndexStorageHistory");
assert_eq!(StageId::IndexAccountsHistory.to_string(), "IndexAccountHistory");
assert_eq!(StageId::IndexStoragesHistory.to_string(), "IndexStorageHistory");
assert_eq!(StageId::TransactionLookup.to_string(), "TransactionLookup");
assert_eq!(StageId::Finish.to_string(), "Finish");

Expand Down
10 changes: 5 additions & 5 deletions crates/stages/src/sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
use crate::{
stages::{
AccountHashingStage, BodyStage, ExecutionStage, FinishStage, HeaderStage,
IndexAccountHistoryStage, IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage,
IndexAccountsHistoryStage, IndexStoragesHistoryStage, MerkleStage, SenderRecoveryStage,
StorageHashingStage, TotalDifficultyStage, TransactionLookupStage,
},
StageSet, StageSetBuilder,
Expand Down Expand Up @@ -73,8 +73,8 @@ use std::sync::Arc;
/// - [`StorageHashingStage`]
/// - [`MerkleStage`] (execute)
/// - [`TransactionLookupStage`]
/// - [`IndexStorageHistoryStage`]
/// - [`IndexAccountHistoryStage`]
/// - [`IndexStoragesHistoryStage`]
/// - [`IndexAccountsHistoryStage`]
/// - [`FinishStage`]
#[derive(Debug)]
pub struct DefaultStages<Provider, H, B, EF> {
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<DB: Database> StageSet<DB> for HistoryIndexingStages {
fn builder(self) -> StageSetBuilder<DB> {
StageSetBuilder::default()
.add_stage(TransactionLookupStage::default())
.add_stage(IndexStorageHistoryStage::default())
.add_stage(IndexAccountHistoryStage::default())
.add_stage(IndexStoragesHistoryStage::default())
.add_stage(IndexAccountsHistoryStage::default())
}
}
32 changes: 16 additions & 16 deletions crates/stages/src/stages/index_account_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ use std::fmt::Debug;
/// [`ExecutionStage`][crate::stages::ExecutionStage]. For more information
/// on index sharding take a look at [`reth_db::tables::AccountsHistory`]
#[derive(Debug)]
pub struct IndexAccountHistoryStage {
pub struct IndexAccountsHistoryStage {
/// Number of blocks after which the control
/// flow will be returned to the pipeline for commit.
pub commit_threshold: u64,
/// Pruning configuration.
pub prune_mode: Option<PruneMode>,
}

impl IndexAccountHistoryStage {
/// Create new instance of [IndexAccountHistoryStage].
impl IndexAccountsHistoryStage {
/// Create new instance of [IndexAccountsHistoryStage].
pub fn new(commit_threshold: u64, prune_mode: Option<PruneMode>) -> Self {
Self { commit_threshold, prune_mode }
}
}

impl Default for IndexAccountHistoryStage {
impl Default for IndexAccountsHistoryStage {
fn default() -> Self {
Self { commit_threshold: 100_000, prune_mode: None }
}
}

impl<DB: Database> Stage<DB> for IndexAccountHistoryStage {
impl<DB: Database> Stage<DB> for IndexAccountsHistoryStage {
/// Return the id of the stage
fn id(&self) -> StageId {
StageId::IndexAccountHistory
StageId::IndexAccountsHistory
}

/// Execute the stage.
Expand Down Expand Up @@ -177,7 +177,7 @@ mod tests {
checkpoint: input_checkpoint
.map(|block_number| StageCheckpoint { block_number, stage_checkpoint: None }),
};
let mut stage = IndexAccountHistoryStage::default();
let mut stage = IndexAccountsHistoryStage::default();
let provider = db.factory.provider_rw().unwrap();
let out = stage.execute(&provider, input).unwrap();
assert_eq!(out, ExecOutput { checkpoint: StageCheckpoint::new(run_to), done: true });
Expand All @@ -190,7 +190,7 @@ mod tests {
unwind_to,
..Default::default()
};
let mut stage = IndexAccountHistoryStage::default();
let mut stage = IndexAccountsHistoryStage::default();
let provider = db.factory.provider_rw().unwrap();
let out = stage.unwind(&provider, input).unwrap();
assert_eq!(out, UnwindOutput { checkpoint: StageCheckpoint::new(unwind_to) });
Expand Down Expand Up @@ -434,7 +434,7 @@ mod tests {

// run
let input = ExecInput { target: Some(20000), ..Default::default() };
let mut stage = IndexAccountHistoryStage {
let mut stage = IndexAccountsHistoryStage {
prune_mode: Some(PruneMode::Before(36)),
..Default::default()
};
Expand All @@ -455,22 +455,22 @@ mod tests {
assert!(table.is_empty());
}

stage_test_suite_ext!(IndexAccountHistoryTestRunner, index_account_history);
stage_test_suite_ext!(IndexAccountsHistoryTestRunner, index_account_history);

struct IndexAccountHistoryTestRunner {
struct IndexAccountsHistoryTestRunner {
pub(crate) db: TestStageDB,
commit_threshold: u64,
prune_mode: Option<PruneMode>,
}

impl Default for IndexAccountHistoryTestRunner {
impl Default for IndexAccountsHistoryTestRunner {
fn default() -> Self {
Self { db: TestStageDB::default(), commit_threshold: 1000, prune_mode: None }
}
}

impl StageTestRunner for IndexAccountHistoryTestRunner {
type S = IndexAccountHistoryStage;
impl StageTestRunner for IndexAccountsHistoryTestRunner {
type S = IndexAccountsHistoryStage;

fn db(&self) -> &TestStageDB {
&self.db
Expand All @@ -481,7 +481,7 @@ mod tests {
}
}

impl ExecuteStageTestRunner for IndexAccountHistoryTestRunner {
impl ExecuteStageTestRunner for IndexAccountsHistoryTestRunner {
type Seed = ();

fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> {
Expand Down Expand Up @@ -578,7 +578,7 @@ mod tests {
}
}

impl UnwindStageTestRunner for IndexAccountHistoryTestRunner {
impl UnwindStageTestRunner for IndexAccountsHistoryTestRunner {
fn validate_unwind(&self, _input: UnwindInput) -> Result<(), TestRunnerError> {
let table = self.db.table::<tables::AccountsHistory>().unwrap();
assert!(table.is_empty());
Expand Down
32 changes: 16 additions & 16 deletions crates/stages/src/stages/index_storage_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ use std::fmt::Debug;
/// [`ExecutionStage`][crate::stages::ExecutionStage]. For more information
/// on index sharding take a look at [`reth_db::tables::StorageHistory`].
#[derive(Debug)]
pub struct IndexStorageHistoryStage {
pub struct IndexStoragesHistoryStage {
/// Number of blocks after which the control
/// flow will be returned to the pipeline for commit.
pub commit_threshold: u64,
/// Pruning configuration.
pub prune_mode: Option<PruneMode>,
}

impl IndexStorageHistoryStage {
/// Create new instance of [IndexStorageHistoryStage].
impl IndexStoragesHistoryStage {
/// Create new instance of [IndexStoragesHistoryStage].
pub fn new(commit_threshold: u64, prune_mode: Option<PruneMode>) -> Self {
Self { commit_threshold, prune_mode }
}
}

impl Default for IndexStorageHistoryStage {
impl Default for IndexStoragesHistoryStage {
fn default() -> Self {
Self { commit_threshold: 100_000, prune_mode: None }
}
}

impl<DB: Database> Stage<DB> for IndexStorageHistoryStage {
impl<DB: Database> Stage<DB> for IndexStoragesHistoryStage {
/// Return the id of the stage
fn id(&self) -> StageId {
StageId::IndexStorageHistory
StageId::IndexStoragesHistory
}

/// Execute the stage.
Expand Down Expand Up @@ -188,7 +188,7 @@ mod tests {
checkpoint: input_checkpoint
.map(|block_number| StageCheckpoint { block_number, stage_checkpoint: None }),
};
let mut stage = IndexStorageHistoryStage::default();
let mut stage = IndexStoragesHistoryStage::default();
let provider = db.factory.provider_rw().unwrap();
let out = stage.execute(&provider, input).unwrap();
assert_eq!(out, ExecOutput { checkpoint: StageCheckpoint::new(run_to), done: true });
Expand All @@ -201,7 +201,7 @@ mod tests {
unwind_to,
..Default::default()
};
let mut stage = IndexStorageHistoryStage::default();
let mut stage = IndexStoragesHistoryStage::default();
let provider = db.factory.provider_rw().unwrap();
let out = stage.unwind(&provider, input).unwrap();
assert_eq!(out, UnwindOutput { checkpoint: StageCheckpoint::new(unwind_to) });
Expand Down Expand Up @@ -448,7 +448,7 @@ mod tests {

// run
let input = ExecInput { target: Some(20000), ..Default::default() };
let mut stage = IndexStorageHistoryStage {
let mut stage = IndexStoragesHistoryStage {
prune_mode: Some(PruneMode::Before(36)),
..Default::default()
};
Expand All @@ -469,22 +469,22 @@ mod tests {
assert!(table.is_empty());
}

stage_test_suite_ext!(IndexStorageHistoryTestRunner, index_storage_history);
stage_test_suite_ext!(IndexStoragesHistoryTestRunner, index_storage_history);

struct IndexStorageHistoryTestRunner {
struct IndexStoragesHistoryTestRunner {
pub(crate) db: TestStageDB,
commit_threshold: u64,
prune_mode: Option<PruneMode>,
}

impl Default for IndexStorageHistoryTestRunner {
impl Default for IndexStoragesHistoryTestRunner {
fn default() -> Self {
Self { db: TestStageDB::default(), commit_threshold: 1000, prune_mode: None }
}
}

impl StageTestRunner for IndexStorageHistoryTestRunner {
type S = IndexStorageHistoryStage;
impl StageTestRunner for IndexStoragesHistoryTestRunner {
type S = IndexStoragesHistoryStage;

fn db(&self) -> &TestStageDB {
&self.db
Expand All @@ -495,7 +495,7 @@ mod tests {
}
}

impl ExecuteStageTestRunner for IndexStorageHistoryTestRunner {
impl ExecuteStageTestRunner for IndexStoragesHistoryTestRunner {
type Seed = ();

fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> {
Expand Down Expand Up @@ -600,7 +600,7 @@ mod tests {
}
}

impl UnwindStageTestRunner for IndexStorageHistoryTestRunner {
impl UnwindStageTestRunner for IndexStoragesHistoryTestRunner {
fn validate_unwind(&self, _input: UnwindInput) -> Result<(), TestRunnerError> {
let table = self.db.table::<tables::StoragesHistory>().unwrap();
assert!(table.is_empty());
Expand Down
4 changes: 2 additions & 2 deletions crates/stages/src/stages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod tests {
);

// Check AccountHistory
let mut acc_indexing_stage = IndexAccountHistoryStage {
let mut acc_indexing_stage = IndexAccountsHistoryStage {
prune_mode: prune_modes.account_history,
..Default::default()
};
Expand All @@ -171,7 +171,7 @@ mod tests {
}

// Check StorageHistory
let mut storage_indexing_stage = IndexStorageHistoryStage {
let mut storage_indexing_stage = IndexStoragesHistoryStage {
prune_mode: prune_modes.storage_history,
..Default::default()
};
Expand Down
Loading

0 comments on commit abe4e69

Please sign in to comment.