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

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 (467) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +25 -13
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.js +1 -1
  5. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  6. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  7. package/lib/api/impl/beacon/state/index.js +27 -32
  8. package/lib/api/impl/beacon/state/index.js.map +1 -1
  9. package/lib/api/impl/beacon/state/utils.d.ts +4 -4
  10. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  11. package/lib/api/impl/beacon/state/utils.js +7 -10
  12. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  13. package/lib/api/impl/debug/index.js.map +1 -1
  14. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  15. package/lib/api/impl/lodestar/index.js +4 -6
  16. package/lib/api/impl/lodestar/index.js.map +1 -1
  17. package/lib/api/impl/proof/index.d.ts.map +1 -1
  18. package/lib/api/impl/proof/index.js +2 -6
  19. package/lib/api/impl/proof/index.js.map +1 -1
  20. package/lib/api/impl/validator/index.d.ts.map +1 -1
  21. package/lib/api/impl/validator/index.js +27 -27
  22. package/lib/api/impl/validator/index.js.map +1 -1
  23. package/lib/api/impl/validator/utils.d.ts +2 -2
  24. package/lib/api/impl/validator/utils.d.ts.map +1 -1
  25. package/lib/api/impl/validator/utils.js +3 -3
  26. package/lib/api/impl/validator/utils.js.map +1 -1
  27. package/lib/chain/ColumnReconstructionTracker.d.ts +2 -1
  28. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  29. package/lib/chain/ColumnReconstructionTracker.js +5 -5
  30. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  31. package/lib/chain/GetBlobsTracker.d.ts +2 -1
  32. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  33. package/lib/chain/GetBlobsTracker.js +14 -12
  34. package/lib/chain/GetBlobsTracker.js.map +1 -1
  35. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  36. package/lib/chain/archiveStore/archiveStore.js +1 -0
  37. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  38. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +3 -7
  39. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  40. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +8 -26
  41. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  42. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts +2 -2
  43. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  44. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -0
  45. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  46. package/lib/chain/archiveStore/historicalState/types.d.ts +2 -0
  47. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  48. package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
  49. package/lib/chain/archiveStore/historicalState/worker.js +1 -3
  50. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  51. package/lib/chain/archiveStore/interface.d.ts +1 -0
  52. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  53. package/lib/chain/balancesCache.d.ts +2 -2
  54. package/lib/chain/balancesCache.d.ts.map +1 -1
  55. package/lib/chain/balancesCache.js +4 -4
  56. package/lib/chain/balancesCache.js.map +1 -1
  57. package/lib/chain/blocks/blockInput/blockInput.d.ts +5 -5
  58. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  59. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  60. package/lib/chain/blocks/blockInput/types.d.ts +5 -4
  61. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  62. package/lib/chain/blocks/blockInput/types.js +1 -0
  63. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  64. package/lib/chain/blocks/importBlock.d.ts +3 -3
  65. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  66. package/lib/chain/blocks/importBlock.js +34 -22
  67. package/lib/chain/blocks/importBlock.js.map +1 -1
  68. package/lib/chain/blocks/importExecutionPayload.d.ts +10 -8
  69. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  70. package/lib/chain/blocks/importExecutionPayload.js +78 -51
  71. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  72. package/lib/chain/blocks/index.d.ts.map +1 -1
  73. package/lib/chain/blocks/index.js +3 -2
  74. package/lib/chain/blocks/index.js.map +1 -1
  75. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +14 -6
  76. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  77. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +33 -2
  78. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  79. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
  80. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  81. package/lib/chain/blocks/types.d.ts +21 -15
  82. package/lib/chain/blocks/types.d.ts.map +1 -1
  83. package/lib/chain/blocks/types.js.map +1 -1
  84. package/lib/chain/blocks/utils/checkpoint.d.ts +2 -2
  85. package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -1
  86. package/lib/chain/blocks/utils/checkpoint.js.map +1 -1
  87. package/lib/chain/blocks/verifyBlock.d.ts +2 -2
  88. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  89. package/lib/chain/blocks/verifyBlock.js +4 -4
  90. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  91. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +5 -5
  92. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  93. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -4
  94. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  95. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  96. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  97. package/lib/chain/blocks/verifyBlocksSignatures.js +1 -1
  98. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  99. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -3
  100. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  101. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +3 -3
  102. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  103. package/lib/chain/chain.d.ts +15 -14
  104. package/lib/chain/chain.d.ts.map +1 -1
  105. package/lib/chain/chain.js +102 -59
  106. package/lib/chain/chain.js.map +1 -1
  107. package/lib/chain/emitter.d.ts +31 -9
  108. package/lib/chain/emitter.d.ts.map +1 -1
  109. package/lib/chain/emitter.js +12 -3
  110. package/lib/chain/emitter.js.map +1 -1
  111. package/lib/chain/errors/blockError.d.ts +4 -4
  112. package/lib/chain/errors/blockError.d.ts.map +1 -1
  113. package/lib/chain/errors/dataColumnSidecarError.d.ts +31 -1
  114. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  115. package/lib/chain/errors/dataColumnSidecarError.js +7 -0
  116. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  117. package/lib/chain/forkChoice/index.d.ts +4 -4
  118. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  119. package/lib/chain/forkChoice/index.js +27 -23
  120. package/lib/chain/forkChoice/index.js.map +1 -1
  121. package/lib/chain/initState.d.ts +2 -2
  122. package/lib/chain/initState.d.ts.map +1 -1
  123. package/lib/chain/initState.js +1 -1
  124. package/lib/chain/initState.js.map +1 -1
  125. package/lib/chain/interface.d.ts +15 -14
  126. package/lib/chain/interface.d.ts.map +1 -1
  127. package/lib/chain/lightClient/index.d.ts +2 -2
  128. package/lib/chain/lightClient/index.d.ts.map +1 -1
  129. package/lib/chain/lightClient/index.js +4 -4
  130. package/lib/chain/lightClient/index.js.map +1 -1
  131. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +6 -6
  132. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  133. package/lib/chain/opPools/aggregatedAttestationPool.js +10 -13
  134. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  135. package/lib/chain/opPools/opPool.d.ts +3 -3
  136. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  137. package/lib/chain/opPools/opPool.js +7 -7
  138. package/lib/chain/opPools/opPool.js.map +1 -1
  139. package/lib/chain/opPools/utils.d.ts +2 -2
  140. package/lib/chain/opPools/utils.d.ts.map +1 -1
  141. package/lib/chain/opPools/utils.js +1 -1
  142. package/lib/chain/opPools/utils.js.map +1 -1
  143. package/lib/chain/options.d.ts +1 -0
  144. package/lib/chain/options.d.ts.map +1 -1
  145. package/lib/chain/options.js +1 -0
  146. package/lib/chain/options.js.map +1 -1
  147. package/lib/chain/prepareNextSlot.d.ts +2 -2
  148. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  149. package/lib/chain/prepareNextSlot.js +3 -3
  150. package/lib/chain/prepareNextSlot.js.map +1 -1
  151. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +4 -4
  152. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  153. package/lib/chain/produceBlock/computeNewStateRoot.js +3 -4
  154. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  155. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  156. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  157. package/lib/chain/produceBlock/produceBlockBody.js +12 -16
  158. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  159. package/lib/chain/regen/interface.d.ts +13 -13
  160. package/lib/chain/regen/interface.d.ts.map +1 -1
  161. package/lib/chain/regen/queued.d.ts +14 -14
  162. package/lib/chain/regen/queued.d.ts.map +1 -1
  163. package/lib/chain/regen/queued.js.map +1 -1
  164. package/lib/chain/regen/regen.d.ts +6 -5
  165. package/lib/chain/regen/regen.d.ts.map +1 -1
  166. package/lib/chain/regen/regen.js +6 -6
  167. package/lib/chain/regen/regen.js.map +1 -1
  168. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +1 -1
  169. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  170. package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
  171. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  172. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +1 -1
  173. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  174. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +2 -2
  175. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  176. package/lib/chain/serializeState.d.ts +2 -2
  177. package/lib/chain/serializeState.d.ts.map +1 -1
  178. package/lib/chain/serializeState.js +1 -1
  179. package/lib/chain/serializeState.js.map +1 -1
  180. package/lib/chain/shufflingCache.d.ts +2 -2
  181. package/lib/chain/shufflingCache.d.ts.map +1 -1
  182. package/lib/chain/shufflingCache.js +3 -4
  183. package/lib/chain/shufflingCache.js.map +1 -1
  184. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +6 -6
  185. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  186. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  187. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +11 -11
  188. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  189. package/lib/chain/stateCache/persistentCheckpointsCache.js +12 -16
  190. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  191. package/lib/chain/stateCache/types.d.ts +14 -14
  192. package/lib/chain/stateCache/types.d.ts.map +1 -1
  193. package/lib/chain/stateCache/types.js.map +1 -1
  194. package/lib/chain/validation/attestation.js +3 -3
  195. package/lib/chain/validation/attestation.js.map +1 -1
  196. package/lib/chain/validation/attesterSlashing.js +3 -3
  197. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  198. package/lib/chain/validation/blobSidecar.js +1 -1
  199. package/lib/chain/validation/blobSidecar.js.map +1 -1
  200. package/lib/chain/validation/block.d.ts.map +1 -1
  201. package/lib/chain/validation/block.js +3 -3
  202. package/lib/chain/validation/block.js.map +1 -1
  203. package/lib/chain/validation/blsToExecutionChange.js +2 -2
  204. package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
  205. package/lib/chain/validation/dataColumnSidecar.d.ts +11 -4
  206. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  207. package/lib/chain/validation/dataColumnSidecar.js +185 -6
  208. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  209. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  210. package/lib/chain/validation/executionPayloadBid.js +4 -4
  211. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  212. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  213. package/lib/chain/validation/executionPayloadEnvelope.js +2 -3
  214. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  215. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  216. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  217. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  218. package/lib/chain/validation/proposerSlashing.js +1 -1
  219. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  220. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  221. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  222. package/lib/chain/validation/signatureSets/contributionAndProof.js +1 -1
  223. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  224. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  225. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  226. package/lib/chain/validation/signatureSets/syncCommittee.js +1 -1
  227. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  228. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  229. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  230. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  231. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  232. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  233. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -1
  234. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  235. package/lib/chain/validation/syncCommittee.d.ts +4 -4
  236. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  237. package/lib/chain/validation/syncCommittee.js +13 -12
  238. package/lib/chain/validation/syncCommittee.js.map +1 -1
  239. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  240. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  241. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  242. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  243. package/lib/chain/validation/voluntaryExit.js +3 -3
  244. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  245. package/lib/chain/validatorMonitor.d.ts +3 -3
  246. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  247. package/lib/chain/validatorMonitor.js +9 -7
  248. package/lib/chain/validatorMonitor.js.map +1 -1
  249. package/lib/db/buckets.d.ts +2 -2
  250. package/lib/db/buckets.d.ts.map +1 -1
  251. package/lib/db/buckets.js +2 -2
  252. package/lib/db/buckets.js.map +1 -1
  253. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  254. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  255. package/lib/db/repositories/dataColumnSidecar.d.ts.map +1 -1
  256. package/lib/db/repositories/dataColumnSidecar.js +4 -2
  257. package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
  258. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
  259. package/lib/db/repositories/dataColumnSidecarArchive.js +4 -2
  260. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  261. package/lib/metrics/metrics/lodestar.d.ts +32 -4
  262. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  263. package/lib/metrics/metrics/lodestar.js +52 -15
  264. package/lib/metrics/metrics/lodestar.js.map +1 -1
  265. package/lib/network/gossip/encoding.d.ts.map +1 -1
  266. package/lib/network/gossip/encoding.js +15 -0
  267. package/lib/network/gossip/encoding.js.map +1 -1
  268. package/lib/network/interface.d.ts +7 -4
  269. package/lib/network/interface.d.ts.map +1 -1
  270. package/lib/network/libp2p/index.d.ts.map +1 -1
  271. package/lib/network/libp2p/index.js +22 -11
  272. package/lib/network/libp2p/index.js.map +1 -1
  273. package/lib/network/network.d.ts +7 -4
  274. package/lib/network/network.d.ts.map +1 -1
  275. package/lib/network/network.js +12 -3
  276. package/lib/network/network.js.map +1 -1
  277. package/lib/network/options.d.ts.map +1 -1
  278. package/lib/network/options.js +7 -2
  279. package/lib/network/options.js.map +1 -1
  280. package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
  281. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
  282. package/lib/network/processor/extractSlotRootFns.js +25 -5
  283. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  284. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  285. package/lib/network/processor/gossipHandlers.js +265 -80
  286. package/lib/network/processor/gossipHandlers.js.map +1 -1
  287. package/lib/network/processor/index.d.ts +22 -7
  288. package/lib/network/processor/index.d.ts.map +1 -1
  289. package/lib/network/processor/index.js +311 -80
  290. package/lib/network/processor/index.js.map +1 -1
  291. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  292. package/lib/network/reqresp/ReqRespBeaconNode.js +9 -0
  293. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  294. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts +8 -0
  295. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -0
  296. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +69 -0
  297. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -0
  298. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts +6 -0
  299. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -0
  300. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +28 -0
  301. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -0
  302. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  303. package/lib/network/reqresp/handlers/index.js +11 -1
  304. package/lib/network/reqresp/handlers/index.js.map +1 -1
  305. package/lib/network/reqresp/protocols.d.ts +2 -0
  306. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  307. package/lib/network/reqresp/protocols.js +10 -0
  308. package/lib/network/reqresp/protocols.js.map +1 -1
  309. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  310. package/lib/network/reqresp/rateLimit.js +8 -0
  311. package/lib/network/reqresp/rateLimit.js.map +1 -1
  312. package/lib/network/reqresp/score.d.ts.map +1 -1
  313. package/lib/network/reqresp/score.js +2 -0
  314. package/lib/network/reqresp/score.js.map +1 -1
  315. package/lib/network/reqresp/types.d.ts +10 -4
  316. package/lib/network/reqresp/types.d.ts.map +1 -1
  317. package/lib/network/reqresp/types.js +16 -4
  318. package/lib/network/reqresp/types.js.map +1 -1
  319. package/lib/node/nodejs.d.ts +2 -2
  320. package/lib/node/nodejs.d.ts.map +1 -1
  321. package/lib/node/nodejs.js +1 -4
  322. package/lib/node/nodejs.js.map +1 -1
  323. package/lib/node/notifier.d.ts.map +1 -1
  324. package/lib/node/notifier.js +3 -3
  325. package/lib/node/notifier.js.map +1 -1
  326. package/lib/sync/backfill/backfill.d.ts +2 -2
  327. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  328. package/lib/sync/backfill/backfill.js +2 -2
  329. package/lib/sync/backfill/backfill.js.map +1 -1
  330. package/lib/sync/unknownBlock.d.ts +3 -9
  331. package/lib/sync/unknownBlock.d.ts.map +1 -1
  332. package/lib/sync/unknownBlock.js +10 -43
  333. package/lib/sync/unknownBlock.js.map +1 -1
  334. package/lib/sync/utils/downloadByRange.d.ts +3 -3
  335. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  336. package/lib/sync/utils/downloadByRange.js +4 -2
  337. package/lib/sync/utils/downloadByRange.js.map +1 -1
  338. package/lib/sync/utils/downloadByRoot.d.ts +3 -3
  339. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  340. package/lib/sync/utils/downloadByRoot.js +10 -5
  341. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  342. package/lib/util/blobs.d.ts +3 -3
  343. package/lib/util/blobs.d.ts.map +1 -1
  344. package/lib/util/blobs.js +21 -10
  345. package/lib/util/blobs.js.map +1 -1
  346. package/lib/util/dataColumns.d.ts +18 -11
  347. package/lib/util/dataColumns.d.ts.map +1 -1
  348. package/lib/util/dataColumns.js +51 -17
  349. package/lib/util/dataColumns.js.map +1 -1
  350. package/lib/util/execution.d.ts +6 -2
  351. package/lib/util/execution.d.ts.map +1 -1
  352. package/lib/util/execution.js +49 -25
  353. package/lib/util/execution.js.map +1 -1
  354. package/lib/util/sszBytes.d.ts +19 -2
  355. package/lib/util/sszBytes.d.ts.map +1 -1
  356. package/lib/util/sszBytes.js +173 -3
  357. package/lib/util/sszBytes.js.map +1 -1
  358. package/lib/util/types.d.ts +2 -0
  359. package/lib/util/types.d.ts.map +1 -1
  360. package/lib/util/types.js +1 -0
  361. package/lib/util/types.js.map +1 -1
  362. package/package.json +16 -16
  363. package/src/api/impl/beacon/blocks/index.ts +33 -16
  364. package/src/api/impl/beacon/pool/index.ts +1 -1
  365. package/src/api/impl/beacon/state/index.ts +29 -41
  366. package/src/api/impl/beacon/state/utils.ts +11 -25
  367. package/src/api/impl/debug/index.ts +2 -2
  368. package/src/api/impl/lodestar/index.ts +4 -8
  369. package/src/api/impl/proof/index.ts +2 -9
  370. package/src/api/impl/validator/index.ts +29 -41
  371. package/src/api/impl/validator/utils.ts +4 -7
  372. package/src/chain/ColumnReconstructionTracker.ts +6 -5
  373. package/src/chain/GetBlobsTracker.ts +14 -12
  374. package/src/chain/archiveStore/archiveStore.ts +1 -0
  375. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -39
  376. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +2 -1
  377. package/src/chain/archiveStore/historicalState/types.ts +2 -0
  378. package/src/chain/archiveStore/historicalState/worker.ts +1 -4
  379. package/src/chain/archiveStore/interface.ts +1 -0
  380. package/src/chain/balancesCache.ts +5 -11
  381. package/src/chain/blocks/blockInput/blockInput.ts +8 -8
  382. package/src/chain/blocks/blockInput/types.ts +5 -4
  383. package/src/chain/blocks/importBlock.ts +41 -26
  384. package/src/chain/blocks/importExecutionPayload.ts +89 -63
  385. package/src/chain/blocks/index.ts +3 -2
  386. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +53 -12
  387. package/src/chain/blocks/payloadEnvelopeInput/types.ts +2 -1
  388. package/src/chain/blocks/types.ts +26 -15
  389. package/src/chain/blocks/utils/checkpoint.ts +2 -2
  390. package/src/chain/blocks/verifyBlock.ts +5 -10
  391. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -14
  392. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -3
  393. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -8
  394. package/src/chain/chain.ts +138 -91
  395. package/src/chain/emitter.ts +27 -9
  396. package/src/chain/errors/blockError.ts +4 -4
  397. package/src/chain/errors/dataColumnSidecarError.ts +32 -1
  398. package/src/chain/forkChoice/index.ts +33 -42
  399. package/src/chain/initState.ts +7 -2
  400. package/src/chain/interface.ts +16 -15
  401. package/src/chain/lightClient/index.ts +9 -22
  402. package/src/chain/opPools/aggregatedAttestationPool.ts +15 -21
  403. package/src/chain/opPools/opPool.ts +13 -14
  404. package/src/chain/opPools/utils.ts +3 -3
  405. package/src/chain/options.ts +2 -0
  406. package/src/chain/prepareNextSlot.ts +6 -8
  407. package/src/chain/produceBlock/computeNewStateRoot.ts +6 -10
  408. package/src/chain/produceBlock/produceBlockBody.ts +22 -49
  409. package/src/chain/regen/interface.ts +13 -17
  410. package/src/chain/regen/queued.ts +16 -20
  411. package/src/chain/regen/regen.ts +16 -17
  412. package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
  413. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +2 -2
  414. package/src/chain/serializeState.ts +3 -3
  415. package/src/chain/shufflingCache.ts +5 -7
  416. package/src/chain/stateCache/fifoBlockStateCache.ts +7 -7
  417. package/src/chain/stateCache/persistentCheckpointsCache.ts +27 -42
  418. package/src/chain/stateCache/types.ts +14 -18
  419. package/src/chain/validation/attestation.ts +3 -3
  420. package/src/chain/validation/attesterSlashing.ts +3 -3
  421. package/src/chain/validation/blobSidecar.ts +1 -1
  422. package/src/chain/validation/block.ts +2 -4
  423. package/src/chain/validation/blsToExecutionChange.ts +2 -2
  424. package/src/chain/validation/dataColumnSidecar.ts +231 -8
  425. package/src/chain/validation/executionPayloadBid.ts +3 -7
  426. package/src/chain/validation/executionPayloadEnvelope.ts +2 -8
  427. package/src/chain/validation/payloadAttestationMessage.ts +2 -4
  428. package/src/chain/validation/proposerSlashing.ts +1 -1
  429. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -7
  430. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -7
  431. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -2
  432. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -7
  433. package/src/chain/validation/syncCommittee.ts +21 -20
  434. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -10
  435. package/src/chain/validation/voluntaryExit.ts +3 -8
  436. package/src/chain/validatorMonitor.ts +12 -11
  437. package/src/db/buckets.ts +2 -2
  438. package/src/db/repositories/dataColumnSidecar.ts +4 -2
  439. package/src/db/repositories/dataColumnSidecarArchive.ts +4 -2
  440. package/src/metrics/metrics/lodestar.ts +57 -19
  441. package/src/network/gossip/encoding.ts +16 -0
  442. package/src/network/interface.ts +18 -4
  443. package/src/network/libp2p/index.ts +24 -13
  444. package/src/network/network.ts +39 -8
  445. package/src/network/options.ts +7 -2
  446. package/src/network/processor/extractSlotRootFns.ts +32 -6
  447. package/src/network/processor/gossipHandlers.ts +329 -94
  448. package/src/network/processor/index.ts +393 -92
  449. package/src/network/reqresp/ReqRespBeaconNode.ts +13 -0
  450. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +94 -0
  451. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +43 -0
  452. package/src/network/reqresp/handlers/index.ts +12 -0
  453. package/src/network/reqresp/protocols.ts +12 -0
  454. package/src/network/reqresp/rateLimit.ts +18 -0
  455. package/src/network/reqresp/score.ts +2 -0
  456. package/src/network/reqresp/types.ts +26 -5
  457. package/src/node/nodejs.ts +3 -5
  458. package/src/node/notifier.ts +4 -10
  459. package/src/sync/backfill/backfill.ts +3 -3
  460. package/src/sync/unknownBlock.ts +13 -53
  461. package/src/sync/utils/downloadByRange.ts +9 -7
  462. package/src/sync/utils/downloadByRoot.ts +16 -12
  463. package/src/util/blobs.ts +35 -15
  464. package/src/util/dataColumns.ts +69 -25
  465. package/src/util/execution.ts +49 -30
  466. package/src/util/sszBytes.ts +223 -7
  467. package/src/util/types.ts +6 -0
