@lodestar/beacon-node 1.51.0-dev.83da04fef3 → 1.51.0-dev.a1662c7de7
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/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +3 -0
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +95 -5
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +11 -11
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +46 -40
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +3 -2
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +49 -2
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +4 -0
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/types.js +5 -0
- package/lib/chain/blocks/types.js.map +1 -1
- package/lib/chain/chain.d.ts +2 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +5 -1
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +11 -1
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +2 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/inclusionList.d.ts +60 -0
- package/lib/chain/errors/inclusionList.d.ts.map +1 -0
- package/lib/chain/errors/inclusionList.js +19 -0
- package/lib/chain/errors/inclusionList.js.map +1 -0
- package/lib/chain/errors/index.d.ts +1 -0
- package/lib/chain/errors/index.d.ts.map +1 -1
- package/lib/chain/errors/index.js +1 -0
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/inclusionListStore.d.ts +63 -0
- package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -0
- package/lib/chain/opPools/inclusionListStore.js +171 -0
- package/lib/chain/opPools/inclusionListStore.js.map +1 -0
- package/lib/chain/opPools/index.d.ts +1 -0
- package/lib/chain/opPools/index.d.ts.map +1 -1
- package/lib/chain/opPools/index.js +1 -0
- package/lib/chain/opPools/index.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +30 -9
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +1 -0
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +1 -0
- package/lib/chain/regen/interface.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +33 -1
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/inclusionList.d.ts +14 -0
- package/lib/chain/validation/inclusionList.d.ts.map +1 -0
- package/lib/chain/validation/inclusionList.js +141 -0
- package/lib/chain/validation/inclusionList.js.map +1 -0
- package/lib/chain/validation/index.d.ts +1 -0
- package/lib/chain/validation/index.d.ts.map +1 -1
- package/lib/chain/validation/index.js +1 -0
- package/lib/chain/validation/index.js.map +1 -1
- package/lib/execution/builder/validateBid.d.ts.map +1 -1
- package/lib/execution/builder/validateBid.js +14 -1
- package/lib/execution/builder/validateBid.js.map +1 -1
- package/lib/execution/engine/disabled.d.ts +1 -0
- package/lib/execution/engine/disabled.d.ts.map +1 -1
- package/lib/execution/engine/disabled.js +3 -0
- package/lib/execution/engine/disabled.js.map +1 -1
- package/lib/execution/engine/http.d.ts +8 -2
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +28 -4
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +11 -2
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +3 -2
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.js +33 -9
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
- package/lib/execution/engine/mock.d.ts +1 -0
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +25 -3
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +4 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +13 -2
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +2 -1
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +3 -0
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/transport.d.ts +5 -2
- package/lib/execution/engine/transport.d.ts.map +1 -1
- package/lib/execution/engine/types.d.ts +24 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +12 -0
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +16 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +35 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +16 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +44 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +8 -2
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/gossip/interface.js +1 -0
- package/lib/network/gossip/interface.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +8 -0
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +13 -1
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/interface.d.ts +2 -1
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +2 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +5 -0
- package/lib/network/network.js.map +1 -1
- package/lib/network/peers/utils/enrSubnetsDeserialize.d.ts.map +1 -1
- package/lib/network/peers/utils/enrSubnetsDeserialize.js +5 -2
- package/lib/network/peers/utils/enrSubnetsDeserialize.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +40 -1
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
- package/lib/network/processor/gossipQueues/index.js +6 -0
- package/lib/network/processor/gossipQueues/index.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +5 -1
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/index.d.ts +5 -0
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +11 -1
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +6 -0
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts +10 -0
- package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts.map +1 -0
- package/lib/network/reqresp/handlers/inclusionListsByIndices.js +30 -0
- package/lib/network/reqresp/handlers/inclusionListsByIndices.js.map +1 -0
- package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/index.js +5 -0
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts +1 -0
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +5 -0
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
- package/lib/network/reqresp/rateLimit.js +4 -0
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +5 -2
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/reqresp/types.js +3 -0
- package/lib/network/reqresp/types.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/debug/index.ts +4 -0
- package/src/api/impl/validator/index.ts +125 -3
- package/src/chain/ColumnReconstructionTracker.ts +60 -41
- package/src/chain/blocks/importBlock.ts +3 -7
- package/src/chain/blocks/importExecutionPayload.ts +67 -2
- package/src/chain/blocks/types.ts +5 -0
- package/src/chain/chain.ts +5 -0
- package/src/chain/errors/executionPayloadBid.ts +12 -0
- package/src/chain/errors/inclusionList.ts +38 -0
- package/src/chain/errors/index.ts +1 -0
- package/src/chain/interface.ts +2 -0
- package/src/chain/opPools/inclusionListStore.ts +208 -0
- package/src/chain/opPools/index.ts +1 -0
- package/src/chain/produceBlock/produceBlockBody.ts +60 -18
- package/src/chain/regen/interface.ts +1 -0
- package/src/chain/validation/executionPayloadBid.ts +52 -2
- package/src/chain/validation/inclusionList.ts +183 -0
- package/src/chain/validation/index.ts +1 -0
- package/src/execution/builder/validateBid.ts +23 -2
- package/src/execution/engine/disabled.ts +4 -0
- package/src/execution/engine/http.ts +41 -5
- package/src/execution/engine/interface.ts +27 -3
- package/src/execution/engine/jsonRpcTransport.ts +46 -9
- package/src/execution/engine/mock.ts +26 -3
- package/src/execution/engine/payloadIdCache.ts +23 -4
- package/src/execution/engine/restTransport.ts +15 -1
- package/src/execution/engine/transport.ts +7 -2
- package/src/execution/engine/types.ts +35 -0
- package/src/metrics/metrics/beacon.ts +37 -0
- package/src/metrics/metrics/lodestar.ts +46 -0
- package/src/network/gossip/interface.ts +5 -0
- package/src/network/gossip/topic.ts +14 -0
- package/src/network/interface.ts +2 -0
- package/src/network/network.ts +11 -0
- package/src/network/peers/utils/enrSubnetsDeserialize.ts +5 -2
- package/src/network/processor/gossipHandlers.ts +52 -1
- package/src/network/processor/gossipQueues/index.ts +6 -0
- package/src/network/processor/gossipValidatorFn.ts +5 -0
- package/src/network/processor/index.ts +11 -1
- package/src/network/reqresp/ReqRespBeaconNode.ts +7 -0
- package/src/network/reqresp/handlers/inclusionListsByIndices.ts +44 -0
- package/src/network/reqresp/handlers/index.ts +5 -0
- package/src/network/reqresp/protocols.ts +6 -0
- package/src/network/reqresp/rateLimit.ts +4 -0
- package/src/network/reqresp/types.ts +6 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
+
import {NUMBER_OF_COLUMNS} from "@lodestar/params";
|
|
3
|
+
import {RootHex} from "@lodestar/types";
|
|
2
4
|
import {Logger, sleep} from "@lodestar/utils";
|
|
3
5
|
import {Metrics} from "../metrics/metrics.js";
|
|
4
6
|
import {DataColumnReconstructionCode, recoverDataColumnSidecars} from "../util/dataColumns.js";
|
|
7
|
+
import {JobItemQueue} from "../util/queue/index.js";
|
|
5
8
|
import {BlockInputColumns} from "./blocks/blockInput/index.js";
|
|
6
9
|
import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/index.js";
|
|
7
10
|
import {ChainEventEmitter} from "./emitter.js";
|
|
@@ -16,15 +19,22 @@ const RECONSTRUCTION_DELAY_MIN_BPS = 667;
|
|
|
16
19
|
*/
|
|
17
20
|
const RECONSTRUCTION_DELAY_MAX_BPS = 1000;
|
|
18
21
|
|
|
22
|
+
const QUEUE_MAX_LENGTH = 16;
|
|
23
|
+
|
|
24
|
+
export type ColumnReconstructionInput = BlockInputColumns | PayloadEnvelopeInput;
|
|
25
|
+
|
|
19
26
|
export type ColumnReconstructionTrackerInit = {
|
|
20
27
|
logger: Logger;
|
|
21
28
|
emitter: ChainEventEmitter;
|
|
22
29
|
metrics: Metrics | null;
|
|
23
30
|
config: ChainForkConfig;
|
|
31
|
+
signal: AbortSignal;
|
|
24
32
|
};
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
|
-
*
|
|
35
|
+
* Runs column reconstruction one block root at a time, in trigger order. A trigger for a root that is
|
|
36
|
+
* queued or in flight is a no-op. A root is removed once its attempt finishes so a later column can
|
|
37
|
+
* retry a failed attempt.
|
|
28
38
|
*/
|
|
29
39
|
export class ColumnReconstructionTracker {
|
|
30
40
|
logger: Logger;
|
|
@@ -32,62 +42,71 @@ export class ColumnReconstructionTracker {
|
|
|
32
42
|
metrics: Metrics | null;
|
|
33
43
|
config: ChainForkConfig;
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* This is sufficient to avoid duplicate calls since we only call this
|
|
39
|
-
* function when we see a new data column sidecar from gossip.
|
|
40
|
-
*/
|
|
41
|
-
lastBlockRootHex: string | null = null;
|
|
42
|
-
/** Track if a reconstruction attempt is in-flight */
|
|
43
|
-
running = false;
|
|
45
|
+
private readonly signal: AbortSignal;
|
|
46
|
+
private readonly pending = new Set<RootHex>();
|
|
47
|
+
private readonly queue: JobItemQueue<[ColumnReconstructionInput, number], void>;
|
|
44
48
|
|
|
45
49
|
constructor(init: ColumnReconstructionTrackerInit) {
|
|
46
50
|
this.logger = init.logger;
|
|
47
51
|
this.emitter = init.emitter;
|
|
48
52
|
this.metrics = init.metrics;
|
|
49
53
|
this.config = init.config;
|
|
54
|
+
this.signal = init.signal;
|
|
55
|
+
this.queue = new JobItemQueue(
|
|
56
|
+
this.reconstruct,
|
|
57
|
+
{maxLength: QUEUE_MAX_LENGTH, signal: init.signal},
|
|
58
|
+
init.metrics?.columnReconstructionQueue
|
|
59
|
+
);
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
triggerColumnReconstruction(input:
|
|
53
|
-
if (this.
|
|
62
|
+
triggerColumnReconstruction(input: ColumnReconstructionInput): void {
|
|
63
|
+
if (this.pending.has(input.blockRootHex)) {
|
|
54
64
|
return;
|
|
55
65
|
}
|
|
56
66
|
|
|
57
|
-
if (
|
|
67
|
+
if (input.getAllColumns().length < NUMBER_OF_COLUMNS / 2) {
|
|
58
68
|
return;
|
|
59
69
|
}
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
this.pending.add(input.blockRootHex);
|
|
72
|
+
void this.enqueue(input);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private async enqueue(input: ColumnReconstructionInput): Promise<void> {
|
|
76
|
+
try {
|
|
77
|
+
await this.queue.push(input, Date.now());
|
|
78
|
+
} catch (e) {
|
|
79
|
+
this.logger.debug(
|
|
80
|
+
"Data column sidecar reconstruction dropped",
|
|
81
|
+
{slot: input.slot, root: input.blockRootHex},
|
|
82
|
+
e as Error
|
|
83
|
+
);
|
|
84
|
+
} finally {
|
|
85
|
+
this.pending.delete(input.blockRootHex);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private reconstruct = async (input: ColumnReconstructionInput, queuedAtMs: number): Promise<void> => {
|
|
65
90
|
const fork = this.config.getForkName(input.slot);
|
|
66
91
|
const minDelayMs = this.config.getSlotComponentDurationMs(fork, RECONSTRUCTION_DELAY_MIN_BPS);
|
|
67
92
|
const maxDelayMs = this.config.getSlotComponentDurationMs(fork, RECONSTRUCTION_DELAY_MAX_BPS);
|
|
68
93
|
const delay = minDelayMs + Math.random() * (maxDelayMs - minDelayMs);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
})
|
|
89
|
-
.catch((err) => {
|
|
90
|
-
this.logger.debug("ColumnReconstructionTracker unreachable error", {}, err);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
94
|
+
|
|
95
|
+
// The delay gives gossip a chance to deliver the remaining columns, so time already spent in the
|
|
96
|
+
// queue behind another root counts towards it
|
|
97
|
+
await sleep(delay - (Date.now() - queuedAtMs), this.signal);
|
|
98
|
+
|
|
99
|
+
const logCtx = {slot: input.slot, root: input.blockRootHex};
|
|
100
|
+
this.logger.debug("Attempting data column sidecar reconstruction", logCtx);
|
|
101
|
+
try {
|
|
102
|
+
const result = await recoverDataColumnSidecars(input, this.emitter, this.metrics);
|
|
103
|
+
this.metrics?.recoverDataColumnSidecars.reconstructionResult.inc({result});
|
|
104
|
+
this.logger.debug("Data column sidecar reconstruction complete", {...logCtx, result});
|
|
105
|
+
} catch (e) {
|
|
106
|
+
this.metrics?.recoverDataColumnSidecars.reconstructionResult.inc({result: DataColumnReconstructionCode.Failed});
|
|
107
|
+
this.logger.debug("Error during data column sidecar reconstruction", logCtx, e as Error);
|
|
108
|
+
} finally {
|
|
109
|
+
this.logger.debug("Data column sidecar reconstruction attempt finished", logCtx);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
93
112
|
}
|
|
@@ -458,7 +458,8 @@ export async function importBlock(
|
|
|
458
458
|
* - `headBlockHash !== null` -> Pre BELLATRIX_EPOCH
|
|
459
459
|
* - `headBlockHash !== ZERO_HASH` -> Pre TTD
|
|
460
460
|
*/
|
|
461
|
-
const
|
|
461
|
+
const fcuHead = this.forkChoice.getHead();
|
|
462
|
+
const headBlockHash = fcuHead.executionPayloadBlockHash ?? ZERO_HASH_HEX;
|
|
462
463
|
/**
|
|
463
464
|
* After BELLATRIX_EPOCH and TTD it's okay to send a zero hash block hash for the finalized block. This will happen if
|
|
464
465
|
* the current finalized block does not contain any execution payload at all (pre MERGE_EPOCH) or if it contains a
|
|
@@ -468,12 +469,7 @@ export async function importBlock(
|
|
|
468
469
|
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
|
|
469
470
|
if (headBlockHash !== ZERO_HASH_HEX) {
|
|
470
471
|
this.executionEngine
|
|
471
|
-
.notifyForkchoiceUpdate(
|
|
472
|
-
this.config.getForkName(this.forkChoice.getHead().slot),
|
|
473
|
-
headBlockHash,
|
|
474
|
-
safeBlockHash,
|
|
475
|
-
finalizedBlockHash
|
|
476
|
-
)
|
|
472
|
+
.notifyForkchoiceUpdate(this.config.getForkName(fcuHead.slot), headBlockHash, safeBlockHash, finalizedBlockHash)
|
|
477
473
|
.catch((e) => {
|
|
478
474
|
if (!isErrorAborted(e) && !isQueueErrorAborted(e)) {
|
|
479
475
|
this.logger.error("Error pushing notifyForkchoiceUpdate()", {headBlockHash, finalizedBlockHash}, e);
|
|
@@ -5,9 +5,16 @@ import {
|
|
|
5
5
|
getFinalizedExecutionBlockHash,
|
|
6
6
|
getSafeExecutionBlockHash,
|
|
7
7
|
} from "@lodestar/fork-choice";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
DataAvailabilityStatus,
|
|
10
|
+
computeEpochAtSlot,
|
|
11
|
+
isStatePostGloas,
|
|
12
|
+
isStatePostHeze,
|
|
13
|
+
} from "@lodestar/state-transition";
|
|
14
|
+
import {RootHex, bellatrix} from "@lodestar/types";
|
|
9
15
|
import {isErrorAborted} from "@lodestar/utils";
|
|
10
16
|
import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
17
|
+
import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
|
|
11
18
|
import {isQueueErrorAborted} from "../../util/queue/index.js";
|
|
12
19
|
import {BeaconChain} from "../chain.js";
|
|
13
20
|
import {RegenCaller} from "../regen/interface.js";
|
|
@@ -172,6 +179,37 @@ export async function importExecutionPayload(
|
|
|
172
179
|
);
|
|
173
180
|
}
|
|
174
181
|
|
|
182
|
+
// Timely inclusion lists of the preceding slot, keyed by that slot's dependent root on the block's branch and
|
|
183
|
+
// resolved from the parent, which is at or before that slot. Gossip validation only accepts lists whose dependent
|
|
184
|
+
// block is in fork choice, so a dependent root fork choice cannot resolve (below the anchor after checkpoint sync)
|
|
185
|
+
// keys no stored list
|
|
186
|
+
let inclusionListTransactions: bellatrix.Transactions | undefined;
|
|
187
|
+
if (isStatePostHeze(blockState)) {
|
|
188
|
+
const inclusionListSlot = protoBlock.slot - 1;
|
|
189
|
+
let dependentRoot: RootHex | null = null;
|
|
190
|
+
const parentBlock = this.forkChoice.getBlockHexDefaultStatus(protoBlock.parentRoot);
|
|
191
|
+
if (parentBlock !== null) {
|
|
192
|
+
try {
|
|
193
|
+
dependentRoot = getShufflingDependentRoot(
|
|
194
|
+
this.forkChoice,
|
|
195
|
+
computeEpochAtSlot(inclusionListSlot),
|
|
196
|
+
computeEpochAtSlot(parentBlock.slot),
|
|
197
|
+
parentBlock
|
|
198
|
+
);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
this.logger.debug(
|
|
201
|
+
"Inclusion list dependent root not in fork choice, importing payload without lists",
|
|
202
|
+
{slot, root: blockRootHex},
|
|
203
|
+
e as Error
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
inclusionListTransactions =
|
|
208
|
+
dependentRoot === null
|
|
209
|
+
? []
|
|
210
|
+
: this.inclusionListStore.getInclusionListTransactions(inclusionListSlot, dependentRoot, true);
|
|
211
|
+
}
|
|
212
|
+
|
|
175
213
|
// 4a. Run EL and signature verification in parallel
|
|
176
214
|
const logCtx = {slot, root: blockRootHex, executionBlock: envelope.payload.blockNumber};
|
|
177
215
|
this.logger.debug("Call engine api newPayload", logCtx);
|
|
@@ -182,7 +220,8 @@ export async function importExecutionPayload(
|
|
|
182
220
|
envelope.payload,
|
|
183
221
|
payloadInput.getVersionedHashes(),
|
|
184
222
|
envelope.parentBeaconBlockRoot,
|
|
185
|
-
envelope.executionRequests
|
|
223
|
+
envelope.executionRequests,
|
|
224
|
+
inclusionListTransactions
|
|
186
225
|
),
|
|
187
226
|
|
|
188
227
|
opts.validSignature === true
|
|
@@ -250,6 +289,32 @@ export async function importExecutionPayload(
|
|
|
250
289
|
}
|
|
251
290
|
});
|
|
252
291
|
|
|
292
|
+
// A VALID payload that does not satisfy the inclusion list constraints is still imported, fork choice
|
|
293
|
+
// only records the verdict so should_extend_payload moves the head to the EMPTY variant, which the next
|
|
294
|
+
// proposer builds on.
|
|
295
|
+
// Recorded before the payload enters fork choice. A VALID response must carry a verdict, an
|
|
296
|
+
// optimistically imported payload counts as satisfied until the engine validates it, anything else as
|
|
297
|
+
// unsatisfied. A VALID response without a verdict violates the engine API, it is logged and treated as
|
|
298
|
+
// satisfied so a non-compliant engine does not orphan every payload
|
|
299
|
+
if (inclusionListTransactions !== undefined) {
|
|
300
|
+
if (execResult.status === ExecutionPayloadStatus.VALID && execResult.inclusionListSatisfied == null) {
|
|
301
|
+
this.logger.warn("Execution engine reported no inclusion list verdict, not enforcing inclusion lists", logCtx);
|
|
302
|
+
}
|
|
303
|
+
const satisfied =
|
|
304
|
+
execResult.status === ExecutionPayloadStatus.VALID
|
|
305
|
+
? (execResult.inclusionListSatisfied ?? true)
|
|
306
|
+
: execResult.status === ExecutionPayloadStatus.SYNCING || execResult.status === ExecutionPayloadStatus.ACCEPTED;
|
|
307
|
+
this.forkChoice.recordPayloadInclusionListSatisfaction(blockRootHex, satisfied);
|
|
308
|
+
if (!satisfied) {
|
|
309
|
+
this.logger.verbose("Payload did not satisfy inclusion list constraints", {
|
|
310
|
+
...logCtx,
|
|
311
|
+
blockHash: blockHashHex,
|
|
312
|
+
status: execResult.status,
|
|
313
|
+
inclusionListTransactions: inclusionListTransactions.length,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
253
318
|
// 6. Update fork choice, transitions the block's PENDING variant to FULL
|
|
254
319
|
const execStatus = toForkChoiceExecutionStatus(execResult.status);
|
|
255
320
|
this.forkChoice.onExecutionPayload(
|
|
@@ -12,6 +12,11 @@ export enum GossipedInputType {
|
|
|
12
12
|
dataColumn = "data_column",
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export enum InclusionListSource {
|
|
16
|
+
gossip = "gossip",
|
|
17
|
+
api = "api",
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
type DataColumnData = {
|
|
16
21
|
dataColumn: fulu.DataColumnSidecar;
|
|
17
22
|
dataColumnBytes: Uint8Array | null;
|
package/src/chain/chain.ts
CHANGED
|
@@ -100,6 +100,7 @@ import {
|
|
|
100
100
|
AttestationPool,
|
|
101
101
|
DeferredVoluntaryExitPool,
|
|
102
102
|
ExecutionPayloadBidPool,
|
|
103
|
+
InclusionListStore,
|
|
103
104
|
OpPool,
|
|
104
105
|
PayloadAttestationPool,
|
|
105
106
|
ProposerPreferencesPool,
|
|
@@ -198,6 +199,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
198
199
|
readonly executionPayloadBidPool: ExecutionPayloadBidPool;
|
|
199
200
|
readonly payloadAttestationPool: PayloadAttestationPool;
|
|
200
201
|
readonly proposerPreferencesPool = new ProposerPreferencesPool();
|
|
202
|
+
readonly inclusionListStore: InclusionListStore;
|
|
201
203
|
readonly opPool: OpPool;
|
|
202
204
|
readonly deferredVoluntaryExitPool: DeferredVoluntaryExitPool;
|
|
203
205
|
|
|
@@ -335,6 +337,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
335
337
|
this.payloadAttestationPool = new PayloadAttestationPool(config, clock, metrics);
|
|
336
338
|
this.opPool = new OpPool(config);
|
|
337
339
|
this.deferredVoluntaryExitPool = new DeferredVoluntaryExitPool(logger);
|
|
340
|
+
this.inclusionListStore = new InclusionListStore(config);
|
|
338
341
|
|
|
339
342
|
this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
|
|
340
343
|
this.seenContributionAndProof = new SeenContributionAndProof(metrics);
|
|
@@ -509,6 +512,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
509
512
|
emitter,
|
|
510
513
|
metrics,
|
|
511
514
|
config,
|
|
515
|
+
signal,
|
|
512
516
|
});
|
|
513
517
|
|
|
514
518
|
this.archiveStore = new ArchiveStore(
|
|
@@ -1831,6 +1835,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1831
1835
|
this.executionPayloadBidPool.prune(slot);
|
|
1832
1836
|
this.seenExecutionPayloadBids.prune(slot);
|
|
1833
1837
|
this.proposerPreferencesPool.prune(slot);
|
|
1838
|
+
this.inclusionListStore.prune(slot);
|
|
1834
1839
|
this.seenAttestationDatas.onSlot(slot);
|
|
1835
1840
|
this.reprocessController.onSlot(slot);
|
|
1836
1841
|
|
|
@@ -21,6 +21,8 @@ export enum ExecutionPayloadBidErrorCode {
|
|
|
21
21
|
NO_MATCHING_PROPOSER_PREFERENCES = "EXECUTION_PAYLOAD_BID_ERROR_NO_MATCHING_PROPOSER_PREFERENCES",
|
|
22
22
|
PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH",
|
|
23
23
|
PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH",
|
|
24
|
+
INCLUSION_LIST_BITS_NOT_INCLUSIVE = "EXECUTION_PAYLOAD_BID_ERROR_INCLUSION_LIST_BITS_NOT_INCLUSIVE",
|
|
25
|
+
BEFORE_INCLUSION_LIST_DEADLINE = "EXECUTION_PAYLOAD_BID_ERROR_BEFORE_INCLUSION_LIST_DEADLINE",
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export type ExecutionPayloadBidErrorType =
|
|
@@ -86,6 +88,16 @@ export type ExecutionPayloadBidErrorType =
|
|
|
86
88
|
bidFeeRecipient: string;
|
|
87
89
|
expectedFeeRecipient: string;
|
|
88
90
|
}
|
|
91
|
+
| {
|
|
92
|
+
code: ExecutionPayloadBidErrorCode.INCLUSION_LIST_BITS_NOT_INCLUSIVE;
|
|
93
|
+
builderIndex: BuilderIndex;
|
|
94
|
+
slot: Slot;
|
|
95
|
+
}
|
|
96
|
+
| {
|
|
97
|
+
code: ExecutionPayloadBidErrorCode.BEFORE_INCLUSION_LIST_DEADLINE;
|
|
98
|
+
builderIndex: BuilderIndex;
|
|
99
|
+
slot: Slot;
|
|
100
|
+
}
|
|
89
101
|
| {
|
|
90
102
|
code: ExecutionPayloadBidErrorCode.PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH;
|
|
91
103
|
builderIndex: BuilderIndex;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {Epoch, RootHex, Slot, ValidatorIndex} from "@lodestar/types";
|
|
2
|
+
import {GossipActionError} from "./gossipValidation.js";
|
|
3
|
+
|
|
4
|
+
export enum InclusionListErrorCode {
|
|
5
|
+
EMPTY_TRANSACTIONS = "INCLUSION_LIST_ERROR_EMPTY_TRANSACTIONS",
|
|
6
|
+
MAXIMUM_SIZE_EXCEEDED = "INCLUSION_LIST_ERROR_MAXIMUM_SIZE_EXCEEDED",
|
|
7
|
+
EMPTY_TRANSACTION = "INCLUSION_LIST_ERROR_EMPTY_TRANSACTION",
|
|
8
|
+
INVALID_SLOT = "INCLUSION_LIST_ERROR_INVALID_SLOT",
|
|
9
|
+
MORE_THAN_TWO = "INCLUSION_LIST_ERROR_MORE_THAN_TWO",
|
|
10
|
+
VALIDATOR_NOT_IN_COMMITTEE = "INCLUSION_LIST_ERROR_VALIDATOR_NOT_IN_COMMITTEE",
|
|
11
|
+
UNKNOWN_DEPENDENT_ROOT = "INCLUSION_LIST_ERROR_UNKNOWN_DEPENDENT_ROOT",
|
|
12
|
+
INVALID_DEPENDENT_ROOT_SLOT = "INCLUSION_LIST_ERROR_INVALID_DEPENDENT_ROOT_SLOT",
|
|
13
|
+
INVALID_DEPENDENT_ROOT = "INCLUSION_LIST_ERROR_INVALID_DEPENDENT_ROOT",
|
|
14
|
+
MISSING_SHUFFLING = "INCLUSION_LIST_ERROR_MISSING_SHUFFLING",
|
|
15
|
+
INVALID_SIGNATURE = "INCLUSION_LIST_ERROR_INVALID_SIGNATURE",
|
|
16
|
+
PRE_HEZE_SLOT = "INCLUSION_LIST_ERROR_PRE_HEZE_SLOT",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type InclusionListErrorType =
|
|
20
|
+
| {code: InclusionListErrorCode.EMPTY_TRANSACTIONS}
|
|
21
|
+
| {code: InclusionListErrorCode.MAXIMUM_SIZE_EXCEEDED; totalBytes: number; maxBytes: number}
|
|
22
|
+
| {code: InclusionListErrorCode.EMPTY_TRANSACTION; transactionIndex: number}
|
|
23
|
+
| {code: InclusionListErrorCode.INVALID_SLOT; inclusionListSlot: Slot; currentSlot: Slot}
|
|
24
|
+
| {code: InclusionListErrorCode.MORE_THAN_TWO; validatorIndex: ValidatorIndex}
|
|
25
|
+
| {code: InclusionListErrorCode.VALIDATOR_NOT_IN_COMMITTEE; validatorIndex: ValidatorIndex}
|
|
26
|
+
| {code: InclusionListErrorCode.UNKNOWN_DEPENDENT_ROOT; dependentRoot: RootHex}
|
|
27
|
+
| {
|
|
28
|
+
code: InclusionListErrorCode.INVALID_DEPENDENT_ROOT_SLOT;
|
|
29
|
+
dependentRoot: RootHex;
|
|
30
|
+
dependentSlot: Slot;
|
|
31
|
+
maxSlot: Slot;
|
|
32
|
+
}
|
|
33
|
+
| {code: InclusionListErrorCode.INVALID_DEPENDENT_ROOT; dependentRoot: RootHex; epoch: Epoch}
|
|
34
|
+
| {code: InclusionListErrorCode.MISSING_SHUFFLING; dependentRoot: RootHex; epoch: Epoch}
|
|
35
|
+
| {code: InclusionListErrorCode.INVALID_SIGNATURE}
|
|
36
|
+
| {code: InclusionListErrorCode.PRE_HEZE_SLOT; inclusionListSlot: Slot};
|
|
37
|
+
|
|
38
|
+
export class InclusionListError extends GossipActionError<InclusionListErrorType> {}
|
|
@@ -8,6 +8,7 @@ export * from "./envelopeReconstructionError.js";
|
|
|
8
8
|
export * from "./executionPayloadBid.js";
|
|
9
9
|
export * from "./executionPayloadEnvelope.js";
|
|
10
10
|
export * from "./gossipValidation.js";
|
|
11
|
+
export * from "./inclusionList.js";
|
|
11
12
|
export * from "./payloadAttestation.js";
|
|
12
13
|
export * from "./proposerPreferences.js";
|
|
13
14
|
export * from "./proposerSlashingError.js";
|
package/src/chain/interface.ts
CHANGED
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
AttestationPool,
|
|
50
50
|
DeferredVoluntaryExitPool,
|
|
51
51
|
ExecutionPayloadBidPool,
|
|
52
|
+
InclusionListStore,
|
|
52
53
|
OpPool,
|
|
53
54
|
PayloadAttestationPool,
|
|
54
55
|
ProposerPreferencesPool,
|
|
@@ -131,6 +132,7 @@ export interface IBeaconChain {
|
|
|
131
132
|
readonly executionPayloadBidPool: ExecutionPayloadBidPool;
|
|
132
133
|
readonly payloadAttestationPool: PayloadAttestationPool;
|
|
133
134
|
readonly proposerPreferencesPool: ProposerPreferencesPool;
|
|
135
|
+
readonly inclusionListStore: InclusionListStore;
|
|
134
136
|
readonly opPool: OpPool;
|
|
135
137
|
readonly deferredVoluntaryExitPool: DeferredVoluntaryExitPool;
|
|
136
138
|
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {BitArray} from "@chainsafe/ssz";
|
|
2
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
+
import {INCLUSION_LIST_COMMITTEE_SIZE} from "@lodestar/params";
|
|
4
|
+
import {RootHex, Slot, ValidatorIndex, bellatrix, heze, ssz} from "@lodestar/types";
|
|
5
|
+
import {MapDef, toHex, toRootHex} from "@lodestar/utils";
|
|
6
|
+
|
|
7
|
+
export enum InclusionListInsertOutcome {
|
|
8
|
+
/** Stored as a new entry. */
|
|
9
|
+
New = "New",
|
|
10
|
+
/** Slot is older than the prune horizon. */
|
|
11
|
+
Old = "Old",
|
|
12
|
+
/** Identical inclusion list already stored. */
|
|
13
|
+
Seen = "Seen",
|
|
14
|
+
/** New equivocation evidence: this validator already has a different inclusion list stored. */
|
|
15
|
+
Equivocating = "Equivocating",
|
|
16
|
+
/** Validator was already marked as an equivocator for this `(slot, dependent_root)`. */
|
|
17
|
+
SubsequentEquivocation = "SubsequentEquivocation",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type InclusionListEntry = {
|
|
21
|
+
signedInclusionList: heze.SignedInclusionList;
|
|
22
|
+
/** Positions of the validator in `get_inclusion_list_committee(state, slot)`, several when the committee cycles */
|
|
23
|
+
committeeIndices: number[];
|
|
24
|
+
/** Received before the inclusion list deadline of its slot. */
|
|
25
|
+
timely: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Spec `InclusionListStore`: inclusion lists keyed by `(slot, dependent_root)`, one per validator index.
|
|
30
|
+
* The committee position is recorded at insert time (gossip validation resolves it) so the bit-oriented
|
|
31
|
+
* reads need no shuffling lookup. Signed lists are kept so InclusionListsByIndices can serve them.
|
|
32
|
+
* A validator's first list stays stored and an equivocation marks the validator so reads skip it.
|
|
33
|
+
*/
|
|
34
|
+
export class InclusionListStore {
|
|
35
|
+
/** slot -> dependent_root -> validator index -> entry */
|
|
36
|
+
private readonly inclusionLists = new MapDef<Slot, MapDef<RootHex, Map<ValidatorIndex, InclusionListEntry>>>(
|
|
37
|
+
() => new MapDef<RootHex, Map<ValidatorIndex, InclusionListEntry>>(() => new Map())
|
|
38
|
+
);
|
|
39
|
+
/** slot -> dependent_root -> equivocating validator indices */
|
|
40
|
+
private readonly equivocators = new MapDef<Slot, MapDef<RootHex, Set<ValidatorIndex>>>(
|
|
41
|
+
() => new MapDef<RootHex, Set<ValidatorIndex>>(() => new Set())
|
|
42
|
+
);
|
|
43
|
+
/** slot -> dependent_root -> validator index -> count, for the p2p "first or second message" rule */
|
|
44
|
+
private readonly seenCounts = new MapDef<Slot, MapDef<RootHex, Map<ValidatorIndex, number>>>(
|
|
45
|
+
() => new MapDef<RootHex, Map<ValidatorIndex, number>>(() => new Map())
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
private lowestPermissibleSlot = 0;
|
|
49
|
+
|
|
50
|
+
constructor(private readonly config: BeaconConfig) {}
|
|
51
|
+
|
|
52
|
+
get size(): number {
|
|
53
|
+
let count = 0;
|
|
54
|
+
for (const byDependentRoot of this.inclusionLists.values()) {
|
|
55
|
+
for (const entries of byDependentRoot.values()) {
|
|
56
|
+
count += entries.size;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return count;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Late lists are stored with `timely=false` rather than dropped: they still count toward the
|
|
64
|
+
* non-timely view used to validate another node's `inclusion_list_bits`.
|
|
65
|
+
*/
|
|
66
|
+
process(
|
|
67
|
+
signedInclusionList: heze.SignedInclusionList,
|
|
68
|
+
committeeIndices: number[],
|
|
69
|
+
timely: boolean
|
|
70
|
+
): InclusionListInsertOutcome {
|
|
71
|
+
const inclusionList = signedInclusionList.message;
|
|
72
|
+
const {slot, validatorIndex} = inclusionList;
|
|
73
|
+
|
|
74
|
+
if (slot < this.lowestPermissibleSlot) {
|
|
75
|
+
return InclusionListInsertOutcome.Old;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const dependentRoot = toRootHex(inclusionList.dependentRoot);
|
|
79
|
+
const stored = this.inclusionLists.getOrDefault(slot).getOrDefault(dependentRoot);
|
|
80
|
+
|
|
81
|
+
const entry = stored.get(validatorIndex);
|
|
82
|
+
if (entry !== undefined) {
|
|
83
|
+
if (ssz.heze.InclusionList.equals(entry.signedInclusionList.message, inclusionList)) {
|
|
84
|
+
return InclusionListInsertOutcome.Seen;
|
|
85
|
+
}
|
|
86
|
+
const equivocators = this.equivocators.getOrDefault(slot).getOrDefault(dependentRoot);
|
|
87
|
+
if (equivocators.has(validatorIndex)) {
|
|
88
|
+
return InclusionListInsertOutcome.SubsequentEquivocation;
|
|
89
|
+
}
|
|
90
|
+
equivocators.add(validatorIndex);
|
|
91
|
+
return InclusionListInsertOutcome.Equivocating;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
stored.set(validatorIndex, {signedInclusionList, committeeIndices, timely});
|
|
95
|
+
return InclusionListInsertOutcome.New;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Count a valid message of `validatorIndex` for the first-or-second message gossip rule */
|
|
99
|
+
markSeen(slot: Slot, dependentRoot: RootHex, validatorIndex: ValidatorIndex): void {
|
|
100
|
+
const counts = this.seenCounts.getOrDefault(slot).getOrDefault(dependentRoot);
|
|
101
|
+
counts.set(validatorIndex, (counts.get(validatorIndex) ?? 0) + 1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Gossip rule: at most two valid messages per validator for a `(slot, dependent_root)` */
|
|
105
|
+
seenTwice(slot: Slot, dependentRoot: RootHex, validatorIndex: ValidatorIndex): boolean {
|
|
106
|
+
return (this.seenCounts.get(slot)?.get(dependentRoot)?.get(validatorIndex) ?? 0) >= 2;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Deduplicated transactions from valid, non-equivocating inclusion lists at `(slot, dependentRoot)`. */
|
|
110
|
+
getInclusionListTransactions(slot: Slot, dependentRoot: RootHex, onlyTimely = true): bellatrix.Transactions {
|
|
111
|
+
const transactions: bellatrix.Transactions = [];
|
|
112
|
+
const seen = new Set<string>();
|
|
113
|
+
|
|
114
|
+
for (const {signedInclusionList} of this.getEligible(slot, dependentRoot, onlyTimely)) {
|
|
115
|
+
for (const transaction of signedInclusionList.message.transactions) {
|
|
116
|
+
const key = toHex(transaction);
|
|
117
|
+
if (!seen.has(key)) {
|
|
118
|
+
seen.add(key);
|
|
119
|
+
transactions.push(transaction);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return transactions;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Bit `i` is set when committee member `i` submitted a valid, non-equivocating inclusion list */
|
|
128
|
+
getInclusionListBits(slot: Slot, dependentRoot: RootHex, onlyTimely = true): BitArray {
|
|
129
|
+
const bits = BitArray.fromBitLen(INCLUSION_LIST_COMMITTEE_SIZE);
|
|
130
|
+
for (const {committeeIndices} of this.getEligible(slot, dependentRoot, onlyTimely)) {
|
|
131
|
+
for (const committeeIndex of committeeIndices) {
|
|
132
|
+
bits.set(committeeIndex, true);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return bits;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* True if `bits` has a bit set for every bit set in the local inclusion list bits.
|
|
140
|
+
*
|
|
141
|
+
* Intentionally deviates from the spec by only checking against timely lists, where the proposer would check
|
|
142
|
+
* against every list it observed (only_timely=False in
|
|
143
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.4/specs/heze/validator.md#signed-execution-payload-bid).
|
|
144
|
+
* A bid that passed gossip must stay eligible, otherwise a list released after the deadline voids every bid and
|
|
145
|
+
* a high early bid with empty bits crowds out the rest without ever paying.
|
|
146
|
+
*/
|
|
147
|
+
isInclusionListBitsInclusive(slot: Slot, dependentRoot: RootHex, bits: BitArray): boolean {
|
|
148
|
+
for (const {committeeIndices} of this.getEligible(slot, dependentRoot, true)) {
|
|
149
|
+
if (committeeIndices.some((committeeIndex) => !bits.get(committeeIndex))) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Inclusion lists for the given committee positions, to serve InclusionListsByIndices. */
|
|
157
|
+
getByIndices(slot: Slot, dependentRoot: RootHex, indices: BitArray): heze.SignedInclusionList[] {
|
|
158
|
+
const out: heze.SignedInclusionList[] = [];
|
|
159
|
+
for (const {signedInclusionList, committeeIndices} of this.getEligible(slot, dependentRoot, false)) {
|
|
160
|
+
if (committeeIndices.some((committeeIndex) => indices.get(committeeIndex))) {
|
|
161
|
+
out.push(signedInclusionList);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Lists are retained for MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS slots so InclusionListsByIndices can serve them */
|
|
168
|
+
prune(clockSlot: Slot): void {
|
|
169
|
+
const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS;
|
|
170
|
+
|
|
171
|
+
for (const slot of this.inclusionLists.keys()) {
|
|
172
|
+
if (slot < horizon) {
|
|
173
|
+
this.inclusionLists.delete(slot);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
for (const slot of this.equivocators.keys()) {
|
|
177
|
+
if (slot < horizon) {
|
|
178
|
+
this.equivocators.delete(slot);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
for (const slot of this.seenCounts.keys()) {
|
|
182
|
+
if (slot < horizon) {
|
|
183
|
+
this.seenCounts.delete(slot);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.lowestPermissibleSlot = Math.max(horizon, 0);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Entries at `(slot, dependentRoot)` from non-equivocating validators, timely when required. */
|
|
191
|
+
private *getEligible(slot: Slot, dependentRoot: RootHex, onlyTimely: boolean): Generator<InclusionListEntry> {
|
|
192
|
+
const stored = this.inclusionLists.get(slot)?.get(dependentRoot);
|
|
193
|
+
if (!stored || stored.size === 0) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const equivocators = this.equivocators.get(slot)?.get(dependentRoot);
|
|
197
|
+
|
|
198
|
+
for (const [validatorIndex, entry] of stored) {
|
|
199
|
+
if (equivocators?.has(validatorIndex)) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (onlyTimely && !entry.timely) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
yield entry;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -2,6 +2,7 @@ export {AggregatedAttestationPool} from "./aggregatedAttestationPool.js";
|
|
|
2
2
|
export {AttestationPool} from "./attestationPool.js";
|
|
3
3
|
export {DeferredVoluntaryExitPool} from "./deferredVoluntaryExitPool.js";
|
|
4
4
|
export {ExecutionPayloadBidPool, type PooledExecutionPayloadBid} from "./executionPayloadBidPool.js";
|
|
5
|
+
export {InclusionListInsertOutcome, InclusionListStore} from "./inclusionListStore.js";
|
|
5
6
|
export {OpPool} from "./opPool.js";
|
|
6
7
|
export {PayloadAttestationPool} from "./payloadAttestationPool.js";
|
|
7
8
|
export {ProposerPreferencesPool} from "./proposerPreferencesPool.js";
|