@lodestar/fork-choice 1.43.0-dev.433e692fd9 → 1.43.0-dev.4358217e12
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/forkChoice.d.ts +25 -18
- package/lib/forkChoice/forkChoice.d.ts.map +1 -1
- package/lib/forkChoice/forkChoice.js +61 -66
- 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 +8 -21
- package/lib/protoArray/protoArray.js.map +1 -1
- package/package.json +8 -8
- package/src/forkChoice/forkChoice.ts +73 -108
- 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 +8 -31
|
@@ -2,7 +2,7 @@ import { DataAvailabilityStatus, EffectiveBalanceIncrements, IBeaconStateView }
|
|
|
2
2
|
import { AttesterSlashing, BeaconBlock, Epoch, IndexedAttestation, Root, RootHex, Slot } from "@lodestar/types";
|
|
3
3
|
import { BlockExecutionStatus, LVHExecResponse, PayloadExecutionStatus, PayloadStatus, ProtoBlock, ProtoNode } from "../protoArray/interface.js";
|
|
4
4
|
import { UpdateAndGetHeadOpt } from "./forkChoice.js";
|
|
5
|
-
import { CheckpointWithHex
|
|
5
|
+
import { CheckpointWithHex } from "./store.js";
|
|
6
6
|
export type CheckpointHex = {
|
|
7
7
|
epoch: Epoch;
|
|
8
8
|
root: RootHex;
|
|
@@ -11,11 +11,11 @@ export type CheckpointsWithHex = {
|
|
|
11
11
|
justifiedCheckpoint: CheckpointWithHex;
|
|
12
12
|
finalizedCheckpoint: CheckpointWithHex;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
checkpoint:
|
|
14
|
+
export type CheckpointWithBalance = {
|
|
15
|
+
checkpoint: CheckpointWithHex;
|
|
16
16
|
balances: EffectiveBalanceIncrements;
|
|
17
17
|
};
|
|
18
|
-
export type
|
|
18
|
+
export type CheckpointWithTotalBalance = CheckpointWithBalance & {
|
|
19
19
|
totalBalance: number;
|
|
20
20
|
};
|
|
21
21
|
export declare enum EpochDifference {
|
|
@@ -107,8 +107,8 @@ export interface IForkChoice {
|
|
|
107
107
|
* Retrieve all nodes for the debug API.
|
|
108
108
|
*/
|
|
109
109
|
getAllNodes(): ProtoNode[];
|
|
110
|
-
getFinalizedCheckpoint():
|
|
111
|
-
getJustifiedCheckpoint():
|
|
110
|
+
getFinalizedCheckpoint(): CheckpointWithHex;
|
|
111
|
+
getJustifiedCheckpoint(): CheckpointWithHex;
|
|
112
112
|
/**
|
|
113
113
|
* Add `block` to the fork choice DAG.
|
|
114
114
|
*
|
|
@@ -177,9 +177,8 @@ export interface IForkChoice {
|
|
|
177
177
|
* @param blockRoot - The beacon block root for which the payload arrived
|
|
178
178
|
* @param executionPayloadBlockHash - The block hash of the execution payload
|
|
179
179
|
* @param executionPayloadNumber - The block number of the execution payload
|
|
180
|
-
* @param executionPayloadStateRoot - The execution payload state root ie. the root of post-state after processExecutionPayloadEnvelope()
|
|
181
180
|
*/
|
|
182
|
-
onExecutionPayload(blockRoot: RootHex, executionPayloadBlockHash: RootHex, executionPayloadNumber: number,
|
|
181
|
+
onExecutionPayload(blockRoot: RootHex, executionPayloadBlockHash: RootHex, executionPayloadNumber: number, executionStatus: PayloadExecutionStatus): void;
|
|
183
182
|
/**
|
|
184
183
|
* Call `onTick` for all slots between `fcStore.getCurrentSlot()` and the provided `currentSlot`.
|
|
185
184
|
*/
|
|
@@ -213,6 +212,7 @@ export interface IForkChoice {
|
|
|
213
212
|
getBlockDefaultStatus(blockRoot: Root): ProtoBlock | null;
|
|
214
213
|
getBlockHexDefaultStatus(blockRoot: RootHex): ProtoBlock | null;
|
|
215
214
|
getBlockHexAndBlockHash(blockRoot: RootHex, blockHash: RootHex): ProtoBlock | null;
|
|
215
|
+
shouldExtendPayload(blockRoot: RootHex): boolean;
|
|
216
216
|
getFinalizedBlock(): ProtoBlock;
|
|
217
217
|
getJustifiedBlock(): ProtoBlock;
|
|
218
218
|
getFinalizedCheckpointSlot(): Slot;
|
|
@@ -239,11 +239,23 @@ export interface IForkChoice {
|
|
|
239
239
|
getAllNonAncestorBlocks(blockRoot: RootHex, payloadStatus: PayloadStatus): ProtoBlock[];
|
|
240
240
|
/**
|
|
241
241
|
* Returns both ancestor and non-ancestor blocks in a single traversal.
|
|
242
|
+
*
|
|
243
|
+
* `ancestors` is the raw walk and includes the previous finalized block as its last element —
|
|
244
|
+
* callers that don't want the boundary should slice it off themselves.
|
|
242
245
|
*/
|
|
243
246
|
getAllAncestorAndNonAncestorBlocks(blockRoot: RootHex, payloadStatus: PayloadStatus): {
|
|
244
247
|
ancestors: ProtoBlock[];
|
|
245
248
|
nonAncestors: ProtoBlock[];
|
|
246
249
|
};
|
|
250
|
+
/**
|
|
251
|
+
* Same as `getAllAncestorAndNonAncestorBlocks` but resolves the default payload-status variant
|
|
252
|
+
* (FULL pre-Gloas, PENDING for Gloas) for the given root. Use when the caller holds a
|
|
253
|
+
* `CheckpointWithHex` / finalized root without a specific payload-status variant in mind.
|
|
254
|
+
*/
|
|
255
|
+
getAllAncestorAndNonAncestorBlocksDefaultStatus(blockRoot: RootHex): {
|
|
256
|
+
ancestors: ProtoBlock[];
|
|
257
|
+
nonAncestors: ProtoBlock[];
|
|
258
|
+
};
|
|
247
259
|
getCanonicalBlockByRoot(blockRoot: Root): ProtoBlock | null;
|
|
248
260
|
getCanonicalBlockAtSlot(slot: Slot): ProtoBlock | null;
|
|
249
261
|
getCanonicalBlockClosestLteSlot(slot: Slot): ProtoBlock | null;
|
|
@@ -255,6 +267,12 @@ export interface IForkChoice {
|
|
|
255
267
|
* Iterates forward descendants of blockRoot. Does not yield blockRoot itself
|
|
256
268
|
*/
|
|
257
269
|
forwardIterateDescendants(blockRoot: RootHex, payloadStatus: PayloadStatus): IterableIterator<ProtoBlock>;
|
|
270
|
+
/**
|
|
271
|
+
* Same as `forwardIterateDescendants` but resolves the default payload-status variant
|
|
272
|
+
* (FULL pre-Gloas, PENDING for Gloas) for the given root. Use when the caller holds a
|
|
273
|
+
* `CheckpointWithHex` / finalized root without a specific payload-status variant in mind.
|
|
274
|
+
*/
|
|
275
|
+
forwardIterateDescendantsDefaultStatus(blockRoot: RootHex): IterableIterator<ProtoBlock>;
|
|
258
276
|
getBlockSummariesByParentRoot(parentRoot: RootHex): ProtoBlock[];
|
|
259
277
|
getBlockSummariesAtSlot(slot: Slot): ProtoBlock[];
|
|
260
278
|
/** Returns the distance of common ancestor of nodes to the max of the newNode and the prevNode. */
|
|
@@ -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,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,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/forkChoice/interface.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1,6 @@
|
|
|
1
1
|
import { EffectiveBalanceIncrements, IBeaconStateView } from "@lodestar/state-transition";
|
|
2
2
|
import { RootHex, Slot, ValidatorIndex, phase0 } from "@lodestar/types";
|
|
3
|
-
import {
|
|
4
|
-
import { CheckpointWithPayloadAndBalance, CheckpointWithPayloadAndTotalBalance } from "./interface.js";
|
|
3
|
+
import { CheckpointWithBalance, CheckpointWithTotalBalance } from "./interface.js";
|
|
5
4
|
/**
|
|
6
5
|
* Stores checkpoints in a hybrid format:
|
|
7
6
|
* - Original checkpoint for fast consumption in Lodestar's side
|
|
@@ -10,16 +9,6 @@ import { CheckpointWithPayloadAndBalance, CheckpointWithPayloadAndTotalBalance }
|
|
|
10
9
|
export type CheckpointWithHex = phase0.Checkpoint & {
|
|
11
10
|
rootHex: RootHex;
|
|
12
11
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Checkpoint with payload status for Gloas fork choice.
|
|
15
|
-
* Used to track which variant (EMPTY or FULL) of the finalized/justified block to use.
|
|
16
|
-
*
|
|
17
|
-
* Pre-Gloas: payloadStatus is always FULL (payload embedded in block)
|
|
18
|
-
* Gloas: determined by state.execution_payload_availability
|
|
19
|
-
*/
|
|
20
|
-
export type CheckpointWithPayloadStatus = CheckpointWithHex & {
|
|
21
|
-
payloadStatus: PayloadStatus;
|
|
22
|
-
};
|
|
23
12
|
export type JustifiedBalances = EffectiveBalanceIncrements;
|
|
24
13
|
/**
|
|
25
14
|
* Returns the justified balances of checkpoint.
|
|
@@ -27,7 +16,7 @@ export type JustifiedBalances = EffectiveBalanceIncrements;
|
|
|
27
16
|
* `blockState` is maybe used as a fallback state to get balances since it's very close to desired justified state.
|
|
28
17
|
* @param blockState state that declares justified checkpoint `checkpoint`
|
|
29
18
|
*/
|
|
30
|
-
export type JustifiedBalancesGetter = (checkpoint:
|
|
19
|
+
export type JustifiedBalancesGetter = (checkpoint: CheckpointWithHex, blockState: IBeaconStateView) => JustifiedBalances;
|
|
31
20
|
/**
|
|
32
21
|
* Approximates the `Store` in "Ethereum Consensus -- Beacon Chain Fork Choice":
|
|
33
22
|
*
|
|
@@ -42,11 +31,11 @@ export type JustifiedBalancesGetter = (checkpoint: CheckpointWithPayloadStatus,
|
|
|
42
31
|
*/
|
|
43
32
|
export interface IForkChoiceStore {
|
|
44
33
|
currentSlot: Slot;
|
|
45
|
-
get justified():
|
|
46
|
-
set justified(justified:
|
|
47
|
-
unrealizedJustified:
|
|
48
|
-
finalizedCheckpoint:
|
|
49
|
-
unrealizedFinalizedCheckpoint:
|
|
34
|
+
get justified(): CheckpointWithTotalBalance;
|
|
35
|
+
set justified(justified: CheckpointWithBalance);
|
|
36
|
+
unrealizedJustified: CheckpointWithBalance;
|
|
37
|
+
finalizedCheckpoint: CheckpointWithHex;
|
|
38
|
+
unrealizedFinalizedCheckpoint: CheckpointWithHex;
|
|
50
39
|
justifiedBalancesGetter: JustifiedBalancesGetter;
|
|
51
40
|
equivocatingIndices: Set<ValidatorIndex>;
|
|
52
41
|
}
|
|
@@ -56,35 +45,22 @@ export interface IForkChoiceStore {
|
|
|
56
45
|
export declare class ForkChoiceStore implements IForkChoiceStore {
|
|
57
46
|
private readonly events?;
|
|
58
47
|
private _justified;
|
|
59
|
-
unrealizedJustified:
|
|
48
|
+
unrealizedJustified: CheckpointWithBalance;
|
|
60
49
|
private _finalizedCheckpoint;
|
|
61
|
-
unrealizedFinalizedCheckpoint:
|
|
50
|
+
unrealizedFinalizedCheckpoint: CheckpointWithHex;
|
|
62
51
|
equivocatingIndices: Set<number>;
|
|
63
52
|
justifiedBalancesGetter: JustifiedBalancesGetter;
|
|
64
53
|
currentSlot: Slot;
|
|
65
|
-
constructor(currentSlot: Slot, justifiedCheckpoint: phase0.Checkpoint, finalizedCheckpoint: phase0.Checkpoint, justifiedBalances: EffectiveBalanceIncrements, justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
* Pre-Gloas: always FULL
|
|
69
|
-
* Gloas: determined by state.execution_payload_availability
|
|
70
|
-
*/
|
|
71
|
-
justifiedPayloadStatus: PayloadStatus,
|
|
72
|
-
/**
|
|
73
|
-
* Payload status for finalized checkpoint.
|
|
74
|
-
* Pre-Gloas: always FULL
|
|
75
|
-
* Gloas: determined by state.execution_payload_availability
|
|
76
|
-
*/
|
|
77
|
-
finalizedPayloadStatus: PayloadStatus, events?: {
|
|
78
|
-
onJustified: (cp: CheckpointWithPayloadStatus) => void;
|
|
79
|
-
onFinalized: (cp: CheckpointWithPayloadStatus) => void;
|
|
54
|
+
constructor(currentSlot: Slot, justifiedCheckpoint: phase0.Checkpoint, finalizedCheckpoint: phase0.Checkpoint, justifiedBalances: EffectiveBalanceIncrements, justifiedBalancesGetter: JustifiedBalancesGetter, events?: {
|
|
55
|
+
onJustified: (cp: CheckpointWithHex) => void;
|
|
56
|
+
onFinalized: (cp: CheckpointWithHex) => void;
|
|
80
57
|
} | undefined);
|
|
81
|
-
get justified():
|
|
82
|
-
set justified(justified:
|
|
83
|
-
get finalizedCheckpoint():
|
|
84
|
-
set finalizedCheckpoint(checkpoint:
|
|
58
|
+
get justified(): CheckpointWithTotalBalance;
|
|
59
|
+
set justified(justified: CheckpointWithBalance);
|
|
60
|
+
get finalizedCheckpoint(): CheckpointWithHex;
|
|
61
|
+
set finalizedCheckpoint(checkpoint: CheckpointWithHex);
|
|
85
62
|
}
|
|
86
63
|
export declare function toCheckpointWithHex(checkpoint: phase0.Checkpoint): CheckpointWithHex;
|
|
87
|
-
export declare function toCheckpointWithPayload(checkpoint: phase0.Checkpoint, payloadStatus: PayloadStatus): CheckpointWithPayloadStatus;
|
|
88
64
|
export declare function equalCheckpointWithHex(a: CheckpointWithHex, b: CheckpointWithHex): boolean;
|
|
89
65
|
export declare function computeTotalBalance(balances: EffectiveBalanceIncrements): number;
|
|
90
66
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/fork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AAC,MAAM,CAAC;IAd1B,OAAO,CAAC,UAAU,CAA6B;IAC/C,mBAAmB,EAAE,qBAAqB,CAAC;IAC3C,OAAO,CAAC,oBAAoB,CAAoB;IAChD,6BAA6B,EAAE,iBAAiB,CAAC;IACjD,mBAAmB,cAA6B;IAChD,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,WAAW,EAAE,IAAI,CAAC;IAElB,YACE,WAAW,EAAE,IAAI,EACjB,mBAAmB,EAAE,MAAM,CAAC,UAAU,EACtC,mBAAmB,EAAE,MAAM,CAAC,UAAU,EACtC,iBAAiB,EAAE,0BAA0B,EAC7C,uBAAuB,EAAE,uBAAuB,EAC/B,MAAM,CAAC;;;iBAGvB,EAaF;IAED,IAAI,SAAS,IAAI,0BAA0B,CAE1C;IACD,IAAI,SAAS,CAAC,SAAS,EAAE,qBAAqB,EAG7C;IAED,IAAI,mBAAmB,IAAI,iBAAiB,CAE3C;IACD,IAAI,mBAAmB,CAAC,UAAU,EAAE,iBAAiB,EAIpD;CACF;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,GAAG,iBAAiB,CASpF;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAE1F;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,GAAG,MAAM,CAMhF"}
|
package/lib/forkChoice/store.js
CHANGED
|
@@ -11,30 +11,18 @@ export class ForkChoiceStore {
|
|
|
11
11
|
equivocatingIndices = new Set();
|
|
12
12
|
justifiedBalancesGetter;
|
|
13
13
|
currentSlot;
|
|
14
|
-
constructor(currentSlot, justifiedCheckpoint, finalizedCheckpoint, justifiedBalances, justifiedBalancesGetter,
|
|
15
|
-
/**
|
|
16
|
-
* Payload status for justified checkpoint.
|
|
17
|
-
* Pre-Gloas: always FULL
|
|
18
|
-
* Gloas: determined by state.execution_payload_availability
|
|
19
|
-
*/
|
|
20
|
-
justifiedPayloadStatus,
|
|
21
|
-
/**
|
|
22
|
-
* Payload status for finalized checkpoint.
|
|
23
|
-
* Pre-Gloas: always FULL
|
|
24
|
-
* Gloas: determined by state.execution_payload_availability
|
|
25
|
-
*/
|
|
26
|
-
finalizedPayloadStatus, events) {
|
|
14
|
+
constructor(currentSlot, justifiedCheckpoint, finalizedCheckpoint, justifiedBalances, justifiedBalancesGetter, events) {
|
|
27
15
|
this.events = events;
|
|
28
16
|
this.justifiedBalancesGetter = justifiedBalancesGetter;
|
|
29
17
|
this.currentSlot = currentSlot;
|
|
30
18
|
const justified = {
|
|
31
|
-
checkpoint:
|
|
19
|
+
checkpoint: toCheckpointWithHex(justifiedCheckpoint),
|
|
32
20
|
balances: justifiedBalances,
|
|
33
21
|
totalBalance: computeTotalBalance(justifiedBalances),
|
|
34
22
|
};
|
|
35
23
|
this._justified = justified;
|
|
36
24
|
this.unrealizedJustified = justified;
|
|
37
|
-
this._finalizedCheckpoint =
|
|
25
|
+
this._finalizedCheckpoint = toCheckpointWithHex(finalizedCheckpoint);
|
|
38
26
|
this.unrealizedFinalizedCheckpoint = this._finalizedCheckpoint;
|
|
39
27
|
}
|
|
40
28
|
get justified() {
|
|
@@ -48,7 +36,7 @@ export class ForkChoiceStore {
|
|
|
48
36
|
return this._finalizedCheckpoint;
|
|
49
37
|
}
|
|
50
38
|
set finalizedCheckpoint(checkpoint) {
|
|
51
|
-
const cp =
|
|
39
|
+
const cp = toCheckpointWithHex(checkpoint);
|
|
52
40
|
this._finalizedCheckpoint = cp;
|
|
53
41
|
this.events?.onFinalized(cp);
|
|
54
42
|
}
|
|
@@ -63,12 +51,6 @@ export function toCheckpointWithHex(checkpoint) {
|
|
|
63
51
|
rootHex: toRootHex(root),
|
|
64
52
|
};
|
|
65
53
|
}
|
|
66
|
-
export function toCheckpointWithPayload(checkpoint, payloadStatus) {
|
|
67
|
-
return {
|
|
68
|
-
...toCheckpointWithHex(checkpoint),
|
|
69
|
-
payloadStatus,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
54
|
export function equalCheckpointWithHex(a, b) {
|
|
73
55
|
return a.epoch === b.epoch && a.rootHex === b.rootHex;
|
|
74
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/forkChoice/store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/forkChoice/store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AA8C1C;;GAEG;AACH,MAAM,OAAO,eAAe;IAeP,MAAM;IAdjB,UAAU,CAA6B;IAC/C,mBAAmB,CAAwB;IACnC,oBAAoB,CAAoB;IAChD,6BAA6B,CAAoB;IACjD,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,uBAAuB,CAA0B;IACjD,WAAW,CAAO;IAElB,YACE,WAAiB,EACjB,mBAAsC,EACtC,mBAAsC,EACtC,iBAA6C,EAC7C,uBAAgD,EAC/B,MAGhB,EACD;sBAJiB,MAAM;QAKvB,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;QACvD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,MAAM,SAAS,GAAG;YAChB,UAAU,EAAE,mBAAmB,CAAC,mBAAmB,CAAC;YACpD,QAAQ,EAAE,iBAAiB;YAC3B,YAAY,EAAE,mBAAmB,CAAC,iBAAiB,CAAC;SACrD,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;QACrE,IAAI,CAAC,6BAA6B,GAAG,IAAI,CAAC,oBAAoB,CAAC;IAAA,CAChE;IAED,IAAI,SAAS,GAA+B;Q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C,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,YAAY,CAAC;AAAA,CACrB"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ForkChoiceError, ForkChoiceErrorCode, type InvalidAttestation, InvalidAttestationCode, type InvalidBlock, InvalidBlockCode, } from "./forkChoice/errors.js";
|
|
2
|
-
export { ForkChoice, type ForkChoiceOpts, UpdateHeadOpt
|
|
3
|
-
export { type AncestorResult, AncestorStatus, type
|
|
2
|
+
export { ForkChoice, type ForkChoiceOpts, UpdateHeadOpt } from "./forkChoice/forkChoice.js";
|
|
3
|
+
export { type AncestorResult, AncestorStatus, type CheckpointWithBalance, type CheckpointWithTotalBalance, EpochDifference, type IForkChoice, NotReorgedReason, } from "./forkChoice/interface.js";
|
|
4
4
|
export * from "./forkChoice/safeBlocks.js";
|
|
5
|
-
export { type CheckpointWithHex,
|
|
5
|
+
export { type CheckpointWithHex, ForkChoiceStore, type IForkChoiceStore, type JustifiedBalancesGetter, } from "./forkChoice/store.js";
|
|
6
6
|
export { type ForkChoiceMetrics, getForkChoiceMetrics } from "./metrics.js";
|
|
7
7
|
export type { BlockExecutionStatus, BlockExtraMeta, LVHInvalidResponse, LVHValidResponse, PayloadExecutionStatus, ProtoBlock, ProtoNode, } from "./protoArray/interface.js";
|
|
8
8
|
export { ExecutionStatus, PayloadStatus, isGloasBlock } from "./protoArray/interface.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,
|
|
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,EAAC,UAAU,EAAE,KAAK,cAAc,EAAE,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAC1F,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,5 +1,5 @@
|
|
|
1
1
|
export { ForkChoiceError, ForkChoiceErrorCode, InvalidAttestationCode, InvalidBlockCode, } from "./forkChoice/errors.js";
|
|
2
|
-
export { ForkChoice, UpdateHeadOpt
|
|
2
|
+
export { ForkChoice, UpdateHeadOpt } from "./forkChoice/forkChoice.js";
|
|
3
3
|
export { AncestorStatus, EpochDifference, NotReorgedReason, } from "./forkChoice/interface.js";
|
|
4
4
|
export * from "./forkChoice/safeBlocks.js";
|
|
5
5
|
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,
|
|
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,EAAC,UAAU,EAAuB,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAC1F,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"}
|
|
@@ -143,7 +143,7 @@ export declare class ProtoArray {
|
|
|
143
143
|
*
|
|
144
144
|
* Spec: gloas/fork-choice.md (on_execution_payload event)
|
|
145
145
|
*/
|
|
146
|
-
onExecutionPayload(blockRoot: RootHex, currentSlot: Slot, executionPayloadBlockHash: RootHex, executionPayloadNumber: number,
|
|
146
|
+
onExecutionPayload(blockRoot: RootHex, currentSlot: Slot, executionPayloadBlockHash: RootHex, executionPayloadNumber: number, proposerBoostRoot: RootHex | null, executionStatus: PayloadExecutionStatus): void;
|
|
147
147
|
/**
|
|
148
148
|
* Update PTC votes for multiple validators attesting to a block
|
|
149
149
|
* Spec: gloas/fork-choice.md#new-on_payload_attestation_message
|
|
@@ -176,7 +176,7 @@ export declare class ProtoArray {
|
|
|
176
176
|
* Determine if we should extend the payload (prefer FULL over EMPTY)
|
|
177
177
|
* Spec: gloas/fork-choice.md#new-should_extend_payload
|
|
178
178
|
*
|
|
179
|
-
* Returns true if:
|
|
179
|
+
* Returns true if payload is verified (FULL variant exists) AND:
|
|
180
180
|
* 1. Payload is timely, OR
|
|
181
181
|
* 2. No proposer boost root (empty/zero hash), OR
|
|
182
182
|
* 3. Proposer boost root's parent is not this block, OR
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protoArray.d.ts","sourceRoot":"","sources":["../../src/protoArray/protoArray.ts"],"names":[],"mappings":"AAGA,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;AAQxB,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,KAAK,aAAa,GAAG;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC;AAIpD,yEAAyE;AACzE,KAAK,oBAAoB,GAAG,MAAM,CAAC;AACnC;;;;GAIG;AACH,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvE,KAAK,cAAc,GAAG,oBAAoB,GAAG,mBAAmB,CAAC;AAEjE,qBAAa,UAAU;IAGrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,KAAK,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,KAAK,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,SAAS,EAAE,CAAM;IACxB;;;;;;;;;OASG;IACH,OAAO,8BAAsC;IAC7C,QAAQ,CAAC,EAAE,YAAY,CAAC;I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xB"}
|
|
@@ -63,20 +63,6 @@ export class ProtoArray {
|
|
|
63
63
|
// We are using the blockROot as the targetRoot, since it always lies on an epoch boundary
|
|
64
64
|
targetRoot: block.blockRoot,
|
|
65
65
|
}, currentSlot, null);
|
|
66
|
-
// Anchor block PTC votes must be all-true per spec get_forkchoice_store:
|
|
67
|
-
// payload_timeliness_vote={anchor_root: Vector[boolean, PTC_SIZE](True for _ in range(PTC_SIZE))}
|
|
68
|
-
// Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.4/specs/gloas/fork-choice.md#modified-get_forkchoice_store
|
|
69
|
-
if (protoArray.ptcVotes.has(block.blockRoot)) {
|
|
70
|
-
protoArray.ptcVotes.set(block.blockRoot, BitArray.fromBoolArray(Array.from({ length: PTC_SIZE }, () => true)));
|
|
71
|
-
// In the spec, we have payload_states = {anchor_root: anchor_state.copy()}
|
|
72
|
-
// which means the anchor's "payload" is considered received
|
|
73
|
-
// Without FULL, blocks extending FULL from the anchor would be orphaned.
|
|
74
|
-
// TODO GLOAS: This is a bug in the spec. Keep this to pass the current spec test
|
|
75
|
-
// for now. Need to remove this when we work on v1.7.0-alpha.5
|
|
76
|
-
if (block.executionPayloadBlockHash !== null) {
|
|
77
|
-
protoArray.onExecutionPayload(block.blockRoot, currentSlot, block.executionPayloadBlockHash, block.executionPayloadNumber ?? 0, block.stateRoot, null, ExecutionStatus.Valid);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
66
|
return protoArray;
|
|
81
67
|
}
|
|
82
68
|
/**
|
|
@@ -442,7 +428,7 @@ export class ProtoArray {
|
|
|
442
428
|
*
|
|
443
429
|
* Spec: gloas/fork-choice.md (on_execution_payload event)
|
|
444
430
|
*/
|
|
445
|
-
onExecutionPayload(blockRoot, currentSlot, executionPayloadBlockHash, executionPayloadNumber,
|
|
431
|
+
onExecutionPayload(blockRoot, currentSlot, executionPayloadBlockHash, executionPayloadNumber, proposerBoostRoot, executionStatus) {
|
|
446
432
|
// First check if block exists
|
|
447
433
|
const variants = this.indices.get(blockRoot);
|
|
448
434
|
if (variants == null) {
|
|
@@ -490,7 +476,6 @@ export class ProtoArray {
|
|
|
490
476
|
executionStatus,
|
|
491
477
|
executionPayloadBlockHash,
|
|
492
478
|
executionPayloadNumber,
|
|
493
|
-
stateRoot: executionPayloadStateRoot,
|
|
494
479
|
};
|
|
495
480
|
const fullIndex = this.nodes.length;
|
|
496
481
|
this.nodes.push(fullNode);
|
|
@@ -558,7 +543,7 @@ export class ProtoArray {
|
|
|
558
543
|
* Determine if we should extend the payload (prefer FULL over EMPTY)
|
|
559
544
|
* Spec: gloas/fork-choice.md#new-should_extend_payload
|
|
560
545
|
*
|
|
561
|
-
* Returns true if:
|
|
546
|
+
* Returns true if payload is verified (FULL variant exists) AND:
|
|
562
547
|
* 1. Payload is timely, OR
|
|
563
548
|
* 2. No proposer boost root (empty/zero hash), OR
|
|
564
549
|
* 3. Proposer boost root's parent is not this block, OR
|
|
@@ -568,6 +553,9 @@ export class ProtoArray {
|
|
|
568
553
|
* @param proposerBoostRoot - Current proposer boost root (from ForkChoice)
|
|
569
554
|
*/
|
|
570
555
|
shouldExtendPayload(blockRoot, proposerBoostRoot) {
|
|
556
|
+
if (!this.hasPayload(blockRoot)) {
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
571
559
|
// Condition 1: Payload is timely
|
|
572
560
|
if (this.isPayloadTimely(blockRoot)) {
|
|
573
561
|
return true;
|
|
@@ -1403,10 +1391,9 @@ export class ProtoArray {
|
|
|
1403
1391
|
}
|
|
1404
1392
|
const ancestors = [];
|
|
1405
1393
|
const nonAncestors = [];
|
|
1406
|
-
//
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
}
|
|
1394
|
+
// caller of this method may pass default status
|
|
1395
|
+
// this is the only node that we accept PENDING
|
|
1396
|
+
ancestors.push(node);
|
|
1410
1397
|
let nodeIndex = startIndex;
|
|
1411
1398
|
while (node.parent !== undefined) {
|
|
1412
1399
|
const parentIndex = this.getParentNodeIndex(node);
|