@lodestar/beacon-node 2.1.0-dev.475f7d67bc → 2.1.0-dev.4b0199a2eb

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 (378) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +1 -3
  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 +8 -0
  6. package/lib/api/impl/beacon/pool/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 +3 -2
  9. package/lib/api/impl/beacon/state/index.js.map +1 -1
  10. package/lib/api/impl/beacon/state/utils.js +1 -1
  11. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  12. package/lib/api/impl/config/constants.d.ts +0 -1
  13. package/lib/api/impl/config/constants.d.ts.map +1 -1
  14. package/lib/api/impl/config/constants.js +1 -3
  15. package/lib/api/impl/config/constants.js.map +1 -1
  16. package/lib/api/impl/debug/index.d.ts.map +1 -1
  17. package/lib/api/impl/debug/index.js +0 -3
  18. package/lib/api/impl/debug/index.js.map +1 -1
  19. package/lib/api/impl/errors.d.ts +7 -0
  20. package/lib/api/impl/errors.d.ts.map +1 -1
  21. package/lib/api/impl/errors.js +9 -0
  22. package/lib/api/impl/errors.js.map +1 -1
  23. package/lib/api/impl/validator/index.d.ts.map +1 -1
  24. package/lib/api/impl/validator/index.js +4 -94
  25. package/lib/api/impl/validator/index.js.map +1 -1
  26. package/lib/api/rest/base.d.ts.map +1 -1
  27. package/lib/api/rest/base.js +6 -3
  28. package/lib/api/rest/base.js.map +1 -1
  29. package/lib/chain/ColumnReconstructionTracker.d.ts +3 -0
  30. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  31. package/lib/chain/ColumnReconstructionTracker.js +3 -1
  32. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  33. package/lib/chain/GetBlobsTracker.d.ts +3 -0
  34. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  35. package/lib/chain/GetBlobsTracker.js +3 -1
  36. package/lib/chain/GetBlobsTracker.js.map +1 -1
  37. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  38. package/lib/chain/blocks/importBlock.js +14 -5
  39. package/lib/chain/blocks/importBlock.js.map +1 -1
  40. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  41. package/lib/chain/blocks/importExecutionPayload.js +7 -56
  42. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  43. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
  44. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  45. package/lib/chain/blocks/types.d.ts +0 -4
  46. package/lib/chain/blocks/types.d.ts.map +1 -1
  47. package/lib/chain/blocks/types.js +0 -5
  48. package/lib/chain/blocks/types.js.map +1 -1
  49. package/lib/chain/chain.d.ts +3 -3
  50. package/lib/chain/chain.d.ts.map +1 -1
  51. package/lib/chain/chain.js +30 -10
  52. package/lib/chain/chain.js.map +1 -1
  53. package/lib/chain/errors/dataColumnSidecarError.d.ts +7 -0
  54. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  55. package/lib/chain/errors/dataColumnSidecarError.js +1 -0
  56. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  57. package/lib/chain/errors/executionPayloadBid.d.ts +0 -15
  58. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  59. package/lib/chain/errors/executionPayloadBid.js +0 -3
  60. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  61. package/lib/chain/errors/index.d.ts +0 -1
  62. package/lib/chain/errors/index.d.ts.map +1 -1
  63. package/lib/chain/errors/index.js +0 -1
  64. package/lib/chain/errors/index.js.map +1 -1
  65. package/lib/chain/forkChoice/index.d.ts +11 -2
  66. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  67. package/lib/chain/forkChoice/index.js +180 -13
  68. package/lib/chain/forkChoice/index.js.map +1 -1
  69. package/lib/chain/forkChoiceExecutionEngine.d.ts +1 -2
  70. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
  71. package/lib/chain/forkChoiceExecutionEngine.js +0 -3
  72. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
  73. package/lib/chain/interface.d.ts +3 -3
  74. package/lib/chain/interface.d.ts.map +1 -1
  75. package/lib/chain/interface.js.map +1 -1
  76. package/lib/chain/opPools/index.d.ts +0 -1
  77. package/lib/chain/opPools/index.d.ts.map +1 -1
  78. package/lib/chain/opPools/index.js +0 -1
  79. package/lib/chain/opPools/index.js.map +1 -1
  80. package/lib/chain/opPools/opPool.d.ts +9 -3
  81. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  82. package/lib/chain/opPools/opPool.js +22 -16
  83. package/lib/chain/opPools/opPool.js.map +1 -1
  84. package/lib/chain/options.d.ts.map +1 -1
  85. package/lib/chain/options.js +1 -3
  86. package/lib/chain/options.js.map +1 -1
  87. package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -3
  88. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  89. package/lib/chain/produceBlock/produceBlockBody.js +3 -33
  90. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  91. package/lib/chain/regen/interface.d.ts +0 -1
  92. package/lib/chain/regen/interface.d.ts.map +1 -1
  93. package/lib/chain/regen/interface.js +0 -1
  94. package/lib/chain/regen/interface.js.map +1 -1
  95. package/lib/chain/seenCache/index.d.ts +1 -0
  96. package/lib/chain/seenCache/index.d.ts.map +1 -1
  97. package/lib/chain/seenCache/index.js +1 -0
  98. package/lib/chain/seenCache/index.js.map +1 -1
  99. package/lib/chain/seenCache/seenBlockProposers.d.ts +3 -0
  100. package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
  101. package/lib/chain/seenCache/seenBlockProposers.js +6 -2
  102. package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
  103. package/lib/chain/seenCache/seenDataColumnSidecars.d.ts +17 -0
  104. package/lib/chain/seenCache/seenDataColumnSidecars.d.ts.map +1 -0
  105. package/lib/chain/seenCache/seenDataColumnSidecars.js +61 -0
  106. package/lib/chain/seenCache/seenDataColumnSidecars.js.map +1 -0
  107. package/lib/chain/seenCache/seenGossipBlockInput.js +1 -1
  108. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  109. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +11 -2
  110. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  111. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +28 -2
  112. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  113. package/lib/chain/validation/attestation.d.ts.map +1 -1
  114. package/lib/chain/validation/attestation.js +4 -2
  115. package/lib/chain/validation/attestation.js.map +1 -1
  116. package/lib/chain/validation/block.d.ts.map +1 -1
  117. package/lib/chain/validation/block.js +20 -7
  118. package/lib/chain/validation/block.js.map +1 -1
  119. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  120. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  121. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  122. package/lib/chain/validation/executionPayloadBid.js +1 -34
  123. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  124. package/lib/chain/validation/index.d.ts +0 -1
  125. package/lib/chain/validation/index.d.ts.map +1 -1
  126. package/lib/chain/validation/index.js +0 -1
  127. package/lib/chain/validation/index.js.map +1 -1
  128. package/lib/chain/validation/proposerSlashing.js +5 -1
  129. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  130. package/lib/chain/validation/voluntaryExit.js +2 -2
  131. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  132. package/lib/execution/builder/validateBid.d.ts.map +1 -1
  133. package/lib/execution/builder/validateBid.js +1 -14
  134. package/lib/execution/builder/validateBid.js.map +1 -1
  135. package/lib/execution/engine/disabled.d.ts +0 -1
  136. package/lib/execution/engine/disabled.d.ts.map +1 -1
  137. package/lib/execution/engine/disabled.js +0 -3
  138. package/lib/execution/engine/disabled.js.map +1 -1
  139. package/lib/execution/engine/http.d.ts +2 -8
  140. package/lib/execution/engine/http.d.ts.map +1 -1
  141. package/lib/execution/engine/http.js +4 -27
  142. package/lib/execution/engine/http.js.map +1 -1
  143. package/lib/execution/engine/interface.d.ts +2 -13
  144. package/lib/execution/engine/interface.d.ts.map +1 -1
  145. package/lib/execution/engine/interface.js.map +1 -1
  146. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -3
  147. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  148. package/lib/execution/engine/jsonRpcTransport.js +9 -33
  149. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  150. package/lib/execution/engine/mock.d.ts +0 -1
  151. package/lib/execution/engine/mock.d.ts.map +1 -1
  152. package/lib/execution/engine/mock.js +3 -25
  153. package/lib/execution/engine/mock.js.map +1 -1
  154. package/lib/execution/engine/payloadIdCache.d.ts +1 -4
  155. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  156. package/lib/execution/engine/payloadIdCache.js +2 -16
  157. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  158. package/lib/execution/engine/restTransport.d.ts +1 -2
  159. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  160. package/lib/execution/engine/restTransport.js +0 -3
  161. package/lib/execution/engine/restTransport.js.map +1 -1
  162. package/lib/execution/engine/transport.d.ts +2 -3
  163. package/lib/execution/engine/transport.d.ts.map +1 -1
  164. package/lib/execution/engine/types.d.ts +0 -24
  165. package/lib/execution/engine/types.d.ts.map +1 -1
  166. package/lib/execution/engine/types.js +0 -12
  167. package/lib/execution/engine/types.js.map +1 -1
  168. package/lib/index.d.ts +1 -0
  169. package/lib/index.d.ts.map +1 -1
  170. package/lib/index.js +1 -0
  171. package/lib/index.js.map +1 -1
  172. package/lib/metrics/metrics/beacon.d.ts +0 -16
  173. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  174. package/lib/metrics/metrics/beacon.js +0 -35
  175. package/lib/metrics/metrics/beacon.js.map +1 -1
  176. package/lib/metrics/metrics/lodestar.d.ts +0 -9
  177. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  178. package/lib/metrics/metrics/lodestar.js +0 -20
  179. package/lib/metrics/metrics/lodestar.js.map +1 -1
  180. package/lib/network/core/networkCore.d.ts +1 -3
  181. package/lib/network/core/networkCore.d.ts.map +1 -1
  182. package/lib/network/core/networkCore.js +1 -3
  183. package/lib/network/core/networkCore.js.map +1 -1
  184. package/lib/network/forks.d.ts +2 -2
  185. package/lib/network/forks.d.ts.map +1 -1
  186. package/lib/network/forks.js +3 -3
  187. package/lib/network/forks.js.map +1 -1
  188. package/lib/network/gossip/interface.d.ts +2 -8
  189. package/lib/network/gossip/interface.d.ts.map +1 -1
  190. package/lib/network/gossip/interface.js +0 -1
  191. package/lib/network/gossip/interface.js.map +1 -1
  192. package/lib/network/gossip/scoringParameters.js +19 -14
  193. package/lib/network/gossip/scoringParameters.js.map +1 -1
  194. package/lib/network/gossip/topic.d.ts +17 -29
  195. package/lib/network/gossip/topic.d.ts.map +1 -1
  196. package/lib/network/gossip/topic.js +1 -13
  197. package/lib/network/gossip/topic.js.map +1 -1
  198. package/lib/network/interface.d.ts +1 -2
  199. package/lib/network/interface.d.ts.map +1 -1
  200. package/lib/network/network.d.ts +2 -8
  201. package/lib/network/network.d.ts.map +1 -1
  202. package/lib/network/network.js +16 -45
  203. package/lib/network/network.js.map +1 -1
  204. package/lib/network/options.d.ts +0 -1
  205. package/lib/network/options.d.ts.map +1 -1
  206. package/lib/network/options.js +0 -1
  207. package/lib/network/options.js.map +1 -1
  208. package/lib/network/peers/discover.d.ts +1 -0
  209. package/lib/network/peers/discover.d.ts.map +1 -1
  210. package/lib/network/peers/discover.js +44 -48
  211. package/lib/network/peers/discover.js.map +1 -1
  212. package/lib/network/peers/score/store.d.ts.map +1 -1
  213. package/lib/network/peers/score/store.js +1 -2
  214. package/lib/network/peers/score/store.js.map +1 -1
  215. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  216. package/lib/network/processor/gossipHandlers.js +85 -57
  217. package/lib/network/processor/gossipHandlers.js.map +1 -1
  218. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  219. package/lib/network/processor/gossipQueues/index.js +0 -6
  220. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  221. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  222. package/lib/network/processor/gossipValidatorFn.js +1 -5
  223. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  224. package/lib/network/processor/index.d.ts.map +1 -1
  225. package/lib/network/processor/index.js +0 -1
  226. package/lib/network/processor/index.js.map +1 -1
  227. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  228. package/lib/network/reqresp/ReqRespBeaconNode.js +0 -6
  229. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  230. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  231. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +3 -1
  232. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  233. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  234. package/lib/network/reqresp/handlers/index.js +0 -5
  235. package/lib/network/reqresp/handlers/index.js.map +1 -1
  236. package/lib/network/reqresp/protocols.d.ts +0 -1
  237. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  238. package/lib/network/reqresp/protocols.js +0 -5
  239. package/lib/network/reqresp/protocols.js.map +1 -1
  240. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  241. package/lib/network/reqresp/rateLimit.js +0 -4
  242. package/lib/network/reqresp/rateLimit.js.map +1 -1
  243. package/lib/network/reqresp/types.d.ts +2 -5
  244. package/lib/network/reqresp/types.d.ts.map +1 -1
  245. package/lib/network/reqresp/types.js +0 -3
  246. package/lib/network/reqresp/types.js.map +1 -1
  247. package/lib/sync/range/chain.d.ts.map +1 -1
  248. package/lib/sync/range/chain.js +1 -0
  249. package/lib/sync/range/chain.js.map +1 -1
  250. package/lib/sync/range/range.d.ts.map +1 -1
  251. package/lib/sync/range/range.js +5 -1
  252. package/lib/sync/range/range.js.map +1 -1
  253. package/lib/sync/unknownBlock.d.ts.map +1 -1
  254. package/lib/sync/unknownBlock.js +14 -1
  255. package/lib/sync/unknownBlock.js.map +1 -1
  256. package/lib/sync/utils/downloadByRange.d.ts +6 -0
  257. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  258. package/lib/sync/utils/downloadByRange.js +17 -8
  259. package/lib/sync/utils/downloadByRange.js.map +1 -1
  260. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  261. package/lib/sync/utils/downloadByRoot.js +1 -1
  262. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  263. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  264. package/lib/sync/utils/pendingBlocksTree.js +6 -1
  265. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  266. package/lib/util/dataColumns.d.ts +2 -1
  267. package/lib/util/dataColumns.d.ts.map +1 -1
  268. package/lib/util/dataColumns.js +7 -2
  269. package/lib/util/dataColumns.js.map +1 -1
  270. package/lib/util/execution.d.ts +2 -1
  271. package/lib/util/execution.d.ts.map +1 -1
  272. package/lib/util/execution.js +7 -2
  273. package/lib/util/execution.js.map +1 -1
  274. package/lib/util/sszBytes.d.ts.map +1 -1
  275. package/lib/util/sszBytes.js +6 -4
  276. package/lib/util/sszBytes.js.map +1 -1
  277. package/package.json +18 -21
  278. package/src/api/impl/beacon/blocks/index.ts +1 -5
  279. package/src/api/impl/beacon/pool/index.ts +11 -0
  280. package/src/api/impl/beacon/state/index.ts +3 -7
  281. package/src/api/impl/beacon/state/utils.ts +1 -1
  282. package/src/api/impl/config/constants.ts +0 -4
  283. package/src/api/impl/debug/index.ts +0 -4
  284. package/src/api/impl/errors.ts +10 -0
  285. package/src/api/impl/validator/index.ts +2 -123
  286. package/src/api/rest/base.ts +9 -3
  287. package/src/chain/ColumnReconstructionTracker.ts +5 -1
  288. package/src/chain/GetBlobsTracker.ts +5 -0
  289. package/src/chain/blocks/importBlock.ts +14 -7
  290. package/src/chain/blocks/importExecutionPayload.ts +7 -74
  291. package/src/chain/blocks/payloadEnvelopeInput/types.ts +8 -1
  292. package/src/chain/blocks/types.ts +0 -5
  293. package/src/chain/chain.ts +34 -9
  294. package/src/chain/errors/dataColumnSidecarError.ts +8 -0
  295. package/src/chain/errors/executionPayloadBid.ts +0 -18
  296. package/src/chain/errors/index.ts +0 -1
  297. package/src/chain/forkChoice/index.ts +233 -13
  298. package/src/chain/forkChoiceExecutionEngine.ts +1 -5
  299. package/src/chain/interface.ts +2 -2
  300. package/src/chain/opPools/index.ts +0 -1
  301. package/src/chain/opPools/opPool.ts +27 -16
  302. package/src/chain/options.ts +1 -3
  303. package/src/chain/produceBlock/produceBlockBody.ts +12 -66
  304. package/src/chain/regen/interface.ts +0 -1
  305. package/src/chain/seenCache/index.ts +1 -0
  306. package/src/chain/seenCache/seenBlockProposers.ts +12 -2
  307. package/src/chain/seenCache/seenDataColumnSidecars.ts +69 -0
  308. package/src/chain/seenCache/seenGossipBlockInput.ts +1 -1
  309. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +28 -2
  310. package/src/chain/validation/attestation.ts +4 -2
  311. package/src/chain/validation/block.ts +19 -7
  312. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  313. package/src/chain/validation/executionPayloadBid.ts +2 -49
  314. package/src/chain/validation/index.ts +0 -1
  315. package/src/chain/validation/proposerSlashing.ts +5 -1
  316. package/src/chain/validation/voluntaryExit.ts +2 -2
  317. package/src/execution/builder/validateBid.ts +2 -23
  318. package/src/execution/engine/disabled.ts +0 -4
  319. package/src/execution/engine/http.ts +5 -40
  320. package/src/execution/engine/interface.ts +2 -24
  321. package/src/execution/engine/jsonRpcTransport.ts +9 -46
  322. package/src/execution/engine/mock.ts +3 -26
  323. package/src/execution/engine/payloadIdCache.ts +4 -25
  324. package/src/execution/engine/restTransport.ts +1 -15
  325. package/src/execution/engine/transport.ts +2 -5
  326. package/src/execution/engine/types.ts +0 -35
  327. package/src/index.ts +1 -0
  328. package/src/metrics/metrics/beacon.ts +0 -37
  329. package/src/metrics/metrics/lodestar.ts +0 -21
  330. package/src/network/core/networkCore.ts +1 -3
  331. package/src/network/forks.ts +7 -3
  332. package/src/network/gossip/interface.ts +0 -5
  333. package/src/network/gossip/scoringParameters.ts +23 -14
  334. package/src/network/gossip/topic.ts +0 -14
  335. package/src/network/interface.ts +0 -2
  336. package/src/network/network.ts +20 -55
  337. package/src/network/options.ts +0 -2
  338. package/src/network/peers/discover.ts +42 -52
  339. package/src/network/peers/score/store.ts +1 -2
  340. package/src/network/processor/gossipHandlers.ts +147 -76
  341. package/src/network/processor/gossipQueues/index.ts +0 -6
  342. package/src/network/processor/gossipValidatorFn.ts +0 -5
  343. package/src/network/processor/index.ts +0 -1
  344. package/src/network/reqresp/ReqRespBeaconNode.ts +0 -7
  345. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +4 -1
  346. package/src/network/reqresp/handlers/index.ts +0 -5
  347. package/src/network/reqresp/protocols.ts +0 -6
  348. package/src/network/reqresp/rateLimit.ts +0 -4
  349. package/src/network/reqresp/types.ts +0 -6
  350. package/src/sync/range/chain.ts +1 -0
  351. package/src/sync/range/range.ts +7 -1
  352. package/src/sync/unknownBlock.ts +20 -1
  353. package/src/sync/utils/downloadByRange.ts +30 -7
  354. package/src/sync/utils/downloadByRoot.ts +12 -9
  355. package/src/sync/utils/pendingBlocksTree.ts +6 -1
  356. package/src/util/dataColumns.ts +13 -1
  357. package/src/util/execution.ts +16 -1
  358. package/src/util/sszBytes.ts +7 -8
  359. package/lib/chain/errors/inclusionList.d.ts +0 -60
  360. package/lib/chain/errors/inclusionList.d.ts.map +0 -1
  361. package/lib/chain/errors/inclusionList.js +0 -19
  362. package/lib/chain/errors/inclusionList.js.map +0 -1
  363. package/lib/chain/opPools/inclusionListStore.d.ts +0 -66
  364. package/lib/chain/opPools/inclusionListStore.d.ts.map +0 -1
  365. package/lib/chain/opPools/inclusionListStore.js +0 -174
  366. package/lib/chain/opPools/inclusionListStore.js.map +0 -1
  367. package/lib/chain/validation/inclusionList.d.ts +0 -14
  368. package/lib/chain/validation/inclusionList.d.ts.map +0 -1
  369. package/lib/chain/validation/inclusionList.js +0 -150
  370. package/lib/chain/validation/inclusionList.js.map +0 -1
  371. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts +0 -10
  372. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts.map +0 -1
  373. package/lib/network/reqresp/handlers/inclusionListsByIndices.js +0 -30
  374. package/lib/network/reqresp/handlers/inclusionListsByIndices.js.map +0 -1
  375. package/src/chain/errors/inclusionList.ts +0 -38
  376. package/src/chain/opPools/inclusionListStore.ts +0 -211
  377. package/src/chain/validation/inclusionList.ts +0 -192
  378. package/src/network/reqresp/handlers/inclusionListsByIndices.ts +0 -44
