@lodestar/beacon-node 1.51.0-dev.4157a0dec4 → 1.51.0-dev.41efb1b1d9

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 (456) hide show
  1. package/lib/api/impl/api.js +1 -1
  2. package/lib/api/impl/api.js.map +1 -1
  3. package/lib/api/impl/beacon/blocks/index.d.ts +2 -1
  4. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/blocks/index.js +29 -34
  6. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  7. package/lib/api/impl/beacon/index.d.ts +2 -1
  8. package/lib/api/impl/beacon/index.d.ts.map +1 -1
  9. package/lib/api/impl/beacon/index.js +2 -2
  10. package/lib/api/impl/beacon/index.js.map +1 -1
  11. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  12. package/lib/api/impl/beacon/pool/index.js +5 -2
  13. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  14. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  15. package/lib/api/impl/beacon/state/index.js +8 -2
  16. package/lib/api/impl/beacon/state/index.js.map +1 -1
  17. package/lib/api/impl/beacon/state/utils.d.ts +3 -2
  18. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  19. package/lib/api/impl/beacon/state/utils.js +17 -9
  20. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  21. package/lib/api/impl/debug/index.d.ts.map +1 -1
  22. package/lib/api/impl/debug/index.js +3 -0
  23. package/lib/api/impl/debug/index.js.map +1 -1
  24. package/lib/api/impl/validator/index.d.ts +6 -0
  25. package/lib/api/impl/validator/index.d.ts.map +1 -1
  26. package/lib/api/impl/validator/index.js +143 -35
  27. package/lib/api/impl/validator/index.js.map +1 -1
  28. package/lib/api/options.d.ts +2 -0
  29. package/lib/api/options.d.ts.map +1 -1
  30. package/lib/api/options.js +1 -0
  31. package/lib/api/options.js.map +1 -1
  32. package/lib/chain/GetBlobsTracker.d.ts +11 -0
  33. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  34. package/lib/chain/GetBlobsTracker.js +85 -27
  35. package/lib/chain/GetBlobsTracker.js.map +1 -1
  36. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  37. package/lib/chain/archiveStore/archiveStore.js +1 -0
  38. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  39. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +4 -0
  40. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  41. package/lib/chain/archiveStore/utils/archiveBlocks.js +61 -97
  42. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  43. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  44. package/lib/chain/blocks/importBlock.js +9 -7
  45. package/lib/chain/blocks/importBlock.js.map +1 -1
  46. package/lib/chain/blocks/importExecutionPayload.d.ts +6 -11
  47. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  48. package/lib/chain/blocks/importExecutionPayload.js +58 -17
  49. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  50. package/lib/chain/blocks/index.js +2 -2
  51. package/lib/chain/blocks/index.js.map +1 -1
  52. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +12 -9
  53. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  54. package/lib/chain/blocks/payloadEnvelopeProcessor.js +24 -19
  55. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  56. package/lib/chain/blocks/types.d.ts +8 -1
  57. package/lib/chain/blocks/types.d.ts.map +1 -1
  58. package/lib/chain/blocks/types.js +5 -0
  59. package/lib/chain/blocks/types.js.map +1 -1
  60. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  61. package/lib/chain/blocks/verifyBlock.js +18 -7
  62. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  63. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  64. package/lib/chain/blocks/verifyBlocksDataAvailability.js +8 -1
  65. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  66. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  67. package/lib/chain/blocks/verifyBlocksSignatures.js +7 -5
  68. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  69. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +3 -3
  70. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  71. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +11 -6
  72. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  73. package/lib/chain/bls/interface.d.ts +2 -0
  74. package/lib/chain/bls/interface.d.ts.map +1 -1
  75. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  76. package/lib/chain/bls/multithread/index.js +13 -11
  77. package/lib/chain/bls/multithread/index.js.map +1 -1
  78. package/lib/chain/bls/multithread/types.d.ts +1 -1
  79. package/lib/chain/bls/multithread/types.d.ts.map +1 -1
  80. package/lib/chain/bls/multithread/worker.js +1 -1
  81. package/lib/chain/bls/multithread/worker.js.map +1 -1
  82. package/lib/chain/bls/singleThread.js +1 -1
  83. package/lib/chain/bls/singleThread.js.map +1 -1
  84. package/lib/chain/bls/utils.js +1 -1
  85. package/lib/chain/bls/utils.js.map +1 -1
  86. package/lib/chain/chain.d.ts +3 -2
  87. package/lib/chain/chain.d.ts.map +1 -1
  88. package/lib/chain/chain.js +8 -5
  89. package/lib/chain/chain.js.map +1 -1
  90. package/lib/chain/errors/blockError.d.ts +1 -1
  91. package/lib/chain/errors/blockError.d.ts.map +1 -1
  92. package/lib/chain/errors/blockError.js +1 -1
  93. package/lib/chain/errors/blockError.js.map +1 -1
  94. package/lib/chain/errors/executionPayloadBid.d.ts +11 -1
  95. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  96. package/lib/chain/errors/executionPayloadBid.js +2 -0
  97. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  98. package/lib/chain/errors/inclusionList.d.ts +60 -0
  99. package/lib/chain/errors/inclusionList.d.ts.map +1 -0
  100. package/lib/chain/errors/inclusionList.js +19 -0
  101. package/lib/chain/errors/inclusionList.js.map +1 -0
  102. package/lib/chain/errors/index.d.ts +1 -0
  103. package/lib/chain/errors/index.d.ts.map +1 -1
  104. package/lib/chain/errors/index.js +1 -0
  105. package/lib/chain/errors/index.js.map +1 -1
  106. package/lib/chain/interface.d.ts +4 -4
  107. package/lib/chain/interface.d.ts.map +1 -1
  108. package/lib/chain/interface.js.map +1 -1
  109. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  110. package/lib/chain/opPools/aggregatedAttestationPool.js +23 -10
  111. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  112. package/lib/chain/opPools/attestationPool.d.ts +1 -1
  113. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  114. package/lib/chain/opPools/attestationPool.js +15 -4
  115. package/lib/chain/opPools/attestationPool.js.map +1 -1
  116. package/lib/chain/opPools/inclusionListStore.d.ts +63 -0
  117. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -0
  118. package/lib/chain/opPools/inclusionListStore.js +171 -0
  119. package/lib/chain/opPools/inclusionListStore.js.map +1 -0
  120. package/lib/chain/opPools/index.d.ts +1 -0
  121. package/lib/chain/opPools/index.d.ts.map +1 -1
  122. package/lib/chain/opPools/index.js +1 -0
  123. package/lib/chain/opPools/index.js.map +1 -1
  124. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  125. package/lib/chain/opPools/payloadAttestationPool.js +17 -7
  126. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  127. package/lib/chain/opPools/syncCommitteeMessagePool.d.ts.map +1 -1
  128. package/lib/chain/opPools/syncCommitteeMessagePool.js +9 -3
  129. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  130. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
  131. package/lib/chain/opPools/syncContributionAndProofPool.js +11 -3
  132. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  133. package/lib/chain/opPools/utils.d.ts +1 -1
  134. package/lib/chain/opPools/utils.d.ts.map +1 -1
  135. package/lib/chain/opPools/utils.js +1 -1
  136. package/lib/chain/opPools/utils.js.map +1 -1
  137. package/lib/chain/options.d.ts +0 -1
  138. package/lib/chain/options.d.ts.map +1 -1
  139. package/lib/chain/options.js +0 -1
  140. package/lib/chain/options.js.map +1 -1
  141. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -1
  142. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  143. package/lib/chain/produceBlock/produceBlockBody.js +30 -10
  144. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  145. package/lib/chain/regen/interface.d.ts +1 -1
  146. package/lib/chain/regen/interface.d.ts.map +1 -1
  147. package/lib/chain/regen/interface.js +1 -1
  148. package/lib/chain/regen/interface.js.map +1 -1
  149. package/lib/chain/validation/executionPayloadBid.d.ts +0 -15
  150. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  151. package/lib/chain/validation/executionPayloadBid.js +37 -158
  152. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  153. package/lib/chain/validation/inclusionList.d.ts +14 -0
  154. package/lib/chain/validation/inclusionList.d.ts.map +1 -0
  155. package/lib/chain/validation/inclusionList.js +150 -0
  156. package/lib/chain/validation/inclusionList.js.map +1 -0
  157. package/lib/chain/validation/index.d.ts +1 -0
  158. package/lib/chain/validation/index.d.ts.map +1 -1
  159. package/lib/chain/validation/index.js +1 -0
  160. package/lib/chain/validation/index.js.map +1 -1
  161. package/lib/db/beacon.d.ts +7 -0
  162. package/lib/db/beacon.d.ts.map +1 -1
  163. package/lib/db/beacon.js +34 -0
  164. package/lib/db/beacon.js.map +1 -1
  165. package/lib/db/dataColumnStore.d.ts +1 -1
  166. package/lib/db/dataColumnStore.d.ts.map +1 -1
  167. package/lib/db/dataColumnStore.js +1 -4
  168. package/lib/db/dataColumnStore.js.map +1 -1
  169. package/lib/db/flatFileStore/flatFileStore.js +5 -5
  170. package/lib/db/flatFileStore/flatFileStore.js.map +1 -1
  171. package/lib/db/flatFileStore/slotIndex.d.ts.map +1 -1
  172. package/lib/db/flatFileStore/slotIndex.js +2 -2
  173. package/lib/db/flatFileStore/slotIndex.js.map +1 -1
  174. package/lib/db/interface.d.ts +1 -0
  175. package/lib/db/interface.d.ts.map +1 -1
  176. package/lib/db/repositories/dataColumnSidecarArchive.d.ts +6 -0
  177. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
  178. package/lib/db/repositories/dataColumnSidecarArchive.js +19 -0
  179. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  180. package/lib/execution/builder/apiClient.d.ts +14 -8
  181. package/lib/execution/builder/apiClient.d.ts.map +1 -1
  182. package/lib/execution/builder/apiClient.js +12 -10
  183. package/lib/execution/builder/apiClient.js.map +1 -1
  184. package/lib/execution/builder/http.d.ts +2 -0
  185. package/lib/execution/builder/http.d.ts.map +1 -1
  186. package/lib/execution/builder/http.js +2 -0
  187. package/lib/execution/builder/http.js.map +1 -1
  188. package/lib/execution/builder/validateBid.d.ts.map +1 -1
  189. package/lib/execution/builder/validateBid.js +14 -1
  190. package/lib/execution/builder/validateBid.js.map +1 -1
  191. package/lib/execution/engine/blobVersionedHashes.d.ts +1 -1
  192. package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -1
  193. package/lib/execution/engine/blobVersionedHashes.js.map +1 -1
  194. package/lib/execution/engine/disabled.d.ts +1 -0
  195. package/lib/execution/engine/disabled.d.ts.map +1 -1
  196. package/lib/execution/engine/disabled.js +3 -0
  197. package/lib/execution/engine/disabled.js.map +1 -1
  198. package/lib/execution/engine/http.d.ts +8 -2
  199. package/lib/execution/engine/http.d.ts.map +1 -1
  200. package/lib/execution/engine/http.js +27 -4
  201. package/lib/execution/engine/http.js.map +1 -1
  202. package/lib/execution/engine/index.d.ts +1 -1
  203. package/lib/execution/engine/index.d.ts.map +1 -1
  204. package/lib/execution/engine/index.js +1 -1
  205. package/lib/execution/engine/index.js.map +1 -1
  206. package/lib/execution/engine/interface.d.ts +12 -3
  207. package/lib/execution/engine/interface.d.ts.map +1 -1
  208. package/lib/execution/engine/interface.js.map +1 -1
  209. package/lib/execution/engine/jsonRpcTransport.d.ts +3 -2
  210. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  211. package/lib/execution/engine/jsonRpcTransport.js +33 -9
  212. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  213. package/lib/execution/engine/mock.d.ts +1 -0
  214. package/lib/execution/engine/mock.d.ts.map +1 -1
  215. package/lib/execution/engine/mock.js +31 -7
  216. package/lib/execution/engine/mock.js.map +1 -1
  217. package/lib/execution/engine/payloadIdCache.d.ts +5 -3
  218. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  219. package/lib/execution/engine/payloadIdCache.js +15 -4
  220. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  221. package/lib/execution/engine/restTransport.d.ts +2 -1
  222. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  223. package/lib/execution/engine/restTransport.js +3 -0
  224. package/lib/execution/engine/restTransport.js.map +1 -1
  225. package/lib/execution/engine/sszTypes.d.ts +38 -38
  226. package/lib/execution/engine/transport.d.ts +5 -2
  227. package/lib/execution/engine/transport.d.ts.map +1 -1
  228. package/lib/execution/engine/types.d.ts +25 -1
  229. package/lib/execution/engine/types.d.ts.map +1 -1
  230. package/lib/execution/engine/types.js +19 -6
  231. package/lib/execution/engine/types.js.map +1 -1
  232. package/lib/execution/engine/utils.d.ts.map +1 -1
  233. package/lib/execution/engine/utils.js +3 -2
  234. package/lib/execution/engine/utils.js.map +1 -1
  235. package/lib/index.d.ts +1 -0
  236. package/lib/index.d.ts.map +1 -1
  237. package/lib/index.js +2 -0
  238. package/lib/index.js.map +1 -1
  239. package/lib/metrics/metrics/beacon.d.ts +16 -0
  240. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  241. package/lib/metrics/metrics/beacon.js +35 -0
  242. package/lib/metrics/metrics/beacon.js.map +1 -1
  243. package/lib/metrics/metrics/lodestar.d.ts +16 -0
  244. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  245. package/lib/metrics/metrics/lodestar.js +35 -0
  246. package/lib/metrics/metrics/lodestar.js.map +1 -1
  247. package/lib/metrics/server/http.js +5 -5
  248. package/lib/metrics/server/http.js.map +1 -1
  249. package/lib/monitoring/service.js +1 -1
  250. package/lib/monitoring/service.js.map +1 -1
  251. package/lib/network/core/networkCore.d.ts +2 -0
  252. package/lib/network/core/networkCore.d.ts.map +1 -1
  253. package/lib/network/core/networkCore.js +3 -0
  254. package/lib/network/core/networkCore.js.map +1 -1
  255. package/lib/network/core/networkCoreWorker.js +1 -0
  256. package/lib/network/core/networkCoreWorker.js.map +1 -1
  257. package/lib/network/core/networkCoreWorkerHandler.d.ts +2 -0
  258. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  259. package/lib/network/core/networkCoreWorkerHandler.js +3 -0
  260. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  261. package/lib/network/core/types.d.ts +2 -0
  262. package/lib/network/core/types.d.ts.map +1 -1
  263. package/lib/network/gossip/interface.d.ts +8 -2
  264. package/lib/network/gossip/interface.d.ts.map +1 -1
  265. package/lib/network/gossip/interface.js +1 -0
  266. package/lib/network/gossip/interface.js.map +1 -1
  267. package/lib/network/gossip/topic.d.ts +13 -5
  268. package/lib/network/gossip/topic.d.ts.map +1 -1
  269. package/lib/network/gossip/topic.js +13 -1
  270. package/lib/network/gossip/topic.js.map +1 -1
  271. package/lib/network/interface.d.ts +4 -1
  272. package/lib/network/interface.d.ts.map +1 -1
  273. package/lib/network/libp2p/index.d.ts.map +1 -1
  274. package/lib/network/libp2p/index.js +5 -1
  275. package/lib/network/libp2p/index.js.map +1 -1
  276. package/lib/network/network.d.ts +4 -1
  277. package/lib/network/network.d.ts.map +1 -1
  278. package/lib/network/network.js +11 -1
  279. package/lib/network/network.js.map +1 -1
  280. package/lib/network/options.d.ts +2 -0
  281. package/lib/network/options.d.ts.map +1 -1
  282. package/lib/network/options.js.map +1 -1
  283. package/lib/network/peers/peerManager.d.ts +2 -1
  284. package/lib/network/peers/peerManager.d.ts.map +1 -1
  285. package/lib/network/peers/peerManager.js.map +1 -1
  286. package/lib/network/peers/utils/assertPeerRelevance.d.ts +9 -1
  287. package/lib/network/peers/utils/assertPeerRelevance.d.ts.map +1 -1
  288. package/lib/network/peers/utils/assertPeerRelevance.js +32 -21
  289. package/lib/network/peers/utils/assertPeerRelevance.js.map +1 -1
  290. package/lib/network/peers/utils/enrSubnetsDeserialize.d.ts.map +1 -1
  291. package/lib/network/peers/utils/enrSubnetsDeserialize.js +5 -2
  292. package/lib/network/peers/utils/enrSubnetsDeserialize.js.map +1 -1
  293. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  294. package/lib/network/processor/gossipHandlers.js +95 -37
  295. package/lib/network/processor/gossipHandlers.js.map +1 -1
  296. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  297. package/lib/network/processor/gossipQueues/index.js +6 -0
  298. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  299. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  300. package/lib/network/processor/gossipValidatorFn.js +5 -1
  301. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  302. package/lib/network/processor/index.d.ts +5 -0
  303. package/lib/network/processor/index.d.ts.map +1 -1
  304. package/lib/network/processor/index.js +37 -26
  305. package/lib/network/processor/index.js.map +1 -1
  306. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  307. package/lib/network/reqresp/ReqRespBeaconNode.js +6 -0
  308. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  309. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts +10 -0
  310. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts.map +1 -0
  311. package/lib/network/reqresp/handlers/inclusionListsByIndices.js +30 -0
  312. package/lib/network/reqresp/handlers/inclusionListsByIndices.js.map +1 -0
  313. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  314. package/lib/network/reqresp/handlers/index.js +5 -0
  315. package/lib/network/reqresp/handlers/index.js.map +1 -1
  316. package/lib/network/reqresp/protocols.d.ts +1 -0
  317. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  318. package/lib/network/reqresp/protocols.js +5 -0
  319. package/lib/network/reqresp/protocols.js.map +1 -1
  320. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  321. package/lib/network/reqresp/rateLimit.js +4 -0
  322. package/lib/network/reqresp/rateLimit.js.map +1 -1
  323. package/lib/network/reqresp/types.d.ts +5 -2
  324. package/lib/network/reqresp/types.d.ts.map +1 -1
  325. package/lib/network/reqresp/types.js +3 -0
  326. package/lib/network/reqresp/types.js.map +1 -1
  327. package/lib/node/nodejs.d.ts +3 -1
  328. package/lib/node/nodejs.d.ts.map +1 -1
  329. package/lib/node/nodejs.js +47 -21
  330. package/lib/node/nodejs.js.map +1 -1
  331. package/lib/node/options.d.ts +3 -1
  332. package/lib/node/options.d.ts.map +1 -1
  333. package/lib/node/options.js +4 -2
  334. package/lib/node/options.js.map +1 -1
  335. package/lib/sync/interface.d.ts.map +1 -1
  336. package/lib/sync/interface.js.map +1 -1
  337. package/lib/sync/sync.d.ts +7 -0
  338. package/lib/sync/sync.d.ts.map +1 -1
  339. package/lib/sync/sync.js +61 -3
  340. package/lib/sync/sync.js.map +1 -1
  341. package/lib/sync/unknownBlock.d.ts.map +1 -1
  342. package/lib/sync/unknownBlock.js +42 -18
  343. package/lib/sync/unknownBlock.js.map +1 -1
  344. package/lib/util/file.d.ts.map +1 -1
  345. package/lib/util/file.js +8 -9
  346. package/lib/util/file.js.map +1 -1
  347. package/lib/util/queue/itemQueue.js +1 -1
  348. package/lib/util/queue/itemQueue.js.map +1 -1
  349. package/lib/util/sszBytes.js +2 -2
  350. package/lib/util/sszBytes.js.map +1 -1
  351. package/package.json +31 -32
  352. package/src/api/impl/api.ts +1 -1
  353. package/src/api/impl/beacon/blocks/index.ts +57 -62
  354. package/src/api/impl/beacon/index.ts +3 -1
  355. package/src/api/impl/beacon/pool/index.ts +5 -1
  356. package/src/api/impl/beacon/state/index.ts +10 -1
  357. package/src/api/impl/beacon/state/utils.ts +20 -10
  358. package/src/api/impl/debug/index.ts +4 -0
  359. package/src/api/impl/validator/index.ts +178 -39
  360. package/src/api/options.ts +3 -0
  361. package/src/chain/GetBlobsTracker.ts +97 -38
  362. package/src/chain/archiveStore/archiveStore.ts +1 -0
  363. package/src/chain/archiveStore/utils/archiveBlocks.ts +76 -130
  364. package/src/chain/blocks/importBlock.ts +11 -14
  365. package/src/chain/blocks/importExecutionPayload.ts +81 -23
  366. package/src/chain/blocks/index.ts +6 -2
  367. package/src/chain/blocks/payloadEnvelopeProcessor.ts +35 -24
  368. package/src/chain/blocks/types.ts +9 -1
  369. package/src/chain/blocks/verifyBlock.ts +31 -16
  370. package/src/chain/blocks/verifyBlocksDataAvailability.ts +10 -1
  371. package/src/chain/blocks/verifyBlocksSignatures.ts +7 -5
  372. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +14 -6
  373. package/src/chain/bls/interface.ts +2 -0
  374. package/src/chain/bls/multithread/index.ts +14 -10
  375. package/src/chain/bls/multithread/types.ts +1 -1
  376. package/src/chain/bls/multithread/worker.ts +1 -5
  377. package/src/chain/bls/singleThread.ts +1 -1
  378. package/src/chain/bls/utils.ts +1 -1
  379. package/src/chain/chain.ts +9 -5
  380. package/src/chain/errors/blockError.ts +1 -1
  381. package/src/chain/errors/executionPayloadBid.ts +12 -0
  382. package/src/chain/errors/inclusionList.ts +38 -0
  383. package/src/chain/errors/index.ts +1 -0
  384. package/src/chain/interface.ts +4 -3
  385. package/src/chain/opPools/aggregatedAttestationPool.ts +25 -9
  386. package/src/chain/opPools/attestationPool.ts +16 -4
  387. package/src/chain/opPools/inclusionListStore.ts +208 -0
  388. package/src/chain/opPools/index.ts +1 -0
  389. package/src/chain/opPools/payloadAttestationPool.ts +18 -7
  390. package/src/chain/opPools/syncCommitteeMessagePool.ts +10 -3
  391. package/src/chain/opPools/syncContributionAndProofPool.ts +13 -3
  392. package/src/chain/opPools/utils.ts +1 -1
  393. package/src/chain/options.ts +0 -2
  394. package/src/chain/produceBlock/produceBlockBody.ts +60 -19
  395. package/src/chain/regen/interface.ts +1 -1
  396. package/src/chain/validation/executionPayloadBid.ts +54 -183
  397. package/src/chain/validation/inclusionList.ts +192 -0
  398. package/src/chain/validation/index.ts +1 -0
  399. package/src/db/beacon.ts +44 -0
  400. package/src/db/dataColumnStore.ts +2 -4
  401. package/src/db/flatFileStore/flatFileStore.ts +7 -7
  402. package/src/db/flatFileStore/slotIndex.ts +4 -3
  403. package/src/db/interface.ts +2 -0
  404. package/src/db/repositories/dataColumnSidecarArchive.ts +20 -0
  405. package/src/execution/builder/apiClient.ts +16 -13
  406. package/src/execution/builder/http.ts +4 -0
  407. package/src/execution/builder/validateBid.ts +23 -2
  408. package/src/execution/engine/blobVersionedHashes.ts +1 -1
  409. package/src/execution/engine/disabled.ts +4 -0
  410. package/src/execution/engine/http.ts +40 -5
  411. package/src/execution/engine/index.ts +1 -1
  412. package/src/execution/engine/interface.ts +28 -4
  413. package/src/execution/engine/jsonRpcTransport.ts +46 -9
  414. package/src/execution/engine/mock.ts +32 -7
  415. package/src/execution/engine/payloadIdCache.ts +24 -6
  416. package/src/execution/engine/restTransport.ts +15 -1
  417. package/src/execution/engine/transport.ts +7 -2
  418. package/src/execution/engine/types.ts +44 -7
  419. package/src/execution/engine/utils.ts +4 -2
  420. package/src/index.ts +2 -0
  421. package/src/metrics/metrics/beacon.ts +37 -0
  422. package/src/metrics/metrics/lodestar.ts +36 -0
  423. package/src/metrics/server/http.ts +5 -5
  424. package/src/monitoring/service.ts +1 -1
  425. package/src/network/core/networkCore.ts +5 -0
  426. package/src/network/core/networkCoreWorker.ts +1 -0
  427. package/src/network/core/networkCoreWorkerHandler.ts +4 -0
  428. package/src/network/core/types.ts +2 -0
  429. package/src/network/gossip/interface.ts +5 -0
  430. package/src/network/gossip/topic.ts +14 -0
  431. package/src/network/interface.ts +4 -0
  432. package/src/network/libp2p/index.ts +5 -1
  433. package/src/network/network.ts +19 -1
  434. package/src/network/options.ts +2 -0
  435. package/src/network/peers/peerManager.ts +1 -1
  436. package/src/network/peers/utils/assertPeerRelevance.ts +39 -23
  437. package/src/network/peers/utils/enrSubnetsDeserialize.ts +5 -2
  438. package/src/network/processor/gossipHandlers.ts +116 -40
  439. package/src/network/processor/gossipQueues/index.ts +6 -0
  440. package/src/network/processor/gossipValidatorFn.ts +5 -0
  441. package/src/network/processor/index.ts +33 -24
  442. package/src/network/processor/types.ts +1 -1
  443. package/src/network/reqresp/ReqRespBeaconNode.ts +7 -0
  444. package/src/network/reqresp/handlers/inclusionListsByIndices.ts +44 -0
  445. package/src/network/reqresp/handlers/index.ts +5 -0
  446. package/src/network/reqresp/protocols.ts +6 -0
  447. package/src/network/reqresp/rateLimit.ts +4 -0
  448. package/src/network/reqresp/types.ts +6 -0
  449. package/src/node/nodejs.ts +58 -22
  450. package/src/node/options.ts +9 -6
  451. package/src/sync/interface.ts +1 -0
  452. package/src/sync/sync.ts +65 -4
  453. package/src/sync/unknownBlock.ts +47 -28
  454. package/src/util/file.ts +8 -9
  455. package/src/util/queue/itemQueue.ts +1 -1
  456. package/src/util/sszBytes.ts +2 -2
