@lodestar/beacon-node 1.41.0 → 1.42.0-dev.2fd27cd2f6

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 (455) 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 +6 -6
  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 +32 -28
  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 +0 -1
  27. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  28. package/lib/chain/archiveStore/archiveStore.js +0 -9
  29. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  30. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +2 -6
  31. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  32. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +3 -23
  33. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  34. package/lib/chain/archiveStore/historicalState/worker.js +1 -0
  35. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  36. package/lib/chain/archiveStore/interface.d.ts +4 -4
  37. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  38. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  39. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  40. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +4 -1
  41. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  42. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  43. package/lib/chain/archiveStore/utils/archiveBlocks.js +38 -0
  44. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  45. package/lib/chain/balancesCache.d.ts +2 -2
  46. package/lib/chain/balancesCache.d.ts.map +1 -1
  47. package/lib/chain/balancesCache.js +4 -4
  48. package/lib/chain/balancesCache.js.map +1 -1
  49. package/lib/chain/blocks/blockInput/types.d.ts +4 -3
  50. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  51. package/lib/chain/blocks/blockInput/types.js +1 -0
  52. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  53. package/lib/chain/blocks/importBlock.d.ts +3 -3
  54. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  55. package/lib/chain/blocks/importBlock.js +38 -18
  56. package/lib/chain/blocks/importBlock.js.map +1 -1
  57. package/lib/chain/blocks/importExecutionPayload.d.ts +48 -0
  58. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -0
  59. package/lib/chain/blocks/importExecutionPayload.js +158 -0
  60. package/lib/chain/blocks/importExecutionPayload.js.map +1 -0
  61. package/lib/chain/blocks/index.js +1 -1
  62. package/lib/chain/blocks/index.js.map +1 -1
  63. package/lib/chain/blocks/payloadEnvelopeInput/index.d.ts +3 -0
  64. package/lib/chain/blocks/payloadEnvelopeInput/index.d.ts.map +1 -0
  65. package/lib/chain/blocks/payloadEnvelopeInput/index.js +3 -0
  66. package/lib/chain/blocks/payloadEnvelopeInput/index.js.map +1 -0
  67. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +80 -0
  68. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -0
  69. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +248 -0
  70. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -0
  71. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +29 -0
  72. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -0
  73. package/lib/chain/blocks/payloadEnvelopeInput/types.js +11 -0
  74. package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -0
  75. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +15 -0
  76. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -0
  77. package/lib/chain/blocks/payloadEnvelopeProcessor.js +46 -0
  78. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -0
  79. package/lib/chain/blocks/types.d.ts +9 -2
  80. package/lib/chain/blocks/types.d.ts.map +1 -1
  81. package/lib/chain/blocks/types.js.map +1 -1
  82. package/lib/chain/blocks/utils/checkpoint.d.ts +2 -2
  83. package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -1
  84. package/lib/chain/blocks/utils/checkpoint.js.map +1 -1
  85. package/lib/chain/blocks/verifyBlock.d.ts +2 -2
  86. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  87. package/lib/chain/blocks/verifyBlock.js +4 -4
  88. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  89. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +3 -3
  90. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  91. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -3
  92. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  93. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  94. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  95. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
  96. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  97. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -3
  98. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  99. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +3 -3
  100. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  101. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +12 -0
  102. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -0
  103. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +40 -0
  104. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -0
  105. package/lib/chain/chain.d.ts +22 -17
  106. package/lib/chain/chain.d.ts.map +1 -1
  107. package/lib/chain/chain.js +90 -48
  108. package/lib/chain/chain.js.map +1 -1
  109. package/lib/chain/emitter.d.ts +2 -2
  110. package/lib/chain/emitter.d.ts.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/executionPayloadEnvelope.d.ts +12 -2
  114. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  115. package/lib/chain/errors/executionPayloadEnvelope.js +3 -1
  116. package/lib/chain/errors/executionPayloadEnvelope.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 -33
  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 +19 -17
  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 +2 -2
  142. package/lib/chain/opPools/utils.js.map +1 -1
  143. package/lib/chain/prepareNextSlot.d.ts +2 -2
  144. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  145. package/lib/chain/prepareNextSlot.js +9 -5
  146. package/lib/chain/prepareNextSlot.js.map +1 -1
  147. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +4 -4
  148. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  149. package/lib/chain/produceBlock/computeNewStateRoot.js +8 -4
  150. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  151. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  152. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  153. package/lib/chain/produceBlock/produceBlockBody.js +13 -17
  154. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  155. package/lib/chain/regen/errors.d.ts +11 -1
  156. package/lib/chain/regen/errors.d.ts.map +1 -1
  157. package/lib/chain/regen/errors.js +2 -0
  158. package/lib/chain/regen/errors.js.map +1 -1
  159. package/lib/chain/regen/interface.d.ts +22 -14
  160. package/lib/chain/regen/interface.d.ts.map +1 -1
  161. package/lib/chain/regen/interface.js +2 -0
  162. package/lib/chain/regen/interface.js.map +1 -1
  163. package/lib/chain/regen/queued.d.ts +20 -15
  164. package/lib/chain/regen/queued.d.ts.map +1 -1
  165. package/lib/chain/regen/queued.js +40 -8
  166. package/lib/chain/regen/queued.js.map +1 -1
  167. package/lib/chain/regen/regen.d.ts +11 -5
  168. package/lib/chain/regen/regen.d.ts.map +1 -1
  169. package/lib/chain/regen/regen.js +38 -11
  170. package/lib/chain/regen/regen.js.map +1 -1
  171. package/lib/chain/seenCache/index.d.ts +1 -1
  172. package/lib/chain/seenCache/index.d.ts.map +1 -1
  173. package/lib/chain/seenCache/index.js +1 -1
  174. package/lib/chain/seenCache/index.js.map +1 -1
  175. package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
  176. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  177. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +38 -0
  178. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -0
  179. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +76 -0
  180. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -0
  181. package/lib/chain/serializeState.d.ts +2 -2
  182. package/lib/chain/serializeState.d.ts.map +1 -1
  183. package/lib/chain/serializeState.js +1 -1
  184. package/lib/chain/serializeState.js.map +1 -1
  185. package/lib/chain/shufflingCache.d.ts +2 -2
  186. package/lib/chain/shufflingCache.d.ts.map +1 -1
  187. package/lib/chain/shufflingCache.js +3 -4
  188. package/lib/chain/shufflingCache.js.map +1 -1
  189. package/lib/chain/stateCache/datastore/db.d.ts +4 -5
  190. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  191. package/lib/chain/stateCache/datastore/db.js +32 -10
  192. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  193. package/lib/chain/stateCache/datastore/file.d.ts +1 -1
  194. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  195. package/lib/chain/stateCache/datastore/file.js +5 -5
  196. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  197. package/lib/chain/stateCache/datastore/types.d.ts +1 -1
  198. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  199. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +13 -10
  200. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  201. package/lib/chain/stateCache/fifoBlockStateCache.js +8 -3
  202. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  203. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +36 -17
  204. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  205. package/lib/chain/stateCache/persistentCheckpointsCache.js +228 -134
  206. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  207. package/lib/chain/stateCache/types.d.ts +23 -16
  208. package/lib/chain/stateCache/types.d.ts.map +1 -1
  209. package/lib/chain/stateCache/types.js.map +1 -1
  210. package/lib/chain/validation/attesterSlashing.js +3 -3
  211. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  212. package/lib/chain/validation/blobSidecar.js +1 -1
  213. package/lib/chain/validation/blobSidecar.js.map +1 -1
  214. package/lib/chain/validation/block.d.ts.map +1 -1
  215. package/lib/chain/validation/block.js +3 -3
  216. package/lib/chain/validation/block.js.map +1 -1
  217. package/lib/chain/validation/blsToExecutionChange.js +2 -2
  218. package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
  219. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  220. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  221. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  222. package/lib/chain/validation/executionPayloadBid.js +4 -4
  223. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  224. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  225. package/lib/chain/validation/executionPayloadEnvelope.js +29 -19
  226. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  227. package/lib/chain/validation/lightClientFinalityUpdate.js +1 -1
  228. package/lib/chain/validation/lightClientFinalityUpdate.js.map +1 -1
  229. package/lib/chain/validation/lightClientOptimisticUpdate.js +1 -1
  230. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  231. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  232. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  233. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  234. package/lib/chain/validation/proposerSlashing.js +1 -1
  235. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  236. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  237. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  238. package/lib/chain/validation/signatureSets/contributionAndProof.js +1 -1
  239. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  240. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  241. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  242. package/lib/chain/validation/signatureSets/syncCommittee.js +1 -1
  243. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  244. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  245. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  246. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  247. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  248. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  249. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -1
  250. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  251. package/lib/chain/validation/syncCommittee.d.ts +4 -4
  252. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  253. package/lib/chain/validation/syncCommittee.js +13 -12
  254. package/lib/chain/validation/syncCommittee.js.map +1 -1
  255. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  256. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  257. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  258. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  259. package/lib/chain/validation/voluntaryExit.js +3 -3
  260. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  261. package/lib/chain/validatorMonitor.d.ts +5 -4
  262. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  263. package/lib/chain/validatorMonitor.js +13 -8
  264. package/lib/chain/validatorMonitor.js.map +1 -1
  265. package/lib/execution/engine/interface.d.ts +2 -2
  266. package/lib/metrics/metrics/lodestar.d.ts +40 -4
  267. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  268. package/lib/metrics/metrics/lodestar.js +93 -15
  269. package/lib/metrics/metrics/lodestar.js.map +1 -1
  270. package/lib/network/gossip/encoding.d.ts.map +1 -1
  271. package/lib/network/gossip/encoding.js +15 -0
  272. package/lib/network/gossip/encoding.js.map +1 -1
  273. package/lib/network/interface.d.ts +4 -2
  274. package/lib/network/interface.d.ts.map +1 -1
  275. package/lib/network/network.d.ts +4 -2
  276. package/lib/network/network.d.ts.map +1 -1
  277. package/lib/network/network.js +11 -5
  278. package/lib/network/network.js.map +1 -1
  279. package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
  280. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
  281. package/lib/network/processor/extractSlotRootFns.js +15 -5
  282. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  283. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  284. package/lib/network/processor/gossipHandlers.js +39 -9
  285. package/lib/network/processor/gossipHandlers.js.map +1 -1
  286. package/lib/network/processor/index.d.ts +12 -7
  287. package/lib/network/processor/index.d.ts.map +1 -1
  288. package/lib/network/processor/index.js +99 -78
  289. package/lib/network/processor/index.js.map +1 -1
  290. package/lib/network/reqresp/ReqRespBeaconNode.d.ts +1 -1
  291. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  292. package/lib/network/reqresp/ReqRespBeaconNode.js +10 -1
  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 +8 -2
  316. package/lib/network/reqresp/types.d.ts.map +1 -1
  317. package/lib/network/reqresp/types.js +7 -1
  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 +3 -3
  327. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  328. package/lib/sync/backfill/backfill.js +3 -3
  329. package/lib/sync/backfill/backfill.js.map +1 -1
  330. package/lib/sync/constants.d.ts +1 -1
  331. package/lib/sync/constants.js +1 -1
  332. package/lib/sync/unknownBlock.d.ts +3 -9
  333. package/lib/sync/unknownBlock.d.ts.map +1 -1
  334. package/lib/sync/unknownBlock.js +8 -41
  335. package/lib/sync/unknownBlock.js.map +1 -1
  336. package/lib/util/sszBytes.d.ts +4 -1
  337. package/lib/util/sszBytes.d.ts.map +1 -1
  338. package/lib/util/sszBytes.js +69 -12
  339. package/lib/util/sszBytes.js.map +1 -1
  340. package/lib/util/types.d.ts +2 -0
  341. package/lib/util/types.d.ts.map +1 -1
  342. package/lib/util/types.js +1 -0
  343. package/lib/util/types.js.map +1 -1
  344. package/package.json +15 -15
  345. package/src/api/impl/beacon/blocks/index.ts +37 -18
  346. package/src/api/impl/beacon/pool/index.ts +1 -1
  347. package/src/api/impl/beacon/state/index.ts +29 -41
  348. package/src/api/impl/beacon/state/utils.ts +13 -27
  349. package/src/api/impl/lodestar/index.ts +4 -8
  350. package/src/api/impl/proof/index.ts +2 -9
  351. package/src/api/impl/validator/index.ts +35 -43
  352. package/src/api/impl/validator/utils.ts +4 -7
  353. package/src/chain/archiveStore/archiveStore.ts +0 -10
  354. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +6 -36
  355. package/src/chain/archiveStore/historicalState/worker.ts +1 -0
  356. package/src/chain/archiveStore/interface.ts +4 -4
  357. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +8 -5
  358. package/src/chain/archiveStore/utils/archiveBlocks.ts +59 -1
  359. package/src/chain/balancesCache.ts +5 -11
  360. package/src/chain/blocks/blockInput/types.ts +4 -3
  361. package/src/chain/blocks/importBlock.ts +58 -22
  362. package/src/chain/blocks/importExecutionPayload.ts +236 -0
  363. package/src/chain/blocks/index.ts +1 -1
  364. package/src/chain/blocks/payloadEnvelopeInput/index.ts +2 -0
  365. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +336 -0
  366. package/src/chain/blocks/payloadEnvelopeInput/types.ts +33 -0
  367. package/src/chain/blocks/payloadEnvelopeProcessor.ts +61 -0
  368. package/src/chain/blocks/types.ts +10 -2
  369. package/src/chain/blocks/utils/checkpoint.ts +2 -2
  370. package/src/chain/blocks/verifyBlock.ts +5 -10
  371. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +5 -10
  372. package/src/chain/blocks/verifyBlocksSignatures.ts +4 -4
  373. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -8
  374. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +55 -0
  375. package/src/chain/chain.ts +134 -81
  376. package/src/chain/emitter.ts +2 -2
  377. package/src/chain/errors/blockError.ts +4 -4
  378. package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
  379. package/src/chain/forkChoice/index.ts +33 -52
  380. package/src/chain/initState.ts +7 -2
  381. package/src/chain/interface.ts +20 -18
  382. package/src/chain/lightClient/index.ts +9 -22
  383. package/src/chain/opPools/aggregatedAttestationPool.ts +15 -21
  384. package/src/chain/opPools/opPool.ts +13 -14
  385. package/src/chain/opPools/utils.ts +4 -4
  386. package/src/chain/prepareNextSlot.ts +12 -10
  387. package/src/chain/produceBlock/computeNewStateRoot.ts +11 -10
  388. package/src/chain/produceBlock/produceBlockBody.ts +23 -50
  389. package/src/chain/regen/errors.ts +6 -1
  390. package/src/chain/regen/interface.ts +22 -18
  391. package/src/chain/regen/queued.ts +59 -27
  392. package/src/chain/regen/regen.ts +52 -23
  393. package/src/chain/seenCache/index.ts +1 -1
  394. package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
  395. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +106 -0
  396. package/src/chain/serializeState.ts +3 -3
  397. package/src/chain/shufflingCache.ts +5 -7
  398. package/src/chain/stateCache/datastore/db.ts +33 -10
  399. package/src/chain/stateCache/datastore/file.ts +6 -5
  400. package/src/chain/stateCache/datastore/types.ts +3 -2
  401. package/src/chain/stateCache/fifoBlockStateCache.ts +17 -11
  402. package/src/chain/stateCache/persistentCheckpointsCache.ts +266 -172
  403. package/src/chain/stateCache/types.ts +22 -16
  404. package/src/chain/validation/attesterSlashing.ts +3 -3
  405. package/src/chain/validation/blobSidecar.ts +1 -1
  406. package/src/chain/validation/block.ts +2 -4
  407. package/src/chain/validation/blsToExecutionChange.ts +2 -2
  408. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  409. package/src/chain/validation/executionPayloadBid.ts +3 -7
  410. package/src/chain/validation/executionPayloadEnvelope.ts +36 -29
  411. package/src/chain/validation/lightClientFinalityUpdate.ts +1 -1
  412. package/src/chain/validation/lightClientOptimisticUpdate.ts +1 -1
  413. package/src/chain/validation/payloadAttestationMessage.ts +2 -4
  414. package/src/chain/validation/proposerSlashing.ts +1 -1
  415. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -7
  416. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -7
  417. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -2
  418. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -7
  419. package/src/chain/validation/syncCommittee.ts +21 -20
  420. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -10
  421. package/src/chain/validation/voluntaryExit.ts +3 -7
  422. package/src/chain/validatorMonitor.ts +23 -12
  423. package/src/execution/engine/interface.ts +2 -2
  424. package/src/metrics/metrics/lodestar.ts +100 -19
  425. package/src/network/gossip/encoding.ts +16 -0
  426. package/src/network/interface.ts +15 -2
  427. package/src/network/network.ts +34 -6
  428. package/src/network/processor/extractSlotRootFns.ts +19 -6
  429. package/src/network/processor/gossipHandlers.ts +45 -8
  430. package/src/network/processor/index.ts +110 -89
  431. package/src/network/reqresp/ReqRespBeaconNode.ts +14 -1
  432. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +94 -0
  433. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +43 -0
  434. package/src/network/reqresp/handlers/index.ts +12 -0
  435. package/src/network/reqresp/protocols.ts +12 -0
  436. package/src/network/reqresp/rateLimit.ts +18 -0
  437. package/src/network/reqresp/score.ts +2 -0
  438. package/src/network/reqresp/types.ts +13 -0
  439. package/src/node/nodejs.ts +3 -5
  440. package/src/node/notifier.ts +4 -10
  441. package/src/sync/backfill/backfill.ts +4 -4
  442. package/src/sync/constants.ts +1 -1
  443. package/src/sync/unknownBlock.ts +10 -50
  444. package/src/util/sszBytes.ts +90 -10
  445. package/src/util/types.ts +6 -0
  446. package/lib/chain/archiveStore/utils/archivePayloads.d.ts +0 -7
  447. package/lib/chain/archiveStore/utils/archivePayloads.d.ts.map +0 -1
  448. package/lib/chain/archiveStore/utils/archivePayloads.js +0 -10
  449. package/lib/chain/archiveStore/utils/archivePayloads.js.map +0 -1
  450. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +0 -15
  451. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +0 -1
  452. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +0 -28
  453. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +0 -1
  454. package/src/chain/archiveStore/utils/archivePayloads.ts +0 -15
  455. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +0 -34
