@lodestar/beacon-node 1.41.0-dev.555261016d → 1.41.0-dev.66fe43ae9e

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 (411) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +123 -4
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/state/index.js +8 -8
  5. package/lib/api/impl/beacon/state/index.js.map +1 -1
  6. package/lib/api/impl/beacon/state/utils.d.ts +3 -4
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +5 -24
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/lightclient/index.d.ts.map +1 -1
  14. package/lib/api/impl/lightclient/index.js +19 -2
  15. package/lib/api/impl/lightclient/index.js.map +1 -1
  16. package/lib/api/impl/node/index.d.ts +1 -1
  17. package/lib/api/impl/node/index.d.ts.map +1 -1
  18. package/lib/api/impl/node/index.js +18 -1
  19. package/lib/api/impl/node/index.js.map +1 -1
  20. package/lib/api/impl/node/utils.d.ts +1 -1
  21. package/lib/api/impl/node/utils.d.ts.map +1 -1
  22. package/lib/api/impl/node/utils.js.map +1 -1
  23. package/lib/api/impl/validator/index.d.ts.map +1 -1
  24. package/lib/api/impl/validator/index.js +130 -16
  25. package/lib/api/impl/validator/index.js.map +1 -1
  26. package/lib/chain/archiveStore/archiveStore.d.ts +1 -0
  27. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  28. package/lib/chain/archiveStore/archiveStore.js +9 -0
  29. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  30. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +5 -6
  31. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  32. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +9 -10
  33. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  34. package/lib/chain/archiveStore/historicalState/worker.js +3 -3
  35. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  36. package/lib/chain/archiveStore/utils/archivePayloads.d.ts +7 -0
  37. package/lib/chain/archiveStore/utils/archivePayloads.d.ts.map +1 -0
  38. package/lib/chain/archiveStore/utils/archivePayloads.js +10 -0
  39. package/lib/chain/archiveStore/utils/archivePayloads.js.map +1 -0
  40. package/lib/chain/archiveStore/utils/updateBackfillRange.js +1 -1
  41. package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +1 -1
  42. package/lib/chain/blocks/blockInput/blockInput.d.ts +20 -2
  43. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  44. package/lib/chain/blocks/blockInput/blockInput.js +47 -0
  45. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  46. package/lib/chain/blocks/blockInput/types.d.ts +2 -1
  47. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  48. package/lib/chain/blocks/blockInput/types.js +1 -0
  49. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  50. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  51. package/lib/chain/blocks/importBlock.js +26 -5
  52. package/lib/chain/blocks/importBlock.js.map +1 -1
  53. package/lib/chain/blocks/index.d.ts.map +1 -1
  54. package/lib/chain/blocks/index.js +2 -1
  55. package/lib/chain/blocks/index.js.map +1 -1
  56. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  57. package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -0
  58. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  59. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +4 -0
  60. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  61. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -1
  62. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  63. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  64. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -1
  65. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  66. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  67. package/lib/chain/blocks/writeBlockInputToDb.js +3 -0
  68. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  69. package/lib/chain/bls/multithread/index.d.ts +3 -3
  70. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  71. package/lib/chain/bls/multithread/index.js +5 -5
  72. package/lib/chain/bls/multithread/index.js.map +1 -1
  73. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  74. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  75. package/lib/chain/bls/multithread/jobItem.js +2 -2
  76. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  77. package/lib/chain/bls/singleThread.d.ts +4 -4
  78. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  79. package/lib/chain/bls/singleThread.js +4 -4
  80. package/lib/chain/bls/singleThread.js.map +1 -1
  81. package/lib/chain/bls/utils.d.ts +2 -2
  82. package/lib/chain/bls/utils.d.ts.map +1 -1
  83. package/lib/chain/bls/utils.js +7 -4
  84. package/lib/chain/bls/utils.js.map +1 -1
  85. package/lib/chain/chain.d.ts +6 -9
  86. package/lib/chain/chain.d.ts.map +1 -1
  87. package/lib/chain/chain.js +38 -22
  88. package/lib/chain/chain.js.map +1 -1
  89. package/lib/chain/emitter.d.ts +5 -5
  90. package/lib/chain/emitter.d.ts.map +1 -1
  91. package/lib/chain/errors/blockError.d.ts +7 -1
  92. package/lib/chain/errors/blockError.d.ts.map +1 -1
  93. package/lib/chain/errors/blockError.js +2 -0
  94. package/lib/chain/errors/blockError.js.map +1 -1
  95. package/lib/chain/errors/executionPayloadEnvelope.d.ts +2 -2
  96. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  97. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  98. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  99. package/lib/chain/forkChoice/index.js +30 -24
  100. package/lib/chain/forkChoice/index.js.map +1 -1
  101. package/lib/chain/interface.d.ts +4 -6
  102. package/lib/chain/interface.d.ts.map +1 -1
  103. package/lib/chain/interface.js.map +1 -1
  104. package/lib/chain/lightClient/index.d.ts.map +1 -1
  105. package/lib/chain/lightClient/index.js +1 -1
  106. package/lib/chain/lightClient/index.js.map +1 -1
  107. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  108. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  109. package/lib/chain/options.d.ts.map +1 -1
  110. package/lib/chain/options.js.map +1 -1
  111. package/lib/chain/prepareNextSlot.js +3 -3
  112. package/lib/chain/prepareNextSlot.js.map +1 -1
  113. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +10 -2
  114. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  115. package/lib/chain/produceBlock/computeNewStateRoot.js +24 -2
  116. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  117. package/lib/chain/produceBlock/produceBlockBody.d.ts +22 -7
  118. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  119. package/lib/chain/produceBlock/produceBlockBody.js +109 -10
  120. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  121. package/lib/chain/regen/queued.d.ts.map +1 -1
  122. package/lib/chain/regen/queued.js +4 -1
  123. package/lib/chain/regen/queued.js.map +1 -1
  124. package/lib/chain/regen/regen.d.ts.map +1 -1
  125. package/lib/chain/regen/regen.js +5 -1
  126. package/lib/chain/regen/regen.js.map +1 -1
  127. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  128. package/lib/chain/seenCache/seenGossipBlockInput.js +15 -7
  129. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  130. package/lib/chain/validation/aggregateAndProof.js +1 -1
  131. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  132. package/lib/chain/validation/attestation.d.ts.map +1 -1
  133. package/lib/chain/validation/attestation.js +7 -4
  134. package/lib/chain/validation/attestation.js.map +1 -1
  135. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  136. package/lib/chain/validation/attesterSlashing.js +9 -2
  137. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  138. package/lib/chain/validation/blobSidecar.js +2 -2
  139. package/lib/chain/validation/blobSidecar.js.map +1 -1
  140. package/lib/chain/validation/block.d.ts.map +1 -1
  141. package/lib/chain/validation/block.js +33 -6
  142. package/lib/chain/validation/block.js.map +1 -1
  143. package/lib/chain/validation/dataColumnSidecar.d.ts +2 -2
  144. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  145. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  146. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  147. package/lib/chain/validation/executionPayloadBid.js +1 -2
  148. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  149. package/lib/chain/validation/executionPayloadEnvelope.js +6 -5
  150. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  151. package/lib/chain/validation/payloadAttestationMessage.js +9 -3
  152. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  153. package/lib/chain/validation/proposerSlashing.js +1 -1
  154. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  155. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  156. package/lib/db/beacon.d.ts +3 -1
  157. package/lib/db/beacon.d.ts.map +1 -1
  158. package/lib/db/beacon.js +5 -1
  159. package/lib/db/beacon.js.map +1 -1
  160. package/lib/db/buckets.d.ts +3 -1
  161. package/lib/db/buckets.d.ts.map +1 -1
  162. package/lib/db/buckets.js +2 -0
  163. package/lib/db/buckets.js.map +1 -1
  164. package/lib/db/interface.d.ts +3 -1
  165. package/lib/db/interface.d.ts.map +1 -1
  166. package/lib/db/repositories/blockArchive.d.ts.map +1 -1
  167. package/lib/db/repositories/blockArchive.js +1 -2
  168. package/lib/db/repositories/blockArchive.js.map +1 -1
  169. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  170. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  171. package/lib/db/repositories/dataColumnSidecar.d.ts +5 -3
  172. package/lib/db/repositories/dataColumnSidecar.d.ts.map +1 -1
  173. package/lib/db/repositories/dataColumnSidecar.js +14 -1
  174. package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
  175. package/lib/db/repositories/dataColumnSidecarArchive.d.ts +5 -3
  176. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
  177. package/lib/db/repositories/dataColumnSidecarArchive.js +14 -1
  178. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  179. package/lib/db/repositories/executionPayloadEnvelope.d.ts +19 -0
  180. package/lib/db/repositories/executionPayloadEnvelope.d.ts.map +1 -0
  181. package/lib/db/repositories/executionPayloadEnvelope.js +22 -0
  182. package/lib/db/repositories/executionPayloadEnvelope.js.map +1 -0
  183. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts +18 -0
  184. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts.map +1 -0
  185. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +28 -0
  186. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -0
  187. package/lib/db/repositories/index.d.ts +2 -0
  188. package/lib/db/repositories/index.d.ts.map +1 -1
  189. package/lib/db/repositories/index.js +2 -0
  190. package/lib/db/repositories/index.js.map +1 -1
  191. package/lib/execution/engine/http.d.ts +1 -0
  192. package/lib/execution/engine/http.d.ts.map +1 -1
  193. package/lib/execution/engine/http.js +3 -0
  194. package/lib/execution/engine/http.js.map +1 -1
  195. package/lib/execution/engine/interface.d.ts +3 -25
  196. package/lib/execution/engine/interface.d.ts.map +1 -1
  197. package/lib/execution/engine/interface.js +2 -20
  198. package/lib/execution/engine/interface.js.map +1 -1
  199. package/lib/metrics/metrics/beacon.d.ts +1 -0
  200. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  201. package/lib/metrics/metrics/beacon.js +5 -0
  202. package/lib/metrics/metrics/beacon.js.map +1 -1
  203. package/lib/metrics/metrics/lodestar.d.ts +8 -0
  204. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  205. package/lib/metrics/metrics/lodestar.js +14 -0
  206. package/lib/metrics/metrics/lodestar.js.map +1 -1
  207. package/lib/metrics/metrics.d.ts.map +1 -1
  208. package/lib/metrics/metrics.js +8 -3
  209. package/lib/metrics/metrics.js.map +1 -1
  210. package/lib/monitoring/service.d.ts +2 -2
  211. package/lib/monitoring/service.d.ts.map +1 -1
  212. package/lib/monitoring/service.js +3 -2
  213. package/lib/monitoring/service.js.map +1 -1
  214. package/lib/network/core/networkCore.d.ts +3 -3
  215. package/lib/network/core/networkCore.d.ts.map +1 -1
  216. package/lib/network/core/networkCore.js.map +1 -1
  217. package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -3
  218. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  219. package/lib/network/core/types.d.ts +2 -2
  220. package/lib/network/core/types.d.ts.map +1 -1
  221. package/lib/network/events.d.ts +2 -1
  222. package/lib/network/events.d.ts.map +1 -1
  223. package/lib/network/events.js.map +1 -1
  224. package/lib/network/gossip/encoding.d.ts +3 -3
  225. package/lib/network/gossip/encoding.d.ts.map +1 -1
  226. package/lib/network/gossip/encoding.js.map +1 -1
  227. package/lib/network/gossip/gossipsub.d.ts +13 -4
  228. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  229. package/lib/network/gossip/gossipsub.js +47 -20
  230. package/lib/network/gossip/gossipsub.js.map +1 -1
  231. package/lib/network/gossip/interface.d.ts +6 -6
  232. package/lib/network/gossip/interface.d.ts.map +1 -1
  233. package/lib/network/gossip/scoringParameters.d.ts +1 -1
  234. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  235. package/lib/network/gossip/scoringParameters.js +1 -1
  236. package/lib/network/gossip/scoringParameters.js.map +1 -1
  237. package/lib/network/gossip/topic.d.ts +114 -65
  238. package/lib/network/gossip/topic.d.ts.map +1 -1
  239. package/lib/network/gossip/topic.js +2 -2
  240. package/lib/network/gossip/topic.js.map +1 -1
  241. package/lib/network/interface.d.ts +6 -5
  242. package/lib/network/interface.d.ts.map +1 -1
  243. package/lib/network/libp2p/index.d.ts +1 -1
  244. package/lib/network/libp2p/index.d.ts.map +1 -1
  245. package/lib/network/libp2p/index.js +7 -2
  246. package/lib/network/libp2p/index.js.map +1 -1
  247. package/lib/network/network.d.ts +5 -4
  248. package/lib/network/network.d.ts.map +1 -1
  249. package/lib/network/network.js +10 -1
  250. package/lib/network/network.js.map +1 -1
  251. package/lib/network/options.d.ts.map +1 -1
  252. package/lib/network/options.js +3 -0
  253. package/lib/network/options.js.map +1 -1
  254. package/lib/network/peers/datastore.d.ts +7 -5
  255. package/lib/network/peers/datastore.d.ts.map +1 -1
  256. package/lib/network/peers/datastore.js +10 -10
  257. package/lib/network/peers/datastore.js.map +1 -1
  258. package/lib/network/peers/peerManager.d.ts +3 -0
  259. package/lib/network/peers/peerManager.d.ts.map +1 -1
  260. package/lib/network/peers/peerManager.js +103 -53
  261. package/lib/network/peers/peerManager.js.map +1 -1
  262. package/lib/network/peers/utils/prioritizePeers.d.ts +3 -3
  263. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  264. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  265. package/lib/network/processor/gossipHandlers.js +9 -2
  266. package/lib/network/processor/gossipHandlers.js.map +1 -1
  267. package/lib/network/processor/gossipValidatorFn.js +1 -1
  268. package/lib/network/processor/types.d.ts +1 -1
  269. package/lib/network/processor/types.d.ts.map +1 -1
  270. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +1 -1
  271. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  272. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  273. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  274. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.d.ts.map +1 -1
  275. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js +7 -1
  276. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js.map +1 -1
  277. package/lib/network/reqresp/score.d.ts.map +1 -1
  278. package/lib/network/reqresp/score.js +0 -1
  279. package/lib/network/reqresp/score.js.map +1 -1
  280. package/lib/network/util.js +2 -2
  281. package/lib/network/util.js.map +1 -1
  282. package/lib/node/nodejs.d.ts +3 -5
  283. package/lib/node/nodejs.d.ts.map +1 -1
  284. package/lib/node/nodejs.js +6 -4
  285. package/lib/node/nodejs.js.map +1 -1
  286. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  287. package/lib/sync/utils/downloadByRange.js +3 -9
  288. package/lib/sync/utils/downloadByRange.js.map +1 -1
  289. package/lib/sync/utils/downloadByRoot.d.ts +1 -1
  290. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  291. package/lib/sync/utils/downloadByRoot.js +4 -4
  292. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  293. package/lib/util/blobs.d.ts +2 -2
  294. package/lib/util/blobs.d.ts.map +1 -1
  295. package/lib/util/blobs.js.map +1 -1
  296. package/lib/util/clock.d.ts +6 -0
  297. package/lib/util/clock.d.ts.map +1 -1
  298. package/lib/util/clock.js +9 -3
  299. package/lib/util/clock.js.map +1 -1
  300. package/lib/util/dataColumns.d.ts +15 -2
  301. package/lib/util/dataColumns.d.ts.map +1 -1
  302. package/lib/util/dataColumns.js +40 -5
  303. package/lib/util/dataColumns.js.map +1 -1
  304. package/lib/util/multifork.d.ts +8 -0
  305. package/lib/util/multifork.d.ts.map +1 -1
  306. package/lib/util/multifork.js +37 -0
  307. package/lib/util/multifork.js.map +1 -1
  308. package/lib/util/serializedCache.d.ts +5 -0
  309. package/lib/util/serializedCache.d.ts.map +1 -1
  310. package/lib/util/serializedCache.js +5 -0
  311. package/lib/util/serializedCache.js.map +1 -1
  312. package/package.json +39 -42
  313. package/src/api/impl/beacon/blocks/index.ts +147 -3
  314. package/src/api/impl/beacon/state/index.ts +8 -8
  315. package/src/api/impl/beacon/state/utils.ts +15 -29
  316. package/src/api/impl/debug/index.ts +9 -5
  317. package/src/api/impl/lightclient/index.ts +19 -2
  318. package/src/api/impl/node/index.ts +22 -1
  319. package/src/api/impl/node/utils.ts +3 -3
  320. package/src/api/impl/validator/index.ts +153 -17
  321. package/src/chain/archiveStore/archiveStore.ts +10 -0
  322. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -11
  323. package/src/chain/archiveStore/historicalState/worker.ts +3 -3
  324. package/src/chain/archiveStore/utils/archivePayloads.ts +15 -0
  325. package/src/chain/archiveStore/utils/updateBackfillRange.ts +1 -1
  326. package/src/chain/blocks/blockInput/blockInput.ts +68 -3
  327. package/src/chain/blocks/blockInput/types.ts +1 -0
  328. package/src/chain/blocks/importBlock.ts +34 -6
  329. package/src/chain/blocks/index.ts +2 -1
  330. package/src/chain/blocks/verifyBlocksDataAvailability.ts +3 -0
  331. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
  332. package/src/chain/blocks/verifyBlocksSanityChecks.ts +7 -2
  333. package/src/chain/blocks/writeBlockInputToDb.ts +3 -0
  334. package/src/chain/bls/multithread/index.ts +7 -7
  335. package/src/chain/bls/multithread/jobItem.ts +3 -3
  336. package/src/chain/bls/singleThread.ts +5 -5
  337. package/src/chain/bls/utils.ts +8 -5
  338. package/src/chain/chain.ts +57 -32
  339. package/src/chain/emitter.ts +5 -5
  340. package/src/chain/errors/blockError.ts +4 -1
  341. package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
  342. package/src/chain/forkChoice/index.ts +39 -21
  343. package/src/chain/interface.ts +4 -11
  344. package/src/chain/lightClient/index.ts +4 -1
  345. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  346. package/src/chain/options.ts +1 -0
  347. package/src/chain/prepareNextSlot.ts +5 -5
  348. package/src/chain/produceBlock/computeNewStateRoot.ts +35 -3
  349. package/src/chain/produceBlock/produceBlockBody.ts +162 -13
  350. package/src/chain/regen/queued.ts +7 -2
  351. package/src/chain/regen/regen.ts +8 -2
  352. package/src/chain/seenCache/seenGossipBlockInput.ts +16 -7
  353. package/src/chain/validation/aggregateAndProof.ts +1 -1
  354. package/src/chain/validation/attestation.ts +7 -4
  355. package/src/chain/validation/attesterSlashing.ts +10 -1
  356. package/src/chain/validation/blobSidecar.ts +2 -2
  357. package/src/chain/validation/block.ts +40 -7
  358. package/src/chain/validation/dataColumnSidecar.ts +3 -6
  359. package/src/chain/validation/executionPayloadBid.ts +1 -2
  360. package/src/chain/validation/executionPayloadEnvelope.ts +6 -5
  361. package/src/chain/validation/payloadAttestationMessage.ts +11 -4
  362. package/src/chain/validation/proposerSlashing.ts +1 -1
  363. package/src/chain/validation/syncCommitteeContributionAndProof.ts +1 -1
  364. package/src/db/beacon.ts +8 -0
  365. package/src/db/buckets.ts +3 -0
  366. package/src/db/interface.ts +5 -0
  367. package/src/db/repositories/blockArchive.ts +1 -2
  368. package/src/db/repositories/dataColumnSidecar.ts +18 -3
  369. package/src/db/repositories/dataColumnSidecarArchive.ts +18 -3
  370. package/src/db/repositories/executionPayloadEnvelope.ts +26 -0
  371. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +32 -0
  372. package/src/db/repositories/index.ts +2 -0
  373. package/src/execution/engine/http.ts +3 -0
  374. package/src/execution/engine/interface.ts +3 -27
  375. package/src/metrics/metrics/beacon.ts +5 -0
  376. package/src/metrics/metrics/lodestar.ts +14 -0
  377. package/src/metrics/metrics.ts +8 -3
  378. package/src/monitoring/service.ts +3 -2
  379. package/src/network/core/networkCore.ts +3 -3
  380. package/src/network/core/networkCoreWorkerHandler.ts +3 -3
  381. package/src/network/core/types.ts +2 -2
  382. package/src/network/events.ts +2 -1
  383. package/src/network/gossip/encoding.ts +3 -3
  384. package/src/network/gossip/gossipsub.ts +86 -25
  385. package/src/network/gossip/interface.ts +6 -6
  386. package/src/network/gossip/scoringParameters.ts +4 -4
  387. package/src/network/gossip/topic.ts +2 -1
  388. package/src/network/interface.ts +7 -4
  389. package/src/network/libp2p/index.ts +8 -3
  390. package/src/network/network.ts +24 -6
  391. package/src/network/options.ts +3 -0
  392. package/src/network/peers/datastore.ts +13 -10
  393. package/src/network/peers/peerManager.ts +118 -54
  394. package/src/network/peers/utils/prioritizePeers.ts +3 -3
  395. package/src/network/processor/gossipHandlers.ts +19 -4
  396. package/src/network/processor/gossipValidatorFn.ts +1 -1
  397. package/src/network/processor/types.ts +1 -1
  398. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +1 -1
  399. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  400. package/src/network/reqresp/handlers/lightClientUpdatesByRange.ts +6 -1
  401. package/src/network/reqresp/score.ts +0 -1
  402. package/src/network/util.ts +2 -2
  403. package/src/node/nodejs.ts +8 -9
  404. package/src/sync/utils/downloadByRange.ts +3 -15
  405. package/src/sync/utils/downloadByRoot.ts +5 -11
  406. package/src/util/blobs.ts +3 -3
  407. package/src/util/clock.ts +9 -4
  408. package/src/util/dataColumns.ts +54 -5
  409. package/src/util/multifork.ts +45 -0
  410. package/src/util/serializedCache.ts +5 -0
  411. package/src/util/workerEvents.ts +1 -1
