@aztec/p2p 4.0.0-nightly.20260107 → 4.0.0-nightly.20260110

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 (61) hide show
  1. package/dest/client/p2p_client.d.ts +2 -2
  2. package/dest/client/p2p_client.d.ts.map +1 -1
  3. package/dest/client/p2p_client.js +3 -2
  4. package/dest/mem_pools/instrumentation.d.ts +1 -1
  5. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  6. package/dest/mem_pools/instrumentation.js +4 -13
  7. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +1 -1
  8. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  9. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -5
  10. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  11. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  12. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
  13. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  14. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +1 -1
  15. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  16. package/dest/services/libp2p/instrumentation.d.ts +1 -1
  17. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  18. package/dest/services/libp2p/instrumentation.js +15 -68
  19. package/dest/services/libp2p/libp2p_service.d.ts +2 -1
  20. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  21. package/dest/services/libp2p/libp2p_service.js +54 -13
  22. package/dest/services/peer-manager/metrics.d.ts +1 -1
  23. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  24. package/dest/services/peer-manager/metrics.js +6 -26
  25. package/dest/services/peer-manager/peer_manager.d.ts +2 -2
  26. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  27. package/dest/services/peer-manager/peer_manager.js +1 -385
  28. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  29. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  30. package/dest/services/peer-manager/peer_scoring.js +2 -5
  31. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -1
  32. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  33. package/dest/services/reqresp/metrics.d.ts +1 -1
  34. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  35. package/dest/services/reqresp/metrics.js +5 -21
  36. package/dest/services/reqresp/protocols/status.d.ts +1 -1
  37. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  38. package/dest/services/reqresp/protocols/status.js +2 -0
  39. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  40. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  41. package/dest/services/tx_collection/instrumentation.js +4 -14
  42. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  43. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  44. package/dest/services/tx_provider_instrumentation.js +6 -19
  45. package/package.json +14 -14
  46. package/src/client/p2p_client.ts +9 -18
  47. package/src/mem_pools/instrumentation.ts +9 -18
  48. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -5
  49. package/src/msg_validators/tx_validator/data_validator.ts +12 -4
  50. package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
  51. package/src/msg_validators/tx_validator/timestamp_validator.ts +3 -1
  52. package/src/services/libp2p/instrumentation.ts +14 -68
  53. package/src/services/libp2p/libp2p_service.ts +73 -13
  54. package/src/services/peer-manager/metrics.ts +5 -26
  55. package/src/services/peer-manager/peer_manager.ts +1 -2
  56. package/src/services/peer-manager/peer_scoring.ts +1 -5
  57. package/src/services/reqresp/connection-sampler/connection_sampler.ts +3 -1
  58. package/src/services/reqresp/metrics.ts +7 -23
  59. package/src/services/reqresp/protocols/status.ts +2 -1
  60. package/src/services/tx_collection/instrumentation.ts +4 -21
  61. package/src/services/tx_provider_instrumentation.ts +11 -24
@@ -1,23 +1,13 @@
1
- import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
1
+ import { Attributes, Metrics } from '@aztec/telemetry-client';
2
2
  export class TxCollectionInstrumentation {
3
3
  txsCollected;
4
4
  collectionDurationPerTx;
5
5
  collectionDurationPerRequest;
6
6
  constructor(client, name){
7
7
  const meter = client.getMeter(name);
8
- this.txsCollected = meter.createUpDownCounter(Metrics.TX_COLLECTOR_COUNT, {
9
- description: 'The number of txs collected'
10
- });
11
- this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX, {
12
- unit: 'ms',
13
- description: 'Average duration per tx of an individual tx collection request',
14
- valueType: ValueType.INT
15
- });
16
- this.collectionDurationPerRequest = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_REQUEST, {
17
- unit: 'ms',
18
- description: 'Total duration of an individual tx collection request',
19
- valueType: ValueType.INT
20
- });
8
+ this.txsCollected = meter.createUpDownCounter(Metrics.TX_COLLECTOR_COUNT);
9
+ this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
10
+ this.collectionDurationPerRequest = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_REQUEST);
21
11
  }
