@lodestar/beacon-node 1.42.0 → 1.43.0-dev.2870b59b6a

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 (216) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +20 -0
  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/attesterSlashing.d.ts +8 -0
  11. package/lib/api/impl/lodestar/attesterSlashing.d.ts.map +1 -0
  12. package/lib/api/impl/lodestar/attesterSlashing.js +29 -0
  13. package/lib/api/impl/lodestar/attesterSlashing.js.map +1 -0
  14. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  15. package/lib/api/impl/lodestar/index.js +39 -0
  16. package/lib/api/impl/lodestar/index.js.map +1 -1
  17. package/lib/api/impl/validator/index.d.ts.map +1 -1
  18. package/lib/api/impl/validator/index.js +9 -3
  19. package/lib/api/impl/validator/index.js.map +1 -1
  20. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  21. package/lib/chain/blocks/importBlock.js +10 -8
  22. package/lib/chain/blocks/importBlock.js.map +1 -1
  23. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  24. package/lib/chain/blocks/importExecutionPayload.js +14 -5
  25. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  26. package/lib/chain/blocks/index.js +1 -1
  27. package/lib/chain/blocks/index.js.map +1 -1
  28. package/lib/chain/blocks/types.d.ts +3 -3
  29. package/lib/chain/blocks/types.d.ts.map +1 -1
  30. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  31. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -2
  32. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  33. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  34. package/lib/chain/blocks/verifyBlocksSignatures.js +4 -2
  35. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  36. package/lib/chain/chain.d.ts +2 -1
  37. package/lib/chain/chain.d.ts.map +1 -1
  38. package/lib/chain/chain.js +25 -15
  39. package/lib/chain/chain.js.map +1 -1
  40. package/lib/chain/errors/attestationError.d.ts +8 -1
  41. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  42. package/lib/chain/errors/attestationError.js +4 -0
  43. package/lib/chain/errors/attestationError.js.map +1 -1
  44. package/lib/chain/errors/blockError.d.ts +11 -1
  45. package/lib/chain/errors/blockError.d.ts.map +1 -1
  46. package/lib/chain/errors/blockError.js +4 -0
  47. package/lib/chain/errors/blockError.js.map +1 -1
  48. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  49. package/lib/chain/forkChoice/index.js +10 -8
  50. package/lib/chain/forkChoice/index.js.map +1 -1
  51. package/lib/chain/interface.d.ts +2 -1
  52. package/lib/chain/interface.d.ts.map +1 -1
  53. package/lib/chain/interface.js.map +1 -1
  54. package/lib/chain/lightClient/index.d.ts +2 -2
  55. package/lib/chain/lightClient/index.d.ts.map +1 -1
  56. package/lib/chain/lightClient/index.js +7 -0
  57. package/lib/chain/lightClient/index.js.map +1 -1
  58. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  59. package/lib/chain/opPools/aggregatedAttestationPool.js +5 -2
  60. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  61. package/lib/chain/opPools/executionPayloadBidPool.d.ts +2 -2
  62. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
  63. package/lib/chain/opPools/executionPayloadBidPool.js +2 -2
  64. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
  65. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  66. package/lib/chain/prepareNextSlot.js +7 -1
  67. package/lib/chain/prepareNextSlot.js.map +1 -1
  68. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +3 -3
  69. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  70. package/lib/chain/produceBlock/computeNewStateRoot.js +8 -8
  71. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  72. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  73. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  74. package/lib/chain/produceBlock/produceBlockBody.js +23 -4
  75. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  76. package/lib/chain/regen/interface.d.ts +0 -1
  77. package/lib/chain/regen/interface.d.ts.map +1 -1
  78. package/lib/chain/regen/queued.d.ts +2 -3
  79. package/lib/chain/regen/queued.d.ts.map +1 -1
  80. package/lib/chain/regen/queued.js +7 -32
  81. package/lib/chain/regen/queued.js.map +1 -1
  82. package/lib/chain/regen/regen.d.ts.map +1 -1
  83. package/lib/chain/regen/regen.js +7 -26
  84. package/lib/chain/regen/regen.js.map +1 -1
  85. package/lib/chain/stateCache/datastore/db.d.ts +5 -4
  86. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  87. package/lib/chain/stateCache/datastore/db.js +10 -32
  88. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  89. package/lib/chain/stateCache/datastore/file.d.ts +1 -1
  90. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  91. package/lib/chain/stateCache/datastore/file.js +5 -5
  92. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  93. package/lib/chain/stateCache/datastore/types.d.ts +1 -1
  94. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  95. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -7
  96. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  97. package/lib/chain/stateCache/fifoBlockStateCache.js +0 -8
  98. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  99. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +19 -30
  100. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  101. package/lib/chain/stateCache/persistentCheckpointsCache.js +118 -209
  102. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  103. package/lib/chain/stateCache/types.d.ts +12 -13
  104. package/lib/chain/stateCache/types.d.ts.map +1 -1
  105. package/lib/chain/stateCache/types.js.map +1 -1
  106. package/lib/chain/validation/aggregateAndProof.js +12 -0
  107. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  108. package/lib/chain/validation/attestation.d.ts.map +1 -1
  109. package/lib/chain/validation/attestation.js +12 -0
  110. package/lib/chain/validation/attestation.js.map +1 -1
  111. package/lib/chain/validation/block.d.ts.map +1 -1
  112. package/lib/chain/validation/block.js +27 -5
  113. package/lib/chain/validation/block.js.map +1 -1
  114. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  115. package/lib/chain/validation/executionPayloadBid.js +7 -4
  116. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  117. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  118. package/lib/chain/validation/executionPayloadEnvelope.js +7 -2
  119. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  120. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  121. package/lib/chain/validation/payloadAttestationMessage.js +4 -1
  122. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  123. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  124. package/lib/chain/validation/syncCommittee.js +4 -0
  125. package/lib/chain/validation/syncCommittee.js.map +1 -1
  126. package/lib/chain/validation/syncCommitteeContributionAndProof.js +4 -1
  127. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  128. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  129. package/lib/chain/validatorMonitor.js +3 -3
  130. package/lib/chain/validatorMonitor.js.map +1 -1
  131. package/lib/network/gossip/topic.d.ts +2 -729
  132. package/lib/network/gossip/topic.d.ts.map +1 -1
  133. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  134. package/lib/network/processor/gossipHandlers.js +4 -0
  135. package/lib/network/processor/gossipHandlers.js.map +1 -1
  136. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  137. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -1
  138. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  139. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  140. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +2 -0
  141. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  142. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts +2 -2
  143. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  144. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +7 -3
  145. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  146. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  147. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +6 -0
  148. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  149. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -2
  150. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  151. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +7 -3
  152. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  153. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  154. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +2 -1
  155. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  156. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
  157. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +3 -8
  158. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  159. package/lib/node/nodejs.d.ts.map +1 -1
  160. package/lib/node/nodejs.js +4 -1
  161. package/lib/node/nodejs.js.map +1 -1
  162. package/lib/node/notifier.d.ts.map +1 -1
  163. package/lib/node/notifier.js +2 -2
  164. package/lib/node/notifier.js.map +1 -1
  165. package/package.json +15 -15
  166. package/src/api/impl/beacon/blocks/index.ts +29 -0
  167. package/src/api/impl/beacon/pool/index.ts +4 -0
  168. package/src/api/impl/beacon/state/index.ts +15 -15
  169. package/src/api/impl/lodestar/attesterSlashing.ts +43 -0
  170. package/src/api/impl/lodestar/index.ts +51 -1
  171. package/src/api/impl/validator/index.ts +9 -2
  172. package/src/chain/blocks/importBlock.ts +15 -11
  173. package/src/chain/blocks/importExecutionPayload.ts +15 -5
  174. package/src/chain/blocks/index.ts +1 -1
  175. package/src/chain/blocks/types.ts +3 -3
  176. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +2 -1
  177. package/src/chain/blocks/verifyBlocksSignatures.ts +9 -2
  178. package/src/chain/chain.ts +33 -23
  179. package/src/chain/errors/attestationError.ts +6 -1
  180. package/src/chain/errors/blockError.ts +7 -1
  181. package/src/chain/forkChoice/index.ts +11 -8
  182. package/src/chain/interface.ts +5 -0
  183. package/src/chain/lightClient/index.ts +15 -3
  184. package/src/chain/opPools/aggregatedAttestationPool.ts +6 -1
  185. package/src/chain/opPools/executionPayloadBidPool.ts +3 -3
  186. package/src/chain/prepareNextSlot.ts +8 -0
  187. package/src/chain/produceBlock/computeNewStateRoot.ts +11 -10
  188. package/src/chain/produceBlock/produceBlockBody.ts +40 -10
  189. package/src/chain/regen/interface.ts +0 -1
  190. package/src/chain/regen/queued.ts +8 -36
  191. package/src/chain/regen/regen.ts +8 -28
  192. package/src/chain/stateCache/datastore/db.ts +10 -33
  193. package/src/chain/stateCache/datastore/file.ts +5 -6
  194. package/src/chain/stateCache/datastore/types.ts +2 -3
  195. package/src/chain/stateCache/fifoBlockStateCache.ts +1 -10
  196. package/src/chain/stateCache/persistentCheckpointsCache.ts +142 -240
  197. package/src/chain/stateCache/types.ts +10 -13
  198. package/src/chain/validation/aggregateAndProof.ts +13 -0
  199. package/src/chain/validation/attestation.ts +13 -0
  200. package/src/chain/validation/block.ts +30 -7
  201. package/src/chain/validation/executionPayloadBid.ts +7 -3
  202. package/src/chain/validation/executionPayloadEnvelope.ts +11 -2
  203. package/src/chain/validation/payloadAttestationMessage.ts +4 -0
  204. package/src/chain/validation/syncCommittee.ts +5 -1
  205. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -1
  206. package/src/chain/validatorMonitor.ts +3 -2
  207. package/src/network/processor/gossipHandlers.ts +5 -0
  208. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +3 -1
  209. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +3 -0
  210. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +15 -3
  211. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +11 -0
  212. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +19 -3
  213. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +3 -1
  214. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +3 -12
  215. package/src/node/nodejs.ts +5 -2
  216. package/src/node/notifier.ts +7 -2
