@lodestar/beacon-node 1.35.0-dev.ba92bd8a88 → 1.35.0-dev.be3c5220f4

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 (144) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +8 -2
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/lodestar/index.js +1 -1
  5. package/lib/api/impl/lodestar/index.js.map +1 -1
  6. package/lib/api/impl/validator/index.d.ts.map +1 -1
  7. package/lib/api/impl/validator/index.js +24 -33
  8. package/lib/api/impl/validator/index.js.map +1 -1
  9. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  10. package/lib/chain/blocks/blockInput/blockInput.js +3 -2
  11. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  12. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  13. package/lib/chain/blocks/importBlock.js +7 -6
  14. package/lib/chain/blocks/importBlock.js.map +1 -1
  15. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  16. package/lib/chain/blocks/verifyBlocksDataAvailability.js +8 -1
  17. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  18. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  19. package/lib/chain/blocks/writeBlockInputToDb.js +1 -7
  20. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  21. package/lib/chain/chain.d.ts +1 -1
  22. package/lib/chain/chain.d.ts.map +1 -1
  23. package/lib/chain/chain.js +4 -6
  24. package/lib/chain/chain.js.map +1 -1
  25. package/lib/chain/lightClient/index.d.ts +2 -2
  26. package/lib/chain/lightClient/index.d.ts.map +1 -1
  27. package/lib/chain/lightClient/index.js +2 -0
  28. package/lib/chain/lightClient/index.js.map +1 -1
  29. package/lib/chain/opPools/attestationPool.d.ts +2 -3
  30. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  31. package/lib/chain/opPools/attestationPool.js +3 -5
  32. package/lib/chain/opPools/attestationPool.js.map +1 -1
  33. package/lib/chain/opPools/syncCommitteeMessagePool.d.ts +3 -2
  34. package/lib/chain/opPools/syncCommitteeMessagePool.d.ts.map +1 -1
  35. package/lib/chain/opPools/syncCommitteeMessagePool.js +6 -5
  36. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  37. package/lib/chain/opPools/types.d.ts +1 -1
  38. package/lib/chain/opPools/types.d.ts.map +1 -1
  39. package/lib/chain/opPools/types.js +1 -1
  40. package/lib/chain/opPools/types.js.map +1 -1
  41. package/lib/chain/prepareNextSlot.d.ts +3 -3
  42. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  43. package/lib/chain/prepareNextSlot.js +8 -8
  44. package/lib/chain/prepareNextSlot.js.map +1 -1
  45. package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -4
  46. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  47. package/lib/chain/produceBlock/produceBlockBody.js +13 -4
  48. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  49. package/lib/chain/regen/interface.d.ts +1 -0
  50. package/lib/chain/regen/interface.d.ts.map +1 -1
  51. package/lib/chain/regen/interface.js +1 -0
  52. package/lib/chain/regen/interface.js.map +1 -1
  53. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  54. package/lib/chain/seenCache/seenGossipBlockInput.js +8 -1
  55. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  56. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  57. package/lib/chain/stateCache/persistentCheckpointsCache.js +9 -8
  58. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  59. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  60. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  61. package/lib/chain/validation/lightClientFinalityUpdate.d.ts.map +1 -1
  62. package/lib/chain/validation/lightClientFinalityUpdate.js +4 -3
  63. package/lib/chain/validation/lightClientFinalityUpdate.js.map +1 -1
  64. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts +6 -4
  65. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -1
  66. package/lib/chain/validation/lightClientOptimisticUpdate.js +11 -11
  67. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  68. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  69. package/lib/chain/validatorMonitor.js +21 -15
  70. package/lib/chain/validatorMonitor.js.map +1 -1
  71. package/lib/metrics/metrics/lodestar.d.ts +1 -1
  72. package/lib/metrics/metrics/lodestar.js +3 -3
  73. package/lib/metrics/metrics/lodestar.js.map +1 -1
  74. package/lib/network/gossip/gossipsub.js +1 -1
  75. package/lib/network/gossip/gossipsub.js.map +1 -1
  76. package/lib/network/gossip/scoringParameters.js +4 -4
  77. package/lib/network/gossip/scoringParameters.js.map +1 -1
  78. package/lib/network/network.d.ts +1 -1
  79. package/lib/network/network.d.ts.map +1 -1
  80. package/lib/network/network.js +9 -9
  81. package/lib/network/network.js.map +1 -1
  82. package/lib/network/peers/peerManager.d.ts.map +1 -1
  83. package/lib/network/peers/peerManager.js +2 -1
  84. package/lib/network/peers/peerManager.js.map +1 -1
  85. package/lib/network/processor/gossipHandlers.js +1 -1
  86. package/lib/network/processor/gossipHandlers.js.map +1 -1
  87. package/lib/network/subnets/attnetsService.d.ts.map +1 -1
  88. package/lib/network/subnets/attnetsService.js +1 -1
  89. package/lib/network/subnets/attnetsService.js.map +1 -1
  90. package/lib/node/notifier.js +1 -1
  91. package/lib/node/notifier.js.map +1 -1
  92. package/lib/sync/unknownBlock.d.ts +0 -1
  93. package/lib/sync/unknownBlock.d.ts.map +1 -1
  94. package/lib/sync/unknownBlock.js +7 -6
  95. package/lib/sync/unknownBlock.js.map +1 -1
  96. package/lib/sync/utils/downloadByRange.d.ts +2 -1
  97. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  98. package/lib/sync/utils/downloadByRange.js +8 -3
  99. package/lib/sync/utils/downloadByRange.js.map +1 -1
  100. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  101. package/lib/sync/utils/downloadByRoot.js +2 -1
  102. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  103. package/lib/util/clock.d.ts +8 -3
  104. package/lib/util/clock.d.ts.map +1 -1
  105. package/lib/util/clock.js +8 -5
  106. package/lib/util/clock.js.map +1 -1
  107. package/lib/util/dataColumns.d.ts.map +1 -1
  108. package/lib/util/dataColumns.js +4 -2
  109. package/lib/util/dataColumns.js.map +1 -1
  110. package/package.json +14 -14
  111. package/src/api/impl/beacon/blocks/index.ts +11 -2
  112. package/src/api/impl/lodestar/index.ts +1 -1
  113. package/src/api/impl/validator/index.ts +25 -37
  114. package/src/chain/blocks/blockInput/blockInput.ts +7 -4
  115. package/src/chain/blocks/importBlock.ts +8 -12
  116. package/src/chain/blocks/verifyBlocksDataAvailability.ts +10 -2
  117. package/src/chain/blocks/writeBlockInputToDb.ts +1 -9
  118. package/src/chain/chain.ts +3 -16
  119. package/src/chain/lightClient/index.ts +11 -3
  120. package/src/chain/opPools/attestationPool.ts +2 -3
  121. package/src/chain/opPools/syncCommitteeMessagePool.ts +5 -3
  122. package/src/chain/opPools/types.ts +1 -1
  123. package/src/chain/prepareNextSlot.ts +8 -8
  124. package/src/chain/produceBlock/produceBlockBody.ts +16 -14
  125. package/src/chain/regen/interface.ts +1 -0
  126. package/src/chain/seenCache/seenGossipBlockInput.ts +10 -2
  127. package/src/chain/stateCache/persistentCheckpointsCache.ts +10 -8
  128. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  129. package/src/chain/validation/lightClientFinalityUpdate.ts +4 -3
  130. package/src/chain/validation/lightClientOptimisticUpdate.ts +12 -11
  131. package/src/chain/validatorMonitor.ts +28 -17
  132. package/src/metrics/metrics/lodestar.ts +3 -3
  133. package/src/network/gossip/gossipsub.ts +1 -1
  134. package/src/network/gossip/scoringParameters.ts +4 -4
  135. package/src/network/network.ts +9 -9
  136. package/src/network/peers/peerManager.ts +2 -1
  137. package/src/network/processor/gossipHandlers.ts +1 -1
  138. package/src/network/subnets/attnetsService.ts +3 -6
  139. package/src/node/notifier.ts +1 -1
  140. package/src/sync/unknownBlock.ts +7 -6
  141. package/src/sync/utils/downloadByRange.ts +12 -6
  142. package/src/sync/utils/downloadByRoot.ts +12 -4
  143. package/src/util/clock.ts +14 -6
  144. package/src/util/dataColumns.ts +11 -2
