@lodestar/beacon-node 1.36.0-dev.f259361847 → 1.36.0-dev.f3703b7882
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 +41 -22
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts +5 -0
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +35 -10
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/node/utils.js +1 -1
- package/lib/api/impl/node/utils.js.map +1 -1
- package/lib/chain/chain.d.ts +5 -2
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +32 -16
- package/lib/chain/chain.js.map +1 -1
- 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/dataColumnSidecarError.d.ts +21 -14
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js +4 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +9 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +109 -4
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/options.d.ts +0 -2
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +2 -2
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/stateCache/datastore/db.d.ts +12 -0
- package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/db.js +70 -0
- package/lib/chain/stateCache/datastore/db.js.map +1 -1
- package/lib/chain/stateCache/datastore/file.d.ts +1 -0
- package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/file.js +7 -0
- package/lib/chain/stateCache/datastore/file.js.map +1 -1
- package/lib/chain/stateCache/datastore/types.d.ts +1 -0
- package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +16 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +31 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.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/dataColumnSidecar.d.ts +4 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +64 -19
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/lodestar.js +1 -1
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/networkCore.d.ts.map +1 -1
- package/lib/network/core/networkCore.js +5 -1
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorker.js +8 -8
- package/lib/network/core/networkCoreWorker.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/discv5/worker.js +2 -7
- package/lib/network/discv5/worker.js.map +1 -1
- package/lib/network/events.d.ts +1 -0
- package/lib/network/events.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +1 -1
- 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 +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/gossip/snappy_bun.d.ts +3 -0
- package/lib/network/gossip/snappy_bun.d.ts.map +1 -0
- package/lib/network/gossip/snappy_bun.js +3 -0
- package/lib/network/gossip/snappy_bun.js.map +1 -0
- package/lib/network/metadata.d.ts +1 -1
- package/lib/network/metadata.d.ts.map +1 -1
- package/lib/network/metadata.js +1 -0
- package/lib/network/metadata.js.map +1 -1
- package/lib/network/options.d.ts +0 -1
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/discover.js +2 -2
- package/lib/network/peers/discover.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +15 -1
- 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 +3 -2
- 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/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +3 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +2 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -3
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +9 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +2 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +9 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/index.js +6 -6
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +1 -0
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/node/nodejs.d.ts +2 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +2 -1
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +2 -1
- package/lib/sync/range/range.js.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 +59 -15
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +204 -83
- 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/lib/sync/utils/remoteSyncType.d.ts +2 -1
- package/lib/sync/utils/remoteSyncType.d.ts.map +1 -1
- package/lib/sync/utils/remoteSyncType.js +19 -4
- package/lib/sync/utils/remoteSyncType.js.map +1 -1
- package/lib/util/blobs.d.ts +1 -1
- package/lib/util/blobs.d.ts.map +1 -1
- package/lib/util/blobs.js +53 -20
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/profile.d.ts +6 -4
- package/lib/util/profile.d.ts.map +1 -1
- package/lib/util/profile.js +40 -3
- package/lib/util/profile.js.map +1 -1
- package/lib/util/sszBytes.d.ts +2 -0
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +25 -0
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +32 -25
- package/src/api/impl/beacon/blocks/index.ts +47 -25
- package/src/api/impl/lodestar/index.ts +42 -10
- package/src/api/impl/node/utils.ts +1 -1
- package/src/chain/chain.ts +48 -23
- package/src/chain/errors/blobSidecarError.ts +12 -2
- package/src/chain/errors/dataColumnSidecarError.ts +31 -16
- package/src/chain/forkChoice/index.ts +178 -2
- package/src/chain/interface.ts +2 -0
- package/src/chain/options.ts +2 -3
- package/src/chain/stateCache/datastore/db.ts +89 -1
- package/src/chain/stateCache/datastore/file.ts +8 -0
- package/src/chain/stateCache/datastore/types.ts +1 -0
- package/src/chain/stateCache/persistentCheckpointsCache.ts +45 -2
- package/src/chain/validation/blobSidecar.ts +54 -10
- package/src/chain/validation/dataColumnSidecar.ts +76 -19
- package/src/index.ts +2 -0
- package/src/metrics/metrics/lodestar.ts +1 -1
- package/src/network/core/networkCore.ts +5 -1
- package/src/network/core/networkCoreWorker.ts +9 -9
- package/src/network/core/networkCoreWorkerHandler.ts +1 -1
- package/src/network/discv5/worker.ts +2 -7
- package/src/network/events.ts +1 -1
- package/src/network/gossip/encoding.ts +1 -1
- package/src/network/gossip/gossipsub.ts +7 -1
- package/src/network/gossip/interface.ts +2 -0
- package/src/network/gossip/snappy_bun.ts +2 -0
- package/src/network/metadata.ts +3 -1
- package/src/network/options.ts +0 -1
- package/src/network/peers/discover.ts +2 -2
- package/src/network/processor/gossipHandlers.ts +16 -1
- package/src/network/processor/gossipValidatorFn.ts +15 -2
- package/src/network/processor/types.ts +2 -0
- package/src/network/reqresp/ReqRespBeaconNode.ts +3 -1
- package/src/network/reqresp/handlers/beaconBlocksByRange.ts +18 -3
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +13 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +13 -1
- package/src/network/reqresp/handlers/index.ts +6 -6
- package/src/network/reqresp/types.ts +1 -0
- package/src/node/nodejs.ts +3 -0
- package/src/sync/range/range.ts +2 -1
- package/src/sync/unknownBlock.ts +1 -1
- package/src/sync/utils/downloadByRange.ts +273 -108
- package/src/sync/utils/downloadByRoot.ts +22 -56
- package/src/sync/utils/remoteSyncType.ts +23 -4
- package/src/util/blobs.ts +64 -20
- package/src/util/profile.ts +45 -3
- package/src/util/sszBytes.ts +30 -0
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
computeEpochAtSlot,
|
|
10
10
|
computeStartSlotAtEpoch,
|
|
11
|
-
|
|
11
|
+
getBlockHeaderProposerSignatureSetByHeaderSlot,
|
|
12
|
+
getBlockHeaderProposerSignatureSetByParentStateSlot,
|
|
12
13
|
} from "@lodestar/state-transition";
|
|
13
14
|
import {BlobIndex, Root, Slot, SubnetID, deneb, ssz} from "@lodestar/types";
|
|
14
15
|
import {toRootHex, verifyMerkleBranch} from "@lodestar/utils";
|
|
@@ -100,7 +101,12 @@ export async function validateGossipBlobSidecar(
|
|
|
100
101
|
// descend from the finalized root.
|
|
101
102
|
// (Non-Lighthouse): Since we prune all blocks non-descendant from finalized checking the `db.block` database won't be useful to guard
|
|
102
103
|
// against known bad fork blocks, so we throw PARENT_UNKNOWN for cases (1) and (2)
|
|
103
|
-
throw new BlobSidecarGossipError(GossipAction.IGNORE, {
|
|
104
|
+
throw new BlobSidecarGossipError(GossipAction.IGNORE, {
|
|
105
|
+
code: BlobSidecarErrorCode.PARENT_UNKNOWN,
|
|
106
|
+
parentRoot,
|
|
107
|
+
blockRoot: blockHex,
|
|
108
|
+
slot: blobSlot,
|
|
109
|
+
});
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
// [REJECT] The blob is from a higher slot than its parent.
|
|
@@ -120,15 +126,23 @@ export async function validateGossipBlobSidecar(
|
|
|
120
126
|
const blockState = await chain.regen
|
|
121
127
|
.getBlockSlotState(parentRoot, blobSlot, {dontTransferCache: true}, RegenCaller.validateGossipBlock)
|
|
122
128
|
.catch(() => {
|
|
123
|
-
throw new BlobSidecarGossipError(GossipAction.IGNORE, {
|
|
129
|
+
throw new BlobSidecarGossipError(GossipAction.IGNORE, {
|
|
130
|
+
code: BlobSidecarErrorCode.PARENT_UNKNOWN,
|
|
131
|
+
parentRoot,
|
|
132
|
+
blockRoot: blockHex,
|
|
133
|
+
slot: blobSlot,
|
|
134
|
+
});
|
|
124
135
|
});
|
|
125
136
|
|
|
126
137
|
// [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
|
|
127
|
-
const signatureSet =
|
|
138
|
+
const signatureSet = getBlockHeaderProposerSignatureSetByParentStateSlot(blockState, blobSidecar.signedBlockHeader);
|
|
128
139
|
// Don't batch so verification is not delayed
|
|
129
140
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: true}))) {
|
|
130
141
|
throw new BlobSidecarGossipError(GossipAction.REJECT, {
|
|
131
142
|
code: BlobSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
143
|
+
blockRoot: blockHex,
|
|
144
|
+
index: blobSidecar.index,
|
|
145
|
+
slot: blobSlot,
|
|
132
146
|
});
|
|
133
147
|
}
|
|
134
148
|
|
|
@@ -175,8 +189,12 @@ export async function validateGossipBlobSidecar(
|
|
|
175
189
|
* Validate some blob sidecars in a block
|
|
176
190
|
*
|
|
177
191
|
* Requires the block to be known to the node
|
|
192
|
+
*
|
|
193
|
+
* NOTE: chain is optional to skip signature verification. Helpful for testing purposes and so that can control whether
|
|
194
|
+
* signature gets checked depending on the reqresp method that is being checked
|
|
178
195
|
*/
|
|
179
196
|
export async function validateBlockBlobSidecars(
|
|
197
|
+
chain: IBeaconChain | null,
|
|
180
198
|
blockSlot: Slot,
|
|
181
199
|
blockRoot: Root,
|
|
182
200
|
blockBlobCount: number,
|
|
@@ -196,7 +214,8 @@ export async function validateBlockBlobSidecars(
|
|
|
196
214
|
}
|
|
197
215
|
|
|
198
216
|
// Hash the first sidecar block header and compare the rest via (cheaper) equality
|
|
199
|
-
const
|
|
217
|
+
const firstSidecarSignedBlockHeader = blobSidecars[0].signedBlockHeader;
|
|
218
|
+
const firstSidecarBlockHeader = firstSidecarSignedBlockHeader.message;
|
|
200
219
|
const firstBlockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(firstSidecarBlockHeader);
|
|
201
220
|
if (Buffer.compare(blockRoot, firstBlockRoot) !== 0) {
|
|
202
221
|
throw new BlobSidecarValidationError(
|
|
@@ -211,17 +230,42 @@ export async function validateBlockBlobSidecars(
|
|
|
211
230
|
);
|
|
212
231
|
}
|
|
213
232
|
|
|
233
|
+
if (chain !== null) {
|
|
234
|
+
const headState = await chain.getHeadState();
|
|
235
|
+
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(headState, firstSidecarSignedBlockHeader);
|
|
236
|
+
|
|
237
|
+
if (
|
|
238
|
+
!(await chain.bls.verifySignatureSets([signatureSet], {
|
|
239
|
+
batchable: true,
|
|
240
|
+
priority: true,
|
|
241
|
+
verifyOnMainThread: false,
|
|
242
|
+
}))
|
|
243
|
+
) {
|
|
244
|
+
throw new BlobSidecarValidationError({
|
|
245
|
+
code: BlobSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
246
|
+
blockRoot: toRootHex(blockRoot),
|
|
247
|
+
slot: blockSlot,
|
|
248
|
+
index: blobSidecars[0].index,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
214
253
|
const commitments = [];
|
|
215
254
|
const blobs = [];
|
|
216
255
|
const proofs = [];
|
|
217
|
-
for (
|
|
218
|
-
const
|
|
219
|
-
|
|
256
|
+
for (let i = 0; i < blobSidecars.length; i++) {
|
|
257
|
+
const blobSidecar = blobSidecars[i];
|
|
258
|
+
const blobIndex = blobSidecar.index;
|
|
259
|
+
|
|
260
|
+
if (
|
|
261
|
+
i !== 0 &&
|
|
262
|
+
!ssz.phase0.SignedBeaconBlockHeader.equals(blobSidecar.signedBlockHeader, firstSidecarSignedBlockHeader)
|
|
263
|
+
) {
|
|
220
264
|
throw new BlobSidecarValidationError(
|
|
221
265
|
{
|
|
222
266
|
code: BlobSidecarErrorCode.INCORRECT_BLOCK,
|
|
223
267
|
slot: blockSlot,
|
|
224
|
-
blobIdx,
|
|
268
|
+
blobIdx: blobIndex,
|
|
225
269
|
expected: toRootHex(blockRoot),
|
|
226
270
|
actual: "unknown - compared via equality",
|
|
227
271
|
},
|
|
@@ -234,7 +278,7 @@ export async function validateBlockBlobSidecars(
|
|
|
234
278
|
{
|
|
235
279
|
code: BlobSidecarErrorCode.INCLUSION_PROOF_INVALID,
|
|
236
280
|
slot: blockSlot,
|
|
237
|
-
blobIdx,
|
|
281
|
+
blobIdx: blobIndex,
|
|
238
282
|
},
|
|
239
283
|
"BlobSidecar inclusion proof invalid"
|
|
240
284
|
);
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
computeEpochAtSlot,
|
|
9
9
|
computeStartSlotAtEpoch,
|
|
10
|
-
|
|
10
|
+
getBlockHeaderProposerSignatureSetByHeaderSlot,
|
|
11
|
+
getBlockHeaderProposerSignatureSetByParentStateSlot,
|
|
11
12
|
} from "@lodestar/state-transition";
|
|
12
13
|
import {Root, Slot, SubnetID, fulu, ssz} from "@lodestar/types";
|
|
13
14
|
import {toRootHex, verifyMerkleBranch} from "@lodestar/utils";
|
|
@@ -39,7 +40,7 @@ export async function validateGossipDataColumnSidecar(
|
|
|
39
40
|
if (computeSubnetForDataColumnSidecar(chain.config, dataColumnSidecar) !== gossipSubnet) {
|
|
40
41
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
41
42
|
code: DataColumnSidecarErrorCode.INVALID_SUBNET,
|
|
42
|
-
|
|
43
|
+
columnIndex: dataColumnSidecar.index,
|
|
43
44
|
gossipSubnet: gossipSubnet,
|
|
44
45
|
});
|
|
45
46
|
}
|
|
@@ -86,6 +87,7 @@ export async function validateGossipDataColumnSidecar(
|
|
|
86
87
|
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
87
88
|
code: DataColumnSidecarErrorCode.PARENT_UNKNOWN,
|
|
88
89
|
parentRoot,
|
|
90
|
+
slot: blockHeader.slot,
|
|
89
91
|
});
|
|
90
92
|
}
|
|
91
93
|
|
|
@@ -108,6 +110,7 @@ export async function validateGossipDataColumnSidecar(
|
|
|
108
110
|
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
109
111
|
code: DataColumnSidecarErrorCode.PARENT_UNKNOWN,
|
|
110
112
|
parentRoot,
|
|
113
|
+
slot: blockHeader.slot,
|
|
111
114
|
});
|
|
112
115
|
});
|
|
113
116
|
|
|
@@ -128,15 +131,23 @@ export async function validateGossipDataColumnSidecar(
|
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
// 5) [REJECT] The proposer signature of sidecar.signed_block_header, is valid with respect to the block_header.proposer_index pubkey.
|
|
131
|
-
const signatureSet =
|
|
134
|
+
const signatureSet = getBlockHeaderProposerSignatureSetByParentStateSlot(
|
|
135
|
+
blockState,
|
|
136
|
+
dataColumnSidecar.signedBlockHeader
|
|
137
|
+
);
|
|
132
138
|
// Don't batch so verification is not delayed
|
|
133
139
|
if (
|
|
134
140
|
!(await chain.bls.verifySignatureSets([signatureSet], {
|
|
135
141
|
verifyOnMainThread: blockHeader.slot > chain.forkChoice.getHead().slot,
|
|
136
142
|
}))
|
|
137
143
|
) {
|
|
144
|
+
const blockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(dataColumnSidecar.signedBlockHeader.message);
|
|
145
|
+
const blockRootHex = toRootHex(blockRoot);
|
|
138
146
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
139
147
|
code: DataColumnSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
148
|
+
blockRoot: blockRootHex,
|
|
149
|
+
index: dataColumnSidecar.index,
|
|
150
|
+
slot: blockHeader.slot,
|
|
140
151
|
});
|
|
141
152
|
}
|
|
142
153
|
|
|
@@ -156,7 +167,7 @@ export async function validateGossipDataColumnSidecar(
|
|
|
156
167
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
157
168
|
code: DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID,
|
|
158
169
|
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
159
|
-
|
|
170
|
+
columnIndex: dataColumnSidecar.index,
|
|
160
171
|
});
|
|
161
172
|
}
|
|
162
173
|
|
|
@@ -173,7 +184,7 @@ export async function validateGossipDataColumnSidecar(
|
|
|
173
184
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
174
185
|
code: DataColumnSidecarErrorCode.INVALID_KZG_PROOF,
|
|
175
186
|
slot: blockHeader.slot,
|
|
176
|
-
|
|
187
|
+
columnIndex: dataColumnSidecar.index,
|
|
177
188
|
});
|
|
178
189
|
} finally {
|
|
179
190
|
kzgProofTimer?.();
|
|
@@ -193,7 +204,7 @@ function verifyDataColumnSidecar(config: ChainForkConfig, dataColumnSidecar: ful
|
|
|
193
204
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
194
205
|
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
195
206
|
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
196
|
-
|
|
207
|
+
columnIndex: dataColumnSidecar.index,
|
|
197
208
|
});
|
|
198
209
|
}
|
|
199
210
|
|
|
@@ -201,7 +212,7 @@ function verifyDataColumnSidecar(config: ChainForkConfig, dataColumnSidecar: ful
|
|
|
201
212
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
202
213
|
code: DataColumnSidecarErrorCode.NO_COMMITMENTS,
|
|
203
214
|
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
204
|
-
|
|
215
|
+
columnIndex: dataColumnSidecar.index,
|
|
205
216
|
});
|
|
206
217
|
}
|
|
207
218
|
|
|
@@ -212,7 +223,7 @@ function verifyDataColumnSidecar(config: ChainForkConfig, dataColumnSidecar: ful
|
|
|
212
223
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
213
224
|
code: DataColumnSidecarErrorCode.TOO_MANY_KZG_COMMITMENTS,
|
|
214
225
|
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
215
|
-
|
|
226
|
+
columnIndex: dataColumnSidecar.index,
|
|
216
227
|
count: dataColumnSidecar.kzgCommitments.length,
|
|
217
228
|
limit: maxBlobsPerBlock,
|
|
218
229
|
});
|
|
@@ -271,8 +282,12 @@ export function verifyDataColumnSidecarInclusionProof(dataColumnSidecar: fulu.Da
|
|
|
271
282
|
* Validate a subset of data column sidecars in a block
|
|
272
283
|
*
|
|
273
284
|
* Requires the block to be known to the node
|
|
285
|
+
*
|
|
286
|
+
* NOTE: chain is optional to skip signature verification. Helpful for testing purposes and so that can control whether
|
|
287
|
+
* signature gets checked depending on the reqresp method that is being checked
|
|
274
288
|
*/
|
|
275
289
|
export async function validateBlockDataColumnSidecars(
|
|
290
|
+
chain: IBeaconChain | null,
|
|
276
291
|
blockSlot: Slot,
|
|
277
292
|
blockRoot: Root,
|
|
278
293
|
blockBlobCount: number,
|
|
@@ -293,16 +308,16 @@ export async function validateBlockDataColumnSidecars(
|
|
|
293
308
|
"Block has no blob commitments but data column sidecars were provided"
|
|
294
309
|
);
|
|
295
310
|
}
|
|
296
|
-
|
|
297
311
|
// Hash the first sidecar block header and compare the rest via (cheaper) equality
|
|
298
|
-
const
|
|
312
|
+
const firstSidecarSignedBlockHeader = dataColumnSidecars[0].signedBlockHeader;
|
|
313
|
+
const firstSidecarBlockHeader = firstSidecarSignedBlockHeader.message;
|
|
299
314
|
const firstBlockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(firstSidecarBlockHeader);
|
|
300
315
|
if (Buffer.compare(blockRoot, firstBlockRoot) !== 0) {
|
|
301
316
|
throw new DataColumnSidecarValidationError(
|
|
302
317
|
{
|
|
303
318
|
code: DataColumnSidecarErrorCode.INCORRECT_BLOCK,
|
|
304
319
|
slot: blockSlot,
|
|
305
|
-
|
|
320
|
+
columnIndex: 0,
|
|
306
321
|
expected: toRootHex(blockRoot),
|
|
307
322
|
actual: toRootHex(firstBlockRoot),
|
|
308
323
|
},
|
|
@@ -310,6 +325,26 @@ export async function validateBlockDataColumnSidecars(
|
|
|
310
325
|
);
|
|
311
326
|
}
|
|
312
327
|
|
|
328
|
+
if (chain !== null) {
|
|
329
|
+
const headState = await chain.getHeadState();
|
|
330
|
+
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(headState, firstSidecarSignedBlockHeader);
|
|
331
|
+
|
|
332
|
+
if (
|
|
333
|
+
!(await chain.bls.verifySignatureSets([signatureSet], {
|
|
334
|
+
batchable: true,
|
|
335
|
+
priority: true,
|
|
336
|
+
verifyOnMainThread: false,
|
|
337
|
+
}))
|
|
338
|
+
) {
|
|
339
|
+
throw new DataColumnSidecarValidationError({
|
|
340
|
+
code: DataColumnSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
341
|
+
blockRoot: toRootHex(blockRoot),
|
|
342
|
+
slot: blockSlot,
|
|
343
|
+
index: dataColumnSidecars[0].index,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
313
348
|
const commitments: Uint8Array[] = [];
|
|
314
349
|
const cellIndices: number[] = [];
|
|
315
350
|
const cells: Uint8Array[] = [];
|
|
@@ -317,33 +352,55 @@ export async function validateBlockDataColumnSidecars(
|
|
|
317
352
|
for (let i = 0; i < dataColumnSidecars.length; i++) {
|
|
318
353
|
const columnSidecar = dataColumnSidecars[i];
|
|
319
354
|
|
|
355
|
+
if (
|
|
356
|
+
i !== 0 &&
|
|
357
|
+
!ssz.phase0.SignedBeaconBlockHeader.equals(firstSidecarSignedBlockHeader, columnSidecar.signedBlockHeader)
|
|
358
|
+
) {
|
|
359
|
+
throw new DataColumnSidecarValidationError({
|
|
360
|
+
code: DataColumnSidecarErrorCode.INCORRECT_HEADER_ROOT,
|
|
361
|
+
slot: blockSlot,
|
|
362
|
+
expected: toRootHex(blockRoot),
|
|
363
|
+
actual: toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(columnSidecar.signedBlockHeader.message)),
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
|
|
320
367
|
if (columnSidecar.index >= NUMBER_OF_COLUMNS) {
|
|
321
368
|
throw new DataColumnSidecarValidationError(
|
|
322
369
|
{
|
|
323
370
|
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
324
371
|
slot: blockSlot,
|
|
325
|
-
|
|
372
|
+
columnIndex: columnSidecar.index,
|
|
326
373
|
},
|
|
327
374
|
"DataColumnSidecar has invalid index"
|
|
328
375
|
);
|
|
329
376
|
}
|
|
330
377
|
|
|
331
|
-
if (columnSidecar.
|
|
378
|
+
if (columnSidecar.column.length !== blockBlobCount) {
|
|
332
379
|
throw new DataColumnSidecarValidationError({
|
|
333
|
-
code: DataColumnSidecarErrorCode.
|
|
380
|
+
code: DataColumnSidecarErrorCode.INCORRECT_CELL_COUNT,
|
|
334
381
|
slot: blockSlot,
|
|
335
|
-
|
|
382
|
+
columnIndex: columnSidecar.index,
|
|
336
383
|
expected: blockBlobCount,
|
|
384
|
+
actual: columnSidecar.column.length,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (columnSidecar.column.length !== columnSidecar.kzgCommitments.length) {
|
|
389
|
+
throw new DataColumnSidecarValidationError({
|
|
390
|
+
code: DataColumnSidecarErrorCode.INCORRECT_KZG_COMMITMENTS_COUNT,
|
|
391
|
+
slot: blockSlot,
|
|
392
|
+
columnIndex: columnSidecar.index,
|
|
393
|
+
expected: columnSidecar.column.length,
|
|
337
394
|
actual: columnSidecar.kzgCommitments.length,
|
|
338
395
|
});
|
|
339
396
|
}
|
|
340
397
|
|
|
341
|
-
if (columnSidecar.
|
|
398
|
+
if (columnSidecar.column.length !== columnSidecar.kzgProofs.length) {
|
|
342
399
|
throw new DataColumnSidecarValidationError({
|
|
343
400
|
code: DataColumnSidecarErrorCode.INCORRECT_KZG_PROOF_COUNT,
|
|
344
401
|
slot: blockSlot,
|
|
345
|
-
|
|
346
|
-
expected: columnSidecar.
|
|
402
|
+
columnIndex: columnSidecar.index,
|
|
403
|
+
expected: columnSidecar.column.length,
|
|
347
404
|
actual: columnSidecar.kzgProofs.length,
|
|
348
405
|
});
|
|
349
406
|
}
|
|
@@ -353,7 +410,7 @@ export async function validateBlockDataColumnSidecars(
|
|
|
353
410
|
{
|
|
354
411
|
code: DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID,
|
|
355
412
|
slot: blockSlot,
|
|
356
|
-
|
|
413
|
+
columnIndex: columnSidecar.index,
|
|
357
414
|
},
|
|
358
415
|
"DataColumnSidecar has invalid inclusion proof"
|
|
359
416
|
);
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
export type {RestApiServerMetrics, RestApiServerModules, RestApiServerOpts} from "./api/rest/base.js";
|
|
4
4
|
export {RestApiServer} from "./api/rest/base.js";
|
|
5
5
|
export {checkAndPersistAnchorState, initStateFromDb, initStateFromEth1} from "./chain/index.js";
|
|
6
|
+
export {DbCPStateDatastore} from "./chain/stateCache/datastore/db.js";
|
|
7
|
+
export {FileCPStateDatastore} from "./chain/stateCache/datastore/file.js";
|
|
6
8
|
export {BeaconDb, type IBeaconDb} from "./db/index.js";
|
|
7
9
|
export {Eth1Provider, type IEth1Provider} from "./eth1/index.js";
|
|
8
10
|
// Export metrics utilities to de-duplicate validator metrics
|
|
@@ -1878,7 +1878,7 @@ export function createLodestarMetrics(
|
|
|
1878
1878
|
fetchKeys: register.histogram({
|
|
1879
1879
|
name: "lodestar_prune_history_fetch_keys_time_seconds",
|
|
1880
1880
|
help: "Time to fetch keys in seconds",
|
|
1881
|
-
buckets: [0.001, 0.01, 0.1, 1],
|
|
1881
|
+
buckets: [0.001, 0.01, 0.1, 0.3, 0.5, 1],
|
|
1882
1882
|
}),
|
|
1883
1883
|
|
|
1884
1884
|
pruneKeys: register.histogram({
|
|
@@ -553,7 +553,11 @@ export class NetworkCore implements INetworkCore {
|
|
|
553
553
|
// On fork boundary transition
|
|
554
554
|
if (epoch === nextBoundaryEpoch) {
|
|
555
555
|
// updateEth2Field() MUST be called with clock epoch, onEpoch event is emitted in response to clock events
|
|
556
|
-
this.metadata.updateEth2Field(epoch);
|
|
556
|
+
const {forkDigest} = this.metadata.updateEth2Field(epoch);
|
|
557
|
+
// Update local status to reflect the new fork digest, otherwise we will disconnect peers that re-status us
|
|
558
|
+
// right after the fork transition due to incompatible forks as our fork digest is stale since we only
|
|
559
|
+
// update it once we import a new head or when emitting update status event.
|
|
560
|
+
this.statusCache.update({...this.statusCache.get(), forkDigest});
|
|
557
561
|
this.reqResp.registerProtocolsAtBoundary(nextBoundary);
|
|
558
562
|
}
|
|
559
563
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
1
|
import worker from "node:worker_threads";
|
|
4
2
|
import {privateKeyFromProtobuf} from "@libp2p/crypto/keys";
|
|
5
3
|
import {peerIdFromPrivateKey} from "@libp2p/peer-id";
|
|
@@ -11,7 +9,7 @@ import {RegistryMetricCreator, collectNodeJSMetrics} from "../../metrics/index.j
|
|
|
11
9
|
import {AsyncIterableBridgeCaller, AsyncIterableBridgeHandler} from "../../util/asyncIterableToEvents.js";
|
|
12
10
|
import {Clock} from "../../util/clock.js";
|
|
13
11
|
import {peerIdToString} from "../../util/peerId.js";
|
|
14
|
-
import {
|
|
12
|
+
import {ProfileThread, profileThread, writeHeapSnapshot} from "../../util/profile.js";
|
|
15
13
|
import {wireEventsOnWorkerThread} from "../../util/workerEvents.js";
|
|
16
14
|
import {NetworkEventBus, NetworkEventData, networkEventDirection} from "../events.js";
|
|
17
15
|
import {
|
|
@@ -100,8 +98,13 @@ const core = await NetworkCore.init({
|
|
|
100
98
|
metricsRegistry: metricsRegister,
|
|
101
99
|
events,
|
|
102
100
|
clock,
|
|
103
|
-
getReqRespHandler: (method) => (req, peerId) =>
|
|
104
|
-
reqRespBridgeRespCaller.getAsyncIterable({
|
|
101
|
+
getReqRespHandler: (method) => (req, peerId, peerClient) =>
|
|
102
|
+
reqRespBridgeRespCaller.getAsyncIterable({
|
|
103
|
+
method,
|
|
104
|
+
req,
|
|
105
|
+
peerId: peerIdToString(peerId),
|
|
106
|
+
peerClient,
|
|
107
|
+
}),
|
|
105
108
|
activeValidatorCount: workerData.activeValidatorCount,
|
|
106
109
|
initialStatus: workerData.initialStatus,
|
|
107
110
|
initialCustodyGroupCount: workerData.initialCustodyGroupCount,
|
|
@@ -157,10 +160,7 @@ const libp2pWorkerApi: NetworkWorkerApi = {
|
|
|
157
160
|
dumpDiscv5KadValues: () => core.dumpDiscv5KadValues(),
|
|
158
161
|
dumpMeshPeers: () => core.dumpMeshPeers(),
|
|
159
162
|
writeProfile: async (durationMs: number, dirpath: string) => {
|
|
160
|
-
|
|
161
|
-
const filePath = path.join(dirpath, `network_thread_${new Date().toISOString()}.cpuprofile`);
|
|
162
|
-
fs.writeFileSync(filePath, profile);
|
|
163
|
-
return filePath;
|
|
163
|
+
return profileThread(ProfileThread.NETWORK, durationMs, dirpath);
|
|
164
164
|
},
|
|
165
165
|
writeDiscv5Profile: async (durationMs: number, dirpath: string) => {
|
|
166
166
|
return core.writeDiscv5Profile(durationMs, dirpath);
|
|
@@ -73,7 +73,7 @@ export class WorkerNetworkCore implements INetworkCore {
|
|
|
73
73
|
// Handles ReqResp response from worker and calls async generator in main thread
|
|
74
74
|
this.reqRespBridgeRespHandler = new AsyncIterableBridgeHandler(
|
|
75
75
|
getReqRespBridgeRespEvents(this.reqRespBridgeEventBus),
|
|
76
|
-
(data) => modules.getReqRespHandler(data.method)(data.req, peerIdFromString(data.peerId))
|
|
76
|
+
(data) => modules.getReqRespHandler(data.method)(data.req, peerIdFromString(data.peerId), data.peerClient)
|
|
77
77
|
);
|
|
78
78
|
|
|
79
79
|
wireEventsOnMainThread<NetworkEventData>(
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
1
|
import worker from "node:worker_threads";
|
|
4
2
|
import {privateKeyFromProtobuf} from "@libp2p/crypto/keys";
|
|
5
3
|
import {peerIdFromPrivateKey} from "@libp2p/peer-id";
|
|
@@ -14,7 +12,7 @@ import {Gauge} from "@lodestar/utils";
|
|
|
14
12
|
import {RegistryMetricCreator} from "../../metrics/index.js";
|
|
15
13
|
import {collectNodeJSMetrics} from "../../metrics/nodeJsMetrics.js";
|
|
16
14
|
import {Clock} from "../../util/clock.js";
|
|
17
|
-
import {
|
|
15
|
+
import {ProfileThread, profileThread, writeHeapSnapshot} from "../../util/profile.js";
|
|
18
16
|
import {Discv5WorkerApi, Discv5WorkerData} from "./types.js";
|
|
19
17
|
import {ENRRelevance, enrRelevance} from "./utils.js";
|
|
20
18
|
|
|
@@ -108,10 +106,7 @@ const module: Discv5WorkerApi = {
|
|
|
108
106
|
return (await metricsRegistry?.metrics()) ?? "";
|
|
109
107
|
},
|
|
110
108
|
writeProfile: async (durationMs: number, dirpath: string) => {
|
|
111
|
-
|
|
112
|
-
const filePath = path.join(dirpath, `discv5_thread_${new Date().toISOString()}.cpuprofile`);
|
|
113
|
-
fs.writeFileSync(filePath, profile);
|
|
114
|
-
return filePath;
|
|
109
|
+
return profileThread(ProfileThread.DISC5, durationMs, dirpath);
|
|
115
110
|
},
|
|
116
111
|
writeHeapSnapshot: async (prefix: string, dirpath: string) => {
|
|
117
112
|
return writeHeapSnapshot(prefix, dirpath);
|
package/src/network/events.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type NetworkEventData = {
|
|
|
29
29
|
clientAgent: string;
|
|
30
30
|
};
|
|
31
31
|
[NetworkEvent.peerDisconnected]: {peer: PeerIdStr};
|
|
32
|
-
[NetworkEvent.reqRespRequest]: {request: RequestTypedContainer; peer: PeerId};
|
|
32
|
+
[NetworkEvent.reqRespRequest]: {request: RequestTypedContainer; peer: PeerId; peerClient: string};
|
|
33
33
|
[NetworkEvent.pendingGossipsubMessage]: PendingGossipsubMessage;
|
|
34
34
|
[NetworkEvent.gossipMessageValidationResult]: {
|
|
35
35
|
msgId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Message} from "@libp2p/interface";
|
|
2
|
-
import {compress, uncompress} from "snappyjs";
|
|
3
2
|
import xxhashFactory from "xxhash-wasm";
|
|
3
|
+
import {compress, uncompress} from "#snappy";
|
|
4
4
|
import {digest} from "@chainsafe/as-sha256";
|
|
5
5
|
import {RPC} from "@chainsafe/libp2p-gossipsub/message";
|
|
6
6
|
import {DataTransform} from "@chainsafe/libp2p-gossipsub/types";
|
|
@@ -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
|
});
|
package/src/network/metadata.ts
CHANGED
|
@@ -126,7 +126,7 @@ export class MetadataController {
|
|
|
126
126
|
* 2. Network MUST call this method on fork transition.
|
|
127
127
|
* Current Clock implementation ensures no race conditions, epoch is correct if re-fetched
|
|
128
128
|
*/
|
|
129
|
-
updateEth2Field(epoch: Epoch):
|
|
129
|
+
updateEth2Field(epoch: Epoch): phase0.ENRForkID {
|
|
130
130
|
const config = this.networkConfig.config;
|
|
131
131
|
const enrForkId = getENRForkID(config, epoch);
|
|
132
132
|
const {forkDigest, nextForkVersion, nextForkEpoch} = enrForkId;
|
|
@@ -143,6 +143,8 @@ export class MetadataController {
|
|
|
143
143
|
: ssz.ForkDigest.defaultValue();
|
|
144
144
|
this.onSetValue(ENRKey.nfd, nextForkDigest);
|
|
145
145
|
this.logger.debug("Updated nfd field in ENR", {nextForkDigest: toHex(nextForkDigest)});
|
|
146
|
+
|
|
147
|
+
return enrForkId;
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
|
package/src/network/options.ts
CHANGED
|
@@ -391,8 +391,8 @@ export class PeerDiscovery {
|
|
|
391
391
|
// tcp multiaddr is known to be be present, checked inside the worker
|
|
392
392
|
const multiaddrTCP = enr.getLocationMultiaddr(ENRKey.tcp);
|
|
393
393
|
if (!multiaddrTCP) {
|
|
394
|
-
this.logger.
|
|
395
|
-
this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.
|
|
394
|
+
this.logger.warn("Discv5 worker sent enr without tcp multiaddr", {enr: enr.encodeTxt()});
|
|
395
|
+
this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.no_multiaddrs});
|
|
396
396
|
return;
|
|
397
397
|
}
|
|
398
398
|
// Are this fields mandatory?
|
|
@@ -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);
|
|
@@ -307,7 +322,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
307
322
|
});
|
|
308
323
|
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
309
324
|
code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
|
|
310
|
-
|
|
325
|
+
columnIndex: dataColumnSidecar.index,
|
|
311
326
|
slot,
|
|
312
327
|
});
|
|
313
328
|
}
|
|
@@ -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;
|
|
@@ -99,7 +100,15 @@ export function getGossipValidatorBatchFn(
|
|
|
99
100
|
export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: ValidatorFnModules): GossipValidatorFn {
|
|
100
101
|
const {logger, metrics} = modules;
|
|
101
102
|
|
|
102
|
-
return async function gossipValidatorFn({
|
|
103
|
+
return async function gossipValidatorFn({
|
|
104
|
+
topic,
|
|
105
|
+
msg,
|
|
106
|
+
propagationSource,
|
|
107
|
+
clientAgent,
|
|
108
|
+
clientVersion,
|
|
109
|
+
seenTimestampSec,
|
|
110
|
+
msgSlot,
|
|
111
|
+
}) {
|
|
103
112
|
const type = topic.type;
|
|
104
113
|
|
|
105
114
|
try {
|
|
@@ -134,7 +143,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
|
|
|
134
143
|
|
|
135
144
|
case GossipAction.REJECT:
|
|
136
145
|
metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
|
|
137
|
-
logger.debug(
|
|
146
|
+
logger.debug(
|
|
147
|
+
`Gossip validation ${type} rejected`,
|
|
148
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
149
|
+
e
|
|
150
|
+
);
|
|
138
151
|
return TopicValidatorResult.Reject;
|
|
139
152
|
}
|
|
140
153
|
}
|
|
@@ -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
|