@lodestar/beacon-node 1.36.0-rc.2 → 1.36.0-rc.4
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/chain/errors/blobSidecarError.d.ts +5 -0
- package/lib/chain/errors/blobSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/blobSidecarError.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +1 -0
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +4 -0
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/validation/blobSidecar.d.ts +4 -1
- package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
- package/lib/chain/validation/blobSidecar.js +46 -11
- package/lib/chain/validation/blobSidecar.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +1 -0
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +4 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +33 -5
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +6 -1
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +2 -0
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +14 -0
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +8 -6
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/types.d.ts +2 -0
- package/lib/network/processor/types.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +1 -1
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +1 -2
- 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 +8 -14
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +18 -33
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/package.json +14 -14
- package/src/chain/errors/blobSidecarError.ts +12 -2
- package/src/chain/errors/blockError.ts +1 -1
- package/src/chain/errors/dataColumnSidecarError.ts +11 -2
- package/src/chain/validation/blobSidecar.ts +54 -10
- package/src/chain/validation/block.ts +1 -0
- package/src/chain/validation/dataColumnSidecar.ts +43 -4
- package/src/network/gossip/gossipsub.ts +7 -1
- package/src/network/gossip/interface.ts +2 -0
- package/src/network/processor/gossipHandlers.ts +15 -0
- package/src/network/processor/gossipValidatorFn.ts +33 -6
- package/src/network/processor/types.ts +2 -0
- package/src/sync/unknownBlock.ts +1 -1
- package/src/sync/utils/downloadByRange.ts +15 -6
- package/src/sync/utils/downloadByRoot.ts +22 -56
|
@@ -296,6 +296,10 @@ export class Eth2Gossipsub extends GossipSub {
|
|
|
296
296
|
// Get seenTimestamp before adding the message to the queue or add async delays
|
|
297
297
|
const seenTimestampSec = Date.now() / 1000;
|
|
298
298
|
|
|
299
|
+
const peerIdStr = propagationSource.toString();
|
|
300
|
+
const clientAgent = this.peersData.getPeerKind(peerIdStr) ?? "Unknown";
|
|
301
|
+
const clientVersion = this.peersData.getAgentVersion(peerIdStr);
|
|
302
|
+
|
|
299
303
|
// Use setTimeout to yield to the macro queue
|
|
300
304
|
// Without this we'll have huge event loop lag
|
|
301
305
|
// See https://github.com/ChainSafe/lodestar/issues/5604
|
|
@@ -305,7 +309,9 @@ export class Eth2Gossipsub extends GossipSub {
|
|
|
305
309
|
msg,
|
|
306
310
|
msgId,
|
|
307
311
|
// Hot path, use cached .toString() version
|
|
308
|
-
propagationSource:
|
|
312
|
+
propagationSource: peerIdStr,
|
|
313
|
+
clientVersion,
|
|
314
|
+
clientAgent,
|
|
309
315
|
seenTimestampSec,
|
|
310
316
|
startProcessUnixSec: null,
|
|
311
317
|
});
|
|
@@ -296,6 +296,21 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
296
296
|
const slot = dataColumnBlockHeader.slot;
|
|
297
297
|
const blockRootHex = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(dataColumnBlockHeader));
|
|
298
298
|
|
|
299
|
+
// check to see if block has already been processed and BlockInput has been deleted (column received via reqresp or other means)
|
|
300
|
+
if (chain.forkChoice.hasBlockHex(blockRootHex)) {
|
|
301
|
+
metrics?.peerDas.dataColumnSidecarProcessingSkip.inc();
|
|
302
|
+
logger.debug("Already processed block for column sidecar, skipping processing", {
|
|
303
|
+
slot,
|
|
304
|
+
blockRoot: blockRootHex,
|
|
305
|
+
index: dataColumnSidecar.index,
|
|
306
|
+
});
|
|
307
|
+
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
308
|
+
code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
|
|
309
|
+
columnIndex: dataColumnSidecar.index,
|
|
310
|
+
slot,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
299
314
|
// first check if we should even process this column (we may have already processed it via getBlobsV2)
|
|
300
315
|
{
|
|
301
316
|
const blockInput = chain.seenBlockInputCache.get(blockRootHex);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
GossipValidatorBatchFn,
|
|
12
12
|
GossipValidatorFn,
|
|
13
13
|
} from "../gossip/interface.js";
|
|
14
|
+
import {prettyPrintPeerIdStr} from "../util.ts";
|
|
14
15
|
|
|
15
16
|
export type ValidatorFnModules = {
|
|
16
17
|
config: ChainForkConfig;
|
|
@@ -45,13 +46,19 @@ export function getGossipValidatorBatchFn(
|
|
|
45
46
|
}))
|
|
46
47
|
);
|
|
47
48
|
|
|
48
|
-
return results.map((e) => {
|
|
49
|
+
return results.map((e, i) => {
|
|
49
50
|
if (e == null) {
|
|
50
51
|
return TopicValidatorResult.Accept;
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
const {clientAgent, clientVersion, propagationSource} = messageInfos[i];
|
|
55
|
+
|
|
53
56
|
if (!(e instanceof AttestationError)) {
|
|
54
|
-
logger.debug(
|
|
57
|
+
logger.debug(
|
|
58
|
+
`Gossip batch validation ${type} threw a non-AttestationError`,
|
|
59
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
60
|
+
e as Error
|
|
61
|
+
);
|
|
55
62
|
metrics?.networkProcessor.gossipValidationIgnore.inc({topic: type});
|
|
56
63
|
return TopicValidatorResult.Ignore;
|
|
57
64
|
}
|
|
@@ -66,7 +73,11 @@ export function getGossipValidatorBatchFn(
|
|
|
66
73
|
metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
|
|
67
74
|
// only beacon_attestation topic is validated in batch
|
|
68
75
|
metrics?.networkProcessor.gossipAttestationRejectByReason.inc({reason: e.type.code});
|
|
69
|
-
logger.debug(
|
|
76
|
+
logger.debug(
|
|
77
|
+
`Gossip validation ${type} rejected`,
|
|
78
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
79
|
+
e
|
|
80
|
+
);
|
|
70
81
|
return TopicValidatorResult.Reject;
|
|
71
82
|
}
|
|
72
83
|
});
|
|
@@ -99,7 +110,15 @@ export function getGossipValidatorBatchFn(
|
|
|
99
110
|
export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: ValidatorFnModules): GossipValidatorFn {
|
|
100
111
|
const {logger, metrics} = modules;
|
|
101
112
|
|
|
102
|
-
return async function gossipValidatorFn({
|
|
113
|
+
return async function gossipValidatorFn({
|
|
114
|
+
topic,
|
|
115
|
+
msg,
|
|
116
|
+
propagationSource,
|
|
117
|
+
clientAgent,
|
|
118
|
+
clientVersion,
|
|
119
|
+
seenTimestampSec,
|
|
120
|
+
msgSlot,
|
|
121
|
+
}) {
|
|
103
122
|
const type = topic.type;
|
|
104
123
|
|
|
105
124
|
try {
|
|
@@ -116,7 +135,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
|
|
|
116
135
|
} catch (e) {
|
|
117
136
|
if (!(e instanceof GossipActionError)) {
|
|
118
137
|
// not deserve to log error here, it looks too dangerous to users
|
|
119
|
-
logger.debug(
|
|
138
|
+
logger.debug(
|
|
139
|
+
`Gossip validation ${type} threw a non-GossipActionError`,
|
|
140
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
141
|
+
e as Error
|
|
142
|
+
);
|
|
120
143
|
return TopicValidatorResult.Ignore;
|
|
121
144
|
}
|
|
122
145
|
|
|
@@ -134,7 +157,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
|
|
|
134
157
|
|
|
135
158
|
case GossipAction.REJECT:
|
|
136
159
|
metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
|
|
137
|
-
logger.debug(
|
|
160
|
+
logger.debug(
|
|
161
|
+
`Gossip validation ${type} rejected`,
|
|
162
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
163
|
+
e
|
|
164
|
+
);
|
|
138
165
|
return TopicValidatorResult.Reject;
|
|
139
166
|
}
|
|
140
167
|
}
|
|
@@ -15,6 +15,8 @@ export type PendingGossipsubMessage = {
|
|
|
15
15
|
msgSlot?: Slot;
|
|
16
16
|
msgId: string;
|
|
17
17
|
propagationSource: PeerIdStr;
|
|
18
|
+
clientAgent: string;
|
|
19
|
+
clientVersion: string;
|
|
18
20
|
seenTimestampSec: number;
|
|
19
21
|
startProcessUnixSec: number | null;
|
|
20
22
|
// specific properties for IndexedGossipQueueMinSize, for beacon_attestation topic only
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -532,7 +532,7 @@ export class BlockInputSync {
|
|
|
532
532
|
const downloadResult = await downloadByRoot({
|
|
533
533
|
config: this.config,
|
|
534
534
|
network: this.network,
|
|
535
|
-
|
|
535
|
+
chain: this.chain,
|
|
536
536
|
emitter: this.chain.emitter,
|
|
537
537
|
peerMeta,
|
|
538
538
|
cacheItem,
|
|
@@ -37,7 +37,6 @@ export type DownloadByRangeResponses = {
|
|
|
37
37
|
|
|
38
38
|
export type DownloadAndCacheByRangeProps = DownloadByRangeRequests & {
|
|
39
39
|
config: ChainForkConfig;
|
|
40
|
-
cache: SeenBlockInput;
|
|
41
40
|
network: INetwork;
|
|
42
41
|
logger: Logger;
|
|
43
42
|
peerIdStr: string;
|
|
@@ -203,7 +202,7 @@ export async function downloadByRange({
|
|
|
203
202
|
blocksRequest,
|
|
204
203
|
blobsRequest,
|
|
205
204
|
columnsRequest,
|
|
206
|
-
}:
|
|
205
|
+
}: DownloadAndCacheByRangeProps): Promise<WarnResult<ValidatedResponses, DownloadByRangeError>> {
|
|
207
206
|
let response: DownloadByRangeResponses;
|
|
208
207
|
try {
|
|
209
208
|
response = await requestByRange({
|
|
@@ -555,9 +554,13 @@ export async function validateBlobsByRangeResponse(
|
|
|
555
554
|
}
|
|
556
555
|
|
|
557
556
|
validateSidecarsPromises.push(
|
|
558
|
-
validateBlockBlobSidecars(
|
|
559
|
-
|
|
560
|
-
|
|
557
|
+
validateBlockBlobSidecars(
|
|
558
|
+
null, // do not pass chain here so we do not validate header signature
|
|
559
|
+
block.message.slot,
|
|
560
|
+
blockRoot,
|
|
561
|
+
blockKzgCommitments.length,
|
|
562
|
+
blockBlobSidecars
|
|
563
|
+
).then(() => ({blockRoot, blobSidecars: blockBlobSidecars}))
|
|
561
564
|
);
|
|
562
565
|
}
|
|
563
566
|
|
|
@@ -768,7 +771,13 @@ export async function validateColumnsByRangeResponse(
|
|
|
768
771
|
}
|
|
769
772
|
|
|
770
773
|
validationPromises.push(
|
|
771
|
-
validateBlockDataColumnSidecars(
|
|
774
|
+
validateBlockDataColumnSidecars(
|
|
775
|
+
null, // do not pass chain here so we do not validate header signature
|
|
776
|
+
slot,
|
|
777
|
+
blockRoot,
|
|
778
|
+
blobCount,
|
|
779
|
+
columnSidecars
|
|
780
|
+
).then(() => ({
|
|
772
781
|
blockRoot,
|
|
773
782
|
columnSidecars,
|
|
774
783
|
}))
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
isForkPostFulu,
|
|
10
10
|
} from "@lodestar/params";
|
|
11
11
|
import {BeaconBlockBody, BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
|
12
|
-
import {LodestarError, fromHex,
|
|
12
|
+
import {LodestarError, fromHex, prettyPrintIndices, toHex, toRootHex} from "@lodestar/utils";
|
|
13
13
|
import {isBlockInputBlobs, isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
|
|
14
14
|
import {BlockInputSource, IBlockInput} from "../../chain/blocks/blockInput/types.js";
|
|
15
15
|
import {ChainEventEmitter} from "../../chain/emitter.js";
|
|
16
|
-
import {
|
|
16
|
+
import {IBeaconChain} from "../../chain/interface.ts";
|
|
17
17
|
import {validateBlockBlobSidecars} from "../../chain/validation/blobSidecar.js";
|
|
18
18
|
import {validateBlockDataColumnSidecars} from "../../chain/validation/dataColumnSidecar.js";
|
|
19
19
|
import {INetwork} from "../../network/interface.js";
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
|
|
33
33
|
export type FetchByRootCoreProps = {
|
|
34
34
|
config: ChainForkConfig;
|
|
35
|
+
chain: IBeaconChain | null; // null for testing purposes
|
|
35
36
|
network: INetwork;
|
|
36
37
|
peerMeta: PeerSyncMeta;
|
|
37
38
|
};
|
|
@@ -63,13 +64,13 @@ export type FetchByRootResponses = {
|
|
|
63
64
|
|
|
64
65
|
export type DownloadByRootProps = FetchByRootCoreProps & {
|
|
65
66
|
cacheItem: BlockInputSyncCacheItem;
|
|
66
|
-
|
|
67
|
+
chain: IBeaconChain;
|
|
67
68
|
emitter: ChainEventEmitter;
|
|
68
69
|
};
|
|
69
70
|
|
|
70
71
|
export async function downloadByRoot({
|
|
71
72
|
config,
|
|
72
|
-
|
|
73
|
+
chain,
|
|
73
74
|
network,
|
|
74
75
|
emitter,
|
|
75
76
|
peerMeta,
|
|
@@ -84,6 +85,7 @@ export async function downloadByRoot({
|
|
|
84
85
|
warnings,
|
|
85
86
|
} = await fetchByRoot({
|
|
86
87
|
config,
|
|
88
|
+
chain,
|
|
87
89
|
network,
|
|
88
90
|
cacheItem,
|
|
89
91
|
blockRoot,
|
|
@@ -103,7 +105,7 @@ export async function downloadByRoot({
|
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
} else {
|
|
106
|
-
blockInput =
|
|
108
|
+
blockInput = chain.seenBlockInputCache.getByBlock({
|
|
107
109
|
block,
|
|
108
110
|
peerIdStr,
|
|
109
111
|
blockRootHex: rootHex,
|
|
@@ -119,7 +121,7 @@ export async function downloadByRoot({
|
|
|
119
121
|
if (!blobSidecars) {
|
|
120
122
|
throw new DownloadByRootError({
|
|
121
123
|
code: DownloadByRootErrorCode.MISSING_BLOB_RESPONSE,
|
|
122
|
-
blockRoot:
|
|
124
|
+
blockRoot: rootHex,
|
|
123
125
|
peer: peerIdStr,
|
|
124
126
|
});
|
|
125
127
|
}
|
|
@@ -157,7 +159,7 @@ export async function downloadByRoot({
|
|
|
157
159
|
if (!columnSidecars) {
|
|
158
160
|
throw new DownloadByRootError({
|
|
159
161
|
code: DownloadByRootErrorCode.MISSING_COLUMN_RESPONSE,
|
|
160
|
-
blockRoot:
|
|
162
|
+
blockRoot: rootHex,
|
|
161
163
|
peer: peerIdStr,
|
|
162
164
|
});
|
|
163
165
|
}
|
|
@@ -210,6 +212,7 @@ export async function downloadByRoot({
|
|
|
210
212
|
|
|
211
213
|
export async function fetchByRoot({
|
|
212
214
|
config,
|
|
215
|
+
chain,
|
|
213
216
|
network,
|
|
214
217
|
peerMeta,
|
|
215
218
|
blockRoot,
|
|
@@ -237,6 +240,7 @@ export async function fetchByRoot({
|
|
|
237
240
|
if (isBlockInputBlobs(cacheItem.blockInput)) {
|
|
238
241
|
blobSidecars = await fetchAndValidateBlobs({
|
|
239
242
|
config,
|
|
243
|
+
chain,
|
|
240
244
|
network,
|
|
241
245
|
peerIdStr,
|
|
242
246
|
forkName: forkName as ForkPreFulu,
|
|
@@ -248,6 +252,7 @@ export async function fetchByRoot({
|
|
|
248
252
|
if (isBlockInputColumns(cacheItem.blockInput)) {
|
|
249
253
|
columnSidecarResult = await fetchAndValidateColumns({
|
|
250
254
|
config,
|
|
255
|
+
chain,
|
|
251
256
|
network,
|
|
252
257
|
peerMeta,
|
|
253
258
|
forkName: forkName as ForkPostFulu,
|
|
@@ -268,6 +273,7 @@ export async function fetchByRoot({
|
|
|
268
273
|
if (isForkPostFulu(forkName)) {
|
|
269
274
|
columnSidecarResult = await fetchAndValidateColumns({
|
|
270
275
|
config,
|
|
276
|
+
chain,
|
|
271
277
|
network,
|
|
272
278
|
peerMeta,
|
|
273
279
|
forkName,
|
|
@@ -280,6 +286,7 @@ export async function fetchByRoot({
|
|
|
280
286
|
const blobCount = commitments.length;
|
|
281
287
|
blobSidecars = await fetchAndValidateBlobs({
|
|
282
288
|
config,
|
|
289
|
+
chain,
|
|
283
290
|
network,
|
|
284
291
|
peerIdStr,
|
|
285
292
|
forkName: forkName as ForkPreFulu,
|
|
@@ -305,14 +312,14 @@ export async function fetchAndValidateBlock({
|
|
|
305
312
|
network,
|
|
306
313
|
peerIdStr,
|
|
307
314
|
blockRoot,
|
|
308
|
-
}: FetchByRootAndValidateBlockProps): Promise<SignedBeaconBlock> {
|
|
315
|
+
}: Omit<FetchByRootAndValidateBlockProps, "chain">): Promise<SignedBeaconBlock> {
|
|
309
316
|
const response = await network.sendBeaconBlocksByRoot(peerIdStr, [blockRoot]);
|
|
310
317
|
const block = response.at(0)?.data;
|
|
311
318
|
if (!block) {
|
|
312
319
|
throw new DownloadByRootError({
|
|
313
320
|
code: DownloadByRootErrorCode.MISSING_BLOCK_RESPONSE,
|
|
314
321
|
peer: prettyPrintPeerIdStr(peerIdStr),
|
|
315
|
-
blockRoot:
|
|
322
|
+
blockRoot: toRootHex(blockRoot),
|
|
316
323
|
});
|
|
317
324
|
}
|
|
318
325
|
const receivedRoot = config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message);
|
|
@@ -321,8 +328,8 @@ export async function fetchAndValidateBlock({
|
|
|
321
328
|
{
|
|
322
329
|
code: DownloadByRootErrorCode.MISMATCH_BLOCK_ROOT,
|
|
323
330
|
peer: prettyPrintPeerIdStr(peerIdStr),
|
|
324
|
-
requestedBlockRoot:
|
|
325
|
-
receivedBlockRoot:
|
|
331
|
+
requestedBlockRoot: toRootHex(blockRoot),
|
|
332
|
+
receivedBlockRoot: toRootHex(receivedRoot),
|
|
326
333
|
},
|
|
327
334
|
"block does not match requested root"
|
|
328
335
|
);
|
|
@@ -331,6 +338,7 @@ export async function fetchAndValidateBlock({
|
|
|
331
338
|
}
|
|
332
339
|
|
|
333
340
|
export async function fetchAndValidateBlobs({
|
|
341
|
+
chain,
|
|
334
342
|
network,
|
|
335
343
|
peerIdStr,
|
|
336
344
|
blockRoot,
|
|
@@ -344,7 +352,7 @@ export async function fetchAndValidateBlobs({
|
|
|
344
352
|
missing,
|
|
345
353
|
});
|
|
346
354
|
|
|
347
|
-
await validateBlockBlobSidecars(block.message.slot, blockRoot, missing.length, blobSidecars);
|
|
355
|
+
await validateBlockBlobSidecars(chain, block.message.slot, blockRoot, missing.length, blobSidecars);
|
|
348
356
|
|
|
349
357
|
return blobSidecars;
|
|
350
358
|
}
|
|
@@ -368,6 +376,7 @@ export async function fetchBlobsByRoot({
|
|
|
368
376
|
}
|
|
369
377
|
|
|
370
378
|
export async function fetchAndValidateColumns({
|
|
379
|
+
chain,
|
|
371
380
|
network,
|
|
372
381
|
peerMeta,
|
|
373
382
|
block,
|
|
@@ -438,7 +447,7 @@ export async function fetchAndValidateColumns({
|
|
|
438
447
|
);
|
|
439
448
|
}
|
|
440
449
|
|
|
441
|
-
await validateBlockDataColumnSidecars(slot, blockRoot, blobCount, columnSidecars);
|
|
450
|
+
await validateBlockDataColumnSidecars(chain, slot, blockRoot, blobCount, columnSidecars);
|
|
442
451
|
|
|
443
452
|
return {result: columnSidecars, warnings: warnings.length > 0 ? warnings : null};
|
|
444
453
|
}
|
|
@@ -456,49 +465,6 @@ export async function fetchColumnsByRoot({
|
|
|
456
465
|
return await network.sendDataColumnSidecarsByRoot(peerMeta.peerId, [{blockRoot, columns: missing}]);
|
|
457
466
|
}
|
|
458
467
|
|
|
459
|
-
// TODO(fulu) not in use, remove?
|
|
460
|
-
export type ValidateColumnSidecarsProps = Pick<
|
|
461
|
-
FetchByRootAndValidateColumnsProps,
|
|
462
|
-
"config" | "peerMeta" | "blockRoot" | "missing"
|
|
463
|
-
> & {
|
|
464
|
-
slot: number;
|
|
465
|
-
blobCount: number;
|
|
466
|
-
needed?: fulu.DataColumnSidecars;
|
|
467
|
-
needToPublish?: fulu.DataColumnSidecars;
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
// TODO(fulu) not in use, remove?
|
|
471
|
-
export async function validateColumnSidecars({
|
|
472
|
-
peerMeta,
|
|
473
|
-
slot,
|
|
474
|
-
blockRoot,
|
|
475
|
-
blobCount,
|
|
476
|
-
missing,
|
|
477
|
-
needed = [],
|
|
478
|
-
needToPublish = [],
|
|
479
|
-
}: ValidateColumnSidecarsProps): Promise<void> {
|
|
480
|
-
const requestedIndices = missing;
|
|
481
|
-
const extraIndices: number[] = [];
|
|
482
|
-
for (const columnSidecar of needed) {
|
|
483
|
-
if (!requestedIndices.includes(columnSidecar.index)) {
|
|
484
|
-
extraIndices.push(columnSidecar.index);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (extraIndices.length > 0) {
|
|
488
|
-
throw new DownloadByRootError(
|
|
489
|
-
{
|
|
490
|
-
code: DownloadByRootErrorCode.EXTRA_SIDECAR_RECEIVED,
|
|
491
|
-
peer: prettyPrintPeerIdStr(peerMeta.peerId),
|
|
492
|
-
slot,
|
|
493
|
-
blockRoot: prettyBytes(blockRoot),
|
|
494
|
-
invalidIndices: prettyPrintIndices(extraIndices),
|
|
495
|
-
},
|
|
496
|
-
"Received a columnSidecar that was not requested"
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
await validateBlockDataColumnSidecars(slot, blockRoot, blobCount, [...needed, ...needToPublish]);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
468
|
export enum DownloadByRootErrorCode {
|
|
503
469
|
MISMATCH_BLOCK_ROOT = "DOWNLOAD_BY_ROOT_ERROR_MISMATCH_BLOCK_ROOT",
|
|
504
470
|
EXTRA_SIDECAR_RECEIVED = "DOWNLOAD_BY_ROOT_ERROR_EXTRA_SIDECAR_RECEIVED",
|