diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 4f37d3088..36b29a161 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -1780,9 +1780,22 @@ impl, Cold: ItemStore> HotColdDB // 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, Cold: ItemStore> HotColdDB 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,