@lodestar/beacon-node 1.43.0-dev.aef3645690 → 1.43.0-dev.b741495bdc

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 (219) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +1 -4
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/state/utils.d.ts +2 -2
  5. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  6. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  7. package/lib/api/impl/validator/index.d.ts.map +1 -1
  8. package/lib/api/impl/validator/index.js +1 -4
  9. package/lib/api/impl/validator/index.js.map +1 -1
  10. package/lib/chain/GetBlobsTracker.d.ts +1 -1
  11. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  12. package/lib/chain/GetBlobsTracker.js +1 -2
  13. package/lib/chain/GetBlobsTracker.js.map +1 -1
  14. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  15. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  16. package/lib/chain/archiveStore/interface.d.ts +4 -4
  17. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  18. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  19. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  20. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +2 -4
  21. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  22. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
  23. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  24. package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
  25. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  26. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  27. package/lib/chain/blocks/importBlock.js +27 -35
  28. package/lib/chain/blocks/importBlock.js.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts +15 -14
  30. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.js +63 -85
  32. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  33. package/lib/chain/blocks/index.d.ts.map +1 -1
  34. package/lib/chain/blocks/index.js +1 -2
  35. package/lib/chain/blocks/index.js.map +1 -1
  36. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +3 -0
  37. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  38. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +20 -0
  39. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  40. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -0
  41. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  42. package/lib/chain/blocks/payloadEnvelopeProcessor.js +6 -4
  43. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  44. package/lib/chain/blocks/types.d.ts +15 -21
  45. package/lib/chain/blocks/types.d.ts.map +1 -1
  46. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
  47. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
  48. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +76 -0
  49. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
  50. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +14 -0
  51. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -0
  52. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +25 -0
  53. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -0
  54. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
  55. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +1 -1
  56. package/lib/chain/chain.d.ts +3 -3
  57. package/lib/chain/chain.d.ts.map +1 -1
  58. package/lib/chain/chain.js +19 -39
  59. package/lib/chain/chain.js.map +1 -1
  60. package/lib/chain/emitter.d.ts +16 -4
  61. package/lib/chain/emitter.d.ts.map +1 -1
  62. package/lib/chain/emitter.js +5 -0
  63. package/lib/chain/emitter.js.map +1 -1
  64. package/lib/chain/errors/attestationError.d.ts +8 -1
  65. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  66. package/lib/chain/errors/attestationError.js +4 -0
  67. package/lib/chain/errors/attestationError.js.map +1 -1
  68. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  69. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  70. package/lib/chain/errors/executionPayloadBid.js +1 -0
  71. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  72. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  73. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  74. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  75. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  76. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  77. package/lib/chain/forkChoice/index.js +11 -15
  78. package/lib/chain/forkChoice/index.js.map +1 -1
  79. package/lib/chain/interface.d.ts +2 -2
  80. package/lib/chain/interface.d.ts.map +1 -1
  81. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  82. package/lib/chain/prepareNextSlot.js +22 -16
  83. package/lib/chain/prepareNextSlot.js.map +1 -1
  84. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +3 -9
  85. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  86. package/lib/chain/produceBlock/computeNewStateRoot.js +5 -32
  87. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  88. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -8
  89. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  90. package/lib/chain/produceBlock/produceBlockBody.js +30 -19
  91. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  92. package/lib/chain/regen/errors.d.ts +1 -11
  93. package/lib/chain/regen/errors.d.ts.map +1 -1
  94. package/lib/chain/regen/errors.js +0 -2
  95. package/lib/chain/regen/errors.js.map +1 -1
  96. package/lib/chain/regen/interface.d.ts +6 -12
  97. package/lib/chain/regen/interface.d.ts.map +1 -1
  98. package/lib/chain/regen/queued.d.ts +6 -11
  99. package/lib/chain/regen/queued.d.ts.map +1 -1
  100. package/lib/chain/regen/queued.js +8 -40
  101. package/lib/chain/regen/queued.js.map +1 -1
  102. package/lib/chain/regen/regen.d.ts +0 -5
  103. package/lib/chain/regen/regen.d.ts.map +1 -1
  104. package/lib/chain/regen/regen.js +7 -34
  105. package/lib/chain/regen/regen.js.map +1 -1
  106. package/lib/chain/stateCache/datastore/db.d.ts +5 -4
  107. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  108. package/lib/chain/stateCache/datastore/db.js +10 -32
  109. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  110. package/lib/chain/stateCache/datastore/file.d.ts +1 -1
  111. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  112. package/lib/chain/stateCache/datastore/file.js +5 -5
  113. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  114. package/lib/chain/stateCache/datastore/types.d.ts +1 -1
  115. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  116. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -7
  117. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  118. package/lib/chain/stateCache/fifoBlockStateCache.js +0 -8
  119. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  120. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +13 -30
  121. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  122. package/lib/chain/stateCache/persistentCheckpointsCache.js +120 -216
  123. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  124. package/lib/chain/stateCache/types.d.ts +8 -15
  125. package/lib/chain/stateCache/types.d.ts.map +1 -1
  126. package/lib/chain/stateCache/types.js.map +1 -1
  127. package/lib/chain/validation/aggregateAndProof.js +12 -0
  128. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  129. package/lib/chain/validation/attestation.d.ts.map +1 -1
  130. package/lib/chain/validation/attestation.js +12 -0
  131. package/lib/chain/validation/attestation.js.map +1 -1
  132. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  133. package/lib/chain/validation/executionPayloadBid.js +13 -1
  134. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  135. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  136. package/lib/chain/validation/executionPayloadEnvelope.js +21 -11
  137. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  138. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  139. package/lib/chain/validation/payloadAttestationMessage.js +4 -3
  140. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  141. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  142. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  143. package/lib/execution/engine/http.d.ts.map +1 -1
  144. package/lib/execution/engine/http.js +21 -14
  145. package/lib/execution/engine/http.js.map +1 -1
  146. package/lib/execution/engine/interface.d.ts +1 -0
  147. package/lib/execution/engine/interface.d.ts.map +1 -1
  148. package/lib/execution/engine/mock.d.ts.map +1 -1
  149. package/lib/execution/engine/mock.js +6 -0
  150. package/lib/execution/engine/mock.js.map +1 -1
  151. package/lib/execution/engine/types.d.ts +20 -0
  152. package/lib/execution/engine/types.d.ts.map +1 -1
  153. package/lib/execution/engine/types.js +18 -0
  154. package/lib/execution/engine/types.js.map +1 -1
  155. package/lib/network/gossip/topic.d.ts +3 -729
  156. package/lib/network/gossip/topic.d.ts.map +1 -1
  157. package/lib/network/network.js +1 -1
  158. package/lib/network/network.js.map +1 -1
  159. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  160. package/lib/network/processor/gossipHandlers.js +22 -6
  161. package/lib/network/processor/gossipHandlers.js.map +1 -1
  162. package/lib/node/nodejs.d.ts.map +1 -1
  163. package/lib/node/nodejs.js +4 -2
  164. package/lib/node/nodejs.js.map +1 -1
  165. package/lib/util/sszBytes.d.ts.map +1 -1
  166. package/lib/util/sszBytes.js +16 -3
  167. package/lib/util/sszBytes.js.map +1 -1
  168. package/package.json +16 -16
  169. package/src/api/impl/beacon/blocks/index.ts +1 -4
  170. package/src/api/impl/beacon/state/utils.ts +2 -2
  171. package/src/api/impl/validator/index.ts +3 -6
  172. package/src/chain/GetBlobsTracker.ts +1 -2
  173. package/src/chain/archiveStore/archiveStore.ts +5 -5
  174. package/src/chain/archiveStore/interface.ts +4 -4
  175. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +6 -8
  176. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  177. package/src/chain/blocks/importBlock.ts +26 -39
  178. package/src/chain/blocks/importExecutionPayload.ts +77 -103
  179. package/src/chain/blocks/index.ts +1 -2
  180. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +27 -0
  181. package/src/chain/blocks/payloadEnvelopeProcessor.ts +6 -5
  182. package/src/chain/blocks/types.ts +15 -26
  183. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +129 -0
  184. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +38 -0
  185. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +1 -1
  186. package/src/chain/chain.ts +25 -62
  187. package/src/chain/emitter.ts +15 -3
  188. package/src/chain/errors/attestationError.ts +6 -1
  189. package/src/chain/errors/executionPayloadBid.ts +6 -0
  190. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  191. package/src/chain/forkChoice/index.ts +8 -20
  192. package/src/chain/interface.ts +2 -2
  193. package/src/chain/prepareNextSlot.ts +25 -16
  194. package/src/chain/produceBlock/computeNewStateRoot.ts +6 -43
  195. package/src/chain/produceBlock/produceBlockBody.ts +41 -20
  196. package/src/chain/regen/errors.ts +1 -6
  197. package/src/chain/regen/interface.ts +6 -12
  198. package/src/chain/regen/queued.ts +12 -48
  199. package/src/chain/regen/regen.ts +8 -36
  200. package/src/chain/stateCache/datastore/db.ts +10 -33
  201. package/src/chain/stateCache/datastore/file.ts +5 -6
  202. package/src/chain/stateCache/datastore/types.ts +2 -3
  203. package/src/chain/stateCache/fifoBlockStateCache.ts +1 -10
  204. package/src/chain/stateCache/persistentCheckpointsCache.ts +139 -247
  205. package/src/chain/stateCache/types.ts +8 -14
  206. package/src/chain/validation/aggregateAndProof.ts +13 -0
  207. package/src/chain/validation/attestation.ts +13 -0
  208. package/src/chain/validation/executionPayloadBid.ts +14 -0
  209. package/src/chain/validation/executionPayloadEnvelope.ts +22 -12
  210. package/src/chain/validation/payloadAttestationMessage.ts +5 -3
  211. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  212. package/src/execution/engine/http.ts +21 -14
  213. package/src/execution/engine/interface.ts +1 -0
  214. package/src/execution/engine/mock.ts +8 -1
  215. package/src/execution/engine/types.ts +41 -0
  216. package/src/network/network.ts +1 -1
  217. package/src/network/processor/gossipHandlers.ts +26 -10
  218. package/src/node/nodejs.ts +4 -2
  219. package/src/util/sszBytes.ts +21 -3