@@ -1,4 +1,3 @@
1
- import {SerializedList} from "@chainsafe/ssz";
2
1
  import {routes} from "@lodestar/api";
3
2
  import {
4
3
  ExecutionStatus,
@@ -11,16 +10,9 @@ import {
11
10
  getFinalizedExecutionBlockHash,
12
11
  getSafeExecutionBlockHash,
13
12
  } from "@lodestar/fork-choice";
14
- import {
15
- DataAvailabilityStatus,
16
- computeEpochAtSlot,
17
- isStatePostGloas,
18
- isStatePostHeze,
19
- } from "@lodestar/state-transition";
20
- import {RootHex, bellatrix} from "@lodestar/types";
13
+ import {DataAvailabilityStatus, isStatePostGloas} from "@lodestar/state-transition";
21
14
  import {isErrorAborted, toRootHex} from "@lodestar/utils";
22
15
  import {ExecutionPayloadStatus} from "../../execution/index.js";
23
- import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
24
16
  import {isQueueErrorAborted} from "../../util/queue/index.js";
25
17
  import {BeaconChain} from "../chain.js";
26
18
  import {ExecutionInvalidSource} from "../forkChoice/index.js";
@@ -202,37 +194,6 @@ export async function importExecutionPayload(
202
194
  );
203
195
  }
