@lodestar/beacon-node 1.42.0-dev.5f2fffc2ce → 1.42.0-dev.6fa48cb5f2

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 (440) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +36 -17
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.js +1 -1
  5. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  6. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  7. package/lib/api/impl/beacon/state/index.js +27 -32
  8. package/lib/api/impl/beacon/state/index.js.map +1 -1
  9. package/lib/api/impl/beacon/state/utils.d.ts +4 -4
  10. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  11. package/lib/api/impl/beacon/state/utils.js +7 -10
  12. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  13. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  14. package/lib/api/impl/lodestar/index.js +4 -6
  15. package/lib/api/impl/lodestar/index.js.map +1 -1
  16. package/lib/api/impl/proof/index.d.ts.map +1 -1
  17. package/lib/api/impl/proof/index.js +2 -6
  18. package/lib/api/impl/proof/index.js.map +1 -1
  19. package/lib/api/impl/validator/index.d.ts.map +1 -1
  20. package/lib/api/impl/validator/index.js +27 -27
  21. package/lib/api/impl/validator/index.js.map +1 -1
  22. package/lib/api/impl/validator/utils.d.ts +2 -2
  23. package/lib/api/impl/validator/utils.d.ts.map +1 -1
  24. package/lib/api/impl/validator/utils.js +3 -3
  25. package/lib/api/impl/validator/utils.js.map +1 -1
  26. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  27. package/lib/chain/archiveStore/archiveStore.js +1 -0
  28. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  29. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +3 -7
  30. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  31. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +8 -26
  32. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  33. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts +2 -2
  34. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  35. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -0
  36. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  37. package/lib/chain/archiveStore/historicalState/types.d.ts +2 -0
  38. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  39. package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
  40. package/lib/chain/archiveStore/historicalState/worker.js +1 -3
  41. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  42. package/lib/chain/archiveStore/interface.d.ts +1 -0
  43. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  44. package/lib/chain/balancesCache.d.ts +2 -2
  45. package/lib/chain/balancesCache.d.ts.map +1 -1
  46. package/lib/chain/balancesCache.js +4 -4
  47. package/lib/chain/balancesCache.js.map +1 -1
  48. package/lib/chain/blocks/blockInput/types.d.ts +4 -3
  49. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  50. package/lib/chain/blocks/blockInput/types.js +1 -0
  51. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  52. package/lib/chain/blocks/importBlock.d.ts +3 -3
  53. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  54. package/lib/chain/blocks/importBlock.js +27 -11
  55. package/lib/chain/blocks/importBlock.js.map +1 -1
  56. package/lib/chain/blocks/importExecutionPayload.d.ts +48 -0
  57. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -0
  58. package/lib/chain/blocks/importExecutionPayload.js +158 -0
  59. package/lib/chain/blocks/importExecutionPayload.js.map +1 -0
  60. package/lib/chain/blocks/index.js +1 -1
  61. package/lib/chain/blocks/index.js.map +1 -1
  62. package/lib/chain/blocks/payloadEnvelopeInput/index.d.ts +3 -0
  63. package/lib/chain/blocks/payloadEnvelopeInput/index.d.ts.map +1 -0
  64. package/lib/chain/blocks/payloadEnvelopeInput/index.js +3 -0
  65. package/lib/chain/blocks/payloadEnvelopeInput/index.js.map +1 -0
  66. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +80 -0
  67. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -0
  68. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +248 -0
  69. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -0
  70. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +29 -0
  71. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -0
  72. package/lib/chain/blocks/payloadEnvelopeInput/types.js +11 -0
  73. package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -0
  74. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +15 -0
  75. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -0
  76. package/lib/chain/blocks/payloadEnvelopeProcessor.js +46 -0
  77. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -0
  78. package/lib/chain/blocks/types.d.ts +9 -2
  79. package/lib/chain/blocks/types.d.ts.map +1 -1
  80. package/lib/chain/blocks/types.js.map +1 -1
  81. package/lib/chain/blocks/utils/checkpoint.d.ts +2 -2
  82. package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -1
  83. package/lib/chain/blocks/utils/checkpoint.js.map +1 -1
  84. package/lib/chain/blocks/verifyBlock.d.ts +2 -2
  85. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  86. package/lib/chain/blocks/verifyBlock.js +4 -4
  87. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  88. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +3 -3
  89. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  90. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -3
  91. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  92. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  93. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  94. package/lib/chain/blocks/verifyBlocksSignatures.js +1 -1
  95. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  96. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -3
  97. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  98. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +3 -3
  99. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  100. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +12 -0
  101. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -0
  102. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +40 -0
  103. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -0
  104. package/lib/chain/chain.d.ts +19 -14
  105. package/lib/chain/chain.d.ts.map +1 -1
  106. package/lib/chain/chain.js +75 -42
  107. package/lib/chain/chain.js.map +1 -1
  108. package/lib/chain/emitter.d.ts +2 -2
  109. package/lib/chain/emitter.d.ts.map +1 -1
  110. package/lib/chain/errors/blockError.d.ts +4 -4
  111. package/lib/chain/errors/blockError.d.ts.map +1 -1
  112. package/lib/chain/errors/executionPayloadEnvelope.d.ts +12 -2
  113. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  114. package/lib/chain/errors/executionPayloadEnvelope.js +3 -1
  115. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  116. package/lib/chain/forkChoice/index.d.ts +4 -4
  117. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  118. package/lib/chain/forkChoice/index.js +27 -33
  119. package/lib/chain/forkChoice/index.js.map +1 -1
  120. package/lib/chain/initState.d.ts +2 -2
  121. package/lib/chain/initState.d.ts.map +1 -1
  122. package/lib/chain/initState.js +1 -1
  123. package/lib/chain/initState.js.map +1 -1
  124. package/lib/chain/interface.d.ts +17 -15
  125. package/lib/chain/interface.d.ts.map +1 -1
  126. package/lib/chain/lightClient/index.d.ts +2 -2
  127. package/lib/chain/lightClient/index.d.ts.map +1 -1
  128. package/lib/chain/lightClient/index.js +4 -4
  129. package/lib/chain/lightClient/index.js.map +1 -1
  130. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +6 -6
  131. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  132. package/lib/chain/opPools/aggregatedAttestationPool.js +10 -13
  133. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  134. package/lib/chain/opPools/opPool.d.ts +3 -3
  135. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  136. package/lib/chain/opPools/opPool.js +7 -7
  137. package/lib/chain/opPools/opPool.js.map +1 -1
  138. package/lib/chain/opPools/utils.d.ts +2 -2
  139. package/lib/chain/opPools/utils.d.ts.map +1 -1
  140. package/lib/chain/opPools/utils.js +2 -2
  141. package/lib/chain/opPools/utils.js.map +1 -1
  142. package/lib/chain/options.d.ts +1 -0
  143. package/lib/chain/options.d.ts.map +1 -1
  144. package/lib/chain/options.js +1 -0
  145. package/lib/chain/options.js.map +1 -1
  146. package/lib/chain/prepareNextSlot.d.ts +2 -2
  147. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  148. package/lib/chain/prepareNextSlot.js +3 -3
  149. package/lib/chain/prepareNextSlot.js.map +1 -1
  150. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +4 -4
  151. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  152. package/lib/chain/produceBlock/computeNewStateRoot.js +8 -4
  153. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  154. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  155. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  156. package/lib/chain/produceBlock/produceBlockBody.js +13 -17
  157. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  158. package/lib/chain/regen/interface.d.ts +15 -13
  159. package/lib/chain/regen/interface.d.ts.map +1 -1
  160. package/lib/chain/regen/interface.js +2 -0
  161. package/lib/chain/regen/interface.js.map +1 -1
  162. package/lib/chain/regen/queued.d.ts +14 -14
  163. package/lib/chain/regen/queued.d.ts.map +1 -1
  164. package/lib/chain/regen/queued.js.map +1 -1
  165. package/lib/chain/regen/regen.d.ts +6 -5
  166. package/lib/chain/regen/regen.d.ts.map +1 -1
  167. package/lib/chain/regen/regen.js +6 -6
  168. package/lib/chain/regen/regen.js.map +1 -1
  169. package/lib/chain/seenCache/index.d.ts +1 -1
  170. package/lib/chain/seenCache/index.d.ts.map +1 -1
  171. package/lib/chain/seenCache/index.js +1 -1
  172. package/lib/chain/seenCache/index.js.map +1 -1
  173. package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
  174. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  175. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +38 -0
  176. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -0
  177. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +76 -0
  178. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -0
  179. package/lib/chain/serializeState.d.ts +2 -2
  180. package/lib/chain/serializeState.d.ts.map +1 -1
  181. package/lib/chain/serializeState.js +1 -1
  182. package/lib/chain/serializeState.js.map +1 -1
  183. package/lib/chain/shufflingCache.d.ts +2 -2
  184. package/lib/chain/shufflingCache.d.ts.map +1 -1
  185. package/lib/chain/shufflingCache.js +3 -4
  186. package/lib/chain/shufflingCache.js.map +1 -1
  187. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +6 -6
  188. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  189. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  190. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +11 -11
  191. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  192. package/lib/chain/stateCache/persistentCheckpointsCache.js +12 -16
  193. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  194. package/lib/chain/stateCache/types.d.ts +14 -14
  195. package/lib/chain/stateCache/types.d.ts.map +1 -1
  196. package/lib/chain/stateCache/types.js.map +1 -1
  197. package/lib/chain/validation/attesterSlashing.js +3 -3
  198. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  199. package/lib/chain/validation/blobSidecar.js +1 -1
  200. package/lib/chain/validation/blobSidecar.js.map +1 -1
  201. package/lib/chain/validation/block.d.ts.map +1 -1
  202. package/lib/chain/validation/block.js +3 -3
  203. package/lib/chain/validation/block.js.map +1 -1
  204. package/lib/chain/validation/blsToExecutionChange.js +2 -2
  205. package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
  206. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  207. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  208. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  209. package/lib/chain/validation/executionPayloadBid.js +4 -4
  210. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  211. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  212. package/lib/chain/validation/executionPayloadEnvelope.js +29 -19
  213. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  214. package/lib/chain/validation/lightClientFinalityUpdate.js +1 -1
  215. package/lib/chain/validation/lightClientFinalityUpdate.js.map +1 -1
  216. package/lib/chain/validation/lightClientOptimisticUpdate.js +1 -1
  217. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  218. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  219. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  220. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  221. package/lib/chain/validation/proposerSlashing.js +1 -1
  222. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  223. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  224. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  225. package/lib/chain/validation/signatureSets/contributionAndProof.js +1 -1
  226. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  227. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  228. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  229. package/lib/chain/validation/signatureSets/syncCommittee.js +1 -1
  230. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  231. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  232. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  233. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  234. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  235. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  236. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -1
  237. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  238. package/lib/chain/validation/syncCommittee.d.ts +4 -4
  239. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  240. package/lib/chain/validation/syncCommittee.js +13 -12
  241. package/lib/chain/validation/syncCommittee.js.map +1 -1
  242. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  243. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  244. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  245. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  246. package/lib/chain/validation/voluntaryExit.js +3 -3
  247. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  248. package/lib/chain/validatorMonitor.d.ts +5 -4
  249. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  250. package/lib/chain/validatorMonitor.js +13 -8
  251. package/lib/chain/validatorMonitor.js.map +1 -1
  252. package/lib/execution/engine/interface.d.ts +2 -2
  253. package/lib/metrics/metrics/lodestar.d.ts +40 -4
  254. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  255. package/lib/metrics/metrics/lodestar.js +93 -15
  256. package/lib/metrics/metrics/lodestar.js.map +1 -1
  257. package/lib/network/gossip/encoding.d.ts.map +1 -1
  258. package/lib/network/gossip/encoding.js +15 -0
  259. package/lib/network/gossip/encoding.js.map +1 -1
  260. package/lib/network/gossip/topic.d.ts +727 -0
  261. package/lib/network/gossip/topic.d.ts.map +1 -1
  262. package/lib/network/interface.d.ts +4 -2
  263. package/lib/network/interface.d.ts.map +1 -1
  264. package/lib/network/libp2p/index.d.ts.map +1 -1
  265. package/lib/network/libp2p/index.js +5 -0
  266. package/lib/network/libp2p/index.js.map +1 -1
  267. package/lib/network/network.d.ts +4 -2
  268. package/lib/network/network.d.ts.map +1 -1
  269. package/lib/network/network.js +11 -5
  270. package/lib/network/network.js.map +1 -1
  271. package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
  272. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
  273. package/lib/network/processor/extractSlotRootFns.js +15 -5
  274. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  275. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  276. package/lib/network/processor/gossipHandlers.js +39 -9
  277. package/lib/network/processor/gossipHandlers.js.map +1 -1
  278. package/lib/network/processor/index.d.ts +12 -7
  279. package/lib/network/processor/index.d.ts.map +1 -1
  280. package/lib/network/processor/index.js +99 -78
  281. package/lib/network/processor/index.js.map +1 -1
  282. package/lib/network/reqresp/ReqRespBeaconNode.d.ts +1 -1
  283. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  284. package/lib/network/reqresp/ReqRespBeaconNode.js +10 -1
  285. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  286. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts +8 -0
  287. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -0
  288. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +69 -0
  289. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -0
  290. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts +6 -0
  291. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -0
  292. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +28 -0
  293. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -0
  294. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  295. package/lib/network/reqresp/handlers/index.js +11 -1
  296. package/lib/network/reqresp/handlers/index.js.map +1 -1
  297. package/lib/network/reqresp/protocols.d.ts +2 -0
  298. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  299. package/lib/network/reqresp/protocols.js +10 -0
  300. package/lib/network/reqresp/protocols.js.map +1 -1
  301. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  302. package/lib/network/reqresp/rateLimit.js +8 -0
  303. package/lib/network/reqresp/rateLimit.js.map +1 -1
  304. package/lib/network/reqresp/score.d.ts.map +1 -1
  305. package/lib/network/reqresp/score.js +2 -0
  306. package/lib/network/reqresp/score.js.map +1 -1
  307. package/lib/network/reqresp/types.d.ts +8 -2
  308. package/lib/network/reqresp/types.d.ts.map +1 -1
  309. package/lib/network/reqresp/types.js +7 -1
  310. package/lib/network/reqresp/types.js.map +1 -1
  311. package/lib/node/nodejs.d.ts +2 -2
  312. package/lib/node/nodejs.d.ts.map +1 -1
  313. package/lib/node/nodejs.js +1 -4
  314. package/lib/node/nodejs.js.map +1 -1
  315. package/lib/node/notifier.d.ts.map +1 -1
  316. package/lib/node/notifier.js +3 -3
  317. package/lib/node/notifier.js.map +1 -1
  318. package/lib/sync/backfill/backfill.d.ts +3 -3
  319. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  320. package/lib/sync/backfill/backfill.js +3 -3
  321. package/lib/sync/backfill/backfill.js.map +1 -1
  322. package/lib/sync/constants.d.ts +1 -1
  323. package/lib/sync/constants.js +1 -1
  324. package/lib/sync/unknownBlock.d.ts +3 -9
  325. package/lib/sync/unknownBlock.d.ts.map +1 -1
  326. package/lib/sync/unknownBlock.js +8 -41
  327. package/lib/sync/unknownBlock.js.map +1 -1
  328. package/lib/util/sszBytes.d.ts +4 -1
  329. package/lib/util/sszBytes.d.ts.map +1 -1
  330. package/lib/util/sszBytes.js +69 -12
  331. package/lib/util/sszBytes.js.map +1 -1
  332. package/lib/util/types.d.ts +2 -0
  333. package/lib/util/types.d.ts.map +1 -1
  334. package/lib/util/types.js +1 -0
  335. package/lib/util/types.js.map +1 -1
  336. package/package.json +16 -16
  337. package/src/api/impl/beacon/blocks/index.ts +37 -18
  338. package/src/api/impl/beacon/pool/index.ts +1 -1
  339. package/src/api/impl/beacon/state/index.ts +29 -41
  340. package/src/api/impl/beacon/state/utils.ts +11 -25
  341. package/src/api/impl/lodestar/index.ts +4 -8
  342. package/src/api/impl/proof/index.ts +2 -9
  343. package/src/api/impl/validator/index.ts +29 -41
  344. package/src/api/impl/validator/utils.ts +4 -7
  345. package/src/chain/archiveStore/archiveStore.ts +1 -0
  346. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -39
  347. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +2 -1
  348. package/src/chain/archiveStore/historicalState/types.ts +2 -0
  349. package/src/chain/archiveStore/historicalState/worker.ts +1 -4
  350. package/src/chain/archiveStore/interface.ts +1 -0
  351. package/src/chain/balancesCache.ts +5 -11
  352. package/src/chain/blocks/blockInput/types.ts +4 -3
  353. package/src/chain/blocks/importBlock.ts +47 -16
  354. package/src/chain/blocks/importExecutionPayload.ts +236 -0
  355. package/src/chain/blocks/index.ts +1 -1
  356. package/src/chain/blocks/payloadEnvelopeInput/index.ts +2 -0
  357. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +336 -0
  358. package/src/chain/blocks/payloadEnvelopeInput/types.ts +33 -0
  359. package/src/chain/blocks/payloadEnvelopeProcessor.ts +61 -0
  360. package/src/chain/blocks/types.ts +10 -2
  361. package/src/chain/blocks/utils/checkpoint.ts +2 -2
  362. package/src/chain/blocks/verifyBlock.ts +5 -10
  363. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +5 -10
  364. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -3
  365. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -8
  366. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +55 -0
  367. package/src/chain/chain.ts +112 -70
  368. package/src/chain/emitter.ts +2 -2
  369. package/src/chain/errors/blockError.ts +4 -4
  370. package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
  371. package/src/chain/forkChoice/index.ts +33 -52
  372. package/src/chain/initState.ts +7 -2
  373. package/src/chain/interface.ts +18 -16
  374. package/src/chain/lightClient/index.ts +9 -22
  375. package/src/chain/opPools/aggregatedAttestationPool.ts +15 -21
  376. package/src/chain/opPools/opPool.ts +13 -14
  377. package/src/chain/opPools/utils.ts +4 -4
  378. package/src/chain/options.ts +2 -0
  379. package/src/chain/prepareNextSlot.ts +6 -8
  380. package/src/chain/produceBlock/computeNewStateRoot.ts +11 -10
  381. package/src/chain/produceBlock/produceBlockBody.ts +23 -50
  382. package/src/chain/regen/interface.ts +15 -17
  383. package/src/chain/regen/queued.ts +16 -20
  384. package/src/chain/regen/regen.ts +16 -17
  385. package/src/chain/seenCache/index.ts +1 -1
  386. package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
  387. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +106 -0
  388. package/src/chain/serializeState.ts +3 -3
  389. package/src/chain/shufflingCache.ts +5 -7
  390. package/src/chain/stateCache/fifoBlockStateCache.ts +7 -7
  391. package/src/chain/stateCache/persistentCheckpointsCache.ts +27 -42
  392. package/src/chain/stateCache/types.ts +14 -18
  393. package/src/chain/validation/attesterSlashing.ts +3 -3
  394. package/src/chain/validation/blobSidecar.ts +1 -1
  395. package/src/chain/validation/block.ts +2 -4
  396. package/src/chain/validation/blsToExecutionChange.ts +2 -2
  397. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  398. package/src/chain/validation/executionPayloadBid.ts +3 -7
  399. package/src/chain/validation/executionPayloadEnvelope.ts +36 -29
  400. package/src/chain/validation/lightClientFinalityUpdate.ts +1 -1
  401. package/src/chain/validation/lightClientOptimisticUpdate.ts +1 -1
  402. package/src/chain/validation/payloadAttestationMessage.ts +2 -4
  403. package/src/chain/validation/proposerSlashing.ts +1 -1
  404. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -7
  405. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -7
  406. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -2
  407. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -7
  408. package/src/chain/validation/syncCommittee.ts +21 -20
  409. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -10
  410. package/src/chain/validation/voluntaryExit.ts +3 -8
  411. package/src/chain/validatorMonitor.ts +23 -12
  412. package/src/execution/engine/interface.ts +2 -2
  413. package/src/metrics/metrics/lodestar.ts +100 -19
  414. package/src/network/gossip/encoding.ts +16 -0
  415. package/src/network/interface.ts +15 -2
  416. package/src/network/libp2p/index.ts +5 -0
  417. package/src/network/network.ts +34 -6
  418. package/src/network/processor/extractSlotRootFns.ts +19 -6
  419. package/src/network/processor/gossipHandlers.ts +45 -8
  420. package/src/network/processor/index.ts +110 -89
  421. package/src/network/reqresp/ReqRespBeaconNode.ts +14 -1
  422. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +94 -0
  423. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +43 -0
  424. package/src/network/reqresp/handlers/index.ts +12 -0
  425. package/src/network/reqresp/protocols.ts +12 -0
  426. package/src/network/reqresp/rateLimit.ts +18 -0
  427. package/src/network/reqresp/score.ts +2 -0
  428. package/src/network/reqresp/types.ts +13 -0
  429. package/src/node/nodejs.ts +3 -5
  430. package/src/node/notifier.ts +4 -10
  431. package/src/sync/backfill/backfill.ts +4 -4
  432. package/src/sync/constants.ts +1 -1
  433. package/src/sync/unknownBlock.ts +10 -50
  434. package/src/util/sszBytes.ts +90 -10
  435. package/src/util/types.ts +6 -0
  436. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +0 -15
  437. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +0 -1
  438. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +0 -28
  439. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +0 -1
  440. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +0 -34
