@aztec/p2p 0.76.4 → 0.77.0-testnet-ignition.21

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 (241) hide show
  1. package/dest/bootstrap/bootstrap.d.ts +2 -2
  2. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  3. package/dest/bootstrap/bootstrap.js +55 -41
  4. package/dest/client/factory.d.ts +8 -6
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +8 -10
  7. package/dest/client/index.js +0 -1
  8. package/dest/client/p2p_client.d.ts +7 -4
  9. package/dest/client/p2p_client.d.ts.map +1 -1
  10. package/dest/client/p2p_client.js +492 -514
  11. package/dest/config.d.ts +8 -10
  12. package/dest/config.d.ts.map +1 -1
  13. package/dest/config.js +54 -47
  14. package/dest/enr/generate-enr.d.ts +9 -0
  15. package/dest/enr/generate-enr.d.ts.map +1 -0
  16. package/dest/enr/generate-enr.js +30 -0
  17. package/dest/enr/index.d.ts +2 -0
  18. package/dest/enr/index.d.ts.map +1 -0
  19. package/dest/enr/index.js +1 -0
  20. package/dest/errors/reqresp.error.js +6 -10
  21. package/dest/index.js +0 -1
  22. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +1 -1
  23. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/attestation_pool.js +6 -2
  25. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
  26. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +65 -33
  28. package/dest/mem_pools/attestation_pool/index.js +0 -1
  29. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +3 -3
  30. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
  31. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +23 -20
  32. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +2 -2
  33. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  34. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +22 -26
  35. package/dest/mem_pools/attestation_pool/mocks.d.ts +3 -2
  36. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  37. package/dest/mem_pools/attestation_pool/mocks.js +12 -7
  38. package/dest/mem_pools/index.d.ts +2 -2
  39. package/dest/mem_pools/index.d.ts.map +1 -1
  40. package/dest/mem_pools/index.js +1 -2
  41. package/dest/mem_pools/instrumentation.d.ts +1 -1
  42. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  43. package/dest/mem_pools/instrumentation.js +35 -39
  44. package/dest/mem_pools/interface.d.ts +3 -3
  45. package/dest/mem_pools/interface.d.ts.map +1 -1
  46. package/dest/mem_pools/interface.js +3 -2
  47. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +2 -2
  48. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +129 -136
  50. package/dest/mem_pools/tx_pool/index.js +0 -1
  51. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +2 -2
  52. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  53. package/dest/mem_pools/tx_pool/memory_tx_pool.js +46 -44
  54. package/dest/mem_pools/tx_pool/priority.d.ts +1 -1
  55. package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
  56. package/dest/mem_pools/tx_pool/priority.js +1 -3
  57. package/dest/mem_pools/tx_pool/tx_pool.d.ts +1 -1
  58. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  59. package/dest/mem_pools/tx_pool/tx_pool.js +3 -2
  60. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
  61. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  62. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +109 -39
  63. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +2 -2
  64. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  65. package/dest/msg_validators/attestation_validator/attestation_validator.js +4 -4
  66. package/dest/msg_validators/attestation_validator/index.js +0 -1
  67. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +2 -2
  68. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
  69. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +3 -3
  70. package/dest/msg_validators/block_proposal_validator/index.js +0 -1
  71. package/dest/msg_validators/index.js +0 -1
  72. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
  73. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  74. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +9 -11
  75. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +2 -2
  76. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  77. package/dest/msg_validators/tx_validator/block_header_validator.js +18 -13
  78. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  79. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  80. package/dest/msg_validators/tx_validator/data_validator.js +102 -33
  81. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +1 -1
  82. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  83. package/dest/msg_validators/tx_validator/double_spend_validator.js +34 -20
  84. package/dest/msg_validators/tx_validator/index.js +0 -1
  85. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +2 -2
  86. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  87. package/dest/msg_validators/tx_validator/metadata_validator.js +30 -27
  88. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
  89. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  90. package/dest/msg_validators/tx_validator/tx_proof_validator.js +17 -12
  91. package/dest/services/data_store.js +57 -57
  92. package/dest/services/discv5/discV5_service.d.ts +2 -0
  93. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  94. package/dest/services/discv5/discV5_service.js +64 -36
  95. package/dest/services/dummy_service.d.ts +4 -2
  96. package/dest/services/dummy_service.d.ts.map +1 -1
  97. package/dest/services/dummy_service.js +41 -59
  98. package/dest/services/encoding.d.ts +3 -3
  99. package/dest/services/encoding.d.ts.map +1 -1
  100. package/dest/services/encoding.js +10 -9
  101. package/dest/services/gossipsub/scoring.d.ts +7 -0
  102. package/dest/services/gossipsub/scoring.d.ts.map +1 -0
  103. package/dest/services/gossipsub/scoring.js +10 -0
  104. package/dest/services/index.js +0 -1
  105. package/dest/services/libp2p/libp2p_service.d.ts +10 -33
  106. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  107. package/dest/services/libp2p/libp2p_service.js +682 -673
  108. package/dest/services/peer-manager/metrics.js +14 -7
  109. package/dest/services/peer-manager/peer_manager.d.ts +24 -6
  110. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  111. package/dest/services/peer-manager/peer_manager.js +390 -340
  112. package/dest/services/peer-manager/peer_scoring.d.ts +3 -3
  113. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  114. package/dest/services/peer-manager/peer_scoring.js +21 -19
  115. package/dest/services/reqresp/config.js +4 -5
  116. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +2 -2
  117. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  118. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +35 -28
  119. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -1
  120. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  121. package/dest/services/reqresp/connection-sampler/connection_sampler.js +67 -61
  122. package/dest/services/reqresp/index.js +1 -3
  123. package/dest/services/reqresp/interface.d.ts +2 -2
  124. package/dest/services/reqresp/interface.d.ts.map +1 -1
  125. package/dest/services/reqresp/interface.js +27 -31
  126. package/dest/services/reqresp/metrics.d.ts +1 -1
  127. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  128. package/dest/services/reqresp/metrics.js +23 -10
  129. package/dest/services/reqresp/protocols/block.d.ts +2 -2
  130. package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
  131. package/dest/services/reqresp/protocols/block.js +1 -2
  132. package/dest/services/reqresp/protocols/goodbye.d.ts +5 -5
  133. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  134. package/dest/services/reqresp/protocols/goodbye.js +36 -41
  135. package/dest/services/reqresp/protocols/index.js +1 -3
  136. package/dest/services/reqresp/protocols/ping.js +1 -3
  137. package/dest/services/reqresp/protocols/status.js +1 -3
  138. package/dest/services/reqresp/protocols/tx.d.ts +3 -3
  139. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  140. package/dest/services/reqresp/protocols/tx.js +6 -9
  141. package/dest/services/reqresp/rate-limiter/index.js +0 -1
  142. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +9 -9
  143. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  144. package/dest/services/reqresp/rate-limiter/rate_limiter.js +53 -46
  145. package/dest/services/reqresp/rate-limiter/rate_limits.js +16 -17
  146. package/dest/services/reqresp/reqresp.d.ts +4 -4
  147. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  148. package/dest/services/reqresp/reqresp.js +467 -464
  149. package/dest/services/reqresp/status.js +16 -17
  150. package/dest/services/service.d.ts +3 -2
  151. package/dest/services/service.d.ts.map +1 -1
  152. package/dest/services/service.js +3 -4
  153. package/dest/test-helpers/generate-peer-id-private-keys.js +2 -4
  154. package/dest/test-helpers/get-ports.js +3 -3
  155. package/dest/test-helpers/index.js +0 -1
  156. package/dest/test-helpers/make-enrs.d.ts +1 -1
  157. package/dest/test-helpers/make-enrs.d.ts.map +1 -1
  158. package/dest/test-helpers/make-enrs.js +3 -6
  159. package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -6
  160. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  161. package/dest/test-helpers/make-test-p2p-clients.js +10 -12
  162. package/dest/test-helpers/reqresp-nodes.d.ts +18 -7
  163. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  164. package/dest/test-helpers/reqresp-nodes.js +64 -40
  165. package/dest/testbench/p2p_client_testbench_worker.js +61 -45
  166. package/dest/testbench/parse_log_file.d.ts +2 -0
  167. package/dest/testbench/parse_log_file.d.ts.map +1 -0
  168. package/dest/testbench/parse_log_file.js +131 -0
  169. package/dest/testbench/testbench.d.ts +2 -0
  170. package/dest/testbench/testbench.d.ts.map +1 -0
  171. package/dest/testbench/testbench.js +141 -0
  172. package/dest/{services/types.d.ts → types/index.d.ts} +1 -1
  173. package/dest/types/index.d.ts.map +1 -0
  174. package/dest/types/index.js +28 -0
  175. package/dest/util.d.ts +5 -5
  176. package/dest/util.d.ts.map +1 -1
  177. package/dest/util.js +23 -34
  178. package/dest/versioning.d.ts +3 -3
  179. package/dest/versioning.d.ts.map +1 -1
  180. package/dest/versioning.js +7 -12
  181. package/package.json +15 -13
  182. package/src/bootstrap/bootstrap.ts +30 -17
  183. package/src/client/factory.ts +9 -12
  184. package/src/client/p2p_client.ts +13 -24
  185. package/src/config.ts +14 -15
  186. package/src/enr/generate-enr.ts +39 -0
  187. package/src/enr/index.ts +1 -0
  188. package/src/mem_pools/attestation_pool/attestation_pool.ts +1 -1
  189. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +4 -3
  190. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +3 -3
  191. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +2 -2
  192. package/src/mem_pools/attestation_pool/mocks.ts +5 -5
  193. package/src/mem_pools/index.ts +2 -2
  194. package/src/mem_pools/instrumentation.ts +4 -3
  195. package/src/mem_pools/interface.ts +3 -3
  196. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +4 -4
  197. package/src/mem_pools/tx_pool/memory_tx_pool.ts +3 -3
  198. package/src/mem_pools/tx_pool/priority.ts +1 -1
  199. package/src/mem_pools/tx_pool/tx_pool.ts +1 -1
  200. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +4 -3
  201. package/src/msg_validators/attestation_validator/attestation_validator.ts +2 -2
  202. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +2 -2
  203. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +1 -1
  204. package/src/msg_validators/tx_validator/block_header_validator.ts +2 -2
  205. package/src/msg_validators/tx_validator/data_validator.ts +57 -4
  206. package/src/msg_validators/tx_validator/double_spend_validator.ts +17 -12
  207. package/src/msg_validators/tx_validator/metadata_validator.ts +2 -2
  208. package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -6
  209. package/src/services/discv5/discV5_service.ts +33 -8
  210. package/src/services/dummy_service.ts +4 -2
  211. package/src/services/encoding.ts +3 -3
  212. package/src/services/gossipsub/scoring.ts +13 -0
  213. package/src/services/libp2p/libp2p_service.ts +124 -146
  214. package/src/services/peer-manager/peer_manager.ts +71 -13
  215. package/src/services/peer-manager/peer_scoring.ts +3 -3
  216. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +2 -2
  217. package/src/services/reqresp/connection-sampler/connection_sampler.ts +9 -3
  218. package/src/services/reqresp/interface.ts +4 -3
  219. package/src/services/reqresp/metrics.ts +1 -1
  220. package/src/services/reqresp/protocols/block.ts +3 -3
  221. package/src/services/reqresp/protocols/goodbye.ts +7 -7
  222. package/src/services/reqresp/protocols/tx.ts +5 -5
  223. package/src/services/reqresp/rate-limiter/rate_limiter.ts +22 -18
  224. package/src/services/reqresp/reqresp.ts +18 -11
  225. package/src/services/service.ts +3 -2
  226. package/src/test-helpers/make-enrs.ts +1 -1
  227. package/src/test-helpers/make-test-p2p-clients.ts +9 -7
  228. package/src/test-helpers/reqresp-nodes.ts +32 -18
  229. package/src/testbench/p2p_client_testbench_worker.ts +16 -9
  230. package/src/testbench/parse_log_file.ts +175 -0
  231. package/src/testbench/testbench.ts +157 -0
  232. package/src/util.ts +5 -5
  233. package/src/versioning.ts +7 -7
  234. package/dest/services/libp2p/libp2p_logger.d.ts +0 -7
  235. package/dest/services/libp2p/libp2p_logger.d.ts.map +0 -1
  236. package/dest/services/libp2p/libp2p_logger.js +0 -67
  237. package/dest/services/types.d.ts.map +0 -1
  238. package/dest/services/types.js +0 -35
  239. package/src/services/libp2p/libp2p_logger.ts +0 -78
  240. package/src/testbench/scripts/run_testbench.sh +0 -7
  241. /package/src/{services/types.ts → types/index.ts} +0 -0
