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

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 (334) hide show
  1. package/dest/bootstrap/bootstrap.d.ts +1 -1
  2. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  3. package/dest/bootstrap/bootstrap.js +14 -4
  4. package/dest/client/factory.d.ts +3 -2
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +9 -5
  7. package/dest/client/index.d.ts +1 -1
  8. package/dest/client/interface.d.ts +8 -6
  9. package/dest/client/interface.d.ts.map +1 -1
  10. package/dest/client/p2p_client.d.ts +12 -35
  11. package/dest/client/p2p_client.d.ts.map +1 -1
  12. package/dest/client/p2p_client.js +457 -61
  13. package/dest/config.d.ts +67 -61
  14. package/dest/config.d.ts.map +1 -1
  15. package/dest/config.js +28 -15
  16. package/dest/enr/generate-enr.d.ts +2 -2
  17. package/dest/enr/generate-enr.d.ts.map +1 -1
  18. package/dest/enr/generate-enr.js +1 -1
  19. package/dest/enr/index.d.ts +1 -1
  20. package/dest/errors/attestation-pool.error.d.ts +7 -0
  21. package/dest/errors/attestation-pool.error.d.ts.map +1 -0
  22. package/dest/errors/attestation-pool.error.js +12 -0
  23. package/dest/errors/reqresp.error.d.ts +1 -1
  24. package/dest/errors/reqresp.error.d.ts.map +1 -1
  25. package/dest/index.d.ts +1 -1
  26. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +43 -6
  27. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  28. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
  29. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +72 -46
  31. package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
  32. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +15 -6
  33. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
  34. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +73 -18
  35. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +13 -6
  36. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  37. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +69 -11
  38. package/dest/mem_pools/attestation_pool/mocks.d.ts +226 -5
  39. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  40. package/dest/mem_pools/attestation_pool/mocks.js +9 -7
  41. package/dest/mem_pools/index.d.ts +1 -1
  42. package/dest/mem_pools/instrumentation.d.ts +9 -1
  43. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  44. package/dest/mem_pools/instrumentation.js +38 -2
  45. package/dest/mem_pools/interface.d.ts +3 -4
  46. package/dest/mem_pools/interface.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +39 -58
  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 +314 -317
  50. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +18 -0
  51. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
  52. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +56 -0
  53. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +83 -0
  54. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
  55. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +5 -0
  56. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +15 -0
  57. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +1 -0
  58. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +88 -0
  59. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
  60. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  61. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
  62. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
  63. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  64. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +76 -0
  65. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
  66. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  67. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
  68. package/dest/mem_pools/tx_pool/index.d.ts +1 -2
  69. package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
  70. package/dest/mem_pools/tx_pool/index.js +0 -1
  71. package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
  72. package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
  73. package/dest/mem_pools/tx_pool/priority.js +6 -1
  74. package/dest/mem_pools/tx_pool/tx_pool.d.ts +28 -9
  75. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  76. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
  77. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  78. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +155 -25
  79. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -2
  80. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  81. package/dest/msg_validators/attestation_validator/attestation_validator.js +32 -5
  82. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
  83. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
  84. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +67 -0
  85. package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
  86. package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
  87. package/dest/msg_validators/attestation_validator/index.js +1 -0
  88. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +5 -2
  89. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
  90. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +44 -12
  91. package/dest/msg_validators/block_proposal_validator/index.d.ts +1 -1
  92. package/dest/msg_validators/index.d.ts +1 -1
  93. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
  94. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
  95. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
  96. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  97. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +1 -1
  98. package/dest/msg_validators/tx_validator/archive_cache.d.ts +2 -2
  99. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  100. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +2 -2
  101. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  102. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  103. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  104. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  105. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +1 -1
  106. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  107. package/dest/msg_validators/tx_validator/double_spend_validator.js +1 -1
  108. package/dest/msg_validators/tx_validator/factory.d.ts +4 -3
  109. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  110. package/dest/msg_validators/tx_validator/factory.js +11 -5
  111. package/dest/msg_validators/tx_validator/gas_validator.d.ts +1 -1
  112. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  113. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  114. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  115. package/dest/msg_validators/tx_validator/index.js +1 -0
  116. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -6
  117. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  118. package/dest/msg_validators/tx_validator/metadata_validator.js +6 -24
  119. package/dest/msg_validators/tx_validator/phases_validator.d.ts +1 -1
  120. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  121. package/dest/msg_validators/tx_validator/phases_validator.js +3 -1
  122. package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
  123. package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
  124. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +13 -0
  125. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -0
  126. package/dest/msg_validators/tx_validator/timestamp_validator.js +32 -0
  127. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +1 -1
  128. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  129. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +1 -1
  130. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  131. package/dest/services/data_store.d.ts +1 -1
  132. package/dest/services/data_store.d.ts.map +1 -1
  133. package/dest/services/discv5/discV5_service.d.ts +3 -3
  134. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  135. package/dest/services/discv5/discV5_service.js +2 -2
  136. package/dest/services/dummy_service.d.ts +2 -2
  137. package/dest/services/dummy_service.d.ts.map +1 -1
  138. package/dest/services/encoding.d.ts +25 -4
  139. package/dest/services/encoding.d.ts.map +1 -1
  140. package/dest/services/encoding.js +74 -6
  141. package/dest/services/gossipsub/scoring.d.ts +1 -1
  142. package/dest/services/index.d.ts +1 -1
  143. package/dest/services/libp2p/instrumentation.d.ts +3 -1
  144. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  145. package/dest/services/libp2p/instrumentation.js +9 -2
  146. package/dest/services/libp2p/libp2p_service.d.ts +32 -72
  147. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  148. package/dest/services/libp2p/libp2p_service.js +796 -171
  149. package/dest/services/peer-manager/interface.d.ts +1 -1
  150. package/dest/services/peer-manager/metrics.d.ts +8 -1
  151. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  152. package/dest/services/peer-manager/metrics.js +28 -0
  153. package/dest/services/peer-manager/peer_manager.d.ts +1 -32
  154. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  155. package/dest/services/peer-manager/peer_manager.js +412 -21
  156. package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
  157. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  158. package/dest/services/peer-manager/peer_scoring.js +40 -2
  159. package/dest/services/reqresp/config.d.ts +1 -1
  160. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
  161. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  162. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -4
  163. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  164. package/dest/services/reqresp/index.d.ts +1 -1
  165. package/dest/services/reqresp/interface.d.ts +2 -11
  166. package/dest/services/reqresp/interface.d.ts.map +1 -1
  167. package/dest/services/reqresp/interface.js +1 -18
  168. package/dest/services/reqresp/metrics.d.ts +1 -1
  169. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  170. package/dest/services/reqresp/protocols/auth.d.ts +2 -2
  171. package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
  172. package/dest/services/reqresp/protocols/auth.js +2 -2
  173. package/dest/services/reqresp/protocols/block.d.ts +1 -1
  174. package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
  175. package/dest/services/reqresp/protocols/block.js +3 -2
  176. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +1 -1
  177. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  178. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
  179. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +4 -6
  180. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  181. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +1 -1
  182. package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
  183. package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
  184. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  185. package/dest/services/reqresp/protocols/index.d.ts +1 -1
  186. package/dest/services/reqresp/protocols/ping.d.ts +1 -1
  187. package/dest/services/reqresp/protocols/status.d.ts +6 -5
  188. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  189. package/dest/services/reqresp/protocols/status.js +4 -3
  190. package/dest/services/reqresp/protocols/tx.d.ts +2 -3
  191. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  192. package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
  193. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +2 -2
  194. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  195. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  196. package/dest/services/reqresp/reqresp.d.ts +1 -41
  197. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  198. package/dest/services/reqresp/reqresp.js +416 -34
  199. package/dest/services/reqresp/status.d.ts +2 -2
  200. package/dest/services/reqresp/status.d.ts.map +1 -1
  201. package/dest/services/service.d.ts +2 -2
  202. package/dest/services/service.d.ts.map +1 -1
  203. package/dest/services/tx_collection/config.d.ts +1 -1
  204. package/dest/services/tx_collection/config.js +1 -1
  205. package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -9
  206. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  207. package/dest/services/tx_collection/fast_tx_collection.js +6 -1
  208. package/dest/services/tx_collection/index.d.ts +1 -1
  209. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  210. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  211. package/dest/services/tx_collection/slow_tx_collection.d.ts +6 -7
  212. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  213. package/dest/services/tx_collection/slow_tx_collection.js +2 -1
  214. package/dest/services/tx_collection/tx_collection.d.ts +12 -11
  215. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  216. package/dest/services/tx_collection/tx_collection.js +3 -2
  217. package/dest/services/tx_collection/tx_collection_sink.d.ts +3 -3
  218. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  219. package/dest/services/tx_collection/tx_collection_sink.js +34 -4
  220. package/dest/services/tx_collection/tx_source.d.ts +1 -1
  221. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  222. package/dest/services/tx_collection/tx_source.js +2 -2
  223. package/dest/services/tx_provider.d.ts +6 -4
  224. package/dest/services/tx_provider.d.ts.map +1 -1
  225. package/dest/services/tx_provider.js +19 -6
  226. package/dest/services/tx_provider_instrumentation.d.ts +5 -2
  227. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  228. package/dest/services/tx_provider_instrumentation.js +14 -1
  229. package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
  230. package/dest/test-helpers/get-ports.d.ts +1 -1
  231. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  232. package/dest/test-helpers/index.d.ts +1 -1
  233. package/dest/test-helpers/make-enrs.d.ts +1 -1
  234. package/dest/test-helpers/make-enrs.js +1 -1
  235. package/dest/test-helpers/make-test-p2p-clients.d.ts +2 -2
  236. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  237. package/dest/test-helpers/mock-pubsub.d.ts +4 -4
  238. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  239. package/dest/test-helpers/mock-tx-helpers.d.ts +12 -0
  240. package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -0
  241. package/dest/test-helpers/mock-tx-helpers.js +19 -0
  242. package/dest/test-helpers/reqresp-nodes.d.ts +3 -3
  243. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  244. package/dest/test-helpers/reqresp-nodes.js +4 -3
  245. package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
  246. package/dest/testbench/p2p_client_testbench_worker.js +17 -9
  247. package/dest/testbench/parse_log_file.d.ts +1 -1
  248. package/dest/testbench/testbench.d.ts +1 -1
  249. package/dest/testbench/testbench.js +2 -2
  250. package/dest/testbench/worker_client_manager.d.ts +1 -1
  251. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  252. package/dest/types/index.d.ts +1 -1
  253. package/dest/util.d.ts +2 -1
  254. package/dest/util.d.ts.map +1 -1
  255. package/dest/util.js +11 -2
  256. package/dest/versioning.d.ts +2 -2
  257. package/dest/versioning.d.ts.map +1 -1
  258. package/dest/versioning.js +2 -2
  259. package/package.json +21 -21
  260. package/src/bootstrap/bootstrap.ts +15 -4
  261. package/src/client/factory.ts +21 -12
  262. package/src/client/interface.ts +8 -5
  263. package/src/client/p2p_client.ts +97 -88
  264. package/src/config.ts +42 -21
  265. package/src/enr/generate-enr.ts +1 -1
  266. package/src/errors/attestation-pool.error.ts +13 -0
  267. package/src/mem_pools/attestation_pool/attestation_pool.ts +46 -5
  268. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +89 -48
  269. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +107 -24
  270. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +98 -19
  271. package/src/mem_pools/attestation_pool/mocks.ts +11 -8
  272. package/src/mem_pools/instrumentation.ts +46 -0
  273. package/src/mem_pools/interface.ts +2 -4
  274. package/src/mem_pools/tx_pool/README.md +255 -0
  275. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +368 -360
  276. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +71 -0
  277. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +93 -0
  278. package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +108 -0
  279. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
  280. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +91 -0
  281. package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
  282. package/src/mem_pools/tx_pool/index.ts +0 -1
  283. package/src/mem_pools/tx_pool/priority.ts +8 -1
  284. package/src/mem_pools/tx_pool/tx_pool.ts +28 -8
  285. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +131 -18
  286. package/src/msg_validators/attestation_validator/attestation_validator.ts +41 -6
  287. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +91 -0
  288. package/src/msg_validators/attestation_validator/index.ts +1 -0
  289. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +53 -12
  290. package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
  291. package/src/msg_validators/tx_validator/block_header_validator.ts +2 -2
  292. package/src/msg_validators/tx_validator/double_spend_validator.ts +1 -1
  293. package/src/msg_validators/tx_validator/factory.ts +13 -6
  294. package/src/msg_validators/tx_validator/index.ts +1 -0
  295. package/src/msg_validators/tx_validator/metadata_validator.ts +8 -42
  296. package/src/msg_validators/tx_validator/phases_validator.ts +3 -1
  297. package/src/msg_validators/tx_validator/test_utils.ts +1 -1
  298. package/src/msg_validators/tx_validator/timestamp_validator.ts +47 -0
  299. package/src/services/discv5/discV5_service.ts +2 -2
  300. package/src/services/dummy_service.ts +1 -1
  301. package/src/services/encoding.ts +81 -6
  302. package/src/services/libp2p/instrumentation.ts +10 -1
  303. package/src/services/libp2p/libp2p_service.ts +430 -165
  304. package/src/services/peer-manager/metrics.ts +32 -0
  305. package/src/services/peer-manager/peer_manager.ts +24 -14
  306. package/src/services/peer-manager/peer_scoring.ts +46 -3
  307. package/src/services/reqresp/interface.ts +1 -22
  308. package/src/services/reqresp/protocols/auth.ts +2 -2
  309. package/src/services/reqresp/protocols/block.ts +3 -2
  310. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +1 -1
  311. package/src/services/reqresp/protocols/status.ts +9 -8
  312. package/src/services/reqresp/protocols/tx.ts +1 -2
  313. package/src/services/reqresp/reqresp.ts +15 -11
  314. package/src/services/service.ts +1 -1
  315. package/src/services/tx_collection/config.ts +1 -1
  316. package/src/services/tx_collection/fast_tx_collection.ts +8 -5
  317. package/src/services/tx_collection/slow_tx_collection.ts +7 -6
  318. package/src/services/tx_collection/tx_collection.ts +12 -10
  319. package/src/services/tx_collection/tx_collection_sink.ts +34 -3
  320. package/src/services/tx_collection/tx_source.ts +2 -2
  321. package/src/services/tx_provider.ts +26 -9
  322. package/src/services/tx_provider_instrumentation.ts +19 -2
  323. package/src/test-helpers/make-enrs.ts +1 -1
  324. package/src/test-helpers/mock-pubsub.ts +1 -1
  325. package/src/test-helpers/mock-tx-helpers.ts +24 -0
  326. package/src/test-helpers/reqresp-nodes.ts +4 -3
  327. package/src/testbench/p2p_client_testbench_worker.ts +14 -6
  328. package/src/testbench/testbench.ts +2 -2
  329. package/src/util.ts +12 -2
  330. package/src/versioning.ts +3 -3
  331. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -68
  332. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
  333. package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -160
  334. package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -199
