@lodestar/beacon-node 1.49.0-dev.161265afaf → 1.49.0-dev.19005536f2

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 (221) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +13 -4
  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/validator/index.d.ts.map +1 -1
  8. package/lib/api/impl/validator/index.js +3 -1
  9. package/lib/api/impl/validator/index.js.map +1 -1
  10. package/lib/chain/archiveStore/archiveStore.d.ts +1 -2
  11. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  12. package/lib/chain/archiveStore/archiveStore.js +23 -7
  13. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  14. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  15. package/lib/chain/archiveStore/historicalState/metrics.js +5 -6
  16. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  17. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +11 -2
  18. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/utils/archiveBlocks.js +46 -28
  20. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  21. package/lib/chain/archiveStore/utils/pruneHistory.d.ts +2 -2
  22. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  23. package/lib/chain/archiveStore/utils/pruneHistory.js +1 -0
  24. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  25. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  26. package/lib/chain/blocks/importExecutionPayload.js +13 -0
  27. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  28. package/lib/chain/chain.d.ts +10 -0
  29. package/lib/chain/chain.d.ts.map +1 -1
  30. package/lib/chain/chain.js +85 -16
  31. package/lib/chain/chain.js.map +1 -1
  32. package/lib/chain/errors/envelopeReconstructionError.d.ts +23 -0
  33. package/lib/chain/errors/envelopeReconstructionError.d.ts.map +1 -0
  34. package/lib/chain/errors/envelopeReconstructionError.js +13 -0
  35. package/lib/chain/errors/envelopeReconstructionError.js.map +1 -0
  36. package/lib/chain/errors/index.d.ts +1 -0
  37. package/lib/chain/errors/index.d.ts.map +1 -1
  38. package/lib/chain/errors/index.js +1 -0
  39. package/lib/chain/errors/index.js.map +1 -1
  40. package/lib/chain/errors/payloadAttestation.d.ts +4 -0
  41. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -1
  42. package/lib/chain/errors/payloadAttestation.js +1 -0
  43. package/lib/chain/errors/payloadAttestation.js.map +1 -1
  44. package/lib/chain/interface.d.ts +6 -1
  45. package/lib/chain/interface.d.ts.map +1 -1
  46. package/lib/chain/interface.js.map +1 -1
  47. package/lib/chain/options.d.ts +2 -4
  48. package/lib/chain/options.d.ts.map +1 -1
  49. package/lib/chain/options.js +1 -1
  50. package/lib/chain/options.js.map +1 -1
  51. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  52. package/lib/chain/produceBlock/computeNewStateRoot.js +4 -2
  53. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  54. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  55. package/lib/chain/validation/payloadAttestationMessage.js +8 -1
  56. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  57. package/lib/db/beacon.d.ts +1 -2
  58. package/lib/db/beacon.d.ts.map +1 -1
  59. package/lib/db/beacon.js +1 -3
  60. package/lib/db/beacon.js.map +1 -1
  61. package/lib/db/buckets.d.ts +0 -1
  62. package/lib/db/buckets.d.ts.map +1 -1
  63. package/lib/db/buckets.js +1 -1
  64. package/lib/db/buckets.js.map +1 -1
  65. package/lib/db/interface.d.ts +1 -2
  66. package/lib/db/interface.d.ts.map +1 -1
  67. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  68. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  69. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts +21 -9
  70. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts.map +1 -1
  71. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +32 -12
  72. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  73. package/lib/db/repositories/index.d.ts +1 -2
  74. package/lib/db/repositories/index.d.ts.map +1 -1
  75. package/lib/db/repositories/index.js +1 -2
  76. package/lib/db/repositories/index.js.map +1 -1
  77. package/lib/execution/engine/disabled.d.ts +1 -0
  78. package/lib/execution/engine/disabled.d.ts.map +1 -1
  79. package/lib/execution/engine/disabled.js +3 -0
  80. package/lib/execution/engine/disabled.js.map +1 -1
  81. package/lib/execution/engine/http.d.ts +2 -1
  82. package/lib/execution/engine/http.d.ts.map +1 -1
  83. package/lib/execution/engine/http.js +7 -1
  84. package/lib/execution/engine/http.js.map +1 -1
  85. package/lib/execution/engine/interface.d.ts +3 -1
  86. package/lib/execution/engine/interface.d.ts.map +1 -1
  87. package/lib/execution/engine/mock.d.ts +1 -0
  88. package/lib/execution/engine/mock.d.ts.map +1 -1
  89. package/lib/execution/engine/mock.js +14 -2
  90. package/lib/execution/engine/mock.js.map +1 -1
  91. package/lib/execution/engine/types.d.ts +11 -0
  92. package/lib/execution/engine/types.d.ts.map +1 -1
  93. package/lib/execution/engine/types.js +10 -0
  94. package/lib/execution/engine/types.js.map +1 -1
  95. package/lib/metrics/metrics/beacon.d.ts +9 -0
  96. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  97. package/lib/metrics/metrics/beacon.js +16 -0
  98. package/lib/metrics/metrics/beacon.js.map +1 -1
  99. package/lib/metrics/metrics/lodestar.d.ts +21 -11
  100. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  101. package/lib/metrics/metrics/lodestar.js +48 -23
  102. package/lib/metrics/metrics/lodestar.js.map +1 -1
  103. package/lib/metrics/metrics.d.ts +3 -1
  104. package/lib/metrics/metrics.d.ts.map +1 -1
  105. package/lib/metrics/metrics.js +2 -2
  106. package/lib/metrics/metrics.js.map +1 -1
  107. package/lib/network/processor/index.d.ts +1 -1
  108. package/lib/network/processor/index.d.ts.map +1 -1
  109. package/lib/network/processor/index.js +42 -21
  110. package/lib/network/processor/index.js.map +1 -1
  111. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  112. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +47 -34
  113. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  114. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
  115. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +23 -4
  116. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  117. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  118. package/lib/network/reqresp/handlers/index.js +20 -4
  119. package/lib/network/reqresp/handlers/index.js.map +1 -1
  120. package/lib/node/nodejs.d.ts +2 -7
  121. package/lib/node/nodejs.d.ts.map +1 -1
  122. package/lib/node/nodejs.js +2 -22
  123. package/lib/node/nodejs.js.map +1 -1
  124. package/lib/sync/interface.d.ts +1 -2
  125. package/lib/sync/interface.d.ts.map +1 -1
  126. package/lib/sync/options.d.ts +0 -6
  127. package/lib/sync/options.d.ts.map +1 -1
  128. package/lib/sync/options.js +0 -2
  129. package/lib/sync/options.js.map +1 -1
  130. package/lib/sync/types.d.ts +18 -3
  131. package/lib/sync/types.d.ts.map +1 -1
  132. package/lib/sync/types.js +19 -3
  133. package/lib/sync/types.js.map +1 -1
  134. package/lib/sync/unknownBlock.d.ts +19 -0
  135. package/lib/sync/unknownBlock.d.ts.map +1 -1
  136. package/lib/sync/unknownBlock.js +184 -15
  137. package/lib/sync/unknownBlock.js.map +1 -1
  138. package/lib/util/execution.d.ts +42 -0
  139. package/lib/util/execution.d.ts.map +1 -1
  140. package/lib/util/execution.js +123 -2
  141. package/lib/util/execution.js.map +1 -1
  142. package/lib/util/headerEnvelope.d.ts +17 -0
  143. package/lib/util/headerEnvelope.d.ts.map +1 -0
  144. package/lib/util/headerEnvelope.js +43 -0
  145. package/lib/util/headerEnvelope.js.map +1 -0
  146. package/lib/util/shuffle.d.ts +0 -4
  147. package/lib/util/shuffle.d.ts.map +1 -1
  148. package/lib/util/shuffle.js +0 -8
  149. package/lib/util/shuffle.js.map +1 -1
  150. package/package.json +16 -16
  151. package/src/api/impl/beacon/blocks/index.ts +16 -3
  152. package/src/api/impl/beacon/pool/index.ts +6 -2
  153. package/src/api/impl/validator/index.ts +3 -1
  154. package/src/chain/archiveStore/archiveStore.ts +24 -8
  155. package/src/chain/archiveStore/historicalState/metrics.ts +5 -7
  156. package/src/chain/archiveStore/utils/archiveBlocks.ts +54 -32
  157. package/src/chain/archiveStore/utils/pruneHistory.ts +4 -2
  158. package/src/chain/blocks/importExecutionPayload.ts +14 -0
  159. package/src/chain/chain.ts +96 -20
  160. package/src/chain/errors/envelopeReconstructionError.ts +22 -0
  161. package/src/chain/errors/index.ts +1 -0
  162. package/src/chain/errors/payloadAttestation.ts +2 -0
  163. package/src/chain/interface.ts +6 -1
  164. package/src/chain/options.ts +3 -5
  165. package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
  166. package/src/chain/validation/payloadAttestationMessage.ts +9 -0
  167. package/src/db/beacon.ts +0 -5
  168. package/src/db/buckets.ts +2 -2
  169. package/src/db/interface.ts +0 -3
  170. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +43 -13
  171. package/src/db/repositories/index.ts +6 -2
  172. package/src/execution/engine/disabled.ts +4 -0
  173. package/src/execution/engine/http.ts +12 -0
  174. package/src/execution/engine/interface.ts +4 -1
  175. package/src/execution/engine/mock.ts +22 -2
  176. package/src/execution/engine/types.ts +25 -0
  177. package/src/metrics/metrics/beacon.ts +16 -0
  178. package/src/metrics/metrics/lodestar.ts +58 -26
  179. package/src/metrics/metrics.ts +7 -2
  180. package/src/network/processor/index.ts +51 -22
  181. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +57 -39
  182. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +27 -5
  183. package/src/network/reqresp/handlers/index.ts +49 -5
  184. package/src/node/nodejs.ts +0 -27
  185. package/src/sync/interface.ts +1 -2
  186. package/src/sync/options.ts +0 -8
  187. package/src/sync/types.ts +19 -3
  188. package/src/sync/unknownBlock.ts +192 -14
  189. package/src/util/execution.ts +175 -2
  190. package/src/util/headerEnvelope.ts +76 -0
  191. package/src/util/shuffle.ts +0 -9
  192. package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts +0 -20
  193. package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts.map +0 -1
  194. package/lib/chain/archiveStore/utils/updateBackfillRange.js +0 -40
  195. package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +0 -1
  196. package/lib/db/repositories/backfilledRanges.d.ts +0 -18
  197. package/lib/db/repositories/backfilledRanges.d.ts.map +0 -1
  198. package/lib/db/repositories/backfilledRanges.js +0 -26
  199. package/lib/db/repositories/backfilledRanges.js.map +0 -1
  200. package/lib/sync/backfill/backfill.d.ts +0 -169
  201. package/lib/sync/backfill/backfill.d.ts.map +0 -1
  202. package/lib/sync/backfill/backfill.js +0 -686
  203. package/lib/sync/backfill/backfill.js.map +0 -1
  204. package/lib/sync/backfill/errors.d.ts +0 -30
  205. package/lib/sync/backfill/errors.d.ts.map +0 -1
  206. package/lib/sync/backfill/errors.js +0 -15
  207. package/lib/sync/backfill/errors.js.map +0 -1
  208. package/lib/sync/backfill/index.d.ts +0 -2
  209. package/lib/sync/backfill/index.d.ts.map +0 -1
  210. package/lib/sync/backfill/index.js +0 -2
  211. package/lib/sync/backfill/index.js.map +0 -1
  212. package/lib/sync/backfill/verify.d.ts +0 -18
  213. package/lib/sync/backfill/verify.d.ts.map +0 -1
  214. package/lib/sync/backfill/verify.js +0 -36
  215. package/lib/sync/backfill/verify.js.map +0 -1
  216. package/src/chain/archiveStore/utils/updateBackfillRange.ts +0 -50
  217. package/src/db/repositories/backfilledRanges.ts +0 -29
  218. package/src/sync/backfill/backfill.ts +0 -916
  219. package/src/sync/backfill/errors.ts +0 -23
  220. package/src/sync/backfill/index.ts +0 -1
  221. package/src/sync/backfill/verify.ts +0 -58
