@aztec/p2p 0.0.1-commit.8afd444 → 0.0.1-commit.9117c5f5a

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/client/factory.d.ts +10 -10
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +39 -15
  4. package/dest/client/interface.d.ts +46 -33
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +39 -51
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +145 -200
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +7 -8
  10. package/dest/config.d.ts +25 -9
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +16 -6
  13. package/dest/errors/tx-pool.error.d.ts +8 -0
  14. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  15. package/dest/errors/tx-pool.error.js +9 -0
  16. package/dest/index.d.ts +2 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -0
  19. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
  20. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  22. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  23. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  25. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  26. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/index.js +1 -2
  28. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  29. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  31. package/dest/mem_pools/index.d.ts +3 -2
  32. package/dest/mem_pools/index.d.ts.map +1 -1
  33. package/dest/mem_pools/index.js +1 -1
  34. package/dest/mem_pools/interface.d.ts +5 -5
  35. package/dest/mem_pools/interface.d.ts.map +1 -1
  36. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  37. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  38. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  39. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  40. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  41. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  42. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  43. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  44. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  45. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  46. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  47. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  48. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
  49. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  50. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  51. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
  52. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  53. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  54. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  56. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  58. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
  59. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  60. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
  61. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  76. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  77. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  78. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  79. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  80. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  81. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  82. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
  83. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  84. package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
  85. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +119 -0
  86. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  87. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +193 -0
  88. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  89. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  90. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  91. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
  92. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  93. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +354 -0
  94. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -0
  95. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  96. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
  97. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -0
  98. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  99. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +905 -0
  100. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  101. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  102. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
  103. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  104. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
  105. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
  106. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  107. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  108. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
  109. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  110. package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
  111. package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
  112. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  113. package/dest/msg_validators/tx_validator/factory.js +219 -58
  114. package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
  115. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  116. package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
  117. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  118. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  119. package/dest/msg_validators/tx_validator/index.js +1 -0
  120. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  121. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  122. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  123. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
  124. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  125. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  126. package/dest/services/dummy_service.d.ts +13 -5
  127. package/dest/services/dummy_service.d.ts.map +1 -1
  128. package/dest/services/dummy_service.js +10 -4
  129. package/dest/services/encoding.d.ts +3 -3
  130. package/dest/services/encoding.d.ts.map +1 -1
  131. package/dest/services/encoding.js +11 -10
  132. package/dest/services/gossipsub/index.d.ts +3 -0
  133. package/dest/services/gossipsub/index.d.ts.map +1 -0
  134. package/dest/services/gossipsub/index.js +2 -0
  135. package/dest/services/gossipsub/scoring.d.ts +21 -3
  136. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  137. package/dest/services/gossipsub/scoring.js +24 -7
  138. package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
  139. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  140. package/dest/services/gossipsub/topic_score_params.js +346 -0
  141. package/dest/services/libp2p/libp2p_service.d.ts +94 -42
  142. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  143. package/dest/services/libp2p/libp2p_service.js +420 -337
  144. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  145. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  146. package/dest/services/peer-manager/peer_scoring.js +25 -2
  147. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +6 -5
  148. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  149. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +26 -53
  150. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
  151. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  152. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
  153. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  154. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
  155. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
  156. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  157. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
  158. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
  159. package/dest/services/reqresp/interface.d.ts +10 -1
  160. package/dest/services/reqresp/interface.d.ts.map +1 -1
  161. package/dest/services/reqresp/interface.js +15 -1
  162. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  163. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  164. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +16 -11
  165. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +21 -10
  166. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  167. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +27 -11
  168. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  169. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  170. package/dest/services/reqresp/protocols/tx.js +20 -0
  171. package/dest/services/reqresp/reqresp.d.ts +1 -1
  172. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  173. package/dest/services/reqresp/reqresp.js +13 -5
  174. package/dest/services/service.d.ts +39 -3
  175. package/dest/services/service.d.ts.map +1 -1
  176. package/dest/services/tx_collection/config.d.ts +22 -4
  177. package/dest/services/tx_collection/config.d.ts.map +1 -1
  178. package/dest/services/tx_collection/config.js +49 -3
  179. package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
  180. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  181. package/dest/services/tx_collection/fast_tx_collection.js +64 -48
  182. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  183. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  184. package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
  185. package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
  186. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  187. package/dest/services/tx_collection/file_store_tx_source.js +90 -0
  188. package/dest/services/tx_collection/index.d.ts +3 -2
  189. package/dest/services/tx_collection/index.d.ts.map +1 -1
  190. package/dest/services/tx_collection/index.js +1 -0
  191. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  192. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  193. package/dest/services/tx_collection/instrumentation.js +2 -1
  194. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  195. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  196. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  197. package/dest/services/tx_collection/proposal_tx_collector.d.ts +15 -14
  198. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  199. package/dest/services/tx_collection/proposal_tx_collector.js +6 -6
  200. package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
  201. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  202. package/dest/services/tx_collection/slow_tx_collection.js +60 -26
  203. package/dest/services/tx_collection/tx_collection.d.ts +23 -10
  204. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  205. package/dest/services/tx_collection/tx_collection.js +75 -3
  206. package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
  207. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  208. package/dest/services/tx_collection/tx_collection_sink.js +26 -29
  209. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  210. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  211. package/dest/services/tx_collection/tx_source.js +19 -2
  212. package/dest/services/tx_file_store/config.d.ts +1 -3
  213. package/dest/services/tx_file_store/config.d.ts.map +1 -1
  214. package/dest/services/tx_file_store/config.js +0 -4
  215. package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
  216. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  217. package/dest/services/tx_file_store/tx_file_store.js +9 -6
  218. package/dest/services/tx_provider.d.ts +4 -4
  219. package/dest/services/tx_provider.d.ts.map +1 -1
  220. package/dest/services/tx_provider.js +9 -8
  221. package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
  222. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  223. package/dest/test-helpers/make-test-p2p-clients.js +1 -2
  224. package/dest/test-helpers/mock-pubsub.d.ts +30 -4
  225. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  226. package/dest/test-helpers/mock-pubsub.js +105 -4
  227. package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
  228. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  229. package/dest/test-helpers/reqresp-nodes.js +4 -3
  230. package/dest/test-helpers/testbench-utils.d.ts +43 -38
  231. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  232. package/dest/test-helpers/testbench-utils.js +128 -59
  233. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  234. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  235. package/dest/testbench/p2p_client_testbench_worker.js +15 -15
  236. package/dest/util.d.ts +2 -2
  237. package/dest/util.d.ts.map +1 -1
  238. package/package.json +14 -14
  239. package/src/client/factory.ts +74 -27
  240. package/src/client/interface.ts +56 -34
  241. package/src/client/p2p_client.ts +180 -247
  242. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
  243. package/src/config.ts +35 -11
  244. package/src/errors/tx-pool.error.ts +12 -0
  245. package/src/index.ts +1 -0
  246. package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
  247. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  248. package/src/mem_pools/attestation_pool/index.ts +9 -2
  249. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  250. package/src/mem_pools/index.ts +4 -1
  251. package/src/mem_pools/interface.ts +4 -4
  252. package/src/mem_pools/tx_pool/README.md +1 -1
  253. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  254. package/src/mem_pools/tx_pool_v2/README.md +275 -0
  255. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  256. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  257. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  258. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  259. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
  260. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
  261. package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
  262. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
  263. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  264. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  265. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
  266. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
  267. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  268. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  269. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  270. package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
  271. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +297 -0
  272. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  273. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
  274. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
  275. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1083 -0
  276. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  277. package/src/msg_validators/tx_validator/README.md +115 -0
  278. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
  279. package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
  280. package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
  281. package/src/msg_validators/tx_validator/factory.ts +353 -77
  282. package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
  283. package/src/msg_validators/tx_validator/index.ts +1 -0
  284. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  285. package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
  286. package/src/services/dummy_service.ts +18 -6
  287. package/src/services/encoding.ts +9 -9
  288. package/src/services/gossipsub/README.md +641 -0
  289. package/src/services/gossipsub/index.ts +2 -0
  290. package/src/services/gossipsub/scoring.ts +29 -5
  291. package/src/services/gossipsub/topic_score_params.ts +487 -0
  292. package/src/services/libp2p/libp2p_service.ts +445 -360
  293. package/src/services/peer-manager/peer_scoring.ts +25 -0
  294. package/src/services/reqresp/batch-tx-requester/README.md +7 -7
  295. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +31 -59
  296. package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
  297. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
  298. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
  299. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
  300. package/src/services/reqresp/interface.ts +26 -1
  301. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
  302. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +38 -15
  303. package/src/services/reqresp/protocols/tx.ts +22 -0
  304. package/src/services/reqresp/reqresp.ts +16 -4
  305. package/src/services/service.ts +51 -2
  306. package/src/services/tx_collection/config.ts +74 -6
  307. package/src/services/tx_collection/fast_tx_collection.ts +74 -51
  308. package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
  309. package/src/services/tx_collection/file_store_tx_source.ts +117 -0
  310. package/src/services/tx_collection/index.ts +2 -1
  311. package/src/services/tx_collection/instrumentation.ts +7 -1
  312. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  313. package/src/services/tx_collection/proposal_tx_collector.ts +20 -21
  314. package/src/services/tx_collection/slow_tx_collection.ts +66 -33
  315. package/src/services/tx_collection/tx_collection.ts +113 -16
  316. package/src/services/tx_collection/tx_collection_sink.ts +30 -34
  317. package/src/services/tx_collection/tx_source.ts +22 -3
  318. package/src/services/tx_file_store/config.ts +0 -6
  319. package/src/services/tx_file_store/tx_file_store.ts +10 -8
  320. package/src/services/tx_provider.ts +10 -9
  321. package/src/test-helpers/make-test-p2p-clients.ts +3 -5
  322. package/src/test-helpers/mock-pubsub.ts +146 -9
  323. package/src/test-helpers/reqresp-nodes.ts +4 -6
  324. package/src/test-helpers/testbench-utils.ts +127 -71
  325. package/src/testbench/p2p_client_testbench_worker.ts +24 -21
  326. package/src/util.ts +7 -1
  327. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  328. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  329. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  330. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  331. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  332. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  333. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  334. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -13,7 +13,7 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
