@lodestar/beacon-node 1.42.0-dev.8b81ee6c3e → 1.42.0-dev.972ec54bb9

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 (204) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +22 -2
  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 -0
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/index.js +13 -10
  9. package/lib/api/impl/beacon/state/index.js.map +1 -1
  10. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  11. package/lib/api/impl/lodestar/index.js +4 -0
  12. package/lib/api/impl/lodestar/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +9 -3
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  17. package/lib/chain/blocks/importBlock.js +6 -4
  18. package/lib/chain/blocks/importBlock.js.map +1 -1
  19. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  20. package/lib/chain/blocks/importExecutionPayload.js +14 -5
  21. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  22. package/lib/chain/blocks/index.js +1 -1
  23. package/lib/chain/blocks/index.js.map +1 -1
  24. package/lib/chain/blocks/types.d.ts +3 -3
  25. package/lib/chain/blocks/types.d.ts.map +1 -1
  26. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  27. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -2
  28. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  29. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  30. package/lib/chain/blocks/verifyBlocksSignatures.js +4 -2
  31. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  32. package/lib/chain/chain.d.ts +3 -1
  33. package/lib/chain/chain.d.ts.map +1 -1
  34. package/lib/chain/chain.js +26 -9
  35. package/lib/chain/chain.js.map +1 -1
  36. package/lib/chain/emitter.d.ts +27 -5
  37. package/lib/chain/emitter.d.ts.map +1 -1
  38. package/lib/chain/emitter.js +12 -3
  39. package/lib/chain/emitter.js.map +1 -1
  40. package/lib/chain/errors/blockError.d.ts +11 -1
  41. package/lib/chain/errors/blockError.d.ts.map +1 -1
  42. package/lib/chain/errors/blockError.js +4 -0
  43. package/lib/chain/errors/blockError.js.map +1 -1
  44. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  45. package/lib/chain/forkChoice/index.js +10 -8
  46. package/lib/chain/forkChoice/index.js.map +1 -1
  47. package/lib/chain/interface.d.ts +4 -1
  48. package/lib/chain/interface.d.ts.map +1 -1
  49. package/lib/chain/interface.js.map +1 -1
  50. package/lib/chain/lightClient/index.d.ts +2 -2
  51. package/lib/chain/lightClient/index.d.ts.map +1 -1
  52. package/lib/chain/lightClient/index.js +7 -0
  53. package/lib/chain/lightClient/index.js.map +1 -1
  54. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  55. package/lib/chain/opPools/aggregatedAttestationPool.js +5 -2
  56. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  57. package/lib/chain/opPools/executionPayloadBidPool.d.ts +2 -2
  58. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
  59. package/lib/chain/opPools/executionPayloadBidPool.js +2 -2
  60. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
  61. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  62. package/lib/chain/prepareNextSlot.js +7 -1
  63. package/lib/chain/prepareNextSlot.js.map +1 -1
  64. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +3 -3
  65. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  66. package/lib/chain/produceBlock/computeNewStateRoot.js +8 -8
  67. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  68. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  69. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  70. package/lib/chain/produceBlock/produceBlockBody.js +23 -4
  71. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  72. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +1 -1
  73. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  74. package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
  75. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  76. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +1 -1
  77. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  78. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +2 -2
  79. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  80. package/lib/chain/validation/block.d.ts.map +1 -1
  81. package/lib/chain/validation/block.js +27 -5
  82. package/lib/chain/validation/block.js.map +1 -1
  83. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  84. package/lib/chain/validation/executionPayloadBid.js +7 -4
  85. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  86. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  87. package/lib/chain/validation/executionPayloadEnvelope.js +6 -1
  88. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  89. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  90. package/lib/chain/validation/payloadAttestationMessage.js +4 -1
  91. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  92. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  93. package/lib/chain/validation/syncCommittee.js +4 -0
  94. package/lib/chain/validation/syncCommittee.js.map +1 -1
  95. package/lib/chain/validation/syncCommitteeContributionAndProof.js +4 -1
  96. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  97. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  98. package/lib/chain/validatorMonitor.js +3 -3
  99. package/lib/chain/validatorMonitor.js.map +1 -1
  100. package/lib/metrics/metrics/lodestar.d.ts +20 -0
  101. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  102. package/lib/metrics/metrics/lodestar.js +33 -0
  103. package/lib/metrics/metrics/lodestar.js.map +1 -1
  104. package/lib/network/interface.d.ts +1 -0
  105. package/lib/network/interface.d.ts.map +1 -1
  106. package/lib/network/network.d.ts +1 -0
  107. package/lib/network/network.d.ts.map +1 -1
  108. package/lib/network/network.js +3 -0
  109. package/lib/network/network.js.map +1 -1
  110. package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
  111. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
  112. package/lib/network/processor/extractSlotRootFns.js +25 -5
  113. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  114. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  115. package/lib/network/processor/gossipHandlers.js +42 -12
  116. package/lib/network/processor/gossipHandlers.js.map +1 -1
  117. package/lib/network/processor/index.d.ts +11 -1
  118. package/lib/network/processor/index.d.ts.map +1 -1
  119. package/lib/network/processor/index.js +234 -22
  120. package/lib/network/processor/index.js.map +1 -1
  121. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  122. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -1
  123. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  124. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  125. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +2 -0
  126. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  127. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts +2 -2
  128. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  129. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +7 -3
  130. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  131. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  132. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +6 -0
  133. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  134. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -2
  135. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  136. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +7 -3
  137. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  138. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  139. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +2 -1
  140. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  141. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
  142. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +3 -8
  143. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  144. package/lib/node/nodejs.d.ts.map +1 -1
  145. package/lib/node/nodejs.js +4 -1
  146. package/lib/node/nodejs.js.map +1 -1
  147. package/lib/node/notifier.d.ts.map +1 -1
  148. package/lib/node/notifier.js +2 -2
  149. package/lib/node/notifier.js.map +1 -1
  150. package/lib/sync/unknownBlock.js +2 -2
  151. package/lib/sync/unknownBlock.js.map +1 -1
  152. package/lib/util/sszBytes.d.ts +25 -1
  153. package/lib/util/sszBytes.d.ts.map +1 -1
  154. package/lib/util/sszBytes.js +155 -1
  155. package/lib/util/sszBytes.js.map +1 -1
  156. package/package.json +15 -15
  157. package/src/api/impl/beacon/blocks/index.ts +31 -2
  158. package/src/api/impl/beacon/pool/index.ts +4 -0
  159. package/src/api/impl/beacon/state/index.ts +15 -15
  160. package/src/api/impl/lodestar/index.ts +4 -0
  161. package/src/api/impl/validator/index.ts +9 -2
  162. package/src/chain/blocks/importBlock.ts +11 -7
  163. package/src/chain/blocks/importExecutionPayload.ts +15 -5
  164. package/src/chain/blocks/index.ts +1 -1
  165. package/src/chain/blocks/types.ts +3 -3
  166. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +2 -1
  167. package/src/chain/blocks/verifyBlocksSignatures.ts +9 -2
  168. package/src/chain/chain.ts +35 -9
  169. package/src/chain/emitter.ts +23 -5
  170. package/src/chain/errors/blockError.ts +7 -1
  171. package/src/chain/forkChoice/index.ts +11 -8
  172. package/src/chain/interface.ts +7 -0
  173. package/src/chain/lightClient/index.ts +15 -3
  174. package/src/chain/opPools/aggregatedAttestationPool.ts +6 -1
  175. package/src/chain/opPools/executionPayloadBidPool.ts +3 -3
  176. package/src/chain/prepareNextSlot.ts +8 -0
  177. package/src/chain/produceBlock/computeNewStateRoot.ts +11 -10
  178. package/src/chain/produceBlock/produceBlockBody.ts +40 -10
  179. package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
  180. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +2 -2
  181. package/src/chain/validation/block.ts +30 -7
  182. package/src/chain/validation/executionPayloadBid.ts +7 -3
  183. package/src/chain/validation/executionPayloadEnvelope.ts +10 -1
  184. package/src/chain/validation/payloadAttestationMessage.ts +4 -0
  185. package/src/chain/validation/syncCommittee.ts +5 -1
  186. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -1
  187. package/src/chain/validatorMonitor.ts +3 -2
  188. package/src/metrics/metrics/lodestar.ts +34 -0
  189. package/src/network/interface.ts +1 -0
  190. package/src/network/network.ts +4 -0
  191. package/src/network/processor/extractSlotRootFns.ts +32 -6
  192. package/src/network/processor/gossipHandlers.ts +49 -12
  193. package/src/network/processor/index.ts +304 -22
  194. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +3 -1
  195. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +3 -0
  196. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +15 -3
  197. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +11 -0
  198. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +19 -3
  199. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +3 -1
  200. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +3 -12
  201. package/src/node/nodejs.ts +5 -2
  202. package/src/node/notifier.ts +7 -2
  203. package/src/sync/unknownBlock.ts +3 -3
  204. package/src/util/sszBytes.ts +203 -1
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ExecutionStatus, PayloadExecutionStatus} from "@lodestar/fork-choice";
3
3
  import {SLOTS_PER_EPOCH} from "@lodestar/params";