204
196
 
205
- // Timely inclusion lists of the preceding slot, keyed by that slot's dependent root on the block's branch and
206
- // resolved from the parent, which is at or before that slot. Gossip validation only accepts lists whose dependent
207
- // block is in fork choice, so a dependent root fork choice cannot resolve (below the anchor after checkpoint sync)
208
- // keys no stored list
209
- let inclusionListTransactions: bellatrix.Transactions | undefined;
210
- if (isStatePostHeze(blockState)) {
211
- const inclusionListSlot = protoBlock.slot - 1;
212
- let dependentRoot: RootHex | null = null;
213
- const parentBlock = this.forkChoice.getBlockHexDefaultStatus(protoBlock.parentRoot);
214
- if (parentBlock !== null) {
215
- try {
216
- dependentRoot = getShufflingDependentRoot(
217
- this.forkChoice,
218
- computeEpochAtSlot(inclusionListSlot),
219
- computeEpochAtSlot(parentBlock.slot),
220
- parentBlock
221
- );
222
- } catch (e) {
223
- this.logger.debug(
224
- "Inclusion list dependent root not in fork choice, importing payload without lists",
225
- {slot, root: blockRootHex},
226
- e as Error
227
- );
228
- }
229
- }
230
- inclusionListTransactions =
231
- dependentRoot === null
232
- ? SerializedList.empty()
233
- : this.inclusionListStore.getInclusionListTransactions(inclusionListSlot, dependentRoot, true);
234
- }
235
-
236
197
  // 4a. Run EL and signature verification in parallel