@@ -1,17 +1,14 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
  import {
4
4
  type AnyTx,
5
5
  TX_ERROR_INCORRECT_L1_CHAIN_ID,
6
- TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT,
6
+ TX_ERROR_INCORRECT_PROTOCOL_CONTRACTS_HASH,
7
7
  TX_ERROR_INCORRECT_ROLLUP_VERSION,
8
8
  TX_ERROR_INCORRECT_VK_TREE_ROOT,
9
- TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP,
10
9
  type TxValidationResult,
11
10
  type TxValidator,
12
- getTxHash,
13
11
  } from '@aztec/stdlib/tx';
14
- import type { UInt64 } from '@aztec/stdlib/types';
15
12
 
16
13
  export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
17
14
  #log = createLogger('p2p:tx_validator:tx_metadata');
@@ -20,13 +17,8 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
20
17
  private values: {
21
18
  l1ChainId: Fr;
22
19
  rollupVersion: Fr;
23
- // Timestamp at which we will validate that the tx is not expired. This is typically the timestamp of the block
24
- // being built.
25
- timestamp: UInt64;
26
- // Block number in which the tx is considered to be included.
27
- blockNumber: number;
28
20
  vkTreeRoot: Fr;
29
- protocolContractTreeRoot: Fr;
21
+ protocolContractsHash: Fr;
30
22
  },