13
13
  import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
14
14
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
15
15
  import { protocolContractsHash } from '@aztec/protocol-contracts';
16
- import { P2PClientType, P2PMessage } from '@aztec/stdlib/p2p';
16
+ import { P2PMessage } from '@aztec/stdlib/p2p';
17
17
  import { ChonkProof } from '@aztec/stdlib/proofs';
18
18
  import { makeAztecAddress, makeBlockHeader, makeBlockProposal, mockTx } from '@aztec/stdlib/testing';
19
19
  import { Tx } from '@aztec/stdlib/tx';
@@ -21,18 +21,18 @@ import { getTelemetryClient } from '@aztec/telemetry-client';
21
21
  import { TopicValidatorResult } from '@libp2p/interface';
22
22
  import { peerIdFromString } from '@libp2p/peer-id';
23
23
  import { createP2PClient } from '../index.js';
24
- import { LibP2PService } from '../services/libp2p/libp2p_service.js';
24
+ import { BatchTxRequesterCollector, LibP2PService, SendBatchRequestCollector } from '../services/index.js';
25
25
  import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
26
- import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../services/tx_collection/proposal_tx_collector.js';
27
- import { AlwaysTrueCircuitVerifier } from '../test-helpers/reqresp-nodes.js';
28
- import { BENCHMARK_CONSTANTS, InMemoryAttestationPool, InMemoryTxPool, UNLIMITED_RATE_LIMIT_QUOTA, createMockEpochCache, createMockWorldStateSynchronizer, filterTxsByDistribution } from '../test-helpers/testbench-utils.js';
26
+ import { MissingTxsTracker } from '../services/tx_collection/missing_txs_tracker.js';
27
+ import { AlwaysTrueCircuitVerifier } from '../test-helpers/index.js';
28
+ import { BENCHMARK_CONSTANTS, InMemoryAttestationPool, InMemoryTxPool, UNLIMITED_RATE_LIMIT_QUOTA, createMockEpochCache, createMockWorldStateSynchronizer, filterTxsByDistribution } from '../test-helpers/index.js';
29
29
  export { COLLECTOR_DISPLAY_NAMES } from '../test-helpers/testbench-utils.js';
