@lodestar/beacon-node 1.40.0-dev.0ae7a89ead → 1.40.0-dev.193b2e2047

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 (339) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +8 -18
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/config/constants.d.ts +3 -0
  5. package/lib/api/impl/config/constants.d.ts.map +1 -1
  6. package/lib/api/impl/config/constants.js +5 -1
  7. package/lib/api/impl/config/constants.js.map +1 -1
  8. package/lib/api/impl/debug/index.d.ts +1 -1
  9. package/lib/api/impl/debug/index.d.ts.map +1 -1
  10. package/lib/api/impl/debug/index.js +3 -6
  11. package/lib/api/impl/debug/index.js.map +1 -1
  12. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  13. package/lib/api/impl/lodestar/index.js +5 -2
  14. package/lib/api/impl/lodestar/index.js.map +1 -1
  15. package/lib/api/impl/validator/index.d.ts.map +1 -1
  16. package/lib/api/impl/validator/index.js +9 -8
  17. package/lib/api/impl/validator/index.js.map +1 -1
  18. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/utils/archiveBlocks.js +4 -0
  20. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  21. package/lib/chain/blocks/blockInput/blockInput.d.ts +2 -0
  22. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  23. package/lib/chain/blocks/blockInput/blockInput.js +6 -0
  24. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  25. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  26. package/lib/chain/blocks/importBlock.js +2 -6
  27. package/lib/chain/blocks/importBlock.js.map +1 -1
  28. package/lib/chain/blocks/index.d.ts.map +1 -1
  29. package/lib/chain/blocks/index.js +0 -14
  30. package/lib/chain/blocks/index.js.map +1 -1
  31. package/lib/chain/blocks/types.d.ts +0 -2
  32. package/lib/chain/blocks/types.d.ts.map +1 -1
  33. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  34. package/lib/chain/blocks/verifyBlock.js +1 -8
  35. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  36. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  37. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  38. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
  39. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  40. package/lib/chain/blocks/writeBlockInputToDb.d.ts +1 -4
  41. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  42. package/lib/chain/blocks/writeBlockInputToDb.js +20 -28
  43. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  44. package/lib/chain/bls/multithread/index.d.ts +3 -1
  45. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  46. package/lib/chain/bls/multithread/index.js +5 -3
  47. package/lib/chain/bls/multithread/index.js.map +1 -1
  48. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  49. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  50. package/lib/chain/bls/multithread/jobItem.js +2 -2
  51. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  52. package/lib/chain/bls/singleThread.d.ts +4 -2
  53. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  54. package/lib/chain/bls/singleThread.js +4 -2
  55. package/lib/chain/bls/singleThread.js.map +1 -1
  56. package/lib/chain/bls/utils.d.ts +2 -2
  57. package/lib/chain/bls/utils.d.ts.map +1 -1
  58. package/lib/chain/bls/utils.js +9 -6
  59. package/lib/chain/bls/utils.js.map +1 -1
  60. package/lib/chain/chain.d.ts +21 -4
  61. package/lib/chain/chain.d.ts.map +1 -1
  62. package/lib/chain/chain.js +180 -15
  63. package/lib/chain/chain.js.map +1 -1
  64. package/lib/chain/errors/attestationError.d.ts +14 -1
  65. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  66. package/lib/chain/errors/attestationError.js +8 -0
  67. package/lib/chain/errors/attestationError.js.map +1 -1
  68. package/lib/chain/errors/executionPayloadBid.d.ts +48 -0
  69. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -0
  70. package/lib/chain/errors/executionPayloadBid.js +15 -0
  71. package/lib/chain/errors/executionPayloadBid.js.map +1 -0
  72. package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
  73. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -0
  74. package/lib/chain/errors/executionPayloadEnvelope.js +16 -0
  75. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -0
  76. package/lib/chain/errors/index.d.ts +3 -0
  77. package/lib/chain/errors/index.d.ts.map +1 -1
  78. package/lib/chain/errors/index.js +3 -0
  79. package/lib/chain/errors/index.js.map +1 -1
  80. package/lib/chain/errors/payloadAttestation.d.ts +34 -0
  81. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -0
  82. package/lib/chain/errors/payloadAttestation.js +13 -0
  83. package/lib/chain/errors/payloadAttestation.js.map +1 -0
  84. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  85. package/lib/chain/forkChoice/index.js +18 -0
  86. package/lib/chain/forkChoice/index.js.map +1 -1
  87. package/lib/chain/interface.d.ts +21 -3
  88. package/lib/chain/interface.d.ts.map +1 -1
  89. package/lib/chain/interface.js.map +1 -1
  90. package/lib/chain/opPools/executionPayloadBidPool.d.ts +21 -0
  91. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -0
  92. package/lib/chain/opPools/executionPayloadBidPool.js +57 -0
  93. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -0
  94. package/lib/chain/opPools/index.d.ts +2 -0
  95. package/lib/chain/opPools/index.d.ts.map +1 -1
  96. package/lib/chain/opPools/index.js +2 -0
  97. package/lib/chain/opPools/index.js.map +1 -1
  98. package/lib/chain/opPools/payloadAttestationPool.d.ts +24 -0
  99. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -0
  100. package/lib/chain/opPools/payloadAttestationPool.js +109 -0
  101. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -0
  102. package/lib/chain/prepareNextSlot.js +6 -4
  103. package/lib/chain/prepareNextSlot.js.map +1 -1
  104. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  105. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  106. package/lib/chain/produceBlock/produceBlockBody.js +5 -3
  107. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  108. package/lib/chain/regen/interface.d.ts +3 -8
  109. package/lib/chain/regen/interface.d.ts.map +1 -1
  110. package/lib/chain/regen/interface.js +1 -1
  111. package/lib/chain/regen/interface.js.map +1 -1
  112. package/lib/chain/regen/queued.d.ts +1 -2
  113. package/lib/chain/regen/queued.d.ts.map +1 -1
  114. package/lib/chain/regen/queued.js +2 -16
  115. package/lib/chain/regen/queued.js.map +1 -1
  116. package/lib/chain/regen/regen.d.ts +3 -7
  117. package/lib/chain/regen/regen.d.ts.map +1 -1
  118. package/lib/chain/regen/regen.js +3 -16
  119. package/lib/chain/regen/regen.js.map +1 -1
  120. package/lib/chain/seenCache/index.d.ts +3 -1
  121. package/lib/chain/seenCache/index.d.ts.map +1 -1
  122. package/lib/chain/seenCache/index.js +3 -1
  123. package/lib/chain/seenCache/index.js.map +1 -1
  124. package/lib/chain/seenCache/seenAttesters.d.ts +5 -0
  125. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  126. package/lib/chain/seenCache/seenAttesters.js +5 -0
  127. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  128. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +12 -0
  129. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -0
  130. package/lib/chain/seenCache/seenExecutionPayloadBids.js +30 -0
  131. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -0
  132. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +15 -0
  133. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +1 -0
  134. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +28 -0
  135. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +1 -0
  136. package/lib/chain/validation/aggregateAndProof.js +35 -14
  137. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  138. package/lib/chain/validation/attestation.d.ts +2 -2
  139. package/lib/chain/validation/attestation.d.ts.map +1 -1
  140. package/lib/chain/validation/attestation.js +27 -8
  141. package/lib/chain/validation/attestation.js.map +1 -1
  142. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  143. package/lib/chain/validation/attesterSlashing.js +1 -1
  144. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  145. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  146. package/lib/chain/validation/blobSidecar.js +3 -3
  147. package/lib/chain/validation/blobSidecar.js.map +1 -1
  148. package/lib/chain/validation/block.d.ts.map +1 -1
  149. package/lib/chain/validation/block.js +5 -4
  150. package/lib/chain/validation/block.js.map +1 -1
  151. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  152. package/lib/chain/validation/dataColumnSidecar.js +3 -3
  153. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  154. package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
  155. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -0
  156. package/lib/chain/validation/executionPayloadBid.js +104 -0
  157. package/lib/chain/validation/executionPayloadBid.js.map +1 -0
  158. package/lib/chain/validation/executionPayloadEnvelope.d.ts +5 -0
  159. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -0
  160. package/lib/chain/validation/executionPayloadEnvelope.js +89 -0
  161. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -0
  162. package/lib/chain/validation/payloadAttestationMessage.d.ts +9 -0
  163. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -0
  164. package/lib/chain/validation/payloadAttestationMessage.js +72 -0
  165. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -0
  166. package/lib/chain/validation/proposerSlashing.js +1 -1
  167. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  168. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +2 -3
  169. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
  170. package/lib/chain/validation/signatureSets/aggregateAndProof.js +8 -3
  171. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  172. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  173. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  174. package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -3
  175. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  176. package/lib/chain/validation/signatureSets/selectionProof.d.ts +2 -3
  177. package/lib/chain/validation/signatureSets/selectionProof.d.ts.map +1 -1
  178. package/lib/chain/validation/signatureSets/selectionProof.js +8 -3
  179. package/lib/chain/validation/signatureSets/selectionProof.js.map +1 -1
  180. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  181. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  182. package/lib/chain/validation/signatureSets/syncCommittee.js +3 -3
  183. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  184. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +1 -2
  185. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  186. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  187. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  188. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  189. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  190. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +3 -3
  191. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  192. package/lib/chain/validation/syncCommittee.js +1 -1
  193. package/lib/chain/validation/syncCommittee.js.map +1 -1
  194. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  195. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -5
  196. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  197. package/lib/chain/validation/voluntaryExit.js +1 -1
  198. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  199. package/lib/chain/validatorMonitor.d.ts +2 -0
  200. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  201. package/lib/chain/validatorMonitor.js +42 -3
  202. package/lib/chain/validatorMonitor.js.map +1 -1
  203. package/lib/db/repositories/checkpointState.js +0 -1
  204. package/lib/db/repositories/checkpointState.js.map +1 -1
  205. package/lib/metrics/metrics/lodestar.d.ts +27 -0
  206. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  207. package/lib/metrics/metrics/lodestar.js +64 -0
  208. package/lib/metrics/metrics/lodestar.js.map +1 -1
  209. package/lib/network/gossip/interface.d.ts +20 -2
  210. package/lib/network/gossip/interface.d.ts.map +1 -1
  211. package/lib/network/gossip/interface.js +3 -0
  212. package/lib/network/gossip/interface.js.map +1 -1
  213. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  214. package/lib/network/gossip/scoringParameters.js +38 -2
  215. package/lib/network/gossip/scoringParameters.js.map +1 -1
  216. package/lib/network/gossip/topic.d.ts +77 -1
  217. package/lib/network/gossip/topic.d.ts.map +1 -1
  218. package/lib/network/gossip/topic.js +20 -0
  219. package/lib/network/gossip/topic.js.map +1 -1
  220. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  221. package/lib/network/processor/gossipHandlers.js +34 -3
  222. package/lib/network/processor/gossipHandlers.js.map +1 -1
  223. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  224. package/lib/network/processor/gossipQueues/index.js +16 -0
  225. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  226. package/lib/network/processor/index.d.ts.map +1 -1
  227. package/lib/network/processor/index.js +3 -0
  228. package/lib/network/processor/index.js.map +1 -1
  229. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  230. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -4
  231. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  232. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts +1 -2
  233. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  234. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +5 -26
  235. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  236. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +1 -2
  237. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  238. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +5 -7
  239. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  240. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  241. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -2
  242. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  243. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  244. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -5
  245. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  246. package/lib/network/reqresp/handlers/index.js +2 -2
  247. package/lib/network/reqresp/handlers/index.js.map +1 -1
  248. package/lib/sync/backfill/backfill.js +2 -2
  249. package/lib/sync/backfill/backfill.js.map +1 -1
  250. package/lib/sync/backfill/verify.d.ts +1 -2
  251. package/lib/sync/backfill/verify.d.ts.map +1 -1
  252. package/lib/sync/backfill/verify.js +2 -2
  253. package/lib/sync/backfill/verify.js.map +1 -1
  254. package/lib/sync/range/chain.d.ts.map +1 -1
  255. package/lib/sync/range/chain.js +0 -1
  256. package/lib/sync/range/chain.js.map +1 -1
  257. package/lib/sync/range/range.d.ts.map +1 -1
  258. package/lib/sync/range/range.js +0 -3
  259. package/lib/sync/range/range.js.map +1 -1
  260. package/lib/sync/unknownBlock.d.ts.map +1 -1
  261. package/lib/sync/unknownBlock.js +0 -3
  262. package/lib/sync/unknownBlock.js.map +1 -1
  263. package/package.json +15 -15
  264. package/src/api/impl/beacon/blocks/index.ts +8 -18
  265. package/src/api/impl/config/constants.ts +8 -0
  266. package/src/api/impl/debug/index.ts +2 -6
  267. package/src/api/impl/lodestar/index.ts +6 -3
  268. package/src/api/impl/validator/index.ts +12 -11
  269. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -0
  270. package/src/chain/blocks/blockInput/blockInput.ts +8 -0
  271. package/src/chain/blocks/importBlock.ts +2 -6
  272. package/src/chain/blocks/index.ts +0 -19
  273. package/src/chain/blocks/types.ts +0 -2
  274. package/src/chain/blocks/verifyBlock.ts +0 -9
  275. package/src/chain/blocks/verifyBlocksSignatures.ts +4 -12
  276. package/src/chain/blocks/writeBlockInputToDb.ts +24 -30
  277. package/src/chain/bls/multithread/index.ts +7 -4
  278. package/src/chain/bls/multithread/jobItem.ts +7 -3
  279. package/src/chain/bls/singleThread.ts +5 -3
  280. package/src/chain/bls/utils.ts +15 -7
  281. package/src/chain/chain.ts +205 -23
  282. package/src/chain/errors/attestationError.ts +11 -1
  283. package/src/chain/errors/executionPayloadBid.ts +35 -0
  284. package/src/chain/errors/executionPayloadEnvelope.ts +34 -0
  285. package/src/chain/errors/index.ts +3 -0
  286. package/src/chain/errors/payloadAttestation.ts +25 -0
  287. package/src/chain/forkChoice/index.ts +19 -0
  288. package/src/chain/interface.ts +32 -1
  289. package/src/chain/opPools/executionPayloadBidPool.ts +77 -0
  290. package/src/chain/opPools/index.ts +2 -0
  291. package/src/chain/opPools/payloadAttestationPool.ts +157 -0
  292. package/src/chain/prepareNextSlot.ts +6 -6
  293. package/src/chain/produceBlock/produceBlockBody.ts +7 -5
  294. package/src/chain/regen/interface.ts +2 -12
  295. package/src/chain/regen/queued.ts +3 -23
  296. package/src/chain/regen/regen.ts +4 -24
  297. package/src/chain/seenCache/index.ts +3 -1
  298. package/src/chain/seenCache/seenAttesters.ts +5 -0
  299. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -0
  300. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +34 -0
  301. package/src/chain/validation/aggregateAndProof.ts +36 -14
  302. package/src/chain/validation/attestation.ts +33 -16
  303. package/src/chain/validation/attesterSlashing.ts +1 -6
  304. package/src/chain/validation/blobSidecar.ts +2 -7
  305. package/src/chain/validation/block.ts +5 -4
  306. package/src/chain/validation/dataColumnSidecar.ts +2 -7
  307. package/src/chain/validation/executionPayloadBid.ts +141 -0
  308. package/src/chain/validation/executionPayloadEnvelope.ts +122 -0
  309. package/src/chain/validation/payloadAttestationMessage.ts +109 -0
  310. package/src/chain/validation/proposerSlashing.ts +1 -6
  311. package/src/chain/validation/signatureSets/aggregateAndProof.ts +9 -14
  312. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -4
  313. package/src/chain/validation/signatureSets/selectionProof.ts +9 -9
  314. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -4
  315. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  316. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -4
  317. package/src/chain/validation/syncCommittee.ts +1 -1
  318. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -5
  319. package/src/chain/validation/voluntaryExit.ts +1 -1
  320. package/src/chain/validatorMonitor.ts +52 -3
  321. package/src/db/repositories/checkpointState.ts +1 -1
  322. package/src/metrics/metrics/lodestar.ts +65 -0
  323. package/src/network/gossip/interface.ts +17 -0
  324. package/src/network/gossip/scoringParameters.ts +44 -2
  325. package/src/network/gossip/topic.ts +21 -0
  326. package/src/network/processor/gossipHandlers.ts +48 -3
  327. package/src/network/processor/gossipQueues/index.ts +16 -0
  328. package/src/network/processor/index.ts +3 -0
  329. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -4
  330. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +5 -32
  331. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -9
  332. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +5 -2
  333. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -5
  334. package/src/network/reqresp/handlers/index.ts +2 -2
  335. package/src/sync/backfill/backfill.ts +2 -2
  336. package/src/sync/backfill/verify.ts +2 -3
  337. package/src/sync/range/chain.ts +0 -1
  338. package/src/sync/range/range.ts +0 -3
  339. package/src/sync/unknownBlock.ts +0 -3
