@lodestar/beacon-node 1.50.0-dev.335476095e → 1.50.0-dev.3430a7cf04

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 (289) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +7 -2
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/state/index.js +28 -6
  6. package/lib/api/impl/beacon/state/index.js.map +1 -1
  7. package/lib/api/impl/debug/index.d.ts.map +1 -1
  8. package/lib/api/impl/debug/index.js +26 -18
  9. package/lib/api/impl/debug/index.js.map +1 -1
  10. package/lib/api/impl/validator/index.d.ts.map +1 -1
  11. package/lib/api/impl/validator/index.js +63 -17
  12. package/lib/api/impl/validator/index.js.map +1 -1
  13. package/lib/chain/ColumnReconstructionTracker.d.ts +0 -2
  14. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  15. package/lib/chain/ColumnReconstructionTracker.js +4 -5
  16. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  17. package/lib/chain/archiveStore/archiveStore.d.ts +5 -0
  18. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/archiveStore.js +13 -23
  20. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  21. package/lib/chain/archiveStore/utils/pruneHistory.d.ts +1 -1
  22. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  23. package/lib/chain/archiveStore/utils/pruneHistory.js +2 -1
  24. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  25. package/lib/chain/beaconProposerCache.d.ts +6 -0
  26. package/lib/chain/beaconProposerCache.d.ts.map +1 -1
  27. package/lib/chain/beaconProposerCache.js +16 -0
  28. package/lib/chain/beaconProposerCache.js.map +1 -1
  29. package/lib/chain/blocks/blockInput/blockInput.d.ts +1 -1
  30. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  31. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  32. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  33. package/lib/chain/blocks/importBlock.js +21 -12
  34. package/lib/chain/blocks/importBlock.js.map +1 -1
  35. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  36. package/lib/chain/blocks/verifyBlock.js +6 -6
  37. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  38. package/lib/chain/chain.d.ts +4 -1
  39. package/lib/chain/chain.d.ts.map +1 -1
  40. package/lib/chain/chain.js +65 -22
  41. package/lib/chain/chain.js.map +1 -1
  42. package/lib/chain/interface.d.ts +4 -1
  43. package/lib/chain/interface.d.ts.map +1 -1
  44. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +4 -2
  45. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  46. package/lib/chain/opPools/aggregatedAttestationPool.js +30 -8
  47. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  48. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  49. package/lib/chain/opPools/opPool.js +1 -23
  50. package/lib/chain/opPools/opPool.js.map +1 -1
  51. package/lib/chain/opPools/proposerPreferencesPool.d.ts +4 -0
  52. package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
  53. package/lib/chain/opPools/proposerPreferencesPool.js +13 -1
  54. package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
  55. package/lib/chain/opPools/utils.d.ts +11 -0
  56. package/lib/chain/opPools/utils.d.ts.map +1 -1
  57. package/lib/chain/opPools/utils.js +22 -0
  58. package/lib/chain/opPools/utils.js.map +1 -1
  59. package/lib/chain/options.d.ts +1 -0
  60. package/lib/chain/options.d.ts.map +1 -1
  61. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  62. package/lib/chain/prepareNextSlot.js +15 -6
  63. package/lib/chain/prepareNextSlot.js.map +1 -1
  64. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  65. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  66. package/lib/chain/produceBlock/produceBlockBody.d.ts +8 -0
  67. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  68. package/lib/chain/produceBlock/produceBlockBody.js +48 -34
  69. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  70. package/lib/chain/reprocess.d.ts +2 -1
  71. package/lib/chain/reprocess.d.ts.map +1 -1
  72. package/lib/chain/reprocess.js +2 -1
  73. package/lib/chain/reprocess.js.map +1 -1
  74. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +7 -0
  75. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  76. package/lib/chain/seenCache/seenGossipBlockInput.js +22 -1
  77. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  78. package/lib/chain/shufflingCache.d.ts +18 -8
  79. package/lib/chain/shufflingCache.d.ts.map +1 -1
  80. package/lib/chain/shufflingCache.js +72 -18
  81. package/lib/chain/shufflingCache.js.map +1 -1
  82. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  83. package/lib/chain/stateCache/persistentCheckpointsCache.js +1 -1
  84. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  85. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  86. package/lib/chain/validatorMonitor.js +6 -4
  87. package/lib/chain/validatorMonitor.js.map +1 -1
  88. package/lib/constants/constants.d.ts +1 -0
  89. package/lib/constants/constants.d.ts.map +1 -1
  90. package/lib/constants/constants.js +1 -0
  91. package/lib/constants/constants.js.map +1 -1
  92. package/lib/db/beacon.d.ts +4 -1
  93. package/lib/db/beacon.d.ts.map +1 -1
  94. package/lib/db/beacon.js +6 -1
  95. package/lib/db/beacon.js.map +1 -1
  96. package/lib/db/buckets.d.ts +3 -1
  97. package/lib/db/buckets.d.ts.map +1 -1
  98. package/lib/db/buckets.js +2 -0
  99. package/lib/db/buckets.js.map +1 -1
  100. package/lib/db/interface.d.ts +4 -1
  101. package/lib/db/interface.d.ts.map +1 -1
  102. package/lib/db/repositories/blockArchive.js +2 -2
  103. package/lib/db/repositories/blockArchive.js.map +1 -1
  104. package/lib/db/repositories/blockArchiveIndex.d.ts +3 -3
  105. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  106. package/lib/db/repositories/blockArchiveIndex.js +1 -2
  107. package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
  108. package/lib/db/repositories/earliestAvailableSlot.d.ts +11 -0
  109. package/lib/db/repositories/earliestAvailableSlot.d.ts.map +1 -0
  110. package/lib/db/repositories/earliestAvailableSlot.js +19 -0
  111. package/lib/db/repositories/earliestAvailableSlot.js.map +1 -0
  112. package/lib/db/repositories/index.d.ts +1 -0
  113. package/lib/db/repositories/index.d.ts.map +1 -1
  114. package/lib/db/repositories/index.js +1 -0
  115. package/lib/db/repositories/index.js.map +1 -1
  116. package/lib/db/repositories/proposerPreferences.d.ts +14 -0
  117. package/lib/db/repositories/proposerPreferences.d.ts.map +1 -0
  118. package/lib/db/repositories/proposerPreferences.js +21 -0
  119. package/lib/db/repositories/proposerPreferences.js.map +1 -0
  120. package/lib/execution/engine/blobVersionedHashes.d.ts +9 -0
  121. package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -0
  122. package/lib/execution/engine/blobVersionedHashes.js +74 -0
  123. package/lib/execution/engine/blobVersionedHashes.js.map +1 -0
  124. package/lib/execution/engine/http.d.ts +45 -13
  125. package/lib/execution/engine/http.d.ts.map +1 -1
  126. package/lib/execution/engine/http.js +236 -198
  127. package/lib/execution/engine/http.js.map +1 -1
  128. package/lib/execution/engine/index.d.ts +3 -2
  129. package/lib/execution/engine/index.d.ts.map +1 -1
  130. package/lib/execution/engine/index.js +33 -8
  131. package/lib/execution/engine/index.js.map +1 -1
  132. package/lib/execution/engine/interface.d.ts +1 -1
  133. package/lib/execution/engine/interface.d.ts.map +1 -1
  134. package/lib/execution/engine/jsonRpcTransport.d.ts +25 -0
  135. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -0
  136. package/lib/execution/engine/jsonRpcTransport.js +158 -0
  137. package/lib/execution/engine/jsonRpcTransport.js.map +1 -0
  138. package/lib/execution/engine/restHttpClient.d.ts +71 -0
  139. package/lib/execution/engine/restHttpClient.d.ts.map +1 -0
  140. package/lib/execution/engine/restHttpClient.js +201 -0
  141. package/lib/execution/engine/restHttpClient.js.map +1 -0
  142. package/lib/execution/engine/restTransport.d.ts +46 -0
  143. package/lib/execution/engine/restTransport.d.ts.map +1 -0
  144. package/lib/execution/engine/restTransport.js +399 -0
  145. package/lib/execution/engine/restTransport.js.map +1 -0
  146. package/lib/execution/engine/sszTypes.d.ts +1261 -0
  147. package/lib/execution/engine/sszTypes.d.ts.map +1 -0
  148. package/lib/execution/engine/sszTypes.js +216 -0
  149. package/lib/execution/engine/sszTypes.js.map +1 -0
  150. package/lib/execution/engine/transport.d.ts +39 -0
  151. package/lib/execution/engine/transport.d.ts.map +1 -0
  152. package/lib/execution/engine/transport.js +2 -0
  153. package/lib/execution/engine/transport.js.map +1 -0
  154. package/lib/execution/engine/types.d.ts +2 -0
  155. package/lib/execution/engine/types.d.ts.map +1 -1
  156. package/lib/execution/engine/types.js +31 -63
  157. package/lib/execution/engine/types.js.map +1 -1
  158. package/lib/execution/engine/utils.d.ts.map +1 -1
  159. package/lib/execution/engine/utils.js +9 -2
  160. package/lib/execution/engine/utils.js.map +1 -1
  161. package/lib/metrics/metrics/lodestar.d.ts +10 -0
  162. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  163. package/lib/metrics/metrics/lodestar.js +22 -0
  164. package/lib/metrics/metrics/lodestar.js.map +1 -1
  165. package/lib/network/core/events.d.ts +5 -1
  166. package/lib/network/core/events.d.ts.map +1 -1
  167. package/lib/network/core/events.js +8 -0
  168. package/lib/network/core/events.js.map +1 -1
  169. package/lib/network/gossip/topic.d.ts +0 -14
  170. package/lib/network/gossip/topic.d.ts.map +1 -1
  171. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  172. package/lib/network/processor/gossipHandlers.js +60 -64
  173. package/lib/network/processor/gossipHandlers.js.map +1 -1
  174. package/lib/network/processor/index.js +3 -3
  175. package/lib/network/processor/index.js.map +1 -1
  176. package/lib/network/reqresp/rateLimit.js +2 -2
  177. package/lib/network/reqresp/rateLimit.js.map +1 -1
  178. package/lib/network/subnets/attnetsService.d.ts.map +1 -1
  179. package/lib/network/subnets/attnetsService.js +3 -1
  180. package/lib/network/subnets/attnetsService.js.map +1 -1
  181. package/lib/node/nodejs.d.ts +3 -1
  182. package/lib/node/nodejs.d.ts.map +1 -1
  183. package/lib/node/nodejs.js +2 -1
  184. package/lib/node/nodejs.js.map +1 -1
  185. package/lib/node/notifier.d.ts.map +1 -1
  186. package/lib/node/notifier.js +12 -13
  187. package/lib/node/notifier.js.map +1 -1
  188. package/lib/node/options.d.ts +3 -2
  189. package/lib/node/options.d.ts.map +1 -1
  190. package/lib/node/options.js +2 -2
  191. package/lib/node/options.js.map +1 -1
  192. package/lib/sync/range/batch.d.ts +5 -5
  193. package/lib/sync/range/batch.d.ts.map +1 -1
  194. package/lib/sync/range/batch.js +11 -17
  195. package/lib/sync/range/batch.js.map +1 -1
  196. package/lib/sync/range/chain.d.ts +4 -4
  197. package/lib/sync/range/chain.d.ts.map +1 -1
  198. package/lib/sync/range/chain.js +7 -5
  199. package/lib/sync/range/chain.js.map +1 -1
  200. package/lib/sync/range/range.d.ts.map +1 -1
  201. package/lib/sync/range/range.js +25 -11
  202. package/lib/sync/range/range.js.map +1 -1
  203. package/lib/sync/unknownBlock.d.ts +5 -2
  204. package/lib/sync/unknownBlock.d.ts.map +1 -1
  205. package/lib/sync/unknownBlock.js +47 -22
  206. package/lib/sync/unknownBlock.js.map +1 -1
  207. package/lib/sync/utils/downloadByRange.d.ts +38 -14
  208. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  209. package/lib/sync/utils/downloadByRange.js +84 -39
  210. package/lib/sync/utils/downloadByRange.js.map +1 -1
  211. package/lib/util/asyncIterableToEvents.d.ts +10 -2
  212. package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
  213. package/lib/util/asyncIterableToEvents.js +29 -3
  214. package/lib/util/asyncIterableToEvents.js.map +1 -1
  215. package/lib/util/clock.d.ts.map +1 -1
  216. package/lib/util/clock.js +3 -4
  217. package/lib/util/clock.js.map +1 -1
  218. package/lib/util/metadata.d.ts.map +1 -1
  219. package/lib/util/metadata.js +2 -1
  220. package/lib/util/metadata.js.map +1 -1
  221. package/lib/util/sszBytes.d.ts +2 -2
  222. package/lib/util/sszBytes.d.ts.map +1 -1
  223. package/lib/util/sszBytes.js +22 -14
  224. package/lib/util/sszBytes.js.map +1 -1
  225. package/package.json +17 -16
  226. package/src/api/impl/beacon/blocks/index.ts +10 -3
  227. package/src/api/impl/beacon/state/index.ts +43 -6
  228. package/src/api/impl/debug/index.ts +28 -19
  229. package/src/api/impl/validator/index.ts +86 -19
  230. package/src/chain/ColumnReconstructionTracker.ts +4 -6
  231. package/src/chain/archiveStore/archiveStore.ts +18 -24
  232. package/src/chain/archiveStore/utils/pruneHistory.ts +4 -1
  233. package/src/chain/beaconProposerCache.ts +19 -1
  234. package/src/chain/blocks/blockInput/blockInput.ts +1 -1
  235. package/src/chain/blocks/importBlock.ts +25 -11
  236. package/src/chain/blocks/verifyBlock.ts +7 -6
  237. package/src/chain/chain.ts +88 -21
  238. package/src/chain/interface.ts +5 -1
  239. package/src/chain/opPools/aggregatedAttestationPool.ts +34 -10
  240. package/src/chain/opPools/opPool.ts +1 -31
  241. package/src/chain/opPools/proposerPreferencesPool.ts +20 -1
  242. package/src/chain/opPools/utils.ts +31 -0
  243. package/src/chain/options.ts +1 -1
  244. package/src/chain/prepareNextSlot.ts +22 -6
  245. package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
  246. package/src/chain/produceBlock/produceBlockBody.ts +78 -39
  247. package/src/chain/reprocess.ts +2 -1
  248. package/src/chain/seenCache/seenGossipBlockInput.ts +25 -1
  249. package/src/chain/shufflingCache.ts +84 -22
  250. package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
  251. package/src/chain/validatorMonitor.ts +7 -4
  252. package/src/constants/constants.ts +1 -0
  253. package/src/db/beacon.ts +6 -0
  254. package/src/db/buckets.ts +2 -0
  255. package/src/db/interface.ts +4 -0
  256. package/src/db/repositories/blockArchive.ts +2 -2
  257. package/src/db/repositories/blockArchiveIndex.ts +2 -3
  258. package/src/db/repositories/earliestAvailableSlot.ts +19 -0
  259. package/src/db/repositories/index.ts +1 -0
  260. package/src/db/repositories/proposerPreferences.ts +23 -0
  261. package/src/execution/engine/blobVersionedHashes.ts +72 -0
  262. package/src/execution/engine/http.ts +304 -271
  263. package/src/execution/engine/index.ts +41 -7
  264. package/src/execution/engine/interface.ts +1 -1
  265. package/src/execution/engine/jsonRpcTransport.ts +247 -0
  266. package/src/execution/engine/restHttpClient.ts +269 -0
  267. package/src/execution/engine/restTransport.ts +544 -0
  268. package/src/execution/engine/sszTypes.ts +354 -0
  269. package/src/execution/engine/transport.ts +61 -0
  270. package/src/execution/engine/types.ts +42 -80
  271. package/src/execution/engine/utils.ts +12 -2
  272. package/src/metrics/metrics/lodestar.ts +23 -0
  273. package/src/network/core/events.ts +16 -1
  274. package/src/network/processor/gossipHandlers.ts +91 -77
  275. package/src/network/processor/index.ts +3 -3
  276. package/src/network/reqresp/rateLimit.ts +2 -2
  277. package/src/network/subnets/attnetsService.ts +8 -3
  278. package/src/node/nodejs.ts +4 -0
  279. package/src/node/notifier.ts +14 -13
  280. package/src/node/options.ts +10 -1
  281. package/src/sync/range/batch.ts +14 -19
  282. package/src/sync/range/chain.ts +9 -7
  283. package/src/sync/range/range.ts +26 -12
  284. package/src/sync/unknownBlock.ts +60 -23
  285. package/src/sync/utils/downloadByRange.ts +123 -58
  286. package/src/util/asyncIterableToEvents.ts +44 -5
  287. package/src/util/clock.ts +3 -4
  288. package/src/util/metadata.ts +2 -1
  289. package/src/util/sszBytes.ts +25 -12
