From 263e4c862ef713a07dbdd0cb323c7361086564d6 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Wed, 15 Nov 2023 19:53:45 +0100 Subject: [PATCH] fix rebase (#7711) avoid creating tracker for known blocks --- .../statetransition/util/BlobSidecarPoolImpl.java | 14 +++++++++++++- .../util/BlobSidecarPoolImplTest.java | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java index 0617148db21..16be6c60d5f 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java @@ -168,6 +168,9 @@ public synchronized void onNewBlock(final SignedBeaconBlock block) { if (block.getMessage().getBody().toVersionDeneb().isEmpty()) { return; } + if (recentChainData.containsBlock(block.getRoot())) { + return; + } if (shouldIgnoreItemAtSlot(block.getSlot())) { return; } @@ -195,6 +198,9 @@ public void onCompletedBlockAndBlobSidecarsOld( @Override public synchronized void onCompletedBlockAndBlobSidecars( final SignedBeaconBlock block, final List blobSidecars) { + if (recentChainData.containsBlock(block.getRoot())) { + return; + } final SlotAndBlockRoot slotAndBlockRoot = block.getSlotAndBlockRoot(); final BlockBlobSidecarsTracker blobSidecarsTracker = @@ -247,7 +253,13 @@ BlockBlobSidecarsTracker getBlobSidecarsTracker(final SlotAndBlockRoot slotAndBl public void onSlot(final UInt64 slot) { super.onSlot(slot); - LOG.trace("Trackers: {}", blockBlobSidecarsTrackers); + LOG.trace( + "Trackers: {}", + () -> { + synchronized (this) { + return blockBlobSidecarsTrackers.toString(); + } + }); } @VisibleForTesting diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java index aaf7d6b1b4f..561dfc90bc7 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java @@ -186,7 +186,8 @@ public void onNewBlock_shouldIgnorePreDenebBlocks() { } @Test - public void onNewBlobSidecar_shouldIgnoreBlobsForAlreadyImportedBlocks() { + public void + onNewBlobSidecar_onNewBlock_onCompletedBlockAndBlobSidecars_shouldIgnoreAlreadyImportedBlocks() { final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(currentSlot); final BlobSidecar blobSidecar = dataStructureUtil @@ -197,6 +198,8 @@ public void onNewBlobSidecar_shouldIgnoreBlobsForAlreadyImportedBlocks() { when(recentChainData.containsBlock(blobSidecar.getBlockRoot())).thenReturn(true); blobSidecarPool.onNewBlobSidecar(blobSidecar); + blobSidecarPool.onNewBlock(block); + blobSidecarPool.onCompletedBlockAndBlobSidecars(block, List.of(blobSidecar)); assertThat(blobSidecarPool.containsBlock(block.getRoot())).isFalse(); assertThat(requiredBlockRootEvents).isEmpty();