@@ -0,0 +1,35 @@
1
+ import {BuilderIndex, RootHex, Slot} from "@lodestar/types";
2
+ import {GossipActionError} from "./gossipValidation.ts";
3
+
4
+ export enum ExecutionPayloadBidErrorCode {
5
+ BUILDER_NOT_ELIGIBLE = "EXECUTION_PAYLOAD_BID_ERROR_BUILDER_NOT_ELIGIBLE",
6
+ NON_ZERO_EXECUTION_PAYMENT = "EXECUTION_PAYLOAD_BID_ERROR_NON_ZERO_EXECUTION_PAYMENT",
7
+ BID_ALREADY_KNOWN = "EXECUTION_PAYLOAD_BID_ERROR_BID_ALREADY_KNOWN",
8
+ BID_TOO_LOW = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_LOW",
9
+ BID_TOO_HIGH = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_HIGH",
10
+ UNKNOWN_BLOCK_ROOT = "EXECUTION_PAYLOAD_BID_ERROR_UNKNOWN_BLOCK_ROOT",
11
+ INVALID_SLOT = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SLOT",
12
+ INVALID_SIGNATURE = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SIGNATURE",
13
+ }
14
+
15
+ export type ExecutionPayloadBidErrorType =
16
+ | {code: ExecutionPayloadBidErrorCode.BUILDER_NOT_ELIGIBLE; builderIndex: BuilderIndex}
17
+ | {
18
+ code: ExecutionPayloadBidErrorCode.NON_ZERO_EXECUTION_PAYMENT;
19
+ builderIndex: BuilderIndex;
20
+ executionPayment: number;
21
+ }
22
+ | {
23
+ code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN;
24
+ builderIndex: BuilderIndex;
25
+ slot: Slot;
26
+ parentBlockRoot: RootHex;
27
+ parentBlockHash: RootHex;
28
+ }
29
+ | {code: ExecutionPayloadBidErrorCode.BID_TOO_LOW; bidValue: number; currentHighestBid: number}
30
+ | {code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH; bidValue: number; builderBalance: number}
31
+ | {code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT; parentBlockRoot: RootHex}
32
+ | {code: ExecutionPayloadBidErrorCode.INVALID_SLOT; builderIndex: BuilderIndex; slot: Slot}
33
+ | {code: ExecutionPayloadBidErrorCode.INVALID_SIGNATURE; builderIndex: BuilderIndex; slot: Slot};
34
+
35
+ export class ExecutionPayloadBidError extends GossipActionError<ExecutionPayloadBidErrorType> {}
@@ -0,0 +1,34 @@
1
+ import {BuilderIndex, RootHex, Slot} from "@lodestar/types";
2
+ import {GossipActionError} from "./gossipValidation.js";
3
+
4
+ export enum ExecutionPayloadEnvelopeErrorCode {
5
+ BELONG_TO_FINALIZED_BLOCK = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BELONG_TO_FINALIZED_BLOCK",
6
+ BLOCK_ROOT_UNKNOWN = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_ROOT_UNKNOWN",
7
+ ENVELOPE_ALREADY_KNOWN = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_ALREADY_KNOWN",
8
+ INVALID_BLOCK = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_BLOCK",
9
+ SLOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_SLOT_MISMATCH",
10
+ BUILDER_INDEX_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BUILDER_INDEX_MISMATCH",
11
+ BLOCK_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_HASH_MISMATCH",
12
+ INVALID_SIGNATURE = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_SIGNATURE",
13
+ CACHE_FAIL = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_CACHE_FAIL",
14
+ }
15
+ export type ExecutionPayloadEnvelopeErrorType =
16
+ | {code: ExecutionPayloadEnvelopeErrorCode.BELONG_TO_FINALIZED_BLOCK; envelopeSlot: Slot; finalizedSlot: Slot}
17
+ | {code: ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN; blockRoot: RootHex}
18
+ | {
19
+ code: ExecutionPayloadEnvelopeErrorCode.ENVELOPE_ALREADY_KNOWN;
20
+ blockRoot: RootHex;
21
+ slot: Slot;
22
+ }
23
+ | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_BLOCK; blockRoot: RootHex}
24
+ | {code: ExecutionPayloadEnvelopeErrorCode.SLOT_MISMATCH; envelopeSlot: Slot; blockSlot: Slot}
25
+ | {
26
+ code: ExecutionPayloadEnvelopeErrorCode.BUILDER_INDEX_MISMATCH;
27
+ envelopeBuilderIndex: BuilderIndex;
28
+ bidBuilderIndex: BuilderIndex;
29
+ }
30
+ | {code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH; envelopeBlockHash: RootHex; bidBlockHash: RootHex}
31
+ | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE}
32
+ | {code: ExecutionPayloadEnvelopeErrorCode.CACHE_FAIL; blockRoot: RootHex};
33
+
34
+ export class ExecutionPayloadEnvelopeError extends GossipActionError<ExecutionPayloadEnvelopeErrorType> {}
@@ -4,7 +4,10 @@ export * from "./blobSidecarError.js";
4
4
  export * from "./blockError.js";
