@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.
Files changed (245) hide show
  1. package/lib/api/impl/beacon/blocks/index.js +162 -55
  2. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  3. package/lib/api/impl/beacon/state/index.js +6 -12
  4. package/lib/api/impl/beacon/state/index.js.map +1 -1
  5. package/lib/api/impl/debug/index.d.ts +1 -1
  6. package/lib/api/impl/debug/index.js +24 -1
  7. package/lib/api/impl/debug/index.js.map +1 -1
  8. package/lib/api/impl/validator/index.js +41 -24
  9. package/lib/api/impl/validator/index.js.map +1 -1
  10. package/lib/chain/archiveStore/archiveStore.d.ts +1 -1
  11. package/lib/chain/archiveStore/archiveStore.js +2 -2
  12. package/lib/chain/archiveStore/interface.d.ts +1 -1
  13. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +1 -1
  14. package/lib/chain/archiveStore/utils/archiveBlocks.js +91 -23
  15. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  16. package/lib/chain/beaconProposerCache.d.ts +1 -0
  17. package/lib/chain/beaconProposerCache.js +3 -0
  18. package/lib/chain/beaconProposerCache.js.map +1 -1
  19. package/lib/chain/blocks/importBlock.js +3 -2
  20. package/lib/chain/blocks/importBlock.js.map +1 -1
  21. package/lib/chain/blocks/types.d.ts +66 -23
  22. package/lib/chain/blocks/types.js +39 -5
  23. package/lib/chain/blocks/types.js.map +1 -1
  24. package/lib/chain/blocks/verifyBlocksDataAvailability.js +21 -10
  25. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  26. package/lib/chain/blocks/writeBlockInputToDb.js +89 -15
  27. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  28. package/lib/chain/chain.d.ts +18 -101
  29. package/lib/chain/chain.js +91 -67
  30. package/lib/chain/chain.js.map +1 -1
  31. package/lib/chain/emitter.d.ts +18 -2
  32. package/lib/chain/emitter.js +13 -0
  33. package/lib/chain/emitter.js.map +1 -1
  34. package/lib/chain/errors/dataColumnSidecarError.d.ts +69 -0
  35. package/lib/chain/errors/dataColumnSidecarError.js +21 -0
  36. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -0
  37. package/lib/chain/errors/index.d.ts +1 -0
  38. package/lib/chain/errors/index.js +1 -0
  39. package/lib/chain/errors/index.js.map +1 -1
  40. package/lib/chain/interface.d.ts +6 -7
  41. package/lib/chain/interface.js.map +1 -1
  42. package/lib/chain/options.d.ts +4 -1
  43. package/lib/chain/options.js +1 -0
  44. package/lib/chain/options.js.map +1 -1
  45. package/lib/chain/prepareNextSlot.js +2 -1
  46. package/lib/chain/prepareNextSlot.js.map +1 -1
  47. package/lib/chain/produceBlock/produceBlockBody.d.ts +30 -16
  48. package/lib/chain/produceBlock/produceBlockBody.js +28 -28
  49. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  50. package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.d.ts +6 -3
  51. package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.js +28 -4
  52. package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.js.map +1 -1
  53. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +64 -18
  54. package/lib/chain/seenCache/seenGossipBlockInput.js +321 -53
  55. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  56. package/lib/chain/validation/dataColumnSidecar.d.ts +29 -0
  57. package/lib/chain/validation/dataColumnSidecar.js +248 -0
  58. package/lib/chain/validation/dataColumnSidecar.js.map +1 -0
  59. package/lib/db/beacon.d.ts +3 -1
  60. package/lib/db/beacon.js +3 -1
  61. package/lib/db/beacon.js.map +1 -1
  62. package/lib/db/buckets.d.ts +3 -1
  63. package/lib/db/buckets.js +2 -0
  64. package/lib/db/buckets.js.map +1 -1
  65. package/lib/db/interface.d.ts +3 -1
  66. package/lib/db/repositories/dataColumnSidecars.d.ts +47 -0
  67. package/lib/db/repositories/dataColumnSidecars.js +40 -0
  68. package/lib/db/repositories/dataColumnSidecars.js.map +1 -0
  69. package/lib/db/repositories/dataColumnSidecarsArchive.d.ts +15 -0
  70. package/lib/db/repositories/dataColumnSidecarsArchive.js +23 -0
  71. package/lib/db/repositories/dataColumnSidecarsArchive.js.map +1 -0
  72. package/lib/db/repositories/index.d.ts +2 -0
  73. package/lib/db/repositories/index.js +2 -0
  74. package/lib/db/repositories/index.js.map +1 -1
  75. package/lib/execution/builder/http.d.ts +20 -4
  76. package/lib/execution/builder/http.js +30 -11
  77. package/lib/execution/builder/http.js.map +1 -1
  78. package/lib/execution/builder/interface.d.ts +5 -4
  79. package/lib/execution/engine/http.d.ts +8 -5
  80. package/lib/execution/engine/http.js +56 -42
  81. package/lib/execution/engine/http.js.map +1 -1
  82. package/lib/execution/engine/interface.d.ts +6 -13
  83. package/lib/execution/engine/interface.js +1 -1
  84. package/lib/execution/engine/interface.js.map +1 -1
  85. package/lib/execution/engine/mock.d.ts +1 -0
  86. package/lib/execution/engine/mock.js +5 -0
  87. package/lib/execution/engine/mock.js.map +1 -1
  88. package/lib/execution/engine/types.d.ts +12 -2
  89. package/lib/execution/engine/types.js +8 -2
  90. package/lib/execution/engine/types.js.map +1 -1
  91. package/lib/metrics/metrics/beacon.d.ts +15 -5
  92. package/lib/metrics/metrics/beacon.js +61 -14
  93. package/lib/metrics/metrics/beacon.js.map +1 -1
  94. package/lib/metrics/metrics/lodestar.d.ts +24 -1
  95. package/lib/metrics/metrics/lodestar.js +45 -0
  96. package/lib/metrics/metrics/lodestar.js.map +1 -1
  97. package/lib/network/core/metrics.d.ts +10 -3
  98. package/lib/network/core/metrics.js +22 -4
  99. package/lib/network/core/metrics.js.map +1 -1
  100. package/lib/network/core/networkCore.d.ts +15 -4
  101. package/lib/network/core/networkCore.js +73 -23
  102. package/lib/network/core/networkCore.js.map +1 -1
  103. package/lib/network/core/networkCoreWorker.js +2 -0
  104. package/lib/network/core/networkCoreWorker.js.map +1 -1
  105. package/lib/network/core/networkCoreWorkerHandler.d.ts +5 -3
  106. package/lib/network/core/networkCoreWorkerHandler.js +6 -1
  107. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  108. package/lib/network/core/types.d.ts +7 -4
  109. package/lib/network/events.d.ts +4 -2
  110. package/lib/network/events.js.map +1 -1
  111. package/lib/network/gossip/gossipsub.d.ts +2 -2
  112. package/lib/network/gossip/gossipsub.js +8 -6
  113. package/lib/network/gossip/gossipsub.js.map +1 -1
  114. package/lib/network/gossip/interface.d.ts +8 -1
  115. package/lib/network/gossip/interface.js +1 -0
  116. package/lib/network/gossip/interface.js.map +1 -1
  117. package/lib/network/gossip/scoringParameters.d.ts +6 -2
  118. package/lib/network/gossip/scoringParameters.js.map +1 -1
  119. package/lib/network/gossip/topic.d.ts +2005 -1456
  120. package/lib/network/gossip/topic.js +29 -1
  121. package/lib/network/gossip/topic.js.map +1 -1
  122. package/lib/network/interface.d.ts +9 -1
  123. package/lib/network/metadata.d.ts +9 -5
  124. package/lib/network/metadata.js +26 -5
  125. package/lib/network/metadata.js.map +1 -1
  126. package/lib/network/network.d.ts +12 -2
  127. package/lib/network/network.js +73 -11
  128. package/lib/network/network.js.map +1 -1
  129. package/lib/network/networkConfig.d.ts +12 -0
  130. package/lib/network/networkConfig.js +2 -0
  131. package/lib/network/networkConfig.js.map +1 -0
  132. package/lib/network/options.d.ts +1 -0
  133. package/lib/network/options.js +5 -0
  134. package/lib/network/options.js.map +1 -1
  135. package/lib/network/peers/discover.d.ts +8 -3
  136. package/lib/network/peers/discover.js +99 -14
  137. package/lib/network/peers/discover.js.map +1 -1
  138. package/lib/network/peers/peerManager.d.ts +10 -4
  139. package/lib/network/peers/peerManager.js +105 -19
  140. package/lib/network/peers/peerManager.js.map +1 -1
  141. package/lib/network/peers/peersData.d.ts +17 -3
  142. package/lib/network/peers/peersData.js.map +1 -1
  143. package/lib/network/peers/score/interface.d.ts +1 -1
  144. package/lib/network/peers/score/score.d.ts +2 -2
  145. package/lib/network/peers/score/score.js +4 -1
  146. package/lib/network/peers/score/score.js.map +1 -1
  147. package/lib/network/peers/score/store.d.ts +3 -1
  148. package/lib/network/peers/score/store.js +6 -2
  149. package/lib/network/peers/score/store.js.map +1 -1
  150. package/lib/network/peers/utils/assertPeerRelevance.d.ts +7 -3
  151. package/lib/network/peers/utils/assertPeerRelevance.js +10 -1
  152. package/lib/network/peers/utils/assertPeerRelevance.js.map +1 -1
  153. package/lib/network/peers/utils/prioritizePeers.d.ts +19 -7
  154. package/lib/network/peers/utils/prioritizePeers.js +42 -6
  155. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  156. package/lib/network/processor/extractSlotRootFns.js +8 -1
  157. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  158. package/lib/network/processor/gossipHandlers.js +165 -16
  159. package/lib/network/processor/gossipHandlers.js.map +1 -1
  160. package/lib/network/processor/gossipQueues/index.js +5 -0
  161. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  162. package/lib/network/processor/index.js +1 -0
  163. package/lib/network/processor/index.js.map +1 -1
  164. package/lib/network/reqresp/ReqRespBeaconNode.d.ts +2 -2
  165. package/lib/network/reqresp/ReqRespBeaconNode.js +36 -14
  166. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  167. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.d.ts +24 -4
  168. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js +259 -20
  169. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js.map +1 -1
  170. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.d.ts +32 -6
  171. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js +283 -28
  172. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js.map +1 -1
  173. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +1 -1
  174. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  175. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +8 -0
  176. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +92 -0
  177. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -0
  178. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +6 -0
  179. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +50 -0
  180. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -0
  181. package/lib/network/reqresp/handlers/index.js +10 -0
  182. package/lib/network/reqresp/handlers/index.js.map +1 -1
  183. package/lib/network/reqresp/protocols.d.ts +4 -0
  184. package/lib/network/reqresp/protocols.js +20 -0
  185. package/lib/network/reqresp/protocols.js.map +1 -1
  186. package/lib/network/reqresp/rateLimit.js +10 -0
  187. package/lib/network/reqresp/rateLimit.js.map +1 -1
  188. package/lib/network/reqresp/score.js +3 -0
  189. package/lib/network/reqresp/score.js.map +1 -1
  190. package/lib/network/reqresp/types.d.ts +11 -4
  191. package/lib/network/reqresp/types.js +12 -3
  192. package/lib/network/reqresp/types.js.map +1 -1
  193. package/lib/network/statusCache.d.ts +5 -5
  194. package/lib/network/statusCache.js.map +1 -1
  195. package/lib/network/subnets/interface.d.ts +3 -0
  196. package/lib/network/subnets/interface.js +14 -1
  197. package/lib/network/subnets/interface.js.map +1 -1
  198. package/lib/network/subnets/syncnetsService.js +4 -5
  199. package/lib/network/subnets/syncnetsService.js.map +1 -1
  200. package/lib/node/nodejs.js +1 -0
  201. package/lib/node/nodejs.js.map +1 -1
  202. package/lib/sync/constants.d.ts +18 -3
  203. package/lib/sync/constants.js +21 -3
  204. package/lib/sync/constants.js.map +1 -1
  205. package/lib/sync/interface.d.ts +2 -2
  206. package/lib/sync/interface.js +1 -1
  207. package/lib/sync/interface.js.map +1 -1
  208. package/lib/sync/range/batch.d.ts +17 -2
  209. package/lib/sync/range/batch.js +39 -7
  210. package/lib/sync/range/batch.js.map +1 -1
  211. package/lib/sync/range/chain.d.ts +15 -1
  212. package/lib/sync/range/chain.js +124 -33
  213. package/lib/sync/range/chain.js.map +1 -1
  214. package/lib/sync/range/range.d.ts +3 -2
  215. package/lib/sync/range/range.js +9 -3
  216. package/lib/sync/range/range.js.map +1 -1
  217. package/lib/sync/range/utils/chainTarget.d.ts +5 -1
  218. package/lib/sync/range/utils/chainTarget.js +26 -1
  219. package/lib/sync/range/utils/chainTarget.js.map +1 -1
  220. package/lib/sync/range/utils/peerBalancer.d.ts +19 -5
  221. package/lib/sync/range/utils/peerBalancer.js +104 -10
  222. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  223. package/lib/sync/sync.js +1 -1
  224. package/lib/sync/sync.js.map +1 -1
  225. package/lib/sync/unknownBlock.d.ts +10 -2
  226. package/lib/sync/unknownBlock.js +257 -76
  227. package/lib/sync/unknownBlock.js.map +1 -1
  228. package/lib/sync/utils/remoteSyncType.d.ts +4 -4
  229. package/lib/sync/utils/remoteSyncType.js.map +1 -1
  230. package/lib/util/blobs.d.ts +16 -4
  231. package/lib/util/blobs.js +122 -5
  232. package/lib/util/blobs.js.map +1 -1
  233. package/lib/util/dataColumns.d.ts +137 -0
  234. package/lib/util/dataColumns.js +358 -0
  235. package/lib/util/dataColumns.js.map +1 -0
  236. package/lib/util/metadata.d.ts +5 -0
  237. package/lib/util/metadata.js +10 -0
  238. package/lib/util/metadata.js.map +1 -1
  239. package/lib/util/sszBytes.d.ts +1 -0
  240. package/lib/util/sszBytes.js +17 -0
  241. package/lib/util/sszBytes.js.map +1 -1
  242. package/package.json +16 -16
  243. package/lib/network/reqresp/handlers/status.d.ts +0 -4
  244. package/lib/network/reqresp/handlers/status.js +0 -11
  245. package/lib/network/reqresp/handlers/status.js.map +0 -1
