@lodestar/beacon-node 1.50.0-dev.f0b11f836e → 1.50.0-dev.f23b93e9eb

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 (106) hide show
  1. package/lib/chain/archiveStore/archiveStore.js +1 -1
  2. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  3. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +2 -2
  4. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  5. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +5 -7
  6. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  7. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -1
  8. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  9. package/lib/chain/archiveStore/historicalState/types.d.ts +2 -2
  10. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  11. package/lib/chain/archiveStore/historicalState/worker.js +1 -1
  12. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  13. package/lib/chain/archiveStore/interface.d.ts +1 -1
  14. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  15. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  16. package/lib/chain/blocks/verifyBlock.js +1 -1
  17. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  18. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +2 -1
  19. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  20. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +5 -4
  21. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  22. package/lib/chain/chain.d.ts.map +1 -1
  23. package/lib/chain/chain.js +18 -0
  24. package/lib/chain/chain.js.map +1 -1
  25. package/lib/chain/emitter.d.ts +7 -1
  26. package/lib/chain/emitter.d.ts.map +1 -1
  27. package/lib/chain/emitter.js +5 -0
  28. package/lib/chain/emitter.js.map +1 -1
  29. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  30. package/lib/chain/forkChoice/index.js +2 -0
  31. package/lib/chain/forkChoice/index.js.map +1 -1
  32. package/lib/chain/options.d.ts +1 -1
  33. package/lib/chain/options.d.ts.map +1 -1
  34. package/lib/chain/options.js +1 -1
  35. package/lib/chain/options.js.map +1 -1
  36. package/lib/chain/produceBlock/computeNewStateRoot.js +1 -1
  37. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  38. package/lib/chain/regen/regen.d.ts +2 -0
  39. package/lib/chain/regen/regen.d.ts.map +1 -1
  40. package/lib/chain/regen/regen.js +10 -4
  41. package/lib/chain/regen/regen.js.map +1 -1
  42. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +3 -2
  43. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  44. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +13 -13
  45. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  46. package/lib/chain/validatorMonitor.d.ts +5 -1
  47. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  48. package/lib/chain/validatorMonitor.js +64 -54
  49. package/lib/chain/validatorMonitor.js.map +1 -1
  50. package/lib/execution/engine/disabled.d.ts +0 -2
  51. package/lib/execution/engine/disabled.d.ts.map +1 -1
  52. package/lib/execution/engine/disabled.js +0 -6
  53. package/lib/execution/engine/disabled.js.map +1 -1
  54. package/lib/execution/engine/http.d.ts +1 -3
  55. package/lib/execution/engine/http.d.ts.map +1 -1
  56. package/lib/execution/engine/http.js +2 -17
  57. package/lib/execution/engine/http.js.map +1 -1
  58. package/lib/execution/engine/interface.d.ts +2 -4
  59. package/lib/execution/engine/interface.d.ts.map +1 -1
  60. package/lib/execution/engine/mock.d.ts +0 -2
  61. package/lib/execution/engine/mock.d.ts.map +1 -1
  62. package/lib/execution/engine/mock.js +0 -8
  63. package/lib/execution/engine/mock.js.map +1 -1
  64. package/lib/execution/engine/types.d.ts +0 -8
  65. package/lib/execution/engine/types.d.ts.map +1 -1
  66. package/lib/execution/engine/types.js.map +1 -1
  67. package/lib/metrics/metrics.d.ts +7 -3
  68. package/lib/metrics/metrics.d.ts.map +1 -1
  69. package/lib/metrics/metrics.js +4 -4
  70. package/lib/metrics/metrics.js.map +1 -1
  71. package/lib/node/nodejs.d.ts.map +1 -1
  72. package/lib/node/nodejs.js +25 -3
  73. package/lib/node/nodejs.js.map +1 -1
  74. package/lib/sync/range/batch.d.ts +6 -0
  75. package/lib/sync/range/batch.d.ts.map +1 -1
  76. package/lib/sync/range/batch.js +10 -0
  77. package/lib/sync/range/batch.js.map +1 -1
  78. package/lib/sync/range/chain.d.ts.map +1 -1
  79. package/lib/sync/range/chain.js +3 -1
  80. package/lib/sync/range/chain.js.map +1 -1
  81. package/package.json +16 -16
  82. package/src/chain/archiveStore/archiveStore.ts +1 -1
  83. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +5 -7
  84. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +1 -1
  85. package/src/chain/archiveStore/historicalState/types.ts +2 -2
  86. package/src/chain/archiveStore/historicalState/worker.ts +1 -2
  87. package/src/chain/archiveStore/interface.ts +1 -1
  88. package/src/chain/blocks/verifyBlock.ts +1 -0
  89. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -3
  90. package/src/chain/chain.ts +21 -0
  91. package/src/chain/emitter.ts +7 -1
  92. package/src/chain/forkChoice/index.ts +2 -0
  93. package/src/chain/options.ts +2 -2
  94. package/src/chain/produceBlock/computeNewStateRoot.ts +1 -1
  95. package/src/chain/regen/regen.ts +12 -4
  96. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +20 -13
  97. package/src/chain/validatorMonitor.ts +75 -57
  98. package/src/execution/engine/disabled.ts +0 -8
  99. package/src/execution/engine/http.ts +1 -30
  100. package/src/execution/engine/interface.ts +2 -6
  101. package/src/execution/engine/mock.ts +1 -19
  102. package/src/execution/engine/types.ts +0 -10
  103. package/src/metrics/metrics.ts +21 -6
  104. package/src/node/nodejs.ts +31 -3
  105. package/src/sync/range/batch.ts +11 -0
  106. package/src/sync/range/chain.ts +3 -1