@@ -0,0 +1,44 @@
1
+ import {PeerId} from "@libp2p/interface";
2
+ import {ResponseOutgoing} from "@lodestar/reqresp";
3
+ import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
4
+ import {heze, ssz} from "@lodestar/types";
5
+ import {toRootHex} from "@lodestar/utils";
6
+ import {IBeaconChain} from "../../../chain/index.js";
7
+ import {prettyPrintPeerId} from "../../util.js";
8
+
9
+ /**
10
+ * Only lists that passed gossip validation are stored and the store skips equivocators, so the spec's
11
+ * "SHOULD NOT respond with lists that fail gossip validation or are from equivocators" holds by construction.
12
+ */
13
+ export async function* onInclusionListsByIndices(
14
+ requestBody: heze.InclusionListsByIndicesRequest,
15
+ chain: IBeaconChain,
16
+ peerId: PeerId,
17
+ peerClient: string
18
+ ): AsyncIterable<ResponseOutgoing> {
19
+ const {slot, dependentRoot, indices} = requestBody;
20
+
21
+ const minimumRequestSlot = Math.max(
22
+ chain.clock.currentSlot - chain.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS,
23
+ computeStartSlotAtEpoch(chain.config.HEZE_FORK_EPOCH)
24
+ );
25
+ if (slot < minimumRequestSlot) {
26
+ chain.logger.debug("Cannot serve InclusionListsByIndices: slot below minimum request slot", {
27
+ slot,
28
+ minimumRequestSlot,
29
+ peer: prettyPrintPeerId(peerId),
30
+ client: peerClient,
31
+ });
32
+ return;
33
+ }
34
+
35
+ const signedInclusionLists = chain.inclusionListStore.getByIndices(slot, toRootHex(dependentRoot), indices);
36
+
37
+ const boundary = chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(slot));
38
+ for (const signedInclusionList of signedInclusionLists.slice(0, chain.config.MAX_REQUEST_INCLUSION_LIST)) {
39
+ yield {
40
+ data: ssz.heze.SignedInclusionList.serialize(signedInclusionList),
41
+ boundary,
42
+ };
43
+ }
44
+ }
@@ -19,6 +19,7 @@ import {onDataColumnSidecarsByRange} from "./dataColumnSidecarsByRange.js";
19
19
  import {onDataColumnSidecarsByRoot} from "./dataColumnSidecarsByRoot.js";
