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

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 (195) 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 +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.js +19 -26
  32. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  33. package/lib/chain/blocks/index.js +1 -1
  34. package/lib/chain/blocks/index.js.map +1 -1
  35. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +3 -0
  36. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  37. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +20 -0
  38. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  39. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -0
  40. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  41. package/lib/chain/blocks/payloadEnvelopeProcessor.js +6 -4
  42. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  43. package/lib/chain/blocks/types.d.ts +1 -1
  44. package/lib/chain/blocks/types.d.ts.map +1 -1
  45. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +14 -0
  46. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -0
  47. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +25 -0
  48. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -0
  49. package/lib/chain/chain.d.ts +3 -3
  50. package/lib/chain/chain.d.ts.map +1 -1
  51. package/lib/chain/chain.js +19 -39
  52. package/lib/chain/chain.js.map +1 -1
  53. package/lib/chain/emitter.d.ts +16 -4
  54. package/lib/chain/emitter.d.ts.map +1 -1
  55. package/lib/chain/emitter.js +5 -0
  56. package/lib/chain/emitter.js.map +1 -1
  57. package/lib/chain/errors/attestationError.d.ts +8 -1
  58. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  59. package/lib/chain/errors/attestationError.js +4 -0
  60. package/lib/chain/errors/attestationError.js.map +1 -1
  61. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  62. package/lib/chain/forkChoice/index.js +9 -13
  63. package/lib/chain/forkChoice/index.js.map +1 -1
  64. package/lib/chain/interface.d.ts +2 -2
  65. package/lib/chain/interface.d.ts.map +1 -1
  66. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  67. package/lib/chain/prepareNextSlot.js +22 -16
  68. package/lib/chain/prepareNextSlot.js.map +1 -1
  69. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +3 -9
  70. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  71. package/lib/chain/produceBlock/computeNewStateRoot.js +5 -32
  72. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  73. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -8
  74. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  75. package/lib/chain/produceBlock/produceBlockBody.js +29 -19
  76. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  77. package/lib/chain/regen/errors.d.ts +1 -11
  78. package/lib/chain/regen/errors.d.ts.map +1 -1
  79. package/lib/chain/regen/errors.js +0 -2
  80. package/lib/chain/regen/errors.js.map +1 -1
  81. package/lib/chain/regen/interface.d.ts +6 -12
  82. package/lib/chain/regen/interface.d.ts.map +1 -1
  83. package/lib/chain/regen/queued.d.ts +6 -11
  84. package/lib/chain/regen/queued.d.ts.map +1 -1
  85. package/lib/chain/regen/queued.js +8 -40
  86. package/lib/chain/regen/queued.js.map +1 -1
  87. package/lib/chain/regen/regen.d.ts +0 -5
  88. package/lib/chain/regen/regen.d.ts.map +1 -1
  89. package/lib/chain/regen/regen.js +7 -34
  90. package/lib/chain/regen/regen.js.map +1 -1
  91. package/lib/chain/stateCache/datastore/db.d.ts +5 -4
  92. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  93. package/lib/chain/stateCache/datastore/db.js +10 -32
  94. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  95. package/lib/chain/stateCache/datastore/file.d.ts +1 -1
  96. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  97. package/lib/chain/stateCache/datastore/file.js +5 -5
  98. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  99. package/lib/chain/stateCache/datastore/types.d.ts +1 -1
  100. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  101. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -7
  102. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  103. package/lib/chain/stateCache/fifoBlockStateCache.js +0 -8
  104. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  105. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +13 -30
  106. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  107. package/lib/chain/stateCache/persistentCheckpointsCache.js +120 -216
  108. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  109. package/lib/chain/stateCache/types.d.ts +8 -15
  110. package/lib/chain/stateCache/types.d.ts.map +1 -1
  111. package/lib/chain/stateCache/types.js.map +1 -1
  112. package/lib/chain/validation/aggregateAndProof.js +12 -0
  113. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  114. package/lib/chain/validation/attestation.d.ts.map +1 -1
  115. package/lib/chain/validation/attestation.js +12 -0
  116. package/lib/chain/validation/attestation.js.map +1 -1
  117. package/lib/chain/validation/executionPayloadEnvelope.js +10 -10
  118. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  119. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  120. package/lib/chain/validation/payloadAttestationMessage.js +4 -3
  121. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  122. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  123. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  124. package/lib/execution/engine/http.d.ts.map +1 -1
  125. package/lib/execution/engine/http.js +21 -14
  126. package/lib/execution/engine/http.js.map +1 -1
  127. package/lib/execution/engine/interface.d.ts +1 -0
  128. package/lib/execution/engine/interface.d.ts.map +1 -1
  129. package/lib/execution/engine/mock.d.ts.map +1 -1
  130. package/lib/execution/engine/mock.js +6 -0
  131. package/lib/execution/engine/mock.js.map +1 -1
  132. package/lib/execution/engine/types.d.ts +20 -0
  133. package/lib/execution/engine/types.d.ts.map +1 -1
  134. package/lib/execution/engine/types.js +18 -0
  135. package/lib/execution/engine/types.js.map +1 -1
  136. package/lib/network/gossip/topic.d.ts +3 -729
  137. package/lib/network/gossip/topic.d.ts.map +1 -1
  138. package/lib/network/network.js +1 -1
  139. package/lib/network/network.js.map +1 -1
  140. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  141. package/lib/network/processor/gossipHandlers.js +22 -6
  142. package/lib/network/processor/gossipHandlers.js.map +1 -1
  143. package/lib/node/nodejs.d.ts.map +1 -1
  144. package/lib/node/nodejs.js +4 -2
  145. package/lib/node/nodejs.js.map +1 -1
  146. package/lib/util/sszBytes.d.ts.map +1 -1
  147. package/lib/util/sszBytes.js +16 -3
  148. package/lib/util/sszBytes.js.map +1 -1
  149. package/package.json +16 -16
  150. package/src/api/impl/beacon/blocks/index.ts +1 -4
  151. package/src/api/impl/beacon/state/utils.ts +2 -2
  152. package/src/api/impl/validator/index.ts +3 -6
  153. package/src/chain/GetBlobsTracker.ts +1 -2
  154. package/src/chain/archiveStore/archiveStore.ts +5 -5
  155. package/src/chain/archiveStore/interface.ts +4 -4
  156. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +6 -8
  157. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  158. package/src/chain/blocks/importBlock.ts +26 -39
  159. package/src/chain/blocks/importExecutionPayload.ts +20 -26
  160. package/src/chain/blocks/index.ts +1 -1
  161. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +27 -0
  162. package/src/chain/blocks/payloadEnvelopeProcessor.ts +6 -5
  163. package/src/chain/blocks/types.ts +1 -1
  164. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +38 -0
  165. package/src/chain/chain.ts +25 -62
  166. package/src/chain/emitter.ts +15 -3
  167. package/src/chain/errors/attestationError.ts +6 -1
  168. package/src/chain/forkChoice/index.ts +6 -18
  169. package/src/chain/interface.ts +2 -2
  170. package/src/chain/prepareNextSlot.ts +25 -16
  171. package/src/chain/produceBlock/computeNewStateRoot.ts +6 -43
  172. package/src/chain/produceBlock/produceBlockBody.ts +40 -20
  173. package/src/chain/regen/errors.ts +1 -6
  174. package/src/chain/regen/interface.ts +6 -12
  175. package/src/chain/regen/queued.ts +12 -48
  176. package/src/chain/regen/regen.ts +8 -36
  177. package/src/chain/stateCache/datastore/db.ts +10 -33
  178. package/src/chain/stateCache/datastore/file.ts +5 -6
  179. package/src/chain/stateCache/datastore/types.ts +2 -3
  180. package/src/chain/stateCache/fifoBlockStateCache.ts +1 -10
  181. package/src/chain/stateCache/persistentCheckpointsCache.ts +139 -247
  182. package/src/chain/stateCache/types.ts +8 -14
  183. package/src/chain/validation/aggregateAndProof.ts +13 -0
  184. package/src/chain/validation/attestation.ts +13 -0
  185. package/src/chain/validation/executionPayloadEnvelope.ts +10 -10
  186. package/src/chain/validation/payloadAttestationMessage.ts +5 -3
  187. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  188. package/src/execution/engine/http.ts +21 -14
  189. package/src/execution/engine/interface.ts +1 -0
  190. package/src/execution/engine/mock.ts +8 -1
  191. package/src/execution/engine/types.ts +41 -0
  192. package/src/network/network.ts +1 -1
  193. package/src/network/processor/gossipHandlers.ts +26 -10
  194. package/src/node/nodejs.ts +4 -2
  195. package/src/util/sszBytes.ts +21 -3
@@ -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