@lodestar/beacon-node 1.50.0-dev.8ba9d1dd30 → 1.50.0-dev.9203d3d7da

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 (382) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +13 -3
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/index.js +13 -0
  6. package/lib/api/impl/beacon/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/index.js +28 -6
  9. package/lib/api/impl/beacon/state/index.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +26 -18
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts +1 -0
  14. package/lib/api/impl/validator/index.d.ts.map +1 -1
  15. package/lib/api/impl/validator/index.js +80 -18
  16. package/lib/api/impl/validator/index.js.map +1 -1
  17. package/lib/chain/ColumnReconstructionTracker.d.ts +0 -2
  18. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  19. package/lib/chain/ColumnReconstructionTracker.js +4 -5
  20. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  21. package/lib/chain/archiveStore/archiveStore.d.ts +5 -0
  22. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  23. package/lib/chain/archiveStore/archiveStore.js +14 -24
  24. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  25. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +2 -2
  26. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  27. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +5 -7
  28. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  29. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -1
  30. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  31. package/lib/chain/archiveStore/historicalState/types.d.ts +2 -2
  32. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  33. package/lib/chain/archiveStore/historicalState/worker.js +1 -1
  34. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  35. package/lib/chain/archiveStore/interface.d.ts +1 -1
  36. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  37. package/lib/chain/archiveStore/utils/pruneHistory.d.ts +1 -1
  38. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  39. package/lib/chain/archiveStore/utils/pruneHistory.js +2 -1
  40. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  41. package/lib/chain/beaconProposerCache.d.ts +6 -0
  42. package/lib/chain/beaconProposerCache.d.ts.map +1 -1
  43. package/lib/chain/beaconProposerCache.js +16 -0
  44. package/lib/chain/beaconProposerCache.js.map +1 -1
  45. package/lib/chain/blocks/blockInput/blockInput.d.ts +1 -1
  46. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  47. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  48. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  49. package/lib/chain/blocks/importBlock.js +20 -11
  50. package/lib/chain/blocks/importBlock.js.map +1 -1
  51. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
  52. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  53. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  54. package/lib/chain/blocks/verifyBlock.js +7 -7
  55. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  56. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +2 -1
  57. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  58. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +5 -4
  59. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  60. package/lib/chain/chain.d.ts +10 -5
  61. package/lib/chain/chain.d.ts.map +1 -1
  62. package/lib/chain/chain.js +105 -35
  63. package/lib/chain/chain.js.map +1 -1
  64. package/lib/chain/emitter.d.ts +7 -1
  65. package/lib/chain/emitter.d.ts.map +1 -1
  66. package/lib/chain/emitter.js +5 -0
  67. package/lib/chain/emitter.js.map +1 -1
  68. package/lib/chain/errors/envelopeReconstructionError.d.ts +5 -0
  69. package/lib/chain/errors/envelopeReconstructionError.d.ts.map +1 -1
  70. package/lib/chain/errors/envelopeReconstructionError.js +2 -0
  71. package/lib/chain/errors/envelopeReconstructionError.js.map +1 -1
  72. package/lib/chain/errors/gossipValidation.d.ts +1 -0
  73. package/lib/chain/errors/gossipValidation.d.ts.map +1 -1
  74. package/lib/chain/errors/gossipValidation.js +1 -0
  75. package/lib/chain/errors/gossipValidation.js.map +1 -1
  76. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  77. package/lib/chain/forkChoice/index.js +2 -0
  78. package/lib/chain/forkChoice/index.js.map +1 -1
  79. package/lib/chain/interface.d.ts +6 -3
  80. package/lib/chain/interface.d.ts.map +1 -1
  81. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +4 -2
  82. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  83. package/lib/chain/opPools/aggregatedAttestationPool.js +30 -8
  84. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  85. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  86. package/lib/chain/opPools/opPool.js +1 -23
  87. package/lib/chain/opPools/opPool.js.map +1 -1
  88. package/lib/chain/opPools/proposerPreferencesPool.d.ts +8 -4
  89. package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
  90. package/lib/chain/opPools/proposerPreferencesPool.js +27 -12
  91. package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
  92. package/lib/chain/opPools/utils.d.ts +11 -0
  93. package/lib/chain/opPools/utils.d.ts.map +1 -1
  94. package/lib/chain/opPools/utils.js +22 -0
  95. package/lib/chain/opPools/utils.js.map +1 -1
  96. package/lib/chain/options.d.ts +2 -1
  97. package/lib/chain/options.d.ts.map +1 -1
  98. package/lib/chain/options.js +1 -1
  99. package/lib/chain/options.js.map +1 -1
  100. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  101. package/lib/chain/prepareNextSlot.js +15 -6
  102. package/lib/chain/prepareNextSlot.js.map +1 -1
  103. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  104. package/lib/chain/produceBlock/computeNewStateRoot.js +1 -1
  105. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  106. package/lib/chain/produceBlock/produceBlockBody.d.ts +8 -0
  107. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  108. package/lib/chain/produceBlock/produceBlockBody.js +48 -34
  109. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  110. package/lib/chain/regen/regen.d.ts +2 -0
  111. package/lib/chain/regen/regen.d.ts.map +1 -1
  112. package/lib/chain/regen/regen.js +10 -4
  113. package/lib/chain/regen/regen.js.map +1 -1
  114. package/lib/chain/reprocess.d.ts +2 -1
  115. package/lib/chain/reprocess.d.ts.map +1 -1
  116. package/lib/chain/reprocess.js +2 -1
  117. package/lib/chain/reprocess.js.map +1 -1
  118. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +7 -0
  119. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  120. package/lib/chain/seenCache/seenGossipBlockInput.js +22 -1
  121. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  122. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +9 -2
  123. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  124. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +23 -13
  125. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  126. package/lib/chain/shufflingCache.d.ts +18 -8
  127. package/lib/chain/shufflingCache.d.ts.map +1 -1
  128. package/lib/chain/shufflingCache.js +72 -18
  129. package/lib/chain/shufflingCache.js.map +1 -1
  130. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  131. package/lib/chain/stateCache/persistentCheckpointsCache.js +1 -1
  132. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  133. package/lib/chain/validatorMonitor.d.ts +5 -1
  134. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  135. package/lib/chain/validatorMonitor.js +70 -58
  136. package/lib/chain/validatorMonitor.js.map +1 -1
  137. package/lib/constants/constants.d.ts +1 -0
  138. package/lib/constants/constants.d.ts.map +1 -1
  139. package/lib/constants/constants.js +1 -0
  140. package/lib/constants/constants.js.map +1 -1
  141. package/lib/db/beacon.d.ts +4 -1
  142. package/lib/db/beacon.d.ts.map +1 -1
  143. package/lib/db/beacon.js +6 -1
  144. package/lib/db/beacon.js.map +1 -1
  145. package/lib/db/buckets.d.ts +3 -1
  146. package/lib/db/buckets.d.ts.map +1 -1
  147. package/lib/db/buckets.js +2 -0
  148. package/lib/db/buckets.js.map +1 -1
  149. package/lib/db/interface.d.ts +4 -1
  150. package/lib/db/interface.d.ts.map +1 -1
  151. package/lib/db/repositories/blockArchive.js +2 -2
  152. package/lib/db/repositories/blockArchive.js.map +1 -1
  153. package/lib/db/repositories/blockArchiveIndex.d.ts +3 -3
  154. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  155. package/lib/db/repositories/blockArchiveIndex.js +1 -2
  156. package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
  157. package/lib/db/repositories/earliestAvailableSlot.d.ts +11 -0
  158. package/lib/db/repositories/earliestAvailableSlot.d.ts.map +1 -0
  159. package/lib/db/repositories/earliestAvailableSlot.js +19 -0
  160. package/lib/db/repositories/earliestAvailableSlot.js.map +1 -0
  161. package/lib/db/repositories/index.d.ts +1 -0
  162. package/lib/db/repositories/index.d.ts.map +1 -1
  163. package/lib/db/repositories/index.js +1 -0
  164. package/lib/db/repositories/index.js.map +1 -1
  165. package/lib/db/repositories/proposerPreferences.d.ts +14 -0
  166. package/lib/db/repositories/proposerPreferences.d.ts.map +1 -0
  167. package/lib/db/repositories/proposerPreferences.js +21 -0
  168. package/lib/db/repositories/proposerPreferences.js.map +1 -0
  169. package/lib/execution/engine/blobVersionedHashes.d.ts +9 -0
  170. package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -0
  171. package/lib/execution/engine/blobVersionedHashes.js +74 -0
  172. package/lib/execution/engine/blobVersionedHashes.js.map +1 -0
  173. package/lib/execution/engine/disabled.d.ts +0 -2
  174. package/lib/execution/engine/disabled.d.ts.map +1 -1
  175. package/lib/execution/engine/disabled.js +0 -6
  176. package/lib/execution/engine/disabled.js.map +1 -1
  177. package/lib/execution/engine/http.d.ts +46 -16
  178. package/lib/execution/engine/http.d.ts.map +1 -1
  179. package/lib/execution/engine/http.js +236 -213
  180. package/lib/execution/engine/http.js.map +1 -1
  181. package/lib/execution/engine/index.d.ts +3 -2
  182. package/lib/execution/engine/index.d.ts.map +1 -1
  183. package/lib/execution/engine/index.js +33 -8
  184. package/lib/execution/engine/index.js.map +1 -1
  185. package/lib/execution/engine/interface.d.ts +2 -4
  186. package/lib/execution/engine/interface.d.ts.map +1 -1
  187. package/lib/execution/engine/jsonRpcTransport.d.ts +25 -0
  188. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -0
  189. package/lib/execution/engine/jsonRpcTransport.js +158 -0
  190. package/lib/execution/engine/jsonRpcTransport.js.map +1 -0
  191. package/lib/execution/engine/mock.d.ts +0 -2
  192. package/lib/execution/engine/mock.d.ts.map +1 -1
  193. package/lib/execution/engine/mock.js +0 -8
  194. package/lib/execution/engine/mock.js.map +1 -1
  195. package/lib/execution/engine/restHttpClient.d.ts +71 -0
  196. package/lib/execution/engine/restHttpClient.d.ts.map +1 -0
  197. package/lib/execution/engine/restHttpClient.js +201 -0
  198. package/lib/execution/engine/restHttpClient.js.map +1 -0
  199. package/lib/execution/engine/restTransport.d.ts +46 -0
  200. package/lib/execution/engine/restTransport.d.ts.map +1 -0
  201. package/lib/execution/engine/restTransport.js +399 -0
  202. package/lib/execution/engine/restTransport.js.map +1 -0
  203. package/lib/execution/engine/sszTypes.d.ts +1261 -0
  204. package/lib/execution/engine/sszTypes.d.ts.map +1 -0
  205. package/lib/execution/engine/sszTypes.js +216 -0
  206. package/lib/execution/engine/sszTypes.js.map +1 -0
  207. package/lib/execution/engine/transport.d.ts +39 -0
  208. package/lib/execution/engine/transport.d.ts.map +1 -0
  209. package/lib/execution/engine/transport.js +2 -0
  210. package/lib/execution/engine/transport.js.map +1 -0
  211. package/lib/execution/engine/types.d.ts +2 -8
  212. package/lib/execution/engine/types.d.ts.map +1 -1
  213. package/lib/execution/engine/types.js +24 -57
  214. package/lib/execution/engine/types.js.map +1 -1
  215. package/lib/execution/engine/utils.d.ts.map +1 -1
  216. package/lib/execution/engine/utils.js +9 -2
  217. package/lib/execution/engine/utils.js.map +1 -1
  218. package/lib/metrics/metrics/lodestar.d.ts +10 -0
  219. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  220. package/lib/metrics/metrics/lodestar.js +22 -0
  221. package/lib/metrics/metrics/lodestar.js.map +1 -1
  222. package/lib/metrics/metrics.d.ts +7 -3
  223. package/lib/metrics/metrics.d.ts.map +1 -1
  224. package/lib/metrics/metrics.js +4 -4
  225. package/lib/metrics/metrics.js.map +1 -1
  226. package/lib/network/core/events.d.ts +5 -1
  227. package/lib/network/core/events.d.ts.map +1 -1
  228. package/lib/network/core/events.js +8 -0
  229. package/lib/network/core/events.js.map +1 -1
  230. package/lib/network/gossip/topic.d.ts +0 -14
  231. package/lib/network/gossip/topic.d.ts.map +1 -1
  232. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  233. package/lib/network/processor/gossipHandlers.js +63 -64
  234. package/lib/network/processor/gossipHandlers.js.map +1 -1
  235. package/lib/network/processor/gossipValidatorFn.d.ts +4 -2
  236. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  237. package/lib/network/processor/gossipValidatorFn.js +6 -2
  238. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  239. package/lib/network/processor/index.d.ts +8 -0
  240. package/lib/network/processor/index.d.ts.map +1 -1
  241. package/lib/network/processor/index.js +52 -5
  242. package/lib/network/processor/index.js.map +1 -1
  243. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +1 -1
  244. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  245. package/lib/network/reqresp/rateLimit.js +2 -2
  246. package/lib/network/reqresp/rateLimit.js.map +1 -1
  247. package/lib/network/subnets/attnetsService.d.ts.map +1 -1
  248. package/lib/network/subnets/attnetsService.js +3 -1
  249. package/lib/network/subnets/attnetsService.js.map +1 -1
  250. package/lib/node/nodejs.d.ts +3 -1
  251. package/lib/node/nodejs.d.ts.map +1 -1
  252. package/lib/node/nodejs.js +27 -4
  253. package/lib/node/nodejs.js.map +1 -1
  254. package/lib/node/notifier.d.ts.map +1 -1
  255. package/lib/node/notifier.js +12 -13
  256. package/lib/node/notifier.js.map +1 -1
  257. package/lib/node/options.d.ts +3 -2
  258. package/lib/node/options.d.ts.map +1 -1
  259. package/lib/node/options.js +2 -2
  260. package/lib/node/options.js.map +1 -1
  261. package/lib/sync/range/batch.d.ts +11 -5
  262. package/lib/sync/range/batch.d.ts.map +1 -1
  263. package/lib/sync/range/batch.js +21 -17
  264. package/lib/sync/range/batch.js.map +1 -1
  265. package/lib/sync/range/chain.d.ts +4 -4
  266. package/lib/sync/range/chain.d.ts.map +1 -1
  267. package/lib/sync/range/chain.js +12 -6
  268. package/lib/sync/range/chain.js.map +1 -1
  269. package/lib/sync/range/range.d.ts.map +1 -1
  270. package/lib/sync/range/range.js +75 -29
  271. package/lib/sync/range/range.js.map +1 -1
  272. package/lib/sync/unknownBlock.d.ts +5 -2
  273. package/lib/sync/unknownBlock.d.ts.map +1 -1
  274. package/lib/sync/unknownBlock.js +52 -26
  275. package/lib/sync/unknownBlock.js.map +1 -1
  276. package/lib/sync/utils/downloadByRange.d.ts +38 -14
  277. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  278. package/lib/sync/utils/downloadByRange.js +84 -39
  279. package/lib/sync/utils/downloadByRange.js.map +1 -1
  280. package/lib/util/asyncIterableToEvents.d.ts +10 -2
  281. package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
  282. package/lib/util/asyncIterableToEvents.js +29 -3
  283. package/lib/util/asyncIterableToEvents.js.map +1 -1
  284. package/lib/util/clock.d.ts.map +1 -1
  285. package/lib/util/clock.js +3 -4
  286. package/lib/util/clock.js.map +1 -1
  287. package/lib/util/execution.d.ts +9 -11
  288. package/lib/util/execution.d.ts.map +1 -1
  289. package/lib/util/execution.js +5 -1
  290. package/lib/util/execution.js.map +1 -1
  291. package/lib/util/metadata.d.ts.map +1 -1
  292. package/lib/util/metadata.js +2 -1
  293. package/lib/util/metadata.js.map +1 -1
  294. package/lib/util/sszBytes.d.ts +2 -2
  295. package/lib/util/sszBytes.d.ts.map +1 -1
  296. package/lib/util/sszBytes.js +22 -14
  297. package/lib/util/sszBytes.js.map +1 -1
  298. package/package.json +18 -17
  299. package/src/api/impl/beacon/blocks/index.ts +17 -7
  300. package/src/api/impl/beacon/index.ts +15 -0
  301. package/src/api/impl/beacon/state/index.ts +43 -6
  302. package/src/api/impl/debug/index.ts +28 -19
  303. package/src/api/impl/validator/index.ts +102 -21
  304. package/src/chain/ColumnReconstructionTracker.ts +4 -6
  305. package/src/chain/archiveStore/archiveStore.ts +19 -25
  306. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +5 -7
  307. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +1 -1
  308. package/src/chain/archiveStore/historicalState/types.ts +2 -2
  309. package/src/chain/archiveStore/historicalState/worker.ts +1 -2
  310. package/src/chain/archiveStore/interface.ts +1 -1
  311. package/src/chain/archiveStore/utils/pruneHistory.ts +4 -1
  312. package/src/chain/beaconProposerCache.ts +19 -1
  313. package/src/chain/blocks/blockInput/blockInput.ts +1 -1
  314. package/src/chain/blocks/importBlock.ts +24 -10
  315. package/src/chain/blocks/payloadEnvelopeInput/types.ts +2 -1
  316. package/src/chain/blocks/verifyBlock.ts +8 -6
  317. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -3
  318. package/src/chain/chain.ts +135 -37
  319. package/src/chain/emitter.ts +7 -1
  320. package/src/chain/errors/envelopeReconstructionError.ts +3 -0
  321. package/src/chain/errors/gossipValidation.ts +1 -0
  322. package/src/chain/forkChoice/index.ts +2 -0
  323. package/src/chain/interface.ts +7 -3
  324. package/src/chain/opPools/aggregatedAttestationPool.ts +34 -10
  325. package/src/chain/opPools/opPool.ts +1 -31
  326. package/src/chain/opPools/proposerPreferencesPool.ts +34 -11
  327. package/src/chain/opPools/utils.ts +31 -0
  328. package/src/chain/options.ts +3 -3
  329. package/src/chain/prepareNextSlot.ts +22 -6
  330. package/src/chain/produceBlock/computeNewStateRoot.ts +10 -3
  331. package/src/chain/produceBlock/produceBlockBody.ts +78 -39
  332. package/src/chain/regen/regen.ts +12 -4
  333. package/src/chain/reprocess.ts +2 -1
  334. package/src/chain/seenCache/seenGossipBlockInput.ts +25 -1
  335. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +31 -13
  336. package/src/chain/shufflingCache.ts +84 -22
  337. package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
  338. package/src/chain/validatorMonitor.ts +82 -61
  339. package/src/constants/constants.ts +1 -0
  340. package/src/db/beacon.ts +6 -0
  341. package/src/db/buckets.ts +2 -0
  342. package/src/db/interface.ts +4 -0
  343. package/src/db/repositories/blockArchive.ts +2 -2
  344. package/src/db/repositories/blockArchiveIndex.ts +2 -3
  345. package/src/db/repositories/earliestAvailableSlot.ts +19 -0
  346. package/src/db/repositories/index.ts +1 -0
  347. package/src/db/repositories/proposerPreferences.ts +23 -0
  348. package/src/execution/engine/blobVersionedHashes.ts +72 -0
  349. package/src/execution/engine/disabled.ts +0 -8
  350. package/src/execution/engine/http.ts +304 -300
  351. package/src/execution/engine/index.ts +41 -7
  352. package/src/execution/engine/interface.ts +2 -6
  353. package/src/execution/engine/jsonRpcTransport.ts +247 -0
  354. package/src/execution/engine/mock.ts +1 -19
  355. package/src/execution/engine/restHttpClient.ts +269 -0
  356. package/src/execution/engine/restTransport.ts +544 -0
  357. package/src/execution/engine/sszTypes.ts +354 -0
  358. package/src/execution/engine/transport.ts +61 -0
  359. package/src/execution/engine/types.ts +34 -84
  360. package/src/execution/engine/utils.ts +12 -2
  361. package/src/metrics/metrics/lodestar.ts +23 -0
  362. package/src/metrics/metrics.ts +21 -6
  363. package/src/network/core/events.ts +16 -1
  364. package/src/network/processor/gossipHandlers.ts +94 -77
  365. package/src/network/processor/gossipValidatorFn.ts +12 -2
  366. package/src/network/processor/index.ts +58 -5
  367. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +1 -1
  368. package/src/network/reqresp/rateLimit.ts +2 -2
  369. package/src/network/subnets/attnetsService.ts +8 -3
  370. package/src/node/nodejs.ts +35 -3
  371. package/src/node/notifier.ts +14 -13
  372. package/src/node/options.ts +10 -1
  373. package/src/sync/range/batch.ts +25 -19
  374. package/src/sync/range/chain.ts +15 -8
  375. package/src/sync/range/range.ts +76 -30
  376. package/src/sync/unknownBlock.ts +65 -27
  377. package/src/sync/utils/downloadByRange.ts +123 -58
  378. package/src/util/asyncIterableToEvents.ts +44 -5
  379. package/src/util/clock.ts +3 -4
  380. package/src/util/execution.ts +16 -8
  381. package/src/util/metadata.ts +2 -1
  382. package/src/util/sszBytes.ts +25 -12