@@ -27,11 +27,11 @@ export type NetworkProcessorOpts = GossipHandlerOpts & {
27
27
  */
28
28
  export declare enum ReprocessRejectReason {
29
29
  /**
30
- * There are too many attestations that have unknown block root.
30
+ * There are too many gossip messages that have unknown block root.
31
31
  */
32
32
  reached_limit = "reached_limit",
33
33
  /**
34
- * The awaiting attestation is pruned per clock slot.
34
+ * The awaiting gossip message is pruned per clock slot.
35
35
  */
36
36
  expired = "expired"
37
37
  }
@@ -59,7 +59,7 @@ export declare enum CannotAcceptWorkReason {
59
59
  *
60
60
  * ### PendingGossipsubMessage beacon_attestation example
61
61
  *
62
- * For attestations, processing the message includes the steps:
62
+ * For gossip messages, processing the message includes the steps:
63
63
  * 1. Pre shuffling sync validation
64
64
  * 2. Retrieve shuffling: async + goes into the regen queue and can be expensive
65
65
  * 3. Pre sig validation sync validation
@@ -79,17 +79,30 @@ export declare class NetworkProcessor {
79
79
  private readonly gossipQueues;
80
80
  private readonly gossipTopicConcurrency;
81
81
  private readonly extractBlockSlotRootFns;
82
- private readonly awaitingGossipsubMessagesByRootBySlot;
83
- private unknownBlockGossipsubMessagesCount;
84
- private unknownRootsBySlot;
82
+ private readonly awaitingMessagesByBlockRoot;
83
+ private readonly awaitingMessagesByPayloadBlockRoot;
84
+ private unknownBlocksBySlot;
85
+ private unknownEnvelopesBySlot;
85
86
  constructor(modules: NetworkProcessorModules, opts: NetworkProcessorOpts);
86
87
  stop(): Promise<void>;
87
88
  dropAllJobs(): void;
88
89
  dumpGossipQueue(topic: GossipType): PendingGossipsubMessage[];
89
- searchUnknownSlotRoot({ slot, root }: SlotRootHex, source: BlockInputSource, peer?: PeerIdStr): void;
90
+ /**
91
+ * Search block via `ChainEvent.unknownBlockRoot` event
92
+ * Slot is the message slot, which is not necessarily the same as the block's slot, but it can be used for a good prune strategy.
93
+ * In the rare case, if 2 messages on 2 slots search for the same root (for example beacon_attestation) we may emit the same root twice but BlockInputSync should handle it well.
94
+ */
95
+ searchUnknownBlock({ slot, root }: SlotRootHex, source: BlockInputSource, peer?: PeerIdStr): void;
96
+ /**
97
+ * Search envelope via `ChainEvent.unknownEnvelopeBlockRoot` event
98
+ * Slot is the message slot, which is not necessarily the same as the envelope's slot, but it can be used for a good prune strategy.
99
+ * In the rare case, if 2 messages on 2 slots search for the same root (for example beacon_attestation) we may emit the same root twice but BlockInputSync should handle it well.
100
+ */
101
+ searchUnknownEnvelope({ slot, root }: SlotRootHex, source: BlockInputSource, peer?: PeerIdStr): void;
90
102
  private onPendingGossipsubMessage;
91
103
  private pushPendingGossipsubMessageToQueue;
92
104
  private onBlockProcessed;
105
+ private onPayloadEnvelopeProcessed;
93
106
  private onClockSlot;
94
107
  private executeWork;
95
108
  private processPendingGossipsubMessage;
@@ -98,5 +111,7 @@ export declare class NetworkProcessor {
98
111
  * Return null if chain can accept work, otherwise return the reason why it cannot accept work
99
112
  */
100
113
  private checkAcceptWork;
114
+ private get unknownBlockGossipsubMessagesCount();
115
+ private get unknownPayloadGossipsubMessagesCount();
101
116
  }
102
117
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/network/processor/index.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/network/processor/index.ts"],"names":[],"mappings":"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"}
@@ -1,12 +1,13 @@
1
1
  import { routes } from "@lodestar/api";
2
2
  import { ForkSeq } from "@lodestar/params";
3
3
  import { computeStartSlotAtEpoch } from "@lodestar/state-transition";
4
- import { MapDef, mapValues, pruneSetToMax, sleep } from "@lodestar/utils";
4
+ import { MapDef, mapValues, sleep } from "@lodestar/utils";
5
5
  import { BlockInputSource } from "../../chain/blocks/blockInput/types.js";
6
6
  import { ChainEvent } from "../../chain/emitter.js";
7
7
  import { GossipErrorCode } from "../../chain/errors/gossipValidation.js";
8
8
  import { ClockEvent } from "../../util/clock.js";
9
9
  import { callInNextEventLoop } from "../../util/eventLoop.js";
10
+ import { getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized, getIndexFromSignedAggregateAndProofSerialized, getIndexFromSingleAttestationSerialized, getParentBlockHashFromGloasSignedBeaconBlockSerialized, getParentBlockHashFromSignedExecutionPayloadBidSerialized, getParentBlockRootFromSignedExecutionPayloadBidSerialized, getParentRootFromSignedBeaconBlockSerialized, getPayloadPresentFromPayloadAttestationMessageSerialized, } from "../../util/sszBytes.js";
10
11
  import { NetworkEvent } from "../events.js";
11
12
  import { GossipType, } from "../gossip/interface.js";
12
13
  import { createExtractBlockSlotRootFns } from "./extractSlotRootFns.js";
@@ -50,14 +51,16 @@ const executeGossipWorkOrderObj = {
50
51
  const executeGossipWorkOrder = Object.keys(executeGossipWorkOrderObj);
51
52
  // TODO: Arbitrary constant, check metrics
52
53
  const MAX_JOBS_SUBMITTED_PER_TICK = 128;
53
- // How many attestations (aggregate + unaggregate) we keep before new ones get dropped.
54
+ // How many gossip messages we keep before new ones get dropped.
54
55
  const MAX_QUEUED_UNKNOWN_BLOCK_GOSSIP_OBJECTS = 16_384;
55
- // We don't want to process too many attestations in a single tick
56
- // As seen on mainnet, attestation concurrency metric ranges from 1000 to 2000
56
+ // TODO gloas: arbitrary constant, check metrics.
57
+ const MAX_QUEUED_UNKNOWN_PAYLOAD_GOSSIP_OBJECTS = 1024;
58
+ // We don't want to process too many gossip messages in a single tick
59
+ // As seen on mainnet, gossip messages concurrency metric ranges from 1000 to 2000
57
60
  // so make this constant a little bit conservative
58
- const MAX_UNKNOWN_BLOCK_GOSSIP_OBJECTS_PER_TICK = 1024;
61
+ const MAX_AWAITING_GOSSIP_OBJECTS_PER_TICK = 1024;
59
62
  // Same motivation to JobItemQueue, we don't want to block the event loop
60
- const PROCESS_UNKNOWN_BLOCK_GOSSIP_OBJECTS_YIELD_EVERY_MS = 50;
63
+ const AWAITING_GOSSIP_OBJECTS_YIELD_EVERY_MS = 50;
61
64
  export { ReprocessRejectReason };
62
65
  /**
63
66
  * Reprocess reject reason for metrics
@@ -65,11 +68,11 @@ export { ReprocessRejectReason };
65
68
  var ReprocessRejectReason;
66
69
  (function (ReprocessRejectReason) {
67
70
  /**
68
- * There are too many attestations that have unknown block root.
71
+ * There are too many gossip messages that have unknown block root.
69
72
  */
70
73
  ReprocessRejectReason["reached_limit"] = "reached_limit";
71
74
  /**
72
- * The awaiting attestation is pruned per clock slot.
75
+ * The awaiting gossip message is pruned per clock slot.
73
76
  */
74
77
  ReprocessRejectReason["expired"] = "expired";
75
78
  })(ReprocessRejectReason || (ReprocessRejectReason = {}));
@@ -88,6 +91,15 @@ var CannotAcceptWorkReason;
88
91
  */
89
92
  CannotAcceptWorkReason["regen"] = "regen_busy";
90
93
  })(CannotAcceptWorkReason || (CannotAcceptWorkReason = {}));
