@lodestar/beacon-node 1.50.0-dev.45e4260336 → 1.50.0-dev.4ef13ee111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/state/index.js +28 -6
  3. package/lib/api/impl/beacon/state/index.js.map +1 -1
  4. package/lib/api/impl/debug/index.d.ts.map +1 -1
  5. package/lib/api/impl/debug/index.js +4 -0
  6. package/lib/api/impl/debug/index.js.map +1 -1
  7. package/lib/api/impl/validator/index.d.ts.map +1 -1
  8. package/lib/api/impl/validator/index.js +8 -0
  9. package/lib/api/impl/validator/index.js.map +1 -1
  10. package/lib/chain/archiveStore/archiveStore.d.ts +5 -0
  11. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  12. package/lib/chain/archiveStore/archiveStore.js +13 -23
  13. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  14. package/lib/chain/archiveStore/utils/pruneHistory.d.ts +1 -1
  15. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  16. package/lib/chain/archiveStore/utils/pruneHistory.js +2 -1
  17. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  18. package/lib/chain/beaconProposerCache.d.ts +6 -0
  19. package/lib/chain/beaconProposerCache.d.ts.map +1 -1
  20. package/lib/chain/beaconProposerCache.js +16 -0
  21. package/lib/chain/beaconProposerCache.js.map +1 -1
  22. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  23. package/lib/chain/blocks/importBlock.js +14 -8
  24. package/lib/chain/blocks/importBlock.js.map +1 -1
  25. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  26. package/lib/chain/blocks/verifyBlock.js +6 -6
  27. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  28. package/lib/chain/chain.d.ts +3 -1
  29. package/lib/chain/chain.d.ts.map +1 -1
  30. package/lib/chain/chain.js +55 -19
  31. package/lib/chain/chain.js.map +1 -1
  32. package/lib/chain/interface.d.ts +2 -0
  33. package/lib/chain/interface.d.ts.map +1 -1
  34. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +4 -2
  35. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  36. package/lib/chain/opPools/aggregatedAttestationPool.js +30 -8
  37. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  38. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  39. package/lib/chain/opPools/opPool.js +1 -23
  40. package/lib/chain/opPools/opPool.js.map +1 -1
  41. package/lib/chain/opPools/proposerPreferencesPool.d.ts +4 -0
  42. package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
  43. package/lib/chain/opPools/proposerPreferencesPool.js +13 -1
  44. package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
  45. package/lib/chain/opPools/utils.d.ts +11 -0
  46. package/lib/chain/opPools/utils.d.ts.map +1 -1
  47. package/lib/chain/opPools/utils.js +22 -0
  48. package/lib/chain/opPools/utils.js.map +1 -1
  49. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  50. package/lib/chain/prepareNextSlot.js +11 -3
  51. package/lib/chain/prepareNextSlot.js.map +1 -1
  52. package/lib/chain/produceBlock/produceBlockBody.d.ts +8 -0
  53. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  54. package/lib/chain/produceBlock/produceBlockBody.js +40 -28
  55. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  56. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +7 -0
  57. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  58. package/lib/chain/seenCache/seenGossipBlockInput.js +21 -0
  59. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  60. package/lib/chain/shufflingCache.d.ts +18 -8
  61. package/lib/chain/shufflingCache.d.ts.map +1 -1
  62. package/lib/chain/shufflingCache.js +72 -18
  63. package/lib/chain/shufflingCache.js.map +1 -1
  64. package/lib/db/beacon.d.ts +4 -1
  65. package/lib/db/beacon.d.ts.map +1 -1
  66. package/lib/db/beacon.js +6 -1
  67. package/lib/db/beacon.js.map +1 -1
  68. package/lib/db/buckets.d.ts +3 -1
  69. package/lib/db/buckets.d.ts.map +1 -1
  70. package/lib/db/buckets.js +2 -0
  71. package/lib/db/buckets.js.map +1 -1
  72. package/lib/db/interface.d.ts +4 -1
  73. package/lib/db/interface.d.ts.map +1 -1
  74. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  75. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  76. package/lib/db/repositories/earliestAvailableSlot.d.ts +11 -0
  77. package/lib/db/repositories/earliestAvailableSlot.d.ts.map +1 -0
  78. package/lib/db/repositories/earliestAvailableSlot.js +19 -0
  79. package/lib/db/repositories/earliestAvailableSlot.js.map +1 -0
  80. package/lib/db/repositories/index.d.ts +1 -0
  81. package/lib/db/repositories/index.d.ts.map +1 -1
  82. package/lib/db/repositories/index.js +1 -0
  83. package/lib/db/repositories/index.js.map +1 -1
  84. package/lib/db/repositories/proposerPreferences.d.ts +14 -0
  85. package/lib/db/repositories/proposerPreferences.d.ts.map +1 -0
  86. package/lib/db/repositories/proposerPreferences.js +21 -0
  87. package/lib/db/repositories/proposerPreferences.js.map +1 -0
  88. package/lib/execution/engine/blobVersionedHashes.d.ts +9 -0
  89. package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -0
  90. package/lib/execution/engine/blobVersionedHashes.js +74 -0
  91. package/lib/execution/engine/blobVersionedHashes.js.map +1 -0
  92. package/lib/execution/engine/http.d.ts +45 -13
  93. package/lib/execution/engine/http.d.ts.map +1 -1
  94. package/lib/execution/engine/http.js +236 -198
  95. package/lib/execution/engine/http.js.map +1 -1
  96. package/lib/execution/engine/index.d.ts +3 -2
  97. package/lib/execution/engine/index.d.ts.map +1 -1
  98. package/lib/execution/engine/index.js +33 -8
  99. package/lib/execution/engine/index.js.map +1 -1
  100. package/lib/execution/engine/interface.d.ts +1 -1
  101. package/lib/execution/engine/interface.d.ts.map +1 -1
  102. package/lib/execution/engine/jsonRpcTransport.d.ts +25 -0
  103. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -0
  104. package/lib/execution/engine/jsonRpcTransport.js +158 -0
  105. package/lib/execution/engine/jsonRpcTransport.js.map +1 -0
  106. package/lib/execution/engine/restHttpClient.d.ts +71 -0
  107. package/lib/execution/engine/restHttpClient.d.ts.map +1 -0
  108. package/lib/execution/engine/restHttpClient.js +201 -0
  109. package/lib/execution/engine/restHttpClient.js.map +1 -0
  110. package/lib/execution/engine/restTransport.d.ts +46 -0
  111. package/lib/execution/engine/restTransport.d.ts.map +1 -0
  112. package/lib/execution/engine/restTransport.js +399 -0
  113. package/lib/execution/engine/restTransport.js.map +1 -0
  114. package/lib/execution/engine/sszTypes.d.ts +1261 -0
  115. package/lib/execution/engine/sszTypes.d.ts.map +1 -0
  116. package/lib/execution/engine/sszTypes.js +216 -0
  117. package/lib/execution/engine/sszTypes.js.map +1 -0
  118. package/lib/execution/engine/transport.d.ts +39 -0
  119. package/lib/execution/engine/transport.d.ts.map +1 -0
  120. package/lib/execution/engine/transport.js +2 -0
  121. package/lib/execution/engine/transport.js.map +1 -0
  122. package/lib/execution/engine/types.d.ts +2 -0
  123. package/lib/execution/engine/types.d.ts.map +1 -1
  124. package/lib/execution/engine/types.js +24 -57
  125. package/lib/execution/engine/types.js.map +1 -1
  126. package/lib/execution/engine/utils.d.ts.map +1 -1
  127. package/lib/execution/engine/utils.js +9 -2
  128. package/lib/execution/engine/utils.js.map +1 -1
  129. package/lib/metrics/metrics/lodestar.d.ts +10 -0
  130. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  131. package/lib/metrics/metrics/lodestar.js +22 -0
  132. package/lib/metrics/metrics/lodestar.js.map +1 -1
  133. package/lib/network/core/events.d.ts +5 -1
  134. package/lib/network/core/events.d.ts.map +1 -1
  135. package/lib/network/core/events.js +8 -0
  136. package/lib/network/core/events.js.map +1 -1
  137. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  138. package/lib/network/processor/gossipHandlers.js +60 -64
  139. package/lib/network/processor/gossipHandlers.js.map +1 -1
  140. package/lib/node/nodejs.d.ts +3 -1
  141. package/lib/node/nodejs.d.ts.map +1 -1
  142. package/lib/node/nodejs.js +2 -1
  143. package/lib/node/nodejs.js.map +1 -1
  144. package/lib/node/options.d.ts +3 -2
  145. package/lib/node/options.d.ts.map +1 -1
  146. package/lib/node/options.js +2 -2
  147. package/lib/node/options.js.map +1 -1
  148. package/lib/sync/range/batch.d.ts +5 -5
  149. package/lib/sync/range/batch.d.ts.map +1 -1
  150. package/lib/sync/range/batch.js +11 -17
  151. package/lib/sync/range/batch.js.map +1 -1
  152. package/lib/sync/range/chain.d.ts +4 -4
  153. package/lib/sync/range/chain.d.ts.map +1 -1
  154. package/lib/sync/range/chain.js +7 -5
  155. package/lib/sync/range/chain.js.map +1 -1
  156. package/lib/sync/range/range.d.ts.map +1 -1
  157. package/lib/sync/range/range.js +25 -11
  158. package/lib/sync/range/range.js.map +1 -1
  159. package/lib/sync/unknownBlock.d.ts +5 -2
  160. package/lib/sync/unknownBlock.d.ts.map +1 -1
  161. package/lib/sync/unknownBlock.js +44 -20
  162. package/lib/sync/unknownBlock.js.map +1 -1
  163. package/lib/sync/utils/downloadByRange.d.ts +38 -14
  164. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  165. package/lib/sync/utils/downloadByRange.js +84 -39
  166. package/lib/sync/utils/downloadByRange.js.map +1 -1
  167. package/lib/util/asyncIterableToEvents.d.ts +10 -2
  168. package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
  169. package/lib/util/asyncIterableToEvents.js +29 -3
  170. package/lib/util/asyncIterableToEvents.js.map +1 -1
  171. package/lib/util/metadata.d.ts.map +1 -1
  172. package/lib/util/metadata.js +2 -1
  173. package/lib/util/metadata.js.map +1 -1
  174. package/package.json +17 -16
  175. package/src/api/impl/beacon/state/index.ts +43 -6
  176. package/src/api/impl/debug/index.ts +4 -0
  177. package/src/api/impl/validator/index.ts +11 -0
  178. package/src/chain/archiveStore/archiveStore.ts +18 -24
  179. package/src/chain/archiveStore/utils/pruneHistory.ts +4 -1
  180. package/src/chain/beaconProposerCache.ts +19 -1
  181. package/src/chain/blocks/importBlock.ts +17 -7
  182. package/src/chain/blocks/verifyBlock.ts +7 -6
  183. package/src/chain/chain.ts +68 -18
  184. package/src/chain/interface.ts +2 -0
  185. package/src/chain/opPools/aggregatedAttestationPool.ts +34 -10
  186. package/src/chain/opPools/opPool.ts +1 -31
  187. package/src/chain/opPools/proposerPreferencesPool.ts +20 -1
  188. package/src/chain/opPools/utils.ts +31 -0
  189. package/src/chain/prepareNextSlot.ts +15 -3
  190. package/src/chain/produceBlock/produceBlockBody.ts +68 -34
  191. package/src/chain/seenCache/seenGossipBlockInput.ts +23 -0
  192. package/src/chain/shufflingCache.ts +84 -22
  193. package/src/db/beacon.ts +6 -0
  194. package/src/db/buckets.ts +2 -0
  195. package/src/db/interface.ts +4 -0
  196. package/src/db/repositories/earliestAvailableSlot.ts +19 -0
  197. package/src/db/repositories/index.ts +1 -0
  198. package/src/db/repositories/proposerPreferences.ts +23 -0
  199. package/src/execution/engine/blobVersionedHashes.ts +72 -0
  200. package/src/execution/engine/http.ts +304 -271
  201. package/src/execution/engine/index.ts +41 -7
  202. package/src/execution/engine/interface.ts +1 -1
  203. package/src/execution/engine/jsonRpcTransport.ts +247 -0
  204. package/src/execution/engine/restHttpClient.ts +269 -0
  205. package/src/execution/engine/restTransport.ts +544 -0
  206. package/src/execution/engine/sszTypes.ts +354 -0
  207. package/src/execution/engine/transport.ts +61 -0
  208. package/src/execution/engine/types.ts +34 -74
  209. package/src/execution/engine/utils.ts +12 -2
  210. package/src/metrics/metrics/lodestar.ts +23 -0
  211. package/src/network/core/events.ts +16 -1
  212. package/src/network/processor/gossipHandlers.ts +91 -77
  213. package/src/node/nodejs.ts +4 -0
  214. package/src/node/options.ts +10 -1
  215. package/src/sync/range/batch.ts +14 -19
  216. package/src/sync/range/chain.ts +9 -7
  217. package/src/sync/range/range.ts +26 -12
  218. package/src/sync/unknownBlock.ts +57 -21
  219. package/src/sync/utils/downloadByRange.ts +123 -58
  220. package/src/util/asyncIterableToEvents.ts +44 -5
  221. package/src/util/metadata.ts +2 -1
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/ChainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.50.0-dev.45e4260336",
14
+ "version": "1.50.0-dev.4ef13ee111",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -109,7 +109,7 @@
109
109
  "@chainsafe/persistent-merkle-tree": "^1.3.1",
