@lodestar/beacon-node 1.45.0 → 1.46.0-dev.4191d8e353

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 (198) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +186 -57
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  5. package/lib/api/impl/lodestar/index.js +2 -3
  6. package/lib/api/impl/lodestar/index.js.map +1 -1
  7. package/lib/api/impl/validator/index.d.ts.map +1 -1
  8. package/lib/api/impl/validator/index.js +172 -88
  9. package/lib/api/impl/validator/index.js.map +1 -1
  10. package/lib/api/rest/base.d.ts.map +1 -1
  11. package/lib/api/rest/base.js +6 -3
  12. package/lib/api/rest/base.js.map +1 -1
  13. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  14. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +0 -1
  15. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  16. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  17. package/lib/chain/blocks/importBlock.js +2 -17
  18. package/lib/chain/blocks/importBlock.js.map +1 -1
  19. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  20. package/lib/chain/blocks/utils/chainSegment.js +13 -5
  21. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  22. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +1 -1
  23. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  24. package/lib/chain/blocks/verifyBlocksSanityChecks.js +1 -1
  25. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  26. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +2 -2
  27. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  28. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  29. package/lib/chain/bls/multithread/index.js +0 -1
  30. package/lib/chain/bls/multithread/index.js.map +1 -1
  31. package/lib/chain/chain.d.ts.map +1 -1
  32. package/lib/chain/chain.js +44 -2
  33. package/lib/chain/chain.js.map +1 -1
  34. package/lib/chain/errors/blockError.d.ts +48 -6
  35. package/lib/chain/errors/blockError.d.ts.map +1 -1
  36. package/lib/chain/errors/blockError.js +25 -4
  37. package/lib/chain/errors/blockError.js.map +1 -1
  38. package/lib/chain/errors/executionPayloadEnvelope.d.ts +11 -0
  39. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  40. package/lib/chain/errors/executionPayloadEnvelope.js +2 -0
  41. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  42. package/lib/chain/errors/proposerPreferences.d.ts +14 -1
  43. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
  44. package/lib/chain/errors/proposerPreferences.js +2 -0
  45. package/lib/chain/errors/proposerPreferences.js.map +1 -1
  46. package/lib/chain/lightClient/index.d.ts.map +1 -1
  47. package/lib/chain/lightClient/index.js +11 -6
  48. package/lib/chain/lightClient/index.js.map +1 -1
  49. package/lib/chain/lightClient/proofs.d.ts.map +1 -1
  50. package/lib/chain/lightClient/proofs.js +28 -2
  51. package/lib/chain/lightClient/proofs.js.map +1 -1
  52. package/lib/chain/lightClient/types.d.ts +3 -1
  53. package/lib/chain/lightClient/types.d.ts.map +1 -1
  54. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  55. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  56. package/lib/chain/opPools/proposerPreferencesPool.d.ts +1 -1
  57. package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
  58. package/lib/chain/opPools/proposerPreferencesPool.js +1 -1
  59. package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
  60. package/lib/chain/validation/aggregateAndProof.js +10 -6
  61. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  62. package/lib/chain/validation/attestation.d.ts.map +1 -1
  63. package/lib/chain/validation/attestation.js +10 -6
  64. package/lib/chain/validation/attestation.js.map +1 -1
  65. package/lib/chain/validation/block.d.ts.map +1 -1
  66. package/lib/chain/validation/block.js +53 -4
  67. package/lib/chain/validation/block.js.map +1 -1
  68. package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
  69. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  70. package/lib/chain/validation/executionPayloadBid.js +31 -3
  71. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  72. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  73. package/lib/chain/validation/executionPayloadEnvelope.js +29 -0
  74. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  75. package/lib/chain/validation/proposerPreferences.d.ts +9 -2
  76. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  77. package/lib/chain/validation/proposerPreferences.js +61 -9
  78. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  79. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
  80. package/lib/chain/validation/signatureSets/aggregateAndProof.js +2 -3
  81. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  82. package/lib/db/repositories/lightclientSyncCommitteeWitness.d.ts.map +1 -1
  83. package/lib/db/repositories/lightclientSyncCommitteeWitness.js +42 -7
  84. package/lib/db/repositories/lightclientSyncCommitteeWitness.js.map +1 -1
  85. package/lib/metrics/nodeJsMetrics.js +1 -1
  86. package/lib/metrics/nodeJsMetrics.js.map +1 -1
  87. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  88. package/lib/network/core/networkCoreWorkerHandler.js +2 -7
  89. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  90. package/lib/network/discv5/index.d.ts.map +1 -1
  91. package/lib/network/discv5/index.js +1 -4
  92. package/lib/network/discv5/index.js.map +1 -1
  93. package/lib/network/gossip/encoding.d.ts +2 -2
  94. package/lib/network/gossip/encoding.d.ts.map +1 -1
  95. package/lib/network/gossip/encoding.js +15 -9
  96. package/lib/network/gossip/encoding.js.map +1 -1
  97. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  98. package/lib/network/gossip/gossipsub.js +2 -2
  99. package/lib/network/gossip/gossipsub.js.map +1 -1
  100. package/lib/network/gossip/topic.d.ts +74 -231
  101. package/lib/network/gossip/topic.d.ts.map +1 -1
  102. package/lib/network/gossip/topic.js +24 -1
  103. package/lib/network/gossip/topic.js.map +1 -1
  104. package/lib/network/interface.d.ts +4 -1
  105. package/lib/network/interface.d.ts.map +1 -1
  106. package/lib/network/libp2p/index.d.ts.map +1 -1
  107. package/lib/network/libp2p/index.js +2 -9
  108. package/lib/network/libp2p/index.js.map +1 -1
  109. package/lib/network/network.d.ts +4 -1
  110. package/lib/network/network.d.ts.map +1 -1
  111. package/lib/network/network.js +19 -11
  112. package/lib/network/network.js.map +1 -1
  113. package/lib/network/peers/datastore.d.ts +1 -1
  114. package/lib/network/peers/datastore.d.ts.map +1 -1
  115. package/lib/network/peers/datastore.js +1 -1
  116. package/lib/network/peers/datastore.js.map +1 -1
  117. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  118. package/lib/network/processor/gossipHandlers.js +12 -6
  119. package/lib/network/processor/gossipHandlers.js.map +1 -1
  120. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  121. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +4 -2
  122. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  123. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  124. package/lib/network/reqresp/handlers/index.js +20 -11
  125. package/lib/network/reqresp/handlers/index.js.map +1 -1
  126. package/lib/network/util.d.ts +1 -0
  127. package/lib/network/util.d.ts.map +1 -1
  128. package/lib/network/util.js +4 -0
  129. package/lib/network/util.js.map +1 -1
  130. package/lib/sync/sync.d.ts.map +1 -1
  131. package/lib/sync/sync.js +7 -0
  132. package/lib/sync/sync.js.map +1 -1
  133. package/lib/sync/unknownBlock.d.ts.map +1 -1
  134. package/lib/sync/unknownBlock.js +7 -2
  135. package/lib/sync/unknownBlock.js.map +1 -1
  136. package/lib/util/execution.js +1 -1
  137. package/lib/util/execution.js.map +1 -1
  138. package/lib/util/profile.d.ts +3 -0
  139. package/lib/util/profile.d.ts.map +1 -1
  140. package/lib/util/profile.js +1 -27
  141. package/lib/util/profile.js.map +1 -1
  142. package/package.json +29 -38
  143. package/src/api/impl/beacon/blocks/index.ts +221 -63
  144. package/src/api/impl/lodestar/index.ts +2 -3
  145. package/src/api/impl/validator/index.ts +206 -98
  146. package/src/api/rest/base.ts +8 -3
  147. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +0 -1
  148. package/src/chain/blocks/importBlock.ts +0 -17
  149. package/src/chain/blocks/utils/chainSegment.ts +16 -5
  150. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +1 -1
  151. package/src/chain/blocks/verifyBlocksSanityChecks.ts +1 -1
  152. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +2 -2
  153. package/src/chain/bls/multithread/index.ts +0 -1
  154. package/src/chain/chain.ts +61 -2
  155. package/src/chain/errors/blockError.ts +44 -7
  156. package/src/chain/errors/executionPayloadEnvelope.ts +9 -0
  157. package/src/chain/errors/proposerPreferences.ts +16 -1
  158. package/src/chain/lightClient/index.ts +12 -7
  159. package/src/chain/lightClient/proofs.ts +36 -1
  160. package/src/chain/lightClient/types.ts +3 -1
  161. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  162. package/src/chain/opPools/proposerPreferencesPool.ts +1 -1
  163. package/src/chain/validation/aggregateAndProof.ts +12 -6
  164. package/src/chain/validation/attestation.ts +12 -6
  165. package/src/chain/validation/block.ts +69 -4
  166. package/src/chain/validation/executionPayloadBid.ts +33 -3
  167. package/src/chain/validation/executionPayloadEnvelope.ts +37 -0
  168. package/src/chain/validation/proposerPreferences.ts +71 -9
  169. package/src/chain/validation/signatureSets/aggregateAndProof.ts +3 -3
  170. package/src/db/repositories/lightclientSyncCommitteeWitness.ts +57 -9
  171. package/src/metrics/nodeJsMetrics.ts +1 -1
  172. package/src/network/core/networkCoreWorkerHandler.ts +2 -6
  173. package/src/network/discv5/index.ts +1 -4
  174. package/src/network/gossip/encoding.ts +13 -7
  175. package/src/network/gossip/gossipsub.ts +7 -2
  176. package/src/network/gossip/topic.ts +30 -0
  177. package/src/network/interface.ts +3 -1
  178. package/src/network/libp2p/index.ts +2 -10
  179. package/src/network/network.ts +24 -15
  180. package/src/network/peers/datastore.ts +1 -1
  181. package/src/network/processor/gossipHandlers.ts +12 -6
  182. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +4 -2
  183. package/src/network/reqresp/handlers/index.ts +21 -12
  184. package/src/network/util.ts +5 -0
  185. package/src/sync/sync.ts +10 -0
  186. package/src/sync/unknownBlock.ts +8 -2
  187. package/src/util/execution.ts +1 -1
  188. package/src/util/profile.ts +1 -31
  189. package/lib/bun-wrappers/prometheus-gc-stats.d.ts +0 -2
  190. package/lib/bun-wrappers/prometheus-gc-stats.d.ts.map +0 -1
  191. package/lib/bun-wrappers/prometheus-gc-stats.js +0 -8
  192. package/lib/bun-wrappers/prometheus-gc-stats.js.map +0 -1
  193. package/lib/network/peers/datastore_bun.d.ts +0 -3
  194. package/lib/network/peers/datastore_bun.d.ts.map +0 -1
  195. package/lib/network/peers/datastore_bun.js +0 -3
  196. package/lib/network/peers/datastore_bun.js.map +0 -1
  197. package/src/bun-wrappers/prometheus-gc-stats.ts +0 -7
  198. package/src/network/peers/datastore_bun.ts +0 -3
