@lodestar/beacon-node 2.1.0-dev.8e668b372b → 2.1.0-dev.8fca104f0d
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/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/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.map +1 -1
- package/lib/chain/chain.js +11 -4
- package/lib/chain/chain.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 +181 -13
- package/lib/chain/forkChoice/index.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/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/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/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +15 -7
- 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/package.json +16 -19
- 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/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 +16 -4
- package/src/chain/forkChoice/index.ts +235 -13
- package/src/chain/options.ts +1 -0
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +28 -2
- package/src/chain/validation/attestation.ts +4 -2
- package/src/network/forks.ts +7 -3
- package/src/network/gossip/scoringParameters.ts +23 -14
- package/src/network/processor/gossipHandlers.ts +28 -15
- 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/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) {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ForkName,
|
|
4
|
+
ForkPostDeneb,
|
|
5
|
+
ForkPostFulu,
|
|
6
|
+
ForkPostGloas,
|
|
7
|
+
isForkPostDeneb,
|
|
8
|
+
isForkPostFulu,
|
|
9
|
+
isForkPostGloas,
|
|
10
|
+
} from "@lodestar/params";
|
|
11
|
+
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
3
12
|
import {
|
|
4
13
|
ColumnIndex,
|
|
5
14
|
DataColumnSidecar,
|
|
@@ -28,6 +37,7 @@ import {INetwork} from "../../network/index.js";
|
|
|
28
37
|
import {CustodyConfig, getBlobKzgCommitments} from "../../util/dataColumns.js";
|
|
29
38
|
import {PeerIdStr} from "../../util/peerId.js";
|
|
30
39
|
import {WarnResult} from "../../util/wrapError.js";
|
|
40
|
+
import {getRateLimitedUntilMs} from "./rateLimit.js";
|
|
31
41
|
|
|
32
42
|
export type DownloadByRangeRequests = {
|
|
33
43
|
blocksRequest?: phase0.BeaconBlocksByRangeRequest;
|
|
@@ -327,6 +337,8 @@ export async function downloadByRange({
|
|
|
327
337
|
parentPayloadRequest,
|
|
328
338
|
});
|
|
329
339
|
} catch (err) {
|
|
340
|
+
// Rethrow rate limit errors as is, so range sync can back off from the peer instead of counting a failed download
|
|
341
|
+
if (getRateLimitedUntilMs(err) !== null) throw err;
|
|
330
342
|
throw new DownloadByRangeError({
|
|
331
343
|
code: DownloadByRangeErrorCode.REQ_RESP_ERROR,
|
|
332
344
|
reason: (err as Error).message,
|
|
@@ -697,6 +709,15 @@ export function validateBlockByRangeResponse(
|
|
|
697
709
|
|
|
698
710
|
for (let i = 0; i < blocks.length; i++) {
|
|
699
711
|
const block = blocks[i];
|
|
712
|
+
const slot = block.message.slot;
|
|
713
|
+
const fork = config.getForkName(slot);
|
|
714
|
+
if (isForkPostDeneb(fork)) {
|
|
715
|
+
const count = getBlobKzgCommitments(fork, block as SignedBeaconBlock<ForkPostDeneb>).length;
|
|
716
|
+
const limit = config.getMaxBlobsPerBlock(computeEpochAtSlot(slot));
|
|
717
|
+
if (count > limit) {
|
|
718
|
+
throw new DownloadByRangeError({code: DownloadByRangeErrorCode.TOO_MANY_KZG_COMMITMENTS, slot, count, limit});
|
|
719
|
+
}
|
|
720
|
+
}
|
|
700
721
|
const blockRoot = type.hashTreeRoot(block.message);
|
|
701
722
|
response.push({block, blockRoot});
|
|
702
723
|
|
|
@@ -825,12 +846,7 @@ export async function validateColumnsByRangeResponse(
|
|
|
825
846
|
}
|
|
826
847
|
|
|
827
848
|
seenSlotColumns.set(columnSidecar.index, columnSidecar);
|
|
828
|
-
|
|
829
|
-
// a new slot has started, reset index
|
|
830
|
-
currentIndex = -1;
|
|
831
|
-
} else {
|
|
832
|
-
currentIndex = columnSidecar.index;
|
|
833
|
-
}
|
|
849
|
+
currentIndex = columnSidecar.index;
|
|
834
850
|
currentSlot = slot;
|
|
835
851
|
}
|
|
836
852
|
|
|
@@ -1030,6 +1046,7 @@ export enum DownloadByRangeErrorCode {
|
|
|
1030
1046
|
|
|
1031
1047
|
PARENT_ROOT_MISMATCH = "DOWNLOAD_BY_RANGE_ERROR_PARENT_ROOT_MISMATCH",
|
|
1032
1048
|
EXTRA_BLOCKS = "DOWNLOAD_BY_RANGE_ERROR_EXTRA_BLOCKS",
|
|
1049
|
+
TOO_MANY_KZG_COMMITMENTS = "DOWNLOAD_BY_RANGE_ERROR_TOO_MANY_KZG_COMMITMENTS",
|
|
1033
1050
|
OUT_OF_RANGE_BLOCKS = "DOWNLOAD_BY_RANGE_OUT_OF_RANGE_BLOCKS",
|
|
1034
1051
|
OUT_OF_ORDER_BLOCKS = "DOWNLOAD_BY_RANGE_OUT_OF_ORDER_BLOCKS",
|
|
1035
1052
|
|
|
@@ -1072,6 +1089,12 @@ export type DownloadByRangeErrorType =
|
|
|
1072
1089
|
columnSidecarCount: number;
|
|
1073
1090
|
payloadEnvelopeCount: number;
|
|
1074
1091
|
}
|
|
1092
|
+
| {
|
|
1093
|
+
code: DownloadByRangeErrorCode.TOO_MANY_KZG_COMMITMENTS;
|
|
1094
|
+
slot: Slot;
|
|
1095
|
+
count: number;
|
|
1096
|
+
limit: number;
|
|
1097
|
+
}
|
|
1075
1098
|
| {
|
|
1076
1099
|
code: DownloadByRangeErrorCode.OUT_OF_RANGE_BLOCKS;
|
|
1077
1100
|
slot: number;
|
|
@@ -104,15 +104,18 @@ export async function downloadByRoot({
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
if (isForkPostGloas(blockInput.forkName)) {
|
|
107
|
-
chain.seenPayloadEnvelopeInputCache.add(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
chain.seenPayloadEnvelopeInputCache.add(
|
|
108
|
+
{
|
|
109
|
+
blockRootHex: rootHex,
|
|
110
|
+
block: blockInput.getBlock() as SignedBeaconBlock<ForkPostGloas>,
|
|
111
|
+
forkName: blockInput.forkName,
|
|
112
|
+
sampledColumns: chain.custodyConfig.sampledColumns,
|
|
113
|
+
custodyColumns: chain.custodyConfig.custodyColumns,
|
|
114
|
+
seenTimestampSec: Date.now() / 1000,
|
|
115
|
+
source: PayloadEnvelopeInputSource.byRoot,
|
|
116
|
+
},
|
|
117
|
+
{unvalidated: true}
|
|
118
|
+
);
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
// Like range sync, download every sampled column, half of them only counts as available for reconstruction
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {RootHex} from "@lodestar/types";
|
|
2
2
|
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
import {isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
|
|
3
4
|
import {
|
|
4
5
|
BlockInputSyncCacheItem,
|
|
5
6
|
PendingBlockInput,
|
|
@@ -61,9 +62,13 @@ export function getUnknownAndAncestorBlocks(blocks: Map<RootHex, BlockInputSyncC
|
|
|
61
62
|
const ancestors = new Map<RootHex, PendingBlockInput>();
|
|
62
63
|
|
|
63
64
|
for (const block of blocks.values()) {
|
|
65
|
+
// Half the columns counts as all data, but a pending block is only complete with all sampled columns
|
|
64
66
|
if (
|
|
65
67
|
block.status === PendingBlockInputStatus.pending &&
|
|
66
|
-
(isPendingBlockInput(block)
|
|
68
|
+
(isPendingBlockInput(block)
|
|
69
|
+
? !block.blockInput.hasBlockAndAllData() ||
|
|
70
|
+
(isBlockInputColumns(block.blockInput) && !block.blockInput.hasComputedAllData())
|
|
71
|
+
: true)
|
|
67
72
|
) {
|
|
68
73
|
unknowns.set(getBlockInputSyncCacheItemRootHex(block), block);
|
|
69
74
|
} else if (
|