@@ -7,14 +7,12 @@ import {
7
7
  getIndexedAttestation,
8
8
  } from "@lodestar/state-transition";
9
9
  import {Attestation, CommitteeIndex, Epoch, IndexedAttestation, RootHex, Slot} from "@lodestar/types";
10
- import {LodestarError, Logger, MapDef, pruneSetToMax} from "@lodestar/utils";
10
+ import {LodestarError, Logger, MapDef} from "@lodestar/utils";
11
11
  import {Metrics} from "../metrics/metrics.js";
12
12
 
13
13
  /**
14
- * Same value to CheckpointBalancesCache, with the assumption that we don't have to use it for old epochs. In the worse case:
15
- * - when loading state bytes from disk, we need to compute shuffling for all epochs (~1s as of Sep 2023)
16
- * - don't have shuffling to verify attestations, need to do 1 epoch transition to add shuffling to this cache. This never happens
17
- * with default chain option of maxSkipSlots = 32
14
+ * Lookahead duties, gossip validation, and block production need epochs n-1, n, and n+1 for current epoch n.
15
+ * Keep the 4 highest epochs so that it works for epoch rotation.
18
16
  **/
19
17
  const MAX_EPOCHS = 4;
20
18
 
@@ -37,24 +35,29 @@ type ShufflingCacheItem = {
37
35
  type PromiseCacheItem = {
38
36
  type: CacheItemType.promise;
39
37
  timeInsertedMs: number;
40
- promise: Promise<EpochShuffling>;
41
- resolveFn: (shuffling: EpochShuffling) => void;
38
+ /** Resolves to null if the promise is cancelled */
39
+ promise: Promise<EpochShuffling | null>;
40
+ resolveFn: (shuffling: EpochShuffling | null) => void;
42
41
  };
43
42
 
44
43
  type CacheItem = ShufflingCacheItem | PromiseCacheItem;
45
44
 
45
+ export enum ShufflingPromiseCancelReason {
46
+ regenError = "regen_error",
47
+ decisionRootMismatch = "decision_root_mismatch",
48
+ pruned = "pruned",
49
+ }
50
+
46
51
  export type ShufflingCacheOpts = {
47
52
  maxShufflingCacheEpochs?: number;
48
53
  };
49
54
 
50
55
  /**
51
- * A shuffling cache to help:
52
- * - get committee quickly for attestation verification
53
- * - if a shuffling is not available (which does not happen with default chain option of maxSkipSlots = 32), track a promise to make sure we don't compute the same shuffling twice
54
- * - skip computing shuffling when loading state bytes from disk
56
+ * Cache recent epoch shufflings for lookahead duties, gossip validation, and block production.
57
+ * Pending promises deduplicate computation of missing shufflings.
55
58
  */
56
59
  export class ShufflingCache {
57
- /** LRU cache implemented as a map, pruned every time we add an item */
60
+ /** Pruned to the `maxEpochs` highest epochs every time we add a shuffling */
58
61
  private readonly itemsByDecisionRootByEpoch: MapDef<Epoch, Map<RootHex, CacheItem>> = new MapDef(
59
62
  () => new Map<RootHex, CacheItem>()
60
63
  );
@@ -73,6 +76,9 @@ export class ShufflingCache {
73
76
  Array.from(this.itemsByDecisionRootByEpoch.values()).reduce((total, innerMap) => total + innerMap.size, 0)
74
77
  )
75
78
  );
79
+ metrics.shufflingCache.epochs.addCollect(() =>
80
+ metrics.shufflingCache.epochs.set(this.itemsByDecisionRootByEpoch.size)
81
+ );
76
82
  }