@@ -0,0 +1,22 @@
1
+ import {Slot} from "@lodestar/types";
2
+ import {LodestarError} from "@lodestar/utils";
3
+
4
+ export enum EnvelopeReconstructionErrorCode {
5
+ /** The EL failed to answer engine_getPayloadBodiesByHashV2 (transport / EL down). Transient. */
6
+ ENGINE_UNAVAILABLE = "ENVELOPE_RECONSTRUCTION_ERROR_ENGINE_UNAVAILABLE",
7
+ /** A body returned by the EL does not hash to the root stored in the header envelope. Local DB/EL inconsistency. */
8
+ BODY_ROOT_MISMATCH = "ENVELOPE_RECONSTRUCTION_ERROR_BODY_ROOT_MISMATCH",
9
+ /** A by-range stream stopped short at a slot that cannot be served; the response so far is still valid */
10
+ RANGE_UNSERVABLE = "ENVELOPE_RECONSTRUCTION_ERROR_RANGE_UNSERVABLE",
11
+ }
12
+
13
+ export type EnvelopeReconstructionErrorType =
14
+ | {code: EnvelopeReconstructionErrorCode.ENGINE_UNAVAILABLE}
15
+ | {
16
+ code: EnvelopeReconstructionErrorCode.BODY_ROOT_MISMATCH;
17
+ slot: Slot;
18
+ field: "transactions" | "withdrawals" | "blockAccessList";
19
+ }
20
+ | {code: EnvelopeReconstructionErrorCode.RANGE_UNSERVABLE; slot: Slot};
21
+
22
+ export class EnvelopeReconstructionError extends LodestarError<EnvelopeReconstructionErrorType> {}
@@ -4,6 +4,7 @@ export * from "./blobSidecarError.js";
4
4
  export * from "./blockError.js";