110
110
  "@chainsafe/prometheus-gc-stats": "^1.0.0",
111
111
  "@chainsafe/snappy-wasm": "^0.5.2",
112
- "@chainsafe/ssz": "^1.8.0",
112
+ "@chainsafe/ssz": "^1.8.1",
113
113
  "@chainsafe/threads": "^1.11.3",
114
114
  "@crate-crypto/node-eth-kzg": "0.9.1",
115
115
  "@fastify/bearer-auth": "^10.0.1",
@@ -127,17 +127,17 @@
127
127
  "@libp2p/prometheus-metrics": "^5.0.28",
128
128
  "@libp2p/tcp": "^11.0.27",
129
129
  "@libp2p/utils": "^7.4.0",
130
- "@lodestar/api": "^1.50.0-dev.45e4260336",
131
- "@lodestar/config": "^1.50.0-dev.45e4260336",
132
- "@lodestar/db": "^1.50.0-dev.45e4260336",
133
- "@lodestar/fork-choice": "^1.50.0-dev.45e4260336",
134
- "@lodestar/logger": "^1.50.0-dev.45e4260336",
135
- "@lodestar/params": "^1.50.0-dev.45e4260336",
136
- "@lodestar/reqresp": "^1.50.0-dev.45e4260336",
137
- "@lodestar/state-transition": "^1.50.0-dev.45e4260336",
138
- "@lodestar/types": "^1.50.0-dev.45e4260336",
139
- "@lodestar/utils": "^1.50.0-dev.45e4260336",
140
- "@lodestar/validator": "^1.50.0-dev.45e4260336",
130
+ "@lodestar/api": "^1.50.0-dev.4ef13ee111",
131
+ "@lodestar/config": "^1.50.0-dev.4ef13ee111",
132
+ "@lodestar/db": "^1.50.0-dev.4ef13ee111",
133
+ "@lodestar/fork-choice": "^1.50.0-dev.4ef13ee111",
134
+ "@lodestar/logger": "^1.50.0-dev.4ef13ee111",
135
+ "@lodestar/params": "^1.50.0-dev.4ef13ee111",
136
+ "@lodestar/reqresp": "^1.50.0-dev.4ef13ee111",
137
+ "@lodestar/state-transition": "^1.50.0-dev.4ef13ee111",
138
+ "@lodestar/types": "^1.50.0-dev.4ef13ee111",
139
+ "@lodestar/utils": "^1.50.0-dev.4ef13ee111",
140
+ "@lodestar/validator": "^1.50.0-dev.4ef13ee111",
141
141
  "@multiformats/multiaddr": "^13.0.1",
