mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
fixup! Allow user to set an epoch margin for pruning
This commit is contained in:
@@ -9,7 +9,7 @@ pub const DEFAULT_SLOTS_PER_RESTORE_POINT: u64 = 8192;
|
||||
pub const DEFAULT_BLOCK_CACHE_SIZE: usize = 5;
|
||||
pub const DEFAULT_BLOB_CACHE_SIZE: usize = 5;
|
||||
pub const DEFAULT_EPOCHS_PER_BLOB_PRUNE: u64 = 1;
|
||||
pub const DEFAULT_BLOB_PUNE_MARGIN_EPOCHS: Option<u64> = None;
|
||||
pub const DEFAULT_BLOB_PUNE_MARGIN_EPOCHS: u64 = 0;
|
||||
|
||||
/// Database configuration parameters.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -34,7 +34,7 @@ pub struct StoreConfig {
|
||||
pub epochs_per_blob_prune: u64,
|
||||
/// The margin for blob pruning in epochs. The oldest blobs are pruned up until
|
||||
/// data_availability_boundary - blob_prune_margin_epochs. Default: 0.
|
||||
pub blob_prune_margin_epochs: Option<u64>,
|
||||
pub blob_prune_margin_epochs: u64,
|
||||
}
|
||||
|
||||
/// Variant of `StoreConfig` that gets written to disk. Contains immutable configuration params.
|
||||
|
||||
@@ -1779,18 +1779,12 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
// middle of an epoch otherwise the oldest blob slot is a start slot.
|
||||
let last_pruned_epoch = oldest_blob_slot.epoch(E::slots_per_epoch()) - 1;
|
||||
|
||||
// At most prune up until the data availability boundary epoch, leaving at least blobs in
|
||||
// the data availability boundary epoch and younger.
|
||||
let end_epoch = {
|
||||
let earliest_prunable_epoch = data_availability_boundary - 1;
|
||||
// Stop pruning before reaching the data availability boundary if a margin is
|
||||
// configured.
|
||||
if let Some(margin) = self.get_config().blob_prune_margin_epochs {
|
||||
earliest_prunable_epoch - margin
|
||||
} else {
|
||||
earliest_prunable_epoch
|
||||
}
|
||||
};
|
||||
// At most prune blobs up until the data availability boundary epoch, leaving at least
|
||||
// blobs of the data availability boundary epoch and younger.
|
||||
let earliest_prunable_epoch = data_availability_boundary - 1;
|
||||
// Stop pruning before reaching the data availability boundary if a margin is configured.
|
||||
let margin_epochs = self.get_config().blob_prune_margin_epochs;
|
||||
let end_epoch = earliest_prunable_epoch - margin_epochs;
|
||||
|
||||
if !force {
|
||||
if last_pruned_epoch.as_u64() + self.get_config().epochs_per_blob_prune
|
||||
|
||||
Reference in New Issue
Block a user