Skip to content
Merged
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
1 change: 1 addition & 0 deletions packages/beacon-node/src/api/impl/beacon/pool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ export function getBeaconPoolApi({

chain.forkChoice.notifyPtcMessages(
toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
payloadAttestationMessage.data.slot,
validatorCommitteeIndices,
payloadAttestationMessage.data.payloadPresent,
payloadAttestationMessage.data.blobDataAvailable
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/src/chain/blocks/importBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export async function importBlock(
if (ptcIndices.length > 0) {
this.forkChoice.notifyPtcMessages(
toRootHex(payloadAttestation.data.beaconBlockRoot),
payloadAttestation.data.slot,
ptcIndices,
payloadAttestation.data.payloadPresent,
payloadAttestation.data.blobDataAvailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
}
chain.forkChoice.notifyPtcMessages(
toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
payloadAttestationMessage.data.slot,
validationResult.validatorCommitteeIndices,
payloadAttestationMessage.data.payloadPresent,
payloadAttestationMessage.data.blobDataAvailable
Expand Down
3 changes: 2 additions & 1 deletion packages/fork-choice/src/forkChoice/forkChoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,12 @@ export class ForkChoice implements IForkChoice {
*/
notifyPtcMessages(
blockRoot: RootHex,
slot: Slot,
ptcIndices: number[],
payloadPresent: boolean,
blobDataAvailable: boolean
): void {
this.protoArray.notifyPtcMessages(blockRoot, ptcIndices, payloadPresent, blobDataAvailable);
this.protoArray.notifyPtcMessages(blockRoot, slot, ptcIndices, payloadPresent, blobDataAvailable);
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/fork-choice/src/forkChoice/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export interface IForkChoice {
*/
notifyPtcMessages(
blockRoot: RootHex,
slot: Slot,
ptcIndices: number[],
payloadPresent: boolean,
blobDataAvailable: boolean
Expand Down
8 changes: 8 additions & 0 deletions packages/fork-choice/src/protoArray/protoArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ export class ProtoArray {
*/
notifyPtcMessages(
blockRoot: RootHex,
slot: Slot,
ptcIndices: number[],
payloadPresent: boolean,
blobDataAvailable: boolean
Expand All @@ -690,6 +691,13 @@ export class ProtoArray {
return;
}

// PTC votes can only change the vote for their assigned beacon block, return early otherwise
const nodeIndex = this.getDefaultNodeIndex(blockRoot);
const node = nodeIndex !== undefined ? this.getNodeByIndex(nodeIndex) : undefined;
if (node === undefined || node.slot !== slot) {
return;
Comment on lines +697 to +698
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject slot-mismatched PTC messages before side effects

When this new branch returns for data.slot != block.slot, gossip/API validation has already treated the message as valid: validatePayloadAttestationMessage() only checks that the block root is known, verifies the signature against data.slot, and then adds the validator to seenPayloadAttesters; the API/gossip handlers also insert it into the payload-attestation pool before calling here. In the skipped-slot case the local validator API can produce exactly this shape by returning the closest prior canonical block with the current slot, so the message is then silently ignored by fork choice but still consumes the validator's per-epoch dedup and can be pooled/published. Please move this slot/root check into validation before marking seen/inserting, or make this call report that the message was ignored so callers can avoid those side effects.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

for (const ptcIndex of ptcIndices) {
if (ptcIndex < 0 || ptcIndex >= PTC_SIZE) {
throw new Error(`Invalid PTC index: ${ptcIndex}, must be 0..${PTC_SIZE - 1}`);
Expand Down
113 changes: 73 additions & 40 deletions packages/fork-choice/test/unit/protoArray/gloas.test.ts

Large diffs are not rendered by default.

Loading