Skip to content

Commit

Permalink
tiny blobs pruner fix (Consensys#8854)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr authored Nov 27, 2024
1 parent e24934d commit d5528fa
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<SpecConfigDeneb> 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);
Expand Down

0 comments on commit d5528fa

Please sign in to comment.