@lodestar/beacon-node 2.1.0-dev.9af51a1670 → 2.1.0-dev.9d8b35c280
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 +1 -3
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +8 -0
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +3 -2
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +1 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/validator/index.js +1 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +3 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +3 -1
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/GetBlobsTracker.d.ts +3 -0
- package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
- package/lib/chain/GetBlobsTracker.js +3 -1
- package/lib/chain/GetBlobsTracker.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +14 -5
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +4 -2
- package/lib/chain/blocks/importExecutionPayload.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 +2 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +29 -6
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +7 -0
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js +1 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +11 -2
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +180 -13
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/opPool.d.ts +9 -3
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +22 -16
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +1 -0
- package/lib/chain/seenCache/index.d.ts.map +1 -1
- package/lib/chain/seenCache/index.js +1 -0
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +1 -0
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +5 -1
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/seenCache/seenDataColumnSidecars.d.ts +16 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.d.ts.map +1 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.js +56 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.js.map +1 -0
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +11 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +28 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +4 -2
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +20 -7
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +1 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +5 -1
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/network/forks.d.ts +2 -2
- package/lib/network/forks.d.ts.map +1 -1
- package/lib/network/forks.js +3 -3
- package/lib/network/forks.js.map +1 -1
- package/lib/network/gossip/scoringParameters.js +19 -14
- package/lib/network/gossip/scoringParameters.js.map +1 -1
- package/lib/network/peers/discover.d.ts +1 -0
- package/lib/network/peers/discover.d.ts.map +1 -1
- package/lib/network/peers/discover.js +43 -47
- package/lib/network/peers/discover.js.map +1 -1
- package/lib/network/peers/score/store.d.ts.map +1 -1
- package/lib/network/peers/score/store.js +1 -2
- package/lib/network/peers/score/store.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +75 -9
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +3 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +1 -0
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +5 -1
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +14 -1
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +6 -0
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +17 -8
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +1 -1
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.js +6 -1
- package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
- package/lib/util/dataColumns.d.ts +2 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +7 -2
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/execution.d.ts +2 -1
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +7 -2
- package/lib/util/execution.js.map +1 -1
- package/package.json +18 -21
- package/src/api/impl/beacon/blocks/index.ts +1 -5
- package/src/api/impl/beacon/pool/index.ts +11 -0
- package/src/api/impl/beacon/state/index.ts +3 -7
- package/src/api/impl/beacon/state/utils.ts +1 -1
- package/src/api/impl/validator/index.ts +1 -1
- package/src/chain/ColumnReconstructionTracker.ts +5 -1
- package/src/chain/GetBlobsTracker.ts +5 -0
- package/src/chain/blocks/importBlock.ts +14 -7
- package/src/chain/blocks/importExecutionPayload.ts +4 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +8 -1
- package/src/chain/chain.ts +34 -5
- package/src/chain/errors/dataColumnSidecarError.ts +8 -0
- package/src/chain/forkChoice/index.ts +233 -13
- package/src/chain/interface.ts +2 -0
- package/src/chain/opPools/opPool.ts +27 -16
- package/src/chain/options.ts +1 -0
- package/src/chain/seenCache/index.ts +1 -0
- package/src/chain/seenCache/seenBlockProposers.ts +11 -1
- package/src/chain/seenCache/seenDataColumnSidecars.ts +64 -0
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +28 -2
- package/src/chain/validation/attestation.ts +4 -2
- package/src/chain/validation/block.ts +19 -7
- package/src/chain/validation/dataColumnSidecar.ts +1 -1
- package/src/chain/validation/proposerSlashing.ts +5 -1
- package/src/network/forks.ts +7 -3
- package/src/network/gossip/scoringParameters.ts +23 -14
- package/src/network/peers/discover.ts +41 -51
- package/src/network/peers/score/store.ts +1 -2
- package/src/network/processor/gossipHandlers.ts +134 -17
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +4 -1
- package/src/sync/range/chain.ts +1 -0
- package/src/sync/range/range.ts +7 -1
- package/src/sync/unknownBlock.ts +20 -1
- package/src/sync/utils/downloadByRange.ts +30 -7
- package/src/sync/utils/downloadByRoot.ts +12 -9
- package/src/sync/utils/pendingBlocksTree.ts +6 -1
- package/src/util/dataColumns.ts +13 -1
- package/src/util/execution.ts +16 -1
|
@@ -36,7 +36,11 @@ async function validateProposerSlashing(
|
|
|
36
36
|
|
|
37
37
|
// [REJECT] All of the conditions within process_proposer_slashing pass validation.
|
|
38
38
|
try {
|
|
39
|
-
const
|
|
39
|
+
const {proposerIndex} = proposerSlashing.signedHeader1.message;
|
|
40
|
+
if (proposerIndex >= state.validatorCount) {
|
|
41
|
+
throw Error(`Unknown proposer index ${proposerIndex}`);
|
|
42
|
+
}
|
|
43
|
+
const proposer = state.getValidator(proposerIndex);
|
|
40
44
|
// verifySignature = false, verified in batch below
|
|
41
45
|
assertValidProposerSlashing(chain.config, state.slot, proposerSlashing, proposer, false);
|
|
42
46
|
} catch (e) {
|
package/src/network/forks.ts
CHANGED
|
@@ -29,10 +29,14 @@ import {Epoch} from "@lodestar/types";
|
|
|
29
29
|
export const FORK_EPOCH_LOOKAHEAD = 2;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Return the
|
|
32
|
+
* Return the fork boundaries active at any epoch in the inclusive range.
|
|
33
33
|
* @see FORK_EPOCH_LOOKAHEAD for details on when fork boundaries are considered 'active'
|
|
34
34
|
*/
|
|
35
|
-
export function getActiveForkBoundaries(
|
|
35
|
+
export function getActiveForkBoundaries(
|
|
36
|
+
config: ChainForkConfig,
|
|
37
|
+
fromEpoch: Epoch,
|
|
38
|
+
toEpoch = fromEpoch
|
|
39
|
+
): ForkBoundary[] {
|
|
36
40
|
const activeBoundaries: ForkBoundary[] = [];
|
|
37
41
|
const {forkBoundariesAscendingEpochOrder} = config;
|
|
38
42
|
|
|
@@ -48,7 +52,7 @@ export function getActiveForkBoundaries(config: ChainForkConfig, epoch: Epoch):
|
|
|
48
52
|
continue;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
if (
|
|
55
|
+
if (toEpoch >= currentEpoch - FORK_EPOCH_LOOKAHEAD && fromEpoch <= nextEpoch + FORK_EPOCH_LOOKAHEAD) {
|
|
52
56
|
activeBoundaries.push(currentForkBoundary);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from "@libp2p/gossipsub/score";
|
|
7
7
|
import {BeaconConfig} from "@lodestar/config";
|
|
8
8
|
import {ATTESTATION_SUBNET_COUNT, PTC_SIZE, SLOTS_PER_EPOCH, TARGET_AGGREGATORS_PER_COMMITTEE} from "@lodestar/params";
|
|
9
|
-
import {computeCommitteeCount} from "@lodestar/state-transition";
|
|
10
|
-
import {getActiveForkBoundaries} from "../forks.js";
|
|
9
|
+
import {computeCommitteeCount, computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
10
|
+
import {FORK_EPOCH_LOOKAHEAD, getActiveForkBoundaries} from "../forks.js";
|
|
11
11
|
import {Eth2Context} from "./gossipsub.js";
|
|
12
12
|
import {GossipType} from "./interface.js";
|
|
13
13
|
import {stringifyGossipTopic} from "./topic.js";
|
|
@@ -132,11 +132,20 @@ function getAllTopicsScoreParams(
|
|
|
132
132
|
precomputedParams: PreComputedParams
|
|
133
133
|
): Record<string, TopicScoreParams> {
|
|
134
134
|
const {epochDurationMs, slotDurationMs} = precomputedParams;
|
|
135
|
-
const epoch = eth2Context.currentEpoch;
|
|
136
135
|
const topicsParams: Record<string, TopicScoreParams> = {};
|
|
137
|
-
|
|
136
|
+
// Gossipsub copies the score parameters at construction, including those for future subscriptions.
|
|
137
|
+
const boundaries = getActiveForkBoundaries(config, eth2Context.currentEpoch, Infinity);
|
|
138
138
|
const beaconAttestationSubnetWeight = 1 / ATTESTATION_SUBNET_COUNT;
|
|
139
139
|
for (const boundary of boundaries) {
|
|
140
|
+
const currentSlot = Math.max(
|
|
141
|
+
eth2Context.currentSlot,
|
|
142
|
+
computeStartSlotAtEpoch(boundary.epoch - FORK_EPOCH_LOOKAHEAD)
|
|
143
|
+
);
|
|
144
|
+
// The node subscribes to a boundary's topics FORK_EPOCH_LOOKAHEAD epochs early, but peers only publish on
|
|
145
|
+
// them from the boundary epoch. Hold back the mesh delivery penalty until then, otherwise every mesh peer
|
|
146
|
+
// is penalized for an empty topic.
|
|
147
|
+
const subscribeEpoch = Math.max(eth2Context.currentEpoch, boundary.epoch - FORK_EPOCH_LOOKAHEAD);
|
|
148
|
+
const activationDelayMs = Math.max(0, boundary.epoch - subscribeEpoch) * epochDurationMs;
|
|
140
149
|
//first all fixed topics
|
|
141
150
|
topicsParams[
|
|
142
151
|
stringifyGossipTopic(config, {
|
|
@@ -225,8 +234,8 @@ function getAllTopicsScoreParams(
|
|
|
225
234
|
meshMessageInfo: {
|
|
226
235
|
decaySlots: SLOTS_PER_EPOCH * 5,
|
|
227
236
|
capFactor: 3,
|
|
228
|
-
activationWindow: epochDurationMs,
|
|
229
|
-
currentSlot
|
|
237
|
+
activationWindow: activationDelayMs + epochDurationMs,
|
|
238
|
+
currentSlot,
|
|
230
239
|
},
|
|
231
240
|
});
|
|
232
241
|
topicsParams[
|
|
@@ -241,8 +250,8 @@ function getAllTopicsScoreParams(
|
|
|
241
250
|
meshMessageInfo: {
|
|
242
251
|
decaySlots: SLOTS_PER_EPOCH * 5,
|
|
243
252
|
capFactor: 3,
|
|
244
|
-
activationWindow: epochDurationMs,
|
|
245
|
-
currentSlot
|
|
253
|
+
activationWindow: activationDelayMs + epochDurationMs,
|
|
254
|
+
currentSlot,
|
|
246
255
|
},
|
|
247
256
|
});
|
|
248
257
|
|
|
@@ -268,8 +277,8 @@ function getAllTopicsScoreParams(
|
|
|
268
277
|
meshMessageInfo: {
|
|
269
278
|
decaySlots: SLOTS_PER_EPOCH * 2,
|
|
270
279
|
capFactor: 4,
|
|
271
|
-
activationWindow: epochDurationMs,
|
|
272
|
-
currentSlot
|
|
280
|
+
activationWindow: activationDelayMs + epochDurationMs,
|
|
281
|
+
currentSlot,
|
|
273
282
|
},
|
|
274
283
|
});
|
|
275
284
|
|
|
@@ -280,10 +289,10 @@ function getAllTopicsScoreParams(
|
|
|
280
289
|
meshMessageInfo: {
|
|
281
290
|
decaySlots: multipleBurstsPerSubnetPerEpoch ? SLOTS_PER_EPOCH * 4 : SLOTS_PER_EPOCH * 16,
|
|
282
291
|
capFactor: 16,
|
|
283
|
-
activationWindow:
|
|
284
|
-
|
|
285
|
-
: epochDurationMs,
|
|
286
|
-
currentSlot
|
|
292
|
+
activationWindow:
|
|
293
|
+
activationDelayMs +
|
|
294
|
+
(multipleBurstsPerSubnetPerEpoch ? slotDurationMs * (SLOTS_PER_EPOCH / 2 + 1) : epochDurationMs),
|
|
295
|
+
currentSlot,
|
|
287
296
|
},
|
|
288
297
|
});
|
|
289
298
|
for (let subnet = 0; subnet < ATTESTATION_SUBNET_COUNT; subnet++) {
|
|
@@ -4,7 +4,7 @@ import {ENR} from "@chainsafe/enr";
|
|
|
4
4
|
import {BeaconConfig} from "@lodestar/config";
|
|
5
5
|
import {LoggerNode} from "@lodestar/logger/node";
|
|
6
6
|
import {ATTESTATION_SUBNET_COUNT, ForkSeq, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
|
|
7
|
-
import {
|
|
7
|
+
import {SubnetID} from "@lodestar/types";
|
|
8
8
|
import {bytesToInt, pruneSetToMax, sleep, toHex} from "@lodestar/utils";
|
|
9
9
|
import {IClock} from "../../util/clock.js";
|
|
10
10
|
import {getCustodyGroups} from "../../util/dataColumns.js";
|
|
@@ -255,29 +255,19 @@ export class PeerDiscovery {
|
|
|
255
255
|
this.peersToConnect += peersToConnect;
|
|
256
256
|
|
|
257
257
|
// starting from PeerDAS, we need to prioritize column subnet peers first in order to have stable subnet sampling
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
cachedENRsToDial.set(cachedENR.peerId.toString(), cachedENR);
|
|
268
|
-
|
|
269
|
-
if (++cachedENRsInGroup >= maxPeersToConnect) {
|
|
270
|
-
continue group;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const groupPeersToConnect = Math.max(maxPeersToConnect - cachedENRsInGroup, 0);
|
|
275
|
-
this.custodyGroupQueries.set(group, groupPeersToConnect);
|
|
276
|
-
groupsToDiscover.add(group);
|
|
277
|
-
groupPeersToDiscover += groupPeersToConnect;
|
|
258
|
+
this.custodyGroupQueries.clear();
|
|
259
|
+
if (this.config.getForkSeq(this.clock.currentSlot) >= ForkSeq.fulu) {
|
|
260
|
+
for (const [group, count] of custodyGroupRequests) {
|
|
261
|
+
if (count > 0) this.custodyGroupQueries.set(group, count);
|
|
262
|
+
}
|
|
263
|
+
for (const cachedENR of cachedENRsReverse) {
|
|
264
|
+
if (this.custodyGroupQueries.size === 0) break;
|
|
265
|
+
if (this.consumeCustodyGroupRequests(cachedENR)) {
|
|
266
|
+
cachedENRsToDial.set(cachedENR.peerId.toString(), cachedENR);
|
|
278
267
|
}
|
|
279
268
|
}
|
|
280
269
|
}
|
|
270
|
+
const groupPeersToDiscover = Array.from(this.custodyGroupQueries.values()).reduce((sum, count) => sum + count, 0);
|
|
281
271
|
|
|
282
272
|
subnet: for (const subnetRequest of subnetRequests) {
|
|
283
273
|
// Get cached ENRs from the discovery service that are in the requested `subnetId`, but not connected yet
|
|
@@ -312,7 +302,7 @@ export class PeerDiscovery {
|
|
|
312
302
|
}
|
|
313
303
|
|
|
314
304
|
// If subnetRequests won't connect enough peers for peersToConnect, add more
|
|
315
|
-
if (cachedENRsToDial.size < peersToConnect) {
|
|
305
|
+
if (groupPeersToDiscover === 0 && cachedENRsToDial.size < peersToConnect) {
|
|
316
306
|
for (const cachedENR of cachedENRsReverse) {
|
|
317
307
|
cachedENRsToDial.set(cachedENR.peerId.toString(), cachedENR);
|
|
318
308
|
if (cachedENRsToDial.size >= peersToConnect) {
|
|
@@ -330,7 +320,8 @@ export class PeerDiscovery {
|
|
|
330
320
|
}
|
|
331
321
|
|
|
332
322
|
// Run a discv5 subnet query to try to discover new peers
|
|
333
|
-
const shouldRunFindRandomNodeQuery =
|
|
323
|
+
const shouldRunFindRandomNodeQuery =
|
|
324
|
+
groupPeersToDiscover > 0 || subnetsToDiscoverPeers.length > 0 || cachedENRsToDial.size < peersToConnect;
|
|
334
325
|
if (shouldRunFindRandomNodeQuery) {
|
|
335
326
|
void this.runFindRandomNodeQuery();
|
|
336
327
|
}
|
|
@@ -339,7 +330,7 @@ export class PeerDiscovery {
|
|
|
339
330
|
peersToConnect,
|
|
340
331
|
peersAvailableToDial: cachedENRsToDial.size,
|
|
341
332
|
subnetsToDiscover: subnetsToDiscoverPeers.length,
|
|
342
|
-
groupsToDiscover: Array.from(
|
|
333
|
+
groupsToDiscover: Array.from(this.custodyGroupQueries.keys()).join(","),
|
|
343
334
|
groupPeersToDiscover,
|
|
344
335
|
shouldRunFindRandomNodeQuery,
|
|
345
336
|
});
|
|
@@ -411,7 +402,14 @@ export class PeerDiscovery {
|
|
|
411
402
|
if (this.randomNodeQuery.code === QueryStatusCode.Active) {
|
|
412
403
|
this.randomNodeQuery.count++;
|
|
413
404
|
}
|
|
414
|
-
|
|
405
|
+
let peerId: PeerId;
|
|
406
|
+
try {
|
|
407
|
+
peerId = enr.peerId;
|
|
408
|
+
} catch (e) {
|
|
409
|
+
this.logger.debug("Discovered ENR with invalid public key", {nodeId: enr.nodeId}, e as Error);
|
|
410
|
+
this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.error});
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
415
413
|
// At least one transport is known to be present, checked inside the worker
|
|
416
414
|
const multiaddrTCP = enr.getLocationMultiaddr(ENRKey.tcp);
|
|
417
415
|
const multiaddrQUIC = enr.getLocationMultiaddr(ENRKey.quic);
|
|
@@ -530,32 +528,24 @@ export class PeerDiscovery {
|
|
|
530
528
|
}
|
|
531
529
|
}
|
|
532
530
|
|
|
533
|
-
private
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
// given SAMPLES_PER_SLOT = 8 and 100 peers, we have 800 custody columns from peers
|
|
539
|
-
// with NUMBER_OF_CUSTODY_GROUPS = 128, we have 800 / 128 = 6.25 peers per column in average
|
|
540
|
-
// it would not be hard to find TARGET_SUBNET_PEERS(6) peers per sampling columns columns and TARGET_GROUP_PEERS_PER_SUBNET(4) peers per non-sampling columns
|
|
541
|
-
// after some first heartbeats, we should have no more column requested, then go with conditions of prior forks
|
|
542
|
-
let hasMatchingGroup = false;
|
|
543
|
-
let custodyGroupRequestCount = 0;
|
|
544
|
-
for (const [group, peersToConnect] of this.custodyGroupQueries.entries()) {
|
|
545
|
-
if (peersToConnect <= 0) {
|
|
546
|
-
this.custodyGroupQueries.delete(group);
|
|
547
|
-
} else if (peer.custodyGroups.includes(group)) {
|
|
548
|
-
this.custodyGroupQueries.set(group, Math.max(0, peersToConnect - 1));
|
|
549
|
-
hasMatchingGroup = true;
|
|
550
|
-
custodyGroupRequestCount += peersToConnect;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
531
|
+
private consumeCustodyGroupRequests(peer: CachedENR): boolean {
|
|
532
|
+
let matched = false;
|
|
533
|
+
for (const group of peer.custodyGroups ?? []) {
|
|
534
|
+
const remaining = this.custodyGroupQueries.get(group);
|
|
535
|
+
if (remaining === undefined) continue;
|
|
553
536
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
537
|
+
if (remaining === 1) this.custodyGroupQueries.delete(group);
|
|
538
|
+
else this.custodyGroupQueries.set(group, remaining - 1);
|
|
539
|
+
matched = true;
|
|
540
|
+
}
|
|
541
|
+
return matched;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
private shouldDialPeer(peer: CachedENR): boolean {
|
|
545
|
+
const needsCustodyPeers = this.custodyGroupQueries.size > 0;
|
|
546
|
+
if (needsCustodyPeers && !this.consumeCustodyGroupRequests(peer)) {
|
|
547
|
+
this.metrics?.discovery.notDialReason.inc({reason: NotDialReason.not_contain_requested_sampling_groups});
|
|
548
|
+
return false;
|
|
559
549
|
}
|
|
560
550
|
|
|
561
551
|
// logics up to Deneb fork
|
|
@@ -580,7 +570,7 @@ export class PeerDiscovery {
|
|
|
580
570
|
// ideally we may want to leave this cheap condition at the top of the function
|
|
581
571
|
// however we want to also update peersToConnect in this.subnetRequests
|
|
582
572
|
// the this.subnetRequests[type] gradually has 0 subnet so this function should be cheap enough
|
|
583
|
-
if (this.peersToConnect > 0) {
|
|
573
|
+
if (needsCustodyPeers || this.peersToConnect > 0) {
|
|
584
574
|
return true;
|
|
585
575
|
}
|
|
586
576
|
|
|
@@ -85,8 +85,7 @@ export class PeerRpcScoreStore implements IPeerRpcScoreStore {
|
|
|
85
85
|
for (const [peerIdStr, peerScore] of this.scores) {
|
|
86
86
|
const newScore = peerScore.update();
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
if (Math.abs(newScore) < SCORE_THRESHOLD) {
|
|
88
|
+
if (Math.abs(newScore) < SCORE_THRESHOLD && !peerScore.isCoolingDown()) {
|
|
90
89
|
this.scores.delete(peerIdStr);
|
|
91
90
|
}
|
|
92
91
|
}
|
|
@@ -12,7 +12,11 @@ import {
|
|
|
12
12
|
isForkPostElectra,
|
|
13
13
|
isForkPostGloas,
|
|
14
14
|
} from "@lodestar/params";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
computeTimeAtSlot,
|
|
17
|
+
getBlockHeaderProposerSignatureSetByHeaderSlot,
|
|
18
|
+
signedBlockToSignedHeader,
|
|
19
|
+
} from "@lodestar/state-transition";
|
|
16
20
|
import {
|
|
17
21
|
Root,
|
|
18
22
|
RootHex,
|
|
@@ -25,6 +29,7 @@ import {
|
|
|
25
29
|
gloas,
|
|
26
30
|
isGloasBeaconBlock,
|
|
27
31
|
isGloasDataColumnSidecar,
|
|
32
|
+
phase0,
|
|
28
33
|
ssz,
|
|
29
34
|
sszTypesFor,
|
|
30
35
|
} from "@lodestar/types";
|
|
@@ -183,7 +188,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
183
188
|
blockRootHex: RootHex,
|
|
184
189
|
fork: ForkName,
|
|
185
190
|
peerIdStr: string,
|
|
186
|
-
seenTimestampSec: number
|
|
191
|
+
seenTimestampSec: number,
|
|
192
|
+
opts?: {unvalidated?: boolean}
|
|
187
193
|
): BlockInput {
|
|
188
194
|
const blockInput = chain.seenBlockInputCache.getByBlock({
|
|
189
195
|
block: signedBlock,
|
|
@@ -196,15 +202,18 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
196
202
|
// Also seed the payload-envelope cache, so we have PayloadEnvelopeInput even through "PARENT_BLOCK_UNKNOWN" error
|
|
197
203
|
// see https://github.com/ChainSafe/lodestar/issues/9475
|
|
198
204
|
if (isForkPostGloas(fork)) {
|
|
199
|
-
chain.seenPayloadEnvelopeInputCache.add(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
chain.seenPayloadEnvelopeInputCache.add(
|
|
206
|
+
{
|
|
207
|
+
blockRootHex,
|
|
208
|
+
block: signedBlock as SignedBeaconBlock<ForkPostGloas>,
|
|
209
|
+
forkName: fork,
|
|
210
|
+
sampledColumns: chain.custodyConfig.sampledColumns,
|
|
211
|
+
custodyColumns: chain.custodyConfig.custodyColumns,
|
|
212
|
+
seenTimestampSec,
|
|
213
|
+
source: PayloadEnvelopeInputSource.gossip,
|
|
214
|
+
},
|
|
215
|
+
opts
|
|
216
|
+
);
|
|
208
217
|
}
|
|
209
218
|
|
|
210
219
|
return blockInput;
|
|
@@ -300,7 +309,9 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
300
309
|
}
|
|
301
310
|
chain.seenBlockProposers.add(slot, proposerIndex, blockRootHex);
|
|
302
311
|
|
|
303
|
-
const blockInput = cacheSignatureVerifiedBlock(signedBlock, blockRootHex, fork, peerIdStr, seenTimestampSec
|
|
312
|
+
const blockInput = cacheSignatureVerifiedBlock(signedBlock, blockRootHex, fork, peerIdStr, seenTimestampSec, {
|
|
313
|
+
unvalidated: true,
|
|
314
|
+
});
|
|
304
315
|
chain.emitter.emit(ChainEvent.blockUnknownParent, {
|
|
305
316
|
blockInput,
|
|
306
317
|
peer: peerIdStr,
|
|
@@ -374,6 +385,28 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
374
385
|
}
|
|
375
386
|
}
|
|
376
387
|
|
|
388
|
+
// The block input may have been pruned before the block was imported
|
|
389
|
+
if (
|
|
390
|
+
chain.seenDataColumnSidecars.isKnown(
|
|
391
|
+
slot,
|
|
392
|
+
dataColumnBlockHeader.proposerIndex,
|
|
393
|
+
dataColumnSidecar.index,
|
|
394
|
+
blockRootHex
|
|
395
|
+
)
|
|
396
|
+
) {
|
|
397
|
+
metrics?.peerDas.dataColumnSidecarProcessingSkip.inc();
|
|
398
|
+
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
399
|
+
code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
|
|
400
|
+
columnIndex: dataColumnSidecar.index,
|
|
401
|
+
slot,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (isRepeatColumnProposal(chain, dataColumnSidecar, blockRootHex)) {
|
|
406
|
+
await observeRepeatColumnProposal(chain, dataColumnSidecar, blockRootHex);
|
|
407
|
+
throw repeatColumnProposalError(dataColumnSidecar, blockRootHex);
|
|
408
|
+
}
|
|
409
|
+
|
|
377
410
|
const verificationTimer = metrics?.peerDas.dataColumnSidecarGossipVerificationTime.startTimer();
|
|
378
411
|
|
|
379
412
|
const delaySec = chain.clock.secFromSlot(slot, seenTimestampSec);
|
|
@@ -382,6 +415,17 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
382
415
|
|
|
383
416
|
try {
|
|
384
417
|
await validateGossipFuluDataColumnSidecar(chain, dataColumnSidecar, gossipSubnet, metrics);
|
|
418
|
+
observeColumnBlockHeader(chain, dataColumnSidecar.signedBlockHeader, blockRootHex);
|
|
419
|
+
// Another block root may have been seen for the same tuple while validating
|
|
420
|
+
if (isRepeatColumnProposal(chain, dataColumnSidecar, blockRootHex)) {
|
|
421
|
+
throw repeatColumnProposalError(dataColumnSidecar, blockRootHex);
|
|
422
|
+
}
|
|
423
|
+
chain.seenDataColumnSidecars.add(
|
|
424
|
+
slot,
|
|
425
|
+
dataColumnBlockHeader.proposerIndex,
|
|
426
|
+
dataColumnSidecar.index,
|
|
427
|
+
blockRootHex
|
|
428
|
+
);
|
|
385
429
|
const blockInput = chain.seenBlockInputCache.getByColumn({
|
|
386
430
|
blockRootHex,
|
|
387
431
|
columnSidecar: dataColumnSidecar,
|
|
@@ -575,7 +619,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
575
619
|
const delaySec = seenTimestampSec - computeTimeAtSlot(config, slot, chain.genesisTime);
|
|
576
620
|
metrics?.gossipBlock.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
|
|
577
621
|
chain.validatorMonitor?.registerBeaconBlock(OpSource.gossip, delaySec, signedBlock.message);
|
|
578
|
-
|
|
622
|
+
const missingData = !blockInput.hasBlockAndAllData();
|
|
623
|
+
if (missingData) {
|
|
579
624
|
chain.logger.debug("Received gossip block, attempting fetch of unavailable data", blockInput.getLogMeta());
|
|
580
625
|
// The data is not yet fully available, immediately trigger an aggressive pull via unknown block sync
|
|
581
626
|
chain.emitter.emit(ChainEvent.incompleteBlockInput, {
|
|
@@ -668,8 +713,13 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
668
713
|
}
|
|
669
714
|
metrics?.gossipBlock.processBlockErrors.inc({error: e instanceof BlockError ? e.type.code : "NOT_BLOCK_ERROR"});
|
|
670
715
|
logger[logLevel]("Error processing block", {slot, root: blockInput.blockRootHex, peer: peerIdStr}, e as Error);
|
|
671
|
-
//
|
|
672
|
-
|
|
716
|
+
// BlockInputSync retries the import of a block with missing data from this same BlockInput, pruning it here
|
|
717
|
+
// would put later gossip columns into a new BlockInput that is never imported. The entry is released once the
|
|
718
|
+
// block is persisted, BlockInputSync removes it, on finalization or by the cache size limit
|
|
719
|
+
if (!missingData) {
|
|
720
|
+
// TODO(fulu): Revisit when we prune block inputs
|
|
721
|
+
chain.seenBlockInputCache.prune(blockInput.blockRootHex);
|
|
722
|
+
}
|
|
673
723
|
});
|
|
674
724
|
}
|
|
675
725
|
|
|
@@ -707,7 +757,12 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
707
757
|
e.type.code === BlockErrorCode.REPEAT_PROPOSAL &&
|
|
708
758
|
// Only a signature-verified sibling recorded in the seen cache is imported. The cache holds at most two
|
|
709
759
|
// roots per proposer and slot, which bounds full imports over gossip to one alternate
|
|
710
|
-
chain.seenBlockProposers.
|
|
760
|
+
chain.seenBlockProposers.hasBlockSignature(
|
|
761
|
+
signedBlock.message.slot,
|
|
762
|
+
e.type.proposerIndex,
|
|
763
|
+
e.type.root,
|
|
764
|
+
signedBlock.signature
|
|
765
|
+
) &&
|
|
711
766
|
// A sibling with an unknown parent cannot be imported, sync fetches it if its branch becomes relevant
|
|
712
767
|
chain.forkChoice.getBlockHexDefaultStatus(toRootHex(signedBlock.message.parentRoot)) !== null &&
|
|
713
768
|
(!isGloasBeaconBlock(signedBlock.message) ||
|
|
@@ -721,7 +776,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
721
776
|
e.type.root,
|
|
722
777
|
topic.boundary.fork,
|
|
723
778
|
peerIdStr,
|
|
724
|
-
seenTimestampSec
|
|
779
|
+
seenTimestampSec,
|
|
780
|
+
{unvalidated: false}
|
|
725
781
|
);
|
|
726
782
|
// We're returning IGNORE (thrown below), so this block is not forwarded to peers. Unlike the
|
|
727
783
|
// happy path there is no rush to forward, so we don't need to wrap in callInNextEventLoop.
|
|
@@ -1650,3 +1706,64 @@ function getCutoffTimeMs(
|
|
|
1650
1706
|
0
|
|
1651
1707
|
);
|
|
1652
1708
|
}
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* [IGNORE] The sidecar is the first sidecar for the tuple (block_header.slot, block_header.proposer_index, sidecar.index)
|
|
1712
|
+
* with valid header signature, sidecar inclusion proof, and kzg proof
|
|
1713
|
+
*/
|
|
1714
|
+
function isRepeatColumnProposal(
|
|
1715
|
+
chain: IBeaconChain,
|
|
1716
|
+
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
1717
|
+
blockRootHex: RootHex
|
|
1718
|
+
): boolean {
|
|
1719
|
+
const {slot, proposerIndex} = dataColumnSidecar.signedBlockHeader.message;
|
|
1720
|
+
return chain.seenDataColumnSidecars.isRepeatProposal(slot, proposerIndex, dataColumnSidecar.index, blockRootHex);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
function repeatColumnProposalError(
|
|
1724
|
+
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
1725
|
+
blockRootHex: RootHex
|
|
1726
|
+
): DataColumnSidecarGossipError {
|
|
1727
|
+
const {slot, proposerIndex} = dataColumnSidecar.signedBlockHeader.message;
|
|
1728
|
+
return new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
1729
|
+
code: DataColumnSidecarErrorCode.REPEAT_PROPOSAL,
|
|
1730
|
+
slot,
|
|
1731
|
+
proposerIndex,
|
|
1732
|
+
columnIndex: dataColumnSidecar.index,
|
|
1733
|
+
root: blockRootHex,
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
function observeColumnBlockHeader(
|
|
1738
|
+
chain: IBeaconChain,
|
|
1739
|
+
signedBlockHeader: phase0.SignedBeaconBlockHeader,
|
|
1740
|
+
blockRootHex: RootHex
|
|
1741
|
+
): void {
|
|
1742
|
+
const {slot, proposerIndex} = signedBlockHeader.message;
|
|
1743
|
+
chain.seenBlockProposers.observeBlockRoot(slot, proposerIndex, blockRootHex, signedBlockHeader);
|
|
1744
|
+
if (chain.seenBlockProposers.isEquivocating(slot, proposerIndex)) {
|
|
1745
|
+
chain.processProposerEquivocation(slot, proposerIndex);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
async function observeRepeatColumnProposal(
|
|
1750
|
+
chain: IBeaconChain,
|
|
1751
|
+
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
1752
|
+
blockRootHex: RootHex
|
|
1753
|
+
): Promise<void> {
|
|
1754
|
+
const {signedBlockHeader} = dataColumnSidecar;
|
|
1755
|
+
const {slot, proposerIndex} = signedBlockHeader.message;
|
|
1756
|
+
// Only needed as slashing evidence, so verify at most one conflicting header per slot and proposer
|
|
1757
|
+
if (
|
|
1758
|
+
chain.seenBlockProposers.hasBlockRoot(slot, proposerIndex, blockRootHex) ||
|
|
1759
|
+
chain.seenBlockProposers.isEquivocating(slot, proposerIndex) ||
|
|
1760
|
+
!chain.seenDataColumnSidecars.markEvidenceCheck(slot, proposerIndex)
|
|
1761
|
+
) {
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(chain.config, signedBlockHeader);
|
|
1766
|
+
if (await chain.bls.verifySignatureSets([signatureSet])) {
|
|
1767
|
+
observeColumnBlockHeader(chain, signedBlockHeader, blockRootHex);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
@@ -226,5 +226,8 @@ export function validateDataColumnSidecarsByRangeRequest(
|
|
|
226
226
|
count = config.MAX_REQUEST_BLOCKS_DENEB;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
// Spec: sidecars MUST be sent in (slot, column_index) order, so serve each requested column once, ascending
|
|
230
|
+
const sortedColumns = Array.from(new Set(columns)).sort((a, b) => a - b);
|
|
231
|
+
|
|
232
|
+
return {startSlot, count, columns: sortedColumns};
|
|
230
233
|
}
|
package/src/sync/range/chain.ts
CHANGED
|
@@ -627,6 +627,7 @@ export class SyncChain {
|
|
|
627
627
|
case DownloadByRangeErrorCode.INVALID_ENVELOPE_BLOCK_HASH:
|
|
628
628
|
case DownloadByRangeErrorCode.INVALID_ENVELOPE_SLOT:
|
|
629
629
|
case DownloadByRangeErrorCode.INVALID_CHAIN_SEGMENT:
|
|
630
|
+
case DownloadByRangeErrorCode.TOO_MANY_KZG_COMMITMENTS:
|
|
630
631
|
case DataColumnSidecarErrorCode.INCORRECT_KZG_COMMITMENTS_COUNT:
|
|
631
632
|
case DataColumnSidecarErrorCode.INCORRECT_KZG_PROOF_COUNT:
|
|
632
633
|
case DataColumnSidecarErrorCode.INVALID_KZG_PROOF_BATCH:
|
package/src/sync/range/range.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {EventEmitter} from "node:events";
|
|
2
2
|
import {StrictEventEmitter} from "strict-event-emitter-types";
|
|
3
3
|
import {BeaconConfig} from "@lodestar/config";
|
|
4
|
+
import {isForkPostGloas} from "@lodestar/params";
|
|
4
5
|
import {IBeaconStateViewGloas, computeStartSlotAtEpoch, isStatePostGloas} from "@lodestar/state-transition";
|
|
5
6
|
import {Epoch, Status, fulu, ssz} from "@lodestar/types";
|
|
6
7
|
import {Logger, byteArrayEquals, prettyPrintIndices, toHex, toRootHex} from "@lodestar/utils";
|
|
@@ -434,7 +435,12 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
|
|
|
434
435
|
// the batch then downloads the head's payload as dangling parent and validates it against the bid
|
|
435
436
|
const headState = this.chain.getHeadState();
|
|
436
437
|
let parentPayload: ParentPayload | undefined;
|
|
437
|
-
|
|
438
|
+
// A pre-Gloas head block in a state upgraded to Gloas carried its own payload, no envelope follows it
|
|
439
|
+
if (
|
|
440
|
+
isStatePostGloas(headState) &&
|
|
441
|
+
headState.latestBlockHeader.slot > 0 &&
|
|
442
|
+
isForkPostGloas(this.config.getForkName(headState.latestBlockHeader.slot))
|
|
443
|
+
) {
|
|
438
444
|
const header = ssz.phase0.BeaconBlockHeader.clone(headState.latestBlockHeader);
|
|
439
445
|
if (byteArrayEquals(header.stateRoot, ssz.Root.defaultValue())) {
|
|
440
446
|
header.stateRoot = headState.hashTreeRoot();
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -928,6 +928,19 @@ export class BlockInputSync {
|
|
|
928
928
|
const connectedPeers = this.network.getConnectedPeers();
|
|
929
929
|
const hasConnectedPeers = connectedPeers.length > 0;
|
|
930
930
|
|
|
931
|
+
// Gossip, getBlobs or column reconstruction can complete a pending block's data through the shared BlockInput.
|
|
932
|
+
// With only half the columns the block stays pending, its fetch asks a peer for the rest before reconstructing
|
|
933
|
+
for (const block of this.pendingBlocks.values()) {
|
|
934
|
+
if (
|
|
935
|
+
isPendingBlockInput(block) &&
|
|
936
|
+
block.status === PendingBlockInputStatus.pending &&
|
|
937
|
+
block.blockInput.hasBlockAndAllData() &&
|
|
938
|
+
(!isBlockInputColumns(block.blockInput) || block.blockInput.hasComputedAllData())
|
|
939
|
+
) {
|
|
940
|
+
block.status = PendingBlockInputStatus.downloaded;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
931
944
|
const {unknowns, ancestors} = getUnknownAndAncestorBlocks(this.pendingBlocks);
|
|
932
945
|
let processedBlocks = 0;
|
|
933
946
|
let shouldRerunBlockSearch = false;
|
|
@@ -2201,7 +2214,13 @@ export class BlockInputSync {
|
|
|
2201
2214
|
const cacheItemRootHex = getBlockInputSyncCacheItemRootHex(cacheItem);
|
|
2202
2215
|
// pruning may have dropped it mid-fetch
|
|
2203
2216
|
if (this.pendingBlocks.has(cacheItemRootHex)) {
|
|
2204
|
-
|
|
2217
|
+
// A partial download stays fetching while the next peer is asked, a pending entry would be fetched again
|
|
2218
|
+
this.pendingBlocks.set(
|
|
2219
|
+
cacheItemRootHex,
|
|
2220
|
+
cacheItem.status === PendingBlockInputStatus.pending
|
|
2221
|
+
? {...cacheItem, status: PendingBlockInputStatus.fetching}
|
|
2222
|
+
: cacheItem
|
|
2223
|
+
);
|
|
2205
2224
|
}
|
|
2206
2225
|
|
|
2207
2226
|
if (cacheItem.status === PendingBlockInputStatus.downloaded) {
|