Skip to content

Commit 1809daf

Browse files
committed
Improve DasSamplerBasic check as recentChainData.contains doesn't mean we should drop in Gloas
1 parent 297b55e commit 1809daf

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,19 @@ public void onSlot(final UInt64 slot) {
255255
.values()
256256
.removeIf(
257257
tracker -> {
258-
if (tracker.slot().isLessThan(firstNonFinalizedSlot)
259-
|| recentChainData.containsBlock(tracker.blockRoot())) {
258+
final boolean isCleanupDue;
259+
if (tracker.slot().isLessThan(firstNonFinalizedSlot)) {
260+
isCleanupDue = true;
261+
} else {
262+
final boolean blockImported = recentChainData.containsBlock(tracker.blockRoot());
263+
final boolean isDataAvailabilityDeferred =
264+
spec.atSlot(tracker.slot())
265+
.getForkChoiceUtil()
266+
.isDataAvailabilityCheckDeferredToExecutionPayloadEnvelope();
267+
isCleanupDue = blockImported && !isDataAvailabilityDeferred;
268+
}
269+
270+
if (isCleanupDue) {
260271
// Outdated
261272
if (!tracker.completionFuture().isDone()) {
262273
// make sure the future releases any pending waiters

ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasicTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,36 @@ void onBlockImported_shouldRetainTrackerWhenDataAvailabilityDeferredToExecutionP
563563
.doesNotContainKey(blockWithBlobs.getRoot());
564564
}
565565

566+
@Test
567+
void onSlot_shouldRetainGloasImportedBlockTrackerUntilExecutionPayloadImported() {
568+
final DasSamplerBasic gloasSampler = createGloasSampler();
569+
final SignedBeaconBlock blockWithBlobs =
570+
dataStructureUtil.randomSignedBeaconBlockWithCommitments(UInt64.ONE, 1);
571+
when(rpcFetchDelayProvider.calculate(blockWithBlobs.getSlot())).thenReturn(Duration.ZERO);
572+
when(recentChainData.getFinalizedEpoch()).thenReturn(UInt64.ZERO);
573+
when(recentChainData.containsBlock(blockWithBlobs.getRoot())).thenReturn(true);
574+
575+
gloasSampler.onNewBlock(blockWithBlobs, Optional.of(RemoteOrigin.GOSSIP));
576+
final SafeFuture<List<UInt64>> completionFuture =
577+
gloasSampler
578+
.getRecentlySampledColumnsByRoot()
579+
.get(blockWithBlobs.getRoot())
580+
.completionFuture();
581+
582+
gloasSampler.onSlot(UInt64.valueOf(2));
583+
584+
assertThat(gloasSampler.getRecentlySampledColumnsByRoot())
585+
.containsKey(blockWithBlobs.getRoot());
586+
assertThat(completionFuture).isNotDone();
587+
588+
// Data availability is deferred to the payload, so the tracker is pruned now.
589+
gloasSampler.onExecutionPayloadImported(blockWithBlobs.getSlotAndBlockRoot());
590+
591+
assertThat(gloasSampler.getRecentlySampledColumnsByRoot())
592+
.doesNotContainKey(blockWithBlobs.getRoot());
593+
assertThat(completionFuture).isCancelled();
594+
}
595+
566596
@Test
567597
void enableBlockImportOnCompletion_shouldImportOnlyOnceWhenCalledMultipleTimes() {
568598
final SignedBeaconBlock blockWithBlobs =

0 commit comments

Comments
 (0)