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

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 (372) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +14 -2
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.js +1 -1
  5. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  6. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  7. package/lib/api/impl/beacon/state/index.js +27 -32
  8. package/lib/api/impl/beacon/state/index.js.map +1 -1
  9. package/lib/api/impl/beacon/state/utils.d.ts +4 -4
  10. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  11. package/lib/api/impl/beacon/state/utils.js +7 -10
  12. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  13. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  14. package/lib/api/impl/lodestar/index.js +4 -6
  15. package/lib/api/impl/lodestar/index.js.map +1 -1
  16. package/lib/api/impl/proof/index.d.ts.map +1 -1
  17. package/lib/api/impl/proof/index.js +2 -6
  18. package/lib/api/impl/proof/index.js.map +1 -1
  19. package/lib/api/impl/validator/index.d.ts.map +1 -1
  20. package/lib/api/impl/validator/index.js +27 -27
  21. package/lib/api/impl/validator/index.js.map +1 -1
  22. package/lib/api/impl/validator/utils.d.ts +2 -2
  23. package/lib/api/impl/validator/utils.d.ts.map +1 -1
  24. package/lib/api/impl/validator/utils.js +3 -3
  25. package/lib/api/impl/validator/utils.js.map +1 -1
  26. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  27. package/lib/chain/archiveStore/archiveStore.js +1 -0
  28. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  29. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +3 -7
  30. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  31. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +8 -26
  32. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  33. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts +2 -2
  34. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  35. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -0
  36. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  37. package/lib/chain/archiveStore/historicalState/types.d.ts +2 -0
  38. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  39. package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
  40. package/lib/chain/archiveStore/historicalState/worker.js +1 -3
  41. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  42. package/lib/chain/archiveStore/interface.d.ts +1 -0
  43. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  44. package/lib/chain/balancesCache.d.ts +2 -2
  45. package/lib/chain/balancesCache.d.ts.map +1 -1
  46. package/lib/chain/balancesCache.js +4 -4
  47. package/lib/chain/balancesCache.js.map +1 -1
  48. package/lib/chain/blocks/blockInput/types.d.ts +1 -0
  49. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  50. package/lib/chain/blocks/blockInput/types.js +1 -0
  51. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  52. package/lib/chain/blocks/importBlock.d.ts +3 -3
  53. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  54. package/lib/chain/blocks/importBlock.js +21 -21
  55. package/lib/chain/blocks/importBlock.js.map +1 -1
  56. package/lib/chain/blocks/importExecutionPayload.d.ts +10 -8
  57. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  58. package/lib/chain/blocks/importExecutionPayload.js +78 -51
  59. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  60. package/lib/chain/blocks/index.d.ts.map +1 -1
  61. package/lib/chain/blocks/index.js +3 -2
  62. package/lib/chain/blocks/index.js.map +1 -1
  63. package/lib/chain/blocks/types.d.ts +21 -15
  64. package/lib/chain/blocks/types.d.ts.map +1 -1
  65. package/lib/chain/blocks/types.js.map +1 -1
  66. package/lib/chain/blocks/utils/checkpoint.d.ts +2 -2
  67. package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -1
  68. package/lib/chain/blocks/utils/checkpoint.js.map +1 -1
  69. package/lib/chain/blocks/verifyBlock.d.ts +2 -2
  70. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  71. package/lib/chain/blocks/verifyBlock.js +4 -4
  72. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  73. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +5 -5
  74. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  75. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -4
  76. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  77. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  78. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  79. package/lib/chain/blocks/verifyBlocksSignatures.js +1 -1
  80. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  81. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -3
  82. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  83. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +3 -3
  84. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  85. package/lib/chain/chain.d.ts +12 -12
  86. package/lib/chain/chain.d.ts.map +1 -1
  87. package/lib/chain/chain.js +47 -39
  88. package/lib/chain/chain.js.map +1 -1
  89. package/lib/chain/emitter.d.ts +2 -2
  90. package/lib/chain/emitter.d.ts.map +1 -1
  91. package/lib/chain/errors/blockError.d.ts +4 -4
  92. package/lib/chain/errors/blockError.d.ts.map +1 -1
  93. package/lib/chain/forkChoice/index.d.ts +4 -4
  94. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  95. package/lib/chain/forkChoice/index.js +27 -23
  96. package/lib/chain/forkChoice/index.js.map +1 -1
  97. package/lib/chain/initState.d.ts +2 -2
  98. package/lib/chain/initState.d.ts.map +1 -1
  99. package/lib/chain/initState.js +1 -1
  100. package/lib/chain/initState.js.map +1 -1
  101. package/lib/chain/interface.d.ts +11 -12
  102. package/lib/chain/interface.d.ts.map +1 -1
  103. package/lib/chain/lightClient/index.d.ts +2 -2
  104. package/lib/chain/lightClient/index.d.ts.map +1 -1
  105. package/lib/chain/lightClient/index.js +4 -4
  106. package/lib/chain/lightClient/index.js.map +1 -1
  107. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +6 -6
  108. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  109. package/lib/chain/opPools/aggregatedAttestationPool.js +10 -13
  110. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  111. package/lib/chain/opPools/opPool.d.ts +3 -3
  112. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  113. package/lib/chain/opPools/opPool.js +7 -7
  114. package/lib/chain/opPools/opPool.js.map +1 -1
  115. package/lib/chain/opPools/utils.d.ts +2 -2
  116. package/lib/chain/opPools/utils.d.ts.map +1 -1
  117. package/lib/chain/opPools/utils.js +1 -1
  118. package/lib/chain/opPools/utils.js.map +1 -1
  119. package/lib/chain/options.d.ts +1 -0
  120. package/lib/chain/options.d.ts.map +1 -1
  121. package/lib/chain/options.js +1 -0
  122. package/lib/chain/options.js.map +1 -1
  123. package/lib/chain/prepareNextSlot.d.ts +2 -2
  124. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  125. package/lib/chain/prepareNextSlot.js +3 -3
  126. package/lib/chain/prepareNextSlot.js.map +1 -1
  127. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +4 -4
  128. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  129. package/lib/chain/produceBlock/computeNewStateRoot.js +3 -4
  130. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  131. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  132. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  133. package/lib/chain/produceBlock/produceBlockBody.js +12 -16
  134. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  135. package/lib/chain/regen/interface.d.ts +13 -13
  136. package/lib/chain/regen/interface.d.ts.map +1 -1
  137. package/lib/chain/regen/queued.d.ts +14 -14
  138. package/lib/chain/regen/queued.d.ts.map +1 -1
  139. package/lib/chain/regen/queued.js.map +1 -1
  140. package/lib/chain/regen/regen.d.ts +6 -5
  141. package/lib/chain/regen/regen.d.ts.map +1 -1
  142. package/lib/chain/regen/regen.js +6 -6
  143. package/lib/chain/regen/regen.js.map +1 -1
  144. package/lib/chain/serializeState.d.ts +2 -2
  145. package/lib/chain/serializeState.d.ts.map +1 -1
  146. package/lib/chain/serializeState.js +1 -1
  147. package/lib/chain/serializeState.js.map +1 -1
  148. package/lib/chain/shufflingCache.d.ts +2 -2
  149. package/lib/chain/shufflingCache.d.ts.map +1 -1
  150. package/lib/chain/shufflingCache.js +3 -4
  151. package/lib/chain/shufflingCache.js.map +1 -1
  152. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +6 -6
  153. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  154. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  155. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +11 -11
  156. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  157. package/lib/chain/stateCache/persistentCheckpointsCache.js +12 -16
  158. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  159. package/lib/chain/stateCache/types.d.ts +14 -14
  160. package/lib/chain/stateCache/types.d.ts.map +1 -1
  161. package/lib/chain/stateCache/types.js.map +1 -1
  162. package/lib/chain/validation/attesterSlashing.js +3 -3
  163. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  164. package/lib/chain/validation/blobSidecar.js +1 -1
  165. package/lib/chain/validation/blobSidecar.js.map +1 -1
  166. package/lib/chain/validation/block.d.ts.map +1 -1
  167. package/lib/chain/validation/block.js +3 -3
  168. package/lib/chain/validation/block.js.map +1 -1
  169. package/lib/chain/validation/blsToExecutionChange.js +2 -2
  170. package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
  171. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  172. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  173. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  174. package/lib/chain/validation/executionPayloadBid.js +4 -4
  175. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  176. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  177. package/lib/chain/validation/executionPayloadEnvelope.js +2 -3
  178. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  179. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  180. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  181. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  182. package/lib/chain/validation/proposerSlashing.js +1 -1
  183. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  184. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  185. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  186. package/lib/chain/validation/signatureSets/contributionAndProof.js +1 -1
  187. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  188. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  189. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  190. package/lib/chain/validation/signatureSets/syncCommittee.js +1 -1
  191. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  192. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  193. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  194. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  195. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  196. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  197. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -1
  198. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  199. package/lib/chain/validation/syncCommittee.d.ts +4 -4
  200. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  201. package/lib/chain/validation/syncCommittee.js +13 -12
  202. package/lib/chain/validation/syncCommittee.js.map +1 -1
  203. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  204. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  205. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  206. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  207. package/lib/chain/validation/voluntaryExit.js +3 -3
  208. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  209. package/lib/chain/validatorMonitor.d.ts +3 -3
  210. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  211. package/lib/chain/validatorMonitor.js +9 -7
  212. package/lib/chain/validatorMonitor.js.map +1 -1
  213. package/lib/metrics/metrics/lodestar.d.ts +12 -4
  214. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  215. package/lib/metrics/metrics/lodestar.js +19 -15
  216. package/lib/metrics/metrics/lodestar.js.map +1 -1
  217. package/lib/network/gossip/encoding.d.ts.map +1 -1
  218. package/lib/network/gossip/encoding.js +15 -0
  219. package/lib/network/gossip/encoding.js.map +1 -1
  220. package/lib/network/gossip/topic.d.ts +2 -729
  221. package/lib/network/gossip/topic.d.ts.map +1 -1
  222. package/lib/network/interface.d.ts +4 -2
  223. package/lib/network/interface.d.ts.map +1 -1
  224. package/lib/network/libp2p/index.d.ts.map +1 -1
  225. package/lib/network/libp2p/index.js +5 -0
  226. package/lib/network/libp2p/index.js.map +1 -1
  227. package/lib/network/network.d.ts +4 -2
  228. package/lib/network/network.d.ts.map +1 -1
  229. package/lib/network/network.js +9 -3
  230. package/lib/network/network.js.map +1 -1
  231. package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
  232. package/lib/network/processor/extractSlotRootFns.js +1 -1
  233. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  234. package/lib/network/processor/gossipHandlers.js +24 -15
  235. package/lib/network/processor/gossipHandlers.js.map +1 -1
  236. package/lib/network/processor/index.d.ts +12 -7
  237. package/lib/network/processor/index.d.ts.map +1 -1
  238. package/lib/network/processor/index.js +99 -78
  239. package/lib/network/processor/index.js.map +1 -1
  240. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  241. package/lib/network/reqresp/ReqRespBeaconNode.js +9 -0
  242. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  243. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts +8 -0
  244. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -0
  245. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +69 -0
  246. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -0
  247. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts +6 -0
  248. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -0
  249. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +28 -0
  250. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -0
  251. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  252. package/lib/network/reqresp/handlers/index.js +11 -1
  253. package/lib/network/reqresp/handlers/index.js.map +1 -1
  254. package/lib/network/reqresp/protocols.d.ts +2 -0
  255. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  256. package/lib/network/reqresp/protocols.js +10 -0
  257. package/lib/network/reqresp/protocols.js.map +1 -1
  258. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  259. package/lib/network/reqresp/rateLimit.js +8 -0
  260. package/lib/network/reqresp/rateLimit.js.map +1 -1
  261. package/lib/network/reqresp/score.d.ts.map +1 -1
  262. package/lib/network/reqresp/score.js +2 -0
  263. package/lib/network/reqresp/score.js.map +1 -1
  264. package/lib/network/reqresp/types.d.ts +8 -2
  265. package/lib/network/reqresp/types.d.ts.map +1 -1
  266. package/lib/network/reqresp/types.js +7 -1
  267. package/lib/network/reqresp/types.js.map +1 -1
  268. package/lib/node/nodejs.d.ts +2 -2
  269. package/lib/node/nodejs.d.ts.map +1 -1
  270. package/lib/node/nodejs.js +1 -4
  271. package/lib/node/nodejs.js.map +1 -1
  272. package/lib/node/notifier.d.ts.map +1 -1
  273. package/lib/node/notifier.js +3 -3
  274. package/lib/node/notifier.js.map +1 -1
  275. package/lib/sync/backfill/backfill.d.ts +2 -2
  276. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  277. package/lib/sync/backfill/backfill.js +2 -2
  278. package/lib/sync/backfill/backfill.js.map +1 -1
  279. package/lib/sync/unknownBlock.d.ts +3 -9
  280. package/lib/sync/unknownBlock.d.ts.map +1 -1
  281. package/lib/sync/unknownBlock.js +8 -41
  282. package/lib/sync/unknownBlock.js.map +1 -1
  283. package/lib/util/types.d.ts +2 -0
  284. package/lib/util/types.d.ts.map +1 -1
  285. package/lib/util/types.js +1 -0
  286. package/lib/util/types.js.map +1 -1
  287. package/package.json +16 -16
  288. package/src/api/impl/beacon/blocks/index.ts +16 -2
  289. package/src/api/impl/beacon/pool/index.ts +1 -1
  290. package/src/api/impl/beacon/state/index.ts +29 -41
  291. package/src/api/impl/beacon/state/utils.ts +11 -25
  292. package/src/api/impl/lodestar/index.ts +4 -8
  293. package/src/api/impl/proof/index.ts +2 -9
  294. package/src/api/impl/validator/index.ts +29 -41
  295. package/src/api/impl/validator/utils.ts +4 -7
  296. package/src/chain/archiveStore/archiveStore.ts +1 -0
  297. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -39
  298. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +2 -1
  299. package/src/chain/archiveStore/historicalState/types.ts +2 -0
  300. package/src/chain/archiveStore/historicalState/worker.ts +1 -4
  301. package/src/chain/archiveStore/interface.ts +1 -0
  302. package/src/chain/balancesCache.ts +5 -11
  303. package/src/chain/blocks/blockInput/types.ts +1 -0
  304. package/src/chain/blocks/importBlock.ts +23 -25
  305. package/src/chain/blocks/importExecutionPayload.ts +89 -63
  306. package/src/chain/blocks/index.ts +3 -2
  307. package/src/chain/blocks/types.ts +26 -15
  308. package/src/chain/blocks/utils/checkpoint.ts +2 -2
  309. package/src/chain/blocks/verifyBlock.ts +5 -10
  310. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -14
  311. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -3
  312. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -8
  313. package/src/chain/chain.ts +75 -67
  314. package/src/chain/emitter.ts +2 -2
  315. package/src/chain/errors/blockError.ts +4 -4
  316. package/src/chain/forkChoice/index.ts +33 -42
  317. package/src/chain/initState.ts +7 -2
  318. package/src/chain/interface.ts +12 -13
  319. package/src/chain/lightClient/index.ts +9 -22
  320. package/src/chain/opPools/aggregatedAttestationPool.ts +15 -21
  321. package/src/chain/opPools/opPool.ts +13 -14
  322. package/src/chain/opPools/utils.ts +3 -3
  323. package/src/chain/options.ts +2 -0
  324. package/src/chain/prepareNextSlot.ts +6 -8
  325. package/src/chain/produceBlock/computeNewStateRoot.ts +6 -10
  326. package/src/chain/produceBlock/produceBlockBody.ts +22 -49
  327. package/src/chain/regen/interface.ts +13 -17
  328. package/src/chain/regen/queued.ts +16 -20
  329. package/src/chain/regen/regen.ts +16 -17
  330. package/src/chain/serializeState.ts +3 -3
  331. package/src/chain/shufflingCache.ts +5 -7
  332. package/src/chain/stateCache/fifoBlockStateCache.ts +7 -7
  333. package/src/chain/stateCache/persistentCheckpointsCache.ts +27 -42
  334. package/src/chain/stateCache/types.ts +14 -18
  335. package/src/chain/validation/attesterSlashing.ts +3 -3
  336. package/src/chain/validation/blobSidecar.ts +1 -1
  337. package/src/chain/validation/block.ts +2 -4
  338. package/src/chain/validation/blsToExecutionChange.ts +2 -2
  339. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  340. package/src/chain/validation/executionPayloadBid.ts +3 -7
  341. package/src/chain/validation/executionPayloadEnvelope.ts +2 -8
  342. package/src/chain/validation/payloadAttestationMessage.ts +2 -4
  343. package/src/chain/validation/proposerSlashing.ts +1 -1
  344. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -7
  345. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -7
  346. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -2
  347. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -7
  348. package/src/chain/validation/syncCommittee.ts +21 -20
  349. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -10
  350. package/src/chain/validation/voluntaryExit.ts +3 -8
  351. package/src/chain/validatorMonitor.ts +12 -11
  352. package/src/metrics/metrics/lodestar.ts +23 -19
  353. package/src/network/gossip/encoding.ts +16 -0
  354. package/src/network/interface.ts +15 -2
  355. package/src/network/libp2p/index.ts +5 -0
  356. package/src/network/network.ts +32 -4
  357. package/src/network/processor/extractSlotRootFns.ts +1 -1
  358. package/src/network/processor/gossipHandlers.ts +25 -16
  359. package/src/network/processor/index.ts +110 -89
  360. package/src/network/reqresp/ReqRespBeaconNode.ts +13 -0
  361. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +94 -0
  362. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +43 -0
  363. package/src/network/reqresp/handlers/index.ts +12 -0
  364. package/src/network/reqresp/protocols.ts +12 -0
  365. package/src/network/reqresp/rateLimit.ts +18 -0
  366. package/src/network/reqresp/score.ts +2 -0
  367. package/src/network/reqresp/types.ts +13 -0
  368. package/src/node/nodejs.ts +3 -5
  369. package/src/node/notifier.ts +4 -10
  370. package/src/sync/backfill/backfill.ts +3 -3
  371. package/src/sync/unknownBlock.ts +10 -50
  372. package/src/util/types.ts +6 -0
