Skip to content

Commit

Permalink
return empty blob sidecar list when no kzg commitments (Consensys#7640)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi authored Oct 27, 2023
1 parent 8aed71f commit 1c9b9f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,9 +106,12 @@ private SafeFuture<Optional<List<BlobSidecar>>> getBlobSidecarsForBlock(
}
final Optional<BeaconBlockBodyDeneb> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<BlobSidecar>> maybeBlobsidecars =
blobSidecarSelectorFactory
.slotSelector(blockWithEmptyCommitments.getSlot())
.getBlobSidecars(indices)
.get();
verify(client, never()).getBlobSidecars(any(SlotAndBlockRoot.class), anyList());
assertThat(maybeBlobsidecars).isPresent();
assertThat(maybeBlobsidecars.get()).isEmpty();
}

@TestTemplate
Expand Down

0 comments on commit 1c9b9f5

Please sign in to comment.