31
23
  ) {}
32
24
 
@@ -38,14 +30,11 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
38
30
  if (!this.#hasCorrectRollupVersion(tx)) {
39
31
  errors.push(TX_ERROR_INCORRECT_ROLLUP_VERSION);
40
32
  }
41
- if (!this.#isValidForTimestamp(tx)) {
42
- errors.push(TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP);
43
- }
44
33
  if (!this.#hasCorrectVkTreeRoot(tx)) {
45
34
  errors.push(TX_ERROR_INCORRECT_VK_TREE_ROOT);
46
35
  }
47
- if (!this.#hasCorrectProtocolContractTreeRoot(tx)) {
48
- errors.push(TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT);
36
+ if (!this.#hasCorrectprotocolContractsHash(tx)) {
37
+ errors.push(TX_ERROR_INCORRECT_PROTOCOL_CONTRACTS_HASH);
49
38
  }
50
39
  return Promise.resolve(errors.length > 0 ? { result: 'invalid', reason: errors } : { result: 'valid' });
51
40
  }
@@ -62,10 +51,10 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
62
51
  }
63
52
  }
64
53
 
65
- #hasCorrectProtocolContractTreeRoot(tx: T): boolean {
66
- if (!tx.data.constants.protocolContractTreeRoot.equals(this.values.protocolContractTreeRoot)) {
54
+ #hasCorrectprotocolContractsHash(tx: T): boolean {
55
+ if (!tx.data.constants.protocolContractsHash.equals(this.values.protocolContractsHash)) {
67
56
  this.#log.verbose(
68
- `Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} because of incorrect protocol contract tree root ${tx.data.constants.protocolContractTreeRoot.toString()} != ${this.values.protocolContractTreeRoot.toString()}`,
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()}`,
69
58
  );
70
59
  return false;
71
60
  }
@@ -83,29 +72,6 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
83
72
  }
84
73
  }
85
74
 
86
- #isValidForTimestamp(tx: T): boolean {
87
- const includeByTimestamp = tx.data.includeByTimestamp;
88
- // If building block 1, we skip the expiration check. For details on why see the `validate_include_by_timestamp`
89
- // function in `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
90
- const buildingBlock1 = this.values.blockNumber === 1;
91
-
92
- if (!buildingBlock1 && includeByTimestamp < this.values.timestamp) {
93
- if (tx.data.constants.historicalHeader.globalVariables.blockNumber === 0) {
94
- this.#log.warn(
95
- `A tx built against a genesis block failed to be included in block 1 which is the only block in which txs built against a genesis block are allowed to be included.`,
96
- );
97
- }
98
- this.#log.verbose(
99
- `Rejecting tx ${getTxHash(tx)} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${
100
- this.values.timestamp
101
- }.`,
102
- );
103
- return false;
104
- } else {
105
- return true;
106
- }
107
- }
108
-
109
75
  #hasCorrectRollupVersion(tx: T): boolean {
