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

prune_config no longer returns an optional value #10784

Closed
mattsse opened this issue Sep 9, 2024 · 1 comment
Closed

prune_config no longer returns an optional value #10784

mattsse opened this issue Sep 9, 2024 · 1 comment
Assignees
Labels
A-cli Related to the reth CLI C-bug An unexpected or incorrect behavior C-enhancement New feature or request

Comments

@mattsse
Copy link
Collaborator

mattsse commented Sep 9, 2024

Describe the feature

in #10639 additional prune cli args were introduced and the return value of

/// Returns pruning configuration.
pub fn prune_config(&self, chain_spec: &ChainSpec) -> Option<PruneConfig> {
// Initialise with a default prune configuration.
let mut config = PruneConfig::default();
// If --full is set, use full node defaults.
if self.full {
config = PruneConfig {
block_interval: 5,
segments: PruneModes {
sender_recovery: Some(PruneMode::Full),
transaction_lookup: None,
// prune all receipts if chain doesn't have deposit contract specified in chain
// spec
receipts: chain_spec
.deposit_contract
.as_ref()
.map(|contract| PruneMode::Before(contract.block))
.or(Some(PruneMode::Distance(MINIMUM_PRUNING_DISTANCE))),
account_history: Some(PruneMode::Distance(MINIMUM_PRUNING_DISTANCE)),
storage_history: Some(PruneMode::Distance(MINIMUM_PRUNING_DISTANCE)),
receipts_log_filter: ReceiptsLogPruneConfig(
chain_spec
.deposit_contract
.as_ref()
.map(|contract| (contract.address, PruneMode::Before(contract.block)))
.into_iter()
.collect(),
),
},
}
}
// Override with any explicitly set prune.* flags.
if let Some(mode) = self.sender_recovery_prune_mode() {
config.segments.sender_recovery = Some(mode);
}
if let Some(mode) = self.transaction_lookup_prune_mode() {
config.segments.transaction_lookup = Some(mode);
}
if let Some(mode) = self.receipts_prune_mode() {
config.segments.receipts = Some(mode);
}
if let Some(mode) = self.account_history_prune_mode() {
config.segments.account_history = Some(mode);
}
if let Some(mode) = self.storage_history_prune_mode() {
config.segments.storage_history = Some(mode);
}
Some(config)
}

was changed, this now no longer returns an optional value

this should remain an option because None is equivalent to "no pruning == archive"

Additional context

imo we can require the full flag for all of these, and return none if no full is set
this shouldn't impact #10774

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled C-bug An unexpected or incorrect behavior and removed S-needs-triage This issue needs to be labelled labels Sep 9, 2024
@mattsse mattsse added the A-cli Related to the reth CLI label Sep 9, 2024
@emhane
Copy link
Member

emhane commented Sep 9, 2024

I don't see the issue, this is exactly what the node builder does - it will end up being the default PruneConfig, same thing method in description returns.

let mut pruner_builder = ctx.pruner_builder();

/// Returns an initialized [`PrunerBuilder`] based on the configured [`PruneConfig`]
pub fn pruner_builder(&self) -> PrunerBuilder {
PrunerBuilder::new(self.prune_config().unwrap_or_default())
.delete_limit(self.chain_spec().prune_delete_limit)
.timeout(PrunerBuilder::DEFAULT_TIMEOUT)
}

@mattsse mattsse closed this as completed Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Related to the reth CLI C-bug An unexpected or incorrect behavior C-enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants