chore: reorder struct account hashing struct defs (#8392)

This commit is contained in:
Matthias Seitz
2024-05-25 10:58:42 +02:00
committed by GitHub
parent a8e5eb6186
commit 46fd454d80

View File

@@ -53,37 +53,6 @@ impl AccountHashingStage {
}
}
impl Default for AccountHashingStage {
fn default() -> Self {
Self {
clean_threshold: 500_000,
commit_threshold: 100_000,
etl_config: EtlConfig::default(),
}
}
}
// TODO: Rewrite this
/// `SeedOpts` provides configuration parameters for calling `AccountHashingStage::seed`
/// in unit tests or benchmarks to generate an initial database state for running the
/// stage.
///
/// In order to check the "full hashing" mode of the stage you want to generate more
/// transitions than `AccountHashingStage.clean_threshold`. This requires:
/// 1. Creating enough blocks so there's enough transactions to generate the required transition
/// keys in the `BlockTransitionIndex` (which depends on the `TxTransitionIndex` internally)
/// 2. Setting `blocks.len() > clean_threshold` so that there's enough diffs to actually take the
/// 2nd codepath
#[derive(Clone, Debug)]
pub struct SeedOpts {
/// The range of blocks to be generated
pub blocks: RangeInclusive<u64>,
/// The number of accounts to be generated
pub accounts: usize,
/// The range of transactions to be generated per block.
pub txs: Range<u8>,
}
#[cfg(any(test, feature = "test-utils"))]
impl AccountHashingStage {
/// Initializes the `PlainAccountState` table with `num_accounts` having some random state
@@ -144,6 +113,16 @@ impl AccountHashingStage {
}
}
impl Default for AccountHashingStage {
fn default() -> Self {
Self {
clean_threshold: 500_000,
commit_threshold: 100_000,
etl_config: EtlConfig::default(),
}
}
}
impl<DB: Database> Stage<DB> for AccountHashingStage {
/// Return the id of the stage
fn id(&self) -> StageId {
@@ -280,6 +259,27 @@ fn collect(
Ok(())
}
// TODO: Rewrite this
/// `SeedOpts` provides configuration parameters for calling `AccountHashingStage::seed`
/// in unit tests or benchmarks to generate an initial database state for running the
/// stage.
///
/// In order to check the "full hashing" mode of the stage you want to generate more
/// transitions than `AccountHashingStage.clean_threshold`. This requires:
/// 1. Creating enough blocks so there's enough transactions to generate the required transition
/// keys in the `BlockTransitionIndex` (which depends on the `TxTransitionIndex` internally)
/// 2. Setting `blocks.len() > clean_threshold` so that there's enough diffs to actually take the
/// 2nd codepath
#[derive(Clone, Debug)]
pub struct SeedOpts {
/// The range of blocks to be generated
pub blocks: RangeInclusive<u64>,
/// The number of accounts to be generated
pub accounts: usize,
/// The range of transactions to be generated per block.
pub txs: Range<u8>,
}
fn stage_checkpoint_progress<DB: Database>(
provider: &DatabaseProviderRW<DB>,
) -> ProviderResult<EntitiesCheckpoint> {