@@ -1,33 +1,15 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {
3
- BeaconStateAllForks,
4
- CachedBeaconStateAllForks,
5
3
  DataAvailabilityStatus,
6
4
  ExecutionPayloadStatus,
7
- PubkeyCache,
8
- createCachedBeaconState,
9
- stateTransition,
5
+ IBeaconStateView,
6
+ createBeaconStateViewForHistoricalRegen,
10
7
  } from "@lodestar/state-transition";
11
8
  import {byteArrayEquals} from "@lodestar/utils";
12
9
  import {IBeaconDb} from "../../../db/index.js";
13
- import {getStateTypeFromBytes} from "../../../util/multifork.js";
14
10
  import {HistoricalStateRegenMetrics} from "./metrics.js";
15
11
  import {RegenErrorType} from "./types.js";
16
12
 
17
- /**
18
- * Populate a PubkeyCache with any new entries based on a BeaconState
19
- */
20
- export function syncPubkeyCache(state: BeaconStateAllForks, pubkeyCache: PubkeyCache): void {
21
- // Get the validators sub tree once for all the loop
22
- const validators = state.validators;
23
-
24
- const newCount = state.validators.length;
25
- for (let i = pubkeyCache.size; i < newCount; i++) {
26
- const pubkey = validators.getReadonly(i).pubkey;
27
- pubkeyCache.set(i, pubkey);
28
- }
29
- }
30
-
31
13
  /**
32
14
  * Get the nearest BeaconState at or before a slot
33
15
  */
