fixup! Allow user to set an epoch margin for pruning

This commit is contained in:
Emilia Hane 2023-01-20 18:42:57 +01:00
parent 1812301c9c
commit 4de523fb75
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA

View File

@ -1780,9 +1780,22 @@ 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
}
};
if !force {
if last_pruned_epoch.as_u64() + self.get_config().epochs_per_blob_prune
> data_availability_boundary.as_u64()
> end_epoch.as_u64()
{
info!(self.log, "Blobs sidecars are pruned");
return Ok(());
@ -1798,20 +1811,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
let mut ops = vec![];
let mut last_pruned_block_root = None;
// At most prune up until the data availability boundary epoch, leaving at least blobs in
// the data availability boundary epoch and younger.
let end_slot = {
let earliest_prunable_epoch = data_availability_boundary - 1;
// Stop pruning before reaching the data availability boundary if a margin is
// configured.
let end_epoch = if let Some(margin) = self.get_config().blob_prune_margin_epochs {
earliest_prunable_epoch - margin
} else {
earliest_prunable_epoch
};
end_epoch.end_slot(E::slots_per_epoch())
};
let end_slot = end_epoch.end_slot(E::slots_per_epoch());
for res in self.forwards_block_roots_iterator_until(
oldest_blob_slot,