@lodestar/beacon-node 1.52.0-dev.a9e15e2b94 → 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/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +12 -11
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/bls/utils.js +1 -1
- package/lib/chain/bls/utils.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/options.js +1 -1
- package/lib/chain/options.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/shufflingCache.d.ts +5 -0
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +39 -1
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +37 -9
- 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 +3 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +14 -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/blocks/verifyBlock.ts +14 -10
- package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
- package/src/chain/bls/utils.ts +1 -1
- 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/options.ts +1 -1
- 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/shufflingCache.ts +40 -1
- package/src/chain/validation/aggregateAndProof.ts +43 -14
- 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 +14 -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
|
@@ -10,14 +10,16 @@ import {
|
|
|
10
10
|
ForkPostCapella,
|
|
11
11
|
ForkSeq,
|
|
12
12
|
SLOTS_PER_EPOCH,
|
|
13
|
+
isForkPostElectra,
|
|
13
14
|
} from "@lodestar/params";
|
|
14
15
|
import {computeTimeAtSlot} from "@lodestar/state-transition";
|
|
15
|
-
import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz} from "@lodestar/types";
|
|
16
|
+
import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz, sszTypesFor} from "@lodestar/types";
|
|
16
17
|
import {fromHex, toRootHex} from "@lodestar/utils";
|
|
17
18
|
import {ZERO_HASH_HEX} from "../../constants/index.js";
|
|
18
19
|
import {INTEROP_BLOCK_HASH} from "../../node/utils/interop/state.js";
|
|
19
20
|
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
|
|
20
21
|
import {kzg} from "../../util/kzg.js";
|
|
22
|
+
import {computeExecutionBlockHash} from "./blockHash.js";
|
|
21
23
|
import {ClientCode, ExecutionPayloadStatus, PayloadIdCache} from "./interface.js";
|
|
22
24
|
import {
|
|
23
25
|
BlobsBundleRpc,
|
|
@@ -351,7 +353,6 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
|
|
|
351
353
|
executionPayload.gasLimit = INTEROP_GAS_LIMIT;
|
|
352
354
|
executionPayload.gasUsed = Math.floor(0.5 * INTEROP_GAS_LIMIT);
|
|
353
355
|
executionPayload.timestamp = payloadAttributes.timestamp;
|
|
354
|
-
executionPayload.blockHash = crypto.randomBytes(32);
|
|
355
356
|
const transactions: Uint8Array[] = [];
|
|
356
357
|
|
|
357
358
|
// Between 0 and 4 transactions for all forks
|
|
@@ -401,6 +402,15 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
|
|
|
401
402
|
(executionPayload as gloas.ExecutionPayload).slotNumber = payloadAttributes.slotNumber;
|
|
402
403
|
}
|
|
403
404
|
|
|
405
|
+
const executionRequests = isForkPostElectra(fork) ? sszTypesFor(fork).ExecutionRequests.defaultValue() : null;
|
|
406
|
+
|
|
407
|
+
executionPayload.blockHash = computeExecutionBlockHash(
|
|
408
|
+
fork,
|
|
409
|
+
executionPayload,
|
|
410
|
+
payloadAttributes.parentBeaconBlockRoot ?? null,
|
|
411
|
+
executionRequests
|
|
412
|
+
);
|
|
413
|
+
|
|
404
414
|
this.preparingPayloads.set(payloadId, {
|
|
405
415
|
executionPayload: serializeExecutionPayload(fork, executionPayload),
|
|
406
416
|
blobsBundle: serializeBlobsBundle({
|
|
@@ -408,12 +418,7 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
|
|
|
408
418
|
blobs,
|
|
409
419
|
proofs,
|
|
410
420
|
}),
|
|
411
|
-
executionRequests: serializeExecutionRequests(
|
|
412
|
-
fork,
|
|
413
|
-
ForkSeq[fork] >= ForkSeq.gloas
|
|
414
|
-
? ssz.gloas.ExecutionRequests.defaultValue()
|
|
415
|
-
: ssz.electra.ExecutionRequests.defaultValue()
|
|
416
|
-
),
|
|
421
|
+
executionRequests: executionRequests !== null ? serializeExecutionRequests(fork, executionRequests) : [],
|
|
417
422
|
});
|
|
418
423
|
|
|
419
424
|
// IF the payload is deemed VALID and the build process has begun
|
|
@@ -12,6 +12,9 @@ const MAX_PAYLOAD_IDS = SLOTS_PER_EPOCH;
|
|
|
12
12
|
// Since we do no processing with this id, we have no need to deserialize it
|
|
13
13
|
export type PayloadId = string;
|
|
14
14
|
|
|
15
|
+
/** Payload id returned by the engine and when the payload was requested from it, monotonic `performance.now()` ms */
|
|
16
|
+
export type PreparedPayloadId = {payloadId: PayloadId; preparedAtMs: number};
|
|
17
|
+
|
|
15
18
|
export type WithdrawalV1 = {
|
|
16
19
|
index: QUANTITY;
|
|
17
20
|
validatorIndex: QUANTITY;
|
|
@@ -26,7 +29,7 @@ type FcuAttributes = {headBlockHash: DATA} & Omit<PayloadAttributesRpc, "withdra
|
|
|
26
29
|
export class PayloadIdCache {
|
|
27
30
|
private readonly payloadIdByFcuAttributes = new Map<
|
|
28
31
|
string,
|
|
29
|
-
|
|
32
|
+
PreparedPayloadId & {fullKey: string; inclusionListTransactions?: bellatrix.Transactions}
|
|
30
33
|
>();
|
|
31
34
|
|
|
32
35
|
getFullKey({headBlockHash, timestamp, prevRandao, suggestedFeeRecipient}: FcuAttributes): string {
|
|
@@ -45,7 +48,12 @@ export class PayloadIdCache {
|
|
|
45
48
|
const key = this.getKey(fcuAttributes);
|
|
46
49
|
const fullKey = this.getFullKey(fcuAttributes);
|
|
47
50
|
const {inclusionListTransactions} = fcuAttributes;
|
|
48
|
-
this.payloadIdByFcuAttributes.set(key, {
|
|
51
|
+
this.payloadIdByFcuAttributes.set(key, {
|
|
52
|
+
payloadId,
|
|
53
|
+
preparedAtMs: performance.now(),
|
|
54
|
+
fullKey,
|
|
55
|
+
inclusionListTransactions,
|
|
56
|
+
});
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
prune(): void {
|
|
@@ -53,13 +61,13 @@ export class PayloadIdCache {
|
|
|
53
61
|
pruneSetToMax(this.payloadIdByFcuAttributes, MAX_PAYLOAD_IDS);
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
get(fcuAttributes: FcuAttributes):
|
|
64
|
+
get(fcuAttributes: FcuAttributes): PreparedPayloadId | undefined {
|
|
57
65
|
const key = this.getKey(fcuAttributes);
|
|
58
66
|
const fullKey = this.getFullKey(fcuAttributes);
|
|
59
67
|
const payloadInfo = this.payloadIdByFcuAttributes.get(key);
|
|
60
68
|
return payloadInfo?.fullKey === fullKey &&
|
|
61
69
|
isSameInclusionList(payloadInfo.inclusionListTransactions, fcuAttributes.inclusionListTransactions)
|
|
62
|
-
? payloadInfo.payloadId
|
|
70
|
+
? {payloadId: payloadInfo.payloadId, preparedAtMs: payloadInfo.preparedAtMs}
|
|
63
71
|
: undefined;
|
|
64
72
|
}
|
|
65
73
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ReqOpts,
|
|
7
7
|
} from "./jsonRpcHttpClient.js";
|
|
8
8
|
import {JwtClaim, encodeJwtToken} from "./jwt.js";
|
|
9
|
+
import {withRequestSignal} from "./signal.js";
|
|
9
10
|
import {ExecutionForkName} from "./sszTypes.js";
|
|
10
11
|
|
|
11
12
|
export const ENGINE_REST_BASE_PATH = "/engine/v1";
|
|
@@ -115,15 +116,18 @@ export class EngineRestHttpClient {
|
|
|
115
116
|
/** Perform request with retries without emitting events, used to probe support for the REST API */
|
|
116
117
|
async requestWithRetries(req: EngineRestRequest, opts?: ReqOpts): Promise<EngineRestResponse> {
|
|
117
118
|
const routeId = opts?.routeId ?? "unknown";
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
// The delay between retries has to end with the request signal as well
|
|
120
|
+
return withRequestSignal(this.opts.signal, opts?.signal, (signal) =>
|
|
121
|
+
retry(() => this.requestAnyUrl(req, opts), {
|
|
122
|
+
retries: opts?.retries ?? this.opts.retries ?? 0,
|
|
123
|
+
retryDelay: opts?.retryDelay ?? this.opts.retryDelay,
|
|
124
|
+
shouldRetry: opts?.shouldRetry ?? isRetryableEngineRestError,
|
|
125
|
+
signal,
|
|
126
|
+
onRetry: () => {
|
|
127
|
+
this.metrics?.retryCount.inc({routeId});
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
);
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
private async requestAnyUrl(req: EngineRestRequest, opts?: ReqOpts): Promise<EngineRestResponse> {
|
|
@@ -154,7 +158,8 @@ export class EngineRestHttpClient {
|
|
|
154
158
|
// Not AbortSignal.any(), Node retains every composite until the long-lived parent signal aborts
|
|
155
159
|
const onParentSignalAbort = (): void => controller.abort();
|
|
156
160
|
this.opts.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
|
|
157
|
-
|
|
161
|
+
opts?.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
|
|
162
|
+
if (this.opts.signal?.aborted || opts?.signal?.aborted) {
|
|
158
163
|
controller.abort();
|
|
159
164
|
}
|
|
160
165
|
|
|
@@ -223,7 +228,7 @@ export class EngineRestHttpClient {
|
|
|
223
228
|
} catch (e) {
|
|
224
229
|
this.metrics?.requestErrors.inc({routeId});
|
|
225
230
|
if (controller.signal.aborted) {
|
|
226
|
-
if (this.opts.signal?.aborted) {
|
|
231
|
+
if (this.opts.signal?.aborted || opts?.signal?.aborted) {
|
|
227
232
|
throw new ErrorAborted("request");
|
|
228
233
|
}
|
|
229
234
|
throw new TimeoutError("request");
|
|
@@ -235,6 +240,7 @@ export class EngineRestHttpClient {
|
|
|
235
240
|
|
|
236
241
|
clearTimeout(timeout);
|
|
237
242
|
this.opts.signal?.removeEventListener("abort", onParentSignalAbort);
|
|
243
|
+
opts?.signal?.removeEventListener("abort", onParentSignalAbort);
|
|
238
244
|
}
|
|
239
245
|
}
|
|
240
246
|
}
|
|
@@ -241,7 +241,8 @@ export class RestEngineTransport implements IEngineTransport {
|
|
|
241
241
|
headBlockHash: RootHex,
|
|
242
242
|
safeBlockHash: RootHex,
|
|
243
243
|
finalizedBlockHash: RootHex,
|
|
244
|
-
payloadAttributes?: PayloadAttributes
|
|
244
|
+
payloadAttributes?: PayloadAttributes,
|
|
245
|
+
signal?: AbortSignal
|
|
245
246
|
): Promise<ForkchoiceUpdatedResult> {
|
|
246
247
|
const forkchoiceState = {
|
|
247
248
|
headBlockHash: fromHex(headBlockHash),
|
|
@@ -279,7 +280,7 @@ export class RestEngineTransport implements IEngineTransport {
|
|
|
279
280
|
|
|
280
281
|
const res = await this.client.request(
|
|
281
282
|
{method: "POST", path: "/forkchoice", executionFork: toExecutionForkName(fork), body, responseType: "ssz"},
|
|
282
|
-
fcUReqOpts
|
|
283
|
+
{...fcUReqOpts, signal}
|
|
283
284
|
);
|
|
284
285
|
const {payloadStatus, payloadId} = deserializeResponse(
|
|
285
286
|
ForkchoiceUpdateResponse,
|
|
@@ -293,14 +294,14 @@ export class RestEngineTransport implements IEngineTransport {
|
|
|
293
294
|
};
|
|
294
295
|
}
|
|
295
296
|
|
|
296
|
-
async getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult> {
|
|
297
|
+
async getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult> {
|
|
297
298
|
if (!PAYLOAD_ID_REGEX.test(payloadId)) {
|
|
298
299
|
throw Error(`Invalid payloadId=${payloadId}, expected 0x prefixed 8 bytes hex`);
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
const res = await this.client.request(
|
|
302
303
|
{method: "GET", path: `/payloads/${payloadId}`, executionFork: toExecutionForkName(fork), responseType: "ssz"},
|
|
303
|
-
getPayloadOpts
|
|
304
|
+
{...getPayloadOpts, signal}
|
|
304
305
|
);
|
|
305
306
|
|
|
306
307
|
if (ForkSeq[fork] >= ForkSeq.gloas) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `fn` with a signal that aborts with either the signal of the client or the signal of a single request.
|
|
3
|
+
* Not AbortSignal.any(), Node retains every composite until the long-lived client signal aborts.
|
|
4
|
+
*/
|
|
5
|
+
export async function withRequestSignal<T>(
|
|
6
|
+
clientSignal: AbortSignal | undefined,
|
|
7
|
+
requestSignal: AbortSignal | undefined,
|
|
8
|
+
fn: (signal: AbortSignal | undefined) => Promise<T>
|
|
9
|
+
): Promise<T> {
|
|
10
|
+
if (requestSignal === undefined) {
|
|
11
|
+
return fn(clientSignal);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const onAbort = (): void => controller.abort();
|
|
16
|
+
clientSignal?.addEventListener("abort", onAbort, {once: true});
|
|
17
|
+
requestSignal.addEventListener("abort", onAbort, {once: true});
|
|
18
|
+
if (clientSignal?.aborted || requestSignal.aborted) {
|
|
19
|
+
controller.abort();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
return await fn(controller.signal);
|
|
24
|
+
} finally {
|
|
25
|
+
clientSignal?.removeEventListener("abort", onAbort);
|
|
26
|
+
requestSignal.removeEventListener("abort", onAbort);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -42,10 +42,11 @@ export interface IEngineTransport {
|
|
|
42
42
|
headBlockHash: RootHex,
|
|
43
43
|
safeBlockHash: RootHex,
|
|
44
44
|
finalizedBlockHash: RootHex,
|
|
45
|
-
payloadAttributes?: PayloadAttributes
|
|
45
|
+
payloadAttributes?: PayloadAttributes,
|
|
46
|
+
signal?: AbortSignal
|
|
46
47
|
): Promise<ForkchoiceUpdatedResult>;
|
|
47
48
|
|
|
48
|
-
getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult>;
|
|
49
|
+
getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult>;
|
|
49
50
|
|
|
50
51
|
getPayloadBodiesByHashV2(blockHashes: RootHex[]): Promise<(ExecutionPayloadBodyV2 | null)[]>;
|
|
51
52
|
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,12 @@ export {DbCPStateDatastore} from "./chain/stateCache/datastore/db.js";
|
|
|
7
7
|
export {FileCPStateDatastore} from "./chain/stateCache/datastore/file.js";
|
|
8
8
|
export {BeaconDb, type IBeaconDb} from "./db/index.js";
|
|
9
9
|
// Export execution engine to make it usable by builder
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
ExecutionEngineError,
|
|
12
|
+
ExecutionEngineErrorCode,
|
|
13
|
+
ExecutionPayloadStatus,
|
|
14
|
+
initializeExecutionEngine,
|
|
15
|
+
} from "./execution/index.js";
|
|
11
16
|
// Export metrics utilities to de-duplicate validator metrics
|
|
12
17
|
export {
|
|
13
18
|
type HttpMetricsServer,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {ProducedBlockSource} from "@lodestar/types";
|
|
2
2
|
import {BlockSelectionResult} from "../../api/impl/validator/index.js";
|
|
3
3
|
import {InclusionListSource} from "../../chain/blocks/types.js";
|
|
4
|
+
import {PreparePayloadReason} from "../../chain/prepareNextSlot.js";
|
|
4
5
|
import {BlockProductionStep, PayloadPreparationType} from "../../chain/produceBlock/index.js";
|
|
5
6
|
import {RegistryMetricCreator} from "../utils/registryMetricCreator.js";
|
|
6
7
|
|
|
@@ -164,6 +165,14 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
|
|
|
164
165
|
help: "Time for preparing payload in advance",
|
|
165
166
|
buckets: [0.1, 1, 3, 5, 10],
|
|
166
167
|
}),
|
|
168
|
+
payloadReprepare: register.counter<{
|
|
169
|
+
reason: PreparePayloadReason;
|
|
170
|
+
result: "changed" | "unchanged" | "dropped" | "error";
|
|
171
|
+
}>({
|
|
172
|
+
name: "beacon_block_payload_reprepare_total",
|
|
173
|
+
help: "Re-runs of the next slot payload preparation after the scheduled run, by reason and result: prepared again as the head or its parent payload changed, unchanged, dropped as the proposal slot started, or failed",
|
|
174
|
+
labelNames: ["reason", "result"],
|
|
175
|
+
}),
|
|
167
176
|
executionPayloadEnvelopeProcessingTime: register.histogram({
|
|
168
177
|
name: "beacon_block_payload_envelope_processing_seconds",
|
|
169
178
|
help: "Time to process execution payload envelope during block production",
|
|
@@ -1068,6 +1068,11 @@ export function createLodestarMetrics(
|
|
|
1068
1068
|
help: "Count of errors, by error type, while processing execution payload envelopes",
|
|
1069
1069
|
labelNames: ["error"],
|
|
1070
1070
|
}),
|
|
1071
|
+
blockHashTime: register.histogram({
|
|
1072
|
+
name: "lodestar_gossip_execution_payload_envelope_block_hash_seconds",
|
|
1073
|
+
help: "Time to compute the execution block hash of a gossip execution payload envelope",
|
|
1074
|
+
buckets: [0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.5, 1],
|
|
1075
|
+
}),
|
|
1071
1076
|
executionPayload: {
|
|
1072
1077
|
recvToValidation: register.histogram({
|
|
1073
1078
|
name: "lodestar_gossip_execution_payload_envelope_received_to_execution_payload_verification_seconds",
|
|
@@ -1784,6 +1789,15 @@ export function createLodestarMetrics(
|
|
|
1784
1789
|
help: "Time from promise insertion until promise resolution when shuffling was ready in seconds",
|
|
1785
1790
|
buckets: [0.5, 1, 1.5, 2],
|
|
1786
1791
|
}),
|
|
1792
|
+
committeePubkeysComputeTime: register.histogram({
|
|
1793
|
+
name: "lodestar_shuffling_cache_committee_pubkeys_compute_seconds",
|
|
1794
|
+
help: "Time to aggregate the committee pubkeys of a shuffling off the main thread in seconds",
|
|
1795
|
+
buckets: [0.1, 0.25, 0.5, 1, 2, 5],
|
|
1796
|
+
}),
|
|
1797
|
+
committeePubkeysErrors: register.counter({
|
|
1798
|
+
name: "lodestar_shuffling_cache_committee_pubkeys_errors_total",
|
|
1799
|
+
help: "Total number of shufflings whose committee pubkeys could not be computed",
|
|
1800
|
+
}),
|
|
1787
1801
|
},
|
|
1788
1802
|
|
|
1789
1803
|
seenCache: {
|
|
@@ -25,7 +25,7 @@ import {getSlotDurations} from "@lodestar/state-transition";
|
|
|
25
25
|
import {SubnetID} from "@lodestar/types";
|
|
26
26
|
import {Logger, Map2d, Map2dArr} from "@lodestar/utils";
|
|
27
27
|
import {RegistryMetricCreator} from "../../metrics/index.js";
|
|
28
|
-
import {
|
|
28
|
+
import {callAfterIO, callInNextEventLoop} from "../../util/eventLoop.js";
|
|
29
29
|
import {NetworkEvent, NetworkEventBus, NetworkEventData} from "../events.js";
|
|
30
30
|
import {Libp2p} from "../interface.js";
|
|
31
31
|
import {NetworkConfig} from "../networkConfig.js";
|
|
@@ -433,7 +433,7 @@ export class Eth2Gossipsub {
|
|
|
433
433
|
// See https://github.com/ChainSafe/lodestar/issues/5604
|
|
434
434
|
// A block arrives once per slot and cannot cause that lag, so it skips the 1ms timer delay
|
|
435
435
|
if (topic.type === GossipType.beacon_block) {
|
|
436
|
-
|
|
436
|
+
callAfterIO(emitPendingMessage);
|
|
437
437
|
} else {
|
|
438
438
|
callInNextEventLoop(emitPendingMessage);
|
|
439
439
|
}
|
|
@@ -505,6 +505,10 @@ export class Eth2Gossipsub {
|
|
|
505
505
|
getDirectPeers(): string[] {
|
|
506
506
|
return Array.from(this.gossipsub.direct);
|
|
507
507
|
}
|
|
508
|
+
|
|
509
|
+
isDirectPeer(peerIdStr: string): boolean {
|
|
510
|
+
return this.gossipsub.direct.has(peerIdStr);
|
|
511
|
+
}
|
|
508
512
|
}
|
|
509
513
|
|
|
510
514
|
/**
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
isForkPostGloas,
|
|
13
13
|
} from "@lodestar/params";
|
|
14
14
|
import {TypeSizes} from "@lodestar/reqresp";
|
|
15
|
-
import {
|
|
15
|
+
import {SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
|
|
16
16
|
import {GossipAction, GossipActionError, GossipErrorCode} from "../../chain/errors/gossipValidation.js";
|
|
17
17
|
import {computeMaxGloasDataColumnSidecarSize} from "../../util/sszBytes.js";
|
|
18
18
|
import {NetworkConfig} from "../networkConfig.js";
|
|
@@ -173,19 +173,6 @@ export function sszDeserialize<T extends GossipTopic>(topic: T, serializedData:
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
/**
|
|
177
|
-
* @deprecated
|
|
178
|
-
* Deserialize a gossip serialized data into an Attestation object.
|
|
179
|
-
* No longer used post-electra. Use `sszDeserializeSingleAttestation` instead
|
|
180
|
-
*/
|
|
181
|
-
export function sszDeserializeAttestation(fork: ForkName, serializedData: Uint8Array): Attestation {
|
|
182
|
-
try {
|
|
183
|
-
return sszTypesFor(fork).Attestation.deserialize(serializedData);
|
|
184
|
-
} catch (_e) {
|
|
185
|
-
throw new GossipActionError(GossipAction.REJECT, {code: GossipErrorCode.INVALID_SERIALIZED_BYTES_ERROR_CODE});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
176
|
/**
|
|
190
177
|
* Deserialize a gossip seralized data into an SingleAttestation object.
|
|
191
178
|
*/
|
package/src/network/network.ts
CHANGED
|
@@ -431,7 +431,7 @@ export class Network implements INetwork {
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
async publishBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise<number> {
|
|
434
|
-
const publishChanges = [];
|
|
434
|
+
const publishChanges: Promise<number>[] = [];
|
|
435
435
|
for (const boundary of getActiveForkBoundaries(this.config, this.clock.currentEpoch)) {
|
|
436
436
|
const fork = ForkSeq[boundary.fork];
|
|
437
437
|
|
|
@@ -447,7 +447,11 @@ export class Network implements INetwork {
|
|
|
447
447
|
if (publishChanges.length === 0) {
|
|
448
448
|
throw Error("No capella+ fork active yet to publish blsToExecutionChange");
|
|
449
449
|
}
|
|
450
|
-
|
|
450
|
+
try {
|
|
451
|
+
return await Promise.any(publishChanges);
|
|
452
|
+
} finally {
|
|
453
|
+
await Promise.allSettled(publishChanges);
|
|
454
|
+
}
|
|
451
455
|
}
|
|
452
456
|
|
|
453
457
|
async publishProposerSlashing(proposerSlashing: phase0.ProposerSlashing): Promise<number> {
|
|
@@ -596,7 +600,8 @@ export class Network implements INetwork {
|
|
|
596
600
|
request
|
|
597
601
|
),
|
|
598
602
|
request,
|
|
599
|
-
this.chain.serializedCache
|
|
603
|
+
this.chain.serializedCache,
|
|
604
|
+
() => this.reportInvalidResponse(peerId)
|
|
600
605
|
);
|
|
601
606
|
}
|
|
602
607
|
|
|
@@ -611,7 +616,8 @@ export class Network implements INetwork {
|
|
|
611
616
|
),
|
|
612
617
|
request.length,
|
|
613
618
|
responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByRoot],
|
|
614
|
-
this.chain.serializedCache
|
|
619
|
+
this.chain.serializedCache,
|
|
620
|
+
() => this.reportInvalidResponse(peerId)
|
|
615
621
|
);
|
|
616
622
|
}
|
|
617
623
|
|
|
@@ -623,28 +629,32 @@ export class Network implements INetwork {
|
|
|
623
629
|
this.sendReqRespRequest(peerId, ReqRespMethod.BeaconBlocksByHead, [Version.V1], request),
|
|
624
630
|
Math.min(request.count, this.config.MAX_REQUEST_BLOCKS_DENEB),
|
|
625
631
|
responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByHead],
|
|
626
|
-
this.chain.serializedCache
|
|
632
|
+
this.chain.serializedCache,
|
|
633
|
+
() => this.reportInvalidResponse(peerId)
|
|
627
634
|
);
|
|
628
635
|
}
|
|
629
636
|
|
|
630
637
|
async sendLightClientBootstrap(peerId: PeerIdStr, request: Root): Promise<LightClientBootstrap> {
|
|
631
638
|
return collectExactOneTyped(
|
|
632
639
|
this.sendReqRespRequest(peerId, ReqRespMethod.LightClientBootstrap, [Version.V1], request),
|
|
633
|
-
responseSszTypeByMethod[ReqRespMethod.LightClientBootstrap]
|
|
640
|
+
responseSszTypeByMethod[ReqRespMethod.LightClientBootstrap],
|
|
641
|
+
() => this.reportInvalidResponse(peerId)
|
|
634
642
|
);
|
|
635
643
|
}
|
|
636
644
|
|
|
637
645
|
async sendLightClientOptimisticUpdate(peerId: PeerIdStr): Promise<LightClientOptimisticUpdate> {
|
|
638
646
|
return collectExactOneTyped(
|
|
639
647
|
this.sendReqRespRequest(peerId, ReqRespMethod.LightClientOptimisticUpdate, [Version.V1], null),
|
|
640
|
-
responseSszTypeByMethod[ReqRespMethod.LightClientOptimisticUpdate]
|
|
648
|
+
responseSszTypeByMethod[ReqRespMethod.LightClientOptimisticUpdate],
|
|
649
|
+
() => this.reportInvalidResponse(peerId)
|
|
641
650
|
);
|
|
642
651
|
}
|
|
643
652
|
|
|
644
653
|
async sendLightClientFinalityUpdate(peerId: PeerIdStr): Promise<LightClientFinalityUpdate> {
|
|
645
654
|
return collectExactOneTyped(
|
|
646
655
|
this.sendReqRespRequest(peerId, ReqRespMethod.LightClientFinalityUpdate, [Version.V1], null),
|
|
647
|
-
responseSszTypeByMethod[ReqRespMethod.LightClientFinalityUpdate]
|
|
656
|
+
responseSszTypeByMethod[ReqRespMethod.LightClientFinalityUpdate],
|
|
657
|
+
() => this.reportInvalidResponse(peerId)
|
|
648
658
|
);
|
|
649
659
|
}
|
|
650
660
|
|
|
@@ -655,7 +665,9 @@ export class Network implements INetwork {
|
|
|
655
665
|
return collectMaxResponseTyped(
|
|
656
666
|
this.sendReqRespRequest(peerId, ReqRespMethod.LightClientUpdatesByRange, [Version.V1], request),
|
|
657
667
|
request.count,
|
|
658
|
-
responseSszTypeByMethod[ReqRespMethod.LightClientUpdatesByRange]
|
|
668
|
+
responseSszTypeByMethod[ReqRespMethod.LightClientUpdatesByRange],
|
|
669
|
+
undefined,
|
|
670
|
+
() => this.reportInvalidResponse(peerId)
|
|
659
671
|
);
|
|
660
672
|
}
|
|
661
673
|
|
|
@@ -666,7 +678,9 @@ export class Network implements INetwork {
|
|
|
666
678
|
return collectMaxResponseTyped(
|
|
667
679
|
this.sendReqRespRequest(peerId, ReqRespMethod.DataColumnSidecarsByRange, [Version.V1], request),
|
|
668
680
|
request.count * request.columns.length,
|
|
669
|
-
responseSszTypeByMethod[ReqRespMethod.DataColumnSidecarsByRange]
|
|
681
|
+
responseSszTypeByMethod[ReqRespMethod.DataColumnSidecarsByRange],
|
|
682
|
+
undefined,
|
|
683
|
+
() => this.reportInvalidResponse(peerId)
|
|
670
684
|
);
|
|
671
685
|
}
|
|
672
686
|
|
|
@@ -678,7 +692,8 @@ export class Network implements INetwork {
|
|
|
678
692
|
this.sendReqRespRequest(peerId, ReqRespMethod.DataColumnSidecarsByRoot, [Version.V1], request),
|
|
679
693
|
request.reduce((total, {columns}) => total + columns.length, 0),
|
|
680
694
|
responseSszTypeByMethod[ReqRespMethod.DataColumnSidecarsByRoot],
|
|
681
|
-
this.chain.serializedCache
|
|
695
|
+
this.chain.serializedCache,
|
|
696
|
+
() => this.reportInvalidResponse(peerId)
|
|
682
697
|
);
|
|
683
698
|
}
|
|
684
699
|
|
|
@@ -689,7 +704,9 @@ export class Network implements INetwork {
|
|
|
689
704
|
return collectMaxResponseTyped(
|
|
690
705
|
this.sendReqRespRequest(peerId, ReqRespMethod.ExecutionPayloadEnvelopesByRange, [Version.V1], request),
|
|
691
706
|
request.count,
|
|
692
|
-
responseSszTypeByMethod[ReqRespMethod.ExecutionPayloadEnvelopesByRange]
|
|
707
|
+
responseSszTypeByMethod[ReqRespMethod.ExecutionPayloadEnvelopesByRange],
|
|
708
|
+
undefined,
|
|
709
|
+
() => this.reportInvalidResponse(peerId)
|
|
693
710
|
);
|
|
694
711
|
}
|
|
695
712
|
|
|
@@ -701,10 +718,19 @@ export class Network implements INetwork {
|
|
|
701
718
|
this.sendReqRespRequest(peerId, ReqRespMethod.ExecutionPayloadEnvelopesByRoot, [Version.V1], request),
|
|
702
719
|
request.length,
|
|
703
720
|
responseSszTypeByMethod[ReqRespMethod.ExecutionPayloadEnvelopesByRoot],
|
|
704
|
-
this.chain.serializedCache
|
|
721
|
+
this.chain.serializedCache,
|
|
722
|
+
() => this.reportInvalidResponse(peerId)
|
|
705
723
|
);
|
|
706
724
|
}
|
|
707
725
|
|
|
726
|
+
private async reportInvalidResponse(peerId: PeerIdStr): Promise<void> {
|
|
727
|
+
try {
|
|
728
|
+
await this.core.reportPeer(peerId, PeerAction.LowToleranceError, "InvalidResponseSsz");
|
|
729
|
+
} catch (error) {
|
|
730
|
+
this.logger.debug("Failed to report invalid response", {peerId}, error as Error);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
708
734
|
private sendReqRespRequest<Req>(
|
|
709
735
|
peerId: PeerIdStr,
|
|
710
736
|
method: ReqRespMethod,
|
|
@@ -449,7 +449,8 @@ export class PeerManager {
|
|
|
449
449
|
.catch((e) => this.logger.verbose("cannot tag peer", {peerId: peer.toString()}, e as Error));
|
|
450
450
|
peerData.relevantStatus = RelevantPeerStatus.relevant;
|
|
451
451
|
}
|
|
452
|
-
|
|
452
|
+
// A peer rejected on connect is not tracked and may still send a status before its goodbye completes
|
|
453
|
+
if (peerData && getConnection(this.libp2p, peer.toString())) {
|
|
453
454
|
const nodeId = peerData?.nodeId ?? computeNodeId(peer);
|
|
454
455
|
// TODO(fulu): Are we sure we've run Metadata before this?
|
|
455
456
|
const custodyGroupCount = peerData?.metadata?.custodyGroupCount ?? this.config.CUSTODY_REQUIREMENT;
|
|
@@ -554,6 +555,11 @@ export class PeerManager {
|
|
|
554
555
|
// ban and disconnect peers with bad score, collect rest of healthy peers
|
|
555
556
|
const connectedHealthyPeers: PeerId[] = [];
|
|
556
557
|
for (const peer of connectedPeers) {
|
|
558
|
+
// Direct peers are trusted by the operator, a bad score never disconnects them
|
|
559
|
+
if (this.gossipsub.isDirectPeer(peer.toString())) {
|
|
560
|
+
connectedHealthyPeers.push(peer);
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
557
563
|
switch (this.peerRpcScores.getScoreState(peer)) {
|
|
558
564
|
case ScoreState.Banned:
|
|
559
565
|
this.metrics?.peerManager.peersPruned.inc({reason: "banned"});
|
|
@@ -584,9 +590,11 @@ export class PeerManager {
|
|
|
584
590
|
const prioritizeTimer = this.metrics?.peerManager.prioritizePeersDuration.startTimer();
|
|
585
591
|
const {peersToDisconnect, peersToConnect, attnetQueries, syncnetQueries, custodyGroupQueries} = prioritizePeers(
|
|
586
592
|
connectedHealthyPeers.map((peer) => {
|
|
587
|
-
const
|
|
593
|
+
const peerIdStr = peer.toString();
|
|
594
|
+
const peerData = this.connectedPeers.get(peerIdStr);
|
|
588
595
|
return {
|
|
589
596
|
id: peer,
|
|
597
|
+
direct: this.gossipsub.isDirectPeer(peerIdStr),
|
|
590
598
|
direction: peerData?.direction ?? null,
|
|
591
599
|
status: peerData?.status ?? null,
|
|
592
600
|
attnets: peerData?.metadata?.attnets ?? null,
|
|
@@ -708,6 +716,10 @@ export class PeerManager {
|
|
|
708
716
|
private updateGossipsubScores(): void {
|
|
709
717
|
const gossipsubScores = new Map<string, number>();
|
|
710
718
|
for (const peerIdStr of this.connectedPeers.keys()) {
|
|
719
|
+
// Direct peers are never disconnected, they must not take the negative score allowance of other peers
|
|
720
|
+
if (this.gossipsub.isDirectPeer(peerIdStr)) {
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
711
723
|
gossipsubScores.set(peerIdStr, this.gossipsub.getScore(peerIdStr));
|
|
712
724
|
}
|
|
713
725
|
|
|
@@ -786,6 +798,18 @@ export class PeerManager {
|
|
|
786
798
|
return false;
|
|
787
799
|
}
|
|
788
800
|
|
|
801
|
+
// The heartbeat only disconnects peers that are already connected, a peer with a bad score
|
|
802
|
+
// could otherwise reconnect right after and stay connected until the next heartbeat
|
|
803
|
+
const scoreState = this.peerRpcScores.getScoreState(remotePeer);
|
|
804
|
+
if (scoreState !== ScoreState.Healthy && !this.gossipsub.isDirectPeer(remotePeerStr)) {
|
|
805
|
+
this.logger.debug("Peer with bad score connected, disconnecting", {peer: remotePeerPrettyStr, scoreState});
|
|
806
|
+
void this.goodbyeAndDisconnect(
|
|
807
|
+
remotePeer,
|
|
808
|
+
scoreState === ScoreState.Banned ? GoodByeReasonCode.BANNED : GoodByeReasonCode.SCORE_TOO_LOW
|
|
809
|
+
);
|
|
810
|
+
return false;
|
|
811
|
+
}
|
|
812
|
+
|
|
789
813
|
if (!opts.overwriteExisting && this.connectedPeers.has(remotePeerStr)) {
|
|
790
814
|
return false;
|
|
791
815
|
}
|
|
@@ -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) {
|