Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/fork-choice/src/forkChoice/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export enum InvalidAttestationCode {
* The attestation data index is invalid for a Gloas block (must be 0 or 1).
*/
INVALID_DATA_INDEX = "INVALID_DATA_INDEX",
/**
* Attestation index=1 (full node) but the payload is not known/available.
*/
UNKNOWN_PAYLOAD_STATUS = "UNKNOWN_PAYLOAD_STATUS",
}

export type InvalidAttestation =
Expand All @@ -69,7 +73,8 @@ export type InvalidAttestation =
| {code: InvalidAttestationCode.INVALID_TARGET; attestation: RootHex; local: RootHex}
| {code: InvalidAttestationCode.ATTESTS_TO_FUTURE_BLOCK; block: Slot; attestation: Slot}
| {code: InvalidAttestationCode.FUTURE_SLOT; attestationSlot: Slot; latestPermissibleSlot: Slot}
| {code: InvalidAttestationCode.INVALID_DATA_INDEX; index: number};
| {code: InvalidAttestationCode.INVALID_DATA_INDEX; index: number}
| {code: InvalidAttestationCode.UNKNOWN_PAYLOAD_STATUS; beaconBlockRoot: RootHex};

export enum ForkChoiceErrorCode {
INVALID_ATTESTATION = "FORKCHOICE_ERROR_INVALID_ATTESTATION",
Expand Down
16 changes: 16 additions & 0 deletions packages/fork-choice/src/forkChoice/forkChoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,22 @@ export class ForkChoice implements IForkChoice {
});
}

// [New in Gloas:EIP7732]
// If attesting for a full node (index=1), the payload must be known (locally available)
// Spec: gloas/fork-choice.md#modified-validate_on_attestation
if (isGloasBlock(block) && attestationData.index === 1) {
const fullVariant = this.protoArray.getNodeIndexByRootAndStatus(beaconBlockRootHex, PayloadStatus.FULL);
if (fullVariant === undefined) {
throw new ForkChoiceError({
code: ForkChoiceErrorCode.INVALID_ATTESTATION,
err: {
code: InvalidAttestationCode.UNKNOWN_PAYLOAD_STATUS,
beaconBlockRoot: beaconBlockRootHex,
},
});
}
}

this.validatedAttestationDatas.add(attDataRoot);
}

Expand Down
Loading