@lodestar/beacon-node 1.34.0-dev.8cfc843bd3 → 1.34.0-dev.8d743ffafc
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.js +162 -55
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.js +6 -12
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts +1 -1
- package/lib/api/impl/debug/index.js +24 -1
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.js +41 -24
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +1 -1
- package/lib/chain/archiveStore/archiveStore.js +2 -2
- package/lib/chain/archiveStore/interface.d.ts +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +91 -23
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/beaconProposerCache.d.ts +1 -0
- package/lib/chain/beaconProposerCache.js +3 -0
- package/lib/chain/beaconProposerCache.js.map +1 -1
- package/lib/chain/blocks/importBlock.js +3 -2
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +66 -23
- package/lib/chain/blocks/types.js +39 -5
- package/lib/chain/blocks/types.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.js +21 -10
- package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.js +89 -15
- package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
- package/lib/chain/chain.d.ts +18 -101
- package/lib/chain/chain.js +91 -67
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +18 -2
- package/lib/chain/emitter.js +13 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +69 -0
- package/lib/chain/errors/dataColumnSidecarError.js +21 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -0
- package/lib/chain/errors/index.d.ts +1 -0
- package/lib/chain/errors/index.js +1 -0
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/interface.d.ts +6 -7
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/options.d.ts +4 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.js +2 -1
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +30 -16
- package/lib/chain/produceBlock/produceBlockBody.js +28 -28
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.d.ts +6 -3
- package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.js +28 -4
- package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts +64 -18
- package/lib/chain/seenCache/seenGossipBlockInput.js +321 -53
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +29 -0
- package/lib/chain/validation/dataColumnSidecar.js +248 -0
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -0
- package/lib/db/beacon.d.ts +3 -1
- package/lib/db/beacon.js +3 -1
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +3 -1
- package/lib/db/buckets.js +2 -0
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +3 -1
- package/lib/db/repositories/dataColumnSidecars.d.ts +47 -0
- package/lib/db/repositories/dataColumnSidecars.js +40 -0
- package/lib/db/repositories/dataColumnSidecars.js.map +1 -0
- package/lib/db/repositories/dataColumnSidecarsArchive.d.ts +15 -0
- package/lib/db/repositories/dataColumnSidecarsArchive.js +23 -0
- package/lib/db/repositories/dataColumnSidecarsArchive.js.map +1 -0
- package/lib/db/repositories/index.d.ts +2 -0
- package/lib/db/repositories/index.js +2 -0
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/execution/builder/http.d.ts +20 -4
- package/lib/execution/builder/http.js +30 -11
- package/lib/execution/builder/http.js.map +1 -1
- package/lib/execution/builder/interface.d.ts +5 -4
- package/lib/execution/engine/http.d.ts +8 -5
- package/lib/execution/engine/http.js +56 -42
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +6 -13
- package/lib/execution/engine/interface.js +1 -1
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/mock.d.ts +1 -0
- package/lib/execution/engine/mock.js +5 -0
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/types.d.ts +12 -2
- package/lib/execution/engine/types.js +8 -2
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +15 -5
- package/lib/metrics/metrics/beacon.js +61 -14
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +24 -1
- package/lib/metrics/metrics/lodestar.js +45 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/metrics.d.ts +10 -3
- package/lib/network/core/metrics.js +22 -4
- package/lib/network/core/metrics.js.map +1 -1
- package/lib/network/core/networkCore.d.ts +15 -4
- package/lib/network/core/networkCore.js +73 -23
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorker.js +2 -0
- package/lib/network/core/networkCoreWorker.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts +5 -3
- package/lib/network/core/networkCoreWorkerHandler.js +6 -1
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/core/types.d.ts +7 -4
- package/lib/network/events.d.ts +4 -2
- package/lib/network/events.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +2 -2
- package/lib/network/gossip/gossipsub.js +8 -6
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +8 -1
- package/lib/network/gossip/interface.js +1 -0
- package/lib/network/gossip/interface.js.map +1 -1
- package/lib/network/gossip/scoringParameters.d.ts +6 -2
- package/lib/network/gossip/scoringParameters.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +2005 -1456
- package/lib/network/gossip/topic.js +29 -1
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/interface.d.ts +9 -1
- package/lib/network/metadata.d.ts +9 -5
- package/lib/network/metadata.js +26 -5
- package/lib/network/metadata.js.map +1 -1
- package/lib/network/network.d.ts +12 -2
- package/lib/network/network.js +73 -11
- package/lib/network/network.js.map +1 -1
- package/lib/network/networkConfig.d.ts +12 -0
- package/lib/network/networkConfig.js +2 -0
- package/lib/network/networkConfig.js.map +1 -0
- package/lib/network/options.d.ts +1 -0
- package/lib/network/options.js +5 -0
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/discover.d.ts +8 -3
- package/lib/network/peers/discover.js +99 -14
- package/lib/network/peers/discover.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts +10 -4
- package/lib/network/peers/peerManager.js +105 -19
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/peersData.d.ts +17 -3
- package/lib/network/peers/peersData.js.map +1 -1
- package/lib/network/peers/score/interface.d.ts +1 -1
- package/lib/network/peers/score/score.d.ts +2 -2
- package/lib/network/peers/score/score.js +4 -1
- package/lib/network/peers/score/score.js.map +1 -1
- package/lib/network/peers/score/store.d.ts +3 -1
- package/lib/network/peers/score/store.js +6 -2
- package/lib/network/peers/score/store.js.map +1 -1
- package/lib/network/peers/utils/assertPeerRelevance.d.ts +7 -3
- package/lib/network/peers/utils/assertPeerRelevance.js +10 -1
- package/lib/network/peers/utils/assertPeerRelevance.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +19 -7
- package/lib/network/peers/utils/prioritizePeers.js +42 -6
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/network/processor/extractSlotRootFns.js +8 -1
- package/lib/network/processor/extractSlotRootFns.js.map +1 -1
- package/lib/network/processor/gossipHandlers.js +165 -16
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/index.js +5 -0
- package/lib/network/processor/gossipQueues/index.js.map +1 -1
- package/lib/network/processor/index.js +1 -0
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts +2 -2
- package/lib/network/reqresp/ReqRespBeaconNode.js +36 -14
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.d.ts +24 -4
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js +259 -20
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js.map +1 -1
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.d.ts +32 -6
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js +283 -28
- package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +8 -0
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +92 -0
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -0
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +6 -0
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +50 -0
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -0
- package/lib/network/reqresp/handlers/index.js +10 -0
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts +4 -0
- package/lib/network/reqresp/protocols.js +20 -0
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/rateLimit.js +10 -0
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/score.js +3 -0
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +11 -4
- package/lib/network/reqresp/types.js +12 -3
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/network/statusCache.d.ts +5 -5
- package/lib/network/statusCache.js.map +1 -1
- package/lib/network/subnets/interface.d.ts +3 -0
- package/lib/network/subnets/interface.js +14 -1
- package/lib/network/subnets/interface.js.map +1 -1
- package/lib/network/subnets/syncnetsService.js +4 -5
- package/lib/network/subnets/syncnetsService.js.map +1 -1
- package/lib/node/nodejs.js +1 -0
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/constants.d.ts +18 -3
- package/lib/sync/constants.js +21 -3
- package/lib/sync/constants.js.map +1 -1
- package/lib/sync/interface.d.ts +2 -2
- package/lib/sync/interface.js +1 -1
- package/lib/sync/interface.js.map +1 -1
- package/lib/sync/range/batch.d.ts +17 -2
- package/lib/sync/range/batch.js +39 -7
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +15 -1
- package/lib/sync/range/chain.js +124 -33
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts +3 -2
- package/lib/sync/range/range.js +9 -3
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/chainTarget.d.ts +5 -1
- package/lib/sync/range/utils/chainTarget.js +26 -1
- package/lib/sync/range/utils/chainTarget.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts +19 -5
- package/lib/sync/range/utils/peerBalancer.js +104 -10
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/sync.js +1 -1
- package/lib/sync/sync.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +10 -2
- package/lib/sync/unknownBlock.js +257 -76
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/remoteSyncType.d.ts +4 -4
- package/lib/sync/utils/remoteSyncType.js.map +1 -1
- package/lib/util/blobs.d.ts +16 -4
- package/lib/util/blobs.js +122 -5
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/dataColumns.d.ts +137 -0
- package/lib/util/dataColumns.js +358 -0
- package/lib/util/dataColumns.js.map +1 -0
- package/lib/util/metadata.d.ts +5 -0
- package/lib/util/metadata.js +10 -0
- package/lib/util/metadata.js.map +1 -1
- package/lib/util/sszBytes.d.ts +1 -0
- package/lib/util/sszBytes.js +17 -0
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +16 -16
- package/lib/network/reqresp/handlers/status.d.ts +0 -4
- package/lib/network/reqresp/handlers/status.js +0 -11
- package/lib/network/reqresp/handlers/status.js.map +0 -1
package/lib/chain/chain.d.ts
CHANGED
|
@@ -3,15 +3,17 @@ import { CompositeTypeAny, TreeView, Type } from "@chainsafe/ssz";
|
|
|
3
3
|
import { BeaconConfig } from "@lodestar/config";
|
|
4
4
|
import { CheckpointWithHex, IForkChoice, ProtoBlock } from "@lodestar/fork-choice";
|
|
5
5
|
import { BeaconStateAllForks, CachedBeaconStateAllForks, EpochShuffling, Index2PubkeyCache } from "@lodestar/state-transition";
|
|
6
|
-
import { BeaconBlock, BlindedBeaconBlock, Epoch, Root, RootHex, SignedBeaconBlock, Slot, UintNum64, ValidatorIndex, Wei
|
|
6
|
+
import { BeaconBlock, BlindedBeaconBlock, Epoch, Root, RootHex, SignedBeaconBlock, Slot, Status, UintNum64, ValidatorIndex, Wei } from "@lodestar/types";
|
|
7
7
|
import { Logger } from "@lodestar/utils";
|
|
8
8
|
import { ProcessShutdownCallback } from "@lodestar/validator";
|
|
9
|
+
import { PrivateKey } from "@libp2p/interface";
|
|
9
10
|
import { IBeaconDb } from "../db/index.js";
|
|
10
11
|
import { IEth1ForBlockProduction } from "../eth1/index.js";
|
|
11
12
|
import { IExecutionBuilder, IExecutionEngine } from "../execution/index.js";
|
|
12
13
|
import { Metrics } from "../metrics/index.js";
|
|
13
14
|
import { BufferPool } from "../util/bufferPool.js";
|
|
14
15
|
import { IClock } from "../util/clock.js";
|
|
16
|
+
import { CustodyConfig } from "../util/dataColumns.js";
|
|
15
17
|
import { SerializedCache } from "../util/serializedCache.js";
|
|
16
18
|
import { ArchiveStore } from "./archiveStore/archiveStore.js";
|
|
17
19
|
import { CheckpointBalancesCache } from "./balancesCache.js";
|
|
@@ -25,7 +27,7 @@ import { CommonBlockBody, IBeaconChain, ProposerPreparationData, StateGetOpts }
|
|
|
25
27
|
import { LightClientServer } from "./lightClient/index.js";
|
|
26
28
|
import { AggregatedAttestationPool, AttestationPool, OpPool, SyncCommitteeMessagePool, SyncContributionAndProofPool } from "./opPools/index.js";
|
|
27
29
|
import { IChainOptions } from "./options.js";
|
|
28
|
-
import { AssembledBlockType, BlockType } from "./produceBlock/index.js";
|
|
30
|
+
import { AssembledBlockType, BlockType, ProduceResult } from "./produceBlock/index.js";
|
|
29
31
|
import { BlockAttributes } from "./produceBlock/produceBlockBody.js";
|
|
30
32
|
import { QueuedStateRegenerator, RegenCaller } from "./regen/index.js";
|
|
31
33
|
import { ReprocessController } from "./reprocess.js";
|
|
@@ -47,6 +49,7 @@ export declare class BeaconChain implements IBeaconChain {
|
|
|
47
49
|
readonly executionEngine: IExecutionEngine;
|
|
48
50
|
readonly executionBuilder?: IExecutionBuilder;
|
|
49
51
|
readonly config: BeaconConfig;
|
|
52
|
+
readonly custodyConfig: CustodyConfig;
|
|
50
53
|
readonly logger: Logger;
|
|
51
54
|
readonly metrics: Metrics | null;
|
|
52
55
|
readonly validatorMonitor: ValidatorMonitor | null;
|
|
@@ -80,92 +83,12 @@ export declare class BeaconChain implements IBeaconChain {
|
|
|
80
83
|
readonly beaconProposerCache: BeaconProposerCache;
|
|
81
84
|
readonly checkpointBalancesCache: CheckpointBalancesCache;
|
|
82
85
|
readonly shufflingCache: ShufflingCache;
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
stateRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
90
|
-
receiptsRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
91
|
-
logsBloom: import("@chainsafe/ssz").ByteVectorType;
|
|
92
|
-
prevRandao: import("@chainsafe/ssz").ByteVectorType;
|
|
93
|
-
blockNumber: import("@chainsafe/ssz").UintNumberType;
|
|
94
|
-
gasLimit: import("@chainsafe/ssz").UintNumberType;
|
|
95
|
-
gasUsed: import("@chainsafe/ssz").UintNumberType;
|
|
96
|
-
timestamp: import("@chainsafe/ssz").UintNumberType;
|
|
97
|
-
extraData: import("@chainsafe/ssz").ByteListType;
|
|
98
|
-
baseFeePerGas: import("@chainsafe/ssz").UintBigintType;
|
|
99
|
-
blockHash: import("@chainsafe/ssz").ByteVectorType;
|
|
100
|
-
}> | import("@chainsafe/ssz").ValueOfFields<{
|
|
101
|
-
withdrawals: import("@chainsafe/ssz").ListCompositeType<import("@chainsafe/ssz").ContainerType<{
|
|
102
|
-
index: import("@chainsafe/ssz").UintNumberType;
|
|
103
|
-
validatorIndex: import("@chainsafe/ssz").UintNumberType;
|
|
104
|
-
address: import("@lodestar/types/lib/utils/executionAddress.js").ExecutionAddressType;
|
|
105
|
-
amount: import("@chainsafe/ssz").UintBigintType;
|
|
106
|
-
}>>;
|
|
107
|
-
transactions: import("@chainsafe/ssz").ListCompositeType<import("@chainsafe/ssz").ByteListType>;
|
|
108
|
-
parentHash: import("@chainsafe/ssz").ByteVectorType;
|
|
109
|
-
feeRecipient: import("@lodestar/types/lib/utils/executionAddress.js").ExecutionAddressType;
|
|
110
|
-
stateRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
111
|
-
receiptsRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
112
|
-
logsBloom: import("@chainsafe/ssz").ByteVectorType;
|
|
113
|
-
prevRandao: import("@chainsafe/ssz").ByteVectorType;
|
|
114
|
-
blockNumber: import("@chainsafe/ssz").UintNumberType;
|
|
115
|
-
gasLimit: import("@chainsafe/ssz").UintNumberType;
|
|
116
|
-
gasUsed: import("@chainsafe/ssz").UintNumberType;
|
|
117
|
-
timestamp: import("@chainsafe/ssz").UintNumberType;
|
|
118
|
-
extraData: import("@chainsafe/ssz").ByteListType;
|
|
119
|
-
baseFeePerGas: import("@chainsafe/ssz").UintBigintType;
|
|
120
|
-
blockHash: import("@chainsafe/ssz").ByteVectorType;
|
|
121
|
-
}> | import("@chainsafe/ssz").ValueOfFields<{
|
|
122
|
-
blobGasUsed: import("@chainsafe/ssz").UintBigintType;
|
|
123
|
-
excessBlobGas: import("@chainsafe/ssz").UintBigintType;
|
|
124
|
-
withdrawals: import("@chainsafe/ssz").ListCompositeType<import("@chainsafe/ssz").ContainerType<{
|
|
125
|
-
index: import("@chainsafe/ssz").UintNumberType;
|
|
126
|
-
validatorIndex: import("@chainsafe/ssz").UintNumberType;
|
|
127
|
-
address: import("@lodestar/types/lib/utils/executionAddress.js").ExecutionAddressType;
|
|
128
|
-
amount: import("@chainsafe/ssz").UintBigintType;
|
|
129
|
-
}>>;
|
|
130
|
-
transactions: import("@chainsafe/ssz").ListCompositeType<import("@chainsafe/ssz").ByteListType>;
|
|
131
|
-
parentHash: import("@chainsafe/ssz").ByteVectorType;
|
|
132
|
-
feeRecipient: import("@lodestar/types/lib/utils/executionAddress.js").ExecutionAddressType;
|
|
133
|
-
stateRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
134
|
-
receiptsRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
135
|
-
logsBloom: import("@chainsafe/ssz").ByteVectorType;
|
|
136
|
-
prevRandao: import("@chainsafe/ssz").ByteVectorType;
|
|
137
|
-
blockNumber: import("@chainsafe/ssz").UintNumberType;
|
|
138
|
-
gasLimit: import("@chainsafe/ssz").UintNumberType;
|
|
139
|
-
gasUsed: import("@chainsafe/ssz").UintNumberType;
|
|
140
|
-
timestamp: import("@chainsafe/ssz").UintNumberType;
|
|
141
|
-
extraData: import("@chainsafe/ssz").ByteListType;
|
|
142
|
-
baseFeePerGas: import("@chainsafe/ssz").UintBigintType;
|
|
143
|
-
blockHash: import("@chainsafe/ssz").ByteVectorType;
|
|
144
|
-
}> | import("@chainsafe/ssz").ValueOfFields<{
|
|
145
|
-
blobGasUsed: import("@chainsafe/ssz").UintBigintType;
|
|
146
|
-
excessBlobGas: import("@chainsafe/ssz").UintBigintType;
|
|
147
|
-
withdrawals: import("@chainsafe/ssz").ListCompositeType<import("@chainsafe/ssz").ContainerType<{
|
|
148
|
-
index: import("@chainsafe/ssz").UintNumberType;
|
|
149
|
-
validatorIndex: import("@chainsafe/ssz").UintNumberType;
|
|
150
|
-
address: import("@lodestar/types/lib/utils/executionAddress.js").ExecutionAddressType;
|
|
151
|
-
amount: import("@chainsafe/ssz").UintBigintType;
|
|
152
|
-
}>>;
|
|
153
|
-
transactions: import("@chainsafe/ssz").ListCompositeType<import("@chainsafe/ssz").ByteListType>;
|
|
154
|
-
parentHash: import("@chainsafe/ssz").ByteVectorType;
|
|
155
|
-
feeRecipient: import("@lodestar/types/lib/utils/executionAddress.js").ExecutionAddressType;
|
|
156
|
-
stateRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
157
|
-
receiptsRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
158
|
-
logsBloom: import("@chainsafe/ssz").ByteVectorType;
|
|
159
|
-
prevRandao: import("@chainsafe/ssz").ByteVectorType;
|
|
160
|
-
blockNumber: import("@chainsafe/ssz").UintNumberType;
|
|
161
|
-
gasLimit: import("@chainsafe/ssz").UintNumberType;
|
|
162
|
-
gasUsed: import("@chainsafe/ssz").UintNumberType;
|
|
163
|
-
timestamp: import("@chainsafe/ssz").UintNumberType;
|
|
164
|
-
extraData: import("@chainsafe/ssz").ByteListType;
|
|
165
|
-
baseFeePerGas: import("@chainsafe/ssz").UintBigintType;
|
|
166
|
-
blockHash: import("@chainsafe/ssz").ByteVectorType;
|
|
167
|
-
}> | null>;
|
|
168
|
-
readonly producedBlindedBlockRoot: Set<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Cache produced results (ExecutionPayload, DA Data) from the local execution so that we can send
|
|
88
|
+
* and get signed/published blinded versions which beacon node can
|
|
89
|
+
* assemble into full blocks before publishing to the network.
|
|
90
|
+
*/
|
|
91
|
+
readonly blockProductionCache: Map<string, ProduceResult>;
|
|
169
92
|
readonly blacklistedBlocks: Map<RootHex, Slot | null>;
|
|
170
93
|
readonly serializedCache: SerializedCache;
|
|
171
94
|
readonly opts: IChainOptions;
|
|
@@ -173,7 +96,11 @@ export declare class BeaconChain implements IBeaconChain {
|
|
|
173
96
|
protected readonly db: IBeaconDb;
|
|
174
97
|
private abortController;
|
|
175
98
|
private processShutdownCallback;
|
|
176
|
-
|
|
99
|
+
private _earliestAvailableSlot;
|
|
100
|
+
get earliestAvailableSlot(): Slot;
|
|
101
|
+
set earliestAvailableSlot(slot: Slot);
|
|
102
|
+
constructor(opts: IChainOptions, { privateKey, config, db, dbName, dataDir, logger, processShutdownCallback, clock, metrics, validatorMonitor, anchorState, eth1, executionEngine, executionBuilder, }: {
|
|
103
|
+
privateKey: PrivateKey;
|
|
177
104
|
config: BeaconConfig;
|
|
178
105
|
db: IBeaconDb;
|
|
179
106
|
dbName: string;
|
|
@@ -261,20 +188,9 @@ export declare class BeaconChain implements IBeaconChain {
|
|
|
261
188
|
consensusBlockValue: Wei;
|
|
262
189
|
shouldOverrideBuilder?: boolean;
|
|
263
190
|
}>;
|
|
264
|
-
/**
|
|
265
|
-
* https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/validator.md#sidecar
|
|
266
|
-
* def get_blobs_sidecar(block: BeaconBlock, blobs: Sequence[Blob]) -> BlobSidecars:
|
|
267
|
-
* return BlobSidecars(
|
|
268
|
-
* beacon_block_root=hash_tree_root(block),
|
|
269
|
-
* beacon_block_slot=block.slot,
|
|
270
|
-
* blobs=blobs,
|
|
271
|
-
* kzg_aggregated_proof=compute_proof_from_blobs(blobs),
|
|
272
|
-
* )
|
|
273
|
-
*/
|
|
274
|
-
getContents(beaconBlock: deneb.BeaconBlock): deneb.Contents;
|
|
275
191
|
processBlock(block: BlockInput, opts?: ImportBlockOpts): Promise<void>;
|
|
276
192
|
processChainSegment(blocks: BlockInput[], opts?: ImportBlockOpts): Promise<void>;
|
|
277
|
-
getStatus():
|
|
193
|
+
getStatus(): Status;
|
|
278
194
|
recomputeForkChoiceHead(caller: ForkchoiceCaller): ProtoBlock;
|
|
279
195
|
predictProposerHead(slot: Slot): ProtoBlock;
|
|
280
196
|
getProposerHead(slot: Slot): ProtoBlock;
|
|
@@ -322,6 +238,7 @@ export declare class BeaconChain implements IBeaconChain {
|
|
|
322
238
|
private onForkChoiceJustified;
|
|
323
239
|
private onForkChoiceFinalized;
|
|
324
240
|
updateBeaconProposerData(epoch: Epoch, proposers: ProposerPreparationData[]): Promise<void>;
|
|
241
|
+
private updateValidatorsCustodyRequirement;
|
|
325
242
|
updateBuilderStatus(clockSlot: Slot): void;
|
|
326
243
|
getBlockRewards(block: BeaconBlock | BlindedBeaconBlock): Promise<BlockRewards>;
|
|
327
244
|
getAttestationsRewards(epoch: Epoch, validatorIds?: (ValidatorIndex | string)[]): Promise<{
|
package/lib/chain/chain.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { PubkeyIndexMap } from "@chainsafe/pubkey-index-map";
|
|
3
3
|
import { ExecutionStatus, UpdateHeadOpt } from "@lodestar/fork-choice";
|
|
4
|
-
import {
|
|
4
|
+
import { GENESIS_SLOT, SLOTS_PER_EPOCH, isForkPostElectra } from "@lodestar/params";
|
|
5
5
|
import { computeAnchorCheckpoint, computeEndSlotAtEpoch, computeEpochAtSlot, computeStartSlotAtEpoch, createCachedBeaconState, getEffectiveBalanceIncrementsZeroInactive, isCachedBeaconState, processSlots, } from "@lodestar/state-transition";
|
|
6
6
|
import { isBlindedBeaconBlock, } from "@lodestar/types";
|
|
7
7
|
import { fromHex, gweiToWei, isErrorAborted, pruneSetToMax, sleep, toRootHex } from "@lodestar/utils";
|
|
8
|
+
import { getEffectiveBalancesFromStateBytes } from "@lodestar/state-transition";
|
|
8
9
|
import { GENESIS_EPOCH, ZERO_HASH } from "../constants/index.js";
|
|
10
|
+
import { BuilderStatus } from "../execution/builder/http.js";
|
|
11
|
+
import { computeNodeIdFromPrivateKey } from "../network/subnets/interface.js";
|
|
9
12
|
import { BufferPool } from "../util/bufferPool.js";
|
|
10
13
|
import { Clock, ClockEvent } from "../util/clock.js";
|
|
14
|
+
import { CustodyConfig, getValidatorsCustodyRequirement } from "../util/dataColumns.js";
|
|
11
15
|
import { ensureDir, writeIfNotExist } from "../util/file.js";
|
|
12
16
|
import { isOptimisticBlock } from "../util/forkChoice.js";
|
|
13
17
|
import { SerializedCache } from "../util/serializedCache.js";
|
|
@@ -18,12 +22,12 @@ import { BlockProcessor } from "./blocks/index.js";
|
|
|
18
22
|
import { BlsMultiThreadWorkerPool, BlsSingleThreadVerifier } from "./bls/index.js";
|
|
19
23
|
import { ChainEvent, ChainEventEmitter } from "./emitter.js";
|
|
20
24
|
import { initializeForkChoice } from "./forkChoice/index.js";
|
|
21
|
-
import { FindHeadFnName
|
|
25
|
+
import { FindHeadFnName } from "./interface.js";
|
|
22
26
|
import { LightClientServer } from "./lightClient/index.js";
|
|
23
27
|
import { AggregatedAttestationPool, AttestationPool, OpPool, SyncCommitteeMessagePool, SyncContributionAndProofPool, } from "./opPools/index.js";
|
|
24
28
|
import { PrepareNextSlotScheduler } from "./prepareNextSlot.js";
|
|
25
29
|
import { computeNewStateRoot } from "./produceBlock/computeNewStateRoot.js";
|
|
26
|
-
import {
|
|
30
|
+
import { BlockType } from "./produceBlock/index.js";
|
|
27
31
|
import { produceBlockBody, produceCommonBlockBody } from "./produceBlock/produceBlockBody.js";
|
|
28
32
|
import { QueuedStateRegenerator, RegenCaller } from "./regen/index.js";
|
|
29
33
|
import { ReprocessController } from "./reprocess.js";
|
|
@@ -44,29 +48,38 @@ import { FIFOBlockStateCache } from "./stateCache/fifoBlockStateCache.js";
|
|
|
44
48
|
import { InMemoryCheckpointStateCache } from "./stateCache/inMemoryCheckpointsCache.js";
|
|
45
49
|
import { PersistentCheckpointStateCache } from "./stateCache/persistentCheckpointsCache.js";
|
|
46
50
|
/**
|
|
47
|
-
*
|
|
51
|
+
* The maximum number of cached produced results to keep in memory.
|
|
52
|
+
*
|
|
53
|
+
* Arbitrary constant. Blobs and payloads should be consumed immediately in the same slot
|
|
48
54
|
* they are produced. A value of 1 would probably be sufficient. However it's sensible to
|
|
49
55
|
* allow some margin if the node overloads.
|
|
50
56
|
*/
|
|
51
|
-
const
|
|
57
|
+
const DEFAULT_MAX_CACHED_PRODUCED_RESULTS = 4;
|
|
52
58
|
export class BeaconChain {
|
|
53
|
-
|
|
59
|
+
get earliestAvailableSlot() {
|
|
60
|
+
return this._earliestAvailableSlot;
|
|
61
|
+
}
|
|
62
|
+
set earliestAvailableSlot(slot) {
|
|
63
|
+
if (this._earliestAvailableSlot !== slot) {
|
|
64
|
+
this._earliestAvailableSlot = slot;
|
|
65
|
+
this.emitter.emit(ChainEvent.updateStatus);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
constructor(opts, { privateKey, config, db, dbName, dataDir, logger, processShutdownCallback, clock, metrics, validatorMonitor, anchorState, eth1, executionEngine, executionBuilder, }) {
|
|
54
69
|
this.opPool = new OpPool();
|
|
55
70
|
// Gossip seen cache
|
|
56
71
|
this.seenAttesters = new SeenAttesters();
|
|
57
72
|
this.seenAggregators = new SeenAggregators();
|
|
58
73
|
this.seenBlockProposers = new SeenBlockProposers();
|
|
59
74
|
this.seenSyncCommitteeMessages = new SeenSyncCommitteeMessages();
|
|
60
|
-
this.seenGossipBlockInput = new SeenGossipBlockInput();
|
|
61
75
|
// Seen cache for liveness checks
|
|
62
76
|
this.seenBlockAttesters = new SeenBlockAttesters();
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.
|
|
69
|
-
this.producedBlindedBlockRoot = new Set();
|
|
77
|
+
/**
|
|
78
|
+
* Cache produced results (ExecutionPayload, DA Data) from the local execution so that we can send
|
|
79
|
+
* and get signed/published blinded versions which beacon node can
|
|
80
|
+
* assemble into full blocks before publishing to the network.
|
|
81
|
+
*/
|
|
82
|
+
this.blockProductionCache = new Map();
|
|
70
83
|
this.abortController = new AbortController();
|
|
71
84
|
this.opts = opts;
|
|
72
85
|
this.config = config;
|
|
@@ -98,6 +111,15 @@ export class BeaconChain {
|
|
|
98
111
|
this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
|
|
99
112
|
this.seenContributionAndProof = new SeenContributionAndProof(metrics);
|
|
100
113
|
this.seenAttestationDatas = new SeenAttestationDatas(metrics, this.opts?.attDataCacheSlotDistance);
|
|
114
|
+
const nodeId = computeNodeIdFromPrivateKey(privateKey);
|
|
115
|
+
const initialCustodyGroupCount = opts.initialCustodyGroupCount ?? (opts.supernode ? config.NUMBER_OF_CUSTODY_GROUPS : config.CUSTODY_REQUIREMENT);
|
|
116
|
+
this.metrics?.peerDas.targetCustodyGroupCount.set(initialCustodyGroupCount);
|
|
117
|
+
this.custodyConfig = new CustodyConfig({
|
|
118
|
+
nodeId,
|
|
119
|
+
config,
|
|
120
|
+
initialCustodyGroupCount,
|
|
121
|
+
});
|
|
122
|
+
this.seenGossipBlockInput = new SeenGossipBlockInput(this.custodyConfig, this.executionEngine, emitter, clock, logger);
|
|
101
123
|
this.beaconProposerCache = new BeaconProposerCache(opts);
|
|
102
124
|
this.checkpointBalancesCache = new CheckpointBalancesCache();
|
|
103
125
|
this.seenBlockInputCache = new SeenBlockInputCache({
|
|
@@ -120,6 +142,7 @@ export class BeaconChain {
|
|
|
120
142
|
pubkey2index: new PubkeyIndexMap(),
|
|
121
143
|
index2pubkey: [],
|
|
122
144
|
});
|
|
145
|
+
this._earliestAvailableSlot = cachedState.slot;
|
|
123
146
|
this.shufflingCache = cachedState.epochCtx.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
|
|
124
147
|
{
|
|
125
148
|
shuffling: cachedState.epochCtx.previousShuffling,
|
|
@@ -416,7 +439,7 @@ export class BeaconChain {
|
|
|
416
439
|
const state = await this.regen.getBlockSlotState(toRootHex(parentBlockRoot), slot, { dontTransferCache: true }, RegenCaller.produceBlock);
|
|
417
440
|
const proposerIndex = state.epochCtx.getBeaconProposer(slot);
|
|
418
441
|
const proposerPubKey = state.epochCtx.index2pubkey[proposerIndex].toBytes();
|
|
419
|
-
const { body,
|
|
442
|
+
const { body, produceResult, executionPayloadValue, shouldOverrideBuilder } = await produceBlockBody.call(this, blockType, state, {
|
|
420
443
|
randaoReveal,
|
|
421
444
|
graffiti,
|
|
422
445
|
slot,
|
|
@@ -428,7 +451,7 @@ export class BeaconChain {
|
|
|
428
451
|
commonBlockBodyPromise,
|
|
429
452
|
});
|
|
430
453
|
// The hashtree root computed here for debug log will get cached and hence won't introduce additional delays
|
|
431
|
-
const bodyRoot =
|
|
454
|
+
const bodyRoot = produceResult.type === BlockType.Full
|
|
432
455
|
? this.config.getForkTypes(slot).BeaconBlockBody.hashTreeRoot(body)
|
|
433
456
|
: this.config
|
|
434
457
|
.getPostBellatrixForkTypes(slot)
|
|
@@ -447,51 +470,15 @@ export class BeaconChain {
|
|
|
447
470
|
};
|
|
448
471
|
const { newStateRoot, proposerReward } = computeNewStateRoot(this.metrics, state, block);
|
|
449
472
|
block.stateRoot = newStateRoot;
|
|
450
|
-
const blockRoot =
|
|
473
|
+
const blockRoot = produceResult.type === BlockType.Full
|
|
451
474
|
? this.config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block)
|
|
452
475
|
: this.config.getPostBellatrixForkTypes(slot).BlindedBeaconBlock.hashTreeRoot(block);
|
|
453
476
|
const blockRootHex = toRootHex(blockRoot);
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
this.producedBlockRoot.set(blockRootHex, block.body.executionPayload ?? null);
|
|
458
|
-
this.metrics?.blockProductionCaches.producedBlockRoot.set(this.producedBlockRoot.size);
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
this.logger.debug("Tracking the produced blinded block", { blockRootHex, slot, blockType });
|
|
462
|
-
this.producedBlindedBlockRoot.add(blockRootHex);
|
|
463
|
-
this.metrics?.blockProductionCaches.producedBlindedBlockRoot.set(this.producedBlindedBlockRoot.size);
|
|
464
|
-
}
|
|
465
|
-
// Cache for latter broadcasting
|
|
466
|
-
//
|
|
467
|
-
// blinded blobs will be fetched and added to this cache later before finally
|
|
468
|
-
// publishing the blinded block's full version
|
|
469
|
-
if (blobs.type === BlobsResultType.produced) {
|
|
470
|
-
// body is of full type here
|
|
471
|
-
const { blockHash, contents } = blobs;
|
|
472
|
-
this.producedContentsCache.set(blockHash, contents);
|
|
473
|
-
this.metrics?.blockProductionCaches.producedContentsCache.set(this.producedContentsCache.size);
|
|
474
|
-
}
|
|
477
|
+
// Track the produced block for consensus broadcast validations, later validation, etc.
|
|
478
|
+
this.blockProductionCache.set(blockRootHex, produceResult);
|
|
479
|
+
this.metrics?.blockProductionCacheSize.set(this.blockProductionCache.size);
|
|
475
480
|
return { block, executionPayloadValue, consensusBlockValue: gweiToWei(proposerReward), shouldOverrideBuilder };
|
|
476
481
|
}
|
|
477
|
-
/**
|
|
478
|
-
* https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/validator.md#sidecar
|
|
479
|
-
* def get_blobs_sidecar(block: BeaconBlock, blobs: Sequence[Blob]) -> BlobSidecars:
|
|
480
|
-
* return BlobSidecars(
|
|
481
|
-
* beacon_block_root=hash_tree_root(block),
|
|
482
|
-
* beacon_block_slot=block.slot,
|
|
483
|
-
* blobs=blobs,
|
|
484
|
-
* kzg_aggregated_proof=compute_proof_from_blobs(blobs),
|
|
485
|
-
* )
|
|
486
|
-
*/
|
|
487
|
-
getContents(beaconBlock) {
|
|
488
|
-
const blockHash = toRootHex(beaconBlock.body.executionPayload.blockHash);
|
|
489
|
-
const contents = this.producedContentsCache.get(blockHash);
|
|
490
|
-
if (!contents) {
|
|
491
|
-
throw Error(`No contents for executionPayload.blockHash ${blockHash}`);
|
|
492
|
-
}
|
|
493
|
-
return contents;
|
|
494
|
-
}
|
|
495
482
|
async processBlock(block, opts) {
|
|
496
483
|
return this.blockProcessor.processBlocksJob([block], opts);
|
|
497
484
|
}
|
|
@@ -514,6 +501,7 @@ export class BeaconChain {
|
|
|
514
501
|
// TODO: PERFORMANCE: Memoize to prevent re-computing every time
|
|
515
502
|
headRoot: fromHex(head.blockRoot),
|
|
516
503
|
headSlot: head.slot,
|
|
504
|
+
earliestAvailableSlot: this._earliestAvailableSlot,
|
|
517
505
|
};
|
|
518
506
|
}
|
|
519
507
|
recomputeForkChoiceHead(caller) {
|
|
@@ -775,14 +763,8 @@ export class BeaconChain {
|
|
|
775
763
|
this.seenAttestationDatas.onSlot(slot);
|
|
776
764
|
this.reprocessController.onSlot(slot);
|
|
777
765
|
// Prune old cached block production artifacts, those are only useful on their slot
|
|
778
|
-
pruneSetToMax(this.
|
|
779
|
-
this.metrics?.
|
|
780
|
-
pruneSetToMax(this.producedBlindedBlockRoot, this.opts.maxCachedProducedRoots ?? DEFAULT_MAX_CACHED_PRODUCED_ROOTS);
|
|
781
|
-
this.metrics?.blockProductionCaches.producedBlindedBlockRoot.set(this.producedBlindedBlockRoot.size);
|
|
782
|
-
if (this.config.getForkSeq(slot) >= ForkSeq.deneb) {
|
|
783
|
-
pruneSetToMax(this.producedContentsCache, this.opts.maxCachedProducedRoots ?? DEFAULT_MAX_CACHED_PRODUCED_ROOTS);
|
|
784
|
-
this.metrics?.blockProductionCaches.producedContentsCache.set(this.producedContentsCache.size);
|
|
785
|
-
}
|
|
766
|
+
pruneSetToMax(this.blockProductionCache, this.opts.maxCachedProducedRoots ?? DEFAULT_MAX_CACHED_PRODUCED_RESULTS);
|
|
767
|
+
this.metrics?.blockProductionCacheSize.set(this.blockProductionCache.size);
|
|
786
768
|
const metrics = this.metrics;
|
|
787
769
|
if (metrics && (slot + 1) % SLOTS_PER_EPOCH === 0) {
|
|
788
770
|
// On the last slot of the epoch
|
|
@@ -822,6 +804,8 @@ export class BeaconChain {
|
|
|
822
804
|
async onForkChoiceFinalized(cp) {
|
|
823
805
|
this.logger.verbose("Fork choice finalized", { epoch: cp.epoch, root: cp.rootHex });
|
|
824
806
|
this.seenBlockProposers.prune(computeStartSlotAtEpoch(cp.epoch));
|
|
807
|
+
// Update validator custody to account for effective balance changes
|
|
808
|
+
await this.updateValidatorsCustodyRequirement(cp);
|
|
825
809
|
// TODO: Improve using regen here
|
|
826
810
|
const { blockRoot, stateRoot, slot } = this.forkChoice.getHead();
|
|
827
811
|
const headState = this.regen.getStateSync(stateRoot);
|
|
@@ -837,9 +821,49 @@ export class BeaconChain {
|
|
|
837
821
|
}
|
|
838
822
|
}
|
|
839
823
|
async updateBeaconProposerData(epoch, proposers) {
|
|
824
|
+
const previousValidatorCount = this.beaconProposerCache.getValidatorIndices().length;
|
|
840
825
|
for (const proposer of proposers) {
|
|
841
826
|
this.beaconProposerCache.add(epoch, proposer);
|
|
842
827
|
}
|
|
828
|
+
const newValidatorCount = this.beaconProposerCache.getValidatorIndices().length;
|
|
829
|
+
// Only update validator custody if we discovered new validators
|
|
830
|
+
if (newValidatorCount > previousValidatorCount) {
|
|
831
|
+
const finalizedCheckpoint = this.forkChoice.getFinalizedCheckpoint();
|
|
832
|
+
await this.updateValidatorsCustodyRequirement(finalizedCheckpoint);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
async updateValidatorsCustodyRequirement(finalizedCheckpoint) {
|
|
836
|
+
if (this.opts.supernode) {
|
|
837
|
+
// Disable dynamic custody updates for supernodes since they must maintain custody
|
|
838
|
+
// of all custody groups regardless of validator effective balances
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
// Update custody requirement based on finalized state
|
|
842
|
+
const stateOrBytes = (await this.getStateOrBytesByCheckpoint(finalizedCheckpoint))?.state;
|
|
843
|
+
if (!stateOrBytes) {
|
|
844
|
+
throw Error(`No finalized state for epoch ${finalizedCheckpoint.epoch} and root ${finalizedCheckpoint.rootHex} to update target custody group count`);
|
|
845
|
+
}
|
|
846
|
+
// Validators attached to the node
|
|
847
|
+
const validatorIndices = this.beaconProposerCache.getValidatorIndices();
|
|
848
|
+
let effectiveBalances;
|
|
849
|
+
if (stateOrBytes instanceof Uint8Array) {
|
|
850
|
+
effectiveBalances = getEffectiveBalancesFromStateBytes(this.config, stateOrBytes, validatorIndices);
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
effectiveBalances = validatorIndices.map((index) => stateOrBytes.validators.get(index).effectiveBalance);
|
|
854
|
+
}
|
|
855
|
+
const targetCustodyGroupCount = getValidatorsCustodyRequirement(this.config, effectiveBalances);
|
|
856
|
+
// Only update if target is increased
|
|
857
|
+
if (targetCustodyGroupCount > this.custodyConfig.targetCustodyGroupCount) {
|
|
858
|
+
this.custodyConfig.updateTargetCustodyGroupCount(targetCustodyGroupCount);
|
|
859
|
+
this.metrics?.peerDas.targetCustodyGroupCount.set(targetCustodyGroupCount);
|
|
860
|
+
this.logger.verbose("Updated target custody group count", {
|
|
861
|
+
finalizedEpoch: finalizedCheckpoint.epoch,
|
|
862
|
+
validatorCount: validatorIndices.length,
|
|
863
|
+
targetCustodyGroupCount,
|
|
864
|
+
});
|
|
865
|
+
this.emitter.emit(ChainEvent.updateTargetCustodyGroupCount, targetCustodyGroupCount);
|
|
866
|
+
}
|
|
843
867
|
}
|
|
844
868
|
updateBuilderStatus(clockSlot) {
|
|
845
869
|
const executionBuilder = this.executionBuilder;
|
|
@@ -848,7 +872,7 @@ export class BeaconChain {
|
|
|
848
872
|
const slotsPresent = this.forkChoice.getSlotsPresent(clockSlot - faultInspectionWindow);
|
|
849
873
|
const previousStatus = executionBuilder.status;
|
|
850
874
|
const shouldEnable = slotsPresent >= Math.min(faultInspectionWindow - allowedFaults, clockSlot);
|
|
851
|
-
executionBuilder.updateStatus(shouldEnable);
|
|
875
|
+
executionBuilder.updateStatus(shouldEnable ? BuilderStatus.enabled : BuilderStatus.circuitBreaker);
|
|
852
876
|
// The status changed we should log
|
|
853
877
|
const status = executionBuilder.status;
|
|
854
878
|
const builderLog = {
|
|
@@ -858,10 +882,10 @@ export class BeaconChain {
|
|
|
858
882
|
allowedFaults,
|
|
859
883
|
};
|
|
860
884
|
if (status !== previousStatus) {
|
|
861
|
-
this.logger.info("
|
|
885
|
+
this.logger.info("External builder status updated", builderLog);
|
|
862
886
|
}
|
|
863
887
|
else {
|
|
864
|
-
this.logger.verbose("
|
|
888
|
+
this.logger.verbose("External builder status", builderLog);
|
|
865
889
|
}
|
|
866
890
|
}
|
|
867
891
|
}
|