@lodestar/beacon-node 1.42.0-dev.d73eccfa56 → 1.42.0-dev.e8407e9657

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 (467) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +25 -13
  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/debug/index.js.map +1 -1
  14. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  15. package/lib/api/impl/lodestar/index.js +4 -6
  16. package/lib/api/impl/lodestar/index.js.map +1 -1
  17. package/lib/api/impl/proof/index.d.ts.map +1 -1
  18. package/lib/api/impl/proof/index.js +2 -6
  19. package/lib/api/impl/proof/index.js.map +1 -1
  20. package/lib/api/impl/validator/index.d.ts.map +1 -1
  21. package/lib/api/impl/validator/index.js +27 -27
  22. package/lib/api/impl/validator/index.js.map +1 -1
  23. package/lib/api/impl/validator/utils.d.ts +2 -2
  24. package/lib/api/impl/validator/utils.d.ts.map +1 -1
  25. package/lib/api/impl/validator/utils.js +3 -3
  26. package/lib/api/impl/validator/utils.js.map +1 -1
  27. package/lib/chain/ColumnReconstructionTracker.d.ts +2 -1
  28. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  29. package/lib/chain/ColumnReconstructionTracker.js +5 -5
  30. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  31. package/lib/chain/GetBlobsTracker.d.ts +2 -1
  32. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  33. package/lib/chain/GetBlobsTracker.js +14 -12
  34. package/lib/chain/GetBlobsTracker.js.map +1 -1
  35. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  36. package/lib/chain/archiveStore/archiveStore.js +1 -0
  37. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  38. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +3 -7
  39. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  40. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +8 -26
  41. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  42. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts +2 -2
  43. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  44. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -0
  45. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  46. package/lib/chain/archiveStore/historicalState/types.d.ts +2 -0
  47. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  48. package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
  49. package/lib/chain/archiveStore/historicalState/worker.js +1 -3
  50. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  51. package/lib/chain/archiveStore/interface.d.ts +1 -0
  52. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  53. package/lib/chain/balancesCache.d.ts +2 -2
  54. package/lib/chain/balancesCache.d.ts.map +1 -1
  55. package/lib/chain/balancesCache.js +4 -4
  56. package/lib/chain/balancesCache.js.map +1 -1
  57. package/lib/chain/blocks/blockInput/blockInput.d.ts +5 -5
  58. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  59. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  60. package/lib/chain/blocks/blockInput/types.d.ts +5 -4
  61. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  62. package/lib/chain/blocks/blockInput/types.js +1 -0
  63. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  64. package/lib/chain/blocks/importBlock.d.ts +3 -3
  65. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  66. package/lib/chain/blocks/importBlock.js +34 -22
  67. package/lib/chain/blocks/importBlock.js.map +1 -1
  68. package/lib/chain/blocks/importExecutionPayload.d.ts +10 -8
  69. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  70. package/lib/chain/blocks/importExecutionPayload.js +78 -51
  71. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  72. package/lib/chain/blocks/index.d.ts.map +1 -1
  73. package/lib/chain/blocks/index.js +3 -2
  74. package/lib/chain/blocks/index.js.map +1 -1
  75. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +14 -6
  76. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  77. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +33 -2
  78. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  79. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
  80. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  81. package/lib/chain/blocks/types.d.ts +21 -15
  82. package/lib/chain/blocks/types.d.ts.map +1 -1
  83. package/lib/chain/blocks/types.js.map +1 -1
  84. package/lib/chain/blocks/utils/checkpoint.d.ts +2 -2
  85. package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -1
  86. package/lib/chain/blocks/utils/checkpoint.js.map +1 -1
  87. package/lib/chain/blocks/verifyBlock.d.ts +2 -2
  88. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  89. package/lib/chain/blocks/verifyBlock.js +4 -4
  90. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  91. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +5 -5
  92. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  93. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -4
  94. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  95. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  96. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  97. package/lib/chain/blocks/verifyBlocksSignatures.js +1 -1
  98. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  99. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -3
  100. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  101. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +3 -3
  102. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  103. package/lib/chain/chain.d.ts +15 -14
  104. package/lib/chain/chain.d.ts.map +1 -1
  105. package/lib/chain/chain.js +102 -59
  106. package/lib/chain/chain.js.map +1 -1
  107. package/lib/chain/emitter.d.ts +31 -9
  108. package/lib/chain/emitter.d.ts.map +1 -1
  109. package/lib/chain/emitter.js +12 -3
  110. package/lib/chain/emitter.js.map +1 -1
  111. package/lib/chain/errors/blockError.d.ts +4 -4
  112. package/lib/chain/errors/blockError.d.ts.map +1 -1
  113. package/lib/chain/errors/dataColumnSidecarError.d.ts +31 -1
  114. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  115. package/lib/chain/errors/dataColumnSidecarError.js +7 -0
  116. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  117. package/lib/chain/forkChoice/index.d.ts +4 -4
  118. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  119. package/lib/chain/forkChoice/index.js +27 -23
  120. package/lib/chain/forkChoice/index.js.map +1 -1
  121. package/lib/chain/initState.d.ts +2 -2
  122. package/lib/chain/initState.d.ts.map +1 -1
  123. package/lib/chain/initState.js +1 -1
  124. package/lib/chain/initState.js.map +1 -1
  125. package/lib/chain/interface.d.ts +15 -14
  126. package/lib/chain/interface.d.ts.map +1 -1
  127. package/lib/chain/lightClient/index.d.ts +2 -2
  128. package/lib/chain/lightClient/index.d.ts.map +1 -1
  129. package/lib/chain/lightClient/index.js +4 -4
  130. package/lib/chain/lightClient/index.js.map +1 -1
  131. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +6 -6
  132. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  133. package/lib/chain/opPools/aggregatedAttestationPool.js +10 -13
  134. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  135. package/lib/chain/opPools/opPool.d.ts +3 -3
  136. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  137. package/lib/chain/opPools/opPool.js +7 -7
  138. package/lib/chain/opPools/opPool.js.map +1 -1
  139. package/lib/chain/opPools/utils.d.ts +2 -2
  140. package/lib/chain/opPools/utils.d.ts.map +1 -1
  141. package/lib/chain/opPools/utils.js +1 -1
  142. package/lib/chain/opPools/utils.js.map +1 -1
  143. package/lib/chain/options.d.ts +1 -0
  144. package/lib/chain/options.d.ts.map +1 -1
  145. package/lib/chain/options.js +1 -0
  146. package/lib/chain/options.js.map +1 -1
  147. package/lib/chain/prepareNextSlot.d.ts +2 -2
  148. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  149. package/lib/chain/prepareNextSlot.js +3 -3
  150. package/lib/chain/prepareNextSlot.js.map +1 -1
  151. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +4 -4
  152. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  153. package/lib/chain/produceBlock/computeNewStateRoot.js +3 -4
  154. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  155. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  156. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  157. package/lib/chain/produceBlock/produceBlockBody.js +12 -16
  158. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  159. package/lib/chain/regen/interface.d.ts +13 -13
  160. package/lib/chain/regen/interface.d.ts.map +1 -1
  161. package/lib/chain/regen/queued.d.ts +14 -14
  162. package/lib/chain/regen/queued.d.ts.map +1 -1
  163. package/lib/chain/regen/queued.js.map +1 -1
  164. package/lib/chain/regen/regen.d.ts +6 -5
  165. package/lib/chain/regen/regen.d.ts.map +1 -1
  166. package/lib/chain/regen/regen.js +6 -6
  167. package/lib/chain/regen/regen.js.map +1 -1
  168. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +1 -1
  169. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  170. package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
  171. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  172. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +1 -1
  173. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  174. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +2 -2
  175. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  176. package/lib/chain/serializeState.d.ts +2 -2
  177. package/lib/chain/serializeState.d.ts.map +1 -1
  178. package/lib/chain/serializeState.js +1 -1
  179. package/lib/chain/serializeState.js.map +1 -1
  180. package/lib/chain/shufflingCache.d.ts +2 -2
  181. package/lib/chain/shufflingCache.d.ts.map +1 -1
  182. package/lib/chain/shufflingCache.js +3 -4
  183. package/lib/chain/shufflingCache.js.map +1 -1
  184. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +6 -6
  185. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  186. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  187. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +11 -11
  188. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  189. package/lib/chain/stateCache/persistentCheckpointsCache.js +12 -16
  190. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  191. package/lib/chain/stateCache/types.d.ts +14 -14
  192. package/lib/chain/stateCache/types.d.ts.map +1 -1
  193. package/lib/chain/stateCache/types.js.map +1 -1
  194. package/lib/chain/validation/attestation.js +3 -3
  195. package/lib/chain/validation/attestation.js.map +1 -1
  196. package/lib/chain/validation/attesterSlashing.js +3 -3
  197. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  198. package/lib/chain/validation/blobSidecar.js +1 -1
  199. package/lib/chain/validation/blobSidecar.js.map +1 -1
  200. package/lib/chain/validation/block.d.ts.map +1 -1
  201. package/lib/chain/validation/block.js +3 -3
  202. package/lib/chain/validation/block.js.map +1 -1
  203. package/lib/chain/validation/blsToExecutionChange.js +2 -2
  204. package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
  205. package/lib/chain/validation/dataColumnSidecar.d.ts +11 -4
  206. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  207. package/lib/chain/validation/dataColumnSidecar.js +185 -6
  208. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  209. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  210. package/lib/chain/validation/executionPayloadBid.js +4 -4
  211. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  212. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  213. package/lib/chain/validation/executionPayloadEnvelope.js +2 -3
  214. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  215. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  216. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  217. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  218. package/lib/chain/validation/proposerSlashing.js +1 -1
  219. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  220. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  221. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  222. package/lib/chain/validation/signatureSets/contributionAndProof.js +1 -1
  223. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  224. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  225. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  226. package/lib/chain/validation/signatureSets/syncCommittee.js +1 -1
  227. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  228. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  229. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  230. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  231. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  232. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  233. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -1
  234. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  235. package/lib/chain/validation/syncCommittee.d.ts +4 -4
  236. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  237. package/lib/chain/validation/syncCommittee.js +13 -12
  238. package/lib/chain/validation/syncCommittee.js.map +1 -1
  239. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  240. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  241. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  242. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  243. package/lib/chain/validation/voluntaryExit.js +3 -3
  244. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  245. package/lib/chain/validatorMonitor.d.ts +3 -3
  246. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  247. package/lib/chain/validatorMonitor.js +9 -7
  248. package/lib/chain/validatorMonitor.js.map +1 -1
  249. package/lib/db/buckets.d.ts +2 -2
  250. package/lib/db/buckets.d.ts.map +1 -1
  251. package/lib/db/buckets.js +2 -2
  252. package/lib/db/buckets.js.map +1 -1
  253. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  254. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  255. package/lib/db/repositories/dataColumnSidecar.d.ts.map +1 -1
  256. package/lib/db/repositories/dataColumnSidecar.js +4 -2
  257. package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
  258. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
  259. package/lib/db/repositories/dataColumnSidecarArchive.js +4 -2
  260. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  261. package/lib/metrics/metrics/lodestar.d.ts +32 -4
  262. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  263. package/lib/metrics/metrics/lodestar.js +52 -15
  264. package/lib/metrics/metrics/lodestar.js.map +1 -1
  265. package/lib/network/gossip/encoding.d.ts.map +1 -1
  266. package/lib/network/gossip/encoding.js +15 -0
  267. package/lib/network/gossip/encoding.js.map +1 -1
  268. package/lib/network/interface.d.ts +7 -4
  269. package/lib/network/interface.d.ts.map +1 -1
  270. package/lib/network/libp2p/index.d.ts.map +1 -1
  271. package/lib/network/libp2p/index.js +22 -11
  272. package/lib/network/libp2p/index.js.map +1 -1
  273. package/lib/network/network.d.ts +7 -4
  274. package/lib/network/network.d.ts.map +1 -1
  275. package/lib/network/network.js +12 -3
  276. package/lib/network/network.js.map +1 -1
  277. package/lib/network/options.d.ts.map +1 -1
  278. package/lib/network/options.js +7 -2
  279. package/lib/network/options.js.map +1 -1
  280. package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
  281. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
  282. package/lib/network/processor/extractSlotRootFns.js +25 -5
  283. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  284. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  285. package/lib/network/processor/gossipHandlers.js +265 -80
  286. package/lib/network/processor/gossipHandlers.js.map +1 -1
  287. package/lib/network/processor/index.d.ts +22 -7
  288. package/lib/network/processor/index.d.ts.map +1 -1
  289. package/lib/network/processor/index.js +311 -80
  290. package/lib/network/processor/index.js.map +1 -1
  291. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  292. package/lib/network/reqresp/ReqRespBeaconNode.js +9 -0
  293. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  294. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts +8 -0
  295. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -0
  296. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +69 -0
  297. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -0
  298. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts +6 -0
  299. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -0
  300. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +28 -0
  301. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -0
  302. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  303. package/lib/network/reqresp/handlers/index.js +11 -1
  304. package/lib/network/reqresp/handlers/index.js.map +1 -1
  305. package/lib/network/reqresp/protocols.d.ts +2 -0
  306. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  307. package/lib/network/reqresp/protocols.js +10 -0
  308. package/lib/network/reqresp/protocols.js.map +1 -1
  309. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  310. package/lib/network/reqresp/rateLimit.js +8 -0
  311. package/lib/network/reqresp/rateLimit.js.map +1 -1
  312. package/lib/network/reqresp/score.d.ts.map +1 -1
  313. package/lib/network/reqresp/score.js +2 -0
  314. package/lib/network/reqresp/score.js.map +1 -1
  315. package/lib/network/reqresp/types.d.ts +10 -4
  316. package/lib/network/reqresp/types.d.ts.map +1 -1
  317. package/lib/network/reqresp/types.js +16 -4
  318. package/lib/network/reqresp/types.js.map +1 -1
  319. package/lib/node/nodejs.d.ts +2 -2
  320. package/lib/node/nodejs.d.ts.map +1 -1
  321. package/lib/node/nodejs.js +1 -4
  322. package/lib/node/nodejs.js.map +1 -1
  323. package/lib/node/notifier.d.ts.map +1 -1
  324. package/lib/node/notifier.js +3 -3
  325. package/lib/node/notifier.js.map +1 -1
  326. package/lib/sync/backfill/backfill.d.ts +2 -2
  327. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  328. package/lib/sync/backfill/backfill.js +2 -2
  329. package/lib/sync/backfill/backfill.js.map +1 -1
  330. package/lib/sync/unknownBlock.d.ts +3 -9
  331. package/lib/sync/unknownBlock.d.ts.map +1 -1
  332. package/lib/sync/unknownBlock.js +10 -43
  333. package/lib/sync/unknownBlock.js.map +1 -1
  334. package/lib/sync/utils/downloadByRange.d.ts +3 -3
  335. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  336. package/lib/sync/utils/downloadByRange.js +4 -2
  337. package/lib/sync/utils/downloadByRange.js.map +1 -1
  338. package/lib/sync/utils/downloadByRoot.d.ts +3 -3
  339. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  340. package/lib/sync/utils/downloadByRoot.js +10 -5
  341. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  342. package/lib/util/blobs.d.ts +3 -3
  343. package/lib/util/blobs.d.ts.map +1 -1
  344. package/lib/util/blobs.js +21 -10
  345. package/lib/util/blobs.js.map +1 -1
  346. package/lib/util/dataColumns.d.ts +18 -11
  347. package/lib/util/dataColumns.d.ts.map +1 -1
  348. package/lib/util/dataColumns.js +51 -17
  349. package/lib/util/dataColumns.js.map +1 -1
  350. package/lib/util/execution.d.ts +6 -2
  351. package/lib/util/execution.d.ts.map +1 -1
  352. package/lib/util/execution.js +49 -25
  353. package/lib/util/execution.js.map +1 -1
  354. package/lib/util/sszBytes.d.ts +19 -2
  355. package/lib/util/sszBytes.d.ts.map +1 -1
  356. package/lib/util/sszBytes.js +173 -3
  357. package/lib/util/sszBytes.js.map +1 -1
  358. package/lib/util/types.d.ts +2 -0
  359. package/lib/util/types.d.ts.map +1 -1
  360. package/lib/util/types.js +1 -0
  361. package/lib/util/types.js.map +1 -1
  362. package/package.json +16 -16
  363. package/src/api/impl/beacon/blocks/index.ts +33 -16
  364. package/src/api/impl/beacon/pool/index.ts +1 -1
  365. package/src/api/impl/beacon/state/index.ts +29 -41
  366. package/src/api/impl/beacon/state/utils.ts +11 -25
  367. package/src/api/impl/debug/index.ts +2 -2
  368. package/src/api/impl/lodestar/index.ts +4 -8
  369. package/src/api/impl/proof/index.ts +2 -9
  370. package/src/api/impl/validator/index.ts +29 -41
  371. package/src/api/impl/validator/utils.ts +4 -7
  372. package/src/chain/ColumnReconstructionTracker.ts +6 -5
  373. package/src/chain/GetBlobsTracker.ts +14 -12
  374. package/src/chain/archiveStore/archiveStore.ts +1 -0
  375. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -39
  376. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +2 -1
  377. package/src/chain/archiveStore/historicalState/types.ts +2 -0
  378. package/src/chain/archiveStore/historicalState/worker.ts +1 -4
  379. package/src/chain/archiveStore/interface.ts +1 -0
  380. package/src/chain/balancesCache.ts +5 -11
  381. package/src/chain/blocks/blockInput/blockInput.ts +8 -8
  382. package/src/chain/blocks/blockInput/types.ts +5 -4
  383. package/src/chain/blocks/importBlock.ts +41 -26
  384. package/src/chain/blocks/importExecutionPayload.ts +89 -63
  385. package/src/chain/blocks/index.ts +3 -2
  386. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +53 -12
  387. package/src/chain/blocks/payloadEnvelopeInput/types.ts +2 -1
  388. package/src/chain/blocks/types.ts +26 -15
  389. package/src/chain/blocks/utils/checkpoint.ts +2 -2
  390. package/src/chain/blocks/verifyBlock.ts +5 -10
  391. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -14
  392. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -3
  393. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -8
  394. package/src/chain/chain.ts +138 -91
  395. package/src/chain/emitter.ts +27 -9
  396. package/src/chain/errors/blockError.ts +4 -4
  397. package/src/chain/errors/dataColumnSidecarError.ts +32 -1
  398. package/src/chain/forkChoice/index.ts +33 -42
  399. package/src/chain/initState.ts +7 -2
  400. package/src/chain/interface.ts +16 -15
  401. package/src/chain/lightClient/index.ts +9 -22
  402. package/src/chain/opPools/aggregatedAttestationPool.ts +15 -21
  403. package/src/chain/opPools/opPool.ts +13 -14
  404. package/src/chain/opPools/utils.ts +3 -3
  405. package/src/chain/options.ts +2 -0
  406. package/src/chain/prepareNextSlot.ts +6 -8
  407. package/src/chain/produceBlock/computeNewStateRoot.ts +6 -10
  408. package/src/chain/produceBlock/produceBlockBody.ts +22 -49
  409. package/src/chain/regen/interface.ts +13 -17
  410. package/src/chain/regen/queued.ts +16 -20
  411. package/src/chain/regen/regen.ts +16 -17
  412. package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
  413. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +2 -2
  414. package/src/chain/serializeState.ts +3 -3
  415. package/src/chain/shufflingCache.ts +5 -7
  416. package/src/chain/stateCache/fifoBlockStateCache.ts +7 -7
  417. package/src/chain/stateCache/persistentCheckpointsCache.ts +27 -42
  418. package/src/chain/stateCache/types.ts +14 -18
  419. package/src/chain/validation/attestation.ts +3 -3
  420. package/src/chain/validation/attesterSlashing.ts +3 -3
  421. package/src/chain/validation/blobSidecar.ts +1 -1
  422. package/src/chain/validation/block.ts +2 -4
  423. package/src/chain/validation/blsToExecutionChange.ts +2 -2
  424. package/src/chain/validation/dataColumnSidecar.ts +231 -8
  425. package/src/chain/validation/executionPayloadBid.ts +3 -7
  426. package/src/chain/validation/executionPayloadEnvelope.ts +2 -8
  427. package/src/chain/validation/payloadAttestationMessage.ts +2 -4
  428. package/src/chain/validation/proposerSlashing.ts +1 -1
  429. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -7
  430. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -7
  431. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -2
  432. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -7
  433. package/src/chain/validation/syncCommittee.ts +21 -20
  434. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -10
  435. package/src/chain/validation/voluntaryExit.ts +3 -8
  436. package/src/chain/validatorMonitor.ts +12 -11
  437. package/src/db/buckets.ts +2 -2
  438. package/src/db/repositories/dataColumnSidecar.ts +4 -2
  439. package/src/db/repositories/dataColumnSidecarArchive.ts +4 -2
  440. package/src/metrics/metrics/lodestar.ts +57 -19
  441. package/src/network/gossip/encoding.ts +16 -0
  442. package/src/network/interface.ts +18 -4
  443. package/src/network/libp2p/index.ts +24 -13
  444. package/src/network/network.ts +39 -8
  445. package/src/network/options.ts +7 -2
  446. package/src/network/processor/extractSlotRootFns.ts +32 -6
  447. package/src/network/processor/gossipHandlers.ts +329 -94
  448. package/src/network/processor/index.ts +393 -92
  449. package/src/network/reqresp/ReqRespBeaconNode.ts +13 -0
  450. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +94 -0
  451. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +43 -0
  452. package/src/network/reqresp/handlers/index.ts +12 -0
  453. package/src/network/reqresp/protocols.ts +12 -0
  454. package/src/network/reqresp/rateLimit.ts +18 -0
  455. package/src/network/reqresp/score.ts +2 -0
  456. package/src/network/reqresp/types.ts +26 -5
  457. package/src/node/nodejs.ts +3 -5
  458. package/src/node/notifier.ts +4 -10
  459. package/src/sync/backfill/backfill.ts +3 -3
  460. package/src/sync/unknownBlock.ts +13 -53
  461. package/src/sync/utils/downloadByRange.ts +9 -7
  462. package/src/sync/utils/downloadByRoot.ts +16 -12
  463. package/src/util/blobs.ts +35 -15
  464. package/src/util/dataColumns.ts +69 -25
  465. package/src/util/execution.ts +49 -30
  466. package/src/util/sszBytes.ts +223 -7
  467. package/src/util/types.ts +6 -0