@@ -1,8 +1,8 @@
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
8
  import {BlockStateCache, CheckpointHexPayload, CheckpointStateCache} from "../stateCache/types.js";
@@ -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
  }
@@ -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 {
@@ -190,9 +168,8 @@ export class QueuedStateRegenerator implements IStateRegenerator {
190
168
  this.blockStateCache.add(payloadState);
191
169
  }
192
170
 
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);
171
+ addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, _payloadPresent: boolean): void {
172
+ this.checkpointStateCache.add(cp, item);
196
173
  }
197
174
 
198
175
  updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void {
@@ -228,13 +205,8 @@ export class QueuedStateRegenerator implements IStateRegenerator {
228
205
  }
229
206
  }
230
207
 
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();
208
+ updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch, _payloadPresent: boolean): number | null {
209
+ return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch);
238
210
  }
239
211
 
240
212
  /**
@@ -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
  }
@@ -375,7 +356,7 @@ export async function processSlotsToNearestCheckpoint(
375
356
  const postSlot = slot;
376
357
  const preEpoch = computeEpochAtSlot(preSlot);
377
358
  let postState = preState;
378
- const {config, checkpointStateCache, emitter, metrics, logger} = modules;
359
+ const {checkpointStateCache, emitter, metrics, logger} = modules;
379
360
  let count = 0;
380
361
 
381
362
  for (
@@ -402,8 +383,7 @@ export async function processSlotsToNearestCheckpoint(
402
383
  // processSlots() only does epoch transitions, never processes payloads
403
384
  // Pre-Gloas: payloadPresent is always true (execution payload embedded in block)
404
385
  // Post-Gloas: result is a block state (payloadPresent=false)
405
- const isPayloadPresent = config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
406
- checkpointStateCache.add(cp, checkpointState, isPayloadPresent);
386
+ checkpointStateCache.add(cp, checkpointState);
407
387
  // consumers should not mutate state ever
408
388
  emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
409
389
 
@@ -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