5
5
  export * from "./blsToExecutionChangeError.js";
6
6
  export * from "./dataColumnSidecarError.js";
7
+ export * from "./envelopeReconstructionError.js";
7
8
  export * from "./executionPayloadBid.js";
8
9
  export * from "./executionPayloadEnvelope.js";
9
10
  export * from "./gossipValidation.js";
@@ -6,6 +6,7 @@ export enum PayloadAttestationErrorCode {
6
6
  PAYLOAD_ATTESTATION_ALREADY_KNOWN = "PAYLOAD_ATTESTATION_ERROR_PAYLOAD_ATTESTATION_ALREADY_KNOWN",
7
7
  UNKNOWN_BLOCK_ROOT = "PAYLOAD_ATTESTATION_ERROR_UNKNOWN_BLOCK_ROOT",
8
8
  INVALID_BLOCK_SLOT = "PAYLOAD_ATTESTATION_ERROR_INVALID_BLOCK_SLOT",
9
+ PRE_GLOAS_SLOT = "PAYLOAD_ATTESTATION_ERROR_PRE_GLOAS_SLOT",
9
10
  INVALID_BLOCK = "PAYLOAD_ATTESTATION_ERROR_INVALID_BLOCK",
10
11
  INVALID_ATTESTER = "PAYLOAD_ATTESTATION_ERROR_INVALID_ATTESTER",
11
12
  INVALID_SIGNATURE = "PAYLOAD_ATTESTATION_ERROR_INVALID_SIGNATURE",
@@ -20,6 +21,7 @@ export type PayloadAttestationErrorType =
20
21
  }