237
198
  const logCtx = {slot, root: blockRootHex, executionBlock: envelope.payload.blockNumber};
238
199
  this.logger.debug("Call engine api newPayload", logCtx);
@@ -243,8 +204,7 @@ export async function importExecutionPayload(
243
204
  envelope.payload,
244
205
  payloadInput.getVersionedHashes(),
245
206
  envelope.parentBeaconBlockRoot,
246
- envelope.executionRequests,
247
- inclusionListTransactions
207
+ envelope.executionRequests
248
208
  ),
249
209
 
250
210
  opts.validSignature === true
@@ -329,32 +289,6 @@ export async function importExecutionPayload(
329
289
  }
330
290
  });
331
291
 
332
- // A VALID payload that does not satisfy the inclusion list constraints is still imported, fork choice
333
- // only records the verdict so should_extend_payload moves the head to the EMPTY variant, which the next
334
- // proposer builds on.
335
- // Recorded before the payload enters fork choice. A VALID response must carry a verdict, an
336
- // optimistically imported payload counts as satisfied until the engine validates it, anything else as
337
- // unsatisfied. A VALID response without a verdict violates the engine API, it is logged and treated as
338
- // satisfied so a non-compliant engine does not orphan every payload
339
- if (inclusionListTransactions !== undefined) {
340
- if (execResult.status === ExecutionPayloadStatus.VALID && execResult.inclusionListSatisfied == null) {
341
- this.logger.warn("Execution engine reported no inclusion list verdict, not enforcing inclusion lists", logCtx);
342
- }
343
- const satisfied =
344
- execResult.status === ExecutionPayloadStatus.VALID
345
- ? (execResult.inclusionListSatisfied ?? true)
346
- : execResult.status === ExecutionPayloadStatus.SYNCING || execResult.status === ExecutionPayloadStatus.ACCEPTED;
347
- this.forkChoice.recordPayloadInclusionListSatisfaction(blockRootHex, satisfied);
348
- if (!satisfied) {
349
- this.logger.verbose("Payload did not satisfy inclusion list constraints", {
350
- ...logCtx,
351
- blockHash: blockHashHex,
352
- status: execResult.status,
353
- inclusionListTransactions: inclusionListTransactions.length,
354
- });
355
- }
356
- }
357
-
358
292
  // 6. Update fork choice, transitions the block's PENDING variant to FULL
359
293
  const execStatus = toForkChoiceExecutionStatus(execResult.status);
360
294
  const prevHead = this.forkChoice.getHead();
@@ -368,11 +302,13 @@ export async function importExecutionPayload(
368
302
  dataAvailabilityStatus
369
303
  );