77
83
 
78
84
  this.maxEpochs = opts.maxShufflingCacheEpochs ?? MAX_EPOCHS;
@@ -97,8 +103,8 @@ export class ShufflingCache {
97
103
  `Too many shuffling promises: ${promiseCount}, shufflingEpoch: ${epoch}, decisionRootHex: ${decisionRoot}`
98
104
  );
99
105
  }
100
- let resolveFn: ((shuffling: EpochShuffling) => void) | null = null;
101
- const promise = new Promise<EpochShuffling>((resolve) => {
106
+ let resolveFn: ((shuffling: EpochShuffling | null) => void) | null = null;
107
+ const promise = new Promise<EpochShuffling | null>((resolve) => {
102
108
  resolveFn = resolve;
103
109
  });
104
110
  if (resolveFn === null) {
@@ -121,7 +127,7 @@ export class ShufflingCache {
121
127
  * Return null if we don't have a shuffling for this epoch and dependentRootHex.
122
128
  */
123
129
  async get(epoch: Epoch, decisionRoot: RootHex): Promise<EpochShuffling | null> {
124
- const cacheItem = this.itemsByDecisionRootByEpoch.getOrDefault(epoch).get(decisionRoot);
130
+ const cacheItem = this.itemsByDecisionRootByEpoch.get(epoch)?.get(decisionRoot);
125
131
  if (cacheItem === undefined) {
126
132
  this.metrics?.shufflingCache.miss.inc();
127
133
  return null;
@@ -136,12 +142,10 @@ export class ShufflingCache {
136
142
  }
137
143
 
138
144
  /**
139
- * Get a shuffling synchronously, return null if not present.
140
- * The only time we have a promise cache item is when we regen shuffling for attestation, which never happens
141
- * with default chain option.
145
+ * Get a shuffling synchronously, return null if not present or if it's still being computed.
142
146
  */
143
147
  getSync(epoch: Epoch, decisionRoot: RootHex): EpochShuffling | null {
144
- const cacheItem = this.itemsByDecisionRootByEpoch.getOrDefault(epoch).get(decisionRoot);
148
+ const cacheItem = this.itemsByDecisionRootByEpoch.get(epoch)?.get(decisionRoot);
145
149
  if (cacheItem === undefined) {
146
150
  this.metrics?.shufflingCache.miss.inc();
147
151
  return null;
@@ -161,7 +165,7 @@ export class ShufflingCache {
161
165
  * `NativeBeaconStateView`.
162
166
  */
163
167
  has(epoch: Epoch, decisionRoot: RootHex): boolean {
164
- const cacheItem = this.itemsByDecisionRootByEpoch.getOrDefault(epoch).get(decisionRoot);
168
+ const cacheItem = this.itemsByDecisionRootByEpoch.get(epoch)?.get(decisionRoot);
165
169
  return cacheItem !== undefined && isShufflingCacheItem(cacheItem);
166
170
  }
167
171
 
@@ -186,6 +190,25 @@ export class ShufflingCache {
186
190
  }
187
191
  }
188
192
 
193
+ /**
194
+ * Resolve a pending promise with null so that waiters don't hang, then remove it.
195
+ */
196
+ cancelPromise(epoch: Epoch, decisionRoot: RootHex, reason: ShufflingPromiseCancelReason): void {
197
+ const itemsByDecisionRoot = this.itemsByDecisionRootByEpoch.get(epoch);
198
+ const cacheItem = itemsByDecisionRoot?.get(decisionRoot);
199
+ if (itemsByDecisionRoot === undefined || cacheItem === undefined || !isPromiseCacheItem(cacheItem)) {
200
+ return;
201
+ }
202
+
203
+ cacheItem.resolveFn(null);
204
+ itemsByDecisionRoot.delete(decisionRoot);
205
+ if (itemsByDecisionRoot.size === 0) {
206
+ this.itemsByDecisionRootByEpoch.delete(epoch);
207
+ }
208
+ this.metrics?.shufflingCache.cancelledPromises.inc({reason});
209
+ this.logger?.debug("Cancelled shuffling promise", {epoch, decisionRoot, reason});
210
+ }
211
+
189
212
  getIndexedAttestation(
190
213
  epoch: number,
191
214
  decisionRoot: string,
@@ -205,6 +228,11 @@ export class ShufflingCache {
205
228
  return this.getBeaconCommittees(epoch, decisionRoot, slot, [index])[0];
206
229
  }
207
230
 
231
+ getBeaconCommitteeOrNull(epoch: number, decisionRoot: string, slot: Slot, index: CommitteeIndex): Uint32Array | null {
232
+ const shuffling = this.getSync(epoch, decisionRoot);
233
+ return shuffling === null ? null : getBeaconCommittees(shuffling, slot, [index])[0];
234
+ }
235
+
208
236
  getBeaconCommittees(epoch: number, decisionRoot: string, slot: Slot, indices: CommitteeIndex[]): Uint32Array[] {
209
237
  const shuffling = this.getShufflingOrThrow(epoch, decisionRoot);
210
238
  return getBeaconCommittees(shuffling, slot, indices);
@@ -243,8 +271,42 @@ export class ShufflingCache {
243
271
  }
244
272
  // set the shuffling
245
273
  shufflingAtEpoch.set(decisionRoot, {type: CacheItemType.shuffling, shuffling});
246
- // prune the cache
247
- pruneSetToMax(this.itemsByDecisionRootByEpoch, this.maxEpochs);
274
+ this.prune();
275
+ }
276
+
277
+ /**
278
+ * Keep the `maxEpochs` highest epochs, regardless of insertion order.
279
+ */
280
+ private prune(): void {
281
+ const toDelete = this.itemsByDecisionRootByEpoch.size - this.maxEpochs;
282
+ if (toDelete <= 0) {
283
+ return;
284
+ }
285
+
286
+ const prunedEpochs = Array.from(this.itemsByDecisionRootByEpoch.keys())
287
+ .sort((a, b) => a - b)
288
+ .slice(0, toDelete);
289
+ let prunedShufflings = 0;
290
+ for (const epoch of prunedEpochs) {
291
+ for (const cacheItem of this.itemsByDecisionRootByEpoch.get(epoch)?.values() ?? []) {
292
+ if (isPromiseCacheItem(cacheItem)) {
293
+ cacheItem.resolveFn(null);
294
+ this.metrics?.shufflingCache.cancelledPromises.inc({reason: ShufflingPromiseCancelReason.pruned});
295
+ } else {
296
+ prunedShufflings++;
297
+ }
298
+ }
299
+ this.itemsByDecisionRootByEpoch.delete(epoch);
300
+ }
301
+ this.metrics?.shufflingCache.prunedShufflings.inc(prunedShufflings);
302
+
303
+ this.logger?.verbose("Pruned shuffling cache", {
304
+ prunedEpochs: prunedEpochs.join(","),
305
+ prunedShufflings,
306
+ cachedEpochs: Array.from(this.itemsByDecisionRootByEpoch.keys())
307
+ .sort((a, b) => a - b)
308
+ .join(","),
309
+ });
248
310
  }
249
311
  }
250
312
 
@@ -592,7 +592,10 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
592
592
  }
593
593
 
594
594
  const blockSlot = state.slot;
595
- const processCPStatesTimeMs = this.config.getSlotComponentDurationMs(PROCESS_CHECKPOINT_STATES_BPS);
595
+ const processCPStatesTimeMs = this.config.getSlotComponentDurationMs(
596
+ this.config.getForkName(blockSlot),
597
+ PROCESS_CHECKPOINT_STATES_BPS
598
+ );
596
599
  // we always have clock in production, fallback value is only for test
597
600
  const msFromSlot = this.clock?.msFromSlot(blockSlot) ?? processCPStatesTimeMs;
598
601
  const msToProcessCPStates = processCPStatesTimeMs - msFromSlot;
@@ -1,5 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
2
+ import {ForkName, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
3
3
  import {
4
4
  IBeaconStateView,
5
5
  ParticipationFlags,
@@ -123,6 +123,11 @@ export type ValidatorMonitorOpts = {
123
123
  validatorMonitorLogs?: boolean;
124
124
  };
125
125
 
126
+ export type NativeValidatorMonitor = {
127
+ registerLocalValidator(index: ValidatorIndex): void;
128
+ unregisterLocalValidator(index: ValidatorIndex): void;
129
+ };
130
+
126
131
  export const defaultValidatorMonitorOpts: ValidatorMonitorOpts = {
127
132
  validatorMonitorLogs: false,
128
133
  };
@@ -296,7 +301,8 @@ export function createValidatorMonitor(
296
301
  config: ChainForkConfig,
297
302
  genesisTime: number,
298
303
  logger: Logger,
299
- opts: ValidatorMonitorOpts
304
+ opts: ValidatorMonitorOpts,
305
+ nativeValidatorMonitor: NativeValidatorMonitor | null = null
300
306
  ): ValidatorMonitor {
301
307
  const logLevel = opts.validatorMonitorLogs ? LogLevel.info : LogLevel.debug;
302
308
  const log: LogHandler = (message: string, context?: LogData) => {
@@ -327,18 +333,23 @@ export function createValidatorMonitor(
327
333
  }));
328
334
 
329
335
  let lastRegisteredStatusEpoch = -1;
336
+ let lastAttestationSummaryEpoch = -1;
330
337
 
331
338
  // Track validator additions/removals per epoch for logging
332
339
  const addedValidatorsInEpoch: Set<ValidatorIndex> = new Set();
333
340
  const removedValidatorsInEpoch: Set<ValidatorIndex> = new Set();
334
341
 
335
- const validatorMonitorMetrics = metricsRegister ? createValidatorMonitorMetrics(metricsRegister) : null;
342
+ const shouldRegisterStateDerivedMetrics = nativeValidatorMonitor === null;
343
+ const validatorMonitorMetrics = metricsRegister
344
+ ? createValidatorMonitorMetrics(metricsRegister, shouldRegisterStateDerivedMetrics)
345
+ : null;
336
346
 
337
347
  const validatorMonitor: ValidatorMonitor = {
338
348
  registerLocalValidator(index) {
339
349
  const isNewValidator = !validators.has(index);
340
350
  validators.getOrDefault(index).lastRegisteredTimeMs = Date.now();
341
351
  if (isNewValidator) {
352
+ nativeValidatorMonitor?.registerLocalValidator(index);
342
353
  addedValidatorsInEpoch.add(index);
343
354
  }
344
355
  },
@@ -366,7 +377,7 @@ export function createValidatorMonitor(
366
377
  // Track total balance instead of per-validator balance to reduce metric cardinality
367
378
  let totalBalance = 0;
368
379
 
369
- for (const [index, monitoredValidator] of validators.entries()) {
380
+ for (const index of validators.keys()) {
370
381
  // We subtract two from the state of the epoch that generated these summaries.
371
382
  //
372
383
  // - One to account for it being the previous epoch.
@@ -380,68 +391,29 @@ export function createValidatorMonitor(
380
391
  );
381
392
 
382
393
  if (summary.isPrevSourceAttester) {
383
- validatorMonitorMetrics?.prevEpochOnChainSourceAttesterHit.inc();
394
+ validatorMonitorMetrics?.prevEpochOnChainSourceAttesterHit?.inc();
384
395
  } else {
385
- validatorMonitorMetrics?.prevEpochOnChainSourceAttesterMiss.inc();
396
+ validatorMonitorMetrics?.prevEpochOnChainSourceAttesterMiss?.inc();
386
397
  }
387
398
  if (summary.isPrevHeadAttester) {
388
- validatorMonitorMetrics?.prevEpochOnChainHeadAttesterHit.inc();
399
+ validatorMonitorMetrics?.prevEpochOnChainHeadAttesterHit?.inc();
389
400
  } else {
390
- validatorMonitorMetrics?.prevEpochOnChainHeadAttesterMiss.inc();
401
+ validatorMonitorMetrics?.prevEpochOnChainHeadAttesterMiss?.inc();
391
402
  }
392
403
  if (summary.isPrevTargetAttester) {
393
- validatorMonitorMetrics?.prevEpochOnChainTargetAttesterHit.inc();
404
+ validatorMonitorMetrics?.prevEpochOnChainTargetAttesterHit?.inc();
394
405
  } else {
395
- validatorMonitorMetrics?.prevEpochOnChainTargetAttesterMiss.inc();
396
- }
397
-
398
- const prevEpochSummary = monitoredValidator.summaries.get(previousEpoch);
399
- const attestationCorrectHead = prevEpochSummary?.attestationCorrectHead;
400
- if (attestationCorrectHead !== null && attestationCorrectHead !== undefined) {
401
- if (attestationCorrectHead) {
402
- validatorMonitorMetrics?.prevOnChainAttesterCorrectHead.inc();
403
- } else {
404
- validatorMonitorMetrics?.prevOnChainAttesterIncorrectHead.inc();
405
- }
406
- }
407
-
408
- const attestationMinBlockInclusionDistance = prevEpochSummary?.attestationMinBlockInclusionDistance;
409
- const inclusionDistance =
410
- attestationMinBlockInclusionDistance != null && attestationMinBlockInclusionDistance > 0
411
- ? // altair, attestation is not missed
412
- attestationMinBlockInclusionDistance
413
- : summary.inclusionDistance
414
- ? // phase0, this is from the state transition
415
- summary.inclusionDistance
416
- : null;
417
-
418
- if (inclusionDistance !== null) {
419
- validatorMonitorMetrics?.prevEpochOnChainInclusionDistance.observe(inclusionDistance);
420
- validatorMonitorMetrics?.prevEpochOnChainAttesterHit.inc();
421
- } else {
422
- validatorMonitorMetrics?.prevEpochOnChainAttesterMiss.inc();
406
+ validatorMonitorMetrics?.prevEpochOnChainTargetAttesterMiss?.inc();
423
407
  }
424
408
 
425
409
  const balance = balances?.[index];
426
410
  if (balance !== undefined) {
427
411
  totalBalance += balance;
428
412
  }
429
-
430
- if (!summary.isPrevSourceAttester || !summary.isPrevTargetAttester || !summary.isPrevHeadAttester) {
431
- log("Failed attestation in previous epoch", {
432
- validator: index,
433
- prevEpoch: currentEpoch - 1,
434
- isPrevSourceAttester: summary.isPrevSourceAttester,
435
- isPrevHeadAttester: summary.isPrevHeadAttester,
436
- isPrevTargetAttester: summary.isPrevTargetAttester,
437
- // inclusionDistance is not available in summary since altair
438
- inclusionDistance,
439
- });
440
- }
441
413
  }
442
414
 
443
415
  if (balances !== undefined) {
444
- validatorMonitorMetrics?.prevEpochOnChainBalance.set(totalBalance);
416
+ validatorMonitorMetrics?.prevEpochOnChainBalance?.set(totalBalance);
445
417
  }
446
418
  },
447
419
 
@@ -732,6 +704,7 @@ export function createValidatorMonitor(
732
704
  // Prune validators not seen in a while
733
705
  for (const [index, validator] of validators.entries()) {
734
706
  if (Date.now() - validator.lastRegisteredTimeMs > retainRegisteredValidatorsMs) {
707
+ nativeValidatorMonitor?.unregisterLocalValidator(index);
735
708
  validators.delete(index);
736
709
  removedValidatorsInEpoch.add(index);
737
710
  }
@@ -767,23 +740,67 @@ export function createValidatorMonitor(
767
740
  return;
768
741
  }
769
742
 
743
+ // On-chain attestation summary of prevEpoch. Reads only the epoch summaries filled by
744
+ // registerAttestationInBlock(), so it works with both TS and native state transition.
745
+ if (prevEpoch > lastAttestationSummaryEpoch) {
746
+ lastAttestationSummaryEpoch = prevEpoch;
747
+
748
+ for (const monitoredValidator of validators.values()) {
749
+ const prevEpochSummary = monitoredValidator.summaries.get(prevEpoch);
750
+ const attestationCorrectHead = prevEpochSummary?.attestationCorrectHead;
751
+ if (attestationCorrectHead !== null && attestationCorrectHead !== undefined) {
752
+ if (attestationCorrectHead) {
753
+ validatorMonitorMetrics?.prevOnChainAttesterCorrectHead.inc();
754
+ } else {
755
+ validatorMonitorMetrics?.prevOnChainAttesterIncorrectHead.inc();
756
+ }
757
+ }
758
+
759
+ const attestationMinBlockInclusionDistance = prevEpochSummary?.attestationMinBlockInclusionDistance;
760
+ const inclusionDistance =
761
+ attestationMinBlockInclusionDistance != null && attestationMinBlockInclusionDistance > 0
762
+ ? // altair, attestation is not missed
763
+ attestationMinBlockInclusionDistance
764
+ : null;
765
+
766
+ if (inclusionDistance !== null) {
767
+ validatorMonitorMetrics?.prevEpochOnChainInclusionDistance.observe(inclusionDistance);
768
+ validatorMonitorMetrics?.prevEpochOnChainAttesterHit.inc();
769
+ } else {
770
+ validatorMonitorMetrics?.prevEpochOnChainAttesterMiss.inc();
771
+ }
772
+ }
773
+ }
774
+
770
775
  const rootCache = new RootHexCache(headState);
771
776
 
772
777
  if (isStatePostAltair(headState)) {
773
778
  const prevEpochStartSlot = computeStartSlotAtEpoch(prevEpoch);
779
+ const prevEpochFork = config.getForkName(prevEpochStartSlot);
774
780
  const prevEpochTargetRoot = toRootHex(headState.getBlockRootAtSlot(prevEpochStartSlot));
775
781
 
776
782
  // Check attestation performance
777
783
  for (const [index, validator] of validators.entries()) {
778
784
  const flags = parseParticipationFlags(headState.getPreviousEpochParticipation(index));
779
785
  const attestationSummary = validator.attestations.get(prevEpoch)?.get(prevEpochTargetRoot);
780
- const summary = renderAttestationSummary(config, rootCache, attestationSummary, flags);
786
+ const summary = renderAttestationSummary(config, prevEpochFork, rootCache, attestationSummary, flags);
781
787
  validatorMonitorMetrics?.prevEpochAttestationSummary.inc({summary});
782
788
  log("Previous epoch attestation", {
783
789
  validator: index,
784
790
  epoch: prevEpoch,
785
791
  summary,
786
792
  });
793
+
794
+ if (!flags.timelySource || !flags.timelyTarget || !flags.timelyHead) {
795
+ log("Failed attestation in previous epoch", {
796
+ validator: index,
797
+ prevEpoch,
798
+ isPrevSourceAttester: flags.timelySource,
799
+ isPrevHeadAttester: flags.timelyHead,
800
+ isPrevTargetAttester: flags.timelyTarget,
801
+ inclusionDistance: validator.summaries.get(prevEpoch)?.attestationMinBlockInclusionDistance ?? null,
802
+ });
803
+ }
787
804
  }
788
805
  }
789
806
 
@@ -925,6 +942,7 @@ export function createValidatorMonitor(
925
942
  */
926
943
  function renderAttestationSummary(
927
944
  config: ChainForkConfig,
945
+ fork: ForkName,
928
946
  rootCache: RootHexCache,
929
947
  summary: AttestationSummary | undefined,
930
948
  flags: ParticipationFlags
@@ -1027,7 +1045,7 @@ function renderAttestationSummary(
1027
1045
  }
1028
1046
 
1029
1047
  const submittedLate =
1030
- summary.poolSubmitDelayMinSec > config.getSlotComponentDurationMs(LATE_ATTESTATION_SUBMISSION_BPS) / 1000;
1048
+ summary.poolSubmitDelayMinSec > config.getSlotComponentDurationMs(fork, LATE_ATTESTATION_SUBMISSION_BPS) / 1000;
1031
1049
 
1032
1050
  const aggregateInclusion = summary.aggregateInclusionDelaysSec.length > 0;
1033
1051
 
@@ -1162,7 +1180,8 @@ function renderBlockProposalSummary(
1162
1180
 
1163
1181
  if (
1164
1182
  proposal.poolSubmitDelaySec !== null &&
1165
- proposal.poolSubmitDelaySec > config.getSlotComponentDurationMs(LATE_BLOCK_SUBMISSION_BPS) / 1000
1183
+ proposal.poolSubmitDelaySec >
1184
+ config.getSlotComponentDurationMs(config.getForkName(proposalSlot), LATE_BLOCK_SUBMISSION_BPS) / 1000
1166
1185
  ) {
1167
1186
  out += "_late";
1168
1187
  }
@@ -1198,7 +1217,9 @@ export class RootHexCache {
1198
1217
  }
1199
1218
  }
1200
1219
 
1201
- function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
1220
+ function createValidatorMonitorMetrics(register: RegistryMetricCreator, registerStateDerivedMetrics = true) {
1221
+ const stateDerivedRegister = registerStateDerivedMetrics ? register : null;
1222
+
1202
1223
  return {
1203
1224
  validatorsConnected: register.gauge({
1204
1225
  name: "validator_monitor_validators",
@@ -1217,7 +1238,7 @@ function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
1217
1238
  }),
1218
1239
 
1219
1240
  // Validator Monitor Metrics (per-epoch summaries)
1220
- prevEpochOnChainBalance: register.gauge({
1241
+ prevEpochOnChainBalance: stateDerivedRegister?.gauge({
1221
1242
  name: "validator_monitor_prev_epoch_on_chain_balance",
1222
1243
  help: "Total balance of all monitored validators after an epoch",
1223
1244
  }),
@@ -1229,19 +1250,19 @@ function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
1229
1250
  name: "validator_monitor_prev_epoch_on_chain_attester_miss_total",
1230
1251
  help: "Incremented if validator's submitted attestation is not included in any blocks",
1231
1252
  }),
1232
- prevEpochOnChainSourceAttesterHit: register.gauge({
1253
+ prevEpochOnChainSourceAttesterHit: stateDerivedRegister?.gauge({
1233
1254
  name: "validator_monitor_prev_epoch_on_chain_source_attester_hit_total",
1234
1255
  help: "Incremented if the validator is flagged as a previous epoch source attester during per epoch processing",
1235
1256
  }),
1236
- prevEpochOnChainSourceAttesterMiss: register.gauge({
1257
+ prevEpochOnChainSourceAttesterMiss: stateDerivedRegister?.gauge({
1237
1258
  name: "validator_monitor_prev_epoch_on_chain_source_attester_miss_total",
1238
1259
  help: "Incremented if the validator is not flagged as a previous epoch source attester during per epoch processing",
1239
1260
  }),
1240
- prevEpochOnChainHeadAttesterHit: register.gauge({
1261
+ prevEpochOnChainHeadAttesterHit: stateDerivedRegister?.gauge({
1241
1262
  name: "validator_monitor_prev_epoch_on_chain_head_attester_hit_total",
1242
1263
  help: "Incremented if the validator is flagged as a previous epoch head attester during per epoch processing",
1243
1264
  }),
1244
- prevEpochOnChainHeadAttesterMiss: register.gauge({
1265
+ prevEpochOnChainHeadAttesterMiss: stateDerivedRegister?.gauge({
1245
1266
  name: "validator_monitor_prev_epoch_on_chain_head_attester_miss_total",
1246
1267
  help: "Incremented if the validator is not flagged as a previous epoch head attester during per epoch processing",
1247
1268
  }),
@@ -1253,11 +1274,11 @@ function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
1253
1274
  name: "validator_monitor_prev_epoch_on_chain_attester_incorrect_head_total",
1254
1275
  help: "Total count of times a validator votes incorrect head",
1255
1276
  }),
1256
- prevEpochOnChainTargetAttesterHit: register.gauge({
1277
+ prevEpochOnChainTargetAttesterHit: stateDerivedRegister?.gauge({
1257
1278
  name: "validator_monitor_prev_epoch_on_chain_target_attester_hit_total",
1258
1279
  help: "Incremented if the validator is flagged as a previous epoch target attester during per epoch processing",
1259
1280
  }),
1260
- prevEpochOnChainTargetAttesterMiss: register.gauge({
1281
+ prevEpochOnChainTargetAttesterMiss: stateDerivedRegister?.gauge({
1261
1282
  name: "validator_monitor_prev_epoch_on_chain_target_attester_miss_total",
1262
1283
  help: "Incremented if the validator is not flagged as a previous epoch target attester during per epoch processing",
1263
1284
  }),
@@ -7,3 +7,4 @@ export const ZERO_HASH = Buffer.alloc(32, 0);
7
7
  export const ZERO_HASH_HEX = "0x" + "00".repeat(32);
8
8
  export const EMPTY_SIGNATURE = Buffer.alloc(96, 0);
9
9
  export const GRAFFITI_SIZE = 32;
10
+ export const HALF_SLOT_BPS = 5000;
package/src/db/beacon.ts CHANGED
@@ -8,6 +8,7 @@ import {FlatFileStore} from "./flatFileStore/flatFileStore.js";
8
8
  import type {FlatFileStoreMetrics} from "./flatFileStore/metrics.js";
9
9
  import {IBeaconDb} from "./interface.js";
10
10
  import {CheckpointStateRepository} from "./repositories/checkpointState.js";
11
+ import {EarliestAvailableSlotRepository} from "./repositories/earliestAvailableSlot.js";
11
12
  import {
12
13
  AttesterSlashingRepository,
13
14
  BLSToExecutionChangeRepository,
@@ -21,6 +22,7 @@ import {
21
22
  DataColumnSidecarRepository,
22
23
  ExecutionPayloadEnvelopeArchiveRepository,
23
24
  ExecutionPayloadEnvelopeRepository,
25
+ ProposerPreferencesRepository,
24
26
  ProposerSlashingRepository,
25
27
  StateArchiveRepository,
26
28
  SyncCommitteeRepository,
@@ -48,9 +50,11 @@ export class BeaconDb implements IBeaconDb {
48
50
 
49
51
  stateArchive: StateArchiveRepository;
50
52
  checkpointState: CheckpointStateRepository;
53
+ earliestAvailableSlot: EarliestAvailableSlotRepository;
51
54
 
52
55
  voluntaryExit: VoluntaryExitRepository;
53
56
  proposerSlashing: ProposerSlashingRepository;
57
+ proposerPreferences: ProposerPreferencesRepository;
54
58
  attesterSlashing: AttesterSlashingRepository;
55
59
  blsToExecutionChange: BLSToExecutionChangeRepository;
56
60
 
@@ -83,9 +87,11 @@ export class BeaconDb implements IBeaconDb {
83
87
 
84
88
  this.stateArchive = new StateArchiveRepository(config, db);
85
89
  this.checkpointState = new CheckpointStateRepository(config, db);
90
+ this.earliestAvailableSlot = new EarliestAvailableSlotRepository(db);
86
91
  this.voluntaryExit = new VoluntaryExitRepository(config, db);
87
92
  this.blsToExecutionChange = new BLSToExecutionChangeRepository(config, db);
88
93
  this.proposerSlashing = new ProposerSlashingRepository(config, db);
94
+ this.proposerPreferences = new ProposerPreferencesRepository(config, db);
89
95
  this.attesterSlashing = new AttesterSlashingRepository(config, db);
90
96
 
91
97
  // lightclient
package/src/db/buckets.ts CHANGED
@@ -72,6 +72,8 @@ export enum Bucket {
72
72
 
73
73
  gloas_executionPayloadEnvelope = 59, // GLOAS BeaconBlockRoot -> SignedExecutionPayloadEnvelope
74
74
  gloas_executionPayloadEnvelopeArchive = 60, // GLOAS Slot -> SignedExecutionPayloadEnvelope, or 0x00 + SignedExecutionPayloadHeaderEnvelope
75
+ earliestAvailableSlot = 61, // singleton -> Slot
76
+ gloas_proposerPreferences = 62, // Slot || DependentRoot -> SignedProposerPreferences
75
77
  }
76
78
 
77
79
  export function getBucketNameByValue<T extends Bucket>(enumValue: T): keyof typeof Bucket {
@@ -3,6 +3,7 @@ import {Slot} from "@lodestar/types";
3
3
  import type {IDataColumnStore} from "./dataColumnStore.js";
4
4
  import type {FlatFileStoreMetrics} from "./flatFileStore/metrics.js";
5
5
  import {CheckpointStateRepository} from "./repositories/checkpointState.js";
6
+ import {EarliestAvailableSlotRepository} from "./repositories/earliestAvailableSlot.js";
6
7
  import {
7
8
  AttesterSlashingRepository,
8
9
  BLSToExecutionChangeRepository,
@@ -16,6 +17,7 @@ import {
16
17
  DataColumnSidecarRepository,
17
18
  ExecutionPayloadEnvelopeArchiveRepository,
18
19
  ExecutionPayloadEnvelopeRepository,
20
+ ProposerPreferencesRepository,
19
21
  ProposerSlashingRepository,
20
22
  StateArchiveRepository,
21
23
  SyncCommitteeRepository,
@@ -46,10 +48,12 @@ export interface IBeaconDb {
46
48
  stateArchive: StateArchiveRepository;
47
49
  // checkpoint states
48
50
  checkpointState: CheckpointStateRepository;
51
+ earliestAvailableSlot: EarliestAvailableSlotRepository;
49
52
 
50
53
  // op pool
51
54
  voluntaryExit: VoluntaryExitRepository;
52
55
  proposerSlashing: ProposerSlashingRepository;
56
+ proposerPreferences: ProposerPreferencesRepository;
53
57
  attesterSlashing: AttesterSlashingRepository;
54
58
  blsToExecutionChange: BLSToExecutionChangeRepository;
55
59
 
@@ -184,7 +184,7 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
184
184
  async remove(value: SignedBeaconBlock): Promise<void> {
185
185
  await Promise.all([
186
186
  super.remove(value),
187
- deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).SignedBeaconBlock, value),
187
+ deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).BeaconBlock, value),
188
188
  deleteParentRootIndex(this.db, value),
189
189
  ]);
190
190
  }
@@ -193,7 +193,7 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
193
193
  await Promise.all([
194
194
  super.batchRemove(values),
195
195
  ...values.map((value) =>
196
- deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).SignedBeaconBlock, value)
196
+ deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).BeaconBlock, value)
197
197
  ),
198
198
  ...values.map((value) => deleteParentRootIndex(this.db, value)),
199
199
  ]);
@@ -1,6 +1,6 @@
1
1
  import {Db, encodeKey} from "@lodestar/db";
2
2
  import {ForkAll} from "@lodestar/params";
3
- import {Root, SSZTypesFor, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
3
+ import {Root, SSZTypesFor, SignedBeaconBlock, Slot} from "@lodestar/types";
4
4
  import {Bucket, getBucketNameByValue} from "../buckets.js";
5
5
 
6
6
  export const rootIndexBucketId = getBucketNameByValue(Bucket.index_blockArchiveRootIndex);
@@ -16,10 +16,9 @@ export async function getParentRootIndex(db: Db, parentRoot: Root): Promise<Uint
16
16
 
17
17
  export async function deleteRootIndex(
18
18
  db: Db,
19
- signedBeaconBlockType: SSZTypesFor<ForkAll, "SignedBeaconBlock">,
19
+ beaconBlockType: SSZTypesFor<ForkAll, "BeaconBlock">,
20
20
  block: SignedBeaconBlock
21
21
  ): Promise<void> {
22
- const beaconBlockType = (signedBeaconBlockType as typeof ssz.phase0.SignedBeaconBlock).fields.message;
23
22
  return db.delete(getRootIndexKey(beaconBlockType.hashTreeRoot(block.message)), {bucketId: rootIndexBucketId});
24
23
  }
25
24
 
@@ -0,0 +1,19 @@
1
+ import {Db, encodeKey} from "@lodestar/db";
2
+ import {Slot, ssz} from "@lodestar/types";
3
+ import {Bucket, getBucketNameByValue} from "../buckets.js";
4
+
5
+ export class EarliestAvailableSlotRepository {
6
+ private readonly key = encodeKey(Bucket.earliestAvailableSlot, 0);
7
+ private readonly opts = {bucketId: getBucketNameByValue(Bucket.earliestAvailableSlot)};
8
+
9
+ constructor(private readonly db: Db) {}
10
+
11
+ async get(): Promise<Slot | null> {
12
+ const bytes = await this.db.get(this.key, this.opts);
13
+ return bytes === null ? null : ssz.Slot.deserialize(bytes);
14
+ }
15
+
16
+ async set(slot: Slot): Promise<void> {
17
+ await this.db.put(this.key, ssz.Slot.serialize(slot), this.opts);
18
+ }
19
+ }
@@ -18,6 +18,7 @@ export {BestLightClientUpdateRepository} from "./lightclientBestUpdate.js";
18
18
  export {CheckpointHeaderRepository} from "./lightclientCheckpointHeader.js";
19
19
  export {SyncCommitteeRepository} from "./lightclientSyncCommittee.js";
20
20
  export {SyncCommitteeWitnessRepository} from "./lightclientSyncCommitteeWitness.js";
21
+ export {ProposerPreferencesRepository} from "./proposerPreferences.js";
21
22
  export {ProposerSlashingRepository} from "./proposerSlashing.js";
22
23
  export {StateArchiveRepository} from "./stateArchive.js";
23
24
  export {VoluntaryExitRepository} from "./voluntaryExit.js";