5
5
  export * from "./blsToExecutionChangeError.js";
6
6
  export * from "./dataColumnSidecarError.js";
7
+ export * from "./executionPayloadBid.js";
8
+ export * from "./executionPayloadEnvelope.js";
7
9
  export * from "./gossipValidation.js";
10
+ export * from "./payloadAttestation.js";
8
11
  export * from "./proposerSlashingError.js";
9
12
  export * from "./syncCommitteeError.js";
10
13
  export * from "./voluntaryExitError.js";
@@ -0,0 +1,25 @@
1
+ import {RootHex, Slot, ValidatorIndex} from "@lodestar/types";
2
+ import {GossipActionError} from "./gossipValidation.ts";
3
+
4
+ export enum PayloadAttestationErrorCode {
5
+ NOT_CURRENT_SLOT = "PAYLOAD_ATTESTATION_ERROR_NOT_CURRENT_SLOT",
6
+ PAYLOAD_ATTESTATION_ALREADY_KNOWN = "PAYLOAD_ATTESTATION_ERROR_PAYLOAD_ATTESTATION_ALREADY_KNOWN",
7
+ UNKNOWN_BLOCK_ROOT = "PAYLOAD_ATTESTATION_ERROR_UNKNOWN_BLOCK_ROOT",
8
+ INVALID_BLOCK = "PAYLOAD_ATTESTATION_ERROR_INVALID_BLOCK",
9
+ INVALID_ATTESTER = "PAYLOAD_ATTESTATION_ERROR_INVALID_ATTESTER",
10
+ INVALID_SIGNATURE = "PAYLOAD_ATTESTATION_ERROR_INVALID_SIGNATURE",
11
+ }
12
+ export type PayloadAttestationErrorType =
13
+ | {code: PayloadAttestationErrorCode.NOT_CURRENT_SLOT; currentSlot: Slot; slot: Slot}
14
+ | {
15
+ code: PayloadAttestationErrorCode.PAYLOAD_ATTESTATION_ALREADY_KNOWN;
16
+ validatorIndex: ValidatorIndex;
17
+ slot: Slot;
18
+ blockRoot: RootHex;
19
+ }
20
+ | {code: PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT; blockRoot: RootHex}
21
+ | {code: PayloadAttestationErrorCode.INVALID_BLOCK; blockRoot: RootHex}
22
+ | {code: PayloadAttestationErrorCode.INVALID_ATTESTER; attesterIndex: ValidatorIndex}
23
+ | {code: PayloadAttestationErrorCode.INVALID_SIGNATURE};
24
+
25
+ export class PayloadAttestationError extends GossipActionError<PayloadAttestationErrorType> {}
@@ -11,6 +11,7 @@ import {
11
11
  import {ZERO_HASH_HEX} from "@lodestar/params";
12
12
  import {
13
13
  CachedBeaconStateAllForks,
14
+ CachedBeaconStateGloas,
14
15
  DataAvailabilityStatus,
15
16
  computeAnchorCheckpoint,
16
17
  computeEpochAtSlot,
@@ -144,6 +145,15 @@ export function initializeForkChoiceFromFinalizedState(
144
145
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
145
146
 
146
147
  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
+ }),
147
157
  },