@@ -1,6 +1,12 @@
1
1
  import {setMaxListeners} from "node:events";
2
2
  import {PrivateKey} from "@libp2p/interface";
3
3
  import {Registry} from "prom-client";
4
+ import {
5
+ init as initNativeMetrics,
6
+ registerLocalValidator as registerNativeLocalValidator,
7
+ scrapeMetrics as scrapeNativeMetrics,
8
+ unregisterLocalValidator as unregisterNativeLocalValidator,
9
+ } from "@chainsafe/lodestar-z/metrics";
4
10
  import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
5
11
  import {hasher} from "@chainsafe/persistent-merkle-tree";
6
12
  import {BeaconApiMethods} from "@lodestar/api/beacon/server";
@@ -171,7 +177,13 @@ export class BeaconNode {
171
177
  // monitoring relies on metrics data
172
178
  opts.monitoring.endpoint
173
179
  ) {
174
- metrics = createMetrics(opts.metrics, anchorState.genesisTime, metricsRegistries);
180
+ if (opts.chain.nativeStateTransition) {
181
+ initNativeMetrics();
182
+ }
183
+
184
+ metrics = createMetrics(opts.metrics, anchorState.genesisTime, metricsRegistries, {
185
+ includeStateTransitionMetrics: !opts.chain.nativeStateTransition,
186
+ });
175
187
  initBeaconMetrics(metrics, anchorState);
176
188
  // Since the db is instantiated before this, metrics must be injected manually afterwards
177
189
  db.setMetrics(metrics.db, metrics.flatFileStore);
@@ -185,7 +197,13 @@ export class BeaconNode {
185
197
  config,
186
198
  anchorState.genesisTime,
187
199
  logger.child({module: LoggerModule.vmon}),
188
- opts.validatorMonitor
200
+ opts.validatorMonitor,
201
+ opts.chain.nativeStateTransition
202
+ ? {
203
+ registerLocalValidator: registerNativeLocalValidator,
204
+ unregisterLocalValidator: unregisterNativeLocalValidator,
205
+ }
206
+ : null
189
207
  )
190
208
  : null;
191
209
 
@@ -303,7 +321,17 @@ export class BeaconNode {
303
321
  const metricsServer = opts.metrics.enabled
304
322
  ? await getHttpMetricsServer(opts.metrics, {
305
323
  register: (metrics as Metrics).register,
306
- getOtherMetrics: async () => Promise.all([network.scrapeMetrics(), chain.archiveStore.scrapeMetrics()]),
324
+ getOtherMetrics: async () => {
325
+ const otherMetrics = await Promise.all([network.scrapeMetrics(), chain.archiveStore.scrapeMetrics()]);
326
+ if (opts.chain.nativeStateTransition) {
327
+ try {
328
+ otherMetrics.push(scrapeNativeMetrics());
329
+ } catch (e) {
330
+ logger.warn("Failed to scrape native state-transition metrics", {}, e as Error);
331
+ }
332
+ }
333
+ return otherMetrics;
334
+ },
307
335
  logger: logger.child({module: LoggerModule.metrics}),
308
336
  })
309
337
  : null;
@@ -773,6 +773,7 @@ export class Batch {
773
773
  // remove any downloaded blocks and re-attempt
774
774
  // TODO(fulu): need to remove the bad blocks from the SeenBlockInputCache
775
775
  this.state = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
776
+ this.resetRequests();
776
777
  }
777
778
 
778
779
  private onProcessingError(attempt: FailedAttempt): void {
@@ -784,6 +785,16 @@ export class Batch {
784
785
  // remove any downloaded blocks and re-attempt
785
786
  // TODO(fulu): need to remove the bad blocks from the SeenBlockInputCache
786
787
  this.state = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
788
+ this.resetRequests();
789
+ }
790
+
791
+ /**
792
+ * After a partial download `requests` only cover the data still missing from the downloaded blocks,
793
+ * e.g. a single column. Once those blocks are dropped, request the whole batch again, otherwise
794
+ * every peer fails the retry for lack of blocks to validate the data against.
795
+ */
796
+ private resetRequests(): void {
797
+ this.requests = this.getRequests([]);
787
798
  }
788
799
 
789
800
  /** Helper to construct typed BatchError. Stack traces are correct as the error is thrown above */
@@ -417,8 +417,10 @@ export class SyncChain {
417
417
  this.rateLimitBackoffTimeout = setTimeout(
418
418
  () => {
419
419
  this.rateLimitBackoffTimeout = undefined;
420
- this.triggerBatchDownloader();
420
+ // Must run before the downloader, it drops expired peers without triggering a download. If it ran
421
+ // after, a backoff expiring in between would leave the peer idle with no retry scheduled.
421
422
  this.scheduleRateLimitBackoffRetry();
423
+ this.triggerBatchDownloader();
422
424
  },
423
425
  Math.max(0, retryAt - now)
424
426
  );