diff --git a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts index 08bb33922732..c9542d1519fb 100644 --- a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts +++ b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts @@ -276,8 +276,8 @@ export async function produceBlockBody( // Apply parent payload once here as it's reused by EL prep and voluntary exit filtering below let stateAfterParentPayload: IBeaconStateViewBellatrix = currentState; // Spec: should_build_on_full(store, head). `parentBlock` is the proposer's head - // (set by chain.getProposerHead(slot)). Returns false when the PTC majority - // signalled the blob data is not available, forcing a build on EMPTY (reorg). + // (set by chain.getProposerHead(slot)). Returns false when the PTC majority signalled + // the blob data is not available or the payload was not timely, forcing a build on EMPTY (reorg). const isBuildingOnFull = this.forkChoice.shouldBuildOnFull(parentBlock, blockSlot); if (isBuildingOnFull) { parentBlockHash = currentState.latestExecutionPayloadBid.blockHash; diff --git a/packages/fork-choice/src/protoArray/protoArray.ts b/packages/fork-choice/src/protoArray/protoArray.ts index c6908c92a856..c47e1a0b6d25 100644 --- a/packages/fork-choice/src/protoArray/protoArray.ts +++ b/packages/fork-choice/src/protoArray/protoArray.ts @@ -766,7 +766,8 @@ export class ProtoArray { * Spec: should_build_on_full(store, head) * * The proposer is forced to build on the EMPTY variant (effectively reorging) - * when the PTC majority voted that the blob data is not available. + * when the PTC majority voted that the blob data is not available or that the + * payload was not timely. */ shouldBuildOnFull(head: ProtoBlock, slot: Slot): boolean { if (head.payloadStatus === PayloadStatus.PENDING) { @@ -774,11 +775,14 @@ export class ProtoArray { } if (head.payloadStatus === PayloadStatus.EMPTY) return false; - // The PTC data availability view is only consulted for a head from the previous slot. - // For an earlier head the empty/full variant has already been resolved by weight in getHead. + // The PTC data availability and timeliness views are only consulted for a head from the + // previous slot. For an earlier head the empty/full variant has already been resolved by + // weight in getHead. if (head.slot + 1 !== slot) return true; - return !this.isPayloadDataNotAvailable(head.blockRoot); + if (this.isPayloadDataNotAvailable(head.blockRoot)) return false; + + return !this.isPayloadNotTimely(head.blockRoot); } /** diff --git a/packages/fork-choice/test/unit/protoArray/gloas.test.ts b/packages/fork-choice/test/unit/protoArray/gloas.test.ts index 677027b559b2..9a737eddce77 100644 --- a/packages/fork-choice/test/unit/protoArray/gloas.test.ts +++ b/packages/fork-choice/test/unit/protoArray/gloas.test.ts @@ -1048,6 +1048,23 @@ describe("Gloas Fork Choice", () => { expect(protoArray.shouldBuildOnFull(head, head.slot + 1)).toBe(true); }); + it("returns false when head is FULL, data available but timeliness NO votes exceed threshold (late payload reorg)", () => { + const head = makeHead(PayloadStatus.FULL); + const overThreshold = Math.floor(PTC_SIZE / 2) + 1; + const indices = Array.from({length: overThreshold}, (_, i) => i); + // payloadPresent=false (untimely), blobDataAvailable=true (data available) + protoArray.notifyPtcMessages("0x02", head.slot, indices, false, true); + expect(protoArray.shouldBuildOnFull(head, head.slot + 1)).toBe(false); + }); + + it("returns true when head is FULL and timeliness NO votes exactly at threshold (>, not >=)", () => { + const head = makeHead(PayloadStatus.FULL); + const atThreshold = Math.floor(PTC_SIZE / 2); + const indices = Array.from({length: atThreshold}, (_, i) => i); + protoArray.notifyPtcMessages("0x02", head.slot, indices, false, true); + expect(protoArray.shouldBuildOnFull(head, head.slot + 1)).toBe(true); + }); + it("returns true for a FULL head that is not from the previous slot, even with PTC voting against it", () => { const head = makeHead(PayloadStatus.FULL); const overThreshold = Math.floor(PTC_SIZE / 2) + 1;