Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions packages/fork-choice/src/protoArray/protoArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ 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)
Expand Down Expand Up @@ -552,7 +552,7 @@ 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));
Comment thread
nflaig marked this conversation as resolved.
Resolved
this.daVotes.set(block.blockRoot, BitArray.fromBitLen(PTC_SIZE));
} else {
Expand Down Expand Up @@ -682,7 +682,7 @@ 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);
if (votes === undefined || attended === undefined || daVotes === undefined) {
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 Down Expand Up @@ -1205,7 +1205,7 @@ 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);
}
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 daVotes.
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 daVotes, not payloadTimelinessVotes.
makeFullBlock();
const indices = Array.from({length: PTC_SIZE}, (_, i) => i);
protoArray.notifyPtcMessages("0x02", indices, false, true);
Expand Down
Loading