@@ -1,4 +1,5 @@
1
- import {ProtocolHandler} from "@lodestar/reqresp";
1
+ import type {Type} from "@chainsafe/ssz";
2
+ import {ProtocolHandler, RespStatus, ResponseError} from "@lodestar/reqresp";
2
3
  import {ssz} from "@lodestar/types";
3
4
  import {IBeaconChain} from "../../../chain/index.js";
4
5
  import {IBeaconDb} from "../../../db/index.js";
@@ -29,6 +30,14 @@ function notImplemented(method: ReqRespMethod): ProtocolHandler {
29
30
  };
30
31
  }
31
32
 
33
+ function deserializeRequestBody<T>(type: Type<T>, data: Uint8Array): T {
34
+ try {
35
+ return type.deserialize(data);
36
+ } catch (e) {
37
+ throw new ResponseError(RespStatus.INVALID_REQUEST, e instanceof Error ? e.message : String(e));
38
+ }
39
+ }
40
+
32
41
  /**
33
42
  * The ReqRespHandler module handles app-level requests / responses from other peers,
34
43
  * fetching state from the chain and database as needed.
@@ -40,51 +49,51 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
40
49
  [ReqRespMethod.Ping]: notImplemented(ReqRespMethod.Ping),
41
50
  [ReqRespMethod.Metadata]: notImplemented(ReqRespMethod.Metadata),
42
51
  [ReqRespMethod.BeaconBlocksByRange]: (req, peerId, peerClient) => {
43
- const body = ssz.phase0.BeaconBlocksByRangeRequest.deserialize(req.data);
52
+ const body = deserializeRequestBody(ssz.phase0.BeaconBlocksByRangeRequest, req.data);
44
53
  return onBeaconBlocksByRange(body, chain, db, peerId, peerClient);
45
54
  },
46
55
  [ReqRespMethod.BeaconBlocksByRoot]: (req) => {
47
56
  const fork = chain.config.getForkName(chain.clock.currentSlot);
48
- const body = BeaconBlocksByRootRequestType(fork, chain.config).deserialize(req.data);
57
+ const body = deserializeRequestBody(BeaconBlocksByRootRequestType(fork, chain.config), req.data);
49
58
  return onBeaconBlocksByRoot(body, chain);
50
59
  },
51
60
  [ReqRespMethod.BeaconBlocksByHead]: (req, peerId, peerClient) => {
52
- const body = ssz.fulu.BeaconBlocksByHeadRequest.deserialize(req.data);
61
+ const body = deserializeRequestBody(ssz.fulu.BeaconBlocksByHeadRequest, req.data);
53
62
  return onBeaconBlocksByHead(body, chain, peerId, peerClient);
54
63
  },
55
64
  [ReqRespMethod.BlobSidecarsByRoot]: (req) => {
56
65
  const fork = chain.config.getForkName(chain.clock.currentSlot);
57
- const body = BlobSidecarsByRootRequestType(fork, chain.config).deserialize(req.data);
66
+ const body = deserializeRequestBody(BlobSidecarsByRootRequestType(fork, chain.config), req.data);
58
67
  return onBlobSidecarsByRoot(body, chain);
59
68
  },
60
69
  [ReqRespMethod.BlobSidecarsByRange]: (req) => {
61
- const body = ssz.deneb.BlobSidecarsByRangeRequest.deserialize(req.data);
70
+ const body = deserializeRequestBody(ssz.deneb.BlobSidecarsByRangeRequest, req.data);
62
71
  return onBlobSidecarsByRange(body, chain, db);
63
72
  },
64
73
  [ReqRespMethod.DataColumnSidecarsByRange]: (req, peerId, peerClient) => {
65
- const body = ssz.fulu.DataColumnSidecarsByRangeRequest.deserialize(req.data);
74
+ const body = deserializeRequestBody(ssz.fulu.DataColumnSidecarsByRangeRequest, req.data);
66
75
  return onDataColumnSidecarsByRange(body, chain, db, peerId, peerClient);
67
76
  },
68
77
  [ReqRespMethod.DataColumnSidecarsByRoot]: (req, peerId, peerClient) => {
69
- const body = DataColumnSidecarsByRootRequestType(chain.config).deserialize(req.data);
78
+ const body = deserializeRequestBody(DataColumnSidecarsByRootRequestType(chain.config), req.data);
70
79
  return onDataColumnSidecarsByRoot(body, chain, db, peerId, peerClient);
71
80
  },
72
81
 
73
82
  [ReqRespMethod.ExecutionPayloadEnvelopesByRoot]: (req, peerId, peerClient) => {
74
- const body = ExecutionPayloadEnvelopesByRootRequestType(chain.config).deserialize(req.data);
83
+ const body = deserializeRequestBody(ExecutionPayloadEnvelopesByRootRequestType(chain.config), req.data);
75
84
  return onExecutionPayloadEnvelopesByRoot(body, chain, db, peerId, peerClient);
76
85
  },
77
86
  [ReqRespMethod.ExecutionPayloadEnvelopesByRange]: (req, peerId, peerClient) => {
78
- const body = ssz.gloas.ExecutionPayloadEnvelopesByRangeRequest.deserialize(req.data);
87
+ const body = deserializeRequestBody(ssz.gloas.ExecutionPayloadEnvelopesByRangeRequest, req.data);
79
88
  return onExecutionPayloadEnvelopesByRange(body, chain, db, peerId, peerClient);
80
89
  },
81
90
 
82
91
  [ReqRespMethod.LightClientBootstrap]: (req) => {
83
- const body = ssz.Root.deserialize(req.data);
92
+ const body = deserializeRequestBody(ssz.Root, req.data);
84
93
  return onLightClientBootstrap(body, chain);
85
94
  },
86
95
  [ReqRespMethod.LightClientUpdatesByRange]: (req) => {
87
- const body = ssz.altair.LightClientUpdatesByRange.deserialize(req.data);
96
+ const body = deserializeRequestBody(ssz.altair.LightClientUpdatesByRange, req.data);
88
97
  return onLightClientUpdatesByRange(body, chain);
89
98
  },
90
99
  [ReqRespMethod.LightClientFinalityUpdate]: () => onLightClientFinalityUpdate(chain),
@@ -27,3 +27,8 @@ export function getConnection(libp2p: Libp2p, peerIdStr: string): Connection | u
27
27
  export function isPublishToZeroPeersError(e: Error): boolean {
28
28
  return e.message.includes("PublishError.NoPeersSubscribedToTopic");
29
29
  }
30
+
31
+ // https://github.com/libp2p/js-libp2p/blob/f87cba928991736d9646b3e054c367f55cab315c/packages/gossipsub/src/gossipsub.ts#L2076
32
+ export function isPublishDuplicateError(e: Error): boolean {
33
+ return e.message.includes("PublishError.Duplicate");
34
+ }
package/src/sync/sync.ts CHANGED
@@ -75,6 +75,11 @@ export class BeaconSync implements IBeaconSync {
75
75
  if (metrics) {
76
76
  metrics.syncStatus.addCollect(() => this.scrapeMetrics(metrics));
77
77
  }
78
+
79
+ // A from-scratch or large-gap start boots not synced; updateSyncState resumes once synced
80
+ if (this.state !== SyncState.Synced) {
81
+ this.chain.forkChoice.pauseFastConfirmation();
82
+ }
78
83
  }
79
84
 
80
85
  close(): void {
@@ -228,6 +233,8 @@ export class BeaconSync implements IBeaconSync {
228
233
 
229
234
  // We have become synced, subscribe to all the gossip core topics
230
235
  if (state === SyncState.Synced && this.chain.clock.currentEpoch >= MIN_EPOCH_TO_START_GOSSIP) {
236
+ this.chain.forkChoice.resumeFastConfirmation();
237
+
231
238
  if (!this.network.isSubscribedToGossipCoreTopics()) {
232
239
  this.network
233
240
  .subscribeGossipCoreTopics()
@@ -251,6 +258,9 @@ export class BeaconSync implements IBeaconSync {
251
258
  else if (state !== SyncState.Synced) {
252
259
  const syncDiff = this.chain.clock.currentSlot - this.chain.forkChoice.getHead().slot;
253
260
  if (syncDiff > this.slotImportTolerance * 2) {
261
+ // Same debounce as gossip: transient blips keep the rule running, only a real gap pauses it
262
+ this.chain.forkChoice.pauseFastConfirmation();
263
+
254
264
  if (this.network.isSubscribedToGossipCoreTopics()) {
255
265
  this.logger.warn(`Node sync has fallen behind by ${syncDiff} slots`);
256
266
  this.network
@@ -819,7 +819,7 @@ export class BlockInputSync {
819
819
  // case BlockErrorCode.ALREADY_KNOWN:
820
820
  // case BlockErrorCode.GENESIS_BLOCK:
821
821
 
822
- case BlockErrorCode.PARENT_UNKNOWN:
822
+ case BlockErrorCode.PARENT_BLOCK_UNKNOWN:
823
823
  case BlockErrorCode.PRESTATE_MISSING:
824
824
  // Should not happen, mark as downloaded to try again latter
825
825
  this.logger.debug("Attempted to process block but its parent was still unknown", errorData, res.err);
@@ -841,10 +841,16 @@ export class BlockInputSync {
841
841
 
842
842
  case BlockErrorCode.EXECUTION_ENGINE_ERROR:
843
843
  // Removing the block(s) without penalizing the peers, hoping for EL to
844
- // recover on a latter download + verify attempt
844
+ // recover on a latter download + verify attempt.
845
845
  this.removeAllDescendants(pendingBlock);
846
846
  break;
847
847
 
848
+ case BlockErrorCode.EXECUTION_ENGINE_INVALID:
849
+ // the peer served a bad block
850
+ this.logger.debug("Execution engine rejected block from unknown parent sync", errorData, res.err);
851
+ this.removeAndDownScoreAllDescendants(pendingBlock);
852
+ break;
853
+
848
854
  default:
849
855
  // Block is not correct with respect to our chain. Log error loudly
850
856
  this.logger.debug("Error processing block from unknown parent sync", errorData, res.err);
@@ -199,7 +199,7 @@ export async function getDataColumnSidecarsFromExecution(
199
199
  const previouslyMissingColumns = input.getMissingSampledColumnMeta().missing;
200
200
  const sampledColumns = previouslyMissingColumns.map((columnIndex) => dataColumnSidecars[columnIndex]);
201
201
 
202
- // for columns that we already seen, it will be ignored through `ignoreDuplicatePublishError` gossip option
202
+ // for columns we have already seen, publishDataColumnSidecar() catches PublishError.Duplicate and marks alreadyPublished=true
203
203
  emitter.emit(ChainEvent.publishDataColumns, sampledColumns);
204
204
  // TODO: Can we record dataColumns.sentPeersPerSubnet metric here somehow
205
205
 
@@ -8,21 +8,10 @@ export enum ProfileThread {
8
8
  DISC5 = "discv5",
9
9
  }
10
10
 
11
- /**
12
- * The time to take a Bun profile.
13
- * If we increase this time it'll potentiall cause the app to crash.
14
- * If we decrease this time, profile recorded will be fragmented and hard to analyze.
15
- */
16
- const BUN_PROFILE_MS = 3 * 1000;
17
-
18
- export async function profileThread(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
19
- return globalThis.Bun ? profileBun(thread, durationMs) : profileNodeJS(thread, durationMs, dirpath);
20
- }
21
-
22
11
  /**
23
12
  * Take `durationMs` profile of the current thread and return the persisted file path.
24
13
  */
