@lodestar/beacon-node 1.52.0-dev.50261a81cb → 1.52.0-dev.5745da1108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +7 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/lightClient/index.d.ts +13 -6
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +95 -115
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +79 -4
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/execution/engine/http.d.ts +2 -2
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +13 -7
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +16 -3
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js +11 -0
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.js +4 -4
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/restHttpClient.js +9 -5
- package/lib/execution/engine/restHttpClient.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +2 -2
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +4 -4
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/signal.d.ts +6 -0
- package/lib/execution/engine/signal.d.ts.map +1 -0
- package/lib/execution/engine/signal.js +24 -0
- package/lib/execution/engine/signal.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +2 -2
- package/lib/execution/engine/transport.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +1 -0
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +5 -2
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +6 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +22 -2
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
- package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.js +11 -2
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/network/processor/gossipHandlers.js +2 -2
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +63 -3
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +5 -4
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/eventLoop.d.ts +3 -3
- package/lib/util/eventLoop.d.ts.map +1 -1
- package/lib/util/eventLoop.js +3 -3
- package/lib/util/eventLoop.js.map +1 -1
- package/package.json +25 -25
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/errors/executionPayloadEnvelope.ts +50 -0
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/validation/executionPayloadEnvelope.ts +87 -3
- package/src/execution/engine/http.ts +18 -10
- package/src/execution/engine/interface.ts +18 -3
- package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
- package/src/execution/engine/jsonRpcTransport.ts +8 -4
- package/src/execution/engine/restHttpClient.ts +17 -11
- package/src/execution/engine/restTransport.ts +5 -4
- package/src/execution/engine/signal.ts +28 -0
- package/src/execution/engine/transport.ts +3 -2
- package/src/index.ts +6 -1
- package/src/network/gossip/gossipsub.ts +6 -2
- package/src/network/network.ts +6 -2
- package/src/network/peers/peerManager.ts +26 -2
- package/src/network/peers/utils/prioritizePeers.ts +14 -1
- package/src/network/processor/gossipHandlers.ts +2 -2
- package/src/sync/unknownBlock.ts +68 -2
- package/src/sync/utils/downloadByRoot.ts +7 -5
- package/src/util/eventLoop.ts +3 -3
|
@@ -98,6 +98,7 @@ function computeStatusScore(ours: Status, theirs: Status | null, opts: Prioritiz
|
|
|
98
98
|
|
|
99
99
|
type PeerInfo = {
|
|
100
100
|
id: PeerId;
|
|
101
|
+
direct: boolean;
|
|
101
102
|
direction: MessageStreamDirection | null;
|
|
102
103
|
statusScore: StatusScore;
|
|
103
104
|
attnets: phase0.AttestationSubnets;
|
|
@@ -140,6 +141,7 @@ export enum ExcessPeerDisconnectReason {
|
|
|
140
141
|
export function prioritizePeers(
|
|
141
142
|
connectedPeersInfo: {
|
|
142
143
|
id: PeerId;
|
|
144
|
+
direct?: boolean;
|
|
143
145
|
direction: MessageStreamDirection | null;
|
|
144
146
|
status: Status | null;
|
|
145
147
|
attnets: phase0.AttestationSubnets | null;
|
|
@@ -169,6 +171,7 @@ export function prioritizePeers(
|
|
|
169
171
|
const connectedPeers = connectedPeersInfo.map(
|
|
170
172
|
(peer): PeerInfo => ({
|
|
171
173
|
id: peer.id,
|
|
174
|
+
direct: peer.direct ?? false,
|
|
172
175
|
direction: peer.direction,
|
|
173
176
|
statusScore: computeStatusScore(opts.status, peer.status, opts),
|
|
174
177
|
attnets: peer.attnets ?? attnetsZero,
|
|
@@ -365,6 +368,11 @@ function pruneExcessPeers(
|
|
|
365
368
|
const peersEligibleForPruning = sortedPeers
|
|
366
369
|
// Then, iterate from highest score to lowest doing a manual filter for duties and outbound ratio
|
|
367
370
|
.filter((peer) => {
|
|
371
|
+
// Direct peers are pinned by the operator, they count towards all targets but are never pruned
|
|
372
|
+
if (peer.direct) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
|
|
368
376
|
// Peers with duties are not eligible for pruning
|
|
369
377
|
if ((dutiesByPeer.get(peer) ?? 0) > 0) {
|
|
370
378
|
return false;
|
|
@@ -488,11 +496,12 @@ function pruneExcessPeers(
|
|
|
488
496
|
// otherwise we'll not able to accept new peer connection to consider better peers
|
|
489
497
|
// see https://github.com/ChainSafe/lodestar/issues/5198
|
|
490
498
|
const remainingPeersToDisconnect: PeerId[] = [];
|
|
491
|
-
for (const {id} of sortedPeers) {
|
|
499
|
+
for (const {id, direct} of sortedPeers) {
|
|
492
500
|
if (peersToDisconnectCount >= peersToDisconnectTarget) {
|
|
493
501
|
break;
|
|
494
502
|
}
|
|
495
503
|
if (
|
|
504
|
+
direct ||
|
|
496
505
|
noLongLivedSubnetPeersToDisconnect.includes(id) ||
|
|
497
506
|
badScorePeersToDisconnect.includes(id) ||
|
|
498
507
|
tooGroupedPeersToDisconnect.includes(id)
|
|
@@ -568,6 +577,10 @@ function findPeerToRemove(
|
|
|
568
577
|
const peersOnSubnet = sortBy(peersOnMostGroupedSubnet, (peer) => peer.attnetsTrueBitIndices.length);
|
|
569
578
|
let removedPeer: PeerInfo | null = null;
|
|
570
579
|
for (const candidatePeer of peersOnSubnet) {
|
|
580
|
+
if (candidatePeer.direct) {
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
|
|
571
584
|
// new logic of lodestar
|
|
572
585
|
const attnetIndices = candidatePeer.attnetsTrueBitIndices;
|
|
573
586
|
if (attnetIndices.length > 0) {
|
|
@@ -89,7 +89,7 @@ import {validateGossipProposerPreferences} from "../../chain/validation/proposer
|
|
|
89
89
|
import {OpSource} from "../../chain/validatorMonitor.js";
|
|
90
90
|
import {Metrics} from "../../metrics/index.js";
|
|
91
91
|
import {getBlobKzgCommitments, getDataColumnSidecarSlot} from "../../util/dataColumns.js";
|
|
92
|
-
import {
|
|
92
|
+
import {callAfterIO, callInNextEventLoop} from "../../util/eventLoop.js";
|
|
93
93
|
import {INetworkCore} from "../core/index.js";
|
|
94
94
|
import {NetworkEventBus} from "../events.js";
|
|
95
95
|
import {
|
|
@@ -686,7 +686,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
686
686
|
try {
|
|
687
687
|
const blockInput = await validateBeaconBlock(signedBlock, topic.boundary.fork, peerIdStr, seenTimestampSec);
|
|
688
688
|
// Runs after the validation result is reported, except with `network.useWorker: false`
|
|
689
|
-
|
|
689
|
+
callAfterIO(() => {
|
|
690
690
|
try {
|
|
691
691
|
chain.serializedCache.set(signedBlock, serializedData);
|
|
692
692
|
handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec);
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -13,6 +13,8 @@ import {PayloadEnvelopeInput, PayloadEnvelopeInputSource} from "../chain/blocks/
|
|
|
13
13
|
import {
|
|
14
14
|
BlockError,
|
|
15
15
|
BlockErrorCode,
|
|
16
|
+
DataColumnSidecarErrorCode,
|
|
17
|
+
DataColumnSidecarValidationError,
|
|
16
18
|
ExecutionPayloadEnvelopeError,
|
|
17
19
|
ExecutionPayloadEnvelopeErrorCode,
|
|
18
20
|
} from "../chain/errors/index.js";
|
|
@@ -1997,7 +1999,20 @@ export class BlockInputSync {
|
|
|
1997
1999
|
|
|
1998
2000
|
let i = 0;
|
|
1999
2001
|
let deferredByRateLimit = false;
|
|
2002
|
+
let requestedWhenReconstructable = false;
|
|
2000
2003
|
while (i++ < this.getMaxDownloadAttempts()) {
|
|
2004
|
+
const reconstructable =
|
|
2005
|
+
isPendingBlockInput(cacheItem) &&
|
|
2006
|
+
isBlockInputColumns(cacheItem.blockInput) &&
|
|
2007
|
+
cacheItem.blockInput.hasBlockAndAllData();
|
|
2008
|
+
// Reconstruction recovers whole rows however many columns are missing, so only one more request is worth it,
|
|
2009
|
+
// further peers could each hold the import until their response times out
|
|
2010
|
+
if (reconstructable) {
|
|
2011
|
+
if (requestedWhenReconstructable) {
|
|
2012
|
+
break;
|
|
2013
|
+
}
|
|
2014
|
+
requestedWhenReconstructable = true;
|
|
2015
|
+
}
|
|
2001
2016
|
const pendingColumns =
|
|
2002
2017
|
isPendingBlockInput(cacheItem) && isBlockInputColumns(cacheItem.blockInput)
|
|
2003
2018
|
? new Set(cacheItem.blockInput.getMissingSampledColumnMeta().missing)
|
|
@@ -2012,6 +2027,10 @@ export class BlockInputSync {
|
|
|
2012
2027
|
now
|
|
2013
2028
|
);
|
|
2014
2029
|
if (peerMeta === null) {
|
|
2030
|
+
if (reconstructable) {
|
|
2031
|
+
break;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2015
2034
|
const retryAt = this.peerBalancer.getNextRateLimitRetryAt(pendingColumns, excludedPeers, now);
|
|
2016
2035
|
if (retryAt !== null) {
|
|
2017
2036
|
throw new UnknownBlockRateLimitedError(
|
|
@@ -2056,8 +2075,16 @@ export class BlockInputSync {
|
|
|
2056
2075
|
for (const warning of warnings) {
|
|
2057
2076
|
this.logger.debug("BlockInputSync.fetchBlockInput: downloaded with warning", logCtx, warning);
|
|
2058
2077
|
this.metrics?.blockInputSync.downloadByRoot.warn.inc({code: warning.type.code, client: peerClient});
|
|
2078
|
+
// A partial response is legal, columns that were not requested are not
|
|
2079
|
+
if (warning.type.code === DownloadByRootErrorCode.EXTRA_SIDECAR_RECEIVED) {
|
|
2080
|
+
this.network.reportPeer(peerId, PeerAction.LowToleranceError, warning.type.code);
|
|
2081
|
+
excludedPeers.add(peerId);
|
|
2082
|
+
}
|
|
2083
|
+
// Not picked again for this block, it would be preferred as a previous source of it
|
|
2084
|
+
if (warning.type.code === DownloadByRootErrorCode.NOT_ENOUGH_SIDECARS_RECEIVED) {
|
|
2085
|
+
excludedPeers.add(peerId);
|
|
2086
|
+
}
|
|
2059
2087
|
}
|
|
2060
|
-
// TODO: penalize peer?
|
|
2061
2088
|
}
|
|
2062
2089
|
} catch (e) {
|
|
2063
2090
|
this.logger.debug(
|
|
@@ -2066,7 +2093,6 @@ export class BlockInputSync {
|
|
|
2066
2093
|
e as Error
|
|
2067
2094
|
);
|
|
2068
2095
|
const downloadByRootMetrics = this.metrics?.blockInputSync.downloadByRoot;
|
|
2069
|
-
// TODO: penalize peer?
|
|
2070
2096
|
if (e instanceof DownloadByRootError) {
|
|
2071
2097
|
const errorCode = e.type.code;
|
|
2072
2098
|
downloadByRootMetrics?.error.inc({code: errorCode, client: peerClient});
|
|
@@ -2082,6 +2108,22 @@ export class BlockInputSync {
|
|
|
2082
2108
|
this.network.reportPeer(peerId, PeerAction.LowToleranceError, errorCode);
|
|
2083
2109
|
}
|
|
2084
2110
|
excludedPeers.add(peerId);
|
|
2111
|
+
} else if (e instanceof DataColumnSidecarValidationError) {
|
|
2112
|
+
const errorCode = e.type.code;
|
|
2113
|
+
downloadByRootMetrics?.error.inc({code: errorCode, client: peerClient});
|
|
2114
|
+
// Not PROPOSAL_SIGNATURE_INVALID or INCORRECT_HEADER_ROOT, which compares signatures too: the spec does not
|
|
2115
|
+
// require verifying the header signature of req/resp columns, so honest peers may serve a bad one
|
|
2116
|
+
switch (errorCode) {
|
|
2117
|
+
case DataColumnSidecarErrorCode.INCORRECT_BLOCK:
|
|
2118
|
+
case DataColumnSidecarErrorCode.INVALID_INDEX:
|
|
2119
|
+
case DataColumnSidecarErrorCode.INCORRECT_CELL_COUNT:
|
|
2120
|
+
case DataColumnSidecarErrorCode.INCORRECT_KZG_COMMITMENTS_COUNT:
|
|
2121
|
+
case DataColumnSidecarErrorCode.INCORRECT_KZG_PROOF_COUNT:
|
|
2122
|
+
case DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID:
|
|
2123
|
+
case DataColumnSidecarErrorCode.INVALID_KZG_PROOF_BATCH:
|
|
2124
|
+
this.network.reportPeer(peerId, PeerAction.LowToleranceError, errorCode);
|
|
2125
|
+
}
|
|
2126
|
+
excludedPeers.add(peerId);
|
|
2085
2127
|
} else if (e instanceof RequestError) {
|
|
2086
2128
|
// should look into req_resp metrics in this case
|
|
2087
2129
|
downloadByRootMetrics?.error.inc({code: "req_resp", client: peerClient});
|
|
@@ -2133,6 +2175,30 @@ export class BlockInputSync {
|
|
|
2133
2175
|
|
|
2134
2176
|
const message = `Error fetching BlockInput with slot=${slot} root=${rootHex} after ${i - 1} attempts.`;
|
|
2135
2177
|
|
|
2178
|
+
if (
|
|
2179
|
+
isPendingBlockInput(cacheItem) &&
|
|
2180
|
+
isBlockInputColumns(cacheItem.blockInput) &&
|
|
2181
|
+
cacheItem.blockInput.hasBlockAndAllData()
|
|
2182
|
+
) {
|
|
2183
|
+
// Peers cannot serve the remaining columns now, half of them is enough to reconstruct the rest
|
|
2184
|
+
this.logger.verbose("BlockInputSync.fetchBlockInput: reconstructing columns peers could not serve", {
|
|
2185
|
+
slot,
|
|
2186
|
+
rootHex,
|
|
2187
|
+
missing: cacheItem.blockInput.getMissingSampledColumnMeta().missing.length,
|
|
2188
|
+
});
|
|
2189
|
+
this.chain.columnReconstructionTracker.triggerColumnReconstruction(cacheItem.blockInput);
|
|
2190
|
+
cacheItem = {...cacheItem, status: PendingBlockInputStatus.downloaded, timeSyncedSec: Date.now() / 1000};
|
|
2191
|
+
if (this.pendingBlocks.has(rootHex)) {
|
|
2192
|
+
this.pendingBlocks.set(rootHex, cacheItem);
|
|
2193
|
+
}
|
|
2194
|
+
const result = this.chain.forkChoice.hasBlockHex(cacheItem.blockInput.parentRootHex)
|
|
2195
|
+
? FetchResult.SuccessResolved
|
|
2196
|
+
: FetchResult.SuccessMissingParent;
|
|
2197
|
+
this.metrics?.blockInputSync.fetchTime.observe({result}, Date.now() / 1000 - fetchStartSec);
|
|
2198
|
+
this.metrics?.blockInputSync.fetchPeers.set({result}, i - 1);
|
|
2199
|
+
return cacheItem;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2136
2202
|
const retryAt = deferredByRateLimit ? this.peerBalancer.getNextRateLimitRetryAt() : null;
|
|
2137
2203
|
if (retryAt !== null) {
|
|
2138
2204
|
throw new UnknownBlockRateLimitedError(`${message} Peers are rate-limited.`, retryAt);
|
|
@@ -115,9 +115,8 @@ export async function downloadByRoot({
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (isBlockInputColumns(blockInput) && !hasAllDataPreDownload) {
|
|
118
|
+
// Like range sync, download every sampled column, half of them only counts as available for reconstruction
|
|
119
|
+
if (isBlockInputColumns(blockInput) && !blockInput.hasComputedAllData()) {
|
|
121
120
|
// columnSidecars could be undefined if gossip resulted in full block+columns so we don't download any
|
|
122
121
|
if (!columnSidecars) {
|
|
123
122
|
throw new DownloadByRootError({
|
|
@@ -154,7 +153,10 @@ export async function downloadByRoot({
|
|
|
154
153
|
|
|
155
154
|
let status: PendingBlockInputStatus;
|
|
156
155
|
let timeSyncedSec: number | undefined;
|
|
157
|
-
if (
|
|
156
|
+
if (
|
|
157
|
+
blockInput.hasBlock() &&
|
|
158
|
+
(isBlockInputColumns(blockInput) ? blockInput.hasComputedAllData() : blockInput.hasAllData())
|
|
159
|
+
) {
|
|
158
160
|
status = PendingBlockInputStatus.downloaded;
|
|
159
161
|
timeSyncedSec = Date.now() / 1000;
|
|
160
162
|
} else {
|
|
@@ -201,7 +203,7 @@ export async function fetchByRoot({
|
|
|
201
203
|
}
|
|
202
204
|
|
|
203
205
|
const forkName = config.getForkName(block.message.slot);
|
|
204
|
-
if (
|
|
206
|
+
if (isBlockInputColumns(cacheItem.blockInput) && !cacheItem.blockInput.hasComputedAllData()) {
|
|
205
207
|
columnSidecarResult = await fetchAndValidateColumns({
|
|
206
208
|
config,
|
|
207
209
|
chain,
|
package/src/util/eventLoop.ts
CHANGED
|
@@ -22,9 +22,9 @@ export function callInNextEventLoop(callback: () => void): void {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Schedules a callback for the `check` phase
|
|
26
|
-
* and there is no 1ms timer delay.
|
|
25
|
+
* Schedules a callback for the `check` phase, after the `poll` phase handles ready I/O.
|
|
26
|
+
* Pending promise continuations run first, and there is no 1ms timer delay.
|
|
27
27
|
*/
|
|
28
|
-
export function
|
|
28
|
+
export function callAfterIO(callback: () => void): void {
|
|
29
29
|
setImmediate(callback);
|
|
30
30
|
}
|