@lodestar/fork-choice 1.51.0-dev.88c15a0731 → 1.51.0-dev.8d5cdd33be
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 +6 -1
- package/lib/forkChoice/errors.d.ts.map +1 -1
- package/lib/forkChoice/errors.js +1 -0
- package/lib/forkChoice/errors.js.map +1 -1
- package/lib/forkChoice/forkChoice.d.ts +17 -18
- package/lib/forkChoice/forkChoice.d.ts.map +1 -1
- package/lib/forkChoice/forkChoice.js +79 -38
- package/lib/forkChoice/forkChoice.js.map +1 -1
- package/lib/forkChoice/interface.d.ts +12 -4
- package/lib/forkChoice/interface.d.ts.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 +2 -0
- package/lib/protoArray/interface.d.ts.map +1 -1
- package/lib/protoArray/interface.js.map +1 -1
- package/lib/protoArray/protoArray.d.ts +20 -4
- package/lib/protoArray/protoArray.d.ts.map +1 -1
- package/lib/protoArray/protoArray.js +115 -51
- package/lib/protoArray/protoArray.js.map +1 -1
- package/package.json +7 -7
- package/src/forkChoice/errors.ts +3 -1
- package/src/forkChoice/forkChoice.ts +86 -40
- package/src/forkChoice/interface.ts +11 -5
- package/src/metrics.ts +5 -0
- package/src/protoArray/interface.ts +2 -0
- package/src/protoArray/protoArray.ts +133 -56
|
@@ -4,7 +4,8 @@ export declare enum InvalidBlockCode {
|
|
|
4
4
|
UNKNOWN_PARENT = "UNKNOWN_PARENT",
|
|
5
5
|
FUTURE_SLOT = "FUTURE_SLOT",
|
|
6
6
|
FINALIZED_SLOT = "FINALIZED_SLOT",
|
|
7
|
-
NOT_FINALIZED_DESCENDANT = "NOT_FINALIZED_DESCENDANT"
|
|
7
|
+
NOT_FINALIZED_DESCENDANT = "NOT_FINALIZED_DESCENDANT",
|
|
8
|
+
PARENT_EXECUTION_INVALID = "PARENT_EXECUTION_INVALID"
|
|
8
9
|
}
|
|
9
10
|
export type InvalidBlock = {
|
|
10
11
|
code: InvalidBlockCode.UNKNOWN_PARENT;
|
|
@@ -22,6 +23,10 @@ export type InvalidBlock = {
|
|
|
22
23
|
code: InvalidBlockCode.NOT_FINALIZED_DESCENDANT;
|
|
23
24
|
finalizedRoot: RootHex;
|
|
24
25
|
blockAncestor?: RootHex;
|
|
26
|
+
} | {
|
|
27
|
+
code: InvalidBlockCode.PARENT_EXECUTION_INVALID;
|
|
28
|
+
root: RootHex;
|
|
29
|
+
hash: RootHex | null;
|
|
25
30
|
};
|
|
26
31
|
export declare enum InvalidAttestationCode {
|
|
27
32
|
/**
|
|
@@ -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;IAAC,IAAI,EAAE,gBAAgB,CAAC,wBAAwB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,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,GAC5D;IAAC,IAAI,EAAE,mBAAmB,CAAC,oCAAoC,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAC,CAAC;AAEhG,qBAAa,eAAgB,SAAQ,aAAa,CAAC,mBAAmB,CAAC;CAAG"}
|
package/lib/forkChoice/errors.js
CHANGED
|
@@ -5,6 +5,7 @@ export var InvalidBlockCode;
|
|
|
5
5
|
InvalidBlockCode["FUTURE_SLOT"] = "FUTURE_SLOT";
|
|
6
6
|
InvalidBlockCode["FINALIZED_SLOT"] = "FINALIZED_SLOT";
|
|
7
7
|
InvalidBlockCode["NOT_FINALIZED_DESCENDANT"] = "NOT_FINALIZED_DESCENDANT";
|
|
8
|
+
InvalidBlockCode["PARENT_EXECUTION_INVALID"] = "PARENT_EXECUTION_INVALID";
|
|
8
9
|
})(InvalidBlockCode || (InvalidBlockCode = {}));
|
|
9
10
|
export var InvalidAttestationCode;
|
|
10
11
|
(function (InvalidAttestationCode) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/forkChoice/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MA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,OAAO,eAAgB,SAAQ,aAAkC;CAAG"}
|
|
@@ -23,11 +23,11 @@ export type UpdateAndGetHeadOpt = {
|
|
|
23
23
|
mode: UpdateHeadOpt.GetCanonicalHead;
|
|
24
24
|
} | {
|
|
25
25
|
mode: UpdateHeadOpt.GetProposerHead;
|
|
26
|
-
|
|
26
|
+
msFromSlot: number;
|
|
27
27
|
slot: Slot;
|
|
28
28
|
} | {
|
|
29
29
|
mode: UpdateHeadOpt.GetPredictedProposerHead;
|
|
30
|
-
|
|
30
|
+
msFromSlot: number;
|
|
31
31
|
slot: Slot;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
@@ -150,7 +150,7 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
150
150
|
isHeadTimely?: boolean;
|
|
151
151
|
notReorgedReason?: NotReorgedReason;
|
|
152
152
|
};
|
|
153
|
-
shouldOverrideForkChoiceUpdate(headBlock: ProtoBlock,
|
|
153
|
+
shouldOverrideForkChoiceUpdate(headBlock: ProtoBlock, msFromSlot: number, currentSlot: Slot): ShouldOverrideForkChoiceUpdateResult;
|
|
154
154
|
/**
|
|
155
155
|
* Get the proposer boost root
|
|
156
156
|
*/
|
|
@@ -177,7 +177,7 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
177
177
|
* By calling this function, we assume we are the proposer of next slot
|
|
178
178
|
*
|
|
179
179
|
*/
|
|
180
|
-
predictProposerHead(headBlock: ProtoBlock,
|
|
180
|
+
predictProposerHead(headBlock: ProtoBlock, msFromSlot: number, currentSlot: Slot): ProtoBlock;
|
|
181
181
|
/**
|
|
182
182
|
*
|
|
183
183
|
* This function takes in the canonical head block and determine the proposer head (canonical head block or its parent)
|
|
@@ -187,7 +187,7 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
187
187
|
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/phase0/fork-choice.md#get_proposer_head
|
|
188
188
|
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/gloas/fork-choice.md#modified-get_proposer_head
|
|
189
189
|
*/
|
|
190
|
-
getProposerHead(headBlock: ProtoBlock,
|
|
190
|
+
getProposerHead(headBlock: ProtoBlock, msFromSlot: number, slot: Slot): {
|
|
191
191
|
proposerHead: ProtoBlock;
|
|
192
192
|
isHeadTimely: boolean;
|
|
193
193
|
notReorgedReason?: NotReorgedReason;
|
|
@@ -245,8 +245,11 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
245
245
|
*
|
|
246
246
|
* `justifiedBalances` balances of justified state which is updated synchronously.
|
|
247
247
|
* This ensures that the forkchoice is never out of sync.
|
|
248
|
+
*
|
|
249
|
+
* A block whose parent payload chain was invalidated is rejected. `executionStatus` is ignored for a gloas
|
|
250
|
+
* block: it has no payload of its own and inherits the status of the parent variant it builds on.
|
|
248
251
|
*/
|
|
249
|
-
onBlock(block: BeaconBlock, state: IBeaconStateView,
|
|
252
|
+
onBlock(block: BeaconBlock, state: IBeaconStateView, receiveDelayMs: number, importDelayMs: number, currentSlot: Slot, executionStatus: BlockExecutionStatus, dataAvailabilityStatus: DataAvailabilityStatus): ProtoBlock;
|
|
250
253
|
/**
|
|
251
254
|
* Register `attestation` with the fork choice DAG so that it may influence future calls to `getHead`.
|
|
252
255
|
*
|
|
@@ -256,14 +259,8 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
256
259
|
*
|
|
257
260
|
* https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#on_attestation
|
|
258
261
|
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* too expensive to call again.
|
|
262
|
-
*
|
|
263
|
-
* ## Notes:
|
|
264
|
-
*
|
|
265
|
-
* The supplied `attestation` **must** pass the `in_valid_indexed_attestation` function as it
|
|
266
|
-
* will not be run here.
|
|
262
|
+
* Does not run `is_valid_indexed_attestation`. The caller must ensure all of its
|
|
263
|
+
* validity requirements except index ordering: `attestingIndices` may be unsorted.
|
|
267
264
|
*/
|
|
268
265
|
onAttestation(attestation: IndexedAttestation, attDataRoot: string, forceImport?: boolean): void;
|
|
269
266
|
/**
|
|
@@ -420,7 +417,9 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
420
417
|
* justified's status as well as validate the terminal conditions if terminal block
|
|
421
418
|
* becomes valid
|
|
422
419
|
*/
|
|
423
|
-
validateLatestHash(execResponse: LVHExecResponse
|
|
420
|
+
validateLatestHash(execResponse: LVHExecResponse, opts?: {
|
|
421
|
+
strict?: boolean;
|
|
422
|
+
}): boolean;
|
|
424
423
|
/**
|
|
425
424
|
* A dependent root is the block root of the last block before the state transition that decided a specific shuffling
|
|
426
425
|
*
|
|
@@ -468,7 +467,7 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
468
467
|
* Return true if the block is timely for the current slot.
|
|
469
468
|
* Child class can overwrite this for testing purpose.
|
|
470
469
|
*/
|
|
471
|
-
protected isBlockReceivedTimely(block: BeaconBlock,
|
|
470
|
+
protected isBlockReceivedTimely(block: BeaconBlock, blockDelayMs: number): boolean;
|
|
472
471
|
/**
|
|
473
472
|
* Return true if the block arrived before the PTC (payload-timeliness committee) deadline,
|
|
474
473
|
* ie. block_timeliness[PTC_TIMELINESS_INDEX]. should_apply_proposer_boost uses this as the
|
|
@@ -479,13 +478,13 @@ export declare class ForkChoice implements IForkChoice {
|
|
|
479
478
|
*
|
|
480
479
|
* Child class can overwrite this for testing purpose.
|
|
481
480
|
*/
|
|
482
|
-
protected isBlockPtcTimely(block: BeaconBlock,
|
|
481
|
+
protected isBlockPtcTimely(block: BeaconBlock, blockDelayMs: number): boolean;
|
|
483
482
|
/**
|
|
484
483
|
* Return true if THIS node finished importing the block before the attestation cutoff, ie. the
|
|
485
484
|
* block was imported in a timely manner for its own slot.
|
|
486
485
|
* This is not part of the spec, we use this to determine late canonical blocks.
|
|
487
486
|
*/
|
|
488
|
-
protected isBlockImportedTimely(block: BeaconBlock,
|
|
487
|
+
protected isBlockImportedTimely(block: BeaconBlock, importDelayMs: number): boolean;
|
|
489
488
|
/**
|
|
490
489
|
* Determine whether proposer boost should be applied to `proposerBoostRoot`.
|
|
491
490
|
*
|
|
@@ -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;AAQjD,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,EAAmD,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAGhD,OAAO,EACL,oBAAoB,EAGpB,eAAe,EAEf,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,SAAS,EACT,SAAS,EAIV,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAKL,KAAK,0BAA0B,EAChC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,cAAc,EAEd,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,oCAAoC,EACrC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAyC,MAAM,YAAY,CAAC;AAEvG,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAIF,oBAAY,aAAa;IACvB,gBAAgB,qBAAqB,CAAE,uBAAuB;IAC9D,eAAe,oBAAoB,CAAE,uBAAuB;IAC5D,wBAAwB,6BAA6B;CAC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CAAC,wBAAwB;IAsChC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAM9B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,sBAAsB;IAU9B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,iBAAiB;IAwBzB;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAgBnC;;;;;;;;OAQG;IACH,OAAO,CAAC,qBAAqB;IA4B7B,OAAO,CAAC,uBAAuB;IAwJ/B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IAkCxB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAsB/B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM;IAgCd;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IA8ClC,kGAAkG;IAClG,OAAO,CAAC,mBAAmB;IAiE3B,OAAO,CAAC,6BAA6B;CA2DtC"}
|
|
@@ -223,9 +223,9 @@ export class ForkChoice {
|
|
|
223
223
|
const canonicalHeadBlock = mode === UpdateHeadOpt.GetPredictedProposerHead ? this.getHead() : this.updateHead();
|
|
224
224
|
switch (mode) {
|
|
225
225
|
case UpdateHeadOpt.GetPredictedProposerHead:
|
|
226
|
-
return { head: this.predictProposerHead(canonicalHeadBlock, opt.
|
|
226
|
+
return { head: this.predictProposerHead(canonicalHeadBlock, opt.msFromSlot, opt.slot) };
|
|
227
227
|
case UpdateHeadOpt.GetProposerHead: {
|
|
228
|
-
const { proposerHead: head, isHeadTimely, notReorgedReason, } = this.getProposerHead(canonicalHeadBlock, opt.
|
|
228
|
+
const { proposerHead: head, isHeadTimely, notReorgedReason, } = this.getProposerHead(canonicalHeadBlock, opt.msFromSlot, opt.slot);
|
|
229
229
|
return { head, isHeadTimely, notReorgedReason };
|
|
230
230
|
}
|
|
231
231
|
case UpdateHeadOpt.GetCanonicalHead:
|
|
@@ -239,7 +239,7 @@ export class ForkChoice {
|
|
|
239
239
|
// Return true if the given block passes all criteria to be re-orged out
|
|
240
240
|
// Return false otherwise.
|
|
241
241
|
// Note when proposer boost reorg is disabled, it always returns false
|
|
242
|
-
shouldOverrideForkChoiceUpdate(headBlock,
|
|
242
|
+
shouldOverrideForkChoiceUpdate(headBlock, msFromSlot, currentSlot) {
|
|
243
243
|
if (headBlock === null) {
|
|
244
244
|
// should not happen because this block just got imported. Fall back to no-reorg.
|
|
245
245
|
return { shouldOverrideFcu: false, reason: NotReorgedReason.HeadBlockNotAvailable };
|
|
@@ -261,7 +261,7 @@ export class ForkChoice {
|
|
|
261
261
|
return { shouldOverrideFcu: false, reason: NotReorgedReason.ParentBlockNotAvailable };
|
|
262
262
|
}
|
|
263
263
|
const currentTimeOk = headBlock.slot === currentSlot ||
|
|
264
|
-
(proposalSlot === currentSlot && this.isProposingOnTime(
|
|
264
|
+
(proposalSlot === currentSlot && this.isProposingOnTime(msFromSlot, currentSlot));
|
|
265
265
|
// Mirror the proposer equivocation branch of getProposerHead(). The head slot's attestations are
|
|
266
266
|
// still queued at this point so the head is assumed weak, same as for the regular branch below.
|
|
267
267
|
if (currentTimeOk && this.isProposerEquivocation(headBlock)) {
|
|
@@ -330,7 +330,7 @@ export class ForkChoice {
|
|
|
330
330
|
* By calling this function, we assume we are the proposer of next slot
|
|
331
331
|
*
|
|
332
332
|
*/
|
|
333
|
-
predictProposerHead(headBlock,
|
|
333
|
+
predictProposerHead(headBlock, msFromSlot, currentSlot) {
|
|
334
334
|
const { proposerBoost, proposerBoostReorg } = this.opts ?? {};
|
|
335
335
|
// Skip re-org attempt if proposer boost (reorg) are disabled
|
|
336
336
|
if (!proposerBoost || !proposerBoostReorg) {
|
|
@@ -342,7 +342,7 @@ export class ForkChoice {
|
|
|
342
342
|
return headBlock;
|
|
343
343
|
}
|
|
344
344
|
const blockRoot = headBlock.blockRoot;
|
|
345
|
-
const result = this.shouldOverrideForkChoiceUpdate(headBlock,
|
|
345
|
+
const result = this.shouldOverrideForkChoiceUpdate(headBlock, msFromSlot, currentSlot);
|
|
346
346
|
if (result.shouldOverrideFcu) {
|
|
347
347
|
this.logger?.verbose("Current head is weak. Predicting next block to be built on parent of head.", {
|
|
348
348
|
slot: currentSlot,
|
|
@@ -367,7 +367,7 @@ export class ForkChoice {
|
|
|
367
367
|
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/phase0/fork-choice.md#get_proposer_head
|
|
368
368
|
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/gloas/fork-choice.md#modified-get_proposer_head
|
|
369
369
|
*/
|
|
370
|
-
getProposerHead(headBlock,
|
|
370
|
+
getProposerHead(headBlock, msFromSlot, slot) {
|
|
371
371
|
const isHeadTimely = headBlock.timeliness;
|
|
372
372
|
let proposerHead = headBlock;
|
|
373
373
|
// Skip re-org attempt if proposer boost (reorg) are disabled
|
|
@@ -408,7 +408,7 @@ export class ForkChoice {
|
|
|
408
408
|
return { proposerHead, isHeadTimely, notReorgedReason: prelimNotReorgedReason };
|
|
409
409
|
}
|
|
410
410
|
// Only re-org if we are proposing on-time
|
|
411
|
-
if (!this.isProposingOnTime(
|
|
411
|
+
if (!this.isProposingOnTime(msFromSlot, slot)) {
|
|
412
412
|
return { proposerHead, isHeadTimely, notReorgedReason: NotReorgedReason.NotProposingOnTime };
|
|
413
413
|
}
|
|
414
414
|
// No reorg if attempted reorg is more than a single slot
|
|
@@ -515,7 +515,19 @@ export class ForkChoice {
|
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
// findHead returns the ProtoNode representing the head
|
|
518
|
-
|
|
518
|
+
let head;
|
|
519
|
+
try {
|
|
520
|
+
head = this.protoArray.findHead(this.fcStore.justified.checkpoint.rootHex, currentSlot);
|
|
521
|
+
}
|
|
522
|
+
catch (e) {
|
|
523
|
+
// A poisoned tree never recovers, shut the node down instead of failing every head computation
|
|
524
|
+
if (e instanceof ProtoArrayError &&
|
|
525
|
+
(e.type.code === ProtoArrayErrorCode.INVALID_LVH_EXECUTION_RESPONSE ||
|
|
526
|
+
e.type.code === ProtoArrayErrorCode.INVALID_JUSTIFIED_EXECUTION_STATUS)) {
|
|
527
|
+
this.irrecoverableError = e;
|
|
528
|
+
}
|
|
529
|
+
throw e;
|
|
530
|
+
}
|
|
519
531
|
this.head = head;
|
|
520
532
|
return this.head;
|
|
521
533
|
}
|
|
@@ -566,8 +578,11 @@ export class ForkChoice {
|
|
|
566
578
|
*
|
|
567
579
|
* `justifiedBalances` balances of justified state which is updated synchronously.
|
|
568
580
|
* This ensures that the forkchoice is never out of sync.
|
|
581
|
+
*
|
|
582
|
+
* A block whose parent payload chain was invalidated is rejected. `executionStatus` is ignored for a gloas
|
|
583
|
+
* block: it has no payload of its own and inherits the status of the parent variant it builds on.
|
|
569
584
|
*/
|
|
570
|
-
onBlock(block, state,
|
|
585
|
+
onBlock(block, state, receiveDelayMs, importDelayMs, currentSlot, executionStatus, dataAvailabilityStatus) {
|
|
571
586
|
const { parentRoot, slot } = block;
|
|
572
587
|
const parentRootHex = toRootHex(parentRoot);
|
|
573
588
|
// Parent block must be known because state_transition would have failed otherwise.
|
|
@@ -585,6 +600,18 @@ export class ForkChoice {
|
|
|
585
600
|
},
|
|
586
601
|
});
|
|
587
602
|
}
|
|
603
|
+
// An execution engine verdict can invalidate the parent while this block is being verified. Inserting the
|
|
604
|
+
// block would put a viable node below an invalidated one, or poison the tree if this block is VALID
|
|
605
|
+
if (parentBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
606
|
+
throw new ForkChoiceError({
|
|
607
|
+
code: ForkChoiceErrorCode.INVALID_BLOCK,
|
|
608
|
+
err: {
|
|
609
|
+
code: InvalidBlockCode.PARENT_EXECUTION_INVALID,
|
|
610
|
+
root: parentRootHex,
|
|
611
|
+
hash: parentHashHex,
|
|
612
|
+
},
|
|
613
|
+
});
|
|
614
|
+
}
|
|
588
615
|
// Blocks cannot be in the future. If they are, their consideration must be delayed until
|
|
589
616
|
// the are in the past.
|
|
590
617
|
//
|
|
@@ -630,7 +657,7 @@ export class ForkChoice {
|
|
|
630
657
|
// Decide whether this block should receive proposer boost, and whether the block is timely.
|
|
631
658
|
// The store field `this.proposerBoostRoot` and `updateCheckpoints()` are mutated only after
|
|
632
659
|
// `protoArray.onBlock()` succeeds
|
|
633
|
-
const isTimely = this.isBlockReceivedTimely(block,
|
|
660
|
+
const isTimely = this.isBlockReceivedTimely(block, receiveDelayMs);
|
|
634
661
|
const isProposerBoostBlock = this.opts?.proposerBoost === true &&
|
|
635
662
|
isTimely &&
|
|
636
663
|
// only boost the first block we see
|
|
@@ -644,21 +671,26 @@ export class ForkChoice {
|
|
|
644
671
|
const finalizedCheckpoint = toCheckpointWithHex(state.finalizedCheckpoint);
|
|
645
672
|
const blockEpoch = computeEpochAtSlot(slot);
|
|
646
673
|
// same logic to compute_pulled_up_tip in the spec, making it inline because of reusing variables
|
|
647
|
-
// If the parent checkpoints are already at the same epoch as the
|
|
648
|
-
// it's impossible for the unrealized checkpoints to differ from the parent's.
|
|
649
|
-
// holds true because:
|
|
674
|
+
// If the block has no slashings and the parent checkpoints are already at the same epoch as the
|
|
675
|
+
// block being imported, it's impossible for the unrealized checkpoints to differ from the parent's.
|
|
676
|
+
// This holds true because:
|
|
650
677
|
//
|
|
651
678
|
// 1. A child block cannot have lower FFG checkpoints than its parent.
|
|
652
679
|
// 2. A block in epoch `N` cannot contain attestations which would justify an epoch higher than `N`.
|
|
653
680
|
// 3. A block in epoch `N` cannot contain attestations which would finalize an epoch higher than `N - 1`.
|
|
654
681
|
//
|
|
682
|
+
// Slashings are excluded because they can reduce the unslashed target balance of the child state
|
|
683
|
+
// and therefore lower its unrealized checkpoints.
|
|
684
|
+
//
|
|
655
685
|
// This is an optimization. It should reduce the amount of times we run
|
|
656
686
|
// `process_justification_and_finalization` by approximately 1/3rd when the chain is
|
|
657
687
|
// performing optimally.
|
|
658
688
|
let unrealizedJustifiedCheckpoint;
|
|
659
689
|
let unrealizedFinalizedCheckpoint;
|
|
660
690
|
if (this.opts?.computeUnrealized) {
|
|
661
|
-
if (
|
|
691
|
+
if (block.body.proposerSlashings.length === 0 &&
|
|
692
|
+
block.body.attesterSlashings.length === 0 &&
|
|
693
|
+
parentBlock.unrealizedJustifiedEpoch === blockEpoch &&
|
|
662
694
|
parentBlock.unrealizedFinalizedEpoch + 1 >= blockEpoch) {
|
|
663
695
|
// reuse from parent, happens at 1/3 last blocks of epoch as monitored in mainnet
|
|
664
696
|
unrealizedJustifiedCheckpoint = {
|
|
@@ -694,8 +726,8 @@ export class ForkChoice {
|
|
|
694
726
|
targetRoot: toRootHex(targetRoot),
|
|
695
727
|
stateRoot: toRootHex(block.stateRoot),
|
|
696
728
|
timeliness: isTimely,
|
|
697
|
-
ptcTimeliness: this.isBlockPtcTimely(block,
|
|
698
|
-
importedTimely: this.isBlockImportedTimely(block,
|
|
729
|
+
ptcTimeliness: this.isBlockPtcTimely(block, receiveDelayMs),
|
|
730
|
+
importedTimely: this.isBlockImportedTimely(block, importDelayMs),
|
|
699
731
|
proposerIndex: block.proposerIndex,
|
|
700
732
|
justifiedEpoch: stateJustifiedEpoch,
|
|
701
733
|
justifiedRoot: toRootHex(state.currentJustifiedCheckpoint.root),
|
|
@@ -725,7 +757,9 @@ export class ForkChoice {
|
|
|
725
757
|
executionPayloadBlockHash: parentBlockHashFromBid,
|
|
726
758
|
executionPayloadNumber: parentMeta.number,
|
|
727
759
|
executionPayloadGasLimit: parentMeta.gasLimit,
|
|
728
|
-
|
|
760
|
+
// The parent's default (PENDING) variant does not reflect a SYNCING parent payload, inheriting
|
|
761
|
+
// from the variant matching the bid's parent block hash keeps that payload from being marked VALID
|
|
762
|
+
executionStatus: this.getPostMergeExecStatus(parentBlock.executionStatus),
|
|
729
763
|
dataAvailabilityStatus,
|
|
730
764
|
};
|
|
731
765
|
})()
|
|
@@ -772,14 +806,8 @@ export class ForkChoice {
|
|
|
772
806
|
*
|
|
773
807
|
* https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#on_attestation
|
|
774
808
|
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
* too expensive to call again.
|
|
778
|
-
*
|
|
779
|
-
* ## Notes:
|
|
780
|
-
*
|
|
781
|
-
* The supplied `attestation` **must** pass the `in_valid_indexed_attestation` function as it
|
|
782
|
-
* will not be run here.
|
|
809
|
+
* Does not run `is_valid_indexed_attestation`. The caller must ensure all of its
|
|
810
|
+
* validity requirements except index ordering: `attestingIndices` may be unsorted.
|
|
783
811
|
*/
|
|
784
812
|
onAttestation(attestation, attDataRoot, forceImport) {
|
|
785
813
|
// Ignore any attestations to the zero hash.
|
|
@@ -902,6 +930,18 @@ export class ForkChoice {
|
|
|
902
930
|
* Spec: gloas/fork-choice.md#new-on_execution_payload
|
|
903
931
|
*/
|
|
904
932
|
onExecutionPayload(blockRoot, executionPayloadBlockHash, executionPayloadNumber, executionPayloadGasLimit, executionStatus, dataAvailabilityStatus) {
|
|
933
|
+
// Same guard as onBlock: the PENDING variant carries the status of the payload chain this block builds on
|
|
934
|
+
const pendingBlock = this.getBlockHexDefaultStatus(blockRoot);
|
|
935
|
+
if (pendingBlock?.executionStatus === ExecutionStatus.Invalid) {
|
|
936
|
+
throw new ForkChoiceError({
|
|
937
|
+
code: ForkChoiceErrorCode.INVALID_BLOCK,
|
|
938
|
+
err: {
|
|
939
|
+
code: InvalidBlockCode.PARENT_EXECUTION_INVALID,
|
|
940
|
+
root: pendingBlock.parentRoot,
|
|
941
|
+
hash: pendingBlock.executionPayloadBlockHash,
|
|
942
|
+
},
|
|
943
|
+
});
|
|
944
|
+
}
|
|
905
945
|
this.protoArray.onExecutionPayload(blockRoot, this.fcStore.currentSlot, executionPayloadBlockHash, executionPayloadNumber, executionPayloadGasLimit, this.proposerBoostRoot, executionStatus, dataAvailabilityStatus);
|
|
906
946
|
}
|
|
907
947
|
/**
|
|
@@ -1228,7 +1268,7 @@ export class ForkChoice {
|
|
|
1228
1268
|
}
|
|
1229
1269
|
/** Very expensive function, iterates the entire ProtoArray. TODO: Is this function even necessary? */
|
|
1230
1270
|
getBlockSummariesByParentRoot(parentRoot) {
|
|
1231
|
-
return this.protoArray.nodes.filter((node) => node.parentRoot === parentRoot);
|
|
1271
|
+
return this.protoArray.nodes.filter((node) => node.parentRoot === parentRoot && (!isGloasBlock(node) || node.payloadStatus === PayloadStatus.PENDING));
|
|
1232
1272
|
}
|
|
1233
1273
|
/** Very expensive function, iterates the entire ProtoArray. TODO: Is this function even necessary? */
|
|
1234
1274
|
getBlockSummariesAtSlot(slot) {
|
|
@@ -1236,7 +1276,7 @@ export class ForkChoice {
|
|
|
1236
1276
|
const blocksAtSlot = [];
|
|
1237
1277
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
1238
1278
|
const node = nodes[i];
|
|
1239
|
-
if (node.slot === slot) {
|
|
1279
|
+
if (node.slot === slot && (!isGloasBlock(node) || node.payloadStatus === PayloadStatus.PENDING)) {
|
|
1240
1280
|
blocksAtSlot.push(node);
|
|
1241
1281
|
}
|
|
1242
1282
|
}
|
|
@@ -1268,14 +1308,15 @@ export class ForkChoice {
|
|
|
1268
1308
|
* justified's status as well as validate the terminal conditions if terminal block
|
|
1269
1309
|
* becomes valid
|
|
1270
1310
|
*/
|
|
1271
|
-
validateLatestHash(execResponse) {
|
|
1311
|
+
validateLatestHash(execResponse, opts) {
|
|
1272
1312
|
try {
|
|
1273
|
-
this.protoArray.validateLatestHash(execResponse, this.fcStore.currentSlot);
|
|
1313
|
+
return this.protoArray.validateLatestHash(execResponse, this.fcStore.currentSlot, opts);
|
|
1274
1314
|
}
|
|
1275
1315
|
catch (e) {
|
|
1276
1316
|
if (e instanceof ProtoArrayError && e.type.code === ProtoArrayErrorCode.INVALID_LVH_EXECUTION_RESPONSE) {
|
|
1277
1317
|
this.irrecoverableError = e;
|
|
1278
1318
|
}
|
|
1319
|
+
return false;
|
|
1279
1320
|
}
|
|
1280
1321
|
}
|
|
1281
1322
|
/**
|
|
@@ -1437,9 +1478,9 @@ export class ForkChoice {
|
|
|
1437
1478
|
* Return true if the block is timely for the current slot.
|
|
1438
1479
|
* Child class can overwrite this for testing purpose.
|
|
1439
1480
|
*/
|
|
1440
|
-
isBlockReceivedTimely(block,
|
|
1481
|
+
isBlockReceivedTimely(block, blockDelayMs) {
|
|
1441
1482
|
const fork = this.config.getForkName(block.slot);
|
|
1442
|
-
const isBeforeLateBlockCutoff =
|
|
1483
|
+
const isBeforeLateBlockCutoff = blockDelayMs < this.config.getAttestationDueMs(fork);
|
|
1443
1484
|
return this.fcStore.currentSlot === block.slot && isBeforeLateBlockCutoff;
|
|
1444
1485
|
}
|
|
1445
1486
|
/**
|
|
@@ -1452,18 +1493,18 @@ export class ForkChoice {
|
|
|
1452
1493
|
*
|
|
1453
1494
|
* Child class can overwrite this for testing purpose.
|
|
1454
1495
|
*/
|
|
1455
|
-
isBlockPtcTimely(block,
|
|
1496
|
+
isBlockPtcTimely(block, blockDelayMs) {
|
|
1456
1497
|
const ptcThresholdMs = this.config.getSlotComponentDurationMs(this.config.getForkName(block.slot), this.config.PAYLOAD_ATTESTATION_DUE_BPS);
|
|
1457
|
-
return this.fcStore.currentSlot === block.slot &&
|
|
1498
|
+
return this.fcStore.currentSlot === block.slot && blockDelayMs < ptcThresholdMs;
|
|
1458
1499
|
}
|
|
1459
1500
|
/**
|
|
1460
1501
|
* Return true if THIS node finished importing the block before the attestation cutoff, ie. the
|
|
1461
1502
|
* block was imported in a timely manner for its own slot.
|
|
1462
1503
|
* This is not part of the spec, we use this to determine late canonical blocks.
|
|
1463
1504
|
*/
|
|
1464
|
-
isBlockImportedTimely(block,
|
|
1505
|
+
isBlockImportedTimely(block, importDelayMs) {
|
|
1465
1506
|
const fork = this.config.getForkName(block.slot);
|
|
1466
|
-
const isBeforeLateBlockCutoff =
|
|
1507
|
+
const isBeforeLateBlockCutoff = importDelayMs < this.config.getAttestationDueMs(fork);
|
|
1467
1508
|
return this.fcStore.currentSlot === block.slot && isBeforeLateBlockCutoff;
|
|
1468
1509
|
}
|
|
1469
1510
|
/**
|
|
@@ -1532,10 +1573,10 @@ export class ForkChoice {
|
|
|
1532
1573
|
/**
|
|
1533
1574
|
* https://github.com/ethereum/consensus-specs/blob/v1.5.0/specs/phase0/fork-choice.md#is_proposing_on_time
|
|
1534
1575
|
*/
|
|
1535
|
-
isProposingOnTime(
|
|
1576
|
+
isProposingOnTime(msFromSlot, slot) {
|
|
1536
1577
|
const fork = this.config.getForkName(slot);
|
|
1537
1578
|
const proposerReorgCutoff = this.config.getProposerReorgCutoffMs(fork);
|
|
1538
|
-
return
|
|
1579
|
+
return msFromSlot <= proposerReorgCutoff;
|
|
1539
1580
|
}
|
|
1540
1581
|
getPreMergeExecStatus(executionStatus) {
|
|
1541
1582
|
if (executionStatus !== ExecutionStatus.PreMerge)
|