@@ -19,7 +19,6 @@ import {
19
19
  IBeaconStateView,
20
20
  type IBeaconStateViewBellatrix,
21
21
  computeTimeAtSlot,
22
- isParentBlockFull,
23
22
  isStatePostBellatrix,
24
23
  isStatePostCapella,
25
24
  isStatePostGloas,
@@ -47,8 +46,9 @@ import {
47
46
  electra,
48
47
  fulu,
49
48
  gloas,
49
+ ssz,
50
50
  } from "@lodestar/types";
51
- import {Logger, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
51
+ import {Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
52
52
  import {ZERO_HASH_HEX} from "../../constants/index.js";
53
53
  import {numToQuantity} from "../../execution/engine/utils.js";
54
54
  import {
@@ -111,12 +111,6 @@ export type ProduceFullGloas = {
111
111
  executionRequests: electra.ExecutionRequests;
112
112
  blobsBundle: BlobsBundle<ForkPostGloas>;
113
113
  cells: fulu.Cell[][];
114
- /**
115
- * Cached payload envelope state root computed during block production.
116
- * This is the state root after running `processExecutionPayloadEnvelope` on the
117
- * post-block state, and later used to construct the `ExecutionPayloadEnvelope`.
118
- */
119
- payloadEnvelopeStateRoot: Root;
120
114
  };
121
115
  export type ProduceFullFulu = {
122
116
  type: BlockType.Full;
@@ -220,11 +214,15 @@ export async function produceBlockBody<T extends BlockType>(
220
214
  });
221
215
 
222
216
  // Get execution payload from EL
217
+ const parentBlockHash = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot))
218
+ ? currentState.latestExecutionPayloadBid.blockHash
219
+ : currentState.latestExecutionPayloadBid.parentBlockHash;
223
220
  const prepareRes = await prepareExecutionPayload(
224
221
  this,
225
222
  this.logger,
226
223
  fork,
227
224
  parentBlockRoot,
225
+ parentBlockHash,
228
226
  safeBlockHash,
229
227
  finalizedBlockHash ?? ZERO_HASH_HEX,
230
228
  currentState,
@@ -261,8 +259,8 @@ export async function produceBlockBody<T extends BlockType>(
261
259
 
262
260
  // Create self-build execution payload bid
263
261
  const bid: gloas.ExecutionPayloadBid = {
264
- parentBlockHash: currentState.latestBlockHash,
265
- parentBlockRoot: parentBlockRoot,
262
+ parentBlockHash,
263
+ parentBlockRoot,
266
264
  blockHash: executionPayload.blockHash,
267
265
  prevRandao: currentState.getRandaoMix(currentState.epoch),
268
266
  feeRecipient: executionPayload.feeRecipient,
@@ -272,6 +270,7 @@ export async function produceBlockBody<T extends BlockType>(
272
270
  value: 0,
273
271
  executionPayment: 0,
274
272
  blobKzgCommitments: blobsBundle.commitments,
273
+ executionRequestsRoot: ssz.electra.ExecutionRequests.hashTreeRoot(executionRequests),
275
274
  };
276
275
  const signedBid: gloas.SignedExecutionPayloadBid = {
277
276
  message: bid,
@@ -283,6 +282,7 @@ export async function produceBlockBody<T extends BlockType>(
283
282
  gloasBody.signedExecutionPayloadBid = signedBid;
284
283
  // TODO GLOAS: Get payload attestations from pool for previous slot
285
284
  gloasBody.payloadAttestations = [];
285
+ // TODO GLOAS: set parentExecutionRequests in the block body
286
286
  blockBody = gloasBody as AssembledBodyType<T>;
287
287
 
288
288
  // Store execution payload data required to construct execution payload envelope later
@@ -340,6 +340,7 @@ export async function produceBlockBody<T extends BlockType>(
340
340
  this.logger,
341
341
  fork,
342
342
  parentBlockRoot,
343
+ currentState.latestExecutionPayloadHeader.blockHash,
343
344
  safeBlockHash,
344
345
  finalizedBlockHash ?? ZERO_HASH_HEX,
345
346
  currentState,
@@ -448,6 +449,7 @@ export async function produceBlockBody<T extends BlockType>(
448
449
  this.logger,
449
450
  fork,
450
451
  parentBlockRoot,
452
+ currentState.latestExecutionPayloadHeader.blockHash,
451
453
  safeBlockHash,
452
454
  finalizedBlockHash ?? ZERO_HASH_HEX,
453
455
  currentState,
@@ -613,17 +615,17 @@ export async function prepareExecutionPayload(
613
615
  logger: Logger,
614
616
  fork: ForkPostBellatrix,
615
617
  parentBlockRoot: Root,
618
+ parentBlockHash: Bytes32,
616
619
  safeBlockHash: RootHex,
617
620
  finalizedBlockHash: RootHex,
618
621
  state: IBeaconStateViewBellatrix,
619
622
  suggestedFeeRecipient: string
620
623
  ): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
621
- const parentHash = state.latestBlockHash;
622
624
  const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
623
625
  const prevRandao = state.getRandaoMix(state.epoch);
624
626
 
625
627
  const payloadIdCached = chain.executionEngine.payloadIdCache.get({
626
- headBlockHash: toRootHex(parentHash),
628
+ headBlockHash: toRootHex(parentBlockHash),
627
629
  finalizedBlockHash,
628
630
  timestamp: numToQuantity(timestamp),
629
631
  prevRandao: toHex(prevRandao),
@@ -652,12 +654,13 @@ export async function prepareExecutionPayload(
652
654
  prepareState: state,
653
655
  prepareSlot: state.slot,
654
656
  parentBlockRoot,
657
+ parentBlockHash,
655
658
  feeRecipient: suggestedFeeRecipient,
656
659
  });
657
660
 
658
661
  payloadId = await chain.executionEngine.notifyForkchoiceUpdate(
659
662
  fork,
660
- toRootHex(parentHash),
663
+ toRootHex(parentBlockHash),
661
664
  safeBlockHash,
662
665
  finalizedBlockHash,
663
666
  attributes
@@ -709,20 +712,30 @@ export function getPayloadAttributesForSSE(
709
712
  prepareState,
710
713
  prepareSlot,
711
714
  parentBlockRoot,
715
+ parentBlockHash,
712
716
  feeRecipient,
713
- }: {prepareState: IBeaconStateViewBellatrix; prepareSlot: Slot; parentBlockRoot: Root; feeRecipient: string}
717
+ }: {
718
+ prepareState: IBeaconStateViewBellatrix;
719
+ prepareSlot: Slot;
720
+ parentBlockRoot: Root;
721
+ parentBlockHash: Bytes32;
722
+ feeRecipient: string;
723
+ }
714
724
  ): SSEPayloadAttributes {
715
- const parentHash = prepareState.latestBlockHash;
716
725
  const payloadAttributes = preparePayloadAttributes(fork, chain, {
717
726
  prepareState,
718
727
  prepareSlot,
719
728
  parentBlockRoot,
729
+ parentBlockHash,
720
730
  feeRecipient,
721
731
  });
722
732
 
723
733
  let parentBlockNumber: number;
724
734
  if (isForkPostGloas(fork)) {
725
- const parentBlock = chain.forkChoice.getBlockHexAndBlockHash(toRootHex(parentBlockRoot), toRootHex(parentHash));
735
+ const parentBlock = chain.forkChoice.getBlockHexAndBlockHash(
736
+ toRootHex(parentBlockRoot),
737
+ toRootHex(parentBlockHash)
738
+ );
726
739
  if (parentBlock?.executionPayloadBlockHash == null) {
727
740
  throw Error(`Parent block not found in fork choice root=${toRootHex(parentBlockRoot)}`);
728
741
  }
@@ -736,7 +749,7 @@ export function getPayloadAttributesForSSE(
736
749
  proposalSlot: prepareSlot,
737
750
  parentBlockNumber,
738
751
  parentBlockRoot,
739
- parentBlockHash: parentHash,
752
+ parentBlockHash,
740
753
  payloadAttributes,
741
754
  };
742
755
  return ssePayloadAttributes;
@@ -751,11 +764,13 @@ function preparePayloadAttributes(
751
764
  prepareState,
752
765
  prepareSlot,
753
766
  parentBlockRoot,
767
+ parentBlockHash,
754
768
  feeRecipient,
755
769
  }: {
756
770
  prepareState: IBeaconStateViewBellatrix;
757
771
  prepareSlot: Slot;
758
772
  parentBlockRoot: Root;
773
+ parentBlockHash: Bytes32;
759
774
  feeRecipient: string;
760
775
  }
761
776
  ): SSEPayloadAttributes["payloadAttributes"] {
@@ -772,13 +787,15 @@ function preparePayloadAttributes(
772
787
  throw new Error("Expected Capella state for withdrawals");
773
788
  }
774
789
 
775
- if (isStatePostGloas(prepareState) && !isParentBlockFull(prepareState)) {
790
+ if (isStatePostGloas(prepareState)) {
791
+ const isExtendingPayload = byteArrayEquals(parentBlockHash, prepareState.latestExecutionPayloadBid.blockHash);
776
792
  // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
777
793
  // already deducted from CL balances but never credited on the EL (the envelope
778
794
  // was not delivered). The next payload must carry those same withdrawals to
779
795
  // restore CL/EL consistency, otherwise validators permanently lose that balance.
780
- (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
781
- prepareState.payloadExpectedWithdrawals;
796
+ (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals = isExtendingPayload
797
+ ? prepareState.getExpectedWithdrawals().expectedWithdrawals
798
+ : prepareState.payloadExpectedWithdrawals;
782
799
  } else {
783
800
  // withdrawals logic is now fork aware as it changes on electra fork post capella
784
801
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
@@ -790,6 +807,10 @@ function preparePayloadAttributes(
790
807
  (payloadAttributes as deneb.SSEPayloadAttributes["payloadAttributes"]).parentBeaconBlockRoot = parentBlockRoot;
791
808
  }
792
809
 
810
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
811
+ (payloadAttributes as gloas.SSEPayloadAttributes["payloadAttributes"]).slotNumber = prepareSlot;
812
+ }
813
+
793
814
  return payloadAttributes;
794
815
  }
795
816
 
@@ -1,4 +1,3 @@
1
- import {PayloadStatus} from "@lodestar/fork-choice";
2
1
  import {Root, RootHex, Slot} from "@lodestar/types";
3
2
 
4
3
  export enum RegenErrorCode {
@@ -10,8 +9,6 @@ export enum RegenErrorCode {
10
9
  BLOCK_NOT_IN_DB = "REGEN_ERROR_BLOCK_NOT_IN_DB",
11
10
  STATE_TRANSITION_ERROR = "REGEN_ERROR_STATE_TRANSITION_ERROR",
12
11
  INVALID_STATE_ROOT = "REGEN_ERROR_INVALID_STATE_ROOT",
13
- UNEXPECTED_PAYLOAD_STATUS = "REGEN_ERROR_UNEXPECTED_PAYLOAD_STATUS",
14
- INTERNAL_ERROR = "REGEN_ERROR_INTERNAL_ERROR",
15
12
  }
16
13
 
17
14
  export type RegenErrorType =
@@ -22,9 +19,7 @@ export type RegenErrorType =
22
19
  | {code: RegenErrorCode.TOO_MANY_BLOCK_PROCESSED; stateRoot: RootHex | Root}
23
20
  | {code: RegenErrorCode.BLOCK_NOT_IN_DB; blockRoot: RootHex | Root}
24
21
  | {code: RegenErrorCode.STATE_TRANSITION_ERROR; error: Error}
25
- | {code: RegenErrorCode.INVALID_STATE_ROOT; slot: Slot; expected: RootHex; actual: RootHex}
26
- | {code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS; blockRoot: RootHex | Root; payloadStatus: PayloadStatus}
27
- | {code: RegenErrorCode.INTERNAL_ERROR; message: string};
22
+ | {code: RegenErrorCode.INVALID_STATE_ROOT; slot: Slot; expected: RootHex; actual: RootHex};
28
23
 
29
24
  export class RegenError extends Error {
30
25
  type: RegenErrorType;
@@ -2,7 +2,7 @@ import {routes} from "@lodestar/api";
2
2
  import {ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {IBeaconStateView} from "@lodestar/state-transition";
4
4
  import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
5
- import {CheckpointHexPayload} from "../stateCache/types.js";
5
+ import {CheckpointHex} from "../stateCache/types.js";
6
6
 
7
7
  export enum RegenCaller {
8
8
  getDuties = "getDuties",
@@ -40,21 +40,15 @@ export interface IStateRegenerator extends IStateRegeneratorInternal {
40
40
  dumpCacheSummary(): routes.lodestar.StateCacheItem[];
41
41
  getStateSync(stateRoot: RootHex): IBeaconStateView | null;
42
42
  getPreStateSync(block: BeaconBlock): IBeaconStateView | null;
43
- getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null>;
44
- getCheckpointStateSync(cp: CheckpointHexPayload): IBeaconStateView | null;
43
+ getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null>;
44
+ getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null;
45
45
  getClosestHeadState(head: ProtoBlock): IBeaconStateView | null;
46
46
  pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
47
47
  pruneOnFinalized(finalizedEpoch: Epoch): void;
48
- processBlockState(blockRootHex: RootHex, postState: IBeaconStateView): void;
49
- processPayloadState(payloadState: IBeaconStateView): void;
50
- /**
51
- * payloadPresent is true if this is payload state, false if block state.
52
- * payloadPresent is always true for pre-gloas.
53
- */
54
- addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void;
48
+ processState(blockRootHex: RootHex, postState: IBeaconStateView): void;
49
+ addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void;
55
50
  updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void;
56
- updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch, payloadPresent: boolean): number | null;
57
- upgradeForGloas(epoch: Epoch): void;
51
+ updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null;
58
52
  }
59
53
 
60
54
  /**
@@ -1,11 +1,11 @@
1
1
  import {routes} from "@lodestar/api";
2
- import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
2
+ import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
4
4
  import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
5
- import {Logger, fromHex, toRootHex} from "@lodestar/utils";
5
+ import {Logger, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
7
7
  import {JobItemQueue} from "../../util/queue/index.js";
8
- import {BlockStateCache, CheckpointHexPayload, CheckpointStateCache} from "../stateCache/types.js";
8
+ import {BlockStateCache, CheckpointHex, CheckpointStateCache} from "../stateCache/types.js";
9
9
  import {RegenError, RegenErrorCode} from "./errors.js";
10
10
  import {
11
11
  IStateRegenerator,
@@ -104,19 +104,9 @@ export class QueuedStateRegenerator implements IStateRegenerator {
104
104
  const parentEpoch = computeEpochAtSlot(parentBlock.slot);
105
105
  const blockEpoch = computeEpochAtSlot(block.slot);
106
106
 
107
- // Convert PayloadStatus to payloadPresent boolean
108
- if (parentBlock.payloadStatus === PayloadStatus.PENDING) {
109
- throw new RegenError({
110
- code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
111
- blockRoot: block.parentRoot,
112
- payloadStatus: parentBlock.payloadStatus,
113
- });
114
- }
115
- const payloadPresent = parentBlock.payloadStatus === PayloadStatus.FULL;
116
-
117
107
  // Check the checkpoint cache (if the pre-state is a checkpoint state)
118
108
  if (parentEpoch < blockEpoch) {
119
- const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch, payloadPresent);
109
+ const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch);
120
110
  if (checkpointState && computeEpochAtSlot(checkpointState.slot) === blockEpoch) {
121
111
  return checkpointState;
122
112
  }
@@ -135,14 +125,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
135
125
  return null;
136
126
  }
137
127
 
138
- async getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null> {
128
+ async getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null> {
139
129
  return this.checkpointStateCache.getStateOrBytes(cp);
140
130
  }
141
131
 
142
132
  /**
143
133
  * Get checkpoint state from cache
144
134
  */
145
- getCheckpointStateSync(cp: CheckpointHexPayload): IBeaconStateView | null {
135
+ getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null {
146
136
  return this.checkpointStateCache.get(cp);
147
137
  }
148
138
 
@@ -150,19 +140,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
150
140
  * Get state closest to head
151
141
  */
152
142
  getClosestHeadState(head: ProtoBlock): IBeaconStateView | null {
153
- // Convert PayloadStatus to payloadPresent boolean
154
- if (head.payloadStatus === PayloadStatus.PENDING) {
155
- throw new RegenError({
156
- code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
157
- blockRoot: fromHex(head.blockRoot),
158
- payloadStatus: head.payloadStatus,
159
- });
160
- }
161
- const payloadPresent = head.payloadStatus === PayloadStatus.FULL;
162
- return (
163
- this.checkpointStateCache.getLatest(head.blockRoot, Infinity, payloadPresent) ||
164
- this.blockStateCache.get(head.stateRoot)
165
- );
143
+ return this.checkpointStateCache.getLatest(head.blockRoot, Infinity) || this.blockStateCache.get(head.stateRoot);
166
144
  }
167
145
 
168
146
  pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void {
@@ -175,24 +153,15 @@ export class QueuedStateRegenerator implements IStateRegenerator {
175
153
  this.blockStateCache.deleteAllBeforeEpoch(finalizedEpoch);
176
154
  }
177
155
 
178
- processBlockState(blockRootHex: RootHex, postState: IBeaconStateView): void {
156
+ processState(blockRootHex: RootHex, postState: IBeaconStateView): void {
179
157
  this.blockStateCache.add(postState);
180
158
  this.checkpointStateCache.processState(blockRootHex, postState).catch((e) => {
181
159
  this.logger.debug("Error processing block state", {blockRootHex, slot: postState.slot}, e);
182
160
  });
183
161
  }
184
162
 
185
- /**
186
- * Process payload state for caching after importing execution payload.
187
- */
188
- processPayloadState(payloadState: IBeaconStateView): void {
189
- // Add payload state to block state cache (keyed by payload state root)
190
- this.blockStateCache.add(payloadState);
191
- }
192
-
193
- // TODO GLOAS: This should also be called when importing execution payload after we implement it
194
- addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void {
195
- this.checkpointStateCache.add(cp, item, payloadPresent);
163
+ addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void {
164
+ this.checkpointStateCache.add(cp, item);
196
165
  }
197
166
 
198
167
  updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void {
@@ -228,13 +197,8 @@ export class QueuedStateRegenerator implements IStateRegenerator {
228
197
  }
229
198
  }
230
199
 
231
- updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch, payloadPresent: boolean): number | null {
232
- return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch, payloadPresent);
233
- }
234
-
235
- upgradeForGloas(epoch: Epoch): void {
236
- this.logger.verbose("Upgrading block state cache for Gloas fork", {epoch});
237
- this.blockStateCache.upgradeToGloas();
200
+ updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null {
201
+ return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch);
238
202
  }
239
203
 
240
204
  /**
@@ -1,6 +1,6 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
3
- import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
+ import {SLOTS_PER_EPOCH} from "@lodestar/params";
4
4
  import {
5
5
  DataAvailabilityStatus,
6
6
  ExecutionPayloadStatus,
@@ -110,19 +110,9 @@ export class StateRegenerator implements IStateRegeneratorInternal {
110
110
  const {checkpointStateCache} = this.modules;
111
111
  const epoch = computeEpochAtSlot(slot);
112
112
 
113
- // Convert PayloadStatus to payloadPresent boolean
114
- if (block.payloadStatus === PayloadStatus.PENDING) {
115
- throw new RegenError({
116
- code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
117
- blockRoot: fromHex(blockRoot),
118
- payloadStatus: block.payloadStatus,
119
- });
120
- }
121
- const payloadPresent = block.payloadStatus === PayloadStatus.FULL;
122
-
123
113
  const latestCheckpointStateCtx = allowDiskReload
124
- ? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch, payloadPresent)
125
- : checkpointStateCache.getLatest(blockRoot, epoch, payloadPresent);
114
+ ? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch)
115
+ : checkpointStateCache.getLatest(blockRoot, epoch);
126
116
 
127
117
  // If a checkpoint state exists with the given checkpoint root, it either is in requested epoch
128
118
  // or needs to have empty slots processed until the requested epoch
@@ -176,18 +166,9 @@ export class StateRegenerator implements IStateRegeneratorInternal {
176
166
  if (!lastBlockToReplay) continue;
177
167
  const epoch = computeEpochAtSlot(lastBlockToReplay.slot - 1);
178
168
 
179
- // Convert PayloadStatus to payloadPresent boolean
180
- if (b.payloadStatus === PayloadStatus.PENDING) {
181
- throw new RegenError({
182
- code: RegenErrorCode.INTERNAL_ERROR,
183
- message: `Unexpected PENDING payloadStatus for ancestor block ${b.blockRoot} at slot ${b.slot}`,
184
- });
185
- }
186
- const payloadPresent = b.payloadStatus === PayloadStatus.FULL;
187
-
188
169
  state = allowDiskReload
189
- ? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch, payloadPresent)
190
- : checkpointStateCache.getLatest(b.blockRoot, epoch, payloadPresent);
170
+ ? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch)
171
+ : checkpointStateCache.getLatest(b.blockRoot, epoch);
191
172
  if (state) {
192
173
  break;
193
174
  }
@@ -351,11 +332,6 @@ async function processSlotsByCheckpoint(
351
332
  * emitting "checkpoint" events after every epoch processed.
352
333
  *
353
334
  * Stops processing after no more full epochs can be processed.
354
- *
355
- * Output state variant:
356
- * - Post-Gloas: If slots are processed, returns block state (payloadPresent=false).
357
- * If no slots processed, returns preState as-is (preserves variant).
358
- * - Pre-Gloas: Always payloadPresent=true (no block/payload distinction).
359
335
  */
360
336
  export async function processSlotsToNearestCheckpoint(
361
337
  modules: {
@@ -375,7 +351,7 @@ export async function processSlotsToNearestCheckpoint(
375
351
  const postSlot = slot;
376
352
  const preEpoch = computeEpochAtSlot(preSlot);
377
353
  let postState = preState;
378
- const {config, checkpointStateCache, emitter, metrics, logger} = modules;
354
+ const {checkpointStateCache, emitter, metrics, logger} = modules;
379
355
  let count = 0;
380
356
 
381
357
  for (
@@ -399,11 +375,7 @@ export async function processSlotsToNearestCheckpoint(
399
375
  // This may becomes the "official" checkpoint state if the 1st block of epoch is skipped
400
376
  const checkpointState = postState;
401
377
  const cp = getCheckpointFromState(checkpointState);
402
- // processSlots() only does epoch transitions, never processes payloads
403
- // Pre-Gloas: payloadPresent is always true (execution payload embedded in block)
404
- // Post-Gloas: result is a block state (payloadPresent=false)
405
- const isPayloadPresent = config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
406
- checkpointStateCache.add(cp, checkpointState, isPayloadPresent);
378
+ checkpointStateCache.add(cp, checkpointState);
407
379
  // consumers should not mutate state ever
408
380
  emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
409
381
 
@@ -1,6 +1,6 @@
1
1
  import {SLOTS_PER_EPOCH} from "@lodestar/params";
2
2
  import {Epoch, phase0, ssz} from "@lodestar/types";
3
- import {MapDef, byteArrayEquals} from "@lodestar/utils";
3
+ import {MapDef} from "@lodestar/utils";
4
4
  import {IBeaconDb} from "../../../db/interface.js";
5
5
  import {
6
6
  getLastProcessedSlotFromBeaconStateSerialized,
@@ -14,8 +14,8 @@ import {CPStateDatastore, DatastoreKey} from "./types.js";
14
14
  export class DbCPStateDatastore implements CPStateDatastore {
15
15
  constructor(private readonly db: IBeaconDb) {}
16
16
 
17
- async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array, payloadPresent: boolean): Promise<DatastoreKey> {
18
- const serializedCheckpoint = checkpointToDatastoreKey(cpKey, payloadPresent);
17
+ async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
18
+ const serializedCheckpoint = checkpointToDatastoreKey(cpKey);
19
19
  await this.db.checkpointState.putBinary(serializedCheckpoint, stateBytes);
20
20
  return serializedCheckpoint;
21
21
  }
@@ -40,30 +40,18 @@ export class DbCPStateDatastore implements CPStateDatastore {
40
40
  }
41
41
  }
42
42
 
43
- function extractCheckpointBytes(key: DatastoreKey): Uint8Array {
44
- const fixedSize = ssz.phase0.Checkpoint.minSize;
45
- return key.subarray(0, fixedSize);
46
- }
47
-
48
43
  export function datastoreKeyToCheckpoint(key: DatastoreKey): phase0.Checkpoint {
49
- return ssz.phase0.Checkpoint.deserialize(extractCheckpointBytes(key));
50
- }
51
-
52
- export function checkpointToDatastoreKey(cp: phase0.Checkpoint, payloadPresent: boolean): DatastoreKey {
53
- const cpBytes = ssz.phase0.Checkpoint.serialize(cp);
54
- const key = new Uint8Array(cpBytes.length + 1);
55
- key.set(cpBytes);
56
- key[cpBytes.length] = payloadPresent ? 1 : 0;
57
- return key;
44
+ return ssz.phase0.Checkpoint.deserialize(key);
58
45
  }
59
46
 
60
- function isPayloadCheckpointState(key: DatastoreKey): boolean {
61
- return key.at(-1) === 1;
47
+ export function checkpointToDatastoreKey(cp: phase0.Checkpoint): DatastoreKey {
48
+ return ssz.phase0.Checkpoint.serialize(cp);
62
49
  }
63
50
 
64
51
  /**
65
- * Get the latest "safe" checkpoint state the node can use to boot from
66
- * - its last processed block slot should be at epoch boundary (CRCS) or last slot of previous epoch (PRCS)
52
+ * Get the latest safe checkpoint state the node can use to boot from
53
+ * - it should be the checkpoint state that's unique in its epoch
54
+ * - its last processed block slot should be at epoch boundary or last slot of previous epoch
67
55
  * - state slot should be at epoch boundary
68
56
  * - state slot should be equal to epoch * SLOTS_PER_EPOCH
69
57
  *
@@ -82,20 +70,9 @@ export async function getLatestSafeDatastoreKey(
82
70
 
83
71
  const dataStoreKeyByEpoch: Map<Epoch, DatastoreKey> = new Map();
84
72
  for (const [epoch, keys] of checkpointsByEpoch.entries()) {
73
+ // only consider epochs with a single checkpoint to avoid ambiguity from forks
85
74
  if (keys.length === 1) {
86
- // PRCS (skipped slot) or CRCS and no payloadPresent
87
- // Pre-gloas always fall into this case
88
75
  dataStoreKeyByEpoch.set(epoch, keys[0]);
89
- } else if (keys.length === 2) {
90
- // CRCS without payload and CRCS with payload
91
- // ie Two keys for the same checkpoint with different payloadPresent suffix (FULL/EMPTY)
92
- // TODO GLOAS: Here we pick FULL key, there is a chance that payload is orphaned hence we not be able to sync
93
- const cp0 = extractCheckpointBytes(keys[0]);
94
- const cp1 = extractCheckpointBytes(keys[1]);
95
- if (byteArrayEquals(cp0, cp1)) {
96
- const fullKey = isPayloadCheckpointState(keys[0]) ? keys[0] : keys[1];
97
- dataStoreKeyByEpoch.set(epoch, fullKey);
98
- }
99
76
  }
100
77
  }
101
78
 
@@ -1,13 +1,12 @@
1
1
  import path from "node:path";
2
- import {phase0} from "@lodestar/types";
2
+ import {phase0, ssz} from "@lodestar/types";
3
3
  import {fromHex, toHex} from "@lodestar/utils";
4
4
  import {ensureDir, readFile, readFileNames, removeFile, writeIfNotExist} from "../../../util/file.js";
5
- import {checkpointToDatastoreKey, getLatestSafeDatastoreKey} from "./db.js";
5
+ import {getLatestSafeDatastoreKey} from "./db.js";
6
6
  import {CPStateDatastore, DatastoreKey} from "./types.js";
7
7
 
8
8
  const CHECKPOINT_STATES_FOLDER = "checkpoint_states";
9
- /** 41 bytes (40 checkpoint + 1 payloadPresent) = 82 hex chars + "0x" prefix = 84 */
10
- const CHECKPOINT_FILE_NAME_LENGTH = 84;
9
+ const CHECKPOINT_FILE_NAME_LENGTH = 82;
11
10
 
12
11
  /**
13
12
  * Implementation of CPStateDatastore using file system, this is beneficial for debugging.
@@ -29,8 +28,8 @@ export class FileCPStateDatastore implements CPStateDatastore {
29
28
  }
30
29
  }
31
30
 
32
- async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array, payloadPresent: boolean): Promise<DatastoreKey> {
33
- const serializedCheckpoint = checkpointToDatastoreKey(cpKey, payloadPresent);
31
+ async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
32
+ const serializedCheckpoint = ssz.phase0.Checkpoint.serialize(cpKey);
34
33
  const filePath = path.join(this.folderPath, toHex(serializedCheckpoint));
35
34
  await writeIfNotExist(filePath, stateBytes);
36
35
  return serializedCheckpoint;
@@ -1,12 +1,11 @@
1
1
  import {phase0} from "@lodestar/types";
2
2
 
3
- // With db implementation, persistedKey is serialized data of a checkpoint + 1
4
- // ie a fixed size of `ssz.phase0.Checkpoint.minSize + 1`
3
+ // With db implementation, persistedKey is serialized data of a checkpoint
5
4
  export type DatastoreKey = Uint8Array;
6
5
 
7
6
  // Make this generic to support testing
8
7
  export interface CPStateDatastore {
9
- write: (cpKey: phase0.Checkpoint, stateBytes: Uint8Array, payloadPresent: boolean) => Promise<DatastoreKey>;
8
+ write: (cpKey: phase0.Checkpoint, stateBytes: Uint8Array) => Promise<DatastoreKey>;
10
9
  remove: (key: DatastoreKey) => Promise<void>;
11
10
  read: (key: DatastoreKey) => Promise<Uint8Array | null>;
12
11
  readLatestSafe: () => Promise<Uint8Array | null>;
@@ -20,11 +20,6 @@ export type FIFOBlockStateCacheOpts = {
20
20
  * clock slot
21
21
  */
22
22
  export const DEFAULT_MAX_BLOCK_STATES = 64;
23
- /**
24
- * For Gloas (ePBS), each block can have two states: block state and payload state.
25
- * Double the cache size to maintain the same effective block depth.
26
- */
27
- export const DEFAULT_MAX_BLOCK_STATES_GLOAS = 128;
28
23
 
29
24
  /**
30
25
  * New implementation of BlockStateCache that keeps the most recent n states consistently
@@ -46,7 +41,7 @@ export const DEFAULT_MAX_BLOCK_STATES_GLOAS = 128;
46
41
  * The maintained key order would be: 11 -> 13 -> 12 -> 10, and state 10 will be pruned first.
47
42
  */
48
43
  export class FIFOBlockStateCache implements BlockStateCache {
49
- private maxStates: number;
44
+ readonly maxStates: number;
50
45
 
51
46
  private readonly cache: MapTracker<string, IBeaconStateView>;
52
47
  /**
@@ -172,10 +167,6 @@ export class FIFOBlockStateCache implements BlockStateCache {
172
167
  }
173
168
  }
174
169
 
175
- upgradeToGloas(): void {
176
- this.maxStates = DEFAULT_MAX_BLOCK_STATES_GLOAS;
177
- }
178
-
179
170
  /**
180
171
  * No need for this implementation
181
172
  * This is only to conform to the old api