Skip to content

Commit

Permalink
fix rebase (Consensys#7711)
Browse files Browse the repository at this point in the history
avoid creating tracker for known blocks
  • Loading branch information
tbenr authored Nov 15, 2023
1 parent 8903e0d commit 263e4c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -195,6 +198,9 @@ public void onCompletedBlockAndBlobSidecarsOld(
@Override
public synchronized void onCompletedBlockAndBlobSidecars(
final SignedBeaconBlock block, final List<BlobSidecar> blobSidecars) {
if (recentChainData.containsBlock(block.getRoot())) {
return;
}
final SlotAndBlockRoot slotAndBlockRoot = block.getSlotAndBlockRoot();

final BlockBlobSidecarsTracker blobSidecarsTracker =
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit 263e4c8

Please sign in to comment.