94
+ /**
95
+ * No metrics needed here; using a number to keep it lightweight
96
+ */
97
+ var PreprocessAction;
98
+ (function (PreprocessAction) {
99
+ PreprocessAction[PreprocessAction["AwaitBlock"] = 0] = "AwaitBlock";
100
+ PreprocessAction[PreprocessAction["AwaitEnvelope"] = 1] = "AwaitEnvelope";
101
+ PreprocessAction[PreprocessAction["PushToQueue"] = 2] = "PushToQueue";
102
+ })(PreprocessAction || (PreprocessAction = {}));
91
103
  /**
92
104
  * Network processor handles the gossip queues and throtles processing to not overload the main thread
93
105
  * - Decides when to process work and what to process
@@ -99,7 +111,7 @@ var CannotAcceptWorkReason;
99
111
  *
100
112
  * ### PendingGossipsubMessage beacon_attestation example
101
113
  *
102
- * For attestations, processing the message includes the steps:
114
+ * For gossip messages, processing the message includes the steps:
103
115
  * 1. Pre shuffling sync validation
104
116
  * 2. Retrieve shuffling: async + goes into the regen queue and can be expensive
105
117
  * 3. Pre sig validation sync validation
@@ -119,11 +131,14 @@ export class NetworkProcessor {
119
131
  gossipQueues;
120
132
  gossipTopicConcurrency;
121
133
  extractBlockSlotRootFns = createExtractBlockSlotRootFns();
122
- // we may not receive the block for Attestation and SignedAggregateAndProof messages, in that case PendingGossipsubMessage needs
134
+ // we may not receive the block for messages like Attestation and SignedAggregateAndProof messages, in that case PendingGossipsubMessage needs
123
135
  // to be stored in this Map and reprocessed once the block comes
124
- awaitingGossipsubMessagesByRootBySlot;
125
- unknownBlockGossipsubMessagesCount = 0;
126
- unknownRootsBySlot = new MapDef(() => new Set());
136
+ awaitingMessagesByBlockRoot;
137
+ // we may not receive the payload for messages like payload_attestation_message messages, in that case PendingGossipsubMessage needs
138
+ // to be stored in this Map and reprocessed once the payload comes
139
+ awaitingMessagesByPayloadBlockRoot;
140
+ unknownBlocksBySlot = new MapDef(() => new Set());
141
+ unknownEnvelopesBySlot = new MapDef(() => new Set());
127
142
  constructor(modules, opts) {
128
143
  this.opts = opts;
129
144
  const { chain, events, logger, metrics } = modules;
@@ -136,10 +151,12 @@ export class NetworkProcessor {
136
151
  this.gossipTopicConcurrency = mapValues(this.gossipQueues, () => 0);
137
152
  this.gossipValidatorFn = getGossipValidatorFn(modules.gossipHandlers ?? getGossipHandlers(modules, opts), modules);
138
153
  this.gossipValidatorBatchFn = getGossipValidatorBatchFn(modules.gossipHandlers ?? getGossipHandlers(modules, opts), modules);
139
- events.on(NetworkEvent.pendingGossipsubMessage, this.onPendingGossipsubMessage.bind(this));
140
- this.chain.emitter.on(routes.events.EventType.block, this.onBlockProcessed.bind(this));
141
- this.chain.clock.on(ClockEvent.slot, this.onClockSlot.bind(this));
142
- this.awaitingGossipsubMessagesByRootBySlot = new MapDef(() => new MapDef(() => new Set()));
154
+ events.on(NetworkEvent.pendingGossipsubMessage, this.onPendingGossipsubMessage);
155
+ this.chain.emitter.on(routes.events.EventType.block, this.onBlockProcessed);
156
+ this.chain.emitter.on(routes.events.EventType.executionPayload, this.onPayloadEnvelopeProcessed);
157
+ this.chain.clock.on(ClockEvent.slot, this.onClockSlot);
158
+ this.awaitingMessagesByBlockRoot = new MapDef(() => new Set());
159
+ this.awaitingMessagesByPayloadBlockRoot = new MapDef(() => new Set());
143
160
  // TODO: Implement queues and priorization for ReqResp incoming requests
144
161
  // Listens to NetworkEvent.reqRespIncomingRequest event
145
162
  if (metrics) {
@@ -149,7 +166,8 @@ export class NetworkProcessor {
149
166
  metrics.gossipValidationQueue.keySize.set({ topic }, this.gossipQueues[topic].keySize);
150
167
  metrics.gossipValidationQueue.concurrency.set({ topic }, this.gossipTopicConcurrency[topic]);
151
168
  }
152
- metrics.reprocessGossipAttestations.countPerSlot.set(this.unknownBlockGossipsubMessagesCount);
169
+ metrics.awaitingBlockGossipMessages.countPerSlot.set(this.unknownBlockGossipsubMessagesCount);
170
+ metrics.awaitingPayloadGossipMessages.countPerSlot.set(this.unknownPayloadGossipsubMessagesCount);
153
171
  // specific metric for beacon_attestation topic
154
172
  metrics.gossipValidationQueue.keyAge.reset();
155
173
  for (const ageMs of this.gossipQueues.beacon_attestation.getDataAgeMs()) {
@@ -164,6 +182,7 @@ export class NetworkProcessor {
164
182
  async stop() {
165
183
  this.events.off(NetworkEvent.pendingGossipsubMessage, this.onPendingGossipsubMessage);
166
184
  this.chain.emitter.off(routes.events.EventType.block, this.onBlockProcessed);
185
+ this.chain.emitter.off(routes.events.EventType.executionPayload, this.onPayloadEnvelopeProcessed);
167
186
  this.chain.emitter.off(ClockEvent.slot, this.onClockSlot);
168
187
  }
169
188
  dropAllJobs() {
@@ -178,112 +197,310 @@ export class NetworkProcessor {
178
197
  }
179
198
  return queue.getAll();
180
199
  }
181
- searchUnknownSlotRoot({ slot, root }, source, peer) {
182
- if (this.chain.seenBlock(root) || this.unknownRootsBySlot.getOrDefault(slot).has(root)) {
200
+ /**
201
+ * Search block via `ChainEvent.unknownBlockRoot` event
202
+ * Slot is the message slot, which is not necessarily the same as the block's slot, but it can be used for a good prune strategy.
203
+ * In the rare case, if 2 messages on 2 slots search for the same root (for example beacon_attestation) we may emit the same root twice but BlockInputSync should handle it well.
204
+ */
205
+ searchUnknownBlock({ slot, root }, source, peer) {
206
+ if (this.chain.seenBlock(root) ||
207
+ this.awaitingMessagesByBlockRoot.has(root) ||
208
+ this.unknownBlocksBySlot.getOrDefault(slot).has(root)) {
183
209
  return;
184
210
  }
185
211
  // Search for the unknown block
186
- this.unknownRootsBySlot.getOrDefault(slot).add(root);
212
+ this.unknownBlocksBySlot.getOrDefault(slot).add(root);
187
213
  this.chain.emitter.emit(ChainEvent.unknownBlockRoot, { rootHex: root, peer, source });
188
214
  }
