@lodestar/beacon-node 1.52.0-dev.53c3aab4e9 → 1.52.0-dev.643dd3c5bf

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 (372) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +63 -39
  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 +3 -1
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +2 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +19 -11
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
  17. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  18. package/lib/chain/ColumnReconstructionTracker.js +4 -0
  19. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  23. package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
  24. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  25. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  26. package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
  27. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  28. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  29. package/lib/chain/blocks/blockInput/blockInput.js +3 -1
  30. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
  32. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  33. package/lib/chain/blocks/importExecutionPayload.js +25 -5
  34. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  35. package/lib/chain/blocks/index.d.ts.map +1 -1
  36. package/lib/chain/blocks/index.js +3 -17
  37. package/lib/chain/blocks/index.js.map +1 -1
  38. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  39. package/lib/chain/blocks/verifyBlock.js +21 -17
  40. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  41. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +2 -2
  42. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -3
  44. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  45. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -5
  47. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  48. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  49. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  50. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
  51. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  52. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +2 -2
  53. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  54. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +3 -3
  55. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  56. package/lib/chain/bls/utils.js +1 -1
  57. package/lib/chain/bls/utils.js.map +1 -1
  58. package/lib/chain/chain.d.ts +6 -5
  59. package/lib/chain/chain.d.ts.map +1 -1
  60. package/lib/chain/chain.js +83 -31
  61. package/lib/chain/chain.js.map +1 -1
  62. package/lib/chain/errors/attestationError.d.ts +15 -1
  63. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  64. package/lib/chain/errors/attestationError.js +8 -0
  65. package/lib/chain/errors/attestationError.js.map +1 -1
  66. package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
  67. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  68. package/lib/chain/errors/executionPayloadBid.js +2 -1
  69. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  70. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  71. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  72. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  73. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  74. package/lib/chain/forkChoice/index.d.ts +1 -4
  75. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  76. package/lib/chain/forkChoice/index.js +1 -4
  77. package/lib/chain/forkChoice/index.js.map +1 -1
  78. package/lib/chain/forkChoiceExecutionEngine.d.ts +5 -3
  79. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
  80. package/lib/chain/forkChoiceExecutionEngine.js +34 -11
  81. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
  82. package/lib/chain/interface.d.ts +1 -1
  83. package/lib/chain/interface.d.ts.map +1 -1
  84. package/lib/chain/lightClient/index.d.ts +13 -6
  85. package/lib/chain/lightClient/index.d.ts.map +1 -1
  86. package/lib/chain/lightClient/index.js +95 -115
  87. package/lib/chain/lightClient/index.js.map +1 -1
  88. package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
  89. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
  90. package/lib/chain/opPools/inclusionListStore.js +5 -2
  91. package/lib/chain/opPools/inclusionListStore.js.map +1 -1
  92. package/lib/chain/opPools/opPool.js +6 -6
  93. package/lib/chain/opPools/opPool.js.map +1 -1
  94. package/lib/chain/options.js +2 -2
  95. package/lib/chain/options.js.map +1 -1
  96. package/lib/chain/prepareNextSlot.d.ts +45 -0
  97. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  98. package/lib/chain/prepareNextSlot.js +265 -69
  99. package/lib/chain/prepareNextSlot.js.map +1 -1
  100. package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
  101. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  102. package/lib/chain/produceBlock/produceBlockBody.js +23 -15
  103. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  104. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  105. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  106. package/lib/chain/seenCache/seenAttesters.js +1 -1
  107. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  108. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  109. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  110. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  111. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  112. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  113. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  114. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  115. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  116. package/lib/chain/shufflingCache.d.ts +5 -0
  117. package/lib/chain/shufflingCache.d.ts.map +1 -1
  118. package/lib/chain/shufflingCache.js +39 -1
  119. package/lib/chain/shufflingCache.js.map +1 -1
  120. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  121. package/lib/chain/validation/aggregateAndProof.js +37 -9
  122. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  123. package/lib/chain/validation/attestation.d.ts.map +1 -1
  124. package/lib/chain/validation/attestation.js +32 -16
  125. package/lib/chain/validation/attestation.js.map +1 -1
  126. package/lib/chain/validation/block.d.ts.map +1 -1
  127. package/lib/chain/validation/block.js +9 -1
  128. package/lib/chain/validation/block.js.map +1 -1
  129. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  130. package/lib/chain/validation/dataColumnSidecar.js +8 -1
  131. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  132. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  133. package/lib/chain/validation/executionPayloadBid.js +47 -42
  134. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  135. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  136. package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
  137. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  138. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  139. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  140. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  141. package/lib/chain/validation/voluntaryExit.js +39 -6
  142. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  143. package/lib/execution/engine/blockHash.d.ts +12 -0
  144. package/lib/execution/engine/blockHash.d.ts.map +1 -0
  145. package/lib/execution/engine/blockHash.js +17 -0
  146. package/lib/execution/engine/blockHash.js.map +1 -0
  147. package/lib/execution/engine/http.d.ts +2 -2
  148. package/lib/execution/engine/http.d.ts.map +1 -1
  149. package/lib/execution/engine/http.js +13 -7
  150. package/lib/execution/engine/http.js.map +1 -1
  151. package/lib/execution/engine/interface.d.ts +16 -3
  152. package/lib/execution/engine/interface.d.ts.map +1 -1
  153. package/lib/execution/engine/interface.js +11 -0
  154. package/lib/execution/engine/interface.js.map +1 -1
  155. package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
  156. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  157. package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
  158. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  159. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  160. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  161. package/lib/execution/engine/jsonRpcTransport.js +4 -4
  162. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  163. package/lib/execution/engine/mock.d.ts.map +1 -1
  164. package/lib/execution/engine/mock.js +6 -6
  165. package/lib/execution/engine/mock.js.map +1 -1
  166. package/lib/execution/engine/payloadIdCache.d.ts +6 -1
  167. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  168. package/lib/execution/engine/payloadIdCache.js +7 -2
  169. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  170. package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
  171. package/lib/execution/engine/restHttpClient.js +9 -5
  172. package/lib/execution/engine/restHttpClient.js.map +1 -1
  173. package/lib/execution/engine/restTransport.d.ts +2 -2
  174. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  175. package/lib/execution/engine/restTransport.js +4 -4
  176. package/lib/execution/engine/restTransport.js.map +1 -1
  177. package/lib/execution/engine/signal.d.ts +6 -0
  178. package/lib/execution/engine/signal.d.ts.map +1 -0
  179. package/lib/execution/engine/signal.js +24 -0
  180. package/lib/execution/engine/signal.js.map +1 -0
  181. package/lib/execution/engine/transport.d.ts +2 -2
  182. package/lib/execution/engine/transport.d.ts.map +1 -1
  183. package/lib/index.d.ts +1 -1
  184. package/lib/index.d.ts.map +1 -1
  185. package/lib/index.js +1 -1
  186. package/lib/index.js.map +1 -1
  187. package/lib/metrics/metrics/beacon.d.ts +9 -0
  188. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  189. package/lib/metrics/metrics/beacon.js +16 -2
  190. package/lib/metrics/metrics/beacon.js.map +1 -1
  191. package/lib/metrics/metrics/lodestar.d.ts +3 -0
  192. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  193. package/lib/metrics/metrics/lodestar.js +42 -28
  194. package/lib/metrics/metrics/lodestar.js.map +1 -1
  195. package/lib/network/core/events.d.ts +6 -2
  196. package/lib/network/core/events.d.ts.map +1 -1
  197. package/lib/network/core/events.js +9 -0
  198. package/lib/network/core/events.js.map +1 -1
  199. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  200. package/lib/network/core/networkCoreWorkerHandler.js +3 -2
  201. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  202. package/lib/network/gossip/gossipsub.d.ts +1 -0
  203. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  204. package/lib/network/gossip/gossipsub.js +5 -2
  205. package/lib/network/gossip/gossipsub.js.map +1 -1
  206. package/lib/network/gossip/topic.d.ts +1 -7
  207. package/lib/network/gossip/topic.d.ts.map +1 -1
  208. package/lib/network/gossip/topic.js +0 -13
  209. package/lib/network/gossip/topic.js.map +1 -1
  210. package/lib/network/network.d.ts +1 -0
  211. package/lib/network/network.d.ts.map +1 -1
  212. package/lib/network/network.js +26 -12
  213. package/lib/network/network.js.map +1 -1
  214. package/lib/network/peers/peerManager.d.ts.map +1 -1
  215. package/lib/network/peers/peerManager.js +22 -2
  216. package/lib/network/peers/peerManager.js.map +1 -1
  217. package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
  218. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  219. package/lib/network/peers/utils/prioritizePeers.js +11 -2
  220. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  221. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  222. package/lib/network/processor/gossipHandlers.js +19 -6
  223. package/lib/network/processor/gossipHandlers.js.map +1 -1
  224. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  225. package/lib/network/processor/gossipValidatorFn.js +4 -1
  226. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  227. package/lib/network/processor/index.d.ts.map +1 -1
  228. package/lib/network/processor/index.js +4 -2
  229. package/lib/network/processor/index.js.map +1 -1
  230. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
  231. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  232. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  233. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  234. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  235. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  236. package/lib/network/reqresp/utils/collect.js +9 -8
  237. package/lib/network/reqresp/utils/collect.js.map +1 -1
  238. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  239. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  240. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  241. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  242. package/lib/sync/range/batch.d.ts +10 -0
  243. package/lib/sync/range/batch.d.ts.map +1 -1
  244. package/lib/sync/range/batch.js +29 -0
  245. package/lib/sync/range/batch.js.map +1 -1
  246. package/lib/sync/range/chain.d.ts +17 -2
  247. package/lib/sync/range/chain.d.ts.map +1 -1
  248. package/lib/sync/range/chain.js +60 -20
  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 +44 -3
  252. package/lib/sync/range/range.js.map +1 -1
  253. package/lib/sync/range/utils/batches.d.ts +20 -4
  254. package/lib/sync/range/utils/batches.d.ts.map +1 -1
  255. package/lib/sync/range/utils/batches.js +31 -13
  256. package/lib/sync/range/utils/batches.js.map +1 -1
  257. package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
  258. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
  259. package/lib/sync/range/utils/peerBalancer.js +5 -2
  260. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  261. package/lib/sync/types.d.ts +14 -1
  262. package/lib/sync/types.d.ts.map +1 -1
  263. package/lib/sync/types.js +2 -0
  264. package/lib/sync/types.js.map +1 -1
  265. package/lib/sync/unknownBlock.d.ts +28 -1
  266. package/lib/sync/unknownBlock.d.ts.map +1 -1
  267. package/lib/sync/unknownBlock.js +340 -27
  268. package/lib/sync/unknownBlock.js.map +1 -1
  269. package/lib/sync/utils/downloadByRange.d.ts +22 -1
  270. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  271. package/lib/sync/utils/downloadByRange.js +55 -25
  272. package/lib/sync/utils/downloadByRange.js.map +1 -1
  273. package/lib/sync/utils/downloadByRoot.d.ts +24 -2
  274. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  275. package/lib/sync/utils/downloadByRoot.js +48 -5
  276. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  277. package/lib/util/asyncIterableToEvents.d.ts +20 -3
  278. package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
  279. package/lib/util/asyncIterableToEvents.js +76 -20
  280. package/lib/util/asyncIterableToEvents.js.map +1 -1
  281. package/lib/util/dataColumns.d.ts +1 -1
  282. package/lib/util/dataColumns.d.ts.map +1 -1
  283. package/lib/util/dataColumns.js +4 -1
  284. package/lib/util/dataColumns.js.map +1 -1
  285. package/lib/util/eventLoop.d.ts +3 -3
  286. package/lib/util/eventLoop.d.ts.map +1 -1
  287. package/lib/util/eventLoop.js +3 -3
  288. package/lib/util/eventLoop.js.map +1 -1
  289. package/package.json +27 -27
  290. package/src/api/impl/beacon/blocks/index.ts +74 -47
  291. package/src/api/impl/beacon/pool/index.ts +9 -7
  292. package/src/api/impl/beacon/state/utils.ts +2 -1
  293. package/src/api/impl/debug/index.ts +6 -2
  294. package/src/api/impl/validator/index.ts +21 -11
  295. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  296. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  297. package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
  298. package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
  299. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  300. package/src/chain/blocks/importExecutionPayload.ts +30 -4
  301. package/src/chain/blocks/index.ts +3 -31
  302. package/src/chain/blocks/verifyBlock.ts +24 -17
  303. package/src/chain/blocks/verifyBlocksDataAvailability.ts +4 -4
  304. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +7 -4
  305. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
  306. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +5 -4
  307. package/src/chain/bls/utils.ts +1 -1
  308. package/src/chain/chain.ts +116 -48
  309. package/src/chain/errors/attestationError.ts +11 -1
  310. package/src/chain/errors/executionPayloadBid.ts +9 -2
  311. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  312. package/src/chain/forkChoice/index.ts +1 -4
  313. package/src/chain/forkChoiceExecutionEngine.ts +48 -15
  314. package/src/chain/interface.ts +1 -1
  315. package/src/chain/lightClient/index.ts +108 -142
  316. package/src/chain/opPools/inclusionListStore.ts +5 -2
  317. package/src/chain/opPools/opPool.ts +6 -6
  318. package/src/chain/options.ts +2 -2
  319. package/src/chain/prepareNextSlot.ts +347 -89
  320. package/src/chain/produceBlock/produceBlockBody.ts +25 -16
  321. package/src/chain/seenCache/seenAttesters.ts +1 -1
  322. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  323. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  324. package/src/chain/shufflingCache.ts +40 -1
  325. package/src/chain/validation/aggregateAndProof.ts +43 -14
  326. package/src/chain/validation/attestation.ts +31 -20
  327. package/src/chain/validation/block.ts +9 -1
  328. package/src/chain/validation/dataColumnSidecar.ts +7 -1
  329. package/src/chain/validation/executionPayloadBid.ts +60 -44
  330. package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
  331. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  332. package/src/chain/validation/voluntaryExit.ts +44 -6
  333. package/src/execution/engine/blockHash.ts +27 -0
  334. package/src/execution/engine/http.ts +18 -10
  335. package/src/execution/engine/interface.ts +18 -3
  336. package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
  337. package/src/execution/engine/jsonRpcTransport.ts +8 -4
  338. package/src/execution/engine/mock.ts +13 -8
  339. package/src/execution/engine/payloadIdCache.ts +12 -4
  340. package/src/execution/engine/restHttpClient.ts +17 -11
  341. package/src/execution/engine/restTransport.ts +5 -4
  342. package/src/execution/engine/signal.ts +28 -0
  343. package/src/execution/engine/transport.ts +3 -2
  344. package/src/index.ts +6 -1
  345. package/src/metrics/metrics/beacon.ts +20 -2
  346. package/src/metrics/metrics/lodestar.ts +42 -28
  347. package/src/network/core/events.ts +12 -0
  348. package/src/network/core/networkCoreWorkerHandler.ts +6 -2
  349. package/src/network/gossip/gossipsub.ts +6 -2
  350. package/src/network/gossip/topic.ts +1 -14
  351. package/src/network/network.ts +39 -13
  352. package/src/network/peers/peerManager.ts +26 -2
  353. package/src/network/peers/utils/prioritizePeers.ts +14 -1
  354. package/src/network/processor/gossipHandlers.ts +25 -13
  355. package/src/network/processor/gossipValidatorFn.ts +4 -0
  356. package/src/network/processor/index.ts +7 -2
  357. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
  358. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  359. package/src/network/reqresp/utils/collect.ts +16 -8
  360. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  361. package/src/sync/range/batch.ts +33 -0
  362. package/src/sync/range/chain.ts +72 -17
  363. package/src/sync/range/range.ts +57 -3
  364. package/src/sync/range/utils/batches.ts +38 -13
  365. package/src/sync/range/utils/peerBalancer.ts +4 -1
  366. package/src/sync/types.ts +13 -0
  367. package/src/sync/unknownBlock.ts +389 -29
  368. package/src/sync/utils/downloadByRange.ts +89 -29
  369. package/src/sync/utils/downloadByRoot.ts +75 -7
  370. package/src/util/asyncIterableToEvents.ts +100 -21
  371. package/src/util/dataColumns.ts +4 -1
  372. package/src/util/eventLoop.ts +3 -3