110
76
  if (!tx.data.constants.txContext.version.equals(this.values.rollupVersion)) {
111
77
  this.#log.verbose(
@@ -26,10 +26,12 @@ export class PhasesTxValidator implements TxValidator<Tx> {
26
26
  }
27
27
 
28
28
  async validateTx(tx: Tx): Promise<TxValidationResult> {
29
+ this.contractsDB.createCheckpoint();
29
30
  try {
30
31
  // TODO(@spalladino): We add this just to handle public authwit-check calls during setup
31
32
  // which are needed for public FPC flows, but fail if the account contract hasnt been deployed yet,
32
33
  // which is what we're trying to do as part of the current txs.
34
+ // We only need to create/revert checkpoint here because of this addNewContracts call.
33
35
  await this.contractsDB.addNewContracts(tx);
34
36
 
35
37
  if (!tx.data.forPublic) {
@@ -58,7 +60,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
58
60
  this.#log.error(`Error validating phases for tx`, err);
59
61
  return { result: 'invalid', reason: [TX_ERROR_DURING_VALIDATION] };
60
62
  } finally {
61
- this.contractsDB.clearContractsForTx();
63
+ this.contractsDB.revertCheckpoint();
62
64
  }
63
65
  }
64
66
 
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { FunctionSelector } from '@aztec/stdlib/abi';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { HashedValues, type Tx } from '@aztec/stdlib/tx';
@@ -0,0 +1,47 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import {
4
+ type AnyTx,
5
+ TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP,
6
+ type TxValidationResult,
7
+ type TxValidator,
8
+ getTxHash,
9
+ } from '@aztec/stdlib/tx';
10
+ import type { UInt64 } from '@aztec/stdlib/types';
11
+
12
+ export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
13
+ #log = createLogger('p2p:tx_validator:timestamp');
14
+
15
+ constructor(
16
+ private values: {
17
+ // Timestamp at which we will validate that the tx is not expired. This is typically the timestamp of the block
18
+ // being built.
19
+ timestamp: UInt64;
20
+ // Block number in which the tx is considered to be included.
21
+ blockNumber: BlockNumber;
22
+ },
23
+ ) {}
24
+
25
+ validateTx(tx: T): Promise<TxValidationResult> {
26
+ const includeByTimestamp = tx.data.includeByTimestamp;
27
+ // If building block 1, we skip the expiration check. For details on why see the `validate_include_by_timestamp`
28
+ // function in `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
29
+ const buildingBlock1 = this.values.blockNumber === 1;
30
+
31
+ if (!buildingBlock1 && includeByTimestamp < this.values.timestamp) {
32
+ if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber === 0) {
33
+ this.#log.warn(
34
+ `A tx built against a genesis block failed to be included in block 1 which is the only block in which txs built against a genesis block are allowed to be included.`,
35
+ );
36
+ }
37
+ this.#log.verbose(
38
+ `Rejecting tx ${getTxHash(tx)} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${
39
+ this.values.timestamp
40
+ }.`,
41
+ );
42
+ return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP] });
43
+ } else {
44
+ return Promise.resolve({ result: 'valid' });
45
+ }
46
+ }
47
+ }
@@ -3,10 +3,10 @@ import { sleep } from '@aztec/foundation/sleep';
3
3
  import { type ComponentsVersions, checkCompressedComponentVersion } from '@aztec/stdlib/versioning';
