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
26 changes: 13 additions & 13 deletions packages/fork-choice/src/protoArray/protoArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ export class ProtoArray {
*
* Bit i = PTC member i voted payloadPresent=true (timeliness YES vote)
*/
private ptcVotes = new Map<RootHex, BitArray>();
private payloadTimelinessVotes = new Map<RootHex, BitArray>();
/**
* Blob data availability votes per block.
* Spec: gloas/fork-choice.md#modified-store (payload_data_availability_vote)
*
* Bit i = PTC member i voted blobDataAvailable=true (DA YES vote)
*/
private daVotes = new Map<RootHex, BitArray>();
private payloadDataAvailabilityVotes = new Map<RootHex, BitArray>();
/**
* Tracks which PTC members have attested at all (any payload_status).
* Without this, we cannot tell "didn't vote" (None) from "voted false" —
Expand Down Expand Up @@ -552,9 +552,9 @@ export class ProtoArray {

// Initialize PTC vote bitvectors for this block.
// Spec: gloas/fork-choice.md#modified-on_block
this.ptcVotes.set(block.blockRoot, BitArray.fromBitLen(PTC_SIZE));
this.payloadTimelinessVotes.set(block.blockRoot, BitArray.fromBitLen(PTC_SIZE));
this.ptcAttested.set(block.blockRoot, BitArray.fromBitLen(PTC_SIZE));
this.daVotes.set(block.blockRoot, BitArray.fromBitLen(PTC_SIZE));
this.payloadDataAvailabilityVotes.set(block.blockRoot, BitArray.fromBitLen(PTC_SIZE));
} else {
// Pre-Gloas: Only create FULL node (payload embedded in block)
const node: ProtoNode = {
Expand Down Expand Up @@ -682,9 +682,9 @@ export class ProtoArray {
payloadPresent: boolean,
blobDataAvailable: boolean
): void {
const votes = this.ptcVotes.get(blockRoot);
const votes = this.payloadTimelinessVotes.get(blockRoot);
const attended = this.ptcAttested.get(blockRoot);
const daVotes = this.daVotes.get(blockRoot);
const daVotes = this.payloadDataAvailabilityVotes.get(blockRoot);
if (votes === undefined || attended === undefined || daVotes === undefined) {
// Block not found or not a Gloas block, ignore
return;
Expand All @@ -701,7 +701,7 @@ export class ProtoArray {
}

getPTCVotes(blockRootHex: RootHex): BitArray | null {
const votes = this.ptcVotes.get(blockRootHex);
const votes = this.payloadTimelinessVotes.get(blockRootHex);
if (votes === undefined) {
// Block not found or not a Gloas block
return null;
Expand All @@ -714,7 +714,7 @@ export class ProtoArray {
* Spec: payload_timeliness(store, root, timely=True)
*/
isPayloadTimely(blockRoot: RootHex): boolean {
const votes = this.ptcVotes.get(blockRoot);
const votes = this.payloadTimelinessVotes.get(blockRoot);
if (votes === undefined) return false;
if (!this.hasPayload(blockRoot)) return false;
return bitCount(votes.uint8Array) > PAYLOAD_TIMELY_THRESHOLD;
Expand All @@ -724,7 +724,7 @@ export class ProtoArray {
* Spec: payload_timeliness(store, root, timely=False)
*/
isPayloadNotTimely(blockRoot: RootHex): boolean {
const votes = this.ptcVotes.get(blockRoot);
const votes = this.payloadTimelinessVotes.get(blockRoot);
const attended = this.ptcAttested.get(blockRoot);
if (votes === undefined || attended === undefined) return false;
// Spec: not verified locally → returns `not False = True`
Expand All @@ -736,7 +736,7 @@ export class ProtoArray {
* Spec: payload_data_availability(store, root, available=True)
*/
isPayloadDataAvailable(blockRoot: RootHex): boolean {
const daVotes = this.daVotes.get(blockRoot);
const daVotes = this.payloadDataAvailabilityVotes.get(blockRoot);
if (daVotes === undefined) return false;
if (!this.hasPayload(blockRoot)) return false;
return bitCount(daVotes.uint8Array) > DATA_AVAILABILITY_TIMELY_THRESHOLD;
Expand All @@ -746,7 +746,7 @@ export class ProtoArray {
* Spec: payload_data_availability(store, root, available=False)
*/
isPayloadDataNotAvailable(blockRoot: RootHex): boolean {
const daVotes = this.daVotes.get(blockRoot);
const daVotes = this.payloadDataAvailabilityVotes.get(blockRoot);
const attended = this.ptcAttested.get(blockRoot);
if (daVotes === undefined || attended === undefined) return false;
// Spec: not verified locally → returns `not False = True`
Expand Down Expand Up @@ -1205,9 +1205,9 @@ export class ProtoArray {
this.indices.delete(root);
// Prune PTC votes for this block to prevent memory leak
// Spec: gloas/fork-choice.md (implicit - finalized blocks don't need PTC votes)
this.ptcVotes.delete(root);
this.payloadTimelinessVotes.delete(root);
this.ptcAttested.delete(root);
this.daVotes.delete(root);
this.payloadDataAvailabilityVotes.delete(root);
}

// Store nodes prior to finalization
Expand Down
4 changes: 2 additions & 2 deletions packages/fork-choice/test/unit/protoArray/gloas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ describe("Gloas Fork Choice", () => {
it("DA NO votes do not pollute timeliness NO count (cross-dimension isolation)", () => {
// Every PTC member votes (payloadPresent=true, blobDataAvailable=false).
// Timeliness YES → no timeliness NO votes. DA NO → DA NO threshold tripped.
// isPayloadNotTimely must read only ptcVotes, not daVotes.
// isPayloadNotTimely must read only payloadTimelinessVotes, not payloadDataAvailabilityVotes.
makeFullBlock();
const indices = Array.from({length: PTC_SIZE}, (_, i) => i);
protoArray.notifyPtcMessages("0x02", indices, true, false);
Expand Down Expand Up @@ -893,7 +893,7 @@ describe("Gloas Fork Choice", () => {
it("timeliness NO votes do not pollute DA NO count (cross-dimension isolation)", () => {
// Every PTC member votes (payloadPresent=false, blobDataAvailable=true).
// Timeliness NO → timeliness NO threshold tripped. DA YES → no DA NO votes.
// isPayloadDataNotAvailable must read only daVotes, not ptcVotes.
// isPayloadDataNotAvailable must read only payloadDataAvailabilityVotes, not payloadTimelinessVotes.
makeFullBlock();
const indices = Array.from({length: PTC_SIZE}, (_, i) => i);
protoArray.notifyPtcMessages("0x02", indices, false, true);
Expand Down
Loading