diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactory.java b/data/provider/src/main/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactory.java index 18d0f4f3b19..f901afc7a87 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactory.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactory.java @@ -15,6 +15,7 @@ import static tech.pegasys.teku.spec.config.SpecConfig.GENESIS_SLOT; +import java.util.Collections; import java.util.List; import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; @@ -105,9 +106,12 @@ private SafeFuture>> getBlobSidecarsForBlock( } final Optional maybeDenebBlock = maybeBlock.get().getMessage().getBody().toVersionDeneb(); - if (maybeDenebBlock.isEmpty() || maybeDenebBlock.get().getBlobKzgCommitments().isEmpty()) { + if (maybeDenebBlock.isEmpty()) { return SafeFuture.completedFuture(Optional.empty()); } + if (maybeDenebBlock.get().getBlobKzgCommitments().isEmpty()) { + return SafeFuture.completedFuture(Optional.of(Collections.emptyList())); + } final SignedBeaconBlock block = maybeBlock.get(); return getBlobSidecars(block.getSlotAndBlockRoot(), indices); } diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactoryTest.java b/data/provider/src/test/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactoryTest.java index e274fbac4d3..bc58c027bb9 100644 --- a/data/provider/src/test/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactoryTest.java +++ b/data/provider/src/test/java/tech/pegasys/teku/api/blobselector/BlobSidecarSelectorFactoryTest.java @@ -193,11 +193,14 @@ public void shouldNotLookForBlobSidecarsWhenNoKzgCommitments() when(client.isFinalized(blockWithEmptyCommitments.getSlot())).thenReturn(false); when(client.getBlockAtSlotExact(blockWithEmptyCommitments.getSlot())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockWithEmptyCommitments))); - blobSidecarSelectorFactory - .slotSelector(blockWithEmptyCommitments.getSlot()) - .getBlobSidecars(indices) - .get(); + Optional> maybeBlobsidecars = + blobSidecarSelectorFactory + .slotSelector(blockWithEmptyCommitments.getSlot()) + .getBlobSidecars(indices) + .get(); verify(client, never()).getBlobSidecars(any(SlotAndBlockRoot.class), anyList()); + assertThat(maybeBlobsidecars).isPresent(); + assertThat(maybeBlobsidecars.get()).isEmpty(); } @TestTemplate