189
- onPendingGossipsubMessage(message) {
215
+ /**
216
+ * Search envelope via `ChainEvent.unknownEnvelopeBlockRoot` event
217
+ * Slot is the message slot, which is not necessarily the same as the envelope's slot, but it can be used for a good prune strategy.
218
+ * In the rare case, if 2 messages on 2 slots search for the same root (for example beacon_attestation) we may emit the same root twice but BlockInputSync should handle it well.
219
+ */
220
+ searchUnknownEnvelope({ slot, root }, source, peer) {
221
+ if (this.chain.seenPayloadEnvelope(root) ||
222
+ this.awaitingMessagesByPayloadBlockRoot.has(root) ||
223
+ this.unknownEnvelopesBySlot.getOrDefault(slot).has(root)) {
224
+ return;
225
+ }
226
+ this.unknownEnvelopesBySlot.getOrDefault(slot).add(root);
227
+ this.chain.emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, { rootHex: root, peer, source });
228
+ }
229
+ onPendingGossipsubMessage = (message) => {
190
230
  const topicType = message.topic.type;
191
231
  const extractBlockSlotRootFn = this.extractBlockSlotRootFns[topicType];
192
- // check block root of Attestation and SignedAggregateAndProof messages
193
- if (extractBlockSlotRootFn) {
194
- const slotRoot = extractBlockSlotRootFn(message.msg.data, message.topic.boundary.fork);
195
- // if slotRoot is null, it means the msg.data is invalid
196
- // in that case message will be rejected when deserializing data in later phase (gossipValidatorFn)
197
- if (slotRoot) {
198
- // DOS protection: avoid processing messages that are too old
199
- const { slot, root } = slotRoot;
200
- const clockSlot = this.chain.clock.currentSlot;
201
- const { fork } = message.topic.boundary;
202
- let earliestPermissableSlot = clockSlot - DEFAULT_EARLIEST_PERMISSIBLE_SLOT_DISTANCE;
203
- if (ForkSeq[fork] >= ForkSeq.deneb && topicType === GossipType.beacon_attestation) {
204
- // post deneb, the attestations could be in current or previous epoch
205
- earliestPermissableSlot = computeStartSlotAtEpoch(this.chain.clock.currentEpoch - 1);
232
+ // 1st extract round: make sure slot is in range and if block root is not available
233
+ // proactively search for it + queue the message
234
+ const slotRoot = extractBlockSlotRootFn
235
+ ? extractBlockSlotRootFn(message.msg.data, message.topic.boundary.fork)
236
+ : null;
237
+ if (slotRoot === null) {
238
+ // some messages don't have slot and root
239
+ // if the msg.data is invalid, message will be rejected when deserializing data in later phase (gossipValidatorFn)
240
+ this.pushPendingGossipsubMessageToQueue(message);
241
+ return;
242
+ }
243
+ // common check for all topics
244
+ // DOS protection: avoid processing messages that are too old
245
+ const { slot, root } = slotRoot;
246
+ const clockSlot = this.chain.clock.currentSlot;
247
+ const { fork } = message.topic.boundary;
248
+ let earliestPermissableSlot = clockSlot - DEFAULT_EARLIEST_PERMISSIBLE_SLOT_DISTANCE;
249
+ if (ForkSeq[fork] >= ForkSeq.deneb && topicType === GossipType.beacon_attestation) {
250
+ // post deneb, the attestations could be in current or previous epoch
251
+ earliestPermissableSlot = computeStartSlotAtEpoch(this.chain.clock.currentEpoch - 1);
252
+ }
253
+ if (slot < earliestPermissableSlot) {
254
+ // No need to report the dropped job to gossip. It will be eventually pruned from the mcache
255
+ this.metrics?.networkProcessor.gossipValidationError.inc({
256
+ topic: topicType,
257
+ error: GossipErrorCode.PAST_SLOT,
258
+ });
259
+ return;
260
+ }
261
+ message.msgSlot = slot;
262
+ // this determines whether this message needs to wait for a Block or Envelope
263
+ // a message should only wait for what it voted for, hence we don't want to put it on both queues
264
+ let preprocessResult = { action: PreprocessAction.PushToQueue };
265
+ // no need to check if root is a descendant of the current finalized block, it will be checked once we validate the message if needed
266
+ if (root && !this.chain.forkChoice.hasBlockHexUnsafe(root)) {
267
+ // starting from GLOAS, unknown root from data_column_sidecar also falls into this case
268
+ this.searchUnknownBlock({ slot, root }, BlockInputSource.network_processor, message.propagationSource.toString());
269
+ // for beacon_attestation and beacon_aggregate_and_proof messages, this is only temporary.
270
+ // if "index = 1" we need to await for the Envelope instead
271
+ preprocessResult = { action: PreprocessAction.AwaitBlock, root };
272
+ }
273
+ // 2nd extract round for some specific topics
274
+ // we separate the search action from the await action
275
+ // beacon_block: proactively search for parent block/envelope across all forks, but never queue.
276
+ // BlockInputSync handles cascading recovery if the gossip handler throws.
277
+ if (topicType === GossipType.beacon_block) {
278
+ const parentRoot = getParentRootFromSignedBeaconBlockSerialized(message.msg.data);
279
+ if (parentRoot) {
280
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
281
+ // GLOAS: also check parent envelope, same logic as execution_payload_bid
282
+ const parentBlockHash = getParentBlockHashFromGloasSignedBeaconBlockSerialized(message.msg.data);
283
+ if (parentBlockHash && !this.chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHash)) {
284
+ const protoBlock = this.chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
285
+ if (protoBlock === null) {
286
+ this.searchUnknownBlock({ slot, root: parentRoot }, BlockInputSource.network_processor, message.propagationSource.toString());
287
+ }
288
+ else if (protoBlock.executionPayloadBlockHash &&
289
+ protoBlock.executionPayloadBlockHash !== parentBlockHash) {
290
+ // only search for the envelope by block root if we're sure there is one. Otherwise UnknownBlockSync will penalize the peer.
291
+ this.searchUnknownEnvelope({ slot, root: parentRoot }, BlockInputSource.network_processor, message.propagationSource.toString());
292
+ }
293
+ }
294
+ }
295
+ else if (!this.chain.forkChoice.hasBlockHexUnsafe(parentRoot)) {
296
+ this.searchUnknownBlock({ slot, root: parentRoot }, BlockInputSource.network_processor, message.propagationSource.toString());
297
+ }
298
+ }
299
+ preprocessResult = { action: PreprocessAction.PushToQueue };
300
+ }
301
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
302
+ // specific check for each topic
303
+ // note that it's supposed to NOT queue beacon_block (handled above) and execution_payload because it's not a one-off;
304
+ // for those topics, gossip handlers will throw and BlockInputSync will handle a tree of them instead
305
+ switch (topicType) {
306
+ case GossipType.beacon_attestation:
307
+ case GossipType.beacon_aggregate_and_proof: {
308
+ if (root == null)
309
+ break;
310
+ const attIndex = topicType === GossipType.beacon_attestation
311
+ ? getIndexFromSingleAttestationSerialized(fork, message.msg.data)
312
+ : getIndexFromSignedAggregateAndProofSerialized(message.msg.data);
313
+ if (attIndex === 1 && !this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
314
+ // ptc attestation votes for the payload but the envelope is not yet known
315
+ this.searchUnknownEnvelope({ slot, root }, BlockInputSource.network_processor, message.propagationSource.toString());
316
+ preprocessResult = { action: PreprocessAction.AwaitEnvelope, root };
317
+ }
318
+ break;
319
+ }
320
+ case GossipType.payload_attestation_message: {
321
+ if (root == null)
322
+ break;
323
+ const payloadPresent = getPayloadPresentFromPayloadAttestationMessageSerialized(message.msg.data);
324
+ if (payloadPresent && !this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
325
+ this.searchUnknownEnvelope({ slot, root }, BlockInputSource.network_processor, message.propagationSource.toString());
326
+ preprocessResult = { action: PreprocessAction.AwaitEnvelope, root };
327
+ }
328
+ break;
329
+ }
330
+ case GossipType.data_column_sidecar: {
331
+ if (root == null)
332
+ break;
333
+ if (!this.chain.forkChoice.hasPayloadHexUnsafe(root)) {
334
+ this.searchUnknownEnvelope({ slot, root }, BlockInputSource.network_processor, message.propagationSource.toString());
335
+ // do not await the envelope, we can do gossip validation
336
+ // also do not reset preprocessResult, we may already await for the block
337
+ }
338
+ break;
339
+ }
340
+ case GossipType.execution_payload: {
341
+ // extractBlockSlotRootFn does not return a root for this topic.
342
+ // Extract beacon_block_root directly and proactively trigger block sync if missing.
343
+ // Do NOT await the block — the handler runs immediately; BlockInputSync handles recovery.
344
+ const blockRoot = getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized(message.msg.data);
345
+ if (blockRoot && !this.chain.forkChoice.hasBlockHexUnsafe(blockRoot)) {
346
+ this.searchUnknownBlock({ slot, root: blockRoot }, BlockInputSource.network_processor, message.propagationSource.toString());
347
+ }
348
+ // do not await the block, we want UnknownBlockSync to handle it.
349
+ preprocessResult = { action: PreprocessAction.PushToQueue };
350
+ break;
351
+ }
352
+ case GossipType.execution_payload_bid: {
353
+ // instead of searching for the message root, this searches for the parent root
354
+ const parentBlockRoot = getParentBlockRootFromSignedExecutionPayloadBidSerialized(message.msg.data);
355
+ const parentBlockHash = getParentBlockHashFromSignedExecutionPayloadBidSerialized(message.msg.data);
356
+ if (parentBlockRoot &&
357
+ parentBlockHash &&
358
+ !this.chain.forkChoice.getBlockHexAndBlockHash(parentBlockRoot, parentBlockHash)) {
359
+ const protoBlock = this.chain.forkChoice.getBlockHexDefaultStatus(parentBlockRoot);
360
+ if (protoBlock === null) {
361
+ this.searchUnknownBlock({ slot, root: parentBlockRoot }, BlockInputSource.network_processor, message.propagationSource.toString());
362
+ preprocessResult = { action: PreprocessAction.AwaitBlock, root: parentBlockRoot };
363
+ }
364
+ else if (protoBlock.executionPayloadBlockHash &&
365
+ protoBlock.executionPayloadBlockHash !== parentBlockHash) {
366
+ this.searchUnknownEnvelope({ slot, root: parentBlockRoot }, BlockInputSource.network_processor, message.propagationSource.toString());
367
+ preprocessResult = { action: PreprocessAction.AwaitEnvelope, root: parentBlockRoot };
368
+ }
369
+ }
370
+ break;
206
371
  }
207
- if (slot < earliestPermissableSlot) {
208
- // TODO: Should report the dropped job to gossip? It will be eventually pruned from the mcache
209
- this.metrics?.networkProcessor.gossipValidationError.inc({
372
+ }
373
+ }
374
+ switch (preprocessResult.action) {
375
+ case PreprocessAction.PushToQueue:
376
+ this.pushPendingGossipsubMessageToQueue(message);
377
+ break;
378
+ case PreprocessAction.AwaitBlock: {
379
+ if (this.unknownBlockGossipsubMessagesCount > MAX_QUEUED_UNKNOWN_BLOCK_GOSSIP_OBJECTS) {
380
+ // No need to report the dropped job to gossip. It will be eventually pruned from the mcache
381
+ this.metrics?.awaitingBlockGossipMessages.reject.inc({
382
+ reason: ReprocessRejectReason.reached_limit,
210
383
  topic: topicType,
211
- error: GossipErrorCode.PAST_SLOT,
212
384
  });
213
385
  return;
214
386
  }
215
- message.msgSlot = slot;
216
- // check if we processed a block with this root
217
- // no need to check if root is a descendant of the current finalized block, it will be checked once we validate the message if needed
218
- if (root && !this.chain.forkChoice.hasBlockHexUnsafe(root)) {
219
- this.searchUnknownSlotRoot({ slot, root }, BlockInputSource.gossip, message.propagationSource.toString());
220
- if (this.unknownBlockGossipsubMessagesCount > MAX_QUEUED_UNKNOWN_BLOCK_GOSSIP_OBJECTS) {
221
- // TODO: Should report the dropped job to gossip? It will be eventually pruned from the mcache
222
- this.metrics?.reprocessGossipAttestations.reject.inc({ reason: ReprocessRejectReason.reached_limit });
223
- return;
224
- }
225
- this.metrics?.reprocessGossipAttestations.total.inc();
226
- const awaitingGossipsubMessagesByRoot = this.awaitingGossipsubMessagesByRootBySlot.getOrDefault(slot);
227
- const awaitingGossipsubMessages = awaitingGossipsubMessagesByRoot.getOrDefault(root);
228
- awaitingGossipsubMessages.add(message);
229
- this.unknownBlockGossipsubMessagesCount++;
387
+ this.metrics?.awaitingBlockGossipMessages.queue.inc({ topic: topicType });
388
+ const awaitingGossipsubMessages = this.awaitingMessagesByBlockRoot.getOrDefault(preprocessResult.root);
389
+ awaitingGossipsubMessages.add(message);
390
+ break;
391
+ }
392
+ case PreprocessAction.AwaitEnvelope: {
393
+ if (this.unknownPayloadGossipsubMessagesCount > MAX_QUEUED_UNKNOWN_PAYLOAD_GOSSIP_OBJECTS) {
394
+ this.metrics?.awaitingPayloadGossipMessages.reject.inc({
395
+ reason: ReprocessRejectReason.reached_limit,
396
+ topic: topicType,
397
+ });
230
398
  return;
231
399
  }
400
+ this.metrics?.awaitingPayloadGossipMessages.queue.inc({ topic: topicType });
401
+ const awaitingPayloadGossipsubMessages = this.awaitingMessagesByPayloadBlockRoot.getOrDefault(preprocessResult.root);
402
+ awaitingPayloadGossipsubMessages.add(message);
403
+ break;
232
404
  }
233
405
  }
234
- // bypass the check for other messages
235
- this.pushPendingGossipsubMessageToQueue(message);
236
- }
406
+ };
237
407
  pushPendingGossipsubMessageToQueue(message) {
238
408
  const topicType = message.topic.type;
239
409
  const droppedCount = this.gossipQueues[topicType].add(message);
240
410
  if (droppedCount) {
241
- // TODO: Should report the dropped job to gossip? It will be eventually pruned from the mcache
411
+ // No need to report the dropped job to gossip. It will be eventually pruned from the mcache
242
412
  this.metrics?.gossipValidationQueue.droppedJobs.inc({ topic: message.topic.type }, droppedCount);
243
413
  }
244
414
  // Tentatively perform work
245
415
  this.executeWork();
246
416
  }
247
- async onBlockProcessed({ slot, block: rootHex, }) {
248
- const byRootGossipsubMessages = this.awaitingGossipsubMessagesByRootBySlot.getOrDefault(slot);
249
- const waitingGossipsubMessages = byRootGossipsubMessages.getOrDefault(rootHex);
250
- if (waitingGossipsubMessages.size === 0) {
417
+ onBlockProcessed = async ({ block: rootHex }) => {
418
+ const waitingGossipsubMessages = this.awaitingMessagesByBlockRoot.get(rootHex);
419
+ if (!waitingGossipsubMessages || waitingGossipsubMessages.size === 0) {
251
420
  return;
252
421
  }
253
- this.metrics?.reprocessGossipAttestations.resolve.inc(waitingGossipsubMessages.size);
254
422
  const nowSec = Date.now() / 1000;
255
423
  let count = 0;
256
424
  // TODO: we can group attestations to process in batches but since we have the SeenAttestationDatas
257
425
  // cache, it may not be necessary at this time
258
426
  for (const message of waitingGossipsubMessages) {
259
- this.metrics?.reprocessGossipAttestations.waitSecBeforeResolve.set(nowSec - message.seenTimestampSec);
427
+ const topicType = message.topic.type;
428
+ this.metrics?.awaitingBlockGossipMessages.waitSecBeforeResolve.set({ topic: topicType }, nowSec - message.seenTimestampSec);
429
+ this.metrics?.awaitingBlockGossipMessages.resolve.inc({ topic: topicType });
260
430
  this.pushPendingGossipsubMessageToQueue(message);
261
431
  count++;
262
432
  // don't want to block the event loop, worse case it'd wait for 16_084 / 1024 * 50ms = 800ms which is not a big deal
263
- if (count === MAX_UNKNOWN_BLOCK_GOSSIP_OBJECTS_PER_TICK) {
433
+ if (count === MAX_AWAITING_GOSSIP_OBJECTS_PER_TICK) {
264
434
  count = 0;
265
- await sleep(PROCESS_UNKNOWN_BLOCK_GOSSIP_OBJECTS_YIELD_EVERY_MS);
435
+ await sleep(AWAITING_GOSSIP_OBJECTS_YIELD_EVERY_MS);
266
436
  }
267
437
  }
268
- byRootGossipsubMessages.delete(rootHex);
269
- }
270
- onClockSlot(clockSlot) {
438
+ this.awaitingMessagesByBlockRoot.delete(rootHex);
439
+ };
440
+ onPayloadEnvelopeProcessed = async ({ blockRoot: rootHex }) => {
441
+ const waitingGossipsubMessages = this.awaitingMessagesByPayloadBlockRoot.get(rootHex);
442
+ if (!waitingGossipsubMessages || waitingGossipsubMessages.size === 0) {
443
+ return;
444
+ }
445
+ const nowSec = Date.now() / 1000;
446
+ let count = 0;
447
+ for (const message of waitingGossipsubMessages) {
448
+ const topicType = message.topic.type;
449
+ this.metrics?.awaitingPayloadGossipMessages.waitSecBeforeResolve.set({ topic: topicType }, nowSec - message.seenTimestampSec);
450
+ this.metrics?.awaitingPayloadGossipMessages.resolve.inc({ topic: topicType });
451
+ this.pushPendingGossipsubMessageToQueue(message);
452
+ count++;
453
+ if (count === MAX_AWAITING_GOSSIP_OBJECTS_PER_TICK) {
454
+ count = 0;
455
+ await sleep(AWAITING_GOSSIP_OBJECTS_YIELD_EVERY_MS);
456
+ }
457
+ }
458
+ this.awaitingMessagesByPayloadBlockRoot.delete(rootHex);
459
+ };
460
+ onClockSlot = (clockSlot) => {
271
461
  const nowSec = Date.now() / 1000;
272
- for (const [slot, gossipMessagesByRoot] of this.awaitingGossipsubMessagesByRootBySlot.entries()) {
273
- if (slot < clockSlot) {
274
- for (const gossipMessages of gossipMessagesByRoot.values()) {
462
+ const minSlot = clockSlot - MAX_UNKNOWN_ROOTS_SLOT_CACHE_SIZE;
463
+ for (const [slot, roots] of this.unknownBlocksBySlot) {
464
+ if (slot > minSlot)
465
+ continue;
466
+ for (const rootHex of roots) {
467
+ const gossipMessages = this.awaitingMessagesByBlockRoot.get(rootHex);
468
+ if (gossipMessages !== undefined) {
275
469
  for (const message of gossipMessages) {
276
- this.metrics?.reprocessGossipAttestations.reject.inc({ reason: ReprocessRejectReason.expired });
277
- this.metrics?.reprocessGossipAttestations.waitSecBeforeReject.set({ reason: ReprocessRejectReason.expired }, nowSec - message.seenTimestampSec);
278
- // TODO: Should report the dropped job to gossip? It will be eventually pruned from the mcache
470
+ const topicType = message.topic.type;
471
+ this.metrics?.awaitingBlockGossipMessages.reject.inc({
472
+ topic: topicType,
473
+ reason: ReprocessRejectReason.expired,
474
+ });
475
+ this.metrics?.awaitingBlockGossipMessages.waitSecBeforeReject.set({ topic: topicType, reason: ReprocessRejectReason.expired }, nowSec - message.seenTimestampSec);
476
+ // No need to report the dropped job to gossip. It will be eventually pruned from the mcache
279
477
  }
478
+ this.awaitingMessagesByBlockRoot.delete(rootHex);
280
479
  }
281
- this.awaitingGossipsubMessagesByRootBySlot.delete(slot);
282
480
  }
481
+ this.unknownBlocksBySlot.delete(slot);
283
482
  }
284
- pruneSetToMax(this.unknownRootsBySlot, MAX_UNKNOWN_ROOTS_SLOT_CACHE_SIZE);
285
- this.unknownBlockGossipsubMessagesCount = 0;
286
- }
483
+ for (const [slot, roots] of this.unknownEnvelopesBySlot) {
484
+ if (slot > minSlot)
485
+ continue;
486
+ for (const rootHex of roots) {
487
+ const gossipMessages = this.awaitingMessagesByPayloadBlockRoot.get(rootHex);
488
+ if (gossipMessages !== undefined) {
489
+ for (const message of gossipMessages) {
490
+ const topicType = message.topic.type;
491
+ this.metrics?.awaitingPayloadGossipMessages.reject.inc({
492
+ topic: topicType,
493
+ reason: ReprocessRejectReason.expired,
494
+ });
495
+ this.metrics?.awaitingPayloadGossipMessages.waitSecBeforeReject.set({ topic: topicType, reason: ReprocessRejectReason.expired }, nowSec - message.seenTimestampSec);
496
+ // No need to report the dropped job to gossip. It will be eventually pruned from the mcache
497
+ }
498
+ this.awaitingMessagesByPayloadBlockRoot.delete(rootHex);
499
+ }
500
+ }
501
+ this.unknownEnvelopesBySlot.delete(slot);
502
+ }
503
+ };
287
504
  executeWork() {
288
505
  // TODO: Maybe de-bounce by timing the last time executeWork was run
289
506
  this.metrics?.networkProcessor.executeWorkCalls.inc();
@@ -397,5 +614,19 @@ export class NetworkProcessor {
397
614
  }
398
615
  return null;
399
616
  }
617
+ get unknownBlockGossipsubMessagesCount() {
618
+ let count = 0;
619
+ for (const messages of this.awaitingMessagesByBlockRoot.values()) {
620
+ count += messages.size;
621
+ }
622
+ return count;
623
+ }
624
+ get unknownPayloadGossipsubMessagesCount() {
625
+ let count = 0;
626
+ for (const messages of this.awaitingMessagesByPayloadBlockRoot.values()) {
627
+ count += messages.size;
628
+ }
629
+ return count;
630
+ }
400
631
  }
401
632
  //# sourceMappingURL=index.js.map