@@ -1,6 +1,6 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
3
- import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition";
3
+ import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
4
4
  import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
5
5
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
@@ -34,7 +34,7 @@ export type RegenRequest = RegenRequestByKey[RegenRequestKey];
34
34
  * All requests are queued so that only a single state at a time may be regenerated at a time
35
35
  */
36
36
  export class QueuedStateRegenerator implements IStateRegenerator {
37
- readonly jobQueue: JobItemQueue<[RegenRequest], CachedBeaconStateAllForks>;
37
+ readonly jobQueue: JobItemQueue<[RegenRequest], IBeaconStateView>;
38
38
  private readonly regen: StateRegenerator;
39
39
 
40
40
  private readonly forkChoice: IForkChoice;
@@ -45,7 +45,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
45
45
 
46
46
  constructor(modules: QueuedStateRegeneratorModules) {
47
47
  this.regen = new StateRegenerator(modules);
48
- this.jobQueue = new JobItemQueue<[RegenRequest], CachedBeaconStateAllForks>(
48
+ this.jobQueue = new JobItemQueue<[RegenRequest], IBeaconStateView>(
49
49
  this.jobQueueProcessor,
50
50
  {maxLength: REGEN_QUEUE_MAX_LEN, signal: modules.signal},
51
51
  modules.metrics ? modules.metrics.regenQueue : undefined
@@ -79,14 +79,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
79
79
  /**
80
80
  * Get a state from block state cache.
81
81
  */
82
- getStateSync(stateRoot: RootHex): CachedBeaconStateAllForks | null {
82
+ getStateSync(stateRoot: RootHex): IBeaconStateView | null {
83
83
  return this.blockStateCache.get(stateRoot);
84
84
  }
85
85
 
86
86
  /**
87
87
  * Get state for block processing.
88
88
  */
89
- getPreStateSync(block: BeaconBlock): CachedBeaconStateAllForks | null {
89
+ getPreStateSync(block: BeaconBlock): IBeaconStateView | null {
90
90
  const parentRoot = toRootHex(block.parentRoot);
91
91
  const parentBlock = isGloasBeaconBlock(block)
92
92
  ? this.forkChoice.getBlockHexAndBlockHash(
@@ -135,21 +135,21 @@ export class QueuedStateRegenerator implements IStateRegenerator {
135
135
  return null;
136
136
  }
137
137
 
138
- async getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<CachedBeaconStateAllForks | Uint8Array | null> {
138
+ async getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null> {
139
139
  return this.checkpointStateCache.getStateOrBytes(cp);
140
140
  }
141
141
 
142
142
  /**
143
143
  * Get checkpoint state from cache
144
144
  */
145
- getCheckpointStateSync(cp: CheckpointHexPayload): CachedBeaconStateAllForks | null {
145
+ getCheckpointStateSync(cp: CheckpointHexPayload): IBeaconStateView | null {
146
146
  return this.checkpointStateCache.get(cp);
147
147
  }
148
148
 
149
149
  /**
150
150
  * Get state closest to head
151
151
  */
152
- getClosestHeadState(head: ProtoBlock): CachedBeaconStateAllForks | null {
152
+ getClosestHeadState(head: ProtoBlock): IBeaconStateView | null {
153
153
  // Convert PayloadStatus to payloadPresent boolean
154
154
  if (head.payloadStatus === PayloadStatus.PENDING) {
155
155
  throw new RegenError({
@@ -175,7 +175,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
175
175
  this.blockStateCache.deleteAllBeforeEpoch(finalizedEpoch);
176
176
  }
177
177
 
178
- processBlockState(blockRootHex: RootHex, postState: CachedBeaconStateAllForks): void {
178
+ processBlockState(blockRootHex: RootHex, postState: IBeaconStateView): void {
179
179
  this.blockStateCache.add(postState);
180
180
  this.checkpointStateCache.processState(blockRootHex, postState).catch((e) => {
181
181
  this.logger.debug("Error processing block state", {blockRootHex, slot: postState.slot}, e);
@@ -185,17 +185,17 @@ export class QueuedStateRegenerator implements IStateRegenerator {
185
185
  /**
186
186
  * Process payload state for caching after importing execution payload.
187
187
  */
188
- processPayloadState(payloadState: CachedBeaconStateAllForks): void {
188
+ processPayloadState(payloadState: IBeaconStateView): void {
189
189
  // Add payload state to block state cache (keyed by payload state root)
190
190
  this.blockStateCache.add(payloadState);
191
191
  }
192
192
 
193
193
  // TODO GLOAS: This should also be called when importing execution payload after we implement it
194
- addCheckpointState(cp: phase0.Checkpoint, item: CachedBeaconStateAllForks, payloadPresent: boolean): void {
194
+ addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void {
195
195
  this.checkpointStateCache.add(cp, item, payloadPresent);
196
196
  }
197
197
 
198
- updateHeadState(newHead: ProtoBlock, maybeHeadState: CachedBeaconStateAllForks): void {
198
+ updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void {
199
199
  const {stateRoot: newHeadStateRoot, blockRoot: newHeadBlockRoot, slot: newHeadSlot} = newHead;
200
200
  const maybeHeadStateRoot = toRootHex(maybeHeadState.hashTreeRoot());
201
201
  const logCtx = {
@@ -241,11 +241,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
241
241
  * Get the state to run with `block`.
242
242
  * - State after `block.parentRoot` dialed forward to block.slot
243
243
  */
244
- async getPreState(
245
- block: BeaconBlock,
246
- opts: StateRegenerationOpts,
247
- rCaller: RegenCaller
248
- ): Promise<CachedBeaconStateAllForks> {
244
+ async getPreState(block: BeaconBlock, opts: StateRegenerationOpts, rCaller: RegenCaller): Promise<IBeaconStateView> {
249
245
  this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getPreState});
250
246
 
251
247
  // First attempt to fetch the state from caches before queueing
@@ -271,14 +267,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
271
267
  slot: Slot,
272
268
  opts: StateRegenerationOpts,
273
269
  rCaller: RegenCaller
274
- ): Promise<CachedBeaconStateAllForks> {
270
+ ): Promise<IBeaconStateView> {
275
271
  this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getBlockSlotState});
276
272
 
277
273
  // The state is not immediately available in the caches, enqueue the job
278
274
  return this.jobQueue.push({key: "getBlockSlotState", args: [block, slot, opts, rCaller]});
279
275
  }
280
276
 
281
- async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<CachedBeaconStateAllForks> {
277
+ async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<IBeaconStateView> {
282
278
  this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getState});
283
279
 
284
280
  // First attempt to fetch the state from cache before queueing
@@ -292,7 +288,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
292
288
  return this.jobQueue.push({key: "getState", args: [stateRoot, rCaller]});
293
289
  }
294
290
 
295
- private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<CachedBeaconStateAllForks> => {
291
+ private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<IBeaconStateView> => {
296
292
  const metricsLabels = {
297
293
  caller: regenRequest.args.at(-1) as RegenCaller,
298
294
  entrypoint: regenRequest.key as RegenFnName,
@@ -2,14 +2,12 @@ import {ChainForkConfig} from "@lodestar/config";
2
2
  import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
4
4
  import {
5
- CachedBeaconStateAllForks,
6
5
  DataAvailabilityStatus,
7
6
  ExecutionPayloadStatus,
7
+ IBeaconStateView,
8
8
  StateHashTreeRootSource,
9
9
  computeEpochAtSlot,
10
10
  computeStartSlotAtEpoch,
11
- processSlots,
12
- stateTransition,
13
11
  } from "@lodestar/state-transition";
14
12
  import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
15
13
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
@@ -57,7 +55,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
57
55
  block: BeaconBlock,
58
56
  opts: StateRegenerationOpts,
59
57
  regenCaller: RegenCaller
60
- ): Promise<CachedBeaconStateAllForks> {
58
+ ): Promise<IBeaconStateView> {
61
59
  const parentRoot = toRootHex(block.parentRoot);
62
60
  const parentBlock = isGloasBeaconBlock(block)
63
61
  ? this.modules.forkChoice.getBlockHexAndBlockHash(
@@ -99,7 +97,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
99
97
  opts: StateRegenerationOpts,
100
98
  regenCaller: RegenCaller,
101
99
  allowDiskReload = false
102
- ): Promise<CachedBeaconStateAllForks> {
100
+ ): Promise<IBeaconStateView> {
103
101
  if (slot < block.slot) {
104
102
  throw new RegenError({
105
103
  code: RegenErrorCode.SLOT_BEFORE_BLOCK_SLOT,
@@ -149,7 +147,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
149
147
  caller: RegenCaller,
150
148
  // internal option, don't want to expose to external caller
151
149
  allowDiskReload = false
152
- ): Promise<CachedBeaconStateAllForks> {
150
+ ): Promise<IBeaconStateView> {
153
151
  // Trivial case, state at stateRoot is already cached
154
152
  const cachedStateCtx = this.modules.blockStateCache.get(stateRoot);
155
153
  if (cachedStateCtx) {
@@ -164,7 +162,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
164
162
  // blocks to replay, ordered highest to lowest
165
163
  // gets reversed when replayed
166
164
  const blocksToReplay = [block];
167
- let state: CachedBeaconStateAllForks | null = null;
165
+ let state: IBeaconStateView | null = null;
168
166
  const {checkpointStateCache} = this.modules;
169
167
 
170
168
  const getSeedStateTimer = this.modules.metrics?.regenGetState.getSeedState.startTimer({caller});
@@ -260,8 +258,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
260
258
  // Only advances state trusting block's signture and hashes.
261
259
  // We are only running the state transition to get a specific state's data.
262
260
  // stateTransition() does the clone() inside, transfer cache to make the regen faster
263
- state = stateTransition(
264
- state,
261
+ state = state.stateTransition(
265
262
  block,
266
263
  {
267
264
  // Replay previously imported blocks, assume valid and available
@@ -333,16 +330,17 @@ async function processSlotsByCheckpoint(
333
330
  metrics: Metrics | null;
334
331
  validatorMonitor: ValidatorMonitor | null;
335
332
  emitter: ChainEventEmitter;
333
+ config: ChainForkConfig;
336
334
  logger: Logger;
337
335
  },
338
- preState: CachedBeaconStateAllForks,
336
+ preState: IBeaconStateView,
339
337
  slot: Slot,
340
338
  regenCaller: RegenCaller,
341
339
  opts: StateRegenerationOpts
342
- ): Promise<CachedBeaconStateAllForks> {
340
+ ): Promise<IBeaconStateView> {
343
341
  let postState = await processSlotsToNearestCheckpoint(modules, preState, slot, regenCaller, opts);
344
342
  if (postState.slot < slot) {
345
- postState = processSlots(postState, slot, opts, modules);
343
+ postState = postState.processSlots(slot, opts, modules);
346
344
  }
347
345
  return postState;
348
346
  }
@@ -365,18 +363,19 @@ export async function processSlotsToNearestCheckpoint(
365
363
  metrics: Metrics | null;
366
364
  validatorMonitor: ValidatorMonitor | null;
367
365
  emitter: ChainEventEmitter | null;
366
+ config: ChainForkConfig;
368
367
  logger: Logger | null;
369
368
  },
370
- preState: CachedBeaconStateAllForks,
369
+ preState: IBeaconStateView,
371
370
  slot: Slot,
372
371
  regenCaller: RegenCaller,
373
372
  opts: StateRegenerationOpts
374
- ): Promise<CachedBeaconStateAllForks> {
373
+ ): Promise<IBeaconStateView> {
375
374
  const preSlot = preState.slot;
376
375
  const postSlot = slot;
377
376
  const preEpoch = computeEpochAtSlot(preSlot);
378
377
  let postState = preState;
379
- const {checkpointStateCache, emitter, metrics, logger} = modules;
378
+ const {config, checkpointStateCache, emitter, metrics, logger} = modules;
380
379
  let count = 0;
381
380
 
382
381
  for (
@@ -391,7 +390,7 @@ export async function processSlotsToNearestCheckpoint(
391
390
  caller: regenCaller,
392
391
  });
393
392
  // processSlots calls .clone() before mutating
394
- postState = processSlots(postState, nextEpochSlot, opts, modules);
393
+ postState = postState.processSlots(nextEpochSlot, opts, modules);
395
394
  metrics?.epochTransitionByCaller.inc({caller: regenCaller});
396
395
 
397
396
  // this is usually added when we prepare for next slot or validate gossip block
@@ -403,7 +402,7 @@ export async function processSlotsToNearestCheckpoint(
403
402
  // processSlots() only does epoch transitions, never processes payloads
404
403
  // Pre-Gloas: payloadPresent is always true (execution payload embedded in block)
405
404
  // Post-Gloas: result is a block state (payloadPresent=false)
406
- const isPayloadPresent = checkpointState.config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
405
+ const isPayloadPresent = config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
407
406
  checkpointStateCache.add(cp, checkpointState, isPayloadPresent);
408
407
  // consumers should not mutate state ever
409
408
  emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
@@ -149,8 +149,8 @@ export class SeenBlockInput {
149
149
  });
150
150
  }
151
151
 
152
- has(rootHex: RootHex): boolean {
153
- return this.blockInputs.has(rootHex);
152
+ hasBlock(rootHex: RootHex): boolean {
153
+ return this.blockInputs.get(rootHex)?.hasBlock() ?? false;
154
154
  }
155
155
 
156
156
  get(rootHex: RootHex): IBlockInput | undefined {
@@ -84,8 +84,8 @@ export class SeenPayloadEnvelopeInput {
84
84
  return this.payloadInputs.get(blockRootHex);
85
85
  }
86
86
 
87
- has(blockRootHex: RootHex): boolean {
88
- return this.payloadInputs.has(blockRootHex);
87
+ hasPayload(blockRootHex: RootHex): boolean {
88
+ return this.payloadInputs.get(blockRootHex)?.hasPayloadEnvelope() ?? false;
89
89
  }
90
90
 
91
91
  prune(blockRootHex: RootHex): void {
@@ -1,4 +1,4 @@
1
- import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
1
+ import {IBeaconStateView} from "@lodestar/state-transition";
2
2
  import {AllocSource, BufferPool} from "../util/bufferPool.js";
3
3
 
4
4
  type ProcessStateBytesFn<T> = (stateBytes: Uint8Array) => Promise<T>;
@@ -7,12 +7,12 @@ type ProcessStateBytesFn<T> = (stateBytes: Uint8Array) => Promise<T>;
7
7
  * Serialize state using the BufferPool if provided.
8
8
  */
9
9
  export async function serializeState<T>(
10
- state: CachedBeaconStateAllForks,
10
+ state: IBeaconStateView,
11
11
  source: AllocSource,
12
12
  processFn: ProcessStateBytesFn<T>,
13
13
  bufferPool?: BufferPool | null
14
14
  ): Promise<T> {
15
- const size = state.type.tree_serializedSize(state.node);
15
+ const size = state.serializedSize();
16
16
  let stateBytes: Uint8Array | null = null;
17
17
  if (bufferPool) {
18
18
  using bufferWithKey = bufferPool.alloc(size, source);
@@ -1,7 +1,7 @@
1
1
  import {ForkSeq} from "@lodestar/params";
2
2
  import {
3
- CachedBeaconStateAllForks,
4
3
  EpochShuffling,
4
+ IBeaconStateView,
5
5
  getAttestingIndices,
6
6
  getBeaconCommittees,
7
7
  getIndexedAttestation,
@@ -159,17 +159,15 @@ export class ShufflingCache {
159
159
  * Process a state to extract and cache all shufflings (previous, current, next).
160
160
  * Uses the stored decision roots from epochCtx.
161
161
  */
162
- processState(state: CachedBeaconStateAllForks): void {
163
- const {epochCtx} = state;
164
-
162
+ processState(state: IBeaconStateView): void {
165
163
  // Cache previous shuffling
166
- this.set(epochCtx.previousShuffling, epochCtx.previousDecisionRoot);
164
+ this.set(state.getPreviousShuffling(), state.previousDecisionRoot);
167
165
 
168
166
  // Cache current shuffling
169
- this.set(epochCtx.currentShuffling, epochCtx.currentDecisionRoot);
167
+ this.set(state.getCurrentShuffling(), state.currentDecisionRoot);
170
168
 
171
169
  // Cache next shuffling
172
- this.set(epochCtx.nextShuffling, epochCtx.nextDecisionRoot);
170
+ this.set(state.getNextShuffling(), state.nextDecisionRoot);
173
171
  }
174
172
 
175
173
  getIndexedAttestation(
@@ -1,5 +1,5 @@
1
1
  import {routes} from "@lodestar/api";
2
- import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
2
+ import {IBeaconStateView} from "@lodestar/state-transition";
3
3
  import {RootHex} from "@lodestar/types";
4
4
  import {toRootHex} from "@lodestar/utils";
5
5
  import {Metrics} from "../../metrics/index.js";
@@ -48,7 +48,7 @@ export const DEFAULT_MAX_BLOCK_STATES_GLOAS = 128;
48
48
  export class FIFOBlockStateCache implements BlockStateCache {
49
49
  private maxStates: number;
50
50
 
51
- private readonly cache: MapTracker<string, CachedBeaconStateAllForks>;
51
+ private readonly cache: MapTracker<string, IBeaconStateView>;
52
52
  /**
53
53
  * Key order to implement FIFO cache
54
54
  */
@@ -68,7 +68,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
68
68
  /**
69
69
  * Set a state as head, happens when importing a block and head block is changed.
70
70
  */
71
- setHeadState(item: CachedBeaconStateAllForks | null): void {
71
+ setHeadState(item: IBeaconStateView | null): void {
72
72
  if (item !== null) {
73
73
  this.add(item, true);
74
74
  }
@@ -79,7 +79,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
79
79
  * base merkle tree for all BeaconState objects across application.
80
80
  * See packages/state-transition/src/util/loadState/loadState.ts for more detail
81
81
  */
82
- getSeedState(): CachedBeaconStateAllForks {
82
+ getSeedState(): IBeaconStateView {
83
83
  const firstValue = this.cache.values().next();
84
84
  if (firstValue.done) {
85
85
  // should not happen
@@ -94,7 +94,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
94
94
  /**
95
95
  * Get a state from this cache given a state root hex.
96
96
  */
97
- get(rootHex: RootHex): CachedBeaconStateAllForks | null {
97
+ get(rootHex: RootHex): IBeaconStateView | null {
98
98
  this.metrics?.lookups.inc();
99
99
  const item = this.cache.get(rootHex);
100
100
  if (!item) {
@@ -112,7 +112,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
112
112
  * @param isHead if true, move it to the head of the list. Otherwise add to the 2nd position.
113
113
  * In importBlock() steps, normally it'll call add() with isHead = false first. Then call setHeadState() to set the head.
114
114
  */
115
- add(item: CachedBeaconStateAllForks, isHead = false): void {
115
+ add(item: IBeaconStateView, isHead = false): void {
116
116
  const key = toRootHex(item.hashTreeRoot());
117
117
  if (this.cache.get(key) != null) {
118
118
  if (!this.keyOrder.has(key)) {
@@ -200,7 +200,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
200
200
  }));
201
201
  }
202
202
 
203
- getStates(): IterableIterator<CachedBeaconStateAllForks> {
203
+ getStates(): IterableIterator<IBeaconStateView> {
204
204
  return this.cache.values();
205
205
  }
206
206
 
@@ -1,12 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {BeaconConfig} from "@lodestar/config";
3
3
  import {CheckpointWithPayloadStatus} from "@lodestar/fork-choice";
4
- import {
5
- CachedBeaconStateAllForks,
6
- computeStartSlotAtEpoch,
7
- getBlockRootAtSlot,
8
- loadCachedBeaconState,
9
- } from "@lodestar/state-transition";
4
+ import {IBeaconStateView, computeStartSlotAtEpoch} from "@lodestar/state-transition";
10
5
  import {Epoch, RootHex, phase0} from "@lodestar/types";
11
6
  import {Logger, MapDef, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils";
12
7
  import {Metrics} from "../../metrics/index.js";
@@ -40,7 +35,7 @@ type CacheKey = string;
40
35
 
41
36
  type InMemoryCacheItem = {
42
37
  type: CacheItemType.inMemory;
43
- state: CachedBeaconStateAllForks;
38
+ state: IBeaconStateView;
44
39
  // if a cp state is reloaded from disk, it'll keep track of persistedKey to allow us to remove it from disk later
45
40
  // it also helps not to persist it again
46
41
  persistedKey?: DatastoreKey;
@@ -220,9 +215,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
220
215
  * - Get block for processing
221
216
  * - Regen head state
222
217
  */
223
- async getOrReload(cp: CheckpointHexPayload): Promise<CachedBeaconStateAllForks | null> {
218
+ async getOrReload(cp: CheckpointHexPayload): Promise<IBeaconStateView | null> {
224
219
  const stateOrStateBytesData = await this.getStateOrLoadDb(cp);
225
- if (stateOrStateBytesData === null || isCachedBeaconState(stateOrStateBytesData)) {
220
+ if (stateOrStateBytesData === null || isBeaconStateView(stateOrStateBytesData)) {
226
221
  return stateOrStateBytesData ?? null;
227
222
  }
228
223
  const {persistedKey, stateBytes} = stateOrStateBytesData;
@@ -237,7 +232,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
237
232
  this.clock?.secFromSlot(this.clock?.currentSlot ?? 0) ?? 0
238
233
  );
239
234
  const seedState = this.findSeedStateToReload(cp);
240
- this.metrics?.cpStateCache.stateReloadEpochDiff.observe(Math.abs(seedState.epochCtx.epoch - cp.epoch));
235
+ this.metrics?.cpStateCache.stateReloadEpochDiff.observe(Math.abs(seedState.epoch - cp.epoch));
241
236
  this.logger.debug("Reload: found seed state", {...logMeta, seedSlot: seedState.slot});
242
237
 
243
238
  try {
@@ -249,19 +244,16 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
249
244
  if (validatorsBytes == null) {
250
245
  // fallback logic in case we can't use the buffer pool
251
246
  this.metrics?.cpStateCache.stateReloadValidatorsSerializeAllocCount.inc();
252
- validatorsBytes = seedState.validators.serialize();
247
+ validatorsBytes = seedState.serializeValidators();
253
248
  }
254
249
  sszTimer?.();
255
250
  const timer = this.metrics?.cpStateCache.stateReloadDuration.startTimer();
256
- const newCachedState = loadCachedBeaconState(seedState, stateBytes, {}, validatorsBytes);
251
+ const newCachedState = seedState.loadOtherState(stateBytes, validatorsBytes);
257
252
  // hashTreeRoot() calls the commit() inside
258
253
  // there is no modification inside the state, it's just that we want to compute and cache all roots
259
254
  const stateRoot = toRootHex(newCachedState.hashTreeRoot());
260
255
  timer?.();
261
256
 
262
- // load all cache in order for consumers (usually regen.getState()) to process blocks faster
263
- newCachedState.validators.getAllReadonlyValues();
264
- newCachedState.balances.getAll();
265
257
  this.logger.debug("Reload: cached state load successful", {
266
258
  ...logMeta,
267
259
  stateSlot: newCachedState.slot,
@@ -284,9 +276,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
284
276
  /**
285
277
  * Return either state or state bytes loaded from db.
286
278
  */
287
- async getStateOrBytes(cp: CheckpointHexPayload): Promise<CachedBeaconStateAllForks | Uint8Array | null> {
279
+ async getStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null> {
288
280
  const stateOrLoadedState = await this.getStateOrLoadDb(cp);
289
- if (stateOrLoadedState === null || isCachedBeaconState(stateOrLoadedState)) {
281
+ if (stateOrLoadedState === null || isBeaconStateView(stateOrLoadedState)) {
290
282
  return stateOrLoadedState;
291
283
  }
292
284
  return stateOrLoadedState.stateBytes;
@@ -295,7 +287,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
295
287
  /**
296
288
  * Return either state or state bytes with persisted key loaded from db.
297
289
  */
298
- async getStateOrLoadDb(cp: CheckpointHexPayload): Promise<CachedBeaconStateAllForks | LoadedStateBytesData | null> {
290
+ async getStateOrLoadDb(cp: CheckpointHexPayload): Promise<IBeaconStateView | LoadedStateBytesData | null> {
299
291
  const cpKey = toCacheKey(cp);
300
292
  const inMemoryState = this.get(cpKey);
301
293
  if (inMemoryState) {
@@ -326,7 +318,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
326
318
  /**
327
319
  * Similar to get() api without reloading from disk
328
320
  */
329
- get(cpOrKey: CheckpointHexPayload | CacheKey): CachedBeaconStateAllForks | null {
321
+ get(cpOrKey: CheckpointHexPayload | CacheKey): IBeaconStateView | null {
330
322
  this.metrics?.cpStateCache.lookups.inc();
331
323
  const cpKey = typeof cpOrKey === "string" ? cpOrKey : toCacheKey(cpOrKey);
332
324
  const cacheItem = this.cache.get(cpKey);
@@ -355,7 +347,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
355
347
  * @param payloadPresent - For Gloas: true if this is payload state, false if block state.
356
348
  * Always true for pre-Gloas.
357
349
  */
358
- add(cp: phase0.Checkpoint, state: CachedBeaconStateAllForks, payloadPresent: boolean): void {
350
+ add(cp: phase0.Checkpoint, state: IBeaconStateView, payloadPresent: boolean): void {
359
351
  const cpHex = toCheckpointHexPayload(cp, payloadPresent);
360
352
  const key = toCacheKey(cpHex);
361
353
  const cacheItem = this.cache.get(key);
@@ -385,7 +377,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
385
377
  /**
386
378
  * Searches in-memory state for the latest cached state with a `root` without reload, starting with `epoch` and descending
387
379
  */
388
- getLatest(rootHex: RootHex, maxEpoch: Epoch, payloadPresent: boolean): CachedBeaconStateAllForks | null {
380
+ getLatest(rootHex: RootHex, maxEpoch: Epoch, payloadPresent: boolean): IBeaconStateView | null {
389
381
  // sort epochs in descending order, only consider epochs lte `epoch`
390
382
  const epochs = Array.from(this.epochIndex.keys())
391
383
  .sort((a, b) => b - a)
@@ -412,7 +404,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
412
404
  rootHex: RootHex,
413
405
  maxEpoch: Epoch,
414
406
  payloadPresent: boolean
415
- ): Promise<CachedBeaconStateAllForks | null> {
407
+ ): Promise<IBeaconStateView | null> {
416
408
  // sort epochs in descending order, only consider epochs lte `epoch`
417
409
  const epochs = Array.from(this.epochIndex.keys())
418
410
  .sort((a, b) => b - a)
@@ -518,7 +510,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
518
510
  * For Gloas: Processes both block state and payload state variants together. The decision of which roots to persist/prune
519
511
  * is based on root canonicality (from state's view), not payload presence. Both variants are managed as a unit.
520
512
  */
521
- async processState(blockRootHex: RootHex, state: CachedBeaconStateAllForks): Promise<number> {
513
+ async processState(blockRootHex: RootHex, state: IBeaconStateView): Promise<number> {
522
514
  let persistCount = 0;
523
515
  // it's important to sort the epochs in ascending order, in case of big reorg we always want to keep the most recent checkpoint states
524
516
  const sortedEpochs = Array.from(this.epochIndex.keys()).sort((a, b) => a - b);
@@ -587,10 +579,10 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
587
579
  *
588
580
  * Use seed state from the block cache if cannot find any seed states within this cache.
589
581
  */
590
- findSeedStateToReload(reloadedCp: CheckpointHexPayload): CachedBeaconStateAllForks {
582
+ findSeedStateToReload(reloadedCp: CheckpointHexPayload): IBeaconStateView {
591
583
  const maxEpoch = Math.max(...Array.from(this.epochIndex.keys()));
592
584
  const reloadedCpSlot = computeStartSlotAtEpoch(reloadedCp.epoch);
593
- let firstState: CachedBeaconStateAllForks | null = null;
585
+ let firstState: IBeaconStateView | null = null;
594
586
  const logCtx = {reloadedCpEpoch: reloadedCp.epoch, reloadedCpRoot: reloadedCp.rootHex};
595
587
 
596
588
  // no need to check epochs before `maxEpoch - this.maxEpochsInMemory + 1` before they are all persisted
@@ -620,7 +612,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
620
612
  // amongst states of the same epoch, choose the one with the same view of reloadedCp
621
613
  if (
622
614
  reloadedCpSlot < state.slot &&
623
- toRootHex(getBlockRootAtSlot(state, reloadedCpSlot)) === reloadedCp.rootHex
615
+ toRootHex(state.getBlockRootAtSlot(reloadedCpSlot)) === reloadedCp.rootHex
624
616
  ) {
625
617
  this.logger.verbose("Reload: use checkpoint state as seed state", {...cpLog, ...logCtx});
626
618
  return state;
@@ -685,7 +677,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
685
677
  });
686
678
  }
687
679
 
688
- getStates(): IterableIterator<CachedBeaconStateAllForks> {
680
+ getStates(): IterableIterator<IBeaconStateView> {
689
681
  const items = Array.from(this.cache.values())
690
682
  .filter(isInMemoryCacheItem)
691
683
  .map((item) => item.state);
@@ -735,17 +727,13 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
735
727
  * - In normal condition, we persist 1 checkpoint state per epoch.
736
728
  * - In reorged condition, we may persist multiple (most likely 2) checkpoint states per epoch.
737
729
  */
738
- private async processPastEpoch(
739
- blockRootHex: RootHex,
740
- state: CachedBeaconStateAllForks,
741
- epoch: Epoch
742
- ): Promise<number> {
730
+ private async processPastEpoch(blockRootHex: RootHex, state: IBeaconStateView, epoch: Epoch): Promise<number> {
743
731
  let persistCount = 0;
744
732
  const epochBoundarySlot = computeStartSlotAtEpoch(epoch);
745
733
  const epochBoundaryRoot =
746
- epochBoundarySlot === state.slot ? fromHex(blockRootHex) : getBlockRootAtSlot(state, epochBoundarySlot);
734
+ epochBoundarySlot === state.slot ? fromHex(blockRootHex) : state.getBlockRootAtSlot(epochBoundarySlot);
747
735
  const epochBoundaryHex = toRootHex(epochBoundaryRoot);
748
- const prevEpochRoot = toRootHex(getBlockRootAtSlot(state, epochBoundarySlot - 1));
736
+ const prevEpochRoot = toRootHex(state.getBlockRootAtSlot(epochBoundarySlot - 1));
749
737
 
750
738
  // for each epoch, usually there are 2 rootHexes respective to the 2 checkpoint states: Previous Root Checkpoint State and Current Root Checkpoint State
751
739
  const cpRootHexMap = this.epochIndex.get(epoch) ?? new Map<RootHex, number>();
@@ -912,15 +900,14 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
912
900
  * - Also `serializeState.test.ts` perf test shows a lot of differences allocating validators bytes once vs every time,
913
901
  * This is 2x - 3x faster than allocating memory every time.
914
902
  */
915
- private serializeStateValidators(state: CachedBeaconStateAllForks): BufferWithKey | null {
916
- const type = state.type.fields.validators;
917
- const size = type.tree_serializedSize(state.validators.node);
903
+ private serializeStateValidators(state: IBeaconStateView): BufferWithKey | null {
904
+ const size = state.serializedValidatorsSize();
918
905
  if (this.bufferPool) {
919
906
  const bufferWithKey = this.bufferPool.alloc(size, AllocSource.PERSISTENT_CHECKPOINTS_CACHE_VALIDATORS);
920
907
  if (bufferWithKey) {
921
908
  const validatorsBytes = bufferWithKey.buffer;
922
909
  const dataView = new DataView(validatorsBytes.buffer, validatorsBytes.byteOffset, validatorsBytes.byteLength);
923
- state.validators.serializeToBytes({uint8Array: validatorsBytes, dataView}, 0);
910
+ state.serializeValidatorsToBytes({uint8Array: validatorsBytes, dataView}, 0);
924
911
  return bufferWithKey;
925
912
  }
926
913
  }
@@ -983,10 +970,8 @@ function fromCacheKey(key: CacheKey): CheckpointHexPayload {
983
970
  };
984
971
  }
985
972
 
986
- function isCachedBeaconState(
987
- stateOrBytes: CachedBeaconStateAllForks | LoadedStateBytesData
988
- ): stateOrBytes is CachedBeaconStateAllForks {
989
- return (stateOrBytes as CachedBeaconStateAllForks).slot !== undefined;
973
+ function isBeaconStateView(stateOrBytes: IBeaconStateView | LoadedStateBytesData): stateOrBytes is IBeaconStateView {
974
+ return (stateOrBytes as IBeaconStateView).slot !== undefined;
990
975
  }
991
976
 
992
977
  function isInMemoryCacheItem(cacheItem: CacheItem): cacheItem is InMemoryCacheItem {