@@ -58,7 +58,7 @@ import {
58
58
  } from "@lodestar/types";
59
59
  import {Logger, fromHex, gweiToWei, isErrorAborted, pruneSetToMax, sleep, toRootHex} from "@lodestar/utils";
60
60
  import {ProcessShutdownCallback} from "@lodestar/validator";
61
- import {GENESIS_EPOCH, ZERO_HASH} from "../constants/index.js";
61
+ import {GENESIS_EPOCH, HALF_SLOT_BPS, ZERO_HASH} from "../constants/index.js";
62
62
  import {IBeaconDb} from "../db/index.js";
63
63
  import {BLOB_SIDECARS_IN_WRAPPER_INDEX} from "../db/repositories/blobSidecars.js";
64
64
  import {decodeArchivedEnvelope} from "../db/repositories/index.js";
@@ -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 {
@@ -1536,6 +1544,22 @@ export class BeaconChain implements IBeaconChain {
1536
1544
  }
1537
1545
  }
1538
1546
 
1547
+ persistExecutionPayloadEnvelope(envelope: gloas.ExecutionPayloadEnvelope): void {
1548
+ const blockRoot = toRootHex(envelope.beaconBlockRoot);
1549
+ void this.persistSszObject(
1550
+ "ExecutionPayloadEnvelope",
1551
+ ssz.gloas.ExecutionPayloadEnvelope.serialize(envelope),
1552
+ blockRoot,
1553
+ "produced_execution_payload_envelope"
1554
+ ).catch((e) => {
1555
+ this.logger.error(
1556
+ "Error persisting produced execution payload envelope",
1557
+ {slot: envelope.payload.slotNumber, blockRoot},
1558
+ e as Error
1559
+ );
1560
+ });
1561
+ }
1562
+
1539
1563
  /**
1540
1564
  * Invalid state root error is critical and it causes the node to stale most of the time so we want to always
1541
1565
  * persist preState, postState and block for further investigation.
@@ -1607,21 +1631,48 @@ export class BeaconChain implements IBeaconChain {
1607
1631
  const blockEpoch = computeEpochAtSlot(attHeadBlock.slot);
1608
1632
 
1609
1633
  let state: IBeaconStateView;
1610
- if (blockEpoch < attEpoch - 1) {
1611
- // thanks to one epoch look ahead, we don't need to dial up to attEpoch
1612
- const targetSlot = computeStartSlotAtEpoch(attEpoch - 1);
1613
- this.metrics?.gossipAttestation.useHeadBlockStateDialedToTargetEpoch.inc({caller: regenCaller});
1614
- state = await this.regen.getBlockSlotState(attHeadBlock, targetSlot, {dontTransferCache: true}, regenCaller);
1615
- } else if (blockEpoch > attEpoch) {
1616
- // should not happen, handled inside attestation verification code
1617
- throw Error(`Block epoch ${blockEpoch} is after attestation epoch ${attEpoch}`);
1618
- } else {
1619
- // should use either current or next shuffling of head state
1620
- // it's not likely to hit this since these shufflings are cached already
1621
- // so handle just in case
1622
- this.metrics?.gossipAttestation.useHeadBlockState.inc({caller: regenCaller});
1623
- 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;
1624
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
+ );
1674
+ }
1675
+
1625
1676
  // resolve the promise to unblock other calls of the same epoch and dependent root
1626
1677
  this.shufflingCache.processState(state);
1627
1678
  return state.getShufflingAtEpoch(attEpoch);
@@ -1731,7 +1782,7 @@ export class BeaconChain implements IBeaconChain {
1731
1782
  // remove date suffixes in file name, and check duplicate to avoid redundant persistence
1732
1783
  await writeIfNotExist(filepath, bytes);
1733
1784
 
1734
- this.logger.debug("Persisted invalid ssz object", {id: logStr, filepath});
1785
+ this.logger.debug("Persisted SSZ object", {id: logStr, filepath});
1735
1786
  }
1736
1787
 
1737
1788
  private onScrapeMetrics(metrics: Metrics): void {
@@ -1790,7 +1841,8 @@ export class BeaconChain implements IBeaconChain {
1790
1841
  const metrics = this.metrics;
1791
1842
  if (metrics && (slot + 1) % SLOTS_PER_EPOCH === 0) {
1792
1843
  // On the last slot of the epoch
1793
- sleep(this.config.SLOT_DURATION_MS / 2)
1844
+ const fork = this.config.getForkName(slot);
1845
+ sleep(this.config.getSlotComponentDurationMs(fork, HALF_SLOT_BPS))
1794
1846
  .then(() => this.validatorMonitor?.onceEveryEndOfEpoch(this.getHeadState()))
1795
1847
  .catch((e) => {
1796
1848
  if (!isErrorAborted(e)) this.logger.error("Error on validator monitor onceEveryEndOfEpoch", {slot}, e);
@@ -1885,6 +1937,21 @@ export class BeaconChain implements IBeaconChain {
1885
1937
  }
1886
1938
  }
1887
1939
 
1940
+ async updateAttachedValidators(epoch: Epoch, validatorIndices: ValidatorIndex[]): Promise<void> {
1941
+ let hasNewValidators = false;
1942
+ for (const validatorIndex of validatorIndices) {
1943
+ if (this.beaconProposerCache.track(epoch, validatorIndex)) {
1944
+ hasNewValidators = true;
1945
+ }
1946
+ }
1947
+
1948
+ // Only update validator custody if we discovered new validators
1949
+ if (hasNewValidators) {
1950
+ const finalizedCheckpoint = this.forkChoice.getFinalizedCheckpoint();
1951
+ await this.updateValidatorsCustodyRequirement(finalizedCheckpoint);
1952
+ }
1953
+ }
1954
+
1888
1955
  private async updateValidatorsCustodyRequirement(finalizedCheckpoint: CheckpointWithHex): Promise<void> {
1889
1956
  if (this.custodyConfig.targetCustodyGroupCount === this.config.NUMBER_OF_CUSTODY_GROUPS) {
1890
1957
  // Custody requirements can only be increased, we can disable dynamic custody updates
@@ -288,8 +288,11 @@ 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;
295
+ persistExecutionPayloadEnvelope(envelope: gloas.ExecutionPayloadEnvelope): void;
293
296
  persistInvalidStateRoot(
294
297
  preState: IBeaconStateView,
295
298
  postState: IBeaconStateView,
@@ -328,6 +331,7 @@ export type SSZObjectType =
328
331
  | "syncCommittee"
329
332
  | "contributionAndProof";
330
333
 
331
- export type CommonBlockBody = phase0.BeaconBlockBody &
334
+ export type CommonBlockBody = Omit<phase0.BeaconBlockBody, "eth1Data" | "deposits"> &
335
+ Partial<Pick<phase0.BeaconBlockBody, "eth1Data" | "deposits">> &
332
336
  Pick<capella.BeaconBlockBody, "blsToExecutionChanges"> &
333
337
  Pick<altair.BeaconBlockBody, "syncAggregate">;
@@ -30,7 +30,7 @@ import {
30
30
  isStatePostGloas,
31
31
  } from "@lodestar/state-transition";
32
32
  import {Attestation, Epoch, RootHex, Slot, electra, isElectraAttestation, phase0, ssz} from "@lodestar/types";
33
- import {MapDef, assert, toRootHex} from "@lodestar/utils";
33
+ import {Logger, MapDef, assert, toRootHex} from "@lodestar/utils";
34
34
  import {Metrics} from "../../metrics/metrics.js";
35
35
  import {IntersectResult, intersectUint8Arrays} from "../../util/bitArray.js";
36
36
  import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
@@ -58,7 +58,7 @@ export type AttestationsConsolidation = {
58
58
 
59
59
  /**
60
60
  * This function returns not seen participation for a given epoch and slot and committee index.
61
- * Return null if all validators are seen or no info to check.
61
+ * Return an empty set if all validators are seen, or null if the committee cannot be computed (e.g. missing shuffling).
62
62
  */
