@lodestar/beacon-node 1.49.0-dev.07c3496aff → 1.49.0-dev.0a27fd270f
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 +15 -6
- 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 +4 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +28 -0
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +9 -7
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +1 -2
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +23 -7
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.js +5 -6
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +11 -2
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +46 -28
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts +2 -2
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +15 -3
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +13 -0
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.js +2 -2
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/chain.d.ts +10 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +85 -16
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +10 -0
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +4 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/attesterSlashingError.d.ts +4 -1
- package/lib/chain/errors/attesterSlashingError.d.ts.map +1 -1
- package/lib/chain/errors/attesterSlashingError.js +1 -0
- package/lib/chain/errors/attesterSlashingError.js.map +1 -1
- package/lib/chain/errors/envelopeReconstructionError.d.ts +23 -0
- package/lib/chain/errors/envelopeReconstructionError.d.ts.map +1 -0
- package/lib/chain/errors/envelopeReconstructionError.js +13 -0
- package/lib/chain/errors/envelopeReconstructionError.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/errors/payloadAttestation.d.ts +4 -0
- package/lib/chain/errors/payloadAttestation.d.ts.map +1 -1
- package/lib/chain/errors/payloadAttestation.js +1 -0
- package/lib/chain/errors/payloadAttestation.js.map +1 -1
- package/lib/chain/errors/proposerSlashingError.d.ts +4 -1
- package/lib/chain/errors/proposerSlashingError.d.ts.map +1 -1
- package/lib/chain/errors/proposerSlashingError.js +1 -0
- package/lib/chain/errors/proposerSlashingError.js.map +1 -1
- package/lib/chain/interface.d.ts +6 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/options.d.ts +2 -4
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +4 -2
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +6 -6
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +2 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +3 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +1 -2
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +8 -1
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +1 -2
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +2 -2
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/db/beacon.d.ts +1 -2
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +1 -3
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +0 -1
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +1 -1
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +1 -2
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.d.ts +5 -0
- package/lib/db/repositories/blockArchive.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.js +36 -1
- package/lib/db/repositories/blockArchive.js.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts +21 -9
- package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts.map +1 -1
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js +32 -12
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
- package/lib/db/repositories/index.d.ts +1 -2
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +1 -2
- package/lib/db/repositories/index.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 +2 -1
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +7 -1
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +3 -1
- package/lib/execution/engine/interface.d.ts.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 +14 -2
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/types.d.ts +11 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +10 -0
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +9 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +16 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +35 -14
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +76 -24
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/metrics/metrics.d.ts +3 -1
- package/lib/metrics/metrics.d.ts.map +1 -1
- package/lib/metrics/metrics.js +2 -2
- package/lib/metrics/metrics.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts +1 -2
- package/lib/network/gossip/encoding.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +5 -10
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +16 -1
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +9 -6
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +23 -8
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +16 -5
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts +2 -0
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +88 -7
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/index.d.ts +6 -2
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +62 -24
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +47 -34
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +23 -4
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/index.js +20 -4
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +19 -5
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/node/nodejs.d.ts +2 -7
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +2 -22
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/interface.d.ts +1 -2
- package/lib/sync/interface.d.ts.map +1 -1
- package/lib/sync/options.d.ts +0 -6
- package/lib/sync/options.d.ts.map +1 -1
- package/lib/sync/options.js +0 -2
- package/lib/sync/options.js.map +1 -1
- package/lib/sync/types.d.ts +39 -2
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +42 -2
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +20 -0
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +231 -26
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/util/execution.d.ts +42 -0
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +123 -2
- package/lib/util/execution.js.map +1 -1
- package/lib/util/headerEnvelope.d.ts +17 -0
- package/lib/util/headerEnvelope.d.ts.map +1 -0
- package/lib/util/headerEnvelope.js +43 -0
- package/lib/util/headerEnvelope.js.map +1 -0
- package/lib/util/shuffle.d.ts +0 -4
- package/lib/util/shuffle.d.ts.map +1 -1
- package/lib/util/shuffle.js +0 -8
- package/lib/util/shuffle.js.map +1 -1
- package/lib/util/sszBytes.d.ts +5 -0
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +13 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +18 -5
- package/src/api/impl/beacon/pool/index.ts +6 -2
- package/src/api/impl/beacon/state/index.ts +36 -0
- package/src/api/impl/validator/index.ts +9 -7
- package/src/chain/archiveStore/archiveStore.ts +24 -8
- package/src/chain/archiveStore/historicalState/metrics.ts +5 -7
- package/src/chain/archiveStore/utils/archiveBlocks.ts +54 -32
- package/src/chain/archiveStore/utils/pruneHistory.ts +18 -6
- package/src/chain/blocks/importExecutionPayload.ts +14 -0
- package/src/chain/blocks/index.ts +2 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -1
- package/src/chain/chain.ts +96 -20
- package/src/chain/emitter.ts +7 -2
- package/src/chain/errors/attesterSlashingError.ts +3 -1
- package/src/chain/errors/envelopeReconstructionError.ts +22 -0
- package/src/chain/errors/index.ts +1 -0
- package/src/chain/errors/payloadAttestation.ts +2 -0
- package/src/chain/errors/proposerSlashingError.ts +3 -1
- package/src/chain/interface.ts +6 -1
- package/src/chain/options.ts +3 -5
- package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
- package/src/chain/produceBlock/produceBlockBody.ts +17 -6
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +3 -2
- package/src/chain/validation/attesterSlashing.ts +1 -2
- package/src/chain/validation/payloadAttestationMessage.ts +9 -0
- package/src/chain/validation/proposerSlashing.ts +1 -2
- package/src/chain/validatorMonitor.ts +12 -2
- package/src/db/beacon.ts +0 -5
- package/src/db/buckets.ts +2 -2
- package/src/db/interface.ts +0 -3
- package/src/db/repositories/blockArchive.ts +38 -1
- package/src/db/repositories/executionPayloadEnvelopeArchive.ts +43 -13
- package/src/db/repositories/index.ts +6 -2
- package/src/execution/engine/disabled.ts +4 -0
- package/src/execution/engine/http.ts +12 -0
- package/src/execution/engine/interface.ts +4 -1
- package/src/execution/engine/mock.ts +22 -2
- package/src/execution/engine/types.ts +25 -0
- package/src/metrics/metrics/beacon.ts +16 -0
- package/src/metrics/metrics/lodestar.ts +87 -28
- package/src/metrics/metrics.ts +7 -2
- package/src/network/gossip/encoding.ts +5 -8
- package/src/network/gossip/gossipsub.ts +19 -2
- package/src/network/gossip/topic.ts +25 -7
- package/src/network/processor/gossipHandlers.ts +18 -5
- package/src/network/processor/gossipValidatorFn.ts +111 -7
- package/src/network/processor/index.ts +81 -24
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +57 -39
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +27 -5
- package/src/network/reqresp/handlers/index.ts +49 -5
- package/src/network/reqresp/protocols.ts +31 -6
- package/src/node/nodejs.ts +0 -27
- package/src/sync/interface.ts +1 -2
- package/src/sync/options.ts +0 -8
- package/src/sync/types.ts +44 -5
- package/src/sync/unknownBlock.ts +254 -26
- package/src/util/execution.ts +175 -2
- package/src/util/headerEnvelope.ts +76 -0
- package/src/util/shuffle.ts +0 -9
- package/src/util/sszBytes.ts +18 -0
- package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts +0 -20
- package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts.map +0 -1
- package/lib/chain/archiveStore/utils/updateBackfillRange.js +0 -40
- package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +0 -1
- package/lib/db/repositories/backfilledRanges.d.ts +0 -18
- package/lib/db/repositories/backfilledRanges.d.ts.map +0 -1
- package/lib/db/repositories/backfilledRanges.js +0 -26
- package/lib/db/repositories/backfilledRanges.js.map +0 -1
- package/lib/sync/backfill/backfill.d.ts +0 -169
- package/lib/sync/backfill/backfill.d.ts.map +0 -1
- package/lib/sync/backfill/backfill.js +0 -686
- package/lib/sync/backfill/backfill.js.map +0 -1
- package/lib/sync/backfill/errors.d.ts +0 -30
- package/lib/sync/backfill/errors.d.ts.map +0 -1
- package/lib/sync/backfill/errors.js +0 -15
- package/lib/sync/backfill/errors.js.map +0 -1
- package/lib/sync/backfill/index.d.ts +0 -2
- package/lib/sync/backfill/index.d.ts.map +0 -1
- package/lib/sync/backfill/index.js +0 -2
- package/lib/sync/backfill/index.js.map +0 -1
- package/lib/sync/backfill/verify.d.ts +0 -18
- package/lib/sync/backfill/verify.d.ts.map +0 -1
- package/lib/sync/backfill/verify.js +0 -36
- package/lib/sync/backfill/verify.js.map +0 -1
- package/src/chain/archiveStore/utils/updateBackfillRange.ts +0 -50
- package/src/db/repositories/backfilledRanges.ts +0 -29
- package/src/sync/backfill/backfill.ts +0 -916
- package/src/sync/backfill/errors.ts +0 -23
- package/src/sync/backfill/index.ts +0 -1
- package/src/sync/backfill/verify.ts +0 -58
|
@@ -86,8 +86,13 @@ export const MAX_AWAITING_MESSAGES_PER_ROOT: Partial<Record<GossipType, number>>
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* Track the forwarded peers we already emit to UnknownBlockInput sync.
|
|
89
|
+
* envelopeSlotEmitted: whether the unknownEnvelopeBlockRootSlot event was already emitted for this root.
|
|
89
90
|
*/
|
|
90
|
-
type SearchedRootEntry = {
|
|
91
|
+
type SearchedRootEntry = {
|
|
92
|
+
blockPeerIds?: Set<PeerIdStr>;
|
|
93
|
+
envelopePeerIds?: Set<PeerIdStr>;
|
|
94
|
+
envelopeSlotEmitted?: boolean;
|
|
95
|
+
};
|
|
91
96
|
|
|
92
97
|
/**
|
|
93
98
|
* This is respective to gossipsub seenTTL (which is 550 * 0.7 = 385s), also it's respective
|
|
@@ -192,6 +197,19 @@ type PreprocessResult =
|
|
|
192
197
|
| {action: PreprocessAction.AwaitBlock; root: RootHex}
|
|
193
198
|
| {action: PreprocessAction.AwaitEnvelope; root: RootHex};
|
|
194
199
|
|
|
200
|
+
enum SearchTarget {
|
|
201
|
+
Block,
|
|
202
|
+
PayloadEnvelope,
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
type SearchUnknownRootTarget =
|
|
206
|
+
| {target: SearchTarget.Block}
|
|
207
|
+
| {
|
|
208
|
+
target: SearchTarget.PayloadEnvelope;
|
|
209
|
+
/** The message slot is the payload's slot, so it can be used for UnknownBlockInput search */
|
|
210
|
+
slotIsPayloadSlot: boolean;
|
|
211
|
+
};
|
|
212
|
+
|
|
195
213
|
/**
|
|
196
214
|
* Network processor handles the gossip queues and throtles processing to not overload the main thread
|
|
197
215
|
* - Decides when to process work and what to process
|
|
@@ -347,12 +365,17 @@ export class NetworkProcessor {
|
|
|
347
365
|
}
|
|
348
366
|
|
|
349
367
|
/**
|
|
350
|
-
* Search envelope via `ChainEvent.unknownEnvelopeBlockRoot` event
|
|
368
|
+
* Search envelope via `ChainEvent.unknownEnvelopeBlockRoot` / `ChainEvent.unknownEnvelopeBlockRootSlot` event
|
|
351
369
|
* Slot is the message slot, which is not necessarily the same as the envelope's slot, but it can be used for a good prune strategy.
|
|
352
370
|
* In the rare case, if 2 messages on 2 slots search for the same root (for example beacon_attestation) we may emit the same root twice but BlockInputSync should handle it well.
|
|
353
371
|
* Same peer-forwarding + dedup behavior as searchUnknownBlock.
|
|
354
372
|
*/
|
|
355
|
-
searchUnknownEnvelope(
|
|
373
|
+
searchUnknownEnvelope(
|
|
374
|
+
{slot, root}: SlotRootHex,
|
|
375
|
+
source: BlockInputSource,
|
|
376
|
+
peer?: PeerIdStr,
|
|
377
|
+
slotIsPayloadSlot = false
|
|
378
|
+
): void {
|
|
356
379
|
if (this.chain.seenPayloadEnvelope(root)) {
|
|
357
380
|
return;
|
|
358
381
|
}
|
|
@@ -369,8 +392,17 @@ export class NetworkProcessor {
|
|
|
369
392
|
forwardedPeers.add(peer);
|
|
370
393
|
shouldEmit = true;
|
|
371
394
|
}
|
|
395
|
+
// the payload-slot seed must reach the sync once, even if a slot-less trigger started the search first
|
|
396
|
+
if (slotIsPayloadSlot && !entry.envelopeSlotEmitted) {
|
|
397
|
+
shouldEmit = true;
|
|
398
|
+
}
|
|
372
399
|
if (shouldEmit) {
|
|
373
|
-
|
|
400
|
+
if (slotIsPayloadSlot) {
|
|
401
|
+
entry.envelopeSlotEmitted = true;
|
|
402
|
+
this.chain.emitter.emit(ChainEvent.unknownEnvelopeBlockRootSlot, {rootHex: root, slot, peer, source});
|
|
403
|
+
} else {
|
|
404
|
+
this.chain.emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, {rootHex: root, peer, source});
|
|
405
|
+
}
|
|
374
406
|
}
|
|
375
407
|
}
|
|
376
408
|
|
|
@@ -431,7 +463,7 @@ export class NetworkProcessor {
|
|
|
431
463
|
// no need to check if root is a descendant of the current finalized block, it will be checked once we validate the message if needed
|
|
432
464
|
if (root && !this.chain.forkChoice.hasBlockHexUnsafe(root)) {
|
|
433
465
|
// starting from GLOAS, unknown root from data_column_sidecar also falls into this case
|
|
434
|
-
this.searchUnknownRoot({slot, root},
|
|
466
|
+
this.searchUnknownRoot({slot, root}, peerId, {target: SearchTarget.Block});
|
|
435
467
|
// for beacon_attestation and beacon_aggregate_and_proof messages, this is only temporary.
|
|
436
468
|
// if "index = 1" we need to await for the Envelope instead
|
|
437
469
|
preprocessResult = {action: PreprocessAction.AwaitBlock, root};
|
|
@@ -446,27 +478,28 @@ export class NetworkProcessor {
|
|
|
446
478
|
if (topicType === GossipType.beacon_block) {
|
|
447
479
|
const parentRoot = getParentRootFromSignedBeaconBlockSerialized(message.msg.data);
|
|
448
480
|
if (parentRoot) {
|
|
449
|
-
let
|
|
450
|
-
let searchParentEnvelope = false;
|
|
481
|
+
let search: SearchUnknownRootTarget | null = null;
|
|
451
482
|
if (ForkSeq[fork] >= ForkSeq.gloas) {
|
|
452
483
|
// GLOAS: also check parent envelope, same logic as execution_payload_bid
|
|
453
484
|
const parentBlockHash = getParentBlockHashFromGloasSignedBeaconBlockSerialized(message.msg.data);
|
|
454
485
|
if (parentBlockHash && !this.chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHash)) {
|
|
455
486
|
const protoBlock = this.chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
456
487
|
if (protoBlock === null) {
|
|
457
|
-
|
|
488
|
+
search = {target: SearchTarget.Block};
|
|
458
489
|
} else if (
|
|
459
490
|
protoBlock.executionPayloadBlockHash &&
|
|
460
491
|
protoBlock.executionPayloadBlockHash !== parentBlockHash
|
|
461
492
|
) {
|
|
462
493
|
// only search for the envelope by block root if we're sure there is one. Otherwise UnknownBlockSync will penalize the peer.
|
|
463
|
-
|
|
494
|
+
search = {target: SearchTarget.PayloadEnvelope, slotIsPayloadSlot: false};
|
|
464
495
|
}
|
|
465
496
|
}
|
|
466
497
|
} else if (!this.chain.forkChoice.hasBlockHexUnsafe(parentRoot)) {
|
|
467
|
-
|
|
498
|
+
search = {target: SearchTarget.Block};
|
|
499
|
+
}
|
|
500
|
+
if (search !== null) {
|
|
501
|
+
this.searchUnknownRoot({slot, root: parentRoot}, peerId, search);
|
|
468
502
|
}
|
|
469
|
-
this.searchUnknownRoot({slot, root: parentRoot}, searchParentBlock, searchParentEnvelope, peerId);
|
|
470
503
|
}
|
|
471
504
|
preprocessResult = {action: PreprocessAction.PushToQueue};
|
|
472
505
|
}
|
|
@@ -485,7 +518,10 @@ export class NetworkProcessor {
|
|
|
485
518
|
: getDataIndexFromSignedAggregateAndProofSerialized(message.msg.data);
|
|
486
519
|
if (attIndex === 1 && !this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
|
|
487
520
|
// attestation votes that the payload is available but it is not yet known
|
|
488
|
-
this.searchUnknownRoot({slot, root},
|
|
521
|
+
this.searchUnknownRoot({slot, root}, peerId, {
|
|
522
|
+
target: SearchTarget.PayloadEnvelope,
|
|
523
|
+
slotIsPayloadSlot: false,
|
|
524
|
+
});
|
|
489
525
|
preprocessResult = {action: PreprocessAction.AwaitEnvelope, root};
|
|
490
526
|
}
|
|
491
527
|
break;
|
|
@@ -494,8 +530,13 @@ export class NetworkProcessor {
|
|
|
494
530
|
if (root == null) break;
|
|
495
531
|
const payloadPresent = getPayloadPresentFromPayloadAttestationMessageSerialized(message.msg.data);
|
|
496
532
|
if (payloadPresent && !this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
|
|
497
|
-
// payload attestation votes that the payload is available but it is not yet known
|
|
498
|
-
this
|
|
533
|
+
// payload attestation votes that the payload is available but it is not yet known.
|
|
534
|
+
// this is optimistic search, the peer may not have the payload (only the ptc committee had).
|
|
535
|
+
// the PTC vote's slot is the payload's slot
|
|
536
|
+
this.searchUnknownRoot({slot, root}, undefined, {
|
|
537
|
+
target: SearchTarget.PayloadEnvelope,
|
|
538
|
+
slotIsPayloadSlot: true,
|
|
539
|
+
});
|
|
499
540
|
// do not await the envelope, payload attestation processing only requires that the block is known
|
|
500
541
|
// also do not reset preprocessResult, we may already await for the block
|
|
501
542
|
}
|
|
@@ -504,7 +545,12 @@ export class NetworkProcessor {
|
|
|
504
545
|
case GossipType.data_column_sidecar: {
|
|
505
546
|
if (root == null) break;
|
|
506
547
|
if (!this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
|
|
507
|
-
this
|
|
548
|
+
// this is optimistic search, the peer may not have the payload.
|
|
549
|
+
// the sidecar's slot is the block's (and so the payload's) slot
|
|
550
|
+
this.searchUnknownRoot({slot, root}, undefined, {
|
|
551
|
+
target: SearchTarget.PayloadEnvelope,
|
|
552
|
+
slotIsPayloadSlot: true,
|
|
553
|
+
});
|
|
508
554
|
// do not await the envelope, we can do gossip validation
|
|
509
555
|
// also do not reset preprocessResult, we may already await for the block
|
|
510
556
|
}
|
|
@@ -515,7 +561,7 @@ export class NetworkProcessor {
|
|
|
515
561
|
// Extract beacon_block_root directly
|
|
516
562
|
const blockRoot = getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized(message.msg.data);
|
|
517
563
|
if (blockRoot && !this.chain.forkChoice.hasBlockHexUnsafe(blockRoot)) {
|
|
518
|
-
this.searchUnknownRoot({slot, root: blockRoot},
|
|
564
|
+
this.searchUnknownRoot({slot, root: blockRoot}, peerId, {target: SearchTarget.Block});
|
|
519
565
|
// We always want to await the block
|
|
520
566
|
// This allows us to properly forward the payload envelope
|
|
521
567
|
preprocessResult = {action: PreprocessAction.AwaitBlock, root: blockRoot};
|
|
@@ -534,13 +580,16 @@ export class NetworkProcessor {
|
|
|
534
580
|
) {
|
|
535
581
|
const protoBlock = this.chain.forkChoice.getBlockHexDefaultStatus(parentBlockRoot);
|
|
536
582
|
if (protoBlock === null) {
|
|
537
|
-
this.searchUnknownRoot({slot, root: parentBlockRoot},
|
|
583
|
+
this.searchUnknownRoot({slot, root: parentBlockRoot}, peerId, {target: SearchTarget.Block});
|
|
538
584
|
preprocessResult = {action: PreprocessAction.AwaitBlock, root: parentBlockRoot};
|
|
539
585
|
} else if (
|
|
540
586
|
protoBlock.executionPayloadBlockHash &&
|
|
541
587
|
protoBlock.executionPayloadBlockHash !== parentBlockHash
|
|
542
588
|
) {
|
|
543
|
-
this.searchUnknownRoot({slot, root: parentBlockRoot},
|
|
589
|
+
this.searchUnknownRoot({slot, root: parentBlockRoot}, peerId, {
|
|
590
|
+
target: SearchTarget.PayloadEnvelope,
|
|
591
|
+
slotIsPayloadSlot: false,
|
|
592
|
+
});
|
|
544
593
|
preprocessResult = {action: PreprocessAction.AwaitEnvelope, root: parentBlockRoot};
|
|
545
594
|
}
|
|
546
595
|
}
|
|
@@ -641,16 +690,24 @@ export class NetworkProcessor {
|
|
|
641
690
|
return true;
|
|
642
691
|
}
|
|
643
692
|
|
|
693
|
+
/**
|
|
694
|
+
* Search block/envelope given a SlotRootHex
|
|
695
|
+
* undefined peer id means optimistic search
|
|
696
|
+
*/
|
|
644
697
|
private searchUnknownRoot(
|
|
645
698
|
slotRoot: SlotRootHex,
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
peerId: PeerIdStr
|
|
699
|
+
peerId: PeerIdStr | undefined,
|
|
700
|
+
search: SearchUnknownRootTarget
|
|
649
701
|
): void {
|
|
650
|
-
if (!searchBlock && !searchEnvelope) return;
|
|
651
702
|
if (this.tooManySearchedRoots(slotRoot.slot, slotRoot.root)) return;
|
|
652
|
-
|
|
653
|
-
|
|
703
|
+
switch (search.target) {
|
|
704
|
+
case SearchTarget.Block:
|
|
705
|
+
this.searchUnknownBlock(slotRoot, BlockInputSource.network_processor, peerId);
|
|
706
|
+
break;
|
|
707
|
+
case SearchTarget.PayloadEnvelope:
|
|
708
|
+
this.searchUnknownEnvelope(slotRoot, BlockInputSource.network_processor, peerId, search.slotIsPayloadSlot);
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
654
711
|
}
|
|
655
712
|
|
|
656
713
|
private pushPendingGossipsubMessageToQueue(message: PendingGossipsubMessage): void {
|
|
@@ -5,8 +5,10 @@ import {GENESIS_SLOT} from "@lodestar/params";
|
|
|
5
5
|
import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
6
6
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
7
7
|
import {gloas} from "@lodestar/types";
|
|
8
|
+
import {EnvelopeReconstructionError} from "../../../chain/errors/index.js";
|
|
8
9
|
import {IBeaconChain} from "../../../chain/index.js";
|
|
9
10
|
import {IBeaconDb} from "../../../db/index.js";
|
|
11
|
+
import {reconstructExecutionPayloadEnvelopesByRange} from "../../../util/execution.js";
|
|
10
12
|
import {prettyPrintPeerId} from "../../util.js";
|
|
11
13
|
|
|
12
14
|
export async function* onExecutionPayloadEnvelopesByRange(
|
|
@@ -35,58 +37,74 @@ export async function* onExecutionPayloadEnvelopesByRange(
|
|
|
35
37
|
);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
const finalized = db.executionPayloadEnvelopeArchive;
|
|
39
40
|
// Use the finalized block's actual slot as the checkpoint epoch-boundary slot may be skipped
|
|
40
41
|
const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
|
|
41
42
|
// The finalized block's envelope stays in the hot db until the next finalization run
|
|
42
43
|
const archiveMaxSlot = finalizedSlot - 1;
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
let yielded = 0;
|
|
46
|
+
try {
|
|
47
|
+
if (startSlot <= archiveMaxSlot) {
|
|
48
|
+
for await (const {slot, envelopeBytes} of reconstructExecutionPayloadEnvelopesByRange(
|
|
49
|
+
db,
|
|
50
|
+
chain.executionEngine,
|
|
51
|
+
chain.logger,
|
|
52
|
+
chain.metrics,
|
|
53
|
+
startSlot,
|
|
54
|
+
Math.min(endSlot, archiveMaxSlot + 1)
|
|
55
|
+
)) {
|
|
56
|
+
yielded++;
|
|
57
|
+
yield {
|
|
58
|
+
data: envelopeBytes,
|
|
59
|
+
boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(slot)),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
|
-
}
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
// Non-finalized range of envelopes. The finalized block's own envelope may be archived by a
|
|
65
|
+
// migration that ran since archiveMaxSlot was computed, so this read can reconstruct too.
|
|
66
|
+
if (endSlot > archiveMaxSlot) {
|
|
67
|
+
const headBlock = chain.forkChoice.getHead();
|
|
68
|
+
const headRoot = headBlock.blockRoot;
|
|
69
|
+
const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
|
|
63
70
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
// Iterate head chain with ascending block numbers
|
|
72
|
+
for (let i = headChain.length - 1; i >= 0; i--) {
|
|
73
|
+
const block = headChain[i];
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
if (block.slot > archiveMaxSlot && block.slot >= startSlot && block.slot < endSlot) {
|
|
76
|
+
// Skip EMPTY blocks
|
|
77
|
+
if (block.payloadStatus !== PayloadStatus.FULL) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
73
80
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
const envelopeBytes = await chain.getSerializedExecutionPayloadEnvelope(block.slot, block.blockRoot);
|
|
82
|
+
if (!envelopeBytes) {
|
|
83
|
+
throw new ResponseError(
|
|
84
|
+
RespStatus.SERVER_ERROR,
|
|
85
|
+
`No envelope for root ${block.blockRoot} slot ${block.slot}, startSlot=${startSlot} endSlot=${endSlot} finalizedSlot=${finalizedSlot}`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
yielded++;
|
|
90
|
+
yield {
|
|
91
|
+
data: envelopeBytes,
|
|
92
|
+
boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(block.slot)),
|
|
93
|
+
};
|
|
94
|
+
} else if (block.slot >= endSlot) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
88
97
|
}
|
|
89
98
|
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
if (e instanceof EnvelopeReconstructionError) {
|
|
101
|
+
// An unservable entry or our own EL failing: after some envelopes, end short (spec-legal, the
|
|
102
|
+
// peer fetches the rest elsewhere); with nothing served, RESOURCE_UNAVAILABLE rather than
|
|
103
|
+
// SERVER_ERROR so peers don't downscore us for it
|
|
104
|
+
if (yielded > 0) return;
|
|
105
|
+
throw new ResponseError(RespStatus.RESOURCE_UNAVAILABLE, `Failed to serve envelopes: ${e.message}`);
|
|
106
|
+
}
|
|
107
|
+
throw e;
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
110
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {PeerId} from "@libp2p/interface";
|
|
2
|
-
import {ResponseOutgoing} from "@lodestar/reqresp";
|
|
2
|
+
import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
3
3
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
4
|
+
import {RootHex, Slot} from "@lodestar/types";
|
|
4
5
|
import {toRootHex} from "@lodestar/utils";
|
|
6
|
+
import {EnvelopeReconstructionError} from "../../../chain/errors/index.js";
|
|
5
7
|
import {IBeaconChain} from "../../../chain/index.js";
|
|
6
8
|
import {IBeaconDb} from "../../../db/index.js";
|
|
7
9
|
import {ExecutionPayloadEnvelopesByRootRequest} from "../../../util/types.js";
|
|
@@ -17,6 +19,8 @@ export async function* onExecutionPayloadEnvelopesByRoot(
|
|
|
17
19
|
// The gloas req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve.
|
|
18
20
|
// Archival nodes may still serve older retained payloads to allow genesis sync.
|
|
19
21
|
|
|
22
|
+
// Resolve slots first so archived header envelopes are rebuilt in one EL batch, not one call per root
|
|
23
|
+
const requests: {blockSlot: Slot; blockRootHex: RootHex}[] = [];
|
|
20
24
|
for (const root of requestBody) {
|
|
21
25
|
const rootHex = toRootHex(root);
|
|
22
26
|
const block = chain.forkChoice.getBlockHexDefaultStatus(rootHex);
|
|
@@ -34,17 +38,35 @@ export async function* onExecutionPayloadEnvelopesByRoot(
|
|
|
34
38
|
);
|
|
35
39
|
continue;
|
|
36
40
|
}
|
|
41
|
+
requests.push({blockSlot: slot, blockRootHex: rootHex});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let envelopesBytes: (Uint8Array | null)[];
|
|
45
|
+
try {
|
|
46
|
+
// by-root allows omission, so a mismatched envelope is left out rather than failing the response
|
|
47
|
+
envelopesBytes = await chain.getSerializedExecutionPayloadEnvelopes(requests, "omit");
|
|
48
|
+
} catch (e) {
|
|
49
|
+
if (e instanceof EnvelopeReconstructionError) {
|
|
50
|
+
throw new ResponseError(
|
|
51
|
+
RespStatus.RESOURCE_UNAVAILABLE,
|
|
52
|
+
`Failed to reconstruct archived envelopes: ${e.message}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
throw e;
|
|
56
|
+
}
|
|
37
57
|
|
|
38
|
-
|
|
58
|
+
for (let i = 0; i < requests.length; i++) {
|
|
59
|
+
const {blockSlot, blockRootHex} = requests[i];
|
|
60
|
+
const envelopeBytes = envelopesBytes[i];
|
|
39
61
|
if (envelopeBytes) {
|
|
40
62
|
yield {
|
|
41
63
|
data: envelopeBytes,
|
|
42
|
-
boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(
|
|
64
|
+
boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(blockSlot)),
|
|
43
65
|
};
|
|
44
66
|
} else {
|
|
45
67
|
chain.logger.debug("Cannot serve ExecutionPayloadEnvelopesByRoot: envelope not found", {
|
|
46
|
-
slot,
|
|
47
|
-
root:
|
|
68
|
+
slot: blockSlot,
|
|
69
|
+
root: blockRootHex,
|
|
48
70
|
peer: prettyPrintPeerId(peerId),
|
|
49
71
|
client: peerClient,
|
|
50
72
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {Type} from "@chainsafe/ssz";
|
|
2
|
-
import {ProtocolHandler, RespStatus, ResponseError} from "@lodestar/reqresp";
|
|
2
|
+
import {ProtocolHandler, RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
3
3
|
import {ssz} from "@lodestar/types";
|
|
4
4
|
import {IBeaconChain} from "../../../chain/index.js";
|
|
5
5
|
import {IBeaconDb} from "../../../db/index.js";
|
|
@@ -38,6 +38,29 @@ function deserializeRequestBody<T>(type: Type<T>, data: Uint8Array): T {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
async function* trackByRangeResponse(
|
|
42
|
+
chain: IBeaconChain,
|
|
43
|
+
method: ReqRespMethod,
|
|
44
|
+
count: number,
|
|
45
|
+
source: AsyncIterable<ResponseOutgoing>,
|
|
46
|
+
columns?: number
|
|
47
|
+
): AsyncIterable<ResponseOutgoing> {
|
|
48
|
+
chain.metrics?.reqRespByRange.requestedSlots.observe({method}, count);
|
|
49
|
+
if (columns !== undefined) {
|
|
50
|
+
chain.metrics?.reqRespByRange.requestedColumns.observe(columns);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let servedBytes = 0;
|
|
54
|
+
try {
|
|
55
|
+
for await (const chunk of source) {
|
|
56
|
+
servedBytes += chunk.data.length;
|
|
57
|
+
yield chunk;
|
|
58
|
+
}
|
|
59
|
+
} finally {
|
|
60
|
+
chain.metrics?.reqRespByRange.servedBytes.observe({method}, servedBytes);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
41
64
|
/**
|
|
42
65
|
* The ReqRespHandler module handles app-level requests / responses from other peers,
|
|
43
66
|
* fetching state from the chain and database as needed.
|
|
@@ -50,7 +73,12 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
|
|
|
50
73
|
[ReqRespMethod.Metadata]: notImplemented(ReqRespMethod.Metadata),
|
|
51
74
|
[ReqRespMethod.BeaconBlocksByRange]: (req, peerId, peerClient) => {
|
|
52
75
|
const body = deserializeRequestBody(ssz.phase0.BeaconBlocksByRangeRequest, req.data);
|
|
53
|
-
return
|
|
76
|
+
return trackByRangeResponse(
|
|
77
|
+
chain,
|
|
78
|
+
ReqRespMethod.BeaconBlocksByRange,
|
|
79
|
+
body.count,
|
|
80
|
+
onBeaconBlocksByRange(body, chain, db, peerId, peerClient)
|
|
81
|
+
);
|
|
54
82
|
},
|
|
55
83
|
[ReqRespMethod.BeaconBlocksByRoot]: (req) => {
|
|
56
84
|
const fork = chain.config.getForkName(chain.clock.currentSlot);
|
|
@@ -68,11 +96,22 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
|
|
|
68
96
|
},
|
|
69
97
|
[ReqRespMethod.BlobSidecarsByRange]: (req) => {
|
|
70
98
|
const body = deserializeRequestBody(ssz.deneb.BlobSidecarsByRangeRequest, req.data);
|
|
71
|
-
return
|
|
99
|
+
return trackByRangeResponse(
|
|
100
|
+
chain,
|
|
101
|
+
ReqRespMethod.BlobSidecarsByRange,
|
|
102
|
+
body.count,
|
|
103
|
+
onBlobSidecarsByRange(body, chain, db)
|
|
104
|
+
);
|
|
72
105
|
},
|
|
73
106
|
[ReqRespMethod.DataColumnSidecarsByRange]: (req, peerId, peerClient) => {
|
|
74
107
|
const body = deserializeRequestBody(ssz.fulu.DataColumnSidecarsByRangeRequest, req.data);
|
|
75
|
-
return
|
|
108
|
+
return trackByRangeResponse(
|
|
109
|
+
chain,
|
|
110
|
+
ReqRespMethod.DataColumnSidecarsByRange,
|
|
111
|
+
body.count,
|
|
112
|
+
onDataColumnSidecarsByRange(body, chain, db, peerId, peerClient),
|
|
113
|
+
body.columns.length
|
|
114
|
+
);
|
|
76
115
|
},
|
|
77
116
|
[ReqRespMethod.DataColumnSidecarsByRoot]: (req, peerId, peerClient) => {
|
|
78
117
|
const body = deserializeRequestBody(DataColumnSidecarsByRootRequestType(chain.config), req.data);
|
|
@@ -85,7 +124,12 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
|
|
|
85
124
|
},
|
|
86
125
|
[ReqRespMethod.ExecutionPayloadEnvelopesByRange]: (req, peerId, peerClient) => {
|
|
87
126
|
const body = deserializeRequestBody(ssz.gloas.ExecutionPayloadEnvelopesByRangeRequest, req.data);
|
|
88
|
-
return
|
|
127
|
+
return trackByRangeResponse(
|
|
128
|
+
chain,
|
|
129
|
+
ReqRespMethod.ExecutionPayloadEnvelopesByRange,
|
|
130
|
+
body.count,
|
|
131
|
+
onExecutionPayloadEnvelopesByRange(body, chain, db, peerId, peerClient)
|
|
132
|
+
);
|
|
89
133
|
},
|
|
90
134
|
|
|
91
135
|
[ReqRespMethod.LightClientBootstrap]: (req) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
-
import {ForkName} from "@lodestar/params";
|
|
2
|
+
import {ForkName, isForkPostGloas} from "@lodestar/params";
|
|
3
3
|
import {ContextBytesFactory, ContextBytesType, Encoding, TypeSizes} from "@lodestar/reqresp";
|
|
4
|
+
import {computeMaxGloasDataColumnSidecarSize} from "../../util/sszBytes.js";
|
|
4
5
|
import {rateLimitQuotas} from "./rateLimit.js";
|
|
5
6
|
import {ProtocolNoHandler, ReqRespMethod, Version, requestSszTypeByMethod, responseSszTypeByMethod} from "./types.js";
|
|
6
7
|
|
|
@@ -151,18 +152,42 @@ function toProtocol(protocol: ProtocolSummary) {
|
|
|
151
152
|
encoding: Encoding.SSZ_SNAPPY,
|
|
152
153
|
contextBytes: toContextBytes(protocol.contextBytesType, config),
|
|
153
154
|
inboundRateLimits: rateLimitQuotas(fork, config)[protocol.method],
|
|
154
|
-
requestSizes: requestType === null ? null : clampTypeSizes(requestType, config),
|
|
155
|
-
responseSizes: (fork) =>
|
|
155
|
+
requestSizes: requestType === null ? null : clampTypeSizes(requestType, config.MAX_PAYLOAD_SIZE),
|
|
156
|
+
responseSizes: (fork) =>
|
|
157
|
+
clampResponseTypeSizes(
|
|
158
|
+
responseSszTypeByMethod[protocol.method](fork, protocol.version),
|
|
159
|
+
protocol.method,
|
|
160
|
+
fork,
|
|
161
|
+
config
|
|
162
|
+
),
|
|
156
163
|
};
|
|
157
164
|
};
|
|
158
165
|
}
|
|
159
166
|
|
|
167
|
+
function clampResponseTypeSizes(
|
|
168
|
+
type: TypeSizes,
|
|
169
|
+
method: ReqRespMethod,
|
|
170
|
+
fork: ForkName,
|
|
171
|
+
config: BeaconConfig
|
|
172
|
+
): TypeSizes {
|
|
173
|
+
let maxPayloadSize = config.MAX_PAYLOAD_SIZE;
|
|
174
|
+
if (isForkPostGloas(fork)) {
|
|
175
|
+
switch (method) {
|
|
176
|
+
case ReqRespMethod.DataColumnSidecarsByRange:
|
|
177
|
+
case ReqRespMethod.DataColumnSidecarsByRoot:
|
|
178
|
+
maxPayloadSize = Math.min(maxPayloadSize, computeMaxGloasDataColumnSidecarSize(config));
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return clampTypeSizes(type, maxPayloadSize);
|
|
183
|
+
}
|
|
184
|
+
|
|
160
185
|
/**
|
|
161
|
-
* Length-prefix must be within the SSZ type bounds or
|
|
186
|
+
* Length-prefix must be within the SSZ type bounds or the configured payload limit, whichever is smaller.
|
|
162
187
|
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.12/specs/phase0/p2p-interface.md#encoding-strategies
|
|
163
188
|
*/
|
|
164
|
-
function clampTypeSizes(type: TypeSizes,
|
|
165
|
-
return {minSize: type.minSize, maxSize: Math.min(type.maxSize,
|
|
189
|
+
function clampTypeSizes(type: TypeSizes, maxPayloadSize: number): TypeSizes {
|
|
190
|
+
return {minSize: type.minSize, maxSize: Math.min(type.maxSize, maxPayloadSize)};
|
|
166
191
|
}
|
|
167
192
|
|
|
168
193
|
function toContextBytes(type: ContextBytesType, config: BeaconConfig): ContextBytesFactory {
|
package/src/node/nodejs.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {BeaconConfig} from "@lodestar/config";
|
|
|
8
8
|
import type {LoggerNode} from "@lodestar/logger/node";
|
|
9
9
|
import {ZERO_HASH_HEX} from "@lodestar/params";
|
|
10
10
|
import {IBeaconStateView, isStatePostBellatrix, isStatePostGloas} from "@lodestar/state-transition";
|
|
11
|
-
import {phase0} from "@lodestar/types";
|
|
12
11
|
import {sleep, toRootHex} from "@lodestar/utils";
|
|
13
12
|
import {ProcessShutdownCallback} from "@lodestar/validator";
|
|
14
13
|
import {BeaconRestApiServer, getApi} from "../api/index.js";
|
|
@@ -19,7 +18,6 @@ import {initializeExecutionBuilder, initializeExecutionEngine} from "../executio
|
|
|
19
18
|
import {HttpMetricsServer, Metrics, createMetrics, getHttpMetricsServer} from "../metrics/index.js";
|
|
20
19
|
import {MonitoringService} from "../monitoring/index.js";
|
|
21
20
|
import {Network, getReqRespHandlers} from "../network/index.js";
|
|
22
|
-
import {BackfillSync} from "../sync/backfill/index.js";
|
|
23
21
|
import {BeaconSync, IBeaconSync} from "../sync/index.js";
|
|
24
22
|
import {Clock} from "../util/clock.js";
|
|
25
23
|
import {startDeferredVoluntaryExitPublisher} from "./deferredVoluntaryExitPublisher.js";
|
|
@@ -38,7 +36,6 @@ export type BeaconNodeModules = {
|
|
|
38
36
|
chain: IBeaconChain;
|
|
39
37
|
api: BeaconApiMethods;
|
|
40
38
|
sync: IBeaconSync;
|
|
41
|
-
backfillSync: BackfillSync | null;
|
|
42
39
|
metricsServer: HttpMetricsServer | null;
|
|
43
40
|
monitoring: MonitoringService | null;
|
|
44
41
|
restApi?: BeaconRestApiServer;
|
|
@@ -58,7 +55,6 @@ export type BeaconNodeInitModules = {
|
|
|
58
55
|
peerStoreDir?: string;
|
|
59
56
|
anchorState: IBeaconStateView;
|
|
60
57
|
isAnchorStateFinalized: boolean;
|
|
61
|
-
wsCheckpoint?: phase0.Checkpoint;
|
|
62
58
|
metricsRegistries?: Registry[];
|
|
63
59
|
};
|
|
64
60
|
|
|
@@ -70,7 +66,6 @@ export enum BeaconNodeStatus {
|
|
|
70
66
|
|
|
71
67
|
enum LoggerModule {
|
|
72
68
|
api = "api",
|
|
73
|
-
backfill = "backfill",
|
|
74
69
|
chain = "chain",
|
|
75
70
|
execution = "execution",
|
|
76
71
|
metrics = "metrics",
|
|
@@ -105,7 +100,6 @@ export class BeaconNode {
|
|
|
105
100
|
api: BeaconApiMethods;
|
|
106
101
|
restApi?: BeaconRestApiServer;
|
|
107
102
|
sync: IBeaconSync;
|
|
108
|
-
backfillSync: BackfillSync | null;
|
|
109
103
|
|
|
110
104
|
status: BeaconNodeStatus;
|
|
111
105
|
private controller?: AbortController;
|
|
@@ -123,7 +117,6 @@ export class BeaconNode {
|
|
|
123
117
|
api,
|
|
124
118
|
restApi,
|
|
125
119
|
sync,
|
|
126
|
-
backfillSync,
|
|
127
120
|
controller,
|
|
128
121
|
}: BeaconNodeModules) {
|
|
129
122
|
this.opts = opts;
|
|
@@ -138,7 +131,6 @@ export class BeaconNode {
|
|
|
138
131
|
this.restApi = restApi;
|
|
139
132
|
this.network = network;
|
|
140
133
|
this.sync = sync;
|
|
141
|
-
this.backfillSync = backfillSync;
|
|
142
134
|
this.controller = controller;
|
|
143
135
|
|
|
144
136
|
this.status = BeaconNodeStatus.started;
|
|
@@ -161,7 +153,6 @@ export class BeaconNode {
|
|
|
161
153
|
peerStoreDir,
|
|
162
154
|
anchorState,
|
|
163
155
|
isAnchorStateFinalized,
|
|
164
|
-
wsCheckpoint,
|
|
165
156
|
metricsRegistries = [],
|
|
166
157
|
}: BeaconNodeInitModules): Promise<T> {
|
|
167
158
|
if (hasher.name !== "hashtree") {
|
|
@@ -295,25 +286,9 @@ export class BeaconNode {
|
|
|
295
286
|
chain,
|
|
296
287
|
metrics,
|
|
297
288
|
network,
|
|
298
|
-
wsCheckpoint,
|
|
299
289
|
logger: logger.child({module: LoggerModule.sync}),
|
|
300
290
|
});
|
|
301
291
|
|
|
302
|
-
const backfillSync =
|
|
303
|
-
opts.sync.backfillBatchSize > 0
|
|
304
|
-
? await BackfillSync.init(opts.sync, {
|
|
305
|
-
config,
|
|
306
|
-
db,
|
|
307
|
-
chain,
|
|
308
|
-
metrics,
|
|
309
|
-
network,
|
|
310
|
-
wsCheckpoint,
|
|
311
|
-
anchorState,
|
|
312
|
-
logger: logger.child({module: LoggerModule.backfill}),
|
|
313
|
-
signal,
|
|
314
|
-
})
|
|
315
|
-
: null;
|
|
316
|
-
|
|
317
292
|
const api = getApi(opts.api, {
|
|
318
293
|
config,
|
|
319
294
|
logger: logger.child({module: LoggerModule.api}),
|
|
@@ -361,7 +336,6 @@ export class BeaconNode {
|
|
|
361
336
|
api,
|
|
362
337
|
restApi,
|
|
363
338
|
sync,
|
|
364
|
-
backfillSync,
|
|
365
339
|
controller,
|
|
366
340
|
}) as T;
|
|
367
341
|
}
|
|
@@ -373,7 +347,6 @@ export class BeaconNode {
|
|
|
373
347
|
if (this.status === BeaconNodeStatus.started) {
|
|
374
348
|
this.status = BeaconNodeStatus.closing;
|
|
375
349
|
this.sync.close();
|
|
376
|
-
this.backfillSync?.close();
|
|
377
350
|
if (this.restApi) await this.restApi.close();
|
|
378
351
|
await this.network.close();
|
|
379
352
|
if (this.metricsServer) await this.metricsServer.close();
|
package/src/sync/interface.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
-
import {Slot
|
|
3
|
+
import {Slot} from "@lodestar/types";
|
|
4
4
|
import {Logger} from "@lodestar/utils";
|
|
5
5
|
import {IBeaconChain} from "../chain/index.js";
|
|
6
6
|
import {IBeaconDb} from "../db/index.js";
|
|
@@ -51,5 +51,4 @@ export interface SyncModules {
|
|
|
51
51
|
metrics: Metrics | null;
|
|
52
52
|
logger: Logger;
|
|
53
53
|
chain: IBeaconChain;
|
|
54
|
-
wsCheckpoint?: phase0.Checkpoint;
|
|
55
54
|
}
|