@lodestar/beacon-node 1.49.0-dev.09a1892a85 → 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 (289) 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 +11 -2
  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 +21 -11
  138. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  139. package/lib/metrics/metrics/lodestar.js +48 -23
  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/gossipsub.d.ts.map +1 -1
  146. package/lib/network/gossip/gossipsub.js +15 -0
  147. package/lib/network/gossip/gossipsub.js.map +1 -1
  148. package/lib/network/gossip/topic.d.ts +1 -1
  149. package/lib/network/gossip/topic.d.ts.map +1 -1
  150. package/lib/network/gossip/topic.js +1 -1
  151. package/lib/network/gossip/topic.js.map +1 -1
  152. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  153. package/lib/network/processor/gossipHandlers.js +16 -5
  154. package/lib/network/processor/gossipHandlers.js.map +1 -1
  155. package/lib/network/processor/gossipValidatorFn.d.ts +2 -0
  156. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  157. package/lib/network/processor/gossipValidatorFn.js +88 -7
  158. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  159. package/lib/network/processor/index.d.ts +6 -2
  160. package/lib/network/processor/index.d.ts.map +1 -1
  161. package/lib/network/processor/index.js +62 -24
  162. package/lib/network/processor/index.js.map +1 -1
  163. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  164. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +47 -34
  165. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  166. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
  167. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +23 -4
  168. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  169. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  170. package/lib/network/reqresp/handlers/index.js +20 -4
  171. package/lib/network/reqresp/handlers/index.js.map +1 -1
  172. package/lib/node/nodejs.d.ts +2 -7
  173. package/lib/node/nodejs.d.ts.map +1 -1
  174. package/lib/node/nodejs.js +2 -22
  175. package/lib/node/nodejs.js.map +1 -1
  176. package/lib/sync/interface.d.ts +1 -2
  177. package/lib/sync/interface.d.ts.map +1 -1
  178. package/lib/sync/options.d.ts +0 -6
  179. package/lib/sync/options.d.ts.map +1 -1
  180. package/lib/sync/options.js +0 -2
  181. package/lib/sync/options.js.map +1 -1
  182. package/lib/sync/types.d.ts +21 -2
  183. package/lib/sync/types.d.ts.map +1 -1
  184. package/lib/sync/types.js +22 -2
  185. package/lib/sync/types.js.map +1 -1
  186. package/lib/sync/unknownBlock.d.ts +20 -0
  187. package/lib/sync/unknownBlock.d.ts.map +1 -1
  188. package/lib/sync/unknownBlock.js +199 -15
  189. package/lib/sync/unknownBlock.js.map +1 -1
  190. package/lib/util/execution.d.ts +42 -0
  191. package/lib/util/execution.d.ts.map +1 -1
  192. package/lib/util/execution.js +123 -2
  193. package/lib/util/execution.js.map +1 -1
  194. package/lib/util/headerEnvelope.d.ts +17 -0
  195. package/lib/util/headerEnvelope.d.ts.map +1 -0
  196. package/lib/util/headerEnvelope.js +43 -0
  197. package/lib/util/headerEnvelope.js.map +1 -0
  198. package/lib/util/shuffle.d.ts +0 -4
  199. package/lib/util/shuffle.d.ts.map +1 -1
  200. package/lib/util/shuffle.js +0 -8
  201. package/lib/util/shuffle.js.map +1 -1
  202. package/package.json +16 -16
  203. package/src/api/impl/beacon/blocks/index.ts +18 -5
  204. package/src/api/impl/beacon/pool/index.ts +6 -2
  205. package/src/api/impl/beacon/state/index.ts +36 -0
  206. package/src/api/impl/validator/index.ts +9 -7
  207. package/src/chain/archiveStore/archiveStore.ts +24 -8
  208. package/src/chain/archiveStore/historicalState/metrics.ts +5 -7
  209. package/src/chain/archiveStore/utils/archiveBlocks.ts +54 -32
  210. package/src/chain/archiveStore/utils/pruneHistory.ts +14 -5
  211. package/src/chain/blocks/importExecutionPayload.ts +14 -0
  212. package/src/chain/blocks/index.ts +2 -2
  213. package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -1
  214. package/src/chain/chain.ts +96 -20
  215. package/src/chain/emitter.ts +7 -2
  216. package/src/chain/errors/attesterSlashingError.ts +3 -1
  217. package/src/chain/errors/envelopeReconstructionError.ts +22 -0
  218. package/src/chain/errors/index.ts +1 -0
  219. package/src/chain/errors/payloadAttestation.ts +2 -0
  220. package/src/chain/errors/proposerSlashingError.ts +3 -1
  221. package/src/chain/interface.ts +6 -1
  222. package/src/chain/options.ts +3 -5
  223. package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
  224. package/src/chain/produceBlock/produceBlockBody.ts +17 -6
  225. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +3 -2
  226. package/src/chain/validation/attesterSlashing.ts +1 -2
  227. package/src/chain/validation/payloadAttestationMessage.ts +9 -0
  228. package/src/chain/validation/proposerSlashing.ts +1 -2
  229. package/src/chain/validatorMonitor.ts +12 -2
  230. package/src/db/beacon.ts +0 -5
  231. package/src/db/buckets.ts +2 -2
  232. package/src/db/interface.ts +0 -3
  233. package/src/db/repositories/blockArchive.ts +38 -1
  234. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +43 -13
  235. package/src/db/repositories/index.ts +6 -2
  236. package/src/execution/engine/disabled.ts +4 -0
  237. package/src/execution/engine/http.ts +12 -0
  238. package/src/execution/engine/interface.ts +4 -1
  239. package/src/execution/engine/mock.ts +22 -2
  240. package/src/execution/engine/types.ts +25 -0
  241. package/src/metrics/metrics/beacon.ts +16 -0
  242. package/src/metrics/metrics/lodestar.ts +58 -26
  243. package/src/metrics/metrics.ts +7 -2
  244. package/src/network/gossip/gossipsub.ts +18 -1
  245. package/src/network/gossip/topic.ts +2 -2
  246. package/src/network/processor/gossipHandlers.ts +18 -5
  247. package/src/network/processor/gossipValidatorFn.ts +111 -7
  248. package/src/network/processor/index.ts +81 -24
  249. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +57 -39
  250. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +27 -5
  251. package/src/network/reqresp/handlers/index.ts +49 -5
  252. package/src/node/nodejs.ts +0 -27
  253. package/src/sync/interface.ts +1 -2
  254. package/src/sync/options.ts +0 -8
  255. package/src/sync/types.ts +24 -5
  256. package/src/sync/unknownBlock.ts +207 -14
  257. package/src/util/execution.ts +175 -2
  258. package/src/util/headerEnvelope.ts +76 -0
  259. package/src/util/shuffle.ts +0 -9
  260. package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts +0 -20
  261. package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts.map +0 -1
  262. package/lib/chain/archiveStore/utils/updateBackfillRange.js +0 -40
  263. package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +0 -1
  264. package/lib/db/repositories/backfilledRanges.d.ts +0 -18
  265. package/lib/db/repositories/backfilledRanges.d.ts.map +0 -1
  266. package/lib/db/repositories/backfilledRanges.js +0 -26
  267. package/lib/db/repositories/backfilledRanges.js.map +0 -1
  268. package/lib/sync/backfill/backfill.d.ts +0 -169
  269. package/lib/sync/backfill/backfill.d.ts.map +0 -1
  270. package/lib/sync/backfill/backfill.js +0 -686
  271. package/lib/sync/backfill/backfill.js.map +0 -1
  272. package/lib/sync/backfill/errors.d.ts +0 -30
  273. package/lib/sync/backfill/errors.d.ts.map +0 -1
  274. package/lib/sync/backfill/errors.js +0 -15
  275. package/lib/sync/backfill/errors.js.map +0 -1
  276. package/lib/sync/backfill/index.d.ts +0 -2
  277. package/lib/sync/backfill/index.d.ts.map +0 -1
  278. package/lib/sync/backfill/index.js +0 -2
  279. package/lib/sync/backfill/index.js.map +0 -1
  280. package/lib/sync/backfill/verify.d.ts +0 -18
  281. package/lib/sync/backfill/verify.d.ts.map +0 -1
  282. package/lib/sync/backfill/verify.js +0 -36
  283. package/lib/sync/backfill/verify.js.map +0 -1
  284. package/src/chain/archiveStore/utils/updateBackfillRange.ts +0 -50
  285. package/src/db/repositories/backfilledRanges.ts +0 -29
  286. package/src/sync/backfill/backfill.ts +0 -916
  287. package/src/sync/backfill/errors.ts +0 -23
  288. package/src/sync/backfill/index.ts +0 -1
  289. package/src/sync/backfill/verify.ts +0 -58