@@ -1,31 +1,26 @@
1
+ import type { EpochCacheInterface } from '@aztec/epoch-cache';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import { createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
4
+ import { SerialQueue } from '@aztec/foundation/queue';
5
+ import { RunningPromise } from '@aztec/foundation/running-promise';
6
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
7
+ import type { L2BlockSource } from '@aztec/stdlib/block';
8
+ import type { ClientProtocolCircuitVerifier, PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
1
9
  import {
2
10
  BlockAttestation,
3
11
  BlockProposal,
4
- type ClientProtocolCircuitVerifier,
5
12
  type Gossipable,
6
- type L2BlockSource,
7
- MerkleTreeId,
8
13
  P2PClientType,
9
14
  PeerErrorSeverity,
10
- type PeerInfo,
11
- type RawGossipMessage,
12
15
  TopicTypeMap,
13
- Tx,
14
- type TxHash,
15
- type TxValidationResult,
16
- type WorldStateSynchronizer,
17
16
  getTopicTypeForClientType,
18
17
  metricsTopicStrToLabels,
19
- } from '@aztec/circuit-types';
20
- import { Fr } from '@aztec/circuits.js';
21
- import { type EpochCacheInterface } from '@aztec/epoch-cache';
22
- import { createLogger } from '@aztec/foundation/log';
23
- import { SerialQueue } from '@aztec/foundation/queue';
24
- import { RunningPromise } from '@aztec/foundation/running-promise';
25
- import type { AztecAsyncKVStore } from '@aztec/kv-store';
18
+ } from '@aztec/stdlib/p2p';
19
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
20
+ import { Tx, type TxHash, type TxValidationResult } from '@aztec/stdlib/tx';
26
21
  import { Attributes, OtelMetricsAdapter, type TelemetryClient, WithTracer, trackSpan } from '@aztec/telemetry-client';
27
22
 
28
- import { type ENR } from '@chainsafe/enr';
23
+ import type { ENR } from '@chainsafe/enr';
29
24
  import {
30
25
  type GossipSub,
31
26
  type GossipSubComponents,
@@ -39,14 +34,14 @@ import { yamux } from '@chainsafe/libp2p-yamux';
39
34
  import { bootstrap } from '@libp2p/bootstrap';
40
35
  import { identify } from '@libp2p/identify';
41
36
  import { type Message, type PeerId, TopicValidatorResult } from '@libp2p/interface';
42
- import { type ConnectionManager } from '@libp2p/interface-internal';
37
+ import type { ConnectionManager } from '@libp2p/interface-internal';
43
38
  import '@libp2p/kad-dht';
44
39
  import { mplex } from '@libp2p/mplex';
45
40
  import { tcp } from '@libp2p/tcp';
46
41
  import { createLibp2p } from 'libp2p';
47
42
 
48
- import { type P2PConfig } from '../../config.js';
49
- import { type MemPools } from '../../mem_pools/interface.js';
43
+ import type { P2PConfig } from '../../config.js';
44
+ import type { MemPools } from '../../mem_pools/interface.js';
50
45
  import { AttestationValidator, BlockProposalValidator } from '../../msg_validators/index.js';
51
46
  import {
52
47
  DataTxValidator,
@@ -54,9 +49,11 @@ import {
54
49
  MetadataTxValidator,
55
50
  TxProofValidator,
56
51
  } from '../../msg_validators/tx_validator/index.js';
52
+ import { GossipSubEvent } from '../../types/index.js';
57
53
  import { type PubSubLibp2p, convertToMultiaddr } from '../../util.js';
58
54
  import { AztecDatastore } from '../data_store.js';
59
55
  import { SnappyTransform, fastMsgIdFn, getMsgIdFn, msgIdToStrFn } from '../encoding.js';
56
+ import { gossipScoreThresholds } from '../gossipsub/scoring.js';
60
57
  import { PeerManager } from '../peer-manager/peer_manager.js';
61
58
  import { PeerScoring } from '../peer-manager/peer_scoring.js';
62
59
  import { DEFAULT_SUB_PROTOCOL_VALIDATORS, ReqRespSubProtocol, type SubProtocolMap } from '../reqresp/interface.js';
@@ -64,8 +61,6 @@ import { reqGoodbyeHandler } from '../reqresp/protocols/goodbye.js';
64
61
  import { pingHandler, reqRespBlockHandler, reqRespTxHandler, statusHandler } from '../reqresp/protocols/index.js';
65
62
  import { ReqResp } from '../reqresp/reqresp.js';
66
63
  import type { P2PService, PeerDiscoveryService } from '../service.js';
67
- import { GossipSubEvent } from '../types.js';
68
- import { createLibp2pComponentLogger } from './libp2p_logger.js';
69
64
 
70
65
  interface MessageValidator {
71
66
  validator: {
@@ -211,9 +206,9 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
211
206
  connectionEncryption: [noise()],
212
207
  connectionManager: {
213
208
  minConnections: 0,
214
- maxConnections: maxPeerCount,
215
209
 
216
210
  maxParallelDials: 100,
211
+ dialTimeout: 30_000,
217
212
  maxPeerAddrsToDial: 5,
218
213
  maxIncomingPendingConnections: 5,
219
214
  },
@@ -233,8 +228,6 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
233
228
  heartbeatInterval: config.gossipsubInterval,
234
229
  mcacheLength: config.gossipsubMcacheLength,
235
230
  mcacheGossip: config.gossipsubMcacheGossip,
236
- // Increased from default 3s to give time for input lag: configuration and rationale from lodestar
237
- gossipsubIWantFollowupMs: 12 * 1000,
238
231
  msgIdFn: getMsgIdFn,
239
232
  msgIdToStrFn: msgIdToStrFn,
240
233
  fastMsgIdFn: fastMsgIdFn,
@@ -242,6 +235,7 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
242
235
  metricsRegister: otelMetricsAdapter,
243
236
  metricsTopicStrToLabel: metricsTopicStrToLabels(),
244
237
  asyncValidation: true,
238
+ scoreThresholds: gossipScoreThresholds,
245
239
  scoreParams: createPeerScoreParams({
246
240
  // IPColocation factor can be disabled for local testing - default to -5
247
241
  IPColocationFactorWeight: config.debugDisableColocationPenalty ? 0 : -5.0,
@@ -256,7 +250,7 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
256
250
  invalidMessageDeliveriesWeight: -20,
257
251
  invalidMessageDeliveriesDecay: 0.5,
258
252
  }),
259
- [BlockAttestation.p2pTopic]: createTopicScoreParams({
253
+ [BlockProposal.p2pTopic]: createTopicScoreParams({
260
254
  topicWeight: 1,
261
255
  invalidMessageDeliveriesWeight: -20,
262
256
  invalidMessageDeliveriesDecay: 0.5,
@@ -268,8 +262,7 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
268
262
  connectionManager: components.connectionManager,
269
263
  }),
270
264
  },
271
- // Fix the peer id in libp2p logs so we can see the source of the log
272
- logger: createLibp2pComponentLogger(logger.module, { sourcePeerId: peerId }),
265
+ logger: createLibp2pComponentLogger(logger.module),
273
266
  });
274
267
 
275
268
  return new LibP2PService(
@@ -327,26 +320,6 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
327
320
  [ReqRespSubProtocol.BLOCK]: blockHandler.bind(this),
328
321
  };
329
322
 
330
- // Add p2p topic validators
331
- // As they are stored within a kv pair, there is no need to register them conditionally
332
- // based on the client type
333
- const topicValidators = {
334
- [Tx.p2pTopic]: this.validatePropagatedTxFromMessage.bind(this),
335
- [BlockAttestation.p2pTopic]: this.validatePropagatedAttestationFromMessage.bind(this),
336
- [BlockProposal.p2pTopic]: this.validatePropagatedBlockFromMessage.bind(this),
337
- };
338
- // When running bandwidth benchmarks, we use send blobs of data we do not want to validate
339
- // NEVER switch this off in production
340
- if (!this.config.debugDisableMessageValidation) {
341
- for (const [topic, validator] of Object.entries(topicValidators)) {
342
- this.node.services.pubsub.topicValidators.set(topic, validator);
343
- }
344
- } else {
345
- this.logger.warn(
346
- 'MESSAGE VALIDATION DISABLED - IF YOU SEE THIS LOG AND ARE NOT DEBUGGING AND ARE RUNNING IN A PRODUCTION ENVIRONMENT, PLEASE RE-ENABLE MESSAGE VALIDATION',
347
- );
348
- }
349
-
350
323
  // add GossipSub listener
351
324
  this.node.services.pubsub.addEventListener(GossipSubEvent.MESSAGE, this.handleGossipSubEvent.bind(this));
352
325
 
@@ -402,12 +375,16 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
402
375
  }
403
376
 
404
377
  private handleGossipSubEvent(e: CustomEvent<GossipsubMessage>) {
405
- const { msg } = e.detail;
406
378
  this.logger.trace(`Received PUBSUB message.`);
407
379
 
408
- void this.jobQueue
409
- .put(() => this.handleNewGossipMessage(msg))
410
- .catch(err => this.logger.error(`Error processing gossip message`, err));
380
+ const safeJob = async () => {
381
+ try {
382
+ await this.handleNewGossipMessage(e.detail.msg, e.detail.msgId, e.detail.propagationSource);
383
+ } catch (err) {
384
+ this.logger.error(`Error handling gossipsub message: ${err}`);
385
+ }
386
+ };
387
+ setImmediate(() => void safeJob());
411
388
  }
412
389
 
413
390
  /**
@@ -484,35 +461,81 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
484
461
  * @param topic - The message's topic.
485
462
  * @param data - The message data
486
463
  */
487
- private async handleNewGossipMessage(message: RawGossipMessage) {
488
- if (message.topic === Tx.p2pTopic) {
489
- const tx = Tx.fromBuffer(Buffer.from(message.data));
490
- await this.processTxFromPeer(tx);
464
+ private async handleNewGossipMessage(msg: Message, msgId: string, source: PeerId) {
465
+ if (msg.topic === Tx.p2pTopic) {
466
+ await this.handleGossipedTx(msg, msgId, source);
491
467
  }
492
- if (message.topic === BlockAttestation.p2pTopic && this.clientType === P2PClientType.Full) {
493
- const attestation = BlockAttestation.fromBuffer(Buffer.from(message.data));
494
- await this.processAttestationFromPeer(attestation);
468
+ if (msg.topic === BlockAttestation.p2pTopic && this.clientType === P2PClientType.Full) {
469
+ await this.processAttestationFromPeer(msg, msgId, source);
495
470
  }
496
- if (message.topic == BlockProposal.p2pTopic) {
497
- const block = BlockProposal.fromBuffer(Buffer.from(message.data));
498
- await this.processBlockFromPeer(block);
471
+ if (msg.topic == BlockProposal.p2pTopic) {
472
+ await this.processBlockFromPeer(msg, msgId, source);
499
473
  }
500
474
 
501
475
  return;
502
476
  }
503
477
 
478
+ private async validateReceivedMessage<T>(
479
+ validationFunc: () => Promise<{ result: boolean; obj: T }>,
480
+ msgId: string,
481
+ source: PeerId,
482
+ ): Promise<{ result: boolean; obj: T | undefined }> {
483
+ let resultAndObj: { result: boolean; obj: T | undefined } = { result: false, obj: undefined };
484
+ try {
485
+ resultAndObj = await validationFunc();
486
+ } catch (err) {
487
+ this.logger.error(`Error deserialising and validating message `, err);
488
+ }
489
+
490
+ this.node.services.pubsub.reportMessageValidationResult(
491
+ msgId,
492
+ source.toString(),
493
+ resultAndObj.result && resultAndObj.obj ? TopicValidatorResult.Accept : TopicValidatorResult.Reject,
494
+ );
495
+ return resultAndObj;
496
+ }
497
+
498
+ private async handleGossipedTx(msg: Message, msgId: string, source: PeerId) {
499
+ const validationFunc = async () => {
500
+ const tx = Tx.fromBuffer(Buffer.from(msg.data));
501
+ const result = await this.validatePropagatedTx(tx, source);
502
+ return { result, obj: tx };
503
+ };
504
+
505
+ const { result, obj: tx } = await this.validateReceivedMessage<Tx>(validationFunc, msgId, source);
506
+ if (!result || !tx) {
507
+ return;
508
+ }
509
+ const txHash = await tx.getTxHash();
510
+ const txHashString = txHash.toString();
511
+ this.logger.verbose(`Received tx ${txHashString} from external peer ${source.toString()}.`);
512
+ await this.mempools.txPool.addTxs([tx]);
513
+ }
514
+
504
515
  /**Process Attestation From Peer
505
516
  * When a proposal is received from a peer, we add it to the attestation pool, so it can be accessed by other services.
506
517
  *
507
518
  * @param attestation - The attestation to process.
508
519
  */
509
- @trackSpan('Libp2pService.processAttestationFromPeer', async attestation => ({
510
- [Attributes.BLOCK_NUMBER]: attestation.payload.header.globalVariables.blockNumber.toNumber(),
511
- [Attributes.SLOT_NUMBER]: attestation.payload.header.globalVariables.slotNumber.toNumber(),
512
- [Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
513
- [Attributes.P2P_ID]: await attestation.p2pMessageIdentifier().then(i => i.toString()),
514
- }))
515
- private async processAttestationFromPeer(attestation: BlockAttestation): Promise<void> {
520
+ private async processAttestationFromPeer(msg: Message, msgId: string, source: PeerId): Promise<void> {
521
+ const validationFunc = async () => {
522
+ const attestation = BlockAttestation.fromBuffer(Buffer.from(msg.data));
523
+ const result = await this.validateAttestation(source, attestation);
524
+ this.logger.trace(`validatePropagatedAttestation: ${result}`, {
525
+ [Attributes.SLOT_NUMBER]: attestation.payload.header.globalVariables.slotNumber.toString(),
526
+ [Attributes.P2P_ID]: source.toString(),
527
+ });
528
+ return { result, obj: attestation };
529
+ };
530
+
531
+ const { result, obj: attestation } = await this.validateReceivedMessage<BlockAttestation>(
532
+ validationFunc,
533
+ msgId,
534
+ source,
535
+ );
536
+ if (!result || !attestation) {
537
+ return;
538
+ }
516
539
  this.logger.debug(
517
540
  `Received attestation for block ${attestation.blockNumber.toNumber()} slot ${attestation.slotNumber.toNumber()} from external peer.`,
518
541
  {
@@ -525,20 +548,32 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
525
548
  await this.mempools.attestationPool!.addAttestations([attestation]);
526
549
  }
527
550
 
528
- /**Process block from peer
529
- *
530
- * Pass the received block to the validator client
531
- *
532
- * @param block - The block to process.
533
- */
551
+ private async processBlockFromPeer(msg: Message, msgId: string, source: PeerId): Promise<void> {
552
+ const validationFunc = async () => {
553
+ const block = BlockProposal.fromBuffer(Buffer.from(msg.data));
554
+ const result = await this.validateBlockProposal(source, block);
555
+ this.logger.trace(`validatePropagatedBlock: ${result}`, {
556
+ [Attributes.SLOT_NUMBER]: block.payload.header.globalVariables.slotNumber.toString(),
557
+ [Attributes.P2P_ID]: source.toString(),
558
+ });
559
+ return { result, obj: block };
560
+ };
561
+
562
+ const { result, obj: block } = await this.validateReceivedMessage<BlockProposal>(validationFunc, msgId, source);
563
+ if (!result || !block) {
564
+ return;
565
+ }
566
+ await this.processValidBlockProposal(block);
567
+ }
568
+
534
569
  // REVIEW: callback pattern https://github.com/AztecProtocol/aztec-packages/issues/7963
535
- @trackSpan('Libp2pService.processBlockFromPeer', async block => ({
570
+ @trackSpan('Libp2pService.processValidBlockProposal', async block => ({
536
571
  [Attributes.BLOCK_NUMBER]: block.blockNumber.toNumber(),
537
572
  [Attributes.SLOT_NUMBER]: block.slotNumber.toNumber(),
538
573
  [Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
539
574
  [Attributes.P2P_ID]: await block.p2pMessageIdentifier().then(i => i.toString()),
540
575
  }))
541
- private async processBlockFromPeer(block: BlockProposal): Promise<void> {
576
+ private async processValidBlockProposal(block: BlockProposal) {
542
577
  this.logger.verbose(
543
578
  `Received block ${block.blockNumber.toNumber()} for slot ${block.slotNumber.toNumber()} from external peer.`,
544
579
  {
@@ -587,16 +622,13 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
587
622
  public async propagate<T extends Gossipable>(message: T) {
588
623
  const p2pMessageIdentifier = await message.p2pMessageIdentifier();
589
624
  this.logger.trace(`Message ${p2pMessageIdentifier} queued`, { p2pMessageIdentifier });
590
- void this.jobQueue.put(async () => {
591
- await this.sendToPeers(message);
592
- });
593
- }
594
-
595
- private async processTxFromPeer(tx: Tx): Promise<void> {
596
- const txHash = await tx.getTxHash();
597
- const txHashString = txHash.toString();
598
- this.logger.verbose(`Received tx ${txHashString} from external peer.`);
599
- await this.mempools.txPool.addTxs([tx]);
625
+ void this.jobQueue
626
+ .put(async () => {
627
+ await this.sendToPeers(message);
628
+ })
629
+ .catch(error => {
630
+ this.logger.error(`Error propagating message ${p2pMessageIdentifier}`, { error });
631
+ });
600
632
  }
601
633
 
602
634
  /**
@@ -636,63 +668,6 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
636
668
  return true;
637
669
  }
638
670
 
639
- /**
640
- * Validate a tx from a peer.
641
- * @param propagationSource - The peer ID of the peer that sent the tx.
642
- * @param msg - The tx message.
643
- * @returns True if the tx is valid, false otherwise.
644
- */
645
- private async validatePropagatedTxFromMessage(
646
- propagationSource: PeerId,
647
- msg: Message,
648
- ): Promise<TopicValidatorResult> {
649
- const tx = Tx.fromBuffer(Buffer.from(msg.data));
650
- const isValid = await this.validatePropagatedTx(tx, propagationSource);
651
- this.logger.trace(`validatePropagatedTx: ${isValid}`, {
652
- [Attributes.TX_HASH]: (await tx.getTxHash()).toString(),
653
- [Attributes.P2P_ID]: propagationSource.toString(),
654
- });
655
- return isValid ? TopicValidatorResult.Accept : TopicValidatorResult.Reject;
656
- }
657
-
658
- /**
659
- * Validate an attestation from a peer.
660
- * @param propagationSource - The peer ID of the peer that sent the attestation.
661
- * @param msg - The attestation message.
662
- * @returns True if the attestation is valid, false otherwise.
663
- */
664
- private async validatePropagatedAttestationFromMessage(
665
- propagationSource: PeerId,
666
- msg: Message,
667
- ): Promise<TopicValidatorResult> {
668
- const attestation = BlockAttestation.fromBuffer(Buffer.from(msg.data));
669
- const isValid = await this.validateAttestation(propagationSource, attestation);
670
- this.logger.trace(`validatePropagatedAttestation: ${isValid}`, {
671
- [Attributes.SLOT_NUMBER]: attestation.payload.header.globalVariables.slotNumber.toString(),
672
- [Attributes.P2P_ID]: propagationSource.toString(),
673
- });
674
- return isValid ? TopicValidatorResult.Accept : TopicValidatorResult.Reject;
675
- }
676
-
677
- /**
678
- * Validate a block proposal from a peer.
679
- * @param propagationSource - The peer ID of the peer that sent the block.
680
- * @param msg - The block proposal message.
681
- * @returns True if the block proposal is valid, false otherwise.
682
- */
683
- private async validatePropagatedBlockFromMessage(
684
- propagationSource: PeerId,
685
- msg: Message,
686
- ): Promise<TopicValidatorResult> {
687
- const block = BlockProposal.fromBuffer(Buffer.from(msg.data));
688
- const isValid = await this.validateBlockProposal(propagationSource, block);
689
- this.logger.trace(`validatePropagatedBlock: ${isValid}`, {
690
- [Attributes.SLOT_NUMBER]: block.payload.header.globalVariables.slotNumber.toString(),
691
- [Attributes.P2P_ID]: propagationSource.toString(),
692
- });
693
- return isValid ? TopicValidatorResult.Accept : TopicValidatorResult.Reject;
694
- }
695
-
696
671
  @trackSpan('Libp2pService.validatePropagatedTx', async tx => ({
697
672
  [Attributes.TX_HASH]: (await tx.getTxHash()).toString(),
698
673
  }))
@@ -832,8 +807,11 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
832
807
  * @param attestation - The attestation to validate.
833
808
  * @returns True if the attestation is valid, false otherwise.
834
809
  */
835
- @trackSpan('Libp2pService.validateAttestation', (_peerId, attestation) => ({
836
- [Attributes.SLOT_NUMBER]: attestation.payload.header.globalVariables.slotNumber.toString(),
810
+ @trackSpan('Libp2pService.validateAttestation', async (_, attestation) => ({
811
+ [Attributes.BLOCK_NUMBER]: attestation.payload.header.globalVariables.blockNumber.toNumber(),
812
+ [Attributes.SLOT_NUMBER]: attestation.payload.header.globalVariables.slotNumber.toNumber(),
813
+ [Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
814
+ [Attributes.P2P_ID]: await attestation.p2pMessageIdentifier().then(i => i.toString()),
837
815
  }))
838
816
  public async validateAttestation(peerId: PeerId, attestation: BlockAttestation): Promise<boolean> {
839
817
  const severity = await this.attestationValidator.validate(attestation);
@@ -1,19 +1,20 @@
1
- import { type PeerErrorSeverity, type PeerInfo } from '@aztec/circuit-types';
2
1
  import { createLogger } from '@aztec/foundation/log';
2
+ import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
+ import type { PeerErrorSeverity } from '@aztec/stdlib/p2p';
3
4
  import { type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
4
5
 
5
- import { type ENR } from '@chainsafe/enr';
6
- import { type Connection, type PeerId } from '@libp2p/interface';
7
- import { type Multiaddr } from '@multiformats/multiaddr';
6
+ import type { ENR } from '@chainsafe/enr';
7
+ import type { Connection, PeerId } from '@libp2p/interface';
8
+ import type { Multiaddr } from '@multiformats/multiaddr';
8
9
  import { inspect } from 'util';
9
10
 
10
- import { type P2PConfig } from '../../config.js';
11
- import { type PubSubLibp2p } from '../../util.js';
11
+ import type { P2PConfig } from '../../config.js';
12
+ import { PeerEvent } from '../../types/index.js';
13
+ import type { PubSubLibp2p } from '../../util.js';
12
14
  import { ReqRespSubProtocol } from '../reqresp/interface.js';
13
15
  import { GoodByeReason, prettyGoodbyeReason } from '../reqresp/protocols/goodbye.js';
14
- import { type ReqResp } from '../reqresp/reqresp.js';
15
- import { type PeerDiscoveryService } from '../service.js';
16
- import { PeerEvent } from '../types.js';
16
+ import type { ReqResp } from '../reqresp/reqresp.js';
17
+ import type { PeerDiscoveryService } from '../service.js';
17
18
  import { PeerManagerMetrics } from './metrics.js';
18
19
  import { PeerScoreState, type PeerScoring } from './peer_scoring.js';
19
20
 
@@ -189,14 +190,14 @@ export class PeerManager {
189
190
  private discover() {
190
191
  const connections = this.libP2PNode.getConnections();
191
192
 
192
- const healthyConnections = this.pruneUnhealthyPeers(connections);
193
+ const healthyConnections = this.prioritizePeers(this.pruneUnhealthyPeers(this.pruneDuplicatePeers(connections)));
193
194
 
194
195
  // Calculate how many connections we're looking to make
195
196
  const peersToConnect = this.config.maxPeerCount - healthyConnections.length;
196
197
 
197
198
  const logLevel = this.heartbeatCounter % this.displayPeerCountsPeerHeartbeat === 0 ? 'info' : 'debug';
198
- this.logger[logLevel](`Connected to ${connections.length} peers`, {
199
- connections: connections.length,
199
+ this.logger[logLevel](`Connected to ${healthyConnections.length} peers`, {
200
+ connections: healthyConnections.length,
200
201
  maxPeerCount: this.config.maxPeerCount,
201
202
  cachedPeers: this.cachedPeers.size,
202
203
  ...this.peerScoring.getStats(),
@@ -257,7 +258,7 @@ export class PeerManager {
257
258
  void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.BANNED);
258
259
  break;
259
260
  case PeerScoreState.Disconnect:
260
- void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.DISCONNECTED);
261
+ void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.LOW_SCORE);
261
262
  break;
262
263
  case PeerScoreState.Healthy:
263
264
  connectedHealthyPeers.push(peer);
@@ -267,6 +268,63 @@ export class PeerManager {
267
268
  return connectedHealthyPeers;
268
269
  }
269
270
 
271
+ /**
272
+ * If the max peer count is reached, the lowest scoring peers will be pruned to satisfy the max peer count.
273
+ *
274
+ * @param connections - The list of connections to prune low scoring peers above the max peer count from.
275
+ * @returns The pruned list of connections.
276
+ */
277
+ private prioritizePeers(connections: Connection[]): Connection[] {
278
+ if (connections.length > this.config.maxPeerCount) {
279
+ // Sort the peer scores from lowest to highest
280
+ const prioritizedConnections = connections.sort((connectionA, connectionB) => {
281
+ const connectionScoreA = this.peerScoring.getScore(connectionA.remotePeer.toString());
282
+ const connectionScoreB = this.peerScoring.getScore(connectionB.remotePeer.toString());
283
+ return connectionScoreB - connectionScoreA;
284
+ });
285
+
286
+ // Disconnect from the lowest scoring connections.
287
+ for (const conn of prioritizedConnections.slice(this.config.maxPeerCount)) {
288
+ void this.goodbyeAndDisconnectPeer(conn.remotePeer, GoodByeReason.MAX_PEERS);
289
+ }
290
+ return prioritizedConnections.slice(0, this.config.maxPeerCount);
291
+ } else {
292
+ return connections;
293
+ }
294
+ }
295
+
296
+ /**
297
+ * If multiple connections to the same peer are found, the oldest connection is kept and the duplicates are pruned.
298
+ *
299
+ * This is necessary to resolve a race condition where multiple connections to the same peer are established if
300
+ * they are discovered at the same time.
301
+ *
302
+ * @param connections - The list of connections to prune duplicate peers from.
303
+ * @returns The pruned list of connections.
304
+ */
305
+ private pruneDuplicatePeers(connections: Connection[]): Connection[] {
306
+ const peerConnections = new Map<string, Connection>();
307
+
308
+ for (const conn of connections) {
309
+ const peerId = conn.remotePeer.toString();
310
+ const existingConnection = peerConnections.get(peerId);
311
+ if (!existingConnection) {
312
+ peerConnections.set(peerId, conn);
313
+ } else {
314
+ // Keep the oldest connection for each peer
315
+ this.logger.debug(`Found duplicate connection to peer ${peerId}, keeping oldest connection`);
316
+ if (conn.timeline.open < existingConnection.timeline.open) {
317
+ peerConnections.set(peerId, conn);
318
+ void existingConnection.close();
319
+ } else {
320
+ void conn.close();
321
+ }
322
+ }
323
+ }
324
+
325
+ return [...peerConnections.values()];
326
+ }
327
+
270
328
  private async goodbyeAndDisconnectPeer(peer: PeerId, reason: GoodByeReason) {
271
329
  this.logger.debug(`Disconnecting peer ${peer.toString()} with reason ${prettyGoodbyeReason(reason)}`);
272
330
 
@@ -1,10 +1,10 @@
1
- import { PeerErrorSeverity } from '@aztec/circuit-types';
2
1
  import { median } from '@aztec/foundation/collection';
3
2
  import { createLogger } from '@aztec/foundation/log';
3
+ import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
4
4
 
5
- import { type PeerId } from '@libp2p/interface';
5
+ import type { PeerId } from '@libp2p/interface';
6
6
 
7
- import { type P2PConfig } from '../../config.js';
7
+ import type { P2PConfig } from '../../config.js';
8
8
 
9
9
  const DefaultPeerPenalties = {
10
10
  [PeerErrorSeverity.LowToleranceError]: 50,
@@ -1,8 +1,8 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
 
3
- import { type PeerId } from '@libp2p/interface';
3
+ import type { PeerId } from '@libp2p/interface';
4
4
 
5
- import { type ConnectionSampler } from './connection_sampler.js';
5
+ import type { ConnectionSampler } from './connection_sampler.js';
6
6
 
7
7
  /**
8
8
  * Manages batches of peers for parallel request processing.
@@ -1,7 +1,7 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
  import { SerialQueue } from '@aztec/foundation/queue';
3
3
 
4
- import { type Libp2p, type PeerId, type Stream } from '@libp2p/interface';
4
+ import type { Libp2p, PeerId, Stream } from '@libp2p/interface';
5
5
 
6
6
  const MAX_SAMPLE_ATTEMPTS = 4;
7
7
 
@@ -170,7 +170,13 @@ export class ConnectionSampler {
170
170
  */
171
171
  async close(streamId: string): Promise<void> {
172
172
  try {
173
- const { stream, peerId } = this.streams.get(streamId)!;
173
+ const streamAndPeerId = this.streams.get(streamId);
174
+ if (!streamAndPeerId) {
175
+ this.logger.warn(`Stream ${streamId} not found`);
176
+ return;
177
+ }
178
+
179
+ const { stream, peerId } = streamAndPeerId;
174
180
 
175
181
  const updatedActiveConnectionsCount = (this.activeConnectionsCount.get(peerId) ?? 1) - 1;
176
182
  this.activeConnectionsCount.set(peerId, updatedActiveConnectionsCount);
@@ -184,7 +190,7 @@ export class ConnectionSampler {
184
190
 
185
191
  await stream?.close();
186
192
  } catch (error) {
187
- this.logger.warn(`Failed to close connection to peer with stream id ${streamId}`);
193
+ this.logger.error(`Failed to close connection to peer with stream id ${streamId}`, error);
188
194
  } finally {
189
195
  this.streams.delete(streamId);
190
196
  }
@@ -1,9 +1,10 @@
1
- import { L2Block, Tx, TxHash } from '@aztec/circuit-types';
2
1
  import { Fr } from '@aztec/foundation/fields';
2
+ import { L2Block } from '@aztec/stdlib/block';
3
+ import { Tx, TxHash } from '@aztec/stdlib/tx';
3
4
 
4
- import { type PeerId } from '@libp2p/interface';
5
+ import type { PeerId } from '@libp2p/interface';
5
6
 
6
- import { type ReqRespStatus } from './status.js';
7
+ import type { ReqRespStatus } from './status.js';
7
8
 
8
9
  /*
9
10
  * Request Response Sub Protocols
@@ -1,6 +1,6 @@
1
1
  // Request response metrics
2
2
  import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
3
- import { type TelemetryClient, type Tracer, type UpDownCounter } from '@aztec/telemetry-client';
3
+ import type { TelemetryClient, Tracer, UpDownCounter } from '@aztec/telemetry-client';
4
4
 
5
5
  export class ReqRespMetrics {
6
6
  public readonly tracer: Tracer;
@@ -1,9 +1,9 @@
1
- import { type L2BlockSource } from '@aztec/circuit-types';
2
1
  import { Fr } from '@aztec/foundation/fields';
2
+ import type { L2BlockSource } from '@aztec/stdlib/block';
3
3
 
4
- import { type PeerId } from '@libp2p/interface';
4
+ import type { PeerId } from '@libp2p/interface';
5
5
 
6
- import { type ReqRespSubProtocolHandler } from '../interface.js';
6
+ import type { ReqRespSubProtocolHandler } from '../interface.js';
7
7
 
8
8
  export function reqRespBlockHandler(l2BlockSource: L2BlockSource): ReqRespSubProtocolHandler {
9
9
  return async (_peerId: PeerId, msg: Buffer) => {