25
- async function profileNodeJS(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
14
+ export async function profileThread(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
26
15
  const inspector = await import("node:inspector");
27
16
 
28
17
  // due to some typing issues, not able to use promisify here
@@ -54,25 +43,6 @@ async function profileNodeJS(thread: ProfileThread, durationMs: number, dirpath:
54
43
  return filePath;
55
44
  }
56
45
 
57
- /**
58
- * Unlike NodeJS, Bun console.profile() api flush data to the inspector,
59
- * so this api returns ms taken of this profile instead of file path.
60
- */
61
- async function profileBun(thread: ProfileThread, durationMs: number): Promise<string> {
62
- const start = Date.now();
63
- let now = Date.now();
64
- while (now - start < durationMs) {
65
- // biome-ignore lint/suspicious/noConsole: need to use console api to profile in Bun
66
- console.profile(String(now));
67
- await sleep(BUN_PROFILE_MS);
68
- // biome-ignore lint/suspicious/noConsole: need to use console api to profile in Bun
69
- console.profileEnd(String(now));
70
- now = Date.now();
71
- }
72
-
73
- return `Successfully take Bun ${thread} thread profile in ${now - start}ms. Check your inspector to see the profile.`;
74
- }
75
-
76
46
  /**
77
47
  * Write heap snapshot of the current thread to the specified file.
78
48
  */
@@ -1,2 +0,0 @@
1
- export declare function gcStats(): () => void;
2
- //# sourceMappingURL=prometheus-gc-stats.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prometheus-gc-stats.d.ts","sourceRoot":"","sources":["../../src/bun-wrappers/prometheus-gc-stats.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,eAEtB"}
@@ -1,8 +0,0 @@
1
- // Bun does not support `GCProfiler` from `node:v8`a
2
- // Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts`
3
- // So we expose a dummy function for Bun runtime which do nothing for now
4
- // TODO: May look get some useful data from `bun:jsc`
5
- export function gcStats() {
6
- return () => { };
7
- }
8
- //# sourceMappingURL=prometheus-gc-stats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prometheus-gc-stats.js","sourceRoot":"","sources":["../../src/bun-wrappers/prometheus-gc-stats.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,yHAAyH;AACzH,yEAAyE;AACzE,qDAAqD;AACrD,MAAM,UAAU,OAAO,GAAG;IACxB,OAAO,GAAG,EAAE,CAAC,EAAC,CAAC,CAAC;AAAA,CACjB"}
@@ -1,3 +0,0 @@
1
- import { FsDatastore } from "datastore-fs";
2
- export declare const LevelDatastore: typeof FsDatastore;
3
- //# sourceMappingURL=datastore_bun.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datastore_bun.d.ts","sourceRoot":"","sources":["../../../src/network/peers/datastore_bun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,cAAc,oBAAc,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FsDatastore } from "datastore-fs";
2
- export const LevelDatastore = FsDatastore;
3
- //# sourceMappingURL=datastore_bun.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datastore_bun.js","sourceRoot":"","sources":["../../../src/network/peers/datastore_bun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC"}
@@ -1,7 +0,0 @@
1
- // Bun does not support `GCProfiler` from `node:v8`a
2
- // Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts`
3
- // So we expose a dummy function for Bun runtime which do nothing for now
4
- // TODO: May look get some useful data from `bun:jsc`
5
- export function gcStats() {
6
- return () => {};
7
- }
@@ -1,3 +0,0 @@
1
- import {FsDatastore} from "datastore-fs";
2
-
3
- export const LevelDatastore = FsDatastore;