@lodestar/beacon-node 1.51.0 → 1.52.0-dev.03eb33e6f1

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 (677) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +99 -127
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +25 -3
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts +1 -1
  8. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  9. package/lib/api/impl/beacon/state/utils.js +2 -1
  10. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  11. package/lib/api/impl/debug/index.d.ts.map +1 -1
  12. package/lib/api/impl/debug/index.js +6 -2
  13. package/lib/api/impl/debug/index.js.map +1 -1
  14. package/lib/api/impl/validator/index.d.ts +6 -0
  15. package/lib/api/impl/validator/index.d.ts.map +1 -1
  16. package/lib/api/impl/validator/index.js +55 -32
  17. package/lib/api/impl/validator/index.js.map +1 -1
  18. package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
  19. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  20. package/lib/chain/ColumnReconstructionTracker.js +4 -0
  21. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  22. package/lib/chain/GetBlobsTracker.d.ts +13 -2
  23. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  24. package/lib/chain/GetBlobsTracker.js +69 -35
  25. package/lib/chain/GetBlobsTracker.js.map +1 -1
  26. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  27. package/lib/chain/archiveStore/archiveStore.js +4 -4
  28. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  29. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  30. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
  31. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  32. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +12 -0
  33. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  34. package/lib/chain/archiveStore/utils/archiveBlocks.js +17 -2
  35. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  36. package/lib/chain/archiveStore/utils/pruneHistory.d.ts +9 -2
  37. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  38. package/lib/chain/archiveStore/utils/pruneHistory.js +19 -7
  39. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  40. package/lib/chain/blocks/blockInput/blockInput.d.ts +11 -56
  41. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  42. package/lib/chain/blocks/blockInput/blockInput.js +8 -242
  43. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  44. package/lib/chain/blocks/blockInput/errors.d.ts +2 -4
  45. package/lib/chain/blocks/blockInput/errors.d.ts.map +1 -1
  46. package/lib/chain/blocks/blockInput/errors.js.map +1 -1
  47. package/lib/chain/blocks/blockInput/types.d.ts +2 -18
  48. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  49. package/lib/chain/blocks/blockInput/types.js +0 -1
  50. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  51. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  52. package/lib/chain/blocks/importBlock.js +36 -53
  53. package/lib/chain/blocks/importBlock.js.map +1 -1
  54. package/lib/chain/blocks/importExecutionPayload.d.ts +11 -12
  55. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  56. package/lib/chain/blocks/importExecutionPayload.js +56 -22
  57. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  58. package/lib/chain/blocks/index.d.ts.map +1 -1
  59. package/lib/chain/blocks/index.js +5 -19
  60. package/lib/chain/blocks/index.js.map +1 -1
  61. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +10 -7
  62. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  63. package/lib/chain/blocks/payloadEnvelopeProcessor.js +22 -17
  64. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  65. package/lib/chain/blocks/types.d.ts +4 -20
  66. package/lib/chain/blocks/types.d.ts.map +1 -1
  67. package/lib/chain/blocks/types.js +0 -24
  68. package/lib/chain/blocks/types.js.map +1 -1
  69. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  70. package/lib/chain/blocks/verifyBlock.js +29 -14
  71. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  72. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +2 -2
  73. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  74. package/lib/chain/blocks/verifyBlocksDataAvailability.js +17 -5
  75. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  76. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +1 -1
  77. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  78. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +14 -8
  79. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  80. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  81. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -0
  82. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  83. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  84. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  85. package/lib/chain/blocks/verifyBlocksSignatures.js +12 -6
  86. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  87. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +2 -2
  88. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  89. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +12 -7
  90. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  91. package/lib/chain/blocks/writeBlockInputToDb.d.ts +0 -2
  92. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  93. package/lib/chain/blocks/writeBlockInputToDb.js +6 -24
  94. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  95. package/lib/chain/bls/interface.d.ts +2 -0
  96. package/lib/chain/bls/interface.d.ts.map +1 -1
  97. package/lib/chain/bls/multithread/index.d.ts +1 -1
  98. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  99. package/lib/chain/bls/multithread/index.js +50 -22
  100. package/lib/chain/bls/multithread/index.js.map +1 -1
  101. package/lib/chain/bls/multithread/types.d.ts +1 -1
  102. package/lib/chain/bls/multithread/types.d.ts.map +1 -1
  103. package/lib/chain/bls/multithread/worker.js +1 -1
  104. package/lib/chain/bls/multithread/worker.js.map +1 -1
  105. package/lib/chain/bls/singleThread.js +1 -1
  106. package/lib/chain/bls/singleThread.js.map +1 -1
  107. package/lib/chain/bls/utils.js +2 -2
  108. package/lib/chain/bls/utils.js.map +1 -1
  109. package/lib/chain/chain.d.ts +31 -9
  110. package/lib/chain/chain.d.ts.map +1 -1
  111. package/lib/chain/chain.js +193 -64
  112. package/lib/chain/chain.js.map +1 -1
  113. package/lib/chain/emitter.d.ts +7 -7
  114. package/lib/chain/emitter.d.ts.map +1 -1
  115. package/lib/chain/emitter.js +5 -5
  116. package/lib/chain/emitter.js.map +1 -1
  117. package/lib/chain/errors/attestationError.d.ts +15 -1
  118. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  119. package/lib/chain/errors/attestationError.js +8 -0
  120. package/lib/chain/errors/attestationError.js.map +1 -1
  121. package/lib/chain/errors/blockError.d.ts +1 -1
  122. package/lib/chain/errors/blockError.d.ts.map +1 -1
  123. package/lib/chain/errors/blockError.js +1 -1
  124. package/lib/chain/errors/blockError.js.map +1 -1
  125. package/lib/chain/errors/executionPayloadBid.d.ts +3 -2
  126. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  127. package/lib/chain/errors/executionPayloadBid.js +1 -1
  128. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  129. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  130. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  131. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  132. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  133. package/lib/chain/errors/index.d.ts +0 -1
  134. package/lib/chain/errors/index.d.ts.map +1 -1
  135. package/lib/chain/errors/index.js +0 -1
  136. package/lib/chain/errors/index.js.map +1 -1
  137. package/lib/chain/forkChoice/index.d.ts +8 -1
  138. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  139. package/lib/chain/forkChoice/index.js +8 -0
  140. package/lib/chain/forkChoice/index.js.map +1 -1
  141. package/lib/chain/forkChoiceExecutionEngine.d.ts +53 -0
  142. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -0
  143. package/lib/chain/forkChoiceExecutionEngine.js +140 -0
  144. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -0
  145. package/lib/chain/interface.d.ts +10 -8
  146. package/lib/chain/interface.d.ts.map +1 -1
  147. package/lib/chain/interface.js.map +1 -1
  148. package/lib/chain/lightClient/index.d.ts +13 -6
  149. package/lib/chain/lightClient/index.d.ts.map +1 -1
  150. package/lib/chain/lightClient/index.js +95 -115
  151. package/lib/chain/lightClient/index.js.map +1 -1
  152. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +17 -4
  153. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  154. package/lib/chain/opPools/aggregatedAttestationPool.js +199 -46
  155. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  156. package/lib/chain/opPools/attestationPool.d.ts +1 -1
  157. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  158. package/lib/chain/opPools/attestationPool.js +15 -4
  159. package/lib/chain/opPools/attestationPool.js.map +1 -1
  160. package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
  161. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
  162. package/lib/chain/opPools/inclusionListStore.js +5 -2
  163. package/lib/chain/opPools/inclusionListStore.js.map +1 -1
  164. package/lib/chain/opPools/index.d.ts +1 -0
  165. package/lib/chain/opPools/index.d.ts.map +1 -1
  166. package/lib/chain/opPools/index.js +1 -0
  167. package/lib/chain/opPools/index.js.map +1 -1
  168. package/lib/chain/opPools/opPool.js +6 -6
  169. package/lib/chain/opPools/opPool.js.map +1 -1
  170. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  171. package/lib/chain/opPools/payloadAttestationPool.js +17 -7
  172. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  173. package/lib/chain/opPools/singleAttestationPool.d.ts +77 -0
  174. package/lib/chain/opPools/singleAttestationPool.d.ts.map +1 -0
  175. package/lib/chain/opPools/singleAttestationPool.js +209 -0
  176. package/lib/chain/opPools/singleAttestationPool.js.map +1 -0
  177. package/lib/chain/opPools/syncCommitteeMessagePool.d.ts.map +1 -1
  178. package/lib/chain/opPools/syncCommitteeMessagePool.js +9 -3
  179. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  180. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
  181. package/lib/chain/opPools/syncContributionAndProofPool.js +11 -3
  182. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  183. package/lib/chain/opPools/utils.d.ts +1 -1
  184. package/lib/chain/opPools/utils.d.ts.map +1 -1
  185. package/lib/chain/opPools/utils.js +1 -1
  186. package/lib/chain/opPools/utils.js.map +1 -1
  187. package/lib/chain/options.d.ts +5 -3
  188. package/lib/chain/options.d.ts.map +1 -1
  189. package/lib/chain/options.js +2 -3
  190. package/lib/chain/options.js.map +1 -1
  191. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  192. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  193. package/lib/chain/produceBlock/produceBlockBody.js +3 -2
  194. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  195. package/lib/chain/proposerTracker.d.ts +31 -0
  196. package/lib/chain/proposerTracker.d.ts.map +1 -0
  197. package/lib/chain/proposerTracker.js +75 -0
  198. package/lib/chain/proposerTracker.js.map +1 -0
  199. package/lib/chain/regen/interface.d.ts +1 -1
  200. package/lib/chain/regen/interface.d.ts.map +1 -1
  201. package/lib/chain/regen/queued.d.ts +1 -1
  202. package/lib/chain/regen/queued.d.ts.map +1 -1
  203. package/lib/chain/regen/queued.js +5 -3
  204. package/lib/chain/regen/queued.js.map +1 -1
  205. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  206. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  207. package/lib/chain/seenCache/seenAttesters.js +1 -1
  208. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  209. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  210. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  211. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  212. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  213. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  214. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  215. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  216. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  217. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +7 -14
  218. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  219. package/lib/chain/seenCache/seenGossipBlockInput.js +6 -65
  220. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  221. package/lib/chain/shufflingCache.d.ts +5 -0
  222. package/lib/chain/shufflingCache.d.ts.map +1 -1
  223. package/lib/chain/shufflingCache.js +39 -1
  224. package/lib/chain/shufflingCache.js.map +1 -1
  225. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  226. package/lib/chain/validation/aggregateAndProof.js +38 -10
  227. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  228. package/lib/chain/validation/attestation.d.ts.map +1 -1
  229. package/lib/chain/validation/attestation.js +33 -17
  230. package/lib/chain/validation/attestation.js.map +1 -1
  231. package/lib/chain/validation/block.d.ts.map +1 -1
  232. package/lib/chain/validation/block.js +9 -1
  233. package/lib/chain/validation/block.js.map +1 -1
  234. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  235. package/lib/chain/validation/dataColumnSidecar.js +8 -1
  236. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  237. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  238. package/lib/chain/validation/executionPayloadBid.js +36 -46
  239. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  240. package/lib/chain/validation/executionPayloadEnvelope.d.ts +6 -0
  241. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  242. package/lib/chain/validation/executionPayloadEnvelope.js +132 -4
  243. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  244. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  245. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  246. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  247. package/lib/chain/validation/syncCommittee.js +16 -10
  248. package/lib/chain/validation/syncCommittee.js.map +1 -1
  249. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  250. package/lib/chain/validation/syncCommitteeContributionAndProof.js +11 -0
  251. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  252. package/lib/chain/validatorMonitor.d.ts +1 -2
  253. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  254. package/lib/chain/validatorMonitor.js +0 -3
  255. package/lib/chain/validatorMonitor.js.map +1 -1
  256. package/lib/db/dataColumnStore.d.ts +3 -2
  257. package/lib/db/dataColumnStore.d.ts.map +1 -1
  258. package/lib/db/dataColumnStore.js +3 -3
  259. package/lib/db/dataColumnStore.js.map +1 -1
  260. package/lib/db/flatFileStore/flatFileStore.d.ts +1 -1
  261. package/lib/db/flatFileStore/flatFileStore.d.ts.map +1 -1
  262. package/lib/db/flatFileStore/flatFileStore.js +10 -9
  263. package/lib/db/flatFileStore/flatFileStore.js.map +1 -1
  264. package/lib/db/flatFileStore/interface.d.ts +2 -1
  265. package/lib/db/flatFileStore/interface.d.ts.map +1 -1
  266. package/lib/db/flatFileStore/slotIndex.d.ts.map +1 -1
  267. package/lib/db/flatFileStore/slotIndex.js +2 -2
  268. package/lib/db/flatFileStore/slotIndex.js.map +1 -1
  269. package/lib/db/repositories/blobSidecars.d.ts +0 -1
  270. package/lib/db/repositories/blobSidecars.d.ts.map +1 -1
  271. package/lib/db/repositories/blobSidecars.js +0 -1
  272. package/lib/db/repositories/blobSidecars.js.map +1 -1
  273. package/lib/db/repositories/dataColumnSidecarArchive.d.ts +2 -1
  274. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
  275. package/lib/db/repositories/dataColumnSidecarArchive.js +14 -4
  276. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  277. package/lib/execution/builder/apiClient.d.ts +14 -8
  278. package/lib/execution/builder/apiClient.d.ts.map +1 -1
  279. package/lib/execution/builder/apiClient.js +12 -10
  280. package/lib/execution/builder/apiClient.js.map +1 -1
  281. package/lib/execution/builder/http.d.ts +2 -0
  282. package/lib/execution/builder/http.d.ts.map +1 -1
  283. package/lib/execution/builder/http.js +2 -0
  284. package/lib/execution/builder/http.js.map +1 -1
  285. package/lib/execution/engine/http.d.ts +4 -6
  286. package/lib/execution/engine/http.d.ts.map +1 -1
  287. package/lib/execution/engine/http.js +8 -10
  288. package/lib/execution/engine/http.js.map +1 -1
  289. package/lib/execution/engine/index.d.ts +1 -1
  290. package/lib/execution/engine/index.d.ts.map +1 -1
  291. package/lib/execution/engine/index.js +1 -1
  292. package/lib/execution/engine/index.js.map +1 -1
  293. package/lib/execution/engine/interface.d.ts +18 -6
  294. package/lib/execution/engine/interface.d.ts.map +1 -1
  295. package/lib/execution/engine/interface.js.map +1 -1
  296. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -4
  297. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  298. package/lib/execution/engine/jsonRpcTransport.js +2 -12
  299. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  300. package/lib/execution/engine/mock.d.ts +0 -1
  301. package/lib/execution/engine/mock.d.ts.map +1 -1
  302. package/lib/execution/engine/mock.js +0 -4
  303. package/lib/execution/engine/mock.js.map +1 -1
  304. package/lib/execution/engine/restTransport.d.ts +2 -4
  305. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  306. package/lib/execution/engine/restTransport.js +1 -15
  307. package/lib/execution/engine/restTransport.js.map +1 -1
  308. package/lib/execution/engine/sszTypes.d.ts +0 -9
  309. package/lib/execution/engine/sszTypes.d.ts.map +1 -1
  310. package/lib/execution/engine/sszTypes.js +0 -5
  311. package/lib/execution/engine/sszTypes.js.map +1 -1
  312. package/lib/execution/engine/transport.d.ts +1 -14
  313. package/lib/execution/engine/transport.d.ts.map +1 -1
  314. package/lib/execution/engine/types.d.ts +0 -8
  315. package/lib/execution/engine/types.d.ts.map +1 -1
  316. package/lib/execution/engine/types.js +2 -10
  317. package/lib/execution/engine/types.js.map +1 -1
  318. package/lib/execution/engine/utils.d.ts.map +1 -1
  319. package/lib/execution/engine/utils.js +3 -2
  320. package/lib/execution/engine/utils.js.map +1 -1
  321. package/lib/index.d.ts +1 -1
  322. package/lib/index.d.ts.map +1 -1
  323. package/lib/index.js +1 -1
  324. package/lib/index.js.map +1 -1
  325. package/lib/metrics/metrics/beacon.d.ts +4 -9
  326. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  327. package/lib/metrics/metrics/beacon.js +11 -32
  328. package/lib/metrics/metrics/beacon.js.map +1 -1
  329. package/lib/metrics/metrics/lodestar.d.ts +32 -8
  330. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  331. package/lib/metrics/metrics/lodestar.js +116 -46
  332. package/lib/metrics/metrics/lodestar.js.map +1 -1
  333. package/lib/metrics/server/http.js +5 -5
  334. package/lib/metrics/server/http.js.map +1 -1
  335. package/lib/monitoring/service.js +1 -1
  336. package/lib/monitoring/service.js.map +1 -1
  337. package/lib/network/core/networkCore.d.ts +4 -1
  338. package/lib/network/core/networkCore.d.ts.map +1 -1
  339. package/lib/network/core/networkCore.js +7 -0
  340. package/lib/network/core/networkCore.js.map +1 -1
  341. package/lib/network/core/networkCoreWorker.js +2 -0
  342. package/lib/network/core/networkCoreWorker.js.map +1 -1
  343. package/lib/network/core/networkCoreWorkerHandler.d.ts +4 -1
  344. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  345. package/lib/network/core/networkCoreWorkerHandler.js +6 -0
  346. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  347. package/lib/network/core/types.d.ts +6 -1
  348. package/lib/network/core/types.d.ts.map +1 -1
  349. package/lib/network/gossip/gossipsub.d.ts +1 -0
  350. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  351. package/lib/network/gossip/gossipsub.js +23 -6
  352. package/lib/network/gossip/gossipsub.js.map +1 -1
  353. package/lib/network/gossip/interface.d.ts +1 -8
  354. package/lib/network/gossip/interface.d.ts.map +1 -1
  355. package/lib/network/gossip/interface.js +0 -1
  356. package/lib/network/gossip/interface.js.map +1 -1
  357. package/lib/network/gossip/topic.d.ts +1 -23
  358. package/lib/network/gossip/topic.d.ts.map +1 -1
  359. package/lib/network/gossip/topic.js +0 -36
  360. package/lib/network/gossip/topic.js.map +1 -1
  361. package/lib/network/interface.d.ts +4 -5
  362. package/lib/network/interface.d.ts.map +1 -1
  363. package/lib/network/libp2p/index.d.ts.map +1 -1
  364. package/lib/network/libp2p/index.js +5 -1
  365. package/lib/network/libp2p/index.js.map +1 -1
  366. package/lib/network/network.d.ts +9 -7
  367. package/lib/network/network.d.ts.map +1 -1
  368. package/lib/network/network.js +73 -46
  369. package/lib/network/network.js.map +1 -1
  370. package/lib/network/options.d.ts +2 -0
  371. package/lib/network/options.d.ts.map +1 -1
  372. package/lib/network/options.js +2 -0
  373. package/lib/network/options.js.map +1 -1
  374. package/lib/network/peers/peerManager.d.ts +2 -1
  375. package/lib/network/peers/peerManager.d.ts.map +1 -1
  376. package/lib/network/peers/peerManager.js +28 -1
  377. package/lib/network/peers/peerManager.js.map +1 -1
  378. package/lib/network/peers/utils/assertPeerRelevance.d.ts +9 -1
  379. package/lib/network/peers/utils/assertPeerRelevance.d.ts.map +1 -1
  380. package/lib/network/peers/utils/assertPeerRelevance.js +32 -21
  381. package/lib/network/peers/utils/assertPeerRelevance.js.map +1 -1
  382. package/lib/network/peers/utils/prioritizePeers.d.ts +4 -1
  383. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  384. package/lib/network/peers/utils/prioritizePeers.js +8 -16
  385. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  386. package/lib/network/peers/utils/subnetMap.d.ts +5 -2
  387. package/lib/network/peers/utils/subnetMap.d.ts.map +1 -1
  388. package/lib/network/peers/utils/subnetMap.js +6 -3
  389. package/lib/network/peers/utils/subnetMap.js.map +1 -1
  390. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
  391. package/lib/network/processor/extractSlotRootFns.js +1 -8
  392. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  393. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  394. package/lib/network/processor/gossipHandlers.js +72 -138
  395. package/lib/network/processor/gossipHandlers.js.map +1 -1
  396. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  397. package/lib/network/processor/gossipQueues/index.js +0 -6
  398. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  399. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  400. package/lib/network/processor/gossipValidatorFn.js +4 -5
  401. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  402. package/lib/network/processor/index.d.ts +6 -0
  403. package/lib/network/processor/index.d.ts.map +1 -1
  404. package/lib/network/processor/index.js +33 -6
  405. package/lib/network/processor/index.js.map +1 -1
  406. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  407. package/lib/network/reqresp/ReqRespBeaconNode.js +0 -3
  408. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  409. package/lib/network/reqresp/handlers/beaconBlocksByHead.js +1 -1
  410. package/lib/network/reqresp/handlers/beaconBlocksByHead.js.map +1 -1
  411. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +2 -2
  412. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  413. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  414. package/lib/network/reqresp/handlers/index.js +1 -12
  415. package/lib/network/reqresp/handlers/index.js.map +1 -1
  416. package/lib/network/reqresp/protocols.d.ts +0 -2
  417. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  418. package/lib/network/reqresp/protocols.js +0 -10
  419. package/lib/network/reqresp/protocols.js.map +1 -1
  420. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  421. package/lib/network/reqresp/rateLimit.js +1 -17
  422. package/lib/network/reqresp/rateLimit.js.map +1 -1
  423. package/lib/network/reqresp/types.d.ts +2 -8
  424. package/lib/network/reqresp/types.d.ts.map +1 -1
  425. package/lib/network/reqresp/types.js +1 -7
  426. package/lib/network/reqresp/types.js.map +1 -1
  427. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  428. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  429. package/lib/network/reqresp/utils/collect.js +9 -8
  430. package/lib/network/reqresp/utils/collect.js.map +1 -1
  431. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  432. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  433. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  434. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  435. package/lib/network/subnets/attnetsService.d.ts +35 -5
  436. package/lib/network/subnets/attnetsService.d.ts.map +1 -1
  437. package/lib/network/subnets/attnetsService.js +84 -6
  438. package/lib/network/subnets/attnetsService.js.map +1 -1
  439. package/lib/network/subnets/interface.d.ts +7 -0
  440. package/lib/network/subnets/interface.d.ts.map +1 -1
  441. package/lib/network/subnets/interface.js.map +1 -1
  442. package/lib/node/nodejs.d.ts +3 -1
  443. package/lib/node/nodejs.d.ts.map +1 -1
  444. package/lib/node/nodejs.js +38 -20
  445. package/lib/node/nodejs.js.map +1 -1
  446. package/lib/node/options.d.ts +3 -1
  447. package/lib/node/options.d.ts.map +1 -1
  448. package/lib/node/options.js +4 -2
  449. package/lib/node/options.js.map +1 -1
  450. package/lib/sync/interface.d.ts.map +1 -1
  451. package/lib/sync/interface.js.map +1 -1
  452. package/lib/sync/range/batch.d.ts +8 -3
  453. package/lib/sync/range/batch.d.ts.map +1 -1
  454. package/lib/sync/range/batch.js +26 -22
  455. package/lib/sync/range/batch.js.map +1 -1
  456. package/lib/sync/range/chain.d.ts.map +1 -1
  457. package/lib/sync/range/chain.js +10 -16
  458. package/lib/sync/range/chain.js.map +1 -1
  459. package/lib/sync/range/range.d.ts.map +1 -1
  460. package/lib/sync/range/range.js +43 -3
  461. package/lib/sync/range/range.js.map +1 -1
  462. package/lib/sync/sync.d.ts +15 -0
  463. package/lib/sync/sync.d.ts.map +1 -1
  464. package/lib/sync/sync.js +103 -25
  465. package/lib/sync/sync.js.map +1 -1
  466. package/lib/sync/types.d.ts +12 -1
  467. package/lib/sync/types.d.ts.map +1 -1
  468. package/lib/sync/types.js +2 -0
  469. package/lib/sync/types.js.map +1 -1
  470. package/lib/sync/unknownBlock.d.ts +28 -1
  471. package/lib/sync/unknownBlock.d.ts.map +1 -1
  472. package/lib/sync/unknownBlock.js +257 -31
  473. package/lib/sync/unknownBlock.js.map +1 -1
  474. package/lib/sync/utils/downloadByRange.d.ts +20 -35
  475. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  476. package/lib/sync/utils/downloadByRange.js +36 -130
  477. package/lib/sync/utils/downloadByRange.js.map +1 -1
  478. package/lib/sync/utils/downloadByRoot.d.ts +23 -17
  479. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  480. package/lib/sync/utils/downloadByRoot.js +57 -100
  481. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  482. package/lib/util/bitArray.d.ts +6 -6
  483. package/lib/util/bitArray.d.ts.map +1 -1
  484. package/lib/util/bitArray.js +25 -50
  485. package/lib/util/bitArray.js.map +1 -1
  486. package/lib/util/blobs.d.ts +1 -7
  487. package/lib/util/blobs.d.ts.map +1 -1
  488. package/lib/util/blobs.js +0 -19
  489. package/lib/util/blobs.js.map +1 -1
  490. package/lib/util/eventLoop.d.ts +5 -0
  491. package/lib/util/eventLoop.d.ts.map +1 -1
  492. package/lib/util/eventLoop.js +7 -0
  493. package/lib/util/eventLoop.js.map +1 -1
  494. package/lib/util/execution.d.ts +3 -4
  495. package/lib/util/execution.d.ts.map +1 -1
  496. package/lib/util/execution.js +1 -73
  497. package/lib/util/execution.js.map +1 -1
  498. package/lib/util/file.d.ts.map +1 -1
  499. package/lib/util/file.js +8 -9
  500. package/lib/util/file.js.map +1 -1
  501. package/lib/util/queue/itemQueue.js +1 -1
  502. package/lib/util/queue/itemQueue.js.map +1 -1
  503. package/lib/util/sszBytes.d.ts +5 -1
  504. package/lib/util/sszBytes.d.ts.map +1 -1
  505. package/lib/util/sszBytes.js +36 -19
  506. package/lib/util/sszBytes.js.map +1 -1
  507. package/lib/util/types.d.ts +0 -5
  508. package/lib/util/types.d.ts.map +1 -1
  509. package/lib/util/types.js +1 -2
  510. package/lib/util/types.js.map +1 -1
  511. package/package.json +27 -28
  512. package/src/api/impl/beacon/blocks/index.ts +133 -156
  513. package/src/api/impl/beacon/pool/index.ts +40 -8
  514. package/src/api/impl/beacon/state/utils.ts +3 -2
  515. package/src/api/impl/debug/index.ts +6 -2
  516. package/src/api/impl/validator/index.ts +62 -36
  517. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  518. package/src/chain/GetBlobsTracker.ts +82 -52
  519. package/src/chain/archiveStore/archiveStore.ts +6 -4
  520. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  521. package/src/chain/archiveStore/utils/archiveBlocks.ts +21 -2
  522. package/src/chain/archiveStore/utils/pruneHistory.ts +24 -9
  523. package/src/chain/blocks/blockInput/blockInput.ts +15 -344
  524. package/src/chain/blocks/blockInput/errors.ts +1 -2
  525. package/src/chain/blocks/blockInput/types.ts +2 -20
  526. package/src/chain/blocks/importBlock.ts +56 -72
  527. package/src/chain/blocks/importExecutionPayload.ts +85 -38
  528. package/src/chain/blocks/index.ts +8 -33
  529. package/src/chain/blocks/payloadEnvelopeProcessor.ts +33 -22
  530. package/src/chain/blocks/types.ts +5 -31
  531. package/src/chain/blocks/verifyBlock.ts +47 -26
  532. package/src/chain/blocks/verifyBlocksDataAvailability.ts +20 -6
  533. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +16 -10
  534. package/src/chain/blocks/verifyBlocksSanityChecks.ts +4 -1
  535. package/src/chain/blocks/verifyBlocksSignatures.ts +13 -5
  536. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +16 -8
  537. package/src/chain/blocks/writeBlockInputToDb.ts +6 -29
  538. package/src/chain/bls/interface.ts +2 -0
  539. package/src/chain/bls/multithread/index.ts +48 -24
  540. package/src/chain/bls/multithread/types.ts +1 -1
  541. package/src/chain/bls/multithread/worker.ts +1 -5
  542. package/src/chain/bls/singleThread.ts +1 -1
  543. package/src/chain/bls/utils.ts +2 -2
  544. package/src/chain/chain.ts +243 -81
  545. package/src/chain/emitter.ts +8 -8
  546. package/src/chain/errors/attestationError.ts +11 -1
  547. package/src/chain/errors/blockError.ts +1 -1
  548. package/src/chain/errors/executionPayloadBid.ts +3 -2
  549. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  550. package/src/chain/errors/index.ts +0 -1
  551. package/src/chain/forkChoice/index.ts +8 -0
  552. package/src/chain/forkChoiceExecutionEngine.ts +216 -0
  553. package/src/chain/interface.ts +10 -7
  554. package/src/chain/lightClient/index.ts +108 -142
  555. package/src/chain/opPools/aggregatedAttestationPool.ts +246 -43
  556. package/src/chain/opPools/attestationPool.ts +16 -4
  557. package/src/chain/opPools/inclusionListStore.ts +5 -2
  558. package/src/chain/opPools/index.ts +1 -0
  559. package/src/chain/opPools/opPool.ts +6 -6
  560. package/src/chain/opPools/payloadAttestationPool.ts +18 -7
  561. package/src/chain/opPools/singleAttestationPool.ts +287 -0
  562. package/src/chain/opPools/syncCommitteeMessagePool.ts +10 -3
  563. package/src/chain/opPools/syncContributionAndProofPool.ts +13 -3
  564. package/src/chain/opPools/utils.ts +1 -1
  565. package/src/chain/options.ts +7 -6
  566. package/src/chain/produceBlock/produceBlockBody.ts +7 -3
  567. package/src/chain/proposerTracker.ts +94 -0
  568. package/src/chain/regen/interface.ts +1 -1
  569. package/src/chain/regen/queued.ts +6 -4
  570. package/src/chain/seenCache/seenAttesters.ts +1 -1
  571. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  572. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  573. package/src/chain/seenCache/seenGossipBlockInput.ts +9 -93
  574. package/src/chain/shufflingCache.ts +40 -1
  575. package/src/chain/validation/aggregateAndProof.ts +44 -15
  576. package/src/chain/validation/attestation.ts +32 -21
  577. package/src/chain/validation/block.ts +9 -1
  578. package/src/chain/validation/dataColumnSidecar.ts +7 -1
  579. package/src/chain/validation/executionPayloadBid.ts +47 -48
  580. package/src/chain/validation/executionPayloadEnvelope.ts +155 -4
  581. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  582. package/src/chain/validation/syncCommittee.ts +31 -15
  583. package/src/chain/validation/syncCommitteeContributionAndProof.ts +13 -0
  584. package/src/chain/validatorMonitor.ts +0 -6
  585. package/src/db/dataColumnStore.ts +5 -4
  586. package/src/db/flatFileStore/flatFileStore.ts +12 -11
  587. package/src/db/flatFileStore/interface.ts +2 -1
  588. package/src/db/flatFileStore/slotIndex.ts +4 -3
  589. package/src/db/repositories/blobSidecars.ts +0 -1
  590. package/src/db/repositories/dataColumnSidecarArchive.ts +14 -4
  591. package/src/execution/builder/apiClient.ts +16 -13
  592. package/src/execution/builder/http.ts +4 -0
  593. package/src/execution/engine/http.ts +19 -42
  594. package/src/execution/engine/index.ts +1 -1
  595. package/src/execution/engine/interface.ts +19 -10
  596. package/src/execution/engine/jsonRpcTransport.ts +10 -22
  597. package/src/execution/engine/mock.ts +0 -7
  598. package/src/execution/engine/restTransport.ts +3 -22
  599. package/src/execution/engine/sszTypes.ts +0 -9
  600. package/src/execution/engine/transport.ts +8 -17
  601. package/src/execution/engine/types.ts +3 -18
  602. package/src/execution/engine/utils.ts +4 -2
  603. package/src/index.ts +1 -1
  604. package/src/metrics/metrics/beacon.ts +11 -32
  605. package/src/metrics/metrics/lodestar.ts +117 -46
  606. package/src/metrics/server/http.ts +5 -5
  607. package/src/monitoring/service.ts +1 -1
  608. package/src/network/core/networkCore.ts +11 -1
  609. package/src/network/core/networkCoreWorker.ts +2 -0
  610. package/src/network/core/networkCoreWorkerHandler.ts +8 -1
  611. package/src/network/core/types.ts +6 -1
  612. package/src/network/gossip/gossipsub.ts +24 -6
  613. package/src/network/gossip/interface.ts +0 -5
  614. package/src/network/gossip/topic.ts +1 -39
  615. package/src/network/interface.ts +2 -5
  616. package/src/network/libp2p/index.ts +5 -1
  617. package/src/network/network.ts +88 -69
  618. package/src/network/options.ts +4 -0
  619. package/src/network/peers/peerManager.ts +28 -3
  620. package/src/network/peers/utils/assertPeerRelevance.ts +39 -23
  621. package/src/network/peers/utils/prioritizePeers.ts +14 -22
  622. package/src/network/peers/utils/subnetMap.ts +6 -3
  623. package/src/network/processor/extractSlotRootFns.ts +0 -9
  624. package/src/network/processor/gossipHandlers.ts +91 -178
  625. package/src/network/processor/gossipQueues/index.ts +0 -6
  626. package/src/network/processor/gossipValidatorFn.ts +4 -5
  627. package/src/network/processor/index.ts +32 -6
  628. package/src/network/reqresp/ReqRespBeaconNode.ts +0 -7
  629. package/src/network/reqresp/handlers/beaconBlocksByHead.ts +1 -1
  630. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -2
  631. package/src/network/reqresp/handlers/index.ts +0 -17
  632. package/src/network/reqresp/protocols.ts +0 -12
  633. package/src/network/reqresp/rateLimit.ts +1 -17
  634. package/src/network/reqresp/types.ts +0 -13
  635. package/src/network/reqresp/utils/collect.ts +16 -8
  636. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  637. package/src/network/subnets/attnetsService.ts +94 -6
  638. package/src/network/subnets/interface.ts +7 -0
  639. package/src/node/nodejs.ts +40 -21
  640. package/src/node/options.ts +9 -6
  641. package/src/sync/interface.ts +1 -0
  642. package/src/sync/range/batch.ts +29 -21
  643. package/src/sync/range/chain.ts +10 -14
  644. package/src/sync/range/range.ts +56 -3
  645. package/src/sync/sync.ts +108 -26
  646. package/src/sync/types.ts +11 -0
  647. package/src/sync/unknownBlock.ts +296 -32
  648. package/src/sync/utils/downloadByRange.ts +60 -233
  649. package/src/sync/utils/downloadByRoot.ts +78 -139
  650. package/src/util/bitArray.ts +22 -43
  651. package/src/util/blobs.ts +0 -34
  652. package/src/util/eventLoop.ts +8 -0
  653. package/src/util/execution.ts +8 -102
  654. package/src/util/file.ts +8 -9
  655. package/src/util/queue/itemQueue.ts +1 -1
  656. package/src/util/sszBytes.ts +42 -24
  657. package/src/util/types.ts +1 -8
  658. package/lib/chain/errors/blobSidecarError.d.ts +0 -108
  659. package/lib/chain/errors/blobSidecarError.d.ts.map +0 -1
  660. package/lib/chain/errors/blobSidecarError.js +0 -38
  661. package/lib/chain/errors/blobSidecarError.js.map +0 -1
  662. package/lib/chain/validation/blobSidecar.d.ts +0 -16
  663. package/lib/chain/validation/blobSidecar.d.ts.map +0 -1
  664. package/lib/chain/validation/blobSidecar.js +0 -276
  665. package/lib/chain/validation/blobSidecar.js.map +0 -1
  666. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts +0 -9
  667. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +0 -1
  668. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +0 -91
  669. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +0 -1
  670. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +0 -5
  671. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +0 -1
  672. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +0 -46
  673. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +0 -1
  674. package/src/chain/errors/blobSidecarError.ts +0 -70
  675. package/src/chain/validation/blobSidecar.ts +0 -357
  676. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +0 -133
  677. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +0 -69
