@lodestar/fork-choice 1.50.0-dev.fd4f342a40 → 1.50.0-dev.fda8006fc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/forkChoice/fastConfirmation/types.d.ts +3 -1
- package/lib/forkChoice/fastConfirmation/types.d.ts.map +1 -1
- package/lib/forkChoice/fastConfirmation/utils.d.ts +2 -2
- package/lib/forkChoice/fastConfirmation/utils.d.ts.map +1 -1
- package/lib/forkChoice/fastConfirmation/utils.js +8 -3
- package/lib/forkChoice/fastConfirmation/utils.js.map +1 -1
- package/lib/forkChoice/forkChoice.d.ts +2 -1
- package/lib/forkChoice/forkChoice.d.ts.map +1 -1
- package/lib/forkChoice/forkChoice.js +36 -3
- package/lib/forkChoice/forkChoice.js.map +1 -1
- package/lib/forkChoice/interface.d.ts +9 -1
- package/lib/forkChoice/interface.d.ts.map +1 -1
- package/lib/forkChoice/interface.js.map +1 -1
- package/lib/forkChoice/store.d.ts +4 -1
- package/lib/forkChoice/store.d.ts.map +1 -1
- package/lib/forkChoice/store.js +3 -0
- package/lib/forkChoice/store.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics.d.ts +3 -0
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +5 -0
- package/lib/metrics.js.map +1 -1
- package/lib/protoArray/interface.d.ts +15 -0
- package/lib/protoArray/interface.d.ts.map +1 -1
- package/lib/protoArray/interface.js +13 -0
- package/lib/protoArray/interface.js.map +1 -1
- package/lib/protoArray/protoArray.d.ts +6 -1
- package/lib/protoArray/protoArray.d.ts.map +1 -1
- package/lib/protoArray/protoArray.js +23 -0
- package/lib/protoArray/protoArray.js.map +1 -1
- package/package.json +7 -7
- package/src/forkChoice/fastConfirmation/types.ts +3 -2
- package/src/forkChoice/fastConfirmation/utils.ts +12 -5
- package/src/forkChoice/forkChoice.ts +37 -2
- package/src/forkChoice/interface.ts +6 -0
- package/src/forkChoice/store.ts +7 -1
- package/src/index.ts +3 -1
- package/src/metrics.ts +5 -0
- package/src/protoArray/interface.ts +21 -0
- package/src/protoArray/protoArray.ts +24 -0
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
PayloadStatus,
|
|
14
14
|
ProtoBlock,
|
|
15
15
|
ProtoNode,
|
|
16
|
+
PtcQuorum,
|
|
16
17
|
isGloasBlock,
|
|
17
18
|
} from "./interface.js";
|
|
18
19
|
|
|
@@ -52,6 +53,12 @@ export function countNoVotes(attended: BitArray, yes: BitArray): number {
|
|
|
52
53
|
return count;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
function majorityVote(attended: BitArray, yes: BitArray, threshold: number): boolean | null {
|
|
57
|
+
if (bitCount(yes.uint8Array) > threshold) return true;
|
|
58
|
+
if (countNoVotes(attended, yes) > threshold) return false;
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
export const DEFAULT_PRUNE_THRESHOLD = 0;
|
|
56
63
|
type ProposerBoost = {root: RootHex; score: bigint};
|
|
57
64
|
|
|
@@ -801,6 +808,23 @@ export class ProtoArray {
|
|
|
801
808
|
};
|
|
802
809
|
}
|
|
803
810
|
|
|
811
|
+
/**
|
|
812
|
+
* PTC majority per vote field from the raw tallies, regardless of whether the payload is locally
|
|
813
|
+
* available. Returns `null` for pre-Gloas (or pruned) roots, which have no vote maps.
|
|
814
|
+
*/
|
|
815
|
+
getPtcQuorum(blockRoot: RootHex): PtcQuorum | null {
|
|
816
|
+
const attended = this.ptcAttested.get(blockRoot);
|
|
817
|
+
const timelinessVotes = this.payloadTimelinessVotes.get(blockRoot);
|
|
818
|
+
const daVotes = this.payloadDataAvailabilityVotes.get(blockRoot);
|
|
819
|
+
if (attended === undefined || timelinessVotes === undefined || daVotes === undefined) {
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
return {
|
|
823
|
+
payloadPresent: majorityVote(attended, timelinessVotes, PAYLOAD_TIMELY_THRESHOLD),
|
|
824
|
+
blobDataAvailable: majorityVote(attended, daVotes, DATA_AVAILABILITY_TIMELY_THRESHOLD),
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
|
|
804
828
|
getPreviousProposerBoostRoot(): RootHex {
|
|
805
829
|
return this.previousProposerBoost?.root ?? HEX_ZERO_HASH;
|
|
806
830
|
}
|