22
12
  increaseTxsFor(what, count, duration) {
23
13
  const durationPerTx = Math.ceil(duration / count);
@@ -13,4 +13,4 @@ export declare class TxProviderInstrumentation {
13
13
  recordTxsRequestDelay(delay: number): void;
14
14
  incMissingTxs(count: number): void;
15
15
  }
16
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfcHJvdmlkZXJfaW5zdHJ1bWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VydmljZXMvdHhfcHJvdmlkZXJfaW5zdHJ1bWVudGF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBMkIsS0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AM,QAElC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,QAE1B;CACF"}
1
+ {"version":3,"file":"tx_provider_instrumentation.d.ts","sourceRoot":"","sources":["../../src/services/tx_provider_instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAE5G,qBAAa,yBAAyB;IACpC,OAAO,CAAC,mBAAmB,CAAgB;IAC3C,OAAO,CAAC,kBAAkB,CAAgB;IAC1C,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,eAAe,CAAgB;IAEvC,OAAO,CAAC,6BAA6B,CAAY;IACjD,OAAO,CAAC,eAAe,CAAY;IAEnC,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAchD;IAED,mBAAmB,CAAC,KAAK,EAAE,MAAM,QAEhC;IAED,iBAAiB,CAAC,KAAK,EAAE,MAAM,QAE9B;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAGzC;IAED,qBAAqB,CAAC,KAAK,EAAE,MAAM,QAElC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,QAE1B;CACF"}
@@ -8,25 +8,12 @@ export class TxProviderInstrumentation {
8
8
  txsRequestDelay;
9
9
  constructor(client, name){
10
10
  const meter = client.getMeter(name);
11
- this.txFromProposalCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_PROPOSALS_COUNT, {
12
- description: 'The number of txs taken from block proposals'
13
- });
14
- this.txFromMempoolCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_MEMPOOL_COUNT, {
15
- description: 'The number of txs taken from the local mempool'
16
- });
17
- this.txFromP2PCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_P2P_COUNT, {
18
- description: 'The number of txs taken from the p2p network'
19
- });
20
- this.missingTxsCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_MISSING_TXS_COUNT, {
21
- description: 'The number of txs not found anywhere'
22
- });
23
- this.fractionOfTxsRequestedFromP2P = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUESTED_FRACTION, {
24
- description: 'The fraction of transaction requested from peers'
25
- });
26
- this.txsRequestDelay = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUEST_DELAY, {
27
- unit: 'ms',
28
- description: 'The time it took to request missing transactions from p2p'
29
- });
11
+ this.txFromProposalCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_PROPOSALS_COUNT);
12
+ this.txFromMempoolCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_MEMPOOL_COUNT);
13
+ this.txFromP2PCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_P2P_COUNT);
14
+ this.missingTxsCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_MISSING_TXS_COUNT);
15
+ this.fractionOfTxsRequestedFromP2P = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUESTED_FRACTION);
16
+ this.txsRequestDelay = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUEST_DELAY);
30
17
  }
31
18
  incTxsFromProposals(count) {
32
19
  this.txFromProposalCount.add(count);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/p2p",
3
- "version": "4.0.0-nightly.20260107",
3
+ "version": "4.0.0-nightly.20260110",
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": "4.0.0-nightly.20260107",
71
- "@aztec/epoch-cache": "4.0.0-nightly.20260107",
72
- "@aztec/ethereum": "4.0.0-nightly.20260107",
73
- "@aztec/foundation": "4.0.0-nightly.20260107",
74
- "@aztec/kv-store": "4.0.0-nightly.20260107",
75
- "@aztec/noir-contracts.js": "4.0.0-nightly.20260107",
76
- "@aztec/noir-protocol-circuits-types": "4.0.0-nightly.20260107",
77
- "@aztec/protocol-contracts": "4.0.0-nightly.20260107",
78
- "@aztec/simulator": "4.0.0-nightly.20260107",
79
- "@aztec/stdlib": "4.0.0-nightly.20260107",
80
- "@aztec/telemetry-client": "4.0.0-nightly.20260107",
70
+ "@aztec/constants": "4.0.0-nightly.20260110",
71
+ "@aztec/epoch-cache": "4.0.0-nightly.20260110",
72
+ "@aztec/ethereum": "4.0.0-nightly.20260110",
73
+ "@aztec/foundation": "4.0.0-nightly.20260110",
74
+ "@aztec/kv-store": "4.0.0-nightly.20260110",
75
+ "@aztec/noir-contracts.js": "4.0.0-nightly.20260110",
76
+ "@aztec/noir-protocol-circuits-types": "4.0.0-nightly.20260110",
77
+ "@aztec/protocol-contracts": "4.0.0-nightly.20260110",
78
+ "@aztec/simulator": "4.0.0-nightly.20260110",
79
+ "@aztec/stdlib": "4.0.0-nightly.20260110",
80
+ "@aztec/telemetry-client": "4.0.0-nightly.20260110",
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": "4.0.0-nightly.20260107",
108
- "@aztec/world-state": "4.0.0-nightly.20260107",
107
+ "@aztec/archiver": "4.0.0-nightly.20260110",
108
+ "@aztec/world-state": "4.0.0-nightly.20260110",
109
109
  "@jest/globals": "^30.0.0",
110
110
  "@types/jest": "^30.0.0",
111
111
  "@types/node": "^22.15.17",
@@ -3,28 +3,21 @@ import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { DateProvider } from '@aztec/foundation/timer';
5
5
  import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton } from '@aztec/kv-store';