@@ -1,17 +1,17 @@
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
16
  import {
17
17
  IBeaconStateView,
@@ -20,7 +20,7 @@ import {
20
20
  isStatePostGloas,
21
21
  } from "@lodestar/state-transition";
22
22
  import {Slot} from "@lodestar/types";
23
- import {sleep, toRootHex} from "@lodestar/utils";
23
+ import {defer, sleep, toRootHex} from "@lodestar/utils";
24
24
  import {ProcessShutdownCallback} from "@lodestar/validator";
25
25
  import {BeaconRestApiServer, getApi} from "../api/index.js";
26
26
  import {getDataColumnSidecarsMinEpoch} from "../chain/archiveStore/utils/archiveBlocks.js";
@@ -117,6 +117,7 @@ export class BeaconNode {
117
117
 
118
118
  status: BeaconNodeStatus;
119
119
  private controller?: AbortController;
120
+ private closePromise: Promise<void> | undefined;
120
121
 
121
122
  constructor({
122
123
  opts,
@@ -297,6 +298,7 @@ export class BeaconNode {
297
298
  : undefined,
298
299
  builderApiClientOpts: {
299
300
  timeout: opts.executionBuilder.timeout,
301
+ bidDeadline: opts.executionBuilder.bidDeadline,
300
302
  // Sent with all builder api requests, unless the node runs in private mode
301
303
  userAgent: opts.executionBuilder.userAgent,
302
304
  },
@@ -392,23 +394,40 @@ export class BeaconNode {
392
394
  /**
393
395
  * Stop beacon node and its sub-components.
394
396
  */
395
- async close(): Promise<void> {
396
- if (this.status === BeaconNodeStatus.started) {
397
- this.status = BeaconNodeStatus.closing;
398
- this.sync.close();
399
- if (this.restApi) await this.restApi.close();
400
- await this.network.close();
401
- if (this.metricsServer) await this.metricsServer.close();
402
- if (this.monitoring) await this.monitoring.close();
403
- await this.chain.persistToDisk();
404
- 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(),
405
416
  // Abort signal last: close() calls above clear intervals/timeouts so no new
406
417
  // operations get scheduled. If we aborted first, a still-pending interval could
407
418
  // fire and schedule a new operation after abort, leaving it stuck and delaying shutdown.
408
- if (this.controller) this.controller.abort();
409
- await sleep(DELAY_BEFORE_CLOSING_DB_MS);
410
- await this.db.close();
411
- 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
+ }
412
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");
413
432
  }
414
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;
@@ -1,5 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {ForkName, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
2
+ import {ForkName, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
3
3
  import {Epoch, RootHex, SignedBeaconBlock, Slot, gloas, phase0} from "@lodestar/types";
4
4
  import {LodestarError, byteArrayEquals, prettyPrintIndices, toRootHex} from "@lodestar/utils";
5
5
  import {isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
@@ -112,7 +112,6 @@ export type BatchMetadata = {
112
112
  // Per-type outstanding request shapes; only present when that sub-request exists.
113
113
  // Format: "startSlot=<n>,count=<n>" (plus ",cols=<indices>" for columns).
114
114
  blocksReq?: string;
115
- blobsReq?: string;
116
115
  columnsReq?: string;
117
116
  envelopesReq?: string;
118
117
 
@@ -159,7 +158,7 @@ export class Batch {
159
158
  readonly startSlot: Slot;
160
159
  readonly count: number;
161
160
 
162
- /** Block, blob and column requests that are used to determine the best peer and are used in downloadByRange */
161
+ /** Block, column and envelope requests that are used to determine the best peer and are used in downloadByRange */
163
162
  requests: DownloadByRangeRequests;
164
163
  /** State of the batch. */
165
164
  state: BatchState = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
@@ -224,7 +223,7 @@ export class Batch {
224
223
  }
225
224
 
226
225
  /**
227
- * Builds ByRange requests for block, blobs and columns
226
+ * Builds ByRange requests for block, columns and envelopes
228
227
  */
229
228
  private getRequests(blocks: IBlockInput[]): DownloadByRangeRequests {
230
229
  const withinValidRequestWindow = !isDaOutOfRange(
@@ -254,8 +253,6 @@ export class Batch {
254
253
  count: this.count,
255
254
  columns: this.custodyConfig.sampledColumns,
256
255
  };
257
- } else if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
258
- requests.blobsRequest = {startSlot: this.startSlot, count: this.count};
259
256
  }
260
257
 
261
258
  return requests;
@@ -334,23 +331,15 @@ export class Batch {
334
331
  if (dataStartSlot <= endSlot) {
335
332
  // range of 40 - 63, startSlot will be inclusive but subtraction will exclusive so need to + 1
336
333
  const count = endSlot - dataStartSlot + 1;
337
- if (isForkPostFulu(this.forkName) && withinValidRequestWindow) {
338
- // Skip the column re-request when we have no specific column indices outstanding.
339
- // Peer rejects an empty `columns` list
340
- if (neededColumns.size > 0) {
341
- requests.columnsRequest = {
342
- count,
343
- startSlot: dataStartSlot,
344
- columns: Array.from(neededColumns),
345
- };
346
- }
347
- } else if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
348
- requests.blobsRequest = {
334
+ // Peer rejects an empty `columns` list
335
+ if (isForkPostFulu(this.forkName) && withinValidRequestWindow && neededColumns.size > 0) {
336
+ requests.columnsRequest = {
349
337
  count,
350
338
  startSlot: dataStartSlot,
339
+ columns: Array.from(neededColumns),
351
340
  };
352
341
  }
353
- // dataSlot will still have a value but do not create a request for preDeneb forks
342
+ // dataSlot will still have a value but do not create a request for pre-fulu forks
354
343
  }
355
344
 
356
345
  if (isForkPostGloas(this.forkName) && envelopeStartSlot <= endSlot) {
@@ -471,7 +460,7 @@ export class Batch {
471
460
  }
472
461
 
473
462
  getMetadata(): BatchMetadata {
474
- const {blocksRequest, blobsRequest, columnsRequest, envelopesRequest} = this.requests;
463
+ const {blocksRequest, columnsRequest, envelopesRequest} = this.requests;
475
464
  const failedProcessingPeerList = this.failedProcessingAttempts.flatMap((a) => a.peers);
476
465
  const executionErrorPeerList = this.executionErrorAttempts.flatMap((a) => a.peers);
477
466
  return {
@@ -480,7 +469,6 @@ export class Batch {
480
469
  count: this.count,
481
470
  status: this.state.status,
482
471
  ...(blocksRequest && {blocksReq: formatRangeReq(blocksRequest)}),
483
- ...(blobsRequest && {blobsReq: formatRangeReq(blobsRequest)}),
484
472
  ...(columnsRequest && {columnsReq: formatColumnsReq(columnsRequest)}),
485
473
  ...(envelopesRequest && {envelopesReq: formatRangeReq(envelopesRequest)}),
486
474
  downloadAttempts: this.failedDownloadAttempts.length,
@@ -645,6 +633,26 @@ export class Batch {
645
633
  };
646
634
  }
647
635
 
636
+ /**
637
+ * Downloading -> AwaitingDownload
638
+ *
639
+ * The batch may hold an evicted invalid block, drop every downloaded block and request the whole batch again
640
+ */
641
+ downloadingInvalidBlock(peer: PeerIdStr): void {
642
+ if (this.state.status !== BatchStatus.Downloading) {
643
+ throw new BatchError(this.wrongStatusErrorType(BatchStatus.Downloading));
644
+ }
645
+
646
+ this.failedDownloadAttempts.push(peer);
647
+ if (this.failedDownloadAttempts.length > MAX_BATCH_DOWNLOAD_ATTEMPTS) {
648
+ throw new BatchError(this.errorType({code: BatchErrorCode.MAX_DOWNLOAD_ATTEMPTS}));
649
+ }
650
+
651
+ this.successfulDownloads.clear();
652
+ this.state = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
653
+ this.resetRequests();
654
+ }
655
+
648
656
  /**
649
657
  * Downloading -> AwaitingDownload (without counting as a failed attempt).
650
658
  * Used when the peer rate-limited us — the request was never actually served.
@@ -1,11 +1,10 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
2
  import {Epoch, Root, Slot} from "@lodestar/types";
3
3
  import {ErrorAborted, LodestarError, Logger, prettyPrintIndices, toRootHex} from "@lodestar/utils";
4
- import {isBlockInputBlobs, isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
4
+ import {isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
5
5
  import {BlockInputErrorCode} from "../../chain/blocks/blockInput/errors.js";
6
6
  import {IBlockInput} from "../../chain/blocks/blockInput/types.js";
7
7
  import {PayloadEnvelopeInput} from "../../chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js";
8
- import {BlobSidecarErrorCode} from "../../chain/errors/blobSidecarError.js";
9
8
  import {DataColumnSidecarErrorCode} from "../../chain/errors/dataColumnSidecarError.js";
10
9
  import {Metrics} from "../../metrics/metrics.js";
11
10
  import {PeerAction, prettyPrintPeerIdStr} from "../../network/index.js";
@@ -569,12 +568,8 @@ export class SyncChain {
569
568
  // The below cases indicate the peer may be on a different chain, so are not penalized during head sync.
570
569
  switch (errCode) {
571
570
  case BlockInputErrorCode.MISMATCHED_ROOT_HEX:
572
- case DownloadByRangeErrorCode.MISSING_BLOBS:
573
- case DownloadByRangeErrorCode.EXTRA_BLOBS:
574
571
  case DownloadByRangeErrorCode.MISSING_COLUMNS:
575
572
  case DownloadByRangeErrorCode.EXTRA_COLUMNS:
576
- case BlobSidecarErrorCode.INCORRECT_SIDECAR_COUNT:
577
- case BlobSidecarErrorCode.INCORRECT_BLOCK:
578
573
  case DataColumnSidecarErrorCode.INCORRECT_SIDECAR_COUNT:
579
574
  case DataColumnSidecarErrorCode.INCORRECT_BLOCK:
580
575
  this.reportPeer(peer.peerId, PeerAction.LowToleranceError, res.err.message);
@@ -589,8 +584,6 @@ export class SyncChain {
589
584
  case DownloadByRangeErrorCode.INVALID_ENVELOPE_BLOCK_HASH:
590
585
  case DownloadByRangeErrorCode.INVALID_ENVELOPE_SLOT:
591
586
  case DownloadByRangeErrorCode.INVALID_CHAIN_SEGMENT:
592
- case BlobSidecarErrorCode.INCLUSION_PROOF_INVALID:
593
- case BlobSidecarErrorCode.INVALID_KZG_PROOF_BATCH:
594
587
  case DataColumnSidecarErrorCode.INCORRECT_KZG_COMMITMENTS_COUNT:
595
588
  case DataColumnSidecarErrorCode.INCORRECT_KZG_PROOF_COUNT:
596
589
  case DataColumnSidecarErrorCode.INVALID_KZG_PROOF_BATCH:
@@ -609,6 +602,14 @@ export class SyncChain {
609
602
  this.scheduleRateLimitBackoffRetry();
610
603
  batch.downloadingRateLimited();
611
604
  this.triggerBatchDownloader();
605
+ } else if (
606
+ res.err instanceof DownloadByRangeError &&
607
+ res.err.type.code === DownloadByRangeErrorCode.INVALID_CACHED_BLOCK
608
+ ) {
609
+ if (res.err.type.blockPeer !== undefined) {
610
+ this.reportPeer(res.err.type.blockPeer, PeerAction.LowToleranceError, res.err.message);
611
+ }
612
+ batch.downloadingInvalidBlock(res.err.type.blockPeer ?? peer.peerId); // Throws after MAX_DOWNLOAD_ATTEMPTS
612
613
  } else {
613
614
  batch.downloadingError(peer.peerId); // Throws after MAX_DOWNLOAD_ATTEMPTS
614
615
  }
@@ -638,12 +639,7 @@ export class SyncChain {
638
639
  }
639
640
 
640
641
  for (const block of downloadSuccessOutput.blocks) {
641
- if (isBlockInputBlobs(block)) {
642
- const blockLogMeta = block.getLogMeta();
643
- const expectedBlobs = typeof blockLogMeta.expectedBlobs === "number" ? blockLogMeta.expectedBlobs : 0;
644
- logMeta.expectedBlobCount = (logMeta.expectedBlobCount ?? 0) + expectedBlobs;
645
- logMeta.receivedBlobCount = (logMeta.receivedBlobCount ?? 0) + blockLogMeta.receivedBlobs;
646
- } else if (isBlockInputColumns(block)) {
642
+ if (isBlockInputColumns(block)) {
647
643
  logMeta.columnCount = (logMeta.columnCount ?? 0) + block.getLogMeta().receivedColumns;
648
644
  }
649
645
  }
@@ -3,13 +3,20 @@ import {StrictEventEmitter} from "strict-event-emitter-types";
3
3
  import {BeaconConfig} from "@lodestar/config";
4
4
  import {IBeaconStateViewGloas, computeStartSlotAtEpoch, isStatePostGloas} from "@lodestar/state-transition";
5
5
  import {Epoch, Status, fulu, ssz} from "@lodestar/types";
6
- import {Logger, byteArrayEquals, prettyPrintIndices, toRootHex} from "@lodestar/utils";
6
+ import {Logger, byteArrayEquals, prettyPrintIndices, toHex, toRootHex} from "@lodestar/utils";
7
7
  import {IBlockInput} from "../../chain/blocks/blockInput/types.js";
8
8
  import {PayloadError, PayloadErrorCode} from "../../chain/blocks/importExecutionPayload.js";
9
9
  import {AttestationImportOpt, ImportBlockOpts} from "../../chain/blocks/index.js";
10
10
  import {assertLinearChainSegment} from "../../chain/blocks/utils/chainSegment.js";
11
- import {BlockError} from "../../chain/errors/index.js";
11
+ import {
12
+ BlockError,
13
+ BlockErrorCode,
14
+ BlockGossipError,
15
+ DataColumnSidecarErrorCode,
16
+ DataColumnSidecarValidationError,
17
+ } from "../../chain/errors/index.js";
12
18
  import {IBeaconChain} from "../../chain/index.js";
19
+ import {verifyBlockProposerSignature} from "../../chain/validation/block.js";
13
20
  import {Metrics} from "../../metrics/index.js";
14
21
  import {INetwork} from "../../network/index.js";
15
22
  import {PeerIdStr} from "../../util/peerId.js";
@@ -291,7 +298,7 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
291
298
  ...requests,
292
299
  });
293
300
  const {responses, payloadEnvelopes: downloadedPayloadEnvelopes} = result;
294
- const {blocks, payloadEnvelopes} = cacheByRangeResponses({
301
+ const {blocks, payloadEnvelopes, signatureMismatch} = cacheByRangeResponses({
295
302
  cache: this.chain.seenBlockInputCache,
296
303
  seenPayloadEnvelopeInputCache: this.chain.seenPayloadEnvelopeInputCache,
297
304
  peerIdStr: peer.peerId,
@@ -304,6 +311,52 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
304
311
  seenTimestampSec: Date.now() / 1000,
305
312
  });
306
313
 
314
+ if (signatureMismatch !== null) {
315
+ const {blockInput, columnSidecar} = signatureMismatch;
316
+ const block = blockInput.getBlock();
317
+ let isValidBlockSignature: boolean | null = true;
318
+ try {
319
+ await verifyBlockProposerSignature(this.chain, block, blockInput.blockRootHex);
320
+ } catch (e) {
321
+ isValidBlockSignature =
322
+ e instanceof BlockGossipError && e.type.code === BlockErrorCode.PROPOSAL_SIGNATURE_INVALID ? false : null;
323
+ }
324
+
325
+ if (isValidBlockSignature) {
326
+ throw new DataColumnSidecarValidationError(
327
+ {
328
+ code: DataColumnSidecarErrorCode.INCORRECT_BLOCK,
329
+ slot: blockInput.slot,
330
+ columnIndex: columnSidecar.index,
331
+ expected: toHex(block.signature),
332
+ actual: toHex(columnSidecar.signedBlockHeader.signature),
333
+ },
334
+ "DataColumnSidecar header signature doesn't match block signature"
335
+ );
336
+ }
337
+
338
+ // Later downloads reuse a cached block, evict it and the other unverified blocks of a peer
339
+ // proven to serve invalid signatures
340
+ const blockPeer = isValidBlockSignature === false ? blockInput.getBlockSource().peerIdStr : undefined;
341
+ const cache = this.chain.seenBlockInputCache;
342
+ for (const b of blocks) {
343
+ const isSuspect = b === blockInput || (blockPeer !== undefined && b.getBlockSource().peerIdStr === blockPeer);
344
+ if (
345
+ isSuspect &&
346
+ cache.get(b.blockRootHex) === b &&
347
+ !cache.isVerifiedProposerSignature(b.slot, b.blockRootHex, b.getBlock().signature)
348
+ ) {
349
+ cache.remove(b.blockRootHex);
350
+ }
351
+ }
352
+ throw new DownloadByRangeError({
353
+ code: DownloadByRangeErrorCode.INVALID_CACHED_BLOCK,
354
+ slot: blockInput.slot,
355
+ blockRoot: blockInput.blockRootHex,
356
+ blockPeer,
357
+ });
358
+ }
359
+
307
360
  const segmentBlocks = blocks.filter((b) => b.hasBlock()).sort((a, b) => a.slot - b.slot);
308
361
  const envelopeSlots = payloadEnvelopes
309
362
  ? Array.from(payloadEnvelopes.entries())
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
 
@@ -28,12 +33,15 @@ export class BeaconSync implements IBeaconSync {
28
33
  /** For metrics only */
29
34
  private readonly peerSyncType = new Map<string, PeerSyncType>();
30
35
  private readonly slotImportTolerance: Slot;
36
+ /** The requested subscription state, set while a change is being applied */
37
+ private pendingGossipSubscribed: boolean | undefined;
31
38
 
32
39
  constructor(opts: SyncOptions, modules: SyncModules) {
33
- const {config, chain, metrics, network, logger} = modules;
40
+ const {config, chain, db, metrics, network, logger} = modules;
34
41
  this.opts = opts;
35
42
  this.network = network;
36
43
  this.chain = chain;
44
+ this.db = db;
37
45
  this.metrics = metrics;
38
46
  this.logger = logger;
39
47
  this.rangeSync = new RangeSync(modules, opts);
@@ -83,6 +91,7 @@ export class BeaconSync implements IBeaconSync {
83
91
  }
84
92
 
85
93
  close(): void {
94
+ this.pendingGossipSubscribed = undefined;
86
95
  this.network.events.off(NetworkEvent.peerConnected, this.addPeer);
87
96
  this.network.events.off(NetworkEvent.peerDisconnected, this.removePeer);
88
97
  this.chain.clock.off(ClockEvent.epoch, this.onClockEpoch);
@@ -192,6 +201,11 @@ export class BeaconSync implements IBeaconSync {
192
201
  */
193
202
  private addPeer = (data: NetworkEventData[NetworkEvent.peerConnected]): void => {
194
203
  const localStatus = this.chain.getStatus();
204
+ // Genesis and equal finalized epochs are already checked by assertPeerRelevance in the network worker
205
+ if (data.status.finalizedEpoch > GENESIS_EPOCH && data.status.finalizedEpoch < localStatus.finalizedEpoch) {
206
+ void this.verifyPastFinalizedCheckpoint(data.peer, data.status);
207
+ }
208
+
195
209
  const syncType = getPeerSyncType(localStatus, data.status, this.chain.forkChoice, this.slotImportTolerance);
196
210
  this.logger.verbose("Peer sync type classified", {
197
211
  peer: data.peer,
@@ -216,6 +230,56 @@ export class BeaconSync implements IBeaconSync {
216
230
  this.updateSyncState();
217
231
  };
218
232
 
233
+ /**
234
+ * A behind peer's finalized checkpoint must be the canonical block in effect at the start slot of its epoch
235
+ */
236
+ async verifyPastFinalizedCheckpoint(peer: PeerIdStr, remote: Status): Promise<void> {
237
+ const startSlot = computeStartSlotAtEpoch(remote.finalizedEpoch);
238
+ const root = toRootHex(remote.finalizedRoot);
239
+ try {
240
+ let reason: string | null = null;
241
+ // After a finality jump, finalized blocks stay in fork choice until the archiver migrates them.
242
+ // Fork choice is pruned only after archiving, so a miss here means the db already has this range.
243
+ const canonicalBlock = this.chain.forkChoice.getCanonicalBlockClosestLteSlot(startSlot);
244
+ if (canonicalBlock !== null) {
245
+ if (canonicalBlock.blockRoot === root) return;
246
+ reason = "finalized_root_not_canonical";
247
+ } else {
248
+ const slot = await this.db.blockArchive.getSlotByRoot(remote.finalizedRoot);
249
+ if (slot !== null && slot > startSlot) {
250
+ reason = "finalized_root_after_epoch_start";
251
+ } else if (slot !== startSlot) {
252
+ const childSlot = await this.db.blockArchive.getSlotByParentRoot(remote.finalizedRoot);
253
+ if (childSlot !== null) {
254
+ if (childSlot <= startSlot) reason = "finalized_root_not_in_effect_at_epoch_start";
255
+ } else if (slot === null && startSlot > this.chain.earliestAvailableSlot) {
256
+ // childSlot == null too, neither the root nor a child is canonical
257
+ // or they are canonical and both pruned but peer's finalized epoch starts after earliestAvailableSlot
258
+ reason = "unknown_finalized_root";
259
+ }
260
+ }
261
+ }
262
+
263
+ if (reason !== null) {
264
+ this.logger.debug("Peer finalized checkpoint not in our chain", {
265
+ peer,
266
+ finalizedEpoch: remote.finalizedEpoch,
267
+ root,
268
+ reason,
269
+ });
270
+ this.metrics?.syncPeerFinalizedCheckpointMismatch.inc({reason});
271
+ this.network.reportPeer(peer, PeerAction.Fatal, "PeerFinalizedCheckpointMismatch");
272
+ await this.network.goodbyeAndDisconnect(peer, GoodByeReasonCode.IRRELEVANT_NETWORK);
273
+ }
274
+ } catch (e) {
275
+ this.logger.debug(
276
+ "Error verifying peer finalized checkpoint",
277
+ {peer, finalizedEpoch: remote.finalizedEpoch, root},
278
+ e as Error
279
+ );
280
+ }
281
+ }
282
+
219
283
  /**
220
284
  * Must be called by libp2p when a peer is removed from the peer manager
221
285
  */
@@ -235,17 +299,7 @@ export class BeaconSync implements IBeaconSync {
235
299
  if (state === SyncState.Synced && this.chain.clock.currentEpoch >= MIN_EPOCH_TO_START_GOSSIP) {
236
300
  this.chain.forkChoice.resumeFastConfirmation();
237
301
 
238
- if (!this.network.isSubscribedToGossipCoreTopics()) {
239
- this.network
240
- .subscribeGossipCoreTopics()
241
- .then(() => {
242
- this.metrics?.syncSwitchGossipSubscriptions.inc({action: "subscribed"});
243
- this.logger.info("Subscribed gossip core topics");
244
- })
245
- .catch((e) => {
246
- this.logger.error("Error subscribing to gossip core topics", {}, e);
247
- });
248
- }
302
+ this.setGossipSubscription(true);
249
303
 
250
304
  // also start searching for unknown blocks
251
305
  if (!this.unknownBlockSync.isSubscribedToNetwork()) {
@@ -261,17 +315,8 @@ export class BeaconSync implements IBeaconSync {
261
315
  // Same debounce as gossip: transient blips keep the rule running, only a real gap pauses it
262
316
  this.chain.forkChoice.pauseFastConfirmation();
263
317
 
264
- if (this.network.isSubscribedToGossipCoreTopics()) {
265
- this.logger.warn(`Node sync has fallen behind by ${syncDiff} slots`);
266
- this.network
267
- .unsubscribeGossipCoreTopics()
268
- .then(() => {
269
- this.metrics?.syncSwitchGossipSubscriptions.inc({action: "unsubscribed"});
270
- this.logger.info("Un-subscribed gossip core topics");
271
- })
272
- .catch((e) => {
273
- this.logger.error("Error unsubscribing to gossip core topics", {}, e);
274
- });
318
+ if (this.setGossipSubscription(false)) {
319
+ this.logger.warn("Node sync has fallen behind", {slots: syncDiff});
275
320
  }
276
321
 
277
322
  // also stop searching for unknown blocks
@@ -283,6 +328,43 @@ export class BeaconSync implements IBeaconSync {
283
328
  }
284
329
  };
285
330
 
331
+ private setGossipSubscription(subscribe: boolean): boolean {
332
+ if ((this.pendingGossipSubscribed ?? this.network.isSubscribedToGossipCoreTopics()) === subscribe) return false;
333
+ const applying = this.pendingGossipSubscribed !== undefined;
334
+ this.pendingGossipSubscribed = subscribe;
335
+ if (!applying) void this.applyGossipSubscription();
336
+ return true;
337
+ }
338
+
339
+ /**
340
+ * Applies the latest requested state one request at a time. Network skips a subscribe issued while an unsubscribe is
341
+ * in flight, so opposite requests must not overlap.
342
+ */
343
+ private async applyGossipSubscription(): Promise<void> {
344
+ for (;;) {
345
+ const subscribe = this.pendingGossipSubscribed;
346
+ if (subscribe === undefined || subscribe === this.network.isSubscribedToGossipCoreTopics()) break;
347
+ try {
348
+ await (subscribe ? this.network.subscribeGossipCoreTopics() : this.network.unsubscribeGossipCoreTopics());
349
+ } catch (e) {
350
+ this.logger.error(
351
+ subscribe ? "Error subscribing to gossip core topics" : "Error unsubscribing to gossip core topics",
352
+ {},
353
+ e as Error
354
+ );
355
+ // Leave a retry of the same request to the next sync state update
356
+ if (this.pendingGossipSubscribed === subscribe) break;
357
+ continue;
358
+ }
359
+ if (this.pendingGossipSubscribed === undefined || this.network.isSubscribedToGossipCoreTopics() !== subscribe) {
360
+ break;
361
+ }
362
+ this.metrics?.syncSwitchGossipSubscriptions.inc({action: subscribe ? "subscribed" : "unsubscribed"});
363
+ this.logger.info(subscribe ? "Subscribed gossip core topics" : "Un-subscribed gossip core topics");
364
+ }
365
+ this.pendingGossipSubscribed = undefined;
366
+ }
367
+
286
368
  private onClockEpoch = (): void => {
287
369
  // If a node witness the genesis event consider starting gossip
288
370
  // Also, ensure that updateSyncState is run at least once per epoch.
package/src/sync/types.ts CHANGED
@@ -107,6 +107,8 @@ export enum DroppedItemReason {
107
107
  invalidSignature = "invalid_signature",
108
108
  /** an unexpected / unhandled error code led to removal */
109
109
  unknown = "unknown",
110
+ /** a block waiting on its parent was evicted because the peer that gossiped it exceeded its byte budget */
111
+ peerBudget = "peer_budget",
110
112
  }
111
113
 
112
114
  export enum PendingPayloadInputStatus {
@@ -123,6 +125,12 @@ export type PendingBlockInput = {
123
125
  timeAddedSec: number;
124
126
  timeSyncedSec?: number;
125
127
  peerIdStrings: Set<string>;
128
+ /** Peer that gossiped a block retained for unknown parent sync */
129
+ retainedBy?: string;
130
+ retainedBytes?: number;
131
+ failedDownloads?: number;
132
+ /** A failed download is not retried before this time */
133
+ retryAtMs?: number;
126
134
  };
127
135
 
128
136
  export type PendingRootHex = {
@@ -131,6 +139,9 @@ export type PendingRootHex = {
131
139
  timeAddedSec: number;
132
140
  timeSyncedSec?: number;
133
141
  peerIdStrings: Set<string>;
142
+ failedDownloads?: number;
143
+ /** A failed download is not retried before this time */
144
+ retryAtMs?: number;
134
145
  };
135
146
 
136
147
  export type BlockInputSyncCacheItem = PendingBlockInput | PendingRootHex;