@@ -6,38 +6,58 @@ import {MapDef} from "@lodestar/utils";
6
6
  */
7
7
  const SLOTS_RETAINED = 2;
8
8
 
9
+ export type SeenBuilderBids = {
10
+ /** Number of valid bids seen */
11
+ count: number;
12
+ /**
13
+ * The builder's bid limit. Bids for the same slot and parent root are validated against the same state,
14
+ * so it is known without the state once a bid was valid
15
+ */
16
+ limit: number;
17
+ };
18
+
9
19
  /**
10
- * Tracks execution payload bids we've already seen per
20
+ * Counts the valid execution payload bids seen per
11
21
  * (slot, builder, parent block hash, parent block root).
12
22
  */
13
23
  export class SeenExecutionPayloadBids {
14
- private readonly branchesByBuilderBySlot = new MapDef<Slot, MapDef<BuilderIndex, Set<string>>>(
15
- () => new MapDef<BuilderIndex, Set<string>>(() => new Set<string>())
24
+ private readonly bidsByBranchByBuilderBySlot = new MapDef<Slot, MapDef<BuilderIndex, Map<string, SeenBuilderBids>>>(
25
+ () => new MapDef<BuilderIndex, Map<string, SeenBuilderBids>>(() => new Map<string, SeenBuilderBids>())
16
26
  );
17
27
  private lowestPermissibleSlot: Slot = 0;
18
28
 
19
- isKnown(slot: Slot, builderIndex: BuilderIndex, parentBlockHash: RootHex, parentBlockRoot: RootHex): boolean {
20
- return (
21
- this.branchesByBuilderBySlot.get(slot)?.get(builderIndex)?.has(branchKey(parentBlockHash, parentBlockRoot)) ===
22
- true
23
- );
29
+ get(
30
+ slot: Slot,
31
+ builderIndex: BuilderIndex,
32
+ parentBlockHash: RootHex,
33
+ parentBlockRoot: RootHex
34
+ ): SeenBuilderBids | undefined {
35
+ return this.bidsByBranchByBuilderBySlot
36
+ .get(slot)
37
+ ?.get(builderIndex)
38
+ ?.get(branchKey(parentBlockHash, parentBlockRoot));
24
39
  }
25
40
 
26
- add(slot: Slot, builderIndex: BuilderIndex, parentBlockHash: RootHex, parentBlockRoot: RootHex): void {
41
+ add(
42
+ slot: Slot,
43
+ builderIndex: BuilderIndex,
44
+ parentBlockHash: RootHex,
45
+ parentBlockRoot: RootHex,
46
+ bidLimit: number
47
+ ): void {
27
48
  if (slot < this.lowestPermissibleSlot) {
28
49
  throw Error(`slot ${slot} < lowestPermissibleSlot ${this.lowestPermissibleSlot}`);
29
50
  }
30
- this.branchesByBuilderBySlot
31
- .getOrDefault(slot)
32
- .getOrDefault(builderIndex)
33
- .add(branchKey(parentBlockHash, parentBlockRoot));
51
+ const bidsByBranch = this.bidsByBranchByBuilderBySlot.getOrDefault(slot).getOrDefault(builderIndex);
52
+ const key = branchKey(parentBlockHash, parentBlockRoot);
53
+ bidsByBranch.set(key, {count: (bidsByBranch.get(key)?.count ?? 0) + 1, limit: bidLimit});
34
54
  }
35
55
 
36
56
  prune(currentSlot: Slot): void {
37
57
  this.lowestPermissibleSlot = Math.max(currentSlot - SLOTS_RETAINED, 0);
38
- for (const slot of this.branchesByBuilderBySlot.keys()) {
58
+ for (const slot of this.bidsByBranchByBuilderBySlot.keys()) {
39
59
  if (slot < this.lowestPermissibleSlot) {
40
- this.branchesByBuilderBySlot.delete(slot);
60
+ this.bidsByBranchByBuilderBySlot.delete(slot);
41
61
  }
42
62
  }
43
63
  }
@@ -1,4 +1,5 @@
1
- import {ForkSeq, GENESIS_EPOCH} from "@lodestar/params";
1
+ import {computeCommitteePubkeys, releaseCommitteePubkeys} from "@lodestar/native/committee-pubkeys";
2
+ import {ForkSeq, GENESIS_EPOCH, SLOTS_PER_EPOCH} from "@lodestar/params";
2
3
  import {
3
4
  EpochShuffling,
4
5
  IBeaconStateView,
@@ -272,6 +273,40 @@ export class ShufflingCache {
272
273
  // set the shuffling
273
274
  shufflingAtEpoch.set(decisionRoot, {type: CacheItemType.shuffling, shuffling});
274
275
  this.prune();
276
+ if (this.has(shuffling.epoch, decisionRoot)) {
277
+ this.computeCommitteePubkeys(shuffling, decisionRoot);
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Committee pubkeys make attestation signature sets cheaper to verify. Until they resolve, and if computing them
283
+ * fails, sets aggregate the participants instead.
284
+ */
285
+ private computeCommitteePubkeys(shuffling: EpochShuffling, decisionRoot: RootHex): void {
286
+ const timer = this.metrics?.shufflingCache.committeePubkeysComputeTime.startTimer();
287
+ const onError = (e: unknown): void => {
288
+ this.metrics?.shufflingCache.committeePubkeysErrors.inc();
289
+ this.logger?.debug("Error computing committee pubkeys", {epoch: shuffling.epoch, decisionRoot}, e as Error);
290
+ };
291
+
292
+ let promise: Promise<number>;
293
+ try {
294
+ promise = computeCommitteePubkeys(shuffling.shuffling, SLOTS_PER_EPOCH, shuffling.committeesPerSlot);
295
+ } catch (e) {
296
+ onError(e);
297
+ return;
298
+ }
299
+
300
+ promise.then((id) => {
301
+ timer?.();
302
+ const cacheItem = this.itemsByDecisionRootByEpoch.get(shuffling.epoch)?.get(decisionRoot);
303
+ if (cacheItem !== undefined && isShufflingCacheItem(cacheItem) && cacheItem.shuffling === shuffling) {
304
+ shuffling.committeePubkeysId = id;
305
+ } else {
306
+ // Pruned while computing
307
+ releaseCommitteePubkeys(id);
308
+ }
309
+ }, onError);
275
310
  }
276
311
 
277
312
  /**
@@ -294,6 +329,10 @@ export class ShufflingCache {
294
329
  this.metrics?.shufflingCache.cancelledPromises.inc({reason: ShufflingPromiseCancelReason.pruned});
295
330
  } else {
296
331
  prunedShufflings++;
332
+ if (cacheItem.shuffling.committeePubkeysId !== undefined) {
333
+ releaseCommitteePubkeys(cacheItem.shuffling.committeePubkeysId);
334
+ cacheItem.shuffling.committeePubkeysId = undefined;
335
+ }
297
336
  }
298
337
  }
299
338
  this.itemsByDecisionRootByEpoch.delete(epoch);
@@ -1,5 +1,8 @@
1
+ import {ExecutionStatus, PayloadStatus} from "@lodestar/fork-choice";
1
2
  import {ForkName, ForkSeq} from "@lodestar/params";
2
3
  import {
4
+ ISignatureSet,
5
+ SignatureSetType,
3
6
  computeEpochAtSlot,
4
7
  createAggregateSignatureSetFromComponents,
5
8
  isAggregatorFromCommitteeLength,
@@ -98,15 +101,29 @@ async function validateAggregateAndProof(
98
101
  // (a client MAY queue attestations for processing until the payload is imported and SHOULD
99
102
  // request the payload envelope via `ExecutionPayloadEnvelopesByRoot` using
100
103
  // `aggregate.data.beacon_block_root`).
101
- if (
102
- block !== null &&
103
- attData.index === 1 &&
104
- !chain.forkChoice.hasPayloadHexUnsafe(toRootHex(attData.beaconBlockRoot))
105
- ) {
106
- throw new AttestationError(GossipAction.IGNORE, {
107
- code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
108
- beaconBlockRoot: toRootHex(attData.beaconBlockRoot),
109
- });
104
+ if (block !== null && attData.index === 1) {
105
+ const beaconBlockRoot = toRootHex(attData.beaconBlockRoot);
106
+ const fullBlock = chain.forkChoice.getBlockHex(beaconBlockRoot, PayloadStatus.FULL);
107
+ if (fullBlock === null) {
108
+ throw new AttestationError(GossipAction.IGNORE, {
109
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
110
+ beaconBlockRoot,
111
+ });
112
+ }
113
+ // [IGNORE] The attested execution payload is optimistic
114
+ if (fullBlock.executionStatus === ExecutionStatus.Syncing) {
115
+ throw new AttestationError(GossipAction.IGNORE, {
116
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC,
117
+ beaconBlockRoot,
118
+ });
119
+ }
120
+ // [REJECT] The attested execution payload is processed and invalid
121
+ if (fullBlock.executionStatus === ExecutionStatus.Invalid) {
122
+ throw new AttestationError(GossipAction.REJECT, {
123
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID,
124
+ beaconBlockRoot,
125
+ });
126
+ }
110
127
  }
111
128
 
112
129
  // [REJECT] len(committee_indices) == 1, where committee_indices = get_committee_indices(aggregate)
@@ -259,11 +276,23 @@ async function validateAggregateAndProof(
259
276
  // [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
260
277
  // [REJECT] The signature of aggregate is valid.
261
278
  const signingRoot = cachedAttData ? cachedAttData.signingRoot : getAttestationDataSigningRoot(chain.config, attData);
262
- const indexedAttestationSignatureSet = createAggregateSignatureSetFromComponents(
263
- indexedAttestation.attestingIndices,
264
- signingRoot,
265
- indexedAttestation.signature
266
- );
279
+ const indexedAttestationSignatureSet: ISignatureSet =
280
+ shuffling.committeePubkeysId === undefined
281
+ ? createAggregateSignatureSetFromComponents(
282
+ indexedAttestation.attestingIndices,
283
+ signingRoot,
284
+ indexedAttestation.signature
285
+ )
286
+ : {
287
+ type: SignatureSetType.committee,
288
+ indices: indexedAttestation.attestingIndices,
289
+ committeePubkeysId: shuffling.committeePubkeysId,
290
+ slot: attSlot,
291
+ committeeIndices: [committeeIndex],
292
+ aggregationBits: aggregate.aggregationBits,
293
+ signingRoot,
294
+ signature: indexedAttestation.signature,
295
+ };
267
296
  const signatureSets = [
268
297
  getSelectionProofSignatureSet(chain.config, attSlot, aggregatorIndex, signedAggregateAndProof),
269
298
  getAggregateAndProofSignatureSet(chain.config, attEpoch, aggregatorIndex, signedAggregateAndProof),
@@ -1,6 +1,6 @@
1
1
  import {BitArray} from "@chainsafe/ssz";
2
2
  import {BeaconConfig} from "@lodestar/config";
3
- import {ProtoBlock} from "@lodestar/fork-choice";
3
+ import {ExecutionStatus, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
4
4
  import {
5
5
  ATTESTATION_SUBNET_COUNT,
6
6
  DOMAIN_BEACON_ATTESTER,
@@ -309,25 +309,6 @@ async function validateAttestationNoSignatureCheck(
309
309
  code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT,
310
310
  });
311
311
  }
312
-
313
- // [REJECT] If `attestation.data.index == 1` (payload present for a past block),
314
- // the execution payload for `block` passes validation.
315
- // [IGNORE] When `attestation.data.index == 1` (payload present for a past block),
316
- // the execution payload for `block` has been fully imported, including its data -- i.e.
317
- // `is_payload_verified(store, attestation.data.beacon_block_root)` returns `True`
318
- // (a client MAY queue attestations for processing until the payload is imported and
319
- // SHOULD request the payload envelope via `ExecutionPayloadEnvelopesByRoot` using
320
- // `attestation.data.beacon_block_root`).
321
- if (
322
- block !== null &&
323
- attData.index === 1 &&
324
- !chain.forkChoice.hasPayloadHexUnsafe(toRootHex(attData.beaconBlockRoot))
325
- ) {
326
- throw new AttestationError(GossipAction.IGNORE, {
327
- code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
328
- beaconBlockRoot: toRootHex(attData.beaconBlockRoot),
329
- });
330
- }
331
312
  } else {
332
313
  // [REJECT] attestation.data.index == 0
333
314
  if (attData.index !== 0) {
@@ -343,6 +324,36 @@ async function validateAttestationNoSignatureCheck(
343
324
  committeeIndex = attestationOrCache.cache.committeeIndex;
344
325
  }
345
326
 
327
+ // The payload status can change after the attestation data was cached, so this runs for cached data too
328
+ if (isForkPostGloas(fork) && attData.index === 1) {
329
+ const beaconBlockRoot = toRootHex(attData.beaconBlockRoot);
330
+ const fullBlock = chain.forkChoice.getBlockHex(beaconBlockRoot, PayloadStatus.FULL);
331
+ // [IGNORE] The corresponding execution payload envelope has been seen and verified
332
+ // (a client MAY queue attestations for processing until the payload is imported and
333
+ // SHOULD request the payload envelope via `ExecutionPayloadEnvelopesByRoot`).
334
+ // An unknown block is handled by `verifyHeadBlockAndTargetRoot`
335
+ if (fullBlock === null) {
336
+ if (chain.forkChoice.hasBlockHexUnsafe(beaconBlockRoot)) {
337
+ throw new AttestationError(GossipAction.IGNORE, {
338
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
339
+ beaconBlockRoot,
340
+ });
341
+ }
342
+ } else if (fullBlock.executionStatus === ExecutionStatus.Syncing) {
343
+ // [IGNORE] The attested execution payload is optimistic
344
+ throw new AttestationError(GossipAction.IGNORE, {
345
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC,
346
+ beaconBlockRoot,
347
+ });
348
+ } else if (fullBlock.executionStatus === ExecutionStatus.Invalid) {
349
+ // [REJECT] The attested execution payload is processed and invalid
350
+ throw new AttestationError(GossipAction.REJECT, {
351
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID,
352
+ beaconBlockRoot,
353
+ });
354
+ }
355
+ }
356
+
346
357
  chain.metrics?.gossipAttestation.attestationSlotToClockSlot.observe(
347
358
  {caller: RegenCaller.validateGossipAttestation},
348
359
  chain.clock.currentSlot - attSlot
@@ -121,13 +121,21 @@ export async function validateGossipBlock(
121
121
  // (via gossip or non-gossip sources) (a client MAY queue blocks for processing once the parent payload is retrieved).
122
122
  if (isGloasBeaconBlock(block)) {
123
123
  const parentBlockHashHex = toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash);
124
- if (chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex) === null) {
124
+ const parentPayloadBlock = chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex);
125
+ if (parentPayloadBlock === null) {
125
126
  throw new BlockGossipError(GossipAction.IGNORE, {
126
127
  code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
127
128
  parentRoot,
128
129
  parentBlockHash: parentBlockHashHex,
129
130
  });
130
131
  }
132
+ // [IGNORE] The block's parent passed validation but the payload it builds on is invalid
133
+ if (parentPayloadBlock.executionStatus === ExecutionStatus.Invalid) {
134
+ throw new BlockGossipError(GossipAction.IGNORE, {
135
+ code: BlockErrorCode.PARENT_EXECUTION_INVALID,
136
+ parentRoot,
137
+ });
138
+ }
131
139
  }
132
140
 
133
141
  // [REJECT] The block is from a higher slot than its parent.
@@ -152,12 +152,15 @@ export async function validateGossipFuluDataColumnSidecar(
152
152
 
153
153
  // 5) [REJECT] The proposer signature of sidecar.signed_block_header, is valid with respect to the block_header.proposer_index pubkey.
154
154
  const signature = dataColumnSidecar.signedBlockHeader.signature;
155
- if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
155
+ if (chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
156
+ metrics?.peerDas.dataColumnSidecarProposerSignatureChecks.inc({result: "cache_hit"});
157
+ } else {
156
158
  const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(
157
159
  chain.config,
158
160
  dataColumnSidecar.signedBlockHeader
159
161
  );
160
162
 
163
+ metrics?.peerDas.dataColumnSidecarProposerSignatureChecks.inc({result: "verification"});
161
164
  if (
162
165
  !(await chain.bls.verifySignatureSets([signatureSet], {
163
166
  // verify on main thread so that we only need to verify block proposer signature once per block
@@ -172,6 +175,9 @@ export async function validateGossipFuluDataColumnSidecar(
172
175
  });
173
176
  }
174
177
 
178
+ if (metrics && !chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
179
+ metrics.peerDas.dataColumnSidecarProposerSignatureBlocks.inc();
180
+ }
175
181
  chain.seenBlockInputCache.markVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature);
176
182
  }
177
183
 
@@ -16,38 +16,12 @@ import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction} fr
16
16
  import {IBeaconChain} from "../index.js";
17
17
  import {RegenCaller} from "../regen/index.js";
18
18
 
19
- /**
20
- * Relative increment over the current highest bid required to forward a bid, in basis points.
21
- * With 3%, laddering from 1 gwei to 1 ETH takes ~256 bids given the floor and cap below, see
22
- * https://github.com/ethereum/consensus-specs/pull/4792#issuecomment-3714553549.
23
- */
24
- const BID_INCREMENT_BPS = 300;
25
- /**
26
- * Minimum absolute increment (0.0001 ETH). Covers low bid values where the relative increment
27
- * is tiny and provides weak spam protection.
28
- */
29
- const BID_INCREMENT_FLOOR_GWEI = 100_000;
30
- /**
31
- * Maximum absolute increment (0.01 ETH). Bounds the barrier for legitimate competition on
32
- * high value blocks where the relative increment would suppress closely competing bids.
33
- */
34
- const BID_INCREMENT_CAP_GWEI = 10_000_000;
35
-
36
- /**
37
- * Return the minimum value a new bid must have to be forwarded given the current highest bid.
38
- * Division before multiplication to stay within safe integer range for max gwei values.
39
- */
40
- function getMinBidValue(currentHighestBid: number): number {
41
- const relativeIncrement = Math.floor(currentHighestBid / 10_000) * BID_INCREMENT_BPS;
42
- const increment = Math.min(Math.max(BID_INCREMENT_FLOOR_GWEI, relativeIncrement), BID_INCREMENT_CAP_GWEI);
43
- return currentHighestBid + increment;
44
- }
45
-
46
19
  /**
47
20
  * Check whether a bid builds on one of the paths compatible with the local head branch.
48
21
  *
49
- * Building directly on the parent is allowed for proposer-boost reorgs, including at epoch
50
- * boundaries when the head is weak enough that a reorg onto the strong parent is predicted.
22
+ * Building directly on the parent is allowed for the slot after the head if the head was late or
23
+ * its proposer equivocated, the conditions under which a proposer may re-org the head. At epoch
24
+ * boundaries the parent must also be the predicted proposer head.
51
25
  * Otherwise the bid must build on the local head's full or empty payload variant, as selected for its slot.
52
26
  */
53
27
  function isBidCompatibleWithHead(
@@ -61,6 +35,11 @@ function isBidCompatibleWithHead(
61
35
  const buildsOnParentPayload = bidParentBlockHash === head.parentBlockHash;
62
36
 
63
37
  if (buildsOnParentBlock && buildsOnParentPayload) {
38
+ const bidSlotOk = head.slot + 1 === bidSlot;
39
+ const headLate = !head.timeliness;
40
+ if (!bidSlotOk || !(headLate || chain.forkChoice.isProposerEquivocation(head))) {
41
+ return false;
42
+ }
64
43
  if (!isStartSlotOfEpoch(bidSlot)) {
65
44
  return true;
66
45
  }
@@ -141,6 +120,18 @@ async function validateExecutionPayloadBid(
141
120
  });
142
121
  }
143
122
 
123
+ // [IGNORE] The bid is received after the payload attestation deadline of `bid.slot - 1`
124
+ if (
125
+ chain.clock.msFromSlot(bid.slot - 1) <
126
+ chain.config.getPayloadAttestationDueMs(chain.config.getForkName(bid.slot - 1))
127
+ ) {
128
+ throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
129
+ code: ExecutionPayloadBidErrorCode.BEFORE_PAYLOAD_ATTESTATION_DEADLINE,
130
+ builderIndex: bid.builderIndex,
131
+ slot: bid.slot,
132
+ });
133
+ }
134
+
144
135
  // [IGNORE] The bid is received after the inclusion list deadline of `bid.slot - 1`
145
136
  if (
146
137
  isForkPostHeze(chain.config.getForkName(bid.slot)) &&
@@ -165,27 +156,30 @@ async function validateExecutionPayloadBid(
165
156
  });
166
157
  }
167
158
 
168
- // [IGNORE] this is the first signed bid seen with a valid signature from the given builder for
169
- // the tuple `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
170
- // Entries are only added after signature verification, so known tuples can be dropped before
171
- // state regeneration and the other expensive validation steps.
172
- if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)) {
159
+ // [IGNORE] The builder has not reached its bid limit, checked against the limit of its last valid bid.
160
+ // Bids for the same slot and parent root are validated against the same state, so bids past the
161
+ // limit can be dropped before state regeneration and the other expensive validation steps.
162
+ const seenBids = chain.seenExecutionPayloadBids.get(
163
+ bid.slot,
164
+ bid.builderIndex,
165
+ bidParentBlockHash,
166
+ bidParentBlockRoot
167
+ );
168
+ if (seenBids !== undefined && seenBids.count >= seenBids.limit) {
173
169
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
174
- code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN,
170
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
175
171
  builderIndex: bid.builderIndex,
176
172
  slot: bid.slot,
177
173
  parentBlockRoot: bidParentBlockRoot,
178
174
  parentBlockHash: bidParentBlockHash,
175
+ bidLimit: seenBids.limit,
179
176
  });
180
177
  }
181
178
 
182
179
  // [IGNORE] this bid is the highest value bid seen for the tuple
183
180
  // `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
184
- // As a DoS prevention measure, the bid must also exceed the current highest bid by a minimum
185
- // increment, see https://github.com/ethereum/consensus-specs/pull/4831. This prevents spam
186
- // from builders submitting numerous bids with minimal value increments.
187
181
  const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, bidParentBlockHash, bidParentBlockRoot);
188
- if (bestBid !== null && bid.value < getMinBidValue(bestBid.signedBid.message.value)) {
182
+ if (bestBid !== null && bid.value <= bestBid.signedBid.message.value) {
189
183
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
190
184
  code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
191
185
  bidValue: bid.value,
@@ -366,6 +360,24 @@ async function validateExecutionPayloadBid(
366
360
  });
367
361
  }
368
362
 
363
+ // [IGNORE] The builder has not reached its bid limit for the tuple
364
+ // `(bid.slot, bid.parent_block_hash, bid.parent_block_root)` -- i.e. one bid per ETH of builder balance
365
+ // not owed in pending withdrawals, `get_builder_bid_limit(state, bid.builder_index)`.
366
+ const bidLimit = state.getBuilderBidLimit(bid.builderIndex);
367
+ if (
368
+ (chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
369
+ 0) >= bidLimit
370
+ ) {
371
+ throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
372
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
373
+ builderIndex: bid.builderIndex,
374
+ slot: bid.slot,
375
+ parentBlockRoot: bidParentBlockRoot,
376
+ parentBlockHash: bidParentBlockHash,
377
+ bidLimit,
378
+ });
379
+ }
380
+
369
381
  // [IGNORE] `bid.value` is less or equal than the builder's excess balance --
370
382
  // i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
371
383
  if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
@@ -426,20 +438,24 @@ async function validateExecutionPayloadBid(
426
438
  });
427
439
  }
428
440
 
429
- // Repeat the seen check after the awaited signature verification to prevent concurrent bids
430
- // for the same builder and tuple from both passing validation.
431
- if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)) {
441
+ // Repeat the bid limit check after the awaited signature verification to prevent concurrent bids
442
+ // for the same builder and tuple from all passing validation.
443
+ if (
444
+ (chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
445
+ 0) >= bidLimit
446
+ ) {
432
447
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
433
- code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN,
448
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
434
449
  builderIndex: bid.builderIndex,
435
450
  slot: bid.slot,
436
451
  parentBlockRoot: bidParentBlockRoot,
437
452
  parentBlockHash: bidParentBlockHash,
453
+ bidLimit,
438
454
  });
439
455
  }
440
456
 
441
457
  // Valid
442
- chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot);
458
+ chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot, bidLimit);
443
459
 
444
460
  return {proposerIndex: proposerPreferences.message.validatorIndex};
445
461
  }