4
4
  import { OtelMetricsAdapter, type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
5
5
 
6
- import { Discv5, type Discv5EventEmitter, type IDiscv5CreateOptions } from '@chainsafe/discv5';
7
- import { ENR, SignableENR } from '@chainsafe/enr';
8
6
  import type { PeerId } from '@libp2p/interface';
9
7
  import { type Multiaddr, multiaddr } from '@multiformats/multiaddr';
8
+ import { Discv5, type Discv5EventEmitter, type IDiscv5CreateOptions } from '@nethermindeth/discv5';
9
+ import { ENR, SignableENR } from '@nethermindeth/enr';
10
10
  import EventEmitter from 'events';
11
11
 
12
12
  import type { P2PConfig } from '../../config.js';
@@ -3,8 +3,8 @@ import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
3
  import type { Gossipable, PeerErrorSeverity } from '@aztec/stdlib/p2p';
4
4
  import { Tx, TxHash } from '@aztec/stdlib/tx';
5
5
 
6
- import type { ENR } from '@chainsafe/enr';
7
6
  import type { PeerId } from '@libp2p/interface';
7
+ import type { ENR } from '@nethermindeth/enr';
8
8
  import EventEmitter from 'events';
9
9
 
10
10
  import type { PeerManagerInterface } from './peer-manager/interface.js';
@@ -1,5 +1,7 @@
1
1
  // Taken from lodestar: https://github.com/ChainSafe/lodestar
2
- import { sha256 } from '@aztec/foundation/crypto';
2
+ import { sha256 } from '@aztec/foundation/crypto/sha256';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ import { TopicType, getTopicFromString } from '@aztec/stdlib/p2p';
3
5
 
4
6
  import type { RPC } from '@chainsafe/libp2p-gossipsub/message';
5
7
  import type { DataTransform } from '@chainsafe/libp2p-gossipsub/types';
@@ -49,31 +51,104 @@ export function getMsgIdFn(message: Message) {
49
51
  return sha256(Buffer.concat(vec)).subarray(0, 20);
50
52
  }
51
53
 
54
+ const DefaultMaxSizesKb: Record<TopicType, number> = {
55
+ // Tx effects should not exceed 128kb, so 512kb for the full tx obj should be sufficient
56
+ [TopicType.tx]: 512,
57
+ // An attestation has roughly 30 fields, which is 1kb, so 5x is plenty
58
+ [TopicType.block_attestation]: 5,
59
+ // Proposals may carry some tx objects, so we allow a larger size capped at 10mb
60
+ // Note this may not be enough for carrying all tx objects in a block
61
+ [TopicType.block_proposal]: 1024 * 10,
62
+ };
63
+
52
64
  /**
53
65
  * Snappy transform for libp2p gossipsub
54
66
  */
55
67
  export class SnappyTransform implements DataTransform {
68
+ constructor(
69
+ private maxSizesKb: Record<TopicType, number> = DefaultMaxSizesKb,
70
+ private defaultMaxSizeKb: number = 10 * 1024,
71
+ private logger = createLogger('p2p:snappy-transform'),
72
+ ) {}
73
+
56
74
  // Topic string included to satisfy DataTransform interface
57
- inboundTransform(_topicStr: string, data: Uint8Array): Uint8Array {
58
- return this.inboundTransformNoTopic(Buffer.from(data));
75
+ inboundTransform(topicStr: string, data: Uint8Array): Uint8Array {
76
+ const topic = getTopicFromString(topicStr);
77
+ return this.inboundTransformData(Buffer.from(data), topic);
59
78
  }
60
79
 
61
- public inboundTransformNoTopic(data: Buffer): Buffer {
80
+ public inboundTransformData(data: Buffer, topic?: TopicType): Buffer {
62
81
  if (data.length === 0) {
63
82
  return data;
64
83
  }
84
+ const maxSizeKb = this.maxSizesKb[topic!] ?? this.defaultMaxSizeKb;
85
+ const { decompressedSize } = readSnappyPreamble(data);
86
+ if (decompressedSize > maxSizeKb * 1024) {
87
+ this.logger.warn(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);
88
+ throw new Error(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);
89
+ }
90
+
65
91
  return Buffer.from(uncompressSync(data, { asBuffer: true }));
66
92
  }
67
93
 
68
94
  // Topic string included to satisfy DataTransform interface
69
95
  outboundTransform(_topicStr: string, data: Uint8Array): Uint8Array {
70
- return this.outboundTransformNoTopic(Buffer.from(data));
96
+ return this.outboundTransformData(Buffer.from(data));
71
97
  }
72
98
 
73
- public outboundTransformNoTopic(data: Buffer): Buffer {
99
+ public outboundTransformData(data: Buffer): Buffer {
74
100
  if (data.length === 0) {
75
101
  return data;
76
102
  }
77
103
  return Buffer.from(compressSync(data));
78
104
  }
79
105
  }
106
+
107
+ /**
108
+ * Reads the Snappy preamble from compressed data and returns the expected decompressed size.
109
+ *
110
+ * The Snappy format starts with a little-endian varint encoding the uncompressed length.
111
+ * Varints consist of a series of bytes where:
112
+ * - Lower 7 bits contain data
113
+ * - Upper bit (0x80) is set if more bytes follow
114
+ *
115
+ * @param data - The compressed data starting with the Snappy preamble
116
+ * @returns Object containing the decompressed size and the number of bytes read from the preamble
117
+ * @throws Error if the data is too short or the varint is invalid
118
+ */
119
+ export function readSnappyPreamble(data: Uint8Array): { decompressedSize: number; bytesRead: number } {
120
+ if (data.length === 0) {
121
+ throw new Error('Cannot read preamble from empty data');
122
+ }
123
+
124
+ let result = 0;
125
+ let shift = 0;
126
+ let bytesRead = 0;
127
+
128
+ // Maximum varint length for 32-bit value is 5 bytes
129
+ // (7 bits per byte, so 5 bytes = 35 bits, enough for 2^32 - 1)
130
+ const maxBytes = 5;
131
+
132
+ for (let i = 0; i < Math.min(data.length, maxBytes); i++) {
133
+ const byte = data[i];
134
+ bytesRead++;
135
+
136
+ // Extract lower 7 bits and add to result with appropriate shift
137
+ // Use >>> 0 to convert to unsigned 32-bit integer to avoid sign issues
138
+ result = (result | ((byte & 0x7f) << shift)) >>> 0;
139
+
140
+ // If upper bit is not set, we're done
141
+ if ((byte & 0x80) === 0) {
142
+ return { decompressedSize: result, bytesRead };
143
+ }
144
+
145
+ shift += 7;
146
+ }
147
+
148
+ // If we get here, either we ran out of data or the varint is too long
149
+ if (bytesRead >= maxBytes) {
150
+ throw new Error('Varint is too long (max 5 bytes for 32-bit value)');
151
+ }
152
+
153
+ throw new Error('Incomplete varint: data ended before varint termination');
154
+ }
@@ -17,6 +17,7 @@ export class P2PInstrumentation {
17
17
  private messageValidationDuration: Histogram;
18
18
  private messagePrevalidationCount: UpDownCounter;
19
19
  private messageLatency: Histogram;
20
+ private txReceivedCount: UpDownCounter;
20
21
 
21
22
  private aggLatencyHisto = new Map<TopicType, RecordableHistogram>();
22
23
  private aggValidationHisto = new Map<TopicType, RecordableHistogram>();
@@ -44,6 +45,10 @@ export class P2PInstrumentation {
44
45
  valueType: ValueType.INT,
45
46
  });
46
47
 
48
+ this.txReceivedCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_TX_RECEIVED_COUNT, {
49
+ description: 'The number of txs received from the p2p network',
50
+ });
51
+
47
52
  this.aggLatencyMetrics = {
48
53
  avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG, {
49
54
  valueType: ValueType.DOUBLE,
@@ -119,6 +124,10 @@ export class P2PInstrumentation {
119
124
  validationHistogram.record(Math.max(ms, 1));
120
125
  }
121
126
 
127
+ public incrementTxReceived(count: number) {
128
+ this.txReceivedCount.add(count);
129
+ }
130
+
122
131
  public incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined) {
123
132
  this.messagePrevalidationCount.add(1, { [Attributes.TOPIC_NAME]: topicName, [Attributes.OK]: passed });
124
133
  }
@@ -129,7 +138,7 @@ export class P2PInstrumentation {
129
138
 
130
139
  let latencyHistogram = this.aggLatencyHisto.get(topicName);
131
140
  if (!latencyHistogram) {
132
- latencyHistogram = createHistogram({ min: 1, max: 24 * 60 * 60 * 1000 }); // 24hrs
141
+ latencyHistogram = createHistogram({ min: 1, max: 60 * 1000 }); // Max: 1 minute
133
142
  this.aggLatencyHisto.set(topicName, latencyHistogram);
134
143
  }
135
144