@lodestar/beacon-node 1.52.0-dev.a9e15e2b94 → 1.52.0-dev.eea81beb7c

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 (43) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +17 -13
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  5. package/lib/chain/blocks/verifyBlock.js +12 -11
  6. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  7. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  8. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  9. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
  10. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  11. package/lib/chain/bls/utils.js +1 -1
  12. package/lib/chain/bls/utils.js.map +1 -1
  13. package/lib/chain/chain.d.ts.map +1 -1
  14. package/lib/chain/chain.js +12 -6
  15. package/lib/chain/chain.js.map +1 -1
  16. package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
  17. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
  18. package/lib/chain/opPools/inclusionListStore.js +5 -2
  19. package/lib/chain/opPools/inclusionListStore.js.map +1 -1
  20. package/lib/chain/options.js +1 -1
  21. package/lib/chain/options.js.map +1 -1
  22. package/lib/chain/shufflingCache.d.ts +5 -0
  23. package/lib/chain/shufflingCache.d.ts.map +1 -1
  24. package/lib/chain/shufflingCache.js +39 -1
  25. package/lib/chain/shufflingCache.js.map +1 -1
  26. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  27. package/lib/chain/validation/aggregateAndProof.js +13 -2
  28. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  29. package/lib/metrics/metrics/lodestar.d.ts +2 -0
  30. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  31. package/lib/metrics/metrics/lodestar.js +9 -0
  32. package/lib/metrics/metrics/lodestar.js.map +1 -1
  33. package/package.json +16 -16
  34. package/src/api/impl/beacon/blocks/index.ts +22 -19
  35. package/src/chain/blocks/verifyBlock.ts +14 -10
  36. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
  37. package/src/chain/bls/utils.ts +1 -1
  38. package/src/chain/chain.ts +12 -6
  39. package/src/chain/opPools/inclusionListStore.ts +5 -2
  40. package/src/chain/options.ts +1 -1
  41. package/src/chain/shufflingCache.ts +40 -1
  42. package/src/chain/validation/aggregateAndProof.ts +19 -5
  43. package/src/metrics/metrics/lodestar.ts +9 -0