20
20
  import {onExecutionPayloadEnvelopesByRange} from "./executionPayloadEnvelopesByRange.js";
21
21
  import {onExecutionPayloadEnvelopesByRoot} from "./executionPayloadEnvelopesByRoot.js";
22
+ import {onInclusionListsByIndices} from "./inclusionListsByIndices.js";
22
23
  import {onLightClientBootstrap} from "./lightClientBootstrap.js";
23
24
  import {onLightClientFinalityUpdate} from "./lightClientFinalityUpdate.js";
24
25
  import {onLightClientOptimisticUpdate} from "./lightClientOptimisticUpdate.js";
@@ -142,6 +143,10 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
142
143
  },
143
144
  [ReqRespMethod.LightClientFinalityUpdate]: () => onLightClientFinalityUpdate(chain),
144
145
  [ReqRespMethod.LightClientOptimisticUpdate]: () => onLightClientOptimisticUpdate(chain),
146
+ [ReqRespMethod.InclusionListsByIndices]: (req, peerId, peerClient) => {
147
+ const body = deserializeRequestBody(ssz.heze.InclusionListsByIndicesRequest, req.data);
148
+ return onInclusionListsByIndices(body, chain, peerId, peerClient);
149
+ },
145
150
  };
146
151
 
147
152
  return (method) => handlers[method];
