@lodestar/beacon-node 1.43.0-dev.7a6a5b0190 → 1.43.0-dev.87cbe69c66
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/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +10 -0
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +45 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +0 -1
- 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 +68 -2
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +23 -22
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +5 -3
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +25 -14
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +36 -21
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +5 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/types.d.ts +2 -1
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.js +8 -0
- package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts +2 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +30 -12
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.js +16 -7
- package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +5 -2
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +2 -0
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +0 -11
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +0 -4
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/proposerPreferences.d.ts +8 -1
- package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
- package/lib/chain/errors/proposerPreferences.js +1 -0
- package/lib/chain/errors/proposerPreferences.js.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
- package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.js +26 -4
- package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +15 -17
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +12 -3
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +34 -22
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +1 -4
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +1 -4
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +8 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +20 -4
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/seenCache/seenProposerPreferences.d.ts +8 -7
- package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -1
- package/lib/chain/seenCache/seenProposerPreferences.js +17 -11
- package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +11 -8
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
- package/lib/chain/validation/proposerPreferences.js +39 -17
- package/lib/chain/validation/proposerPreferences.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +2 -0
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/interface.d.ts +1 -0
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +1 -0
- 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/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +14 -10
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.js +5 -5
- package/lib/network/processor/index.js.map +1 -1
- package/lib/node/nodejs.js +2 -2
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.js +1 -7
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/range/batch.d.ts +11 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +29 -4
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +23 -5
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +0 -2
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +0 -47
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +36 -19
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +10 -0
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +8 -6
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +13 -0
- package/src/api/impl/beacon/pool/index.ts +83 -1
- package/src/api/impl/debug/index.ts +0 -1
- package/src/api/impl/validator/index.ts +82 -1
- package/src/chain/blocks/importBlock.ts +23 -39
- package/src/chain/blocks/importExecutionPayload.ts +33 -14
- package/src/chain/blocks/index.ts +34 -15
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +6 -1
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -0
- package/src/chain/blocks/types.ts +2 -1
- package/src/chain/blocks/utils/chainSegment.ts +8 -0
- package/src/chain/blocks/verifyBlock.ts +45 -13
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
- package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -6
- package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +7 -2
- package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
- package/src/chain/chain.ts +2 -0
- package/src/chain/emitter.ts +0 -11
- package/src/chain/errors/proposerPreferences.ts +9 -1
- package/src/chain/opPools/payloadAttestationPool.ts +29 -8
- package/src/chain/prepareNextSlot.ts +20 -28
- package/src/chain/produceBlock/produceBlockBody.ts +45 -27
- package/src/chain/regen/queued.ts +2 -7
- package/src/chain/regen/regen.ts +2 -7
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +25 -5
- package/src/chain/seenCache/seenProposerPreferences.ts +20 -12
- package/src/chain/validation/executionPayloadBid.ts +11 -8
- package/src/chain/validation/proposerPreferences.ts +37 -18
- package/src/network/interface.ts +1 -0
- package/src/network/network.ts +11 -0
- package/src/network/processor/gossipHandlers.ts +20 -11
- package/src/network/processor/index.ts +5 -5
- package/src/node/nodejs.ts +2 -2
- package/src/node/notifier.ts +1 -8
- package/src/sync/range/batch.ts +54 -5
- package/src/sync/range/chain.ts +25 -5
- package/src/sync/unknownBlock.ts +0 -50
- package/src/sync/utils/downloadByRange.ts +36 -18
- package/src/sync/utils/downloadByRoot.ts +12 -0
- package/src/util/sszBytes.ts +8 -6
package/src/sync/range/batch.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
2
|
import {ForkName, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
|
|
3
3
|
import {Epoch, RootHex, Slot, phase0} from "@lodestar/types";
|
|
4
|
-
import {LodestarError} from "@lodestar/utils";
|
|
4
|
+
import {LodestarError, prettyPrintIndices} from "@lodestar/utils";
|
|
5
5
|
import {isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
|
|
6
6
|
import {IBlockInput} from "../../chain/blocks/blockInput/types.js";
|
|
7
7
|
import {isDaOutOfRange} from "../../chain/blocks/blockInput/utils.js";
|
|
@@ -79,10 +79,36 @@ export type BatchState =
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
export type BatchMetadata = {
|
|
82
|
+
// Batch-level slot window (always present)
|
|
82
83
|
startEpoch: Epoch;
|
|
84
|
+
startSlot: Slot;
|
|
85
|
+
count: number;
|
|
83
86
|
status: BatchStatus;
|
|
87
|
+
|
|
88
|
+
// Per-type outstanding request shapes; only present when that sub-request exists.
|
|
89
|
+
// Format: "startSlot=<n>,count=<n>" (plus ",cols=<indices>" for columns).
|
|
90
|
+
blocksReq?: string;
|
|
91
|
+
blobsReq?: string;
|
|
92
|
+
columnsReq?: string;
|
|
93
|
+
envelopesReq?: string;
|
|
94
|
+
|
|
95
|
+
// Retry counters
|
|
96
|
+
downloadAttempts: number;
|
|
97
|
+
processingAttempts: number;
|
|
98
|
+
|
|
99
|
+
// Cumulative peer attribution for failed attempts (only present when non-empty)
|
|
100
|
+
failedDownloadPeers?: string;
|
|
101
|
+
failedProcessingPeers?: string;
|
|
84
102
|
};
|
|
85
103
|
|
|
104
|
+
function formatRangeReq(req: {startSlot: Slot; count: number}): string {
|
|
105
|
+
return `startSlot=${req.startSlot},count=${req.count}`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function formatColumnsReq(req: {startSlot: Slot; count: number; columns: number[]}): string {
|
|
109
|
+
return `startSlot=${req.startSlot},count=${req.count},cols=${prettyPrintIndices(req.columns)}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
86
112
|
/**
|
|
87
113
|
* Batches are downloaded at the first block of the epoch.
|
|
88
114
|
*
|
|
@@ -286,7 +312,26 @@ export class Batch {
|
|
|
286
312
|
}
|
|
287
313
|
|
|
288
314
|
getMetadata(): BatchMetadata {
|
|
289
|
-
|
|
315
|
+
const {blocksRequest, blobsRequest, columnsRequest, envelopesRequest} = this.requests;
|
|
316
|
+
const failedProcessingPeerList = this.failedProcessingAttempts.flatMap((a) => a.peers);
|
|
317
|
+
return {
|
|
318
|
+
startEpoch: this.startEpoch,
|
|
319
|
+
startSlot: this.startSlot,
|
|
320
|
+
count: this.count,
|
|
321
|
+
status: this.state.status,
|
|
322
|
+
...(blocksRequest && {blocksReq: formatRangeReq(blocksRequest)}),
|
|
323
|
+
...(blobsRequest && {blobsReq: formatRangeReq(blobsRequest)}),
|
|
324
|
+
...(columnsRequest && {columnsReq: formatColumnsReq(columnsRequest)}),
|
|
325
|
+
...(envelopesRequest && {envelopesReq: formatRangeReq(envelopesRequest)}),
|
|
326
|
+
downloadAttempts: this.failedDownloadAttempts.length,
|
|
327
|
+
processingAttempts: this.failedProcessingAttempts.length,
|
|
328
|
+
...(this.failedDownloadAttempts.length > 0 && {
|
|
329
|
+
failedDownloadPeers: this.failedDownloadAttempts.join(","),
|
|
330
|
+
}),
|
|
331
|
+
...(failedProcessingPeerList.length > 0 && {
|
|
332
|
+
failedProcessingPeers: failedProcessingPeerList.join(","),
|
|
333
|
+
}),
|
|
334
|
+
};
|
|
290
335
|
}
|
|
291
336
|
|
|
292
337
|
getBlocks(): IBlockInput[] {
|
|
@@ -383,7 +428,11 @@ export class Batch {
|
|
|
383
428
|
/**
|
|
384
429
|
* AwaitingProcessing -> Processing
|
|
385
430
|
*/
|
|
386
|
-
startProcessing(): {
|
|
431
|
+
startProcessing(): {
|
|
432
|
+
blocks: IBlockInput[];
|
|
433
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
|
|
434
|
+
peers: PeerIdStr[];
|
|
435
|
+
} {
|
|
387
436
|
if (this.state.status !== BatchStatus.AwaitingProcessing) {
|
|
388
437
|
throw new BatchError(this.wrongStatusErrorType(BatchStatus.AwaitingProcessing));
|
|
389
438
|
}
|
|
@@ -396,7 +445,7 @@ export class Batch {
|
|
|
396
445
|
const peers = this.goodPeers;
|
|
397
446
|
this.goodPeers = [];
|
|
398
447
|
this.state = {status: BatchStatus.Processing, blocks, payloadEnvelopes, attempt: {peers, hash}};
|
|
399
|
-
return {blocks, payloadEnvelopes};
|
|
448
|
+
return {blocks, payloadEnvelopes, peers};
|
|
400
449
|
}
|
|
401
450
|
|
|
402
451
|
/**
|
|
@@ -479,7 +528,7 @@ export class Batch {
|
|
|
479
528
|
|
|
480
529
|
/** Helper to construct typed BatchError. Stack traces are correct as the error is thrown above */
|
|
481
530
|
private errorType(type: BatchErrorType): BatchErrorType & BatchErrorMetadata {
|
|
482
|
-
return {...type,
|
|
531
|
+
return {...type, startEpoch: this.startEpoch, status: this.state.status};
|
|
483
532
|
}
|
|
484
533
|
|
|
485
534
|
private wrongStatusErrorType(expectedStatus: BatchStatus): BatchErrorType & BatchErrorMetadata {
|
package/src/sync/range/chain.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
2
|
import {Epoch, Root, Slot} from "@lodestar/types";
|
|
3
|
-
import {ErrorAborted, LodestarError, Logger, toRootHex} from "@lodestar/utils";
|
|
3
|
+
import {ErrorAborted, LodestarError, Logger, prettyPrintIndices, toRootHex} from "@lodestar/utils";
|
|
4
4
|
import {isBlockInputBlobs, isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
|
|
5
5
|
import {BlockInputErrorCode} from "../../chain/blocks/blockInput/errors.js";
|
|
6
6
|
import {IBlockInput} from "../../chain/blocks/blockInput/types.js";
|
|
@@ -222,12 +222,14 @@ export class SyncChain {
|
|
|
222
222
|
*/
|
|
223
223
|
stopSyncing(): void {
|
|
224
224
|
this.status = SyncChainStatus.Stopped;
|
|
225
|
+
this.logger.debug("SyncChain stopSyncing", {id: this.logId});
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
/**
|
|
228
229
|
* Permanently remove this chain. Throws the main AsyncIterable
|
|
229
230
|
*/
|
|
230
231
|
remove(): void {
|
|
232
|
+
this.logger.debug("SyncChain remove", {id: this.logId});
|
|
231
233
|
this.batchProcessor.end(new ErrorAborted("SyncChain"));
|
|
232
234
|
}
|
|
233
235
|
|
|
@@ -534,7 +536,7 @@ export class SyncChain {
|
|
|
534
536
|
this.metrics?.syncRange.downloadByRange.warn.inc({client: peer.client, code: warning.type.code});
|
|
535
537
|
this.logger.debug(
|
|
536
538
|
"Batch downloaded with warning",
|
|
537
|
-
{id: this.logId,
|
|
539
|
+
{id: this.logId, ...batch.getMetadata(), ...logMeta, peer: prettyPrintPeerIdStr(peer.peerId)},
|
|
538
540
|
warning
|
|
539
541
|
);
|
|
540
542
|
}
|
|
@@ -560,10 +562,17 @@ export class SyncChain {
|
|
|
560
562
|
// the flow will continue to call triggerBatchDownloader() below
|
|
561
563
|
}
|
|
562
564
|
|
|
565
|
+
const blockSlots = downloadSuccessOutput.blocks.map((b) => b.slot);
|
|
566
|
+
const envelopeSlots = downloadSuccessOutput.payloadEnvelopes
|
|
567
|
+
? Array.from(downloadSuccessOutput.payloadEnvelopes.keys())
|
|
568
|
+
: null;
|
|
569
|
+
|
|
563
570
|
this.logger.debug(logMessage, {
|
|
564
571
|
id: this.logId,
|
|
565
|
-
|
|
572
|
+
...batch.getMetadata(),
|
|
566
573
|
...logMeta,
|
|
574
|
+
blockSlots: prettyPrintIndices(blockSlots),
|
|
575
|
+
...(envelopeSlots ? {envelopeSlots: prettyPrintIndices(envelopeSlots)} : {}),
|
|
567
576
|
peer: prettyPrintPeerIdStr(peer.peerId),
|
|
568
577
|
});
|
|
569
578
|
}
|
|
@@ -586,13 +595,24 @@ export class SyncChain {
|
|
|
586
595
|
* Sends `batch` to the processor. Note: batch may be empty
|
|
587
596
|
*/
|
|
588
597
|
private async processBatch(batch: Batch): Promise<void> {
|
|
589
|
-
const {blocks, payloadEnvelopes} = batch.startProcessing();
|
|
598
|
+
const {blocks, payloadEnvelopes, peers} = batch.startProcessing();
|
|
599
|
+
|
|
600
|
+
const logCtx = {
|
|
601
|
+
id: this.logId,
|
|
602
|
+
...batch.getMetadata(),
|
|
603
|
+
blockCount: blocks.length,
|
|
604
|
+
blockSlots: prettyPrintIndices(blocks.map((b) => b.slot)),
|
|
605
|
+
...(payloadEnvelopes ? {envelopeSlots: prettyPrintIndices(Array.from(payloadEnvelopes.keys()))} : {}),
|
|
606
|
+
peers: peers.map(prettyPrintPeerIdStr).join(","),
|
|
607
|
+
};
|
|
608
|
+
this.logger.verbose("Processing batch", logCtx);
|
|
590
609
|
|
|
591
610
|
// wrapError ensures to never call both batch success() and batch error()
|
|
592
611
|
const res = await wrapError(this.processChainSegment(blocks, payloadEnvelopes, this.syncType));
|
|
593
612
|
|
|
594
613
|
if (!res.err) {
|
|
595
614
|
batch.processingSuccess();
|
|
615
|
+
this.logger.verbose("Processed batch", {...logCtx, ...batch.getMetadata()});
|
|
596
616
|
|
|
597
617
|
// If the processed batch is not empty, validate previous AwaitingValidation blocks.
|
|
598
618
|
if (blocks.length > 0) {
|
|
@@ -602,7 +622,7 @@ export class SyncChain {
|
|
|
602
622
|
// Potentially process next AwaitingProcessing batch
|
|
603
623
|
this.triggerBatchProcessor();
|
|
604
624
|
} else {
|
|
605
|
-
this.logger.verbose("Batch process error",
|
|
625
|
+
this.logger.verbose("Batch process error", logCtx, res.err);
|
|
606
626
|
batch.processingError(res.err); // Throws after MAX_BATCH_PROCESSING_ATTEMPTS
|
|
607
627
|
|
|
608
628
|
// At least one block was successfully verified and imported, so we can be sure all
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -145,7 +145,6 @@ export class BlockInputSync {
|
|
|
145
145
|
this.chain.emitter.on(ChainEvent.incompleteBlockInput, this.onIncompleteBlockInput);
|
|
146
146
|
this.chain.emitter.on(ChainEvent.incompletePayloadEnvelope, this.onIncompletePayloadEnvelope);
|
|
147
147
|
this.chain.emitter.on(ChainEvent.blockUnknownParent, this.onUnknownParent);
|
|
148
|
-
this.chain.emitter.on(ChainEvent.envelopeUnknownBlock, this.onEnvelopeUnknownBlock);
|
|
149
148
|
this.chain.emitter.on(routes.events.EventType.block, this.onBlockImported);
|
|
150
149
|
this.chain.emitter.on(routes.events.EventType.executionPayload, this.onPayloadImported);
|
|
151
150
|
this.network.events.on(NetworkEvent.peerConnected, this.onPeerConnected);
|
|
@@ -161,7 +160,6 @@ export class BlockInputSync {
|
|
|
161
160
|
this.chain.emitter.off(ChainEvent.incompleteBlockInput, this.onIncompleteBlockInput);
|
|
162
161
|
this.chain.emitter.off(ChainEvent.incompletePayloadEnvelope, this.onIncompletePayloadEnvelope);
|
|
163
162
|
this.chain.emitter.off(ChainEvent.blockUnknownParent, this.onUnknownParent);
|
|
164
|
-
this.chain.emitter.off(ChainEvent.envelopeUnknownBlock, this.onEnvelopeUnknownBlock);
|
|
165
163
|
this.chain.emitter.off(routes.events.EventType.block, this.onBlockImported);
|
|
166
164
|
this.chain.emitter.off(routes.events.EventType.executionPayload, this.onPayloadImported);
|
|
167
165
|
this.network.events.off(NetworkEvent.peerConnected, this.onPeerConnected);
|
|
@@ -263,19 +261,6 @@ export class BlockInputSync {
|
|
|
263
261
|
}
|
|
264
262
|
};
|
|
265
263
|
|
|
266
|
-
private onEnvelopeUnknownBlock = (data: ChainEventData[ChainEvent.envelopeUnknownBlock]): void => {
|
|
267
|
-
try {
|
|
268
|
-
const blockRootHex = toRootHex(data.envelope.message.beaconBlockRoot);
|
|
269
|
-
this.addByRootHex(blockRootHex, data.peer);
|
|
270
|
-
this.addByPayloadEnvelope(data.envelope, data.peer);
|
|
271
|
-
this.triggerUnknownBlockSearch();
|
|
272
|
-
this.metrics?.blockInputSync.requests.inc({type: PendingBlockType.UNKNOWN_DATA});
|
|
273
|
-
this.metrics?.blockInputSync.source.inc({source: data.source});
|
|
274
|
-
} catch (e) {
|
|
275
|
-
this.logger.debug("Error handling envelopeUnknownBlock event", {}, e as Error);
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
|
|
279
264
|
private onBlockImported = (): void => {
|
|
280
265
|
if (this.pendingPayloads.size > 0) {
|
|
281
266
|
this.triggerUnknownBlockSearch();
|
|
@@ -381,41 +366,6 @@ export class BlockInputSync {
|
|
|
381
366
|
return added;
|
|
382
367
|
};
|
|
383
368
|
|
|
384
|
-
private addByPayloadEnvelope = (envelope: gloas.SignedExecutionPayloadEnvelope, peerIdStr?: PeerIdStr): void => {
|
|
385
|
-
const rootHex = toRootHex(envelope.message.beaconBlockRoot);
|
|
386
|
-
const existingPendingPayload = this.pendingPayloads.get(rootHex);
|
|
387
|
-
let pendingPayload = this.pendingPayloads.get(rootHex);
|
|
388
|
-
if (!pendingPayload || !isPendingPayloadEnvelope(pendingPayload)) {
|
|
389
|
-
pendingPayload = {
|
|
390
|
-
status: PendingPayloadInputStatus.waitingForBlock,
|
|
391
|
-
envelope,
|
|
392
|
-
peerIdStrings: new Set(existingPendingPayload?.peerIdStrings ?? []),
|
|
393
|
-
timeAddedSec: existingPendingPayload?.timeAddedSec ?? Date.now() / 1000,
|
|
394
|
-
};
|
|
395
|
-
this.pendingPayloads.set(rootHex, pendingPayload);
|
|
396
|
-
|
|
397
|
-
this.logger.verbose("Added payload envelope to BlockInputSync.pendingPayloads", {
|
|
398
|
-
slot: envelope.message.payload.slotNumber,
|
|
399
|
-
root: rootHex,
|
|
400
|
-
});
|
|
401
|
-
} else {
|
|
402
|
-
this.logger.debug("Overwriting pending payload envelope for root already waiting for block", {
|
|
403
|
-
slot: envelope.message.payload.slotNumber,
|
|
404
|
-
root: rootHex,
|
|
405
|
-
});
|
|
406
|
-
pendingPayload.envelope = envelope;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (peerIdStr) {
|
|
410
|
-
pendingPayload.peerIdStrings.add(peerIdStr);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
const prunedItemCount = pruneSetToMax(this.pendingPayloads, this.maxPendingBlocks);
|
|
414
|
-
if (prunedItemCount > 0) {
|
|
415
|
-
this.logger.verbose(`Pruned ${prunedItemCount} items from BlockInputSync.pendingPayloads`);
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
|
|
419
369
|
private addByPayloadInput = (
|
|
420
370
|
payloadInput: PayloadEnvelopeInput,
|
|
421
371
|
peerIdStr?: PeerIdStr,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
deneb,
|
|
15
15
|
fulu,
|
|
16
16
|
gloas,
|
|
17
|
+
isGloasBeaconBlock,
|
|
17
18
|
isGloasDataColumnSidecar,
|
|
18
19
|
phase0,
|
|
19
20
|
} from "@lodestar/types";
|
|
@@ -185,9 +186,24 @@ export function cacheByRangeResponses({
|
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
189
|
+
// Seed seenPayloadEnvelopeInputCache for every gloas block in the batch, regardless of whether
|
|
190
|
+
// the peer returned its envelope. Without this, a block returned without its envelope would be
|
|
191
|
+
// imported with no cache entry, and later payload-by-root sync would throw
|
|
192
|
+
// "Missing PayloadEnvelopeInput for known block" (see issue #9306).
|
|
193
|
+
for (const blockInput of updatedBatchBlocks.values()) {
|
|
194
|
+
if (!blockInput.hasBlock() || !isForkPostGloas(blockInput.forkName)) continue;
|
|
195
|
+
seenPayloadEnvelopeInputCache.add({
|
|
196
|
+
blockRootHex: blockInput.blockRootHex,
|
|
197
|
+
block: blockInput.getBlock() as SignedBeaconBlock<ForkPostGloas>,
|
|
198
|
+
forkName: blockInput.forkName,
|
|
199
|
+
sampledColumns: custodyConfig.sampledColumns,
|
|
200
|
+
custodyColumns: custodyConfig.custodyColumns,
|
|
201
|
+
timeCreatedSec: seenTimestampSec,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Attach envelopes to entries whose envelope was returned by the peer. The returned
|
|
206
|
+
// payloadEnvelopes map only contains entries with envelopes ready for importExecutionPayload.
|
|
191
207
|
let payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null = null;
|
|
192
208
|
if (downloadedPayloadEnvelopes !== null) {
|
|
193
209
|
payloadEnvelopes = new Map(existingPayloadEnvelopes ?? []);
|
|
@@ -198,20 +214,11 @@ export function cacheByRangeResponses({
|
|
|
198
214
|
// No block to pair this envelope with; drop silently
|
|
199
215
|
continue;
|
|
200
216
|
}
|
|
201
|
-
const {blockRootHex} = blockInput;
|
|
202
217
|
|
|
203
|
-
|
|
204
|
-
// duplicate cache entries. If missing, create a fresh one from the block's bid.
|
|
205
|
-
let payloadInput = seenPayloadEnvelopeInputCache.get(blockRootHex);
|
|
218
|
+
const payloadInput = seenPayloadEnvelopeInputCache.get(blockInput.blockRootHex);
|
|
206
219
|
if (payloadInput === undefined) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
block: blockInput.getBlock() as SignedBeaconBlock<ForkPostGloas>,
|
|
210
|
-
forkName: blockInput.forkName,
|
|
211
|
-
sampledColumns: custodyConfig.sampledColumns,
|
|
212
|
-
custodyColumns: custodyConfig.custodyColumns,
|
|
213
|
-
timeCreatedSec: seenTimestampSec,
|
|
214
|
-
});
|
|
220
|
+
// Unreachable given the loop above seeded an entry for every gloas block in the batch.
|
|
221
|
+
continue;
|
|
215
222
|
}
|
|
216
223
|
|
|
217
224
|
if (!payloadInput.hasPayloadEnvelope()) {
|
|
@@ -355,7 +362,7 @@ export async function requestByRange({
|
|
|
355
362
|
let blocks: undefined | SignedBeaconBlock[];
|
|
356
363
|
let blobSidecars: undefined | deneb.BlobSidecars;
|
|
357
364
|
let columnSidecars: undefined | DataColumnSidecar[];
|
|
358
|
-
|
|
365
|
+
const payloadEnvelopes: gloas.SignedExecutionPayloadEnvelope[] = [];
|
|
359
366
|
|
|
360
367
|
const requests: Promise<unknown>[] = [];
|
|
361
368
|
|
|
@@ -363,6 +370,17 @@ export async function requestByRange({
|
|
|
363
370
|
requests.push(
|
|
364
371
|
network.sendBeaconBlocksByRange(peerIdStr, blocksRequest).then((blockResponse) => {
|
|
365
372
|
blocks = blockResponse;
|
|
373
|
+
const firstBlock = blockResponse.at(0);
|
|
374
|
+
if (firstBlock && isGloasBeaconBlock(firstBlock.message)) {
|
|
375
|
+
return network
|
|
376
|
+
.sendExecutionPayloadEnvelopesByRoot(peerIdStr, [
|
|
377
|
+
firstBlock.message.body.signedExecutionPayloadBid.message.parentBlockRoot,
|
|
378
|
+
])
|
|
379
|
+
.then((envelopeResponse) => {
|
|
380
|
+
payloadEnvelopes?.unshift(...envelopeResponse);
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return undefined;
|
|
366
384
|
})
|
|
367
385
|
);
|
|
368
386
|
}
|
|
@@ -386,7 +404,7 @@ export async function requestByRange({
|
|
|
386
404
|
if (envelopesRequest) {
|
|
387
405
|
requests.push(
|
|
388
406
|
network.sendExecutionPayloadEnvelopesByRange(peerIdStr, envelopesRequest).then((envelopeResponse) => {
|
|
389
|
-
payloadEnvelopes
|
|
407
|
+
payloadEnvelopes?.push(...envelopeResponse);
|
|
390
408
|
})
|
|
391
409
|
);
|
|
392
410
|
}
|
|
@@ -1173,7 +1191,7 @@ export function validateEnvelopesByRangeResponse(
|
|
|
1173
1191
|
const slot = payloadEnvelope.message.payload.slotNumber;
|
|
1174
1192
|
const batchBlockRoot = batchBlockRoots.get(slot);
|
|
1175
1193
|
|
|
1176
|
-
// Envelopes for slots not in the batch are silently ignored (orphaned payloads)
|
|
1194
|
+
// Envelopes for slots not in the batch are silently ignored (orphaned payloads or a parent payload)
|
|
1177
1195
|
if (batchBlockRoot === undefined) {
|
|
1178
1196
|
continue;
|
|
1179
1197
|
}
|
|
@@ -3,6 +3,7 @@ import {ChainForkConfig} from "@lodestar/config";
|
|
|
3
3
|
import {
|
|
4
4
|
ForkPostDeneb,
|
|
5
5
|
ForkPostFulu,
|
|
6
|
+
ForkPostGloas,
|
|
6
7
|
ForkPreFulu,
|
|
7
8
|
isForkPostDeneb,
|
|
8
9
|
isForkPostFulu,
|
|
@@ -114,6 +115,17 @@ export async function downloadByRoot({
|
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
if (isForkPostGloas(blockInput.forkName)) {
|
|
119
|
+
chain.seenPayloadEnvelopeInputCache.add({
|
|
120
|
+
blockRootHex: rootHex,
|
|
121
|
+
block: blockInput.getBlock() as SignedBeaconBlock<ForkPostGloas>,
|
|
122
|
+
forkName: blockInput.forkName,
|
|
123
|
+
sampledColumns: chain.custodyConfig.sampledColumns,
|
|
124
|
+
custodyColumns: chain.custodyConfig.custodyColumns,
|
|
125
|
+
timeCreatedSec: Date.now() / 1000,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
117
129
|
const hasAllDataPreDownload = blockInput.hasBlockAndAllData();
|
|
118
130
|
|
|
119
131
|
if (isBlockInputBlobs(blockInput) && !hasAllDataPreDownload) {
|
package/src/util/sszBytes.ts
CHANGED
|
@@ -558,9 +558,10 @@ export function getBeaconBlockRootFromDataColumnSidecarSerialized(data: Uint8Arr
|
|
|
558
558
|
* └─ ExecutionPayloadEnvelope (starts at byte 100):
|
|
559
559
|
* ├─ 4 bytes: payload offset
|
|
560
560
|
* ├─ 4 bytes: executionRequests offset
|
|
561
|
-
* ├─ 8 bytes: builderIndex
|
|
562
|
-
* ├─ 32 bytes: beaconBlockRoot
|
|
563
|
-
*
|
|
561
|
+
* ├─ 8 bytes: builderIndex (offset 108-115)
|
|
562
|
+
* ├─ 32 bytes: beaconBlockRoot (offset 116-147)
|
|
563
|
+
* ├─ 32 bytes: parentBeaconBlockRoot (offset 148-179) — new in Gloas alpha.6 (consensus-specs#5152)
|
|
564
|
+
* └─ variable: payload data (starts at envelope + 80)
|
|
564
565
|
* └─ ExecutionPayload fixed portion includes slotNumber at offset 532
|
|
565
566
|
*/
|
|
566
567
|
const SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MESSAGE_OFFSET = 4;
|
|
@@ -576,12 +577,13 @@ const BEACON_BLOCK_ROOT_OFFSET_IN_SIGNED_EXECUTION_PAYLOAD_ENVELOPE =
|
|
|
576
577
|
EXECUTION_PAYLOAD_ENVELOPE_REQUESTS_OFFSET +
|
|
577
578
|
EXECUTION_PAYLOAD_ENVELOPE_BUILDER_INDEX_SIZE; // 116
|
|
578
579
|
|
|
579
|
-
// Envelope fixed portion
|
|
580
|
+
// Envelope fixed portion: payload_offset(4) + requests_offset(4) + builderIndex(8) + beaconBlockRoot(32) + parentBeaconBlockRoot(32) = 80
|
|
580
581
|
const EXECUTION_PAYLOAD_ENVELOPE_FIXED_SIZE =
|
|
581
582
|
EXECUTION_PAYLOAD_ENVELOPE_PAYLOAD_OFFSET +
|
|
582
583
|
EXECUTION_PAYLOAD_ENVELOPE_REQUESTS_OFFSET +
|
|
583
584
|
EXECUTION_PAYLOAD_ENVELOPE_BUILDER_INDEX_SIZE +
|
|
584
|
-
ROOT_SIZE
|
|
585
|
+
ROOT_SIZE +
|
|
586
|
+
ROOT_SIZE; // 80
|
|
585
587
|
|
|
586
588
|
// slotNumber offset within ExecutionPayload fixed portion:
|
|
587
589
|
// parentHash(32) + feeRecipient(20) + stateRoot(32) + receiptsRoot(32) + logsBloom(256) +
|
|
@@ -595,7 +597,7 @@ const ENVELOPE_START_IN_SIGNED =
|
|
|
595
597
|
SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MESSAGE_OFFSET + SIGNED_EXECUTION_PAYLOAD_ENVELOPE_SIGNATURE_SIZE; // 100
|
|
596
598
|
|
|
597
599
|
const SLOT_OFFSET_IN_SIGNED_EXECUTION_PAYLOAD_ENVELOPE =
|
|
598
|
-
ENVELOPE_START_IN_SIGNED + EXECUTION_PAYLOAD_ENVELOPE_FIXED_SIZE + SLOT_NUMBER_OFFSET_IN_EXECUTION_PAYLOAD; // 100 +
|
|
600
|
+
ENVELOPE_START_IN_SIGNED + EXECUTION_PAYLOAD_ENVELOPE_FIXED_SIZE + SLOT_NUMBER_OFFSET_IN_EXECUTION_PAYLOAD; // 100 + 80 + 532 = 712
|
|
599
601
|
|
|
600
602
|
export function getSlotFromExecutionPayloadEnvelopeSerialized(data: Uint8Array): Slot | null {
|
|
601
603
|
if (data.length < SLOT_OFFSET_IN_SIGNED_EXECUTION_PAYLOAD_ENVELOPE + SLOT_SIZE) {
|