63
63
  type GetNotSeenValidatorsFn = (epoch: Epoch, slot: Slot, committeeIndex: number) => Set<number> | null;
64
64
 
@@ -140,7 +140,8 @@ export class AggregatedAttestationPool {
140
140
 
141
141
  constructor(
142
142
  private readonly config: BeaconConfig,
143
- private readonly metrics: Metrics | null = null
143
+ private readonly metrics: Metrics | null = null,
144
+ private readonly logger: Logger | null = null
144
145
  ) {
145
146
  metrics?.opPool.aggregatedAttestationPool.attDataPerSlot.addCollect(() => this.onScrapeMetrics(metrics));
146
147
  }
@@ -244,6 +245,7 @@ export class AggregatedAttestationPool {
244
245
  const consolidations = new Map<AttestationsConsolidation, number>();
245
246
  let scannedSlots = 0;
246
247
  let stopReason: ScannedSlotsTerminationReason | null = null;
248
+ const missingShufflingCommitteesByEpoch = new Map<Epoch, number>();
247
249
  slot: for (const slot of slots) {
248
250
  const attestationGroupByIndexByDataHash = this.attestationGroupByIndexByDataHexBySlot.get(slot);
249
251
  // should not happen
@@ -295,7 +297,12 @@ export class AggregatedAttestationPool {
295
297
 
296
298
  for (const [committeeIndex, attestationGroup] of attestationGroupByIndex.entries()) {
297
299
  const notSeenCommitteeMembers = notSeenValidatorsFn(epoch, slot, committeeIndex);
298
- if (notSeenCommitteeMembers === null || notSeenCommitteeMembers.size === 0) {
300
+ if (notSeenCommitteeMembers === null) {
301
+ // skip this committee instead of failing the whole block production, other epochs may still have shuffling
302
+ missingShufflingCommitteesByEpoch.set(epoch, (missingShufflingCommitteesByEpoch.get(epoch) ?? 0) + 1);
303
+ continue;
304
+ }
305
+ if (notSeenCommitteeMembers.size === 0) {
299
306
  this.metrics?.opPool.aggregatedAttestationPool.packedAttestations.seenCommittees.inc();
300
307
  continue;
301
308
  }
@@ -386,6 +393,18 @@ export class AggregatedAttestationPool {
386
393
  scannedSlots++;
387
394
  }
388
395
 
396
+ for (const [epoch, missingCommittees] of missingShufflingCommitteesByEpoch) {
397
+ this.metrics?.opPool.aggregatedAttestationPool.packedAttestations.missingShufflingCommittees.inc(
398
+ missingCommittees
399
+ );
400
+ this.logger?.debug("Missing shuffling when packing attestations, skipped committees", {
401
+ slot: stateSlot,
402
+ epoch,
403
+ decisionRoot: state.getShufflingDecisionRoot(epoch),
404
+ missingCommittees,
405
+ });
406
+ }
407
+
389
408
  this.metrics?.opPool.aggregatedAttestationPool.packedAttestations.totalConsolidations.set(consolidations.size);
390
409
 
391
410
  const sortedConsolidationsByScore = Array.from(consolidations.entries())
@@ -770,13 +789,18 @@ export function getNotSeenValidatorsFn(
770
789
  }
771
790
  const cacheKey = slot + "_" + committeeIndex;
772
791
  let notSeenCommitteeMembers = cachedNotSeenValidators.get(cacheKey);
773
- if (notSeenCommitteeMembers != null) {
774
- // if all validators are seen then return null, we don't need to check for any attestations of same committee again
775
- return notSeenCommitteeMembers.size === 0 ? null : notSeenCommitteeMembers;
792
+ if (notSeenCommitteeMembers !== undefined) {
793
+ return notSeenCommitteeMembers;
776
794
  }
777
795
 
778
796
  const decisionRoot = state.getShufflingDecisionRoot(computeEpochAtSlot(slot));
779
- const committee = shufflingCache.getBeaconCommittee(epoch, decisionRoot, slot, committeeIndex);
797
+ const committee = shufflingCache.getBeaconCommitteeOrNull(epoch, decisionRoot, slot, committeeIndex);
798
+ if (committee === null) {
799
+ // attestations in the pool were validated against a cached shuffling of the previous or current epoch,
800
+ // so a miss is a ShufflingCache bug. Return null so the caller tracks it via metrics/logs without failing
801
+ // block production. Don't fall back to the state's shuffling, that would hide the bug
802
+ return null;
803
+ }
780
804
  notSeenCommitteeMembers = new Set<number>();
781
805
  for (const [i, validatorIndex] of committee.entries()) {
782
806
  // no need to check flagIsTimelySource as if validator is not seen, it's participation status is 0
@@ -786,8 +810,8 @@ export function getNotSeenValidatorsFn(
786
810
  }
787
811
  }
788
812
  cachedNotSeenValidators.set(cacheKey, notSeenCommitteeMembers);
789
- // if all validators are seen then return null, we don't need to check for any attestations of same committee again
790
- return notSeenCommitteeMembers.size === 0 ? null : notSeenCommitteeMembers;
813
+ // an empty set means all validators are seen, we don't need to check for any attestations of same committee again
814
+ return notSeenCommitteeMembers;
791
815
  };
792
816
  }
793
817
 
@@ -1,5 +1,4 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {DbBatch, Id, Repository} from "@lodestar/db";
3
2
  import {
4
3
  BLS_WITHDRAWAL_PREFIX,
5
4
  ForkName,
@@ -42,6 +41,7 @@ import {
42
41
  getAttesterSlashingSignatureDomains,
43
42
  getProposerSlashingSignatureDomain,
44
43
  isValidBlsToExecutionChangeForBlockInclusion,
44
+ persistDiff,
45
45
  } from "./utils.js";
46
46
 
47
47
  type HexRoot = string;
@@ -500,33 +500,3 @@ function isVoluntaryExitSignatureIncludable(stateFork: ForkSeq, voluntaryExitFor
500
500
  function isSlashableAtEpoch(validator: phase0.Validator, epoch: Epoch): boolean {
501
501
  return !validator.slashed && validator.activationEpoch <= epoch && epoch < validator.withdrawableEpoch;
502
502
  }
503
-
504
- /**
505
- * Persist target items `items` in `dbRepo` doing minimum put and delete writes.
506
- * Reads all keys in repository to compute the diff between current persisted data and target data.
507
- */
508
- async function persistDiff<K extends Id, V>(
509
- dbRepo: Repository<K, V>,
510
- items: {key: K; value: V}[],
511
- serializeKey: (key: K) => number | string,
512
- opts: {updateExisting?: boolean} = {}
513
- ): Promise<void> {
514
- const persistedKeys = await dbRepo.keys();
515
- const batch: DbBatch<K, V> = [];
516
-
517
- const persistedKeysSerialized = new Set(persistedKeys.map(serializeKey));
518
- for (const item of items) {
519
- if (opts.updateExisting || !persistedKeysSerialized.has(serializeKey(item.key))) {
520
- batch.push({type: "put", key: item.key, value: item.value});
521
- }
522
- }
523
-
524
- const targetKeysSerialized = new Set(items.map((item) => serializeKey(item.key)));
525
- for (const persistedKey of persistedKeys) {
526
- if (!targetKeysSerialized.has(serializeKey(persistedKey))) {
527
- batch.push({type: "del", key: persistedKey});
528
- }
529
- }
530
-
531
- if (batch.length > 0) await dbRepo.batch(batch);
532
- }
@@ -1,5 +1,7 @@
1
1
  import {RootHex, Slot, ValidatorIndex, gloas} from "@lodestar/types";
2
- import {toRootHex} from "@lodestar/utils";
2
+ import {toHex, toRootHex} from "@lodestar/utils";
3
+ import {IBeaconDb} from "../../db/index.js";
4
+ import {persistDiff} from "./utils.js";
3
5
 
4
6
  /**
5
7
  * Pool of validated `SignedProposerPreferences` indexed by `(slot, dependent_root)`.
@@ -64,4 +66,21 @@ export class ProposerPreferencesPool {
64
66
  if (slot < currentSlot) this.bySlot.delete(slot);
65
67
  }
66
68
  }
69
+
70
+ /** Restore the preferences of upcoming slots, they were validated before they were persisted */
71
+ async fromPersisted(db: IBeaconDb, currentSlot: Slot): Promise<void> {
72
+ for (const signed of await db.proposerPreferences.values()) {
73
+ if (signed.message.proposalSlot >= currentSlot) {
74
+ this.add(signed);
75
+ }
76
+ }
77
+ }
78
+
79
+ async toPersisted(db: IBeaconDb): Promise<void> {
80
+ await persistDiff(
81
+ db.proposerPreferences,
82
+ this.getAll().map((signed) => ({key: db.proposerPreferences.getId(signed), value: signed})),
83
+ toHex
84
+ );
85
+ }
67
86
  }
@@ -1,5 +1,6 @@
1
1
  import {Signature} from "@chainsafe/lodestar-z/blst";
2
2
  import {BeaconConfig} from "@lodestar/config";
3
+ import {DbBatch, Id, Repository} from "@lodestar/db";
3
4
  import {BLS_WITHDRAWAL_PREFIX, DOMAIN_BEACON_ATTESTER, DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
4
5
  import {IBeaconStateView, computeStartSlotAtEpoch} from "@lodestar/state-transition";
5
6
  import {AttesterSlashing, Domain, Slot, capella, phase0} from "@lodestar/types";
@@ -91,3 +92,33 @@ export function isValidBlsToExecutionChangeForBlockInclusion(
91
92
  export function isElectraAggregate(aggregate: AggregateFast): aggregate is AggregateFastElectra {
92
93
  return (aggregate as AggregateFastElectra).committeeBits !== undefined;
93
94
  }
95
+
96
+ /**
97
+ * Persist target items `items` in `dbRepo` doing minimum put and delete writes.
98
+ * Reads all keys in repository to compute the diff between current persisted data and target data.
99
+ */
100
+ export async function persistDiff<K extends Id, V>(
101
+ dbRepo: Repository<K, V>,
102
+ items: {key: K; value: V}[],
103
+ serializeKey: (key: K) => number | string,
104
+ opts: {updateExisting?: boolean} = {}
105
+ ): Promise<void> {
106
+ const persistedKeys = await dbRepo.keys();
107
+ const batch: DbBatch<K, V> = [];
108
+
109
+ const persistedKeysSerialized = new Set(persistedKeys.map(serializeKey));
110
+ for (const item of items) {
111
+ if (opts.updateExisting || !persistedKeysSerialized.has(serializeKey(item.key))) {
112
+ batch.push({type: "put", key: item.key, value: item.value});
113
+ }
114
+ }
115
+
116
+ const targetKeysSerialized = new Set(items.map((item) => serializeKey(item.key)));
117
+ for (const persistedKey of persistedKeys) {
118
+ if (!targetKeysSerialized.has(serializeKey(persistedKey))) {
119
+ batch.push({type: "del", key: persistedKey});
120
+ }
121
+ }
122
+
123
+ if (batch.length > 0) await dbRepo.batch(batch);
124
+ }
@@ -27,8 +27,8 @@ export type IChainOptions = BlockProcessOpts &
27
27
  blsVerifyAllMainThread?: boolean;
28
28
  blsVerifyAllMultiThread?: boolean;
29
29
  blacklistedBlocks?: string[];
30
- // TODO GLOAS: add similar option for execution payload envelopes?
31
30
  persistProducedBlocks?: boolean;
31
+ persistProducedPayloadEnvelopes?: boolean;
32
32
  /** Archive finalized Gloas payload envelopes as headers (bodies reconstructed from the EL on read) */
33
33
  dedupePayloads?: boolean;
34
34
  persistInvalidSszObjects?: boolean;
@@ -22,7 +22,7 @@ import {
22
22
  isStatePostGloas,
23
23
  } from "@lodestar/state-transition";
24
24
  import {Bytes32, Slot, ValidatorIndex} from "@lodestar/types";
25
- import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
25
+ import {Logger, fromHex, isErrorAborted, sleep, toHex} from "@lodestar/utils";
26
26
  import {GENESIS_SLOT} from "../constants/constants.js";
27
27
  import {BuilderStatus} from "../execution/builder/http.js";
28
28
  import {PayloadAttributes} from "../execution/index.js";
@@ -31,7 +31,11 @@ import {ClockEvent} from "../util/clock.js";
31
31
  import {isQueueErrorAborted} from "../util/queue/index.js";
32
32
  import {ForkchoiceCaller} from "./forkChoice/index.js";
33
33
  import {IBeaconChain} from "./interface.js";
34
- import {getPayloadAttributesForSSE, prepareExecutionPayload} from "./produceBlock/produceBlockBody.js";
34
+ import {
35
+ getPayloadAttributesForSSE,
36
+ getPooledProposerPreferences,
37
+ prepareExecutionPayload,
38
+ } from "./produceBlock/produceBlockBody.js";
35
39
  import {RegenCaller} from "./regen/index.js";
36
40
 
37
41
  // TODO GLOAS: re-evaluate this timing
@@ -92,6 +96,7 @@ export class PrepareNextSlotScheduler {
92
96
  const nextEpoch = computeEpochAtSlot(clockSlot) + 1;
93
97
  const isEpochTransition = prepareEpoch === nextEpoch;
94
98
  const fork = this.config.getForkName(prepareSlot);
99
+ const currentFork = this.config.getForkName(clockSlot);
95
100
 
96
101
  // Early return if we are pre-genesis
97
102
  // or we are pre-bellatrix and this is not an epoch transition
@@ -102,7 +107,7 @@ export class PrepareNextSlotScheduler {
102
107
  try {
103
108
  // At PREPARE_NEXT_SLOT_BPS (~67%) of the current slot we prepare payload for the next slot
104
109
  // or precompute epoch transition
105
- await sleep(this.config.getSlotComponentDurationMs(PREPARE_NEXT_SLOT_BPS), this.signal);
110
+ await sleep(this.config.getSlotComponentDurationMs(currentFork, PREPARE_NEXT_SLOT_BPS), this.signal);
106
111
 
107
112
  // calling updateHead() here before we produce a block to reduce reorg possibility
108
113
  const headBlock = this.chain.recomputeForkChoiceHead(ForkchoiceCaller.prepareNextSlot);
@@ -158,7 +163,15 @@ export class PrepareNextSlotScheduler {
158
163
  };
159
164
 
160
165
  const proposerIndex = await getProposerIndex();
161
- feeRecipient = this.chain.beaconProposerCache.get(proposerIndex);
166
+ if (this.chain.beaconProposerCache.has(proposerIndex)) {
167
+ const pooledPreferences = isForkPostGloas(fork)
168
+ ? getPooledProposerPreferences(this.chain, prepareSlot, headRoot)
169
+ : null;
170
+ feeRecipient =
171
+ pooledPreferences !== null
172
+ ? toHex(pooledPreferences.feeRecipient)
173
+ : this.chain.beaconProposerCache.getOrDefault(proposerIndex);
174
+ }
162
175
 
163
176
  // Predict the proposer head of the next slot when either:
164
177
  // - we are proposing the next slot (single-slot proposer-boost-reorg), or
@@ -357,7 +370,7 @@ export class PrepareNextSlotScheduler {
357
370
  // skip when we're the next-slot proposer — don't compete with block-production prep.
358
371
  feeRecipient === undefined
359
372
  ) {
360
- const maxDurationMs = this.config.getSlotComponentDurationMs(BUILDER_PREVERIFY_LIMIT_BPS);
373
+ const maxDurationMs = this.config.getSlotComponentDurationMs(currentFork, BUILDER_PREVERIFY_LIMIT_BPS);
361
374
  const preVerifyTimer = this.metrics?.builderDepositPreVerify.duration.startTimer();
362
375
  const result = headState.preVerifyBuilderDepositsPreGloas(MAX_BUILDER_DEPOSITS_PER_SLOT, maxDurationMs);
363
376
  preVerifyTimer?.();
@@ -411,7 +424,10 @@ export class PrepareNextSlotScheduler {
411
424
  * later in the slot, connecting at PREPARE_NEXT_SLOT_BPS would go cold before bids are requested.
412
425
  */
413
426
  private checkBuilderStatusBeforeSlot(prepareSlot: Slot): void {
414
- const msBeforeSlot = this.config.getSlotComponentDurationMs(BUILDER_STATUS_CHECK_BEFORE_SLOT_BPS);
427
+ const msBeforeSlot = this.config.getSlotComponentDurationMs(
428
+ this.config.getForkName(prepareSlot - 1),
429
+ BUILDER_STATUS_CHECK_BEFORE_SLOT_BPS
430
+ );
415
431
  const msUntilCheck = -this.chain.clock.msFromSlot(prepareSlot) - msBeforeSlot;
416
432
  sleep(Math.max(0, msUntilCheck), this.signal)
417
433
  .then(() => this.chain.builderApiClient.checkStatus())
@@ -1,5 +1,12 @@
1
1
  import {EMPTY_SIGNATURE, IBeaconStateView, StateHashTreeRootSource} from "@lodestar/state-transition";
2
- import {BeaconBlock, BlindedBeaconBlock, Gwei, Root} from "@lodestar/types";
2
+ import {
3
+ BeaconBlock,
4
+ BlindedBeaconBlock,
5
+ Gwei,
6
+ Root,
7
+ SignedBeaconBlock,
8
+ SignedBlindedBeaconBlock,
9
+ } from "@lodestar/types";
3
10
  import {Metrics} from "../../metrics/index.js";
4
11
 
5
12
  /**
@@ -13,7 +20,7 @@ export function computeNewStateRoot(
13
20
  block: BeaconBlock | BlindedBeaconBlock
14
21
  ): {newStateRoot: Root; proposerReward: Gwei; postState: IBeaconStateView} {
15
22
  // Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
16
- const signedBlock = {message: block, signature: EMPTY_SIGNATURE};
23
+ const signedBlock = {message: block, signature: EMPTY_SIGNATURE} as SignedBeaconBlock | SignedBlindedBeaconBlock;
17
24
  const {newStateRoot, proposerReward, postState, hashTreeRootTime} = state.computeNewStateRoot(
18
25
  {block: signedBlock},
19
26
  {metrics: metrics?.stateTransition}