@@ -35,27 +17,17 @@ export async function getNearestState(
35
17
  slot: number,
36
18
  config: BeaconConfig,
37
19
  db: IBeaconDb,
38
- pubkeyCache: PubkeyCache
39
- ): Promise<CachedBeaconStateAllForks> {
20
+ nativeStateView: boolean
21
+ ): Promise<IBeaconStateView> {
40
22
  const stateBytesArr = await db.stateArchive.binaries({limit: 1, lte: slot, reverse: true});
41
23
  if (!stateBytesArr.length) {
42
24
  throw new Error("No near state found in the database");
43
25
  }
44
26
 
45
27
  const stateBytes = stateBytesArr[0];
46
- const state = getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes);
47
- syncPubkeyCache(state, pubkeyCache);
48
-
49
- return createCachedBeaconState(
50
- state,
51
- {
52
- config,
53
- pubkeyCache,
54
- },
55
- {
56
- skipSyncPubkeys: true,
57
- }
58
- );
28
+ return nativeStateView
29
+ ? createBeaconStateViewForHistoricalRegen({useNative: true, stateBytes})
30
+ : createBeaconStateViewForHistoricalRegen({useNative: false, config, stateBytes});
59
31
  }
60
32
 
61
33
  /**
@@ -65,13 +37,13 @@ export async function getHistoricalState(
65
37
  slot: number,
66
38
  config: BeaconConfig,
67
39
  db: IBeaconDb,
68
- pubkeyCache: PubkeyCache,
40
+ nativeStateView: boolean,
69
41
  metrics?: HistoricalStateRegenMetrics
70
42
  ): Promise<Uint8Array> {
71
43
  const regenTimer = metrics?.regenTime.startTimer();
72
44
 
73
45
  const loadStateTimer = metrics?.loadStateTime.startTimer();
74
- let state = await getNearestState(slot, config, db, pubkeyCache).catch((e) => {
46
+ let state = await getNearestState(slot, config, db, nativeStateView).catch((e) => {
75
47
  metrics?.regenErrorCount.inc({reason: RegenErrorType.loadState});
76
48
  throw e;
77
49
  });
@@ -81,8 +53,7 @@ export async function getHistoricalState(
81
53
  let blockCount = 0;
82
54
  for await (const block of db.blockArchive.valuesStream({gt: state.slot, lte: slot})) {
83
55
  try {
84
- state = stateTransition(
85
- state,
56
+ state = state.stateTransition(
86
57
  block,
87
58
  {
88
59
  verifyProposer: false,
@@ -20,7 +20,7 @@ export class HistoricalStateRegen implements HistoricalStateWorkerApi {
20
20
  private readonly api: ModuleThread<HistoricalStateWorkerApi>;
21
21
  private readonly logger: LoggerNode;
22
22
 
23
- constructor(modules: HistoricalStateRegenModules) {
23
+ private constructor(modules: HistoricalStateRegenModules) {
24
24
  this.api = modules.api;
25
25
  this.logger = modules.logger;
26
26
  modules.signal?.addEventListener("abort", () => this.close(), {once: true});
@@ -35,6 +35,7 @@ export class HistoricalStateRegen implements HistoricalStateWorkerApi {
35
35
  dbLocation: modules.opts.dbLocation,
36
36
  metricsEnabled: Boolean(modules.metrics),
37
37
  loggerOpts: modules.logger.toOpts(),
38
+ nativeStateView: modules.opts.nativeStateView,
38
39
  };
39
40
 
40
41
  const worker = new Worker(path.join(WORKER_DIR, "worker.js"), {
@@ -7,6 +7,7 @@ export type HistoricalStateRegenInitModules = {
7
7
  opts: {
8
8
  genesisTime: number;
9
9
  dbLocation: string;
10
+ nativeStateView: boolean;
10
11
  };
11
12
  config: BeaconConfig;
12
13
  logger: LoggerNode;
@@ -26,6 +27,7 @@ export type HistoricalStateWorkerData = {
26
27
  dbLocation: string;
27
28
  metricsEnabled: boolean;
28
29
  loggerOpts: LoggerNodeOpts;
30
+ nativeStateView: boolean;
29
31
  };
30
32
 
31
33
  export type HistoricalStateWorkerApi = {
@@ -3,7 +3,6 @@ import {Transfer, expose} from "@chainsafe/threads/worker";
3
3
  import {chainConfigFromJson, createBeaconConfig} from "@lodestar/config";
4
4
  import {LevelDbController} from "@lodestar/db/controller/level";
5
5
  import {getNodeLogger} from "@lodestar/logger/node";
6
- import {createPubkeyCache} from "@lodestar/state-transition";
7
6
  import {BeaconDb} from "../../../db/index.js";
8
7
  import {RegistryMetricCreator, collectNodeJSMetrics} from "../../../metrics/index.js";
9
8
  import {JobFnQueue} from "../../../util/queue/fnQueue.js";
@@ -52,8 +51,6 @@ const queue = new JobFnQueue(
52
51
  queueMetrics
53
52
  );
54
53
 
55
- const pubkeyCache = createPubkeyCache();
56
-
57
54
  const api: HistoricalStateWorkerApi = {
58
55
  async close() {
59
56
  abortController.abort();
@@ -65,7 +62,7 @@ const api: HistoricalStateWorkerApi = {
65
62
  historicalStateRegenMetrics?.regenRequestCount.inc();
66
63
 
67
64
  const stateBytes = await queue.push<Uint8Array>(() =>
68
- getHistoricalState(slot, config, db, pubkeyCache, historicalStateRegenMetrics)
65
+ getHistoricalState(slot, config, db, workerData.nativeStateView, historicalStateRegenMetrics)
69
66
  );
70
67
  const result = Transfer(stateBytes, [stateBytes.buffer]) as unknown as Uint8Array;
71
68
 
@@ -25,6 +25,7 @@ export type ArchiveStoreOpts = StatesArchiveOpts & {
25
25
  archiveDataEpochs?: number;
26
26
  pruneHistory?: boolean;
27
27
  serveHistoricalState?: boolean;
28
+ nativeStateView?: boolean;
28
29
  };
29
30
 
30
31
  export type ProposalStats = {
@@ -1,11 +1,5 @@
1
1
  import {CheckpointWithHex} from "@lodestar/fork-choice";
2
- import {
3
- CachedBeaconStateAllForks,
4
- EffectiveBalanceIncrements,
5
- computeStartSlotAtEpoch,
6
- getBlockRootAtSlot,
7
- getEffectiveBalanceIncrementsZeroInactive,
8
- } from "@lodestar/state-transition";
2
+ import {EffectiveBalanceIncrements, IBeaconStateView, computeStartSlotAtEpoch} from "@lodestar/state-transition";
9
3
  import {Epoch, RootHex} from "@lodestar/types";
10
4
  import {toRootHex} from "@lodestar/utils";
11
5
 
@@ -29,11 +23,11 @@ export class CheckpointBalancesCache {
29
23
  * `state.current_epoch`. If there is not already some entry for the given block root, then
30
24
  * add the effective balances from the `state` to the cache.
31
25
  */