142
142
  "datastore-core": "^12.0.1",
143
143
  "datastore-level": "^13.0.1",
@@ -156,10 +156,11 @@
156
156
  "xxhash-wasm": "1.0.2"
157
157
  },
158
158
  "devDependencies": {
159
+ "@ethereumjs/rlp": "^4.0.1",
159
160
  "@libp2p/interface-internal": "^3.1.12",
160
161
  "@libp2p/logger": "^6.2.13",
161
- "@lodestar/spec-test-util": "^1.50.0-dev.45e4260336",
162
- "@lodestar/test-utils": "^1.50.0-dev.45e4260336",
162
+ "@lodestar/spec-test-util": "^1.50.0-dev.4ef13ee111",
163
+ "@lodestar/test-utils": "^1.50.0-dev.4ef13ee111",
163
164
  "@types/js-yaml": "^4.0.5",
164
165
  "@types/qs": "^6.9.7",
165
166
  "@types/tmp": "^0.2.3",
@@ -174,5 +175,5 @@
174
175
  "beacon",
175
176
  "blockchain"
176
177
  ],
177
- "gitHead": "d9246828bf47948c832843c0c47d79d937a5a941"
178
+ "gitHead": "1844dc6fdf0cba1cdc3de8dc573d5d371ae3d57b"
178
179
  }
