@aztec/p2p 3.0.0-nightly.20251109 → 3.0.0-nightly.20251111

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.
@@ -691,6 +691,6 @@ _ts_decorate([
691
691
  trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
692
692
  [Attributes.SLOT_NUMBER]: proposal.slotNumber.toNumber(),
693
693
  [Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
694
- [Attributes.P2P_ID]: (await proposal.p2pMessageIdentifier()).toString()
694
+ [Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString()
695
695
  }))
696
696
  ], P2PClient.prototype, "broadcastProposal", null);
@@ -123,6 +123,14 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
123
123
  result: boolean;
124
124
  topicType?: TopicType;
125
125
  };
126
+ /**
127
+ * Safely deserializes a P2PMessage from raw message data.
128
+ * @param msgId - The message ID.
129
+ * @param source - The peer ID of the message source.
130
+ * @param data - The raw message data.
131
+ * @returns The deserialized P2PMessage or undefined if deserialization fails.
132
+ */
133
+ private safelyDeserializeP2PMessage;
126
134
  /**
127
135
  * Handles a new gossip message that was received by the client.
128
136
  * @param topic - The message's topic.
@@ -1 +1 @@
1
- {"version":3,"file":"libp2p_service.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/libp2p_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,KAAK,MAAM,EAA6C,MAAM,uBAAuB,CAAC;AAI/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,QAAQ,E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100,7 @@ import { P2PInstrumentation } from './instrumentation.js';
100
100
  this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
101
101
  this.blockReceivedCallback = async (block)=>{
102
102
  this.logger.debug(`Handler not yet registered: Block received callback not set. Received block for slot ${block.slotNumber.toNumber()} from peer.`, {
103
- p2pMessageIdentifier: await block.p2pMessageIdentifier()
103
+ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier()
104
104
  });
105
105
  return undefined;
106
106
  };
@@ -466,11 +466,33 @@ import { P2PInstrumentation } from './instrumentation.js';
466
466
  };
467
467
  }
468
468
  /**
469
+ * Safely deserializes a P2PMessage from raw message data.
470
+ * @param msgId - The message ID.
471
+ * @param source - The peer ID of the message source.
472
+ * @param data - The raw message data.
473
+ * @returns The deserialized P2PMessage or undefined if deserialization fails.
474
+ */ safelyDeserializeP2PMessage(msgId, source, data) {
475
+ try {
476
+ return P2PMessage.fromMessageData(Buffer.from(data));
477
+ } catch (err) {
478
+ this.logger.error(`Error deserializing P2PMessage`, err, {
479
+ msgId,
480
+ source: source.toString()
481
+ });
482
+ this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Reject);
483
+ this.peerManager.penalizePeer(source, PeerErrorSeverity.LowToleranceError);
484
+ return undefined;
485
+ }
486
+ }
487
+ /**
469
488
  * Handles a new gossip message that was received by the client.
470
489
  * @param topic - The message's topic.
471
490
  * @param data - The message data
472
491
  */ async handleNewGossipMessage(msg, msgId, source) {
473
- const p2pMessage = P2PMessage.fromMessageData(Buffer.from(msg.data));
492
+ const p2pMessage = this.safelyDeserializeP2PMessage(msgId, source, msg.data);
493
+ if (!p2pMessage) {
494
+ return;
495
+ }
474
496
  const preValidationResult = this.preValidateReceivedMessage(msg, msgId, source);
475
497
  if (!preValidationResult.result) {
476
498
  return;
@@ -494,6 +516,7 @@ import { P2PInstrumentation } from './instrumentation.js';
494
516
  try {
495
517
  resultAndObj = await validationFunc();
496
518
  } catch (err) {
519
+ this.peerManager.penalizePeer(source, PeerErrorSeverity.LowToleranceError);
497
520
  this.logger.error(`Error deserializing and validating gossipsub message`, err, {
498
521
  msgId,
499
522
  source: source.toString(),
@@ -587,7 +610,7 @@ import { P2PInstrumentation } from './instrumentation.js';
587
610
  return;
588
611
  }
589
612
  this.logger.debug(`Received attestation for slot ${attestation.slotNumber.toNumber()} from external peer ${source.toString()}`, {
590
- p2pMessageIdentifier: await attestation.p2pMessageIdentifier(),
613
+ p2pMessageIdentifier: await attestation.p2pMessageLoggingIdentifier(),
591
614
  slot: attestation.slotNumber.toNumber(),
592
615
  archive: attestation.archive.toString(),
593
616
  source: source.toString()
@@ -636,7 +659,7 @@ import { P2PInstrumentation } from './instrumentation.js';
636
659
  const slot = block.slotNumber.toBigInt();
637
660
  const previousSlot = slot - 1n;
638
661
  this.logger.verbose(`Received block proposal for slot ${slot} from external peer ${sender.toString()}.`, {
639
- p2pMessageIdentifier: await block.p2pMessageIdentifier(),
662
+ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier(),
640
663
  slot: block.slotNumber.toNumber(),
641
664
  archive: block.archive.toString(),
642
665
  source: sender.toString()
@@ -654,7 +677,7 @@ import { P2PInstrumentation } from './instrumentation.js';
654
677
  if (attestations?.length) {
655
678
  for (const attestation of attestations){
656
679
  this.logger.verbose(`Broadcasting attestation for slot ${attestation.slotNumber.toNumber()}`, {
657
- p2pMessageIdentifier: await attestation.p2pMessageIdentifier(),
680
+ p2pMessageIdentifier: await attestation.p2pMessageLoggingIdentifier(),
658
681
  slot: attestation.slotNumber.toNumber(),
659
682
  archive: attestation.archive.toString()
660
683
  });
@@ -672,7 +695,7 @@ import { P2PInstrumentation } from './instrumentation.js';
672
695
  * Propagates provided message to peers.
673
696
  * @param message - The message to propagate.
674
697
  */ async propagate(message) {
675
- const p2pMessageIdentifier = await message.p2pMessageIdentifier();
698
+ const p2pMessageIdentifier = await message.p2pMessageLoggingIdentifier();
676
699
  this.logger.trace(`Message ${p2pMessageIdentifier} queued`, {
677
700
  p2pMessageIdentifier
678
701
  });
@@ -924,7 +947,7 @@ import { P2PInstrumentation } from './instrumentation.js';
924
947
  }
925
948
  async sendToPeers(message) {
926
949
  const parent = message.constructor;
927
- const identifier = await message.p2pMessageIdentifier().then((i)=>i.toString());
950
+ const identifier = await message.p2pMessageLoggingIdentifier().then((i)=>i.toString());
928
951
  this.logger.trace(`Sending message ${identifier}`, {
929
952
  p2pMessageIdentifier: identifier
930
953
  });
@@ -955,14 +978,14 @@ _ts_decorate([
955
978
  trackSpan('Libp2pService.processValidBlockProposal', async (block)=>({
956
979
  [Attributes.SLOT_NUMBER]: block.slotNumber.toNumber(),
957
980
  [Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
958
- [Attributes.P2P_ID]: await block.p2pMessageIdentifier().then((i)=>i.toString())
981
+ [Attributes.P2P_ID]: await block.p2pMessageLoggingIdentifier().then((i)=>i.toString())
959
982
  }))
960
983
  ], LibP2PService.prototype, "processValidBlockProposal", null);
961
984
  _ts_decorate([
962
985
  trackSpan('Libp2pService.broadcastAttestation', async (attestation)=>({
963
986
  [Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toNumber(),
964
987
  [Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
965
- [Attributes.P2P_ID]: await attestation.p2pMessageIdentifier().then((i)=>i.toString())
988
+ [Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then((i)=>i.toString())
966
989
  }))
967
990
  ], LibP2PService.prototype, "broadcastAttestation", null);
968
991
  _ts_decorate([
@@ -984,7 +1007,7 @@ _ts_decorate([
984
1007
  trackSpan('Libp2pService.validateAttestation', async (_, attestation)=>({
985
1008
  [Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toNumber(),
986
1009
  [Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
987
- [Attributes.P2P_ID]: await attestation.p2pMessageIdentifier().then((i)=>i.toString())
1010
+ [Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then((i)=>i.toString())
988
1011
  }))
989
1012
  ], LibP2PService.prototype, "validateAttestation", null);
990
1013
  _ts_decorate([
package/dest/util.d.ts CHANGED
@@ -35,6 +35,7 @@ export declare function convertToMultiaddr(address: string, port: number, protoc
35
35
  * Queries the public IP address of the machine.
36
36
  */
37
37
  export declare function getPublicIp(): Promise<string>;
38
+ export declare function isValidIpAddress(address: string): boolean;
38
39
  export declare function resolveAddressIfNecessary(address: string, port: string): Promise<string>;
39
40
  export declare function configureP2PClientAddresses(_config: P2PConfig & DataStoreConfig): Promise<P2PConfig & DataStoreConfig>;
40
41
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAIpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IACxF,QAAQ,EAAE;QACR,MAAM,EAAE,IAAI,CACV,SAAS,EACT,kBAAkB,GAAG,qBAAqB,GAAG,SAAS,GAAG,WAAW,GAAG,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AG,KAAK,GAAG,MAAM,CAOjG;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAQnD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGzD;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW9F;AAcD,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,SAAS,GAAG,eAAe,GACnC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC,CAmBtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE;IAAE,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,EACzG,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CA2D9B;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS1F"}
package/dest/util.js CHANGED
@@ -3,6 +3,7 @@ import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey } from '@libp2p
3
3
  import { createFromPrivKey } from '@libp2p/peer-id-factory';
4
4
  import { resolve } from 'dns/promises';
5
5
  import { promises as fs } from 'fs';
6
+ import net from 'net';
6
7
  import path from 'path';
7
8
  const PEER_ID_DATA_DIR_FILE = 'p2p-private-key';
8
9
  /**
@@ -22,9 +23,17 @@ const PEER_ID_DATA_DIR_FILE = 'p2p-private-key';
22
23
  /**
23
24
  * Queries the public IP address of the machine.
24
25
  */ export async function getPublicIp() {
25
- const resp = await fetch('http://checkip.amazonaws.com/');
26
+ const resp = await fetch('https://checkip.amazonaws.com/');
26
27
  const text = await resp.text();
27
- return text.trim();
28
+ const address = text.trim();
29
+ if (!isValidIpAddress(address)) {
30
+ throw new Error(`Received invalid IP address from checkip service: ${address}`);
31
+ }
32
+ return address;
33
+ }
34
+ export function isValidIpAddress(address) {
35
+ const netType = net.isIP(address);
36
+ return netType === 4;
28
37
  }
29
38
  export async function resolveAddressIfNecessary(address, port) {
30
39
  const multiaddrPrefix = addressToMultiAddressType(address);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/p2p",
3
- "version": "3.0.0-nightly.20251109",
3
+ "version": "3.0.0-nightly.20251111",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -67,17 +67,17 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/constants": "3.0.0-nightly.20251109",
71
- "@aztec/epoch-cache": "3.0.0-nightly.20251109",
72
- "@aztec/ethereum": "3.0.0-nightly.20251109",
73
- "@aztec/foundation": "3.0.0-nightly.20251109",
74
- "@aztec/kv-store": "3.0.0-nightly.20251109",
75
- "@aztec/noir-contracts.js": "3.0.0-nightly.20251109",
76
- "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251109",
77
- "@aztec/protocol-contracts": "3.0.0-nightly.20251109",
78
- "@aztec/simulator": "3.0.0-nightly.20251109",
79
- "@aztec/stdlib": "3.0.0-nightly.20251109",
80
- "@aztec/telemetry-client": "3.0.0-nightly.20251109",
70
+ "@aztec/constants": "3.0.0-nightly.20251111",
71
+ "@aztec/epoch-cache": "3.0.0-nightly.20251111",
72
+ "@aztec/ethereum": "3.0.0-nightly.20251111",
73
+ "@aztec/foundation": "3.0.0-nightly.20251111",
74
+ "@aztec/kv-store": "3.0.0-nightly.20251111",
75
+ "@aztec/noir-contracts.js": "3.0.0-nightly.20251111",
76
+ "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251111",
77
+ "@aztec/protocol-contracts": "3.0.0-nightly.20251111",
78
+ "@aztec/simulator": "3.0.0-nightly.20251111",
79
+ "@aztec/stdlib": "3.0.0-nightly.20251111",
80
+ "@aztec/telemetry-client": "3.0.0-nightly.20251111",
81
81
  "@chainsafe/libp2p-gossipsub": "13.0.0",
82
82
  "@chainsafe/libp2p-noise": "^15.0.0",
83
83
  "@chainsafe/libp2p-yamux": "^6.0.2",
@@ -104,8 +104,8 @@
104
104
  "xxhash-wasm": "^1.1.0"
105
105
  },
106
106
  "devDependencies": {
107
- "@aztec/archiver": "3.0.0-nightly.20251109",
108
- "@aztec/world-state": "3.0.0-nightly.20251109",
107
+ "@aztec/archiver": "3.0.0-nightly.20251111",
108
+ "@aztec/world-state": "3.0.0-nightly.20251111",
109
109
  "@jest/globals": "^30.0.0",
110
110
  "@types/jest": "^30.0.0",
111
111
  "@types/node": "^22.15.17",
@@ -373,7 +373,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
373
373
  @trackSpan('p2pClient.broadcastProposal', async proposal => ({
374
374
  [Attributes.SLOT_NUMBER]: proposal.slotNumber.toNumber(),
375
375
  [Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
376
- [Attributes.P2P_ID]: (await proposal.p2pMessageIdentifier()).toString(),
376
+ [Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
377
377
  }))
378
378
  public broadcastProposal(proposal: BlockProposal): Promise<void> {
379
379
  this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber.toNumber()} to peers`);
@@ -182,7 +182,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
182
182
  this.blockReceivedCallback = async (block: BlockProposal): Promise<BlockAttestation[] | undefined> => {
183
183
  this.logger.debug(
184
184
  `Handler not yet registered: Block received callback not set. Received block for slot ${block.slotNumber.toNumber()} from peer.`,
185
- { p2pMessageIdentifier: await block.p2pMessageIdentifier() },
185
+ { p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier() },
186
186
  );
187
187
  return undefined;
188
188
  };
@@ -660,13 +660,37 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
660
660
  return { result: true, topicType };
661
661
  }
662
662
 
663
+ /**
664
+ * Safely deserializes a P2PMessage from raw message data.
665
+ * @param msgId - The message ID.
666
+ * @param source - The peer ID of the message source.
667
+ * @param data - The raw message data.
668
+ * @returns The deserialized P2PMessage or undefined if deserialization fails.
669
+ */
670
+ private safelyDeserializeP2PMessage(msgId: string, source: PeerId, data: Uint8Array): P2PMessage | undefined {
671
+ try {
672
+ return P2PMessage.fromMessageData(Buffer.from(data));
673
+ } catch (err) {
674
+ this.logger.error(`Error deserializing P2PMessage`, err, {
675
+ msgId,
676
+ source: source.toString(),
677
+ });
678
+ this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Reject);
679
+ this.peerManager.penalizePeer(source, PeerErrorSeverity.LowToleranceError);
680
+ return undefined;
681
+ }
682
+ }
683
+
663
684
  /**
664
685
  * Handles a new gossip message that was received by the client.
665
686
  * @param topic - The message's topic.
666
687
  * @param data - The message data
667
688
  */
668
689
  protected async handleNewGossipMessage(msg: Message, msgId: string, source: PeerId) {
669
- const p2pMessage = P2PMessage.fromMessageData(Buffer.from(msg.data));
690
+ const p2pMessage = this.safelyDeserializeP2PMessage(msgId, source, msg.data);
691
+ if (!p2pMessage) {
692
+ return;
693
+ }
670
694
 
671
695
  const preValidationResult = this.preValidateReceivedMessage(msg, msgId, source);
672
696
 
@@ -698,6 +722,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
698
722
  try {
699
723
  resultAndObj = await validationFunc();
700
724
  } catch (err) {
725
+ this.peerManager.penalizePeer(source, PeerErrorSeverity.LowToleranceError);
701
726
  this.logger.error(`Error deserializing and validating gossipsub message`, err, {
702
727
  msgId,
703
728
  source: source.toString(),
@@ -796,7 +821,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
796
821
  this.logger.debug(
797
822
  `Received attestation for slot ${attestation.slotNumber.toNumber()} from external peer ${source.toString()}`,
798
823
  {
799
- p2pMessageIdentifier: await attestation.p2pMessageIdentifier(),
824
+ p2pMessageIdentifier: await attestation.p2pMessageLoggingIdentifier(),
800
825
  slot: attestation.slotNumber.toNumber(),
801
826
  archive: attestation.archive.toString(),
802
827
  source: source.toString(),
@@ -849,13 +874,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
849
874
  @trackSpan('Libp2pService.processValidBlockProposal', async block => ({
850
875
  [Attributes.SLOT_NUMBER]: block.slotNumber.toNumber(),
851
876
  [Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
852
- [Attributes.P2P_ID]: await block.p2pMessageIdentifier().then(i => i.toString()),
877
+ [Attributes.P2P_ID]: await block.p2pMessageLoggingIdentifier().then(i => i.toString()),
853
878
  }))
854
879
  private async processValidBlockProposal(block: BlockProposal, sender: PeerId) {
855
880
  const slot = block.slotNumber.toBigInt();
856
881
  const previousSlot = slot - 1n;
857
882
  this.logger.verbose(`Received block proposal for slot ${slot} from external peer ${sender.toString()}.`, {
858
- p2pMessageIdentifier: await block.p2pMessageIdentifier(),
883
+ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier(),
859
884
  slot: block.slotNumber.toNumber(),
860
885
  archive: block.archive.toString(),
861
886
  source: sender.toString(),
@@ -875,7 +900,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
875
900
  if (attestations?.length) {
876
901
  for (const attestation of attestations) {
877
902
  this.logger.verbose(`Broadcasting attestation for slot ${attestation.slotNumber.toNumber()}`, {
878
- p2pMessageIdentifier: await attestation.p2pMessageIdentifier(),
903
+ p2pMessageIdentifier: await attestation.p2pMessageLoggingIdentifier(),
879
904
  slot: attestation.slotNumber.toNumber(),
880
905
  archive: attestation.archive.toString(),
881
906
  });
@@ -891,7 +916,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
891
916
  @trackSpan('Libp2pService.broadcastAttestation', async attestation => ({
892
917
  [Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toNumber(),
893
918
  [Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
894
- [Attributes.P2P_ID]: await attestation.p2pMessageIdentifier().then(i => i.toString()),
919
+ [Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then(i => i.toString()),
895
920
  }))
896
921
  private async broadcastAttestation(attestation: BlockAttestation) {
897
922
  await this.propagate(attestation);
@@ -902,7 +927,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
902
927
  * @param message - The message to propagate.
903
928
  */
904
929
  public async propagate<T extends Gossipable>(message: T) {
905
- const p2pMessageIdentifier = await message.p2pMessageIdentifier();
930
+ const p2pMessageIdentifier = await message.p2pMessageLoggingIdentifier();
906
931
  this.logger.trace(`Message ${p2pMessageIdentifier} queued`, { p2pMessageIdentifier });
907
932
  void this.jobQueue
908
933
  .put(async () => {
@@ -1185,7 +1210,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
1185
1210
  @trackSpan('Libp2pService.validateAttestation', async (_, attestation) => ({
1186
1211
  [Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toNumber(),
1187
1212
  [Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
1188
- [Attributes.P2P_ID]: await attestation.p2pMessageIdentifier().then(i => i.toString()),
1213
+ [Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then(i => i.toString()),
1189
1214
  }))
1190
1215
  public async validateAttestation(peerId: PeerId, attestation: BlockAttestation): Promise<boolean> {
1191
1216
  const severity = await this.attestationValidator.validate(attestation);
@@ -1228,7 +1253,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
1228
1253
  private async sendToPeers<T extends Gossipable>(message: T) {
1229
1254
  const parent = message.constructor as typeof Gossipable;
1230
1255
 
1231
- const identifier = await message.p2pMessageIdentifier().then(i => i.toString());
1256
+ const identifier = await message.p2pMessageLoggingIdentifier().then(i => i.toString());
1232
1257
  this.logger.trace(`Sending message ${identifier}`, { p2pMessageIdentifier: identifier });
1233
1258
 
1234
1259
  const recipientsNum = await this.publishToTopic(this.topicStrings[parent.p2pTopic], message);
package/src/util.ts CHANGED
@@ -12,6 +12,7 @@ import { createFromPrivKey } from '@libp2p/peer-id-factory';
12
12
  import { resolve } from 'dns/promises';
13
13
  import { promises as fs } from 'fs';
14
14
  import type { Libp2p } from 'libp2p';
15
+ import net from 'net';
15
16
  import path from 'path';
16
17
 
17
18
  import type { P2PConfig } from './config.js';
@@ -56,9 +57,18 @@ export function convertToMultiaddr(address: string, port: number, protocol: 'tcp
56
57
  * Queries the public IP address of the machine.
57
58
  */
58
59
  export async function getPublicIp(): Promise<string> {
59
- const resp = await fetch('http://checkip.amazonaws.com/');
60
+ const resp = await fetch('https://checkip.amazonaws.com/');
60
61
  const text = await resp.text();
61
- return text.trim();
62
+ const address = text.trim();
63
+ if (!isValidIpAddress(address)) {
64
+ throw new Error(`Received invalid IP address from checkip service: ${address}`);
65
+ }
66
+ return address;
67
+ }
68
+
69
+ export function isValidIpAddress(address: string): boolean {
70
+ const netType = net.isIP(address);
71
+ return netType === 4;
62
72
  }
63
73
 
64
74
  export async function resolveAddressIfNecessary(address: string, port: string): Promise<string> {