148
158
  currentSlot
149
159
  ),
@@ -225,6 +235,15 @@ export function initializeForkChoiceFromUnfinalizedState(
225
235
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
226
236
 
227
237
  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
+ }),
228
247
  };
229
248
 
230
249
  const parentSlot = blockHeader.slot - 1;
@@ -22,6 +22,8 @@ import {
22
22
  Wei,
23
23
  altair,
24
24
  capella,
25
+ deneb,
26
+ fulu,
25
27
  phase0,
26
28
  rewards,
27
29
  } from "@lodestar/types";
@@ -44,7 +46,14 @@ import {ForkchoiceCaller} from "./forkChoice/index.js";
44
46
  import {GetBlobsTracker} from "./GetBlobsTracker.js";
45
47
  import {LightClientServer} from "./lightClient/index.js";
46
48
  import {AggregatedAttestationPool} from "./opPools/aggregatedAttestationPool.js";
47
- import {AttestationPool, OpPool, SyncCommitteeMessagePool, SyncContributionAndProofPool} from "./opPools/index.js";
49
+ import {
50
+ AttestationPool,
51
+ ExecutionPayloadBidPool,
52
+ OpPool,
53
+ PayloadAttestationPool,
54
+ SyncCommitteeMessagePool,
55
+ SyncContributionAndProofPool,
56
+ } from "./opPools/index.js";
48
57
  import {IChainOptions} from "./options.js";
