@lodestar/beacon-node 1.41.0-dev.3b98c59c64 → 1.41.0-dev.45864cc073

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 (210) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +3 -2
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/debug/index.d.ts.map +1 -1
  5. package/lib/api/impl/debug/index.js +1 -0
  6. package/lib/api/impl/debug/index.js.map +1 -1
  7. package/lib/api/impl/node/utils.d.ts +1 -1
  8. package/lib/api/impl/node/utils.d.ts.map +1 -1
  9. package/lib/api/impl/node/utils.js.map +1 -1
  10. package/lib/api/impl/validator/index.js +2 -2
  11. package/lib/api/impl/validator/index.js.map +1 -1
  12. package/lib/chain/archiveStore/utils/updateBackfillRange.js +1 -1
  13. package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +1 -1
  14. package/lib/chain/blocks/blockInput/blockInput.d.ts +20 -2
  15. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  16. package/lib/chain/blocks/blockInput/blockInput.js +47 -0
  17. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  18. package/lib/chain/blocks/blockInput/types.d.ts +2 -1
  19. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  20. package/lib/chain/blocks/blockInput/types.js +1 -0
  21. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  22. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  23. package/lib/chain/blocks/importBlock.js +26 -3
  24. package/lib/chain/blocks/importBlock.js.map +1 -1
  25. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  26. package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -0
  27. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  28. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +4 -0
  29. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  30. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -1
  31. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  32. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  33. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -1
  34. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  35. package/lib/chain/chain.js +6 -6
  36. package/lib/chain/chain.js.map +1 -1
  37. package/lib/chain/emitter.d.ts +3 -3
  38. package/lib/chain/emitter.d.ts.map +1 -1
  39. package/lib/chain/errors/executionPayloadEnvelope.d.ts +2 -2
  40. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  41. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  42. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  43. package/lib/chain/forkChoice/index.js +30 -24
  44. package/lib/chain/forkChoice/index.js.map +1 -1
  45. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  46. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  47. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  48. package/lib/chain/produceBlock/produceBlockBody.js +1 -2
  49. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  50. package/lib/chain/regen/queued.d.ts.map +1 -1
  51. package/lib/chain/regen/queued.js +4 -1
  52. package/lib/chain/regen/queued.js.map +1 -1
  53. package/lib/chain/regen/regen.d.ts.map +1 -1
  54. package/lib/chain/regen/regen.js +5 -1
  55. package/lib/chain/regen/regen.js.map +1 -1
  56. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  57. package/lib/chain/seenCache/seenGossipBlockInput.js +15 -7
  58. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  59. package/lib/chain/validation/aggregateAndProof.js +1 -1
  60. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  61. package/lib/chain/validation/attestation.js +3 -3
  62. package/lib/chain/validation/attestation.js.map +1 -1
  63. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  64. package/lib/chain/validation/attesterSlashing.js +8 -1
  65. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  66. package/lib/chain/validation/blobSidecar.js +2 -2
  67. package/lib/chain/validation/blobSidecar.js.map +1 -1
  68. package/lib/chain/validation/block.d.ts.map +1 -1
  69. package/lib/chain/validation/block.js +6 -3
  70. package/lib/chain/validation/block.js.map +1 -1
  71. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  72. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  73. package/lib/chain/validation/executionPayloadBid.js +1 -2
  74. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  75. package/lib/chain/validation/executionPayloadEnvelope.js +4 -4
  76. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  77. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  78. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  79. package/lib/db/repositories/blockArchive.d.ts.map +1 -1
  80. package/lib/db/repositories/blockArchive.js +1 -2
  81. package/lib/db/repositories/blockArchive.js.map +1 -1
  82. package/lib/execution/engine/http.d.ts +1 -0
  83. package/lib/execution/engine/http.d.ts.map +1 -1
  84. package/lib/execution/engine/http.js +3 -0
  85. package/lib/execution/engine/http.js.map +1 -1
  86. package/lib/metrics/metrics/lodestar.d.ts +3 -0
  87. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  88. package/lib/metrics/metrics/lodestar.js +5 -0
  89. package/lib/metrics/metrics/lodestar.js.map +1 -1
  90. package/lib/network/core/networkCore.d.ts +3 -3
  91. package/lib/network/core/networkCore.d.ts.map +1 -1
  92. package/lib/network/core/networkCore.js.map +1 -1
  93. package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -3
  94. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  95. package/lib/network/core/types.d.ts +2 -2
  96. package/lib/network/core/types.d.ts.map +1 -1
  97. package/lib/network/events.d.ts +2 -1
  98. package/lib/network/events.d.ts.map +1 -1
  99. package/lib/network/events.js.map +1 -1
  100. package/lib/network/gossip/encoding.d.ts +3 -3
  101. package/lib/network/gossip/encoding.d.ts.map +1 -1
  102. package/lib/network/gossip/encoding.js.map +1 -1
  103. package/lib/network/gossip/gossipsub.d.ts +13 -4
  104. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  105. package/lib/network/gossip/gossipsub.js +47 -20
  106. package/lib/network/gossip/gossipsub.js.map +1 -1
  107. package/lib/network/gossip/interface.d.ts +3 -3
  108. package/lib/network/gossip/interface.d.ts.map +1 -1
  109. package/lib/network/gossip/scoringParameters.d.ts +1 -1
  110. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  111. package/lib/network/gossip/scoringParameters.js +1 -1
  112. package/lib/network/gossip/scoringParameters.js.map +1 -1
  113. package/lib/network/interface.d.ts +3 -3
  114. package/lib/network/interface.d.ts.map +1 -1
  115. package/lib/network/libp2p/index.d.ts +1 -1
  116. package/lib/network/libp2p/index.d.ts.map +1 -1
  117. package/lib/network/libp2p/index.js +7 -2
  118. package/lib/network/libp2p/index.js.map +1 -1
  119. package/lib/network/network.d.ts +2 -2
  120. package/lib/network/network.d.ts.map +1 -1
  121. package/lib/network/network.js.map +1 -1
  122. package/lib/network/options.d.ts.map +1 -1
  123. package/lib/network/options.js +3 -0
  124. package/lib/network/options.js.map +1 -1
  125. package/lib/network/peers/datastore.d.ts +7 -5
  126. package/lib/network/peers/datastore.d.ts.map +1 -1
  127. package/lib/network/peers/datastore.js +10 -10
  128. package/lib/network/peers/datastore.js.map +1 -1
  129. package/lib/network/peers/peerManager.d.ts +1 -0
  130. package/lib/network/peers/peerManager.d.ts.map +1 -1
  131. package/lib/network/peers/peerManager.js +51 -29
  132. package/lib/network/peers/peerManager.js.map +1 -1
  133. package/lib/network/peers/utils/prioritizePeers.d.ts +3 -3
  134. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  135. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  136. package/lib/network/processor/gossipHandlers.js +4 -1
  137. package/lib/network/processor/gossipHandlers.js.map +1 -1
  138. package/lib/network/processor/gossipValidatorFn.js +1 -1
  139. package/lib/network/processor/types.d.ts +1 -1
  140. package/lib/network/processor/types.d.ts.map +1 -1
  141. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +1 -1
  142. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  143. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  144. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  145. package/lib/network/reqresp/score.d.ts.map +1 -1
  146. package/lib/network/reqresp/score.js +0 -1
  147. package/lib/network/reqresp/score.js.map +1 -1
  148. package/lib/network/util.js +2 -2
  149. package/lib/network/util.js.map +1 -1
  150. package/lib/util/clock.d.ts +6 -0
  151. package/lib/util/clock.d.ts.map +1 -1
  152. package/lib/util/clock.js +9 -3
  153. package/lib/util/clock.js.map +1 -1
  154. package/package.json +38 -41
  155. package/src/api/impl/beacon/blocks/index.ts +3 -2
  156. package/src/api/impl/debug/index.ts +1 -0
  157. package/src/api/impl/node/utils.ts +3 -3
  158. package/src/api/impl/validator/index.ts +2 -2
  159. package/src/chain/archiveStore/utils/updateBackfillRange.ts +1 -1
  160. package/src/chain/blocks/blockInput/blockInput.ts +68 -3
  161. package/src/chain/blocks/blockInput/types.ts +1 -0
  162. package/src/chain/blocks/importBlock.ts +34 -3
  163. package/src/chain/blocks/verifyBlocksDataAvailability.ts +3 -0
  164. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
  165. package/src/chain/blocks/verifyBlocksSanityChecks.ts +7 -2
  166. package/src/chain/chain.ts +6 -6
  167. package/src/chain/emitter.ts +3 -3
  168. package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
  169. package/src/chain/forkChoice/index.ts +39 -21
  170. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  171. package/src/chain/produceBlock/produceBlockBody.ts +1 -2
  172. package/src/chain/regen/queued.ts +7 -2
  173. package/src/chain/regen/regen.ts +8 -2
  174. package/src/chain/seenCache/seenGossipBlockInput.ts +16 -7
  175. package/src/chain/validation/aggregateAndProof.ts +1 -1
  176. package/src/chain/validation/attestation.ts +3 -3
  177. package/src/chain/validation/attesterSlashing.ts +9 -0
  178. package/src/chain/validation/blobSidecar.ts +2 -2
  179. package/src/chain/validation/block.ts +9 -4
  180. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  181. package/src/chain/validation/executionPayloadBid.ts +1 -2
  182. package/src/chain/validation/executionPayloadEnvelope.ts +4 -4
  183. package/src/chain/validation/payloadAttestationMessage.ts +1 -2
  184. package/src/db/repositories/blockArchive.ts +1 -2
  185. package/src/execution/engine/http.ts +3 -0
  186. package/src/metrics/metrics/lodestar.ts +5 -0
  187. package/src/network/core/networkCore.ts +3 -3
  188. package/src/network/core/networkCoreWorkerHandler.ts +3 -3
  189. package/src/network/core/types.ts +2 -2
  190. package/src/network/events.ts +2 -1
  191. package/src/network/gossip/encoding.ts +3 -3
  192. package/src/network/gossip/gossipsub.ts +86 -25
  193. package/src/network/gossip/interface.ts +3 -3
  194. package/src/network/gossip/scoringParameters.ts +4 -4
  195. package/src/network/interface.ts +3 -3
  196. package/src/network/libp2p/index.ts +8 -3
  197. package/src/network/network.ts +3 -3
  198. package/src/network/options.ts +3 -0
  199. package/src/network/peers/datastore.ts +13 -10
  200. package/src/network/peers/peerManager.ts +56 -30
  201. package/src/network/peers/utils/prioritizePeers.ts +3 -3
  202. package/src/network/processor/gossipHandlers.ts +12 -3
  203. package/src/network/processor/gossipValidatorFn.ts +1 -1
  204. package/src/network/processor/types.ts +1 -1
  205. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +1 -1
  206. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  207. package/src/network/reqresp/score.ts +0 -1
  208. package/src/network/util.ts +2 -2
  209. package/src/util/clock.ts +9 -4
  210. package/src/util/workerEvents.ts +1 -1