@@ -113,6 +113,12 @@ export const ExecutionPayloadEnvelopesByRange = toProtocol({
113
113
  contextBytesType: ContextBytesType.ForkDigest,
114
114
  });
115
115
 
116
+ export const InclusionListsByIndices = toProtocol({
117
+ method: ReqRespMethod.InclusionListsByIndices,
118
+ version: Version.V1,
119
+ contextBytesType: ContextBytesType.ForkDigest,
120
+ });
121
+
116
122
  export const LightClientBootstrap = toProtocol({
117
123
  method: ReqRespMethod.LightClientBootstrap,
118
124
  version: Version.V1,
@@ -109,6 +109,10 @@ export const rateLimitQuotas: (fork: ForkName, config: BeaconConfig) => Record<R
109
109
  // Allow 2 per slot and a very safe bound until there's more testing of real usage.
110
110
  byPeer: {quota: 2, quotaTimeMs: config.getSlotDurationMs(fork)},
111
111
  },
112
+ [ReqRespMethod.InclusionListsByIndices]: {
113
+ // Peers only backfill what gossip missed, so a small per-slot allowance is enough
114
+ byPeer: {quota: 5, quotaTimeMs: config.getSlotDurationMs(fork)},
115
+ },
112
116
  [ReqRespMethod.LightClientOptimisticUpdate]: {
113
117
  // Optimistic updates should not be requested more than once per slot.
114
118
  // Allow 2 per slot and a very safe bound until there's more testing of real usage.
@@ -16,6 +16,7 @@ import {
16
16
  deneb,
17
17
  fulu,
18
18
  gloas,
19
+ heze,
19
20
  phase0,
20
21
  ssz,
21
22
  sszTypesFor,
@@ -53,6 +54,7 @@ export enum ReqRespMethod {
53
54
  LightClientUpdatesByRange = "light_client_updates_by_range",
54
55
  LightClientFinalityUpdate = "light_client_finality_update",
55
56
  LightClientOptimisticUpdate = "light_client_optimistic_update",
57
+ InclusionListsByIndices = "inclusion_lists_by_indices",
56
58
  }
57
59
 
58
60
  // To typesafe events to network
@@ -74,6 +76,7 @@ export type RequestBodyByMethod = {
74
76
  [ReqRespMethod.LightClientUpdatesByRange]: altair.LightClientUpdatesByRange;
75
77
  [ReqRespMethod.LightClientFinalityUpdate]: null;
76
78
  [ReqRespMethod.LightClientOptimisticUpdate]: null;
79
+ [ReqRespMethod.InclusionListsByIndices]: heze.InclusionListsByIndicesRequest;
77
80
  };
78
81
 
79
82
  type ResponseBodyByMethod = {
@@ -96,6 +99,7 @@ type ResponseBodyByMethod = {
96
99
  [ReqRespMethod.LightClientUpdatesByRange]: LightClientUpdate;
97
100
  [ReqRespMethod.LightClientFinalityUpdate]: LightClientFinalityUpdate;
98
101
  [ReqRespMethod.LightClientOptimisticUpdate]: LightClientOptimisticUpdate;
102
+ [ReqRespMethod.InclusionListsByIndices]: heze.SignedInclusionList;
99
103
  };
100
104
 
101
105
  /** Request SSZ type for each method and ForkName */
@@ -126,6 +130,7 @@ export const requestSszTypeByMethod: (
126
130
  [ReqRespMethod.LightClientUpdatesByRange]: ssz.altair.LightClientUpdatesByRange,
127
131
  [ReqRespMethod.LightClientFinalityUpdate]: null,
128
132
  [ReqRespMethod.LightClientOptimisticUpdate]: null,
133
+ [ReqRespMethod.InclusionListsByIndices]: ssz.heze.InclusionListsByIndicesRequest,
129
134
  });
130
135
 
131
136
  export type ResponseTypeGetter<T> = (fork: ForkName, version: number) => Type<T>;
@@ -158,6 +163,7 @@ export const responseSszTypeByMethod: {[K in ReqRespMethod]: ResponseTypeGetter<
158
163
  [ReqRespMethod.ExecutionPayloadEnvelopesByRange]: () => ssz.gloas.SignedExecutionPayloadEnvelope,
159
164
  [ReqRespMethod.LightClientOptimisticUpdate]: (fork) =>
160
165
  sszTypesFor(onlyPostAltairFork(fork)).LightClientOptimisticUpdate,
166
+ [ReqRespMethod.InclusionListsByIndices]: () => ssz.heze.SignedInclusionList,
161
167
  };
162
168
 
163
169
  function onlyPostAltairFork(fork: ForkName): ForkPostAltair {
@@ -1,23 +1,29 @@
1
1
  import {setMaxListeners} from "node:events";
2
2
  import {PrivateKey} from "@libp2p/interface";
3
3
  import {Registry} from "prom-client";
4
+ import {hasher} from "@chainsafe/persistent-merkle-tree";
5
+ import {BeaconApiMethods} from "@lodestar/api/beacon/server";
6
+ import {BeaconConfig} from "@lodestar/config";
7
+ import type {LoggerNode} from "@lodestar/logger/node";
4
8
  import {
5
9
  init as initNativeMetrics,
6
10
  registerLocalValidator as registerNativeLocalValidator,
7
11
  scrapeMetrics as scrapeNativeMetrics,
8
12
  unregisterLocalValidator as unregisterNativeLocalValidator,
9
- } from "@chainsafe/lodestar-z/metrics";
10
- import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
11
- import {hasher} from "@chainsafe/persistent-merkle-tree";
12
- import {BeaconApiMethods} from "@lodestar/api/beacon/server";
13
- import {BeaconConfig} from "@lodestar/config";
14
- import type {LoggerNode} from "@lodestar/logger/node";
13
+ } from "@lodestar/native/metrics";
14
+ import {type PubkeyCache} from "@lodestar/native/pubkeys";
15
15
  import {ZERO_HASH_HEX} from "@lodestar/params";
16
- import {IBeaconStateView, isStatePostBellatrix, isStatePostGloas} from "@lodestar/state-transition";
16
+ import {
17
+ IBeaconStateView,
18
+ computeStartSlotAtEpoch,
19
+ isStatePostBellatrix,
20
+ isStatePostGloas,
21
+ } from "@lodestar/state-transition";
17
22
  import {Slot} from "@lodestar/types";
18
- import {sleep, toRootHex} from "@lodestar/utils";
23
+ import {defer, sleep, toRootHex} from "@lodestar/utils";
19
24
  import {ProcessShutdownCallback} from "@lodestar/validator";
20
25
  import {BeaconRestApiServer, getApi} from "../api/index.js";
26
+ import {getDataColumnSidecarsMinEpoch} from "../chain/archiveStore/utils/archiveBlocks.js";
21
27
  import {BeaconChain, IBeaconChain, initBeaconMetrics} from "../chain/index.js";
22
28
  import {ValidatorMonitor, createValidatorMonitor} from "../chain/validatorMonitor.js";
23
29
  import {IBeaconDb} from "../db/index.js";
@@ -111,6 +117,7 @@ export class BeaconNode {
111
117
 
112
118
  status: BeaconNodeStatus;
113
119
  private controller?: AbortController;
120
+ private closePromise: Promise<void> | undefined;
114
121
 
115
122
  constructor({
116
123
  opts,
@@ -212,6 +219,17 @@ export class BeaconNode {
212
219
 
213
220
  const clock = new Clock({config, genesisTime: anchorState.genesisTime, signal});
214
221
 
222
+ // Before any lookup into the legacy column buckets, which can be slow until compacted
223
+ const columnsMinEpoch =
224
+ opts.chain.archiveDataEpochs === Infinity
225
+ ? null
226
+ : getDataColumnSidecarsMinEpoch(config, clock.currentEpoch, opts.chain.archiveDataEpochs);
227
+ await db.compactLegacyDataColumns(
228
+ columnsMinEpoch !== null && columnsMinEpoch >= config.FULU_FORK_EPOCH
229
+ ? computeStartSlotAtEpoch(columnsMinEpoch)
230
+ : 0
231
+ );
232
+
215
233
  await db.init();
216
234
 
217
235
  // Prune hot db repos
@@ -280,6 +298,7 @@ export class BeaconNode {
280
298
  : undefined,
281
299
  builderApiClientOpts: {
282
300
  timeout: opts.executionBuilder.timeout,
301
+ bidDeadline: opts.executionBuilder.bidDeadline,
283
302
  // Sent with all builder api requests, unless the node runs in private mode
284
303
  userAgent: opts.executionBuilder.userAgent,
285
304
  },
@@ -375,23 +394,40 @@ export class BeaconNode {
375
394
  /**
376
395
  * Stop beacon node and its sub-components.
377
396
  */
378
- async close(): Promise<void> {
379
- if (this.status === BeaconNodeStatus.started) {
380
- this.status = BeaconNodeStatus.closing;
381
- this.sync.close();
382
- if (this.restApi) await this.restApi.close();
383
- await this.network.close();
384
- if (this.metricsServer) await this.metricsServer.close();
385
- if (this.monitoring) await this.monitoring.close();
386
- await this.chain.persistToDisk();
387
- await this.chain.close();
397
+ close(): Promise<void> {
398
+ if (this.closePromise !== undefined) return this.closePromise;
399
+ const completion = defer<void>();
400
+ this.closePromise = completion.promise;
401
+ this.status = BeaconNodeStatus.closing;
402
+ void this.closeInternal().then(completion.resolve, completion.reject);
403
+ return this.closePromise;
404
+ }
405
+
406
+ private async closeInternal(): Promise<void> {
407
+ const errors: unknown[] = [];
408
+ for (const cleanup of [
409
+ () => this.sync.close(),
410
+ () => this.restApi?.close(),
411
+ () => this.network.close(),
412
+ () => this.metricsServer?.close(),
413
+ () => this.monitoring?.close(),
414
+ () => this.chain.persistToDisk(),
415
+ () => this.chain.close(),
388
416
  // Abort signal last: close() calls above clear intervals/timeouts so no new
389
417
  // operations get scheduled. If we aborted first, a still-pending interval could
390
418
  // fire and schedule a new operation after abort, leaving it stuck and delaying shutdown.
391
- if (this.controller) this.controller.abort();
392
- await sleep(DELAY_BEFORE_CLOSING_DB_MS);
393
- await this.db.close();
394
- this.status = BeaconNodeStatus.closed;
419
+ () => this.controller?.abort(),
420
+ () => sleep(DELAY_BEFORE_CLOSING_DB_MS),
421
+ () => this.db.close(),
422
+ ]) {
423
+ try {
424
+ await cleanup();
425
+ } catch (error) {
426
+ errors.push(error);
427
+ }
395
428
  }
429
+ this.status = BeaconNodeStatus.closed;
430
+ if (errors.length === 1) throw errors[0];
431
+ if (errors.length > 1) throw new AggregateError(errors, "Beacon node cleanup failed");
396
432
  }
397
433
  }
@@ -1,7 +1,9 @@
1
+ import {BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS} from "../api/impl/validator/index.js";
1
2
  import {ApiOptions, defaultApiOptions} from "../api/options.js";
2
3
  import {ArchiveMode, DEFAULT_ARCHIVE_MODE, IChainOptions, defaultChainOptions} from "../chain/options.js";
3
4
  import {ValidatorMonitorOpts, defaultValidatorMonitorOpts} from "../chain/validatorMonitor.js";
4
5
  import {DatabaseOptions, defaultDbOptions} from "../db/options.js";
6
+ import {BUILDER_BID_LAG_BUFFER_MS} from "../execution/builder/apiClient.js";
5
7
  import {
6
8
  EngineApiMode,
7
9
  ExecutionBuilderOpts,
@@ -19,16 +21,17 @@ import {SyncOptions, defaultSyncOptions} from "../sync/options.js";
19
21
 
20
22
  // Re-export so the CLI doesn't need to depend on lodestar-api
21
23
  export {allNamespaces} from "../api/rest/index.js";
22
-
23
- // Re-export to use as default values in CLI args
24
+ export type {EngineApiMode};
25
+ // Re-export to use as default values and for validation in CLI args
24
26
  export {
25
- defaultExecutionEngineHttpOpts,
26
- defaultExecutionBuilderHttpOpts,
27
- engineApiModes,
28
27
  ArchiveMode,
28
+ BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS,
29
+ BUILDER_BID_LAG_BUFFER_MS,
29
30
  DEFAULT_ARCHIVE_MODE,
31
+ defaultExecutionBuilderHttpOpts,
32
+ defaultExecutionEngineHttpOpts,
33
+ engineApiModes,
30
34
  };
31
- export type {EngineApiMode};
32
35
 
33
36
  export interface IBeaconNodeOptions {
34
37
  api: ApiOptions;
@@ -7,6 +7,7 @@ import {IBeaconDb} from "../db/index.js";
7
7
  import {Metrics} from "../metrics/index.js";
8
8
  import {INetwork} from "../network/index.js";
9
9
  import {SyncChainDebugState} from "./range/chain.js";
10
+
10
11
  export type {SyncChainDebugState};
11
12
 
12
13
  export type SyncingStatus = routes.node.SyncingStatus;
package/src/sync/sync.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  import {SLOTS_PER_EPOCH} from "@lodestar/params";
2
- import {Slot} from "@lodestar/types";
2
+ import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
3
+ import {Slot, Status} from "@lodestar/types";
3
4
  import {Logger, toRootHex} from "@lodestar/utils";
4
5
  import {IBeaconChain} from "../chain/index.js";
5
- import {GENESIS_SLOT} from "../constants/constants.js";
6
+ import {GENESIS_EPOCH, GENESIS_SLOT} from "../constants/constants.js";
7
+ import {GoodByeReasonCode} from "../constants/index.js";
8
+ import {IBeaconDb} from "../db/index.js";
6
9
  import {ExecutionEngineState} from "../execution/index.js";
7
10
  import {Metrics} from "../metrics/index.js";
8
- import {INetwork, NetworkEvent, NetworkEventData} from "../network/index.js";
11
+ import {INetwork, NetworkEvent, NetworkEventData, PeerAction} from "../network/index.js";
9
12
  import {ClockEvent} from "../util/clock.js";
10
13
  import {isOptimisticBlock} from "../util/forkChoice.js";
14
+ import {PeerIdStr} from "../util/peerId.js";
11
15
  import {MIN_EPOCH_TO_START_GOSSIP} from "./constants.js";
12
16
  import {IBeaconSync, SyncChainDebugState, SyncModules, SyncState, SyncingStatus, syncStateMetric} from "./interface.js";
13
17
  import {SyncOptions} from "./options.js";
@@ -19,6 +23,7 @@ export class BeaconSync implements IBeaconSync {
19
23
  private readonly logger: Logger;
20
24
  private readonly network: INetwork;
21
25
  private readonly chain: IBeaconChain;
26
+ private readonly db: IBeaconDb;
22
27
  private readonly metrics: Metrics | null;
23
28
  private readonly opts: SyncOptions;
24
29
 
@@ -30,10 +35,11 @@ export class BeaconSync implements IBeaconSync {
30
35
  private readonly slotImportTolerance: Slot;
31
36
 
32
37
  constructor(opts: SyncOptions, modules: SyncModules) {
33
- const {config, chain, metrics, network, logger} = modules;
38
+ const {config, chain, db, metrics, network, logger} = modules;
34
39
  this.opts = opts;
35
40
  this.network = network;
36
41
  this.chain = chain;
42
+ this.db = db;
37
43
  this.metrics = metrics;
38
44
  this.logger = logger;
39
45
  this.rangeSync = new RangeSync(modules, opts);
@@ -192,6 +198,11 @@ export class BeaconSync implements IBeaconSync {
192
198
  */
193
199
  private addPeer = (data: NetworkEventData[NetworkEvent.peerConnected]): void => {
194
200
  const localStatus = this.chain.getStatus();
201
+ // Genesis and equal finalized epochs are already checked by assertPeerRelevance in the network worker
202
+ if (data.status.finalizedEpoch > GENESIS_EPOCH && data.status.finalizedEpoch < localStatus.finalizedEpoch) {
203
+ void this.verifyPastFinalizedCheckpoint(data.peer, data.status);
204
+ }
205
+
195
206
  const syncType = getPeerSyncType(localStatus, data.status, this.chain.forkChoice, this.slotImportTolerance);
196
207
  this.logger.verbose("Peer sync type classified", {
197
208
  peer: data.peer,
@@ -216,6 +227,56 @@ export class BeaconSync implements IBeaconSync {
216
227
  this.updateSyncState();
217
228
  };
218
229
 
230
+ /**
231
+ * A behind peer's finalized checkpoint must be the canonical block in effect at the start slot of its epoch
232
+ */
233
+ async verifyPastFinalizedCheckpoint(peer: PeerIdStr, remote: Status): Promise<void> {
234
+ const startSlot = computeStartSlotAtEpoch(remote.finalizedEpoch);
235
+ const root = toRootHex(remote.finalizedRoot);
236
+ try {
237
+ let reason: string | null = null;
238
+ // After a finality jump, finalized blocks stay in fork choice until the archiver migrates them.
239
+ // Fork choice is pruned only after archiving, so a miss here means the db already has this range.
240
+ const canonicalBlock = this.chain.forkChoice.getCanonicalBlockClosestLteSlot(startSlot);
241
+ if (canonicalBlock !== null) {
242
+ if (canonicalBlock.blockRoot === root) return;
243
+ reason = "finalized_root_not_canonical";
244
+ } else {
245
+ const slot = await this.db.blockArchive.getSlotByRoot(remote.finalizedRoot);
246
+ if (slot !== null && slot > startSlot) {
247
+ reason = "finalized_root_after_epoch_start";
248
+ } else if (slot !== startSlot) {
249
+ const childSlot = await this.db.blockArchive.getSlotByParentRoot(remote.finalizedRoot);
250
+ if (childSlot !== null) {
251
+ if (childSlot <= startSlot) reason = "finalized_root_not_in_effect_at_epoch_start";
252
+ } else if (slot === null && startSlot > this.chain.earliestAvailableSlot) {
253
+ // childSlot == null too, neither the root nor a child is canonical
254
+ // or they are canonical and both pruned but peer's finalized epoch starts after earliestAvailableSlot
255
+ reason = "unknown_finalized_root";
256
+ }
257
+ }
258
+ }
259
+
260
+ if (reason !== null) {
261
+ this.logger.debug("Peer finalized checkpoint not in our chain", {
262
+ peer,
263
+ finalizedEpoch: remote.finalizedEpoch,
264
+ root,
265
+ reason,
266
+ });
267
+ this.metrics?.syncPeerFinalizedCheckpointMismatch.inc({reason});
268
+ this.network.reportPeer(peer, PeerAction.Fatal, "PeerFinalizedCheckpointMismatch");
269
+ await this.network.goodbyeAndDisconnect(peer, GoodByeReasonCode.IRRELEVANT_NETWORK);
270
+ }
271
+ } catch (e) {
272
+ this.logger.debug(
273
+ "Error verifying peer finalized checkpoint",
274
+ {peer, finalizedEpoch: remote.finalizedEpoch, root},
275
+ e as Error
276
+ );
277
+ }
278
+ }
279
+
219
280
  /**
220
281
  * Must be called by libp2p when a peer is removed from the peer manager
221
282
  */
@@ -300,10 +300,19 @@ export class BlockInputSync {
300
300
 
301
301
  private onIncompletePayloadEnvelope = (data: ChainEventData[ChainEvent.incompletePayloadEnvelope]): void => {
302
302
  try {
303
- this.addByPayloadInput(data.payloadInput, data.peer);
304
- this.triggerUnknownBlockSearch();
305
- this.metrics?.blockInputSync.requests.inc({type: PendingBlockType.INCOMPLETE_PAYLOAD_ENVELOPE});
306
- this.metrics?.blockInputSync.payloadSource.inc({source: data.source});
303
+ const isNewRoot = this.addByPayloadInput(data.payloadInput, data.peer);
304
+ const pendingPayload = this.pendingPayloads.get(data.payloadInput.blockRootHex);
305
+ if (
306
+ pendingPayload &&
307
+ pendingPayload.status !== PendingPayloadInputStatus.fetching &&
308
+ pendingPayload.status !== PendingPayloadInputStatus.processing
309
+ ) {
310
+ this.triggerUnknownBlockSearch();
311
+ }
312
+ if (isNewRoot) {
313
+ this.metrics?.blockInputSync.requests.inc({type: PendingBlockType.INCOMPLETE_PAYLOAD_ENVELOPE});
314
+ this.metrics?.blockInputSync.payloadSource.inc({source: data.source});
315
+ }
307
316
  } catch (e) {
308
317
  this.logger.debug("Error handling incompletePayloadEnvelope event", {}, e as Error);
309
318
  }
@@ -599,43 +608,44 @@ export class BlockInputSync {
599
608
  return this.chain.seenPayloadEnvelopeInputCache.get(rootHex)?.slot;
600
609
  }
601
610
 
602
- private addByPayloadInput = (
603
- payloadInput: PayloadEnvelopeInput,
604
- peerIdStr?: PeerIdStr,
605
- envelope?: gloas.SignedExecutionPayloadEnvelope
606
- ): void => {
611
+ private addByPayloadInput = (payloadInput: PayloadEnvelopeInput, peerIdStr?: PeerIdStr): boolean => {
607
612
  if (this.knownBadBlocks.has(payloadInput.blockRootHex)) {
608
613
  this.logger.debug("Ignoring payload input for known bad block root", {
609
614
  slot: payloadInput.slot,
610
615
  root: payloadInput.blockRootHex,
611
616
  peerIdStr,
612
617
  });
613
- return;
618
+ return false;
614
619
  }
615
620
 
616
- const pendingPayload = this.toPendingPayloadInput(
617
- payloadInput,
618
- this.pendingPayloads.get(payloadInput.blockRootHex),
619
- envelope
620
- );
621
+ let pendingPayload = this.pendingPayloads.get(payloadInput.blockRootHex);
622
+ const isNewRoot = pendingPayload === undefined;
623
+ // Envelope-only entries must go through reconciliation to validate their speculative envelope.
624
+ if (
625
+ !pendingPayload ||
626
+ pendingPayload.status === PendingPayloadInputStatus.pending ||
627
+ pendingPayload.status === PendingPayloadInputStatus.downloaded
628
+ ) {
629
+ pendingPayload = this.toPendingPayloadInput(payloadInput, pendingPayload);
630
+ this.pendingPayloads.set(payloadInput.blockRootHex, pendingPayload);
631
+
632
+ this.logger.verbose("Added payloadInput to BlockInputSync.pendingPayloads", {
633
+ slot: payloadInput.slot,
634
+ root: payloadInput.blockRootHex,
635
+ delaySec: this.chain.clock.secFromSlot(payloadInput.slot),
636
+ });
637
+ }
621
638
 
622
639
  if (peerIdStr && pendingPayload.peerIdStrings.size < MAX_PEERS_PER_ROOT) {
623
640
  pendingPayload.peerIdStrings.add(peerIdStr);
624
641
  }
625
642
 
626
- this.pendingPayloads.set(payloadInput.blockRootHex, pendingPayload);
627
-
628
- this.logger.verbose("Added payloadInput to BlockInputSync.pendingPayloads", {
629
- slot: payloadInput.slot,
630
- root: payloadInput.blockRootHex,
631
- delaySec: this.chain.clock.secFromSlot(payloadInput.slot),
632
- });
633
-
634
643
  const prunedItemCount = pruneSetToMax(this.pendingPayloads, this.maxPendingBlocks);
635
644
  if (prunedItemCount > 0) {
636
645
  this.metrics?.blockInputSync.removedPayloads.inc({reason: DroppedItemReason.capacity}, prunedItemCount);
637
646
  this.logger.verbose(`Pruned ${prunedItemCount} items from BlockInputSync.pendingPayloads`);
638
647
  }
648
+ return isNewRoot;
639
649
  };
640
650
 
641
651
  private onPeerConnected = (data: NetworkEventData[NetworkEvent.peerConnected]): void => {
@@ -1267,6 +1277,9 @@ export class BlockInputSync {
1267
1277
  }
1268
1278
 
1269
1279
  const payloadInput = await this.chain.seenPayloadEnvelopeInputCache.getOrReload(rootHex);
1280
+ if (this.pendingPayloads.get(rootHex) !== pendingPayload) {
1281
+ return;
1282
+ }
1270
1283
  if (!payloadInput) {
1271
1284
  this.logger.debug("PayloadEnvelopeInput not yet reloadable for imported block, will retry", {
1272
1285
  root: rootHex,
@@ -1278,6 +1291,9 @@ export class BlockInputSync {
1278
1291
  const validationResult = await wrapError(
1279
1292
  validateGossipExecutionPayloadEnvelope(this.chain, pendingPayload.envelope)
1280
1293
  );
1294
+ if (this.pendingPayloads.get(rootHex) !== pendingPayload) {
1295
+ return;
1296
+ }
1281
1297
  if (validationResult.err) {
1282
1298
  this.logger.debug(
1283
1299
  "Pending payload envelope failed validation after block import, refetching by root",
@@ -1345,14 +1361,13 @@ export class BlockInputSync {
1345
1361
  payload.status = PendingPayloadInputStatus.fetching;
1346
1362
 
1347
1363
  const res = await wrapError(this.fetchPayloadInput(payload));
1364
+ if (this.pendingPayloads.get(rootHex) !== payload) {
1365
+ this.logger.verbose("Dropping downloaded payload, entry changed during fetch", logCtx);
1366
+ return;
1367
+ }
1348
1368
  if (!res.err) {
1349
1369
  const pendingPayload = res.result;
1350
1370
  const resultRootHex = getPayloadSyncCacheItemRootHex(pendingPayload);
1351
- // finalization may have deleted this entry while we were awaiting the network, do not resurrect it via the set below
1352
- if (!this.pendingPayloads.has(resultRootHex)) {
1353
- this.logger.verbose("Dropping downloaded payload, entry pruned during fetch", logCtx);
1354
- return;
1355
- }
1356
1371
  this.pendingPayloads.set(resultRootHex, pendingPayload);
1357
1372
  const result = isPendingPayloadEnvelope(pendingPayload)
1358
1373
  ? DownloadResult.WaitingForBlock
@@ -1423,12 +1438,16 @@ export class BlockInputSync {
1423
1438
  this.logger.debug("Processing downloaded payload", logCtx);
1424
1439
 
1425
1440
  const res = await wrapError(this.chain.processExecutionPayload(pendingPayload.payloadInput));
1441
+ // The executionPayload event emitted during import usually removes the entry before this point
1426
1442
  if (!res.err) {
1427
1443
  this.logger.debug("Processed payload from unknown sync", logCtx);
1428
1444
  this.pendingPayloads.delete(rootHex);
1429
1445
  this.triggerUnknownBlockSearch();
1430
1446
  return;
1431
1447
  }
1448
+ if (this.pendingPayloads.get(rootHex) !== pendingPayload) {
1449
+ return;
1450
+ }
1432
1451
 
1433
1452
  if (res.err instanceof PayloadError) {
1434
1453
  switch (res.err.type.code) {
package/src/util/file.ts CHANGED
@@ -1,25 +1,24 @@
1
- import fs from "node:fs";
2
- import {promisify} from "node:util";
1
+ import {readFile as fsReadFile, mkdir, readdir, stat, unlink, writeFile} from "node:fs/promises";
3
2
 
4
3
  /** Ensure a directory exists */
5
4
  export async function ensureDir(path: string): Promise<void> {
6
5
  try {
7
- await promisify(fs.stat)(path);
6
+ await stat(path);
8
7
  } catch (_) {
9
8
  // not exists
10
- await promisify(fs.mkdir)(path, {recursive: true});
9
+ await mkdir(path, {recursive: true});
11
10
  }
12
11
  }
13
12
 
14
13
  /** Write data to a file if it does not exist */
15
14
  export async function writeIfNotExist(filepath: string, bytes: Uint8Array): Promise<boolean> {
16
15
  try {
17
- await promisify(fs.stat)(filepath);
16
+ await stat(filepath);
18
17
  return false;
19
18
  // file exists, do nothing
20
19
  } catch (_) {
21
20
  // not exists
22
- await promisify(fs.writeFile)(filepath, bytes);
21
+ await writeFile(filepath, bytes);
23
22
  return true;
24
23
  }
25
24
  }
@@ -27,7 +26,7 @@ export async function writeIfNotExist(filepath: string, bytes: Uint8Array): Prom
27
26
  /** Remove a file if it exists */
28
27
  export async function removeFile(path: string): Promise<boolean> {
29
28
  try {
30
- await promisify(fs.unlink)(path);
29
+ await unlink(path);
31
30
  return true;
32
31
  } catch (_) {
33
32
  // may not exists
@@ -37,7 +36,7 @@ export async function removeFile(path: string): Promise<boolean> {
37
36
 
38
37
  export async function readFile(path: string): Promise<Uint8Array | null> {
39
38
  try {
40
- return await fs.promises.readFile(path);
39
+ return await fsReadFile(path);
41
40
  } catch (_) {
42
41
  return null;
43
42
  }
@@ -45,7 +44,7 @@ export async function readFile(path: string): Promise<Uint8Array | null> {
45
44
 
46
45
  export async function readFileNames(folderPath: string): Promise<string[]> {
47
46
  try {
48
- return await fs.promises.readdir(folderPath);
47
+ return await readdir(folderPath);
49
48
  } catch (_) {
50
49
  return [];
51
50
  }
@@ -69,7 +69,7 @@ export class JobItemQueue<Args extends any[], R> {
69
69
  if (this.jobs.length === 1 && this.opts.noYieldIfOneItem) {
70
70
  void this.runJob();
71
71
  } else if (this.runningJobs < this.opts.maxConcurrency) {
72
- callInNextEventLoop(this.runJob);
72
+ callInNextEventLoop(() => void this.runJob());
73
73
  }
74
74
  });
75
75
  }
@@ -854,7 +854,7 @@ export function getBlobKzgCommitmentsCountFromSignedBeaconBlockSerialized(
854
854
 
855
855
  const start = bidMsgStart + commitmentsRange.start;
856
856
  const end = bidMsgStart + commitmentsRange.end;
857
- return Math.round(((end > blockBytes.byteLength ? blockBytes.byteLength : end) - start) / commitmentSize);
857
+ return Math.round((Math.min(end, blockBytes.byteLength) - start) / commitmentSize);
858
858
  }
859
859
 
860
860
  const {SignedBeaconBlock, BeaconBlock, BeaconBlockBody, KZGCommitment} = ssz[forkName as ForkPostDeneb];
@@ -880,5 +880,5 @@ export function getBlobKzgCommitmentsCountFromSignedBeaconBlockSerialized(
880
880
  const end = messageRange.end + bodyRange.end + kzgCommitmentsRange.end;
881
881
  const start = messageRange.start + bodyRange.start + kzgCommitmentsRange.start;
882
882
 
883
- return Math.round(((end > blockBytes.byteLength ? blockBytes.byteLength : end) - start) / commitmentSize);
883
+ return Math.round((Math.min(end, blockBytes.byteLength) - start) / commitmentSize);
884
884
  }