@lodestar/fork-choice 1.42.0 → 1.43.0-dev.07875b3e0c
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/errors.d.ts +8 -1
- package/lib/forkChoice/errors.d.ts.map +1 -1
- package/lib/forkChoice/errors.js +4 -0
- package/lib/forkChoice/errors.js.map +1 -1
- package/lib/forkChoice/forkChoice.d.ts +22 -16
- package/lib/forkChoice/forkChoice.d.ts.map +1 -1
- package/lib/forkChoice/forkChoice.js +88 -70
- package/lib/forkChoice/forkChoice.js.map +1 -1
- package/lib/forkChoice/interface.d.ts +26 -8
- package/lib/forkChoice/interface.d.ts.map +1 -1
- package/lib/forkChoice/store.d.ts +16 -40
- package/lib/forkChoice/store.d.ts.map +1 -1
- package/lib/forkChoice/store.js +4 -22
- 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/protoArray/protoArray.d.ts +2 -2
- package/lib/protoArray/protoArray.d.ts.map +1 -1
- package/lib/protoArray/protoArray.js +26 -12
- package/lib/protoArray/protoArray.js.map +1 -1
- package/package.json +8 -8
- package/src/forkChoice/errors.ts +6 -1
- package/src/forkChoice/forkChoice.ts +101 -113
- package/src/forkChoice/interface.ts +25 -8
- package/src/forkChoice/store.ts +20 -52
- package/src/index.ts +3 -9
- package/src/protoArray/protoArray.ts +27 -12
|
@@ -65,7 +65,11 @@ export declare enum InvalidAttestationCode {
|
|
|
65
65
|
/**
|
|
66
66
|
* The attestation data index is invalid for a Gloas block (must be 0 or 1).
|
|
67
67
|
*/
|
|
68
|
-
INVALID_DATA_INDEX = "INVALID_DATA_INDEX"
|
|
68
|
+
INVALID_DATA_INDEX = "INVALID_DATA_INDEX",
|
|
69
|
+
/**
|
|
70
|
+
* The attestation votes for a full payload (index=1) but the payload status is not known.
|
|
71
|
+
*/
|
|
72
|
+
UNKNOWN_PAYLOAD_STATUS = "UNKNOWN_PAYLOAD_STATUS"
|
|
69
73
|
}
|
|
70
74
|
export type InvalidAttestation = {
|
|
71
75
|
code: InvalidAttestationCode.EMPTY_AGGREGATION_BITFIELD;
|
|
@@ -102,6 +106,9 @@ export type InvalidAttestation = {
|
|
|
102
106
|
} | {
|
|
103
107
|
code: InvalidAttestationCode.INVALID_DATA_INDEX;
|
|
104
108
|
index: number;
|
|
109
|
+
} | {
|
|
110
|
+
code: InvalidAttestationCode.UNKNOWN_PAYLOAD_STATUS;
|
|
111
|
+
beaconBlockRoot: RootHex;
|
|
105
112
|
};
|
|
106
113
|
export declare enum ForkChoiceErrorCode {
|
|
107
114
|
INVALID_ATTESTATION = "FORKCHOICE_ERROR_INVALID_ATTESTATION",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/forkChoice/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,oBAAY,gBAAgB;IAC1B,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,wBAAwB,6BAA6B;CACtD;AAED,MAAM,MAAM,YAAY,GACpB;IAAC,IAAI,EAAE,gBAAgB,CAAC,cAAc,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;CAAC,GAC5E;IAAC,IAAI,EAAE,gBAAgB,CAAC,WAAW,CAAC;IAAC,WAAW,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAC,GACxE;IAAC,IAAI,EAAE,gBAAgB,CAAC,cAAc,CAAC;IAAC,aAAa,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAC,GAC7E;IAA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AAI,EAAE,mBAAmB,CAAC,gBAAgB,CAAC;IAAC,YAAY,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAC,GACzF;IAAC,IAAI,EAAE,mBAAmB,CAAC,oBAAoB,CAAC;IAAC,YAAY,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAC,GAChF;IAAC,IAAI,EAAE,mBAAmB,CAAC,kBAAkB,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,GAC5D;IAAC,IAAI,EAAE,mBAAmB,CAAC,+BAA+B,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAC,GACrF;IAAC,IAAI,EAAE,mBAAmB,CAAC,uBAAuB,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,GACjE;IAAC,IAAI,EAAE,mBAAmB,CAAC,kCAAkC,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,GAC5E;IAAC,IAAI,EAAE,mBAAmB,CAAC,kBAAkB,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,CAAC;AAEjE,qBAAa,eAAgB,SAAQ,aAAa,CAAC,mBAAmB,CAAC;CAAG"}
|
package/lib/forkChoice/errors.js
CHANGED
|
@@ -52,6 +52,10 @@ var InvalidAttestationCode;
|
|
|
52
52
|
* The attestation data index is invalid for a Gloas block (must be 0 or 1).
|
|
53
53
|
*/
|
|
54
54
|
InvalidAttestationCode["INVALID_DATA_INDEX"] = "INVALID_DATA_INDEX";
|
|
55
|
+
/**
|
|
56
|
+
* The attestation votes for a full payload (index=1) but the payload status is not known.
|
|
57
|
+
*/
|
|
58
|
+
InvalidAttestationCode["UNKNOWN_PAYLOAD_STATUS"] = "UNKNOWN_PAYLOAD_STATUS";
|
|
55
59
|
})(InvalidAttestationCode || (InvalidAttestationCode = {}));
|
|
56
60
|
export { ForkChoiceErrorCode };
|
|
57
61
|
var ForkChoiceErrorCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/forkChoice/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;SAElC,gBAAgB;AAA5B,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,qDAAiC,CAAA;IACjC,+CAA2B,CAAA;IAC3B,qDAAiC,CAAA;IACjC,yEAAqD,CAAA;AAAC,CACxD,EALY,gBAAgB,KAAhB,gBAAgB,QAK3B;SAQW,sBAAsB;AAAlC,IAAY,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/forkChoice/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;SAElC,gBAAgB;AAA5B,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,qDAAiC,CAAA;IACjC,+CAA2B,CAAA;IAC3B,qDAAiC,CAAA;IACjC,yEAAqD,CAAA;AAAC,CACxD,EALY,gBAAgB,KAAhB,gBAAgB,QAK3B;SAQW,sBAAsB;AAAlC,IAAY,sBA+CX;AA/CD,WAAY,sBAAsB;IAChC;;OAEG;IACH,mFAAyD,CAAA;IACzD;;OAEG;IACH,mEAAyC,CAAA;IACzC;;;OAGG;IACH,+DAAqC,CAAA;IACrC;;OAEG;IACH,qEAA2C,CAAA;IAC3C;;OAEG;IACH,uDAA6B,CAAA;IAC7B;;OAEG;IACH,mDAAyB,CAAA;IACzB;;OAEG;IACH,2DAAiC,CAAA;IACjC;;OAEG;IACH,6EAAmD,CAAA;IACnD;;;OAGG;IACH,qDAA2B,CAAA;IAC3B;;OAEG;IACH,mEAAyC,CAAA;IACzC;;OAEG;IACH,2EAAiD,CAAA;AAAC,CACpD,EA/CY,sBAAsB,KAAtB,sBAAsB,QA+CjC;SAeW,mBAAmB;AAA/B,IAAY,mBAaX;AAbD,WAAY,mBAAmB;IAC7B,mFAA4D,CAAA;IAC5D,uEAAgD,CAAA;IAChD,+EAAwD,CAAA;IACxD,+FAAwE,CAAA;IACxE,+FAAwE,CAAA;IACxE,6EAAsD,CAAA;IACtD,qFAA8D,CAAA;IAC9D,iFAA0D,CAAA;IAC1D,2GAAoF,CAAA;IACpF,2FAAoE,CAAA;IACpE,iHAA0F,CAAA;IAC1F,iFAA0D,CAAA;AAAC,CAC7D,EAbY,mBAAmB,KAAnB,mBAAmB,QAa9B;AAgBD,MAAM,OAAO,eAAgB,SAAQ,aAAkC;CAAG"}
|
|
@@ -6,7 +6,7 @@ import { ForkChoiceMetrics } from "../metrics.js";
|
|
|
6
6
|
import { BlockExecutionStatus, LVHExecResponse, PayloadExecutionStatus, PayloadStatus, ProtoBlock, ProtoNode } from "../protoArray/interface.js";
|
|
7
7
|
import { ProtoArray } from "../protoArray/protoArray.js";
|
|
8
8
|
import { AncestorResult, EpochDifference, IForkChoice, NotReorgedReason, ShouldOverrideForkChoiceUpdateResult } from "./interface.js";
|
|
9
|
-
import {
|
|
9
|
+
import { CheckpointWithHex, IForkChoiceStore } from "./store.js";
|
|
10
10
|
export type ForkChoiceOpts = {
|
|
11
11
|
proposerBoost?: boolean;
|
|
12
12
|
proposerBoostReorg?: boolean;
|
|
@@ -142,6 +142,11 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
142
142
|
* Get the proposer boost root
|
|
143
143
|
*/
|
|
144
144
|
getProposerBoostRoot(): RootHex;
|
|
145
|
+
/**
|
|
146
|
+
* Decides whether to extend an available payload from the previous slot,
|
|
147
|
+
* corresponding to the beacon block `blockRoot`.
|
|
148
|
+
*/
|
|
149
|
+
shouldExtendPayload(blockRoot: RootHex): boolean;
|
|
145
150
|
/**
|
|
146
151
|
* To predict the proposer head of the next slot. That is, to predict if proposer-boost-reorg could happen.
|
|
147
152
|
* Reason why we can't be certain is because information of the head block is not fully available yet
|
|
@@ -189,8 +194,8 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
189
194
|
getHeads(): ProtoBlock[];
|
|
190
195
|
/** This is for the debug API only */
|
|
191
196
|
getAllNodes(): ProtoNode[];
|
|
192
|
-
getFinalizedCheckpoint():
|
|
193
|
-
getJustifiedCheckpoint():
|
|
197
|
+
getFinalizedCheckpoint(): CheckpointWithHex;
|
|
198
|
+
getJustifiedCheckpoint(): CheckpointWithHex;
|
|
194
199
|
/**
|
|
195
200
|
* Add `block` to the fork choice DAG.
|
|
196
201
|
*
|
|
@@ -247,7 +252,7 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
247
252
|
* Creates the FULL variant of a Gloas block when the payload becomes available
|
|
248
253
|
* Spec: gloas/fork-choice.md#new-on_execution_payload
|
|
249
254
|
*/
|
|
250
|
-
onExecutionPayload(blockRoot: RootHex, executionPayloadBlockHash: RootHex, executionPayloadNumber: number,
|
|
255
|
+
onExecutionPayload(blockRoot: RootHex, executionPayloadBlockHash: RootHex, executionPayloadNumber: number, executionStatus: PayloadExecutionStatus): void;
|
|
251
256
|
/**
|
|
252
257
|
* Call `onTick` for all slots between `fcStore.getCurrentSlot()` and the provided `currentSlot`.
|
|
253
258
|
* This should only be called once per slot because:
|
|
@@ -333,17 +338,29 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
333
338
|
getAllNonAncestorBlocks(blockRoot: RootHex, payloadStatus: PayloadStatus): ProtoBlock[];
|
|
334
339
|
/**
|
|
335
340
|
* Returns both ancestor and non-ancestor blocks in a single traversal.
|
|
341
|
+
*
|
|
342
|
+
* `ancestors` is the raw walk and includes the previous finalized block as its last element —
|
|
343
|
+
* callers that don't want the boundary should slice it off themselves.
|
|
344
|
+
* Post-gloas for each block root, it returns exactly one variant of it.
|
|
336
345
|
*/
|
|
337
346
|
getAllAncestorAndNonAncestorBlocks(blockRoot: RootHex, payloadStatus: PayloadStatus): {
|
|
338
347
|
ancestors: ProtoBlock[];
|
|
339
348
|
nonAncestors: ProtoBlock[];
|
|
340
349
|
};
|
|
350
|
+
/**
|
|
351
|
+
* Same to getAllAncestorAndNonAncestorBlocks with default variant of ${blockRoot} to start with
|
|
352
|
+
*/
|
|
353
|
+
getAllAncestorAndNonAncestorBlocksDefaultStatus(blockRoot: RootHex): {
|
|
354
|
+
ancestors: ProtoBlock[];
|
|
355
|
+
nonAncestors: ProtoBlock[];
|
|
356
|
+
};
|
|
341
357
|
getCanonicalBlockByRoot(blockRoot: Root): ProtoBlock | null;
|
|
342
358
|
getCanonicalBlockAtSlot(slot: Slot): ProtoBlock | null;
|
|
343
359
|
getCanonicalBlockClosestLteSlot(slot: Slot): ProtoBlock | null;
|
|
344
360
|
/** Very expensive function, iterates the entire ProtoArray. TODO: Is this function even necessary? */
|
|
345
361
|
forwarditerateAncestorBlocks(): ProtoBlock[];
|
|
346
362
|
forwardIterateDescendants(blockRoot: RootHex, payloadStatus: PayloadStatus): IterableIterator<ProtoBlock>;
|
|
363
|
+
forwardIterateDescendantsDefaultStatus(blockRoot: RootHex): IterableIterator<ProtoBlock>;
|
|
347
364
|
/** Very expensive function, iterates the entire ProtoArray. TODO: Is this function even necessary? */
|
|
348
365
|
getBlockSummariesByParentRoot(parentRoot: RootHex): ProtoBlock[];
|
|
349
366
|
/** Very expensive function, iterates the entire ProtoArray. TODO: Is this function even necessary? */
|
|
@@ -405,7 +422,7 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
405
422
|
*
|
|
406
423
|
* **`on_tick`**
|
|
407
424
|
* May need the justified balances of:
|
|
408
|
-
* - unrealizedJustified: Already available in `
|
|
425
|
+
* - unrealizedJustified: Already available in `CheckpointWithBalance`
|
|
409
426
|
* Since this balances are already available the getter is just `() => balances`, without cache interaction
|
|
410
427
|
*/
|
|
411
428
|
private updateCheckpoints;
|
|
@@ -463,15 +480,4 @@ export declare function getCommitteeFraction(justifiedTotalActiveBalanceByIncrem
|
|
|
463
480
|
slotsPerEpoch: number;
|
|
464
481
|
committeePercent: number;
|
|
465
482
|
}): number;
|
|
466
|
-
/**
|
|
467
|
-
* Get the payload status for a checkpoint.
|
|
468
|
-
*
|
|
469
|
-
* Pre-Gloas: always FULL (payload embedded in block)
|
|
470
|
-
* Gloas: determined by state.execution_payload_availability
|
|
471
|
-
*
|
|
472
|
-
* @param config - The chain fork config to determine fork at checkpoint slot
|
|
473
|
-
* @param state - The state to check execution_payload_availability
|
|
474
|
-
* @param checkpointEpoch - The epoch of the checkpoint
|
|
475
|
-
*/
|
|
476
|
-
export declare function getCheckpointPayloadStatus(config: ChainForkConfig, state: IBeaconStateView, checkpointEpoch: number): PayloadStatus;
|
|
477
483
|
//# sourceMappingURL=forkChoice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forkChoice.d.ts","sourceRoot":"","sources":["../../src/forkChoice/forkChoice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,sBAAsB,EAEtB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"forkChoice.d.ts","sourceRoot":"","sources":["../../src/forkChoice/forkChoice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,sBAAsB,EAEtB,gBAAgB,EAQjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,WAAW,EAEX,kBAAkB,EAClB,IAAI,EACJ,OAAO,EACP,IAAI,EAKL,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,MAAM,EAA6B,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAGhD,OAAO,EACL,oBAAoB,EAGpB,eAAe,EAEf,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,SAAS,EAGV,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EACL,cAAc,EAEd,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,oCAAoC,EACrC,MAAM,gBAAg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abilityStatus, ZERO_HASH, computeEpochAtSlot, computeSlotsSinceEpochStart, computeStartSlotAtEpoch, getAttesterSlashableIndices, isExecutionBlockBodyType, } from "@lodestar/state-transition";
|
|
1
|
+
import { SLOTS_PER_EPOCH } from "@lodestar/params";
|
|
2
|
+
import { DataAvailabilityStatus, ZERO_HASH, computeEpochAtSlot, computeSlotsSinceEpochStart, computeStartSlotAtEpoch, getAttesterSlashableIndices, isExecutionBlockBodyType, isStatePostBellatrix, } from "@lodestar/state-transition";
|
|
3
3
|
import { isGloasBeaconBlock, ssz, } from "@lodestar/types";
|
|
4
4
|
import { MapDef, fromHex, toRootHex } from "@lodestar/utils";
|
|
5
5
|
import { computeDeltas } from "../protoArray/computeDeltas.js";
|
|
@@ -7,7 +7,7 @@ import { ProtoArrayError, ProtoArrayErrorCode } from "../protoArray/errors.js";
|
|
|
7
7
|
import { ExecutionStatus, HEX_ZERO_HASH, NULL_VOTE_INDEX, PayloadStatus, isGloasBlock, } from "../protoArray/interface.js";
|
|
8
8
|
import { ForkChoiceError, ForkChoiceErrorCode, InvalidAttestationCode, InvalidBlockCode } from "./errors.js";
|
|
9
9
|
import { AncestorStatus, NotReorgedReason, } from "./interface.js";
|
|
10
|
-
import {
|
|
10
|
+
import { toCheckpointWithHex } from "./store.js";
|
|
11
11
|
export { UpdateHeadOpt };
|
|
12
12
|
var UpdateHeadOpt;
|
|
13
13
|
(function (UpdateHeadOpt) {
|
|
@@ -215,6 +215,13 @@ export class ForkChoice {
|
|
|
215
215
|
getProposerBoostRoot() {
|
|
216
216
|
return this.proposerBoostRoot ?? HEX_ZERO_HASH;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Decides whether to extend an available payload from the previous slot,
|
|
220
|
+
* corresponding to the beacon block `blockRoot`.
|
|
221
|
+
*/
|
|
222
|
+
shouldExtendPayload(blockRoot) {
|
|
223
|
+
return this.protoArray.shouldExtendPayload(blockRoot, this.proposerBoostRoot);
|
|
224
|
+
}
|
|
218
225
|
/**
|
|
219
226
|
* To predict the proposer head of the next slot. That is, to predict if proposer-boost-reorg could happen.
|
|
220
227
|
* Reason why we can't be certain is because information of the head block is not fully available yet
|
|
@@ -481,8 +488,7 @@ export class ForkChoice {
|
|
|
481
488
|
// Check block is a descendant of the finalized block at the checkpoint finalized slot.
|
|
482
489
|
const blockAncestorNode = this.getAncestor(parentRootHex, finalizedSlot);
|
|
483
490
|
const fcStoreFinalized = this.fcStore.finalizedCheckpoint;
|
|
484
|
-
if (blockAncestorNode.blockRoot !== fcStoreFinalized.rootHex
|
|
485
|
-
blockAncestorNode.payloadStatus !== fcStoreFinalized.payloadStatus) {
|
|
491
|
+
if (blockAncestorNode.blockRoot !== fcStoreFinalized.rootHex) {
|
|
486
492
|
throw new ForkChoiceError({
|
|
487
493
|
code: ForkChoiceErrorCode.INVALID_BLOCK,
|
|
488
494
|
err: {
|
|
@@ -503,13 +509,9 @@ export class ForkChoice {
|
|
|
503
509
|
this.proposerBoostRoot === null) {
|
|
504
510
|
this.proposerBoostRoot = blockRootHex;
|
|
505
511
|
}
|
|
506
|
-
|
|
507
|
-
const justifiedPayloadStatus = getCheckpointPayloadStatus(this.config, state, state.currentJustifiedCheckpoint.epoch);
|
|
508
|
-
const justifiedCheckpoint = toCheckpointWithPayload(state.currentJustifiedCheckpoint, justifiedPayloadStatus);
|
|
512
|
+
const justifiedCheckpoint = toCheckpointWithHex(state.currentJustifiedCheckpoint);
|
|
509
513
|
const stateJustifiedEpoch = justifiedCheckpoint.epoch;
|
|
510
|
-
|
|
511
|
-
const finalizedPayloadStatus = getCheckpointPayloadStatus(this.config, state, state.finalizedCheckpoint.epoch);
|
|
512
|
-
const finalizedCheckpoint = toCheckpointWithPayload(state.finalizedCheckpoint, finalizedPayloadStatus);
|
|
514
|
+
const finalizedCheckpoint = toCheckpointWithHex(state.finalizedCheckpoint);
|
|
513
515
|
// Justified balances for `justifiedCheckpoint` are new to the fork-choice. Compute them on demand only if
|
|
514
516
|
// the justified checkpoint changes
|
|
515
517
|
this.updateCheckpoints(justifiedCheckpoint, finalizedCheckpoint, () => this.fcStore.justifiedBalancesGetter(justifiedCheckpoint, state));
|
|
@@ -532,32 +534,22 @@ export class ForkChoice {
|
|
|
532
534
|
if (parentBlock.unrealizedJustifiedEpoch === blockEpoch &&
|
|
533
535
|
parentBlock.unrealizedFinalizedEpoch + 1 >= blockEpoch) {
|
|
534
536
|
// reuse from parent, happens at 1/3 last blocks of epoch as monitored in mainnet
|
|
535
|
-
// Get payload status for unrealized justified checkpoint
|
|
536
|
-
const unrealizedJustifiedPayloadStatus = getCheckpointPayloadStatus(this.config, state, parentBlock.unrealizedJustifiedEpoch);
|
|
537
537
|
unrealizedJustifiedCheckpoint = {
|
|
538
538
|
epoch: parentBlock.unrealizedJustifiedEpoch,
|
|
539
539
|
root: fromHex(parentBlock.unrealizedJustifiedRoot),
|
|
540
540
|
rootHex: parentBlock.unrealizedJustifiedRoot,
|
|
541
|
-
payloadStatus: unrealizedJustifiedPayloadStatus,
|
|
542
541
|
};
|
|
543
|
-
// Get payload status for unrealized finalized checkpoint
|
|
544
|
-
const unrealizedFinalizedPayloadStatus = getCheckpointPayloadStatus(this.config, state, parentBlock.unrealizedFinalizedEpoch);
|
|
545
542
|
unrealizedFinalizedCheckpoint = {
|
|
546
543
|
epoch: parentBlock.unrealizedFinalizedEpoch,
|
|
547
544
|
root: fromHex(parentBlock.unrealizedFinalizedRoot),
|
|
548
545
|
rootHex: parentBlock.unrealizedFinalizedRoot,
|
|
549
|
-
payloadStatus: unrealizedFinalizedPayloadStatus,
|
|
550
546
|
};
|
|
551
547
|
}
|
|
552
548
|
else {
|
|
553
549
|
// compute new, happens 2/3 first blocks of epoch as monitored in mainnet
|
|
554
550
|
const unrealized = state.computeUnrealizedCheckpoints();
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
unrealizedJustifiedCheckpoint = toCheckpointWithPayload(unrealized.justifiedCheckpoint, unrealizedJustifiedPayloadStatus);
|
|
558
|
-
// Get payload status for unrealized finalized checkpoint
|
|
559
|
-
const unrealizedFinalizedPayloadStatus = getCheckpointPayloadStatus(this.config, state, unrealized.finalizedCheckpoint.epoch);
|
|
560
|
-
unrealizedFinalizedCheckpoint = toCheckpointWithPayload(unrealized.finalizedCheckpoint, unrealizedFinalizedPayloadStatus);
|
|
551
|
+
unrealizedJustifiedCheckpoint = toCheckpointWithHex(unrealized.justifiedCheckpoint);
|
|
552
|
+
unrealizedFinalizedCheckpoint = toCheckpointWithHex(unrealized.finalizedCheckpoint);
|
|
561
553
|
}
|
|
562
554
|
}
|
|
563
555
|
else {
|
|
@@ -615,7 +607,10 @@ export class ForkChoice {
|
|
|
615
607
|
executionStatus: this.getPostGloasExecStatus(executionStatus),
|
|
616
608
|
dataAvailabilityStatus,
|
|
617
609
|
}
|
|
618
|
-
: isExecutionBlockBodyType(block.body) &&
|
|
610
|
+
: isExecutionBlockBodyType(block.body) &&
|
|
611
|
+
isStatePostBellatrix(state) &&
|
|
612
|
+
state.isExecutionStateType &&
|
|
613
|
+
state.isExecutionEnabled(block)
|
|
619
614
|
? {
|
|
620
615
|
executionPayloadBlockHash: toRootHex(block.body.executionPayload.blockHash),
|
|
621
616
|
executionPayloadNumber: block.body.executionPayload.blockNumber,
|
|
@@ -757,8 +752,8 @@ export class ForkChoice {
|
|
|
757
752
|
* Creates the FULL variant of a Gloas block when the payload becomes available
|
|
758
753
|
* Spec: gloas/fork-choice.md#new-on_execution_payload
|
|
759
754
|
*/
|
|
760
|
-
onExecutionPayload(blockRoot, executionPayloadBlockHash, executionPayloadNumber,
|
|
761
|
-
this.protoArray.onExecutionPayload(blockRoot, this.fcStore.currentSlot, executionPayloadBlockHash, executionPayloadNumber,
|
|
755
|
+
onExecutionPayload(blockRoot, executionPayloadBlockHash, executionPayloadNumber, executionStatus) {
|
|
756
|
+
this.protoArray.onExecutionPayload(blockRoot, this.fcStore.currentSlot, executionPayloadBlockHash, executionPayloadNumber, this.proposerBoostRoot, executionStatus);
|
|
762
757
|
}
|
|
763
758
|
/**
|
|
764
759
|
* Call `onTick` for all slots between `fcStore.getCurrentSlot()` and the provided `currentSlot`.
|
|
@@ -869,8 +864,8 @@ export class ForkChoice {
|
|
|
869
864
|
return this.protoArray.getBlockHexAndBlockHash(blockRoot, blockHash);
|
|
870
865
|
}
|
|
871
866
|
getJustifiedBlock() {
|
|
872
|
-
const { rootHex
|
|
873
|
-
const block = this.
|
|
867
|
+
const { rootHex } = this.fcStore.justified.checkpoint;
|
|
868
|
+
const block = this.getBlockHexDefaultStatus(rootHex);
|
|
874
869
|
if (!block) {
|
|
875
870
|
throw new ForkChoiceError({
|
|
876
871
|
code: ForkChoiceErrorCode.MISSING_PROTO_ARRAY_BLOCK,
|
|
@@ -880,8 +875,8 @@ export class ForkChoice {
|
|
|
880
875
|
return block;
|
|
881
876
|
}
|
|
882
877
|
getFinalizedBlock() {
|
|
883
|
-
const { rootHex
|
|
884
|
-
const block = this.
|
|
878
|
+
const { rootHex } = this.fcStore.finalizedCheckpoint;
|
|
879
|
+
const block = this.getBlockHexDefaultStatus(rootHex);
|
|
885
880
|
if (!block) {
|
|
886
881
|
throw new ForkChoiceError({
|
|
887
882
|
code: ForkChoiceErrorCode.MISSING_PROTO_ARRAY_BLOCK,
|
|
@@ -960,14 +955,26 @@ export class ForkChoice {
|
|
|
960
955
|
}
|
|
961
956
|
/**
|
|
962
957
|
* Returns both ancestor and non-ancestor blocks in a single traversal.
|
|
958
|
+
*
|
|
959
|
+
* `ancestors` is the raw walk and includes the previous finalized block as its last element —
|
|
960
|
+
* callers that don't want the boundary should slice it off themselves.
|
|
961
|
+
* Post-gloas for each block root, it returns exactly one variant of it.
|
|
963
962
|
*/
|
|
964
963
|
getAllAncestorAndNonAncestorBlocks(blockRoot, payloadStatus) {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
964
|
+
return this.protoArray.getAllAncestorAndNonAncestorNodes(blockRoot, payloadStatus);
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Same to getAllAncestorAndNonAncestorBlocks with default variant of ${blockRoot} to start with
|
|
968
|
+
*/
|
|
969
|
+
getAllAncestorAndNonAncestorBlocksDefaultStatus(blockRoot) {
|
|
970
|
+
const defaultStatus = this.protoArray.getDefaultVariant(blockRoot);
|
|
971
|
+
if (defaultStatus === undefined) {
|
|
972
|
+
throw new ForkChoiceError({
|
|
973
|
+
code: ForkChoiceErrorCode.MISSING_PROTO_ARRAY_BLOCK,
|
|
974
|
+
root: blockRoot,
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
return this.getAllAncestorAndNonAncestorBlocks(blockRoot, defaultStatus);
|
|
971
978
|
}
|
|
972
979
|
getCanonicalBlockByRoot(blockRoot) {
|
|
973
980
|
const blockRootHex = toRootHex(blockRoot);
|
|
@@ -1027,6 +1034,16 @@ export class ForkChoice {
|
|
|
1027
1034
|
}
|
|
1028
1035
|
}
|
|
1029
1036
|
}
|
|
1037
|
+
forwardIterateDescendantsDefaultStatus(blockRoot) {
|
|
1038
|
+
const defaultStatus = this.protoArray.getDefaultVariant(blockRoot);
|
|
1039
|
+
if (defaultStatus === undefined) {
|
|
1040
|
+
throw new ForkChoiceError({
|
|
1041
|
+
code: ForkChoiceErrorCode.MISSING_PROTO_ARRAY_BLOCK,
|
|
1042
|
+
root: blockRoot,
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
return this.forwardIterateDescendants(blockRoot, defaultStatus);
|
|
1046
|
+
}
|
|
1030
1047
|
/** Very expensive function, iterates the entire ProtoArray. TODO: Is this function even necessary? */
|
|
1031
1048
|
getBlockSummariesByParentRoot(parentRoot) {
|
|
1032
1049
|
return this.protoArray.nodes.filter((node) => node.parentRoot === parentRoot);
|
|
@@ -1186,7 +1203,7 @@ export class ForkChoice {
|
|
|
1186
1203
|
*
|
|
1187
1204
|
* **`on_tick`**
|
|
1188
1205
|
* May need the justified balances of:
|
|
1189
|
-
* - unrealizedJustified: Already available in `
|
|
1206
|
+
* - unrealizedJustified: Already available in `CheckpointWithBalance`
|
|
1190
1207
|
* Since this balances are already available the getter is just `() => balances`, without cache interaction
|
|
1191
1208
|
*/
|
|
1192
1209
|
updateCheckpoints(justifiedCheckpoint, finalizedCheckpoint, getJustifiedBalances) {
|
|
@@ -1340,15 +1357,40 @@ export class ForkChoice {
|
|
|
1340
1357
|
},
|
|
1341
1358
|
});
|
|
1342
1359
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1360
|
+
if (isGloasBlock(block)) {
|
|
1361
|
+
// For Gloas blocks, attestation index must be 0 or 1
|
|
1362
|
+
if (attestationData.index !== 0 && attestationData.index !== 1) {
|
|
1363
|
+
throw new ForkChoiceError({
|
|
1364
|
+
code: ForkChoiceErrorCode.INVALID_ATTESTATION,
|
|
1365
|
+
err: {
|
|
1366
|
+
code: InvalidAttestationCode.INVALID_DATA_INDEX,
|
|
1367
|
+
index: attestationData.index,
|
|
1368
|
+
},
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
// Same-slot attestations can only vote for the PENDING variant
|
|
1372
|
+
if (block.slot === slot && attestationData.index !== 0) {
|
|
1373
|
+
throw new ForkChoiceError({
|
|
1374
|
+
code: ForkChoiceErrorCode.INVALID_ATTESTATION,
|
|
1375
|
+
err: {
|
|
1376
|
+
code: InvalidAttestationCode.INVALID_DATA_INDEX,
|
|
1377
|
+
index: attestationData.index,
|
|
1378
|
+
},
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
// If attesting for a full node, the payload must be known
|
|
1382
|
+
if (attestationData.index === 1) {
|
|
1383
|
+
const fullNodeIndex = this.protoArray.getNodeIndexByRootAndStatus(beaconBlockRootHex, PayloadStatus.FULL);
|
|
1384
|
+
if (fullNodeIndex === undefined) {
|
|
1385
|
+
throw new ForkChoiceError({
|
|
1386
|
+
code: ForkChoiceErrorCode.INVALID_ATTESTATION,
|
|
1387
|
+
err: {
|
|
1388
|
+
code: InvalidAttestationCode.UNKNOWN_PAYLOAD_STATUS,
|
|
1389
|
+
beaconBlockRoot: beaconBlockRootHex,
|
|
1390
|
+
},
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1352
1394
|
}
|
|
1353
1395
|
this.validatedAttestationDatas.add(attDataRoot);
|
|
1354
1396
|
}
|
|
@@ -1492,28 +1534,4 @@ export function getCommitteeFraction(justifiedTotalActiveBalanceByIncrement, con
|
|
|
1492
1534
|
const committeeWeight = Math.floor(justifiedTotalActiveBalanceByIncrement / config.slotsPerEpoch);
|
|
1493
1535
|
return Math.floor((committeeWeight * config.committeePercent) / 100);
|
|
1494
1536
|
}
|
|
1495
|
-
/**
|
|
1496
|
-
* Get the payload status for a checkpoint.
|
|
1497
|
-
*
|
|
1498
|
-
* Pre-Gloas: always FULL (payload embedded in block)
|
|
1499
|
-
* Gloas: determined by state.execution_payload_availability
|
|
1500
|
-
*
|
|
1501
|
-
* @param config - The chain fork config to determine fork at checkpoint slot
|
|
1502
|
-
* @param state - The state to check execution_payload_availability
|
|
1503
|
-
* @param checkpointEpoch - The epoch of the checkpoint
|
|
1504
|
-
*/
|
|
1505
|
-
export function getCheckpointPayloadStatus(config, state, checkpointEpoch) {
|
|
1506
|
-
// Compute checkpoint slot first to determine the correct fork
|
|
1507
|
-
const checkpointSlot = computeStartSlotAtEpoch(checkpointEpoch);
|
|
1508
|
-
const fork = config.getForkSeq(checkpointSlot);
|
|
1509
|
-
// Pre-Gloas: always FULL
|
|
1510
|
-
if (fork < ForkSeq.gloas) {
|
|
1511
|
-
return PayloadStatus.FULL;
|
|
1512
|
-
}
|
|
1513
|
-
// For Gloas, check state.execution_payload_availability
|
|
1514
|
-
// - For non-skipped slots at checkpoint: returns false (EMPTY) since payload hasn't arrived yet
|
|
1515
|
-
// - For skipped slots at checkpoint: returns the actual availability status from state
|
|
1516
|
-
const payloadAvailable = state.executionPayloadAvailability.get(checkpointSlot % SLOTS_PER_HISTORICAL_ROOT);
|
|
1517
|
-
return payloadAvailable ? PayloadStatus.FULL : PayloadStatus.EMPTY;
|
|
1518
|
-
}
|
|
1519
1537
|
//# sourceMappingURL=forkChoice.js.map
|