@@ -162,7 +162,6 @@ export class PeerManager {
162
162
 
163
163
  // A single map of connected peers with all necessary data to handle PINGs, STATUS, and metrics
164
164
  private connectedPeers: Map<PeerIdStr, PeerData>;
165
-
166
165
  private opts: PeerManagerOpts;
167
166
  private intervals: NodeJS.Timeout[] = [];
168
167
 
@@ -480,6 +479,14 @@ export class PeerManager {
480
479
  clientAgent,
481
480
  custodyColumns,
482
481
  });
482
+
483
+ // Identify peer after status proves the connection is usable.
484
+ // This is the only place we trigger identify — avoids wasted streams on
485
+ // peers that close identify right after connection open or turn out to be
486
+ // irrelevant.
487
+ if (peerData?.agentVersion === null) {
488
+ void this.identifyPeer(peer.toString(), prettyPrintPeerId(peer), getConnection(this.libp2p, peer.toString()));
489
+ }
483
490
  }
484
491
  }
485
492
 
@@ -753,21 +760,26 @@ export class PeerManager {
753
760
  // NOTE: libp2p may emit two "peer:connect" events: One for inbound, one for outbound
754
761
  // If that happens, it's okay. Only the "outbound" connection triggers immediate action
755
762
  const now = Date.now();
763
+ const existingPeerData = this.connectedPeers.get(remotePeerStr);
756
764
  const nodeId = computeNodeId(remotePeer);
757
765
  const peerData: PeerData = {
758
- lastReceivedMsgUnixTsMs: direction === "outbound" ? 0 : now,
766
+ // Keep existing timestamps if this peer already had another open connection.
767
+ // libp2p may emit multiple connection:open events per peer.
768
+ lastReceivedMsgUnixTsMs: existingPeerData?.lastReceivedMsgUnixTsMs ?? (direction === "outbound" ? 0 : now),
759
769
  // If inbound, request after STATUS_INBOUND_GRACE_PERIOD
760
- lastStatusUnixTsMs: direction === "outbound" ? 0 : now - STATUS_INTERVAL_MS + STATUS_INBOUND_GRACE_PERIOD,
761
- connectedUnixTsMs: now,
762
- relevantStatus: RelevantPeerStatus.Unknown,
770
+ lastStatusUnixTsMs:
771
+ existingPeerData?.lastStatusUnixTsMs ??
772
+ (direction === "outbound" ? 0 : now - STATUS_INTERVAL_MS + STATUS_INBOUND_GRACE_PERIOD),
773
+ connectedUnixTsMs: existingPeerData?.connectedUnixTsMs ?? now,
774
+ relevantStatus: existingPeerData?.relevantStatus ?? RelevantPeerStatus.Unknown,
763
775
  direction,
764
776
  nodeId,
765
777
  peerId: remotePeer,
766
- status: null,
767
- metadata: null,
768
- agentVersion: null,
769
- agentClient: null,
770
- encodingPreference: null,
778
+ status: existingPeerData?.status ?? null,
779
+ metadata: existingPeerData?.metadata ?? null,
780
+ agentVersion: existingPeerData?.agentVersion ?? null,
781
+ agentClient: existingPeerData?.agentClient ?? null,
782
+ encodingPreference: existingPeerData?.encodingPreference ?? null,
771
783
  };
772
784
  this.connectedPeers.set(remotePeerStr, peerData);
773
785
 
@@ -776,26 +788,6 @@ export class PeerManager {
776
788
  void this.requestStatus(remotePeer, this.statusCache.get());
777
789
  }
778
790
 
779
- this.libp2p.services.identify
780
- .identify(connection)
781
- .then((result) => {
782
- const agentVersion = result.agentVersion;
783
- if (agentVersion) {
784
- peerData.agentVersion = agentVersion;
785
- peerData.agentClient = getKnownClientFromAgentVersion(agentVersion);
786
- }
787
- })
788
- .catch((err) => {
789
- if (connection.status !== "open") {
790
- this.logger.debug("Peer disconnected during identify protocol", {
791
- peerId: remotePeerPrettyStr,
792
- error: (err as Error).message,
793
- });
794
- } else {
795
- this.logger.debug("Error setting agentVersion for the peer", {peerId: remotePeerPrettyStr}, err);
796
- }
797
- });
798
-
799
791
  return true;
800
792
  }
