@lodestar/beacon-node 1.40.0-dev.3be9500fa9 → 1.40.0-dev.45b04262dc

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 (445) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +23 -27
  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 +29 -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/api/rest/base.d.ts.map +1 -1
  19. package/lib/api/rest/base.js +12 -10
  20. package/lib/api/rest/base.js.map +1 -1
  21. package/lib/chain/ColumnReconstructionTracker.d.ts +2 -0
  22. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  23. package/lib/chain/ColumnReconstructionTracker.js +7 -3
  24. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  25. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  26. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +2 -1
  27. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  28. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  29. package/lib/chain/archiveStore/utils/archiveBlocks.js +4 -0
  30. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  31. package/lib/chain/blocks/blockInput/blockInput.d.ts +30 -0
  32. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  33. package/lib/chain/blocks/blockInput/blockInput.js +44 -3
  34. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  35. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  36. package/lib/chain/blocks/importBlock.js +3 -7
  37. package/lib/chain/blocks/importBlock.js.map +1 -1
  38. package/lib/chain/blocks/index.d.ts.map +1 -1
  39. package/lib/chain/blocks/index.js +0 -14
  40. package/lib/chain/blocks/index.js.map +1 -1
  41. package/lib/chain/blocks/types.d.ts +0 -2
  42. package/lib/chain/blocks/types.d.ts.map +1 -1
  43. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  44. package/lib/chain/blocks/verifyBlock.js +1 -8
  45. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  47. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  48. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
  49. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  50. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  51. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +1 -2
  52. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  53. package/lib/chain/blocks/writeBlockInputToDb.d.ts +1 -4
  54. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  55. package/lib/chain/blocks/writeBlockInputToDb.js +28 -28
  56. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  57. package/lib/chain/bls/multithread/index.d.ts +3 -1
  58. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  59. package/lib/chain/bls/multithread/index.js +5 -3
  60. package/lib/chain/bls/multithread/index.js.map +1 -1
  61. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  62. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  63. package/lib/chain/bls/multithread/jobItem.js +2 -2
  64. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  65. package/lib/chain/bls/singleThread.d.ts +4 -2
  66. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  67. package/lib/chain/bls/singleThread.js +4 -2
  68. package/lib/chain/bls/singleThread.js.map +1 -1
  69. package/lib/chain/bls/utils.d.ts +2 -2
  70. package/lib/chain/bls/utils.d.ts.map +1 -1
  71. package/lib/chain/bls/utils.js +9 -6
  72. package/lib/chain/bls/utils.js.map +1 -1
  73. package/lib/chain/chain.d.ts +22 -5
  74. package/lib/chain/chain.d.ts.map +1 -1
  75. package/lib/chain/chain.js +197 -44
  76. package/lib/chain/chain.js.map +1 -1
  77. package/lib/chain/errors/attestationError.d.ts +14 -1
  78. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  79. package/lib/chain/errors/attestationError.js +8 -0
  80. package/lib/chain/errors/attestationError.js.map +1 -1
  81. package/lib/chain/errors/executionPayloadBid.d.ts +48 -0
  82. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -0
  83. package/lib/chain/errors/executionPayloadBid.js +15 -0
  84. package/lib/chain/errors/executionPayloadBid.js.map +1 -0
  85. package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
  86. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -0
  87. package/lib/chain/errors/executionPayloadEnvelope.js +16 -0
  88. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -0
  89. package/lib/chain/errors/index.d.ts +3 -0
  90. package/lib/chain/errors/index.d.ts.map +1 -1
  91. package/lib/chain/errors/index.js +3 -0
  92. package/lib/chain/errors/index.js.map +1 -1
  93. package/lib/chain/errors/payloadAttestation.d.ts +34 -0
  94. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -0
  95. package/lib/chain/errors/payloadAttestation.js +13 -0
  96. package/lib/chain/errors/payloadAttestation.js.map +1 -0
  97. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  98. package/lib/chain/forkChoice/index.js +18 -0
  99. package/lib/chain/forkChoice/index.js.map +1 -1
  100. package/lib/chain/initState.d.ts.map +1 -1
  101. package/lib/chain/initState.js +2 -2
  102. package/lib/chain/initState.js.map +1 -1
  103. package/lib/chain/interface.d.ts +21 -3
  104. package/lib/chain/interface.d.ts.map +1 -1
  105. package/lib/chain/interface.js.map +1 -1
  106. package/lib/chain/lightClient/index.d.ts.map +1 -1
  107. package/lib/chain/lightClient/index.js +1 -2
  108. package/lib/chain/lightClient/index.js.map +1 -1
  109. package/lib/chain/opPools/executionPayloadBidPool.d.ts +21 -0
  110. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -0
  111. package/lib/chain/opPools/executionPayloadBidPool.js +57 -0
  112. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -0
  113. package/lib/chain/opPools/index.d.ts +2 -0
  114. package/lib/chain/opPools/index.d.ts.map +1 -1
  115. package/lib/chain/opPools/index.js +2 -0
  116. package/lib/chain/opPools/index.js.map +1 -1
  117. package/lib/chain/opPools/payloadAttestationPool.d.ts +24 -0
  118. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -0
  119. package/lib/chain/opPools/payloadAttestationPool.js +109 -0
  120. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -0
  121. package/lib/chain/options.d.ts +0 -1
  122. package/lib/chain/options.d.ts.map +1 -1
  123. package/lib/chain/options.js +0 -1
  124. package/lib/chain/options.js.map +1 -1
  125. package/lib/chain/prepareNextSlot.js +6 -4
  126. package/lib/chain/prepareNextSlot.js.map +1 -1
  127. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  128. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  129. package/lib/chain/produceBlock/produceBlockBody.js +5 -3
  130. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  131. package/lib/chain/regen/interface.d.ts +4 -9
  132. package/lib/chain/regen/interface.d.ts.map +1 -1
  133. package/lib/chain/regen/interface.js +1 -1
  134. package/lib/chain/regen/interface.js.map +1 -1
  135. package/lib/chain/regen/queued.d.ts +2 -3
  136. package/lib/chain/regen/queued.d.ts.map +1 -1
  137. package/lib/chain/regen/queued.js +2 -16
  138. package/lib/chain/regen/queued.js.map +1 -1
  139. package/lib/chain/regen/regen.d.ts +5 -7
  140. package/lib/chain/regen/regen.d.ts.map +1 -1
  141. package/lib/chain/regen/regen.js +7 -17
  142. package/lib/chain/regen/regen.js.map +1 -1
  143. package/lib/chain/seenCache/index.d.ts +3 -1
  144. package/lib/chain/seenCache/index.d.ts.map +1 -1
  145. package/lib/chain/seenCache/index.js +3 -1
  146. package/lib/chain/seenCache/index.js.map +1 -1
  147. package/lib/chain/seenCache/seenAttesters.d.ts +5 -0
  148. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  149. package/lib/chain/seenCache/seenAttesters.js +5 -0
  150. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  151. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +12 -0
  152. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -0
  153. package/lib/chain/seenCache/seenExecutionPayloadBids.js +30 -0
  154. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -0
  155. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +15 -0
  156. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +1 -0
  157. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +28 -0
  158. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +1 -0
  159. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  160. package/lib/chain/seenCache/seenGossipBlockInput.js +3 -3
  161. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  162. package/lib/chain/serializeState.d.ts.map +1 -1
  163. package/lib/chain/serializeState.js +2 -1
  164. package/lib/chain/serializeState.js.map +1 -1
  165. package/lib/chain/stateCache/index.d.ts +0 -2
  166. package/lib/chain/stateCache/index.d.ts.map +1 -1
  167. package/lib/chain/stateCache/index.js +0 -2
  168. package/lib/chain/stateCache/index.js.map +1 -1
  169. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +2 -1
  170. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  171. package/lib/chain/stateCache/persistentCheckpointsCache.js +3 -0
  172. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  173. package/lib/chain/validation/aggregateAndProof.js +35 -14
  174. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  175. package/lib/chain/validation/attestation.d.ts +2 -2
  176. package/lib/chain/validation/attestation.d.ts.map +1 -1
  177. package/lib/chain/validation/attestation.js +27 -8
  178. package/lib/chain/validation/attestation.js.map +1 -1
  179. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  180. package/lib/chain/validation/attesterSlashing.js +1 -1
  181. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  182. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  183. package/lib/chain/validation/blobSidecar.js +5 -5
  184. package/lib/chain/validation/blobSidecar.js.map +1 -1
  185. package/lib/chain/validation/block.d.ts.map +1 -1
  186. package/lib/chain/validation/block.js +6 -6
  187. package/lib/chain/validation/block.js.map +1 -1
  188. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  189. package/lib/chain/validation/dataColumnSidecar.js +5 -5
  190. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  191. package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
  192. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -0
  193. package/lib/chain/validation/executionPayloadBid.js +104 -0
  194. package/lib/chain/validation/executionPayloadBid.js.map +1 -0
  195. package/lib/chain/validation/executionPayloadEnvelope.d.ts +5 -0
  196. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -0
  197. package/lib/chain/validation/executionPayloadEnvelope.js +89 -0
  198. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -0
  199. package/lib/chain/validation/payloadAttestationMessage.d.ts +9 -0
  200. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -0
  201. package/lib/chain/validation/payloadAttestationMessage.js +72 -0
  202. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -0
  203. package/lib/chain/validation/proposerSlashing.js +1 -1
  204. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  205. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +2 -3
  206. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
  207. package/lib/chain/validation/signatureSets/aggregateAndProof.js +8 -3
  208. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  209. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  210. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  211. package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -3
  212. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  213. package/lib/chain/validation/signatureSets/selectionProof.d.ts +2 -3
  214. package/lib/chain/validation/signatureSets/selectionProof.d.ts.map +1 -1
  215. package/lib/chain/validation/signatureSets/selectionProof.js +8 -3
  216. package/lib/chain/validation/signatureSets/selectionProof.js.map +1 -1
  217. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  218. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  219. package/lib/chain/validation/signatureSets/syncCommittee.js +3 -3
  220. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  221. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +1 -2
  222. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  223. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  224. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  225. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  226. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  227. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +3 -3
  228. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  229. package/lib/chain/validation/syncCommittee.js +1 -1
  230. package/lib/chain/validation/syncCommittee.js.map +1 -1
  231. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  232. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -5
  233. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  234. package/lib/chain/validation/voluntaryExit.js +1 -1
  235. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  236. package/lib/chain/validatorMonitor.d.ts +2 -0
  237. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  238. package/lib/chain/validatorMonitor.js +49 -7
  239. package/lib/chain/validatorMonitor.js.map +1 -1
  240. package/lib/db/repositories/checkpointState.js +0 -1
  241. package/lib/db/repositories/checkpointState.js.map +1 -1
  242. package/lib/metrics/metrics/lodestar.d.ts +27 -0
  243. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  244. package/lib/metrics/metrics/lodestar.js +64 -0
  245. package/lib/metrics/metrics/lodestar.js.map +1 -1
  246. package/lib/network/core/networkCore.d.ts +3 -0
  247. package/lib/network/core/networkCore.d.ts.map +1 -1
  248. package/lib/network/core/networkCore.js +9 -0
  249. package/lib/network/core/networkCore.js.map +1 -1
  250. package/lib/network/core/networkCoreWorker.js +3 -0
  251. package/lib/network/core/networkCoreWorker.js.map +1 -1
  252. package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -0
  253. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  254. package/lib/network/core/networkCoreWorkerHandler.js +9 -0
  255. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  256. package/lib/network/core/types.d.ts +3 -0
  257. package/lib/network/core/types.d.ts.map +1 -1
  258. package/lib/network/gossip/gossipsub.d.ts +34 -0
  259. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  260. package/lib/network/gossip/gossipsub.js +123 -0
  261. package/lib/network/gossip/gossipsub.js.map +1 -1
  262. package/lib/network/gossip/interface.d.ts +20 -2
  263. package/lib/network/gossip/interface.d.ts.map +1 -1
  264. package/lib/network/gossip/interface.js +3 -0
  265. package/lib/network/gossip/interface.js.map +1 -1
  266. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  267. package/lib/network/gossip/scoringParameters.js +38 -2
  268. package/lib/network/gossip/scoringParameters.js.map +1 -1
  269. package/lib/network/gossip/topic.d.ts +77 -1
  270. package/lib/network/gossip/topic.d.ts.map +1 -1
  271. package/lib/network/gossip/topic.js +20 -0
  272. package/lib/network/gossip/topic.js.map +1 -1
  273. package/lib/network/network.d.ts +3 -0
  274. package/lib/network/network.d.ts.map +1 -1
  275. package/lib/network/network.js +9 -0
  276. package/lib/network/network.js.map +1 -1
  277. package/lib/network/options.d.ts +6 -0
  278. package/lib/network/options.d.ts.map +1 -1
  279. package/lib/network/options.js.map +1 -1
  280. package/lib/network/peers/peerManager.d.ts.map +1 -1
  281. package/lib/network/peers/peerManager.js +9 -0
  282. package/lib/network/peers/peerManager.js.map +1 -1
  283. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  284. package/lib/network/processor/gossipHandlers.js +35 -4
  285. package/lib/network/processor/gossipHandlers.js.map +1 -1
  286. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  287. package/lib/network/processor/gossipQueues/index.js +16 -0
  288. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  289. package/lib/network/processor/index.d.ts.map +1 -1
  290. package/lib/network/processor/index.js +3 -0
  291. package/lib/network/processor/index.js.map +1 -1
  292. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  293. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -4
  294. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  295. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts +1 -2
  296. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  297. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +5 -26
  298. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  299. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +1 -2
  300. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  301. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +5 -7
  302. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  303. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  304. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -2
  305. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  306. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  307. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -5
  308. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  309. package/lib/network/reqresp/handlers/index.js +2 -2
  310. package/lib/network/reqresp/handlers/index.js.map +1 -1
  311. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  312. package/lib/sync/backfill/backfill.js +3 -4
  313. package/lib/sync/backfill/backfill.js.map +1 -1
  314. package/lib/sync/backfill/verify.d.ts +1 -2
  315. package/lib/sync/backfill/verify.d.ts.map +1 -1
  316. package/lib/sync/backfill/verify.js +2 -2
  317. package/lib/sync/backfill/verify.js.map +1 -1
  318. package/lib/sync/range/chain.d.ts.map +1 -1
  319. package/lib/sync/range/chain.js +0 -1
  320. package/lib/sync/range/chain.js.map +1 -1
  321. package/lib/sync/range/range.d.ts.map +1 -1
  322. package/lib/sync/range/range.js +0 -3
  323. package/lib/sync/range/range.js.map +1 -1
  324. package/lib/sync/unknownBlock.d.ts.map +1 -1
  325. package/lib/sync/unknownBlock.js +0 -3
  326. package/lib/sync/unknownBlock.js.map +1 -1
  327. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  328. package/lib/sync/utils/downloadByRange.js +2 -2
  329. package/lib/sync/utils/downloadByRange.js.map +1 -1
  330. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  331. package/lib/sync/utils/downloadByRoot.js +1 -2
  332. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  333. package/package.json +16 -16
  334. package/src/api/impl/beacon/blocks/index.ts +39 -37
  335. package/src/api/impl/config/constants.ts +8 -0
  336. package/src/api/impl/debug/index.ts +2 -6
  337. package/src/api/impl/lodestar/index.ts +35 -3
  338. package/src/api/impl/validator/index.ts +14 -12
  339. package/src/api/rest/base.ts +15 -13
  340. package/src/chain/ColumnReconstructionTracker.ts +8 -4
  341. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +2 -1
  342. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -0
  343. package/src/chain/blocks/blockInput/blockInput.ts +55 -4
  344. package/src/chain/blocks/importBlock.ts +3 -7
  345. package/src/chain/blocks/index.ts +0 -19
  346. package/src/chain/blocks/types.ts +0 -2
  347. package/src/chain/blocks/verifyBlock.ts +0 -9
  348. package/src/chain/blocks/verifyBlocksSignatures.ts +4 -12
  349. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +1 -2
  350. package/src/chain/blocks/writeBlockInputToDb.ts +33 -30
  351. package/src/chain/bls/multithread/index.ts +7 -4
  352. package/src/chain/bls/multithread/jobItem.ts +7 -3
  353. package/src/chain/bls/singleThread.ts +5 -3
  354. package/src/chain/bls/utils.ts +15 -7
  355. package/src/chain/chain.ts +227 -56
  356. package/src/chain/errors/attestationError.ts +11 -1
  357. package/src/chain/errors/executionPayloadBid.ts +35 -0
  358. package/src/chain/errors/executionPayloadEnvelope.ts +34 -0
  359. package/src/chain/errors/index.ts +3 -0
  360. package/src/chain/errors/payloadAttestation.ts +25 -0
  361. package/src/chain/forkChoice/index.ts +19 -0
  362. package/src/chain/initState.ts +2 -2
  363. package/src/chain/interface.ts +32 -1
  364. package/src/chain/lightClient/index.ts +1 -2
  365. package/src/chain/opPools/executionPayloadBidPool.ts +77 -0
  366. package/src/chain/opPools/index.ts +2 -0
  367. package/src/chain/opPools/payloadAttestationPool.ts +157 -0
  368. package/src/chain/options.ts +0 -2
  369. package/src/chain/prepareNextSlot.ts +6 -6
  370. package/src/chain/produceBlock/produceBlockBody.ts +7 -5
  371. package/src/chain/regen/interface.ts +3 -13
  372. package/src/chain/regen/queued.ts +3 -24
  373. package/src/chain/regen/regen.ts +10 -25
  374. package/src/chain/seenCache/index.ts +3 -1
  375. package/src/chain/seenCache/seenAttesters.ts +5 -0
  376. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -0
  377. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +34 -0
  378. package/src/chain/seenCache/seenGossipBlockInput.ts +3 -3
  379. package/src/chain/serializeState.ts +2 -1
  380. package/src/chain/stateCache/index.ts +0 -2
  381. package/src/chain/stateCache/persistentCheckpointsCache.ts +6 -2
  382. package/src/chain/validation/aggregateAndProof.ts +36 -14
  383. package/src/chain/validation/attestation.ts +33 -16
  384. package/src/chain/validation/attesterSlashing.ts +1 -6
  385. package/src/chain/validation/blobSidecar.ts +4 -9
  386. package/src/chain/validation/block.ts +6 -6
  387. package/src/chain/validation/dataColumnSidecar.ts +4 -9
  388. package/src/chain/validation/executionPayloadBid.ts +141 -0
  389. package/src/chain/validation/executionPayloadEnvelope.ts +122 -0
  390. package/src/chain/validation/payloadAttestationMessage.ts +109 -0
  391. package/src/chain/validation/proposerSlashing.ts +1 -6
  392. package/src/chain/validation/signatureSets/aggregateAndProof.ts +9 -14
  393. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -4
  394. package/src/chain/validation/signatureSets/selectionProof.ts +9 -9
  395. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -4
  396. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  397. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -4
  398. package/src/chain/validation/syncCommittee.ts +1 -1
  399. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -5
  400. package/src/chain/validation/voluntaryExit.ts +1 -1
  401. package/src/chain/validatorMonitor.ts +62 -8
  402. package/src/db/repositories/checkpointState.ts +1 -1
  403. package/src/metrics/metrics/lodestar.ts +65 -0
  404. package/src/network/core/networkCore.ts +12 -0
  405. package/src/network/core/networkCoreWorker.ts +3 -0
  406. package/src/network/core/networkCoreWorkerHandler.ts +9 -0
  407. package/src/network/core/types.ts +6 -0
  408. package/src/network/gossip/gossipsub.ts +147 -1
  409. package/src/network/gossip/interface.ts +17 -0
  410. package/src/network/gossip/scoringParameters.ts +44 -2
  411. package/src/network/gossip/topic.ts +21 -0
  412. package/src/network/network.ts +12 -0
  413. package/src/network/options.ts +6 -0
  414. package/src/network/peers/peerManager.ts +11 -0
  415. package/src/network/processor/gossipHandlers.ts +49 -4
  416. package/src/network/processor/gossipQueues/index.ts +16 -0
  417. package/src/network/processor/index.ts +3 -0
  418. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -4
  419. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +5 -32
  420. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -9
  421. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +5 -2
  422. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -5
  423. package/src/network/reqresp/handlers/index.ts +2 -2
  424. package/src/sync/backfill/backfill.ts +3 -4
  425. package/src/sync/backfill/verify.ts +2 -3
  426. package/src/sync/range/chain.ts +0 -1
  427. package/src/sync/range/range.ts +0 -3
  428. package/src/sync/unknownBlock.ts +0 -3
  429. package/src/sync/utils/downloadByRange.ts +2 -2
  430. package/src/sync/utils/downloadByRoot.ts +1 -2
  431. package/lib/chain/stateCache/blockStateCacheImpl.d.ts +0 -54
  432. package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +0 -1
  433. package/lib/chain/stateCache/blockStateCacheImpl.js +0 -130
  434. package/lib/chain/stateCache/blockStateCacheImpl.js.map +0 -1
  435. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts +0 -60
  436. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +0 -1
  437. package/lib/chain/stateCache/inMemoryCheckpointsCache.js +0 -156
  438. package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +0 -1
  439. package/lib/util/bytes.d.ts +0 -3
  440. package/lib/util/bytes.d.ts.map +0 -1
  441. package/lib/util/bytes.js +0 -11
  442. package/lib/util/bytes.js.map +0 -1
  443. package/src/chain/stateCache/blockStateCacheImpl.ts +0 -149
  444. package/src/chain/stateCache/inMemoryCheckpointsCache.ts +0 -192
  445. package/src/util/bytes.ts +0 -11
