@lodestar/fork-choice 1.45.0-dev.c6b2b7f1ba → 1.45.0-dev.d16fa2b13a
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/data.d.ts.map +1 -1
- package/lib/forkChoice/fastConfirmation/data.js +1 -0
- package/lib/forkChoice/fastConfirmation/data.js.map +1 -1
- package/lib/forkChoice/fastConfirmation/types.d.ts +3 -0
- package/lib/forkChoice/fastConfirmation/types.d.ts.map +1 -1
- package/lib/forkChoice/fastConfirmation/types.js.map +1 -1
- package/lib/forkChoice/fastConfirmation/utils.d.ts +3 -3
- package/lib/forkChoice/fastConfirmation/utils.d.ts.map +1 -1
- package/lib/forkChoice/fastConfirmation/utils.js +27 -19
- package/lib/forkChoice/fastConfirmation/utils.js.map +1 -1
- package/lib/forkChoice/forkChoice.d.ts +11 -7
- package/lib/forkChoice/forkChoice.d.ts.map +1 -1
- package/lib/forkChoice/forkChoice.js +27 -24
- package/lib/forkChoice/forkChoice.js.map +1 -1
- package/lib/forkChoice/interface.d.ts +14 -6
- package/lib/forkChoice/interface.d.ts.map +1 -1
- package/lib/forkChoice/interface.js +1 -1
- package/lib/forkChoice/interface.js.map +1 -1
- package/lib/protoArray/computeDeltas.d.ts.map +1 -1
- package/lib/protoArray/computeDeltas.js +19 -15
- package/lib/protoArray/computeDeltas.js.map +1 -1
- package/lib/protoArray/protoArray.d.ts +14 -1
- package/lib/protoArray/protoArray.d.ts.map +1 -1
- package/lib/protoArray/protoArray.js +34 -5
- package/lib/protoArray/protoArray.js.map +1 -1
- package/package.json +8 -8
- package/src/forkChoice/fastConfirmation/data.ts +1 -0
- package/src/forkChoice/fastConfirmation/types.ts +4 -0
- package/src/forkChoice/fastConfirmation/utils.ts +39 -16
- package/src/forkChoice/forkChoice.ts +28 -25
- package/src/forkChoice/interface.ts +11 -16
- package/src/protoArray/computeDeltas.ts +21 -17
- package/src/protoArray/protoArray.ts +37 -5
|
@@ -672,6 +672,28 @@ export class ProtoArray {
|
|
|
672
672
|
this.maybeUpdateBestChildAndDescendant(pendingIndex, fullIndex, currentSlot, proposerBoostRoot);
|
|
673
673
|
}
|
|
674
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Count gloas blocks with fromSlot <= slot <= toSlot and how many of them have a revealed
|
|
677
|
+
* payload (FULL variant exists). Used by the builder circuit breaker.
|
|
678
|
+
*/
|
|
679
|
+
getPayloadRevealCounts(fromSlot: Slot, toSlot: Slot): {blocksPresent: number; payloadsRevealed: number} {
|
|
680
|
+
let blocksPresent = 0;
|
|
681
|
+
let payloadsRevealed = 0;
|
|
682
|
+
// Full scan, nodes are in import order not slot order (an old block can be imported after newer
|
|
683
|
+
// ones during sync or reorg resolution), so we cannot stop early on an out-of-window slot
|
|
684
|
+
for (const node of this.nodes) {
|
|
685
|
+
// Count each gloas block once via its PENDING variant, pre-gloas nodes are FULL only
|
|
686
|
+
if (node.slot < fromSlot || node.slot > toSlot || node.payloadStatus !== PayloadStatus.PENDING) {
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
blocksPresent++;
|
|
690
|
+
if (this.hasPayload(node.blockRoot)) {
|
|
691
|
+
payloadsRevealed++;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return {blocksPresent, payloadsRevealed};
|
|
695
|
+
}
|
|
696
|
+
|
|
675
697
|
/**
|
|
676
698
|
* Update PTC votes for multiple validators attesting to a block
|
|
677
699
|
* Spec: gloas/fork-choice.md#new-notify_ptc_messages
|
|
@@ -1584,7 +1606,7 @@ export class ProtoArray {
|
|
|
1584
1606
|
* ### Specification
|
|
1585
1607
|
*
|
|
1586
1608
|
* Modified for Gloas to return node identifier instead of just root:
|
|
1587
|
-
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.
|
|
1609
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.11/specs/gloas/fork-choice.md#modified-get_ancestor
|
|
1588
1610
|
*
|
|
1589
1611
|
* Pre-Gloas: Returns (root, PAYLOAD_STATUS_FULL)
|
|
1590
1612
|
* Gloas: Returns (root, payloadStatus) based on actual node state
|
|
@@ -1941,6 +1963,11 @@ export class ProtoArray {
|
|
|
1941
1963
|
* Returns `true` if the `descendantRoot` has an ancestor with `ancestorRoot`.
|
|
1942
1964
|
* Always returns `false` if either input roots are unknown.
|
|
1943
1965
|
* Still returns `true` if `ancestorRoot` === `descendantRoot` and payload statuses match.
|
|
1966
|
+
*
|
|
1967
|
+
* Gloas payload-status matching: a `PENDING` ancestor matches any payload variant
|
|
1968
|
+
* (PENDING/EMPTY/FULL) of the same block, so this can also return `true` for the same
|
|
1969
|
+
* root when statuses differ (e.g. ancestor `PENDING`, descendant `EMPTY`/`FULL`).
|
|
1970
|
+
* `EMPTY` and `FULL` are mutually exclusive siblings and never match each other.
|
|
1944
1971
|
*/
|
|
1945
1972
|
isDescendant(
|
|
1946
1973
|
ancestorRoot: RootHex,
|
|
@@ -1958,11 +1985,16 @@ export class ProtoArray {
|
|
|
1958
1985
|
}
|
|
1959
1986
|
|
|
1960
1987
|
for (const node of this.iterateAncestorNodes(descendantRoot, descendantPayloadStatus)) {
|
|
1961
|
-
if (node.
|
|
1962
|
-
|
|
1988
|
+
if (node.blockRoot === ancestorNode.blockRoot) {
|
|
1989
|
+
// Gloas is_ancestor: a PENDING ancestor matches any payload variant of the same block.
|
|
1990
|
+
return (
|
|
1991
|
+
node.payloadStatus === ancestorNode.payloadStatus || ancestorNode.payloadStatus === PayloadStatus.PENDING
|
|
1992
|
+
);
|
|
1963
1993
|
}
|
|
1964
|
-
|
|
1965
|
-
|
|
1994
|
+
// Ancestors are iterated in decreasing slot, so once we reach the ancestor's slot
|
|
1995
|
+
// without a root match it cannot be in this chain.
|
|
1996
|
+
if (node.slot <= ancestorNode.slot) {
|
|
1997
|
+
return false;
|
|
1966
1998
|
}
|
|
1967
1999
|
}
|
|
1968
2000
|
return false;
|