From d5528fa8a62fc343230b56701f10905394d8bbc4 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Wed, 27 Nov 2024 10:30:27 +0100 Subject: [PATCH] tiny blobs pruner fix (#8854) --- .../storage/server/pruner/BlobSidecarPruner.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/storage/src/main/java/tech/pegasys/teku/storage/server/pruner/BlobSidecarPruner.java b/storage/src/main/java/tech/pegasys/teku/storage/server/pruner/BlobSidecarPruner.java index c7d54252b42..30e7020d60e 100644 --- a/storage/src/main/java/tech/pegasys/teku/storage/server/pruner/BlobSidecarPruner.java +++ b/storage/src/main/java/tech/pegasys/teku/storage/server/pruner/BlobSidecarPruner.java @@ -32,7 +32,6 @@ import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.service.serviceutils.Service; import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.config.SpecConfigDeneb; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; import tech.pegasys.teku.storage.archive.DataArchive; @@ -149,7 +148,7 @@ private void pruneBlobsPriorToAvailabilityWindow() { final UInt64 latestPrunableSlot = getLatestPrunableSlot(currentSlot); if (latestPrunableSlot.isZero()) { - LOG.debug("Not pruning as slots to keep include genesis."); + LOG.debug("Not pruning as slots to keep include genesis or Deneb activation epoch"); return; } LOG.debug("Pruning blobs up to slot {}, limit {}", latestPrunableSlot, pruneLimit); @@ -213,10 +212,14 @@ private UInt64 getLatestPrunableSlot(final UInt64 currentSlot) { // DA_boundary: 64 // latest_prunable_slot = 31 - final SpecConfig config = spec.atSlot(currentSlot).getConfig(); - final SpecConfigDeneb specConfigDeneb = SpecConfigDeneb.required(config); + final Optional denebSpecConfig = + spec.atSlot(currentSlot).getConfig().toVersionDeneb(); + if (denebSpecConfig.isEmpty()) { + return UInt64.ZERO; + } + final long slotsToKeep = - (((long) specConfigDeneb.getEpochsStoreBlobs() + 1) + (((long) denebSpecConfig.get().getEpochsStoreBlobs() + 1) * spec.atSlot(currentSlot).getSlotsPerEpoch()) + 1; return currentSlot.minusMinZero(slotsToKeep);