@@ -1,17 +1,8 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {CheckpointWithPayloadStatus, IForkChoice} from "@lodestar/fork-choice";
3
3
  import {GENESIS_SLOT} from "@lodestar/params";
4
- import {BeaconStateAllForks, CachedBeaconStateAllForks, PubkeyCache} from "@lodestar/state-transition";
5
- import {
6
- BLSPubkey,
7
- Epoch,
8
- RootHex,
9
- Slot,
10
- ValidatorIndex,
11
- getValidatorStatus,
12
- mapToGeneralStatus,
13
- phase0,
14
- } from "@lodestar/types";
4
+ import {IBeaconStateView, PubkeyCache} from "@lodestar/state-transition";
5
+ import {BLSPubkey, Epoch, RootHex, Slot, ValidatorIndex, getValidatorStatus, phase0} from "@lodestar/types";
15
6
  import {fromHex} from "@lodestar/utils";
16
7
  import {IBeaconChain} from "../../../../chain/index.js";
17
8
  import {ApiError, ValidationError} from "../../errors.js";
@@ -52,7 +43,7 @@ export function resolveStateId(
52
43
  export async function getStateResponseWithRegen(
53
44
  chain: IBeaconChain,
54
45
  inStateId: routes.beacon.StateId
55
- ): Promise<{state: CachedBeaconStateAllForks | Uint8Array; executionOptimistic: boolean; finalized: boolean}> {
46
+ ): Promise<{state: IBeaconStateView | Uint8Array; executionOptimistic: boolean; finalized: boolean}> {
56
47
  const stateId = resolveStateId(chain.forkChoice, inStateId);
57
48
 
58
49
  const res =
@@ -89,22 +80,17 @@ export function toValidatorResponse(
89
80
 
90
81
  export function filterStateValidatorsByStatus(
91
82
  statuses: string[],
92
- state: BeaconStateAllForks,
83
+ state: IBeaconStateView,
93
84
  pubkeyCache: PubkeyCache,
94
85
  currentEpoch: Epoch
95
86
  ): routes.beacon.ValidatorResponse[] {
96
87
  const responses: routes.beacon.ValidatorResponse[] = [];
97
- const validatorsArr = state.validators.getAllReadonlyValues();
98
- const statusSet = new Set(statuses);
99
-
100
- for (const validator of validatorsArr) {
101
- const validatorStatus = getValidatorStatus(validator, currentEpoch);
102
- const generalStatus = mapToGeneralStatus(validatorStatus);
103
-
88
+ const validators = state.getValidatorsByStatus(new Set(statuses), currentEpoch);
89
+ for (const validator of validators) {
104
90
  const resp = getStateValidatorIndex(validator.pubkey, state, pubkeyCache);
105
- if (resp.valid && (statusSet.has(validatorStatus) || statusSet.has(generalStatus))) {
91
+ if (resp.valid) {
106
92
  responses.push(
107
- toValidatorResponse(resp.validatorIndex, validator, state.balances.get(resp.validatorIndex), currentEpoch)
93
+ toValidatorResponse(resp.validatorIndex, validator, state.getBalance(resp.validatorIndex), currentEpoch)
108
94
  );
109
95
  }
110
96
  }
@@ -117,7 +103,7 @@ type StateValidatorIndexResponse =
117
103
 
118
104
  export function getStateValidatorIndex(
119
105
  id: routes.beacon.ValidatorId | BLSPubkey,
120
- state: BeaconStateAllForks,
106
+ state: IBeaconStateView,
121
107
  pubkeyCache: PubkeyCache
122
108
  ): StateValidatorIndexResponse {
123
109
  if (typeof id === "string") {
@@ -139,7 +125,7 @@ export function getStateValidatorIndex(
139
125
  if (!Number.isSafeInteger(validatorIndex)) {
140
126
  return {valid: false, code: 400, reason: "Invalid validator index"};
141
127
  }
142
- if (validatorIndex >= state.validators.length) {
128
+ if (validatorIndex >= state.validatorCount) {
143
129
  return {valid: false, code: 404, reason: "Validator index from future state"};
144
130
  }
145
131
  return {valid: true, validatorIndex};
@@ -150,7 +136,7 @@ export function getStateValidatorIndex(
150
136
  if (validatorIndex === null) {
151
137
  return {valid: false, code: 404, reason: "Validator pubkey not found in state"};
152
138
  }
153
- if (validatorIndex >= state.validators.length) {
139
+ if (validatorIndex >= state.validatorCount) {
154
140
  return {valid: false, code: 404, reason: "Validator pubkey from future state"};
155
141
  }
156
142
  return {valid: true, validatorIndex};
@@ -1,10 +1,8 @@
1
- import {Tree} from "@chainsafe/persistent-merkle-tree";
2
1
  import {routes} from "@lodestar/api";
3
2
  import {ApplicationMethods} from "@lodestar/api/server";
4
3
  import {ChainForkConfig} from "@lodestar/config";
5
4
  import {Repository} from "@lodestar/db";
6
5
  import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
7
- import {BeaconStateCapella, getLatestWeakSubjectivityCheckpointEpoch, loadState} from "@lodestar/state-transition";
8
6
  import {ssz} from "@lodestar/types";
9
7
  import {Checkpoint} from "@lodestar/types/phase0";
10
8
  import {fromHex, toHex, toRootHex} from "@lodestar/utils";
@@ -86,7 +84,7 @@ export function getLodestarApi({
86
84
 
87
85
  async getLatestWeakSubjectivityCheckpointEpoch() {
88
86
  const state = chain.getHeadState();
89
- return {data: getLatestWeakSubjectivityCheckpointEpoch(config, state)};
87
+ return {data: state.getLatestWeakSubjectivityCheckpointEpoch()};
90
88
  },
91
89
 
92
90
  async getSyncChainsDebugState() {
@@ -214,9 +212,7 @@ export function getLodestarApi({
214
212
  async getHistoricalSummaries({stateId}) {
215
213
  const {state, executionOptimistic, finalized} = await getStateResponseWithRegen(chain, stateId);
216
214
 
217
- const stateView = (
218
- state instanceof Uint8Array ? loadState(config, chain.getHeadState(), state).state : state
219
- ) as BeaconStateCapella;
215
+ const stateView = state instanceof Uint8Array ? chain.getHeadState().loadOtherState(state) : state;
220
216
 
221
217
  const fork = config.getForkName(stateView.slot);
222
218
  if (ForkSeq[fork] < ForkSeq.capella) {
@@ -224,12 +220,12 @@ export function getLodestarApi({
224
220
  }
225
221
 
226
222
  const {gindex} = ssz[fork].BeaconState.getPathInfo(["historicalSummaries"]);
227
- const proof = new Tree(stateView.node).getSingleProof(gindex);
223
+ const proof = stateView.getSingleProof(gindex);
228
224
 
229
225
  return {
230
226
  data: {
231
227
  slot: stateView.slot,
232
- historicalSummaries: stateView.historicalSummaries.toValue(),
228
+ historicalSummaries: stateView.historicalSummaries,
233
229
  proof: proof,
234
230
  },
235
231
  meta: {executionOptimistic, finalized, version: fork},
@@ -1,7 +1,6 @@
1
1
  import {CompactMultiProof, ProofType, createProof} from "@chainsafe/persistent-merkle-tree";
2
2
  import {routes} from "@lodestar/api";
3
3
  import {ApplicationMethods} from "@lodestar/api/server";
4
- import {loadState} from "@lodestar/state-transition";
5
4
  import {ApiOptions} from "../../options.js";
6
5
  import {getBlockResponse} from "../beacon/blocks/utils.js";
7
6
  import {getStateResponseWithRegen} from "../beacon/state/utils.js";
@@ -24,16 +23,10 @@ export function getProofApi(
24
23
 
25
24
  const res = await getStateResponseWithRegen(chain, stateId);
26
25
 
27
- const state =
28
- res.state instanceof Uint8Array ? loadState(config, chain.getHeadState(), res.state).state : res.state;
29
-
30
- // there should be no state changes in beacon-node so no need to commit() here
31
- const stateNode = state.node;
32
-
33
- const proof = createProof(stateNode, {type: ProofType.compactMulti, descriptor});
26
+ const state = res.state instanceof Uint8Array ? chain.getHeadState().loadOtherState(res.state) : res.state;
34
27
 
35
28
  return {
36
- data: proof as CompactMultiProof,
29
+ data: state.createMultiProof(descriptor),
37
30
  meta: {version: config.getForkName(state.slot)},
38
31
  };
39
32
  },
@@ -17,19 +17,14 @@ import {
17
17
  isForkPostGloas,
18
18
  } from "@lodestar/params";
19
19
  import {
20
- CachedBeaconStateAllForks,
21
20
  DataAvailabilityStatus,
22
- attesterShufflingDecisionRoot,
21
+ IBeaconStateView,
23
22
  beaconBlockToBlinded,
24
23
  calculateCommitteeAssignments,
25
24
  computeEpochAtSlot,
26
25
  computeStartSlotAtEpoch,
27
26
  computeTimeAtSlot,
28
- createCachedBeaconState,
29
- createPubkeyCache,
30
- getBlockRootAtSlot,
31
27
  getCurrentSlot,
32
- loadState,
33
28
  proposerShufflingDecisionRoot,
34
29
  } from "@lodestar/state-transition";
35
30
  import {
@@ -193,11 +188,13 @@ export function getValidatorApi(
193
188
  const MAX_API_CLOCK_DISPARITY_MS = MAX_API_CLOCK_DISPARITY_SEC * 1000;
194
189
 
195
190
  /** Compute and cache the genesis block root */
196
- async function getGenesisBlockRoot(state: CachedBeaconStateAllForks): Promise<Root> {
191
+ async function getGenesisBlockRoot(state: IBeaconStateView): Promise<Root> {
197
192
  if (!genesisBlockRoot) {
198
193
  // Close to genesis the genesis block may not be available in the DB
199
- if (state.slot < SLOTS_PER_HISTORICAL_ROOT) {
200
- genesisBlockRoot = state.blockRoots.get(0);
194
+ if (state.slot === GENESIS_SLOT) {
195
+ genesisBlockRoot = state.computeAnchorCheckpoint().checkpoint.root;
196
+ } else if (state.slot < SLOTS_PER_HISTORICAL_ROOT) {
197
+ genesisBlockRoot = state.getBlockRootAtSlot(GENESIS_SLOT);
201
198
  }
202
199
 
203
200
  const blockRes = await chain.getCanonicalBlockAtSlot(GENESIS_SLOT);
@@ -303,7 +300,7 @@ export function getValidatorApi(
303
300
  * |
304
301
  * prepareNextSlot (4s before next slot)
305
302
  */
306
- async function waitForCheckpointState(cpHex: CheckpointHexPayload): Promise<CachedBeaconStateAllForks | null> {
303
+ async function waitForCheckpointState(cpHex: CheckpointHexPayload): Promise<IBeaconStateView | null> {
307
304
  const cpState = chain.regen.getCheckpointStateSync(cpHex);
308
305
  if (cpState) {
309
306
  return cpState;
@@ -995,7 +992,7 @@ export function getValidatorApi(
995
992
  headBlockRoot
996
993
  : // Permit attesting to slots *prior* to the current head. This is desirable when
997
994
  // the VC and BN are out-of-sync due to time issues or overloading.
998
- getBlockRootAtSlot(headState, slot);
995
+ headState.getBlockRootAtSlot(slot);
999
996
 
1000
997
  let index: CommitteeIndex;
1001
998
  if (isForkPostGloas(fork)) {
@@ -1026,7 +1023,7 @@ export function getValidatorApi(
1026
1023
  targetSlot >= headSlot
1027
1024
  ? // If the state is earlier than the target slot then the target *must* be the head block root.
1028
1025
  headBlockRoot
1029
- : getBlockRootAtSlot(headState, targetSlot);
1026
+ : headState.getBlockRootAtSlot(targetSlot);
1030
1027
 
1031
1028
  // Check the execution status as validator shouldn't vote on an optimistic head
1032
1029
  // Check on target is sufficient as a valid target would imply a valid source
@@ -1068,7 +1065,7 @@ export function getValidatorApi(
1068
1065
  // see https://github.com/ChainSafe/lodestar/issues/5063
1069
1066
  if (!chain.forkChoice.hasBlock(beaconBlockRoot)) {
1070
1067
  const rootHex = toRootHex(beaconBlockRoot);
1071
- network.searchUnknownSlotRoot({slot, root: rootHex}, BlockInputSource.api);
1068
+ network.searchUnknownBlock({slot, root: rootHex}, BlockInputSource.api);
1072
1069
  // if result of this call is false, i.e. block hasn't seen after 1 slot then the below notOnOptimisticBlockRoot call will throw error
1073
1070
  await chain.waitForBlock(slot, rootHex);
1074
1071
  }
@@ -1103,7 +1100,7 @@ export function getValidatorApi(
1103
1100
  }
1104
1101
 
1105
1102
  const head = chain.forkChoice.getHead();
1106
- let state: CachedBeaconStateAllForks | undefined = undefined;
1103
+ let state: IBeaconStateView | undefined = undefined;
1107
1104
  const startSlot = computeStartSlotAtEpoch(epoch);
1108
1105
  const prepareNextSlotLookAheadMs =
1109
1106
  config.SLOT_DURATION_MS - config.getSlotComponentDurationMs(PREPARE_NEXT_SLOT_BPS);
@@ -1133,43 +1130,34 @@ export function getValidatorApi(
1133
1130
  } else {
1134
1131
  const res = await getStateResponseWithRegen(chain, startSlot);
1135
1132
 
1136
- const stateViewDU =
1137
- res.state instanceof Uint8Array ? loadState(config, chain.getHeadState(), res.state).state : res.state;
1133
+ state = res.state instanceof Uint8Array ? chain.getHeadState().loadOtherState(res.state) : res.state;
1138
1134
 
1139
- state = createCachedBeaconState(
1140
- stateViewDU,
1141
- {
1142
- config: chain.config,
1143
- // Not required to compute proposers
1144
- pubkeyCache: createPubkeyCache(),
1145
- },
1146
- {skipSyncPubkeys: true, skipSyncCommitteeCache: true}
1147
- );
1148
-
1149
- if (state.epochCtx.epoch !== epoch) {
1150
- throw Error(`Loaded state epoch ${state.epochCtx.epoch} does not match requested epoch ${epoch}`);
1135
+ if (state.epoch !== epoch) {
1136
+ throw Error(`Loaded state epoch ${state.epoch} does not match requested epoch ${epoch}`);
1151
1137
  }
1152
1138
  }
1153
1139
  }
1154
1140
 
1155
- const stateEpoch = state.epochCtx.epoch;
1141
+ const stateEpoch = state.epoch;
1156
1142
  let indexes: ValidatorIndex[] = [];
1157
1143
 
1158
1144
  switch (epoch) {
1159
1145
  case stateEpoch:
1160
- indexes = state.epochCtx.getBeaconProposers();
1146
+ indexes = state.currentProposers;
1161
1147
  break;
1162
1148
 
1163
- case stateEpoch + 1:
1149
+ case stateEpoch + 1: {
1164
1150
  // make sure shuffling is calculated and ready for next call to calculate nextProposers
1165
- await chain.shufflingCache.get(state.epochCtx.nextEpoch, state.epochCtx.nextDecisionRoot);
1151
+ const nextEpoch = state.epoch + 1;
1152
+ await chain.shufflingCache.get(nextEpoch, state.nextDecisionRoot);
1166
1153
  // Requesting duties for next epoch is allowed since they can be predicted with high probabilities.
1167
1154
  // @see `epochCtx.getBeaconProposersNextEpoch` JSDocs for rationale.
1168
- indexes = state.epochCtx.getBeaconProposersNextEpoch();
1155
+ indexes = state.nextProposers;
1169
1156
  break;
1157
+ }
1170
1158
 
1171
1159
  case stateEpoch - 1: {
1172
- const indexesPrevEpoch = state.epochCtx.getBeaconProposersPrevEpoch();
1160
+ const indexesPrevEpoch = state.previousProposers;
1173
1161
  if (indexesPrevEpoch === null) {
1174
1162
  // Should not happen as previous proposer duties should be initialized for head state
1175
1163
  // and if we load state from `Uint8Array` it will always be the state of requested epoch
@@ -1188,7 +1176,7 @@ export function getValidatorApi(
1188
1176
  // See benchmark -> packages/lodestar/test/perf/api/impl/validator/attester.test.ts
1189
1177
  // After dropping the flat caches attached to the CachedBeaconState it's no longer available.
1190
1178
  // TODO: Add a flag to just send 0x00 as pubkeys since the Lodestar validator does not need them.
1191
- const pubkeys = getPubkeysForIndices(state.validators, indexes);
1179
+ const pubkeys = getPubkeysForIndices(state, indexes);
1192
1180
 
1193
1181
  const duties: routes.validator.ProposerDuty[] = [];
1194
1182
  for (let i = 0; i < SLOTS_PER_EPOCH; i++) {
@@ -1242,8 +1230,8 @@ export function getValidatorApi(
1242
1230
  // will equal `currentEpoch + 1`
1243
1231
 
1244
1232
  // Check that all validatorIndex belong to the state before calling getCommitteeAssignments()
1245
- const pubkeys = getPubkeysForIndices(state.validators, indices);
1246
- const decisionRoot = state.epochCtx.getShufflingDecisionRoot(epoch);
1233
+ const pubkeys = getPubkeysForIndices(state, indices);
1234
+ const decisionRoot = state.getShufflingDecisionRoot(epoch);
1247
1235
  const shuffling = await chain.shufflingCache.get(epoch, decisionRoot);
1248
1236
  if (!shuffling) {
1249
1237
  throw new ApiError(
@@ -1264,7 +1252,7 @@ export function getValidatorApi(
1264
1252
  }
1265
1253
  }
1266
1254
 
1267
- const dependentRoot = attesterShufflingDecisionRoot(state, epoch) || (await getGenesisBlockRoot(state));
1255
+ const dependentRoot = fromHex(state.getShufflingDecisionRoot(epoch)) || (await getGenesisBlockRoot(state));
1268
1256
 
1269
1257
  return {
1270
1258
  data: duties,
@@ -1305,9 +1293,9 @@ export function getValidatorApi(
1305
1293
  const state = chain.getHeadState();
1306
1294
 
1307
1295
  // Check that all validatorIndex belong to the state before calling getCommitteeAssignments()
1308
- const pubkeys = getPubkeysForIndices(state.validators, indices);
1296
+ const pubkeys = getPubkeysForIndices(state, indices);
1309
1297
  // Ensures `epoch // EPOCHS_PER_SYNC_COMMITTEE_PERIOD <= current_epoch // EPOCHS_PER_SYNC_COMMITTEE_PERIOD + 1`
1310
- const syncCommitteeCache = state.epochCtx.getIndexedSyncCommitteeAtEpoch(epoch);
1298
+ const syncCommitteeCache = state.getIndexedSyncCommitteeAtEpoch(epoch);
1311
1299
  const validatorSyncCommitteeIndexMap = syncCommitteeCache.validatorIndexMap;
1312
1300
 
1313
1301
  const duties: routes.validator.SyncDuty[] = [];
@@ -1605,7 +1593,7 @@ export function getValidatorApi(
1605
1593
  const validatorIndex = chain.pubkeyCache.getIndex(pubkey);
1606
1594
  if (validatorIndex === null) return false;
1607
1595
 
1608
- const validator = headState.validators.getReadonly(validatorIndex);
1596
+ const validator = headState.getValidator(validatorIndex);
1609
1597
  const status = getValidatorStatus(validator, currentEpoch);
1610
1598
  return (
1611
1599
  status === "active_exiting" ||
@@ -1,6 +1,6 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ATTESTATION_SUBNET_COUNT} from "@lodestar/params";
3
- import {BeaconStateAllForks, computeSlotsSinceEpochStart} from "@lodestar/state-transition";
3
+ import {IBeaconStateView, computeSlotsSinceEpochStart} from "@lodestar/state-transition";
4
4
  import {BLSPubkey, CommitteeIndex, ProducedBlockSource, Slot, SubnetID, ValidatorIndex} from "@lodestar/types";
5
5
  import {MAX_BUILDER_BOOST_FACTOR} from "@lodestar/validator";
6
6
  import {BlockSelectionResult, BuilderBlockSelectionReason, EngineBlockSelectionReason} from "./index.js";
@@ -24,11 +24,8 @@ export function computeSubnetForCommitteesAtSlot(
24
24
  * Note: This is the fastest way of getting compressed pubkeys.
25
25
  * See benchmark -> packages/beacon-node/test/perf/api/impl/validator/attester.test.ts
26
26
  */
27
- export function getPubkeysForIndices(
28
- validators: BeaconStateAllForks["validators"],
29
- indexes: ValidatorIndex[]
30
- ): BLSPubkey[] {
31
- const validatorsLen = validators.length; // Get once, it's expensive
27
+ export function getPubkeysForIndices(state: IBeaconStateView, indexes: ValidatorIndex[]): BLSPubkey[] {
28
+ const validatorsLen = state.validatorCount; // Get once, it's expensive
32
29
 
33
30
  const pubkeys: BLSPubkey[] = [];
34
31
  for (let i = 0, len = indexes.length; i < len; i++) {
@@ -38,7 +35,7 @@ export function getPubkeysForIndices(
38
35
  }
39
36
 
40
37
  // NOTE: This could be optimized further by traversing the tree optimally with .getNodes()
41
- const validator = validators.getReadonly(index);
38
+ const validator = state.getValidator(index);
42
39
  pubkeys.push(validator.pubkey);
43
40
  }
44
41
 
@@ -120,6 +120,7 @@ export class ArchiveStore {
120
120
  opts: {
121
121
  genesisTime: this.chain.clock.genesisTime,
122
122
  dbLocation: this.opts.dbName,
123
+ nativeStateView: this.opts.nativeStateView ?? false,
123
124
  },
124
125
  config: this.chain.config,
125
126
  metrics: this.metrics,
@@ -1,33 +1,15 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {
3
- BeaconStateAllForks,
4
- CachedBeaconStateAllForks,
5
3
  DataAvailabilityStatus,
6
4
  ExecutionPayloadStatus,
7
- PubkeyCache,
8
- createCachedBeaconState,
9
- stateTransition,
5
+ IBeaconStateView,
6
+ createBeaconStateViewForHistoricalRegen,
10
7
  } from "@lodestar/state-transition";
11
8
  import {byteArrayEquals} from "@lodestar/utils";
12
9
  import {IBeaconDb} from "../../../db/index.js";
13
- import {getStateTypeFromBytes} from "../../../util/multifork.js";
14
10
  import {HistoricalStateRegenMetrics} from "./metrics.js";
15
11
  import {RegenErrorType} from "./types.js";
16
12
 
17
- /**
18
- * Populate a PubkeyCache with any new entries based on a BeaconState
19
- */
20
- export function syncPubkeyCache(state: BeaconStateAllForks, pubkeyCache: PubkeyCache): void {
21
- // Get the validators sub tree once for all the loop
22
- const validators = state.validators;
23
-
24
- const newCount = state.validators.length;
25
- for (let i = pubkeyCache.size; i < newCount; i++) {
26
- const pubkey = validators.getReadonly(i).pubkey;
27
- pubkeyCache.set(i, pubkey);
28
- }
29
- }
30
-
31
13
  /**
32
14
  * Get the nearest BeaconState at or before a slot
33
15
  */
@@ -35,27 +17,17 @@ export async function getNearestState(
35
17
  slot: number,
36
18
  config: BeaconConfig,
37
19
  db: IBeaconDb,
38
- pubkeyCache: PubkeyCache
39
- ): Promise<CachedBeaconStateAllForks> {
20
+ nativeStateView: boolean
21
+ ): Promise<IBeaconStateView> {
40
22
  const stateBytesArr = await db.stateArchive.binaries({limit: 1, lte: slot, reverse: true});
41
23
  if (!stateBytesArr.length) {
42
24
  throw new Error("No near state found in the database");
43
25
  }
44
26
 
45
27
  const stateBytes = stateBytesArr[0];
46
- const state = getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes);
47
- syncPubkeyCache(state, pubkeyCache);
48
-
49
- return createCachedBeaconState(
50
- state,
51
- {
52
- config,
53
- pubkeyCache,
54
- },
55
- {
56
- skipSyncPubkeys: true,
57
- }
58
- );
28
+ return nativeStateView
29
+ ? createBeaconStateViewForHistoricalRegen({useNative: true, stateBytes})
30
+ : createBeaconStateViewForHistoricalRegen({useNative: false, config, stateBytes});
59
31
  }
60
32
 
61
33
  /**
@@ -65,13 +37,13 @@ export async function getHistoricalState(
65
37
  slot: number,
66
38
  config: BeaconConfig,
67
39
  db: IBeaconDb,
68
- pubkeyCache: PubkeyCache,
40
+ nativeStateView: boolean,
69
41
  metrics?: HistoricalStateRegenMetrics
70
42
  ): Promise<Uint8Array> {
71
43
  const regenTimer = metrics?.regenTime.startTimer();
72
44
 
73
45
  const loadStateTimer = metrics?.loadStateTime.startTimer();
74
- let state = await getNearestState(slot, config, db, pubkeyCache).catch((e) => {
46
+ let state = await getNearestState(slot, config, db, nativeStateView).catch((e) => {
75
47
  metrics?.regenErrorCount.inc({reason: RegenErrorType.loadState});
76
48
  throw e;
77
49
  });
@@ -81,8 +53,7 @@ export async function getHistoricalState(
81
53
  let blockCount = 0;
82
54
  for await (const block of db.blockArchive.valuesStream({gt: state.slot, lte: slot})) {
83
55
  try {
84
- state = stateTransition(
85
- state,
56
+ state = state.stateTransition(
86
57
  block,
87
58
  {
88
59
  verifyProposer: false,
@@ -20,7 +20,7 @@ export class HistoricalStateRegen implements HistoricalStateWorkerApi {
20
20
  private readonly api: ModuleThread<HistoricalStateWorkerApi>;
21
21
  private readonly logger: LoggerNode;
22
22
 
23
- constructor(modules: HistoricalStateRegenModules) {
23
+ private constructor(modules: HistoricalStateRegenModules) {
24
24
  this.api = modules.api;
25
25
  this.logger = modules.logger;
26
26
  modules.signal?.addEventListener("abort", () => this.close(), {once: true});
@@ -35,6 +35,7 @@ export class HistoricalStateRegen implements HistoricalStateWorkerApi {
35
35
  dbLocation: modules.opts.dbLocation,
36
36
  metricsEnabled: Boolean(modules.metrics),
37
37
  loggerOpts: modules.logger.toOpts(),
38
+ nativeStateView: modules.opts.nativeStateView,
38
39
  };
39
40
 
40
41
  const worker = new Worker(path.join(WORKER_DIR, "worker.js"), {
@@ -7,6 +7,7 @@ export type HistoricalStateRegenInitModules = {
7
7
  opts: {
8
8
  genesisTime: number;
9
9
  dbLocation: string;
10
+ nativeStateView: boolean;
10
11
  };
11
12
  config: BeaconConfig;
12
13
  logger: LoggerNode;
@@ -26,6 +27,7 @@ export type HistoricalStateWorkerData = {
26
27
  dbLocation: string;
27
28
  metricsEnabled: boolean;
28
29
  loggerOpts: LoggerNodeOpts;
30
+ nativeStateView: boolean;
29
31
  };
30
32
 
31
33
  export type HistoricalStateWorkerApi = {
@@ -3,7 +3,6 @@ import {Transfer, expose} from "@chainsafe/threads/worker";
3
3
  import {chainConfigFromJson, createBeaconConfig} from "@lodestar/config";
4
4
  import {LevelDbController} from "@lodestar/db/controller/level";
5
5
  import {getNodeLogger} from "@lodestar/logger/node";
6
- import {createPubkeyCache} from "@lodestar/state-transition";
7
6
  import {BeaconDb} from "../../../db/index.js";
8
7
  import {RegistryMetricCreator, collectNodeJSMetrics} from "../../../metrics/index.js";
9
8
  import {JobFnQueue} from "../../../util/queue/fnQueue.js";
@@ -52,8 +51,6 @@ const queue = new JobFnQueue(
52
51
  queueMetrics
53
52
  );
54
53
 
55
- const pubkeyCache = createPubkeyCache();
56
-
57
54
  const api: HistoricalStateWorkerApi = {
58
55
  async close() {
59
56
  abortController.abort();
@@ -65,7 +62,7 @@ const api: HistoricalStateWorkerApi = {
65
62
  historicalStateRegenMetrics?.regenRequestCount.inc();
66
63
 
67
64
  const stateBytes = await queue.push<Uint8Array>(() =>
68
- getHistoricalState(slot, config, db, pubkeyCache, historicalStateRegenMetrics)
65
+ getHistoricalState(slot, config, db, workerData.nativeStateView, historicalStateRegenMetrics)
69
66
  );
70
67
  const result = Transfer(stateBytes, [stateBytes.buffer]) as unknown as Uint8Array;
71
68
 
@@ -25,6 +25,7 @@ export type ArchiveStoreOpts = StatesArchiveOpts & {
25
25
  archiveDataEpochs?: number;
26
26
  pruneHistory?: boolean;
27
27
  serveHistoricalState?: boolean;
28
+ nativeStateView?: boolean;
28
29
  };
29
30
 
30
31
  export type ProposalStats = {
@@ -1,11 +1,5 @@
1
1
  import {CheckpointWithHex} from "@lodestar/fork-choice";
2
- import {
3
- CachedBeaconStateAllForks,
4
- EffectiveBalanceIncrements,
5
- computeStartSlotAtEpoch,
6
- getBlockRootAtSlot,
7
- getEffectiveBalanceIncrementsZeroInactive,
8
- } from "@lodestar/state-transition";
2
+ import {EffectiveBalanceIncrements, IBeaconStateView, computeStartSlotAtEpoch} from "@lodestar/state-transition";
9
3
  import {Epoch, RootHex} from "@lodestar/types";
10
4
  import {toRootHex} from "@lodestar/utils";
11
5
 
@@ -29,11 +23,11 @@ export class CheckpointBalancesCache {
29
23
  * `state.current_epoch`. If there is not already some entry for the given block root, then
30
24
  * add the effective balances from the `state` to the cache.
31
25
  */
32
- processState(blockRootHex: RootHex, state: CachedBeaconStateAllForks): void {
33
- const epoch = state.epochCtx.epoch;
26
+ processState(blockRootHex: RootHex, state: IBeaconStateView): void {
27
+ const epoch = state.epoch;
34
28
  const epochBoundarySlot = computeStartSlotAtEpoch(epoch);
35
29
  const epochBoundaryRoot =
36
- epochBoundarySlot === state.slot ? blockRootHex : toRootHex(getBlockRootAtSlot(state, epochBoundarySlot));
30
+ epochBoundarySlot === state.slot ? blockRootHex : toRootHex(state.getBlockRootAtSlot(epochBoundarySlot));
37
31
 
38
32
  const index = this.items.findIndex((item) => item.epoch === epoch && item.rootHex === epochBoundaryRoot);
39
33
  if (index === -1) {
@@ -41,7 +35,7 @@ export class CheckpointBalancesCache {
41
35
  this.items.shift();
42
36
  }
43
37
  // expect to reach this once per epoch
44
- this.items.push({epoch, rootHex: epochBoundaryRoot, balances: getEffectiveBalanceIncrementsZeroInactive(state)});
38
+ this.items.push({epoch, rootHex: epochBoundaryRoot, balances: state.getEffectiveBalanceIncrementsZeroInactive()});
45
39
  }
46
40
  }
47
41
 
@@ -1,5 +1,5 @@
1
1
  import {ForkName} from "@lodestar/params";
2
- import {ColumnIndex, RootHex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
2
+ import {ColumnIndex, DataColumnSidecars, RootHex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
3
3
  import {VersionedHashes} from "../../../execution/index.js";
4
4
 
5
5
  export enum DAType {
@@ -16,6 +16,7 @@ export type DAData = null | deneb.BlobSidecars | fulu.DataColumnSidecars;
16
16
  * sources so each should be labelled individually.
17
17
  */
18
18
  export enum BlockInputSource {
19
+ network_processor = "network_processor",
19
20
  gossip = "gossip",
20
21
  api = "api",
21
22
  engine = "engine",
@@ -107,9 +108,9 @@ export type MissingColumnMeta = {
107
108
  export interface IDataColumnsInput {
108
109
  readonly slot: Slot;
109
110
  readonly blockRootHex: string;
110
- getCustodyColumns(): fulu.DataColumnSidecars;
111
+ getCustodyColumns(): DataColumnSidecars;
111
112
  hasComputedAllData(): boolean;
112
- waitForComputedAllData(timeout: number, signal?: AbortSignal): Promise<fulu.DataColumnSidecars>;
113
+ waitForComputedAllData(timeout: number, signal?: AbortSignal): Promise<DataColumnSidecars>;
113
114
  }
114
115
 
115
116
  /**