From 1d8255a21b016d8910743b52dcd85ee8adae7dd8 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Mon, 25 Mar 2024 17:14:07 +0100 Subject: [PATCH] add error log (#8135) --- .../BlockBlobSidecarsTrackersPoolImpl.java | 7 +++++ ...BlockBlobSidecarsTrackersPoolImplTest.java | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImpl.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImpl.java index 00e70803a42..e1e92ecf747 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImpl.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImpl.java @@ -272,6 +272,13 @@ public synchronized void onCompletedBlockAndBlobSidecars( totalBlobSidecars += (int) addedBlobs; sizeGauge.set(totalBlobSidecars, GAUGE_BLOB_SIDECARS_LABEL); + if (!blobSidecarsTracker.isCompleted()) { + LOG.error( + "Tracker for block {} is supposed to be completed but it is not. Missing blob sidecars: {}", + block.toLogString(), + blobSidecarsTracker.getMissingBlobSidecars().count()); + } + if (orderedBlobSidecarsTrackers.add(slotAndBlockRoot)) { sizeGauge.set(orderedBlobSidecarsTrackers.size(), GAUGE_BLOB_SIDECARS_TRACKERS_LABEL); } diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImplTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImplTest.java index 5cbeba193c8..5cefab43d43 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImplTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlockBlobSidecarsTrackersPoolImplTest.java @@ -40,6 +40,7 @@ import org.hyperledger.besu.metrics.prometheus.PrometheusMetricsSystem; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import tech.pegasys.infrastructure.logging.LogCaptor; import tech.pegasys.teku.infrastructure.async.StubAsyncRunner; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; import tech.pegasys.teku.infrastructure.time.StubTimeProvider; @@ -227,6 +228,31 @@ public void onNewBlock_shouldIgnorePreDenebBlocks() { assertBlobSidecarsTrackersCount(0); } + @Test + public void onCompletedBlockAndBlobSidecars_shouldLogWarningWhenNotCompleted() { + try (final LogCaptor logCaptor = LogCaptor.forClass(BlockBlobSidecarsTrackersPoolImpl.class)) { + final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(currentSlot); + final int expectedBlobs = + block + .getMessage() + .getBody() + .toVersionDeneb() + .orElseThrow() + .getBlobKzgCommitments() + .size(); + + assertThat(expectedBlobs).isGreaterThan(0); + + blockBlobSidecarsTrackersPool.onCompletedBlockAndBlobSidecars(block, List.of()); + + logCaptor.assertErrorLog( + "Tracker for block " + + block.toLogString() + + " is supposed to be completed but it is not. Missing blob sidecars: " + + expectedBlobs); + } + } + @Test public void onNewBlobSidecarOnNewBlock_addTrackerWithBothBlockAndBlobSidecar() { final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(currentSlot);