@@ -11,13 +11,14 @@ import {
11
11
  processSlots,
12
12
  stateTransition,
13
13
  } from "@lodestar/state-transition";
14
- import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, phase0} from "@lodestar/types";
14
+ import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
15
15
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
16
16
  import {IBeaconDb} from "../../db/index.js";
17
17
  import {Metrics} from "../../metrics/index.js";
18
18
  import {nextEventLoop} from "../../util/eventLoop.js";
19
19
  import {getCheckpointFromState} from "../blocks/utils/checkpoint.js";
20
20
  import {ChainEvent, ChainEventEmitter} from "../emitter.js";
21
+ import {SeenBlockInput} from "../seenCache/seenGossipBlockInput.js";
21
22
  import {BlockStateCache, CheckpointStateCache} from "../stateCache/types.js";
22
23
  import {ValidatorMonitor} from "../validatorMonitor.js";
23
24
  import {RegenError, RegenErrorCode} from "./errors.js";
@@ -28,6 +29,7 @@ export type RegenModules = {
28
29
  forkChoice: IForkChoice;
29
30
  blockStateCache: BlockStateCache;
30
31
  checkpointStateCache: CheckpointStateCache;
32
+ seenBlockInputCache: SeenBlockInput;
31
33
  config: ChainForkConfig;
32
34
  emitter: ChainEventEmitter;
33
35
  logger: Logger;
@@ -74,45 +76,24 @@ export class StateRegenerator implements IStateRegeneratorInternal {
74
76
  // We may have the checkpoint state with parent root inside the checkpoint state cache
75
77
  // through gossip validation.
76
78
  if (parentEpoch < blockEpoch) {
77
- return this.getCheckpointState({root: block.parentRoot, epoch: blockEpoch}, opts, regenCaller, allowDiskReload);
79
+ return this.getBlockSlotState(parentBlock, block.slot, opts, regenCaller, allowDiskReload);
78
80
  }
79
81
 
80
82
  // Otherwise, get the state normally.
81
83
  return this.getState(parentBlock.stateRoot, regenCaller, allowDiskReload);
82
84
  }
83
85
 
84
- /**
85
- * Get state after block `cp.root` dialed forward to first slot of `cp.epoch`
86
- */
87
- async getCheckpointState(
88
- cp: phase0.Checkpoint,
89
- opts: StateRegenerationOpts,
90
- regenCaller: RegenCaller,
91
- allowDiskReload = false
92
- ): Promise<CachedBeaconStateAllForks> {
93
- const checkpointStartSlot = computeStartSlotAtEpoch(cp.epoch);
94
- return this.getBlockSlotState(toRootHex(cp.root), checkpointStartSlot, opts, regenCaller, allowDiskReload);
95
- }
96
-
97
86
  /**
98
87
  * Get state after block `blockRoot` dialed forward to `slot`
99
88
  * - allowDiskReload should be used with care, as it will cause the state to be reloaded from disk
100
89
  */
101
90
  async getBlockSlotState(
102
- blockRoot: RootHex,
91
+ block: ProtoBlock,
103
92
  slot: Slot,
104
93
  opts: StateRegenerationOpts,
105
94
  regenCaller: RegenCaller,
106
95
  allowDiskReload = false
107
96
  ): Promise<CachedBeaconStateAllForks> {
108
- const block = this.modules.forkChoice.getBlockHex(blockRoot);
109
- if (!block) {
110
- throw new RegenError({
111
- code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
112
- blockRoot,
113
- });
114
- }
115
-
116
97
  if (slot < block.slot) {
117
98
  throw new RegenError({
118
99
  code: RegenErrorCode.SLOT_BEFORE_BLOCK_SLOT,
@@ -121,6 +102,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
121
102
  });
122
103
  }
123
104
 
105
+ const {blockRoot} = block;
124
106
  const {checkpointStateCache} = this.modules;
125
107
  const epoch = computeEpochAtSlot(slot);
126
108
  const latestCheckpointStateCtx = allowDiskReload
@@ -211,7 +193,10 @@ export class StateRegenerator implements IStateRegeneratorInternal {
211
193
  const protoBlocksAsc = blocksToReplay.reverse();
212
194
  for (const [i, protoBlock] of protoBlocksAsc.entries()) {
213
195
  replaySlots[i] = protoBlock.slot;
214
- blockPromises[i] = this.modules.db.block.get(fromHex(protoBlock.blockRoot));
196
+ const blockInput = this.modules.seenBlockInputCache.get(protoBlock.blockRoot);
197
+ blockPromises[i] = blockInput?.hasBlock()
198
+ ? Promise.resolve(blockInput.getBlock())
199
+ : this.modules.db.block.get(fromHex(protoBlock.blockRoot));
215
200
  }
216
201
 
217
202
  const logCtx = {stateRoot, caller, replaySlots: replaySlots.join(",")};
@@ -1,5 +1,7 @@
1
- export {SeenAggregators, SeenAttesters} from "./seenAttesters.js";
1
+ export {SeenAggregators, SeenAttesters, SeenPayloadAttesters} from "./seenAttesters.js";
2
2
  export {SeenBlockProposers} from "./seenBlockProposers.js";
3
3
  export {SeenSyncCommitteeMessages} from "./seenCommittee.js";
4
4
  export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
5
+ export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
6
+ export {SeenExecutionPayloadEnvelopes} from "./seenExecutionPayloadEnvelope.js";
5
7
  export {SeenBlockInput} from "./seenGossipBlockInput.js";
@@ -56,3 +56,8 @@ export class SeenAttesters {
56
56
  * Keeps a cache to filter aggregated attestations from the same aggregators in the same epoch
57
57
  */
58
58
  export class SeenAggregators extends SeenAttesters {}
59
+
60
+ /**
61
+ * Keeps a cache to filter payload attestations from the same attesters in the same epoch
62
+ */
63
+ export class SeenPayloadAttesters extends SeenAttesters {}
@@ -0,0 +1,35 @@
1
+ import {BuilderIndex, Slot} from "@lodestar/types";
2
+ import {MapDef} from "@lodestar/utils";
3
+
4
+ /**
5
+ * TODO GLOAS: Revisit this value and add rational for choosing it
6
+ */
7
+ const SLOTS_RETAINED = 2;
8
+
9
+ /**
10
+ * Tracks execution payload bids we've already seen per (slot, builder).
11
+ */
12
+ export class SeenExecutionPayloadBids {
13
+ private readonly builderIndexesBySlot = new MapDef<Slot, Set<BuilderIndex>>(() => new Set<BuilderIndex>());
14
+ private lowestPermissibleSlot: Slot = 0;
15
+
16
+ isKnown(slot: Slot, builderIndex: BuilderIndex): boolean {
17
+ return this.builderIndexesBySlot.get(slot)?.has(builderIndex) === true;
18
+ }
19
+
20
+ add(slot: Slot, builderIndex: BuilderIndex): void {
21
+ if (slot < this.lowestPermissibleSlot) {
22
+ throw Error(`slot ${slot} < lowestPermissibleSlot ${this.lowestPermissibleSlot}`);
23
+ }
24
+ this.builderIndexesBySlot.getOrDefault(slot).add(builderIndex);
25
+ }
26
+
27
+ prune(currentSlot: Slot): void {
28
+ this.lowestPermissibleSlot = Math.max(currentSlot - SLOTS_RETAINED, 0);
29
+ for (const slot of this.builderIndexesBySlot.keys()) {
30
+ if (slot < this.lowestPermissibleSlot) {
31
+ this.builderIndexesBySlot.delete(slot);
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,34 @@
1
+ import {RootHex, Slot} from "@lodestar/types";
2
+
3
+ /**
4
+ * Cache to prevent processing multiple execution payload envelopes for the same block root.
5
+ * Only one builder qualifies to submit an execution payload for a given slot.
6
+ * We only keep track of envelopes of unfinalized slots.
7
+ * [IGNORE] The node has not seen another valid `SignedExecutionPayloadEnvelope` for this block root.
8
+ */
9
+ export class SeenExecutionPayloadEnvelopes {
10
+ private readonly slotByBlockRoot = new Map<RootHex, Slot>();
11
+ private finalizedSlot: Slot = 0;
12
+
13
+ isKnown(blockRoot: RootHex): boolean {
14
+ return this.slotByBlockRoot.has(blockRoot);
15
+ }
16
+
17
+ add(blockRoot: RootHex, slot: Slot): void {
18
+ if (slot < this.finalizedSlot) {
19
+ throw Error(`slot ${slot} < finalizedSlot ${this.finalizedSlot}`);
20
+ }
21
+
22
+ this.slotByBlockRoot.set(blockRoot, slot);
23
+ }
24
+
25
+ prune(finalizedSlot: Slot): void {
26
+ this.finalizedSlot = finalizedSlot;
27
+
28
+ for (const [blockRoot, slot] of this.slotByBlockRoot.entries()) {
29
+ if (slot < finalizedSlot) {
30
+ this.slotByBlockRoot.delete(blockRoot);
31
+ }
32
+ }
33
+ }
34
+ }
@@ -3,7 +3,7 @@ import {CheckpointWithHex} from "@lodestar/fork-choice";
3
3
  import {ForkName, ForkPostFulu, ForkPreGloas, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
4
4
  import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
5
5
  import {BLSSignature, RootHex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
6
- import {LodestarError, Logger, pruneSetToMax} from "@lodestar/utils";
6
+ import {LodestarError, Logger, byteArrayEquals, pruneSetToMax} from "@lodestar/utils";
7
7
  import {Metrics} from "../../metrics/metrics.js";
8
8
  import {IClock} from "../../util/clock.js";
9
9
  import {CustodyConfig} from "../../util/dataColumns.js";
@@ -344,7 +344,7 @@ export class SeenBlockInput {
344
344
  return false;
345
345
  }
346
346
  // Only consider verified if the signature matches
347
- return Buffer.compare(cachedSignature, signature) === 0;
347
+ return byteArrayEquals(cachedSignature, signature);
348
348
  }
349
349
 
350
350
  /**
@@ -379,7 +379,7 @@ export class SeenBlockInput {
379
379
  let itemsToDelete = this.blockInputs.size - MAX_BLOCK_INPUT_CACHE_SIZE;
380
380
 
381
381
  if (itemsToDelete > 0) {
382
- const sorted = [...this.blockInputs.entries()].sort((a, b) => b[1].slot - a[1].slot);
382
+ const sorted = [...this.blockInputs.entries()].sort((a, b) => a[1].slot - b[1].slot);
383
383
  for (const [rootHex] of sorted) {
384
384
  this.blockInputs.delete(rootHex);
385
385
  itemsToDelete--;
@@ -20,7 +20,8 @@ export async function serializeState<T>(
20
20
  stateBytes = bufferWithKey.buffer;
21
21
  const dataView = new DataView(stateBytes.buffer, stateBytes.byteOffset, stateBytes.byteLength);
22
22
  state.serializeToBytes({uint8Array: stateBytes, dataView}, 0);
23
- return processFn(stateBytes);
23
+ // Await to ensure buffer is not released back to pool until processFn completes
24
+ return await processFn(stateBytes);
24
25
  }
25
26
  // release the buffer back to the pool automatically
26
27
  }
@@ -1,3 +1 @@
1
- export * from "./blockStateCacheImpl.js";
2
1
  export * from "./fifoBlockStateCache.js";
3
- export * from "./inMemoryCheckpointsCache.js";
@@ -31,7 +31,7 @@ type PersistentCheckpointStateCacheModules = {
31
31
  signal?: AbortSignal;
32
32
  datastore: CPStateDatastore;
33
33
  blockStateCache: BlockStateCache;
34
- bufferPool?: BufferPool | null;
34
+ bufferPool?: BufferPool;
35
35
  };
36
36
 
37
37
  /** checkpoint serialized as a string */
@@ -119,7 +119,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
119
119
  private readonly maxEpochsOnDisk: number;
120
120
  private readonly datastore: CPStateDatastore;
121
121
  private readonly blockStateCache: BlockStateCache;
122
- private readonly bufferPool?: BufferPool | null;
122
+ private readonly bufferPool?: BufferPool;
123
123
 
124
124
  constructor(
125
125
  {
@@ -851,6 +851,10 @@ export function toCheckpointHex(checkpoint: phase0.Checkpoint): CheckpointHex {
851
851
  };
852
852
  }
853
853
 
854
+ export function toCheckpointKey(cp: CheckpointHex): string {
855
+ return `${cp.rootHex}:${cp.epoch}`;
856
+ }
857
+
854
858
  function toCacheKey(cp: CheckpointHex | phase0.Checkpoint): CacheKey {
855
859
  if (isCheckpointHex(cp)) {
856
860
  return `${cp.rootHex}_${cp.epoch}`;
@@ -71,11 +71,34 @@ async function validateAggregateAndProof(
71
71
  const attData = aggregate.data;
72
72
  const attSlot = attData.slot;
73
73
 
74
- let attIndex: number | null;
75
- if (ForkSeq[fork] >= ForkSeq.electra) {
76
- attIndex = (aggregate as electra.Attestation).committeeBits.getSingleTrueBit();
74
+ let committeeIndex: number | null;
75
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
76
+ // [REJECT] `aggregate.data.index < 2`.
77
+ if (attData.index >= 2) {
78
+ throw new AttestationError(GossipAction.REJECT, {
79
+ code: AttestationErrorCode.INVALID_PAYLOAD_STATUS_VALUE,
80
+ attDataIndex: attData.index,
81
+ });
82
+ }
83
+ // [REJECT] `aggregate.data.index == 0` if `block.slot == aggregate.data.slot`.
84
+ const block = chain.forkChoice.getBlock(attData.beaconBlockRoot);
85
+
86
+ // If block is unknown, we don't handle it here. It will throw error later on at `verifyHeadBlockAndTargetRoot()`
87
+ if (block !== null && block.slot === attData.slot && attData.index !== 0) {
88
+ throw new AttestationError(GossipAction.REJECT, {
89
+ code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT,
90
+ });
91
+ }
92
+
93
+ // [REJECT] len(committee_indices) == 1, where committee_indices = get_committee_indices(aggregate)
94
+ committeeIndex = (aggregate as electra.Attestation).committeeBits.getSingleTrueBit();
95
+ if (committeeIndex === null) {
96
+ throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.NOT_EXACTLY_ONE_COMMITTEE_BIT_SET});
97
+ }
98
+ } else if (ForkSeq[fork] >= ForkSeq.electra) {
99
+ committeeIndex = (aggregate as electra.Attestation).committeeBits.getSingleTrueBit();
77
100
  // [REJECT] len(committee_indices) == 1, where committee_indices = get_committee_indices(aggregate)
78
- if (attIndex === null) {
101
+ if (committeeIndex === null) {
79
102
  throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.NOT_EXACTLY_ONE_COMMITTEE_BIT_SET});
80
103
  }
81
104
  // [REJECT] aggregate.data.index == 0
@@ -83,11 +106,11 @@ async function validateAggregateAndProof(
83
106
  throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.NON_ZERO_ATTESTATION_DATA_INDEX});
84
107
  }
85
108
  } else {
86
- attIndex = attData.index;
109
+ committeeIndex = attData.index;
87
110
  }
88
111
 
89
112
  const seenAttDataKey = serializedData ? getSeenAttDataKeyFromSignedAggregateAndProof(fork, serializedData) : null;
90
- const cachedAttData = seenAttDataKey ? chain.seenAttestationDatas.get(attSlot, attIndex, seenAttDataKey) : null;
113
+ const cachedAttData = seenAttDataKey ? chain.seenAttestationDatas.get(attSlot, committeeIndex, seenAttDataKey) : null;
91
114
 
92
115
  const attEpoch = computeEpochAtSlot(attSlot);
93
116
  const attTarget = attData.target;
@@ -136,7 +159,7 @@ async function validateAggregateAndProof(
136
159
  : toRootHex(ssz.phase0.AttestationData.hashTreeRoot(attData));
137
160
  if (
138
161
  !skipValidationKnownAttesters &&
139
- chain.seenAggregatedAttestations.isKnown(targetEpoch, attIndex, attDataRootHex, aggregationBits)
162
+ chain.seenAggregatedAttestations.isKnown(targetEpoch, committeeIndex, attDataRootHex, aggregationBits)
140
163
  ) {
141
164
  throw new AttestationError(GossipAction.IGNORE, {
142
165
  code: AttestationErrorCode.ATTESTERS_ALREADY_KNOWN,
@@ -177,7 +200,7 @@ async function validateAggregateAndProof(
177
200
  // -- i.e. data.index < get_committee_count_per_slot(state, data.target.epoch)
178
201
  const committeeValidatorIndices = cachedAttData
179
202
  ? cachedAttData.committeeValidatorIndices
180
- : getCommitteeValidatorIndices(shuffling, attSlot, attIndex);
203
+ : getCommitteeValidatorIndices(shuffling, attSlot, committeeIndex);
181
204
 
182
205
  // [REJECT] The number of aggregation bits matches the committee size
183
206
  // -- i.e. `len(aggregation_bits) == len(get_beacon_committee(state, aggregate.data.slot, index))`.
@@ -216,16 +239,15 @@ async function validateAggregateAndProof(
216
239
  // by the validator with index aggregate_and_proof.aggregator_index.
217
240
  // [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
218
241
  // [REJECT] The signature of aggregate is valid.
219
- const aggregator = chain.index2pubkey[aggregateAndProof.aggregatorIndex];
220
242
  const signingRoot = cachedAttData ? cachedAttData.signingRoot : getAttestationDataSigningRoot(chain.config, attData);
221
243
  const indexedAttestationSignatureSet = createAggregateSignatureSetFromComponents(
222
- indexedAttestation.attestingIndices.map((i) => chain.index2pubkey[i]),
244
+ indexedAttestation.attestingIndices,
223
245
  signingRoot,
224
246
  indexedAttestation.signature
225
247
  );
226
248
  const signatureSets = [
227
- getSelectionProofSignatureSet(chain.config, attSlot, aggregator, signedAggregateAndProof),
228
- getAggregateAndProofSignatureSet(chain.config, attEpoch, aggregator, signedAggregateAndProof),
249
+ getSelectionProofSignatureSet(chain.config, attSlot, aggregatorIndex, signedAggregateAndProof),
250
+ getAggregateAndProofSignatureSet(chain.config, attEpoch, aggregatorIndex, signedAggregateAndProof),
229
251
  indexedAttestationSignatureSet,
230
252
  ];
231
253
  // no need to write to SeenAttestationDatas
@@ -248,7 +270,7 @@ async function validateAggregateAndProof(
248
270
  // Same race-condition check as above for seen aggregators
249
271
  if (
250
272
  !skipValidationKnownAttesters &&
251
- chain.seenAggregatedAttestations.isKnown(targetEpoch, attIndex, attDataRootHex, aggregationBits)
273
+ chain.seenAggregatedAttestations.isKnown(targetEpoch, committeeIndex, attDataRootHex, aggregationBits)
252
274
  ) {
253
275
  throw new AttestationError(GossipAction.IGNORE, {
254
276
  code: AttestationErrorCode.ATTESTERS_ALREADY_KNOWN,
@@ -260,7 +282,7 @@ async function validateAggregateAndProof(
260
282
  chain.seenAggregators.add(targetEpoch, aggregatorIndex);
261
283
  chain.seenAggregatedAttestations.add(
262
284
  targetEpoch,
263
- attIndex,
285
+ committeeIndex,
264
286
  attDataRootHex,
265
287
  {aggregationBits, trueBitCount: attestingIndices.length},
266
288
  false
@@ -10,16 +10,17 @@ import {
10
10
  ForkSeq,
11
11
  SLOTS_PER_EPOCH,
12
12
  isForkPostElectra,
13
+ isForkPostGloas,
13
14
  } from "@lodestar/params";
14
15
  import {
15
16
  EpochShuffling,
17
+ IndexedSignatureSet,
16
18
  ShufflingError,
17
19
  ShufflingErrorCode,
18
- SingleSignatureSet,
19
20
  computeEpochAtSlot,
20
21
  computeSigningRoot,
21
22
  computeStartSlotAtEpoch,
22
- createSingleSignatureSetFromComponents,
23
+ createIndexedSignatureSetFromComponents,
23
24
  } from "@lodestar/state-transition";
24
25
  import {
25
26
  CommitteeIndex,
@@ -89,7 +90,7 @@ export type GossipAttestation = {
89
90
  };
90
91
 
91
92
  export type Step0Result = AttestationValidationResult & {
92
- signatureSet: SingleSignatureSet;
93
+ signatureSet: IndexedSignatureSet;
93
94
  validatorIndex: number;
94
95
  };
95
96
 
@@ -124,7 +125,7 @@ export async function validateGossipAttestationsSameAttData(
124
125
  // step1: verify signatures of all valid attestations
125
126
  // map new index to index in resultOrErrors
126
127
  const newIndexToOldIndex = new Map<number, number>();
127
- const signatureSets: SingleSignatureSet[] = [];
128
+ const signatureSets: IndexedSignatureSet[] = [];
128
129
  let newIndex = 0;
129
130
  const step0Results: Step0Result[] = [];
130
131
  for (const [i, resultOrError] of step0ResultOrErrors.entries()) {
@@ -142,7 +143,7 @@ export async function validateGossipAttestationsSameAttData(
142
143
  if (batchableBls) {
143
144
  // all signature sets should have same signing root since we filtered in network processor
144
145
  signatureValids = await chain.bls.verifySignatureSetsSameMessage(
145
- signatureSets.map((set) => ({publicKey: set.pubkey, signature: set.signature})),
146
+ signatureSets.map((set) => ({publicKey: chain.index2pubkey[set.index], signature: set.signature})),
146
147
  signatureSets[0].signingRoot
147
148
  );
148
149
  } else {
@@ -293,9 +294,29 @@ async function validateAttestationNoSignatureCheck(
293
294
  // api or first time validation of a gossip attestation
294
295
  committeeIndex = attestationOrCache.attestation.committeeIndex;
295
296
 
296
- // [REJECT] attestation.data.index == 0
297
- if (attData.index !== 0) {
298
- throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.NON_ZERO_ATTESTATION_DATA_INDEX});
297
+ if (isForkPostGloas(fork)) {
298
+ // [REJECT] `attestation.data.index < 2`.
299
+ if (attData.index >= 2) {
300
+ throw new AttestationError(GossipAction.REJECT, {
301
+ code: AttestationErrorCode.INVALID_PAYLOAD_STATUS_VALUE,
302
+ attDataIndex: attData.index,
303
+ });
304
+ }
305
+
306
+ // [REJECT] `attestation.data.index == 0` if `block.slot == attestation.data.slot`.
307
+ const block = chain.forkChoice.getBlock(attData.beaconBlockRoot);
308
+
309
+ // block being null will be handled by `verifyHeadBlockAndTargetRoot`
310
+ if (block !== null && block.slot === attSlot && attData.index !== 0) {
311
+ throw new AttestationError(GossipAction.REJECT, {
312
+ code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT,
313
+ });
314
+ }
315
+ } else {
316
+ // [REJECT] attestation.data.index == 0
317
+ if (attData.index !== 0) {
318
+ throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.NON_ZERO_ATTESTATION_DATA_INDEX});
319
+ }
299
320
  }
300
321
  } else {
301
322
  // phase0 attestation
@@ -477,7 +498,7 @@ async function validateAttestationNoSignatureCheck(
477
498
 
478
499
  // [REJECT] The signature of attestation is valid.
479
500
  const attestingIndices = [validatorIndex];
480
- let signatureSet: SingleSignatureSet;
501
+ let signatureSet: IndexedSignatureSet;
481
502
  let attDataRootHex: RootHex;
482
503
  const signature = attestationOrCache.attestation
483
504
  ? attestationOrCache.attestation.signature
@@ -492,18 +513,14 @@ async function validateAttestationNoSignatureCheck(
492
513
 
493
514
  if (attestationOrCache.cache) {
494
515
  // there could be up to 6% of cpu time to compute signing root if we don't clone the signature set
495
- signatureSet = createSingleSignatureSetFromComponents(
496
- chain.index2pubkey[validatorIndex],
516
+ signatureSet = createIndexedSignatureSetFromComponents(
517
+ validatorIndex,
497
518
  attestationOrCache.cache.signingRoot,
498
519
  signature
499
520
  );
500
521
  attDataRootHex = attestationOrCache.cache.attDataRootHex;
501
522
  } else {
502
- signatureSet = createSingleSignatureSetFromComponents(
503
- chain.index2pubkey[validatorIndex],
504
- getSigningRoot(),
505
- signature
506
- );
523
+ signatureSet = createIndexedSignatureSetFromComponents(validatorIndex, getSigningRoot(), signature);
507
524
 
508
525
  // add cached attestation data before verifying signature
509
526
  attDataRootHex = toRootHex(ssz.phase0.AttestationData.hashTreeRoot(attData));
@@ -58,12 +58,7 @@ export async function validateAttesterSlashing(
58
58
  });
59
59
  }
60
60
 
61
- const signatureSets = getAttesterSlashingSignatureSets(
62
- chain.config,
63
- chain.index2pubkey,
64
- state.slot,
65
- attesterSlashing
66
- );
61
+ const signatureSets = getAttesterSlashingSignatureSets(chain.config, state.slot, attesterSlashing);
67
62
  if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
68
63
  throw new AttesterSlashingError(GossipAction.REJECT, {
69
64
  code: AttesterSlashingErrorCode.INVALID,
@@ -12,7 +12,7 @@ import {
12
12
  getBlockHeaderProposerSignatureSetByParentStateSlot,
13
13
  } from "@lodestar/state-transition";
14
14
  import {BlobIndex, Root, Slot, SubnetID, deneb, ssz} from "@lodestar/types";
15
- import {toRootHex, verifyMerkleBranch} from "@lodestar/utils";
15
+ import {byteArrayEquals, toRootHex, verifyMerkleBranch} from "@lodestar/utils";
16
16
  import {kzg} from "../../util/kzg.js";
17
17
  import {BlobSidecarErrorCode, BlobSidecarGossipError, BlobSidecarValidationError} from "../errors/blobSidecarError.js";
18
18
  import {GossipAction} from "../errors/gossipValidation.js";
@@ -124,7 +124,7 @@ export async function validateGossipBlobSidecar(
124
124
  // [IGNORE] The block's parent (defined by block.parent_root) has been seen (via both gossip and non-gossip sources) (a client MAY queue blocks for processing once the parent block is retrieved).
125
125
  // [REJECT] The block's parent (defined by block.parent_root) passes validation.
126
126
  const blockState = await chain.regen
127
- .getBlockSlotState(parentRoot, blobSlot, {dontTransferCache: true}, RegenCaller.validateGossipBlock)
127
+ .getBlockSlotState(parentBlock, blobSlot, {dontTransferCache: true}, RegenCaller.validateGossipBlock)
128
128
  .catch(() => {
129
129
  throw new BlobSidecarGossipError(GossipAction.IGNORE, {
130
130
  code: BlobSidecarErrorCode.PARENT_UNKNOWN,
@@ -139,7 +139,6 @@ export async function validateGossipBlobSidecar(
139
139
  if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blobSlot, blockHex, signature)) {
140
140
  const signatureSet = getBlockHeaderProposerSignatureSetByParentStateSlot(
141
141
  chain.config,
142
- chain.index2pubkey,
143
142
  blockState.slot,
144
143
  blobSidecar.signedBlockHeader
145
144
  );
@@ -227,7 +226,7 @@ export async function validateBlockBlobSidecars(
227
226
  const firstSidecarSignedBlockHeader = blobSidecars[0].signedBlockHeader;
228
227
  const firstSidecarBlockHeader = firstSidecarSignedBlockHeader.message;
229
228
  const firstBlockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(firstSidecarBlockHeader);
230
- if (Buffer.compare(blockRoot, firstBlockRoot) !== 0) {
229
+ if (!byteArrayEquals(blockRoot, firstBlockRoot)) {
231
230
  throw new BlobSidecarValidationError(
232
231
  {
233
232
  code: BlobSidecarErrorCode.INCORRECT_BLOCK,
@@ -244,11 +243,7 @@ export async function validateBlockBlobSidecars(
244
243
  const blockRootHex = toRootHex(blockRoot);
245
244
  const signature = firstSidecarSignedBlockHeader.signature;
246
245
  if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRootHex, signature)) {
247
- const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(
248
- chain.config,
249
- chain.index2pubkey,
250
- firstSidecarSignedBlockHeader
251
- );
246
+ const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(chain.config, firstSidecarSignedBlockHeader);
252
247
 
253
248
  if (
254
249
  !(await chain.bls.verifySignatureSets([signatureSet], {
@@ -1,5 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {ForkName, isForkPostDeneb} from "@lodestar/params";
2
+ import {ForkName, isForkPostBellatrix, isForkPostDeneb, isForkPostGloas} from "@lodestar/params";
3
3
  import {
4
4
  computeEpochAtSlot,
5
5
  computeStartSlotAtEpoch,
@@ -111,7 +111,7 @@ export async function validateGossipBlock(
111
111
  }
112
112
 
113
113
  // [REJECT] The length of KZG commitments is less than or equal to the limitation defined in Consensus Layer -- i.e. validate that len(body.signed_beacon_block.message.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
114
- if (isForkPostDeneb(fork)) {
114
+ if (isForkPostDeneb(fork) && !isForkPostGloas(fork)) {
115
115
  const blobKzgCommitmentsLen = (block as deneb.BeaconBlock).body.blobKzgCommitments.length;
116
116
  const maxBlobsPerBlock = config.getMaxBlobsPerBlock(computeEpochAtSlot(blockSlot));
117
117
  if (blobKzgCommitmentsLen > maxBlobsPerBlock) {
@@ -128,6 +128,7 @@ export async function validateGossipBlock(
128
128
  // this is something we should change this in the future to make the code airtight to the spec.
129
129
  // [IGNORE] The block's parent (defined by block.parent_root) has been seen (via both gossip and non-gossip sources) (a client MAY queue blocks for processing once the parent block is retrieved).
130
130
  // [REJECT] The block's parent (defined by block.parent_root) passes validation.
131
+ // TODO GLOAS: post-gloas, we check the validity of bid's parent payload, not the entire beacon block
131
132
  const blockState = await chain.regen
132
133
  .getPreState(block, {dontTransferCache: true}, RegenCaller.validateGossipBlock)
133
134
  .catch(() => {
@@ -137,11 +138,10 @@ export async function validateGossipBlock(
137
138
  // in forky condition, make sure to populate ShufflingCache with regened state
138
139
  chain.shufflingCache.processState(blockState);
139
140
 
140
- // Extra conditions for merge fork blocks
141
141
  // [REJECT] The block's execution payload timestamp is correct with respect to the slot
142
142
  // -- i.e. execution_payload.timestamp == compute_timestamp_at_slot(state, block.slot).
143
- if (fork === ForkName.bellatrix) {
144
- if (!isExecutionBlockBodyType(block.body)) throw Error("Not merge block type");
143
+ if (isForkPostBellatrix(fork) && !isForkPostGloas(fork)) {
144
+ if (!isExecutionBlockBodyType(block.body)) throw Error("Not execution block body type");
145
145
  const executionPayload = block.body.executionPayload;
146
146
  if (isExecutionStateType(blockState) && isExecutionEnabled(blockState, block)) {
147
147
  const expectedTimestamp = computeTimeAtSlot(config, blockSlot, chain.genesisTime);
@@ -157,7 +157,7 @@ export async function validateGossipBlock(
157
157
 
158
158
  // [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
159
159
  if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature)) {
160
- const signatureSet = getBlockProposerSignatureSet(chain.config, chain.index2pubkey, signedBlock);
160
+ const signatureSet = getBlockProposerSignatureSet(chain.config, signedBlock);
161
161
  // Don't batch so verification is not delayed
162
162
  if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: true}))) {
163
163
  throw new BlockGossipError(GossipAction.REJECT, {
@@ -11,7 +11,7 @@ import {
11
11
  getBlockHeaderProposerSignatureSetByParentStateSlot,
12
12
  } from "@lodestar/state-transition";
13
13
  import {Root, Slot, SubnetID, fulu, ssz} from "@lodestar/types";
14
- import {toRootHex, verifyMerkleBranch} from "@lodestar/utils";
14
+ import {byteArrayEquals, toRootHex, verifyMerkleBranch} from "@lodestar/utils";
15
15
  import {Metrics} from "../../metrics/metrics.js";
16
16
  import {kzg} from "../../util/kzg.js";
17
17
  import {
@@ -106,7 +106,7 @@ export async function validateGossipDataColumnSidecar(
106
106
  // this is something we should change this in the future to make the code airtight to the spec.
107
107
  // 7) [REJECT] The sidecar's block's parent passes validation.
108
108
  const blockState = await chain.regen
109
- .getBlockSlotState(parentRoot, blockHeader.slot, {dontTransferCache: true}, RegenCaller.validateGossipDataColumn)
109
+ .getBlockSlotState(parentBlock, blockHeader.slot, {dontTransferCache: true}, RegenCaller.validateGossipDataColumn)
110
110
  .catch(() => {
111
111
  throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
112
112
  code: DataColumnSidecarErrorCode.PARENT_UNKNOWN,
@@ -136,7 +136,6 @@ export async function validateGossipDataColumnSidecar(
136
136
  if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
137
137
  const signatureSet = getBlockHeaderProposerSignatureSetByParentStateSlot(
138
138
  chain.config,
139
- chain.index2pubkey,
140
139
  blockState.slot,
141
140
  dataColumnSidecar.signedBlockHeader
142
141
  );
@@ -319,7 +318,7 @@ export async function validateBlockDataColumnSidecars(
319
318
  const firstSidecarSignedBlockHeader = dataColumnSidecars[0].signedBlockHeader;
320
319
  const firstSidecarBlockHeader = firstSidecarSignedBlockHeader.message;
321
320
  const firstBlockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(firstSidecarBlockHeader);
322
- if (Buffer.compare(blockRoot, firstBlockRoot) !== 0) {
321
+ if (!byteArrayEquals(blockRoot, firstBlockRoot)) {
323
322
  throw new DataColumnSidecarValidationError(
324
323
  {
325
324
  code: DataColumnSidecarErrorCode.INCORRECT_BLOCK,
@@ -337,11 +336,7 @@ export async function validateBlockDataColumnSidecars(
337
336
  const slot = firstSidecarSignedBlockHeader.message.slot;
338
337
  const signature = firstSidecarSignedBlockHeader.signature;
339
338
  if (!chain.seenBlockInputCache.isVerifiedProposerSignature(slot, rootHex, signature)) {
340
- const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(
341
- chain.config,
342
- chain.index2pubkey,
343
- firstSidecarSignedBlockHeader
344
- );
339
+ const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(chain.config, firstSidecarSignedBlockHeader);
345
340
 
346
341
  if (
347
342
  !(await chain.bls.verifySignatureSets([signatureSet], {