801
793
 
@@ -822,6 +814,19 @@ export class PeerManager {
822
814
  const {direction, status, remotePeer} = evt.detail;
823
815
  const peerIdStr = remotePeer.toString();
824
816
 
817
+ const openConnections =
818
+ getConnectionsMap(this.libp2p)
819
+ .get(peerIdStr)
820
+ ?.value.filter((connection) => connection.status === "open") ?? [];
821
+ if (openConnections.length > 0) {
822
+ this.logger.debug("Ignoring peer disconnect event while another connection is still open", {
823
+ peerId: prettyPrintPeerIdStr(peerIdStr),
824
+ direction,
825
+ status,
826
+ });
827
+ return;
828
+ }
829
+
825
830
  let logMessage = "onLibp2pPeerDisconnect";
826
831
  const logContext: Record<string, string | number> = {
827
832
  peerId: prettyPrintPeerIdStr(peerIdStr),
@@ -856,6 +861,27 @@ export class PeerManager {
856
861
  }
857
862
  }
858
863
 
864
+ private async identifyPeer(peerIdStr: string, peerIdPretty: string, connection?: Connection): Promise<void> {
865
+ if (!connection || connection.status !== "open") {
866
+ this.logger.debug("Peer has no open connection for identify", {peerId: peerIdPretty});
867
+ return;
868
+ }
869
+
870
+ try {
871
+ const result = await this.libp2p.services.identify.identify(connection);
872
+ const agentVersion = result.agentVersion;
873
+ if (agentVersion) {
874
+ const connectedPeerData = this.connectedPeers.get(peerIdStr);
875
+ if (connectedPeerData) {
876
+ connectedPeerData.agentVersion = agentVersion;
877
+ connectedPeerData.agentClient = getKnownClientFromAgentVersion(agentVersion);
878
+ }
879
+ }
880
+ } catch (e) {
881
+ this.logger.debug("Error setting agentVersion for the peer", {peerId: peerIdPretty}, e as Error);
882
+ }
883
+ }
884
+
859
885
  private async goodbyeAndDisconnect(peer: PeerId, goodbye: GoodByeReasonCode): Promise<void> {
860
886
  const reason = GOODBYE_KNOWN_CODES[goodbye.toString()] || "";
861
887
  const peerIdStr = peer.toString();
@@ -1,4 +1,4 @@
1
- import {Direction, PeerId} from "@libp2p/interface";
1
+ import type {MessageStreamDirection, PeerId} from "@libp2p/interface";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {ChainConfig} from "@lodestar/config";
4
4
  import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
@@ -95,7 +95,7 @@ function computeStatusScore(ours: Status, theirs: Status | null, opts: Prioritiz
95
95
 
96
96
  type PeerInfo = {
97
97
  id: PeerId;
98
- direction: Direction | null;
98
+ direction: MessageStreamDirection | null;
99
99
  statusScore: StatusScore;
100
100
  attnets: phase0.AttestationSubnets;
101
101
  syncnets: altair.SyncSubnets;
@@ -137,7 +137,7 @@ export enum ExcessPeerDisconnectReason {
137
137
  export function prioritizePeers(
138
138
  connectedPeersInfo: {
139
139
  id: PeerId;
140
- direction: Direction | null;
140
+ direction: MessageStreamDirection | null;
141
141
  status: Status | null;
142
142
  attnets: phase0.AttestationSubnets | null;
143
143
  syncnets: altair.SyncSubnets | null;
@@ -2,6 +2,7 @@ import {routes} from "@lodestar/api";
2
2
  import {BeaconConfig, ChainForkConfig} from "@lodestar/config";
3
3
  import {
4
4
  ForkName,
5
+ ForkPostDeneb,
5
6
  ForkPostElectra,
6
7
  ForkPreElectra,
7
8
  ForkSeq,
@@ -70,6 +71,7 @@ import {validateGossipPayloadAttestationMessage} from "../../chain/validation/pa
70
71
  import {OpSource} from "../../chain/validatorMonitor.js";
71
72
  import {Metrics} from "../../metrics/index.js";
72
73
  import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
74
+ import {getBlobKzgCommitments} from "../../util/dataColumns.ts";
73
75
  import {INetworkCore} from "../core/index.js";
74
76
  import {NetworkEventBus} from "../events.js";
75
77
  import {
@@ -417,9 +419,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
417
419
  chain.getBlobsTracker.triggerGetBlobs(blockInput);
418
420
  } else {
419
421
  metrics?.blockInputFetchStats.totalDataAvailableBlockInputs.inc();
420
- metrics?.blockInputFetchStats.totalDataAvailableBlockInputBlobs.inc(
421
- (signedBlock.message as deneb.BeaconBlock).body.blobKzgCommitments.length
422
- );
422
+ const blobCount = getBlobKzgCommitments(
423
+ blockInput.forkName,
424
+ signedBlock as SignedBeaconBlock<ForkPostDeneb>
425
+ ).length;
426
+ metrics?.blockInputFetchStats.totalDataAvailableBlockInputBlobs.inc(blobCount);
423
427
  }
424
428
 
425
429
  chain
@@ -852,6 +856,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
852
856
  } catch (e) {
853
857
  logger.error("Error adding to payloadAttestation pool", {}, e as Error);
854
858
  }
859
+ chain.forkChoice.notifyPtcMessages(
860
+ toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
861
+ [validationResult.validatorCommitteeIndex],
862
+ payloadAttestationMessage.data.payloadPresent
863
+ );
855
864
  },
856
865
  [GossipType.execution_payload_bid]: async ({
857
866
  gossipData,
@@ -1,4 +1,4 @@
1
- import {TopicValidatorResult} from "@libp2p/interface";
1
+ import {TopicValidatorResult} from "@libp2p/gossipsub";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {Logger} from "@lodestar/utils";
4
4
  import {AttestationError, GossipAction, GossipActionError} from "../../chain/errors/index.js";
@@ -1,4 +1,4 @@
1
- import {Message} from "@libp2p/interface";
1
+ import type {Message} from "@libp2p/gossipsub";
2
2
  import {ForkName} from "@lodestar/params";
3
3
  import {Slot, SlotOptionalRoot} from "@lodestar/types";
4
4
  import {PeerIdStr} from "../../util/peerId.js";
@@ -20,7 +20,7 @@ export async function* onBlobSidecarsByRoot(
20
20
  for (const blobIdentifier of requestBody) {
21
21
  const {blockRoot, index} = blobIdentifier;
22
22
  const blockRootHex = toRootHex(blockRoot);
23
- const block = chain.forkChoice.getBlockHex(blockRootHex);
23
+ const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
24
24
 
25
25
  // NOTE: Only support non-finalized blocks.
26
26
  // SPEC: Clients MUST support requesting blocks and sidecars since the latest finalized epoch.
@@ -34,7 +34,7 @@ export async function* onDataColumnSidecarsByRoot(
34
34
  }
35
35
 
36
36
  const blockRootHex = toRootHex(blockRoot);
37
- const block = chain.forkChoice.getBlockHex(blockRootHex);
37
+ const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
38
38
  // If the block is not in fork choice, it may be finalized. Attempt to find its slot in block archive
39
39
  const slot = block ? block.slot : await db.blockArchive.getSlotByRoot(blockRoot);
40
40
 
@@ -38,7 +38,6 @@ export function onOutgoingReqRespError(e: RequestError, method: ReqRespMethod):
38
38
  : PeerAction.LowToleranceError;
39
39
  // TODO: Detect SSZDecodeError and return PeerAction.Fatal
40
40
 
41
- case RequestErrorCode.TTFB_TIMEOUT:
42
41
  case RequestErrorCode.RESP_TIMEOUT:
43
42
  switch (method) {
44
43
  case ReqRespMethod.Ping:
@@ -23,7 +23,7 @@ export function getConnection(libp2p: Libp2p, peerIdStr: string): Connection | u
23
23
  return getConnectionsMap(libp2p).get(peerIdStr)?.value[0] ?? undefined;
24
24
  }
25
25
 
26
- // https://github.com/ChainSafe/js-libp2p-gossipsub/blob/3475242ed254f7647798ab7f36b21909f6cb61da/src/index.ts#L2009
26
+ // https://github.com/libp2p/js-libp2p/blob/f87cba928991736d9646b3e054c367f55cab315c/packages/gossipsub/src/gossipsub.ts#L2076
27
27
  export function isPublishToZeroPeersError(e: Error): boolean {
28
- return e.message.includes("PublishError.InsufficientPeers");
28
+ return e.message.includes("PublishError.NoPeersSubscribedToTopic");
29
29
  }
package/src/util/clock.ts CHANGED
@@ -92,15 +92,17 @@ export class Clock extends EventEmitter implements IClock {
92
92
  }
93
93
  return slot;
94
94
  }
95
-
96
95
  /**
97
96
  * If it's too close to next slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY, return currentSlot + 1.
98
97
  * Otherwise return currentSlot
98
+ *
99
+ * Spec: phase0/p2p-interface.md - gossip validation uses `current_time + MAXIMUM_GOSSIP_CLOCK_DISPARITY < message_time`
100
+ * to reject future messages (strict `<`), so the boundary (exactly equal) is accepted, hence `<=` here.
99
101
  */
100
102
  get currentSlotWithGossipDisparity(): Slot {
101
103
  const currentSlot = this.currentSlot;
102
104
  const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
103
- return nextSlotTime - Date.now() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
105
+ return nextSlotTime - Date.now() <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
104
106
  }
105
107
 
106
108
  get currentEpoch(): Epoch {
@@ -121,6 +123,9 @@ export class Clock extends EventEmitter implements IClock {
121
123
 
122
124
  /**
123
125
  * Check if a slot is current slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY.
126
+ *
127
+ * Uses `<=` for disparity checks because the spec rejects with strict `<`
128
+ * (phase0/p2p-interface.md), meaning the boundary (exactly equal) is accepted.
124
129
  */
125
130
  isCurrentSlotGivenGossipDisparity(slot: Slot): boolean {
126
131
  const currentSlot = this.currentSlot;
@@ -129,12 +134,12 @@ export class Clock extends EventEmitter implements IClock {
129
134
  }
130
135
  const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
131
136
  // we're too close to next slot, accept next slot
132
- if (nextSlotTime - Date.now() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
137
+ if (nextSlotTime - Date.now() <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
133
138
  return slot === currentSlot + 1;
134
139
  }
135
140
  const currentSlotTime = computeTimeAtSlot(this.config, currentSlot, this.genesisTime) * 1000;
136
141
  // we've just passed the current slot, accept previous slot
137
- if (Date.now() - currentSlotTime < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
142
+ if (Date.now() - currentSlotTime <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
138
143
  return slot === currentSlot - 1;
139
144
  }
140
145
  return false;
@@ -1,5 +1,5 @@
1
1
  import {MessagePort, Worker} from "node:worker_threads";
2
- import {Message} from "@libp2p/interface";
2
+ import type {Message} from "@libp2p/gossipsub";
3
3
  import {Thread} from "@chainsafe/threads";
4
4
  import {Logger} from "@lodestar/logger";
5
5
  import {sleep} from "@lodestar/utils";