@@ -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
@@ -1,5 +1,6 @@
1
1
  /** biome-ignore-all lint/suspicious/noTemplateCurlyInString: The metric templates requires to have `${}` in a normal string */
2
2
  import {NotReorgedReason} from "@lodestar/fork-choice";
3
+ import {StateHashTreeRootSource} from "@lodestar/state-transition";
3
4
  import {ArchiveStoreTask} from "../../chain/archiveStore/archiveStore.js";
4
5
  import {FrequencyStateArchiveStep} from "../../chain/archiveStore/strategies/frequencyStateArchiveStrategy.js";
5
6
  import type {LateCanonicalBlockReason} from "../../chain/archiveStore/utils/archiveBlocks.js";
@@ -25,8 +26,13 @@ import type {FlatFileStoreOperation} from "../../db/flatFileStore/metrics.js";
25
26
  import {ExecutionPayloadStatus} from "../../execution/index.js";
26
27
  import {GossipType} from "../../network/index.js";
27
28
  import {CannotAcceptWorkReason, ReprocessRejectReason} from "../../network/processor/index.js";
28
- import {BackfillSyncMethod} from "../../sync/backfill/backfill.js";
29
- import {DownloadResult, DroppedItemReason, FetchResult, PendingBlockType} from "../../sync/types.js";
29
+ import {
30
+ DeferredPayloadResult,
31
+ DownloadResult,
32
+ DroppedItemReason,
33
+ FetchResult,
34
+ PendingBlockType,
35
+ } from "../../sync/types.js";
30
36
  import {PeerSyncType, RangeSyncType} from "../../sync/utils/remoteSyncType.js";