@@ -1,6 +1,11 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ApplicationMethods} from "@lodestar/api/server";
3
- import {EPOCHS_PER_HISTORICAL_VECTOR, SLOTS_PER_EPOCH, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
3
+ import {
4
+ EPOCHS_PER_HISTORICAL_VECTOR,
5
+ MIN_SEED_LOOKAHEAD,
6
+ SLOTS_PER_EPOCH,
7
+ SYNC_COMMITTEE_SUBNET_SIZE,
8
+ } from "@lodestar/params";
4
9
  import {
5
10
  IBeaconStateView,
6
11
  computeEpochAtSlot,
@@ -11,7 +16,14 @@ import {
11
16
  isStatePostFulu,
12
17
  isStatePostGloas,
13
18
  } from "@lodestar/state-transition";
14
- import {ValidatorIndex, getBuilderStatus, getValidatorStatus, ssz} from "@lodestar/types";
19
+ import {
20
+ ValidatorIndex,
21
+ getBuilderStatus,
22
+ getValidatorStatus,
23
+ mapToGeneralStatus,
24
+ ssz,
25
+ sszTypesFor,
26
+ } from "@lodestar/types";
15
27
  import {ApiError} from "../../errors.js";
16
28
  import {ApiModules} from "../../types.js";
17
29
  import {assertUniqueItems} from "../../utils.js";
@@ -100,7 +112,8 @@ export function getBeaconStateApi({
100
112
  if (resp.valid) {
101
113
  const validatorIndex = resp.validatorIndex;
102
114
  const validator = state.getValidator(validatorIndex);
103
- if (statuses.length && !statuses.includes(getValidatorStatus(validator, currentEpoch))) {
115
+ const status = getValidatorStatus(validator, currentEpoch);
116
+ if (statuses.length && !statuses.includes(status) && !statuses.includes(mapToGeneralStatus(status))) {
104
117
  continue;
105
118
  }
106
119
  const validatorResponse = toValidatorResponse(
@@ -374,6 +387,28 @@ export function getBeaconStateApi({
374
387
  };
375
388
  },
376
389
 
390
+ async getStatePtc({stateId, slot}) {
391
+ const {state, executionOptimistic, finalized} = await getState(stateId);
392
+ if (!isStatePostGloas(state)) {
393
+ throw new ApiError(400, `Cannot retrieve PTC for pre-gloas state fork=${state.forkName}`);
394
+ }
395
+
396
+ const usedSlot = slot ?? state.slot;
397
+ const epoch = computeEpochAtSlot(usedSlot);
398
+ const stateEpoch = computeEpochAtSlot(state.slot);
399
+ if (epoch < config.GLOAS_FORK_EPOCH) {
400
+ throw new ApiError(400, `Cannot retrieve PTC for pre-gloas slot=${usedSlot}`);
401
+ }
402
+ if (epoch < stateEpoch - 1 || epoch > stateEpoch + MIN_SEED_LOOKAHEAD) {
403
+ throw new ApiError(400, `Slot ${usedSlot} is outside the PTC window of state epoch ${stateEpoch}`);
404
+ }
405
+
406
+ return {
407
+ data: {slot: usedSlot, validators: Array.from(state.getPayloadTimelinessCommittee(usedSlot))},
408
+ meta: {executionOptimistic, finalized},
409
+ };
410
+ },
411
+
377
412
  async getPendingDeposits({stateId}, context) {
378
413
  const {state, executionOptimistic, finalized} = await getState(stateId);
379
414
  const fork = state.forkName;
@@ -385,7 +420,9 @@ export function getBeaconStateApi({
385
420
  const pendingDeposits = state.pendingDeposits;
386
421
 
387
422
  return {
388
- data: context?.returnBytes ? ssz.electra.PendingDeposits.serialize(pendingDeposits) : pendingDeposits,
423
+ data: context?.returnBytes
424
+ ? sszTypesFor(state.forkName).PendingDeposits.serialize(pendingDeposits)
425
+ : pendingDeposits,
389
426
  meta: {executionOptimistic, finalized, version: fork},
390
427
  };
391
428
  },
@@ -402,7 +439,7 @@ export function getBeaconStateApi({
402
439
 
403
440
  return {
404
441
  data: context?.returnBytes
405
- ? ssz.electra.PendingPartialWithdrawals.serialize(pendingPartialWithdrawals)
442
+ ? sszTypesFor(state.forkName).PendingPartialWithdrawals.serialize(pendingPartialWithdrawals)
406
443
  : pendingPartialWithdrawals,
407
444
  meta: {executionOptimistic, finalized, version: fork},
408
445
  };
@@ -420,7 +457,7 @@ export function getBeaconStateApi({
420
457
 
421
458
  return {
422
459
  data: context?.returnBytes
423
- ? ssz.electra.PendingConsolidations.serialize(pendingConsolidations)
460
+ ? sszTypesFor(state.forkName).PendingConsolidations.serialize(pendingConsolidations)
424
461
  : pendingConsolidations,
425
462
  meta: {executionOptimistic, finalized, version: fork},
426
463
  };
@@ -101,15 +101,19 @@ export function getDebugApi({
101
101
  payloadAvailabilityYesCount: ptc?.payloadPresentCount ?? 0,
102
102
  payloadDataAvailabilityYesCount: ptc?.dataAvailableCount ?? 0,
103
103
  extraData: {
104
+ attestationScore: node.attestationScore,
104
105
  executionOptimistic: isOptimisticBlock(node),
105
106
  gasLimit:
106
107
  node.payloadStatus === PayloadStatus.FULL && node.executionStatus !== ExecutionStatus.PreMerge
107
108
  ? node.executionPayloadGasLimit
108
109
  : null,
109
110
  timestamp: computeTimeAtSlot(config, node.slot, chain.genesisTime),
111
+ stateRoot: node.stateRoot,
110
112
  target: node.targetRoot,
111
113
  unrealizedJustifiedEpoch: node.unrealizedJustifiedEpoch,
114
+ unrealizedJustifiedRoot: node.unrealizedJustifiedRoot,
112
115
  unrealizedFinalizedEpoch: node.unrealizedFinalizedEpoch,
116
+ unrealizedFinalizedRoot: node.unrealizedFinalizedRoot,
113
117
  },
114
118
  };
115
119
  }),
@@ -1932,6 +1932,17 @@ export function getValidatorApi(
1932
1932
  },
1933
1933
 
1934
1934
  async prepareBeaconCommitteeSubnet({subscriptions}) {
1935
+ // The subscribing validators use this node for duties regardless of its sync state and
1936
+ // the subscription must not fail on the tracking, e.g. if the finalized state is unavailable
1937
+ try {
1938
+ await chain.updateAttachedValidators(
1939
+ chain.clock.currentEpoch,
1940
+ Array.from(new Set(subscriptions.map(({validatorIndex}) => validatorIndex)))
1941
+ );
1942
+ } catch (e) {
1943
+ logger.warn("Error tracking attached validators", {count: subscriptions.length}, e as Error);
1944
+ }
1945
+
1935
1946
  notWhileSyncing(chain, sync.state);
1936
1947
 
1937
1948
  await network.prepareBeaconCommitteeSubnets(
@@ -113,7 +113,9 @@ export class ArchiveStore {
113
113
  this.logger,
114
114
  this.metrics,
115
115
  this.opts.anchorState.finalizedCheckpoint.epoch,
116
- this.chain.clock.currentEpoch
116
+ this.chain.clock.currentEpoch,
117
+ this.statePruneFromSlot,
118
+ this.advanceEarliestAvailableSlot
117
119
  ),
118
120
  () => this.logger.info("Still pruning historical data, please wait..."),
119
121
  30_000,
@@ -122,26 +124,6 @@ export class ArchiveStore {
122
124
  this.statePruneFromSlot = stateCutoffSlot;
123
125
  }
124
126
 
125
- // Initialize earliestAvailableSlot from the earliest block actually retained (after any pruning
126
- // above), rather than the anchor state slot set in the constructor. On an in-place restart the DB
127
- // still holds finalized history below the anchor; leaving the value at the anchor makes the node
128
- // reject by_range requests (beacon_blocks, execution_payload_envelopes and data_column_sidecars
129
- // all gate on this slot) for data it still retains. An empty archive (e.g. a fresh checkpoint
130
- // sync with nothing below the anchor) leaves the constructor's anchor slot in place.
131
- const earliestArchivedBlockSlot = await this.db.blockArchive.firstKey();
132
- if (earliestArchivedBlockSlot != null) {
133
- const oldEarliestAvailableSlot = this.chain.earliestAvailableSlot;
134
- this.chain.earliestAvailableSlot = earliestArchivedBlockSlot;
135
- this.logger.verbose("Initialized earliestAvailableSlot from retained block archive", {
136
- oldEarliestAvailableSlot,
137
- newEarliestAvailableSlot: earliestArchivedBlockSlot,
138
- });
139
- } else {
140
- this.logger.verbose("Empty block archive on init, keeping anchor earliestAvailableSlot", {
141
- earliestAvailableSlot: this.chain.earliestAvailableSlot,
142
- });
143
- }
144
-
145
127
  if (this.opts.serveHistoricalState) {
146
128
  this.historicalStateRegen = await HistoricalStateRegen.init({
147
129
  opts: {
@@ -158,6 +140,18 @@ export class ArchiveStore {
158
140
  }
159
141
  }
160
142
 
143
+ /**
144
+ * The CLI owns the initial value; this only advances it during pruneHistory.
145
+ * Persisted before any deletion so a crash mid-prune never leaves the floor below deleted data.
146
+ */
147
+ private advanceEarliestAvailableSlot = async (blockCutoffSlot: Slot): Promise<void> => {
148
+ const earliestAvailableSlot = Math.max(this.chain.earliestAvailableSlot, blockCutoffSlot);
149
+ if (earliestAvailableSlot !== this.chain.earliestAvailableSlot) {
150
+ await this.db.earliestAvailableSlot.set(earliestAvailableSlot);
151
+ this.chain.earliestAvailableSlot = earliestAvailableSlot;
152
+ }
153
+ };
154
+
161
155
  async close(): Promise<void> {
162
156
  await this.historicalStateRegen?.close();
163
157
  }
@@ -259,17 +253,17 @@ export class ArchiveStore {
259
253
 
260
254
  if (this.opts.pruneHistory) {
261
255
  timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
262
- const {blockCutoffSlot, stateCutoffSlot} = await pruneHistory(
256
+ const {stateCutoffSlot} = await pruneHistory(
263
257
  this.chain.config,
264
258
  this.db,
265
259
  this.logger,
266
260
  this.metrics,
267
261
  finalizedEpoch,
268
262
  this.chain.clock.currentEpoch,
269
- this.statePruneFromSlot
263
+ this.statePruneFromSlot,
264
+ this.advanceEarliestAvailableSlot
270
265
  );
271
266
  this.statePruneFromSlot = stateCutoffSlot;
272
- this.chain.earliestAvailableSlot = Math.max(this.chain.earliestAvailableSlot, blockCutoffSlot);
273
267
  timer?.({source: ArchiveStoreTask.PruneHistory});
274
268
  }
275
269
 
@@ -12,7 +12,8 @@ export async function pruneHistory(
12
12
  metrics: Metrics | null | undefined,
13
13
  finalizedEpoch: Epoch,
14
14
  currentEpoch: Epoch,
15
- statePruneFromSlot: Slot = 0
15
+ statePruneFromSlot: Slot,
16
+ beforePrune: (blockCutoffSlot: Slot) => Promise<void>
16
17
  ): Promise<{blockCutoffSlot: Slot; stateCutoffSlot: Slot}> {
17
18
  const blockCutoffEpoch = Math.min(
18
19
  // set by config, with underflow protection
@@ -51,6 +52,8 @@ export async function pruneHistory(
51
52
  stateSlots: prettyPrintIndices(states),
52
53
  });
53
54
 
55
+ await beforePrune(blockCutoffSlot);
56
+
54
57
  const step1 = metrics?.pruneHistory.pruneKeys.startTimer();
55
58
  await Promise.all([
56
59
  // ->
@@ -6,7 +6,7 @@ const PROPOSER_PRESERVE_EPOCHS = 2;
6
6
  export type ProposerPreparationData = routes.validator.ProposerPreparationData;
7
7
 
8
8
  export class BeaconProposerCache {
9
- private readonly feeRecipientByValidatorIndex: Map<number, {epoch: Epoch; feeRecipient: string}>;
9
+ private readonly feeRecipientByValidatorIndex: Map<number, {epoch: Epoch; feeRecipient?: string}>;
10
10
  constructor(readonly opts: {suggestedFeeRecipient: string}) {
11
11
  this.feeRecipientByValidatorIndex = new Map();
12
12
  }
@@ -15,6 +15,24 @@ export class BeaconProposerCache {
15
15
  this.feeRecipientByValidatorIndex.set(validatorIndex, {epoch, feeRecipient});
16
16
  }
17
17
 
18
+ /**
19
+ * Track a validator that uses this node for duties, keeping the fee recipient it may have
20
+ * registered. Returns true if the validator was not tracked before.
21
+ */
22
+ track(epoch: Epoch, validatorIndex: number): boolean {
23
+ const entry = this.feeRecipientByValidatorIndex.get(validatorIndex);
24
+ if (entry !== undefined) {
25
+ entry.epoch = epoch;
26
+ return false;
27
+ }
28
+ this.feeRecipientByValidatorIndex.set(validatorIndex, {epoch});
29
+ return true;
30
+ }
31
+
32
+ has(validatorIndex: number): boolean {
33
+ return this.feeRecipientByValidatorIndex.has(validatorIndex);
34
+ }
35
+
18
36
  prune(epoch: Epoch): void {
19
37
  // This is not so optimized function, but could maintain a 2d array may be?
20
38
  for (const [validatorIndex, feeRecipientEntry] of this.feeRecipientByValidatorIndex.entries()) {
@@ -22,6 +22,7 @@ import {
22
22
  RootCache,
23
23
  computeEpochAtSlot,
24
24
  computeTimeAtSlot,
25
+ getBeaconCommittees,
25
26
  isStatePostAltair,
26
27
  isStatePostBellatrix,
27
28
  } from "@lodestar/state-transition";
@@ -129,11 +130,17 @@ export async function importBlock(
129
130
 
130
131
  // Should compute checkpoint balances before forkchoice.onBlock
131
132
  this.checkpointBalancesCache.processState(blockRootHex, postState);
132
- if (fork >= ForkSeq.gloas) {
133
+ if (isGloasBeaconBlock(block.message)) {
134
+ // A gloas block has no payload of its own, it inherits the status of the payload it builds on,
135
+ // i.e. the parent variant matching the bid's parent block hash. The parent's default (PENDING)
136
+ // variant does not reflect a SYNCING parent payload, and onBlock would then mark that payload VALID.
133
137
  const parentRootHex = toRootHex(block.message.parentRoot);
134
- const parentBlock = this.forkChoice.getBlockHexDefaultStatus(parentRootHex);
138
+ const parentBlockHashHex = toRootHex(block.message.body.signedExecutionPayloadBid.message.parentBlockHash);
139
+ const parentBlock = this.forkChoice.getBlockHexAndBlockHash(parentRootHex, parentBlockHashHex);
135
140
  if (parentBlock === null) {
136
- throw Error(`Parent block not found in forkChoice, parentRoot=${parentRootHex}`);
141
+ throw Error(
142
+ `Parent block not found in forkChoice, parentRoot=${parentRootHex} parentBlockHash=${parentBlockHashHex}`
143
+ );
137
144
  }
138
145
  if (parentBlock.executionStatus === ExecutionStatus.Invalid) {
139
146
  throw Error(`Parent block has invalid execution status, parentRoot=${parentRootHex}`);
@@ -400,9 +407,8 @@ export async function importBlock(
400
407
  const proposalSlot = blockSlot + 1;
401
408
  try {
402
409
  const proposerIndex = postState.getBeaconProposer(proposalSlot);
403
- const feeRecipient = this.beaconProposerCache.get(proposerIndex);
404
410
 
405
- if (feeRecipient) {
411
+ if (this.beaconProposerCache.has(proposerIndex)) {
406
412
  // We would set this to true if
407
413
  // 1) This is a gossip block
408
414
  // 2) We are proposer of next slot
@@ -657,8 +663,12 @@ export function addAttestationPostElectra(
657
663
  } else {
658
664
  const attSlot = attestation.data.slot;
659
665
  const attEpoch = computeEpochAtSlot(attSlot);
660
- const decisionRoot = state.getShufflingDecisionRoot(attEpoch);
661
- const committees = this.shufflingCache.getBeaconCommittees(attEpoch, decisionRoot, attSlot, committeeIndices);
666
+ // calling getShufflingAtEpoch may take some time for NativeBeaconStateView
667
+ // we should have the shuffling inside ShufflingCache most of the time
668
+ const shuffling =
669
+ this.shufflingCache.getSync(attEpoch, state.getShufflingDecisionRoot(attEpoch)) ??
670
+ state.getShufflingAtEpoch(attEpoch);
671
+ const committees = getBeaconCommittees(shuffling, attSlot, committeeIndices);
662
672
  const aggregationBools = attestation.aggregationBits.toBoolArray();
663
673
  let offset = 0;
664
674
  for (let i = 0; i < committees.length; i++) {
@@ -4,6 +4,7 @@ import {
4
4
  DataAvailabilityStatus,
5
5
  IBeaconStateView,
6
6
  computeEpochAtSlot,
7
+ getIndexedAttestation,
7
8
  signedBlockToSignedHeader,
8
9
  } from "@lodestar/state-transition";
9
10
  import {IndexedAttestation, Slot, deneb} from "@lodestar/types";
@@ -81,10 +82,6 @@ export async function verifyBlocksInEpoch(
81
82
  throw new BlockError(block0, {code: BlockErrorCode.PRESTATE_MISSING, error: e as Error});
82
83
  });
83
84
 
84
- // in forky condition, make sure to populate ShufflingCache with regened state
85
- // otherwise it may fail to get indexed attestations from shuffling cache later
86
- this.shufflingCache.processState(preState0);
87
-
88
85
  if (!preState0.isStateValidatorsNodesPopulated()) {
89
86
  this.logger.verbose("verifyBlocksInEpoch preState0 SSZ cache stats", {
90
87
  slot: preState0.slot,
@@ -117,8 +114,12 @@ export async function verifyBlocksInEpoch(
117
114
  for (const [i, block] of blocks.entries()) {
118
115
  indexedAttestationsByBlock[i] = block.message.body.attestations.map((attestation) => {
119
116
  const attEpoch = computeEpochAtSlot(attestation.data.slot);
120
- const decisionRoot = preState0.getShufflingDecisionRoot(attEpoch);
121
- return this.shufflingCache.getIndexedAttestation(attEpoch, decisionRoot, fork, attestation);
117
+ // calling getShufflingAtEpoch may take some time for NativeBeaconStateView
118
+ // we should have the shuffling inside ShufflingCache most of the time
119
+ const shuffling =
120
+ this.shufflingCache.getSync(attEpoch, preState0.getShufflingDecisionRoot(attEpoch)) ??
121
+ preState0.getShufflingAtEpoch(attEpoch);
122
+ return getIndexedAttestation(shuffling, fork, attestation);
122
123
  });
123
124
  }
124
125
 
@@ -128,7 +128,7 @@ import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js";
128
128
  import {SeenAttestationDatas} from "./seenCache/seenAttestationData.js";
129
129
  import {SeenBlockAttesters} from "./seenCache/seenBlockAttesters.js";
130
130
  import {SeenBlockInput} from "./seenCache/seenGossipBlockInput.js";
131
- import {ShufflingCache} from "./shufflingCache.js";
131
+ import {ShufflingCache, ShufflingPromiseCancelReason} from "./shufflingCache.js";
132
132
  import {DbCPStateDatastore, checkpointToDatastoreKey} from "./stateCache/datastore/db.js";
133
133
  import {FileCPStateDatastore} from "./stateCache/datastore/file.js";
134
134
  import {CPStateDatastore} from "./stateCache/datastore/types.js";
@@ -279,6 +279,7 @@ export class BeaconChain implements IBeaconChain {
279
279
  validatorMonitor,
280
280
  anchorState,
281
281
  isAnchorStateFinalized,
282
+ earliestAvailableSlot,
282
283
  executionEngine,
283
284
  executionBuilder,
284
285
  builderApiClientOpts,
@@ -298,6 +299,7 @@ export class BeaconChain implements IBeaconChain {
298
299
  validatorMonitor: ValidatorMonitor | null;
299
300
  anchorState: IBeaconStateView;
300
301
  isAnchorStateFinalized: boolean;
302
+ earliestAvailableSlot: Slot;
301
303
  executionEngine: IExecutionEngine;
302
304
  executionBuilder?: IExecutionBuilder;
303
305
  builderApiClientOpts?: BuilderApiClientOpts;
@@ -326,7 +328,7 @@ export class BeaconChain implements IBeaconChain {
326
328
 
327
329
  this.blacklistedBlocks = new Map((opts.blacklistedBlocks ?? []).map((hex) => [hex, null]));
328
330
  this.attestationPool = new AttestationPool(config, clock, this.opts?.preaggregateSlotDistance, metrics);
329
- this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics);
331
+ this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics, logger);
330
332
  this.syncCommitteeMessagePool = new SyncCommitteeMessagePool(config, clock, this.opts?.preaggregateSlotDistance);
331
333
  this.syncContributionAndProofPool = new SyncContributionAndProofPool(config, clock, metrics, logger);
332
334
  this.executionPayloadBidPool = new ExecutionPayloadBidPool();
@@ -363,7 +365,7 @@ export class BeaconChain implements IBeaconChain {
363
365
  logger,
364
366
  });
365
367
 
366
- this._earliestAvailableSlot = anchorState.slot;
368
+ this._earliestAvailableSlot = earliestAvailableSlot;
367
369
 
368
370
  this.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
369
371
  {
@@ -574,7 +576,11 @@ export class BeaconChain implements IBeaconChain {
574
576
  }
575
577
 
576
578
  seenBlock(blockRoot: RootHex): boolean {
577
- return this.seenBlockInputCache.hasBlock(blockRoot) || this.forkChoice.hasBlockHexUnsafe(blockRoot);
579
+ return (
580
+ this.seenBlockInputCache.hasBlock(blockRoot) ||
581
+ this.seenBlockInputCache.isValidatingBlock(blockRoot) ||
582
+ this.forkChoice.hasBlockHexUnsafe(blockRoot)
583
+ );
578
584
  }
579
585
 
580
586
  seenPayloadEnvelope(blockRoot: RootHex): boolean {
@@ -614,12 +620,14 @@ export class BeaconChain implements IBeaconChain {
614
620
  async loadFromDisk(): Promise<void> {
615
621
  await this.regen.init();
616
622
  await this.opPool.fromPersisted(this.db, this.getHeadState(), this.bls, this.clock.currentSlot);
623
+ await this.proposerPreferencesPool.fromPersisted(this.db, this.clock.currentSlot);
617
624
  }
618
625
 
619
626
  /** Persist in-memory data to the DB. Call at least once before stopping the process */
620
627
  async persistToDisk(): Promise<void> {
621
628
  await this.archiveStore.persistToDisk();
622
629
  await this.opPool.toPersisted(this.db);
630
+ await this.proposerPreferencesPool.toPersisted(this.db);
623
631
  }
624
632
 
625
633
  getHeadState(): IBeaconStateView {
@@ -1623,21 +1631,48 @@ export class BeaconChain implements IBeaconChain {
1623
1631
  const blockEpoch = computeEpochAtSlot(attHeadBlock.slot);
1624
1632
 
1625
1633
  let state: IBeaconStateView;
1626
- if (blockEpoch < attEpoch - 1) {
1627
- // thanks to one epoch look ahead, we don't need to dial up to attEpoch
1628
- const targetSlot = computeStartSlotAtEpoch(attEpoch - 1);
1629
- this.metrics?.gossipAttestation.useHeadBlockStateDialedToTargetEpoch.inc({caller: regenCaller});
1630
- state = await this.regen.getBlockSlotState(attHeadBlock, targetSlot, {dontTransferCache: true}, regenCaller);
1631
- } else if (blockEpoch > attEpoch) {
1632
- // should not happen, handled inside attestation verification code
1633
- throw Error(`Block epoch ${blockEpoch} is after attestation epoch ${attEpoch}`);
1634
- } else {
1635
- // should use either current or next shuffling of head state
1636
- // it's not likely to hit this since these shufflings are cached already
1637
- // so handle just in case
1638
- this.metrics?.gossipAttestation.useHeadBlockState.inc({caller: regenCaller});
1639
- state = await this.regen.getState(attHeadBlock.stateRoot, regenCaller);
1634
+ try {
1635
+ if (blockEpoch < attEpoch - 1) {
1636
+ // thanks to one epoch look ahead, we don't need to dial up to attEpoch
1637
+ const targetSlot = computeStartSlotAtEpoch(attEpoch - 1);
1638
+ this.metrics?.gossipAttestation.useHeadBlockStateDialedToTargetEpoch.inc({caller: regenCaller});
1639
+ state = await this.regen.getBlockSlotState(attHeadBlock, targetSlot, {dontTransferCache: true}, regenCaller);
1640
+ } else if (blockEpoch > attEpoch) {
1641
+ // should not happen, handled inside attestation verification code
1642
+ throw Error(`Block epoch ${blockEpoch} is after attestation epoch ${attEpoch}`);
1643
+ } else {
1644
+ // should use either current or next shuffling of head state
1645
+ // it's not likely to hit this since these shufflings are cached already
1646
+ // so handle just in case
1647
+ this.metrics?.gossipAttestation.useHeadBlockState.inc({caller: regenCaller});
1648
+ state = await this.regen.getState(attHeadBlock.stateRoot, regenCaller);
1649
+ }
1650
+ } catch (e) {
1651
+ this.shufflingCache.cancelPromise(attEpoch, shufflingDependentRoot, ShufflingPromiseCancelReason.regenError);
1652
+ throw e;
1653
+ }
1654
+
1655
+ const stateDecisionRoot = state.getShufflingDecisionRoot(attEpoch);
1656
+ if (stateDecisionRoot !== shufflingDependentRoot) {
1657
+ // the promise would never be resolved by the state's shuffling
1658
+ this.shufflingCache.cancelPromise(
1659
+ attEpoch,
1660
+ shufflingDependentRoot,
1661
+ ShufflingPromiseCancelReason.decisionRootMismatch
1662
+ );
1663
+ this.logger.debug("Shuffling decision root mismatch on attestation regen", {
1664
+ slot: attHeadBlock.slot,
1665
+ root: attHeadBlock.blockRoot,
1666
+ epoch: attEpoch,
1667
+ shufflingDependentRoot,
1668
+ stateDecisionRoot,
1669
+ });
1670
+
1671
+ throw Error(
1672
+ `Shuffling decision root mismatch epoch=${attEpoch} slot=${attHeadBlock.slot} root=${attHeadBlock.blockRoot} expected=${shufflingDependentRoot} actual=${stateDecisionRoot}`
1673
+ );
1640
1674
  }
1675
+
1641
1676
  // resolve the promise to unblock other calls of the same epoch and dependent root
1642
1677
  this.shufflingCache.processState(state);
1643
1678
  return state.getShufflingAtEpoch(attEpoch);
@@ -1901,6 +1936,21 @@ export class BeaconChain implements IBeaconChain {
1901
1936
  }
1902
1937
  }
1903
1938
 
1939
+ async updateAttachedValidators(epoch: Epoch, validatorIndices: ValidatorIndex[]): Promise<void> {
1940
+ let hasNewValidators = false;
1941
+ for (const validatorIndex of validatorIndices) {
1942
+ if (this.beaconProposerCache.track(epoch, validatorIndex)) {
1943
+ hasNewValidators = true;
1944
+ }
1945
+ }
1946
+
1947
+ // Only update validator custody if we discovered new validators
1948
+ if (hasNewValidators) {
1949
+ const finalizedCheckpoint = this.forkChoice.getFinalizedCheckpoint();
1950
+ await this.updateValidatorsCustodyRequirement(finalizedCheckpoint);
1951
+ }
1952
+ }
1953
+
1904
1954
  private async updateValidatorsCustodyRequirement(finalizedCheckpoint: CheckpointWithHex): Promise<void> {
1905
1955
  if (this.custodyConfig.targetCustodyGroupCount === this.config.NUMBER_OF_CUSTODY_GROUPS) {
1906
1956
  // Custody requirements can only be increased, we can disable dynamic custody updates
@@ -288,6 +288,8 @@ export interface IBeaconChain {
288
288
  waitForBlock(slot: Slot, root: RootHex): Promise<boolean>;
289
289
 
290
290
  updateBeaconProposerData(epoch: Epoch, proposers: ProposerPreparationData[]): Promise<void>;
291
+ /** Track validators that use this node for duties, e.g. by subscribing to attestation subnets */
292
+ updateAttachedValidators(epoch: Epoch, validatorIndices: ValidatorIndex[]): Promise<void>;
291
293
 
292
294
  persistBlock(data: BeaconBlock | BlindedBeaconBlock, suffix?: string): void;
293
295
  persistExecutionPayloadEnvelope(envelope: gloas.ExecutionPayloadEnvelope): void;