@lodestar/beacon-node 1.42.0-dev.84f3b9f030 → 1.42.0-dev.89ddaaeed2
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 +11 -11
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +2 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +5 -5
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/GetBlobsTracker.d.ts +2 -1
- package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
- package/lib/chain/GetBlobsTracker.js +14 -12
- package/lib/chain/GetBlobsTracker.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +5 -5
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/blockInput/types.d.ts +4 -4
- package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +13 -1
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +14 -6
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +33 -2
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/chain.d.ts +3 -2
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +55 -20
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +29 -7
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +12 -3
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +31 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js +7 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/interface.d.ts +4 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +2 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +11 -4
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +184 -5
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/db/buckets.d.ts +2 -2
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +2 -2
- package/lib/db/buckets.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/dataColumnSidecar.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecar.js +4 -2
- package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
- package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecarArchive.js +4 -2
- package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +20 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +33 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/interface.d.ts +3 -2
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +19 -13
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/network.d.ts +3 -2
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +3 -0
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js +7 -2
- package/lib/network/options.js.map +1 -1
- package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
- package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
- package/lib/network/processor/extractSlotRootFns.js +25 -5
- package/lib/network/processor/extractSlotRootFns.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +242 -66
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts +11 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +232 -22
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +3 -3
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/reqresp/types.js +9 -3
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/sync/unknownBlock.js +2 -2
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +3 -3
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +4 -2
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +3 -3
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +10 -5
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/blobs.d.ts +3 -3
- package/lib/util/blobs.d.ts.map +1 -1
- package/lib/util/blobs.js +21 -10
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/dataColumns.d.ts +18 -11
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +51 -17
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/execution.d.ts +6 -2
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +49 -25
- package/lib/util/execution.js.map +1 -1
- package/lib/util/sszBytes.d.ts +25 -1
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +189 -2
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +17 -14
- package/src/api/impl/debug/index.ts +2 -2
- package/src/chain/ColumnReconstructionTracker.ts +6 -5
- package/src/chain/GetBlobsTracker.ts +14 -12
- package/src/chain/blocks/blockInput/blockInput.ts +8 -8
- package/src/chain/blocks/blockInput/types.ts +4 -4
- package/src/chain/blocks/importBlock.ts +18 -1
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +53 -12
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +2 -1
- package/src/chain/chain.ts +63 -24
- package/src/chain/emitter.ts +25 -7
- package/src/chain/errors/dataColumnSidecarError.ts +32 -1
- package/src/chain/interface.ts +4 -2
- package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +2 -2
- package/src/chain/validation/dataColumnSidecar.ts +230 -7
- package/src/db/buckets.ts +2 -2
- package/src/db/repositories/dataColumnSidecar.ts +4 -2
- package/src/db/repositories/dataColumnSidecarArchive.ts +4 -2
- package/src/metrics/metrics/lodestar.ts +34 -0
- package/src/network/interface.ts +3 -2
- package/src/network/libp2p/index.ts +21 -15
- package/src/network/network.ts +7 -4
- package/src/network/options.ts +7 -2
- package/src/network/processor/extractSlotRootFns.ts +32 -6
- package/src/network/processor/gossipHandlers.ts +305 -79
- package/src/network/processor/index.ts +302 -22
- package/src/network/reqresp/types.ts +13 -5
- package/src/sync/unknownBlock.ts +3 -3
- package/src/sync/utils/downloadByRange.ts +9 -7
- package/src/sync/utils/downloadByRoot.ts +16 -12
- package/src/util/blobs.ts +35 -15
- package/src/util/dataColumns.ts +69 -25
- package/src/util/execution.ts +49 -30
- package/src/util/sszBytes.ts +245 -3
|
@@ -12,6 +12,16 @@ import {Metrics} from "../../metrics/metrics.js";
|
|
|
12
12
|
import {ClockEvent} from "../../util/clock.js";
|
|
13
13
|
import {callInNextEventLoop} from "../../util/eventLoop.js";
|
|
14
14
|
import {PeerIdStr} from "../../util/peerId.js";
|
|
15
|
+
import {
|
|
16
|
+
getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized,
|
|
17
|
+
getDataIndexFromSignedAggregateAndProofSerialized,
|
|
18
|
+
getDataIndexFromSingleAttestationSerialized,
|
|
19
|
+
getParentBlockHashFromGloasSignedBeaconBlockSerialized,
|
|
20
|
+
getParentBlockHashFromSignedExecutionPayloadBidSerialized,
|
|
21
|
+
getParentBlockRootFromSignedExecutionPayloadBidSerialized,
|
|
22
|
+
getParentRootFromSignedBeaconBlockSerialized,
|
|
23
|
+
getPayloadPresentFromPayloadAttestationMessageSerialized,
|
|
24
|
+
} from "../../util/sszBytes.js";
|
|
15
25
|
import {NetworkEvent, NetworkEventBus} from "../events.js";
|
|
16
26
|
import {
|
|
17
27
|
GossipHandlers,
|
|
@@ -89,6 +99,8 @@ const MAX_JOBS_SUBMITTED_PER_TICK = 128;
|
|
|
89
99
|
|
|
90
100
|
// How many gossip messages we keep before new ones get dropped.
|
|
91
101
|
const MAX_QUEUED_UNKNOWN_BLOCK_GOSSIP_OBJECTS = 16_384;
|
|
102
|
+
// TODO gloas: arbitrary constant, check metrics.
|
|
103
|
+
const MAX_QUEUED_UNKNOWN_PAYLOAD_GOSSIP_OBJECTS = 1024;
|
|
92
104
|
|
|
93
105
|
// We don't want to process too many gossip messages in a single tick
|
|
94
106
|
// As seen on mainnet, gossip messages concurrency metric ranges from 1000 to 2000
|
|
@@ -126,6 +138,20 @@ export enum CannotAcceptWorkReason {
|
|
|
126
138
|
regen = "regen_busy",
|
|
127
139
|
}
|
|
128
140
|
|
|
141
|
+
/**
|
|
142
|
+
* No metrics needed here; using a number to keep it lightweight
|
|
143
|
+
*/
|
|
144
|
+
enum PreprocessAction {
|
|
145
|
+
AwaitBlock,
|
|
146
|
+
AwaitEnvelope,
|
|
147
|
+
PushToQueue,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
type PreprocessResult =
|
|
151
|
+
| {action: PreprocessAction.PushToQueue}
|
|
152
|
+
| {action: PreprocessAction.AwaitBlock; root: RootHex}
|
|
153
|
+
| {action: PreprocessAction.AwaitEnvelope; root: RootHex};
|
|
154
|
+
|
|
129
155
|
/**
|
|
130
156
|
* Network processor handles the gossip queues and throtles processing to not overload the main thread
|
|
131
157
|
* - Decides when to process work and what to process
|
|
@@ -159,7 +185,11 @@ export class NetworkProcessor {
|
|
|
159
185
|
// we may not receive the block for messages like Attestation and SignedAggregateAndProof messages, in that case PendingGossipsubMessage needs
|
|
160
186
|
// to be stored in this Map and reprocessed once the block comes
|
|
161
187
|
private readonly awaitingMessagesByBlockRoot: MapDef<RootHex, Set<PendingGossipsubMessage>>;
|
|
188
|
+
// we may not receive the payload for messages like payload_attestation_message messages, in that case PendingGossipsubMessage needs
|
|
189
|
+
// to be stored in this Map and reprocessed once the payload comes
|
|
190
|
+
private readonly awaitingMessagesByPayloadBlockRoot: MapDef<RootHex, Set<PendingGossipsubMessage>>;
|
|
162
191
|
private unknownBlocksBySlot = new MapDef<Slot, Set<RootHex>>(() => new Set());
|
|
192
|
+
private unknownEnvelopesBySlot = new MapDef<Slot, Set<RootHex>>(() => new Set());
|
|
163
193
|
|
|
164
194
|
constructor(
|
|
165
195
|
modules: NetworkProcessorModules,
|
|
@@ -179,11 +209,13 @@ export class NetworkProcessor {
|
|
|
179
209
|
modules
|
|
180
210
|
);
|
|
181
211
|
|
|
182
|
-
events.on(NetworkEvent.pendingGossipsubMessage, this.onPendingGossipsubMessage
|
|
183
|
-
this.chain.emitter.on(routes.events.EventType.block, this.onBlockProcessed
|
|
184
|
-
this.chain.
|
|
212
|
+
events.on(NetworkEvent.pendingGossipsubMessage, this.onPendingGossipsubMessage);
|
|
213
|
+
this.chain.emitter.on(routes.events.EventType.block, this.onBlockProcessed);
|
|
214
|
+
this.chain.emitter.on(routes.events.EventType.executionPayload, this.onPayloadEnvelopeProcessed);
|
|
215
|
+
this.chain.clock.on(ClockEvent.slot, this.onClockSlot);
|
|
185
216
|
|
|
186
217
|
this.awaitingMessagesByBlockRoot = new MapDef<RootHex, Set<PendingGossipsubMessage>>(() => new Set());
|
|
218
|
+
this.awaitingMessagesByPayloadBlockRoot = new MapDef<RootHex, Set<PendingGossipsubMessage>>(() => new Set());
|
|
187
219
|
|
|
188
220
|
// TODO: Implement queues and priorization for ReqResp incoming requests
|
|
189
221
|
// Listens to NetworkEvent.reqRespIncomingRequest event
|
|
@@ -196,6 +228,7 @@ export class NetworkProcessor {
|
|
|
196
228
|
metrics.gossipValidationQueue.concurrency.set({topic}, this.gossipTopicConcurrency[topic]);
|
|
197
229
|
}
|
|
198
230
|
metrics.awaitingBlockGossipMessages.countPerSlot.set(this.unknownBlockGossipsubMessagesCount);
|
|
231
|
+
metrics.awaitingPayloadGossipMessages.countPerSlot.set(this.unknownPayloadGossipsubMessagesCount);
|
|
199
232
|
// specific metric for beacon_attestation topic
|
|
200
233
|
metrics.gossipValidationQueue.keyAge.reset();
|
|
201
234
|
for (const ageMs of this.gossipQueues.beacon_attestation.getDataAgeMs()) {
|
|
@@ -212,6 +245,7 @@ export class NetworkProcessor {
|
|
|
212
245
|
async stop(): Promise<void> {
|
|
213
246
|
this.events.off(NetworkEvent.pendingGossipsubMessage, this.onPendingGossipsubMessage);
|
|
214
247
|
this.chain.emitter.off(routes.events.EventType.block, this.onBlockProcessed);
|
|
248
|
+
this.chain.emitter.off(routes.events.EventType.executionPayload, this.onPayloadEnvelopeProcessed);
|
|
215
249
|
this.chain.emitter.off(ClockEvent.slot, this.onClockSlot);
|
|
216
250
|
}
|
|
217
251
|
|
|
@@ -232,7 +266,7 @@ export class NetworkProcessor {
|
|
|
232
266
|
|
|
233
267
|
/**
|
|
234
268
|
* Search block via `ChainEvent.unknownBlockRoot` event
|
|
235
|
-
*
|
|
269
|
+
* Slot is the message slot, which is not necessarily the same as the block's slot, but it can be used for a good prune strategy.
|
|
236
270
|
* 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.
|
|
237
271
|
*/
|
|
238
272
|
searchUnknownBlock({slot, root}: SlotRootHex, source: BlockInputSource, peer?: PeerIdStr): void {
|
|
@@ -248,9 +282,29 @@ export class NetworkProcessor {
|
|
|
248
282
|
this.chain.emitter.emit(ChainEvent.unknownBlockRoot, {rootHex: root, peer, source});
|
|
249
283
|
}
|
|
250
284
|
|
|
251
|
-
|
|
285
|
+
/**
|
|
286
|
+
* Search envelope via `ChainEvent.unknownEnvelopeBlockRoot` event
|
|
287
|
+
* 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.
|
|
288
|
+
* 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.
|
|
289
|
+
*/
|
|
290
|
+
searchUnknownEnvelope({slot, root}: SlotRootHex, source: BlockInputSource, peer?: PeerIdStr): void {
|
|
291
|
+
if (
|
|
292
|
+
this.chain.seenPayloadEnvelope(root) ||
|
|
293
|
+
this.awaitingMessagesByPayloadBlockRoot.has(root) ||
|
|
294
|
+
this.unknownEnvelopesBySlot.getOrDefault(slot).has(root)
|
|
295
|
+
) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this.unknownEnvelopesBySlot.getOrDefault(slot).add(root);
|
|
299
|
+
this.chain.emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, {rootHex: root, peer, source});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private onPendingGossipsubMessage = (message: PendingGossipsubMessage): void => {
|
|
252
303
|
const topicType = message.topic.type;
|
|
253
304
|
const extractBlockSlotRootFn = this.extractBlockSlotRootFns[topicType];
|
|
305
|
+
|
|
306
|
+
// 1st extract round: make sure slot is in range and if block root is not available
|
|
307
|
+
// proactively search for it + queue the message
|
|
254
308
|
const slotRoot = extractBlockSlotRootFn
|
|
255
309
|
? extractBlockSlotRootFn(message.msg.data, message.topic.boundary.fork)
|
|
256
310
|
: null;
|
|
@@ -282,27 +336,196 @@ export class NetworkProcessor {
|
|
|
282
336
|
|
|
283
337
|
message.msgSlot = slot;
|
|
284
338
|
|
|
339
|
+
// this determines whether this message needs to wait for a Block or Envelope
|
|
340
|
+
// a message should only wait for what it voted for, hence we don't want to put it on both queues
|
|
341
|
+
let preprocessResult: PreprocessResult = {action: PreprocessAction.PushToQueue};
|
|
285
342
|
// 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
|
|
286
343
|
if (root && !this.chain.forkChoice.hasBlockHexUnsafe(root)) {
|
|
344
|
+
// starting from GLOAS, unknown root from data_column_sidecar also falls into this case
|
|
287
345
|
this.searchUnknownBlock({slot, root}, BlockInputSource.network_processor, message.propagationSource.toString());
|
|
346
|
+
// for beacon_attestation and beacon_aggregate_and_proof messages, this is only temporary.
|
|
347
|
+
// if "index = 1" we need to await for the Envelope instead
|
|
348
|
+
preprocessResult = {action: PreprocessAction.AwaitBlock, root};
|
|
349
|
+
}
|
|
288
350
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
351
|
+
// 2nd extract round for some specific topics
|
|
352
|
+
// we separate the search action from the await action
|
|
353
|
+
|
|
354
|
+
// beacon_block: proactively search for parent block/envelope across all forks, but never queue.
|
|
355
|
+
// BlockInputSync handles cascading recovery if the gossip handler throws.
|
|
356
|
+
if (topicType === GossipType.beacon_block) {
|
|
357
|
+
const parentRoot = getParentRootFromSignedBeaconBlockSerialized(message.msg.data);
|
|
358
|
+
if (parentRoot) {
|
|
359
|
+
if (ForkSeq[fork] >= ForkSeq.gloas) {
|
|
360
|
+
// GLOAS: also check parent envelope, same logic as execution_payload_bid
|
|
361
|
+
const parentBlockHash = getParentBlockHashFromGloasSignedBeaconBlockSerialized(message.msg.data);
|
|
362
|
+
if (parentBlockHash && !this.chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHash)) {
|
|
363
|
+
const protoBlock = this.chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
364
|
+
if (protoBlock === null) {
|
|
365
|
+
this.searchUnknownBlock(
|
|
366
|
+
{slot, root: parentRoot},
|
|
367
|
+
BlockInputSource.network_processor,
|
|
368
|
+
message.propagationSource.toString()
|
|
369
|
+
);
|
|
370
|
+
} else if (
|
|
371
|
+
protoBlock.executionPayloadBlockHash &&
|
|
372
|
+
protoBlock.executionPayloadBlockHash !== parentBlockHash
|
|
373
|
+
) {
|
|
374
|
+
// only search for the envelope by block root if we're sure there is one. Otherwise UnknownBlockSync will penalize the peer.
|
|
375
|
+
this.searchUnknownEnvelope(
|
|
376
|
+
{slot, root: parentRoot},
|
|
377
|
+
BlockInputSource.network_processor,
|
|
378
|
+
message.propagationSource.toString()
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
} else if (!this.chain.forkChoice.hasBlockHexUnsafe(parentRoot)) {
|
|
383
|
+
this.searchUnknownBlock(
|
|
384
|
+
{slot, root: parentRoot},
|
|
385
|
+
BlockInputSource.network_processor,
|
|
386
|
+
message.propagationSource.toString()
|
|
387
|
+
);
|
|
388
|
+
}
|
|
296
389
|
}
|
|
390
|
+
preprocessResult = {action: PreprocessAction.PushToQueue};
|
|
391
|
+
}
|
|
297
392
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
393
|
+
if (ForkSeq[fork] >= ForkSeq.gloas) {
|
|
394
|
+
// specific check for each topic
|
|
395
|
+
// note that it's supposed to NOT queue beacon_block (handled above) and execution_payload because it's not a one-off;
|
|
396
|
+
// for those topics, gossip handlers will throw and BlockInputSync will handle a tree of them instead
|
|
397
|
+
switch (topicType) {
|
|
398
|
+
case GossipType.beacon_attestation:
|
|
399
|
+
case GossipType.beacon_aggregate_and_proof: {
|
|
400
|
+
if (root == null) break;
|
|
401
|
+
const attIndex =
|
|
402
|
+
topicType === GossipType.beacon_attestation
|
|
403
|
+
? getDataIndexFromSingleAttestationSerialized(fork, message.msg.data)
|
|
404
|
+
: getDataIndexFromSignedAggregateAndProofSerialized(message.msg.data);
|
|
405
|
+
if (attIndex === 1 && !this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
|
|
406
|
+
// attestation votes that the payload is available but it is not yet known
|
|
407
|
+
this.searchUnknownEnvelope(
|
|
408
|
+
{slot, root},
|
|
409
|
+
BlockInputSource.network_processor,
|
|
410
|
+
message.propagationSource.toString()
|
|
411
|
+
);
|
|
412
|
+
preprocessResult = {action: PreprocessAction.AwaitEnvelope, root};
|
|
413
|
+
}
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
case GossipType.payload_attestation_message: {
|
|
417
|
+
if (root == null) break;
|
|
418
|
+
const payloadPresent = getPayloadPresentFromPayloadAttestationMessageSerialized(message.msg.data);
|
|
419
|
+
if (payloadPresent && !this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
|
|
420
|
+
this.searchUnknownEnvelope(
|
|
421
|
+
{slot, root},
|
|
422
|
+
BlockInputSource.network_processor,
|
|
423
|
+
message.propagationSource.toString()
|
|
424
|
+
);
|
|
425
|
+
preprocessResult = {action: PreprocessAction.AwaitEnvelope, root};
|
|
426
|
+
}
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
case GossipType.data_column_sidecar: {
|
|
430
|
+
if (root == null) break;
|
|
431
|
+
if (!this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
|
|
432
|
+
this.searchUnknownEnvelope(
|
|
433
|
+
{slot, root},
|
|
434
|
+
BlockInputSource.network_processor,
|
|
435
|
+
message.propagationSource.toString()
|
|
436
|
+
);
|
|
437
|
+
// do not await the envelope, we can do gossip validation
|
|
438
|
+
// also do not reset preprocessResult, we may already await for the block
|
|
439
|
+
}
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
case GossipType.execution_payload: {
|
|
443
|
+
// extractBlockSlotRootFn does not return a root for this topic.
|
|
444
|
+
// Extract beacon_block_root directly and proactively trigger block sync if missing.
|
|
445
|
+
// Do NOT await the block — the handler runs immediately; BlockInputSync handles recovery.
|
|
446
|
+
const blockRoot = getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized(message.msg.data);
|
|
447
|
+
if (blockRoot && !this.chain.forkChoice.hasBlockHexUnsafe(blockRoot)) {
|
|
448
|
+
this.searchUnknownBlock(
|
|
449
|
+
{slot, root: blockRoot},
|
|
450
|
+
BlockInputSource.network_processor,
|
|
451
|
+
message.propagationSource.toString()
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
// do not await the block, we want UnknownBlockSync to handle it.
|
|
455
|
+
preprocessResult = {action: PreprocessAction.PushToQueue};
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
case GossipType.execution_payload_bid: {
|
|
459
|
+
// instead of searching for the message root, this searches for the parent root
|
|
460
|
+
const parentBlockRoot = getParentBlockRootFromSignedExecutionPayloadBidSerialized(message.msg.data);
|
|
461
|
+
const parentBlockHash = getParentBlockHashFromSignedExecutionPayloadBidSerialized(message.msg.data);
|
|
462
|
+
if (
|
|
463
|
+
parentBlockRoot &&
|
|
464
|
+
parentBlockHash &&
|
|
465
|
+
!this.chain.forkChoice.getBlockHexAndBlockHash(parentBlockRoot, parentBlockHash)
|
|
466
|
+
) {
|
|
467
|
+
const protoBlock = this.chain.forkChoice.getBlockHexDefaultStatus(parentBlockRoot);
|
|
468
|
+
if (protoBlock === null) {
|
|
469
|
+
this.searchUnknownBlock(
|
|
470
|
+
{slot, root: parentBlockRoot},
|
|
471
|
+
BlockInputSource.network_processor,
|
|
472
|
+
message.propagationSource.toString()
|
|
473
|
+
);
|
|
474
|
+
preprocessResult = {action: PreprocessAction.AwaitBlock, root: parentBlockRoot};
|
|
475
|
+
} else if (
|
|
476
|
+
protoBlock.executionPayloadBlockHash &&
|
|
477
|
+
protoBlock.executionPayloadBlockHash !== parentBlockHash
|
|
478
|
+
) {
|
|
479
|
+
this.searchUnknownEnvelope(
|
|
480
|
+
{slot, root: parentBlockRoot},
|
|
481
|
+
BlockInputSource.network_processor,
|
|
482
|
+
message.propagationSource.toString()
|
|
483
|
+
);
|
|
484
|
+
preprocessResult = {action: PreprocessAction.AwaitEnvelope, root: parentBlockRoot};
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
302
490
|
}
|
|
303
491
|
|
|
304
|
-
|
|
305
|
-
|
|
492
|
+
switch (preprocessResult.action) {
|
|
493
|
+
case PreprocessAction.PushToQueue:
|
|
494
|
+
this.pushPendingGossipsubMessageToQueue(message);
|
|
495
|
+
break;
|
|
496
|
+
case PreprocessAction.AwaitBlock: {
|
|
497
|
+
if (this.unknownBlockGossipsubMessagesCount > MAX_QUEUED_UNKNOWN_BLOCK_GOSSIP_OBJECTS) {
|
|
498
|
+
// No need to report the dropped job to gossip. It will be eventually pruned from the mcache
|
|
499
|
+
this.metrics?.awaitingBlockGossipMessages.reject.inc({
|
|
500
|
+
reason: ReprocessRejectReason.reached_limit,
|
|
501
|
+
topic: topicType,
|
|
502
|
+
});
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
this.metrics?.awaitingBlockGossipMessages.queue.inc({topic: topicType});
|
|
507
|
+
const awaitingGossipsubMessages = this.awaitingMessagesByBlockRoot.getOrDefault(preprocessResult.root);
|
|
508
|
+
awaitingGossipsubMessages.add(message);
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
case PreprocessAction.AwaitEnvelope: {
|
|
512
|
+
if (this.unknownPayloadGossipsubMessagesCount > MAX_QUEUED_UNKNOWN_PAYLOAD_GOSSIP_OBJECTS) {
|
|
513
|
+
this.metrics?.awaitingPayloadGossipMessages.reject.inc({
|
|
514
|
+
reason: ReprocessRejectReason.reached_limit,
|
|
515
|
+
topic: topicType,
|
|
516
|
+
});
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
this.metrics?.awaitingPayloadGossipMessages.queue.inc({topic: topicType});
|
|
521
|
+
const awaitingPayloadGossipsubMessages = this.awaitingMessagesByPayloadBlockRoot.getOrDefault(
|
|
522
|
+
preprocessResult.root
|
|
523
|
+
);
|
|
524
|
+
awaitingPayloadGossipsubMessages.add(message);
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
};
|
|
306
529
|
|
|
307
530
|
private pushPendingGossipsubMessageToQueue(message: PendingGossipsubMessage): void {
|
|
308
531
|
const topicType = message.topic.type;
|
|
@@ -316,7 +539,7 @@ export class NetworkProcessor {
|
|
|
316
539
|
this.executeWork();
|
|
317
540
|
}
|
|
318
541
|
|
|
319
|
-
private async
|
|
542
|
+
private onBlockProcessed = async ({block: rootHex}: {block: string; executionOptimistic: boolean}): Promise<void> => {
|
|
320
543
|
const waitingGossipsubMessages = this.awaitingMessagesByBlockRoot.get(rootHex);
|
|
321
544
|
if (!waitingGossipsubMessages || waitingGossipsubMessages.size === 0) {
|
|
322
545
|
return;
|
|
@@ -343,9 +566,35 @@ export class NetworkProcessor {
|
|
|
343
566
|
}
|
|
344
567
|
|
|
345
568
|
this.awaitingMessagesByBlockRoot.delete(rootHex);
|
|
346
|
-
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
private onPayloadEnvelopeProcessed = async ({blockRoot: rootHex}: {blockRoot: RootHex}): Promise<void> => {
|
|
572
|
+
const waitingGossipsubMessages = this.awaitingMessagesByPayloadBlockRoot.get(rootHex);
|
|
573
|
+
if (!waitingGossipsubMessages || waitingGossipsubMessages.size === 0) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const nowSec = Date.now() / 1000;
|
|
578
|
+
let count = 0;
|
|
579
|
+
for (const message of waitingGossipsubMessages) {
|
|
580
|
+
const topicType = message.topic.type;
|
|
581
|
+
this.metrics?.awaitingPayloadGossipMessages.waitSecBeforeResolve.set(
|
|
582
|
+
{topic: topicType},
|
|
583
|
+
nowSec - message.seenTimestampSec
|
|
584
|
+
);
|
|
585
|
+
this.metrics?.awaitingPayloadGossipMessages.resolve.inc({topic: topicType});
|
|
586
|
+
this.pushPendingGossipsubMessageToQueue(message);
|
|
587
|
+
count++;
|
|
588
|
+
if (count === MAX_AWAITING_GOSSIP_OBJECTS_PER_TICK) {
|
|
589
|
+
count = 0;
|
|
590
|
+
await sleep(AWAITING_GOSSIP_OBJECTS_YIELD_EVERY_MS);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
347
593
|
|
|
348
|
-
|
|
594
|
+
this.awaitingMessagesByPayloadBlockRoot.delete(rootHex);
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
private onClockSlot = (clockSlot: Slot): void => {
|
|
349
598
|
const nowSec = Date.now() / 1000;
|
|
350
599
|
const minSlot = clockSlot - MAX_UNKNOWN_ROOTS_SLOT_CACHE_SIZE;
|
|
351
600
|
|
|
@@ -371,7 +620,30 @@ export class NetworkProcessor {
|
|
|
371
620
|
}
|
|
372
621
|
this.unknownBlocksBySlot.delete(slot);
|
|
373
622
|
}
|
|
374
|
-
|
|
623
|
+
|
|
624
|
+
for (const [slot, roots] of this.unknownEnvelopesBySlot) {
|
|
625
|
+
if (slot > minSlot) continue;
|
|
626
|
+
for (const rootHex of roots) {
|
|
627
|
+
const gossipMessages = this.awaitingMessagesByPayloadBlockRoot.get(rootHex);
|
|
628
|
+
if (gossipMessages !== undefined) {
|
|
629
|
+
for (const message of gossipMessages) {
|
|
630
|
+
const topicType = message.topic.type;
|
|
631
|
+
this.metrics?.awaitingPayloadGossipMessages.reject.inc({
|
|
632
|
+
topic: topicType,
|
|
633
|
+
reason: ReprocessRejectReason.expired,
|
|
634
|
+
});
|
|
635
|
+
this.metrics?.awaitingPayloadGossipMessages.waitSecBeforeReject.set(
|
|
636
|
+
{topic: topicType, reason: ReprocessRejectReason.expired},
|
|
637
|
+
nowSec - message.seenTimestampSec
|
|
638
|
+
);
|
|
639
|
+
// No need to report the dropped job to gossip. It will be eventually pruned from the mcache
|
|
640
|
+
}
|
|
641
|
+
this.awaitingMessagesByPayloadBlockRoot.delete(rootHex);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
this.unknownEnvelopesBySlot.delete(slot);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
375
647
|
|
|
376
648
|
private executeWork(): void {
|
|
377
649
|
// TODO: Maybe de-bounce by timing the last time executeWork was run
|
|
@@ -517,4 +789,12 @@ export class NetworkProcessor {
|
|
|
517
789
|
}
|
|
518
790
|
return count;
|
|
519
791
|
}
|
|
792
|
+
|
|
793
|
+
private get unknownPayloadGossipsubMessagesCount(): number {
|
|
794
|
+
let count = 0;
|
|
795
|
+
for (const messages of this.awaitingMessagesByPayloadBlockRoot.values()) {
|
|
796
|
+
count += messages.size;
|
|
797
|
+
}
|
|
798
|
+
return count;
|
|
799
|
+
}
|
|
520
800
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {Type} from "@chainsafe/ssz";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
-
import {ForkName, ForkPostAltair, isForkPostAltair} from "@lodestar/params";
|
|
3
|
+
import {ForkName, ForkPostAltair, ForkPostFulu, isForkPostAltair, isForkPostFulu} from "@lodestar/params";
|
|
4
4
|
import {Protocol, ProtocolHandler, ReqRespRequest} from "@lodestar/reqresp";
|
|
5
5
|
import {
|
|
6
|
+
DataColumnSidecar,
|
|
6
7
|
LightClientBootstrap,
|
|
7
8
|
LightClientFinalityUpdate,
|
|
8
9
|
LightClientOptimisticUpdate,
|
|
@@ -83,8 +84,8 @@ type ResponseBodyByMethod = {
|
|
|
83
84
|
[ReqRespMethod.BeaconBlocksByRoot]: SignedBeaconBlock;
|
|
84
85
|
[ReqRespMethod.BlobSidecarsByRange]: deneb.BlobSidecar;
|
|
85
86
|
[ReqRespMethod.BlobSidecarsByRoot]: deneb.BlobSidecar;
|
|
86
|
-
[ReqRespMethod.DataColumnSidecarsByRange]:
|
|
87
|
-
[ReqRespMethod.DataColumnSidecarsByRoot]:
|
|
87
|
+
[ReqRespMethod.DataColumnSidecarsByRange]: DataColumnSidecar;
|
|
88
|
+
[ReqRespMethod.DataColumnSidecarsByRoot]: DataColumnSidecar;
|
|
88
89
|
[ReqRespMethod.ExecutionPayloadEnvelopesByRoot]: gloas.SignedExecutionPayloadEnvelope;
|
|
89
90
|
[ReqRespMethod.ExecutionPayloadEnvelopesByRange]: gloas.SignedExecutionPayloadEnvelope;
|
|
90
91
|
|
|
@@ -146,8 +147,8 @@ export const responseSszTypeByMethod: {[K in ReqRespMethod]: ResponseTypeGetter<
|
|
|
146
147
|
[ReqRespMethod.LightClientBootstrap]: (fork) => sszTypesFor(onlyPostAltairFork(fork)).LightClientBootstrap,
|
|
147
148
|
[ReqRespMethod.LightClientUpdatesByRange]: (fork) => sszTypesFor(onlyPostAltairFork(fork)).LightClientUpdate,
|
|
148
149
|
[ReqRespMethod.LightClientFinalityUpdate]: (fork) => sszTypesFor(onlyPostAltairFork(fork)).LightClientFinalityUpdate,
|
|
149
|
-
[ReqRespMethod.DataColumnSidecarsByRange]: () =>
|
|
150
|
-
[ReqRespMethod.DataColumnSidecarsByRoot]: () =>
|
|
150
|
+
[ReqRespMethod.DataColumnSidecarsByRange]: (fork) => sszTypesFor(onlyPostFuluFork(fork)).DataColumnSidecar,
|
|
151
|
+
[ReqRespMethod.DataColumnSidecarsByRoot]: (fork) => sszTypesFor(onlyPostFuluFork(fork)).DataColumnSidecar,
|
|
151
152
|
[ReqRespMethod.ExecutionPayloadEnvelopesByRoot]: () => ssz.gloas.SignedExecutionPayloadEnvelope,
|
|
152
153
|
[ReqRespMethod.ExecutionPayloadEnvelopesByRange]: () => ssz.gloas.SignedExecutionPayloadEnvelope,
|
|
153
154
|
[ReqRespMethod.LightClientOptimisticUpdate]: (fork) =>
|
|
@@ -161,6 +162,13 @@ function onlyPostAltairFork(fork: ForkName): ForkPostAltair {
|
|
|
161
162
|
throw Error(`Not a post-altair fork ${fork}`);
|
|
162
163
|
}
|
|
163
164
|
|
|
165
|
+
function onlyPostFuluFork(fork: ForkName): ForkPostFulu {
|
|
166
|
+
if (isForkPostFulu(fork)) {
|
|
167
|
+
return fork;
|
|
168
|
+
}
|
|
169
|
+
throw Error(`Not a post-fulu fork ${fork}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
164
172
|
export type RequestTypedContainer = {
|
|
165
173
|
[K in ReqRespMethod]: {method: K; body: RequestBodyByMethod[K]};
|
|
166
174
|
}[ReqRespMethod];
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -115,7 +115,7 @@ export class BlockInputSync {
|
|
|
115
115
|
this.logger.verbose("BlockInputSync enabled.");
|
|
116
116
|
this.chain.emitter.on(ChainEvent.unknownBlockRoot, this.onUnknownBlockRoot);
|
|
117
117
|
this.chain.emitter.on(ChainEvent.incompleteBlockInput, this.onIncompleteBlockInput);
|
|
118
|
-
this.chain.emitter.on(ChainEvent.
|
|
118
|
+
this.chain.emitter.on(ChainEvent.blockUnknownParent, this.onUnknownParent);
|
|
119
119
|
this.network.events.on(NetworkEvent.peerConnected, this.onPeerConnected);
|
|
120
120
|
this.network.events.on(NetworkEvent.peerDisconnected, this.onPeerDisconnected);
|
|
121
121
|
this.subscribedToNetworkEvents = true;
|
|
@@ -126,7 +126,7 @@ export class BlockInputSync {
|
|
|
126
126
|
this.logger.verbose("BlockInputSync disabled.");
|
|
127
127
|
this.chain.emitter.off(ChainEvent.unknownBlockRoot, this.onUnknownBlockRoot);
|
|
128
128
|
this.chain.emitter.off(ChainEvent.incompleteBlockInput, this.onIncompleteBlockInput);
|
|
129
|
-
this.chain.emitter.off(ChainEvent.
|
|
129
|
+
this.chain.emitter.off(ChainEvent.blockUnknownParent, this.onUnknownParent);
|
|
130
130
|
this.network.events.off(NetworkEvent.peerConnected, this.onPeerConnected);
|
|
131
131
|
this.network.events.off(NetworkEvent.peerDisconnected, this.onPeerDisconnected);
|
|
132
132
|
this.subscribedToNetworkEvents = false;
|
|
@@ -171,7 +171,7 @@ export class BlockInputSync {
|
|
|
171
171
|
/**
|
|
172
172
|
* Process an unknownBlockParent event and register the block in `pendingBlocks` Map.
|
|
173
173
|
*/
|
|
174
|
-
private onUnknownParent = (data: ChainEventData[ChainEvent.
|
|
174
|
+
private onUnknownParent = (data: ChainEventData[ChainEvent.blockUnknownParent]): void => {
|
|
175
175
|
try {
|
|
176
176
|
this.addByRootHex(data.blockInput.parentRootHex, data.peer);
|
|
177
177
|
this.addByBlockInput(data.blockInput, data.peer);
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../../chain/blocks/blockInput/index.js";
|
|
12
12
|
import {SeenBlockInput} from "../../chain/seenCache/seenGossipBlockInput.js";
|
|
13
13
|
import {validateBlockBlobSidecars} from "../../chain/validation/blobSidecar.js";
|
|
14
|
-
import {
|
|
14
|
+
import {validateFuluBlockDataColumnSidecars} from "../../chain/validation/dataColumnSidecar.js";
|
|
15
15
|
import {BeaconMetrics} from "../../metrics/metrics/beacon.js";
|
|
16
16
|
import {INetwork} from "../../network/index.js";
|
|
17
17
|
import {getBlobKzgCommitments} from "../../util/dataColumns.js";
|
|
@@ -27,7 +27,7 @@ export type DownloadByRangeRequests = {
|
|
|
27
27
|
export type DownloadByRangeResponses = {
|
|
28
28
|
blocks?: SignedBeaconBlock[];
|
|
29
29
|
blobSidecars?: deneb.BlobSidecars;
|
|
30
|
-
columnSidecars?: fulu.
|
|
30
|
+
columnSidecars?: fulu.DataColumnSidecar[];
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export type DownloadAndCacheByRangeProps = DownloadByRangeRequests & {
|
|
@@ -58,7 +58,7 @@ export type ValidatedBlobSidecars = {
|
|
|
58
58
|
|
|
59
59
|
export type ValidatedColumnSidecars = {
|
|
60
60
|
blockRoot: Uint8Array;
|
|
61
|
-
columnSidecars: fulu.
|
|
61
|
+
columnSidecars: fulu.DataColumnSidecar[];
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export type ValidatedResponses = {
|
|
@@ -245,7 +245,7 @@ export async function requestByRange({
|
|
|
245
245
|
}): Promise<DownloadByRangeResponses> {
|
|
246
246
|
let blocks: undefined | SignedBeaconBlock[];
|
|
247
247
|
let blobSidecars: undefined | deneb.BlobSidecars;
|
|
248
|
-
let columnSidecars: undefined | fulu.
|
|
248
|
+
let columnSidecars: undefined | fulu.DataColumnSidecar[];
|
|
249
249
|
|
|
250
250
|
const requests: Promise<unknown>[] = [];
|
|
251
251
|
|
|
@@ -268,7 +268,7 @@ export async function requestByRange({
|
|
|
268
268
|
if (columnsRequest) {
|
|
269
269
|
requests.push(
|
|
270
270
|
network.sendDataColumnSidecarsByRange(peerIdStr, columnsRequest).then((columnResponse) => {
|
|
271
|
-
columnSidecars = columnResponse;
|
|
271
|
+
columnSidecars = columnResponse as fulu.DataColumnSidecar[];
|
|
272
272
|
})
|
|
273
273
|
);
|
|
274
274
|
}
|
|
@@ -615,11 +615,13 @@ export async function validateColumnsByRangeResponse(
|
|
|
615
615
|
config: ChainForkConfig,
|
|
616
616
|
request: fulu.DataColumnSidecarsByRangeRequest,
|
|
617
617
|
blocks: ValidatedBlock[],
|
|
618
|
-
columnSidecars: fulu.
|
|
618
|
+
columnSidecars: fulu.DataColumnSidecar[],
|
|
619
619
|
peerDasMetrics?: BeaconMetrics["peerDas"] | null
|
|
620
620
|
): Promise<WarnResult<ValidatedColumnSidecars[], DownloadByRangeError>> {
|
|
621
621
|
const warnings: DownloadByRangeError[] = [];
|
|
622
622
|
|
|
623
|
+
// TODO GLOAS: Extend by range column sync to support gloas.DataColumnSidecar and
|
|
624
|
+
// validate against the block bid commitments instead of the fulu signed header shape
|
|
623
625
|
const seenColumns = new Map<Slot, Map<number, fulu.DataColumnSidecar>>();
|
|
624
626
|
let currentSlot = -1;
|
|
625
627
|
let currentIndex = -1;
|
|
@@ -767,7 +769,7 @@ export async function validateColumnsByRangeResponse(
|
|
|
767
769
|
}
|
|
768
770
|
|
|
769
771
|
validationPromises.push(
|
|
770
|
-
|
|
772
|
+
validateFuluBlockDataColumnSidecars(
|
|
771
773
|
null, // do not pass chain here so we do not validate header signature
|
|
772
774
|
slot,
|
|
773
775
|
blockRoot,
|
|
@@ -8,7 +8,7 @@ import {BlockInputSource, IBlockInput} from "../../chain/blocks/blockInput/types
|
|
|
8
8
|
import {ChainEventEmitter} from "../../chain/emitter.js";
|
|
9
9
|
import {IBeaconChain} from "../../chain/interface.js";
|
|
10
10
|
import {validateBlockBlobSidecars} from "../../chain/validation/blobSidecar.js";
|
|
11
|
-
import {
|
|
11
|
+
import {validateFuluBlockDataColumnSidecars} from "../../chain/validation/dataColumnSidecar.js";
|
|
12
12
|
import {INetwork} from "../../network/interface.js";
|
|
13
13
|
import {PeerSyncMeta} from "../../network/peers/peersData.js";
|
|
14
14
|
import {prettyPrintPeerIdStr} from "../../network/util.js";
|
|
@@ -52,7 +52,7 @@ export type FetchByRootAndValidateColumnsProps = FetchByRootCoreProps & {
|
|
|
52
52
|
export type FetchByRootResponses = {
|
|
53
53
|
block: SignedBeaconBlock;
|
|
54
54
|
blobSidecars?: deneb.BlobSidecars;
|
|
55
|
-
columnSidecars?: fulu.
|
|
55
|
+
columnSidecars?: fulu.DataColumnSidecar[];
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
export type DownloadByRootProps = FetchByRootCoreProps & {
|
|
@@ -213,7 +213,7 @@ export async function fetchByRoot({
|
|
|
213
213
|
}: FetchByRootProps): Promise<WarnResult<FetchByRootResponses, DownloadByRootError>> {
|
|
214
214
|
let block: SignedBeaconBlock;
|
|
215
215
|
let blobSidecars: deneb.BlobSidecars | undefined;
|
|
216
|
-
let columnSidecarResult: WarnResult<fulu.
|
|
216
|
+
let columnSidecarResult: WarnResult<fulu.DataColumnSidecar[], DownloadByRootError> | undefined;
|
|
217
217
|
const {peerId: peerIdStr} = peerMeta;
|
|
218
218
|
|
|
219
219
|
if (isPendingBlockInput(cacheItem)) {
|
|
@@ -376,7 +376,7 @@ export async function fetchAndValidateColumns({
|
|
|
376
376
|
block,
|
|
377
377
|
blockRoot,
|
|
378
378
|
missing,
|
|
379
|
-
}: FetchByRootAndValidateColumnsProps): Promise<WarnResult<fulu.
|
|
379
|
+
}: FetchByRootAndValidateColumnsProps): Promise<WarnResult<fulu.DataColumnSidecar[], DownloadByRootError>> {
|
|
380
380
|
const {peerId: peerIdStr} = peerMeta;
|
|
381
381
|
const slot = block.message.slot;
|
|
382
382
|
const blobCount = getBlobKzgCommitments(forkName, block).length;
|
|
@@ -387,9 +387,11 @@ export async function fetchAndValidateColumns({
|
|
|
387
387
|
const blockRootHex = toRootHex(blockRoot);
|
|
388
388
|
const peerColumns = new Set(peerMeta.custodyColumns ?? []);
|
|
389
389
|
const requestedColumns = missing.filter((c) => peerColumns.has(c));
|
|
390
|
-
|
|
390
|
+
// TODO GLOAS: Extend by root column sync to support gloas.DataColumnSidecar and
|
|
391
|
+
// validate against block bid commitments instead of the fulu signed header shape
|
|
392
|
+
const columnSidecars = (await network.sendDataColumnSidecarsByRoot(peerIdStr, [
|
|
391
393
|
{blockRoot, columns: requestedColumns},
|
|
392
|
-
]);
|
|
394
|
+
])) as fulu.DataColumnSidecar[];
|
|
393
395
|
|
|
394
396
|
const warnings: DownloadByRootError[] = [];
|
|
395
397
|
|
|
@@ -440,7 +442,8 @@ export async function fetchAndValidateColumns({
|
|
|
440
442
|
);
|
|
441
443
|
}
|
|
442
444
|
|
|
443
|
-
|
|
445
|
+
// TODO GLOAS: Swap to fork-aware column validation once post-gloas by-root sync is implemented
|
|
446
|
+
await validateFuluBlockDataColumnSidecars(chain, slot, blockRoot, blobCount, columnSidecars, chain?.metrics?.peerDas);
|
|
444
447
|
|
|
445
448
|
return {result: columnSidecars, warnings: warnings.length > 0 ? warnings : null};
|
|
446
449
|
}
|
|
@@ -451,11 +454,12 @@ export async function fetchColumnsByRoot({
|
|
|
451
454
|
peerMeta,
|
|
452
455
|
blockRoot,
|
|
453
456
|
missing,
|
|
454
|
-
}: Pick<
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
}: Pick<FetchByRootAndValidateColumnsProps, "network" | "peerMeta" | "blockRoot" | "missing">): Promise<
|
|
458
|
+
fulu.DataColumnSidecar[]
|
|
459
|
+
> {
|
|
460
|
+
return (await network.sendDataColumnSidecarsByRoot(peerMeta.peerId, [
|
|
461
|
+
{blockRoot, columns: missing},
|
|
462
|
+
])) as fulu.DataColumnSidecar[];
|
|
459
463
|
}
|
|
460
464
|
|
|
461
465
|
export enum DownloadByRootErrorCode {
|