31
37
  import {AllocSource} from "../../util/bufferPool.js";
32
38
  import {DataColumnReconstructionCode} from "../../util/dataColumns.js";
@@ -174,6 +180,30 @@ export function createLodestarMetrics(
174
180
  buckets: [0.001, 0.003, 0.01, 0.03, 0.1],
175
181
  }),
176
182
 
183
+ reqRespByRange: {
184
+ requestedSlots: register.histogram<{method: string}>({
185
+ name: "lodestar_reqresp_by_range_requested_slots",
186
+ help: "Histogram of slot count requested per served by_range request",
187
+ labelNames: ["method"],
188
+ buckets: [1, 16, 32, 64, 128],
189
+ }),
190
+ // data_column_sidecars_by_range is the only by_range request carrying columns
191
+ requestedColumns: register.histogram({
192
+ name: "lodestar_reqresp_by_range_requested_columns",
193
+ help: "Histogram of column count requested per served data_column_sidecars_by_range request",
194
+ // 128 is NUMBER_OF_COLUMNS.
195
+ buckets: [1, 4, 8, 32, 128],
196
+ }),
197
+ servedBytes: register.histogram<{method: string}>({
198
+ name: "lodestar_reqresp_by_range_served_bytes",
199
+ help: "Histogram of total serialized bytes served per by_range request",
200
+ labelNames: ["method"],
201
+ // min bucket is roughly a typical mainnet block is 100MB,
202
+ // max bucket is roughly 100 * MAX_PAYLOAD_SIZE
203
+ buckets: [100e3, 1e6, 10e6, 100e6, 1000e6],
204
+ }),
205
+ },
206
+
177
207
  regenQueue: {
178
208
  length: register.gauge({
179
209
  name: "lodestar_regen_queue_length",
@@ -403,6 +433,15 @@ export function createLodestarMetrics(
403
433
  labelNames: ["caller"],
404
434
  }),
405
435
 
436
+ // this metrics stay here instead of @lodestar/state-transition in order to prepare
437
+ // for the native zig state-transition in the future
438
+ stateHashTreeRootTime: register.histogram<{source: StateHashTreeRootSource}>({
439
+ name: "lodestar_stfn_hash_tree_root_seconds",
440
+ help: "Time to compute the hash tree root of a post state in seconds",
441
+ buckets: [0.01, 0.05, 0.1, 0.2, 0.3, 0.5],
442
+ labelNames: ["source"],
443
+ }),
444
+
406
445
  // BLS verifier thread pool and queue
407
446
 
408
447
  bls: {
@@ -655,6 +694,16 @@ export function createLodestarMetrics(
655
694
  help: "Count of payload (execution payload envelope) sync triggers, labeled by their source",
656
695
  labelNames: ["source"],
657
696
  }),
697
+ deferredPayloadResult: register.counter<{result: DeferredPayloadResult}>({
698
+ name: "lodestar_sync_deferred_payload_result_total",
699
+ help: "Outcome of a slot's deferred optimistic payload searches, by result",
700
+ labelNames: ["result"],
701
+ }),
702
+ deferredPayloadPolls: register.histogram({
703
+ name: "lodestar_sync_deferred_payload_polls_count",
704
+ help: "Poll ticks after PAYLOAD_DUE until a searched payload was imported",
705
+ buckets: [0, 1, 2, 3, 6],
706
+ }),
658
707
  pendingBlocks: register.gauge({
659
708
  name: "lodestar_sync_unknown_block_pending_blocks_size",
660
709
  help: "Current size of UnknownBlockSync pending blocks cache",
@@ -986,6 +1035,13 @@ export function createLodestarMetrics(
986
1035
  help: "Count of errors, by error type, while processing execution payload envelopes",
987
1036
  labelNames: ["error"],
988
1037
  }),
1038
+ executionPayload: {
1039
+ recvToValidation: register.histogram({
1040
+ name: "lodestar_gossip_execution_payload_envelope_received_to_execution_payload_verification_seconds",
1041
+ help: "Time elapsed between execution payload envelope received and execution payload verification",
1042
+ buckets: [0.05, 0.1, 0.25, 0.5, 1, 2, 3, 4, 6, 8],
1043
+ }),
1044
+ },
989
1045
  },
990
1046
  gossipExecutionPayloadBid: {
991
1047
  elapsedTimeTillReceived: register.histogram<{source: OpSource}>({
@@ -1120,30 +1176,6 @@ export function createLodestarMetrics(
1120
1176
  help: "The total result of calling notifyForkchoiceUpdate execution engine api",
1121
1177
  labelNames: ["result"],
1122
1178
  }),
1123
- backfillSync: {
1124
- backfilledTillSlot: register.gauge({
1125
- name: "lodestar_backfill_till_slot",
1126
- help: "Current lowest backfilled slot",
1127
- }),
1128
- prevFinOrWsSlot: register.gauge({
1129
- name: "lodestar_backfill_prev_fin_or_ws_slot",
1130
- help: "Slot of previous finalized or wsCheckpoint block to be validated",
1131
- }),
1132
- totalBlocks: register.gauge<{method: BackfillSyncMethod}>({
1133
- name: "lodestar_backfill_sync_blocks_total",
1134
- help: "Total amount of backfilled blocks",
1135
- labelNames: ["method"],
1136
- }),
1137
- errors: register.gauge({
1138
- name: "lodestar_backfill_sync_errors_total",
1139
- help: "Total number of errors while backfilling",
1140
- }),
1141
- status: register.gauge({
1142
- name: "lodestar_backfill_sync_status",
1143
- help: "Current backfill syncing status: [Aborted, Pending, Syncing, Completed]",
1144
- }),
1145
- },
1146
-
1147
1179
  opPool: {
1148
1180
  aggregatedAttestationPool: {
1149
1181
  size: register.gauge({
@@ -12,7 +12,12 @@ export type Metrics = BeaconMetrics &
12
12
  BeaconStateTransitionMetrics &
13
13
  LodestarMetrics & {register: RegistryMetricCreator; close: () => void};
14
14
 
15
- export function createMetrics(opts: MetricsOptions, genesisTime: number, externalRegistries: Registry[] = []): Metrics {
15
+ export function createMetrics(
16
+ opts: MetricsOptions,
17
+ genesisTime: number,
18
+ externalRegistries: Registry[] = [],
19
+ {collectNodeMetrics = true}: {collectNodeMetrics?: boolean} = {}
20
+ ): Metrics {
16
21
  const register = new RegistryMetricCreator();
17
22
  const beacon = createBeaconMetrics(register);
18
23
  const forkChoice = getForkChoiceMetrics(register);
@@ -24,7 +29,7 @@ export function createMetrics(opts: MetricsOptions, genesisTime: number, externa
24
29
  };
25
30
  process.on("unhandledRejection", onUnhandledRejection);
26
31
 
27
- const nodeJsMetricsClose = collectNodeJSMetrics(register);
32
+ const nodeJsMetricsClose = collectNodeMetrics ? collectNodeJSMetrics(register) : (): void => {};
28
33
  const close = (): void => {
29
34
  process.removeListener("unhandledRejection", onUnhandledRejection);
30
35
  nodeJsMetricsClose();
@@ -14,7 +14,7 @@ import {peerIdFromString} from "@libp2p/peer-id";
14
14
  import {type Multiaddr, multiaddr} from "@multiformats/multiaddr";
15
15
  import {ENR} from "@chainsafe/enr";
16
16
  import {routes} from "@lodestar/api";
17
- import {BeaconConfig, ForkBoundary} from "@lodestar/config";
17
+ import {BeaconConfig, ChainConfig, ForkBoundary} from "@lodestar/config";
18
18
  import {
19
19
  ATTESTATION_SUBNET_COUNT,
20
20
  MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE,
@@ -47,6 +47,22 @@ const GOSSIPSUB_HEARTBEAT_INTERVAL = 0.7 * 1000;
47
47
 
48
48
  const MAX_OUTBOUND_BUFFER_SIZE = 2 ** 24; // 16MB
49
49
 
50
+ /**
51
+ * Snappy worst-case compressed length for a payload of `n` bytes
52
+ * https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.0/specs/phase0/p2p-interface.md#max_compressed_len
53
+ */
54
+ function maxCompressedLen(n: number): number {
55
+ return 32 + n + Math.floor(n / 6);
56
+ }
57
+
58
+ /**
59
+ * Max size of an inbound gossipsub RPC frame, including all bundled messages and control
60
+ * https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.0/specs/phase0/p2p-interface.md#max_message_size
61
+ */
62
+ function getMaxInboundDataLength(config: Pick<ChainConfig, "MAX_PAYLOAD_SIZE">): number {
63
+ return Math.max(maxCompressedLen(config.MAX_PAYLOAD_SIZE) + 1024, 1024 * 1024);
64
+ }
65
+
50
66
  export type Eth2Context = {
51
67
  activeValidatorCount: number;
52
68
  currentSlot: number;
@@ -176,6 +192,7 @@ export class Eth2Gossipsub {
176
192
  asyncValidation: true,
177
193
 
178
194
  maxOutboundBufferSize: MAX_OUTBOUND_BUFFER_SIZE,
195
+ maxInboundDataLength: getMaxInboundDataLength(config),
179
196
  // serialize message once and send to all peers when publishing
180
197
  batchPublish: true,
181
198
  // if this is false, only publish to mesh peers. If there is not enough GOSSIP_D mesh peers,
@@ -150,8 +150,8 @@ export function getGossipSSZType(topic: GossipTopic) {
150
150
  /**
151
151
  * Return the maximum uncompressed SSZ byte length allowed by the type and configured network bounds.
152
152
  */
153
- export function getGossipSSZMaxSize(topic: GossipTopic, config: ChainForkConfig, sszType?: CompositeTypeAny): number {
154
- const maxSize = Math.min((sszType ?? getGossipSSZType(topic)).maxSize, config.MAX_PAYLOAD_SIZE);
153
+ export function getGossipSSZMaxSize(topic: GossipTopic, config: ChainForkConfig, sszType: CompositeTypeAny): number {
154
+ const maxSize = Math.min(sszType.maxSize, config.MAX_PAYLOAD_SIZE);
155
155
  if (isForkPostGloas(topic.boundary.fork) && topic.type === GossipType.data_column_sidecar) {
156
156
  return Math.min(maxSize, computeMaxGloasDataColumnSidecarSize(config));
157
157
  }
@@ -244,8 +244,20 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
244
244
 
245
245
  // IGNORE means the block is acceptable (e.g. FUTURE_SLOT, ALREADY_KNOWN), just not propagated.
246
246
  // Keep the optimistically-added cache entries; they are pruned on finalization. Only REJECT
247
- // (provably invalid) and unexpected errors prune below.
247
+ // (provably invalid), unexpected errors and repeat proposals that are not imported prune.
248
248
  if (e.action === GossipAction.IGNORE) {
249
+ // Only a signature-verified sibling is imported by the beacon_block handler, any other repeat proposal
250
+ // is dropped from the caches and re-downloaded by sync if it ever becomes relevant. Its signature was not
251
+ // verified, so only its own entry is removed, never its claimed ancestors
252
+ if (
253
+ e.type.code === BlockErrorCode.REPEAT_PROPOSAL &&
254
+ !chain.seenBlockProposers.hasBlockRoot(slot, signedBlock.message.proposerIndex, blockRootHex)
255
+ ) {
256
+ chain.seenBlockInputCache.remove(blockRootHex);
257
+ if (isForkPostGloas(fork)) {
258
+ chain.seenPayloadEnvelopeInputCache.remove(blockRootHex);
259
+ }
260
+ }
249
261
  throw e;
250
262
  }
251
263
 
@@ -258,10 +270,10 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
258
270
  }
259
271
 
260
272
  // REJECT or unexpected (non-BlockGossipError) error: drop the optimistically-added entries from
261
- // both caches, keeping them consistent.
262
- chain.seenBlockInputCache.prune(blockRootHex);
273
+ // both caches, keeping them consistent. The block may carry any parent root, so only its own entry is removed
274
+ chain.seenBlockInputCache.remove(blockRootHex);
263
275
  if (isForkPostGloas(fork)) {
264
- chain.seenPayloadEnvelopeInputCache.prune(blockRootHex);
276
+ chain.seenPayloadEnvelopeInputCache.remove(blockRootHex);
265
277
  }
266
278
  throw e;
267
279
  } finally {
@@ -738,7 +750,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
738
750
  if (
739
751
  e instanceof BlockGossipError &&
740
752
  e.type.code === BlockErrorCode.REPEAT_PROPOSAL &&
741
- // this is make sure the block's proposer signature was verified, it should be true anyway
753
+ // Only a signature-verified sibling recorded in the seen cache is imported. The cache holds at most two
754
+ // roots per proposer and slot, which bounds full imports over gossip to one alternate
742
755
  chain.seenBlockProposers.hasBlockRoot(signedBlock.message.slot, e.type.proposerIndex, e.type.root)
743
756
  ) {
744
757
  // blockInput was optimistically seeded in validateBeaconBlock and retained on IGNORE