@@ -1,11 +1,11 @@
1
1
  import {routes} from "@lodestar/api";
2
- import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
- import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition";
2
+ import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
3
+ import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
4
4
  import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
5
- import {Logger, toRootHex} from "@lodestar/utils";
5
+ import {Logger, fromHex, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
7
7
  import {JobItemQueue} from "../../util/queue/index.js";
8
- import {BlockStateCache, CheckpointHex, CheckpointStateCache} from "../stateCache/types.js";
8
+ import {BlockStateCache, CheckpointHexPayload, CheckpointStateCache} from "../stateCache/types.js";
9
9
  import {RegenError, RegenErrorCode} from "./errors.js";
10
10
  import {
11
11
  IStateRegenerator,
@@ -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(
@@ -104,9 +104,19 @@ export class QueuedStateRegenerator implements IStateRegenerator {
104
104
  const parentEpoch = computeEpochAtSlot(parentBlock.slot);
105
105
  const blockEpoch = computeEpochAtSlot(block.slot);
106
106
 
107
+ // Convert PayloadStatus to payloadPresent boolean
108
+ if (parentBlock.payloadStatus === PayloadStatus.PENDING) {
109
+ throw new RegenError({
110
+ code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
111
+ blockRoot: block.parentRoot,
112
+ payloadStatus: parentBlock.payloadStatus,
113
+ });
114
+ }
115
+ const payloadPresent = parentBlock.payloadStatus === PayloadStatus.FULL;
116
+
107
117
  // Check the checkpoint cache (if the pre-state is a checkpoint state)
108
118
  if (parentEpoch < blockEpoch) {
109
- const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch);
119
+ const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch, payloadPresent);
110
120
  if (checkpointState && computeEpochAtSlot(checkpointState.slot) === blockEpoch) {
111
121
  return checkpointState;
112
122
  }
@@ -125,22 +135,34 @@ export class QueuedStateRegenerator implements IStateRegenerator {
125
135
  return null;
126
136
  }
127
137
 
128
- async getCheckpointStateOrBytes(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | Uint8Array | null> {
138
+ async getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null> {
129
139
  return this.checkpointStateCache.getStateOrBytes(cp);
130
140
  }
131
141
 
132
142
  /**
133
143
  * Get checkpoint state from cache
134
144
  */
135
- getCheckpointStateSync(cp: CheckpointHex): CachedBeaconStateAllForks | null {
145
+ getCheckpointStateSync(cp: CheckpointHexPayload): IBeaconStateView | null {
136
146
  return this.checkpointStateCache.get(cp);
137
147
  }
138
148
 
139
149
  /**
140
150
  * Get state closest to head
141
151
  */
142
- getClosestHeadState(head: ProtoBlock): CachedBeaconStateAllForks | null {
143
- return this.checkpointStateCache.getLatest(head.blockRoot, Infinity) || this.blockStateCache.get(head.stateRoot);
152
+ getClosestHeadState(head: ProtoBlock): IBeaconStateView | null {
153
+ // Convert PayloadStatus to payloadPresent boolean
154
+ if (head.payloadStatus === PayloadStatus.PENDING) {
155
+ throw new RegenError({
156
+ code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
157
+ blockRoot: fromHex(head.blockRoot),
158
+ payloadStatus: head.payloadStatus,
159
+ });
160
+ }
161
+ const payloadPresent = head.payloadStatus === PayloadStatus.FULL;
162
+ return (
163
+ this.checkpointStateCache.getLatest(head.blockRoot, Infinity, payloadPresent) ||
164
+ this.blockStateCache.get(head.stateRoot)
165
+ );
144
166
  }
145
167
 
146
168
  pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void {
@@ -153,18 +175,27 @@ export class QueuedStateRegenerator implements IStateRegenerator {
153
175
  this.blockStateCache.deleteAllBeforeEpoch(finalizedEpoch);
154
176
  }
155
177
 
156
- processState(blockRootHex: RootHex, postState: CachedBeaconStateAllForks): void {
178
+ processBlockState(blockRootHex: RootHex, postState: IBeaconStateView): void {
157
179
  this.blockStateCache.add(postState);
158
180
  this.checkpointStateCache.processState(blockRootHex, postState).catch((e) => {
159
181
  this.logger.debug("Error processing block state", {blockRootHex, slot: postState.slot}, e);
160
182
  });
161
183
  }
162
184
 
163
- addCheckpointState(cp: phase0.Checkpoint, item: CachedBeaconStateAllForks): void {
164
- this.checkpointStateCache.add(cp, item);
185
+ /**
186
+ * Process payload state for caching after importing execution payload.
187
+ */
188
+ processPayloadState(payloadState: IBeaconStateView): void {
189
+ // Add payload state to block state cache (keyed by payload state root)
190
+ this.blockStateCache.add(payloadState);
191
+ }
192
+
193
+ // TODO GLOAS: This should also be called when importing execution payload after we implement it
194
+ addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void {
195
+ this.checkpointStateCache.add(cp, item, payloadPresent);
165
196
  }
166
197
 
167
- updateHeadState(newHead: ProtoBlock, maybeHeadState: CachedBeaconStateAllForks): void {
198
+ updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void {
168
199
  const {stateRoot: newHeadStateRoot, blockRoot: newHeadBlockRoot, slot: newHeadSlot} = newHead;
169
200
  const maybeHeadStateRoot = toRootHex(maybeHeadState.hashTreeRoot());
170
201
  const logCtx = {
@@ -197,19 +228,20 @@ export class QueuedStateRegenerator implements IStateRegenerator {
197
228
  }
198
229
  }
199
230
 
200
- updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null {
201
- return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch);
231
+ updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch, payloadPresent: boolean): number | null {
232
+ return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch, payloadPresent);
233
+ }
234
+
235
+ upgradeForGloas(epoch: Epoch): void {
236
+ this.logger.verbose("Upgrading block state cache for Gloas fork", {epoch});
237
+ this.blockStateCache.upgradeToGloas();
202
238
  }
203
239
 
204
240
  /**
205
241
  * Get the state to run with `block`.
206
242
  * - State after `block.parentRoot` dialed forward to block.slot
207
243
  */
208
- async getPreState(
209
- block: BeaconBlock,
210
- opts: StateRegenerationOpts,
211
- rCaller: RegenCaller
212
- ): Promise<CachedBeaconStateAllForks> {
244
+ async getPreState(block: BeaconBlock, opts: StateRegenerationOpts, rCaller: RegenCaller): Promise<IBeaconStateView> {
213
245
  this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getPreState});
214
246
 
215
247
  // First attempt to fetch the state from caches before queueing
@@ -235,14 +267,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
235
267
  slot: Slot,
236
268
  opts: StateRegenerationOpts,
237
269
  rCaller: RegenCaller
238
- ): Promise<CachedBeaconStateAllForks> {
270
+ ): Promise<IBeaconStateView> {
239
271
  this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getBlockSlotState});
240
272
 
241
273
  // The state is not immediately available in the caches, enqueue the job
242
274
  return this.jobQueue.push({key: "getBlockSlotState", args: [block, slot, opts, rCaller]});
243
275
  }
244
276
 
245
- async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<CachedBeaconStateAllForks> {
277
+ async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<IBeaconStateView> {
246
278
  this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getState});
247
279
 
248
280
  // First attempt to fetch the state from cache before queueing
@@ -256,7 +288,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
256
288
  return this.jobQueue.push({key: "getState", args: [stateRoot, rCaller]});
257
289
  }
258
290
 
259
- private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<CachedBeaconStateAllForks> => {
291
+ private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<IBeaconStateView> => {
260
292
  const metricsLabels = {
261
293
  caller: regenRequest.args.at(-1) as RegenCaller,
262
294
  entrypoint: regenRequest.key as RegenFnName,
@@ -1,15 +1,13 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
- import {SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
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,
@@ -111,9 +109,20 @@ export class StateRegenerator implements IStateRegeneratorInternal {
111
109
  const {blockRoot} = block;
112
110
  const {checkpointStateCache} = this.modules;
113
111
  const epoch = computeEpochAtSlot(slot);
112
+
113
+ // Convert PayloadStatus to payloadPresent boolean
114
+ if (block.payloadStatus === PayloadStatus.PENDING) {
115
+ throw new RegenError({
116
+ code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
117
+ blockRoot: fromHex(blockRoot),
118
+ payloadStatus: block.payloadStatus,
119
+ });
120
+ }
121
+ const payloadPresent = block.payloadStatus === PayloadStatus.FULL;
122
+
114
123
  const latestCheckpointStateCtx = allowDiskReload
115
- ? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch)
116
- : checkpointStateCache.getLatest(blockRoot, epoch);
124
+ ? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch, payloadPresent)
125
+ : checkpointStateCache.getLatest(blockRoot, epoch, payloadPresent);
117
126
 
118
127
  // If a checkpoint state exists with the given checkpoint root, it either is in requested epoch
119
128
  // or needs to have empty slots processed until the requested epoch
@@ -138,7 +147,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
138
147
  caller: RegenCaller,
139
148
  // internal option, don't want to expose to external caller
140
149
  allowDiskReload = false
141
- ): Promise<CachedBeaconStateAllForks> {
150
+ ): Promise<IBeaconStateView> {
142
151
  // Trivial case, state at stateRoot is already cached
143
152
  const cachedStateCtx = this.modules.blockStateCache.get(stateRoot);
144
153
  if (cachedStateCtx) {
@@ -153,7 +162,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
153
162
  // blocks to replay, ordered highest to lowest
154
163
  // gets reversed when replayed
155
164
  const blocksToReplay = [block];
156
- let state: CachedBeaconStateAllForks | null = null;
165
+ let state: IBeaconStateView | null = null;
157
166
  const {checkpointStateCache} = this.modules;
158
167
 
159
168
  const getSeedStateTimer = this.modules.metrics?.regenGetState.getSeedState.startTimer({caller});
@@ -166,9 +175,19 @@ export class StateRegenerator implements IStateRegeneratorInternal {
166
175
  const lastBlockToReplay = blocksToReplay.at(-1);
167
176
  if (!lastBlockToReplay) continue;
168
177
  const epoch = computeEpochAtSlot(lastBlockToReplay.slot - 1);
178
+
179
+ // Convert PayloadStatus to payloadPresent boolean
180
+ if (b.payloadStatus === PayloadStatus.PENDING) {
181
+ throw new RegenError({
182
+ code: RegenErrorCode.INTERNAL_ERROR,
183
+ message: `Unexpected PENDING payloadStatus for ancestor block ${b.blockRoot} at slot ${b.slot}`,
184
+ });
185
+ }
186
+ const payloadPresent = b.payloadStatus === PayloadStatus.FULL;
187
+
169
188
  state = allowDiskReload
170
- ? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch)
171
- : checkpointStateCache.getLatest(b.blockRoot, epoch);
189
+ ? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch, payloadPresent)
190
+ : checkpointStateCache.getLatest(b.blockRoot, epoch, payloadPresent);
172
191
  if (state) {
173
192
  break;
174
193
  }
@@ -239,8 +258,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
239
258
  // Only advances state trusting block's signture and hashes.
240
259
  // We are only running the state transition to get a specific state's data.
241
260
  // stateTransition() does the clone() inside, transfer cache to make the regen faster
242
- state = stateTransition(
243
- state,
261
+ state = state.stateTransition(
244
262
  block,
245
263
  {
246
264
  // Replay previously imported blocks, assume valid and available
@@ -312,16 +330,17 @@ async function processSlotsByCheckpoint(
312
330
  metrics: Metrics | null;
313
331
  validatorMonitor: ValidatorMonitor | null;
314
332
  emitter: ChainEventEmitter;
333
+ config: ChainForkConfig;
315
334
  logger: Logger;
316
335
  },
317
- preState: CachedBeaconStateAllForks,
336
+ preState: IBeaconStateView,
318
337
  slot: Slot,
319
338
  regenCaller: RegenCaller,
320
339
  opts: StateRegenerationOpts
321
- ): Promise<CachedBeaconStateAllForks> {
340
+ ): Promise<IBeaconStateView> {
322
341
  let postState = await processSlotsToNearestCheckpoint(modules, preState, slot, regenCaller, opts);
323
342
  if (postState.slot < slot) {
324
- postState = processSlots(postState, slot, opts, modules);
343
+ postState = postState.processSlots(slot, opts, modules);
325
344
  }
326
345
  return postState;
327
346
  }
@@ -332,6 +351,11 @@ async function processSlotsByCheckpoint(
332
351
  * emitting "checkpoint" events after every epoch processed.
333
352
  *
334
353
  * Stops processing after no more full epochs can be processed.
354
+ *
355
+ * Output state variant:
356
+ * - Post-Gloas: If slots are processed, returns block state (payloadPresent=false).
357
+ * If no slots processed, returns preState as-is (preserves variant).
358
+ * - Pre-Gloas: Always payloadPresent=true (no block/payload distinction).
335
359
  */
336
360
  export async function processSlotsToNearestCheckpoint(
337
361
  modules: {
@@ -339,18 +363,19 @@ export async function processSlotsToNearestCheckpoint(
339
363
  metrics: Metrics | null;
340
364
  validatorMonitor: ValidatorMonitor | null;
341
365
  emitter: ChainEventEmitter | null;
366
+ config: ChainForkConfig;
342
367
  logger: Logger | null;
343
368
  },
344
- preState: CachedBeaconStateAllForks,
369
+ preState: IBeaconStateView,
345
370
  slot: Slot,
346
371
  regenCaller: RegenCaller,
347
372
  opts: StateRegenerationOpts
348
- ): Promise<CachedBeaconStateAllForks> {
373
+ ): Promise<IBeaconStateView> {
349
374
  const preSlot = preState.slot;
350
375
  const postSlot = slot;
351
376
  const preEpoch = computeEpochAtSlot(preSlot);
352
377
  let postState = preState;
353
- const {checkpointStateCache, emitter, metrics, logger} = modules;
378
+ const {config, checkpointStateCache, emitter, metrics, logger} = modules;
354
379
  let count = 0;
355
380
 
356
381
  for (
@@ -365,7 +390,7 @@ export async function processSlotsToNearestCheckpoint(
365
390
  caller: regenCaller,
366
391
  });
367
392
  // processSlots calls .clone() before mutating
368
- postState = processSlots(postState, nextEpochSlot, opts, modules);
393
+ postState = postState.processSlots(nextEpochSlot, opts, modules);
369
394
  metrics?.epochTransitionByCaller.inc({caller: regenCaller});
370
395
 
371
396
  // this is usually added when we prepare for next slot or validate gossip block
@@ -374,7 +399,11 @@ export async function processSlotsToNearestCheckpoint(
374
399
  // This may becomes the "official" checkpoint state if the 1st block of epoch is skipped
375
400
  const checkpointState = postState;
376
401
  const cp = getCheckpointFromState(checkpointState);
377
- checkpointStateCache.add(cp, checkpointState);
402
+ // processSlots() only does epoch transitions, never processes payloads
403
+ // Pre-Gloas: payloadPresent is always true (execution payload embedded in block)
404
+ // Post-Gloas: result is a block state (payloadPresent=false)
405
+ const isPayloadPresent = config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
406
+ checkpointStateCache.add(cp, checkpointState, isPayloadPresent);
378
407
  // consumers should not mutate state ever
379
408
  emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
380
409
 
@@ -3,5 +3,5 @@ export {SeenBlockProposers} from "./seenBlockProposers.js";
3
3
  export {SeenSyncCommitteeMessages} from "./seenCommittee.js";
4
4
  export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
5
5
  export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
6
- export {SeenExecutionPayloadEnvelopes} from "./seenExecutionPayloadEnvelope.js";
7
6
  export {SeenBlockInput} from "./seenGossipBlockInput.js";
7
+ export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
@@ -180,7 +180,7 @@ export class SeenBlockInput {
180
180
  blockInput = this.blockInputs.get(parentRootHex ?? "");
181
181
  parentRootHex = blockInput?.parentRootHex;
182
182
  }
183
- this.logger?.debug(`BlockInputCache.prune deleted ${deletedCount} cached BlockInputs`);
183
+ this.logger?.debug("BlockInputCache.prune deleted cached BlockInputs", {deletedCount});
184
184
  this.pruneToMaxSize();
185
185
  }
186
186
 
@@ -193,7 +193,7 @@ export class SeenBlockInput {
193
193
  this.evictBlockInput(blockInput);
194
194
  }
195
195
  }
196
- this.logger?.debug(`BlockInputCache.onFinalized deleted ${deletedCount} cached BlockInputs`);
196
+ this.logger?.debug("BlockInputCache.onFinalized deleted cached BlockInputs", {deletedCount});
197
197
  this.pruneToMaxSize();
198
198
  };
199
199
 
@@ -0,0 +1,106 @@
1
+ import {CheckpointWithHex} from "@lodestar/fork-choice";
2
+ import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
3
+ import {RootHex} from "@lodestar/types";
4
+ import {Logger} from "@lodestar/utils";
5
+ import {Metrics} from "../../metrics/metrics.js";
6
+ import {SerializedCache} from "../../util/serializedCache.js";
7
+ import {CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
8
+ import {ChainEvent, ChainEventEmitter} from "../emitter.js";
9
+
10
+ export type {PayloadEnvelopeInputState} from "../blocks/payloadEnvelopeInput/index.js";
11
+ export {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
12
+
13
+ export type SeenPayloadEnvelopeInputModules = {
14
+ chainEvents: ChainEventEmitter;
15
+ signal: AbortSignal;
16
+ serializedCache: SerializedCache;
17
+ metrics: Metrics | null;
18
+ logger?: Logger;
19
+ };
20
+
21
+ /**
22
+ * Cache for tracking PayloadEnvelopeInput instances, keyed by beacon block root.
23
+ *
24
+ * Created during block import when a block is processed.
25
+ * Pruned on finalization and after payload is written to DB.
26
+ */
27
+ export class SeenPayloadEnvelopeInput {
28
+ private readonly chainEvents: ChainEventEmitter;
29
+ private readonly signal: AbortSignal;
30
+ private readonly serializedCache: SerializedCache;
31
+ private readonly metrics: Metrics | null;
32
+ private readonly logger?: Logger;
33
+ private payloadInputs = new Map<RootHex, PayloadEnvelopeInput>();
34
+
35
+ constructor({chainEvents, signal, serializedCache, metrics, logger}: SeenPayloadEnvelopeInputModules) {
36
+ this.chainEvents = chainEvents;
37
+ this.signal = signal;
38
+ this.serializedCache = serializedCache;
39
+ this.metrics = metrics;
40
+ this.logger = logger;
41
+
42
+ if (metrics) {
43
+ metrics.seenCache.payloadEnvelopeInput.count.addCollect(() => {
44
+ metrics.seenCache.payloadEnvelopeInput.count.set(this.payloadInputs.size);
45
+ metrics.seenCache.payloadEnvelopeInput.serializedObjectRefs.set(
46
+ Array.from(this.payloadInputs.values()).reduce(
47
+ (count, payloadInput) => count + payloadInput.getSerializedCacheKeys().length,
48
+ 0
49
+ )
50
+ );
51
+ });
52
+ }
53
+
54
+ this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.onFinalized);
55
+ this.signal.addEventListener("abort", () => {
56
+ this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.onFinalized);
57
+ });
58
+ }
59
+
60
+ private onFinalized = (checkpoint: CheckpointWithHex): void => {
61
+ // Prune all entries with slot < finalized slot
62
+ const finalizedSlot = computeStartSlotAtEpoch(checkpoint.epoch);
63
+ let deletedCount = 0;
64
+ for (const [, input] of this.payloadInputs) {
65
+ if (input.slot < finalizedSlot) {
66
+ this.evictPayloadInput(input);
67
+ deletedCount++;
68
+ }
69
+ }
70
+ this.logger?.debug("SeenPayloadEnvelopeInput.onFinalized deleted cached entries", {deletedCount});
71
+ };
72
+
73
+ add(props: CreateFromBlockProps): PayloadEnvelopeInput {
74
+ if (this.payloadInputs.has(props.blockRootHex)) {
75
+ throw new Error(`PayloadEnvelopeInput already exists for block ${props.blockRootHex}`);
76
+ }
77
+ const input = PayloadEnvelopeInput.createFromBlock(props);
78
+ this.payloadInputs.set(props.blockRootHex, input);
79
+ this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
80
+ return input;
81
+ }
82
+
83
+ get(blockRootHex: RootHex): PayloadEnvelopeInput | undefined {
84
+ return this.payloadInputs.get(blockRootHex);
85
+ }
86
+
87
+ has(blockRootHex: RootHex): boolean {
88
+ return this.payloadInputs.has(blockRootHex);
89
+ }
90
+
91
+ prune(blockRootHex: RootHex): void {
92
+ const payloadInput = this.payloadInputs.get(blockRootHex);
93
+ if (payloadInput) {
94
+ this.evictPayloadInput(payloadInput);
95
+ }
96
+ }
97
+
98
+ size(): number {
99
+ return this.payloadInputs.size;
100
+ }
101
+
102
+ private evictPayloadInput(payloadInput: PayloadEnvelopeInput): void {
103
+ this.serializedCache.delete(payloadInput.getSerializedCacheKeys());
104
+ this.payloadInputs.delete(payloadInput.blockRootHex);
105
+ }
106
+ }
@@ -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,6 +1,6 @@
1
1
  import {SLOTS_PER_EPOCH} from "@lodestar/params";
2
2
  import {Epoch, phase0, ssz} from "@lodestar/types";
3
- import {MapDef} from "@lodestar/utils";
3
+ import {MapDef, byteArrayEquals} from "@lodestar/utils";
4
4
  import {IBeaconDb} from "../../../db/interface.js";
5
5
  import {
6
6
  getLastProcessedSlotFromBeaconStateSerialized,
@@ -14,8 +14,8 @@ import {CPStateDatastore, DatastoreKey} from "./types.js";
14
14
  export class DbCPStateDatastore implements CPStateDatastore {
15
15
  constructor(private readonly db: IBeaconDb) {}
16
16
 
17
- async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
18
- const serializedCheckpoint = checkpointToDatastoreKey(cpKey);
17
+ async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array, payloadPresent: boolean): Promise<DatastoreKey> {
18
+ const serializedCheckpoint = checkpointToDatastoreKey(cpKey, payloadPresent);
19
19
  await this.db.checkpointState.putBinary(serializedCheckpoint, stateBytes);
20
20
  return serializedCheckpoint;
21
21
  }
@@ -40,18 +40,30 @@ export class DbCPStateDatastore implements CPStateDatastore {
40
40
  }
41
41
  }
42
42
 
43
+ function extractCheckpointBytes(key: DatastoreKey): Uint8Array {
44
+ const fixedSize = ssz.phase0.Checkpoint.minSize;
45
+ return key.subarray(0, fixedSize);
46
+ }
47
+
43
48
  export function datastoreKeyToCheckpoint(key: DatastoreKey): phase0.Checkpoint {
44
- return ssz.phase0.Checkpoint.deserialize(key);
49
+ return ssz.phase0.Checkpoint.deserialize(extractCheckpointBytes(key));
50
+ }
51
+
52
+ export function checkpointToDatastoreKey(cp: phase0.Checkpoint, payloadPresent: boolean): DatastoreKey {
53
+ const cpBytes = ssz.phase0.Checkpoint.serialize(cp);
54
+ const key = new Uint8Array(cpBytes.length + 1);
55
+ key.set(cpBytes);
56
+ key[cpBytes.length] = payloadPresent ? 1 : 0;
57
+ return key;
45
58
  }
46
59
 
47
- export function checkpointToDatastoreKey(cp: phase0.Checkpoint): DatastoreKey {
48
- return ssz.phase0.Checkpoint.serialize(cp);
60
+ function isPayloadCheckpointState(key: DatastoreKey): boolean {
61
+ return key.at(-1) === 1;
49
62
  }
50
63
 
51
64
  /**
52
- * Get the latest safe checkpoint state the node can use to boot from
53
- * - it should be the checkpoint state that's unique in its epoch
54
- * - its last processed block slot should be at epoch boundary or last slot of previous epoch
65
+ * Get the latest "safe" checkpoint state the node can use to boot from
66
+ * - its last processed block slot should be at epoch boundary (CRCS) or last slot of previous epoch (PRCS)
55
67
  * - state slot should be at epoch boundary
56
68
  * - state slot should be equal to epoch * SLOTS_PER_EPOCH
57
69
  *
@@ -70,9 +82,20 @@ export async function getLatestSafeDatastoreKey(
70
82
 
71
83
  const dataStoreKeyByEpoch: Map<Epoch, DatastoreKey> = new Map();
72
84
  for (const [epoch, keys] of checkpointsByEpoch.entries()) {
73
- // only consider epochs with a single checkpoint to avoid ambiguity from forks
74
85
  if (keys.length === 1) {
86
+ // PRCS (skipped slot) or CRCS and no payloadPresent
87
+ // Pre-gloas always fall into this case
75
88
  dataStoreKeyByEpoch.set(epoch, keys[0]);
89
+ } else if (keys.length === 2) {
90
+ // CRCS without payload and CRCS with payload
91
+ // ie Two keys for the same checkpoint with different payloadPresent suffix (FULL/EMPTY)
92
+ // TODO GLOAS: Here we pick FULL key, there is a chance that payload is orphaned hence we not be able to sync
93
+ const cp0 = extractCheckpointBytes(keys[0]);
94
+ const cp1 = extractCheckpointBytes(keys[1]);
95
+ if (byteArrayEquals(cp0, cp1)) {
96
+ const fullKey = isPayloadCheckpointState(keys[0]) ? keys[0] : keys[1];
97
+ dataStoreKeyByEpoch.set(epoch, fullKey);
98
+ }
76
99
  }
77
100
  }
78
101
 
@@ -1,12 +1,13 @@
1
1
  import path from "node:path";
2
- import {phase0, ssz} from "@lodestar/types";
2
+ import {phase0} from "@lodestar/types";
3
3
  import {fromHex, toHex} from "@lodestar/utils";
4
4
  import {ensureDir, readFile, readFileNames, removeFile, writeIfNotExist} from "../../../util/file.js";
5
- import {getLatestSafeDatastoreKey} from "./db.js";
5
+ import {checkpointToDatastoreKey, getLatestSafeDatastoreKey} from "./db.js";
6
6
  import {CPStateDatastore, DatastoreKey} from "./types.js";
7
7
 
8
8
  const CHECKPOINT_STATES_FOLDER = "checkpoint_states";
9
- const CHECKPOINT_FILE_NAME_LENGTH = 82;
9
+ /** 41 bytes (40 checkpoint + 1 payloadPresent) = 82 hex chars + "0x" prefix = 84 */
10
+ const CHECKPOINT_FILE_NAME_LENGTH = 84;
10
11
 
11
12
  /**
12
13
  * Implementation of CPStateDatastore using file system, this is beneficial for debugging.
@@ -28,8 +29,8 @@ export class FileCPStateDatastore implements CPStateDatastore {
28
29
  }
29
30
  }
30
31
 
31
- async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
32
- const serializedCheckpoint = ssz.phase0.Checkpoint.serialize(cpKey);
32
+ async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array, payloadPresent: boolean): Promise<DatastoreKey> {
33
+ const serializedCheckpoint = checkpointToDatastoreKey(cpKey, payloadPresent);
33
34
  const filePath = path.join(this.folderPath, toHex(serializedCheckpoint));
34
35
  await writeIfNotExist(filePath, stateBytes);
35
36
  return serializedCheckpoint;