21
22
  | {code: PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT; blockRoot: RootHex}
22
23
  | {code: PayloadAttestationErrorCode.INVALID_BLOCK_SLOT; blockRoot: RootHex; blockSlot: Slot; slot: Slot}
24
+ | {code: PayloadAttestationErrorCode.PRE_GLOAS_SLOT; slot: Slot}
23
25
  | {code: PayloadAttestationErrorCode.INVALID_BLOCK; blockRoot: RootHex}
24
26
  | {code: PayloadAttestationErrorCode.INVALID_ATTESTER; attesterIndex: ValidatorIndex}
25
27
  | {code: PayloadAttestationErrorCode.INVALID_SIGNATURE};
@@ -30,6 +30,7 @@ import {Metrics} from "../metrics/metrics.js";
30
30
  import {BufferPool} from "../util/bufferPool.js";
31
31
  import {IClock} from "../util/clock.js";
32
32
  import {CustodyConfig} from "../util/dataColumns.js";
33
+ import {ReconstructMismatchPolicy} from "../util/execution.js";
33
34
  import {SerializedCache} from "../util/serializedCache.js";
34
35
  import {IArchiveStore} from "./archiveStore/interface.js";
35
36
  import {CheckpointBalancesCache} from "./balancesCache.js";
@@ -96,7 +97,7 @@ export enum FindHeadFnName {
96
97
  export interface IBeaconChain {
97
98
  readonly genesisTime: UintNum64;
98
99
  readonly genesisValidatorsRoot: Root;
99
- readonly earliestAvailableSlot: Slot;
100
+ earliestAvailableSlot: Slot;
100
101
  readonly executionEngine: IExecutionEngine;
101
102
  readonly executionBuilder?: IExecutionBuilder;
102
103
  readonly builderCircuitBreaker: BuilderCircuitBreaker;
@@ -236,6 +237,10 @@ export interface IBeaconChain {
236
237
  indices: number[]
237
238
  ): Promise<(Uint8Array | undefined)[]>;
238
239
  getSerializedExecutionPayloadEnvelope(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null>;
240
+ getSerializedExecutionPayloadEnvelopes(
241
+ requests: {blockSlot: Slot; blockRootHex: RootHex}[],
242
+ onMismatch?: ReconstructMismatchPolicy
243
+ ): Promise<(Uint8Array | null)[]>;
239
244
  getExecutionPayloadEnvelope(
240
245
  blockSlot: Slot,
241
246
  blockRootHex: string
@@ -29,6 +29,8 @@ export type IChainOptions = BlockProcessOpts &
29
29
  blacklistedBlocks?: string[];
30
30
  // TODO GLOAS: add similar option for execution payload envelopes?
31
31
  persistProducedBlocks?: boolean;
32
+ /** Archive finalized Gloas payload envelopes as headers (bodies reconstructed from the EL on read) */
33
+ dedupePayloads?: boolean;
32
34
  persistInvalidSszObjects?: boolean;
33
35
  persistInvalidSszObjectsDir?: string;
34
36
  persistOrphanedBlocks?: boolean;
@@ -63,10 +65,6 @@ export type BlockProcessOpts = {
63
65
  * Will double processing times. Use only for debugging purposes.
64
66
  */
65
67
  disableBlsBatchVerify?: boolean;
66
- /**
67
- * Assert progressive balances the same to EpochTransitionCache
68
- */
69
- assertCorrectProgressiveBalances?: boolean;
70
68
  /** Used for fork_choice spec tests */
71
69
  disableOnBlockError?: boolean;
72
70
  /** Used for fork_choice spec tests */
@@ -109,12 +107,12 @@ export const defaultChainOptions: IChainOptions = {
109
107
  disableBlsBatchVerify: false,
110
108
  proposerBoost: true,
111
109
  proposerBoostReorg: true,
110
+ dedupePayloads: true,
112
111
  computeUnrealized: true,
113
112
  fastConfirmation: false,
114
113
  suggestedFeeRecipient: defaultValidatorOptions.suggestedFeeRecipient,
115
114
  graffitiAppend: true,
116
115
  serveHistoricalState: false,
117
- assertCorrectProgressiveBalances: false,
118
116
  archiveStateEpochFrequency: 1024,
119
117
  archiveMode: DEFAULT_ARCHIVE_MODE,
120
118
  pruneHistory: false,
@@ -1,4 +1,4 @@
1
- import {EMPTY_SIGNATURE, IBeaconStateView} from "@lodestar/state-transition";
1
+ import {EMPTY_SIGNATURE, IBeaconStateView, StateHashTreeRootSource} from "@lodestar/state-transition";
2
2
  import {BeaconBlock, BlindedBeaconBlock, Gwei, Root} from "@lodestar/types";
3
3
  import {Metrics} from "../../metrics/index.js";
4
4
 
@@ -14,5 +14,12 @@ export function computeNewStateRoot(
14
14
  ): {newStateRoot: Root; proposerReward: Gwei; postState: IBeaconStateView} {
15
15
  // Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
16
16
  const signedBlock = {message: block, signature: EMPTY_SIGNATURE};
17
- return state.computeNewStateRoot({block: signedBlock}, {metrics});
17
+ const {newStateRoot, proposerReward, postState, hashTreeRootTime} = state.computeNewStateRoot(
18
+ {block: signedBlock},
19
+ {metrics}
20
+ );
21
+
22
+ metrics?.stateHashTreeRootTime.observe({source: StateHashTreeRootSource.computeNewStateRoot}, hashTreeRootTime);
23
+
24
+ return {newStateRoot, proposerReward, postState};
18
25
  }
@@ -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, {
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,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({