@@ -5,6 +5,7 @@ import {ExecutionStatus} from "@lodestar/fork-choice";
5
5
  import {
6
6
  ForkName,
7
7
  ForkPostBellatrix,
8
+ ForkPreGloas,
8
9
  ForkSeq,
9
10
  GENESIS_SLOT,
10
11
  SLOTS_PER_EPOCH,
@@ -22,6 +23,7 @@ import {
22
23
  calculateCommitteeAssignments,
23
24
  computeEpochAtSlot,
24
25
  computeStartSlotAtEpoch,
26
+ computeTimeAtSlot,
25
27
  createCachedBeaconState,
26
28
  getBlockRootAtSlot,
27
29
  getCurrentSlot,
@@ -66,7 +68,7 @@ import {
66
68
  SyncCommitteeErrorCode,
67
69
  } from "../../../chain/errors/index.js";
68
70
  import {ChainEvent, CheckpointHex, CommonBlockBody} from "../../../chain/index.js";
69
- import {SCHEDULER_LOOKAHEAD_FACTOR} from "../../../chain/prepareNextSlot.js";
71
+ import {PREPARE_NEXT_SLOT_BPS} from "../../../chain/prepareNextSlot.js";
70
72
  import {BlockType, ProduceFullDeneb} from "../../../chain/produceBlock/index.js";
71
73
  import {RegenCaller} from "../../../chain/regen/index.js";
72
74
  import {validateApiAggregateAndProof} from "../../../chain/validation/index.js";
@@ -82,7 +84,7 @@ import {getDefaultGraffiti, toGraffitiBytes} from "../../../util/graffiti.js";
82
84
  import {getLodestarClientVersion} from "../../../util/metadata.js";
83
85
  import {ApiOptions} from "../../options.js";
84
86
  import {getStateResponseWithRegen} from "../beacon/state/utils.js";
85
- import {ApiError, NodeIsSyncing, OnlySupportedByDVT} from "../errors.js";
87
+ import {ApiError, FailureList, IndexedError, NodeIsSyncing, OnlySupportedByDVT} from "../errors.js";
86
88
  import {ApiModules} from "../types.js";
87
89
  import {computeSubnetForCommitteesAtSlot, getPubkeysForIndices, selectBlockProductionSource} from "./utils.js";
88
90
 
@@ -108,6 +110,8 @@ export const SYNC_TOLERANCE_EPOCHS = 1;
108
110
  * Empirically the builder block resolves in ~1 second, and execution block resolves in <500 ms.
109
111
  * A cutoff of 2 seconds gives enough time and if there are unexpected delays it ensures we publish
110
112
  * in time as proposals post 4 seconds into the slot will likely be orphaned due to proposer boost reorg.
113
+ *
114
+ * TODO GLOAS: re-evaluate cutoff timing
111
115
  */
112
116
  const BLOCK_PRODUCTION_RACE_CUTOFF_MS = 2_000;
113
117
  /** Overall timeout for execution and block production apis */
@@ -178,7 +182,7 @@ export function getValidatorApi(
178
182
  * This value is the same to MAXIMUM_GOSSIP_CLOCK_DISPARITY_SEC.
179
183
  * For very fast networks, reduce clock disparity to half a slot.
180
184
  */
181
- const MAX_API_CLOCK_DISPARITY_SEC = Math.min(0.5, config.SECONDS_PER_SLOT / 2);
185
+ const MAX_API_CLOCK_DISPARITY_SEC = Math.min(0.5, config.SLOT_DURATION_MS / 2000);
182
186
  const MAX_API_CLOCK_DISPARITY_MS = MAX_API_CLOCK_DISPARITY_SEC * 1000;
183
187
 
184
188
  /** Compute and cache the genesis block root */
@@ -211,7 +215,7 @@ export function getValidatorApi(
211
215
  return;
212
216
  }
213
217
 
214
- const slotStartSec = chain.genesisTime + slot * config.SECONDS_PER_SLOT;
218
+ const slotStartSec = computeTimeAtSlot(config, slot, chain.genesisTime);
215
219
  const msToSlot = slotStartSec * 1000 - Date.now();
216
220
 
217
221
  if (msToSlot > MAX_API_CLOCK_DISPARITY_MS) {
@@ -242,7 +246,7 @@ export function getValidatorApi(
242
246
  */
243
247
  function msToNextEpoch(): number {
244
248
  const nextEpoch = chain.clock.currentEpoch + 1;
245
- const secPerEpoch = SLOTS_PER_EPOCH * config.SECONDS_PER_SLOT;
249
+ const secPerEpoch = (SLOTS_PER_EPOCH * config.SLOT_DURATION_MS) / 1000;
246
250
  const nextEpochStartSec = chain.genesisTime + nextEpoch * secPerEpoch;
247
251
  return nextEpochStartSec * 1000 - Date.now();
248
252
  }
@@ -407,11 +411,9 @@ export function getValidatorApi(
407
411
  {
408
412
  commonBlockBodyPromise,
409
413
  parentBlockRoot,
410
- parentSlot,
411
414
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
412
415
  commonBlockBodyPromise: Promise<CommonBlockBody>;
413
416
  parentBlockRoot: Root;
414
- parentSlot: Slot;
415
417
  }
416
418
  ): Promise<ProduceBlindedBlockRes> {
417
419
  const version = config.getForkName(slot);
@@ -443,7 +445,6 @@ export function getValidatorApi(
443
445
  const {block, executionPayloadValue, consensusBlockValue} = await chain.produceBlindedBlock({
444
446
  slot,
445
447
  parentBlockRoot,
446
- parentSlot,
447
448
  randaoReveal,
448
449
  graffiti,
449
450
  commonBlockBodyPromise,
@@ -479,11 +480,9 @@ export function getValidatorApi(
479
480
  strictFeeRecipientCheck,
480
481
  commonBlockBodyPromise,
481
482
  parentBlockRoot,
482
- parentSlot,
483
483
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
484
484
  commonBlockBodyPromise: Promise<CommonBlockBody>;
485
485
  parentBlockRoot: Root;
486
- parentSlot: Slot;
487
486
  }
488
487
  ): Promise<ProduceBlockContentsRes & {shouldOverrideBuilder?: boolean}> {
489
488
  const source = ProducedBlockSource.engine;
@@ -495,7 +494,6 @@ export function getValidatorApi(
495
494
  const {block, executionPayloadValue, consensusBlockValue, shouldOverrideBuilder} = await chain.produceBlock({
496
495
  slot,
497
496
  parentBlockRoot,
498
- parentSlot,
499
497
  randaoReveal,
500
498
  graffiti,
501
499
  feeRecipient,
@@ -638,7 +636,6 @@ export function getValidatorApi(
638
636
  strictFeeRecipientCheck: false,
639
637
  commonBlockBodyPromise,
640
638
  parentBlockRoot,
641
- parentSlot,
642
639
  })
643
640
  : Promise.reject(new Error("Builder disabled"));
644
641
 
@@ -648,7 +645,6 @@ export function getValidatorApi(
648
645
  strictFeeRecipientCheck,
649
646
  commonBlockBodyPromise,
650
647
  parentBlockRoot,
651
- parentSlot,
652
648
  }).then((engineBlock) => {
653
649
  // Once the engine returns a block, in the event of either:
654
650
  // - suspected builder censorship
@@ -666,7 +662,7 @@ export function getValidatorApi(
666
662
  : Promise.reject(new Error("Engine disabled"));
667
663
 
668
664
  // Calculate cutoff time based on start of the slot
669
- const cutoffMs = Math.max(0, BLOCK_PRODUCTION_RACE_CUTOFF_MS - Math.round(chain.clock.secFromSlot(slot) * 1000));
665
+ const cutoffMs = Math.max(0, BLOCK_PRODUCTION_RACE_CUTOFF_MS - chain.clock.msFromSlot(slot));
670
666
 
671
667
  logger.verbose("Block production race (builder vs execution) starting", {
672
668
  ...loggerContext,
@@ -691,7 +687,6 @@ export function getValidatorApi(
691
687
  .produceCommonBlockBody({
692
688
  slot,
693
689
  parentBlockRoot,
694
- parentSlot,
695
690
  randaoReveal,
696
691
  graffiti: graffitiBytes,
697
692
  })
@@ -884,13 +879,14 @@ export function getValidatorApi(
884
879
  opts
885
880
  );
886
881
 
887
- if (opts.blindedLocal === true && ForkSeq[meta.version] >= ForkSeq.bellatrix) {
882
+ const fork = ForkSeq[meta.version];
883
+ if (opts.blindedLocal === true && fork >= ForkSeq.bellatrix && fork < ForkSeq.gloas) {
888
884
  if (meta.executionPayloadBlinded) {
889
885
  return {data, meta};
890
886
  }
891
887
 
892
888
  const {block} = data as BlockContents;
893
- const blindedBlock = beaconBlockToBlinded(config, block as BeaconBlock<ForkPostBellatrix>);
889
+ const blindedBlock = beaconBlockToBlinded(config, block as BeaconBlock<ForkPostBellatrix & ForkPreGloas>);
894
890
  return {
895
891
  data: blindedBlock,
896
892
  meta: {...meta, executionPayloadBlinded: true},
@@ -1016,8 +1012,8 @@ export function getValidatorApi(
1016
1012
  const head = chain.forkChoice.getHead();
1017
1013
  let state: CachedBeaconStateAllForks | undefined = undefined;
1018
1014
  const startSlot = computeStartSlotAtEpoch(epoch);
1019
- const slotMs = config.SECONDS_PER_SLOT * 1000;
1020
- const prepareNextSlotLookAheadMs = slotMs / SCHEDULER_LOOKAHEAD_FACTOR;
1015
+ const prepareNextSlotLookAheadMs =
1016
+ config.SLOT_DURATION_MS - config.getSlotComponentDurationMs(PREPARE_NEXT_SLOT_BPS);
1021
1017
  const toNextEpochMs = msToNextEpoch();
1022
1018
  // validators may request next epoch's duties when it's close to next epoch
1023
1019
  // this is to avoid missed block proposal due to 0 epoch look ahead
@@ -1290,7 +1286,7 @@ export function getValidatorApi(
1290
1286
  notWhileSyncing();
1291
1287
 
1292
1288
  const seenTimestampSec = Date.now() / 1000;
1293
- const errors: Error[] = [];
1289
+ const failures: FailureList = [];
1294
1290
  const fork = chain.config.getForkName(chain.clock.currentSlot);
1295
1291
 
1296
1292
  await Promise.all(
@@ -1326,8 +1322,8 @@ export function getValidatorApi(
1326
1322
  return; // Ok to submit the same aggregate twice
1327
1323
  }
1328
1324
 
1329
- errors.push(e as Error);
1330
- logger.error(`Error on publishAggregateAndProofs [${i}]`, logCtx, e as Error);
1325
+ failures.push({index: i, message: (e as Error).message});
1326
+ logger.verbose(`Error on publishAggregateAndProofs [${i}]`, logCtx, e as Error);
1331
1327
  if (e instanceof AttestationError && e.action === GossipAction.REJECT) {
1332
1328
  chain.persistInvalidSszValue(ssz.phase0.SignedAggregateAndProof, signedAggregateAndProof, "api_reject");
1333
1329
  }
@@ -1335,12 +1331,8 @@ export function getValidatorApi(
1335
1331
  })
1336
1332
  );
1337
1333
 
1338
- if (errors.length > 1) {
1339
- throw Error("Multiple errors on publishAggregateAndProofs\n" + errors.map((e) => e.message).join("\n"));
1340
- }
1341
-
1342
- if (errors.length === 1) {
1343
- throw errors[0];
1334
+ if (failures.length > 0) {
1335
+ throw new IndexedError("Error processing aggregate and proofs", failures);
1344
1336
  }
1345
1337
  },
1346
1338
 
@@ -1354,7 +1346,7 @@ export function getValidatorApi(
1354
1346
  async publishContributionAndProofs({contributionAndProofs}) {
1355
1347
  notWhileSyncing();
1356
1348
 
1357
- const errors: Error[] = [];
1349
+ const failures: FailureList = [];
1358
1350
 
1359
1351
  await Promise.all(
1360
1352
  contributionAndProofs.map(async (contributionAndProof, i) => {
@@ -1386,8 +1378,8 @@ export function getValidatorApi(
1386
1378
  return; // Ok to submit the same aggregate twice
1387
1379
  }
1388
1380
 
1389
- errors.push(e as Error);
1390
- logger.error(`Error on publishContributionAndProofs [${i}]`, logCtx, e as Error);
1381
+ failures.push({index: i, message: (e as Error).message});
1382
+ logger.verbose(`Error on publishContributionAndProofs [${i}]`, logCtx, e as Error);
1391
1383
  if (e instanceof SyncCommitteeError && e.action === GossipAction.REJECT) {
1392
1384
  chain.persistInvalidSszValue(ssz.altair.SignedContributionAndProof, contributionAndProof, "api_reject");
1393
1385
  }
@@ -1395,12 +1387,8 @@ export function getValidatorApi(
1395
1387
  })
1396
1388
  );
1397
1389
 
1398
- if (errors.length > 1) {
1399
- throw Error("Multiple errors on publishContributionAndProofs\n" + errors.map((e) => e.message).join("\n"));
1400
- }
1401
-
1402
- if (errors.length === 1) {
1403
- throw errors[0];
1390
+ if (failures.length > 0) {
1391
+ throw new IndexedError("Error processing contribution and proofs", failures);
1404
1392
  }
1405
1393
  },
1406
1394
 
@@ -1,5 +1,5 @@
1
- import {ForkName, ForkPreDeneb} from "@lodestar/params";
2
- import {BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
1
+ import {ForkName, ForkPostFulu, ForkPreDeneb, ForkPreGloas} from "@lodestar/params";
2
+ import {BeaconBlockBody, BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
3
3
  import {fromHex, prettyBytes, toRootHex, withTimeout} from "@lodestar/utils";
4
4
  import {VersionedHashes} from "../../../execution/index.js";
5
5
  import {kzgCommitmentToVersionedHash} from "../../../util/blobs.js";
@@ -652,7 +652,8 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
652
652
  static createFromColumn(
653
653
  props: AddColumn & CreateBlockInputMeta & {sampledColumns: ColumnIndex[]; custodyColumns: ColumnIndex[]}
654
654
  ): BlockInputColumns {
655
- const hasAllData = props.sampledColumns.length === 0;
655
+ const hasAllData =
656
+ props.daOutOfRange || props.columnSidecar.kzgCommitments.length === 0 || props.sampledColumns.length === 0;
656
657
  const state: BlockInputColumnsState = {
657
658
  hasBlock: false,
658
659
  hasAllData,
@@ -714,7 +715,9 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
714
715
  );
715
716
  }
716
717
 
717
- const hasAllData = props.block.message.body.blobKzgCommitments.length === 0 || this.state.hasAllData;
718
+ const hasAllData =
719
+ (props.block.message.body as BeaconBlockBody<ForkPostFulu & ForkPreGloas>).blobKzgCommitments.length === 0 ||
720
+ this.state.hasAllData;
718
721
 
719
722
  this.state = {
720
723
  ...this.state,
@@ -7,20 +7,14 @@ import {
7
7
  ForkChoiceErrorCode,
8
8
  NotReorgedReason,
9
9
  } from "@lodestar/fork-choice";
10
- import {
11
- ForkPostAltair,
12
- ForkPostElectra,
13
- ForkSeq,
14
- INTERVALS_PER_SLOT,
15
- MAX_SEED_LOOKAHEAD,
16
- SLOTS_PER_EPOCH,
17
- } from "@lodestar/params";
10
+ import {ForkPostAltair, ForkPostElectra, ForkSeq, MAX_SEED_LOOKAHEAD, SLOTS_PER_EPOCH} from "@lodestar/params";
18
11
  import {
19
12
  CachedBeaconStateAltair,
20
13
  EpochCache,
21
14
  RootCache,
22
15
  computeEpochAtSlot,
23
16
  computeStartSlotAtEpoch,
17
+ computeTimeAtSlot,
24
18
  isExecutionStateType,
25
19
  isStartSlotOfEpoch,
26
20
  isStateValidatorsNodesPopulated,
@@ -85,7 +79,8 @@ export async function importBlock(
85
79
  const currentEpoch = computeEpochAtSlot(currentSlot);
86
80
  const blockEpoch = computeEpochAtSlot(blockSlot);
87
81
  const prevFinalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
88
- const blockDelaySec = (fullyVerifiedBlock.seenTimestampSec - postState.genesisTime) % this.config.SECONDS_PER_SLOT;
82
+ const blockDelaySec =
83
+ fullyVerifiedBlock.seenTimestampSec - computeTimeAtSlot(this.config, blockSlot, postState.genesisTime);
89
84
  const recvToValLatency = Date.now() / 1000 - (opts.seenTimestampSec ?? Date.now() / 1000);
90
85
  const fork = this.config.getForkSeq(blockSlot);
91
86
 
@@ -265,10 +260,11 @@ export async function importBlock(
265
260
  this.metrics.headSlot.set(newHead.slot);
266
261
  // Only track "recent" blocks. Otherwise sync can distort this metrics heavily.
267
262
  // We want to track recent blocks coming from gossip, unknown block sync, and API.
268
- if (delaySec < SLOTS_PER_EPOCH * this.config.SECONDS_PER_SLOT) {
263
+ if (delaySec < (SLOTS_PER_EPOCH * this.config.SLOT_DURATION_MS) / 1000) {
269
264
  this.metrics.importBlock.elapsedTimeTillBecomeHead.observe(delaySec);
270
- if (delaySec > this.config.SECONDS_PER_SLOT / INTERVALS_PER_SLOT) {
271
- this.metrics.importBlock.setHeadAfterFirstInterval.inc();
265
+ const cutOffSec = this.config.getAttestationDueMs(this.config.getForkName(blockSlot)) / 1000;
266
+ if (delaySec > cutOffSec) {
267
+ this.metrics.importBlock.setHeadAfterCutoff.inc();
272
268
  }
273
269
  }
274
270
  }
@@ -1,5 +1,5 @@
1
1
  import {DataAvailabilityStatus} from "@lodestar/state-transition";
2
- import {DAType, IBlockInput} from "./blockInput/index.js";
2
+ import {DAData, DAType, IBlockInput} from "./blockInput/index.js";
3
3
 
4
4
  // we can now wait for full 12 seconds because unavailable block sync will try pulling
5
5
  // the blobs from the network anyway after 500ms of seeing the block
@@ -18,7 +18,15 @@ export async function verifyBlocksDataAvailability(
18
18
  dataAvailabilityStatuses: DataAvailabilityStatus[];
19
19
  availableTime: number;
20
20
  }> {
21
- await Promise.all(blocks.map((blockInput) => blockInput.waitForAllData(BLOB_AVAILABILITY_TIMEOUT, signal)));
21
+ const promises: Promise<DAData>[] = [];
22
+ for (const blockInput of blocks) {
23
+ // block verification is triggered on a verified gossip block so we only need to wait for all data
24
+ if (!blockInput.hasAllData()) {
25
+ promises.push(blockInput.waitForAllData(BLOB_AVAILABILITY_TIMEOUT, signal));
26
+ }
27
+ }
28
+ await Promise.all(promises);
29
+
22
30
  const availableTime = Math.max(0, Math.max(...blocks.map((blockInput) => blockInput.getTimeComplete())));
23
31
  const dataAvailabilityStatuses: DataAvailabilityStatus[] = blocks.map((blockInput) => {
24
32
  if (blockInput.type === DAType.PreData) {
@@ -102,15 +102,7 @@ export async function removeEagerlyPersistedBlockInputs(this: BeaconChain, block
102
102
  if (!this.forkChoice.hasBlockHex(blockRootHex)) {
103
103
  blockToRemove.push(block);
104
104
 
105
- if (isBlockInputColumns(blockInput)) {
106
- const {custodyColumns} = this.custodyConfig;
107
- const dataColumnsLen = custodyColumns.length;
108
- const dataColumnSidecars = blockInput.getCustodyColumns();
109
- if (dataColumnSidecars.length !== dataColumnsLen) {
110
- throw Error(
111
- `Invalid dataColumnSidecars=${dataColumnSidecars.length} for custody expected custodyColumnsLen=${dataColumnsLen}`
112
- );
113
- }
105
+ if (isBlockInputColumns(blockInput) && blockInput.getCustodyColumns().length > 0) {
114
106
  dataColumnsToRemove.push(blockRoot);
115
107
  } else if (isBlockInputBlobs(blockInput)) {
116
108
  const blobSidecars = blockInput.getBlobs();
@@ -254,20 +254,9 @@ export class BeaconChain implements IBeaconChain {
254
254
  if (!clock) clock = new Clock({config, genesisTime: this.genesisTime, signal});
255
255
 
256
256
  this.blacklistedBlocks = new Map((opts.blacklistedBlocks ?? []).map((hex) => [hex, null]));
257
- const preAggregateCutOffTime = (2 / 3) * this.config.SECONDS_PER_SLOT;
258
- this.attestationPool = new AttestationPool(
259
- config,
260
- clock,
261
- preAggregateCutOffTime,
262
- this.opts?.preaggregateSlotDistance,
263
- metrics
264
- );
257
+ this.attestationPool = new AttestationPool(config, clock, this.opts?.preaggregateSlotDistance, metrics);
265
258
  this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics);
266
- this.syncCommitteeMessagePool = new SyncCommitteeMessagePool(
267
- clock,
268
- preAggregateCutOffTime,
269
- this.opts?.preaggregateSlotDistance
270
- );
259
+ this.syncCommitteeMessagePool = new SyncCommitteeMessagePool(config, clock, this.opts?.preaggregateSlotDistance);
271
260
  this.syncContributionAndProofPool = new SyncContributionAndProofPool(clock, metrics, logger);
272
261
 
273
262
  this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
@@ -730,7 +719,6 @@ export class BeaconChain implements IBeaconChain {
730
719
  feeRecipient,
731
720
  commonBlockBodyPromise,
732
721
  parentBlockRoot,
733
- parentSlot,
734
722
  }: BlockAttributes & {commonBlockBodyPromise: Promise<CommonBlockBody>}
735
723
  ): Promise<{
736
724
  block: AssembledBlockType<T>;
@@ -756,7 +744,6 @@ export class BeaconChain implements IBeaconChain {
756
744
  graffiti,
757
745
  slot,
758
746
  feeRecipient,
759
- parentSlot,
760
747
  parentBlockRoot,
761
748
  proposerIndex,
762
749
  proposerPubKey,
@@ -1150,7 +1137,7 @@ export class BeaconChain implements IBeaconChain {
1150
1137
  const metrics = this.metrics;
1151
1138
  if (metrics && (slot + 1) % SLOTS_PER_EPOCH === 0) {
1152
1139
  // On the last slot of the epoch
1153
- sleep((1000 * this.config.SECONDS_PER_SLOT) / 2)
1140
+ sleep(this.config.SLOT_DURATION_MS / 2)
1154
1141
  .then(() => this.validatorMonitor?.onceEveryEndOfEpoch(this.getHeadState()))
1155
1142
  .catch((e) => {
1156
1143
  if (!isErrorAborted(e)) this.logger.error("Error on validator monitor onceEveryEndOfEpoch", {slot}, e);
@@ -11,6 +11,7 @@ import {
11
11
  ForkName,
12
12
  ForkPostAltair,
13
13
  ForkPostBellatrix,
14
+ ForkPreGloas,
14
15
  ForkSeq,
15
16
  MIN_SYNC_COMMITTEE_PARTICIPANTS,
16
17
  SYNC_COMMITTEE_SIZE,
@@ -741,17 +742,24 @@ export function sumBits(bits: BitArray): number {
741
742
  return bits.getTrueBitIndexes().length;
742
743
  }
743
744
 
744
- export function blockToLightClientHeader(fork: ForkName, block: BeaconBlock<ForkPostAltair>): LightClientHeader {
745
+ // TODO GLOAS: Pending light-client spec but this function probably won't be used
746
+ // in Gloas. So we can assume any types here are pre-gloas
747
+ export function blockToLightClientHeader(
748
+ fork: ForkName,
749
+ block: BeaconBlock<ForkPostAltair & ForkPreGloas>
750
+ ): LightClientHeader {
745
751
  const blockSlot = block.slot;
746
752
  const beacon: phase0.BeaconBlockHeader = {
747
753
  slot: blockSlot,
748
754
  proposerIndex: block.proposerIndex,
749
755
  parentRoot: block.parentRoot,
750
756
  stateRoot: block.stateRoot,
751
- bodyRoot: (ssz[fork].BeaconBlockBody as SSZTypesFor<ForkPostAltair, "BeaconBlockBody">).hashTreeRoot(block.body),
757
+ bodyRoot: (ssz[fork].BeaconBlockBody as SSZTypesFor<ForkPostAltair & ForkPreGloas, "BeaconBlockBody">).hashTreeRoot(
758
+ block.body
759
+ ),
752
760
  };
753
761
  if (ForkSeq[fork] >= ForkSeq.capella) {
754
- const blockBody = block.body as BeaconBlockBody<ForkPostBellatrix>;
762
+ const blockBody = block.body as BeaconBlockBody<ForkPostBellatrix & ForkPreGloas>;
755
763
  const execution = executionPayloadToPayloadHeader(ForkSeq[fork], blockBody.executionPayload);
756
764
  return {
757
765
  beacon,
@@ -74,7 +74,6 @@ export class AttestationPool {
74
74
  constructor(
75
75
  private readonly config: ChainForkConfig,
76
76
  private readonly clock: IClock,
77
- private readonly cutOffSecFromSlot: number,
78
77
  private readonly preaggregateSlotDistance = 0,
79
78
  private readonly metrics: Metrics | null = null
80
79
  ) {}
@@ -98,7 +97,7 @@ export class AttestationPool {
98
97
  * `SignedAggregateAndProof`.
99
98
  *
100
99
  * If the attestation is too old (low slot) to be included in the pool it is simply dropped
101
- * and no error is returned. Also if it's at clock slot but come to the pool later than 2/3
100
+ * and no error is returned. Also if it's at clock slot but come to the pool later than AGGREGATE_DUE_BPS
102
101
  * of slot time, it's dropped too since it's not helpful for the validator anymore
103
102
  *
104
103
  * Expects the attestation to be fully validated:
@@ -126,7 +125,7 @@ export class AttestationPool {
126
125
 
127
126
  // Reject gossip attestations in the current slot but come to this pool very late
128
127
  // for api attestations, we allow them to be added to the pool
129
- if (!priority && this.clock.secFromSlot(slot) > this.cutOffSecFromSlot) {
128
+ if (!priority && this.clock.msFromSlot(slot) > this.config.getAggregateDueMs(fork)) {
130
129
  return InsertOutcome.Late;
131
130
  }
132
131
 
@@ -1,5 +1,6 @@
1
1
  import {Signature, aggregateSignatures} from "@chainsafe/blst";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
+ import {ChainForkConfig} from "@lodestar/config";
3
4
  import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
4
5
  import {Root, Slot, SubcommitteeIndex, SubnetID, altair} from "@lodestar/types";
5
6
  import {MapDef, toRootHex} from "@lodestar/utils";
@@ -44,8 +45,8 @@ export class SyncCommitteeMessagePool {
44
45
  private lowestPermissibleSlot = 0;
45
46
 
46
47
  constructor(
48
+ private readonly config: ChainForkConfig,
47
49
  private readonly clock: IClock,
48
- private readonly cutOffSecFromSlot: number,
49
50
  private readonly preaggregateSlotDistance = 0
50
51
  ) {}
51
52
 
@@ -68,6 +69,7 @@ export class SyncCommitteeMessagePool {
68
69
  priority?: boolean
69
70
  ): InsertOutcome {
70
71
  const {slot, beaconBlockRoot} = signature;
72
+ const fork = this.config.getForkName(slot);
71
73
  const rootHex = toRootHex(beaconBlockRoot);
72
74
  const lowestPermissibleSlot = this.lowestPermissibleSlot;
73
75
 
@@ -76,8 +78,8 @@ export class SyncCommitteeMessagePool {
76
78
  return InsertOutcome.Old;
77
79
  }
78
80
 
79
- // validator gets SyncCommitteeContribution at 2/3 of slot, it's no use to preaggregate later than that time
80
- if (!priority && this.clock.secFromSlot(slot) > this.cutOffSecFromSlot) {
81
+ // validator gets SyncCommitteeContribution at CONTRIBUTION_DUE_BPS of slot, it's no use to preaggregate later than that time
82
+ if (!priority && this.clock.msFromSlot(slot) > this.config.getSyncContributionDueMs(fork)) {
81
83
  return InsertOutcome.Late;
82
84
  }
83
85
 
@@ -13,7 +13,7 @@ export enum InsertOutcome {
13
13
  Old = "Old",
14
14
  /** The pool has reached its limit. No changes were made. */
15
15
  ReachLimit = "ReachLimit",
16
- /** Messages don't bring any value, for example attestations come to the pool at > 2/3 of slot. No changes were made */
16
+ /** Messages don't bring any value, for example attestations come to the pool at > AGGREGATE_DUE_BPS of slot. No changes were made */
17
17
  Late = "Late",
18
18
  /** The data is know, and the new participants have been added to the aggregated signature */
19
19
  Aggregated = "Aggregated",
@@ -22,17 +22,18 @@ import {IBeaconChain} from "./interface.js";
22
22
  import {getPayloadAttributesForSSE, prepareExecutionPayload} from "./produceBlock/produceBlockBody.js";
23
23
  import {RegenCaller} from "./regen/index.js";
24
24
 
25
- /* With 12s slot times, this scheduler will run 4s before the start of each slot (`12 / 3 = 4`). */
26
- export const SCHEDULER_LOOKAHEAD_FACTOR = 3;
25
+ // TODO GLOAS: re-evaluate this timing
26
+ /* With 12s slot times, this scheduler will run 4s before the start of each slot (`12 - 0.6667 * 12 = 4`). */
27
+ export const PREPARE_NEXT_SLOT_BPS = 6667;
27
28
 
28
29
  /* We don't want to do more epoch transition than this */
29
30
  const PREPARE_EPOCH_LIMIT = 1;
30
31
 
31
32
  /**
32
33
  * At Bellatrix, if we are responsible for proposing in next slot, we want to prepare payload
33
- * 4s (1/3 slot) before the start of next slot
34
+ * 4s before the start of next slot at PREPARE_NEXT_SLOT_BPS of the current slot.
34
35
  *
35
- * For all forks, when clock is 1/3 slot before an epoch, we want to prepare for the next epoch
36
+ * For all forks, when clock reaches PREPARE_NEXT_SLOT_BPS of slot before an epoch, we want to prepare for the next epoch
36
37
  * transition from our head so that:
37
38
  * + validators vote for block head on time through attestation
38
39
  * + validators propose blocks on time
@@ -74,10 +75,9 @@ export class PrepareNextSlotScheduler {
74
75
  }
75
76
 
76
77
  try {
77
- // At 1/3 slot time before the next slot, we either prepare payload or precompute
78
- // epoch transition
79
- const slotMs = this.config.SECONDS_PER_SLOT * 1000;
80
- await sleep(slotMs - slotMs / SCHEDULER_LOOKAHEAD_FACTOR, this.signal);
78
+ // At PREPARE_NEXT_SLOT_BPS (~67%) of the current slot we prepare payload for the next slot
79
+ // or precompute epoch transition
80
+ await sleep(this.config.getSlotComponentDurationMs(PREPARE_NEXT_SLOT_BPS), this.signal);
81
81
 
82
82
  // calling updateHead() here before we produce a block to reduce reorg possibility
83
83
  const {slot: headSlot, blockRoot: headRoot} = this.chain.recomputeForkChoiceHead(
@@ -4,9 +4,11 @@ import {
4
4
  ForkPostBellatrix,
5
5
  ForkPostDeneb,
6
6
  ForkPostFulu,
7
+ ForkPreGloas,
7
8
  ForkSeq,
8
9
  isForkPostAltair,
9
10
  isForkPostBellatrix,
11
+ isForkPostGloas,
10
12
  } from "@lodestar/params";
11
13
  import {
12
14
  CachedBeaconStateAllForks,
@@ -90,7 +92,6 @@ export type BlockAttributes = {
90
92
  graffiti: Bytes32;
91
93
  slot: Slot;
92
94
  parentBlockRoot: Root;
93
- parentSlot: Slot;
94
95
  feeRecipient?: string;
95
96
  };
96
97
 
@@ -182,7 +183,14 @@ export async function produceBlockBody<T extends BlockType>(
182
183
  };
183
184
  this.logger.verbose("Producing beacon block body", logMeta);
184
185
 
185
- if (isForkPostBellatrix(fork)) {
186
+ if (isForkPostGloas(fork)) {
187
+ // TODO GLOAS: Set body.signedExecutionPayloadBid and body.payloadAttestation
188
+ const commonBlockBody = await commonBlockBodyPromise;
189
+ blockBody = Object.assign({}, commonBlockBody) as AssembledBodyType<T>;
190
+ executionPayloadValue = BigInt(0);
191
+
192
+ // We don't deal with blinded blocks, execution engine, blobs and execution requests post-gloas
193
+ } else if (isForkPostBellatrix(fork)) {
186
194
  const safeBlockHash = this.forkChoice.getJustifiedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
187
195
  const finalizedBlockHash = this.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
188
196
  const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
@@ -307,6 +315,7 @@ export async function produceBlockBody<T extends BlockType>(
307
315
 
308
316
  // blockType === BlockType.Full
309
317
  else {
318
+ // enginePromise only supports pre-gloas
310
319
  const enginePromise = (async () => {
311
320
  const endExecutionPayload = this.metrics?.executionBlockProductionTimeSteps.startTimer();
312
321
 
@@ -384,13 +393,13 @@ export async function produceBlockBody<T extends BlockType>(
384
393
  blockBody = Object.assign({}, commonBlockBody) as AssembledBodyType<BlockType.Blinded>;
385
394
 
386
395
  if (engineRes.isPremerge) {
387
- (blockBody as BeaconBlockBody<ForkPostBellatrix>).executionPayload = engineRes.executionPayload;
396
+ (blockBody as BeaconBlockBody<ForkPostBellatrix & ForkPreGloas>).executionPayload = engineRes.executionPayload;
388
397
  executionPayloadValue = engineRes.executionPayloadValue;
389
398
  } else {
390
399
  const {prepType, payloadId, executionPayload, blobsBundle, executionRequests} = engineRes;
391
400
  shouldOverrideBuilder = engineRes.shouldOverrideBuilder;
392
401
 
393
- (blockBody as BeaconBlockBody<ForkPostBellatrix>).executionPayload = executionPayload;
402
+ (blockBody as BeaconBlockBody<ForkPostBellatrix & ForkPreGloas>).executionPayload = executionPayload;
394
403
  (produceResult as ProduceFullBellatrix).executionPayload = executionPayload;
395
404
  executionPayloadValue = engineRes.executionPayloadValue;
396
405
  Object.assign(logMeta, {transactions: executionPayload.transactions.length, shouldOverrideBuilder});
@@ -723,15 +732,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
723
732
  this: BeaconChain,
724
733
  blockType: T,
725
734
  currentState: CachedBeaconStateAllForks,
726
- {
727
- randaoReveal,
728
- graffiti,
729
- slot,
730
- parentSlot,
731
- parentBlockRoot,
732
- }: BlockAttributes & {
733
- parentSlot: Slot;
734
- }
735
+ {randaoReveal, graffiti, slot, parentBlockRoot}: BlockAttributes
735
736
  ): Promise<CommonBlockBody> {
736
737
  const stepsMetrics =
737
738
  blockType === BlockType.Full
@@ -783,7 +784,8 @@ export async function produceCommonBlockBody<T extends BlockType>(
783
784
 
784
785
  const endSyncAggregate = stepsMetrics?.startTimer();
785
786
  if (ForkSeq[fork] >= ForkSeq.altair) {
786
- const syncAggregate = this.syncContributionAndProofPool.getAggregate(parentSlot, parentBlockRoot);
787
+ const previousSlot = slot - 1;
788
+ const syncAggregate = this.syncContributionAndProofPool.getAggregate(previousSlot, parentBlockRoot);
787
789
  this.metrics?.production.producedSyncAggregateParticipants.observe(
788
790
  syncAggregate.syncCommitteeBits.getTrueBitIndexes().length
789
791
  );
@@ -10,6 +10,7 @@ export enum RegenCaller {
10
10
  produceBlock = "produceBlock",
11
11
  validateGossipBlock = "validateGossipBlock",
12
12
  validateGossipBlob = "validateGossipBlob",
13
+ validateGossipDataColumn = "validateGossipDataColumn",
13
14
  precomputeEpoch = "precomputeEpoch",
14
15
  predictProposerHead = "predictProposerHead",
15
16
  produceAttestationData = "produceAttestationData",