@@ -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, deneb, phase0 } from "@lodestar/types";
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
- /** Map keyed by executionPayload.blockHash of the block for those blobs */
84
- readonly producedContentsCache: Map<string, deneb.Contents>;
85
- readonly producedBlockRoot: Map<string, import("@chainsafe/ssz").ValueOfFields<{
86
- transactions: import("@chainsafe/ssz").ListCompositeType<import("@chainsafe/ssz").ByteListType>;
87
- parentHash: import("@chainsafe/ssz").ByteVectorType;
88
- feeRecipient: import("@lodestar/types/lib/utils/executionAddress.js").ExecutionAddressType;
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
- constructor(opts: IChainOptions, { config, db, dbName, dataDir, logger, processShutdownCallback, clock, metrics, validatorMonitor, anchorState, eth1, executionEngine, executionBuilder, }: {
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(): phase0.Status;
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<{
@@ -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 { ForkSeq, GENESIS_SLOT, SLOTS_PER_EPOCH, isForkPostElectra } from "@lodestar/params";
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, } from "./interface.js";
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 { BlobsResultType, BlockType } from "./produceBlock/index.js";
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
- * Arbitrary constants, blobs and payloads should be consumed immediately in the same slot
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 DEFAULT_MAX_CACHED_PRODUCED_ROOTS = 4;
57
+ const DEFAULT_MAX_CACHED_PRODUCED_RESULTS = 4;
52
58
  export class BeaconChain {
53
- constructor(opts, { config, db, dbName, dataDir, logger, processShutdownCallback, clock, metrics, validatorMonitor, anchorState, eth1, executionEngine, executionBuilder, }) {
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
- /** Map keyed by executionPayload.blockHash of the block for those blobs */
64
- this.producedContentsCache = new Map();
65
- // Cache payloads from the local execution so that we can send
66
- // and get signed/published blinded versions which beacon node can
67
- // assemble into full blocks before publishing to the network.
68
- this.producedBlockRoot = new Map();
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, blobs, executionPayloadValue, shouldOverrideBuilder } = await produceBlockBody.call(this, blockType, state, {
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 = blockType === BlockType.Full
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 = blockType === BlockType.Full
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
- // track the produced block for consensus broadcast validations
455
- if (blockType === BlockType.Full) {
456
- this.logger.debug("Setting executionPayload cache for produced block", { blockRootHex, slot, blockType });
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.producedBlockRoot, this.opts.maxCachedProducedRoots ?? DEFAULT_MAX_CACHED_PRODUCED_ROOTS);
779
- this.metrics?.blockProductionCaches.producedBlockRoot.set(this.producedBlockRoot.size);
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("Execution builder status updated", builderLog);
885
+ this.logger.info("External builder status updated", builderLog);
862
886
  }
863
887
  else {
864
- this.logger.verbose("Execution builder status", builderLog);
888
+ this.logger.verbose("External builder status", builderLog);
865
889
  }
866
890
  }
867
891
  }