@lodestar/beacon-node 1.49.0-dev.07c3496aff → 1.49.0-dev.0a27fd270f

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 (303) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +15 -6
  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 +4 -2
  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 +28 -0
  9. package/lib/api/impl/beacon/state/index.js.map +1 -1
  10. package/lib/api/impl/validator/index.d.ts.map +1 -1
  11. package/lib/api/impl/validator/index.js +9 -7
  12. package/lib/api/impl/validator/index.js.map +1 -1
  13. package/lib/chain/archiveStore/archiveStore.d.ts +1 -2
  14. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  15. package/lib/chain/archiveStore/archiveStore.js +23 -7
  16. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  17. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  18. package/lib/chain/archiveStore/historicalState/metrics.js +5 -6
  19. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  20. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +11 -2
  21. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  22. package/lib/chain/archiveStore/utils/archiveBlocks.js +46 -28
  23. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  24. package/lib/chain/archiveStore/utils/pruneHistory.d.ts +2 -2
  25. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  26. package/lib/chain/archiveStore/utils/pruneHistory.js +15 -3
  27. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  28. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.js +13 -0
  30. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  31. package/lib/chain/blocks/index.js +2 -2
  32. package/lib/chain/blocks/index.js.map +1 -1
  33. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -1
  34. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  35. package/lib/chain/chain.d.ts +10 -0
  36. package/lib/chain/chain.d.ts.map +1 -1
  37. package/lib/chain/chain.js +85 -16
  38. package/lib/chain/chain.js.map +1 -1
  39. package/lib/chain/emitter.d.ts +10 -0
  40. package/lib/chain/emitter.d.ts.map +1 -1
  41. package/lib/chain/emitter.js +4 -0
  42. package/lib/chain/emitter.js.map +1 -1
  43. package/lib/chain/errors/attesterSlashingError.d.ts +4 -1
  44. package/lib/chain/errors/attesterSlashingError.d.ts.map +1 -1
  45. package/lib/chain/errors/attesterSlashingError.js +1 -0
  46. package/lib/chain/errors/attesterSlashingError.js.map +1 -1
  47. package/lib/chain/errors/envelopeReconstructionError.d.ts +23 -0
  48. package/lib/chain/errors/envelopeReconstructionError.d.ts.map +1 -0
  49. package/lib/chain/errors/envelopeReconstructionError.js +13 -0
  50. package/lib/chain/errors/envelopeReconstructionError.js.map +1 -0
  51. package/lib/chain/errors/index.d.ts +1 -0
  52. package/lib/chain/errors/index.d.ts.map +1 -1
  53. package/lib/chain/errors/index.js +1 -0
  54. package/lib/chain/errors/index.js.map +1 -1
  55. package/lib/chain/errors/payloadAttestation.d.ts +4 -0
  56. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -1
  57. package/lib/chain/errors/payloadAttestation.js +1 -0
  58. package/lib/chain/errors/payloadAttestation.js.map +1 -1
  59. package/lib/chain/errors/proposerSlashingError.d.ts +4 -1
  60. package/lib/chain/errors/proposerSlashingError.d.ts.map +1 -1
  61. package/lib/chain/errors/proposerSlashingError.js +1 -0
  62. package/lib/chain/errors/proposerSlashingError.js.map +1 -1
  63. package/lib/chain/interface.d.ts +6 -1
  64. package/lib/chain/interface.d.ts.map +1 -1
  65. package/lib/chain/interface.js.map +1 -1
  66. package/lib/chain/options.d.ts +2 -4
  67. package/lib/chain/options.d.ts.map +1 -1
  68. package/lib/chain/options.js +1 -1
  69. package/lib/chain/options.js.map +1 -1
  70. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  71. package/lib/chain/produceBlock/computeNewStateRoot.js +4 -2
  72. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  73. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  74. package/lib/chain/produceBlock/produceBlockBody.js +6 -6
  75. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  76. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +2 -1
  77. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  78. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +3 -2
  79. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  80. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  81. package/lib/chain/validation/attesterSlashing.js +1 -2
  82. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  83. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  84. package/lib/chain/validation/payloadAttestationMessage.js +8 -1
  85. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  86. package/lib/chain/validation/proposerSlashing.js +1 -2
  87. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  88. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  89. package/lib/chain/validatorMonitor.js +2 -2
  90. package/lib/chain/validatorMonitor.js.map +1 -1
  91. package/lib/db/beacon.d.ts +1 -2
  92. package/lib/db/beacon.d.ts.map +1 -1
  93. package/lib/db/beacon.js +1 -3
  94. package/lib/db/beacon.js.map +1 -1
  95. package/lib/db/buckets.d.ts +0 -1
  96. package/lib/db/buckets.d.ts.map +1 -1
  97. package/lib/db/buckets.js +1 -1
  98. package/lib/db/buckets.js.map +1 -1
  99. package/lib/db/interface.d.ts +1 -2
  100. package/lib/db/interface.d.ts.map +1 -1
  101. package/lib/db/repositories/blockArchive.d.ts +5 -0
  102. package/lib/db/repositories/blockArchive.d.ts.map +1 -1
  103. package/lib/db/repositories/blockArchive.js +36 -1
  104. package/lib/db/repositories/blockArchive.js.map +1 -1
  105. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  106. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  107. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts +21 -9
  108. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts.map +1 -1
  109. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +32 -12
  110. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  111. package/lib/db/repositories/index.d.ts +1 -2
  112. package/lib/db/repositories/index.d.ts.map +1 -1
  113. package/lib/db/repositories/index.js +1 -2
  114. package/lib/db/repositories/index.js.map +1 -1
  115. package/lib/execution/engine/disabled.d.ts +1 -0
  116. package/lib/execution/engine/disabled.d.ts.map +1 -1
  117. package/lib/execution/engine/disabled.js +3 -0
  118. package/lib/execution/engine/disabled.js.map +1 -1
  119. package/lib/execution/engine/http.d.ts +2 -1
  120. package/lib/execution/engine/http.d.ts.map +1 -1
  121. package/lib/execution/engine/http.js +7 -1
  122. package/lib/execution/engine/http.js.map +1 -1
  123. package/lib/execution/engine/interface.d.ts +3 -1
  124. package/lib/execution/engine/interface.d.ts.map +1 -1
  125. package/lib/execution/engine/mock.d.ts +1 -0
  126. package/lib/execution/engine/mock.d.ts.map +1 -1
  127. package/lib/execution/engine/mock.js +14 -2
  128. package/lib/execution/engine/mock.js.map +1 -1
  129. package/lib/execution/engine/types.d.ts +11 -0
  130. package/lib/execution/engine/types.d.ts.map +1 -1
  131. package/lib/execution/engine/types.js +10 -0
  132. package/lib/execution/engine/types.js.map +1 -1
  133. package/lib/metrics/metrics/beacon.d.ts +9 -0
  134. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  135. package/lib/metrics/metrics/beacon.js +16 -0
  136. package/lib/metrics/metrics/beacon.js.map +1 -1
  137. package/lib/metrics/metrics/lodestar.d.ts +35 -14
  138. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  139. package/lib/metrics/metrics/lodestar.js +76 -24
  140. package/lib/metrics/metrics/lodestar.js.map +1 -1
  141. package/lib/metrics/metrics.d.ts +3 -1
  142. package/lib/metrics/metrics.d.ts.map +1 -1
  143. package/lib/metrics/metrics.js +2 -2
  144. package/lib/metrics/metrics.js.map +1 -1
  145. package/lib/network/gossip/encoding.d.ts +1 -2
  146. package/lib/network/gossip/encoding.d.ts.map +1 -1
  147. package/lib/network/gossip/encoding.js +5 -10
  148. package/lib/network/gossip/encoding.js.map +1 -1
  149. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  150. package/lib/network/gossip/gossipsub.js +16 -1
  151. package/lib/network/gossip/gossipsub.js.map +1 -1
  152. package/lib/network/gossip/topic.d.ts +9 -6
  153. package/lib/network/gossip/topic.d.ts.map +1 -1
  154. package/lib/network/gossip/topic.js +23 -8
  155. package/lib/network/gossip/topic.js.map +1 -1
  156. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  157. package/lib/network/processor/gossipHandlers.js +16 -5
  158. package/lib/network/processor/gossipHandlers.js.map +1 -1
  159. package/lib/network/processor/gossipValidatorFn.d.ts +2 -0
  160. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  161. package/lib/network/processor/gossipValidatorFn.js +88 -7
  162. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  163. package/lib/network/processor/index.d.ts +6 -2
  164. package/lib/network/processor/index.d.ts.map +1 -1
  165. package/lib/network/processor/index.js +62 -24
  166. package/lib/network/processor/index.js.map +1 -1
  167. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  168. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +47 -34
  169. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  170. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
  171. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +23 -4
  172. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  173. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  174. package/lib/network/reqresp/handlers/index.js +20 -4
  175. package/lib/network/reqresp/handlers/index.js.map +1 -1
  176. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  177. package/lib/network/reqresp/protocols.js +19 -5
  178. package/lib/network/reqresp/protocols.js.map +1 -1
  179. package/lib/node/nodejs.d.ts +2 -7
  180. package/lib/node/nodejs.d.ts.map +1 -1
  181. package/lib/node/nodejs.js +2 -22
  182. package/lib/node/nodejs.js.map +1 -1
  183. package/lib/sync/interface.d.ts +1 -2
  184. package/lib/sync/interface.d.ts.map +1 -1
  185. package/lib/sync/options.d.ts +0 -6
  186. package/lib/sync/options.d.ts.map +1 -1
  187. package/lib/sync/options.js +0 -2
  188. package/lib/sync/options.js.map +1 -1
  189. package/lib/sync/types.d.ts +39 -2
  190. package/lib/sync/types.d.ts.map +1 -1
  191. package/lib/sync/types.js +42 -2
  192. package/lib/sync/types.js.map +1 -1
  193. package/lib/sync/unknownBlock.d.ts +20 -0
  194. package/lib/sync/unknownBlock.d.ts.map +1 -1
  195. package/lib/sync/unknownBlock.js +231 -26
  196. package/lib/sync/unknownBlock.js.map +1 -1
  197. package/lib/util/execution.d.ts +42 -0
  198. package/lib/util/execution.d.ts.map +1 -1
  199. package/lib/util/execution.js +123 -2
  200. package/lib/util/execution.js.map +1 -1
  201. package/lib/util/headerEnvelope.d.ts +17 -0
  202. package/lib/util/headerEnvelope.d.ts.map +1 -0
  203. package/lib/util/headerEnvelope.js +43 -0
  204. package/lib/util/headerEnvelope.js.map +1 -0
  205. package/lib/util/shuffle.d.ts +0 -4
  206. package/lib/util/shuffle.d.ts.map +1 -1
  207. package/lib/util/shuffle.js +0 -8
  208. package/lib/util/shuffle.js.map +1 -1
  209. package/lib/util/sszBytes.d.ts +5 -0
  210. package/lib/util/sszBytes.d.ts.map +1 -1
  211. package/lib/util/sszBytes.js +13 -1
  212. package/lib/util/sszBytes.js.map +1 -1
  213. package/package.json +16 -16
  214. package/src/api/impl/beacon/blocks/index.ts +18 -5
  215. package/src/api/impl/beacon/pool/index.ts +6 -2
  216. package/src/api/impl/beacon/state/index.ts +36 -0
  217. package/src/api/impl/validator/index.ts +9 -7
  218. package/src/chain/archiveStore/archiveStore.ts +24 -8
  219. package/src/chain/archiveStore/historicalState/metrics.ts +5 -7
  220. package/src/chain/archiveStore/utils/archiveBlocks.ts +54 -32
  221. package/src/chain/archiveStore/utils/pruneHistory.ts +18 -6
  222. package/src/chain/blocks/importExecutionPayload.ts +14 -0
  223. package/src/chain/blocks/index.ts +2 -2
  224. package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -1
  225. package/src/chain/chain.ts +96 -20
  226. package/src/chain/emitter.ts +7 -2
  227. package/src/chain/errors/attesterSlashingError.ts +3 -1
  228. package/src/chain/errors/envelopeReconstructionError.ts +22 -0
  229. package/src/chain/errors/index.ts +1 -0
  230. package/src/chain/errors/payloadAttestation.ts +2 -0
  231. package/src/chain/errors/proposerSlashingError.ts +3 -1
  232. package/src/chain/interface.ts +6 -1
  233. package/src/chain/options.ts +3 -5
  234. package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
  235. package/src/chain/produceBlock/produceBlockBody.ts +17 -6
  236. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +3 -2
  237. package/src/chain/validation/attesterSlashing.ts +1 -2
  238. package/src/chain/validation/payloadAttestationMessage.ts +9 -0
  239. package/src/chain/validation/proposerSlashing.ts +1 -2
  240. package/src/chain/validatorMonitor.ts +12 -2
  241. package/src/db/beacon.ts +0 -5
  242. package/src/db/buckets.ts +2 -2
  243. package/src/db/interface.ts +0 -3
  244. package/src/db/repositories/blockArchive.ts +38 -1
  245. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +43 -13
  246. package/src/db/repositories/index.ts +6 -2
  247. package/src/execution/engine/disabled.ts +4 -0
  248. package/src/execution/engine/http.ts +12 -0
  249. package/src/execution/engine/interface.ts +4 -1
  250. package/src/execution/engine/mock.ts +22 -2
  251. package/src/execution/engine/types.ts +25 -0
  252. package/src/metrics/metrics/beacon.ts +16 -0
  253. package/src/metrics/metrics/lodestar.ts +87 -28
  254. package/src/metrics/metrics.ts +7 -2
  255. package/src/network/gossip/encoding.ts +5 -8
  256. package/src/network/gossip/gossipsub.ts +19 -2
  257. package/src/network/gossip/topic.ts +25 -7
  258. package/src/network/processor/gossipHandlers.ts +18 -5
  259. package/src/network/processor/gossipValidatorFn.ts +111 -7
  260. package/src/network/processor/index.ts +81 -24
  261. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +57 -39
  262. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +27 -5
  263. package/src/network/reqresp/handlers/index.ts +49 -5
  264. package/src/network/reqresp/protocols.ts +31 -6
  265. package/src/node/nodejs.ts +0 -27
  266. package/src/sync/interface.ts +1 -2
  267. package/src/sync/options.ts +0 -8
  268. package/src/sync/types.ts +44 -5
  269. package/src/sync/unknownBlock.ts +254 -26
  270. package/src/util/execution.ts +175 -2
  271. package/src/util/headerEnvelope.ts +76 -0
  272. package/src/util/shuffle.ts +0 -9
  273. package/src/util/sszBytes.ts +18 -0
  274. package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts +0 -20
  275. package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts.map +0 -1
  276. package/lib/chain/archiveStore/utils/updateBackfillRange.js +0 -40
  277. package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +0 -1
  278. package/lib/db/repositories/backfilledRanges.d.ts +0 -18
  279. package/lib/db/repositories/backfilledRanges.d.ts.map +0 -1
  280. package/lib/db/repositories/backfilledRanges.js +0 -26
  281. package/lib/db/repositories/backfilledRanges.js.map +0 -1
  282. package/lib/sync/backfill/backfill.d.ts +0 -169
  283. package/lib/sync/backfill/backfill.d.ts.map +0 -1
  284. package/lib/sync/backfill/backfill.js +0 -686
  285. package/lib/sync/backfill/backfill.js.map +0 -1
  286. package/lib/sync/backfill/errors.d.ts +0 -30
  287. package/lib/sync/backfill/errors.d.ts.map +0 -1
  288. package/lib/sync/backfill/errors.js +0 -15
  289. package/lib/sync/backfill/errors.js.map +0 -1
  290. package/lib/sync/backfill/index.d.ts +0 -2
  291. package/lib/sync/backfill/index.d.ts.map +0 -1
  292. package/lib/sync/backfill/index.js +0 -2
  293. package/lib/sync/backfill/index.js.map +0 -1
  294. package/lib/sync/backfill/verify.d.ts +0 -18
  295. package/lib/sync/backfill/verify.d.ts.map +0 -1
  296. package/lib/sync/backfill/verify.js +0 -36
  297. package/lib/sync/backfill/verify.js.map +0 -1
  298. package/src/chain/archiveStore/utils/updateBackfillRange.ts +0 -50
  299. package/src/db/repositories/backfilledRanges.ts +0 -29
  300. package/src/sync/backfill/backfill.ts +0 -916
  301. package/src/sync/backfill/errors.ts +0 -23
  302. package/src/sync/backfill/index.ts +0 -1
  303. package/src/sync/backfill/verify.ts +0 -58