32
- processState(blockRootHex: RootHex, state: CachedBeaconStateAllForks): void {
33
- const epoch = state.epochCtx.epoch;
26
+ processState(blockRootHex: RootHex, state: IBeaconStateView): void {
27
+ const epoch = state.epoch;
34
28
  const epochBoundarySlot = computeStartSlotAtEpoch(epoch);
35
29
  const epochBoundaryRoot =
36
- epochBoundarySlot === state.slot ? blockRootHex : toRootHex(getBlockRootAtSlot(state, epochBoundarySlot));
30
+ epochBoundarySlot === state.slot ? blockRootHex : toRootHex(state.getBlockRootAtSlot(epochBoundarySlot));
37
31
 
38
32
  const index = this.items.findIndex((item) => item.epoch === epoch && item.rootHex === epochBoundaryRoot);
39
33
  if (index === -1) {
@@ -41,7 +35,7 @@ export class CheckpointBalancesCache {
41
35
  this.items.shift();
42
36
  }
43
37
  // expect to reach this once per epoch
44
- this.items.push({epoch, rootHex: epochBoundaryRoot, balances: getEffectiveBalanceIncrementsZeroInactive(state)});
38
+ this.items.push({epoch, rootHex: epochBoundaryRoot, balances: state.getEffectiveBalanceIncrementsZeroInactive()});
45
39
  }
46
40
  }
47
41
 
@@ -16,6 +16,7 @@ export type DAData = null | deneb.BlobSidecars | fulu.DataColumnSidecars;
16
16
  * sources so each should be labelled individually.
17
17
  */
18
18
  export enum BlockInputSource {
19
+ network_processor = "network_processor",
19
20
  gossip = "gossip",
20
21
  api = "api",
21
22
  engine = "engine",
@@ -3,6 +3,7 @@ import {routes} from "@lodestar/api";
3
3
  import {
4
4
  AncestorStatus,
5
5
  EpochDifference,
6
+ ExecutionStatus,
6
7
  ForkChoiceError,
7
8
  ForkChoiceErrorCode,
8
9
  NotReorgedReason,
@@ -18,15 +19,12 @@ import {
18
19
  SLOTS_PER_EPOCH,
19
20
  } from "@lodestar/params";
20
21
  import {
21
- CachedBeaconStateAltair,
22
- EpochCache,
22
+ IBeaconStateView,
23
23
  RootCache,
24
24
  computeEpochAtSlot,
25
25
  computeStartSlotAtEpoch,
26
26
  computeTimeAtSlot,
27
- isExecutionStateType,
28
27
  isStartSlotOfEpoch,
29
- isStateValidatorsNodesPopulated,
30
28
  } from "@lodestar/state-transition";
31
29
  import {
32
30
  Attestation,
@@ -87,7 +85,7 @@ export async function importBlock(
87
85
  fullyVerifiedBlock: FullyVerifiedBlock,
88
86
  opts: ImportBlockOpts
89
87
  ): Promise<void> {
90
- const {blockInput, postState, parentBlockSlot, executionStatus, dataAvailabilityStatus, indexedAttestations} =
88
+ const {blockInput, postBlockState, parentBlockSlot, executionStatus, dataAvailabilityStatus, indexedAttestations} =
91
89
  fullyVerifiedBlock;
92
90
  const block = blockInput.getBlock();
93
91
  const source = blockInput.getBlockSource();
@@ -99,7 +97,7 @@ export async function importBlock(
99
97
  const blockEpoch = computeEpochAtSlot(blockSlot);
100
98
  const prevFinalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
101
99
  const blockDelaySec =
102
- fullyVerifiedBlock.seenTimestampSec - computeTimeAtSlot(this.config, blockSlot, postState.genesisTime);
100
+ fullyVerifiedBlock.seenTimestampSec - computeTimeAtSlot(this.config, blockSlot, postBlockState.genesisTime);
103
101
  const recvToValLatency = Date.now() / 1000 - (opts.seenTimestampSec ?? Date.now() / 1000);
104
102
  const fork = this.config.getForkSeq(blockSlot);
105
103
 
@@ -122,13 +120,13 @@ export async function importBlock(
122
120
  // 2. Import block to fork choice
123
121
 
124
122
  // Should compute checkpoint balances before forkchoice.onBlock
125
- this.checkpointBalancesCache.processState(blockRootHex, postState);
123
+ this.checkpointBalancesCache.processState(blockRootHex, postBlockState);
126
124
  const blockSummary = this.forkChoice.onBlock(
127
125
  block.message,
128
- postState,
126
+ postBlockState,
129
127
  blockDelaySec,
130
128
  currentSlot,
131
- executionStatus,
129
+ fork >= ForkSeq.gloas ? ExecutionStatus.PayloadSeparated : executionStatus,
132
130
  dataAvailabilityStatus
133
131
  );
134
132
 
@@ -138,7 +136,7 @@ export async function importBlock(
138
136
  // Post-Gloas: blockSummary.payloadStatus is always PENDING, so payloadPresent = false (block state only, no payload processing yet)
139
137
  const payloadPresent = !isGloasBlock(blockSummary);
140
138
  // processState manages both block state and payload state variants together for memory/disk management
141
- this.regen.processBlockState(blockRootHex, postState);
139
+ this.regen.processBlockState(blockRootHex, postBlockState);
142
140
 
143
141
  // For Gloas blocks, create PayloadEnvelopeInput so it's available for later payload import
144
142
  if (fork >= ForkSeq.gloas) {
@@ -174,7 +172,7 @@ export async function importBlock(
174
172
  (opts.importAttestations !== AttestationImportOpt.Skip && blockEpoch >= currentEpoch - FORK_CHOICE_ATT_EPOCH_LIMIT)
175
173
  ) {
176
174
  const attestations = block.message.body.attestations;
177
- const rootCache = new RootCache(postState);
175
+ const rootCache = new RootCache(postBlockState);
178
176
  const invalidAttestationErrorsByCode = new Map<string, {error: Error; count: number}>();
179
177
 
180
178
  const addAttestation = fork >= ForkSeq.electra ? addAttestationPostElectra : addAttestationPreElectra;
@@ -188,7 +186,7 @@ export async function importBlock(
188
186
  const attDataRoot = toRootHex(ssz.phase0.AttestationData.hashTreeRoot(indexedAttestation.data));
189
187
  addAttestation.call(
190
188
  this,
191
- postState.epochCtx,
189
+ postBlockState,
192
190
  target,
193
191
  attDataRoot,
194
192
  attestation as Attestation<ForkPostElectra>,
@@ -303,7 +301,7 @@ export async function importBlock(
303
301
 
304
302
  if (newHead.blockRoot !== oldHead.blockRoot) {
305
303
  // Set head state as strong reference
306
- this.regen.updateHeadState(newHead, postState);
304
+ this.regen.updateHeadState(newHead, postBlockState);
307
305
 
308
306
  try {
309
307
  this.emitter.emit(routes.events.EventType.head, {
@@ -375,7 +373,7 @@ export async function importBlock(
375
373
  try {
376
374
  this.lightClientServer?.onImportBlockHead(
377
375
  block.message as BeaconBlock<ForkPostAltair>,
378
- postState as CachedBeaconStateAltair,
376
+ postBlockState,
379
377
  parentBlockSlot
380
378
  );
381
379
  } catch (e) {
@@ -396,11 +394,11 @@ export async function importBlock(
396
394
  // and the block is weak and can potentially be reorged out.
397
395
  let shouldOverrideFcu = false;
398
396
 
399
- if (blockSlot >= currentSlot && isExecutionStateType(postState)) {
397
+ if (blockSlot >= currentSlot && postBlockState.isExecutionStateType) {
400
398
  let notOverrideFcuReason = NotReorgedReason.Unknown;
401
399
  const proposalSlot = blockSlot + 1;
402
400
  try {
403
- const proposerIndex = postState.epochCtx.getBeaconProposer(proposalSlot);
401
+ const proposerIndex = postBlockState.getBeaconProposer(proposalSlot);
404
402
  const feeRecipient = this.beaconProposerCache.get(proposerIndex);
405
403
 
406
404
  if (feeRecipient) {
@@ -480,20 +478,20 @@ export async function importBlock(
480
478
  }
481
479
  }
482
480
 
483
- if (!isStateValidatorsNodesPopulated(postState)) {
484
- this.logger.verbose("After importBlock caching postState without SSZ cache", {slot: postState.slot});
481
+ if (!postBlockState.isStateValidatorsNodesPopulated()) {
482
+ this.logger.verbose("After importBlock caching postState without SSZ cache", {slot: postBlockState.slot});
485
483
  }
486
484
 
487
485
  // Cache shufflings when crossing an epoch boundary
488
486
  const parentEpoch = computeEpochAtSlot(parentBlockSlot);
489
487
  if (parentEpoch < blockEpoch) {
490
- this.shufflingCache.processState(postState);
488
+ this.shufflingCache.processState(postBlockState);
491
489
  this.logger.verbose("Processed shuffling for next epoch", {parentEpoch, blockEpoch, slot: blockSlot});
492
490
  }
493
491
 
494
492
  if (blockSlot % SLOTS_PER_EPOCH === 0) {
495
493
  // Cache state to preserve epoch transition work
496
- const checkpointState = postState;
494
+ const checkpointState = postBlockState;
497
495
  const cp = getCheckpointFromState(checkpointState);
498
496
  this.regen.addCheckpointState(cp, checkpointState, payloadPresent);
499
497
  // consumers should not mutate state ever
@@ -502,7 +500,7 @@ export async function importBlock(
502
500
  // Note: in-lined code from previos handler of ChainEvent.checkpoint
503
501
  this.logger.verbose("Checkpoint processed", toCheckpointHexPayload(cp, payloadPresent));
504
502
 
505
- const activeValidatorsCount = checkpointState.epochCtx.currentShuffling.activeIndices.length;
503
+ const activeValidatorsCount = checkpointState.activeValidatorCount;
506
504
  this.metrics?.currentActiveValidators.set(activeValidatorsCount);
507
505
  this.metrics?.currentValidators.set({status: "active"}, activeValidatorsCount);
508
506
 
@@ -587,7 +585,7 @@ export async function importBlock(
587
585
  this.validatorMonitor?.registerSyncAggregateInBlock(
588
586
  blockEpoch,
589
587
  (block as altair.SignedBeaconBlock).message.body.syncAggregate,
590
- fullyVerifiedBlock.postState.epochCtx.currentSyncCommitteeIndexed.validatorIndices
588
+ fullyVerifiedBlock.postBlockState.currentSyncCommitteeIndexed.validatorIndices
591
589
  );
592
590
  }
593
591
 
@@ -629,7 +627,7 @@ export async function importBlock(
629
627
  export function addAttestationPreElectra(
630
628
  this: BeaconChain,
631
629
  // added to have the same signature as addAttestationPostElectra
632
- _: EpochCache,
630
+ _: IBeaconStateView,
633
631
  target: phase0.Checkpoint,
634
632
  attDataRoot: string,
635
633
  attestation: Attestation,
@@ -646,7 +644,7 @@ export function addAttestationPreElectra(
646
644
 
647
645
  export function addAttestationPostElectra(
648
646
  this: BeaconChain,
649
- epochCtx: EpochCache,
647
+ state: IBeaconStateView,
650
648
  target: phase0.Checkpoint,
651
649
  attDataRoot: string,
652
650
  attestation: Attestation<ForkPostElectra>,
@@ -664,7 +662,7 @@ export function addAttestationPostElectra(
664
662
  } else {
665
663
  const attSlot = attestation.data.slot;
666
664
  const attEpoch = computeEpochAtSlot(attSlot);
667
- const decisionRoot = epochCtx.getShufflingDecisionRoot(attEpoch);
665
+ const decisionRoot = state.getShufflingDecisionRoot(attEpoch);
668
666
  const committees = this.shufflingCache.getBeaconCommittees(attEpoch, decisionRoot, attSlot, committeeIndices);
669
667
  const aggregationBools = attestation.aggregationBits.toBoolArray();
670
668
  let offset = 0;
@@ -1,11 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
- import {ForkName} from "@lodestar/params";
3
- import {
4
- BeaconStateView,
5
- CachedBeaconStateGloas,
6
- getExecutionPayloadEnvelopeSignatureSet,
7
- } from "@lodestar/state-transition";
8
- import {processExecutionPayloadEnvelope} from "@lodestar/state-transition/block";
2
+ import {ExecutionStatus, PayloadExecutionStatus} from "@lodestar/fork-choice";
3
+ import {SLOTS_PER_EPOCH} from "@lodestar/params";
4
+ import {getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
9
5
  import {byteArrayEquals, fromHex, toRootHex} from "@lodestar/utils";
10
6
  import {ExecutionPayloadStatus} from "../../execution/index.js";
11
7
  import {isQueueErrorAborted} from "../../util/queue/index.js";
@@ -56,18 +52,33 @@ export class PayloadError extends Error {
56
52
  }
57
53
  }
58
54
 
55
+ function toForkChoiceExecutionStatus(status: ExecutionPayloadStatus): PayloadExecutionStatus {
56
+ switch (status) {
57
+ case ExecutionPayloadStatus.VALID:
58
+ return ExecutionStatus.Valid;
59
+ // TODO GLOAS: Handle optimistic import for payload
60
+ case ExecutionPayloadStatus.SYNCING:
61
+ case ExecutionPayloadStatus.ACCEPTED:
62
+ return ExecutionStatus.Syncing;
63
+ default:
64
+ throw new Error(`Unexpected execution payload status for fork choice: ${status}`);
65
+ }
66
+ }
67
+
59
68
  /**
60
69
  * Import an execution payload envelope after all data is available.
61
70
  *
62
71
  * This function:
63
- * 1. Gets the ProtoBlock from fork choice
64
- * 2. Applies write-queue backpressure (waitForSpace) early, before verification
65
- * 3. Regenerates the block state
66
- * 4. Runs EL verification (notifyNewPayload) in parallel with signature verification and processExecutionPayloadEnvelope
67
- * 5. Persists verified payload envelope to hot DB
68
- * 6. Updates fork choice
69
- * 7. Caches the post-execution payload state
70
- * 8. Records metrics for column sources
72
+ * 1. Emits `execution_payload_available` if payload is for current slot
73
+ * 2. Gets the ProtoBlock from fork choice
74
+ * 3. Applies write-queue backpressure (waitForSpace) early, before verification
75
+ * 4. Regenerates the block state
76
+ * 5. Runs EL verification (notifyNewPayload) in parallel with signature verification and processExecutionPayloadEnvelope
77
+ * 6. Persists verified payload envelope to hot DB
78
+ * 7. Updates fork choice
79
+ * 8. Caches the post-execution payload state
80
+ * 9. Records metrics for column sources
81
+ * 10. Emits `execution_payload` for recent enough payloads after successful import
71
82
  *
72
83
  */
73
84
  export async function importExecutionPayload(
@@ -75,10 +86,24 @@ export async function importExecutionPayload(
75
86
  payloadInput: PayloadEnvelopeInput,
76
87
  opts: ImportPayloadOpts = {}
77
88
  ): Promise<void> {
78
- const envelope = payloadInput.getPayloadEnvelope();
89
+ const signedEnvelope = payloadInput.getPayloadEnvelope();
90
+ const envelope = signedEnvelope.message;
79
91
  const blockRootHex = payloadInput.blockRootHex;
92
+ const blockHashHex = payloadInput.getBlockHashHex();
93
+ const fork = this.config.getForkName(envelope.slot);
94
+
95
+ // 1. Emit `execution_payload_available` event at the start of import. At this point the payload input
96
+ // is already complete, so the payload and required data are available for payload attestation.
97
+ // This event is only about availability, not validity of the execution payload, hence we can emit
98
+ // it before getting a response from the execution client on whether the payload is valid or not.
99
+ if (this.clock.currentSlot === envelope.slot) {
100
+ this.emitter.emit(routes.events.EventType.executionPayloadAvailable, {
101
+ slot: envelope.slot,
102
+ blockRoot: blockRootHex,
103
+ });
104
+ }
80
105
 
81
- // 1. Get ProtoBlock for parent root lookup
106
+ // 2. Get ProtoBlock for parent root lookup
82
107
  const protoBlock = this.forkChoice.getBlockHexDefaultStatus(blockRootHex);
83
108
  if (!protoBlock) {
84
109
  throw new PayloadError({
@@ -87,29 +112,29 @@ export async function importExecutionPayload(
87
112
  });
88
113
  }
89
114
 
90
- // 2. Apply backpressure from the write queue early, before doing verification work.
115
+ // 3. Apply backpressure from the write queue early, before doing verification work.
91
116
  // The actual DB write is deferred until after verification succeeds.
92
117
  await this.unfinalizedPayloadEnvelopeWrites.waitForSpace();
93
118
 
94
- // 3. Get pre-state for processExecutionPayloadEnvelope
119
+ // 4. Get pre-state for processExecutionPayloadEnvelope
95
120
  // We need the block state (post-block, pre-payload) to process the envelope
96
- const blockState = (await this.regen.getBlockSlotState(
121
+ const blockState = await this.regen.getBlockSlotState(
97
122
  protoBlock,
98
123
  protoBlock.slot,
99
124
  {dontTransferCache: true},
100
125
  RegenCaller.processBlock
101
- )) as CachedBeaconStateGloas;
126
+ );
102
127
 
103
- // 4. Run verification steps in parallel
128
+ // 5. Run verification steps in parallel
104
129
  // Note: No data availability check needed here - importExecutionPayload is only
105
130
  // called when payloadInput.isComplete() is true, so all data is already available.
106
131
  const [execResult, signatureValid, postPayloadResult] = await Promise.all([
107
132
  this.executionEngine.notifyNewPayload(
108
- ForkName.gloas,
109
- envelope.message.payload,
133
+ fork,
134
+ envelope.payload,
110
135
  payloadInput.getVersionedHashes(),
111
136
  fromHex(protoBlock.parentRoot),
112
- envelope.message.executionRequests
137
+ envelope.executionRequests
113
138
  ),
114
139
 
115
140
  opts.validSignature === true
@@ -117,9 +142,9 @@ export async function importExecutionPayload(
117
142
  : (async () => {
118
143
  const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
119
144
  this.config,
120
- blockState.epochCtx.pubkeyCache,
121
- new BeaconStateView(blockState),
122
- envelope,
145
+ this.pubkeyCache,
146
+ blockState,
147
+ signedEnvelope,
123
148
  payloadInput.proposerIndex
124
149
  );
125
150
  return this.bls.verifySignatureSets([signatureSet]);
@@ -130,7 +155,7 @@ export async function importExecutionPayload(
130
155
  (async () => {
131
156
  try {
132
157
  return {
133
- postPayloadState: processExecutionPayloadEnvelope(blockState, envelope, {
158
+ postPayloadState: blockState.processExecutionPayloadEnvelope(signedEnvelope, {
134
159
  verifySignature: false,
135
160
  verifyStateRoot: false,
136
161
  }),
@@ -147,12 +172,12 @@ export async function importExecutionPayload(
147
172
  })(),
148
173
  ]);
149
174
 
150
- // 4b. Check signature verification result
175
+ // 5a. Check signature verification result
151
176
  if (!signatureValid) {
152
177
  throw new PayloadError({code: PayloadErrorCode.INVALID_SIGNATURE});
153
178
  }
154
179
 
155
- // 5. Handle EL response
180
+ // 5b. Handle EL response
156
181
  switch (execResult.status) {
157
182
  case ExecutionPayloadStatus.VALID:
158
183
  break;
@@ -166,12 +191,7 @@ export async function importExecutionPayload(
166
191
 
167
192
  case ExecutionPayloadStatus.ACCEPTED:
168
193
  case ExecutionPayloadStatus.SYNCING:
169
- // TODO GLOAS: Handle optimistic import for payload - for now treat as error
170
- throw new PayloadError({
171
- code: PayloadErrorCode.EXECUTION_ENGINE_ERROR,
172
- execStatus: execResult.status,
173
- errorMessage: execResult.validationError ?? "EL syncing, payload not yet validated",
174
- });
194
+ break;
175
195
 
176
196
  case ExecutionPayloadStatus.INVALID_BLOCK_HASH:
177
197
  case ExecutionPayloadStatus.ELERROR:
@@ -183,59 +203,65 @@ export async function importExecutionPayload(
183
203
  });
184
204
  }
185
205
 
186
- // 5b. Verify envelope state root matches post-state
206
+ // 5c. Verify envelope state root matches post-state
187
207
  const postPayloadState = postPayloadResult.postPayloadState;
188
208
  const postPayloadStateRoot = postPayloadState.hashTreeRoot();
189
- if (!byteArrayEquals(envelope.message.stateRoot, postPayloadStateRoot)) {
209
+ if (!byteArrayEquals(envelope.stateRoot, postPayloadStateRoot)) {
190
210
  throw new PayloadError({
191
211
  code: PayloadErrorCode.STATE_TRANSITION_ERROR,
192
- message: `Envelope state root mismatch expected=${toRootHex(envelope.message.stateRoot)} actual=${toRootHex(postPayloadStateRoot)}`,
212
+ message: `Envelope state root mismatch expected=${toRootHex(envelope.stateRoot)} actual=${toRootHex(postPayloadStateRoot)}`,
193
213
  });
194
214
  }
195
215
 
196
- // 5c. Persist payload envelope to hot DB (performed asynchronously to avoid blocking)
216
+ // 6. Persist payload envelope to hot DB (performed asynchronously to avoid blocking)
197
217
  this.unfinalizedPayloadEnvelopeWrites.push(payloadInput).catch((e) => {
198
218
  if (!isQueueErrorAborted(e)) {
199
219
  this.logger.error(
200
220
  "Error pushing payload envelope to unfinalized write queue",
201
- {slot: payloadInput.slot, root: blockRootHex},
221
+ {slot: envelope.slot, root: blockRootHex},
202
222
  e as Error
203
223
  );
204
224
  }
205
225
  });
206
226
 
207
- // 6. Update fork choice
227
+ // 7. Update fork choice
208
228
  this.forkChoice.onExecutionPayload(
209
229
  blockRootHex,
210
- payloadInput.getBlockHashHex(),
211
- envelope.message.payload.blockNumber,
212
- toRootHex(postPayloadStateRoot)
230
+ blockHashHex,
231
+ envelope.payload.blockNumber,
232
+ toRootHex(postPayloadStateRoot),
233
+ toForkChoiceExecutionStatus(execResult.status)
213
234
  );
214
235
 
215
- // 7. Cache payload state
216
- // TODO GLOAS: Enable when PR #8868 merged (adds processPayloadState)
217
- // this.regen.processPayloadState(postPayloadState);
218
- // if epoch boundary also call
219
- // this.regen.addCheckpointState(cp, checkpointState, true);
236
+ // 8. Cache payload state
237
+ this.regen.processPayloadState(postPayloadState);
238
+ if (postPayloadState.slot % SLOTS_PER_EPOCH === 0) {
239
+ const {checkpoint} = postPayloadState.computeAnchorCheckpoint();
240
+ this.regen.addCheckpointState(checkpoint, postPayloadState, true);
241
+ }
220
242
 
221
- // 8. Record metrics for payload envelope and column sources
243
+ // 9. Record metrics for payload envelope and column sources
222
244
  this.metrics?.importPayload.bySource.inc({source: payloadInput.getPayloadEnvelopeSource().source});
223
245
  for (const {source} of payloadInput.getSampledColumnsWithSource()) {
224
246
  this.metrics?.importPayload.columnsBySource.inc({source});
225
247
  }
226
248
 
227
- this.logger.verbose("Execution payload imported", {
228
- slot: payloadInput.slot,
229
- root: blockRootHex,
230
- blockHash: payloadInput.getBlockHashHex(),
231
- });
232
-
233
- // 9. Emit event after payload is fully verified and imported to fork choice, only for recent enough payloads
234
- const currentSlot = this.clock.currentSlot;
235
- if (currentSlot - payloadInput.slot < EVENTSTREAM_EMIT_RECENT_EXECUTION_PAYLOAD_SLOTS) {
236
- this.emitter.emit(routes.events.EventType.executionPayloadAvailable, {
237
- slot: payloadInput.slot,
249
+ // 10. Emit event after payload is fully verified and imported to fork choice, only for recent enough payloads
250
+ if (this.clock.currentSlot - envelope.slot < EVENTSTREAM_EMIT_RECENT_EXECUTION_PAYLOAD_SLOTS) {
251
+ this.emitter.emit(routes.events.EventType.executionPayload, {
252
+ slot: envelope.slot,
253
+ builderIndex: envelope.builderIndex,
254
+ blockHash: blockHashHex,
238
255
  blockRoot: blockRootHex,
256
+ stateRoot: toRootHex(envelope.stateRoot),
257
+ // TODO GLOAS: revisit once we support optimistic import
258
+ executionOptimistic: false,
239
259
  });
240
260
  }
261
+
262
+ this.logger.verbose("Execution payload imported", {
263
+ slot: envelope.slot,
264
+ root: blockRootHex,
265
+ blockHash: blockHashHex,
266
+ });
241
267
  }