@lodestar/beacon-node 1.52.0-dev.dad8e3af98 → 1.52.0-dev.deb8a48a68
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/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +2 -4
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +6 -1
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +7 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/lightClient/index.d.ts +13 -6
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +95 -115
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +45 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +265 -69
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +23 -15
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +17 -2
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +21 -5
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/execution/engine/blockHash.d.ts +12 -0
- package/lib/execution/engine/blockHash.d.ts.map +1 -0
- package/lib/execution/engine/blockHash.js +17 -0
- package/lib/execution/engine/blockHash.js.map +1 -0
- package/lib/execution/engine/http.d.ts +2 -2
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +13 -7
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +16 -3
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js +11 -0
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.js +4 -4
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -6
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +6 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +7 -2
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/restHttpClient.js +9 -5
- package/lib/execution/engine/restHttpClient.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +2 -2
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +4 -4
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/signal.d.ts +6 -0
- package/lib/execution/engine/signal.d.ts.map +1 -0
- package/lib/execution/engine/signal.js +24 -0
- package/lib/execution/engine/signal.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +2 -2
- package/lib/execution/engine/transport.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +5 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +5 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +1 -0
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +3 -0
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +6 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +22 -2
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
- package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.js +11 -2
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/sync/types.d.ts +2 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +123 -22
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +5 -4
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/package.json +26 -26
- package/src/api/impl/validator/index.ts +2 -4
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +8 -0
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +25 -16
- package/src/chain/validation/executionPayloadBid.ts +20 -2
- package/src/chain/validation/executionPayloadEnvelope.ts +28 -5
- package/src/execution/engine/blockHash.ts +27 -0
- package/src/execution/engine/http.ts +18 -10
- package/src/execution/engine/interface.ts +18 -3
- package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
- package/src/execution/engine/jsonRpcTransport.ts +8 -4
- package/src/execution/engine/mock.ts +13 -8
- package/src/execution/engine/payloadIdCache.ts +12 -4
- package/src/execution/engine/restHttpClient.ts +17 -11
- package/src/execution/engine/restTransport.ts +5 -4
- package/src/execution/engine/signal.ts +28 -0
- package/src/execution/engine/transport.ts +3 -2
- package/src/index.ts +6 -1
- package/src/metrics/metrics/beacon.ts +9 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/gossip/gossipsub.ts +4 -0
- package/src/network/network.ts +6 -2
- package/src/network/peers/peerManager.ts +26 -2
- package/src/network/peers/utils/prioritizePeers.ts +14 -1
- package/src/sync/types.ts +2 -0
- package/src/sync/unknownBlock.ts +133 -23
- package/src/sync/utils/downloadByRoot.ts +7 -5
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "@lodestar/state-transition";
|
|
8
8
|
import {gloas, ssz} from "@lodestar/types";
|
|
9
9
|
import {byteArrayEquals, toRootHex} from "@lodestar/utils";
|
|
10
|
+
import {computeExecutionBlockHash} from "../../execution/engine/blockHash.js";
|
|
10
11
|
import {
|
|
11
12
|
getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized,
|
|
12
13
|
getSlotFromExecutionPayloadEnvelopeSerialized,
|
|
@@ -55,7 +56,7 @@ export function validateGossipExecutionPayloadEnvelopeSerialized(
|
|
|
55
56
|
|
|
56
57
|
const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
|
|
57
58
|
if (BigInt(transactionCount) > maxTransactionCount) {
|
|
58
|
-
throw new ExecutionPayloadEnvelopeError(GossipAction.
|
|
59
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
59
60
|
code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
|
|
60
61
|
slot,
|
|
61
62
|
root: blockRootHex,
|
|
@@ -199,12 +200,13 @@ async function validateExecutionPayloadEnvelope(
|
|
|
199
200
|
});
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
//
|
|
203
|
+
// Execution request and withdrawal count limits are enforced by the SSZ list limits on decode
|
|
204
|
+
|
|
205
|
+
// [REJECT] The number of transactions is within the limit implied by the parent payload's gas limit,
|
|
206
|
+
// also checked before deserialization in validateGossipExecutionPayloadEnvelopeSerialized
|
|
205
207
|
const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
|
|
206
208
|
if (BigInt(payload.transactions.length) > maxTransactionCount) {
|
|
207
|
-
throw new ExecutionPayloadEnvelopeError(GossipAction.
|
|
209
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
208
210
|
code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
|
|
209
211
|
slot: payload.slotNumber,
|
|
210
212
|
root: blockRootHex,
|
|
@@ -251,6 +253,8 @@ async function validateExecutionPayloadEnvelope(
|
|
|
251
253
|
}
|
|
252
254
|
|
|
253
255
|
// [REJECT] The payload contains no empty transactions
|
|
256
|
+
// An empty transaction is a deletion in the transactions trie, so trailing empty transactions would not change
|
|
257
|
+
// the block hash. The EL rejects such a payload, as `verify_and_notify_new_payload` does before hashing.
|
|
254
258
|
for (let i = 0; i < payload.transactions.length; i++) {
|
|
255
259
|
if (payload.transactions.getSize(i) === 0) {
|
|
256
260
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
@@ -275,6 +279,25 @@ async function validateExecutionPayloadEnvelope(
|
|
|
275
279
|
});
|
|
276
280
|
}
|
|
277
281
|
|
|
282
|
+
// [REJECT] The payload's block hash is computed correctly
|
|
283
|
+
const timer = chain.metrics?.gossipExecutionPayloadEnvelope.blockHashTime.startTimer();
|
|
284
|
+
const computedBlockHash = computeExecutionBlockHash(
|
|
285
|
+
blockState.forkName,
|
|
286
|
+
payload,
|
|
287
|
+
envelope.parentBeaconBlockRoot,
|
|
288
|
+
envelope.executionRequests
|
|
289
|
+
);
|
|
290
|
+
timer?.();
|
|
291
|
+
if (!byteArrayEquals(computedBlockHash, payload.blockHash)) {
|
|
292
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
293
|
+
code: ExecutionPayloadEnvelopeErrorCode.INVALID_BLOCK_HASH,
|
|
294
|
+
slot: payload.slotNumber,
|
|
295
|
+
root: blockRootHex,
|
|
296
|
+
blockHash: toRootHex(payload.blockHash),
|
|
297
|
+
computedBlockHash: toRootHex(computedBlockHash),
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
278
301
|
// [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
|
|
279
302
|
// by `verify_execution_payload_envelope_signature`.
|
|
280
303
|
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {computeExecutionBlockHash as computeExecutionBlockHashNative} from "@lodestar/native/execution-block-hash";
|
|
2
|
+
import {ForkPostBellatrix, ForkSeq, isForkPostElectra} from "@lodestar/params";
|
|
3
|
+
import {ExecutionPayload, ExecutionRequests, Root, sszTypesFor} from "@lodestar/types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compute the execution block hash of `payload`: keccak256 of the RLP-encoded execution block header,
|
|
7
|
+
* with the header fields laid out as in execution-specs for the execution fork paired with `fork`.
|
|
8
|
+
*
|
|
9
|
+
* `parentBeaconBlockRoot` is required from deneb and `executionRequests` from electra.
|
|
10
|
+
*
|
|
11
|
+
* Throws if a transaction is empty. It would be a deletion in the transactions trie and not change the hash.
|
|
12
|
+
*/
|
|
13
|
+
export function computeExecutionBlockHash(
|
|
14
|
+
fork: ForkPostBellatrix,
|
|
15
|
+
payload: ExecutionPayload,
|
|
16
|
+
parentBeaconBlockRoot: Root | null,
|
|
17
|
+
executionRequests: ExecutionRequests | null
|
|
18
|
+
): Uint8Array {
|
|
19
|
+
return computeExecutionBlockHashNative(
|
|
20
|
+
ForkSeq[fork],
|
|
21
|
+
sszTypesFor(fork).ExecutionPayload.serialize(payload),
|
|
22
|
+
parentBeaconBlockRoot ?? undefined,
|
|
23
|
+
executionRequests !== null && isForkPostElectra(fork)
|
|
24
|
+
? sszTypesFor(fork).ExecutionRequests.serialize(executionRequests)
|
|
25
|
+
: undefined
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -2,7 +2,7 @@ import {Logger} from "@lodestar/logger";
|
|
|
2
2
|
import {ForkName, ForkPostFulu, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix} from "@lodestar/params";
|
|
3
3
|
import {BlobsBundle, ExecutionPayload, ExecutionRequests, Root, RootHex, Wei, bellatrix} from "@lodestar/types";
|
|
4
4
|
import {BlobAndProofV2} from "@lodestar/types/fulu";
|
|
5
|
-
import {isErrorAborted} from "@lodestar/utils";
|
|
5
|
+
import {ErrorAborted, isErrorAborted} from "@lodestar/utils";
|
|
6
6
|
import {Metrics} from "../../metrics/index.js";
|
|
7
7
|
import {EPOCHS_PER_BATCH} from "../../sync/constants.js";
|
|
8
8
|
import {getLodestarClientVersion} from "../../util/metadata.js";
|
|
@@ -11,6 +11,8 @@ import {JobItemQueue} from "../../util/queue/index.js";
|
|
|
11
11
|
import {
|
|
12
12
|
ClientVersion,
|
|
13
13
|
ExecutePayloadResponse,
|
|
14
|
+
ExecutionEngineError,
|
|
15
|
+
ExecutionEngineErrorCode,
|
|
14
16
|
ExecutionEngineState,
|
|
15
17
|
ExecutionPayloadStatus,
|
|
16
18
|
ForkchoiceUpdatedResult,
|
|
@@ -334,13 +336,18 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
334
336
|
headBlockHash: RootHex,
|
|
335
337
|
safeBlockHash: RootHex,
|
|
336
338
|
finalizedBlockHash: RootHex,
|
|
337
|
-
payloadAttributes?: PayloadAttributes
|
|
339
|
+
payloadAttributes?: PayloadAttributes,
|
|
340
|
+
signal?: AbortSignal
|
|
338
341
|
): Promise<ForkchoiceUpdatedResult> {
|
|
339
|
-
const result = await this.enqueue(() =>
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
const result = await this.enqueue(() => {
|
|
343
|
+
// Aborted while waiting in the queue, do not select a transport and sign a request that is not sent
|
|
344
|
+
if (signal?.aborted) {
|
|
345
|
+
throw new ErrorAborted("notifyForkchoiceUpdate");
|
|
346
|
+
}
|
|
347
|
+
return this.withTransport(fork, undefined, (transport) =>
|
|
348
|
+
transport.forkchoiceUpdated(fork, headBlockHash, safeBlockHash, finalizedBlockHash, payloadAttributes, signal)
|
|
349
|
+
);
|
|
350
|
+
});
|
|
344
351
|
const {
|
|
345
352
|
payloadStatus: {status},
|
|
346
353
|
payloadId,
|
|
@@ -373,7 +380,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
373
380
|
case ExecutionPayloadStatus.SYNCING:
|
|
374
381
|
// Throw error on syncing if requested to produce a block, else silently ignore
|
|
375
382
|
if (payloadAttributes) {
|
|
376
|
-
throw
|
|
383
|
+
throw new ExecutionEngineError({code: ExecutionEngineErrorCode.SYNCING}, "Execution Layer Syncing");
|
|
377
384
|
}
|
|
378
385
|
return result;
|
|
379
386
|
|
|
@@ -394,7 +401,8 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
394
401
|
*/
|
|
395
402
|
async getPayload(
|
|
396
403
|
fork: ForkName,
|
|
397
|
-
payloadId: PayloadId
|
|
404
|
+
payloadId: PayloadId,
|
|
405
|
+
signal?: AbortSignal
|
|
398
406
|
): Promise<{
|
|
399
407
|
executionPayload: ExecutionPayload;
|
|
400
408
|
executionPayloadValue: Wei;
|
|
@@ -402,7 +410,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
402
410
|
executionRequests?: ExecutionRequests;
|
|
403
411
|
shouldOverrideBuilder?: boolean;
|
|
404
412
|
}> {
|
|
405
|
-
return this.withTransport(fork, undefined, (transport) => transport.getPayload(fork, payloadId));
|
|
413
|
+
return this.withTransport(fork, undefined, (transport) => transport.getPayload(fork, payloadId, signal));
|
|
406
414
|
}
|
|
407
415
|
|
|
408
416
|
async prunePayloadIdCache(): Promise<void> {
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
capella,
|
|
20
20
|
} from "@lodestar/types";
|
|
21
21
|
import {BlobAndProofV2} from "@lodestar/types/fulu";
|
|
22
|
+
import {LodestarError} from "@lodestar/utils";
|
|
22
23
|
import {PayloadId, PayloadIdCache, WithdrawalV1} from "./payloadIdCache.js";
|
|
23
24
|
import {ExecutionPayloadBodyV2} from "./types.js";
|
|
24
25
|
import {DATA} from "./utils.js";
|
|
@@ -131,6 +132,18 @@ export type PayloadAttributes = {
|
|
|
131
132
|
|
|
132
133
|
export type VersionedHashes = Uint8Array[];
|
|
133
134
|
|
|
135
|
+
export enum ExecutionEngineErrorCode {
|
|
136
|
+
/**
|
|
137
|
+
* `notifyForkchoiceUpdate` requested a payload while the execution client is syncing, the head block is not
|
|
138
|
+
* available to build on yet
|
|
139
|
+
*/
|
|
140
|
+
SYNCING = "EXECUTION_ENGINE_ERROR_SYNCING",
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type ExecutionEngineErrorType = {code: ExecutionEngineErrorCode.SYNCING};
|
|
144
|
+
|
|
145
|
+
export class ExecutionEngineError extends LodestarError<ExecutionEngineErrorType> {}
|
|
146
|
+
|
|
134
147
|
/**
|
|
135
148
|
* Execution engine represents an abstract protocol to interact with execution clients. Potential transports include:
|
|
136
149
|
* - JSON RPC over network
|
|
@@ -180,14 +193,15 @@ export interface IExecutionEngine {
|
|
|
180
193
|
* Should be called in response to fork-choice head and finalized events.
|
|
181
194
|
*
|
|
182
195
|
* An INVALID verdict is returned, not thrown: the caller feeds it back into fork choice together with the
|
|
183
|
-
* `latestValidHash`. Only SYNCING while building a payload is an error
|
|
196
|
+
* `latestValidHash`. Only SYNCING while building a payload is an error, thrown as `ExecutionEngineError` with code `SYNCING`.
|
|
184
197
|
*/
|
|
185
198
|
notifyForkchoiceUpdate(
|
|
186
199
|
fork: ForkName,
|
|
187
200
|
headBlockHash: RootHex,
|
|
188
201
|
safeBlockHash: RootHex,
|
|
189
202
|
finalizedBlockHash: RootHex,
|
|
190
|
-
payloadAttributes?: PayloadAttributes
|
|
203
|
+
payloadAttributes?: PayloadAttributes,
|
|
204
|
+
signal?: AbortSignal
|
|
191
205
|
): Promise<ForkchoiceUpdatedResult>;
|
|
192
206
|
|
|
193
207
|
/**
|
|
@@ -199,7 +213,8 @@ export interface IExecutionEngine {
|
|
|
199
213
|
*/
|
|
200
214
|
getPayload(
|
|
201
215
|
fork: ForkName,
|
|
202
|
-
payloadId: PayloadId
|
|
216
|
+
payloadId: PayloadId,
|
|
217
|
+
signal?: AbortSignal
|
|
203
218
|
): Promise<{
|
|
204
219
|
executionPayload: ExecutionPayload;
|
|
205
220
|
executionPayloadValue: Wei;
|
|
@@ -2,6 +2,7 @@ import {EventEmitter} from "node:events";
|
|
|
2
2
|
import {StrictEventEmitter} from "strict-event-emitter-types";
|
|
3
3
|
import {ErrorAborted, Gauge, Histogram, TimeoutError, fetch, isValidHttpUrl, retry} from "@lodestar/utils";
|
|
4
4
|
import {JwtClaim, encodeJwtToken} from "./jwt.js";
|
|
5
|
+
import {withRequestSignal} from "./signal.js";
|
|
5
6
|
import {EngineTransportMetrics} from "./transportMetrics.js";
|
|
6
7
|
import {IJson, RpcPayload} from "./utils.js";
|
|
7
8
|
|
|
@@ -54,6 +55,8 @@ export type ReqOpts = {
|
|
|
54
55
|
retries?: number;
|
|
55
56
|
retryDelay?: number;
|
|
56
57
|
shouldRetry?: (lastError: Error) => boolean;
|
|
58
|
+
/** Aborts this request only, in addition to the signal of the client */
|
|
59
|
+
signal?: AbortSignal;
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
export type JsonRpcHttpClientMetrics = EngineTransportMetrics & {
|
|
@@ -157,19 +160,23 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
|
|
|
157
160
|
return this.wrapWithEvents(async () => {
|
|
158
161
|
const routeId = opts?.routeId ?? "unknown";
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
retries: opts?.retries ?? this.opts?.retries ?? 0,
|
|
166
|
-
retryDelay: opts?.retryDelay ?? this.opts?.retryDelay,
|
|
167
|
-
shouldRetry: opts?.shouldRetry,
|
|
168
|
-
signal: this.opts?.signal,
|
|
169
|
-
onRetry: () => {
|
|
170
|
-
this.opts?.metrics?.retryCount.inc({routeId});
|
|
163
|
+
// The delay between retries has to end with the request signal as well
|
|
164
|
+
const res = await withRequestSignal(this.opts?.signal, opts?.signal, (signal) =>
|
|
165
|
+
retry<RpcResponse<R>>(
|
|
166
|
+
async (_attempt) => {
|
|
167
|
+
return this.fetchJson({jsonrpc: "2.0", id: this.id++, ...payload}, opts);
|
|
171
168
|
},
|
|
172
|
-
|
|
169
|
+
{
|
|
170
|
+
retries: opts?.retries ?? this.opts?.retries ?? 0,
|
|
171
|
+
retryDelay: opts?.retryDelay ?? this.opts?.retryDelay,
|
|
172
|
+
// An aborted request is no longer of interest to its caller
|
|
173
|
+
shouldRetry: (lastError) => !opts?.signal?.aborted && (opts?.shouldRetry?.(lastError) ?? true),
|
|
174
|
+
signal,
|
|
175
|
+
onRetry: () => {
|
|
176
|
+
this.opts?.metrics?.retryCount.inc({routeId});
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
)
|
|
173
180
|
);
|
|
174
181
|
return parseRpcResponse(res, payload);
|
|
175
182
|
}, payload);
|
|
@@ -244,6 +251,10 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
|
|
|
244
251
|
|
|
245
252
|
const onParentSignalAbort = (): void => controller.abort();
|
|
246
253
|
this.opts?.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
|
|
254
|
+
opts?.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
|
|
255
|
+
if (opts?.signal?.aborted) {
|
|
256
|
+
controller.abort();
|
|
257
|
+
}
|
|
247
258
|
|
|
248
259
|
// Default to "unknown" to prevent mixing metrics with others.
|
|
249
260
|
const routeId = opts?.routeId ?? "unknown";
|
|
@@ -306,8 +317,8 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
|
|
|
306
317
|
} catch (e) {
|
|
307
318
|
this.metrics?.requestErrors.inc({routeId});
|
|
308
319
|
if (controller.signal.aborted) {
|
|
309
|
-
// controller will abort on
|
|
310
|
-
if (this.opts?.signal?.aborted) {
|
|
320
|
+
// controller will abort on parent signal abort, request signal abort + timeout of this specific request
|
|
321
|
+
if (this.opts?.signal?.aborted || opts?.signal?.aborted) {
|
|
311
322
|
throw new ErrorAborted("request");
|
|
312
323
|
}
|
|
313
324
|
throw new TimeoutError("request");
|
|
@@ -319,6 +330,7 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
|
|
|
319
330
|
|
|
320
331
|
clearTimeout(timeout);
|
|
321
332
|
this.opts?.signal?.removeEventListener("abort", onParentSignalAbort);
|
|
333
|
+
opts?.signal?.removeEventListener("abort", onParentSignalAbort);
|
|
322
334
|
}
|
|
323
335
|
}
|
|
324
336
|
}
|
|
@@ -141,7 +141,8 @@ export class JsonRpcEngineTransport implements IEngineTransport {
|
|
|
141
141
|
headBlockHash: RootHex,
|
|
142
142
|
safeBlockHash: RootHex,
|
|
143
143
|
finalizedBlockHash: RootHex,
|
|
144
|
-
payloadAttributes?: PayloadAttributes
|
|
144
|
+
payloadAttributes?: PayloadAttributes,
|
|
145
|
+
signal?: AbortSignal
|
|
145
146
|
): Promise<ForkchoiceUpdatedResult> {
|
|
146
147
|
const method =
|
|
147
148
|
ForkSeq[fork] >= ForkSeq.heze
|
|
@@ -161,12 +162,15 @@ export class JsonRpcEngineTransport implements IEngineTransport {
|
|
|
161
162
|
const {payloadStatus, payloadId} = await this.rpc.fetchWithRetries<
|
|
162
163
|
EngineApiRpcReturnTypes[typeof method],
|
|
163
164
|
EngineApiRpcParamTypes[typeof method]
|
|
164
|
-
>(
|
|
165
|
+
>(
|
|
166
|
+
{method, params: [{headBlockHash, safeBlockHash, finalizedBlockHash}, payloadAttributesRpc]},
|
|
167
|
+
{...fcUReqOpts, signal}
|
|
168
|
+
);
|
|
165
169
|
|
|
166
170
|
return {payloadStatus, payloadId: payloadId && payloadId !== "0x" ? payloadId : null};
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
async getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult> {
|
|
173
|
+
async getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult> {
|
|
170
174
|
let method: keyof EngineApiRpcReturnTypes;
|
|
171
175
|
switch (fork) {
|
|
172
176
|
case ForkName.phase0:
|
|
@@ -193,7 +197,7 @@ export class JsonRpcEngineTransport implements IEngineTransport {
|
|
|
193
197
|
const payloadResponse = await this.rpc.fetchWithRetries<
|
|
194
198
|
EngineApiRpcReturnTypes[typeof method],
|
|
195
199
|
EngineApiRpcParamTypes[typeof method]
|
|
196
|
-
>({method, params: [payloadId]}, getPayloadOpts);
|
|
200
|
+
>({method, params: [payloadId]}, {...getPayloadOpts, signal});
|
|
197
201
|
return parseExecutionPayload(fork, payloadResponse);
|
|
198
202
|
}
|
|
199
203
|
|
|
@@ -10,14 +10,16 @@ import {
|
|
|
10
10
|
ForkPostCapella,
|
|
11
11
|
ForkSeq,
|
|
12
12
|
SLOTS_PER_EPOCH,
|
|
13
|
+
isForkPostElectra,
|
|
13
14
|
} from "@lodestar/params";
|
|
14
15
|
import {computeTimeAtSlot} from "@lodestar/state-transition";
|
|
15
|
-
import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz} from "@lodestar/types";
|
|
16
|
+
import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz, sszTypesFor} from "@lodestar/types";
|
|
16
17
|
import {fromHex, toRootHex} from "@lodestar/utils";
|
|
17
18
|
import {ZERO_HASH_HEX} from "../../constants/index.js";
|
|
18
19
|
import {INTEROP_BLOCK_HASH} from "../../node/utils/interop/state.js";
|
|
19
20
|
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
|
|
20
21
|
import {kzg} from "../../util/kzg.js";
|
|
22
|
+
import {computeExecutionBlockHash} from "./blockHash.js";
|
|
21
23
|
import {ClientCode, ExecutionPayloadStatus, PayloadIdCache} from "./interface.js";
|
|
22
24
|
import {
|
|
23
25
|
BlobsBundleRpc,
|
|
@@ -351,7 +353,6 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
|
|
|
351
353
|
executionPayload.gasLimit = INTEROP_GAS_LIMIT;
|
|
352
354
|
executionPayload.gasUsed = Math.floor(0.5 * INTEROP_GAS_LIMIT);
|
|
353
355
|
executionPayload.timestamp = payloadAttributes.timestamp;
|
|
354
|
-
executionPayload.blockHash = crypto.randomBytes(32);
|
|
355
356
|
const transactions: Uint8Array[] = [];
|
|
356
357
|
|
|
357
358
|
// Between 0 and 4 transactions for all forks
|
|
@@ -401,6 +402,15 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
|
|
|
401
402
|
(executionPayload as gloas.ExecutionPayload).slotNumber = payloadAttributes.slotNumber;
|
|
402
403
|
}
|
|
403
404
|
|
|
405
|
+
const executionRequests = isForkPostElectra(fork) ? sszTypesFor(fork).ExecutionRequests.defaultValue() : null;
|
|
406
|
+
|
|
407
|
+
executionPayload.blockHash = computeExecutionBlockHash(
|
|
408
|
+
fork,
|
|
409
|
+
executionPayload,
|
|
410
|
+
payloadAttributes.parentBeaconBlockRoot ?? null,
|
|
411
|
+
executionRequests
|
|
412
|
+
);
|
|
413
|
+
|
|
404
414
|
this.preparingPayloads.set(payloadId, {
|
|
405
415
|
executionPayload: serializeExecutionPayload(fork, executionPayload),
|
|
406
416
|
blobsBundle: serializeBlobsBundle({
|
|
@@ -408,12 +418,7 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
|
|
|
408
418
|
blobs,
|
|
409
419
|
proofs,
|
|
410
420
|
}),
|
|
411
|
-
executionRequests: serializeExecutionRequests(
|
|
412
|
-
fork,
|
|
413
|
-
ForkSeq[fork] >= ForkSeq.gloas
|
|
414
|
-
? ssz.gloas.ExecutionRequests.defaultValue()
|
|
415
|
-
: ssz.electra.ExecutionRequests.defaultValue()
|
|
416
|
-
),
|
|
421
|
+
executionRequests: executionRequests !== null ? serializeExecutionRequests(fork, executionRequests) : [],
|
|
417
422
|
});
|
|
418
423
|
|
|
419
424
|
// IF the payload is deemed VALID and the build process has begun
|
|
@@ -12,6 +12,9 @@ const MAX_PAYLOAD_IDS = SLOTS_PER_EPOCH;
|
|
|
12
12
|
// Since we do no processing with this id, we have no need to deserialize it
|
|
13
13
|
export type PayloadId = string;
|
|
14
14
|
|
|
15
|
+
/** Payload id returned by the engine and when the payload was requested from it, monotonic `performance.now()` ms */
|
|
16
|
+
export type PreparedPayloadId = {payloadId: PayloadId; preparedAtMs: number};
|
|
17
|
+
|
|
15
18
|
export type WithdrawalV1 = {
|
|
16
19
|
index: QUANTITY;
|
|
17
20
|
validatorIndex: QUANTITY;
|
|
@@ -26,7 +29,7 @@ type FcuAttributes = {headBlockHash: DATA} & Omit<PayloadAttributesRpc, "withdra
|
|
|
26
29
|
export class PayloadIdCache {
|
|
27
30
|
private readonly payloadIdByFcuAttributes = new Map<
|
|
28
31
|
string,
|
|
29
|
-
|
|
32
|
+
PreparedPayloadId & {fullKey: string; inclusionListTransactions?: bellatrix.Transactions}
|
|
30
33
|
>();
|
|
31
34
|
|
|
32
35
|
getFullKey({headBlockHash, timestamp, prevRandao, suggestedFeeRecipient}: FcuAttributes): string {
|
|
@@ -45,7 +48,12 @@ export class PayloadIdCache {
|
|
|
45
48
|
const key = this.getKey(fcuAttributes);
|
|
46
49
|
const fullKey = this.getFullKey(fcuAttributes);
|
|
47
50
|
const {inclusionListTransactions} = fcuAttributes;
|
|
48
|
-
this.payloadIdByFcuAttributes.set(key, {
|
|
51
|
+
this.payloadIdByFcuAttributes.set(key, {
|
|
52
|
+
payloadId,
|
|
53
|
+
preparedAtMs: performance.now(),
|
|
54
|
+
fullKey,
|
|
55
|
+
inclusionListTransactions,
|
|
56
|
+
});
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
prune(): void {
|
|
@@ -53,13 +61,13 @@ export class PayloadIdCache {
|
|
|
53
61
|
pruneSetToMax(this.payloadIdByFcuAttributes, MAX_PAYLOAD_IDS);
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
get(fcuAttributes: FcuAttributes):
|
|
64
|
+
get(fcuAttributes: FcuAttributes): PreparedPayloadId | undefined {
|
|
57
65
|
const key = this.getKey(fcuAttributes);
|
|
58
66
|
const fullKey = this.getFullKey(fcuAttributes);
|
|
59
67
|
const payloadInfo = this.payloadIdByFcuAttributes.get(key);
|
|
60
68
|
return payloadInfo?.fullKey === fullKey &&
|
|
61
69
|
isSameInclusionList(payloadInfo.inclusionListTransactions, fcuAttributes.inclusionListTransactions)
|
|
62
|
-
? payloadInfo.payloadId
|
|
70
|
+
? {payloadId: payloadInfo.payloadId, preparedAtMs: payloadInfo.preparedAtMs}
|
|
63
71
|
: undefined;
|
|
64
72
|
}
|
|
65
73
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ReqOpts,
|
|
7
7
|
} from "./jsonRpcHttpClient.js";
|
|
8
8
|
import {JwtClaim, encodeJwtToken} from "./jwt.js";
|
|
9
|
+
import {withRequestSignal} from "./signal.js";
|
|
9
10
|
import {ExecutionForkName} from "./sszTypes.js";
|
|
10
11
|
|
|
11
12
|
export const ENGINE_REST_BASE_PATH = "/engine/v1";
|
|
@@ -115,15 +116,18 @@ export class EngineRestHttpClient {
|
|
|
115
116
|
/** Perform request with retries without emitting events, used to probe support for the REST API */
|
|
116
117
|
async requestWithRetries(req: EngineRestRequest, opts?: ReqOpts): Promise<EngineRestResponse> {
|
|
117
118
|
const routeId = opts?.routeId ?? "unknown";
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
// The delay between retries has to end with the request signal as well
|
|
120
|
+
return withRequestSignal(this.opts.signal, opts?.signal, (signal) =>
|
|
121
|
+
retry(() => this.requestAnyUrl(req, opts), {
|
|
122
|
+
retries: opts?.retries ?? this.opts.retries ?? 0,
|
|
123
|
+
retryDelay: opts?.retryDelay ?? this.opts.retryDelay,
|
|
124
|
+
shouldRetry: opts?.shouldRetry ?? isRetryableEngineRestError,
|
|
125
|
+
signal,
|
|
126
|
+
onRetry: () => {
|
|
127
|
+
this.metrics?.retryCount.inc({routeId});
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
);
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
private async requestAnyUrl(req: EngineRestRequest, opts?: ReqOpts): Promise<EngineRestResponse> {
|
|
@@ -154,7 +158,8 @@ export class EngineRestHttpClient {
|
|
|
154
158
|
// Not AbortSignal.any(), Node retains every composite until the long-lived parent signal aborts
|
|
155
159
|
const onParentSignalAbort = (): void => controller.abort();
|
|
156
160
|
this.opts.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
|
|
157
|
-
|
|
161
|
+
opts?.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
|
|
162
|
+
if (this.opts.signal?.aborted || opts?.signal?.aborted) {
|
|
158
163
|
controller.abort();
|
|
159
164
|
}
|
|
160
165
|
|
|
@@ -223,7 +228,7 @@ export class EngineRestHttpClient {
|
|
|
223
228
|
} catch (e) {
|
|
224
229
|
this.metrics?.requestErrors.inc({routeId});
|
|
225
230
|
if (controller.signal.aborted) {
|
|
226
|
-
if (this.opts.signal?.aborted) {
|
|
231
|
+
if (this.opts.signal?.aborted || opts?.signal?.aborted) {
|
|
227
232
|
throw new ErrorAborted("request");
|
|
228
233
|
}
|
|
229
234
|
throw new TimeoutError("request");
|
|
@@ -235,6 +240,7 @@ export class EngineRestHttpClient {
|
|
|
235
240
|
|
|
236
241
|
clearTimeout(timeout);
|
|
237
242
|
this.opts.signal?.removeEventListener("abort", onParentSignalAbort);
|
|
243
|
+
opts?.signal?.removeEventListener("abort", onParentSignalAbort);
|
|
238
244
|
}
|
|
239
245
|
}
|
|
240
246
|
}
|
|
@@ -241,7 +241,8 @@ export class RestEngineTransport implements IEngineTransport {
|
|
|
241
241
|
headBlockHash: RootHex,
|
|
242
242
|
safeBlockHash: RootHex,
|
|
243
243
|
finalizedBlockHash: RootHex,
|
|
244
|
-
payloadAttributes?: PayloadAttributes
|
|
244
|
+
payloadAttributes?: PayloadAttributes,
|
|
245
|
+
signal?: AbortSignal
|
|
245
246
|
): Promise<ForkchoiceUpdatedResult> {
|
|
246
247
|
const forkchoiceState = {
|
|
247
248
|
headBlockHash: fromHex(headBlockHash),
|
|
@@ -279,7 +280,7 @@ export class RestEngineTransport implements IEngineTransport {
|
|
|
279
280
|
|
|
280
281
|
const res = await this.client.request(
|
|
281
282
|
{method: "POST", path: "/forkchoice", executionFork: toExecutionForkName(fork), body, responseType: "ssz"},
|
|
282
|
-
fcUReqOpts
|
|
283
|
+
{...fcUReqOpts, signal}
|
|
283
284
|
);
|
|
284
285
|
const {payloadStatus, payloadId} = deserializeResponse(
|
|
285
286
|
ForkchoiceUpdateResponse,
|
|
@@ -293,14 +294,14 @@ export class RestEngineTransport implements IEngineTransport {
|
|
|
293
294
|
};
|
|
294
295
|
}
|
|
295
296
|
|
|
296
|
-
async getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult> {
|
|
297
|
+
async getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult> {
|
|
297
298
|
if (!PAYLOAD_ID_REGEX.test(payloadId)) {
|
|
298
299
|
throw Error(`Invalid payloadId=${payloadId}, expected 0x prefixed 8 bytes hex`);
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
const res = await this.client.request(
|
|
302
303
|
{method: "GET", path: `/payloads/${payloadId}`, executionFork: toExecutionForkName(fork), responseType: "ssz"},
|
|
303
|
-
getPayloadOpts
|
|
304
|
+
{...getPayloadOpts, signal}
|
|
304
305
|
);
|
|
305
306
|
|
|
306
307
|
if (ForkSeq[fork] >= ForkSeq.gloas) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `fn` with a signal that aborts with either the signal of the client or the signal of a single request.
|
|
3
|
+
* Not AbortSignal.any(), Node retains every composite until the long-lived client signal aborts.
|
|
4
|
+
*/
|
|
5
|
+
export async function withRequestSignal<T>(
|
|
6
|
+
clientSignal: AbortSignal | undefined,
|
|
7
|
+
requestSignal: AbortSignal | undefined,
|
|
8
|
+
fn: (signal: AbortSignal | undefined) => Promise<T>
|
|
9
|
+
): Promise<T> {
|
|
10
|
+
if (requestSignal === undefined) {
|
|
11
|
+
return fn(clientSignal);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const onAbort = (): void => controller.abort();
|
|
16
|
+
clientSignal?.addEventListener("abort", onAbort, {once: true});
|
|
17
|
+
requestSignal.addEventListener("abort", onAbort, {once: true});
|
|
18
|
+
if (clientSignal?.aborted || requestSignal.aborted) {
|
|
19
|
+
controller.abort();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
return await fn(controller.signal);
|
|
24
|
+
} finally {
|
|
25
|
+
clientSignal?.removeEventListener("abort", onAbort);
|
|
26
|
+
requestSignal.removeEventListener("abort", onAbort);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -42,10 +42,11 @@ export interface IEngineTransport {
|
|
|
42
42
|
headBlockHash: RootHex,
|
|
43
43
|
safeBlockHash: RootHex,
|
|
44
44
|
finalizedBlockHash: RootHex,
|
|
45
|
-
payloadAttributes?: PayloadAttributes
|
|
45
|
+
payloadAttributes?: PayloadAttributes,
|
|
46
|
+
signal?: AbortSignal
|
|
46
47
|
): Promise<ForkchoiceUpdatedResult>;
|
|
47
48
|
|
|
48
|
-
getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult>;
|
|
49
|
+
getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult>;
|
|
49
50
|
|
|
50
51
|
getPayloadBodiesByHashV2(blockHashes: RootHex[]): Promise<(ExecutionPayloadBodyV2 | null)[]>;
|
|
51
52
|
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,12 @@ export {DbCPStateDatastore} from "./chain/stateCache/datastore/db.js";
|
|
|
7
7
|
export {FileCPStateDatastore} from "./chain/stateCache/datastore/file.js";
|
|
8
8
|
export {BeaconDb, type IBeaconDb} from "./db/index.js";
|
|
9
9
|
// Export execution engine to make it usable by builder
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
ExecutionEngineError,
|
|
12
|
+
ExecutionEngineErrorCode,
|
|
13
|
+
ExecutionPayloadStatus,
|
|
14
|
+
initializeExecutionEngine,
|
|
15
|
+
} from "./execution/index.js";
|
|
11
16
|
// Export metrics utilities to de-duplicate validator metrics
|
|
12
17
|
export {
|
|
13
18
|
type HttpMetricsServer,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {ProducedBlockSource} from "@lodestar/types";
|
|
2
2
|
import {BlockSelectionResult} from "../../api/impl/validator/index.js";
|
|
3
3
|
import {InclusionListSource} from "../../chain/blocks/types.js";
|
|
4
|
+
import {PreparePayloadReason} from "../../chain/prepareNextSlot.js";
|
|
4
5
|
import {BlockProductionStep, PayloadPreparationType} from "../../chain/produceBlock/index.js";
|
|
5
6
|
import {RegistryMetricCreator} from "../utils/registryMetricCreator.js";
|
|
6
7
|
|
|
@@ -164,6 +165,14 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
|
|
|
164
165
|
help: "Time for preparing payload in advance",
|
|
165
166
|
buckets: [0.1, 1, 3, 5, 10],
|
|
166
167
|
}),
|
|
168
|
+
payloadReprepare: register.counter<{
|
|
169
|
+
reason: PreparePayloadReason;
|
|
170
|
+
result: "changed" | "unchanged" | "dropped" | "error";
|
|
171
|
+
}>({
|
|
172
|
+
name: "beacon_block_payload_reprepare_total",
|
|
173
|
+
help: "Re-runs of the next slot payload preparation after the scheduled run, by reason and result: prepared again as the head or its parent payload changed, unchanged, dropped as the proposal slot started, or failed",
|
|
174
|
+
labelNames: ["reason", "result"],
|
|
175
|
+
}),
|
|
167
176
|
executionPayloadEnvelopeProcessingTime: register.histogram({
|
|
168
177
|
name: "beacon_block_payload_envelope_processing_seconds",
|
|
169
178
|
help: "Time to process execution payload envelope during block production",
|
|
@@ -1068,6 +1068,11 @@ export function createLodestarMetrics(
|
|
|
1068
1068
|
help: "Count of errors, by error type, while processing execution payload envelopes",
|
|
1069
1069
|
labelNames: ["error"],
|
|
1070
1070
|
}),
|
|
1071
|
+
blockHashTime: register.histogram({
|
|
1072
|
+
name: "lodestar_gossip_execution_payload_envelope_block_hash_seconds",
|
|
1073
|
+
help: "Time to compute the execution block hash of a gossip execution payload envelope",
|
|
1074
|
+
buckets: [0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.5, 1],
|
|
1075
|
+
}),
|
|
1071
1076
|
executionPayload: {
|
|
1072
1077
|
recvToValidation: register.histogram({
|
|
1073
1078
|
name: "lodestar_gossip_execution_payload_envelope_received_to_execution_payload_verification_seconds",
|