@lodestar/beacon-node 1.52.0-dev.a94ada0e67 → 1.52.0-dev.ae7beea800
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 +63 -39
- 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 +3 -1
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +2 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +6 -2
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +19 -11
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +4 -0
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- 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/archiveBlocks.js +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.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/blocks/importExecutionPayload.d.ts +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +9 -3
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -17
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/chain.d.ts +6 -5
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +83 -31
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +15 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +8 -0
- package/lib/chain/errors/attestationError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +2 -1
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/interface.d.ts +1 -1
- package/lib/chain/interface.d.ts.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/opPools/inclusionListStore.d.ts +4 -1
- package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
- package/lib/chain/opPools/inclusionListStore.js +5 -2
- package/lib/chain/opPools/inclusionListStore.js.map +1 -1
- package/lib/chain/opPools/opPool.js +6 -6
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +45 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +265 -69
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +23 -15
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
- package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +1 -1
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
- package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
- package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
- package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +24 -7
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +32 -16
- 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 +9 -1
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +47 -42
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +9 -0
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +39 -6
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/chain/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/execution/engine/blockHash.d.ts +12 -0
- package/lib/execution/engine/blockHash.d.ts.map +1 -0
- package/lib/execution/engine/blockHash.js +17 -0
- package/lib/execution/engine/blockHash.js.map +1 -0
- 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/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -6
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +6 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +7 -2
- package/lib/execution/engine/payloadIdCache.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/metrics/metrics/beacon.d.ts +5 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +5 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.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/gossip/topic.d.ts +1 -7
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +0 -13
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +26 -12
- 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.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +19 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +4 -1
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +4 -2
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/utils/collect.d.ts +4 -4
- package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collect.js +9 -8
- package/lib/network/reqresp/utils/collect.js.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
- package/lib/sync/range/batch.d.ts +6 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +17 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +8 -1
- 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 +43 -3
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/types.d.ts +14 -1
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +2 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +28 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +340 -27
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +14 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +12 -2
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +24 -2
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +48 -5
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/dataColumns.d.ts +1 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +4 -1
- package/lib/util/dataColumns.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 +27 -27
- package/src/api/impl/beacon/blocks/index.ts +74 -47
- package/src/api/impl/beacon/pool/index.ts +9 -7
- package/src/api/impl/beacon/state/utils.ts +2 -1
- package/src/api/impl/debug/index.ts +6 -2
- package/src/api/impl/validator/index.ts +21 -11
- package/src/chain/ColumnReconstructionTracker.ts +5 -0
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/blocks/importExecutionPayload.ts +9 -2
- package/src/chain/blocks/index.ts +3 -31
- package/src/chain/chain.ts +116 -48
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadBid.ts +9 -2
- package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
- package/src/chain/interface.ts +1 -1
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/opPools/inclusionListStore.ts +5 -2
- package/src/chain/opPools/opPool.ts +6 -6
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +25 -16
- package/src/chain/seenCache/seenAttesters.ts +1 -1
- package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
- package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
- package/src/chain/validation/aggregateAndProof.ts +24 -9
- package/src/chain/validation/attestation.ts +31 -20
- package/src/chain/validation/block.ts +9 -1
- package/src/chain/validation/executionPayloadBid.ts +60 -44
- package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
- package/src/chain/validation/payloadAttestationMessage.ts +10 -0
- package/src/chain/validation/voluntaryExit.ts +44 -6
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/execution/engine/blockHash.ts +27 -0
- 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/mock.ts +13 -8
- package/src/execution/engine/payloadIdCache.ts +12 -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/metrics/metrics/beacon.ts +9 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/gossip/gossipsub.ts +6 -2
- package/src/network/gossip/topic.ts +1 -14
- package/src/network/network.ts +39 -13
- package/src/network/peers/peerManager.ts +26 -2
- package/src/network/peers/utils/prioritizePeers.ts +14 -1
- package/src/network/processor/gossipHandlers.ts +25 -13
- package/src/network/processor/gossipValidatorFn.ts +4 -0
- package/src/network/processor/index.ts +7 -2
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- package/src/network/reqresp/utils/collect.ts +16 -8
- package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
- package/src/sync/range/batch.ts +20 -0
- package/src/sync/range/chain.ts +8 -0
- package/src/sync/range/range.ts +56 -3
- package/src/sync/types.ts +13 -0
- package/src/sync/unknownBlock.ts +389 -29
- package/src/sync/utils/downloadByRange.ts +29 -3
- package/src/sync/utils/downloadByRoot.ts +75 -7
- package/src/util/dataColumns.ts +4 -1
- package/src/util/eventLoop.ts +3 -3
|
@@ -12,11 +12,12 @@ import {ResponseTypeGetter} from "../types.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export async function collectExactOneTyped<T>(
|
|
14
14
|
source: AsyncIterable<ResponseIncoming>,
|
|
15
|
-
typeFn: ResponseTypeGetter<T
|
|
15
|
+
typeFn: ResponseTypeGetter<T>,
|
|
16
|
+
onInvalidResponse?: (chunk: ResponseIncoming) => void
|
|
16
17
|
): Promise<T> {
|
|
17
18
|
for await (const chunk of source) {
|
|
18
19
|
const type = typeFn(chunk.fork, chunk.protocolVersion);
|
|
19
|
-
const response = sszDeserializeResponse(type, chunk
|
|
20
|
+
const response = sszDeserializeResponse(type, chunk, onInvalidResponse);
|
|
20
21
|
return response;
|
|
21
22
|
}
|
|
22
23
|
throw new RequestError({code: RequestErrorCode.EMPTY_RESPONSE});
|
|
@@ -33,13 +34,14 @@ export async function collectMaxResponseTyped<T>(
|
|
|
33
34
|
source: AsyncIterable<ResponseIncoming>,
|
|
34
35
|
maxResponses: number,
|
|
35
36
|
typeFn: ResponseTypeGetter<T>,
|
|
36
|
-
serializedCache?: SerializedCache
|
|
37
|
+
serializedCache?: SerializedCache,
|
|
38
|
+
onInvalidResponse?: (chunk: ResponseIncoming) => void
|
|
37
39
|
): Promise<T[]> {
|
|
38
40
|
// else: zero or more responses
|
|
39
41
|
const responses: T[] = [];
|
|
40
42
|
for await (const chunk of source) {
|
|
41
43
|
const type = typeFn(chunk.fork, chunk.protocolVersion);
|
|
42
|
-
const response = sszDeserializeResponse(type, chunk
|
|
44
|
+
const response = sszDeserializeResponse(type, chunk, onInvalidResponse);
|
|
43
45
|
// optionally cache the serialized response if the cache is available
|
|
44
46
|
serializedCache?.set(response as object, chunk.data);
|
|
45
47
|
responses.push(response);
|
|
@@ -62,13 +64,14 @@ export async function collectMaxResponseTypedWithBytes<T>(
|
|
|
62
64
|
source: AsyncIterable<ResponseIncoming>,
|
|
63
65
|
maxResponses: number,
|
|
64
66
|
typeFn: ResponseTypeGetter<T>,
|
|
65
|
-
serializedCache?: SerializedCache
|
|
67
|
+
serializedCache?: SerializedCache,
|
|
68
|
+
onInvalidResponse?: (chunk: ResponseIncoming) => void
|
|
66
69
|
): Promise<T[]> {
|
|
67
70
|
// else: zero or more responses
|
|
68
71
|
const responses: T[] = [];
|
|
69
72
|
for await (const chunk of source) {
|
|
70
73
|
const type = typeFn(chunk.fork, chunk.protocolVersion);
|
|
71
|
-
const data = sszDeserializeResponse(type, chunk
|
|
74
|
+
const data = sszDeserializeResponse(type, chunk, onInvalidResponse);
|
|
72
75
|
responses.push(data);
|
|
73
76
|
// optionally cache the serialized response if the cache is available
|
|
74
77
|
serializedCache?.set(data as object, chunk.data);
|
|
@@ -81,10 +84,15 @@ export async function collectMaxResponseTypedWithBytes<T>(
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
/** Light wrapper on type to wrap deserialize errors */
|
|
84
|
-
export function sszDeserializeResponse<T>(
|
|
87
|
+
export function sszDeserializeResponse<T>(
|
|
88
|
+
type: Type<T>,
|
|
89
|
+
chunk: ResponseIncoming,
|
|
90
|
+
onInvalidResponse?: (chunk: ResponseIncoming) => void
|
|
91
|
+
): T {
|
|
85
92
|
try {
|
|
86
|
-
return type.deserialize(
|
|
93
|
+
return type.deserialize(chunk.data);
|
|
87
94
|
} catch (e) {
|
|
95
|
+
onInvalidResponse?.(chunk);
|
|
88
96
|
throw new RequestError({code: RequestErrorCode.INVALID_RESPONSE_SSZ, errorMessage: (e as Error).message});
|
|
89
97
|
}
|
|
90
98
|
}
|
|
@@ -12,13 +12,14 @@ import {sszDeserializeResponse} from "./collect.js";
|
|
|
12
12
|
export async function collectSequentialBlocksInRange(
|
|
13
13
|
blockStream: AsyncIterable<ResponseIncoming>,
|
|
14
14
|
{count, startSlot}: Pick<phase0.BeaconBlocksByRangeRequest, "count" | "startSlot">,
|
|
15
|
-
serializedCache?: SerializedCache
|
|
15
|
+
serializedCache?: SerializedCache,
|
|
16
|
+
onInvalidResponse?: (chunk: ResponseIncoming) => void
|
|
16
17
|
): Promise<SignedBeaconBlock[]> {
|
|
17
18
|
const blocks: SignedBeaconBlock[] = [];
|
|
18
19
|
|
|
19
20
|
for await (const chunk of blockStream) {
|
|
20
21
|
const blockType = responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByRange](chunk.fork, chunk.protocolVersion);
|
|
21
|
-
const block = sszDeserializeResponse(blockType, chunk
|
|
22
|
+
const block = sszDeserializeResponse(blockType, chunk, onInvalidResponse);
|
|
22
23
|
|
|
23
24
|
const blockSlot = block.message.slot;
|
|
24
25
|
|
package/src/sync/range/batch.ts
CHANGED
|
@@ -633,6 +633,26 @@ export class Batch {
|
|
|
633
633
|
};
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
+
/**
|
|
637
|
+
* Downloading -> AwaitingDownload
|
|
638
|
+
*
|
|
639
|
+
* The batch may hold an evicted invalid block, drop every downloaded block and request the whole batch again
|
|
640
|
+
*/
|
|
641
|
+
downloadingInvalidBlock(peer: PeerIdStr): void {
|
|
642
|
+
if (this.state.status !== BatchStatus.Downloading) {
|
|
643
|
+
throw new BatchError(this.wrongStatusErrorType(BatchStatus.Downloading));
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
this.failedDownloadAttempts.push(peer);
|
|
647
|
+
if (this.failedDownloadAttempts.length > MAX_BATCH_DOWNLOAD_ATTEMPTS) {
|
|
648
|
+
throw new BatchError(this.errorType({code: BatchErrorCode.MAX_DOWNLOAD_ATTEMPTS}));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
this.successfulDownloads.clear();
|
|
652
|
+
this.state = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
|
|
653
|
+
this.resetRequests();
|
|
654
|
+
}
|
|
655
|
+
|
|
636
656
|
/**
|
|
637
657
|
* Downloading -> AwaitingDownload (without counting as a failed attempt).
|
|
638
658
|
* Used when the peer rate-limited us — the request was never actually served.
|
package/src/sync/range/chain.ts
CHANGED
|
@@ -602,6 +602,14 @@ export class SyncChain {
|
|
|
602
602
|
this.scheduleRateLimitBackoffRetry();
|
|
603
603
|
batch.downloadingRateLimited();
|
|
604
604
|
this.triggerBatchDownloader();
|
|
605
|
+
} else if (
|
|
606
|
+
res.err instanceof DownloadByRangeError &&
|
|
607
|
+
res.err.type.code === DownloadByRangeErrorCode.INVALID_CACHED_BLOCK
|
|
608
|
+
) {
|
|
609
|
+
if (res.err.type.blockPeer !== undefined) {
|
|
610
|
+
this.reportPeer(res.err.type.blockPeer, PeerAction.LowToleranceError, res.err.message);
|
|
611
|
+
}
|
|
612
|
+
batch.downloadingInvalidBlock(res.err.type.blockPeer ?? peer.peerId); // Throws after MAX_DOWNLOAD_ATTEMPTS
|
|
605
613
|
} else {
|
|
606
614
|
batch.downloadingError(peer.peerId); // Throws after MAX_DOWNLOAD_ATTEMPTS
|
|
607
615
|
}
|
package/src/sync/range/range.ts
CHANGED
|
@@ -3,13 +3,20 @@ import {StrictEventEmitter} from "strict-event-emitter-types";
|
|
|
3
3
|
import {BeaconConfig} from "@lodestar/config";
|
|
4
4
|
import {IBeaconStateViewGloas, computeStartSlotAtEpoch, isStatePostGloas} from "@lodestar/state-transition";
|
|
5
5
|
import {Epoch, Status, fulu, ssz} from "@lodestar/types";
|
|
6
|
-
import {Logger, byteArrayEquals, prettyPrintIndices, toRootHex} from "@lodestar/utils";
|
|
6
|
+
import {Logger, byteArrayEquals, prettyPrintIndices, toHex, toRootHex} from "@lodestar/utils";
|
|
7
7
|
import {IBlockInput} from "../../chain/blocks/blockInput/types.js";
|
|
8
8
|
import {PayloadError, PayloadErrorCode} from "../../chain/blocks/importExecutionPayload.js";
|
|
9
9
|
import {AttestationImportOpt, ImportBlockOpts} from "../../chain/blocks/index.js";
|
|
10
10
|
import {assertLinearChainSegment} from "../../chain/blocks/utils/chainSegment.js";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
BlockError,
|
|
13
|
+
BlockErrorCode,
|
|
14
|
+
BlockGossipError,
|
|
15
|
+
DataColumnSidecarErrorCode,
|
|
16
|
+
DataColumnSidecarValidationError,
|
|
17
|
+
} from "../../chain/errors/index.js";
|
|
12
18
|
import {IBeaconChain} from "../../chain/index.js";
|
|
19
|
+
import {verifyBlockProposerSignature} from "../../chain/validation/block.js";
|
|
13
20
|
import {Metrics} from "../../metrics/index.js";
|
|
14
21
|
import {INetwork} from "../../network/index.js";
|
|
15
22
|
import {PeerIdStr} from "../../util/peerId.js";
|
|
@@ -291,7 +298,7 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
|
|
|
291
298
|
...requests,
|
|
292
299
|
});
|
|
293
300
|
const {responses, payloadEnvelopes: downloadedPayloadEnvelopes} = result;
|
|
294
|
-
const {blocks, payloadEnvelopes} = cacheByRangeResponses({
|
|
301
|
+
const {blocks, payloadEnvelopes, signatureMismatch} = cacheByRangeResponses({
|
|
295
302
|
cache: this.chain.seenBlockInputCache,
|
|
296
303
|
seenPayloadEnvelopeInputCache: this.chain.seenPayloadEnvelopeInputCache,
|
|
297
304
|
peerIdStr: peer.peerId,
|
|
@@ -304,6 +311,52 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
|
|
|
304
311
|
seenTimestampSec: Date.now() / 1000,
|
|
305
312
|
});
|
|
306
313
|
|
|
314
|
+
if (signatureMismatch !== null) {
|
|
315
|
+
const {blockInput, columnSidecar} = signatureMismatch;
|
|
316
|
+
const block = blockInput.getBlock();
|
|
317
|
+
let isValidBlockSignature: boolean | null = true;
|
|
318
|
+
try {
|
|
319
|
+
await verifyBlockProposerSignature(this.chain, block, blockInput.blockRootHex);
|
|
320
|
+
} catch (e) {
|
|
321
|
+
isValidBlockSignature =
|
|
322
|
+
e instanceof BlockGossipError && e.type.code === BlockErrorCode.PROPOSAL_SIGNATURE_INVALID ? false : null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (isValidBlockSignature) {
|
|
326
|
+
throw new DataColumnSidecarValidationError(
|
|
327
|
+
{
|
|
328
|
+
code: DataColumnSidecarErrorCode.INCORRECT_BLOCK,
|
|
329
|
+
slot: blockInput.slot,
|
|
330
|
+
columnIndex: columnSidecar.index,
|
|
331
|
+
expected: toHex(block.signature),
|
|
332
|
+
actual: toHex(columnSidecar.signedBlockHeader.signature),
|
|
333
|
+
},
|
|
334
|
+
"DataColumnSidecar header signature doesn't match block signature"
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Later downloads reuse a cached block, evict it and the other unverified blocks of a peer
|
|
339
|
+
// proven to serve invalid signatures
|
|
340
|
+
const blockPeer = isValidBlockSignature === false ? blockInput.getBlockSource().peerIdStr : undefined;
|
|
341
|
+
const cache = this.chain.seenBlockInputCache;
|
|
342
|
+
for (const b of blocks) {
|
|
343
|
+
const isSuspect = b === blockInput || (blockPeer !== undefined && b.getBlockSource().peerIdStr === blockPeer);
|
|
344
|
+
if (
|
|
345
|
+
isSuspect &&
|
|
346
|
+
cache.get(b.blockRootHex) === b &&
|
|
347
|
+
!cache.isVerifiedProposerSignature(b.slot, b.blockRootHex, b.getBlock().signature)
|
|
348
|
+
) {
|
|
349
|
+
cache.remove(b.blockRootHex);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
throw new DownloadByRangeError({
|
|
353
|
+
code: DownloadByRangeErrorCode.INVALID_CACHED_BLOCK,
|
|
354
|
+
slot: blockInput.slot,
|
|
355
|
+
blockRoot: blockInput.blockRootHex,
|
|
356
|
+
blockPeer,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
307
360
|
const segmentBlocks = blocks.filter((b) => b.hasBlock()).sort((a, b) => a.slot - b.slot);
|
|
308
361
|
const envelopeSlots = payloadEnvelopes
|
|
309
362
|
? Array.from(payloadEnvelopes.entries())
|
package/src/sync/types.ts
CHANGED
|
@@ -107,6 +107,8 @@ export enum DroppedItemReason {
|
|
|
107
107
|
invalidSignature = "invalid_signature",
|
|
108
108
|
/** an unexpected / unhandled error code led to removal */
|
|
109
109
|
unknown = "unknown",
|
|
110
|
+
/** a block waiting on its parent was evicted because the peer that gossiped it exceeded its byte budget */
|
|
111
|
+
peerBudget = "peer_budget",
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
export enum PendingPayloadInputStatus {
|
|
@@ -123,6 +125,12 @@ export type PendingBlockInput = {
|
|
|
123
125
|
timeAddedSec: number;
|
|
124
126
|
timeSyncedSec?: number;
|
|
125
127
|
peerIdStrings: Set<string>;
|
|
128
|
+
/** Peer that gossiped a block retained for unknown parent sync */
|
|
129
|
+
retainedBy?: string;
|
|
130
|
+
retainedBytes?: number;
|
|
131
|
+
failedDownloads?: number;
|
|
132
|
+
/** A failed download is not retried before this time */
|
|
133
|
+
retryAtMs?: number;
|
|
126
134
|
};
|
|
127
135
|
|
|
128
136
|
export type PendingRootHex = {
|
|
@@ -131,6 +139,9 @@ export type PendingRootHex = {
|
|
|
131
139
|
timeAddedSec: number;
|
|
132
140
|
timeSyncedSec?: number;
|
|
133
141
|
peerIdStrings: Set<string>;
|
|
142
|
+
failedDownloads?: number;
|
|
143
|
+
/** A failed download is not retried before this time */
|
|
144
|
+
retryAtMs?: number;
|
|
134
145
|
};
|
|
135
146
|
|
|
136
147
|
export type BlockInputSyncCacheItem = PendingBlockInput | PendingRootHex;
|
|
@@ -161,6 +172,8 @@ export type PendingPayloadRootHex = {
|
|
|
161
172
|
export type PendingPayloadEnvelope = {
|
|
162
173
|
status: PendingPayloadInputStatus.waitingForBlock;
|
|
163
174
|
envelope: SignedExecutionPayloadEnvelope;
|
|
175
|
+
/** Peer that served the envelope, undefined if it was already cached */
|
|
176
|
+
envelopePeerId?: string;
|
|
164
177
|
timeAddedSec: number;
|
|
165
178
|
peerIdStrings: Set<string>;
|
|
166
179
|
};
|