@lodestar/beacon-node 1.36.0-dev.793f92c091 → 1.36.0-dev.801b1f4f52
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 +41 -22
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/config/constants.d.ts +4 -2
- package/lib/api/impl/config/constants.d.ts.map +1 -1
- package/lib/api/impl/config/constants.js +6 -3
- package/lib/api/impl/config/constants.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts +5 -0
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +35 -10
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/node/utils.js +1 -1
- package/lib/api/impl/node/utils.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +2 -2
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +9 -0
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +24 -0
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +7 -0
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +31 -5
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
- package/lib/chain/beaconProposerCache.d.ts +3 -0
- package/lib/chain/beaconProposerCache.d.ts.map +1 -1
- package/lib/chain/beaconProposerCache.js +4 -6
- package/lib/chain/beaconProposerCache.js.map +1 -1
- package/lib/chain/chain.d.ts +5 -2
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +34 -18
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blobSidecarError.d.ts +5 -0
- package/lib/chain/errors/blobSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/blobSidecarError.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +1 -0
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +27 -13
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js +5 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/errors/voluntaryExitError.d.ts +16 -2
- package/lib/chain/errors/voluntaryExitError.d.ts.map +1 -1
- package/lib/chain/errors/voluntaryExitError.js +22 -1
- package/lib/chain/errors/voluntaryExitError.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +9 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +109 -4
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/lightClient/index.d.ts +3 -0
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +24 -13
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/syncContributionAndProofPool.d.ts +3 -1
- package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
- package/lib/chain/opPools/syncContributionAndProofPool.js +4 -3
- package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
- package/lib/chain/options.d.ts +0 -2
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +2 -2
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/stateCache/datastore/db.d.ts +12 -0
- package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/db.js +70 -0
- package/lib/chain/stateCache/datastore/db.js.map +1 -1
- package/lib/chain/stateCache/datastore/file.d.ts +1 -0
- package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/file.js +7 -0
- package/lib/chain/stateCache/datastore/file.js.map +1 -1
- package/lib/chain/stateCache/datastore/types.d.ts +1 -0
- package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +16 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +31 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +6 -7
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/blobSidecar.d.ts +4 -1
- package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
- package/lib/chain/validation/blobSidecar.js +46 -11
- package/lib/chain/validation/blobSidecar.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +2 -2
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +4 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +76 -20
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -1
- package/lib/chain/validation/lightClientOptimisticUpdate.js +1 -2
- package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +5 -4
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/constants/constants.d.ts +0 -5
- package/lib/constants/constants.d.ts.map +1 -1
- package/lib/constants/constants.js +0 -5
- package/lib/constants/constants.js.map +1 -1
- package/lib/constants/network.d.ts +0 -14
- package/lib/constants/network.d.ts.map +1 -1
- package/lib/constants/network.js +0 -15
- package/lib/constants/network.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +11 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +19 -1
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/networkCore.d.ts.map +1 -1
- package/lib/network/core/networkCore.js +5 -1
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorker.js +8 -8
- package/lib/network/core/networkCoreWorker.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/discv5/utils.d.ts.map +1 -1
- package/lib/network/discv5/utils.js +1 -2
- package/lib/network/discv5/utils.js.map +1 -1
- package/lib/network/discv5/worker.js +2 -7
- package/lib/network/discv5/worker.js.map +1 -1
- package/lib/network/events.d.ts +1 -0
- package/lib/network/events.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +1 -1
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +7 -8
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +2 -0
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/gossip/snappy_bun.d.ts +3 -0
- package/lib/network/gossip/snappy_bun.d.ts.map +1 -0
- package/lib/network/gossip/snappy_bun.js +3 -0
- package/lib/network/gossip/snappy_bun.js.map +1 -0
- package/lib/network/metadata.d.ts +1 -1
- package/lib/network/metadata.d.ts.map +1 -1
- package/lib/network/metadata.js +1 -0
- package/lib/network/metadata.js.map +1 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +1 -0
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.d.ts +0 -1
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/discover.js +2 -2
- package/lib/network/peers/discover.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +28 -8
- 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 +8 -6
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/types.d.ts +2 -0
- package/lib/network/processor/types.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +3 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +2 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -3
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js +5 -5
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +4 -4
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +9 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +2 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +9 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/index.js +6 -6
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +1 -0
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/subnets/attnetsService.d.ts +1 -1
- package/lib/network/subnets/attnetsService.js +6 -6
- package/lib/network/subnets/attnetsService.js.map +1 -1
- package/lib/network/subnets/util.d.ts +3 -2
- package/lib/network/subnets/util.d.ts.map +1 -1
- package/lib/network/subnets/util.js +6 -6
- package/lib/network/subnets/util.js.map +1 -1
- package/lib/node/nodejs.d.ts +2 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +2 -1
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +2 -1
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/unknownBlock.js +1 -1
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +59 -15
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +204 -83
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +8 -14
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +18 -33
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/sync/utils/remoteSyncType.d.ts +2 -1
- package/lib/sync/utils/remoteSyncType.d.ts.map +1 -1
- package/lib/sync/utils/remoteSyncType.js +19 -4
- package/lib/sync/utils/remoteSyncType.js.map +1 -1
- package/lib/util/blobs.d.ts +1 -1
- package/lib/util/blobs.d.ts.map +1 -1
- package/lib/util/blobs.js +53 -20
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/clock.d.ts.map +1 -1
- package/lib/util/clock.js +3 -4
- package/lib/util/clock.js.map +1 -1
- package/lib/util/profile.d.ts +6 -4
- package/lib/util/profile.d.ts.map +1 -1
- package/lib/util/profile.js +40 -3
- package/lib/util/profile.js.map +1 -1
- package/lib/util/sszBytes.d.ts +2 -0
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +25 -0
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +32 -25
- package/src/api/impl/beacon/blocks/index.ts +47 -25
- package/src/api/impl/config/constants.ts +10 -4
- package/src/api/impl/lodestar/index.ts +42 -10
- package/src/api/impl/node/utils.ts +1 -1
- package/src/api/impl/validator/index.ts +5 -2
- package/src/chain/archiveStore/archiveStore.ts +27 -0
- package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +32 -5
- package/src/chain/beaconProposerCache.ts +4 -8
- package/src/chain/chain.ts +50 -25
- package/src/chain/errors/blobSidecarError.ts +12 -2
- package/src/chain/errors/blockError.ts +1 -1
- package/src/chain/errors/dataColumnSidecarError.ts +38 -15
- package/src/chain/errors/voluntaryExitError.ts +30 -2
- package/src/chain/forkChoice/index.ts +178 -2
- package/src/chain/interface.ts +2 -0
- package/src/chain/lightClient/index.ts +26 -12
- package/src/chain/opPools/syncContributionAndProofPool.ts +3 -2
- package/src/chain/options.ts +2 -3
- package/src/chain/stateCache/datastore/db.ts +89 -1
- package/src/chain/stateCache/datastore/file.ts +8 -0
- package/src/chain/stateCache/datastore/types.ts +1 -0
- package/src/chain/stateCache/persistentCheckpointsCache.ts +45 -2
- package/src/chain/validation/attestation.ts +6 -7
- package/src/chain/validation/blobSidecar.ts +54 -10
- package/src/chain/validation/block.ts +2 -2
- package/src/chain/validation/dataColumnSidecar.ts +95 -21
- package/src/chain/validation/lightClientOptimisticUpdate.ts +3 -2
- package/src/chain/validation/voluntaryExit.ts +14 -4
- package/src/constants/constants.ts +0 -6
- package/src/constants/network.ts +0 -19
- package/src/index.ts +2 -0
- package/src/metrics/metrics/lodestar.ts +22 -1
- package/src/network/core/networkCore.ts +5 -1
- package/src/network/core/networkCoreWorker.ts +9 -9
- package/src/network/core/networkCoreWorkerHandler.ts +1 -1
- package/src/network/discv5/utils.ts +1 -2
- package/src/network/discv5/worker.ts +2 -7
- package/src/network/events.ts +1 -1
- package/src/network/gossip/encoding.ts +1 -1
- package/src/network/gossip/gossipsub.ts +8 -11
- package/src/network/gossip/interface.ts +2 -0
- package/src/network/gossip/snappy_bun.ts +2 -0
- package/src/network/metadata.ts +3 -1
- package/src/network/network.ts +1 -0
- package/src/network/options.ts +0 -1
- package/src/network/peers/discover.ts +2 -2
- package/src/network/processor/gossipHandlers.ts +31 -7
- package/src/network/processor/gossipValidatorFn.ts +33 -6
- package/src/network/processor/types.ts +2 -0
- package/src/network/reqresp/ReqRespBeaconNode.ts +3 -1
- package/src/network/reqresp/handlers/beaconBlocksByRange.ts +18 -3
- package/src/network/reqresp/handlers/blobSidecarsByRange.ts +6 -6
- package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -5
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +13 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +13 -1
- package/src/network/reqresp/handlers/index.ts +6 -6
- package/src/network/reqresp/types.ts +1 -0
- package/src/network/subnets/attnetsService.ts +6 -6
- package/src/network/subnets/util.ts +12 -12
- package/src/node/nodejs.ts +3 -0
- package/src/sync/range/range.ts +2 -1
- package/src/sync/unknownBlock.ts +1 -1
- package/src/sync/utils/downloadByRange.ts +273 -108
- package/src/sync/utils/downloadByRoot.ts +22 -56
- package/src/sync/utils/remoteSyncType.ts +23 -4
- package/src/util/blobs.ts +64 -20
- package/src/util/clock.ts +3 -4
- package/src/util/profile.ts +45 -3
- package/src/util/sszBytes.ts +30 -0
package/src/network/events.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type NetworkEventData = {
|
|
|
29
29
|
clientAgent: string;
|
|
30
30
|
};
|
|
31
31
|
[NetworkEvent.peerDisconnected]: {peer: PeerIdStr};
|
|
32
|
-
[NetworkEvent.reqRespRequest]: {request: RequestTypedContainer; peer: PeerId};
|
|
32
|
+
[NetworkEvent.reqRespRequest]: {request: RequestTypedContainer; peer: PeerId; peerClient: string};
|
|
33
33
|
[NetworkEvent.pendingGossipsubMessage]: PendingGossipsubMessage;
|
|
34
34
|
[NetworkEvent.gossipMessageValidationResult]: {
|
|
35
35
|
msgId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Message} from "@libp2p/interface";
|
|
2
|
-
import {compress, uncompress} from "snappyjs";
|
|
3
2
|
import xxhashFactory from "xxhash-wasm";
|
|
3
|
+
import {compress, uncompress} from "#snappy";
|
|
4
4
|
import {digest} from "@chainsafe/as-sha256";
|
|
5
5
|
import {RPC} from "@chainsafe/libp2p-gossipsub/message";
|
|
6
6
|
import {DataTransform} from "@chainsafe/libp2p-gossipsub/types";
|
|
@@ -6,7 +6,6 @@ import {BeaconConfig, ForkBoundary} from "@lodestar/config";
|
|
|
6
6
|
import {ATTESTATION_SUBNET_COUNT, SLOTS_PER_EPOCH, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
|
|
7
7
|
import {SubnetID} from "@lodestar/types";
|
|
8
8
|
import {Logger, Map2d, Map2dArr} from "@lodestar/utils";
|
|
9
|
-
import {GOSSIP_MAX_SIZE, GOSSIP_MAX_SIZE_BELLATRIX} from "../../constants/network.js";
|
|
10
9
|
import {RegistryMetricCreator} from "../../metrics/index.js";
|
|
11
10
|
import {callInNextEventLoop} from "../../util/eventLoop.js";
|
|
12
11
|
import {NetworkEvent, NetworkEventBus, NetworkEventData} from "../events.js";
|
|
@@ -117,15 +116,7 @@ export class Eth2Gossipsub extends GossipSub {
|
|
|
117
116
|
fastMsgIdFn: fastMsgIdFn,
|
|
118
117
|
msgIdFn: msgIdFn.bind(msgIdFn, gossipTopicCache),
|
|
119
118
|
msgIdToStrFn: msgIdToStrFn,
|
|
120
|
-
|
|
121
|
-
// could only be an issue on outgoing payloads, its highly unlikely we will send out
|
|
122
|
-
// a chunk bigger than GOSSIP_MAX_SIZE pre merge even on mainnet network.
|
|
123
|
-
//
|
|
124
|
-
// TODO: figure out a way to dynamically transition to the size
|
|
125
|
-
dataTransform: new DataTransformSnappy(
|
|
126
|
-
gossipTopicCache,
|
|
127
|
-
Number.isFinite(config.BELLATRIX_FORK_EPOCH) ? GOSSIP_MAX_SIZE_BELLATRIX : GOSSIP_MAX_SIZE
|
|
128
|
-
),
|
|
119
|
+
dataTransform: new DataTransformSnappy(gossipTopicCache, config.MAX_PAYLOAD_SIZE),
|
|
129
120
|
metricsRegister: metricsRegister as MetricsRegister | null,
|
|
130
121
|
metricsTopicStrToLabel: metricsRegister
|
|
131
122
|
? getMetricsTopicStrToLabel(networkConfig, {disableLightClientServer: opts.disableLightClientServer ?? false})
|
|
@@ -305,6 +296,10 @@ export class Eth2Gossipsub extends GossipSub {
|
|
|
305
296
|
// Get seenTimestamp before adding the message to the queue or add async delays
|
|
306
297
|
const seenTimestampSec = Date.now() / 1000;
|
|
307
298
|
|
|
299
|
+
const peerIdStr = propagationSource.toString();
|
|
300
|
+
const clientAgent = this.peersData.getPeerKind(peerIdStr) ?? "Unknown";
|
|
301
|
+
const clientVersion = this.peersData.getAgentVersion(peerIdStr);
|
|
302
|
+
|
|
308
303
|
// Use setTimeout to yield to the macro queue
|
|
309
304
|
// Without this we'll have huge event loop lag
|
|
310
305
|
// See https://github.com/ChainSafe/lodestar/issues/5604
|
|
@@ -314,7 +309,9 @@ export class Eth2Gossipsub extends GossipSub {
|
|
|
314
309
|
msg,
|
|
315
310
|
msgId,
|
|
316
311
|
// Hot path, use cached .toString() version
|
|
317
|
-
propagationSource:
|
|
312
|
+
propagationSource: peerIdStr,
|
|
313
|
+
clientVersion,
|
|
314
|
+
clientAgent,
|
|
318
315
|
seenTimestampSec,
|
|
319
316
|
startProcessUnixSec: null,
|
|
320
317
|
});
|
package/src/network/metadata.ts
CHANGED
|
@@ -126,7 +126,7 @@ export class MetadataController {
|
|
|
126
126
|
* 2. Network MUST call this method on fork transition.
|
|
127
127
|
* Current Clock implementation ensures no race conditions, epoch is correct if re-fetched
|
|
128
128
|
*/
|
|
129
|
-
updateEth2Field(epoch: Epoch):
|
|
129
|
+
updateEth2Field(epoch: Epoch): phase0.ENRForkID {
|
|
130
130
|
const config = this.networkConfig.config;
|
|
131
131
|
const enrForkId = getENRForkID(config, epoch);
|
|
132
132
|
const {forkDigest, nextForkVersion, nextForkEpoch} = enrForkId;
|
|
@@ -143,6 +143,8 @@ export class MetadataController {
|
|
|
143
143
|
: ssz.ForkDigest.defaultValue();
|
|
144
144
|
this.onSetValue(ENRKey.nfd, nextForkDigest);
|
|
145
145
|
this.logger.debug("Updated nfd field in ENR", {nextForkDigest: toHex(nextForkDigest)});
|
|
146
|
+
|
|
147
|
+
return enrForkId;
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
|
package/src/network/network.ts
CHANGED
|
@@ -236,6 +236,7 @@ export class Network implements INetwork {
|
|
|
236
236
|
this.chain.emitter.off(routes.events.EventType.lightClientOptimisticUpdate, this.onLightClientOptimisticUpdate);
|
|
237
237
|
this.chain.emitter.off(ChainEvent.updateTargetCustodyGroupCount, this.onTargetGroupCountUpdated);
|
|
238
238
|
this.chain.emitter.off(ChainEvent.publishDataColumns, this.onPublishDataColumns);
|
|
239
|
+
this.chain.emitter.off(ChainEvent.publishBlobSidecars, this.onPublishBlobSidecars);
|
|
239
240
|
this.chain.emitter.off(ChainEvent.updateStatus, this.onUpdateStatus);
|
|
240
241
|
await this.core.close();
|
|
241
242
|
|
package/src/network/options.ts
CHANGED
|
@@ -391,8 +391,8 @@ export class PeerDiscovery {
|
|
|
391
391
|
// tcp multiaddr is known to be be present, checked inside the worker
|
|
392
392
|
const multiaddrTCP = enr.getLocationMultiaddr(ENRKey.tcp);
|
|
393
393
|
if (!multiaddrTCP) {
|
|
394
|
-
this.logger.
|
|
395
|
-
this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.
|
|
394
|
+
this.logger.warn("Discv5 worker sent enr without tcp multiaddr", {enr: enr.encodeTxt()});
|
|
395
|
+
this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.no_multiaddrs});
|
|
396
396
|
return;
|
|
397
397
|
}
|
|
398
398
|
// Are this fields mandatory?
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
BlockError,
|
|
40
40
|
BlockErrorCode,
|
|
41
41
|
BlockGossipError,
|
|
42
|
+
DataColumnSidecarErrorCode,
|
|
42
43
|
DataColumnSidecarGossipError,
|
|
43
44
|
GossipAction,
|
|
44
45
|
GossipActionError,
|
|
@@ -295,6 +296,21 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
295
296
|
const slot = dataColumnBlockHeader.slot;
|
|
296
297
|
const blockRootHex = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(dataColumnBlockHeader));
|
|
297
298
|
|
|
299
|
+
// check to see if block has already been processed and BlockInput has been deleted (column received via reqresp or other means)
|
|
300
|
+
if (chain.forkChoice.hasBlockHex(blockRootHex)) {
|
|
301
|
+
metrics?.peerDas.dataColumnSidecarProcessingSkip.inc();
|
|
302
|
+
logger.debug("Already processed block for column sidecar, skipping processing", {
|
|
303
|
+
slot,
|
|
304
|
+
blockRoot: blockRootHex,
|
|
305
|
+
index: dataColumnSidecar.index,
|
|
306
|
+
});
|
|
307
|
+
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
308
|
+
code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
|
|
309
|
+
columnIndex: dataColumnSidecar.index,
|
|
310
|
+
slot,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
298
314
|
// first check if we should even process this column (we may have already processed it via getBlobsV2)
|
|
299
315
|
{
|
|
300
316
|
const blockInput = chain.seenBlockInputCache.get(blockRootHex);
|
|
@@ -304,7 +320,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
304
320
|
...blockInput.getLogMeta(),
|
|
305
321
|
index: dataColumnSidecar.index,
|
|
306
322
|
});
|
|
307
|
-
|
|
323
|
+
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
324
|
+
code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
|
|
325
|
+
columnIndex: dataColumnSidecar.index,
|
|
326
|
+
slot,
|
|
327
|
+
});
|
|
308
328
|
}
|
|
309
329
|
}
|
|
310
330
|
|
|
@@ -556,6 +576,16 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
556
576
|
metrics?.dataColumns.elapsedTimeTillReceived.observe({receivedOrder: receivedColumns}, delaySec);
|
|
557
577
|
break;
|
|
558
578
|
}
|
|
579
|
+
|
|
580
|
+
if (!blockInput.hasAllData()) {
|
|
581
|
+
// immediately attempt fetch of data columns from execution engine
|
|
582
|
+
chain.getBlobsTracker.triggerGetBlobs(blockInput);
|
|
583
|
+
// if we've received at least half of the columns, trigger reconstruction of the rest
|
|
584
|
+
if (blockInput.columnCount >= NUMBER_OF_COLUMNS / 2) {
|
|
585
|
+
chain.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
559
589
|
if (!blockInput.hasBlockAndAllData()) {
|
|
560
590
|
const cutoffTimeMs = getCutoffTimeMs(chain, dataColumnSlot, BLOCK_AVAILABILITY_CUTOFF_MS);
|
|
561
591
|
chain.logger.debug("Received gossip data column, waiting for full data availability", {
|
|
@@ -578,12 +608,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
578
608
|
source: BlockInputSource.gossip,
|
|
579
609
|
});
|
|
580
610
|
});
|
|
581
|
-
// immediately attempt fetch of data columns from execution engine
|
|
582
|
-
chain.getBlobsTracker.triggerGetBlobs(blockInput);
|
|
583
|
-
// if we've received at least half of the columns, trigger reconstruction of the rest
|
|
584
|
-
if (blockInput.columnCount >= NUMBER_OF_COLUMNS / 2) {
|
|
585
|
-
chain.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
|
|
586
|
-
}
|
|
587
611
|
}
|
|
588
612
|
},
|
|
589
613
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
GossipValidatorBatchFn,
|
|
12
12
|
GossipValidatorFn,
|
|
13
13
|
} from "../gossip/interface.js";
|
|
14
|
+
import {prettyPrintPeerIdStr} from "../util.ts";
|
|
14
15
|
|
|
15
16
|
export type ValidatorFnModules = {
|
|
16
17
|
config: ChainForkConfig;
|
|
@@ -45,13 +46,19 @@ export function getGossipValidatorBatchFn(
|
|
|
45
46
|
}))
|
|
46
47
|
);
|
|
47
48
|
|
|
48
|
-
return results.map((e) => {
|
|
49
|
+
return results.map((e, i) => {
|
|
49
50
|
if (e == null) {
|
|
50
51
|
return TopicValidatorResult.Accept;
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
const {clientAgent, clientVersion, propagationSource} = messageInfos[i];
|
|
55
|
+
|
|
53
56
|
if (!(e instanceof AttestationError)) {
|
|
54
|
-
logger.debug(
|
|
57
|
+
logger.debug(
|
|
58
|
+
`Gossip batch validation ${type} threw a non-AttestationError`,
|
|
59
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
60
|
+
e as Error
|
|
61
|
+
);
|
|
55
62
|
metrics?.networkProcessor.gossipValidationIgnore.inc({topic: type});
|
|
56
63
|
return TopicValidatorResult.Ignore;
|
|
57
64
|
}
|
|
@@ -66,7 +73,11 @@ export function getGossipValidatorBatchFn(
|
|
|
66
73
|
metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
|
|
67
74
|
// only beacon_attestation topic is validated in batch
|
|
68
75
|
metrics?.networkProcessor.gossipAttestationRejectByReason.inc({reason: e.type.code});
|
|
69
|
-
logger.debug(
|
|
76
|
+
logger.debug(
|
|
77
|
+
`Gossip validation ${type} rejected`,
|
|
78
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
79
|
+
e
|
|
80
|
+
);
|
|
70
81
|
return TopicValidatorResult.Reject;
|
|
71
82
|
}
|
|
72
83
|
});
|
|
@@ -99,7 +110,15 @@ export function getGossipValidatorBatchFn(
|
|
|
99
110
|
export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: ValidatorFnModules): GossipValidatorFn {
|
|
100
111
|
const {logger, metrics} = modules;
|
|
101
112
|
|
|
102
|
-
return async function gossipValidatorFn({
|
|
113
|
+
return async function gossipValidatorFn({
|
|
114
|
+
topic,
|
|
115
|
+
msg,
|
|
116
|
+
propagationSource,
|
|
117
|
+
clientAgent,
|
|
118
|
+
clientVersion,
|
|
119
|
+
seenTimestampSec,
|
|
120
|
+
msgSlot,
|
|
121
|
+
}) {
|
|
103
122
|
const type = topic.type;
|
|
104
123
|
|
|
105
124
|
try {
|
|
@@ -116,7 +135,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
|
|
|
116
135
|
} catch (e) {
|
|
117
136
|
if (!(e instanceof GossipActionError)) {
|
|
118
137
|
// not deserve to log error here, it looks too dangerous to users
|
|
119
|
-
logger.debug(
|
|
138
|
+
logger.debug(
|
|
139
|
+
`Gossip validation ${type} threw a non-GossipActionError`,
|
|
140
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
141
|
+
e as Error
|
|
142
|
+
);
|
|
120
143
|
return TopicValidatorResult.Ignore;
|
|
121
144
|
}
|
|
122
145
|
|
|
@@ -134,7 +157,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
|
|
|
134
157
|
|
|
135
158
|
case GossipAction.REJECT:
|
|
136
159
|
metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
|
|
137
|
-
logger.debug(
|
|
160
|
+
logger.debug(
|
|
161
|
+
`Gossip validation ${type} rejected`,
|
|
162
|
+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
|
|
163
|
+
e
|
|
164
|
+
);
|
|
138
165
|
return TopicValidatorResult.Reject;
|
|
139
166
|
}
|
|
140
167
|
}
|
|
@@ -15,6 +15,8 @@ export type PendingGossipsubMessage = {
|
|
|
15
15
|
msgSlot?: Slot;
|
|
16
16
|
msgId: string;
|
|
17
17
|
propagationSource: PeerIdStr;
|
|
18
|
+
clientAgent: string;
|
|
19
|
+
clientVersion: string;
|
|
18
20
|
seenTimestampSec: number;
|
|
19
21
|
startProcessUnixSec: number | null;
|
|
20
22
|
// specific properties for IndexedGossipQueueMinSize, for beacon_attestation topic only
|
|
@@ -19,6 +19,7 @@ import {callInNextEventLoop} from "../../util/eventLoop.js";
|
|
|
19
19
|
import {NetworkCoreMetrics} from "../core/metrics.js";
|
|
20
20
|
import {INetworkEventBus, NetworkEvent} from "../events.js";
|
|
21
21
|
import {MetadataController} from "../metadata.js";
|
|
22
|
+
import {ClientKind} from "../peers/client.ts";
|
|
22
23
|
import {PeersData} from "../peers/peersData.js";
|
|
23
24
|
import {IPeerRpcScoreStore, PeerAction} from "../peers/score/index.js";
|
|
24
25
|
import {StatusCache} from "../statusCache.js";
|
|
@@ -300,10 +301,11 @@ export class ReqRespBeaconNode extends ReqResp {
|
|
|
300
301
|
}
|
|
301
302
|
|
|
302
303
|
protected onIncomingRequestBody(request: RequestTypedContainer, peer: PeerId): void {
|
|
304
|
+
const peerClient = this.peersData.getPeerKind(peer.toString()) ?? ClientKind.Unknown;
|
|
303
305
|
// Allow onRequest to return and close the stream
|
|
304
306
|
// For Goodbye there may be a race condition where the listener of `receivedGoodbye`
|
|
305
307
|
// disconnects in the same synchronous call, preventing the stream from ending cleanly
|
|
306
|
-
callInNextEventLoop(() => this.networkEventBus.emit(NetworkEvent.reqRespRequest, {request, peer}));
|
|
308
|
+
callInNextEventLoop(() => this.networkEventBus.emit(NetworkEvent.reqRespRequest, {request, peer, peerClient}));
|
|
307
309
|
}
|
|
308
310
|
|
|
309
311
|
protected onIncomingRequest(peerId: PeerId, protocol: ProtocolDescriptor): void {
|
|
@@ -1,25 +1,40 @@
|
|
|
1
|
+
import {PeerId} from "@libp2p/interface";
|
|
1
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
-
import {GENESIS_SLOT, isForkPostDeneb} from "@lodestar/params";
|
|
3
|
+
import {GENESIS_SLOT, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
|
|
3
4
|
import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
4
5
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
5
6
|
import {deneb, phase0} from "@lodestar/types";
|
|
6
7
|
import {fromHex} from "@lodestar/utils";
|
|
7
8
|
import {IBeaconChain} from "../../../chain/index.js";
|
|
8
9
|
import {IBeaconDb} from "../../../db/index.js";
|
|
10
|
+
import {prettyPrintPeerId} from "../../util.ts";
|
|
9
11
|
|
|
10
12
|
// TODO: Unit test
|
|
11
13
|
|
|
12
14
|
export async function* onBeaconBlocksByRange(
|
|
13
15
|
request: phase0.BeaconBlocksByRangeRequest,
|
|
14
16
|
chain: IBeaconChain,
|
|
15
|
-
db: IBeaconDb
|
|
17
|
+
db: IBeaconDb,
|
|
18
|
+
peerId: PeerId,
|
|
19
|
+
peerClient: string
|
|
16
20
|
): AsyncIterable<ResponseOutgoing> {
|
|
17
21
|
const {startSlot, count} = validateBeaconBlocksByRangeRequest(chain.config, request);
|
|
18
22
|
const endSlot = startSlot + count;
|
|
19
23
|
|
|
20
24
|
const finalized = db.blockArchive;
|
|
21
25
|
const unfinalized = db.block;
|
|
22
|
-
|
|
26
|
+
// in the case of initializing from a non-finalized state, we don't have the finalized block so this api does not work
|
|
27
|
+
// chain.forkChoice.getFinalizeBlock().slot
|
|
28
|
+
const finalizedSlot = chain.forkChoice.getFinalizedCheckpointSlot();
|
|
29
|
+
|
|
30
|
+
const forkName = chain.config.getForkName(startSlot);
|
|
31
|
+
if (isForkPostFulu(forkName) && startSlot < chain.earliestAvailableSlot) {
|
|
32
|
+
chain.logger.verbose("Peer did not respect earliestAvailableSlot for BeaconBlocksByRange", {
|
|
33
|
+
peer: prettyPrintPeerId(peerId),
|
|
34
|
+
client: peerClient,
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
23
38
|
|
|
24
39
|
// Finalized range of blocks
|
|
25
40
|
if (startSlot <= finalizedSlot) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ChainConfig} from "@lodestar/config";
|
|
2
|
-
import {
|
|
2
|
+
import {BLOB_SIDECAR_FIXED_SIZE, GENESIS_SLOT} from "@lodestar/params";
|
|
3
3
|
import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
4
4
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
5
5
|
import {Slot, deneb} from "@lodestar/types";
|
|
@@ -71,17 +71,17 @@ export function* iterateBlobBytesFromWrapper(
|
|
|
71
71
|
blockSlot: Slot
|
|
72
72
|
): Iterable<ResponseOutgoing> {
|
|
73
73
|
const allBlobSideCarsBytes = blobSideCarsBytesWrapped.slice(BLOB_SIDECARS_IN_WRAPPER_INDEX);
|
|
74
|
-
const blobsLen = allBlobSideCarsBytes.length /
|
|
74
|
+
const blobsLen = allBlobSideCarsBytes.length / BLOB_SIDECAR_FIXED_SIZE;
|
|
75
75
|
|
|
76
76
|
for (let index = 0; index < blobsLen; index++) {
|
|
77
77
|
const blobSideCarBytes = allBlobSideCarsBytes.slice(
|
|
78
|
-
index *
|
|
79
|
-
(index + 1) *
|
|
78
|
+
index * BLOB_SIDECAR_FIXED_SIZE,
|
|
79
|
+
(index + 1) * BLOB_SIDECAR_FIXED_SIZE
|
|
80
80
|
);
|
|
81
|
-
if (blobSideCarBytes.length !==
|
|
81
|
+
if (blobSideCarBytes.length !== BLOB_SIDECAR_FIXED_SIZE) {
|
|
82
82
|
throw new ResponseError(
|
|
83
83
|
RespStatus.SERVER_ERROR,
|
|
84
|
-
`Invalid blobSidecar index=${index} bytes length=${blobSideCarBytes.length} expected=${
|
|
84
|
+
`Invalid blobSidecar index=${index} bytes length=${blobSideCarBytes.length} expected=${BLOB_SIDECAR_FIXED_SIZE} for slot ${blockSlot} blobsLen=${blobsLen}`
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
yield {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {BLOB_SIDECAR_FIXED_SIZE} from "@lodestar/params";
|
|
2
2
|
import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
3
3
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
4
4
|
import {RootHex} from "@lodestar/types";
|
|
@@ -45,12 +45,12 @@ export async function* onBlobSidecarsByRoot(
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const blobSidecarBytes = lastFetchedSideCars.bytes.slice(
|
|
48
|
-
index *
|
|
49
|
-
(index + 1) *
|
|
48
|
+
index * BLOB_SIDECAR_FIXED_SIZE,
|
|
49
|
+
(index + 1) * BLOB_SIDECAR_FIXED_SIZE
|
|
50
50
|
);
|
|
51
|
-
if (blobSidecarBytes.length !==
|
|
51
|
+
if (blobSidecarBytes.length !== BLOB_SIDECAR_FIXED_SIZE) {
|
|
52
52
|
throw Error(
|
|
53
|
-
`Inconsistent state, blobSidecar blockRoot=${blockRootHex} index=${index} blobSidecarBytes=${blobSidecarBytes.length} expected=${
|
|
53
|
+
`Inconsistent state, blobSidecar blockRoot=${blockRootHex} index=${index} blobSidecarBytes=${blobSidecarBytes.length} expected=${BLOB_SIDECAR_FIXED_SIZE}`
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {PeerId} from "@libp2p/interface";
|
|
1
2
|
import {ChainConfig} from "@lodestar/config";
|
|
2
3
|
import {GENESIS_SLOT} from "@lodestar/params";
|
|
3
4
|
import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
@@ -6,6 +7,7 @@ import {ColumnIndex, fulu} from "@lodestar/types";
|
|
|
6
7
|
import {fromHex} from "@lodestar/utils";
|
|
7
8
|
import {IBeaconChain} from "../../../chain/index.js";
|
|
8
9
|
import {IBeaconDb} from "../../../db/index.js";
|
|
10
|
+
import {prettyPrintPeerId} from "../../util.ts";
|
|
9
11
|
import {
|
|
10
12
|
handleColumnSidecarUnavailability,
|
|
11
13
|
validateRequestedDataColumns,
|
|
@@ -14,7 +16,9 @@ import {
|
|
|
14
16
|
export async function* onDataColumnSidecarsByRange(
|
|
15
17
|
request: fulu.DataColumnSidecarsByRangeRequest,
|
|
16
18
|
chain: IBeaconChain,
|
|
17
|
-
db: IBeaconDb
|
|
19
|
+
db: IBeaconDb,
|
|
20
|
+
peerId: PeerId,
|
|
21
|
+
peerClient: string
|
|
18
22
|
): AsyncIterable<ResponseOutgoing> {
|
|
19
23
|
// Non-finalized range of columns
|
|
20
24
|
const {startSlot, count, columns: requestedColumns} = validateDataColumnSidecarsByRangeRequest(chain.config, request);
|
|
@@ -25,6 +29,14 @@ export async function* onDataColumnSidecarsByRange(
|
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
if (startSlot < chain.earliestAvailableSlot) {
|
|
33
|
+
chain.logger.verbose("Peer did not respect earliestAvailableSlot for DataColumnSidecarsByRange", {
|
|
34
|
+
peer: prettyPrintPeerId(peerId),
|
|
35
|
+
client: peerClient,
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
const finalized = db.dataColumnSidecarArchive;
|
|
29
41
|
const unfinalized = db.dataColumnSidecar;
|
|
30
42
|
const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {PeerId} from "@libp2p/interface";
|
|
1
2
|
import {ResponseOutgoing} from "@lodestar/reqresp";
|
|
2
3
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
3
4
|
import {ColumnIndex} from "@lodestar/types";
|
|
@@ -5,6 +6,7 @@ import {toRootHex} from "@lodestar/utils";
|
|
|
5
6
|
import {IBeaconChain} from "../../../chain/index.js";
|
|
6
7
|
import {IBeaconDb} from "../../../db/index.js";
|
|
7
8
|
import {DataColumnSidecarsByRootRequest} from "../../../util/types.js";
|
|
9
|
+
import {prettyPrintPeerId} from "../../util.ts";
|
|
8
10
|
import {
|
|
9
11
|
handleColumnSidecarUnavailability,
|
|
10
12
|
validateRequestedDataColumns,
|
|
@@ -13,7 +15,9 @@ import {
|
|
|
13
15
|
export async function* onDataColumnSidecarsByRoot(
|
|
14
16
|
requestBody: DataColumnSidecarsByRootRequest,
|
|
15
17
|
chain: IBeaconChain,
|
|
16
|
-
db: IBeaconDb
|
|
18
|
+
db: IBeaconDb,
|
|
19
|
+
peerId: PeerId,
|
|
20
|
+
peerClient: string
|
|
17
21
|
): AsyncIterable<ResponseOutgoing> {
|
|
18
22
|
// SPEC: minimum_request_epoch = max(current_epoch - MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS, FULU_FORK_EPOCH)
|
|
19
23
|
const currentEpoch = chain.clock.currentEpoch;
|
|
@@ -39,6 +43,14 @@ export async function* onDataColumnSidecarsByRoot(
|
|
|
39
43
|
continue;
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
if (slot < chain.earliestAvailableSlot) {
|
|
47
|
+
chain.logger.verbose("Peer did not respect earliestAvailableSlot for DataColumnSidecarsByRoot", {
|
|
48
|
+
peer: prettyPrintPeerId(peerId),
|
|
49
|
+
client: peerClient,
|
|
50
|
+
});
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
const requestedEpoch = computeEpochAtSlot(slot);
|
|
43
55
|
|
|
44
56
|
// SPEC: Clients MUST support requesting sidecars since minimum_request_epoch.
|
|
@@ -35,9 +35,9 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
|
|
|
35
35
|
[ReqRespMethod.Goodbye]: notImplemented(ReqRespMethod.Goodbye),
|
|
36
36
|
[ReqRespMethod.Ping]: notImplemented(ReqRespMethod.Ping),
|
|
37
37
|
[ReqRespMethod.Metadata]: notImplemented(ReqRespMethod.Metadata),
|
|
38
|
-
[ReqRespMethod.BeaconBlocksByRange]: (req) => {
|
|
38
|
+
[ReqRespMethod.BeaconBlocksByRange]: (req, peerId, peerClient) => {
|
|
39
39
|
const body = ssz.phase0.BeaconBlocksByRangeRequest.deserialize(req.data);
|
|
40
|
-
return onBeaconBlocksByRange(body, chain, db);
|
|
40
|
+
return onBeaconBlocksByRange(body, chain, db, peerId, peerClient);
|
|
41
41
|
},
|
|
42
42
|
[ReqRespMethod.BeaconBlocksByRoot]: (req) => {
|
|
43
43
|
const fork = chain.config.getForkName(chain.clock.currentSlot);
|
|
@@ -53,13 +53,13 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
|
|
|
53
53
|
const body = ssz.deneb.BlobSidecarsByRangeRequest.deserialize(req.data);
|
|
54
54
|
return onBlobSidecarsByRange(body, chain, db);
|
|
55
55
|
},
|
|
56
|
-
[ReqRespMethod.DataColumnSidecarsByRange]: (req) => {
|
|
56
|
+
[ReqRespMethod.DataColumnSidecarsByRange]: (req, peerId, peerClient) => {
|
|
57
57
|
const body = ssz.fulu.DataColumnSidecarsByRangeRequest.deserialize(req.data);
|
|
58
|
-
return onDataColumnSidecarsByRange(body, chain, db);
|
|
58
|
+
return onDataColumnSidecarsByRange(body, chain, db, peerId, peerClient);
|
|
59
59
|
},
|
|
60
|
-
[ReqRespMethod.DataColumnSidecarsByRoot]: (req) => {
|
|
60
|
+
[ReqRespMethod.DataColumnSidecarsByRoot]: (req, peerId, peerClient) => {
|
|
61
61
|
const body = DataColumnSidecarsByRootRequestType(chain.config).deserialize(req.data);
|
|
62
|
-
return onDataColumnSidecarsByRoot(body, chain, db);
|
|
62
|
+
return onDataColumnSidecarsByRoot(body, chain, db, peerId, peerClient);
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
[ReqRespMethod.LightClientBootstrap]: (req) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {BeaconConfig, ForkBoundary} from "@lodestar/config";
|
|
2
|
-
import {ATTESTATION_SUBNET_COUNT,
|
|
2
|
+
import {ATTESTATION_SUBNET_COUNT, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
3
3
|
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
4
4
|
import {Epoch, Slot, SubnetID, ssz} from "@lodestar/types";
|
|
5
5
|
import {Logger, MapDef} from "@lodestar/utils";
|
|
@@ -92,8 +92,8 @@ export class AttnetsService implements IAttnetsService {
|
|
|
92
92
|
const shortLivedSubnets = this.committeeSubnets.getActiveTtl(this.clock.currentSlot);
|
|
93
93
|
|
|
94
94
|
const longLivedSubscriptionsToSlot =
|
|
95
|
-
(Math.floor(this.clock.currentEpoch /
|
|
96
|
-
|
|
95
|
+
(Math.floor(this.clock.currentEpoch / this.config.EPOCHS_PER_SUBNET_SUBSCRIPTION) + 1) *
|
|
96
|
+
this.config.EPOCHS_PER_SUBNET_SUBSCRIPTION *
|
|
97
97
|
SLOTS_PER_EPOCH;
|
|
98
98
|
const longLivedSubnets = Array.from(this.longLivedSubscriptions).map((subnet) => ({
|
|
99
99
|
subnet,
|
|
@@ -234,11 +234,11 @@ export class AttnetsService implements IAttnetsService {
|
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Run per epoch, clean-up operations that are not urgent
|
|
237
|
-
* Subscribe to new random subnets every
|
|
237
|
+
* Subscribe to new random subnets every EPOCHS_PER_SUBNET_SUBSCRIPTION epochs
|
|
238
238
|
*/
|
|
239
239
|
private onEpoch = (epoch: Epoch): void => {
|
|
240
240
|
try {
|
|
241
|
-
if (epoch %
|
|
241
|
+
if (epoch % this.config.EPOCHS_PER_SUBNET_SUBSCRIPTION === 0) {
|
|
242
242
|
this.recomputeLongLivedSubnets();
|
|
243
243
|
}
|
|
244
244
|
} catch (e) {
|
|
@@ -253,7 +253,7 @@ export class AttnetsService implements IAttnetsService {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const oldSubnets = this.longLivedSubscriptions;
|
|
256
|
-
const newSubnets = computeSubscribedSubnet(this.nodeId, this.clock.currentEpoch);
|
|
256
|
+
const newSubnets = computeSubscribedSubnet(this.config, this.nodeId, this.clock.currentEpoch);
|
|
257
257
|
this.logger.verbose("Recomputing long-lived subscriptions", {
|
|
258
258
|
epoch: this.clock.currentEpoch,
|
|
259
259
|
oldSubnets: Array.from(oldSubnets).join(","),
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import {digest} from "@chainsafe/as-sha256";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ATTESTATION_SUBNET_PREFIX_BITS,
|
|
5
|
-
EPOCHS_PER_SUBNET_SUBSCRIPTION,
|
|
6
|
-
NODE_ID_BITS,
|
|
7
|
-
SUBNETS_PER_NODE,
|
|
8
|
-
} from "@lodestar/params";
|
|
2
|
+
import {ChainConfig} from "@lodestar/config";
|
|
3
|
+
import {ATTESTATION_SUBNET_COUNT, ATTESTATION_SUBNET_PREFIX_BITS, NODE_ID_BITS} from "@lodestar/params";
|
|
9
4
|
import {computeShuffledIndex} from "@lodestar/state-transition";
|
|
10
5
|
import {Epoch, ssz} from "@lodestar/types";
|
|
11
6
|
import {NodeId} from "./interface.js";
|
|
@@ -13,10 +8,10 @@ import {NodeId} from "./interface.js";
|
|
|
13
8
|
/**
|
|
14
9
|
* Spec https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md
|
|
15
10
|
*/
|
|
16
|
-
export function computeSubscribedSubnet(nodeId: NodeId, epoch: Epoch): number[] {
|
|
11
|
+
export function computeSubscribedSubnet(config: ChainConfig, nodeId: NodeId, epoch: Epoch): number[] {
|
|
17
12
|
const subnets: number[] = [];
|
|
18
|
-
for (let index = 0; index < SUBNETS_PER_NODE; index++) {
|
|
19
|
-
subnets.push(computeSubscribedSubnetByIndex(nodeId, epoch, index));
|
|
13
|
+
for (let index = 0; index < config.SUBNETS_PER_NODE; index++) {
|
|
14
|
+
subnets.push(computeSubscribedSubnetByIndex(config, nodeId, epoch, index));
|
|
20
15
|
}
|
|
21
16
|
return subnets;
|
|
22
17
|
}
|
|
@@ -24,11 +19,16 @@ export function computeSubscribedSubnet(nodeId: NodeId, epoch: Epoch): number[]
|
|
|
24
19
|
/**
|
|
25
20
|
* Spec https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md
|
|
26
21
|
*/
|
|
27
|
-
export function computeSubscribedSubnetByIndex(
|
|
22
|
+
export function computeSubscribedSubnetByIndex(
|
|
23
|
+
config: ChainConfig,
|
|
24
|
+
nodeId: NodeId,
|
|
25
|
+
epoch: Epoch,
|
|
26
|
+
index: number
|
|
27
|
+
): number {
|
|
28
28
|
const nodeIdPrefix = getNodeIdPrefix(nodeId);
|
|
29
29
|
const nodeOffset = getNodeOffset(nodeId);
|
|
30
30
|
const permutationSeed = digest(
|
|
31
|
-
ssz.UintNum64.serialize(Math.floor((epoch + nodeOffset) / EPOCHS_PER_SUBNET_SUBSCRIPTION))
|
|
31
|
+
ssz.UintNum64.serialize(Math.floor((epoch + nodeOffset) / config.EPOCHS_PER_SUBNET_SUBSCRIPTION))
|
|
32
32
|
);
|
|
33
33
|
const permutatedPrefix = computeShuffledIndex(nodeIdPrefix, 1 << ATTESTATION_SUBNET_PREFIX_BITS, permutationSeed);
|
|
34
34
|
return (permutatedPrefix + index) % ATTESTATION_SUBNET_COUNT;
|
package/src/node/nodejs.ts
CHANGED
|
@@ -53,6 +53,7 @@ export type BeaconNodeInitModules = {
|
|
|
53
53
|
dataDir: string;
|
|
54
54
|
peerStoreDir?: string;
|
|
55
55
|
anchorState: BeaconStateAllForks;
|
|
56
|
+
isAnchorStateFinalized: boolean;
|
|
56
57
|
wsCheckpoint?: phase0.Checkpoint;
|
|
57
58
|
metricsRegistries?: Registry[];
|
|
58
59
|
};
|
|
@@ -154,6 +155,7 @@ export class BeaconNode {
|
|
|
154
155
|
dataDir,
|
|
155
156
|
peerStoreDir,
|
|
156
157
|
anchorState,
|
|
158
|
+
isAnchorStateFinalized,
|
|
157
159
|
wsCheckpoint,
|
|
158
160
|
metricsRegistries = [],
|
|
159
161
|
}: BeaconNodeInitModules): Promise<T> {
|
|
@@ -217,6 +219,7 @@ export class BeaconNode {
|
|
|
217
219
|
metrics,
|
|
218
220
|
validatorMonitor,
|
|
219
221
|
anchorState,
|
|
222
|
+
isAnchorStateFinalized,
|
|
220
223
|
eth1: initializeEth1ForBlockProduction(opts.eth1, {
|
|
221
224
|
config,
|
|
222
225
|
db,
|