@lodestar/beacon-node 1.33.0-peerDAS.e03bda542e → 1.33.0-rc.0
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.js +26 -66
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts +1 -1
- package/lib/api/impl/debug/index.js +1 -24
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +1 -1
- package/lib/chain/archiveStore/archiveStore.js +2 -2
- package/lib/chain/archiveStore/interface.d.ts +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +23 -88
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/beaconProposerCache.d.ts +0 -1
- package/lib/chain/beaconProposerCache.js +0 -3
- package/lib/chain/beaconProposerCache.js.map +1 -1
- package/lib/chain/blocks/importBlock.js +3 -8
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +24 -67
- package/lib/chain/blocks/types.js +6 -40
- package/lib/chain/blocks/types.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.js +10 -21
- package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.js +15 -89
- package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
- package/lib/chain/chain.d.ts +5 -16
- package/lib/chain/chain.js +6 -34
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +2 -18
- package/lib/chain/emitter.js +0 -13
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/index.d.ts +0 -1
- package/lib/chain/errors/index.js +0 -1
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/interface.d.ts +4 -10
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/options.d.ts +1 -4
- package/lib/chain/options.js +1 -5
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.js +1 -1
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +2 -4
- package/lib/chain/produceBlock/produceBlockBody.js +2 -7
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.d.ts +2 -3
- package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.js +2 -25
- package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts +18 -64
- package/lib/chain/seenCache/seenGossipBlockInput.js +53 -321
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/constants/network.d.ts +1 -0
- package/lib/constants/network.js +2 -0
- package/lib/constants/network.js.map +1 -1
- package/lib/db/beacon.d.ts +1 -3
- package/lib/db/beacon.js +1 -3
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +1 -3
- package/lib/db/buckets.js +0 -2
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +1 -3
- package/lib/db/repositories/index.d.ts +0 -2
- package/lib/db/repositories/index.js +0 -2
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/execution/engine/http.d.ts +3 -5
- package/lib/execution/engine/http.js +31 -70
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +2 -4
- package/lib/execution/engine/interface.js +1 -1
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/mock.d.ts +0 -1
- package/lib/execution/engine/mock.js +0 -5
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/types.d.ts +0 -10
- package/lib/execution/engine/types.js +0 -6
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +1 -15
- package/lib/metrics/metrics/beacon.js +1 -58
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -23
- package/lib/metrics/metrics/lodestar.js +0 -39
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/metrics.d.ts +3 -10
- package/lib/network/core/metrics.js +4 -22
- package/lib/network/core/metrics.js.map +1 -1
- package/lib/network/core/networkCore.d.ts +3 -8
- package/lib/network/core/networkCore.js +10 -24
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorker.js +0 -1
- package/lib/network/core/networkCoreWorker.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -4
- package/lib/network/core/networkCoreWorkerHandler.js +0 -4
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/core/types.d.ts +4 -6
- package/lib/network/events.d.ts +2 -4
- package/lib/network/events.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +1 -8
- package/lib/network/gossip/interface.js +0 -1
- package/lib/network/gossip/interface.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1497 -1513
- package/lib/network/gossip/topic.js +1 -20
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/interface.d.ts +1 -13
- package/lib/network/metadata.d.ts +5 -9
- package/lib/network/metadata.js +5 -25
- package/lib/network/metadata.js.map +1 -1
- package/lib/network/network.d.ts +2 -12
- package/lib/network/network.js +8 -59
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.js +0 -5
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/discover.d.ts +5 -9
- package/lib/network/peers/discover.js +23 -108
- package/lib/network/peers/discover.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts +4 -10
- package/lib/network/peers/peerManager.js +46 -101
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/peersData.d.ts +3 -17
- package/lib/network/peers/peersData.js.map +1 -1
- package/lib/network/peers/score/constants.d.ts +3 -1
- package/lib/network/peers/score/constants.js +3 -1
- package/lib/network/peers/score/constants.js.map +1 -1
- package/lib/network/peers/score/interface.d.ts +6 -1
- package/lib/network/peers/score/interface.js.map +1 -1
- package/lib/network/peers/score/score.d.ts +7 -2
- package/lib/network/peers/score/score.js +35 -5
- package/lib/network/peers/score/score.js.map +1 -1
- package/lib/network/peers/score/store.d.ts +10 -3
- package/lib/network/peers/score/store.js +15 -6
- package/lib/network/peers/score/store.js.map +1 -1
- package/lib/network/peers/utils/assertPeerRelevance.d.ts +3 -7
- package/lib/network/peers/utils/assertPeerRelevance.js +1 -10
- package/lib/network/peers/utils/assertPeerRelevance.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +7 -18
- package/lib/network/peers/utils/prioritizePeers.js +7 -43
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/network/processor/extractSlotRootFns.js +1 -8
- package/lib/network/processor/extractSlotRootFns.js.map +1 -1
- package/lib/network/processor/gossipHandlers.js +9 -156
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/index.js +0 -5
- package/lib/network/processor/gossipQueues/index.js.map +1 -1
- package/lib/network/processor/index.js +0 -1
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts +2 -2
- package/lib/network/reqresp/ReqRespBeaconNode.js +10 -33
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.d.ts +5 -16
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js +14 -204
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js.map +1 -1
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.d.ts +6 -32
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js +28 -283
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/index.js +0 -10
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/handlers/status.js +2 -3
- package/lib/network/reqresp/handlers/status.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts +0 -4
- package/lib/network/reqresp/protocols.js +0 -20
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/rateLimit.js +1 -11
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +8 -15
- package/lib/network/reqresp/types.js +3 -10
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/network/statusCache.d.ts +5 -5
- package/lib/network/statusCache.js.map +1 -1
- package/lib/network/subnets/interface.d.ts +0 -3
- package/lib/network/subnets/interface.js +1 -14
- package/lib/network/subnets/interface.js.map +1 -1
- package/lib/network/subnets/syncnetsService.js +5 -4
- package/lib/network/subnets/syncnetsService.js.map +1 -1
- package/lib/node/nodejs.js +0 -1
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/constants.d.ts +1 -1
- package/lib/sync/constants.js +1 -4
- package/lib/sync/constants.js.map +1 -1
- package/lib/sync/interface.d.ts +2 -2
- package/lib/sync/interface.js +1 -1
- package/lib/sync/interface.js.map +1 -1
- package/lib/sync/range/batch.d.ts +2 -16
- package/lib/sync/range/batch.js +7 -38
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +1 -16
- package/lib/sync/range/chain.js +30 -110
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts +2 -3
- package/lib/sync/range/range.js +3 -9
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/chainTarget.d.ts +1 -5
- package/lib/sync/range/utils/chainTarget.js +1 -26
- package/lib/sync/range/utils/chainTarget.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts +5 -12
- package/lib/sync/range/utils/peerBalancer.js +10 -69
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +1 -8
- package/lib/sync/unknownBlock.js +69 -226
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/remoteSyncType.d.ts +4 -4
- package/lib/sync/utils/remoteSyncType.js.map +1 -1
- package/lib/util/blobs.d.ts +1 -18
- package/lib/util/blobs.js +1 -104
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/metadata.d.ts +0 -4
- package/lib/util/metadata.js +0 -7
- package/lib/util/metadata.js.map +1 -1
- package/lib/util/sszBytes.d.ts +0 -1
- package/lib/util/sszBytes.js +0 -17
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +14 -14
- package/lib/chain/errors/dataColumnSidecarError.d.ts +0 -69
- package/lib/chain/errors/dataColumnSidecarError.js +0 -21
- package/lib/chain/errors/dataColumnSidecarError.js.map +0 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +0 -28
- package/lib/chain/validation/dataColumnSidecar.js +0 -248
- package/lib/chain/validation/dataColumnSidecar.js.map +0 -1
- package/lib/db/repositories/dataColumnSidecars.d.ts +0 -47
- package/lib/db/repositories/dataColumnSidecars.js +0 -40
- package/lib/db/repositories/dataColumnSidecars.js.map +0 -1
- package/lib/db/repositories/dataColumnSidecarsArchive.d.ts +0 -15
- package/lib/db/repositories/dataColumnSidecarsArchive.js +0 -23
- package/lib/db/repositories/dataColumnSidecarsArchive.js.map +0 -1
- package/lib/network/networkConfig.d.ts +0 -22
- package/lib/network/networkConfig.js +0 -29
- package/lib/network/networkConfig.js.map +0 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +0 -8
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +0 -106
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +0 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +0 -6
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +0 -57
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +0 -1
- package/lib/util/dataColumns.d.ts +0 -132
- package/lib/util/dataColumns.js +0 -353
- package/lib/util/dataColumns.js.map +0 -1
|
@@ -6,11 +6,9 @@ import { BatchStatus } from "../batch.js";
|
|
|
6
6
|
* Shuffles peers only once on instantiation
|
|
7
7
|
*/
|
|
8
8
|
export class ChainPeersBalancer {
|
|
9
|
-
|
|
10
|
-
constructor(peers, batches, custodyConfig) {
|
|
9
|
+
constructor(peers, batches) {
|
|
11
10
|
this.activeRequestsByPeer = new Map();
|
|
12
11
|
this.peers = shuffle(peers);
|
|
13
|
-
this.custodyConfig = custodyConfig;
|
|
14
12
|
// Compute activeRequestsByPeer from all batches internal states
|
|
15
13
|
for (const batch of batches) {
|
|
16
14
|
if (batch.state.status === BatchStatus.Downloading) {
|
|
@@ -23,77 +21,20 @@ export class ChainPeersBalancer {
|
|
|
23
21
|
* Sort peers by (1) no failed request (2) less active requests, then pick first
|
|
24
22
|
*/
|
|
25
23
|
bestPeerToRetryBatch(batch) {
|
|
26
|
-
if (batch.state.status !== BatchStatus.AwaitingDownload) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const { partialDownload } = batch.state;
|
|
30
|
-
const pendingDataColumns = partialDownload?.pendingDataColumns ?? this.custodyConfig.sampledColumns;
|
|
31
|
-
const eligiblePeers = this.filterPeers(batch, pendingDataColumns, false);
|
|
32
24
|
const failedPeers = new Set(batch.getFailedPeers());
|
|
33
|
-
const sortedBestPeers = sortBy(
|
|
34
|
-
(
|
|
35
|
-
({ hasEarliestAvailableSlots }) => (hasEarliestAvailableSlots ? 0 : 1), // prefer peers with earliestAvailableSlots defined
|
|
36
|
-
({ columns }) => -1 * columns // prefer peers with the most columns
|
|
25
|
+
const sortedBestPeers = sortBy(this.peers, (peer) => (failedPeers.has(peer) ? 1 : 0), // Sort by no failed first = 0
|
|
26
|
+
(peer) => this.activeRequestsByPeer.get(peer) ?? 0 // Sort by least active req
|
|
37
27
|
);
|
|
38
|
-
return sortedBestPeers
|
|
28
|
+
return sortedBestPeers[0];
|
|
39
29
|
}
|
|
40
30
|
/**
|
|
41
|
-
* Return peers with 0 or no active requests
|
|
31
|
+
* Return peers with 0 or no active requests
|
|
42
32
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const sortedBestPeers = sortBy(eligiblePeers, ({ hasEarliestAvailableSlots }) => (hasEarliestAvailableSlots ? 0 : 1), // prefer peers with earliestAvailableSlots defined
|
|
49
|
-
({ columns }) => -1 * columns // prefer peers with most columns we need
|
|
50
|
-
);
|
|
51
|
-
const bestPeer = sortedBestPeers[0];
|
|
52
|
-
if (bestPeer != null) {
|
|
53
|
-
// we will use this peer for batch in SyncChain right after this call
|
|
54
|
-
this.activeRequestsByPeer.set(bestPeer.syncInfo.peerId, 1);
|
|
55
|
-
return bestPeer.syncInfo;
|
|
56
|
-
}
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
filterPeers(batch, requestColumns, checkActiveRequest) {
|
|
60
|
-
const eligiblePeers = [];
|
|
61
|
-
for (const peer of this.peers) {
|
|
62
|
-
const { earliestAvailableSlot, custodyGroups, target, peerId } = peer;
|
|
63
|
-
const activeRequest = this.activeRequestsByPeer.get(peerId) ?? 0;
|
|
64
|
-
if (checkActiveRequest && activeRequest > 0) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (target.slot < batch.request.startSlot) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (!batch.isFulu()) {
|
|
71
|
-
// pre-fulu logic, we don't care columns and earliestAvailableSlot
|
|
72
|
-
eligiblePeers.push({ syncInfo: peer, columns: 0, hasEarliestAvailableSlots: false });
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
// for devnet, we optimistically assume peers without earliestAvailableSlot, but don't prioritize them
|
|
76
|
-
// TODO(fulu): consider do not accept these peers
|
|
77
|
-
const earliestSlot = earliestAvailableSlot ?? 0;
|
|
78
|
-
const peerColumns = custodyGroups;
|
|
79
|
-
if (earliestSlot > batch.request.startSlot) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
const columns = peerColumns.reduce((acc, elem) => {
|
|
83
|
-
if (requestColumns.includes(elem)) {
|
|
84
|
-
acc.push(elem);
|
|
85
|
-
}
|
|
86
|
-
return acc;
|
|
87
|
-
}, []);
|
|
88
|
-
if (columns.length > 0) {
|
|
89
|
-
eligiblePeers.push({
|
|
90
|
-
syncInfo: peer,
|
|
91
|
-
columns: columns.length,
|
|
92
|
-
hasEarliestAvailableSlots: earliestAvailableSlot != null,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return eligiblePeers;
|
|
33
|
+
idlePeers() {
|
|
34
|
+
return this.peers.filter((peer) => {
|
|
35
|
+
const activeRequests = this.activeRequestsByPeer.get(peer);
|
|
36
|
+
return activeRequests === undefined || activeRequests === 0;
|
|
37
|
+
});
|
|
97
38
|
}
|
|
98
39
|
}
|
|
99
40
|
//# sourceMappingURL=peerBalancer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peerBalancer.js","sourceRoot":"","sources":["../../../../src/sync/range/utils/peerBalancer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"peerBalancer.js","sourceRoot":"","sources":["../../../../src/sync/range/utils/peerBalancer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAQ,WAAW,EAAC,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAI7B,YAAY,KAAkB,EAAE,OAAgB;QAFxC,yBAAoB,GAAG,IAAI,GAAG,EAAqB,CAAC;QAG1D,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAE5B,gEAAgE;QAChE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;gBACnD,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9G,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,oBAAoB,CAAC,KAAY;QAC/B,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,MAAM,CAC5B,IAAI,CAAC,KAAK,EACV,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,8BAA8B;QACzE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,2BAA2B;SAC/E,CAAC;QACF,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YAChC,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC3D,OAAO,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -58,19 +58,12 @@ export declare class UnknownBlockSync {
|
|
|
58
58
|
*/
|
|
59
59
|
private processBlock;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* - fetch the block
|
|
63
|
-
* - from deneb, fetch all missing blobs
|
|
64
|
-
* - from peerDAS, fetch sampled colmns
|
|
65
|
-
* TODO: this means we only have block root, and nothing else. Consider to reflect this in the function name
|
|
61
|
+
* Fetches the parent of a block by root from a set of shuffled peers.
|
|
66
62
|
* Will attempt a max of `MAX_ATTEMPTS_PER_BLOCK` on different peers if connectPeers.length > MAX_ATTEMPTS_PER_BLOCK.
|
|
67
63
|
* Also verifies the received block root + returns the peer that provided the block for future downscoring.
|
|
68
64
|
*/
|
|
69
65
|
private fetchUnknownBlockRoot;
|
|
70
66
|
/**
|
|
71
|
-
* We have partial block input:
|
|
72
|
-
* - we have block but not have all blobs (deneb) or needed columns (fulu)
|
|
73
|
-
* - we don't have block and have some blobs (deneb) or some columns (fulu)
|
|
74
67
|
* Fetches missing blobs for the blockinput, in future can also pull block is thats also missing
|
|
75
68
|
* along with the blobs (i.e. only some blobs are available)
|
|
76
69
|
*/
|
package/lib/sync/unknownBlock.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ForkName, INTERVALS_PER_SLOT, NUMBER_OF_COLUMNS } from "@lodestar/params";
|
|
1
|
+
import { INTERVALS_PER_SLOT } from "@lodestar/params";
|
|
3
2
|
import { fromHex, pruneSetToMax, toRootHex } from "@lodestar/utils";
|
|
4
3
|
import { sleep } from "@lodestar/utils";
|
|
5
4
|
import { BlockInputType } from "../chain/blocks/types.js";
|
|
6
5
|
import { BlockError, BlockErrorCode } from "../chain/errors/index.js";
|
|
7
|
-
import { NetworkEvent } from "../network/index.js";
|
|
6
|
+
import { NetworkEvent, PeerAction } from "../network/index.js";
|
|
8
7
|
import { beaconBlocksMaybeBlobsByRoot, unavailableBeaconBlobsByRoot, } from "../network/reqresp/beaconBlocksMaybeBlobsByRoot.js";
|
|
9
8
|
import { byteArrayEquals } from "../util/bytes.js";
|
|
10
9
|
import { shuffle } from "../util/shuffle.js";
|
|
@@ -194,8 +193,8 @@ export class UnknownBlockSync {
|
|
|
194
193
|
else {
|
|
195
194
|
if (blockInputOrRootHex.block !== null) {
|
|
196
195
|
const { block } = blockInputOrRootHex;
|
|
197
|
-
blockRootHex =
|
|
198
|
-
unknownBlockType = PendingBlockType.
|
|
196
|
+
blockRootHex = toRootHex(this.config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message));
|
|
197
|
+
unknownBlockType = PendingBlockType.UNKNOWN_BLOBS;
|
|
199
198
|
}
|
|
200
199
|
else {
|
|
201
200
|
unknownBlockType = PendingBlockType.UNKNOWN_BLOCKINPUT;
|
|
@@ -231,70 +230,23 @@ export class UnknownBlockSync {
|
|
|
231
230
|
}
|
|
232
231
|
return unknownBlockType;
|
|
233
232
|
}
|
|
234
|
-
async downloadBlock(block,
|
|
233
|
+
async downloadBlock(block, connectedPeers) {
|
|
235
234
|
if (block.status !== PendingBlockStatus.pending) {
|
|
236
235
|
return;
|
|
237
236
|
}
|
|
238
237
|
const unknownBlockType = block.unknownBlockType;
|
|
239
|
-
|
|
238
|
+
this.logger.verbose("Downloading unknown block", {
|
|
240
239
|
root: block.blockRootHex,
|
|
241
240
|
pendingBlocks: this.pendingBlocks.size,
|
|
242
241
|
slot: block.blockInput?.block?.message.slot ?? "unknown",
|
|
243
242
|
unknownBlockType,
|
|
244
|
-
};
|
|
245
|
-
this.logger.verbose("Downloading unknown block", logCtx);
|
|
243
|
+
});
|
|
246
244
|
block.status = PendingBlockStatus.fetching;
|
|
247
245
|
let res;
|
|
248
|
-
let connectedPeers;
|
|
249
246
|
if (block.blockInput === null) {
|
|
250
|
-
|
|
251
|
-
// we only have block root, and nothing else
|
|
252
|
-
res = await wrapError(this.fetchUnknownBlockRoot(fromHexString(block.blockRootHex), connectedPeers));
|
|
247
|
+
res = await wrapError(this.fetchUnknownBlockRoot(fromHex(block.blockRootHex), connectedPeers));
|
|
253
248
|
}
|
|
254
249
|
else {
|
|
255
|
-
const { cachedData } = block.blockInput;
|
|
256
|
-
if (cachedData.fork === ForkName.fulu) {
|
|
257
|
-
const { dataColumnsCache } = cachedData;
|
|
258
|
-
const sampledColumns = this.network.custodyConfig.sampledColumns;
|
|
259
|
-
const neededColumns = sampledColumns.reduce((acc, elem) => {
|
|
260
|
-
if (dataColumnsCache.get(elem) === undefined) {
|
|
261
|
-
acc.push(elem);
|
|
262
|
-
}
|
|
263
|
-
return acc;
|
|
264
|
-
}, []);
|
|
265
|
-
connectedPeers =
|
|
266
|
-
neededColumns.length <= 0
|
|
267
|
-
? allPeers
|
|
268
|
-
: allPeers.filter((peer) => {
|
|
269
|
-
const { custodyGroups: peerColumns } = this.network.getConnectedPeerSyncMeta(peer);
|
|
270
|
-
const columns = peerColumns.reduce((acc, elem) => {
|
|
271
|
-
if (neededColumns.includes(elem)) {
|
|
272
|
-
acc.push(elem);
|
|
273
|
-
}
|
|
274
|
-
return acc;
|
|
275
|
-
}, []);
|
|
276
|
-
return columns.length > 0;
|
|
277
|
-
});
|
|
278
|
-
if (connectedPeers.length > 0) {
|
|
279
|
-
this.logger.debug("Filtered peers to those having relevant columns for downloading data", {
|
|
280
|
-
...logCtx,
|
|
281
|
-
allPeers: allPeers.length,
|
|
282
|
-
connectedPeers: connectedPeers.length,
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
this.logger.debug("Skipping download as no filtered peers having relevant data", {
|
|
287
|
-
...logCtx,
|
|
288
|
-
allPeers: allPeers.length,
|
|
289
|
-
connectedPeers: connectedPeers.length,
|
|
290
|
-
neededColumns: neededColumns.join(" "),
|
|
291
|
-
});
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
connectedPeers = allPeers;
|
|
297
|
-
}
|
|
298
250
|
res = await wrapError(this.fetchUnavailableBlockInput(block.blockInput, connectedPeers));
|
|
299
251
|
}
|
|
300
252
|
if (res.err)
|
|
@@ -303,73 +255,48 @@ export class UnknownBlockSync {
|
|
|
303
255
|
this.metrics?.syncUnknownBlock.downloadedBlocksSuccess.inc();
|
|
304
256
|
if (!res.err) {
|
|
305
257
|
const { blockInput, peerIdStr } = res.result;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
258
|
+
block = {
|
|
259
|
+
...block,
|
|
260
|
+
status: PendingBlockStatus.downloaded,
|
|
261
|
+
blockInput,
|
|
262
|
+
parentBlockRootHex: toRootHex(blockInput.block.message.parentRoot),
|
|
263
|
+
};
|
|
264
|
+
this.pendingBlocks.set(block.blockRootHex, block);
|
|
265
|
+
const blockSlot = blockInput.block.message.slot;
|
|
266
|
+
const finalizedSlot = this.chain.forkChoice.getFinalizedBlock().slot;
|
|
267
|
+
const delaySec = Date.now() / 1000 - (this.chain.genesisTime + blockSlot * this.config.SECONDS_PER_SLOT);
|
|
268
|
+
this.metrics?.syncUnknownBlock.elapsedTimeTillReceived.observe(delaySec);
|
|
269
|
+
const parentInForkchoice = this.chain.forkChoice.hasBlock(blockInput.block.message.parentRoot);
|
|
270
|
+
this.logger.verbose("Downloaded unknown block", {
|
|
271
|
+
root: block.blockRootHex,
|
|
272
|
+
pendingBlocks: this.pendingBlocks.size,
|
|
273
|
+
parentInForkchoice,
|
|
274
|
+
blockInputType: blockInput.type,
|
|
275
|
+
unknownBlockType,
|
|
276
|
+
});
|
|
277
|
+
if (parentInForkchoice) {
|
|
278
|
+
// Bingo! Process block. Add to pending blocks anyway for recycle the cache that prevents duplicate processing
|
|
279
|
+
this.processBlock(block).catch((e) => {
|
|
280
|
+
this.logger.debug("Unexpected error - process newly downloaded block", {}, e);
|
|
281
|
+
});
|
|
328
282
|
}
|
|
329
|
-
else {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
this.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
this.metrics?.syncUnknownBlock.elapsedTimeTillReceived.observe(delaySec);
|
|
341
|
-
const parentInForkchoice = this.chain.forkChoice.hasBlock(blockInput.block.message.parentRoot);
|
|
342
|
-
this.logger.verbose("Downloaded unknown block", {
|
|
343
|
-
root: block.blockRootHex,
|
|
344
|
-
pendingBlocks: this.pendingBlocks.size,
|
|
345
|
-
parentInForkchoice,
|
|
346
|
-
blockInputType: blockInput.type,
|
|
283
|
+
else if (blockSlot <= finalizedSlot) {
|
|
284
|
+
// the common ancestor of the downloading chain and canonical chain should be at least the finalized slot and
|
|
285
|
+
// we should found it through forkchoice. If not, we should penalize all peers sending us this block chain
|
|
286
|
+
// 0 - 1 - ... - n - finalizedSlot
|
|
287
|
+
// \
|
|
288
|
+
// parent 1 - parent 2 - ... - unknownParent block
|
|
289
|
+
const blockRoot = this.config.getForkTypes(blockSlot).BeaconBlock.hashTreeRoot(blockInput.block.message);
|
|
290
|
+
this.logger.debug("Downloaded block is before finalized slot", {
|
|
291
|
+
finalizedSlot,
|
|
292
|
+
blockSlot,
|
|
293
|
+
parentRoot: toRootHex(blockRoot),
|
|
347
294
|
unknownBlockType,
|
|
348
295
|
});
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
else if (blockSlot <= finalizedSlot) {
|
|
356
|
-
// the common ancestor of the downloading chain and canonical chain should be at least the finalized slot and
|
|
357
|
-
// we should found it through forkchoice. If not, we should penalize all peers sending us this block chain
|
|
358
|
-
// 0 - 1 - ... - n - finalizedSlot
|
|
359
|
-
// \
|
|
360
|
-
// parent 1 - parent 2 - ... - unknownParent block
|
|
361
|
-
const blockRoot = this.config.getForkTypes(blockSlot).BeaconBlock.hashTreeRoot(blockInput.block.message);
|
|
362
|
-
this.logger.debug("Downloaded block is before finalized slot", {
|
|
363
|
-
finalizedSlot,
|
|
364
|
-
blockSlot,
|
|
365
|
-
parentRoot: toHexString(blockRoot),
|
|
366
|
-
unknownBlockType,
|
|
367
|
-
});
|
|
368
|
-
this.removeAndDownscoreAllDescendants(block);
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
this.onUnknownParent({ blockInput, peer: peerIdStr });
|
|
372
|
-
}
|
|
296
|
+
this.removeAndDownscoreAllDescendants(block);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
this.onUnknownParent({ blockInput, peer: peerIdStr });
|
|
373
300
|
}
|
|
374
301
|
}
|
|
375
302
|
else {
|
|
@@ -476,11 +403,7 @@ export class UnknownBlockSync {
|
|
|
476
403
|
}
|
|
477
404
|
}
|
|
478
405
|
/**
|
|
479
|
-
*
|
|
480
|
-
* - fetch the block
|
|
481
|
-
* - from deneb, fetch all missing blobs
|
|
482
|
-
* - from peerDAS, fetch sampled colmns
|
|
483
|
-
* TODO: this means we only have block root, and nothing else. Consider to reflect this in the function name
|
|
406
|
+
* Fetches the parent of a block by root from a set of shuffled peers.
|
|
484
407
|
* Will attempt a max of `MAX_ATTEMPTS_PER_BLOCK` on different peers if connectPeers.length > MAX_ATTEMPTS_PER_BLOCK.
|
|
485
408
|
* Also verifies the received block root + returns the peer that provided the block for future downscoring.
|
|
486
409
|
*/
|
|
@@ -488,58 +411,24 @@ export class UnknownBlockSync {
|
|
|
488
411
|
const shuffledPeers = shuffle(connectedPeers);
|
|
489
412
|
const blockRootHex = toRootHex(blockRoot);
|
|
490
413
|
let lastError = null;
|
|
491
|
-
let partialDownload = null;
|
|
492
|
-
let fetchedPeerId = null;
|
|
493
414
|
for (let i = 0; i < MAX_ATTEMPTS_PER_BLOCK; i++) {
|
|
494
|
-
const
|
|
495
|
-
const { custodyGroups: peerColumns, client: peerClient } = this.network.getConnectedPeerSyncMeta(peerId);
|
|
496
|
-
if (partialDownload !== null) {
|
|
497
|
-
const [prevBlockInput] = partialDownload.blocks;
|
|
498
|
-
if (prevBlockInput === undefined || prevBlockInput.type !== BlockInputType.dataPromise) {
|
|
499
|
-
throw Error(`prevBlockInput=${prevBlockInput?.type} in partialDownload`);
|
|
500
|
-
}
|
|
501
|
-
const { cachedData } = prevBlockInput;
|
|
502
|
-
if (cachedData.fork === ForkName.fulu) {
|
|
503
|
-
const { dataColumnsCache } = cachedData;
|
|
504
|
-
const sampledColumns = this.network.custodyConfig.sampledColumns;
|
|
505
|
-
const neededColumns = sampledColumns.reduce((acc, elem) => {
|
|
506
|
-
if (dataColumnsCache.get(elem) === undefined) {
|
|
507
|
-
acc.push(elem);
|
|
508
|
-
}
|
|
509
|
-
return acc;
|
|
510
|
-
}, []);
|
|
511
|
-
const columns = peerColumns.reduce((acc, elem) => {
|
|
512
|
-
if (neededColumns.includes(elem)) {
|
|
513
|
-
acc.push(elem);
|
|
514
|
-
}
|
|
515
|
-
return acc;
|
|
516
|
-
}, []);
|
|
517
|
-
if (columns.length === 0) {
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
415
|
+
const peer = shuffledPeers[i % shuffledPeers.length];
|
|
522
416
|
try {
|
|
523
|
-
const
|
|
417
|
+
const [blockInput] = await beaconBlocksMaybeBlobsByRoot(this.config, this.network, peer, [blockRoot]);
|
|
524
418
|
// Peer does not have the block, try with next peer
|
|
525
419
|
if (blockInput === undefined) {
|
|
526
420
|
continue;
|
|
527
421
|
}
|
|
528
|
-
if (pendingDataColumns !== null) {
|
|
529
|
-
partialDownload = { blocks: [blockInput], pendingDataColumns };
|
|
530
|
-
fetchedPeerId = peerId;
|
|
531
|
-
continue;
|
|
532
|
-
}
|
|
533
422
|
// Verify block root is correct
|
|
534
423
|
const block = blockInput.block.message;
|
|
535
424
|
const receivedBlockRoot = this.config.getForkTypes(block.slot).BeaconBlock.hashTreeRoot(block);
|
|
536
425
|
if (!byteArrayEquals(receivedBlockRoot, blockRoot)) {
|
|
537
426
|
throw Error(`Wrong block received by peer, got ${toRootHex(receivedBlockRoot)} expected ${blockRootHex}`);
|
|
538
427
|
}
|
|
539
|
-
return { blockInput, peerIdStr:
|
|
428
|
+
return { blockInput, peerIdStr: peer };
|
|
540
429
|
}
|
|
541
430
|
catch (e) {
|
|
542
|
-
this.logger.debug("Error fetching UnknownBlockRoot", { attempt: i, blockRootHex, peer
|
|
431
|
+
this.logger.debug("Error fetching UnknownBlockRoot", { attempt: i, blockRootHex, peer }, e);
|
|
543
432
|
lastError = e;
|
|
544
433
|
}
|
|
545
434
|
}
|
|
@@ -547,16 +436,9 @@ export class UnknownBlockSync {
|
|
|
547
436
|
lastError.message = `Error fetching UnknownBlockRoot after ${MAX_ATTEMPTS_PER_BLOCK} attempts: ${lastError.message}`;
|
|
548
437
|
throw lastError;
|
|
549
438
|
}
|
|
550
|
-
|
|
551
|
-
const { blocks: [blockInput], } = partialDownload;
|
|
552
|
-
return { blockInput, peerIdStr: fetchedPeerId };
|
|
553
|
-
}
|
|
554
|
-
throw Error(`Error fetching UnknownBlockRoot after ${MAX_ATTEMPTS_PER_BLOCK}: unknown error because either partialDownload is null=${partialDownload === null} or fetchedPeerId is null=${fetchedPeerId === null} `);
|
|
439
|
+
throw Error(`Error fetching UnknownBlockRoot after ${MAX_ATTEMPTS_PER_BLOCK}: unknown error`);
|
|
555
440
|
}
|
|
556
441
|
/**
|
|
557
|
-
* We have partial block input:
|
|
558
|
-
* - we have block but not have all blobs (deneb) or needed columns (fulu)
|
|
559
|
-
* - we don't have block and have some blobs (deneb) or some columns (fulu)
|
|
560
442
|
* Fetches missing blobs for the blockinput, in future can also pull block is thats also missing
|
|
561
443
|
* along with the blobs (i.e. only some blobs are available)
|
|
562
444
|
*/
|
|
@@ -566,74 +448,37 @@ export class UnknownBlockSync {
|
|
|
566
448
|
}
|
|
567
449
|
const shuffledPeers = shuffle(connectedPeers);
|
|
568
450
|
let blockRootHex;
|
|
451
|
+
let pendingBlobs;
|
|
569
452
|
let blobKzgCommitmentsLen;
|
|
570
453
|
let blockRoot;
|
|
571
|
-
const dataMeta = {};
|
|
572
|
-
let sampledColumns = [];
|
|
573
454
|
if (unavailableBlockInput.block === null) {
|
|
574
455
|
blockRootHex = unavailableBlockInput.blockRootHex;
|
|
575
456
|
blockRoot = fromHex(blockRootHex);
|
|
576
457
|
}
|
|
577
458
|
else {
|
|
578
|
-
const
|
|
459
|
+
const unavailableBlock = unavailableBlockInput.block;
|
|
579
460
|
blockRoot = this.config
|
|
580
461
|
.getForkTypes(unavailableBlock.message.slot)
|
|
581
462
|
.BeaconBlock.hashTreeRoot(unavailableBlock.message);
|
|
582
463
|
blockRootHex = toRootHex(blockRoot);
|
|
583
464
|
blobKzgCommitmentsLen = unavailableBlock.message.body.blobKzgCommitments.length;
|
|
584
|
-
|
|
585
|
-
const pendingBlobs = blobKzgCommitmentsLen - cachedData.blobsCache.size;
|
|
586
|
-
Object.assign(dataMeta, { pendingBlobs });
|
|
587
|
-
}
|
|
588
|
-
else if (cachedData.fork === ForkName.fulu) {
|
|
589
|
-
sampledColumns = this.network.custodyConfig.sampledColumns;
|
|
590
|
-
const pendingColumns = sampledColumns.length - cachedData.dataColumnsCache.size;
|
|
591
|
-
Object.assign(dataMeta, { pendingColumns });
|
|
592
|
-
}
|
|
465
|
+
pendingBlobs = blobKzgCommitmentsLen - unavailableBlockInput.cachedData.blobsCache.size;
|
|
593
466
|
}
|
|
594
467
|
let lastError = null;
|
|
595
468
|
for (let i = 0; i < MAX_ATTEMPTS_PER_BLOCK; i++) {
|
|
596
|
-
const
|
|
597
|
-
const { custodyGroups: peerColumns, client: peerClient } = this.network.getConnectedPeerSyncMeta(peerId);
|
|
598
|
-
if (unavailableBlockInput.block !== null) {
|
|
599
|
-
const { cachedData } = unavailableBlockInput;
|
|
600
|
-
if (cachedData.fork === ForkName.fulu) {
|
|
601
|
-
const { dataColumnsCache } = cachedData;
|
|
602
|
-
const neededColumns = sampledColumns.reduce((acc, elem) => {
|
|
603
|
-
if (dataColumnsCache.get(elem) === undefined) {
|
|
604
|
-
acc.push(elem);
|
|
605
|
-
}
|
|
606
|
-
return acc;
|
|
607
|
-
}, []);
|
|
608
|
-
const columns = peerColumns.reduce((acc, elem) => {
|
|
609
|
-
if (neededColumns.includes(elem)) {
|
|
610
|
-
acc.push(elem);
|
|
611
|
-
}
|
|
612
|
-
return acc;
|
|
613
|
-
}, []);
|
|
614
|
-
if (columns.length === 0) {
|
|
615
|
-
continue;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}
|
|
469
|
+
const peer = shuffledPeers[i % shuffledPeers.length];
|
|
619
470
|
try {
|
|
620
|
-
const blockInput = await unavailableBeaconBlobsByRoot(this.config, this.network,
|
|
471
|
+
const blockInput = await unavailableBeaconBlobsByRoot(this.config, this.network, peer, unavailableBlockInput, {
|
|
621
472
|
metrics: this.metrics,
|
|
622
|
-
logger: this.logger,
|
|
623
|
-
executionEngine: this.chain.executionEngine,
|
|
624
473
|
emitter: this.chain.emitter,
|
|
625
|
-
|
|
474
|
+
executionEngine: this.chain.executionEngine,
|
|
626
475
|
engineGetBlobsCache: this.engineGetBlobsCache,
|
|
476
|
+
blockInputsRetryTrackerCache: this.blockInputsRetryTrackerCache,
|
|
627
477
|
});
|
|
628
478
|
// Peer does not have the block, try with next peer
|
|
629
479
|
if (blockInput === undefined) {
|
|
630
480
|
continue;
|
|
631
481
|
}
|
|
632
|
-
if (unavailableBlockInput.block !== null && blockInput.type === BlockInputType.dataPromise) {
|
|
633
|
-
// all datacolumns were not downloaded we can continue with other peers
|
|
634
|
-
// as unavailableBlockInput.block's dataColumnsCache would be updated
|
|
635
|
-
continue;
|
|
636
|
-
}
|
|
637
482
|
// Verify block root is correct
|
|
638
483
|
const block = blockInput.block.message;
|
|
639
484
|
const receivedBlockRoot = this.config.getForkTypes(block.slot).BeaconBlock.hashTreeRoot(block);
|
|
@@ -644,12 +489,12 @@ export class UnknownBlockSync {
|
|
|
644
489
|
this.logger.debug("Fetched NullBlockInput", { attempts: i, blockRootHex });
|
|
645
490
|
}
|
|
646
491
|
else {
|
|
647
|
-
this.logger.debug("Fetched UnavailableBlockInput", { attempts: i,
|
|
492
|
+
this.logger.debug("Fetched UnavailableBlockInput", { attempts: i, pendingBlobs, blobKzgCommitmentsLen });
|
|
648
493
|
}
|
|
649
|
-
return { blockInput, peerIdStr:
|
|
494
|
+
return { blockInput, peerIdStr: peer };
|
|
650
495
|
}
|
|
651
496
|
catch (e) {
|
|
652
|
-
this.logger.debug("Error fetching UnavailableBlockInput", { attempt: i, blockRootHex, peer
|
|
497
|
+
this.logger.debug("Error fetching UnavailableBlockInput", { attempt: i, blockRootHex, peer }, e);
|
|
653
498
|
lastError = e;
|
|
654
499
|
}
|
|
655
500
|
}
|
|
@@ -668,15 +513,13 @@ export class UnknownBlockSync {
|
|
|
668
513
|
removeAndDownscoreAllDescendants(block) {
|
|
669
514
|
// Get all blocks that are a descendant of this one
|
|
670
515
|
const badPendingBlocks = this.removeAllDescendants(block);
|
|
671
|
-
// just console log and do not penalize on pending/bad blocks for debugging
|
|
672
|
-
// console.log("removeAndDownscoreAllDescendants", {block});
|
|
673
516
|
for (const block of badPendingBlocks) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
this.logger.debug("
|
|
517
|
+
this.knownBadBlocks.add(block.blockRootHex);
|
|
518
|
+
for (const peerIdStr of block.peerIdStrs) {
|
|
519
|
+
// TODO: Refactor peerRpcScores to work with peerIdStr only
|
|
520
|
+
this.network.reportPeer(peerIdStr, PeerAction.LowToleranceError, "BadBlockByRoot");
|
|
521
|
+
}
|
|
522
|
+
this.logger.debug("Banning unknown block", {
|
|
680
523
|
root: block.blockRootHex,
|
|
681
524
|
peerIdStrs: Array.from(block.peerIdStrs).join(","),
|
|
682
525
|
});
|