@@ -59,7 +59,18 @@ import {
59
59
  heze,
60
60
  ssz,
61
61
  } from "@lodestar/types";
62
- import {GWEI_TO_WEI, Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
62
+ import {
63
+ GWEI_TO_WEI,
64
+ Logger,
65
+ byteArrayEquals,
66
+ fromHex,
67
+ prettyGweiToEth,
68
+ prettyWeiToEth,
69
+ sleep,
70
+ toHex,
71
+ toPubkeyHex,
72
+ toRootHex,
73
+ } from "@lodestar/utils";
63
74
  import {ZERO_HASH_HEX} from "../../constants/index.js";
64
75
  import {numToQuantity} from "../../execution/engine/utils.js";
65
76
  import {IExecutionBuilder, IExecutionEngine, PayloadAttributes, PayloadId} from "../../execution/index.js";
@@ -259,7 +270,7 @@ export async function produceBlockBody<T extends BlockType>(
259
270
  this.logger.verbose("Produced block with builder bid", {
260
271
  slot: blockSlot,
261
272
  builderIndex: builderBid.message.builderIndex,
262
- bidValue: builderBid.message.value,
273
+ bidValue: prettyGweiToEth(builderBid.message.value),
263
274
  parentBlockHash: toRootHex(builderBid.message.parentBlockHash),
264
275
  parentBlockRoot: toRootHex(builderBid.message.parentBlockRoot),
265
276
  blockHash: toRootHex(builderBid.message.blockHash),
@@ -410,7 +421,7 @@ export async function produceBlockBody<T extends BlockType>(
410
421
  this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
411
422
  this.logger.verbose("Produced block with self-build bid", {
412
423
  slot: blockSlot,
413
- executionPayloadValue,
424
+ executionPayloadValue: prettyWeiToEth(executionPayloadValue),
414
425
  prepType,
415
426
  payloadId,
416
427
  fetchedTime,
@@ -490,7 +501,7 @@ export async function produceBlockBody<T extends BlockType>(
490
501
  this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
491
502
  this.logger.verbose("Fetched execution payload header from builder", {
492
503
  slot: blockSlot,
493
- executionPayloadValue,
504
+ executionPayloadValue: prettyWeiToEth(executionPayloadValue),
494
505
  prepType,
495
506
  fetchedTime,
496
507
  });
@@ -607,7 +618,7 @@ export async function produceBlockBody<T extends BlockType>(
607
618
  this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
608
619
  this.logger.verbose("Fetched execution payload from engine", {
609
620
  slot: blockSlot,
610
- executionPayloadValue,
621
+ executionPayloadValue: prettyWeiToEth(executionPayloadValue),
611
622
  prepType,
612
623
  payloadId,
613
624
  fetchedTime,
@@ -708,7 +719,7 @@ export async function produceBlockBody<T extends BlockType>(
708
719
  }
709
720
  }
710
721
 
711
- Object.assign(logMeta, {executionPayloadValue});
722
+ Object.assign(logMeta, {executionPayloadValue: prettyWeiToEth(executionPayloadValue)});
712
723
  this.logger.verbose("Produced beacon block body", logMeta);
713
724
 
714
725
  return {body: blockBody as AssembledBodyType<T>, produceResult, executionPayloadValue, shouldOverrideBuilder};
@@ -256,10 +256,11 @@ export class SeenPayloadEnvelopeInput {
256
256
  return this.payloadInputs.size;
257
257
  }
258
258
 
259
- prune(blockRootHex: RootHex): void {
259
+ /** Removes the single PayloadEnvelopeInput from the cache */
260
+ remove(blockRootHex: RootHex): void {
260
261
  const input = this.payloadInputs.get(blockRootHex);
261
262
  if (input) {
262
- this.evictPayloadInput(input, "prune");
263
+ this.evictPayloadInput(input, "remove");
263
264
  }
264
265
  }
265
266
 
@@ -63,8 +63,7 @@ export async function validateAttesterSlashing(
63
63
  const signatureSets = getAttesterSlashingSignatureSets(chain.config, state.slot, attesterSlashing);
64
64
  if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
65
65
  throw new AttesterSlashingError(GossipAction.REJECT, {
66
- code: AttesterSlashingErrorCode.INVALID,
67
- error: Error("Invalid signature"),
66
+ code: AttesterSlashingErrorCode.INVALID_SIGNATURE,
68
67
  });
69
68
  }
70
69
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ computeEpochAtSlot,
2
3
  createIndexedSignatureSetFromComponents,
3
4
  getPayloadAttestationDataSigningRoot,
4
5
  isStatePostGloas,
@@ -35,6 +36,14 @@ async function validatePayloadAttestationMessage(
35
36
  ): Promise<PayloadAttestationValidationResult> {
36
37
  const {data, validatorIndex} = payloadAttestationMessage;
37
38
 
39
+ // [REJECT] The payload attestation slot is at or after the Gloas fork.
40
+ if (computeEpochAtSlot(data.slot) < chain.config.GLOAS_FORK_EPOCH) {
41
+ throw new PayloadAttestationError(GossipAction.REJECT, {
42
+ code: PayloadAttestationErrorCode.PRE_GLOAS_SLOT,
43
+ slot: data.slot,
44
+ });
45
+ }
46
+
38
47
  // [IGNORE] The message's slot is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance), i.e. `data.slot == current_slot`.
39
48
  if (!chain.clock.isCurrentSlotGivenGossipDisparity(data.slot)) {
40
49
  throw new PayloadAttestationError(GossipAction.IGNORE, {
@@ -48,8 +48,7 @@ async function validateProposerSlashing(
48
48
  const signatureSets = getProposerSlashingSignatureSets(chain.config, state.slot, proposerSlashing);
49
49
  if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
50
50
  throw new ProposerSlashingError(GossipAction.REJECT, {
51
- code: ProposerSlashingErrorCode.INVALID,
52
- error: Error("Invalid signature"),
51
+ code: ProposerSlashingErrorCode.INVALID_SIGNATURE,
53
52
  });
54
53
  }
55
54
  }
@@ -24,7 +24,17 @@ import {
24
24
  deneb,
25
25
  gloas,
26
26
  } from "@lodestar/types";
27
- import {LogData, LogHandler, LogLevel, Logger, MapDef, MapDefMax, prettyPrintIndices, toRootHex} from "@lodestar/utils";
27
+ import {
28
+ LogData,
29
+ LogHandler,
30
+ LogLevel,
31
+ Logger,
32
+ MapDef,
33
+ MapDefMax,
34
+ prettyGweiToEth,
35
+ prettyPrintIndices,
36
+ toRootHex,
37
+ } from "@lodestar/utils";
28
38
  import {GENESIS_SLOT} from "../constants/constants.js";
29
39
  import {RegistryMetricCreator} from "../metrics/index.js";
30
40
 
@@ -470,7 +480,7 @@ export function createValidatorMonitor(
470
480
  src,
471
481
  builderIndex: bid.builderIndex,
472
482
  gasLimit: Number(bid.gasLimit),
473
- value: bid.value.toString(),
483
+ value: prettyGweiToEth(bid.value),
474
484
  parentBlockRoot: toRootHex(bid.parentBlockRoot),
475
485
  parentBlockHash: toRootHex(bid.parentBlockHash),
476
486
  blockHash: toRootHex(bid.blockHash),
package/src/db/beacon.ts CHANGED
@@ -11,7 +11,6 @@ import {CheckpointStateRepository} from "./repositories/checkpointState.js";
11
11
  import {
12
12
  AttesterSlashingRepository,
13
13
  BLSToExecutionChangeRepository,
14
- BackfilledRanges,
15
14
  BestLightClientUpdateRepository,
16
15
  BlobSidecarsArchiveRepository,
17
16
  BlobSidecarsRepository,
@@ -61,8 +60,6 @@ export class BeaconDb implements IBeaconDb {
61
60
  syncCommittee: SyncCommitteeRepository;
62
61
  syncCommitteeWitness: SyncCommitteeWitnessRepository;
63
62
 
64
- backfilledRanges: BackfilledRanges;
65
-
66
63
  readonly dataColumns: IDataColumnStore;
67
64
  lastLegacyArchiveSlot: Slot | null = null;
68
65
  private readonly flatFileStore: FlatFileStore;
@@ -97,8 +94,6 @@ export class BeaconDb implements IBeaconDb {
97
94
  this.syncCommittee = new SyncCommitteeRepository(config, db);
98
95
  this.syncCommitteeWitness = new SyncCommitteeWitnessRepository(config, db);
99
96
 
100
- this.backfilledRanges = new BackfilledRanges(config, db);
101
-
102
97
  this.flatFileStore = new FlatFileStore(opts.dataColumnDir, config, opts.logger, opts.metrics);
103
98
  this.dataColumns = new LegacyDataColumnStore(
104
99
  this.flatFileStore,
package/src/db/buckets.ts CHANGED
@@ -56,7 +56,7 @@ export enum Bucket {
56
56
  // altair_lightClientSyncCommitteeProof = 35, // DEPRECATED on v0.32.0
57
57
  // index_lightClientInitProof = 36, // DEPRECATED on v0.32.0
58
58
 
59
- backfilled_ranges = 42, // Backfilled From to To, inclusive of both From, To
59
+ // backfilled_ranges = 42, // DEPRECATED on v1.48.0
60
60
 
61
61
  // Buckets to support LightClient server v2
62
62
  lightClient_syncCommitteeWitness = 51, // BlockRoot -> SyncCommitteeWitness
@@ -71,7 +71,7 @@ export enum Bucket {
71
71
  allForks_dataColumnSidecarsArchive = 58, // BeaconBlockSlot -> DataColumnSidecars
72
72
 
73
73
  gloas_executionPayloadEnvelope = 59, // GLOAS BeaconBlockRoot -> SignedExecutionPayloadEnvelope
74
- gloas_executionPayloadEnvelopeArchive = 60, // GLOAS Slot -> SignedExecutionPayloadEnvelope
74
+ gloas_executionPayloadEnvelopeArchive = 60, // GLOAS Slot -> SignedExecutionPayloadEnvelope, or 0x00 + SignedExecutionPayloadHeaderEnvelope
75
75
  }
76
76
 
77
77
  export function getBucketNameByValue<T extends Bucket>(enumValue: T): keyof typeof Bucket {
@@ -6,7 +6,6 @@ import {CheckpointStateRepository} from "./repositories/checkpointState.js";
6
6
  import {
7
7
  AttesterSlashingRepository,
8
8
  BLSToExecutionChangeRepository,
9
- BackfilledRanges,
10
9
  BestLightClientUpdateRepository,
11
10
  BlobSidecarsArchiveRepository,
12
11
  BlobSidecarsRepository,
@@ -60,8 +59,6 @@ export interface IBeaconDb {
60
59
  syncCommittee: SyncCommitteeRepository;
61
60
  syncCommitteeWitness: SyncCommitteeWitnessRepository;
62
61
 
63
- backfilledRanges: BackfilledRanges;
64
-
65
62
  dataColumns: IDataColumnStore;
66
63
  /** Highest legacy column slot at startup; later archival writes the block-root index first. */
67
64
  readonly lastLegacyArchiveSlot: Slot | null;
@@ -1,8 +1,9 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
2
  import {Db, DbBatch, FilterOptions, KeyValue, Repository} from "@lodestar/db";
3
3
  import {Root, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
4
- import {bytesToInt, intToBytes} from "@lodestar/utils";
4
+ import {bytesToInt, fromHex, intToBytes} from "@lodestar/utils";
5
5
  import {getSignedBlockTypeFromBytes} from "../../util/multifork.js";
6
+ import {getParentRootFromSignedBeaconBlockSerialized} from "../../util/sszBytes.js";
6
7
  import {Bucket, getBucketNameByValue} from "../buckets.js";
7
8
  import {
8
9
  deleteParentRootIndex,
@@ -24,6 +25,10 @@ export type BlockArchiveBatchPutBinaryItem = KeyValue<Slot, Uint8Array> & {
24
25
  parentRoot: Root;
25
26
  };
26
27
 
28
+ // The initial prune can span millions of slots. This bounds the slot index reads in flight and keeps each
29
+ // delete batch at a few thousand keys, both tiny next to the block value batches in archiveBlocks
30
+ const DELETE_RANGE_CHUNK_SIZE = 1000;
31
+
27
32
  /**
28
33
  * Stores finalized blocks. Block slot is identifier.
29
34
  */
@@ -103,6 +108,38 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
103
108
  );
104
109
  }
105
110
 
111
+ /**
112
+ * Delete a contiguous range of archived blocks together with their index entries.
113
+ * `slots` must be every archived slot in the range, so the parent of each block is the entry before it.
114
+ */
115
+ async batchDeleteRange(slots: Slot[]): Promise<void> {
116
+ const sorted = [...slots].sort((a, b) => a - b);
117
+ let prevRoot: Root | null = null;
118
+
119
+ for (let i = 0; i < sorted.length; i += DELETE_RANGE_CHUNK_SIZE) {
120
+ const chunk = sorted.slice(i, i + DELETE_RANGE_CHUNK_SIZE);
121
+ const roots = await Promise.all(chunk.map((slot) => this.getRootBySlot(slot)));
122
+
123
+ const keys: Uint8Array[] = [];
124
+ for (let j = 0; j < chunk.length; j++) {
125
+ keys.push(this.encodeKey(chunk[j]), getSlotIndexKey(chunk[j]));
126
+ const root = roots[j];
127
+ if (root) keys.push(getRootIndexKey(root));
128
+ // The parent index entry pointing at this block is keyed by its parent root, which is the
129
+ // previous block's root unless that block is unindexed, then it is read from the block itself
130
+ let parentRoot = prevRoot;
131
+ if (parentRoot === null) {
132
+ const block = await this.getBinary(chunk[j]);
133
+ const parentRootHex = block ? getParentRootFromSignedBeaconBlockSerialized(block) : null;
134
+ parentRoot = parentRootHex ? fromHex(parentRootHex) : null;
135
+ }
136
+ if (parentRoot) keys.push(getParentRootIndexKey(parentRoot));
137
+ prevRoot = root;
138
+ }
139
+ await this.db.batchDelete(keys, this.dbReqOpts);
140
+ }
141
+ }
142
+
106
143
  async batch(operations: DbBatch<Slot, SignedBeaconBlock>): Promise<void> {
107
144
  await this.batchBinary(
108
145
  operations.map((operation) =>
@@ -1,25 +1,44 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {BUCKET_LENGTH, Db, Repository, encodeKey as encodeDbKey} from "@lodestar/db";
2
+ import {BUCKET_LENGTH, BinaryRepository, Db, DbBatch, encodeKey as encodeDbKey} from "@lodestar/db";
3
3
  import {Slot, gloas, ssz} from "@lodestar/types";
4
4
  import {bytesToInt} from "@lodestar/utils";
5
5
  import {Bucket, getBucketNameByValue} from "../buckets.js";
6
6
 
7
7
  /**
8
- * Used to store finalized `SignedExecutionPayloadEnvelope`
9
- *
10
- * Indexed by slot for chronological archival
8
+ * Prefix of a header entry. A full `SignedExecutionPayloadEnvelope` starts with the offset of its
9
+ * variable-size `message` field (4 + 96 = 0x64), so a leading 0x00 byte is unambiguous and full
10
+ * entries can be stored as the hot db bytes, untouched.
11
11
  */
12
- export class ExecutionPayloadEnvelopeArchiveRepository extends Repository<Slot, gloas.SignedExecutionPayloadEnvelope> {
12
+ const HEADER_ENVELOPE_PREFIX = 0x00;
13
+
14
+ /** An archive entry as the serving paths need it: full stays bytes, header is deserialized for reconstruction */
15
+ export type ArchivedEnvelope =
16
+ | {headerEnvelope: gloas.SignedExecutionPayloadHeaderEnvelope; envelopeBytes?: undefined}
17
+ | {headerEnvelope?: undefined; envelopeBytes: Uint8Array};
18
+
19
+ export function decodeArchivedEnvelope(bytes: Uint8Array): ArchivedEnvelope {
20
+ return bytes[0] === HEADER_ENVELOPE_PREFIX
21
+ ? {headerEnvelope: ssz.gloas.SignedExecutionPayloadHeaderEnvelope.deserialize(bytes.subarray(1))}
22
+ : {envelopeBytes: bytes};
23
+ }
24
+
25
+ export function encodeArchivedHeaderEnvelope(headerEnvelope: gloas.SignedExecutionPayloadHeaderEnvelope): Uint8Array {
26
+ const value = ssz.gloas.SignedExecutionPayloadHeaderEnvelope.serialize(headerEnvelope);
27
+ const out = new Uint8Array(1 + value.length);
28
+ out[0] = HEADER_ENVELOPE_PREFIX;
29
+ out.set(value, 1);
30
+ return out;
31
+ }
32
+
33
+ /**
34
+ * Finalized envelopes indexed by slot: `SignedExecutionPayloadEnvelope` bytes as-is
35
+ * (`--chain.dedupePayloads=false`, or the block was still optimistic when archived), or a
36
+ * `SignedExecutionPayloadHeaderEnvelope` behind a 0x00 prefix. See {@link decodeArchivedEnvelope}.
37
+ */
38
+ export class ExecutionPayloadEnvelopeArchiveRepository extends BinaryRepository<Slot> {
13
39
  constructor(config: ChainForkConfig, db: Db) {
14
40
  const bucket = Bucket.gloas_executionPayloadEnvelopeArchive;
15
- super(config, db, bucket, ssz.gloas.SignedExecutionPayloadEnvelope, getBucketNameByValue(bucket));
16
- }
17
-
18
- /**
19
- * Id is the slot from the envelope
20
- */
21
- getId(value: gloas.SignedExecutionPayloadEnvelope): Slot {
22
- return value.message.payload.slotNumber;
41
+ super(config, db, bucket, getBucketNameByValue(bucket));
23
42
  }
24
43
 
25
44
  encodeKey(id: Slot): Uint8Array {
@@ -29,4 +48,15 @@ export class ExecutionPayloadEnvelopeArchiveRepository extends Repository<Slot,
29
48
  decodeKey(data: Uint8Array): number {
30
49
  return bytesToInt(data.subarray(BUCKET_LENGTH), "be");
31
50
  }
51
+
52
+ /** Archive entries and delete their hot counterparts (`hotKey` pre-encoded) in one atomic batch */
53
+ async batchArchiveAndDeleteHot(
54
+ entries: {slot: Slot; archivedBytes: Uint8Array; hotKey: Uint8Array}[]
55
+ ): Promise<void> {
56
+ const operations: DbBatch<Uint8Array, Uint8Array> = [];
57
+ for (const {slot, archivedBytes, hotKey} of entries) {
58
+ operations.push({type: "put", key: this.encodeKey(slot), value: archivedBytes}, {type: "del", key: hotKey});
59
+ }
60
+ await this.db.batch(operations, this.dbReqOpts);
61
+ }
32
62
  }
@@ -1,5 +1,4 @@
1
1
  export {AttesterSlashingRepository} from "./attesterSlashing.js";
2
- export {BackfilledRanges} from "./backfilledRanges.js";
3
2
  export {BlobSidecarsRepository} from "./blobSidecars.js";
4
3
  export {BlobSidecarsArchiveRepository} from "./blobSidecarsArchive.js";
5
4
  export {BlockRepository} from "./block.js";
@@ -9,7 +8,12 @@ export {BLSToExecutionChangeRepository} from "./blsToExecutionChange.js";
9
8
  export {DataColumnSidecarRepository} from "./dataColumnSidecar.js";
10
9
  export {DataColumnSidecarArchiveRepository} from "./dataColumnSidecarArchive.js";
11
10
  export {ExecutionPayloadEnvelopeRepository} from "./executionPayloadEnvelope.js";
12
- export {ExecutionPayloadEnvelopeArchiveRepository} from "./executionPayloadEnvelopeArchive.js";
11
+ export {
12
+ type ArchivedEnvelope,
13
+ ExecutionPayloadEnvelopeArchiveRepository,
14
+ decodeArchivedEnvelope,
15
+ encodeArchivedHeaderEnvelope,
16
+ } from "./executionPayloadEnvelopeArchive.js";
13
17
  export {BestLightClientUpdateRepository} from "./lightclientBestUpdate.js";
14
18
  export {CheckpointHeaderRepository} from "./lightclientCheckpointHeader.js";
15
19
  export {SyncCommitteeRepository} from "./lightclientSyncCommittee.js";
@@ -25,6 +25,10 @@ export class ExecutionEngineDisabled implements IExecutionEngine {
25
25
  throw Error("Execution engine disabled");
26
26
  }
27
27
 
28
+ getPayloadBodiesByHashV2(): Promise<never> {
29
+ throw Error("Execution engine disabled");
30
+ }
31
+
28
32
  getPayloadBodiesByRange(): Promise<never> {
29
33
  throw Error("Execution engine disabled");
30
34
  }
@@ -32,11 +32,13 @@ import {
32
32
  EngineApiRpcParamTypes,
33
33
  EngineApiRpcReturnTypes,
34
34
  ExecutionPayloadBody,
35
+ ExecutionPayloadBodyV2,
35
36
  assertReqSizeLimit,
36
37
  deserializeBlobAndProofs,
37
38
  deserializeBlobAndProofsV2,
38
39
  deserializeBlobAndProofsV2IntoBytes,
39
40
  deserializeExecutionPayloadBody,
41
+ deserializeExecutionPayloadBodyV2,
40
42
  parseExecutionPayload,
41
43
  serializeBeaconBlockRoot,
42
44
  serializeExecutionPayload,
@@ -476,6 +478,16 @@ export class ExecutionEngineHttp implements IExecutionEngine {
476
478
  return response.map(deserializeExecutionPayloadBody);
477
479
  }
478
480
 
481
+ async getPayloadBodiesByHashV2(blockHashes: RootHex[]): Promise<(ExecutionPayloadBodyV2 | null)[]> {
482
+ const method = "engine_getPayloadBodiesByHashV2";
483
+ assertReqSizeLimit(blockHashes.length, 32);
484
+ const response = await this.rpc.fetchWithRetries<
485
+ EngineApiRpcReturnTypes[typeof method],
486
+ EngineApiRpcParamTypes[typeof method]
487
+ >({method, params: [blockHashes]}, getPayloadBodiesByHashOpts);
488
+ return response.map(deserializeExecutionPayloadBodyV2);
489
+ }
490
+
479
491
  async getPayloadBodiesByRange(
480
492
  _fork: ForkName,
481
493
  startBlockNumber: number,
@@ -13,7 +13,7 @@ import {BlobsBundle, ExecutionPayload, ExecutionRequests, Root, RootHex, Wei, ca
13
13
  import {BlobAndProof} from "@lodestar/types/deneb";
14
14
  import {BlobAndProofV2} from "@lodestar/types/fulu";
15
15
  import {PayloadId, PayloadIdCache, WithdrawalV1} from "./payloadIdCache.js";
16
- import {ExecutionPayloadBody} from "./types.js";
16
+ import {ExecutionPayloadBody, ExecutionPayloadBodyV2} from "./types.js";
17
17
  import {DATA} from "./utils.js";
18
18
 
19
19
  export {PayloadIdCache, type PayloadId, type WithdrawalV1};
@@ -172,6 +172,9 @@ export interface IExecutionEngine {
172
172
 
173
173
  getPayloadBodiesByHash(fork: ForkName, blockHash: DATA[]): Promise<(ExecutionPayloadBody | null)[]>;
174
174
 
175
+ /** Amsterdam: like V1 but also returns the block access list (null if the EL no longer has it) */
176
+ getPayloadBodiesByHashV2(blockHash: DATA[]): Promise<(ExecutionPayloadBodyV2 | null)[]>;
177
+
175
178
  getPayloadBodiesByRange(fork: ForkName, start: number, count: number): Promise<(ExecutionPayloadBody | null)[]>;
176
179
 
177
180
  getBlobs(
@@ -23,6 +23,7 @@ import {
23
23
  EngineApiRpcParamTypes,
24
24
  EngineApiRpcReturnTypes,
25
25
  ExecutionPayloadBodyRpc,
26
+ ExecutionPayloadBodyV2Rpc,
26
27
  ExecutionPayloadRpc,
27
28
  ExecutionRequestsRpc,
28
29
  PayloadStatus,
@@ -49,6 +50,8 @@ type ExecutionBlock = {
49
50
  blockHash: RootHex;
50
51
  timestamp: number;
51
52
  blockNumber: number;
53
+ /** Bodies as received via newPayload, served back by engine_getPayloadBodiesByHash{V1,V2} */
54
+ body: ExecutionPayloadBodyV2Rpc;
52
55
  };
53
56
 
54
57
  const TX_TYPE_EIP1559 = 2;
@@ -93,6 +96,7 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
93
96
  blockHash: ZERO_HASH_HEX,
94
97
  timestamp: 0,
95
98
  blockNumber: 0,
99
+ body: {transactions: [], withdrawals: null, blockAccessList: null},
96
100
  });
97
101
 
98
102
  const eth1BlockHash = opts.eth1BlockHash ?? toRootHex(INTEROP_BLOCK_HASH);
@@ -102,6 +106,7 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
102
106
  blockHash: eth1BlockHash,
103
107
  timestamp: 0,
104
108
  blockNumber: 1,
109
+ body: {transactions: [], withdrawals: null, blockAccessList: null},
105
110
  });
106
111
 
107
112
  const {config} = opts;
@@ -144,6 +149,7 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
144
149
  engine_getPayloadV5: this.getPayloadV5.bind(this),
145
150
  engine_getPayloadV6: this.getPayloadV5.bind(this),
146
151
  engine_getPayloadBodiesByHashV1: this.getPayloadBodiesByHash.bind(this),
152
+ engine_getPayloadBodiesByHashV2: this.getPayloadBodiesByHashV2.bind(this),
147
153
  engine_getPayloadBodiesByRangeV1: this.getPayloadBodiesByRange.bind(this),
148
154
  engine_getClientVersionV1: this.getClientVersionV1.bind(this),
149
155
  engine_getBlobsV1: this.getBlobs.bind(this),
@@ -152,9 +158,18 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
152
158
  }
153
159
 
154
160
  private getPayloadBodiesByHash(
155
- _blockHex: EngineApiRpcParamTypes["engine_getPayloadBodiesByHashV1"][0]
161
+ blockHashes: EngineApiRpcParamTypes["engine_getPayloadBodiesByHashV1"][0]
156
162
  ): EngineApiRpcReturnTypes["engine_getPayloadBodiesByHashV1"] {
157
- return [] as ExecutionPayloadBodyRpc[];
163
+ return this.getPayloadBodiesByHashV2(blockHashes).map((body) =>
164
+ body ? {transactions: body.transactions, withdrawals: body.withdrawals} : null
165
+ );
166
+ }
167
+
168
+ private getPayloadBodiesByHashV2(
169
+ blockHashes: EngineApiRpcParamTypes["engine_getPayloadBodiesByHashV2"][0]
170
+ ): EngineApiRpcReturnTypes["engine_getPayloadBodiesByHashV2"] {
171
+ // null for unknown blocks, as a real EL does; the genesis/eth1 seed blocks carry no body
172
+ return blockHashes.map((hash) => this.validBlocks.get(hash)?.body ?? null);
158
173
  }
159
174
 
160
175
  private getPayloadBodiesByRange(
@@ -227,6 +242,11 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
227
242
  blockHash,
228
243
  timestamp: quantityToNum(executionPayloadRpc.timestamp),
229
244
  blockNumber: quantityToNum(executionPayloadRpc.blockNumber),
245
+ body: {
246
+ transactions: executionPayloadRpc.transactions,
247
+ withdrawals: executionPayloadRpc.withdrawals ?? null,
248
+ blockAccessList: executionPayloadRpc.blockAccessList ?? null,
249
+ },
230
250
  });
231
251
 
232
252
  // IF the payload has been fully validated while processing the call
@@ -89,6 +89,7 @@ export type EngineApiRpcParamTypes = {
89
89
  * 1. Array of DATA - Array of block_hash field values of the ExecutionPayload structure
90
90
  * */
91
91
  engine_getPayloadBodiesByHashV1: DATA[][];
92
+ engine_getPayloadBodiesByHashV2: DATA[][];
92
93
 
93
94
  /**
94
95
  * 1. start: QUANTITY, 64 bits - Starting block number
@@ -148,6 +149,7 @@ export type EngineApiRpcReturnTypes = {
148
149
  engine_getPayloadV6: ExecutionPayloadResponse;
149
150
 
150
151
  engine_getPayloadBodiesByHashV1: (ExecutionPayloadBodyRpc | null)[];
152
+ engine_getPayloadBodiesByHashV2: (ExecutionPayloadBodyV2Rpc | null)[];
151
153
 
152
154
  engine_getPayloadBodiesByRangeV1: (ExecutionPayloadBodyRpc | null)[];
153
155
 
@@ -177,6 +179,15 @@ export type ExecutionPayloadBody = {
177
179
  withdrawals: capella.Withdrawals | null;
178
180
  };
179
181
 
182
+ /** engine_getPayloadBodiesByHashV2 (Amsterdam): adds the RLP-encoded block access list, or null if the EL has pruned it */
183
+ export type ExecutionPayloadBodyV2Rpc = ExecutionPayloadBodyRpc & {
184
+ blockAccessList?: DATA | null;
185
+ };
186
+
187
+ export type ExecutionPayloadBodyV2 = ExecutionPayloadBody & {
188
+ blockAccessList: Uint8Array | null;
189
+ };
190
+
180
191
  export type ExecutionPayloadRpc = {
181
192
  parentHash: DATA; // 32 bytes
182
193
  feeRecipient: DATA; // 20 bytes
@@ -678,6 +689,20 @@ export function deserializeExecutionPayloadBody(data: ExecutionPayloadBodyRpc |
678
689
  : null;
679
690
  }
680
691
 
692
+ export function deserializeExecutionPayloadBodyV2(
693
+ data: ExecutionPayloadBodyV2Rpc | null
694
+ ): ExecutionPayloadBodyV2 | null {
695
+ const body = deserializeExecutionPayloadBody(data);
696
+ return body
697
+ ? {...body, blockAccessList: data?.blockAccessList ? dataToBytes(data.blockAccessList, null) : null}
698
+ : null;
699
+ }
700
+
701
+ export function serializeExecutionPayloadBodyV2(data: ExecutionPayloadBodyV2 | null): ExecutionPayloadBodyV2Rpc | null {
702
+ const body = serializeExecutionPayloadBody(data);
703
+ return body ? {...body, blockAccessList: data?.blockAccessList ? bytesToData(data.blockAccessList) : null} : null;
704
+ }
705
+
681
706
  export function serializeExecutionPayloadBody(data: ExecutionPayloadBody | null): ExecutionPayloadBodyRpc | null {
682
707
  return data
683
708
  ? {
@@ -215,6 +215,22 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
215
215
  help: "Number of getBlobsV1 hits where a versioned hash returns blob and the blob is needed so call is useful",
216
216
  }),
217
217
  },
218
+ payloadEnvelopeReconstruction: {
219
+ envelopes: register.counter<{result: "ok" | "unavailable" | "mismatch"}>({
220
+ name: "beacon_payload_envelope_reconstruction_envelopes_total",
221
+ help: "Archived header envelopes rebuilt from EL bodies, by outcome",
222
+ labelNames: ["result"],
223
+ }),
224
+ mismatchByField: register.counter<{field: "transactions" | "withdrawals" | "blockAccessList"}>({
225
+ name: "beacon_payload_envelope_reconstruction_mismatch_total",
226
+ help: "Body root mismatches, by which body differed from the stored root",
227
+ labelNames: ["field"],
228
+ }),
229
+ engineErrors: register.counter({
230
+ name: "beacon_payload_envelope_reconstruction_engine_errors_total",
231
+ help: "engine_getPayloadBodiesByHashV2 round-trips that failed while rebuilding envelopes",
232
+ }),
233
+ },
218
234
 
219
235
  blockInputFetchStats: {
220
236
  // of already available blocks which didn't have to go through blobs pull