4
- import {getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
4
+ import {getExecutionPayloadEnvelopeSignatureSet, isStatePostGloas} from "@lodestar/state-transition";
5
5
  import {byteArrayEquals, fromHex, toRootHex} from "@lodestar/utils";
6
6
  import {ExecutionPayloadStatus} from "../../execution/index.js";
7
7
  import {isQueueErrorAborted} from "../../util/queue/index.js";
@@ -96,7 +96,7 @@ export async function importExecutionPayload(
96
96
  // is already complete, so the payload and required data are available for payload attestation.
97
97
  // This event is only about availability, not validity of the execution payload, hence we can emit
98
98
  // it before getting a response from the execution client on whether the payload is valid or not.
99
- if (this.clock.currentSlot === envelope.slot) {
99
+ if (this.clock.currentSlot - envelope.slot < EVENTSTREAM_EMIT_RECENT_EXECUTION_PAYLOAD_SLOTS) {
100
100
  this.emitter.emit(routes.events.EventType.executionPayloadAvailable, {
101
101
  slot: envelope.slot,
102
102
  blockRoot: blockRootHex,
@@ -124,6 +124,12 @@ export async function importExecutionPayload(
124
124
  {dontTransferCache: true},
125
125
  RegenCaller.processBlock
126
126
  );
127
+ if (!isStatePostGloas(blockState)) {
128
+ throw new PayloadError({
129
+ code: PayloadErrorCode.STATE_TRANSITION_ERROR,
130
+ message: `Expected gloas+ block state for payload import, got fork=${blockState.forkName}`,
131
+ });
132
+ }
127
133
 
128
134
  // 5. Run verification steps in parallel
129
135
  // Note: No data availability check needed here - importExecutionPayload is only
@@ -218,7 +224,7 @@ export async function importExecutionPayload(
218
224
  if (!isQueueErrorAborted(e)) {
219
225
  this.logger.error(
220
226
  "Error pushing payload envelope to unfinalized write queue",
221
- {slot: envelope.slot, root: blockRootHex},
227
+ {slot: envelope.slot, blockRoot: blockRootHex},
222
228
  e as Error
223
229
  );
224
230
  }
@@ -246,6 +252,8 @@ export async function importExecutionPayload(
246
252
  this.metrics?.importPayload.columnsBySource.inc({source});
247
253
  }
248
254
 
255
+ const stateRootHex = toRootHex(envelope.stateRoot);
256
+
249
257
  // 10. Emit event after payload is fully verified and imported to fork choice, only for recent enough payloads
250
258
  if (this.clock.currentSlot - envelope.slot < EVENTSTREAM_EMIT_RECENT_EXECUTION_PAYLOAD_SLOTS) {
251
259
  this.emitter.emit(routes.events.EventType.executionPayload, {
@@ -253,7 +261,7 @@ export async function importExecutionPayload(
253
261
  builderIndex: envelope.builderIndex,
254
262
  blockHash: blockHashHex,
255
263
  blockRoot: blockRootHex,
256
- stateRoot: toRootHex(envelope.stateRoot),
264
+ stateRoot: stateRootHex,
257
265
  // TODO GLOAS: revisit once we support optimistic import
258
266
  executionOptimistic: false,
259
267
  });
@@ -261,7 +269,9 @@ export async function importExecutionPayload(
261
269
 
262
270
  this.logger.verbose("Execution payload imported", {
263
271
  slot: envelope.slot,
264
- root: blockRootHex,
272
+ builderIndex: envelope.builderIndex,
273
+ blockRoot: blockRootHex,
265
274
  blockHash: blockHashHex,
275
+ stateRoot: stateRootHex,
266
276
  });
267
277
  }
@@ -89,7 +89,7 @@ export async function processBlocks(
89
89
  (block, i): FullyVerifiedBlock => ({
90
90
  blockInput: block,
91
91
  postBlockState: postStates[i],
92
- postEnvelopeState: null,
92
+ postPayloadState: null,
93
93
  parentBlockSlot: parentSlots[i],
94
94
  executionStatus: executionStatuses[i],
95
95
  // start supporting optimistic syncing/processing
@@ -103,7 +103,7 @@ type FullyVerifiedBlockBase = {
103
103
  /**
104
104
  * A wrapper around a `SignedBeaconBlock` that indicates that this block is fully verified and ready to import.
105
105
  *
106
- * Discriminated union on `postEnvelopeState`:
106
+ * Discriminated union on `postPayloadState`:
107
107
  * - `null` → block has no pre-verified envelope; `executionStatus` is any `BlockExecutionStatus`
108
108
  * - non-null → envelope was pre-verified during state transition; `executionStatus` is narrowed to
109
109
  * `Valid | Syncing` (matching what `forkChoice.onExecutionPayload` expects)
@@ -111,12 +111,12 @@ type FullyVerifiedBlockBase = {
111
111
  export type FullyVerifiedBlock = FullyVerifiedBlockBase &
112
112
  (
113
113
  | {
114
- postEnvelopeState: null;
114
+ postPayloadState: null;
115
115
  /** If the execution payload couldn't be verified because of EL syncing status, used in optimistic sync or for merge block */
116
116
  executionStatus: BlockExecutionStatus;
117
117
  }
118
118
  | {
119
- postEnvelopeState: IBeaconStateView;
119
+ postPayloadState: IBeaconStateView;
120
120
  executionStatus: PayloadExecutionStatus;
121
121
  }
122
122
  );
@@ -8,7 +8,7 @@ import {
8
8
  ProtoBlock,
9
9
  } from "@lodestar/fork-choice";
10
10
  import {ForkSeq} from "@lodestar/params";
11
- import {IBeaconStateView, isExecutionBlockBodyType} from "@lodestar/state-transition";
11
+ import {IBeaconStateView, isExecutionBlockBodyType, isStatePostBellatrix} from "@lodestar/state-transition";
12
12
  import {bellatrix, electra} from "@lodestar/types";
13
13
  import {ErrorAborted, Logger, toRootHex} from "@lodestar/utils";
14
14
  import {ExecutionPayloadStatus, IExecutionEngine} from "../../execution/engine/interface.js";
@@ -152,6 +152,7 @@ export async function verifyBlockExecutionPayload(
152
152
 
153
153
  /** Not null if execution is enabled */
154
154
  const executionPayloadEnabled =
155
+ isStatePostBellatrix(preState0) &&
155
156
  preState0.isExecutionStateType &&
156
157
  isExecutionBlockBodyType(block.message.body) &&
157
158
  preState0.isExecutionEnabled(block.message)
@@ -1,5 +1,10 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {IBeaconStateView, getBlockSignatureSets} from "@lodestar/state-transition";
2
+ import {
3
+ IBeaconStateView,
4
+ SyncCommitteeCacheEmpty,
5
+ getBlockSignatureSets,
6
+ isStatePostAltair,
7
+ } from "@lodestar/state-transition";
3
8
  import {IndexedAttestation, SignedBeaconBlock} from "@lodestar/types";
4
9
  import {Logger} from "@lodestar/utils";
5
10
  import {Metrics} from "../../metrics/metrics.js";
@@ -27,7 +32,9 @@ export async function verifyBlocksSignatures(
27
32
  ): Promise<{verifySignaturesTime: number}> {
28
33
  const isValidPromises: Promise<boolean>[] = [];
29
34
  const recvToValLatency = Date.now() / 1000 - (opts.seenTimestampSec ?? Date.now() / 1000);
30
- const currentSyncCommitteeIndexed = preState0.currentSyncCommitteeIndexed;
35
+ const currentSyncCommitteeIndexed = isStatePostAltair(preState0)
36
+ ? preState0.currentSyncCommitteeIndexed
37
+ : new SyncCommitteeCacheEmpty();
31
38
 
32
39
  // Verifies signatures after running state transition, so all SyncCommittee signed roots are known at this point.
33
40
  // We must ensure block.slot <= state.slot before running getAllBlockSignatureSets().
@@ -18,7 +18,6 @@ import {
18
18
  type ForkPostGloas,
19
19
  GENESIS_SLOT,
20
20
  SLOTS_PER_EPOCH,
21
- isForkPostElectra,
22
21
  isForkPostGloas,
23
22
  } from "@lodestar/params";
24
23
  import {
@@ -30,6 +29,9 @@ import {
30
29
  computeEpochAtSlot,
31
30
  computeStartSlotAtEpoch,
32
31
  getEffectiveBalancesFromStateBytes,
32
+ isStatePostAltair,
33
+ isStatePostElectra,
34
+ isStatePostGloas,
33
35
  } from "@lodestar/state-transition";
34
36
  import {
35
37
  BeaconBlock,
@@ -98,7 +100,7 @@ import {
98
100
  } from "./opPools/index.js";
99
101
  import {IChainOptions} from "./options.js";
100
102
  import {PrepareNextSlotScheduler} from "./prepareNextSlot.js";
101
- import {computeEnvelopeStateRoot, computeNewStateRoot} from "./produceBlock/computeNewStateRoot.js";
103
+ import {computeNewStateRoot, computePayloadEnvelopeStateRoot} from "./produceBlock/computeNewStateRoot.js";
102
104
  import {AssembledBlockType, BlockType, ProduceFullGloas, ProduceResult} from "./produceBlock/index.js";
103
105
  import {BlockAttributes, produceBlockBody, produceCommonBlockBody} from "./produceBlock/produceBlockBody.js";
104
106
  import {QueuedStateRegenerator, RegenCaller} from "./regen/index.js";
@@ -505,7 +507,11 @@ export class BeaconChain implements IBeaconChain {
505
507
  }
506
508
 
507
509
  seenBlock(blockRoot: RootHex): boolean {
508
- return this.seenBlockInputCache.has(blockRoot) || this.forkChoice.hasBlockHex(blockRoot);
510
+ return this.seenBlockInputCache.hasBlock(blockRoot) || this.forkChoice.hasBlockHexUnsafe(blockRoot);
511
+ }
512
+
513
+ seenPayloadEnvelope(blockRoot: RootHex): boolean {
514
+ return this.seenPayloadEnvelopeInputCache.hasPayload(blockRoot) || this.forkChoice.hasPayloadHexUnsafe(blockRoot);
509
515
  }
510
516
 
511
517
  regenCanAcceptWork(): boolean {
@@ -874,6 +880,22 @@ export class BeaconChain implements IBeaconChain {
874
880
  );
875
881
  }
876
882
 
883
+ async getExecutionPayloadEnvelope(
884
+ blockSlot: Slot,
885
+ blockRootHex: string
886
+ ): Promise<gloas.SignedExecutionPayloadEnvelope | null> {
887
+ const payloadInput = this.seenPayloadEnvelopeInputCache.get(blockRootHex);
888
+ if (payloadInput?.hasPayloadEnvelope()) {
889
+ return payloadInput.getPayloadEnvelope();
890
+ }
891
+
892
+ return (
893
+ (await this.db.executionPayloadEnvelope.get(fromHex(blockRootHex))) ??
894
+ (await this.db.executionPayloadEnvelopeArchive.get(blockSlot)) ??
895
+ null
896
+ );
897
+ }
898
+
877
899
  async getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<DataColumnSidecar[]> {
878
900
  const fork = this.config.getForkName(blockSlot);
879
901
 
@@ -1048,7 +1070,7 @@ export class BeaconChain implements IBeaconChain {
1048
1070
  body,
1049
1071
  } as AssembledBlockType<T>;
1050
1072
 
1051
- const {newStateRoot, proposerReward, postState} = computeNewStateRoot(this.metrics, state, block);
1073
+ const {newStateRoot, proposerReward, postBlockState} = computeNewStateRoot(this.metrics, state, block);
1052
1074
  block.stateRoot = newStateRoot;
1053
1075
  const blockRoot =
1054
1076
  produceResult.type === BlockType.Full
@@ -1072,8 +1094,11 @@ export class BeaconChain implements IBeaconChain {
1072
1094
  slot,
1073
1095
  stateRoot: ZERO_HASH,
1074
1096
  };
1075
- const envelopeStateRoot = computeEnvelopeStateRoot(this.metrics, postState, envelope);
1076
- gloasResult.envelopeStateRoot = envelopeStateRoot;
1097
+ if (!isStatePostGloas(postBlockState)) {
1098
+ throw Error(`Expected gloas+ post-state for execution payload envelope, got fork=${postBlockState.forkName}`);
1099
+ }
1100
+ const payloadEnvelopeStateRoot = computePayloadEnvelopeStateRoot(this.metrics, postBlockState, envelope);
1101
+ gloasResult.payloadEnvelopeStateRoot = payloadEnvelopeStateRoot;
1077
1102
  }
1078
1103
 
1079
1104
  // Track the produced block for consensus broadcast validations, later validation, etc.
@@ -1400,9 +1425,7 @@ export class BeaconChain implements IBeaconChain {
1400
1425
  metrics.chain.blacklistedBlocks.set(this.blacklistedBlocks.size);
1401
1426
 
1402
1427
  const headState = this.getHeadState();
1403
- const fork = this.config.getForkName(headState.slot);
1404
-
1405
- if (isForkPostElectra(fork)) {
1428
+ if (isStatePostElectra(headState)) {
1406
1429
  metrics.pendingDeposits.set(headState.pendingDepositsCount);
1407
1430
  metrics.pendingPartialWithdrawals.set(headState.pendingPartialWithdrawalsCount);
1408
1431
  metrics.pendingConsolidations.set(headState.pendingConsolidationsCount);
@@ -1649,6 +1672,9 @@ export class BeaconChain implements IBeaconChain {
1649
1672
  }
1650
1673
 
1651
1674
  preState = preState.processSlots(block.slot); // Dial preState's slot to block.slot
1675
+ if (!isStatePostAltair(preState)) {
1676
+ throw new Error("Sync committee rewards are not supported before Altair");
1677
+ }
1652
1678
 
1653
1679
  return preState.computeSyncCommitteeRewards(block, validatorIds ?? []);
1654
1680
  }
@@ -4,6 +4,7 @@ import {routes} from "@lodestar/api";
4
4
  import {CheckpointWithPayloadStatus} from "@lodestar/fork-choice";
5
5
  import {IBeaconStateView} from "@lodestar/state-transition";
6
6
  import {DataColumnSidecar, RootHex, deneb, phase0} from "@lodestar/types";
7
+ import {SignedExecutionPayloadEnvelope} from "@lodestar/types/gloas";
7
8
  import {PeerIdStr} from "../util/peerId.js";
8
9
  import {BlockInputSource, IBlockInput} from "./blocks/blockInput/types.js";
9
10
 
@@ -54,13 +55,22 @@ export enum ChainEvent {
54
55
  */
55
56
  updateStatus = "updateStatus",
56
57
  /**
57
- * Trigger a BlockInputSync for blocks where the parentRoot is not known to fork choice
58
+ * Trigger BlockInputSync to find parent of a SignedBeaconBlock received
59
+ * Post-gloas, missing parent could be a SignedBeaconBlock and/or a SignedExecutionPayloadEnvelope
58
60
  */
59
- unknownParent = "unknownParent",
61
+ blockUnknownParent = "blockUnknownParent",
60
62
  /**
61
- * Trigger BlockInputSync for objects that correspond to a block that is not known to fork choice
63
+ * Trigger BlockInputSync to find a SignedBeaconBlock given a SignedExecutionPayloadEnvelop received
64
+ */
65
+ envelopeUnknownBlock = "envelopeUnknownBlock",
66
+ /**
67
+ * Trigger BlockInputSync to find a SignedBeaconBlock with specified block root.
62
68
  */
63
69
  unknownBlockRoot = "unknownBlockRoot",
70
+ /**
71
+ * Trigger BlockInputSync to find a SignedExecutionPayloadEnvelope with specified block root.
72
+ */
73
+ unknownEnvelopeBlockRoot = "unknownEnvelopeBlockRoot",
64
74
  /**
65
75
  * Trigger BlockInputSync for blocks that are partially received via gossip but are not complete by time the
66
76
  * cut-off window passes for waiting on gossip
@@ -75,9 +85,15 @@ export type ReorgEventData = routes.events.EventData[routes.events.EventType.cha
75
85
  type ApiEvents = {[K in routes.events.EventType]: (data: routes.events.EventData[K]) => void};
76
86
 
77
87
  export type ChainEventData = {
78
- [ChainEvent.unknownParent]: {blockInput: IBlockInput; peer: PeerIdStr; source: BlockInputSource};
88
+ [ChainEvent.blockUnknownParent]: {blockInput: IBlockInput; peer: PeerIdStr; source: BlockInputSource};
89
+ [ChainEvent.envelopeUnknownBlock]: {
90
+ envelope: SignedExecutionPayloadEnvelope;
91
+ peer?: PeerIdStr;
92
+ source: BlockInputSource;
93
+ };
79
94
  [ChainEvent.unknownBlockRoot]: {rootHex: RootHex; peer?: PeerIdStr; source: BlockInputSource};
80
95
  [ChainEvent.incompleteBlockInput]: {blockInput: IBlockInput; peer: PeerIdStr; source: BlockInputSource};
96
+ [ChainEvent.unknownEnvelopeBlockRoot]: {rootHex: RootHex; peer?: PeerIdStr; source: BlockInputSource};
81
97
  };
82
98
 
83
99
  export type IChainEvents = ApiEvents & {
@@ -96,9 +112,11 @@ export type IChainEvents = ApiEvents & {
96
112
 
97
113
  // Sync events that are chain->chain. Initiated from network requests but do not cross the network
98
114
  // barrier so are considered ChainEvent(s).
99
- [ChainEvent.unknownParent]: (data: ChainEventData[ChainEvent.unknownParent]) => void;
115
+ [ChainEvent.blockUnknownParent]: (data: ChainEventData[ChainEvent.blockUnknownParent]) => void;
116
+ [ChainEvent.envelopeUnknownBlock]: (data: ChainEventData[ChainEvent.envelopeUnknownBlock]) => void;
100
117
  [ChainEvent.unknownBlockRoot]: (data: ChainEventData[ChainEvent.unknownBlockRoot]) => void;
101
118
  [ChainEvent.incompleteBlockInput]: (data: ChainEventData[ChainEvent.incompleteBlockInput]) => void;
119
+ [ChainEvent.unknownEnvelopeBlockRoot]: (data: ChainEventData[ChainEvent.unknownEnvelopeBlockRoot]) => void;
102
120
  };
103
121
 
104
122
  /**
@@ -70,6 +70,10 @@ export enum BlockErrorCode {
70
70
  TOO_MANY_KZG_COMMITMENTS = "BLOCK_ERROR_TOO_MANY_KZG_COMMITMENTS",
71
71
  /** Bid parent block root does not match block parent root */
72
72
  BID_PARENT_ROOT_MISMATCH = "BLOCK_ERROR_BID_PARENT_ROOT_MISMATCH",
73
+ /** The parent block's execution payload has been verified as invalid */
74
+ PARENT_EXECUTION_INVALID = "BLOCK_ERROR_PARENT_EXECUTION_INVALID",
75
+ /** The block's parent execution payload (defined by bid.parent_block_hash) has not been seen */
76
+ PARENT_PAYLOAD_UNKNOWN = "BLOCK_ERROR_PARENT_PAYLOAD_UNKNOWN",
73
77
  }
74
78
 
75
79
  type ExecutionErrorStatus = Exclude<
@@ -114,7 +118,9 @@ export type BlockErrorType =
114
118
  | {code: BlockErrorCode.EXECUTION_ENGINE_ERROR; execStatus: ExecutionErrorStatus; errorMessage: string}
115
119
  | {code: BlockErrorCode.DATA_UNAVAILABLE}
116
120
  | {code: BlockErrorCode.TOO_MANY_KZG_COMMITMENTS; blobKzgCommitmentsLen: number; commitmentLimit: number}
117
- | {code: BlockErrorCode.BID_PARENT_ROOT_MISMATCH; bidParentRoot: RootHex; blockParentRoot: RootHex};
121
+ | {code: BlockErrorCode.BID_PARENT_ROOT_MISMATCH; bidParentRoot: RootHex; blockParentRoot: RootHex}
122
+ | {code: BlockErrorCode.PARENT_EXECUTION_INVALID; parentRoot: RootHex}
123
+ | {code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN; parentBlockHash: RootHex};
118
124
 
119
125
  export class BlockGossipError extends GossipActionError<BlockErrorType> {}
120
126
 
@@ -10,12 +10,14 @@ import {
10
10
  ForkChoiceOpts as RawForkChoiceOpts,
11
11
  getCheckpointPayloadStatus,
12
12
  } from "@lodestar/fork-choice";
13
- import {ForkSeq, ZERO_HASH_HEX} from "@lodestar/params";
13
+ import {ZERO_HASH_HEX} from "@lodestar/params";
14
14
  import {
15
15
  DataAvailabilityStatus,
16
16
  IBeaconStateView,
17
17
  computeEpochAtSlot,
18
18
  computeStartSlotAtEpoch,
19
+ isStatePostBellatrix,
20
+ isStatePostGloas,
19
21
  } from "@lodestar/state-transition";
20
22
  import {Slot, ssz} from "@lodestar/types";
21
23
  import {Logger, toRootHex} from "@lodestar/utils";
@@ -142,19 +144,19 @@ export function initializeForkChoiceFromFinalizedState(
142
144
  unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
143
145
  unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
144
146
 
145
- ...(state.isExecutionStateType && state.isMergeTransitionComplete
147
+ ...(isStatePostBellatrix(state) && state.isExecutionStateType && state.isMergeTransitionComplete
146
148
  ? {
147
149
  executionPayloadBlockHash: toRootHex(state.latestBlockHash),
148
150
  // TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
149
151
  // latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
150
- executionPayloadNumber: config.getForkSeq(state.slot) >= ForkSeq.gloas ? 0 : state.payloadBlockNumber,
152
+ executionPayloadNumber: isStatePostGloas(state) ? 0 : state.payloadBlockNumber,
151
153
  executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
152
154
  }
153
155
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
154
156
 
155
157
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
156
158
  payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
157
- parentBlockHash: isForkPostGloas ? toRootHex(state.latestBlockHash) : null,
159
+ parentBlockHash: isStatePostGloas(state) ? toRootHex(state.latestBlockHash) : null,
158
160
  },
159
161
  currentSlot
160
162
  ),
@@ -237,20 +239,21 @@ export function initializeForkChoiceFromUnfinalizedState(
237
239
  unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
238
240
  unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
239
241
 
240
- ...(unfinalizedState.isExecutionStateType && unfinalizedState.isMergeTransitionComplete
242
+ ...(isStatePostBellatrix(unfinalizedState) &&
243
+ unfinalizedState.isExecutionStateType &&
244
+ unfinalizedState.isMergeTransitionComplete
241
245
  ? {
242
246
  executionPayloadBlockHash: toRootHex(unfinalizedState.latestBlockHash),
243
247
  // TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
244
248
  // latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
245
- executionPayloadNumber:
246
- config.getForkSeq(unfinalizedState.slot) >= ForkSeq.gloas ? 0 : unfinalizedState.payloadBlockNumber,
249
+ executionPayloadNumber: isStatePostGloas(unfinalizedState) ? 0 : unfinalizedState.payloadBlockNumber,
247
250
  executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
248
251
  }
249
252
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
250
253
 
251
254
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
252
255
  payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
253
- parentBlockHash: isForkPostGloas ? toRootHex(unfinalizedState.latestBlockHash) : null,
256
+ parentBlockHash: isStatePostGloas(unfinalizedState) ? toRootHex(unfinalizedState.latestBlockHash) : null,
254
257
  };
255
258
 
256
259
  const parentSlot = blockHeader.slot - 1;
@@ -18,6 +18,7 @@ import {
18
18
  altair,
19
19
  capella,
20
20
  deneb,
21
+ gloas,
21
22
  phase0,
22
23
  rewards,
23
24
  } from "@lodestar/types";
@@ -159,6 +160,8 @@ export interface IBeaconChain {
159
160
  close(): Promise<void>;
160
161
  /** Chain has seen the specified block root or not. The block may not be processed yet, use forkchoice.hasBlock to check it */
161
162
  seenBlock(blockRoot: RootHex): boolean;
163
+ /** Chain has seen a SignedExecutionPayloadEnvelope for this block root (via seenCache or fork choice FULL variant) */
164
+ seenPayloadEnvelope(blockRoot: RootHex): boolean;
162
165
  /** Populate in-memory caches with persisted data. Call at least once on startup */
163
166
  loadFromDisk(): Promise<void>;
164
167
  /** Persist in-memory data to the DB. Call at least once before stopping the process */
@@ -224,6 +227,10 @@ export interface IBeaconChain {
224
227
  indices: number[]
225
228
  ): Promise<(Uint8Array | undefined)[]>;
226
229
  getSerializedExecutionPayloadEnvelope(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null>;
230
+ getExecutionPayloadEnvelope(
231
+ blockSlot: Slot,
232
+ blockRootHex: string
233
+ ): Promise<gloas.SignedExecutionPayloadEnvelope | null>;
227
234
 
228
235
  produceCommonBlockBody(blockAttributes: BlockAttributes): Promise<CommonBlockBody>;
229
236
  produceBlock(blockAttributes: BlockAttributes & {commonBlockBodyPromise: Promise<CommonBlockBody>}): Promise<{
@@ -21,7 +21,7 @@ import {
21
21
  isForkPostElectra,
22
22
  } from "@lodestar/params";
23
23
  import {
24
- IBeaconStateView,
24
+ type IBeaconStateViewAltair,
25
25
  computeStartSlotAtEpoch,
26
26
  computeSyncPeriodAtEpoch,
27
27
  computeSyncPeriodAtSlot,
@@ -260,7 +260,11 @@ export class LightClientServer {
260
260
  * - Persist state witness
261
261
  * - Use block's syncAggregate
262
262
  */
263
- onImportBlockHead(block: BeaconBlock<ForkPostAltair>, postState: IBeaconStateView, parentBlockSlot: Slot): void {
263
+ onImportBlockHead(
264
+ block: BeaconBlock<ForkPostAltair>,
265
+ postState: IBeaconStateViewAltair,
266
+ parentBlockSlot: Slot
267
+ ): void {
264
268
  // TEMP: To disable this functionality for fork_choice spec tests.
265
269
  // Since the tests have deep-reorgs attested data is not available often printing lots of error logs.
266
270
  // While this function is only called for head blocks, best to disable.
@@ -268,6 +272,14 @@ export class LightClientServer {
268
272
  return;
269
273
  }
270
274
 
275
+ // TODO GLOAS: Light client updates for gloas are not yet updated in the spec.
276
+ // The block body no longer contains execution payload, so `blockToLightClientHeader`
277
+ // cannot construct a header from a gloas block. Skip all light client processing
278
+ // for post-gloas blocks, revisit once there is a spec for it.
279
+ if (this.config.getForkSeq(block.slot) >= ForkSeq.gloas) {
280
+ return;
281
+ }
282
+
271
283
  // What is the syncAggregate signing?
272
284
  // From the state-transition
273
285
  // ```
@@ -396,7 +408,7 @@ export class LightClientServer {
396
408
 
397
409
  private async persistPostBlockImportData(
398
410
  block: BeaconBlock<ForkPostAltair>,
399
- postState: IBeaconStateView,
411
+ postState: IBeaconStateViewAltair,
400
412
  parentBlockSlot: Slot
401
413
  ): Promise<void> {
402
414
  const blockSlot = block.slot;
@@ -26,6 +26,8 @@ import {
26
26
  computeSlotsSinceEpochStart,
27
27
  computeStartSlotAtEpoch,
28
28
  getAttestationParticipationStatus,
29
+ isStatePostAltair,
30
+ isStatePostGloas,
29
31
  } from "@lodestar/state-transition";
30
32
  import {Attestation, Epoch, RootHex, Slot, electra, isElectraAttestation, phase0, ssz} from "@lodestar/types";
31
33
  import {MapDef, assert, toRootHex} from "@lodestar/utils";
@@ -359,7 +361,7 @@ export class AggregatedAttestationPool {
359
361
  inclusionDistance,
360
362
  stateEpoch,
361
363
  rootCache,
362
- ForkSeq[fork] >= ForkSeq.gloas ? state.executionPayloadAvailability : null
364
+ isStatePostGloas(state) ? state.executionPayloadAvailability : null
363
365
  );
364
366
 
365
367
  const weight =
@@ -742,6 +744,9 @@ export function getNotSeenValidatorsFn(
742
744
  if (config.getForkName(stateSlot) === ForkName.phase0) {
743
745
  throw new Error("getNotSeenValidatorsFn is not supported phase0 state");
744
746
  }
747
+ if (!isStatePostAltair(state)) {
748
+ throw new Error("Expected Altair state for participation tracking");
749
+ }
745
750
 
746
751
  // altair and future forks
747
752
  // Get attestations to be included in an altair block.
@@ -59,13 +59,13 @@ export class ExecutionPayloadBidPool {
59
59
  }
60
60
 
61
61
  /**
62
- * Return the highest-value bid matching slot, parent block root, and parent block hash.
62
+ * Return the highest-value bid matching slot, parent block hash, and parent block root.
63
63
  * Used for gossip validation and block production.
64
64
  */
65
65
  getBestBid(
66
- parentBlockRoot: BlockRootHex,
66
+ slot: Slot,
67
67
  parentBlockHash: BlockHashHex,
68
- slot: Slot
68
+ parentBlockRoot: BlockRootHex
69
69
  ): gloas.ExecutionPayloadBid | null {
70
70
  const bidByParentHash = this.bidByParentHashByParentRootBySlot.get(slot)?.get(parentBlockRoot);
71
71
  return bidByParentHash?.get(parentBlockHash) ?? null;
@@ -7,6 +7,7 @@ import {
7
7
  StateHashTreeRootSource,
8
8
  computeEpochAtSlot,
9
9
  computeTimeAtSlot,
10
+ isStatePostBellatrix,
10
11
  } from "@lodestar/state-transition";
11
12
  import {Slot} from "@lodestar/types";
12
13
  import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
@@ -159,6 +160,9 @@ export class PrepareNextSlotScheduler {
159
160
  const preparationTime =
160
161
  computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
161
162
  this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
163
+ if (!isStatePostBellatrix(updatedPrepareState)) {
164
+ throw new Error("Expected Bellatrix state for payload preparation");
165
+ }
162
166
 
163
167
  const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice);
164
168
  const finalizedBlockHash =
@@ -183,6 +187,10 @@ export class PrepareNextSlotScheduler {
183
187
  });
184
188
  }
185
189
 
190
+ if (!isStatePostBellatrix(updatedPrepareState)) {
191
+ throw new Error("Expected Bellatrix state for payload attributes");
192
+ }
193
+
186
194
  this.computeStateHashTreeRoot(updatedPrepareState, isEpochTransition);
187
195
 
188
196
  // If emitPayloadAttributes is true emit a SSE payloadAttributes event
@@ -3,6 +3,7 @@ import {
3
3
  ExecutionPayloadStatus,
4
4
  G2_POINT_AT_INFINITY,
5
5
  IBeaconStateView,
6
+ IBeaconStateViewGloas,
6
7
  StateHashTreeRootSource,
7
8
  } from "@lodestar/state-transition";
8
9
  import {BeaconBlock, BlindedBeaconBlock, Gwei, Root, gloas} from "@lodestar/types";
@@ -18,11 +19,11 @@ export function computeNewStateRoot(
18
19
  metrics: Metrics | null,
19
20
  state: IBeaconStateView,
20
21
  block: BeaconBlock | BlindedBeaconBlock
21
- ): {newStateRoot: Root; proposerReward: Gwei; postState: IBeaconStateView} {
22
+ ): {newStateRoot: Root; proposerReward: Gwei; postBlockState: IBeaconStateView} {
22
23
  // Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
23
24
  const blockEmptySig = {message: block, signature: ZERO_HASH};
24
25
 
25
- const postState = state.stateTransition(
26
+ const postBlockState = state.stateTransition(
26
27
  blockEmptySig,
27
28
  {
28
29
  // ExecutionPayloadStatus.valid: Assume payload valid, it has been produced by a trusted EL
@@ -41,16 +42,16 @@ export function computeNewStateRoot(
41
42
  {metrics}
42
43
  );
43
44
 
44
- const {attestations, syncAggregate, slashing} = postState.proposerRewards;
45
+ const {attestations, syncAggregate, slashing} = postBlockState.proposerRewards;
45
46
  const proposerReward = BigInt(attestations + syncAggregate + slashing);
46
47
 
47
48
  const hashTreeRootTimer = metrics?.stateHashTreeRootTime.startTimer({
48
49
  source: StateHashTreeRootSource.computeNewStateRoot,
49
50
  });
50
- const newStateRoot = postState.hashTreeRoot();
51
+ const newStateRoot = postBlockState.hashTreeRoot();
51
52
  hashTreeRootTimer?.();
52
53
 
53
- return {newStateRoot, proposerReward, postState};
54
+ return {newStateRoot, proposerReward, postBlockState};
54
55
  }
55
56
 
56
57
  /**
@@ -58,9 +59,9 @@ export function computeNewStateRoot(
58
59
  * Similar to `computeNewStateRoot` but for payload envelope processing.
59
60
  *
60
61
  */
61
- export function computeEnvelopeStateRoot(
62
+ export function computePayloadEnvelopeStateRoot(
62
63
  metrics: Metrics | null,
63
- postBlockState: IBeaconStateView,
64
+ postBlockState: IBeaconStateViewGloas,
64
65
  envelope: gloas.ExecutionPayloadEnvelope
65
66
  ): Root {
66
67
  const signedEnvelope: gloas.SignedExecutionPayloadEnvelope = {
@@ -69,7 +70,7 @@ export function computeEnvelopeStateRoot(
69
70
  };
70
71
 
71
72
  const processEnvelopeTimer = metrics?.blockPayload.executionPayloadEnvelopeProcessingTime.startTimer();
72
- const postEnvelopeState = postBlockState.processExecutionPayloadEnvelope(signedEnvelope, {
73
+ const postPayloadState = postBlockState.processExecutionPayloadEnvelope(signedEnvelope, {
73
74
  // Signature is zero-ed (G2_POINT_AT_INFINITY), skip verification
74
75
  verifySignature: false,
75
76
  // State root is being computed here, the envelope doesn't have it yet
@@ -80,9 +81,9 @@ export function computeEnvelopeStateRoot(
80
81
  processEnvelopeTimer?.();
81
82
 
82
83
  const hashTreeRootTimer = metrics?.stateHashTreeRootTime.startTimer({
83
- source: StateHashTreeRootSource.computeEnvelopeStateRoot,
84
+ source: StateHashTreeRootSource.computePayloadEnvelopeStateRoot,
84
85
  });
85
- const stateRoot = postEnvelopeState.hashTreeRoot();
86
+ const stateRoot = postPayloadState.hashTreeRoot();
86
87
  hashTreeRootTimer?.();
87
88
 
88
89
  return stateRoot;