370
304
  } catch (e) {
371
- // The payload chain can be invalidated by a forkchoiceUpdated verdict while the engine was awaited
305
+ // The payload chain can be invalidated by a forkchoiceUpdated verdict while the engine was awaited, and the
306
+ // payload itself may already be invalidated through another block delivering it
372
307
  if (
373
308
  e instanceof ForkChoiceError &&
374
309
  e.type.code === ForkChoiceErrorCode.INVALID_BLOCK &&
375
- e.type.err.code === InvalidBlockCode.PARENT_EXECUTION_INVALID
310
+ (e.type.err.code === InvalidBlockCode.PARENT_EXECUTION_INVALID ||
311
+ e.type.err.code === InvalidBlockCode.EXECUTION_INVALID)
376
312
  ) {
377
313
  throw new PayloadError(payloadInput, {code: PayloadErrorCode.BLOCK_EXECUTION_INVALID, blockRootHex});
378
314
  }
@@ -388,10 +324,7 @@ export async function importExecutionPayload(
388
324
  if (
389
325
  !this.opts.disableImportExecutionFcU &&
390
326
  blockRootHex === head.blockRoot &&
391
- head.payloadStatus === PayloadStatus.FULL &&
392
- // Skip a payload that does not satisfy the inclusion list constraints, fork choice keeps the EMPTY
393
- // variant as head and the next prepare fcU keeps the engine on the parent payload
394
- this.forkChoice.isPayloadInclusionListSatisfied(blockRootHex)
327
+ head.payloadStatus === PayloadStatus.FULL
395
328
  ) {
396
329
  const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
397
330
  const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
@@ -22,9 +22,16 @@ export enum PayloadEnvelopeInputSource {
22
22
  * - finalized: below the finalized slot
23
23
  * - prune: explicit prune by root
24
24
  * - cap: insertion-order backstop cap (MAX_PAYLOAD_ENVELOPE_INPUT_CACHE_SIZE)
25
+ * - capUnvalidated: cap eviction of an entry whose block is not validated and imported yet, evicted before the rest
25
26
  * - invalid: the cached envelope failed import with a definitive invalid verdict
26
27
  */
27
- export type PayloadEnvelopeInputPruneReason = "belowParent" | "finalized" | "remove" | "cap" | "invalid";
28
+ export type PayloadEnvelopeInputPruneReason =
29
+ | "belowParent"
30
+ | "finalized"
31
+ | "remove"
32
+ | "cap"
33
+ | "capUnvalidated"
34
+ | "invalid";
28
35
 
29
36
  export type SourceMeta = {
30
37
  source: PayloadEnvelopeInputSource;
@@ -4,11 +4,6 @@ import type {IndexedAttestation, Slot, fulu} from "@lodestar/types";
4
4
  import {IBlockInput} from "./blockInput/types.js";
5
5
  import {OrphanedPayloadEnvelope} from "./utils/chainSegment.js";
6
6
 
7
- export enum InclusionListSource {
8
- gossip = "gossip",
9
- api = "api",
10
- }
11
-
12
7
  type DataColumnData = {
13
8
  dataColumn: fulu.DataColumnSidecar;
14
9
  dataColumnBytes: Uint8Array | null;
@@ -105,7 +105,6 @@ import {
105
105
  AttestationPool,
106
106
  DeferredVoluntaryExitPool,
107
107
  ExecutionPayloadBidPool,
108
- InclusionListStore,
109
108
  OpPool,
110
109
  PayloadAttestationPool,
111
110
  ProposerPreferencesPool,
@@ -127,6 +126,7 @@ import {
127
126
  SeenAttesters,
128
127
  SeenBlockProposers,
129
128
  SeenContributionAndProof,
129
+ SeenDataColumnSidecars,
130
130
  SeenExecutionPayloadBids,
131
131
  SeenPayloadAttesters,
132
132
  SeenPayloadEnvelopeInput,
@@ -213,7 +213,6 @@ export class BeaconChain implements IBeaconChain {
213
213
  readonly executionPayloadBidPool: ExecutionPayloadBidPool;
214
214
  readonly payloadAttestationPool: PayloadAttestationPool;
215
215
  readonly proposerPreferencesPool = new ProposerPreferencesPool();
216
- readonly inclusionListStore: InclusionListStore;
217
216
  readonly opPool: OpPool;
218
217
  readonly deferredVoluntaryExitPool: DeferredVoluntaryExitPool;
219
218
 
@@ -224,6 +223,7 @@ export class BeaconChain implements IBeaconChain {
224
223
  readonly seenAggregatedAttestations: SeenAggregatedAttestations;
225
224
  readonly seenExecutionPayloadBids = new SeenExecutionPayloadBids();
226
225
  readonly seenBlockProposers = new SeenBlockProposers();
226
+ readonly seenDataColumnSidecars = new SeenDataColumnSidecars();
227
227
  /** Proposer indexes with an in-flight proposer slashing production */
228
228
  private readonly producingProposerSlashing = new Set<ValidatorIndex>();
229
229
  readonly seenSyncCommitteeMessages = new SeenSyncCommitteeMessages();
@@ -352,7 +352,6 @@ export class BeaconChain implements IBeaconChain {
352
352
  this.payloadAttestationPool = new PayloadAttestationPool(config, clock, metrics);
353
353
  this.opPool = new OpPool(config);
354
354
  this.deferredVoluntaryExitPool = new DeferredVoluntaryExitPool(logger);
355
- this.inclusionListStore = new InclusionListStore(config);
356
355
 
357
356
  this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
358
357
  this.seenContributionAndProof = new SeenContributionAndProof(metrics);
@@ -501,12 +500,14 @@ export class BeaconChain implements IBeaconChain {
501
500
  });
502
501
 
503
502
  const anchorBlockSlot = anchorState.latestBlockHeader.slot;
504
- if (isStatePostGloas(anchorState) && anchorBlockSlot > 0) {
503
+ const anchorBlockFork = config.getForkName(anchorBlockSlot);
504
+ // A pre-Gloas anchor in a state upgraded to Gloas carried its own payload, no envelope follows it
505
+ if (isStatePostGloas(anchorState) && anchorBlockSlot > 0 && isForkPostGloas(anchorBlockFork)) {
505
506
  const anchorBid = anchorState.latestExecutionPayloadBid;
506
507
  this.seenPayloadEnvelopeInputCache.addFromBid({
507
508
  blockRootHex: toRootHex(checkpoint.root),
508
509
  slot: anchorBlockSlot,
509
- forkName: anchorState.forkName,
510
+ forkName: anchorBlockFork,
510
511
  proposerIndex: anchorState.latestBlockHeader.proposerIndex,
511
512
  bid: anchorBid,
512
513
  sampledColumns: this.custodyConfig.sampledColumns,
@@ -525,12 +526,14 @@ export class BeaconChain implements IBeaconChain {
525
526
  logger,
526
527
  executionEngine: this.executionEngine,
527
528
  emitter,
529
+ seenDataColumnSidecars: this.seenDataColumnSidecars,
528
530
  metrics,
529
531
  config,
530
532
  });
531
533
  this.columnReconstructionTracker = new ColumnReconstructionTracker({
532
534
  logger,
533
535
  emitter,
536
+ seenDataColumnSidecars: this.seenDataColumnSidecars,
534
537
  metrics,
535
538
  config,
536
539
  signal,
@@ -1916,7 +1919,6 @@ export class BeaconChain implements IBeaconChain {
1916
1919
  this.executionPayloadBidPool.prune(slot);
1917
1920
  this.seenExecutionPayloadBids.prune(slot);
1918
1921
  this.proposerPreferencesPool.prune(slot);
1919
- this.inclusionListStore.prune(slot);
1920
1922
  this.seenAttestationDatas.onSlot(slot);
1921
1923
  this.reprocessController.onSlot(slot);
1922
1924
 
@@ -2037,9 +2039,18 @@ export class BeaconChain implements IBeaconChain {
2037
2039
 
2038
2040
  const finalizedSlot = computeStartSlotAtEpoch(cp.epoch);
2039
2041
  this.seenBlockProposers.prune(finalizedSlot);
2042
+ this.seenDataColumnSidecars.prune(finalizedSlot);
2040
2043
 
2041
2044
  // Update validator custody to account for effective balance changes
2042
- await this.updateValidatorsCustodyRequirement(cp);
2045
+ try {
2046
+ await this.updateValidatorsCustodyRequirement(cp);
2047
+ } catch (e) {
2048
+ this.logger.warn(
2049
+ "Error updating validators custody requirement",
2050
+ {epoch: cp.epoch, root: cp.rootHex},
2051
+ e as Error
2052
+ );
2053
+ }
2043
2054
 
2044
2055
  // TODO: Improve using regen here
2045
2056
  const {blockRoot, stateRoot, slot} = this.forkChoice.getHead();
@@ -2050,7 +2061,19 @@ export class BeaconChain implements IBeaconChain {
2050
2061
  }
2051
2062
 
2052
2063
  if (headState) {
2053
- this.opPool.pruneAll(blockResult.block, headState);
2064
+ // The finalized checkpoint state may be loaded from disk, it is only needed to prune voluntary exits
2065
+ let finalizedState: IBeaconStateView | Uint8Array | null = null;
2066
+ if (this.opPool.voluntaryExitsSize > 0) {
2067
+ finalizedState = await this.regen.getCheckpointStateOrBytes({epoch: cp.epoch, rootHex: cp.rootHex});
2068
+ if (finalizedState === null) {
2069
+ // A newer finalization can prune this checkpoint state while this handler awaits, its handler prunes exits
2070
+ this.logger.debug("Finalized checkpoint state not available, skip pruning voluntary exits", {
2071
+ epoch: cp.epoch,
2072
+ root: cp.rootHex,
2073
+ });
2074
+ }
2075
+ }
2076
+ this.opPool.pruneAll(blockResult.block, headState, finalizedState);
2054
2077
  }
2055
2078
 
2056
2079
  if (headState === null) {
@@ -2133,7 +2156,9 @@ export class BeaconChain implements IBeaconChain {
2133
2156
  if (stateOrBytes instanceof Uint8Array) {
2134
2157
  effectiveBalances = getEffectiveBalancesFromStateBytes(this.config, stateOrBytes, validatorIndices);
2135
2158
  } else {
2136
- effectiveBalances = validatorIndices.map((index) => stateOrBytes.getValidator(index).effectiveBalance ?? 0);
2159
+ effectiveBalances = validatorIndices.map((index) =>
2160
+ index < stateOrBytes.validatorCount ? stateOrBytes.getValidator(index).effectiveBalance : 0
2161
+ );
2137
2162
  }
2138
2163
  }
2139
2164
 
@@ -35,6 +35,7 @@ export enum DataColumnSidecarErrorCode {
35
35
 
36
36
  // following errors are adapted from the block errors
37
37
  ALREADY_KNOWN = "DATA_COLUMN_SIDECAR_ERROR_ALREADY_KNOWN",
38
+ REPEAT_PROPOSAL = "DATA_COLUMN_SIDECAR_ERROR_REPEAT_PROPOSAL",
38
39
  FUTURE_SLOT = "DATA_COLUMN_SIDECAR_ERROR_FUTURE_SLOT",
39
40
  WOULD_REVERT_FINALIZED_SLOT = "DATA_COLUMN_SIDECAR_ERROR_WOULD_REVERT_FINALIZED_SLOT",
40
41
  PARENT_UNKNOWN = "DATA_COLUMN_SIDECAR_ERROR_PARENT_UNKNOWN",
@@ -79,6 +80,13 @@ export type DataColumnSidecarErrorType =
79
80
  limit: number;
80
81
  }
81
82
  | {code: DataColumnSidecarErrorCode.ALREADY_KNOWN; columnIndex: number; slot: Slot}
83
+ | {
84
+ code: DataColumnSidecarErrorCode.REPEAT_PROPOSAL;
85
+ slot: Slot;
86
+ proposerIndex: number;
87
+ columnIndex: number;
88
+ root: RootHex;
89
+ }
82
90
  | {code: DataColumnSidecarErrorCode.FUTURE_SLOT; blockSlot: Slot; currentSlot: Slot}
83
91
  | {code: DataColumnSidecarErrorCode.WOULD_REVERT_FINALIZED_SLOT; blockSlot: Slot; finalizedSlot: Slot}
84
92
  | {
@@ -21,9 +21,6 @@ export enum ExecutionPayloadBidErrorCode {
21
21
  NO_MATCHING_PROPOSER_PREFERENCES = "EXECUTION_PAYLOAD_BID_ERROR_NO_MATCHING_PROPOSER_PREFERENCES",
22
22
  PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH",
23
23
  PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH",
24
- INCLUSION_LIST_BITS_NOT_INCLUSIVE = "EXECUTION_PAYLOAD_BID_ERROR_INCLUSION_LIST_BITS_NOT_INCLUSIVE",
25
- UNKNOWN_INCLUSION_LIST_DEPENDENT_ROOT = "EXECUTION_PAYLOAD_BID_ERROR_UNKNOWN_INCLUSION_LIST_DEPENDENT_ROOT",
26
- BEFORE_INCLUSION_LIST_DEADLINE = "EXECUTION_PAYLOAD_BID_ERROR_BEFORE_INCLUSION_LIST_DEADLINE",
27
24
  BEFORE_PAYLOAD_ATTESTATION_DEADLINE = "EXECUTION_PAYLOAD_BID_ERROR_BEFORE_PAYLOAD_ATTESTATION_DEADLINE",
28
25
  }
29
26
 
@@ -91,21 +88,6 @@ export type ExecutionPayloadBidErrorType =
91
88
  bidFeeRecipient: string;
92
89
  expectedFeeRecipient: string;
93
90
  }
94
- | {
95
- code: ExecutionPayloadBidErrorCode.INCLUSION_LIST_BITS_NOT_INCLUSIVE;
96
- builderIndex: BuilderIndex;
97
- slot: Slot;
98
- }
99
- | {
100
- code: ExecutionPayloadBidErrorCode.UNKNOWN_INCLUSION_LIST_DEPENDENT_ROOT;
101
- slot: Slot;
102
- parentBlockRoot: RootHex;
103
- }
104
- | {
105
- code: ExecutionPayloadBidErrorCode.BEFORE_INCLUSION_LIST_DEADLINE;
106
- builderIndex: BuilderIndex;
107
- slot: Slot;
108
- }
109
91
  | {
110
92
  code: ExecutionPayloadBidErrorCode.BEFORE_PAYLOAD_ATTESTATION_DEADLINE;
111
93
  builderIndex: BuilderIndex;
@@ -7,7 +7,6 @@ export * from "./envelopeReconstructionError.js";
7
7
  export * from "./executionPayloadBid.js";
8
8
  export * from "./executionPayloadEnvelope.js";
9
9
  export * from "./gossipValidation.js";
10
- export * from "./inclusionList.js";
11
10
  export * from "./payloadAttestation.js";
12
11
  export * from "./proposerPreferences.js";
13
12
  export * from "./proposerSlashingError.js";
@@ -5,28 +5,33 @@ import {
5
5
  ForkChoice,
6
6
  ForkChoiceStateGetter,
7
7
  ForkChoiceStore,
8
+ IForkChoice,
8
9
  JustifiedBalancesGetter,
10
+ NativeForkChoice,
9
11
  PayloadStatus,
10
12
  ProtoArray,
11
13
  ProtoBlock,
12
14
  ForkChoiceOpts as RawForkChoiceOpts,
13
15
  } from "@lodestar/fork-choice";
14
- import {ZERO_HASH_HEX} from "@lodestar/params";
16
+ import {ForkSeq, SLOTS_PER_HISTORICAL_ROOT, ZERO_HASH_HEX, isForkPostGloas} from "@lodestar/params";
15
17
  import {
16
18
  DataAvailabilityStatus,
17
19
  IBeaconStateView,
20
+ ZERO_HASH,
18
21
  computeEpochAtSlot,
19
22
  computeStartSlotAtEpoch,
20
23
  isStatePostBellatrix,
21
24
  isStatePostGloas,
22
25
  } from "@lodestar/state-transition";
23
- import {Slot, ssz} from "@lodestar/types";
24
- import {Logger, toRootHex} from "@lodestar/utils";
26
+ import {Slot, phase0, ssz} from "@lodestar/types";
27
+ import {Logger, fromHex, toRootHex} from "@lodestar/utils";
25
28
  import {GENESIS_SLOT} from "../../constants/index.js";
26
29
  import {Metrics} from "../../metrics/index.js";
27
30
  import {ChainEvent, ChainEventEmitter} from "../emitter.js";
28
31
 
29
32
  export type ForkChoiceOpts = RawForkChoiceOpts & {
33
+ /** Use the native (Zig) fork choice store instead of the proto-array */
34
+ nativeForkChoice?: boolean;
30
35
  // for testing only
31
36
  forkchoiceConstructor?: typeof ForkChoice;
32
37
  };
@@ -58,7 +63,22 @@ export function initializeForkChoice(
58
63
  stateGetter: ForkChoiceStateGetter,
59
64
  metrics: Metrics | null,
60
65
  logger?: Logger
61
- ): ForkChoice {
66
+ ): IForkChoice {
67
+ if (opts.nativeForkChoice) {
68
+ return initializeNativeForkChoice(
69
+ config,
70
+ emitter,
71
+ currentSlot,
72
+ state,
73
+ isFinalizedState,
74
+ opts,
75
+ justifiedBalancesGetter,
76
+ stateGetter,
77
+ metrics,
78
+ logger
79
+ );
80
+ }
81
+
62
82
  return isFinalizedState
63
83
  ? initializeForkChoiceFromFinalizedState(
64
84
  config,
@@ -115,7 +135,7 @@ export function initializeForkChoiceFromFinalizedState(
115
135
  // production code use ForkChoice constructor directly
116
136
  const forkchoiceConstructor = opts.forkchoiceConstructor ?? ForkChoice;
117
137
 
118
- const isForkPostGloas = computeEpochAtSlot(state.slot) >= config.GLOAS_FORK_EPOCH;
138
+ const isPostGloasAnchor = isStatePostGloas(state) && isForkPostGloas(config.getForkName(blockHeader.slot));
119
139
 
120
140
  return new forkchoiceConstructor(
121
141
  config,
@@ -164,15 +184,20 @@ export function initializeForkChoiceFromFinalizedState(
164
184
  // TODO GLOAS: executionPayloadNumber/GasLimit are not tracked in BeaconState post-gloas
165
185
  // (EIP-7732 removed latestExecutionPayloadHeader). Using 0 as unavailable fallback —
166
186
  // see initializeForkChoiceFromUnfinalizedState for the same caveat on validation.
187
+ // A pre-Gloas anchor's gas limit is kept in the state's bid by the upgrade.
167
188
  executionPayloadNumber: isStatePostGloas(state) ? 0 : state.payloadBlockNumber,
168
- executionPayloadGasLimit: isStatePostGloas(state) ? 0 : state.latestExecutionPayloadHeader.gasLimit,
189
+ executionPayloadGasLimit: isPostGloasAnchor
190
+ ? 0
191
+ : isStatePostGloas(state)
192
+ ? Number(state.latestExecutionPayloadBid.gasLimit)
193
+ : state.latestExecutionPayloadHeader.gasLimit,
169
194
  executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
170
195
  }
171
196
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
172
197
 
173
198
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
174
- payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL,
175
- parentBlockHash: isStatePostGloas(state) ? toRootHex(state.latestBlockHash) : null,
199
+ payloadStatus: isPostGloasAnchor ? PayloadStatus.PENDING : PayloadStatus.FULL,
200
+ parentBlockHash: isPostGloasAnchor ? toRootHex(state.latestBlockHash) : null,
176
201
  },
177
202
  currentSlot
178
203
  ),
@@ -183,6 +208,198 @@ export function initializeForkChoiceFromFinalizedState(
183
208
  );
184
209
  }
185
210
 
211
+ /**
212
+ * Initialize the native fork choice. A finalized anchor is both the justified and the finalized
213
+ * checkpoint, as in the spec's `get_forkchoice_store`. An unfinalized one keeps its state's
214
+ * checkpoints, with stand-ins for the ancestors that connect it to them: nothing is reported as
215
+ * finalized that the chain has not finalized.
216
+ */
217
+ export function initializeNativeForkChoice(
218
+ config: ChainForkConfig,
219
+ emitter: ChainEventEmitter,
220
+ currentSlot: Slot,
221
+ state: IBeaconStateView,
222
+ isFinalizedState: boolean,
223
+ opts: ForkChoiceOpts,
224
+ justifiedBalancesGetter: JustifiedBalancesGetter,
225
+ stateGetter: ForkChoiceStateGetter,
226
+ metrics: Metrics | null,
227
+ logger?: Logger
228
+ ): NativeForkChoice {
229
+ const {blockHeader, checkpoint} = state.computeAnchorCheckpoint();
230
+ const anchorRoot = toRootHex(checkpoint.root);
231
+ const isPostGloas = isStatePostGloas(state);
232
+ // A state upgraded to Gloas through skipped slots still holds a pre-Gloas block, which carried its own payload
233
+ const isPostGloasAnchor = isPostGloas && config.getForkSeq(blockHeader.slot) >= ForkSeq.gloas;
234
+ const bid = isPostGloasAnchor ? state.latestExecutionPayloadBid : null;
235
+ const hasPayload = isStatePostBellatrix(state) && state.isExecutionStateType && state.isMergeTransitionComplete;
236
+ // The state caches the bid of its latest block, except at genesis: the genesis block carries no bid
237
+ const anchorBid = blockHeader.slot === GENESIS_SLOT ? null : bid;
238
+
239
+ // The store aliases no root to genesis, so a checkpoint the chain never moved off genesis is
240
+ // given the genesis block root. Only possible while that root is still in the state's history.
241
+ const withGenesisRoot = (cp: phase0.Checkpoint): phase0.Checkpoint => {
242
+ if (!ssz.Root.equals(cp.root, ZERO_HASH)) return cp;
243
+ if (state.slot > GENESIS_SLOT + SLOTS_PER_HISTORICAL_ROOT) {
244
+ throw Error(
245
+ `The native fork choice cannot start from an unfinalized state at slot ${state.slot} of a chain that never justified a checkpoint: the genesis block root has left the state's block roots. Start without --chain.nativeForkChoice`
246
+ );
247
+ }
248
+ return {epoch: cp.epoch, root: state.getBlockRootAtSlot(GENESIS_SLOT)};
249
+ };
250
+ const justifiedCheckpoint = isFinalizedState ? checkpoint : withGenesisRoot(state.currentJustifiedCheckpoint);
251
+ const finalizedCheckpoint = isFinalizedState ? checkpoint : withGenesisRoot(state.finalizedCheckpoint);
252
+ const justifiedRoot = toRootHex(justifiedCheckpoint.root);
253
+ const finalizedRoot = toRootHex(finalizedCheckpoint.root);
254
+
255
+ if (!isFinalizedState) {
256
+ logger?.warn("Initializing fork choice from unfinalized state", {
257
+ currentSlot,
258
+ stateSlot: state.slot,
259
+ headSlot: blockHeader.slot,
260
+ headRoot: anchorRoot,
261
+ finalizedEpoch: finalizedCheckpoint.epoch,
262
+ finalizedRoot,
263
+ justifiedEpoch: justifiedCheckpoint.epoch,
264
+ justifiedRoot,
265
+ });
266
+ }
267
+
268
+ const store = new ForkChoiceStore(
269
+ currentSlot,
270
+ justifiedCheckpoint,
271
+ finalizedCheckpoint,
272
+ // For an unfinalized anchor this is not the justified state, but no other state is at hand
273
+ state.getEffectiveBalanceIncrementsZeroInactive(),
274
+ justifiedBalancesGetter,
275
+ stateGetter,
276
+ {
277
+ onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
278
+ onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
279
+ onFastConfirmation: ({block, slot, currentSlot}) =>
280
+ emitter.emit(routes.events.EventType.fastConfirmation, {block, slot, currentSlot}),
281
+ onPtcQuorum: (data) => emitter.emit(ChainEvent.forkChoicePtcQuorum, data),
282
+ }
283
+ );
284
+
285
+ const checkpoints = {
286
+ justifiedEpoch: justifiedCheckpoint.epoch,
287
+ justifiedRoot,
288
+ finalizedEpoch: finalizedCheckpoint.epoch,
289
+ finalizedRoot,
290
+ unrealizedJustifiedEpoch: justifiedCheckpoint.epoch,
291
+ unrealizedJustifiedRoot: justifiedRoot,
292
+ unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
293
+ unrealizedFinalizedRoot: finalizedRoot,
294
+ };
295
+
296
+ const block: ProtoBlock = {
297
+ slot: blockHeader.slot,
298
+ parentRoot: toRootHex(blockHeader.parentRoot),
299
+ stateRoot: toRootHex(blockHeader.stateRoot),
300
+ blockRoot: anchorRoot,
301
+ targetRoot: anchorRoot,
302
+ timeliness: true,
303
+ ptcTimeliness: true,
304
+ importedTimely: true,
305
+ proposerIndex: blockHeader.proposerIndex,
306
+ ...checkpoints,
307
+
308
+ ...(hasPayload
309
+ ? {
310
+ executionPayloadBlockHash: isPostGloas
311
+ ? toRootHex(state.latestBlockHash)
312
+ : toRootHex(state.latestExecutionPayloadHeader.blockHash),
313
+ // TODO GLOAS: not tracked in BeaconState post-gloas, see initializeForkChoiceFromFinalizedState
314
+ executionPayloadNumber: isPostGloas ? 0 : state.payloadBlockNumber,
315
+ // The upgrade to Gloas keeps a pre-Gloas block's payload gas limit in the state's bid
316
+ executionPayloadGasLimit: isPostGloasAnchor
317
+ ? 0
318
+ : isPostGloas
319
+ ? Number(state.latestExecutionPayloadBid.gasLimit)
320
+ : state.latestExecutionPayloadHeader.gasLimit,
321
+ executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
322
+ }
323
+ : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
324
+
325
+ dataAvailabilityStatus: DataAvailabilityStatus.PreData,
326
+ payloadStatus: isPostGloasAnchor ? PayloadStatus.PENDING : PayloadStatus.FULL,
327
+ parentBlockHash: bid === null ? null : toRootHex(bid.parentBlockHash),
328
+ };
329
+
330
+ // Ancestors of the anchor known by root only: the finalized block, the justified block, the
331
+ // anchor's parent, and for the anchor's epoch and the one before the checkpoint block, which the
332
+ // chain can still justify and which current votes target, and the block before it, the
333
+ // dependent root of the next epoch's duties. Their slots are upper bounds and their payloads
334
+ // unknown, so they carry none.
335
+ const unfinalizedAncestors: ProtoBlock[] = [];
336
+ if (!isFinalizedState) {
337
+ const finalizedSlot = computeStartSlotAtEpoch(finalizedCheckpoint.epoch);
338
+ const candidates: [string, Slot][] = [
339
+ [finalizedRoot, finalizedSlot],
340
+ [justifiedRoot, computeStartSlotAtEpoch(justifiedCheckpoint.epoch)],
341
+ [block.parentRoot, blockHeader.slot - 1],
342
+ ];
343
+ const anchorEpoch = computeEpochAtSlot(state.slot);
344
+ for (const epoch of [anchorEpoch - 1, anchorEpoch]) {
345
+ const checkpointSlot = computeStartSlotAtEpoch(epoch);
346
+ for (const slot of [checkpointSlot - 1, checkpointSlot]) {
347
+ if (slot > finalizedSlot && slot < blockHeader.slot) {
348
+ candidates.push([toRootHex(state.getBlockRootAtSlot(slot)), slot]);
349
+ }
350
+ }
351
+ }
352
+ // Roots repeat over skipped slots: a block keeps the lowest slot it is known at
353
+ candidates.sort((a, b) => a[1] - b[1]);
354
+ for (const [blockRoot, slot] of candidates) {
355
+ const isKnown = blockRoot === anchorRoot || unfinalizedAncestors.some((b) => b.blockRoot === blockRoot);
356
+ if (isKnown || blockRoot === ZERO_HASH_HEX) continue;
357
+ const isGloas = config.getForkSeq(slot) >= ForkSeq.gloas;
358
+ const targetSlot = computeStartSlotAtEpoch(computeEpochAtSlot(slot));
359
+ unfinalizedAncestors.push({
360
+ slot,
361
+ blockRoot,
362
+ parentRoot: unfinalizedAncestors.at(-1)?.blockRoot ?? ZERO_HASH_HEX,
363
+ stateRoot: ZERO_HASH_HEX,
364
+ targetRoot: targetSlot === slot ? blockRoot : toRootHex(state.getBlockRootAtSlot(targetSlot)),
365
+ timeliness: false,
366
+ ptcTimeliness: false,
367
+ importedTimely: false,
368
+ proposerIndex: 0,
369
+ ...checkpoints,
370
+ executionPayloadBlockHash: null,
371
+ executionStatus: ExecutionStatus.PreMerge,
372
+ dataAvailabilityStatus: DataAvailabilityStatus.PreData,
373
+ payloadStatus: isGloas ? PayloadStatus.PENDING : PayloadStatus.FULL,
374
+ parentBlockHash: isGloas ? ZERO_HASH_HEX : null,
375
+ });
376
+ }
377
+ }
378
+
379
+ return new NativeForkChoice(
380
+ config,
381
+ store,
382
+ {
383
+ block,
384
+ stateSlot: state.slot,
385
+ genesisTime: state.genesisTime,
386
+ genesisValidatorsRoot: state.genesisValidatorsRoot,
387
+ justifiedCheckpoint: isFinalizedState ? state.currentJustifiedCheckpoint : justifiedCheckpoint,
388
+ finalizedCheckpoint: isFinalizedState ? state.finalizedCheckpoint : finalizedCheckpoint,
389
+ unfinalizedAncestors: isFinalizedState ? undefined : unfinalizedAncestors,
390
+ payloadBlockHash: isPostGloasAnchor
391
+ ? (anchorBid?.blockHash ?? null)
392
+ : block.executionPayloadBlockHash === null
393
+ ? null
394
+ : fromHex(block.executionPayloadBlockHash),
395
+ bidParentBlockHash: anchorBid?.parentBlockHash ?? null,
396
+ },
397
+ metrics,
398
+ opts,
399
+ logger
400
+ );
401
+ }
402
+
186
403
  /**
187
404
  * Initialize forkchoice from an unfinalized state.
188
405
  */
@@ -217,7 +434,7 @@ export function initializeForkChoiceFromUnfinalizedState(
217
434
  // this is not the justified state, but there is no other ways to get justified balances
218
435
  const justifiedBalances = unfinalizedState.getEffectiveBalanceIncrementsZeroInactive();
219
436
 
220
- const isForkPostGloas = computeEpochAtSlot(unfinalizedState.slot) >= config.GLOAS_FORK_EPOCH;
437
+ const isPostGloasAnchor = isStatePostGloas(unfinalizedState) && isForkPostGloas(config.getForkName(blockHeader.slot));
221
438
 
222
439
  const store = new ForkChoiceStore(
223
440
  currentSlot,
@@ -270,17 +487,20 @@ export function initializeForkChoiceFromUnfinalizedState(
270
487
  // PENDING/EMPTY convention), so gossip bids that reference the head's *own* payload
271
488
  // hash won't match this variant anyway and will IGNORE until `onExecutionPayload`
272
489
  // upgrades the head to FULL with real values.
490
+ // A pre-Gloas anchor's gas limit is kept in the state's bid by the upgrade.
273
491
  executionPayloadNumber: isStatePostGloas(unfinalizedState) ? 0 : unfinalizedState.payloadBlockNumber,
274
- executionPayloadGasLimit: isStatePostGloas(unfinalizedState)
492
+ executionPayloadGasLimit: isPostGloasAnchor
275
493
  ? 0
276
- : unfinalizedState.latestExecutionPayloadHeader.gasLimit,
494
+ : isStatePostGloas(unfinalizedState)
495
+ ? Number(unfinalizedState.latestExecutionPayloadBid.gasLimit)
496
+ : unfinalizedState.latestExecutionPayloadHeader.gasLimit,
277
497
  executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
278
498
  }
279
499
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
280
500
 
281
501
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
282
- payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL,
283
- parentBlockHash: isStatePostGloas(unfinalizedState) ? toRootHex(unfinalizedState.latestBlockHash) : null,
502
+ payloadStatus: isPostGloasAnchor ? PayloadStatus.PENDING : PayloadStatus.FULL,
503
+ parentBlockHash: isPostGloasAnchor ? toRootHex(unfinalizedState.latestBlockHash) : null,
284
504
  };
285
505
 
286
506
  const parentSlot = blockHeader.slot - 1;