@@ -132,7 +132,7 @@ export const defaultChainOptions: IChainOptions = {
132
132
  // - users can prune the persisted checkpoint state files manually to save disc space
133
133
  // - it helps debug easier when network is unfinalized
134
134
  nHistoricalStatesFileDataStore: true,
135
- nativeStateTransition: false,
135
+ nativeStateTransition: true,
136
136
  maxBlockStates: DEFAULT_MAX_BLOCK_STATES,
137
137
  maxCPStateEpochsInMemory: DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY,
138
138
  maxCPStateEpochsOnDisk: DEFAULT_MAX_CP_STATE_ON_DISK,
@@ -1,4 +1,5 @@
1
- import {ForkSeq, GENESIS_EPOCH} from "@lodestar/params";
1
+ import {computeCommitteePubkeys, releaseCommitteePubkeys} from "@lodestar/native/committee-pubkeys";
2
+ import {ForkSeq, GENESIS_EPOCH, SLOTS_PER_EPOCH} from "@lodestar/params";
2
3
  import {
3
4
  EpochShuffling,
4
5
  IBeaconStateView,
@@ -272,6 +273,40 @@ export class ShufflingCache {
272
273
  // set the shuffling
273
274
  shufflingAtEpoch.set(decisionRoot, {type: CacheItemType.shuffling, shuffling});
274
275
  this.prune();
276
+ if (this.has(shuffling.epoch, decisionRoot)) {
277
+ this.computeCommitteePubkeys(shuffling, decisionRoot);
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Committee pubkeys make attestation signature sets cheaper to verify. Until they resolve, and if computing them
283
+ * fails, sets aggregate the participants instead.
284
+ */
285
+ private computeCommitteePubkeys(shuffling: EpochShuffling, decisionRoot: RootHex): void {
286
+ const timer = this.metrics?.shufflingCache.committeePubkeysComputeTime.startTimer();
287
+ const onError = (e: unknown): void => {
288
+ this.metrics?.shufflingCache.committeePubkeysErrors.inc();
289
+ this.logger?.debug("Error computing committee pubkeys", {epoch: shuffling.epoch, decisionRoot}, e as Error);
290
+ };
291
+
292
+ let promise: Promise<number>;
293
+ try {
294
+ promise = computeCommitteePubkeys(shuffling.shuffling, SLOTS_PER_EPOCH, shuffling.committeesPerSlot);
295
+ } catch (e) {
296
+ onError(e);
297
+ return;
298
+ }
299
+
300
+ promise.then((id) => {
301
+ timer?.();
302
+ const cacheItem = this.itemsByDecisionRootByEpoch.get(shuffling.epoch)?.get(decisionRoot);
303
+ if (cacheItem !== undefined && isShufflingCacheItem(cacheItem) && cacheItem.shuffling === shuffling) {
304
+ shuffling.committeePubkeysId = id;
305
+ } else {
306
+ // Pruned while computing
307
+ releaseCommitteePubkeys(id);
308
+ }
309
+ }, onError);
275
310
  }
276
311
 
277
312
  /**
@@ -294,6 +329,10 @@ export class ShufflingCache {
294
329
  this.metrics?.shufflingCache.cancelledPromises.inc({reason: ShufflingPromiseCancelReason.pruned});
295
330
  } else {
296
331
  prunedShufflings++;
332
+ if (cacheItem.shuffling.committeePubkeysId !== undefined) {
333
+ releaseCommitteePubkeys(cacheItem.shuffling.committeePubkeysId);
334
+ cacheItem.shuffling.committeePubkeysId = undefined;
335
+ }
297
336
  }
298
337
  }
299
338
  this.itemsByDecisionRootByEpoch.delete(epoch);
@@ -1,5 +1,7 @@
1
1
  import {ForkName, ForkSeq} from "@lodestar/params";
2
2
  import {
3
+ ISignatureSet,
4
+ SignatureSetType,
3
5
  computeEpochAtSlot,
4
6
  createAggregateSignatureSetFromComponents,
5
7
  isAggregatorFromCommitteeLength,
@@ -259,11 +261,23 @@ async function validateAggregateAndProof(
259
261
  // [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
260
262
  // [REJECT] The signature of aggregate is valid.
261
263
  const signingRoot = cachedAttData ? cachedAttData.signingRoot : getAttestationDataSigningRoot(chain.config, attData);
262
- const indexedAttestationSignatureSet = createAggregateSignatureSetFromComponents(
263
- indexedAttestation.attestingIndices,
264
- signingRoot,
265
- indexedAttestation.signature
266
- );
264
+ const indexedAttestationSignatureSet: ISignatureSet =
265
+ shuffling.committeePubkeysId === undefined
266
+ ? createAggregateSignatureSetFromComponents(
267
+ indexedAttestation.attestingIndices,
268
+ signingRoot,
269
+ indexedAttestation.signature
270
+ )
271
+ : {
272
+ type: SignatureSetType.committee,
273
+ indices: indexedAttestation.attestingIndices,
274
+ committeePubkeysId: shuffling.committeePubkeysId,
275
+ slot: attSlot,
276
+ committeeIndices: [committeeIndex],
277
+ aggregationBits: aggregate.aggregationBits,
278
+ signingRoot,
279
+ signature: indexedAttestation.signature,
280
+ };
267
281
  const signatureSets = [
268
282
  getSelectionProofSignatureSet(chain.config, attSlot, aggregatorIndex, signedAggregateAndProof),
269
283
  getAggregateAndProofSignatureSet(chain.config, attEpoch, aggregatorIndex, signedAggregateAndProof),
@@ -1784,6 +1784,15 @@ export function createLodestarMetrics(
1784
1784
  help: "Time from promise insertion until promise resolution when shuffling was ready in seconds",
1785
1785
  buckets: [0.5, 1, 1.5, 2],
1786
1786
  }),
1787
+ committeePubkeysComputeTime: register.histogram({
1788
+ name: "lodestar_shuffling_cache_committee_pubkeys_compute_seconds",
1789
+ help: "Time to aggregate the committee pubkeys of a shuffling off the main thread in seconds",
1790
+ buckets: [0.1, 0.25, 0.5, 1, 2, 5],
1791
+ }),
1792
+ committeePubkeysErrors: register.counter({
1793
+ name: "lodestar_shuffling_cache_committee_pubkeys_errors_total",
1794
+ help: "Total number of shufflings whose committee pubkeys could not be computed",
1795
+ }),
1787
1796
  },
1788
1797
 
1789
1798
  seenCache: {