6
- import type {
7
- EthAddress,
8
- L2BlockId,
9
- L2BlockNew,
10
- L2BlockSource,
6
+ import {
7
+ type EthAddress,
8
+ type L2BlockId,
9
+ type L2BlockNew,
10
+ type L2BlockSource,
11
11
  L2BlockStream,
12
- L2BlockStreamEvent,
13
- L2Tips,
12
+ type L2BlockStreamEvent,
13
+ type L2Tips,
14
14
  } from '@aztec/stdlib/block';
15
15
  import type { ContractDataSource } from '@aztec/stdlib/contract';
16
16
  import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
17
17
  import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
18
18
  import { BlockAttestation, type BlockProposal, type P2PClientType } from '@aztec/stdlib/p2p';
19
19
  import type { Tx, TxHash } from '@aztec/stdlib/tx';
20
- import {
21
- Attributes,
22
- type TelemetryClient,
23
- TraceableL2BlockStream,
24
- WithTracer,
25
- getTelemetryClient,
26
- trackSpan,
27
- } from '@aztec/telemetry-client';
20
+ import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
28
21
 
29
22
  import type { PeerId } from '@libp2p/interface';
30
23
  import type { ENR } from '@nethermindeth/enr';
@@ -335,12 +328,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
335
328
  private initBlockStream(startingBlock?: BlockNumber) {
336
329
  if (!this.blockStream) {
337
330
  const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
338
- this.blockStream = new TraceableL2BlockStream(
331
+ this.blockStream = new L2BlockStream(
339
332
  this.l2BlockSource,
340
333
  this,
341
334
  this,
342
- this.telemetry.getTracer('P2PL2BlockStream'),
343
- 'P2PL2BlockStream',
344
335
  createLogger(`${this.log.module}:l2-block-stream`),
345
336
  { batchSize, pollIntervalMS, startingBlock },
346
337
  );
@@ -7,8 +7,8 @@ import {
7
7
  LmdbMetrics,
8
8
  type LmdbStatsCallback,
9
9
  type Meter,
10
+ type MetricDefinition,
10
11
  Metrics,
11
- type MetricsType,
12
12
  type ObservableGauge,
13
13
  type TelemetryClient,
14
14
  type UpDownCounter,
@@ -20,10 +20,10 @@ export enum PoolName {
20
20
  }
21
21
 
22
22
  type MetricsLabels = {
23
- objectInMempool: MetricsType;
24
- objectSize: MetricsType;
25
- itemsAdded: MetricsType;
26
- itemMinedDelay: MetricsType;
23
+ objectInMempool: MetricDefinition;
24
+ objectSize: MetricDefinition;
25
+ itemsAdded: MetricDefinition;
26
+ itemMinedDelay: MetricDefinition;
27
27
  };
28
28
 
29
29
  /**
@@ -85,14 +85,9 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
85
85
 
86
86
  const metricsLabels = getMetricsLabels(name);
87
87
 
88
- this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool, {
89
- description: 'The current number of transactions in the mempool',
90
- });
88
+ this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool);
91
89
 
92
- this.objectSize = this.meter.createHistogram(metricsLabels.objectSize, {
93
- unit: 'By',
94
- description: 'The size of transactions in the mempool',
95
- });
90
+ this.objectSize = this.meter.createHistogram(metricsLabels.objectSize);
96
91
 
97
92
  this.dbMetrics = new LmdbMetrics(
98
93
  this.meter,
@@ -102,13 +97,9 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
102
97
  dbStats,
103
98
  );
104
99
 
105
- this.addObjectCounter = this.meter.createUpDownCounter(metricsLabels.itemsAdded, {
106
- description: 'The number of transactions added to the mempool',
107
- });
100
+ this.addObjectCounter = this.meter.createUpDownCounter(metricsLabels.itemsAdded);
108
101
 
109
- this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay, {
110
- description: 'Delay between transaction added and evicted from the mempool',
111
- });
102
+ this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay);
112
103
 
113
104
  this.meter.addBatchObservableCallback(this.observeStats, [this.objectsInMempool]);
114
105
  }
@@ -1,6 +1,6 @@
1
1
  import type { EpochCacheInterface } from '@aztec/epoch-cache';
2
2
  import { type BlockAttestation, PeerErrorSeverity } from '@aztec/stdlib/p2p';
3
- import { Attributes, Metrics, type TelemetryClient, ValueType } from '@aztec/telemetry-client';
3
+ import { Attributes, Metrics, type TelemetryClient } from '@aztec/telemetry-client';
4
4
 
5
5
  import type { AttestationPool } from '../../mem_pools/attestation_pool/attestation_pool.js';
6
6
  import { AttestationValidator } from './attestation_validator.js';
@@ -25,10 +25,7 @@ export class FishermanAttestationValidator extends AttestationValidator {
25
25
  this.logger = this.logger.createChild('[FISHERMAN]');
26
26
 
27
27
  const meter = telemetryClient.getMeter('FishermanAttestationValidator');
28
- this.invalidAttestationCounter = meter.createUpDownCounter(Metrics.VALIDATOR_INVALID_ATTESTATION_RECEIVED_COUNT, {
29
- description: 'The number of invalid attestations received',
30
- valueType: ValueType.INT,
31
- });
28
+ this.invalidAttestationCounter = meter.createUpDownCounter(Metrics.VALIDATOR_INVALID_ATTESTATION_RECEIVED_COUNT);
32
29
  }
33
30
 
34
31
  override async validate(message: BlockAttestation): Promise<PeerErrorSeverity | undefined> {
@@ -31,7 +31,9 @@ export class DataTxValidator implements TxValidator<Tx> {
31
31
  if (!tx.getTxHash().equals(expected)) {
32
32
  const reason = TX_ERROR_INCORRECT_HASH;
33
33
  this.#log.verbose(
34
- `Rejecting tx ${tx.getTxHash().toString()}. Reason: ${reason}. Expected hash ${expected.toString()}. Got ${tx.getTxHash().toString()}.`,
34
+ `Rejecting tx ${tx.getTxHash().toString()}. Reason: ${reason}. Expected hash ${expected.toString()}. Got ${tx
35
+ .getTxHash()
36
+ .toString()}.`,
35
37
  );
36
38
  return reason;
37
39
  }
@@ -52,7 +54,9 @@ export class DataTxValidator implements TxValidator<Tx> {
52
54
  if (tx.getTotalPublicCalldataCount() > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
53
55
  const reason = TX_ERROR_CALLDATA_COUNT_TOO_LARGE;
54
56
  this.#log.verbose(
55
- `Rejecting tx ${tx.getTxHash().toString()}. Reason: ${reason}. Expected no greater than ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS} fields. Got ${tx.getTotalPublicCalldataCount()}.`,
57
+ `Rejecting tx ${tx
58
+ .getTxHash()
59
+ .toString()}. Reason: ${reason}. Expected no greater than ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS} fields. Got ${tx.getTotalPublicCalldataCount()}.`,
56
60
  );
57
61
  return reason;
58
62
  }
@@ -89,7 +93,9 @@ export class DataTxValidator implements TxValidator<Tx> {
89
93
  if (expectedHashes.some(h => logHash.value.equals(h))) {
90
94
  const matchingLogIndex = expectedHashes.findIndex(l => logHash.value.equals(l));
91
95
  this.#log.verbose(
92
- `Rejecting tx ${tx.getTxHash().toString()} because of mismatched contract class logs indices. Expected ${i} from the kernel's log hashes. Got ${matchingLogIndex} in the tx.`,
96
+ `Rejecting tx ${tx
97
+ .getTxHash()
98
+ .toString()} because of mismatched contract class logs indices. Expected ${i} from the kernel's log hashes. Got ${matchingLogIndex} in the tx.`,
93
99
  );
94
100
  return TX_ERROR_CONTRACT_CLASS_LOG_SORTING;
95
101
  } else {
@@ -105,7 +111,9 @@ export class DataTxValidator implements TxValidator<Tx> {
105
111
  const expectedMinLength = 1 + tx.contractClassLogFields[i].fields.findLastIndex(f => !f.isZero());
106
112
  if (logHash.logHash.length < expectedMinLength) {
107
113
  this.#log.verbose(
108
- `Rejecting tx ${tx.getTxHash().toString()} because of incorrect contract class log length. Expected the length to be at least ${expectedMinLength}. Got ${
114
+ `Rejecting tx ${tx
115
+ .getTxHash()
116
+ .toString()} because of incorrect contract class log length. Expected the length to be at least ${expectedMinLength}. Got ${
109
117
  logHash.logHash.length
110
118
  }.`,
111
119
  );
@@ -43,7 +43,9 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
43
43
  // This gets implicitly tested in the proof validator, but we can get a much cheaper check here by looking early at the vk.
44
44
  if (!tx.data.constants.vkTreeRoot.equals(this.values.vkTreeRoot)) {
45
45
  this.#log.verbose(
46
- `Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} because of incorrect vk tree root ${tx.data.constants.vkTreeRoot.toString()} != ${this.values.vkTreeRoot.toString()}`,
46
+ `Rejecting tx ${
47
+ 'txHash' in tx ? tx.txHash : tx.hash
48
+ } because of incorrect vk tree root ${tx.data.constants.vkTreeRoot.toString()} != ${this.values.vkTreeRoot.toString()}`,
47
49
  );
48
50
  return false;
49
51
  } else {
@@ -54,7 +56,9 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
54
56
  #hasCorrectprotocolContractsHash(tx: T): boolean {
55
57
  if (!tx.data.constants.protocolContractsHash.equals(this.values.protocolContractsHash)) {
56
58
  this.#log.verbose(
57
- `Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} because of incorrect protocol contracts hash ${tx.data.constants.protocolContractsHash.toString()} != ${this.values.protocolContractsHash.toString()}`,
59
+ `Rejecting tx ${
60
+ 'txHash' in tx ? tx.txHash : tx.hash
61
+ } because of incorrect protocol contracts hash ${tx.data.constants.protocolContractsHash.toString()} != ${this.values.protocolContractsHash.toString()}`,
58
62
  );
59
63
  return false;
60
64
  }
@@ -64,7 +68,9 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
64
68
  #hasCorrectL1ChainId(tx: T): boolean {
65
69
  if (!tx.data.constants.txContext.chainId.equals(this.values.l1ChainId)) {
66
70
  this.#log.verbose(
67
- `Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} because of incorrect L1 chain ${tx.data.constants.txContext.chainId.toNumber()} != ${this.values.l1ChainId.toNumber()}`,
71
+ `Rejecting tx ${
72
+ 'txHash' in tx ? tx.txHash : tx.hash
73
+ } because of incorrect L1 chain ${tx.data.constants.txContext.chainId.toNumber()} != ${this.values.l1ChainId.toNumber()}`,
68
74
  );
69
75
  return false;
70
76
  } else {
@@ -75,7 +81,9 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
75
81
  #hasCorrectRollupVersion(tx: T): boolean {
76
82
  if (!tx.data.constants.txContext.version.equals(this.values.rollupVersion)) {
77
83
  this.#log.verbose(
78
- `Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} because of incorrect rollup version ${tx.data.constants.txContext.version.toNumber()} != ${this.values.rollupVersion.toNumber()}`,
84
+ `Rejecting tx ${
85
+ 'txHash' in tx ? tx.txHash : tx.hash
86
+ } because of incorrect rollup version ${tx.data.constants.txContext.version.toNumber()} != ${this.values.rollupVersion.toNumber()}`,
79
87
  );
80
88
  return false;
81
89
  } else {
@@ -35,7 +35,9 @@ export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
35
35
  );
36
36
  }
37
37
  this.#log.verbose(
38
- `Rejecting tx ${getTxHash(tx)} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${
38
+ `Rejecting tx ${getTxHash(
39
+ tx,
40
+ )} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${
39
41
  this.values.timestamp
40
42
  }.`,
41
43
  );
@@ -8,7 +8,6 @@ import {
8
8
  type ObservableGauge,
9
9
  type TelemetryClient,
10
10
  type UpDownCounter,
11
- ValueType,
12
11
  } from '@aztec/telemetry-client';
13
12
 
14
13
  import { type RecordableHistogram, createHistogram } from 'node:perf_hooks';
@@ -28,81 +27,28 @@ export class P2PInstrumentation {
28
27
  constructor(client: TelemetryClient, name: string) {
29
28
  const meter = client.getMeter(name);
30
29
 
31
- this.messageValidationDuration = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_VALIDATION_DURATION, {
32
- unit: 'ms',
33
- description: 'How long validating a gossiped message takes',
34
- valueType: ValueType.INT,
35
- });
30
+ this.messageValidationDuration = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_VALIDATION_DURATION);
36
31
 
37
- this.messagePrevalidationCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_MESSAGE_PREVALIDATION_COUNT, {
38
- description: 'How many message pass/fail prevalidation',
39
- valueType: ValueType.INT,
40
- });
32
+ this.messagePrevalidationCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_MESSAGE_PREVALIDATION_COUNT);
41
33
 
42
- this.messageLatency = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_LATENCY, {
43
- unit: 'ms',
44
- description: 'P2P message latency',
45
- valueType: ValueType.INT,
46
- });
34
+ this.messageLatency = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_LATENCY);
47
35
 
48
- this.txReceivedCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_TX_RECEIVED_COUNT, {
49
- description: 'The number of txs received from the p2p network',
50
- });
36
+ this.txReceivedCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_TX_RECEIVED_COUNT);
51
37
 
52
38
  this.aggLatencyMetrics = {
53
- avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG, {
54
- valueType: ValueType.DOUBLE,
55
- description: 'AVG msg latency',
56
- unit: 'ms',
57
- }),
58
- max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MAX, {
59
- valueType: ValueType.DOUBLE,
60
- description: 'MAX msg latency',
61
- unit: 'ms',
62
- }),
63
- min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MIN, {
64
- valueType: ValueType.DOUBLE,
65
- description: 'MIN msg latency',
66
- unit: 'ms',
67
- }),
68
- p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P50, {
69
- valueType: ValueType.DOUBLE,
70
- description: 'P50 msg latency',
71
- unit: 'ms',
72
- }),
73
- p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P90, {
74
- valueType: ValueType.DOUBLE,
75
- description: 'P90 msg latency',
76
- unit: 'ms',
77
- }),
39
+ avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG),
40
+ max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MAX),
41
+ min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MIN),
42
+ p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P50),
43
+ p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_P90),
78
44
  };
79
45
 
80
46
  this.aggValidationMetrics = {
81
- avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_AVG, {
82
- valueType: ValueType.DOUBLE,
83
- description: 'AVG msg validation',
84
- unit: 'ms',
85
- }),
86
- max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MAX, {
87
- valueType: ValueType.DOUBLE,
88
- description: 'MAX msg validation',
89
- unit: 'ms',
90
- }),
91
- min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MIN, {
92
- valueType: ValueType.DOUBLE,
93
- description: 'MIN msg validation',
94
- unit: 'ms',
95
- }),
96
- p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P50, {
97
- valueType: ValueType.DOUBLE,
98
- description: 'P50 msg validation',
99
- unit: 'ms',
100
- }),
101
- p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P90, {
102
- valueType: ValueType.DOUBLE,
103
- description: 'P90 msg validation',
104
- unit: 'ms',
105
- }),
47
+ avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_AVG),
48
+ max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MAX),
49
+ min: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_MIN),
50
+ p50: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P50),
51
+ p90: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_VALIDATION_DURATION_P90),
106
52
  };
107
53
 
108
54
  meter.addBatchObservableCallback(this.aggregate, [
@@ -28,7 +28,14 @@ import { MerkleTreeId } from '@aztec/stdlib/trees';
28
28
  import { Tx, type TxHash, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
29
29
  import type { UInt64 } from '@aztec/stdlib/types';
30
30
  import { compressComponentVersions } from '@aztec/stdlib/versioning';
31
- import { Attributes, OtelMetricsAdapter, type TelemetryClient, WithTracer, trackSpan } from '@aztec/telemetry-client';
31
+ import {
32
+ Attributes,
33
+ OtelMetricsAdapter,
34
+ SpanStatusCode,
35
+ type TelemetryClient,
36
+ WithTracer,
37
+ trackSpan,
38
+ } from '@aztec/telemetry-client';
32
39
 
33
40
  import {
34
41
  type GossipSub,
@@ -144,6 +151,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
144
151
 
145
152
  private instrumentation: P2PInstrumentation;
146
153
 
154
+ private telemetry: TelemetryClient;
155
+
147
156
  protected logger: Logger;
148
157
 
149
158
  constructor(
@@ -162,6 +171,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
162
171
  logger: Logger = createLogger('p2p:libp2p_service'),
163
172
  ) {
164
173
  super(telemetry, 'LibP2PService');
174
+ this.telemetry = telemetry;
165
175
 
166
176
  // Create child logger with fisherman prefix if in fisherman mode
167
177
  this.logger = config.fishermanMode ? logger.createChild('[FISHERMAN]') : logger;
@@ -622,7 +632,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
622
632
  if (!this.node.services.pubsub) {
623
633
  throw new Error('Pubsub service not available.');
624
634
  }
625
- const p2pMessage = P2PMessage.fromGossipable(message, this.config.debugP2PInstrumentMessages);
635
+ const isBlockProposal = topic === this.topicStrings[TopicType.block_proposal];
636
+ const traceContext =
637
+ this.config.debugP2PInstrumentMessages && isBlockProposal ? this.telemetry.getTraceContext() : undefined;
638
+ const p2pMessage = P2PMessage.fromGossipable(message, this.config.debugP2PInstrumentMessages, traceContext);
626
639
  const result = await this.node.services.pubsub.publish(topic, p2pMessage.toMessageData());
627
640
  return result.recipients.length;
628
641
  }
@@ -707,23 +720,70 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
707
720
  return;
708
721
  }
709
722
 
723
+ // Determine topic type for attributes
710
724
  if (msg.topic === this.topicStrings[TopicType.tx]) {
711
725
  topicType = TopicType.tx;
712
- await this.handleGossipedTx(p2pMessage.payload, msgId, source);
713
- }
714
- if (msg.topic === this.topicStrings[TopicType.block_attestation]) {
726
+ } else if (msg.topic === this.topicStrings[TopicType.block_attestation]) {
715
727
  topicType = TopicType.block_attestation;
716
- if (this.clientType === P2PClientType.Full) {
717
- await this.processAttestationFromPeer(p2pMessage.payload, msgId, source);
718
- }
719
- }
720
- if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
728
+ } else if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
721
729
  topicType = TopicType.block_proposal;
722
- await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
723
730
  }
724
731
 
725
- if (p2pMessage.timestamp !== undefined && topicType !== undefined) {
726
- const latency = msgReceivedTime - p2pMessage.timestamp.getTime();
732
+ // Process the message, optionally within a linked span for trace propagation
733
+ const processMessage = async () => {
734
+ if (msg.topic === this.topicStrings[TopicType.tx]) {
735
+ await this.handleGossipedTx(p2pMessage.payload, msgId, source);
736
+ }
737
+ if (msg.topic === this.topicStrings[TopicType.block_attestation]) {
738
+ if (this.clientType === P2PClientType.Full) {
739
+ await this.processAttestationFromPeer(p2pMessage.payload, msgId, source);
740
+ }
741
+ }
742
+ if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
743
+ await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
744
+ }
745
+ };
746
+
747
+ const latency = p2pMessage.timestamp !== undefined ? msgReceivedTime - p2pMessage.timestamp.getTime() : undefined;
748
+ const propagatedContext = p2pMessage.traceContext
749
+ ? this.telemetry.extractPropagatedContext(p2pMessage.traceContext)
750
+ : undefined;
751
+
752
+ if (propagatedContext) {
753
+ await this.tracer.startActiveSpan(
754
+ 'LibP2PService.processMessage',
755
+ {
756
+ attributes: {
757
+ [Attributes.TOPIC_NAME]: topicType!,
758
+ [Attributes.PEER_ID]: source.toString(),
759
+ },
760
+ },
761
+ propagatedContext,
762
+ async span => {
763
+ try {
764
+ await processMessage();
765
+ span.setStatus({
766
+ code: SpanStatusCode.OK,
767
+ });
768
+ } catch (err) {
769
+ span.setStatus({
770
+ code: SpanStatusCode.ERROR,
771
+ message: String(err),
772
+ });
773
+ if (typeof err === 'string' || (err && err instanceof Error)) {
774
+ span.recordException(err);
775
+ }
776
+ throw err;
777
+ } finally {
778
+ span.end();
779
+ }
780
+ },
781
+ );
782
+ } else {
783
+ await processMessage();
784
+ }
785
+
786
+ if (latency !== undefined && topicType !== undefined) {
727
787
  this.instrumentation.recordMessageLatency(topicType, latency);
728
788
  }
729
789
 
@@ -6,7 +6,6 @@ import {
6
6
  type TelemetryClient,
7
7
  type Tracer,
8
8
  type UpDownCounter,
9
- ValueType,
10
9
  getTelemetryClient,
11
10
  } from '@aztec/telemetry-client';
12
11
 
@@ -32,31 +31,11 @@ export class PeerManagerMetrics {
32
31
  this.tracer = telemetryClient.getTracer(name);
33
32
 
34
33
  const meter = telemetryClient.getMeter(name);
35
- this.sentGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_SENT, {
36
- description: 'Number of goodbyes sent to peers',
37
- unit: 'peers',
38
- valueType: ValueType.INT,
39
- });
40
- this.receivedGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_RECEIVED, {
41
- description: 'Number of goodbyes received from peers',
42
- unit: 'peers',
43
- valueType: ValueType.INT,
44
- });
45
- this.peerCount = meter.createGauge(Metrics.PEER_MANAGER_PEER_COUNT, {
46
- description: 'Number of peers',
47
- unit: 'peers',
48
- valueType: ValueType.INT,
49
- });
50
- this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
51
- description: 'Number of peers disconnected due to low score',
52
- unit: 'peers',
53
- valueType: ValueType.INT,
54
- });
55
- this.peerConnectionDuration = meter.createHistogram(Metrics.PEER_MANAGER_PEER_CONNECTION_DURATION, {
56
- description: 'Time duration between peer connection and disconnection',
57
- unit: 'ms',
58
- valueType: ValueType.INT,
59
- });
34
+ this.sentGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_SENT);
35
+ this.receivedGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_RECEIVED);
36
+ this.peerCount = meter.createGauge(Metrics.PEER_MANAGER_PEER_COUNT);
37
+ this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS);
38
+ this.peerConnectionDuration = meter.createHistogram(Metrics.PEER_MANAGER_PEER_CONNECTION_DURATION);
60
39
  }
61
40
 
62
41
  public recordGoodbyeSent(reason: GoodByeReason) {
@@ -7,7 +7,7 @@ import { bufferToHex } from '@aztec/foundation/string';
7
7
  import { DateProvider } from '@aztec/foundation/timer';
8
8
  import type { PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
9
9
  import type { PeerErrorSeverity } from '@aztec/stdlib/p2p';
10
- import { type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
10
+ import type { TelemetryClient } from '@aztec/telemetry-client';
11
11
 
12
12
  import type { Connection, PeerId } from '@libp2p/interface';
13
13
  import { peerIdFromString } from '@libp2p/peer-id';
@@ -161,7 +161,6 @@ export class PeerManager implements PeerManagerInterface {
161
161
  return this.metrics.tracer;
162
162
  }
163
163
 
164
- @trackSpan('PeerManager.heartbeat')
165
164
  public async heartbeat() {
166
165
  this.heartbeatCounter++;
167
166
  this.peerScoring.decayAllScores();