30
30
  const txCache = new Map();
31
31
  class TestLibP2PService extends LibP2PService {
32
32
  disableTxValidation;
33
33
  gossipMessageCount = 0;
34
- constructor(clientType, config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:test:libp2p_service'), disableTxValidation = true){
35
- super(clientType, config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger);
34
+ constructor(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:test:libp2p_service'), disableTxValidation = true){
35
+ super(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger);
36
36
  this.disableTxValidation = disableTxValidation;
37
37
  }
38
38
  getGossipMessageCount() {
@@ -49,7 +49,7 @@ class TestLibP2PService extends LibP2PService {
49
49
  const txHash = tx.getTxHash();
50
50
  const txHashString = txHash.toString();
51
51
  this.logger.verbose(`Received tx ${txHashString} from external peer ${source.toString()}.`);
52
- await this.mempools.txPool.addTxs([
52
+ await this.mempools.txPool.addPendingTxs([
53
53
  tx
54
54
  ]);
55
55
  } else {
@@ -70,7 +70,7 @@ async function generateDeterministicTxs(txCount, seed, config) {
70
70
  if (cached.length >= txCount) {
71
71
  return cached.slice(0, txCount);
72
72
  }
73
- const includeByTimestampBase = BigInt(seed);
73
+ const expirationTimestampBase = BigInt(seed);
74
74
  for(let i = cached.length; i < txCount; i++){
75
75
  const txSeed = seed * 10000 + i;
76
76
  const tx = await mockTx(txSeed, {
@@ -86,7 +86,7 @@ async function generateDeterministicTxs(txCount, seed, config) {
86
86
  hasPublicTeardownCallRequest: false,
87
87
  publicCalldataSize: 0
88
88
  });
89
- tx.data.includeByTimestamp = includeByTimestampBase + BigInt(i);
89
+ tx.data.expirationTimestamp = expirationTimestampBase + BigInt(i);
90
90
  await tx.recomputeHash();
91
91
  cached.push(tx);
92
92
  }
@@ -154,7 +154,7 @@ async function runAggregatorBenchmark(client, blockProposal, collectorType, time
154
154
  timer = new Timer();
155
155
  if (collectorType === 'batch-requester') {
156
156
  const collector = new BatchTxRequesterCollector(batchTxRequesterService, logger, new DateProvider(), noopTxValidator);
157
- const fetchedTxs = await collector.collectTxs(txHashes, blockProposal, pinnedPeer, timeoutMs);
157
+ const fetchedTxs = await collector.collectTxs(MissingTxsTracker.fromArray(txHashes), blockProposal, pinnedPeer, timeoutMs);
158
158
  const durationMs = timer.ms();
159
159
  return {
160
160
  type: 'BENCH_RESULT',
@@ -164,7 +164,7 @@ async function runAggregatorBenchmark(client, blockProposal, collectorType, time
164
164
  };
165
165
  }
166
166
  const collector = new SendBatchRequestCollector(batchTxRequesterService, BENCHMARK_CONSTANTS.FIXED_MAX_PEERS, BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS);
167
- const fetchedTxs = await collector.collectTxs(txHashes, blockProposal, pinnedPeer, timeoutMs);
167
+ const fetchedTxs = await collector.collectTxs(MissingTxsTracker.fromArray(txHashes), blockProposal, pinnedPeer, timeoutMs);
168
168
  const durationMs = timer.ms();
169
169
  return {
170
170
  type: 'BENCH_RESULT',
@@ -214,8 +214,8 @@ process.on('message', async (msg)=>{
214
214
  store: kvStore,
215
215
  logger: workerLogger
216
216
  };
217
- const client = await createP2PClient(P2PClientType.Full, config, l2BlockSource, proofVerifier, worldState, epochCache, 'test-p2p-bench-worker', undefined, telemetry, deps);
218
- const testService = new TestLibP2PService(P2PClientType.Full, config, client.p2pService.node, client.p2pService.peerDiscoveryService, client.p2pService.reqresp, client.p2pService.peerManager, client.p2pService.mempools, client.p2pService.archiver, epochCache, proofVerifier, worldState, telemetry, workerLogger, true);
217
+ const client = await createP2PClient(config, l2BlockSource, proofVerifier, worldState, epochCache, 'test-p2p-bench-worker', undefined, telemetry, deps);
218
+ const testService = new TestLibP2PService(config, client.p2pService.node, client.p2pService.peerDiscoveryService, client.p2pService.reqresp, client.p2pService.peerManager, client.p2pService.mempools, client.p2pService.archiver, epochCache, proofVerifier, worldState, telemetry, workerLogger, true);
219
219
  client.p2pService = testService;
220
220
  await client.start();
221
221
  for(let i = 0; i < 100; i++){
@@ -273,7 +273,7 @@ process.on('message', async (msg)=>{
273
273
  const allTxs = await generateDeterministicTxs(benchCmd.txCount, benchCmd.seed, workerConfig);
274
274
  const txHashes = allTxs.map((tx)=>tx.getTxHash());
275
275
  const blockProposal = await createBlockProposal(benchCmd.blockNumber, txHashes, benchCmd.seed);
276
- await workerAttestationPool.addBlockProposal(blockProposal);
276
+ await workerAttestationPool.tryAddBlockProposal(blockProposal);
277
277
  workerLogger.debug(`[BENCH] Added block proposal with archive ${blockProposal.archive.toString().slice(0, 10)}...`);
278
278
  if (benchCmd.isAggregator) {
279
279
  workerTxPool.clearTxs();
package/dest/util.d.ts CHANGED
@@ -10,7 +10,7 @@ import type { Libp2p } from 'libp2p';
10
10
  import type { P2PConfig } from './config.js';
11
11
  export interface PubSubLibp2p extends Pick<Libp2p, 'status' | 'start' | 'stop' | 'peerId'> {
12
12
  services: {
13
- pubsub: Pick<GossipSub, 'addEventListener' | 'removeEventListener' | 'publish' | 'subscribe' | 'reportMessageValidationResult' | 'direct'> & {
13
+ pubsub: Pick<GossipSub, 'addEventListener' | 'removeEventListener' | 'publish' | 'subscribe' | 'reportMessageValidationResult' | 'direct' | 'getMeshPeers'> & {
14
14
  score: Pick<GossipSub['score'], 'score'>;
15
15
  };
16
16
  };
@@ -58,4 +58,4 @@ export declare function getPeerIdPrivateKey(config: {
58
58
  * @returns The peer ID.
59
59
  */
60
60
  export declare function createLibP2PPeerIdFromPrivateKey(privateKey: string): Promise<PeerId>;
61
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3V0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUF1QixNQUFNLGlCQUFpQixDQUFDO0FBQzlFLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTdELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBYyxNQUFNLG1CQUFtQixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sNEJBQ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MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW9F;AAcD,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,SAAS,GAAG,eAAe,GACnC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC,CAmBtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE;IAAE,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,EACzG,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CA2D9B;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/p2p",
3
- "version": "0.0.1-commit.8afd444",
3
+ "version": "0.0.1-commit.9117c5f5a",
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": "0.0.1-commit.8afd444",
71
- "@aztec/epoch-cache": "0.0.1-commit.8afd444",
72
- "@aztec/ethereum": "0.0.1-commit.8afd444",
73
- "@aztec/foundation": "0.0.1-commit.8afd444",
74
- "@aztec/kv-store": "0.0.1-commit.8afd444",
75
- "@aztec/noir-contracts.js": "0.0.1-commit.8afd444",
76
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.8afd444",
77
- "@aztec/protocol-contracts": "0.0.1-commit.8afd444",
78
- "@aztec/simulator": "0.0.1-commit.8afd444",
79
- "@aztec/stdlib": "0.0.1-commit.8afd444",
80
- "@aztec/telemetry-client": "0.0.1-commit.8afd444",
70
+ "@aztec/constants": "0.0.1-commit.9117c5f5a",
71
+ "@aztec/epoch-cache": "0.0.1-commit.9117c5f5a",
72
+ "@aztec/ethereum": "0.0.1-commit.9117c5f5a",
73
+ "@aztec/foundation": "0.0.1-commit.9117c5f5a",
74
+ "@aztec/kv-store": "0.0.1-commit.9117c5f5a",
75
+ "@aztec/noir-contracts.js": "0.0.1-commit.9117c5f5a",
76
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.9117c5f5a",
77
+ "@aztec/protocol-contracts": "0.0.1-commit.9117c5f5a",
78
+ "@aztec/simulator": "0.0.1-commit.9117c5f5a",
79
+ "@aztec/stdlib": "0.0.1-commit.9117c5f5a",
80
+ "@aztec/telemetry-client": "0.0.1-commit.9117c5f5a",
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": "0.0.1-commit.8afd444",
108
- "@aztec/world-state": "0.0.1-commit.8afd444",
107
+ "@aztec/archiver": "0.0.1-commit.9117c5f5a",
108
+ "@aztec/world-state": "0.0.1-commit.9117c5f5a",
109
109
  "@jest/globals": "^30.0.0",
110
110
  "@types/jest": "^30.0.0",
111
111
  "@types/node": "^22.15.17",
@@ -1,4 +1,5 @@
1
1
  import type { EpochCacheInterface } from '@aztec/epoch-cache';
2
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
4
  import { DateProvider } from '@aztec/foundation/timer';
4
5
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
@@ -7,30 +8,32 @@ import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
7
8
  import type { L2BlockSource } from '@aztec/stdlib/block';
8
9
  import type { ChainConfig } from '@aztec/stdlib/config';
9
10
  import type { ContractDataSource } from '@aztec/stdlib/contract';
10
- import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
11
- import { P2PClientType } from '@aztec/stdlib/p2p';
11
+ import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
12
12
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
13
13
 
14
14
  import { P2PClient } from '../client/p2p_client.js';
15
15
  import type { P2PConfig } from '../config.js';
16
- import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
17
- import { KvAttestationPool } from '../mem_pools/attestation_pool/kv_attestation_pool.js';
16
+ import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
18
17
  import type { MemPools } from '../mem_pools/interface.js';
19
- import { AztecKVTxPool, type TxPool } from '../mem_pools/tx_pool/index.js';
18
+ import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
19
+ import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
20
+ import { createTxValidatorForTransactionsEnteringPendingTxPool } from '../msg_validators/index.js';
20
21
  import { DummyP2PService } from '../services/dummy_service.js';
21
22
  import { LibP2PService } from '../services/index.js';
23
+ import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
22
24
  import { TxCollection } from '../services/tx_collection/tx_collection.js';
23
- import { type TxSource, createNodeRpcTxSources } from '../services/tx_collection/tx_source.js';
25
+ import { NodeRpcTxSource, type TxSource, createNodeRpcTxSources } from '../services/tx_collection/tx_source.js';
24
26
  import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
25
27
  import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
26
28
 
27
- export type P2PClientDeps<T extends P2PClientType> = {
28
- txPool?: TxPool;
29
+ export type P2PClientDeps = {
30
+ txPool?: TxPoolV2;
29
31
  store?: AztecAsyncKVStore;
30
- attestationPool?: AttestationPool;
32
+ attestationPool?: AttestationPoolApi;
31
33
  logger?: Logger;
32
34
  txCollectionNodeSources?: TxSource[];
33
- p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService<T>>;
35
+ rpcTxProviders?: AztecNode[];
36
+ p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService>;
34
37
  };
35
38
 
36
39
  export const P2P_STORE_NAME = 'p2p';
@@ -38,8 +41,7 @@ export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
38
41
  export const P2P_PEER_STORE_NAME = 'p2p-peers';
39
42
  export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
40
43
 
41
- export async function createP2PClient<T extends P2PClientType>(
42
- clientType: T,
44
+ export async function createP2PClient(
43
45
  inputConfig: P2PConfig & DataStoreConfig & ChainConfig,
44
46
  archiver: L2BlockSource & ContractDataSource,
45
47
  proofVerifier: ClientProtocolCircuitVerifier,
@@ -48,7 +50,7 @@ export async function createP2PClient<T extends P2PClientType>(
48
50
  packageVersion: string,
49
51
  dateProvider: DateProvider = new DateProvider(),
50
52
  telemetry: TelemetryClient = getTelemetryClient(),
51
- deps: P2PClientDeps<T> = {},
53
+ deps: P2PClientDeps = {},
52
54
  ) {
53
55
  const config = await configureP2PClientAddresses({
54
56
  ...inputConfig,
@@ -70,19 +72,45 @@ export async function createP2PClient<T extends P2PClientType>(
70
72
  const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME, 1, config, bindings);
71
73
  const l1Constants = await archiver.getL1Constants();
72
74
 
73
- const mempools: MemPools = {
74
- txPool:
75
- deps.txPool ??
76
- new AztecKVTxPool(store, archive, worldStateSynchronizer, telemetry, {
75
+ const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
76
+ const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
77
+
78
+ const txPool =
79
+ deps.txPool ??
80
+ new AztecKVTxPoolV2(
81
+ store,
82
+ archive,
83
+ {
84
+ l2BlockSource: archiver,
85
+ worldStateSynchronizer,
86
+ createTxValidator: async () => {
87
+ // We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
88
+ const currentBlockNumber = await archiver.getBlockNumber();
89
+ const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
90
+ return createTxValidatorForTransactionsEnteringPendingTxPool(
91
+ worldStateSynchronizer,
92
+ nextSlotTimestamp,
93
+ BlockNumber(currentBlockNumber + 1),
94
+ );
95
+ },
96
+ },
97
+ telemetry,
98
+ {
77
99
  maxPendingTxCount: config.maxPendingTxCount,
78
100
  archivedTxLimit: config.archivedTxLimit,
79
- }),
80
- attestationPool: deps.attestationPool ?? new KvAttestationPool(attestationStore, telemetry),
101
+ minTxPoolAgeMs: config.minTxPoolAgeMs,
102
+ dropTransactionsProbability: config.dropTransactionsProbability,
103
+ },
104
+ dateProvider,
105
+ );
106
+
107
+ const mempools: MemPools = {
108
+ txPool,
109
+ attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
81
110
  };
82
111
 
83
- const p2pService = await createP2PService<T>(
112
+ const p2pService = await createP2PService(
84
113
  config,
85
- clientType,
86
114
  archiver,
87
115
  proofVerifier,
88
116
  worldStateSynchronizer,
@@ -98,6 +126,7 @@ export async function createP2PClient<T extends P2PClientType>(
98
126
 
99
127
  const nodeSources = [
100
128
  ...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, config),
129
+ ...(deps.rpcTxProviders ?? []).map((node, i) => new NodeRpcTxSource(node, `node-rpc-provider-${i}`)),
101
130
  ...(deps.txCollectionNodeSources ?? []),
102
131
  ];
103
132
  if (nodeSources.length > 0) {
@@ -106,36 +135,54 @@ export async function createP2PClient<T extends P2PClientType>(
106
135
  });
107
136
  }
108
137
 
138
+ const fileStoreSources = await createFileStoreTxSources(
139
+ config.txCollectionFileStoreUrls,
140
+ txFileStoreBasePath,
141
+ logger.createChild('file-store-tx-source'),
142
+ telemetry,
143
+ );
144
+ if (fileStoreSources.length > 0) {
145
+ logger.info(`Using ${fileStoreSources.length} file store sources for tx collection.`, {
146
+ stores: fileStoreSources.map(s => s.getInfo()),
147
+ });
148
+ }
149
+
109
150
  const txCollection = new TxCollection(
110
151
  p2pService.getBatchTxRequesterService(),
111
152
  nodeSources,
112
153
  l1Constants,
113
154
  mempools.txPool,
114
155
  config,
156
+ fileStoreSources,
115
157
  dateProvider,
116
158
  telemetry,
117
159
  logger.createChild('tx-collection'),
118
160
  );
119
161
 
120
- const txFileStore = await TxFileStore.create(mempools.txPool, config, logger.createChild('tx-file-store'), telemetry);
162
+ const txFileStore = await TxFileStore.create(
163
+ mempools.txPool,
164
+ config,
165
+ txFileStoreBasePath,
166
+ logger.createChild('tx-file-store'),
167
+ telemetry,
168
+ );
121
169
 
122
170
  return new P2PClient(
123
- clientType,
124
171
  store,
125
172
  archiver,
126
173
  mempools,
127
174
  p2pService,
128
175
  txCollection,
129
176
  txFileStore,
177
+ epochCache,
130
178
  config,
131
179
  dateProvider,
132
180
  telemetry,
133
181
  );
134
182
  }
135
183
 
136
- async function createP2PService<T extends P2PClientType>(
184
+ async function createP2PService(
137
185
  config: P2PConfig & DataStoreConfig,
138
- clientType: T,
139
186
  archiver: L2BlockSource & ContractDataSource,
140
187
  proofVerifier: ClientProtocolCircuitVerifier,
141
188
  worldStateSynchronizer: WorldStateSynchronizer,
@@ -143,7 +190,7 @@ async function createP2PService<T extends P2PClientType>(
143
190
  store: AztecAsyncKVStore,
144
191
  peerStore: AztecLMDBStoreV2,
145
192
  mempools: MemPools,
146
- p2pServiceFactory: P2PClientDeps<T>['p2pServiceFactory'],
193
+ p2pServiceFactory: P2PClientDeps['p2pServiceFactory'],
147
194
  packageVersion: string,
148
195
  logger: Logger,
149
196
  telemetry: TelemetryClient,
@@ -159,7 +206,7 @@ async function createP2PService<T extends P2PClientType>(
159
206
  const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
160
207
  const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
161
208
 
162
- const p2pService = await (p2pServiceFactory ?? LibP2PService.new<T>)(clientType, config, peerId, {
209
+ const p2pService = await (p2pServiceFactory ?? LibP2PService.new)(config, peerId, {
163
210
  packageVersion,
164
211
  mempools,
165
212
  l2BlockSource: archiver,
@@ -1,7 +1,8 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
2
- import type { P2PApiFull } from '@aztec/stdlib/interfaces/server';
3
- import type { BlockProposal, CheckpointAttestation, CheckpointProposal, P2PClientType } from '@aztec/stdlib/p2p';
4
- import type { Tx, TxHash } from '@aztec/stdlib/tx';
3
+ import type { ITxProvider, P2PClient } from '@aztec/stdlib/interfaces/server';
4
+ import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
5
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
5
6
 
6
7
  import type { PeerId } from '@libp2p/interface';
7
8
  import type { ENR } from '@nethermindeth/enr';
@@ -13,7 +14,12 @@ import type {
13
14
  ReqRespSubProtocolHandler,
14
15
  ReqRespSubProtocolValidators,
15
16
  } from '../services/reqresp/interface.js';
16
- import type { P2PBlockReceivedCallback, P2PCheckpointReceivedCallback } from '../services/service.js';
17
+ import type {
18
+ DuplicateAttestationInfo,
19
+ DuplicateProposalInfo,
20
+ P2PBlockReceivedCallback,
21
+ P2PCheckpointReceivedCallback,
22
+ } from '../services/service.js';
17
23
 
18
24
  /**
19
25
  * Enum defining the possible states of the p2p client.
@@ -42,7 +48,7 @@ export interface P2PSyncState {
42
48
  /**
43
49
  * Interface of a P2P client.
44
50
  **/
45
- export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> & {
51
+ export type P2P = P2PClient & {
46
52
  /**
47
53
  * Broadcasts a block proposal to other peers.
48
54
  *
@@ -79,12 +85,21 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
79
85
  registerCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
80
86
 
81
87
  /**
82
- * Request a list of transactions from another peer by their tx hashes.
83
- * @param txHashes - Hashes of the txs to query.
84
- * @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
85
- * @returns A list of transactions or undefined if the transactions are not found.
88
+ * Registers a callback invoked when a duplicate proposal is detected (equivocation).
89
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
90
+ *
91
+ * @param callback - Function called with info about the duplicate proposal
92
+ */
93
+ registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void;
94
+
95
+ /**
96
+ * Registers a callback invoked when a duplicate attestation is detected (equivocation).
97
+ * A validator signing attestations for different proposals at the same slot.
98
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
99
+ *
100
+ * @param callback - Function called with info about the duplicate attestation
86
101
  */
87
- requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId): Promise<Tx[]>;
102
+ registerDuplicateAttestationCallback(callback: (info: DuplicateAttestationInfo) => void): void;
88
103
 
89
104
  /**
90
105
  * Verifies the 'tx' and, if valid, adds it to local tx pool and forwards it to other peers.
@@ -93,18 +108,10 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
93
108
  sendTx(tx: Tx): Promise<void>;
94
109
 
95
110
  /**
96
- * Adds transactions to the pool. Does not send to peers or validate the tx.
97
- * @param txs - The transactions.
98
- * @returns The number of txs added to the pool. Note if the transaction already exists, it will not be added again.
111
+ * Handles failed transaction execution by removing txs from the pool.
112
+ * @param txHashes - Hashes of the transactions that failed execution.
99
113
  **/
100
- addTxsToPool(txs: Tx[]): Promise<number>;
101
-
102
- /**
103
- * Deletes 'txs' from the pool, given hashes.
104
- * NOT used if we use sendTx as reconcileTxPool will handle this.
105
- * @param txHashes - Hashes to check.
106
- **/
107
- deleteTxs(txHashes: TxHash[]): Promise<void>;
114
+ handleFailedExecution(txHashes: TxHash[]): Promise<void>;
108
115
 
109
116
  /**
110
117
  * Returns a transaction in the transaction pool by its hash.
@@ -127,14 +134,6 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
127
134
  */
128
135
  hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
129
136
 
130
- /**
131
- * Returns transactions in the transaction pool by hash, requesting from the network if not found.
132
- * @param txHashes - Hashes of tx to return.
133
- * @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
134
- * @returns An array of tx or undefined.
135
- */
136
- getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]>;
137
-
138
137
  /**
139
138
  * Returns an archived transaction from the transaction pool by its hash.
140
139
  * @param txHash - Hash of tx to return.
@@ -152,14 +151,28 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
152
151
  /** Returns an iterator over pending txs on the mempool. */
153
152
  iteratePendingTxs(): AsyncIterableIterator<Tx>;
154
153
 
154
+ /** Returns an iterator over pending txs that have been in the pool long enough to be eligible for block building. */
155
+ iterateEligiblePendingTxs(): AsyncIterableIterator<Tx>;
156
+
155
157
  /** Returns the number of pending txs in the mempool. */
156
158
  getPendingTxCount(): Promise<number>;
157
159
 
158
160
  /**
159
- * Marks transactions as non-evictable in the pool.
160
- * @param txHashes - Hashes of the transactions to mark as non-evictable.
161
+ * Protects existing transactions by hash for a given slot.
162
+ * Returns hashes of transactions that weren't found in the pool.
163
+ * @param txHashes - Hashes of the transactions to protect.
164
+ * @param blockHeader - The block header providing slot context.
165
+ * @returns Hashes of transactions not found in the pool.
161
166
  */
162
- markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
167
+ protectTxs(txHashes: TxHash[], blockHeader: BlockHeader): Promise<TxHash[]>;
168
+
169
+ /**
170
+ * Prepares the pool for a new slot.
171
+ * Unprotects transactions from earlier slots and validates them before
172
+ * returning to pending state.
173
+ * @param slotNumber - The slot number to prepare for
174
+ */
175
+ prepareForSlot(slotNumber: SlotNumber): Promise<void>;
163
176
 
164
177
  /**
165
178
  * Starts the p2p client.
@@ -192,10 +205,13 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
192
205
  /** Identifies a p2p client. */
193
206
  isP2PClient(): true;
194
207
 
208
+ /** Returns the tx provider used for fetching transactions. */
209
+ getTxProvider(): ITxProvider;
210
+
195
211
  updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
196
212
 
197
- /** Validates a set of txs. */
198
- validate(txs: Tx[]): Promise<void>;
213
+ /** Validates a set of txs received in a block proposal. */
214
+ validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
199
215
 
200
216
  /** Clears the db. */
201
217
  clear(): Promise<void>;
@@ -208,6 +224,12 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
208
224
 
209
225
  handleAuthRequestFromPeer(authRequest: AuthRequest, peerId: PeerId): Promise<StatusMessage>;
210
226
 
227
+ /** Checks if any block proposals exist for the given slot. */
228
+ hasBlockProposalsForSlot(slot: SlotNumber): Promise<boolean>;
229
+
211
230
  /** If node running this P2P stack is validator, passes in validator address to P2P layer */
212
231
  registerThisValidatorAddresses(address: EthAddress[]): void;
232
+
233
+ /** Returns the number of peers in the GossipSub mesh for a given topic type. */
234
+ getGossipMeshPeerCount(topicType: TopicType): Promise<number>;
213
235
  };