@lodestar/fork-choice 1.45.0-dev.f535421f29 → 1.45.0-dev.f6c521a123
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/metrics.d.ts +1 -0
- package/lib/forkChoice/fastConfirmation/metrics.d.ts.map +1 -1
- package/lib/forkChoice/fastConfirmation/metrics.js +4 -0
- package/lib/forkChoice/fastConfirmation/metrics.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 +46 -7
- package/lib/forkChoice/forkChoice.d.ts.map +1 -1
- package/lib/forkChoice/forkChoice.js +171 -50
- package/lib/forkChoice/forkChoice.js.map +1 -1
- package/lib/forkChoice/interface.d.ts +15 -3
- 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/index.d.ts +1 -1
- 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 +1 -0
- package/lib/metrics.d.ts.map +1 -1
- package/lib/protoArray/computeDeltas.d.ts +3 -3
- package/lib/protoArray/computeDeltas.d.ts.map +1 -1
- package/lib/protoArray/computeDeltas.js +31 -27
- package/lib/protoArray/computeDeltas.js.map +1 -1
- package/lib/protoArray/interface.d.ts +6 -0
- package/lib/protoArray/interface.d.ts.map +1 -1
- package/lib/protoArray/protoArray.d.ts +27 -2
- package/lib/protoArray/protoArray.d.ts.map +1 -1
- package/lib/protoArray/protoArray.js +105 -17
- package/lib/protoArray/protoArray.js.map +1 -1
- package/package.json +9 -9
- package/src/forkChoice/fastConfirmation/data.ts +1 -0
- package/src/forkChoice/fastConfirmation/metrics.ts +4 -0
- package/src/forkChoice/fastConfirmation/types.ts +4 -0
- package/src/forkChoice/fastConfirmation/utils.ts +39 -16
- package/src/forkChoice/forkChoice.ts +186 -51
- package/src/forkChoice/interface.ts +12 -13
- package/src/index.ts +1 -1
- package/src/protoArray/computeDeltas.ts +33 -29
- package/src/protoArray/interface.ts +6 -0
- package/src/protoArray/protoArray.ts +116 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/forkChoice/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAE,0BAA0B,EAAE,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAChH,OAAO,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/forkChoice/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAE,0BAA0B,EAAE,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAChH,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,KAAK,CAA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AI,UAAU,EAAE,CAAC;IAC7C;;OAEG;IACH,yBAAyB,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC1G;;;;OAIG;IACH,sCAAsC,CAAC,SAAS,EAAE,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACzF,6BAA6B,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,EAAE,CAAC;IACjE,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE,CAAC;IAClD,mGAAmG;IACnG,sBAAsB,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,cAAc,CAAC;IACpF;;OAEG;IACH,kBAAkB,CAAC,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC;IAExD;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC;CAC5E"}
|
|
@@ -19,7 +19,7 @@ var NotReorgedReason;
|
|
|
19
19
|
NotReorgedReason["HeadBlockIsTimely"] = "headBlockIsTimely";
|
|
20
20
|
NotReorgedReason["ParentBlockNotAvailable"] = "parentBlockNotAvailable";
|
|
21
21
|
NotReorgedReason["ProposerBoostReorgDisabled"] = "proposerBoostReorgDisabled";
|
|
22
|
-
NotReorgedReason["
|
|
22
|
+
NotReorgedReason["AtEpochBoundary"] = "atEpochBoundary";
|
|
23
23
|
NotReorgedReason["NotFFGCompetitive"] = "notFFGCompetitive";
|
|
24
24
|
NotReorgedReason["ChainLongUnfinality"] = "chainLongUnfinality";
|
|
25
25
|
NotReorgedReason["ParentBlockDistanceMoreThanOneSlot"] = "parentBlockDistanceMoreThanOneSlot";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/forkChoice/interface.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/forkChoice/interface.ts"],"names":[],"mappings":"SAgCY,eAAe;AAA3B,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,2DAAW,CAAA;IACX,6DAAY,CAAA;AAAC,CACf,EAHY,eAAe,KAAf,eAAe,QAG1B;SAEW,cAAc;AAA1B,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uEAAc,CAAA;IACd,+DAAU,CAAA;IACV,6EAAiB,CAAA;IACjB,mEAAY,CAAA;AAAC,CACf,EALY,cAAc,KAAd,cAAc,QAKzB;SASW,gBAAgB;AAD5B,yCAAyC;AACzC,IAAY,gBAgBX;AAhBD,WAAY,gBAAgB;IAC1B,2DAAuC,CAAA;IACvC,uEAAmD,CAAA;IACnD,6EAAyD,CAAA;IACzD,uDAAmC,CAAA;IACnC,2DAAuC,CAAA;IACvC,+DAA2C,CAAA;IAC3C,6FAAyE,CAAA;IACzE,iEAA6C,CAAA;IAC7C,uEAAmD,CAAA;IACnD,yDAAqC,CAAA;IACrC,iEAA6C,CAAA;IAC7C,6DAAyC,CAAA;IACzC,mEAA+C,CAAA;IAC/C,mEAA+C,CAAA;IAC/C,uCAAmB,CAAA;AAAC,CAAC,EAfX,gBAAgB,KAAhB,gBAAgB,QAgB3B"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ForkChoiceError, ForkChoiceErrorCode, type InvalidAttestation, InvalidAttestationCode, type InvalidBlock, InvalidBlockCode, } from "./forkChoice/errors.js";
|
|
2
2
|
export { type FastConfirmationBalanceSource, type FastConfirmationContext, type FastConfirmationMetrics, type FastConfirmationResult, FastConfirmationRule, type ForkChoiceStateGetter, type IFastConfirmationRule, type IFastConfirmationStore, getFastConfirmationMetrics, } from "./forkChoice/fastConfirmation/fastConfirmationRule.ts";
|
|
3
|
-
export { ForkChoice, type ForkChoiceOpts, UpdateHeadOpt } from "./forkChoice/forkChoice.js";
|
|
3
|
+
export { ForkChoice, type ForkChoiceOpts, UpdateHeadOpt, getCommitteeFraction } from "./forkChoice/forkChoice.js";
|
|
4
4
|
export { type AncestorResult, AncestorStatus, type CheckpointWithBalance, type CheckpointWithTotalBalance, EpochDifference, type IForkChoice, NotReorgedReason, } from "./forkChoice/interface.js";
|
|
5
5
|
export * from "./forkChoice/safeBlocks.js";
|
|
6
6
|
export { type CheckpointWithHex, ForkChoiceStore, type IForkChoiceStore, type JustifiedBalancesGetter, } from "./forkChoice/store.js";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,sBAAsB,EACtB,KAAK,YAAY,EACjB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,0BAA0B,GAC3B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAE,KAAK,cAAc,EAAE,aAAa,EAAC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,sBAAsB,EACtB,KAAK,YAAY,EACjB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,0BAA0B,GAC3B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAE,KAAK,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AAChH,OAAO,EACL,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,eAAe,EACf,KAAK,WAAW,EAChB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EACL,KAAK,iBAAiB,EACtB,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,KAAK,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAC1E,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ForkChoiceError, ForkChoiceErrorCode, InvalidAttestationCode, InvalidBlockCode, } from "./forkChoice/errors.js";
|
|
2
2
|
export { FastConfirmationRule, getFastConfirmationMetrics, } from "./forkChoice/fastConfirmation/fastConfirmationRule.js";
|
|
3
|
-
export { ForkChoice, UpdateHeadOpt } from "./forkChoice/forkChoice.js";
|
|
3
|
+
export { ForkChoice, UpdateHeadOpt, getCommitteeFraction } from "./forkChoice/forkChoice.js";
|
|
4
4
|
export { AncestorStatus, EpochDifference, NotReorgedReason, } from "./forkChoice/interface.js";
|
|
5
5
|
export * from "./forkChoice/safeBlocks.js";
|
|
6
6
|
export { ForkChoiceStore, } from "./forkChoice/store.js";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EAEnB,sBAAsB,EAEtB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAKL,oBAAoB,EAIpB,0BAA0B,GAC3B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAuB,aAAa,EAAC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EAEnB,sBAAsB,EAEtB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAKL,oBAAoB,EAIpB,0BAA0B,GAC3B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAuB,aAAa,EAAE,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AAChH,OAAO,EAEL,cAAc,EAGd,eAAe,EAEf,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAEL,eAAe,GAGhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAyB,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAU1E,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC"}
|
package/lib/metrics.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function getForkChoiceMetrics(register: MetricsRegisterExtra): {
|
|
|
11
11
|
}>;
|
|
12
12
|
confirmedEpoch: import("@lodestar/utils").GaugeExtra<import("@lodestar/utils").NoLabels>;
|
|
13
13
|
votesTracked: import("@lodestar/utils").GaugeExtra<import("@lodestar/utils").NoLabels>;
|
|
14
|
+
paused: import("@lodestar/utils").GaugeExtra<import("@lodestar/utils").NoLabels>;
|
|
14
15
|
resets: import("@lodestar/utils").Counter<import("@lodestar/utils").NoLabels>;
|
|
15
16
|
slot: import("@lodestar/utils").GaugeExtra<import("@lodestar/utils").NoLabels>;
|
|
16
17
|
reorgs: import("@lodestar/utils").Counter<import("@lodestar/utils").NoLabels>;
|
package/lib/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAC,uBAAuB,EAA6B,MAAM,0CAA0C,CAAC;AAC7G,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG,uBAAuB,CAAC;AAElG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAC,uBAAuB,EAA6B,MAAM,0CAA0C,CAAC;AAC7G,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG,uBAAuB,CAAC;AAElG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoGlE"}
|
|
@@ -2,7 +2,7 @@ import { EffectiveBalanceIncrements } from "@lodestar/state-transition";
|
|
|
2
2
|
import { ValidatorIndex } from "@lodestar/types";
|
|
3
3
|
import { VoteIndex } from "./interface.js";
|
|
4
4
|
export type DeltasResult = {
|
|
5
|
-
|
|
5
|
+
attestationDeltas: number[];
|
|
6
6
|
equivocatingValidators: number;
|
|
7
7
|
oldInactiveValidators: number;
|
|
8
8
|
newInactiveValidators: number;
|
|
@@ -10,9 +10,9 @@ export type DeltasResult = {
|
|
|
10
10
|
newVoteValidators: number;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
* Returns a list of `
|
|
13
|
+
* Returns a list of `attestationDeltas`, where there is one delta for each of the indices in `indices`
|
|
14
14
|
*
|
|
15
|
-
* The
|
|
15
|
+
* The attestationDeltas are formed by a change between `oldBalances` and `newBalances`, and/or a change of vote in `votes`.
|
|
16
16
|
*
|
|
17
17
|
* ## Errors
|
|
18
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeDeltas.d.ts","sourceRoot":"","sources":["../../src/protoArray/computeDeltas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAkB,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAK1D,MAAM,MAAM,YAAY,GAAG;IACzB,
|
|
1
|
+
{"version":3,"file":"computeDeltas.d.ts","sourceRoot":"","sources":["../../src/protoArray/computeDeltas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAkB,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAK1D,MAAM,MAAM,YAAY,GAAG;IACzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAE/B,qBAAqB,EAAE,MAAM,CAAC;IAE9B,qBAAqB,EAAE,MAAM,CAAC;IAE9B,uBAAuB,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,SAAS,EAAE,EAC/B,eAAe,EAAE,SAAS,EAAE,EAC5B,WAAW,EAAE,0BAA0B,EACvC,WAAW,EAAE,0BAA0B,EACvC,mBAAmB,EAAE,GAAG,CAAC,cAAc,CAAC,GACvC,YAAY,CA8Hd"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ProtoArrayError, ProtoArrayErrorCode } from "./errors.js";
|
|
2
2
|
import { NULL_VOTE_INDEX } from "./interface.js";
|
|
3
3
|
// reuse arrays to avoid memory reallocation and gc
|
|
4
|
-
const
|
|
4
|
+
const attestationDeltas = new Array();
|
|
5
5
|
/**
|
|
6
|
-
* Returns a list of `
|
|
6
|
+
* Returns a list of `attestationDeltas`, where there is one delta for each of the indices in `indices`
|
|
7
7
|
*
|
|
8
|
-
* The
|
|
8
|
+
* The attestationDeltas are formed by a change between `oldBalances` and `newBalances`, and/or a change of vote in `votes`.
|
|
9
9
|
*
|
|
10
10
|
* ## Errors
|
|
11
11
|
*
|
|
@@ -19,8 +19,8 @@ export function computeDeltas(numProtoNodes, voteCurrentIndices, voteNextIndices
|
|
|
19
19
|
// this never happen in practice, but we check to be safe
|
|
20
20
|
throw new Error(`numProtoNodes must be less than NULL_VOTE_INDEX: ${numProtoNodes} >= ${NULL_VOTE_INDEX}`);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
attestationDeltas.length = numProtoNodes;
|
|
23
|
+
attestationDeltas.fill(0);
|
|
24
24
|
// avoid creating new variables in the loop to potentially reduce GC pressure
|
|
25
25
|
let oldBalance, newBalance;
|
|
26
26
|
let currentIndex, nextIndex;
|
|
@@ -36,21 +36,9 @@ export function computeDeltas(numProtoNodes, voteCurrentIndices, voteNextIndices
|
|
|
36
36
|
for (let vIndex = 0; vIndex < voteNextIndices.length; vIndex++) {
|
|
37
37
|
currentIndex = voteCurrentIndices[vIndex];
|
|
38
38
|
nextIndex = voteNextIndices[vIndex];
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
oldInactiveValidators++;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
// IF the validator was not included in the _old_ balances (i.e. it did not exist yet)
|
|
46
|
-
// then say its balance was 0
|
|
47
|
-
oldBalance = oldBalances[vIndex] ?? 0;
|
|
48
|
-
// If the validator's vote is not known in the _new_ balances, then use a balance of zero.
|
|
49
|
-
//
|
|
50
|
-
// It is possible that there was a vote for an unknown validator if we change our justified
|
|
51
|
-
// state to a new state with a higher epoch that is on a different fork because that fork may have
|
|
52
|
-
// on-boarded fewer validators than the prior fork.
|
|
53
|
-
newBalance = newBalances === oldBalances ? oldBalance : (newBalances[vIndex] ?? 0);
|
|
39
|
+
// This equivocator check MUST be the first branch in the loop body.
|
|
40
|
+
// Handle equivocating (attester-slashed) validators before the no-live-vote check so the sorted
|
|
41
|
+
// cursor always advances; a jammed cursor would skip the discount for higher-index equivocators.
|
|
54
42
|
if (vIndex === equivocatingValidatorIndex) {
|
|
55
43
|
// this function could be called multiple times but we only want to process slashing validator for 1 time
|
|
56
44
|
if (currentIndex !== NULL_VOTE_INDEX) {
|
|
@@ -60,13 +48,29 @@ export function computeDeltas(numProtoNodes, voteCurrentIndices, voteNextIndices
|
|
|
60
48
|
index: currentIndex,
|
|
61
49
|
});
|
|
62
50
|
}
|
|
63
|
-
|
|
51
|
+
oldBalance = oldBalances[vIndex] ?? 0;
|
|
52
|
+
attestationDeltas[currentIndex] -= oldBalance;
|
|
64
53
|
}
|
|
65
54
|
voteCurrentIndices[vIndex] = NULL_VOTE_INDEX;
|
|
66
55
|
equivocatingIndex++;
|
|
67
56
|
equivocatingValidatorIndex = equivocatingArray[equivocatingIndex];
|
|
68
57
|
continue;
|
|
69
58
|
}
|
|
59
|
+
// There is no need to create a score change if the validator has never voted or both of their
|
|
60
|
+
// votes are for the zero hash (genesis block)
|
|
61
|
+
if (currentIndex === NULL_VOTE_INDEX && nextIndex === NULL_VOTE_INDEX) {
|
|
62
|
+
oldInactiveValidators++;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
// IF the validator was not included in the _old_ balances (i.e. it did not exist yet)
|
|
66
|
+
// then say its balance was 0
|
|
67
|
+
oldBalance = oldBalances[vIndex] ?? 0;
|
|
68
|
+
// If the validator's vote is not known in the _new_ balances, then use a balance of zero.
|
|
69
|
+
//
|
|
70
|
+
// It is possible that there was a vote for an unknown validator if we change our justified
|
|
71
|
+
// state to a new state with a higher epoch that is on a different fork because that fork may have
|
|
72
|
+
// on-boarded fewer validators than the prior fork.
|
|
73
|
+
newBalance = newBalances === oldBalances ? oldBalance : (newBalances[vIndex] ?? 0);
|
|
70
74
|
if (oldBalance === 0 && newBalance === 0) {
|
|
71
75
|
newInactiveValidators++;
|
|
72
76
|
continue;
|
|
@@ -84,7 +88,7 @@ export function computeDeltas(numProtoNodes, voteCurrentIndices, voteNextIndices
|
|
|
84
88
|
index: currentIndex,
|
|
85
89
|
});
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
attestationDeltas[currentIndex] -= oldBalance;
|
|
88
92
|
}
|
|
89
93
|
// We ignore the vote if it is not known in `indices .
|
|
90
94
|
// We assume that it is outside of our tree (ie: pre-finalization) and therefore not interesting
|
|
@@ -95,7 +99,7 @@ export function computeDeltas(numProtoNodes, voteCurrentIndices, voteNextIndices
|
|
|
95
99
|
index: nextIndex,
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
|
-
|
|
102
|
+
attestationDeltas[nextIndex] += newBalance;
|
|
99
103
|
}
|
|
100
104
|
voteCurrentIndices[vIndex] = nextIndex;
|
|
101
105
|
newVoteValidators++;
|
|
@@ -104,12 +108,12 @@ export function computeDeltas(numProtoNodes, voteCurrentIndices, voteNextIndices
|
|
|
104
108
|
unchangedVoteValidators++;
|
|
105
109
|
}
|
|
106
110
|
} // end validator loop
|
|
107
|
-
if (
|
|
108
|
-
//
|
|
109
|
-
throw new Error(`
|
|
111
|
+
if (attestationDeltas.length !== numProtoNodes) {
|
|
112
|
+
// attestationDeltas array could be growed in the loop, especially if we mistakenly set the [NULL_VOTE_INDEX] to it , just to be safe
|
|
113
|
+
throw new Error(`attestationDeltas length mismatch: expected ${numProtoNodes}, got ${attestationDeltas.length}`);
|
|
110
114
|
}
|
|
111
115
|
return {
|
|
112
|
-
|
|
116
|
+
attestationDeltas,
|
|
113
117
|
equivocatingValidators,
|
|
114
118
|
oldInactiveValidators,
|
|
115
119
|
newInactiveValidators,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeDeltas.js","sourceRoot":"","sources":["../../src/protoArray/computeDeltas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAC,MAAM,aAAa,CAAC;AACjE,OAAO,EAAC,eAAe,EAAY,MAAM,gBAAgB,CAAC;AAE1D,mDAAmD;AACnD,MAAM,
|
|
1
|
+
{"version":3,"file":"computeDeltas.js","sourceRoot":"","sources":["../../src/protoArray/computeDeltas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAC,MAAM,aAAa,CAAC;AACjE,OAAO,EAAC,eAAe,EAAY,MAAM,gBAAgB,CAAC;AAE1D,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,IAAI,KAAK,EAAU,CAAC;AAc9C;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,aAAqB,EACrB,kBAA+B,EAC/B,eAA4B,EAC5B,WAAuC,EACvC,WAAuC,EACvC,mBAAwC,EAC1B;IACd,IAAI,kBAAkB,CAAC,MAAM,KAAK,eAAe,CAAC,MAAM,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CACb,qE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aAAa,EAAE,CAAC;oBAClC,MAAM,IAAI,eAAe,CAAC;wBACxB,IAAI,EAAE,mBAAmB,CAAC,kBAAkB;wBAC5C,KAAK,EAAE,YAAY;qBACpB,CAAC,CAAC;gBACL,CAAC;gBAED,iBAAiB,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC;YAChD,CAAC;YAED,sDAAsD;YACtD,gGAAgG;YAChG,IAAI,SAAS,KAAK,eAAe,EAAE,CAAC;gBAClC,IAAI,SAAS,IAAI,aAAa,EAAE,CAAC;oBAC/B,MAAM,IAAI,eAAe,CAAC;wBACxB,IAAI,EAAE,mBAAmB,CAAC,kBAAkB;wBAC5C,KAAK,EAAE,SAAS;qBACjB,CAAC,CAAC;gBACL,CAAC;gBAED,iBAAiB,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC;YAC7C,CAAC;YACD,kBAAkB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;YACvC,iBAAiB,EAAE,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,uBAAuB,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,qBAAqB;IAEvB,IAAI,iBAAiB,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;QAC/C,qIAAqI;QACrI,MAAM,IAAI,KAAK,CAAC,+CAA+C,aAAa,SAAS,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC;IACnH,CAAC;IAED,OAAO;QACL,iBAAiB;QACjB,sBAAsB;QACtB,qBAAqB;QACrB,qBAAqB;QACrB,uBAAuB;QACvB,iBAAiB;KAClB,CAAC;AAAA,CACH"}
|
|
@@ -120,7 +120,13 @@ export type ProtoBlock = BlockExtraMeta & {
|
|
|
120
120
|
*/
|
|
121
121
|
export type ProtoNode = ProtoBlock & {
|
|
122
122
|
parent?: number;
|
|
123
|
+
/** Total weight, ie. attestationScore plus the proposer boost credited to this node */
|
|
123
124
|
weight: number;
|
|
125
|
+
/**
|
|
126
|
+
* Weight from attester votes only, excluding proposer boost.
|
|
127
|
+
* Spec: get_attestation_score
|
|
128
|
+
*/
|
|
129
|
+
attestationScore: number;
|
|
124
130
|
bestChild?: number;
|
|
125
131
|
bestDescendant?: number;
|
|
126
132
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/protoArray/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAIhE,eAAO,MAAM,aAAa,uEAAuE,CAAC;AAElG;;;;GAIG;AACH,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;;;;;;;;;GAUG;AACH,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB;AAED;;;GAGG;AACH,oBAAY,aAAa;IACvB,OAAO,IAAI;IACX,KAAK,IAAI;IACT,IAAI,IAAI;CACT;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEvD;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE,eAAe,CAAC,KAAK,CAAC;IACvC,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,eAAe,CAAC,OAAO,CAAC;IACzC,mBAAmB,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,6BAA6B,EAAE,OAAO,CAAC;IAGvC,6BAA6B,EAAE,OAAO,CAAC;CACxC,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,eAAe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AAuF;IACvF,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
|
@@ -146,8 +146,8 @@ export declare class ProtoArray {
|
|
|
146
146
|
* should become the best child.
|
|
147
147
|
* - If required, update the parents best-descendant with the current node or its best-descendant.
|
|
148
148
|
*/
|
|
149
|
-
applyScoreChanges({
|
|
150
|
-
|
|
149
|
+
applyScoreChanges({ attestationDeltas, proposerBoost, justifiedEpoch, justifiedRoot, finalizedEpoch, finalizedRoot, currentSlot }: {
|
|
150
|
+
attestationDeltas: number[];
|
|
151
151
|
proposerBoost: ProposerBoost | null;
|
|
152
152
|
justifiedEpoch: Epoch;
|
|
153
153
|
justifiedRoot: RootHex;
|
|
@@ -169,6 +169,14 @@ export declare class ProtoArray {
|
|
|
169
169
|
* Spec: gloas/fork-choice.md (on_execution_payload event)
|
|
170
170
|
*/
|
|
171
171
|
onExecutionPayload(blockRoot: RootHex, currentSlot: Slot, executionPayloadBlockHash: RootHex, executionPayloadNumber: number, executionPayloadGasLimit: number, proposerBoostRoot: RootHex | null, executionStatus: PayloadExecutionStatus, dataAvailabilityStatus: DataAvailabilityStatus): void;
|
|
172
|
+
/**
|
|
173
|
+
* Count gloas blocks with fromSlot <= slot <= toSlot and how many of them have a revealed
|
|
174
|
+
* payload (FULL variant exists). Used by the builder circuit breaker.
|
|
175
|
+
*/
|
|
176
|
+
getPayloadRevealCounts(fromSlot: Slot, toSlot: Slot): {
|
|
177
|
+
blocksPresent: number;
|
|
178
|
+
payloadsRevealed: number;
|
|
179
|
+
};
|
|
172
180
|
/**
|
|
173
181
|
* Update PTC votes for multiple validators attesting to a block
|
|
174
182
|
* Spec: gloas/fork-choice.md#new-notify_ptc_messages
|
|
@@ -325,6 +333,12 @@ export declare class ProtoArray {
|
|
|
325
333
|
* head.
|
|
326
334
|
*/
|
|
327
335
|
nodeIsViableForHead(node: ProtoNode, currentSlot: Slot): boolean;
|
|
336
|
+
/** Weights are in EFFECTIVE_BALANCE_INCREMENT units (NOT Gwei); callers scale as needed. */
|
|
337
|
+
getViableHeads(currentSlot: Slot): {
|
|
338
|
+
root: RootHex;
|
|
339
|
+
payloadStatus: PayloadStatus;
|
|
340
|
+
weight: number;
|
|
341
|
+
}[];
|
|
328
342
|
/**
|
|
329
343
|
* Return `true` if `node` is equal to or a descendant of the finalized node.
|
|
330
344
|
* This function helps improve performance of nodeIsViableForHead a lot by avoiding
|
|
@@ -415,6 +429,12 @@ export declare class ProtoArray {
|
|
|
415
429
|
* Use getDefaultVariant() to get the canonical variant for a block.
|
|
416
430
|
*/
|
|
417
431
|
getNode(blockRoot: RootHex, payloadStatus: PayloadStatus): ProtoNode | undefined;
|
|
432
|
+
/**
|
|
433
|
+
* Return ProtoNode for the default/canonical variant in a single hash lookup
|
|
434
|
+
* - Pre-Gloas blocks: the FULL variant
|
|
435
|
+
* - Gloas blocks: the PENDING variant
|
|
436
|
+
*/
|
|
437
|
+
getNodeDefaultStatus(blockRoot: RootHex): ProtoNode | undefined;
|
|
418
438
|
/**
|
|
419
439
|
* Return MUTABLE ProtoBlock for blockRoot with explicit payload status
|
|
420
440
|
*
|
|
@@ -442,6 +462,11 @@ export declare class ProtoArray {
|
|
|
442
462
|
* Returns `true` if the `descendantRoot` has an ancestor with `ancestorRoot`.
|
|
443
463
|
* Always returns `false` if either input roots are unknown.
|
|
444
464
|
* Still returns `true` if `ancestorRoot` === `descendantRoot` and payload statuses match.
|
|
465
|
+
*
|
|
466
|
+
* Gloas payload-status matching: a `PENDING` ancestor matches any payload variant
|
|
467
|
+
* (PENDING/EMPTY/FULL) of the same block, so this can also return `true` for the same
|
|
468
|
+
* root when statuses differ (e.g. ancestor `PENDING`, descendant `EMPTY`/`FULL`).
|
|
469
|
+
* `EMPTY` and `FULL` are mutually exclusive siblings and never match each other.
|
|
445
470
|
*/
|
|
446
471
|
isDescendant(ancestorRoot: RootHex, ancestorPayloadStatus: PayloadStatus, descendantRoot: RootHex, descendantPayloadStatus: PayloadStatus): boolean;
|
|
447
472
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protoArray.d.ts","sourceRoot":"","sources":["../../src/protoArray/protoArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAC,sBAAsB,EAA8C,MAAM,4BAA4B,CAAC;AAC/G,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAC,YAAY,EAAyD,MAAM,aAAa,CAAC;AACjG,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,SAAS,EAEV,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"protoArray.d.ts","sourceRoot":"","sources":["../../src/protoArray/protoArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAC,sBAAsB,EAA8C,MAAM,4BAA4B,CAAC;AAC/G,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAC,YAAY,EAAyD,MAAM,aAAa,CAAC;AACjG,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAmBxB;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,GAAG,MAAM,CAYtE;AAED,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,KAAK,aAAa,GAAG;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC;AAIpD,yEAAyE;AACzE,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ACH,oBAAoB,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAM9D;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAG,UAAU,GAAG,SAAS,CAQjF;IAED;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAG,UAAU,CAM7E;IAED;;;;;;;;;OASG;IACH,YAAY,CACV,YAAY,EAAE,OAAO,EACrB,qBAAqB,EAAE,aAAa,EACpC,cAAc,EAAE,OAAO,EACvB,uBAAuB,EAAE,aAAa,GACrC,OAAO,CAwBT;IAED;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAmCtE;IAED,MAAM,IAAI,MAAM,CAEf;IAED,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,eAAe;CAcxB"}
|
|
@@ -15,6 +15,11 @@ const PAYLOAD_TIMELY_THRESHOLD = Math.floor(PTC_SIZE / 2);
|
|
|
15
15
|
* Spec: gloas/fork-choice.md (DATA_AVAILABILITY_TIMELY_THRESHOLD = PTC_SIZE // 2)
|
|
16
16
|
*/
|
|
17
17
|
const DATA_AVAILABILITY_TIMELY_THRESHOLD = Math.floor(PTC_SIZE / 2);
|
|
18
|
+
/**
|
|
19
|
+
* Proposer boost deltas, back-propagated to the boosted node's ancestors in applyScoreChanges().
|
|
20
|
+
* Reuse the array to avoid memory reallocation and gc, as computeDeltas does for attestation deltas.
|
|
21
|
+
*/
|
|
22
|
+
const boostDeltas = new Array();
|
|
18
23
|
/**
|
|
19
24
|
* popcount(attended AND NOT yes) — explicit False-vote count.
|
|
20
25
|
* Excludes PTC members who didn't attest (the None state).
|
|
@@ -277,14 +282,16 @@ export class ProtoArray {
|
|
|
277
282
|
* should become the best child.
|
|
278
283
|
* - If required, update the parents best-descendant with the current node or its best-descendant.
|
|
279
284
|
*/
|
|
280
|
-
applyScoreChanges({
|
|
281
|
-
if (
|
|
285
|
+
applyScoreChanges({ attestationDeltas, proposerBoost, justifiedEpoch, justifiedRoot, finalizedEpoch, finalizedRoot, currentSlot, }) {
|
|
286
|
+
if (attestationDeltas.length !== this.nodes.length) {
|
|
282
287
|
throw new ProtoArrayError({
|
|
283
288
|
code: ProtoArrayErrorCode.INVALID_DELTA_LEN,
|
|
284
|
-
deltas:
|
|
289
|
+
deltas: attestationDeltas.length,
|
|
285
290
|
indices: this.nodes.length,
|
|
286
291
|
});
|
|
287
292
|
}
|
|
293
|
+
boostDeltas.length = this.nodes.length;
|
|
294
|
+
boostDeltas.fill(0);
|
|
288
295
|
if (justifiedEpoch !== this.justifiedEpoch ||
|
|
289
296
|
finalizedEpoch !== this.finalizedEpoch ||
|
|
290
297
|
justifiedRoot !== this.justifiedRoot ||
|
|
@@ -321,23 +328,29 @@ export class ProtoArray {
|
|
|
321
328
|
// If this node's execution status has been marked invalid, then the weight of the node
|
|
322
329
|
// needs to be taken out of consideration after which the node weight will become 0
|
|
323
330
|
// for subsequent iterations of applyScoreChanges
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
331
|
+
const isInvalid = node.executionStatus === ExecutionStatus.Invalid;
|
|
332
|
+
const attestationDelta = isInvalid ? -node.attestationScore : attestationDeltas[nodeIndex];
|
|
333
|
+
const boostDelta = isInvalid
|
|
334
|
+
? // old boost = weight - attestationScore
|
|
335
|
+
-(node.weight - node.attestationScore)
|
|
336
|
+
: boostDeltas[nodeIndex] + currentBoost - previousBoost;
|
|
337
|
+
// Apply the deltas to the node. Their sum is the node's total delta, so weight is unaffected
|
|
338
|
+
// by tracking the two scores apart.
|
|
339
|
+
node.attestationScore += attestationDelta;
|
|
340
|
+
node.weight += attestationDelta + boostDelta;
|
|
341
|
+
// Update the parent deltas (if any)
|
|
330
342
|
const parentIndex = node.parent;
|
|
331
343
|
if (parentIndex !== undefined) {
|
|
332
|
-
const parentDelta =
|
|
344
|
+
const parentDelta = attestationDeltas[parentIndex];
|
|
333
345
|
if (parentDelta === undefined) {
|
|
334
346
|
throw new ProtoArrayError({
|
|
335
347
|
code: ProtoArrayErrorCode.INVALID_PARENT_DELTA,
|
|
336
348
|
index: parentIndex,
|
|
337
349
|
});
|
|
338
350
|
}
|
|
339
|
-
// back-propagate the nodes
|
|
340
|
-
|
|
351
|
+
// back-propagate the nodes deltas to its parent
|
|
352
|
+
attestationDeltas[parentIndex] += attestationDelta;
|
|
353
|
+
boostDeltas[parentIndex] += boostDelta;
|
|
341
354
|
}
|
|
342
355
|
}
|
|
343
356
|
// A second time, iterate backwards through all indices in `this.nodes`.
|
|
@@ -408,6 +421,7 @@ export class ProtoArray {
|
|
|
408
421
|
parent: parentIndex, // Points to parent's EMPTY/FULL or FULL (for transition)
|
|
409
422
|
payloadStatus: PayloadStatus.PENDING,
|
|
410
423
|
weight: 0,
|
|
424
|
+
attestationScore: 0,
|
|
411
425
|
bestChild: undefined,
|
|
412
426
|
bestDescendant: undefined,
|
|
413
427
|
};
|
|
@@ -419,6 +433,7 @@ export class ProtoArray {
|
|
|
419
433
|
parent: pendingIndex, // Points to own PENDING
|
|
420
434
|
payloadStatus: PayloadStatus.EMPTY,
|
|
421
435
|
weight: 0,
|
|
436
|
+
attestationScore: 0,
|
|
422
437
|
bestChild: undefined,
|
|
423
438
|
bestDescendant: undefined,
|
|
424
439
|
};
|
|
@@ -449,6 +464,7 @@ export class ProtoArray {
|
|
|
449
464
|
parent: this.getNodeIndexByRootAndStatus(block.parentRoot, PayloadStatus.FULL),
|
|
450
465
|
payloadStatus: PayloadStatus.FULL,
|
|
451
466
|
weight: 0,
|
|
467
|
+
attestationScore: 0,
|
|
452
468
|
bestChild: undefined,
|
|
453
469
|
bestDescendant: undefined,
|
|
454
470
|
};
|
|
@@ -515,6 +531,7 @@ export class ProtoArray {
|
|
|
515
531
|
parent: pendingIndex, // Points to own PENDING (same as EMPTY)
|
|
516
532
|
payloadStatus: PayloadStatus.FULL,
|
|
517
533
|
weight: 0,
|
|
534
|
+
attestationScore: 0,
|
|
518
535
|
bestChild: undefined,
|
|
519
536
|
bestDescendant: undefined,
|
|
520
537
|
executionStatus,
|
|
@@ -535,6 +552,27 @@ export class ProtoArray {
|
|
|
535
552
|
// Update bestChild for PENDING node (may now prefer FULL over EMPTY)
|
|
536
553
|
this.maybeUpdateBestChildAndDescendant(pendingIndex, fullIndex, currentSlot, proposerBoostRoot);
|
|
537
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Count gloas blocks with fromSlot <= slot <= toSlot and how many of them have a revealed
|
|
557
|
+
* payload (FULL variant exists). Used by the builder circuit breaker.
|
|
558
|
+
*/
|
|
559
|
+
getPayloadRevealCounts(fromSlot, toSlot) {
|
|
560
|
+
let blocksPresent = 0;
|
|
561
|
+
let payloadsRevealed = 0;
|
|
562
|
+
// Full scan, nodes are in import order not slot order (an old block can be imported after newer
|
|
563
|
+
// ones during sync or reorg resolution), so we cannot stop early on an out-of-window slot
|
|
564
|
+
for (const node of this.nodes) {
|
|
565
|
+
// Count each gloas block once via its PENDING variant, pre-gloas nodes are FULL only
|
|
566
|
+
if (node.slot < fromSlot || node.slot > toSlot || node.payloadStatus !== PayloadStatus.PENDING) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
blocksPresent++;
|
|
570
|
+
if (this.hasPayload(node.blockRoot)) {
|
|
571
|
+
payloadsRevealed++;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return { blocksPresent, payloadsRevealed };
|
|
575
|
+
}
|
|
538
576
|
/**
|
|
539
577
|
* Update PTC votes for multiple validators attesting to a block
|
|
540
578
|
* Spec: gloas/fork-choice.md#new-notify_ptc_messages
|
|
@@ -849,7 +887,7 @@ export class ProtoArray {
|
|
|
849
887
|
}
|
|
850
888
|
// update the forkchoice as the invalidation can change the entire forkchoice DAG
|
|
851
889
|
this.applyScoreChanges({
|
|
852
|
-
|
|
890
|
+
attestationDeltas: Array.from({ length: this.nodes.length }, () => 0),
|
|
853
891
|
proposerBoost: this.previousProposerBoost,
|
|
854
892
|
justifiedEpoch: this.justifiedEpoch,
|
|
855
893
|
justifiedRoot: this.justifiedRoot,
|
|
@@ -1299,6 +1337,36 @@ export class ProtoArray {
|
|
|
1299
1337
|
const correctFinalized = this.finalizedEpoch === 0 || this.isFinalizedRootOrDescendant(node);
|
|
1300
1338
|
return correctJustified && correctFinalized;
|
|
1301
1339
|
}
|
|
1340
|
+
/** Weights are in EFFECTIVE_BALANCE_INCREMENT units (NOT Gwei); callers scale as needed. */
|
|
1341
|
+
getViableHeads(currentSlot) {
|
|
1342
|
+
// Mirror the spec's `get_filtered_block_tree`, which is rooted at the store's justified
|
|
1343
|
+
// checkpoint: a viable head is a leaf (no viable descendant, i.e. `bestChild === undefined`)
|
|
1344
|
+
// that descends from the justified checkpoint block AND is itself viable for head. Iterating
|
|
1345
|
+
// all nodes without the justified-descendant filter would wrongly include FFG-viable leaves
|
|
1346
|
+
// that hang off the finalized checkpoint on a branch not under the current justified checkpoint.
|
|
1347
|
+
const justifiedVariant = this.getDefaultVariant(this.justifiedRoot);
|
|
1348
|
+
// Gloas payload-status variants of one blockRoot are distinct nodes in the spec's filtered
|
|
1349
|
+
// tree, identified by (root, payload_status, weight) — emit one entry per variant.
|
|
1350
|
+
const heads = [];
|
|
1351
|
+
for (const node of this.nodes) {
|
|
1352
|
+
if (node.bestChild !== undefined || !this.nodeIsViableForHead(node, currentSlot)) {
|
|
1353
|
+
continue;
|
|
1354
|
+
}
|
|
1355
|
+
if (this.justifiedEpoch !== GENESIS_EPOCH) {
|
|
1356
|
+
// Same-root short-circuit: every payload-status variant of the justified block itself is
|
|
1357
|
+
// in the filtered tree, but `isDescendant` from the default (PENDING) variant does not
|
|
1358
|
+
// reach the sibling EMPTY/FULL variants of the same root.
|
|
1359
|
+
const descendsFromJustified = node.blockRoot === this.justifiedRoot ||
|
|
1360
|
+
(justifiedVariant !== undefined &&
|
|
1361
|
+
this.isDescendant(this.justifiedRoot, justifiedVariant, node.blockRoot, node.payloadStatus));
|
|
1362
|
+
if (!descendsFromJustified) {
|
|
1363
|
+
continue;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
heads.push({ root: node.blockRoot, payloadStatus: node.payloadStatus, weight: node.weight });
|
|
1367
|
+
}
|
|
1368
|
+
return heads;
|
|
1369
|
+
}
|
|
1302
1370
|
/**
|
|
1303
1371
|
* Return `true` if `node` is equal to or a descendant of the finalized node.
|
|
1304
1372
|
* This function helps improve performance of nodeIsViableForHead a lot by avoiding
|
|
@@ -1605,6 +1673,18 @@ export class ProtoArray {
|
|
|
1605
1673
|
}
|
|
1606
1674
|
return this.getNodeByIndex(blockIndex);
|
|
1607
1675
|
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Return ProtoNode for the default/canonical variant in a single hash lookup
|
|
1678
|
+
* - Pre-Gloas blocks: the FULL variant
|
|
1679
|
+
* - Gloas blocks: the PENDING variant
|
|
1680
|
+
*/
|
|
1681
|
+
getNodeDefaultStatus(blockRoot) {
|
|
1682
|
+
const nodeIndex = this.getDefaultNodeIndex(blockRoot);
|
|
1683
|
+
if (nodeIndex === undefined) {
|
|
1684
|
+
return undefined;
|
|
1685
|
+
}
|
|
1686
|
+
return this.getNodeByIndex(nodeIndex);
|
|
1687
|
+
}
|
|
1608
1688
|
/**
|
|
1609
1689
|
* Return MUTABLE ProtoBlock for blockRoot with explicit payload status
|
|
1610
1690
|
*
|
|
@@ -1646,6 +1726,11 @@ export class ProtoArray {
|
|
|
1646
1726
|
* Returns `true` if the `descendantRoot` has an ancestor with `ancestorRoot`.
|
|
1647
1727
|
* Always returns `false` if either input roots are unknown.
|
|
1648
1728
|
* Still returns `true` if `ancestorRoot` === `descendantRoot` and payload statuses match.
|
|
1729
|
+
*
|
|
1730
|
+
* Gloas payload-status matching: a `PENDING` ancestor matches any payload variant
|
|
1731
|
+
* (PENDING/EMPTY/FULL) of the same block, so this can also return `true` for the same
|
|
1732
|
+
* root when statuses differ (e.g. ancestor `PENDING`, descendant `EMPTY`/`FULL`).
|
|
1733
|
+
* `EMPTY` and `FULL` are mutually exclusive siblings and never match each other.
|
|
1649
1734
|
*/
|
|
1650
1735
|
isDescendant(ancestorRoot, ancestorPayloadStatus, descendantRoot, descendantPayloadStatus) {
|
|
1651
1736
|
const ancestorNode = this.getNode(ancestorRoot, ancestorPayloadStatus);
|
|
@@ -1656,11 +1741,14 @@ export class ProtoArray {
|
|
|
1656
1741
|
return true;
|
|
1657
1742
|
}
|
|
1658
1743
|
for (const node of this.iterateAncestorNodes(descendantRoot, descendantPayloadStatus)) {
|
|
1659
|
-
if (node.
|
|
1660
|
-
|
|
1744
|
+
if (node.blockRoot === ancestorNode.blockRoot) {
|
|
1745
|
+
// Gloas is_ancestor: a PENDING ancestor matches any payload variant of the same block.
|
|
1746
|
+
return (node.payloadStatus === ancestorNode.payloadStatus || ancestorNode.payloadStatus === PayloadStatus.PENDING);
|
|
1661
1747
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1748
|
+
// Ancestors are iterated in decreasing slot, so once we reach the ancestor's slot
|
|
1749
|
+
// without a root match it cannot be in this chain.
|
|
1750
|
+
if (node.slot <= ancestorNode.slot) {
|
|
1751
|
+
return false;
|
|
1664
1752
|
}
|
|
1665
1753
|
}
|
|
1666
1754
|
return false;
|