@@ -1,18 +1,26 @@
1
1
  import path from "node:path";
2
2
  import {PrivateKey} from "@libp2p/interface";
3
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
4
3
  import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz";
5
4
  import {BeaconConfig} from "@lodestar/config";
6
5
  import {CheckpointWithHex, IForkChoice, ProtoBlock, UpdateHeadOpt} from "@lodestar/fork-choice";
7
6
  import {LoggerNode} from "@lodestar/logger/node";
8
- import {EFFECTIVE_BALANCE_INCREMENT, GENESIS_SLOT, SLOTS_PER_EPOCH, isForkPostElectra} from "@lodestar/params";
7
+ import {
8
+ BUILDER_INDEX_SELF_BUILD,
9
+ EFFECTIVE_BALANCE_INCREMENT,
10
+ ForkPostFulu,
11
+ GENESIS_SLOT,
12
+ SLOTS_PER_EPOCH,
13
+ isForkPostElectra,
14
+ isForkPostGloas,
15
+ } from "@lodestar/params";
9
16
  import {
10
17
  BeaconStateAllForks,
11
18
  BeaconStateElectra,
12
19
  CachedBeaconStateAllForks,
20
+ CachedBeaconStateGloas,
13
21
  EffectiveBalanceIncrements,
14
22
  EpochShuffling,
15
- Index2PubkeyCache,
23
+ PubkeyCache,
16
24
  computeAnchorCheckpoint,
17
25
  computeAttestationsRewards,
18
26
  computeBlockRewards,
@@ -28,6 +36,7 @@ import {
28
36
  BeaconBlock,
29
37
  BlindedBeaconBlock,
30
38
  BlindedBeaconBlockBody,
39
+ DataColumnSidecars,
31
40
  Epoch,
32
41
  Root,
33
42
  RootHex,
@@ -38,7 +47,7 @@ import {
38
47
  ValidatorIndex,
39
48
  Wei,
40
49
  deneb,
41
- fulu,
50
+ gloas,
42
51
  isBlindedBeaconBlock,
43
52
  phase0,
44
53
  rewards,
@@ -87,8 +96,8 @@ import {
87
96
  } from "./opPools/index.js";
88
97
  import {IChainOptions} from "./options.js";
89
98
  import {PrepareNextSlotScheduler} from "./prepareNextSlot.js";
90
- import {computeNewStateRoot} from "./produceBlock/computeNewStateRoot.js";
91
- import {AssembledBlockType, BlockType, ProduceResult} from "./produceBlock/index.js";
99
+ import {computeEnvelopeStateRoot, computeNewStateRoot} from "./produceBlock/computeNewStateRoot.js";
100
+ import {AssembledBlockType, BlockType, ProduceFullGloas, ProduceResult} from "./produceBlock/index.js";
92
101
  import {BlockAttributes, produceBlockBody, produceCommonBlockBody} from "./produceBlock/produceBlockBody.js";
93
102
  import {QueuedStateRegenerator, RegenCaller} from "./regen/index.js";
94
103
  import {ReprocessController} from "./reprocess.js";
@@ -182,8 +191,7 @@ export class BeaconChain implements IBeaconChain {
182
191
  readonly seenBlockAttesters = new SeenBlockAttesters();
183
192
 
184
193
  // Global state caches
185
- readonly pubkey2index: PubkeyIndexMap;
186
- readonly index2pubkey: Index2PubkeyCache;
194
+ readonly pubkeyCache: PubkeyCache;
187
195
 
188
196
  readonly beaconProposerCache: BeaconProposerCache;
189
197
  readonly checkpointBalancesCache: CheckpointBalancesCache;
@@ -229,8 +237,7 @@ export class BeaconChain implements IBeaconChain {
229
237
  {
230
238
  privateKey,
231
239
  config,
232
- pubkey2index,
233
- index2pubkey,
240
+ pubkeyCache,
234
241
  db,
235
242
  dbName,
236
243
  dataDir,
@@ -246,8 +253,7 @@ export class BeaconChain implements IBeaconChain {
246
253
  }: {
247
254
  privateKey: PrivateKey;
248
255
  config: BeaconConfig;
249
- pubkey2index: PubkeyIndexMap;
250
- index2pubkey: Index2PubkeyCache;
256
+ pubkeyCache: PubkeyCache;
251
257
  db: IBeaconDb;
252
258
  dbName: string;
253
259
  dataDir: string;
@@ -279,8 +285,8 @@ export class BeaconChain implements IBeaconChain {
279
285
  const emitter = new ChainEventEmitter();
280
286
  // by default, verify signatures on both main threads and worker threads
281
287
  const bls = opts.blsVerifyAllMainThread
282
- ? new BlsSingleThreadVerifier({metrics, index2pubkey})
283
- : new BlsMultiThreadWorkerPool(opts, {logger, metrics, index2pubkey});
288
+ ? new BlsSingleThreadVerifier({metrics, pubkeyCache})
289
+ : new BlsMultiThreadWorkerPool(opts, {logger, metrics, pubkeyCache});
284
290
 
285
291
  if (!clock) clock = new Clock({config, genesisTime: this.genesisTime, signal});
286
292
 
@@ -336,8 +342,7 @@ export class BeaconChain implements IBeaconChain {
336
342
  ]);
337
343
 
338
344
  // Global cache of validators pubkey/index mapping
339
- this.pubkey2index = pubkey2index;
340
- this.index2pubkey = index2pubkey;
345
+ this.pubkeyCache = pubkeyCache;
341
346
 
342
347
  const fileDataStore = opts.nHistoricalStatesFileDataStore ?? true;
343
348
  const blockStateCache = new FIFOBlockStateCache(this.opts, {metrics});
@@ -595,7 +600,7 @@ export class BeaconChain implements IBeaconChain {
595
600
  ): Promise<{state: CachedBeaconStateAllForks | Uint8Array; executionOptimistic: boolean; finalized: boolean} | null> {
596
601
  if (opts?.allowRegen) {
597
602
  const state = await this.regen.getState(stateRoot, RegenCaller.restApi);
598
- const block = this.forkChoice.getBlock(state.latestBlockHeader.hashTreeRoot());
603
+ const block = this.forkChoice.getBlockDefaultStatus(state.latestBlockHeader.hashTreeRoot());
599
604
  const finalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
600
605
  return {
601
606
  state,
@@ -611,7 +616,7 @@ export class BeaconChain implements IBeaconChain {
611
616
  // TODO: This is very inneficient for debug requests of serialized content, since it deserializes to serialize again
612
617
  const cachedStateCtx = this.regen.getStateSync(stateRoot);
613
618
  if (cachedStateCtx) {
614
- const block = this.forkChoice.getBlock(cachedStateCtx.latestBlockHeader.hashTreeRoot());
619
+ const block = this.forkChoice.getBlockDefaultStatus(cachedStateCtx.latestBlockHeader.hashTreeRoot());
615
620
  const finalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
616
621
  return {
617
622
  state: cachedStateCtx,
@@ -645,7 +650,7 @@ export class BeaconChain implements IBeaconChain {
645
650
  // finalized or justified checkpoint states maynot be available with PersistentCheckpointStateCache, use getCheckpointStateOrBytes() api to get Uint8Array
646
651
  const cachedStateCtx = this.regen.getCheckpointStateSync(checkpoint);
647
652
  if (cachedStateCtx) {
648
- const block = this.forkChoice.getBlock(cachedStateCtx.latestBlockHeader.hashTreeRoot());
653
+ const block = this.forkChoice.getBlockDefaultStatus(cachedStateCtx.latestBlockHeader.hashTreeRoot());
649
654
  const finalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
650
655
  return {
651
656
  state: cachedStateCtx,
@@ -662,7 +667,7 @@ export class BeaconChain implements IBeaconChain {
662
667
  ): Promise<{state: CachedBeaconStateAllForks | Uint8Array; executionOptimistic: boolean; finalized: boolean} | null> {
663
668
  const cachedStateCtx = await this.regen.getCheckpointStateOrBytes(checkpoint);
664
669
  if (cachedStateCtx) {
665
- const block = this.forkChoice.getBlock(checkpoint.root);
670
+ const block = this.forkChoice.getBlockDefaultStatus(checkpoint.root);
666
671
  const finalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
667
672
  return {
668
673
  state: cachedStateCtx,
@@ -706,7 +711,7 @@ export class BeaconChain implements IBeaconChain {
706
711
  async getBlockByRoot(
707
712
  root: string
708
713
  ): Promise<{block: SignedBeaconBlock; executionOptimistic: boolean; finalized: boolean} | null> {
709
- const block = this.forkChoice.getBlockHex(root);
714
+ const block = this.forkChoice.getBlockHexDefaultStatus(root);
710
715
  if (block) {
711
716
  // Block found in fork-choice.
712
717
  // It may be in the block input cache, awaiting full DA reconstruction, check there first
@@ -730,7 +735,7 @@ export class BeaconChain implements IBeaconChain {
730
735
  async getSerializedBlockByRoot(
731
736
  root: string
732
737
  ): Promise<{block: Uint8Array; executionOptimistic: boolean; finalized: boolean; slot: Slot} | null> {
733
- const block = this.forkChoice.getBlockHex(root);
738
+ const block = this.forkChoice.getBlockHexDefaultStatus(root);
734
739
  if (block) {
735
740
  // Block found in fork-choice.
736
741
  // It may be in the block input cache, awaiting full DA reconstruction, check there first
@@ -808,7 +813,7 @@ export class BeaconChain implements IBeaconChain {
808
813
  return null;
809
814
  }
810
815
 
811
- async getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<fulu.DataColumnSidecars> {
816
+ async getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<DataColumnSidecars> {
812
817
  const blockInput = this.seenBlockInputCache.get(blockRootHex);
813
818
  if (blockInput) {
814
819
  if (!isBlockInputColumns(blockInput)) {
@@ -818,10 +823,10 @@ export class BeaconChain implements IBeaconChain {
818
823
  }
819
824
  const sidecarsUnfinalized = await this.db.dataColumnSidecar.values(fromHex(blockRootHex));
820
825
  if (sidecarsUnfinalized.length > 0) {
821
- return sidecarsUnfinalized;
826
+ return sidecarsUnfinalized as DataColumnSidecars;
822
827
  }
823
828
  const sidecarsFinalized = await this.db.dataColumnSidecarArchive.values(blockSlot);
824
- return sidecarsFinalized;
829
+ return sidecarsFinalized as DataColumnSidecars;
825
830
  }
826
831
 
827
832
  async getSerializedDataColumnSidecars(
@@ -843,7 +848,7 @@ export class BeaconChain implements IBeaconChain {
843
848
  if (serialized) {
844
849
  return serialized;
845
850
  }
846
- return ssz.fulu.DataColumnSidecar.serialize(sidecar);
851
+ return sszTypesFor(blockInput.forkName as ForkPostFulu).DataColumnSidecar.serialize(sidecar);
847
852
  });
848
853
  }
849
854
  const sidecarsUnfinalized = await this.db.dataColumnSidecar.getManyBinary(fromHex(blockRootHex), indices);
@@ -902,6 +907,7 @@ export class BeaconChain implements IBeaconChain {
902
907
  consensusBlockValue: Wei;
903
908
  shouldOverrideBuilder?: boolean;
904
909
  }> {
910
+ const fork = this.config.getForkName(slot);
905
911
  const state = await this.regen.getBlockSlotState(
906
912
  parentBlock,
907
913
  slot,
@@ -909,7 +915,7 @@ export class BeaconChain implements IBeaconChain {
909
915
  RegenCaller.produceBlock
910
916
  );
911
917
  const proposerIndex = state.epochCtx.getBeaconProposer(slot);
912
- const proposerPubKey = this.index2pubkey[proposerIndex].toBytes();
918
+ const proposerPubKey = this.pubkeyCache.getOrThrow(proposerIndex).toBytes();
913
919
 
914
920
  const {body, produceResult, executionPayloadValue, shouldOverrideBuilder} = await produceBlockBody.call(
915
921
  this,
@@ -930,7 +936,7 @@ export class BeaconChain implements IBeaconChain {
930
936
  // The hashtree root computed here for debug log will get cached and hence won't introduce additional delays
931
937
  const bodyRoot =
932
938
  produceResult.type === BlockType.Full
933
- ? this.config.getForkTypes(slot).BeaconBlockBody.hashTreeRoot(body)
939
+ ? sszTypesFor(fork).BeaconBlockBody.hashTreeRoot(body)
934
940
  : this.config
935
941
  .getPostBellatrixForkTypes(slot)
936
942
  .BlindedBeaconBlockBody.hashTreeRoot(body as BlindedBeaconBlockBody);
@@ -948,14 +954,33 @@ export class BeaconChain implements IBeaconChain {
948
954
  body,
949
955
  } as AssembledBlockType<T>;
950
956
 
951
- const {newStateRoot, proposerReward} = computeNewStateRoot(this.metrics, state, block);
957
+ const {newStateRoot, proposerReward, postState} = computeNewStateRoot(this.metrics, state, block);
952
958
  block.stateRoot = newStateRoot;
953
959
  const blockRoot =
954
960
  produceResult.type === BlockType.Full
955
- ? this.config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block)
961
+ ? sszTypesFor(fork).BeaconBlock.hashTreeRoot(block)
956
962
  : this.config.getPostBellatrixForkTypes(slot).BlindedBeaconBlock.hashTreeRoot(block as BlindedBeaconBlock);
957
963
  const blockRootHex = toRootHex(blockRoot);
958
964
 
965
+ if (isForkPostGloas(fork)) {
966
+ // TODO GLOAS: we should retire BlockType post-gloas, may need a new enum for self vs non-self built
967
+ if (produceResult.type !== BlockType.Full) {
968
+ throw Error(`Unexpected block type=${produceResult.type} for post-gloas fork=${fork}`);
969
+ }
970
+
971
+ const gloasResult = produceResult as ProduceFullGloas;
972
+ const envelope: gloas.ExecutionPayloadEnvelope = {
973
+ payload: gloasResult.executionPayload,
974
+ executionRequests: gloasResult.executionRequests,
975
+ builderIndex: BUILDER_INDEX_SELF_BUILD,
976
+ beaconBlockRoot: blockRoot,
977
+ slot,
978
+ stateRoot: ZERO_HASH,
979
+ };
980
+ const envelopeStateRoot = computeEnvelopeStateRoot(this.metrics, postState as CachedBeaconStateGloas, envelope);
981
+ gloasResult.envelopeStateRoot = envelopeStateRoot;
982
+ }
983
+
959
984
  // Track the produced block for consensus broadcast validations, later validation, etc.
960
985
  this.blockProductionCache.set(blockRootHex, produceResult);
961
986
  this.metrics?.blockProductionCacheSize.set(this.blockProductionCache.size);
@@ -1506,7 +1531,7 @@ export class BeaconChain implements IBeaconChain {
1506
1531
  throw Error(`State is not in cache for slot ${slot}`);
1507
1532
  }
1508
1533
 
1509
- const rewards = await computeAttestationsRewards(this.config, this.pubkey2index, cachedState, validatorIds);
1534
+ const rewards = await computeAttestationsRewards(this.config, this.pubkeyCache, cachedState, validatorIds);
1510
1535
 
1511
1536
  return {rewards, executionOptimistic, finalized};
1512
1537
  }
@@ -1523,6 +1548,6 @@ export class BeaconChain implements IBeaconChain {
1523
1548
 
1524
1549
  preState = processSlots(preState, block.slot); // Dial preState's slot to block.slot
1525
1550
 
1526
- return computeSyncCommitteeRewards(this.config, this.index2pubkey, block, preState, validatorIds);
1551
+ return computeSyncCommitteeRewards(this.config, this.pubkeyCache, block, preState, validatorIds);
1527
1552
  }
1528
1553
  }
@@ -1,9 +1,9 @@
1
1
  import {EventEmitter} from "node:events";
2
2
  import {StrictEventEmitter} from "strict-event-emitter-types";
3
3
  import {routes} from "@lodestar/api";
4
- import {CheckpointWithHex} from "@lodestar/fork-choice";
4
+ import {CheckpointWithPayload} from "@lodestar/fork-choice";
5
5
  import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
6
- import {RootHex, deneb, fulu, phase0} from "@lodestar/types";
6
+ import {DataColumnSidecars, RootHex, deneb, phase0} from "@lodestar/types";
7
7
  import {PeerIdStr} from "../util/peerId.js";
8
8
  import {BlockInputSource, IBlockInput} from "./blocks/blockInput/types.js";
9
9
 
@@ -83,12 +83,12 @@ export type ChainEventData = {
83
83
  export type IChainEvents = ApiEvents & {
84
84
  [ChainEvent.checkpoint]: (checkpoint: phase0.Checkpoint, state: CachedBeaconStateAllForks) => void;
85
85
 
86
- [ChainEvent.forkChoiceJustified]: (checkpoint: CheckpointWithHex) => void;
87
- [ChainEvent.forkChoiceFinalized]: (checkpoint: CheckpointWithHex) => void;
86
+ [ChainEvent.forkChoiceJustified]: (checkpoint: CheckpointWithPayload) => void;
87
+ [ChainEvent.forkChoiceFinalized]: (checkpoint: CheckpointWithPayload) => void;
88
88
 
89
89
  [ChainEvent.updateTargetCustodyGroupCount]: (targetGroupCount: number) => void;
90
90
 
91
- [ChainEvent.publishDataColumns]: (sidecars: fulu.DataColumnSidecar[]) => void;
91
+ [ChainEvent.publishDataColumns]: (sidecars: DataColumnSidecars) => void;
92
92
 
93
93
  [ChainEvent.publishBlobSidecars]: (sidecars: deneb.BlobSidecar[]) => void;
94
94
 
@@ -68,6 +68,8 @@ export enum BlockErrorCode {
68
68
  DATA_UNAVAILABLE = "BLOCK_ERROR_DATA_UNAVAILABLE",
69
69
  /** Block contains too many kzg commitments */
70
70
  TOO_MANY_KZG_COMMITMENTS = "BLOCK_ERROR_TOO_MANY_KZG_COMMITMENTS",
71
+ /** Bid parent block root does not match block parent root */
72
+ BID_PARENT_ROOT_MISMATCH = "BLOCK_ERROR_BID_PARENT_ROOT_MISMATCH",
71
73
  }
72
74
 
73
75
  type ExecutionErrorStatus = Exclude<
@@ -111,7 +113,8 @@ export type BlockErrorType =
111
113
  | {code: BlockErrorCode.TRANSACTIONS_TOO_BIG; size: number; max: number}
112
114
  | {code: BlockErrorCode.EXECUTION_ENGINE_ERROR; execStatus: ExecutionErrorStatus; errorMessage: string}
113
115
  | {code: BlockErrorCode.DATA_UNAVAILABLE}
114
- | {code: BlockErrorCode.TOO_MANY_KZG_COMMITMENTS; blobKzgCommitmentsLen: number; commitmentLimit: number};
116
+ | {code: BlockErrorCode.TOO_MANY_KZG_COMMITMENTS; blobKzgCommitmentsLen: number; commitmentLimit: number}
117
+ | {code: BlockErrorCode.BID_PARENT_ROOT_MISMATCH; bidParentRoot: RootHex; blockParentRoot: RootHex};
115
118
 
116
119
  export class BlockGossipError extends GossipActionError<BlockErrorType> {}
117
120
 
@@ -25,9 +25,13 @@ export type ExecutionPayloadEnvelopeErrorType =
25
25
  | {
26
26
  code: ExecutionPayloadEnvelopeErrorCode.BUILDER_INDEX_MISMATCH;
27
27
  envelopeBuilderIndex: BuilderIndex;
28
- bidBuilderIndex: BuilderIndex;
28
+ bidBuilderIndex: BuilderIndex | null;
29
+ }
30
+ | {
31
+ code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH;
32
+ envelopeBlockHash: RootHex;
33
+ bidBlockHash: RootHex | null;
29
34
  }
30
- | {code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH; envelopeBlockHash: RootHex; bidBlockHash: RootHex}
31
35
  | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE}
32
36
  | {code: ExecutionPayloadEnvelopeErrorCode.CACHE_FAIL; blockRoot: RootHex};
33
37
 
@@ -4,9 +4,11 @@ import {
4
4
  ForkChoice,
5
5
  ForkChoiceStore,
6
6
  JustifiedBalancesGetter,
7
+ PayloadStatus,
7
8
  ProtoArray,
8
9
  ProtoBlock,
9
10
  ForkChoiceOpts as RawForkChoiceOpts,
11
+ getCheckpointPayloadStatus,
10
12
  } from "@lodestar/fork-choice";
11
13
  import {ZERO_HASH_HEX} from "@lodestar/params";
12
14
  import {
@@ -104,6 +106,14 @@ export function initializeForkChoiceFromFinalizedState(
104
106
  // production code use ForkChoice constructor directly
105
107
  const forkchoiceConstructor = opts.forkchoiceConstructor ?? ForkChoice;
106
108
 
109
+ const isForkPostGloas = (state as CachedBeaconStateGloas).latestBlockHash !== undefined;
110
+
111
+ // Determine justified checkpoint payload status
112
+ const justifiedPayloadStatus = getCheckpointPayloadStatus(state, justifiedCheckpoint.epoch);
113
+
114
+ // Determine finalized checkpoint payload status
115
+ const finalizedPayloadStatus = getCheckpointPayloadStatus(state, finalizedCheckpoint.epoch);
116
+
107
117
  return new forkchoiceConstructor(
108
118
  config,
109
119
 
@@ -113,6 +123,8 @@ export function initializeForkChoiceFromFinalizedState(
113
123
  finalizedCheckpoint,
114
124
  justifiedBalances,
115
125
  justifiedBalancesGetter,
126
+ justifiedPayloadStatus,
127
+ finalizedPayloadStatus,
116
128
  {
117
129
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
118
130
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -145,15 +157,12 @@ export function initializeForkChoiceFromFinalizedState(
145
157
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
146
158
 
147
159
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
148
- ...(computeEpochAtSlot(blockHeader.slot) < state.config.GLOAS_FORK_EPOCH
149
- ? {
150
- builderIndex: undefined,
151
- blockHashHex: undefined,
152
- }
153
- : {
154
- builderIndex: (state as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex,
155
- blockHashHex: toRootHex((state as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash),
156
- }),
160
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
161
+ builderIndex: isForkPostGloas ? (state as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex : null,
162
+ blockHashFromBid: isForkPostGloas
163
+ ? toRootHex((state as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash)
164
+ : null,
165
+ parentBlockHash: isForkPostGloas ? toRootHex((state as CachedBeaconStateGloas).latestBlockHash) : null,
157
166
  },
158
167
  currentSlot
159
168
  ),
@@ -196,12 +205,22 @@ export function initializeForkChoiceFromUnfinalizedState(
196
205
 
197
206
  // this is not the justified state, but there is no other ways to get justified balances
198
207
  const justifiedBalances = getEffectiveBalanceIncrementsZeroInactive(unfinalizedState);
208
+
209
+ const isForkPostGloas = (unfinalizedState as CachedBeaconStateGloas).latestBlockHash !== undefined;
210
+
211
+ // For unfinalized state, use getCheckpointPayloadStatus to determine the correct status.
212
+ // It checks state.execution_payload_availability to determine EMPTY vs FULL.
213
+ const justifiedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, justifiedCheckpoint.epoch);
214
+ const finalizedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, finalizedCheckpoint.epoch);
215
+
199
216
  const store = new ForkChoiceStore(
200
217
  currentSlot,
201
218
  justifiedCheckpoint,
202
219
  finalizedCheckpoint,
203
220
  justifiedBalances,
204
221
  justifiedBalancesGetter,
222
+ justifiedPayloadStatus,
223
+ finalizedPayloadStatus,
205
224
  {
206
225
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
207
226
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -235,15 +254,14 @@ export function initializeForkChoiceFromUnfinalizedState(
235
254
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
236
255
 
237
256
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
238
- ...(computeEpochAtSlot(blockHeader.slot) < unfinalizedState.config.GLOAS_FORK_EPOCH
239
- ? {
240
- builderIndex: undefined,
241
- blockHashHex: undefined,
242
- }
243
- : {
244
- builderIndex: (unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex,
245
- blockHashHex: toRootHex((unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash),
246
- }),
257
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
258
+ builderIndex: isForkPostGloas
259
+ ? (unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex
260
+ : null,
261
+ blockHashFromBid: isForkPostGloas
262
+ ? toRootHex((unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash)
263
+ : null,
264
+ parentBlockHash: isForkPostGloas ? toRootHex((unfinalizedState as CachedBeaconStateGloas).latestBlockHash) : null,
247
265
  };
248
266
 
249
267
  const parentSlot = blockHeader.slot - 1;
@@ -285,9 +303,9 @@ export function initializeForkChoiceFromUnfinalizedState(
285
303
  };
286
304
 
287
305
  const protoArray = ProtoArray.initialize(finalizedBlock, currentSlot);
288
- protoArray.onBlock(justifiedBlock, currentSlot);
289
- protoArray.onBlock(parentBlock, currentSlot);
290
- protoArray.onBlock(headBlock, currentSlot);
306
+ protoArray.onBlock(justifiedBlock, currentSlot, null);
307
+ protoArray.onBlock(parentBlock, currentSlot, null);
308
+ protoArray.onBlock(headBlock, currentSlot, null);
291
309
 
292
310
  logger?.verbose("Initialized protoArray successfully", {...logCtx, length: protoArray.length()});
293
311
 
@@ -1,16 +1,11 @@
1
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
2
1
  import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz";
3
2
  import {BeaconConfig} from "@lodestar/config";
4
3
  import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
5
- import {
6
- BeaconStateAllForks,
7
- CachedBeaconStateAllForks,
8
- EpochShuffling,
9
- Index2PubkeyCache,
10
- } from "@lodestar/state-transition";
4
+ import {BeaconStateAllForks, CachedBeaconStateAllForks, EpochShuffling, PubkeyCache} from "@lodestar/state-transition";
11
5
  import {
12
6
  BeaconBlock,
13
7
  BlindedBeaconBlock,
8
+ DataColumnSidecars,
14
9
  Epoch,
15
10
  Root,
16
11
  RootHex,
@@ -23,7 +18,6 @@ import {
23
18
  altair,
24
19
  capella,
25
20
  deneb,
26
- fulu,
27
21
  phase0,
28
22
  rewards,
29
23
  } from "@lodestar/types";
@@ -117,8 +111,7 @@ export interface IBeaconChain {
117
111
  readonly regen: IStateRegenerator;
118
112
  readonly lightClientServer?: LightClientServer;
119
113
  readonly reprocessController: ReprocessController;
120
- readonly pubkey2index: PubkeyIndexMap;
121
- readonly index2pubkey: Index2PubkeyCache;
114
+ readonly pubkeyCache: PubkeyCache;
122
115
  readonly archiveStore: IArchiveStore;
123
116
 
124
117
  // Ops pool
@@ -224,7 +217,7 @@ export interface IBeaconChain {
224
217
  ): Promise<{block: SignedBeaconBlock; executionOptimistic: boolean; finalized: boolean} | null>;
225
218
  getBlobSidecars(blockSlot: Slot, blockRootHex: string): Promise<deneb.BlobSidecars | null>;
226
219
  getSerializedBlobSidecars(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null>;
227
- getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<fulu.DataColumnSidecars>;
220
+ getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<DataColumnSidecars>;
228
221
  getSerializedDataColumnSidecars(
229
222
  blockSlot: Slot,
230
223
  blockRootHex: string,
@@ -355,7 +355,10 @@ export class LightClientServer {
355
355
  // Signature data
356
356
  const update = await this.db.bestLightClientUpdate.get(period);
357
357
  if (!update) {
358
- throw Error(`No partialUpdate available for period ${period}`);
358
+ throw new LightClientServerError(
359
+ {code: LightClientServerErrorCode.RESOURCE_UNAVAILABLE},
360
+ `No partialUpdate available for period ${period}`
361
+ );
359
362
  }
360
363
  return update;
361
364
  }
@@ -864,7 +864,7 @@ function isValidShuffling(
864
864
  // attestation's shuffling is the same as the current state's.
865
865
  // To account for skipped slots, find the first block at *or before* the pivot slot.
866
866
  const beaconBlockRootHex = blockRootHex;
867
- const beaconBlock = forkChoice.getBlockHex(beaconBlockRootHex);
867
+ const beaconBlock = forkChoice.getBlockHexDefaultStatus(beaconBlockRootHex);
868
868
  if (!beaconBlock) {
869
869
  return InvalidAttestationData.BlockNotInForkChoice;
870
870
  }
@@ -27,6 +27,7 @@ export type IChainOptions = BlockProcessOpts &
27
27
  blsVerifyAllMainThread?: boolean;
28
28
  blsVerifyAllMultiThread?: boolean;
29
29
  blacklistedBlocks?: string[];
30
+ // TODO GLOAS: add similar option for execution payload envelopes?
30
31
  persistProducedBlocks?: boolean;
31
32
  persistInvalidSszObjects?: boolean;
32
33
  persistInvalidSszObjectsDir?: string;
@@ -1,14 +1,14 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {getSafeExecutionBlockHash} from "@lodestar/fork-choice";
4
- import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
4
+ import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix} from "@lodestar/params";
5
5
  import {
6
6
  CachedBeaconStateAllForks,
7
7
  CachedBeaconStateExecutions,
8
+ CachedBeaconStateGloas,
8
9
  StateHashTreeRootSource,
9
10
  computeEpochAtSlot,
10
11
  computeTimeAtSlot,
11
- isExecutionStateType,
12
12
  } from "@lodestar/state-transition";
13
13
  import {Slot} from "@lodestar/types";
14
14
  import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
@@ -120,10 +120,10 @@ export class PrepareNextSlotScheduler {
120
120
  RegenCaller.precomputeEpoch
121
121
  );
122
122
 
123
- if (isExecutionStateType(prepareState)) {
123
+ if (isForkPostBellatrix(fork)) {
124
124
  const proposerIndex = prepareState.epochCtx.getBeaconProposer(prepareSlot);
125
125
  const feeRecipient = this.chain.beaconProposerCache.get(proposerIndex);
126
- let updatedPrepareState = prepareState;
126
+ let updatedPrepareState = prepareState as CachedBeaconStateExecutions | CachedBeaconStateGloas;
127
127
  let updatedHeadRoot = headRoot;
128
128
 
129
129
  if (feeRecipient) {
@@ -146,7 +146,7 @@ export class PrepareNextSlotScheduler {
146
146
  // only transfer cache if epoch transition because that's the state we will use to stateTransition() the 1st block of epoch
147
147
  {dontTransferCache: !isEpochTransition},
148
148
  RegenCaller.predictProposerHead
149
- )) as CachedBeaconStateExecutions;
149
+ )) as CachedBeaconStateExecutions | CachedBeaconStateGloas;
150
150
  updatedHeadRoot = proposerHeadRoot;
151
151
  }
152
152
 
@@ -1,11 +1,14 @@
1
1
  import {
2
2
  CachedBeaconStateAllForks,
3
+ CachedBeaconStateGloas,
3
4
  DataAvailabilityStatus,
4
5
  ExecutionPayloadStatus,
6
+ G2_POINT_AT_INFINITY,
5
7
  StateHashTreeRootSource,
6
8
  stateTransition,
7
9
  } from "@lodestar/state-transition";
8
- import {BeaconBlock, BlindedBeaconBlock, Gwei, Root} from "@lodestar/types";
10
+ import {processExecutionPayloadEnvelope} from "@lodestar/state-transition/block";
11
+ import {BeaconBlock, BlindedBeaconBlock, Gwei, Root, gloas} from "@lodestar/types";
9
12
  import {ZERO_HASH} from "../../constants/index.js";
10
13
  import {Metrics} from "../../metrics/index.js";
11
14
 
@@ -18,7 +21,7 @@ export function computeNewStateRoot(
18
21
  metrics: Metrics | null,
19
22
  state: CachedBeaconStateAllForks,
20
23
  block: BeaconBlock | BlindedBeaconBlock
21
- ): {newStateRoot: Root; proposerReward: Gwei} {
24
+ ): {newStateRoot: Root; proposerReward: Gwei; postState: CachedBeaconStateAllForks} {
22
25
  // Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
23
26
  const blockEmptySig = {message: block, signature: ZERO_HASH};
24
27
 
@@ -51,5 +54,34 @@ export function computeNewStateRoot(
51
54
  const newStateRoot = postState.hashTreeRoot();
52
55
  hashTreeRootTimer?.();
53
56
 
54
- return {newStateRoot, proposerReward};
57
+ return {newStateRoot, proposerReward, postState};
58
+ }
59
+
60
+ /**
61
+ * Compute the state root after processing an execution payload envelope.
62
+ * Similar to `computeNewStateRoot` but for payload envelope processing.
63
+ *
64
+ * The `postBlockState` is mutated in place, callers must ensure it is not needed afterward.
65
+ */
66
+ export function computeEnvelopeStateRoot(
67
+ metrics: Metrics | null,
68
+ postBlockState: CachedBeaconStateGloas,
69
+ envelope: gloas.ExecutionPayloadEnvelope
70
+ ): Root {
71
+ const signedEnvelope: gloas.SignedExecutionPayloadEnvelope = {
72
+ message: envelope,
73
+ signature: G2_POINT_AT_INFINITY,
74
+ };
75
+
76
+ const processEnvelopeTimer = metrics?.blockPayload.executionPayloadEnvelopeProcessingTime.startTimer();
77
+ processExecutionPayloadEnvelope(postBlockState, signedEnvelope, false);
78
+ processEnvelopeTimer?.();
79
+
80
+ const hashTreeRootTimer = metrics?.stateHashTreeRootTime.startTimer({
81
+ source: StateHashTreeRootSource.computeEnvelopeStateRoot,
82
+ });
83
+ const stateRoot = postBlockState.hashTreeRoot();
84
+ hashTreeRootTimer?.();
85
+
86
+ return stateRoot;
55
87
  }