49
58
  import {AssembledBlockType, BlockAttributes, BlockType, ProduceResult} from "./produceBlock/produceBlockBody.js";
50
59
  import {IStateRegenerator, RegenCaller} from "./regen/index.js";
@@ -54,6 +63,9 @@ import {
54
63
  SeenAttesters,
55
64
  SeenBlockProposers,
56
65
  SeenContributionAndProof,
66
+ SeenExecutionPayloadBids,
67
+ SeenExecutionPayloadEnvelopes,
68
+ SeenPayloadAttesters,
57
69
  SeenSyncCommitteeMessages,
58
70
  } from "./seenCache/index.js";
59
71
  import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js";
@@ -114,12 +126,17 @@ export interface IBeaconChain {
114
126
  readonly aggregatedAttestationPool: AggregatedAttestationPool;
115
127
  readonly syncCommitteeMessagePool: SyncCommitteeMessagePool;
116
128
  readonly syncContributionAndProofPool: SyncContributionAndProofPool;
129
+ readonly executionPayloadBidPool: ExecutionPayloadBidPool;
130
+ readonly payloadAttestationPool: PayloadAttestationPool;
117
131
  readonly opPool: OpPool;
118
132
 
119
133
  // Gossip seen cache
120
134
  readonly seenAttesters: SeenAttesters;
121
135
  readonly seenAggregators: SeenAggregators;
136
+ readonly seenPayloadAttesters: SeenPayloadAttesters;
122
137
  readonly seenAggregatedAttestations: SeenAggregatedAttestations;
138
+ readonly seenExecutionPayloadEnvelopes: SeenExecutionPayloadEnvelopes;
139
+ readonly seenExecutionPayloadBids: SeenExecutionPayloadBids;
123
140
  readonly seenBlockProposers: SeenBlockProposers;
124
141
  readonly seenSyncCommitteeMessages: SeenSyncCommitteeMessages;
125
142
  readonly seenContributionAndProof: SeenContributionAndProof;
@@ -193,12 +210,26 @@ export interface IBeaconChain {
193
210
  getCanonicalBlockAtSlot(
194
211
  slot: Slot
195
212
  ): Promise<{block: SignedBeaconBlock; executionOptimistic: boolean; finalized: boolean} | null>;
213
+ /**
214
+ * Get local block by root, does not fetch from the network
215
+ */
216
+ getSerializedBlockByRoot(
217
+ root: RootHex
218
+ ): Promise<{block: Uint8Array; executionOptimistic: boolean; finalized: boolean; slot: Slot} | null>;
196
219
  /**
197
220
  * Get local block by root, does not fetch from the network
198
221
  */
199
222
  getBlockByRoot(
200
223
  root: RootHex
201
224
  ): Promise<{block: SignedBeaconBlock; executionOptimistic: boolean; finalized: boolean} | null>;
225
+ getBlobSidecars(blockSlot: Slot, blockRootHex: string): Promise<deneb.BlobSidecars | null>;
226
+ getSerializedBlobSidecars(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null>;
227
+ getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<fulu.DataColumnSidecars>;
228
+ getSerializedDataColumnSidecars(
229
+ blockSlot: Slot,
230
+ blockRootHex: string,
231
+ indices: number[]
232
+ ): Promise<(Uint8Array | undefined)[]>;
202
233
 
203
234
  produceCommonBlockBody(blockAttributes: BlockAttributes): Promise<CommonBlockBody>;
204
235
  produceBlock(blockAttributes: BlockAttributes & {commonBlockBodyPromise: Promise<CommonBlockBody>}): Promise<{
@@ -0,0 +1,77 @@
1
+ import {Slot, gloas} from "@lodestar/types";
2
+ import {MapDef, toRootHex} from "@lodestar/utils";
3
+ import {InsertOutcome} from "./types.js";
4
+ import {pruneBySlot} from "./utils.js";
5
+
6
+ /**
7
+ * TODO GLOAS: Revisit this value and add rational for choosing it
8
+ */
9
+ const SLOTS_RETAINED = 2;
10
+
11
+ type BlockRootHex = string;
12
+ type BlockHashHex = string;
13
+
14
+ /**
15
+ * Store the best execution payload bid per slot / (parent block root, parent block hash).
16
+ */
17
+ export class ExecutionPayloadBidPool {
18
+ private readonly bidByParentHashByParentRootBySlot = new MapDef<
19
+ Slot,
20
+ MapDef<BlockRootHex, Map<BlockHashHex, gloas.ExecutionPayloadBid>>
21
+ >(() => new MapDef<BlockRootHex, Map<BlockHashHex, gloas.ExecutionPayloadBid>>(() => new Map()));
22
+ private lowestPermissibleSlot = 0;
23
+
24
+ get size(): number {
25
+ let count = 0;
26
+ for (const byParentRoot of this.bidByParentHashByParentRootBySlot.values()) {
27
+ for (const byParentHash of byParentRoot.values()) {
28
+ count += byParentHash.size;
29
+ }
30
+ }
31
+ return count;
32
+ }
33
+
34
+ add(bid: gloas.ExecutionPayloadBid): InsertOutcome {
35
+ const {slot, parentBlockRoot, parentBlockHash, value} = bid;
36
+ const lowestPermissibleSlot = this.lowestPermissibleSlot;
37
+
38
+ if (slot < lowestPermissibleSlot) {
39
+ return InsertOutcome.Old;
40
+ }
41
+
42
+ const parentRootHex = toRootHex(parentBlockRoot);
43
+ const parentHashHex = toRootHex(parentBlockHash);
44
+ const bidByParentHash = this.bidByParentHashByParentRootBySlot.getOrDefault(slot).getOrDefault(parentRootHex);
45
+ const existing = bidByParentHash.get(parentHashHex);
46
+
47
+ if (existing) {
48
+ const existingValue = existing.value;
49
+ const newValue = value;
50
+ if (newValue > existingValue) {
51
+ bidByParentHash.set(parentHashHex, bid);
52
+ return InsertOutcome.NewData;
53
+ }
54
+ return newValue === existingValue ? InsertOutcome.AlreadyKnown : InsertOutcome.NotBetterThan;
55
+ }
56
+
57
+ bidByParentHash.set(parentHashHex, bid);
58
+ return InsertOutcome.NewData;
59
+ }
60
+
61
+ /**
62
+ * Return the highest-value bid matching slot, parent block root, and parent block hash.
63
+ * Used for gossip validation and block production.
64
+ */
65
+ getBestBid(
66
+ parentBlockRoot: BlockRootHex,
67
+ parentBlockHash: BlockHashHex,
68
+ slot: Slot
69
+ ): gloas.ExecutionPayloadBid | null {
70
+ const bidByParentHash = this.bidByParentHashByParentRootBySlot.get(slot)?.get(parentBlockRoot);
71
+ return bidByParentHash?.get(parentBlockHash) ?? null;
72
+ }
73
+
74
+ prune(clockSlot: Slot): void {
75
+ this.lowestPermissibleSlot = pruneBySlot(this.bidByParentHashByParentRootBySlot, clockSlot, SLOTS_RETAINED);
76
+ }
77
+ }
@@ -1,5 +1,7 @@
1
1
  export {AggregatedAttestationPool} from "./aggregatedAttestationPool.js";
2
2
  export {AttestationPool} from "./attestationPool.js";
3
+ export {ExecutionPayloadBidPool} from "./executionPayloadBidPool.js";
3
4
  export {OpPool} from "./opPool.js";
5
+ export {PayloadAttestationPool} from "./payloadAttestationPool.js";
4
6
  export {SyncCommitteeMessagePool} from "./syncCommitteeMessagePool.js";
5
7
  export {SyncContributionAndProofPool} from "./syncContributionAndProofPool.js";
@@ -0,0 +1,157 @@
1
+ import {Signature, aggregateSignatures} from "@chainsafe/blst";
2
+ import {BitArray} from "@chainsafe/ssz";
3
+ import {ChainForkConfig} from "@lodestar/config";
4
+ import {MAX_COMMITTEES_PER_SLOT, PTC_SIZE} from "@lodestar/params";
5
+ import {RootHex, Slot, gloas} from "@lodestar/types";
6
+ import {MapDef, toRootHex} from "@lodestar/utils";
7
+ import {Metrics} from "../../metrics/metrics.js";
8
+ import {IClock} from "../../util/clock.js";
9
+ import {InsertOutcome, OpPoolError, OpPoolErrorCode} from "./types.js";
10
+ import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js";
11
+
12
+ /**
13
+ * TODO GLOAS: Revisit this value and add rational for choosing it
14
+ */
15
+ const SLOTS_RETAINED = 2;
16
+
17
+ /**
18
+ * The maximum number of distinct `PayloadAttestationData` that will be stored in each slot.
19
+ *
20
+ * This is a DoS protection measure.
21
+ */
22
+ // TODO GLOAS: Revisit this value. Educated guess would be MAX_ATTESTATIONS_PER_SLOT in AttestationPool divided by MAX_COMMITTEES_PER_SLOT
23
+ const MAX_PAYLOAD_ATTESTATIONS_PER_SLOT = 16_384 / MAX_COMMITTEES_PER_SLOT;
24
+
25
+ type DataRootHex = string;
26
+ type BlockRootHex = string;
27
+
28
+ type AggregateFast = {
29
+ aggregationBits: BitArray;
30
+ data: gloas.PayloadAttestationData;
31
+ signature: Signature;
32
+ };
33
+
34
+ export class PayloadAttestationPool {
35
+ private readonly aggregateByDataRootByBlockRootBySlot = new MapDef<
36
+ Slot,
37
+ Map<BlockRootHex, Map<DataRootHex, AggregateFast>>
38
+ >(() => new Map<BlockRootHex, Map<DataRootHex, AggregateFast>>());
39
+ private lowestPermissibleSlot = 0;
40
+
41
+ constructor(
42
+ private readonly config: ChainForkConfig,
43
+ private readonly clock: IClock,
44
+ private readonly metrics: Metrics | null = null
45
+ ) {}
46
+
47
+ get size(): number {
48
+ let count = 0;
49
+ for (const aggregateByDataRootByBlockRoot of this.aggregateByDataRootByBlockRootBySlot.values()) {
50
+ for (const aggregateByDataRoot of aggregateByDataRootByBlockRoot.values()) {
51
+ count += aggregateByDataRoot.size;
52
+ }
53
+ }
54
+ return count;
55
+ }
56
+
57
+ add(
58
+ message: gloas.PayloadAttestationMessage,
59
+ payloadAttDataRootHex: RootHex,
60
+ validatorCommitteeIndex: number
61
+ ): InsertOutcome {
62
+ const slot = message.data.slot;
63
+ const lowestPermissibleSlot = this.lowestPermissibleSlot;
64
+
65
+ if (slot < lowestPermissibleSlot) {
66
+ return InsertOutcome.Old;
67
+ }
68
+
69
+ if (slot < this.clock.slotWithPastTolerance(this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY / 1000)) {
70
+ return InsertOutcome.Late;
71
+ }
72
+
73
+ const aggregateByDataRootByBlockRoot = this.aggregateByDataRootByBlockRootBySlot.getOrDefault(slot);
74
+ let aggregateByDataRoot = aggregateByDataRootByBlockRoot.get(toRootHex(message.data.beaconBlockRoot));
75
+
76
+ if (!aggregateByDataRoot) {
77
+ aggregateByDataRoot = new Map<DataRootHex, AggregateFast>();
78
+ aggregateByDataRootByBlockRoot.set(toRootHex(message.data.beaconBlockRoot), aggregateByDataRoot);
79
+ }
80
+
81
+ if (aggregateByDataRoot.size >= MAX_PAYLOAD_ATTESTATIONS_PER_SLOT) {
82
+ throw new OpPoolError({code: OpPoolErrorCode.REACHED_MAX_PER_SLOT});
83
+ }
84
+
85
+ const aggregate = aggregateByDataRoot.get(payloadAttDataRootHex);
86
+ if (aggregate) {
87
+ // Aggregate msg into aggregate
88
+ return aggregateMessageInto(message, validatorCommitteeIndex, aggregate);
89
+ }
90
+ // Create a new aggregate with data
91
+ aggregateByDataRoot.set(payloadAttDataRootHex, messageToAggregate(message, validatorCommitteeIndex));
92
+
93
+ return InsertOutcome.NewData;
94
+ }
95
+
96
+ /**
97
+ * Get payload attestations to be included in a block.
98
+ * Pick the top `maxAttestation` number of attestations with the most votes
99
+ */
100
+ getPayloadAttestationsForBlock(
101
+ beaconBlockRoot: BlockRootHex,
102
+ slot: Slot,
103
+ maxAttestation: number
104
+ ): gloas.PayloadAttestation[] {
105
+ const aggregateByDataRootByBlockRoot = this.aggregateByDataRootByBlockRootBySlot.get(slot);
106
+
107
+ if (!aggregateByDataRootByBlockRoot) {
108
+ this.metrics?.opPool.payloadAttestationPool.getPayloadAttestationsCacheMisses.inc();
109
+ return [];
110
+ }
111
+
112
+ const aggregateByDataRoot = aggregateByDataRootByBlockRoot.get(beaconBlockRoot);
113
+
114
+ if (!aggregateByDataRoot) {
115
+ this.metrics?.opPool.payloadAttestationPool.getPayloadAttestationsCacheMisses.inc();
116
+ return [];
117
+ }
118
+
119
+ return Array.from(aggregateByDataRoot.values())
120
+ .slice()
121
+ .sort((a, b) => b.aggregationBits.getTrueBitIndexes().length - a.aggregationBits.getTrueBitIndexes().length)
122
+ .slice(0, maxAttestation)
123
+ .map(fastToPayloadAttestation);
124
+ }
125
+
126
+ prune(clockSlot: Slot): void {
127
+ pruneBySlot(this.aggregateByDataRootByBlockRootBySlot, clockSlot, SLOTS_RETAINED);
128
+ this.lowestPermissibleSlot = clockSlot;
129
+ }
130
+ }
131
+
132
+ function messageToAggregate(message: gloas.PayloadAttestationMessage, validatorCommitteeIndex: number): AggregateFast {
133
+ return {
134
+ aggregationBits: BitArray.fromSingleBit(PTC_SIZE, validatorCommitteeIndex),
135
+ data: message.data,
136
+ signature: signatureFromBytesNoCheck(message.signature),
137
+ };
138
+ }
139
+
140
+ function aggregateMessageInto(
141
+ message: gloas.PayloadAttestationMessage,
142
+ validatorCommitteeIndex: number,
143
+ aggregate: AggregateFast
144
+ ): InsertOutcome {
145
+ if (aggregate.aggregationBits.get(validatorCommitteeIndex) === true) {
146
+ return InsertOutcome.AlreadyKnown;
147
+ }
148
+
149
+ aggregate.aggregationBits.set(validatorCommitteeIndex, true);
150
+ aggregate.signature = aggregateSignatures([aggregate.signature, signatureFromBytesNoCheck(message.signature)]);
151
+
152
+ return InsertOutcome.Aggregated;
153
+ }
154
+
155
+ function fastToPayloadAttestation(aggFast: AggregateFast): gloas.PayloadAttestation {
156
+ return {...aggFast, signature: aggFast.signature.toBytes()};
157
+ }
@@ -80,9 +80,8 @@ export class PrepareNextSlotScheduler {
80
80
  await sleep(this.config.getSlotComponentDurationMs(PREPARE_NEXT_SLOT_BPS), this.signal);
81
81
 
82
82
  // calling updateHead() here before we produce a block to reduce reorg possibility
83
- const {slot: headSlot, blockRoot: headRoot} = this.chain.recomputeForkChoiceHead(
84
- ForkchoiceCaller.prepareNextSlot
85
- );
83
+ const headBlock = this.chain.recomputeForkChoiceHead(ForkchoiceCaller.prepareNextSlot);
84
+ const {slot: headSlot, blockRoot: headRoot} = headBlock;
86
85
 
87
86
  // PS: previously this was comparing slots, but that gave no leway on the skipped
88
87
  // slots on epoch bounday. Making it more fluid.
@@ -112,7 +111,7 @@ export class PrepareNextSlotScheduler {
112
111
  // Pre Bellatrix: we only do precompute state transition for the last slot of epoch
113
112
  // For Bellatrix, we always do the `processSlots()` to prepare payload for the next slot
114
113
  const prepareState = await this.chain.regen.getBlockSlotState(
115
- headRoot,
114
+ headBlock,
116
115
  prepareSlot,
117
116
  // the slot 0 of next epoch will likely use this Previous Root Checkpoint state for state transition so we transfer cache here
118
117
  // the resulting state with cache will be cached in Checkpoint State Cache which is used for the upcoming block processing
@@ -129,7 +128,8 @@ export class PrepareNextSlotScheduler {
129
128
 
130
129
  if (feeRecipient) {
131
130
  // If we are proposing next slot, we need to predict if we can proposer-boost-reorg or not
132
- const {slot: proposerHeadSlot, blockRoot: proposerHeadRoot} = this.chain.predictProposerHead(clockSlot);
131
+ const proposerHead = this.chain.predictProposerHead(clockSlot);
132
+ const {slot: proposerHeadSlot, blockRoot: proposerHeadRoot} = proposerHead;
133
133
 
134
134
  // If we predict we can reorg, update prepareState with proposer head block
135
135
  if (proposerHeadRoot !== headRoot || proposerHeadSlot !== headSlot) {
@@ -141,7 +141,7 @@ export class PrepareNextSlotScheduler {
141
141
  });
142
142
  this.metrics?.weakHeadDetected.inc();
143
143
  updatedPrepareState = (await this.chain.regen.getBlockSlotState(
144
- proposerHeadRoot,
144
+ proposerHead,
145
145
  prepareSlot,
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},
@@ -1,5 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {getSafeExecutionBlockHash} from "@lodestar/fork-choice";
2
+ import {ProtoBlock, getSafeExecutionBlockHash} from "@lodestar/fork-choice";
3
3
  import {
4
4
  ForkName,
5
5
  ForkPostBellatrix,
@@ -43,7 +43,7 @@ import {
43
43
  electra,
44
44
  fulu,
45
45
  } from "@lodestar/types";
46
- import {Logger, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
46
+ import {Logger, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
47
47
  import {ZERO_HASH_HEX} from "../../constants/index.js";
48
48
  import {numToQuantity} from "../../execution/engine/utils.js";
49
49
  import {
@@ -86,7 +86,7 @@ export type BlockAttributes = {
86
86
  randaoReveal: BLSSignature;
87
87
  graffiti: Bytes32;
88
88
  slot: Slot;
89
- parentBlockRoot: Root;
89
+ parentBlock: ProtoBlock;
90
90
  feeRecipient?: string;
91
91
  };
92
92
 
@@ -155,13 +155,14 @@ export async function produceBlockBody<T extends BlockType>(
155
155
  const {
156
156
  slot: blockSlot,
157
157
  feeRecipient: requestedFeeRecipient,
158
- parentBlockRoot,
158
+ parentBlock,
159
159
  proposerIndex,
160
160
  proposerPubKey,
161
161
  commonBlockBodyPromise,
162
162
  } = blockAttr;
163
163
  let executionPayloadValue: Wei;
164
164
  let blockBody: AssembledBodyType<T>;
165
+ const parentBlockRoot = fromHex(parentBlock.blockRoot);
165
166
  // even though shouldOverrideBuilder is relevant for the engine response, for simplicity of typing
166
167
  // we just return it undefined for the builder which anyway doesn't get consumed downstream
167
168
  let shouldOverrideBuilder: boolean | undefined;
@@ -637,7 +638,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
637
638
  this: BeaconChain,
638
639
  blockType: T,
639
640
  currentState: CachedBeaconStateAllForks,
640
- {randaoReveal, graffiti, slot, parentBlockRoot}: BlockAttributes
641
+ {randaoReveal, graffiti, slot, parentBlock}: BlockAttributes
641
642
  ): Promise<CommonBlockBody> {
642
643
  const stepsMetrics =
643
644
  blockType === BlockType.Full
@@ -691,6 +692,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
691
692
 
692
693
  const endSyncAggregate = stepsMetrics?.startTimer();
693
694
  if (ForkSeq[fork] >= ForkSeq.altair) {
695
+ const parentBlockRoot = fromHex(parentBlock.blockRoot);
694
696
  const previousSlot = slot - 1;
695
697
  const syncAggregate = this.syncContributionAndProofPool.getAggregate(previousSlot, parentBlockRoot);
696
698
  this.metrics?.production.producedSyncAggregateParticipants.observe(
@@ -18,6 +18,7 @@ export enum RegenCaller {
18
18
  validateGossipAggregateAndProof = "validateGossipAggregateAndProof",
19
19
  validateGossipAttestation = "validateGossipAttestation",
20
20
  validateGossipVoluntaryExit = "validateGossipVoluntaryExit",
21
+ validateGossipExecutionPayloadBid = "validateGossipExecutionPayloadBid",
21
22
  onForkChoiceFinalized = "onForkChoiceFinalized",
22
23
  restApi = "restApi",
23
24
  }
@@ -26,7 +27,6 @@ export enum RegenFnName {
26
27
  getBlockSlotState = "getBlockSlotState",
27
28
  getState = "getState",
28
29
  getPreState = "getPreState",
29
- getCheckpointState = "getCheckpointState",
30
30
  }
31
31
 
32
32
  export type StateRegenerationOpts = {
@@ -63,21 +63,11 @@ export interface IStateRegeneratorInternal {
63
63
  rCaller: RegenCaller
64
64
  ): Promise<CachedBeaconStateAllForks>;
65
65
 
66
- /**
67
- * Return a valid checkpoint state
68
- * This will always return a state with `state.slot % SLOTS_PER_EPOCH === 0`
69
- */
70
- getCheckpointState(
71
- cp: phase0.Checkpoint,
72
- opts: StateRegenerationOpts,
73
- rCaller: RegenCaller
74
- ): Promise<CachedBeaconStateAllForks>;
75
-
76
66
  /**
77
67
  * Return the state of `blockRoot` processed to slot `slot`
78
68
  */
79
69
  getBlockSlotState(
80
- blockRoot: RootHex,
70
+ block: ProtoBlock,
81
71
  slot: Slot,
82
72
  opts: StateRegenerationOpts,
83
73
  rCaller: RegenCaller
@@ -5,7 +5,7 @@ import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
5
5
  import {Logger, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
7
7
  import {JobItemQueue} from "../../util/queue/index.js";
8
- import {CheckpointHex, toCheckpointHex} from "../stateCache/index.js";
8
+ import {CheckpointHex} from "../stateCache/index.js";
9
9
  import {BlockStateCache, CheckpointStateCache} from "../stateCache/types.js";
10
10
  import {RegenError, RegenErrorCode} from "./errors.js";
11
11
  import {
@@ -220,24 +220,6 @@ export class QueuedStateRegenerator implements IStateRegenerator {
220
220
  return this.jobQueue.push({key: "getPreState", args: [block, opts, rCaller]});
221
221
  }
222
222
 
223
- async getCheckpointState(
224
- cp: phase0.Checkpoint,
225
- opts: StateRegenerationOpts,
226
- rCaller: RegenCaller
227
- ): Promise<CachedBeaconStateAllForks> {
228
- this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getCheckpointState});
229
-
230
- // First attempt to fetch the state from cache before queueing
231
- const checkpointState = this.checkpointStateCache.get(toCheckpointHex(cp));
232
- if (checkpointState) {
233
- return checkpointState;
234
- }
235
-
236
- // The state is not immediately available in the caches, enqueue the job
237
- this.metrics?.regenFnQueuedTotal.inc({caller: rCaller, entrypoint: RegenFnName.getCheckpointState});
238
- return this.jobQueue.push({key: "getCheckpointState", args: [cp, opts, rCaller]});
239
- }
240
-
241
223
  /**
242
224
  * Get state of provided `blockRoot` and dial forward to `slot`
243
225
  * Use this api with care because we don't want the queue to be busy
@@ -245,7 +227,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
245
227
  * @returns
246
228
  */
247
229
  async getBlockSlotState(
248
- blockRoot: RootHex,
230
+ block: ProtoBlock,
249
231
  slot: Slot,
250
232
  opts: StateRegenerationOpts,
251
233
  rCaller: RegenCaller
@@ -253,7 +235,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
253
235
  this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getBlockSlotState});
254
236
 
255
237
  // The state is not immediately available in the caches, enqueue the job
256
- return this.jobQueue.push({key: "getBlockSlotState", args: [blockRoot, slot, opts, rCaller]});
238
+ return this.jobQueue.push({key: "getBlockSlotState", args: [block, slot, opts, rCaller]});
257
239
  }
258
240
 
259
241
  async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<CachedBeaconStateAllForks> {
@@ -281,8 +263,6 @@ export class QueuedStateRegenerator implements IStateRegenerator {
281
263
  switch (regenRequest.key) {
282
264
  case "getPreState":
283
265
  return await this.regen.getPreState(...regenRequest.args);
284
- case "getCheckpointState":
285
- return await this.regen.getCheckpointState(...regenRequest.args);
286
266
  case "getBlockSlotState":
287
267
  return await this.regen.getBlockSlotState(...regenRequest.args);
288
268
  case "getState":