@aztec/p2p 0.0.1-commit.c80b6263 → 0.0.1-commit.cd76b27

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 (330) hide show
  1. package/dest/client/factory.d.ts +7 -6
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +47 -10
  4. package/dest/client/interface.d.ts +43 -23
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +40 -42
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +156 -145
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +7 -7
  10. package/dest/config.d.ts +29 -4
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +19 -2
  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 +95 -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 +74 -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 +209 -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 +8 -0
  85. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +97 -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 +152 -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 +355 -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 +878 -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 +3 -3
  103. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  104. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  105. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  106. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  107. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +18 -5
  108. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  109. package/dest/msg_validators/tx_validator/block_header_validator.js +2 -2
  110. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
  111. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  112. package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
  113. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
  114. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  115. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  116. package/dest/services/data_store.d.ts +1 -1
  117. package/dest/services/data_store.d.ts.map +1 -1
  118. package/dest/services/data_store.js +10 -6
  119. package/dest/services/dummy_service.d.ts +12 -3
  120. package/dest/services/dummy_service.d.ts.map +1 -1
  121. package/dest/services/dummy_service.js +9 -0
  122. package/dest/services/encoding.d.ts +2 -2
  123. package/dest/services/encoding.d.ts.map +1 -1
  124. package/dest/services/encoding.js +4 -3
  125. package/dest/services/gossipsub/index.d.ts +3 -0
  126. package/dest/services/gossipsub/index.d.ts.map +1 -0
  127. package/dest/services/gossipsub/index.js +2 -0
  128. package/dest/services/gossipsub/scoring.d.ts +21 -3
  129. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  130. package/dest/services/gossipsub/scoring.js +24 -7
  131. package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
  132. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  133. package/dest/services/gossipsub/topic_score_params.js +346 -0
  134. package/dest/services/index.d.ts +2 -1
  135. package/dest/services/index.d.ts.map +1 -1
  136. package/dest/services/index.js +1 -0
  137. package/dest/services/libp2p/libp2p_service.d.ts +85 -35
  138. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  139. package/dest/services/libp2p/libp2p_service.js +379 -280
  140. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  141. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  142. package/dest/services/peer-manager/peer_scoring.js +25 -2
  143. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +6 -5
  144. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  145. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +13 -17
  146. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
  147. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  148. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
  149. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  150. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
  151. package/dest/services/reqresp/interface.d.ts +10 -1
  152. package/dest/services/reqresp/interface.d.ts.map +1 -1
  153. package/dest/services/reqresp/interface.js +15 -1
  154. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  155. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  156. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +17 -12
  157. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +25 -14
  158. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  159. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +40 -24
  160. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  161. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  162. package/dest/services/reqresp/protocols/tx.js +20 -0
  163. package/dest/services/reqresp/reqresp.d.ts +1 -1
  164. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  165. package/dest/services/reqresp/reqresp.js +11 -4
  166. package/dest/services/service.d.ts +38 -2
  167. package/dest/services/service.d.ts.map +1 -1
  168. package/dest/services/tx_collection/config.d.ts +22 -4
  169. package/dest/services/tx_collection/config.d.ts.map +1 -1
  170. package/dest/services/tx_collection/config.js +49 -3
  171. package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
  172. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  173. package/dest/services/tx_collection/fast_tx_collection.js +64 -48
  174. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  175. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  176. package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
  177. package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
  178. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  179. package/dest/services/tx_collection/file_store_tx_source.js +90 -0
  180. package/dest/services/tx_collection/index.d.ts +3 -2
  181. package/dest/services/tx_collection/index.d.ts.map +1 -1
  182. package/dest/services/tx_collection/index.js +1 -0
  183. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  184. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  185. package/dest/services/tx_collection/instrumentation.js +2 -1
  186. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  187. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  188. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  189. package/dest/services/tx_collection/proposal_tx_collector.d.ts +15 -14
  190. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  191. package/dest/services/tx_collection/proposal_tx_collector.js +6 -6
  192. package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
  193. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  194. package/dest/services/tx_collection/slow_tx_collection.js +60 -26
  195. package/dest/services/tx_collection/tx_collection.d.ts +23 -10
  196. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  197. package/dest/services/tx_collection/tx_collection.js +75 -3
  198. package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
  199. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  200. package/dest/services/tx_collection/tx_collection_sink.js +26 -29
  201. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  202. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  203. package/dest/services/tx_collection/tx_source.js +19 -2
  204. package/dest/services/tx_file_store/config.d.ts +16 -0
  205. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  206. package/dest/services/tx_file_store/config.js +22 -0
  207. package/dest/services/tx_file_store/index.d.ts +4 -0
  208. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  209. package/dest/services/tx_file_store/index.js +3 -0
  210. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  211. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  212. package/dest/services/tx_file_store/instrumentation.js +29 -0
  213. package/dest/services/tx_file_store/tx_file_store.d.ts +48 -0
  214. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  215. package/dest/services/tx_file_store/tx_file_store.js +152 -0
  216. package/dest/services/tx_provider.d.ts +3 -3
  217. package/dest/services/tx_provider.d.ts.map +1 -1
  218. package/dest/services/tx_provider.js +5 -4
  219. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  220. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  221. package/dest/test-helpers/mock-pubsub.d.ts +29 -2
  222. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  223. package/dest/test-helpers/mock-pubsub.js +103 -2
  224. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  225. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  226. package/dest/test-helpers/reqresp-nodes.js +2 -1
  227. package/dest/test-helpers/testbench-utils.d.ts +45 -38
  228. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  229. package/dest/test-helpers/testbench-utils.js +130 -60
  230. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  231. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  232. package/dest/testbench/p2p_client_testbench_worker.js +11 -11
  233. package/dest/util.d.ts +2 -2
  234. package/dest/util.d.ts.map +1 -1
  235. package/package.json +14 -14
  236. package/src/client/factory.ts +89 -14
  237. package/src/client/interface.ts +59 -23
  238. package/src/client/p2p_client.ts +196 -167
  239. package/src/client/test/tx_proposal_collector/README.md +4 -4
  240. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -10
  241. package/src/config.ts +41 -2
  242. package/src/errors/tx-pool.error.ts +12 -0
  243. package/src/index.ts +1 -0
  244. package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
  245. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  246. package/src/mem_pools/attestation_pool/index.ts +9 -2
  247. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  248. package/src/mem_pools/index.ts +4 -1
  249. package/src/mem_pools/interface.ts +4 -4
  250. package/src/mem_pools/tx_pool/README.md +1 -1
  251. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  252. package/src/mem_pools/tx_pool_v2/README.md +275 -0
  253. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  254. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  255. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  256. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  257. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
  258. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +122 -0
  259. package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
  260. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
  261. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  262. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  263. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +87 -0
  264. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
  265. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  266. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  267. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  268. package/src/mem_pools/tx_pool_v2/interfaces.ts +239 -0
  269. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +242 -0
  270. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  271. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
  272. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
  273. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1052 -0
  274. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  275. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  276. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  277. package/src/msg_validators/tx_validator/block_header_validator.ts +18 -8
  278. package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
  279. package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
  280. package/src/services/data_store.ts +10 -7
  281. package/src/services/dummy_service.ts +17 -1
  282. package/src/services/encoding.ts +4 -3
  283. package/src/services/gossipsub/README.md +641 -0
  284. package/src/services/gossipsub/index.ts +2 -0
  285. package/src/services/gossipsub/scoring.ts +29 -5
  286. package/src/services/gossipsub/topic_score_params.ts +487 -0
  287. package/src/services/index.ts +1 -0
  288. package/src/services/libp2p/libp2p_service.ts +382 -282
  289. package/src/services/peer-manager/peer_scoring.ts +25 -0
  290. package/src/services/reqresp/batch-tx-requester/README.md +14 -14
  291. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +18 -18
  292. package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
  293. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
  294. package/src/services/reqresp/interface.ts +26 -1
  295. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +24 -15
  296. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -24
  297. package/src/services/reqresp/protocols/tx.ts +22 -0
  298. package/src/services/reqresp/reqresp.ts +13 -3
  299. package/src/services/service.ts +50 -1
  300. package/src/services/tx_collection/config.ts +74 -6
  301. package/src/services/tx_collection/fast_tx_collection.ts +74 -51
  302. package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
  303. package/src/services/tx_collection/file_store_tx_source.ts +117 -0
  304. package/src/services/tx_collection/index.ts +2 -1
  305. package/src/services/tx_collection/instrumentation.ts +7 -1
  306. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  307. package/src/services/tx_collection/proposal_tx_collector.ts +20 -21
  308. package/src/services/tx_collection/slow_tx_collection.ts +66 -33
  309. package/src/services/tx_collection/tx_collection.ts +113 -16
  310. package/src/services/tx_collection/tx_collection_sink.ts +30 -34
  311. package/src/services/tx_collection/tx_source.ts +22 -3
  312. package/src/services/tx_file_store/config.ts +37 -0
  313. package/src/services/tx_file_store/index.ts +3 -0
  314. package/src/services/tx_file_store/instrumentation.ts +36 -0
  315. package/src/services/tx_file_store/tx_file_store.ts +175 -0
  316. package/src/services/tx_provider.ts +8 -7
  317. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  318. package/src/test-helpers/mock-pubsub.ts +143 -3
  319. package/src/test-helpers/reqresp-nodes.ts +2 -1
  320. package/src/test-helpers/testbench-utils.ts +129 -71
  321. package/src/testbench/p2p_client_testbench_worker.ts +23 -16
  322. package/src/util.ts +7 -1
  323. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  324. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  325. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  326. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  327. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  328. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  329. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  330. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -0,0 +1,65 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { EvictionEvent } from './interfaces.js';
3
+ /**
4
+ * Eviction rule that removes invalid transactions after a block is mined.
5
+ * Only triggers on BLOCK_MINED events.
6
+ *
7
+ * Eviction criteria includes:
8
+ * - Transactions with nullifiers that are already included in the mined block
9
+ * - Transactions with an expiration timestamp less than or equal to the mined block timestamp
10
+ */ export class InvalidTxsAfterMiningRule {
11
+ name = 'InvalidTxsAfterMining';
12
+ log = createLogger('p2p:tx_pool_v2:invalid_txs_after_mining_rule');
13
+ async evict(context, pool) {
14
+ if (context.event !== EvictionEvent.BLOCK_MINED) {
15
+ return {
16
+ reason: 'block_mined_invalid_txs',
17
+ success: true,
18
+ txsEvicted: []
19
+ };
20
+ }
21
+ try {
22
+ const { timestamp } = context.block.globalVariables;
23
+ const minedNullifiers = new Set(context.newNullifiers);
24
+ const txsToEvict = [];
25
+ const pendingTxs = pool.getPendingTxs();
26
+ for (const meta of pendingTxs){
27
+ // Evict pending txs that share nullifiers with mined txs
28
+ if (meta.nullifiers.some((nullifier)=>minedNullifiers.has(nullifier))) {
29
+ txsToEvict.push(meta.txHash);
30
+ continue;
31
+ }
32
+ // Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
33
+ if (meta.expirationTimestamp <= timestamp) {
34
+ this.log.verbose(`Evicting tx ${meta.txHash} from pool due to the tx being expired (expirationTimestamp: ${meta.expirationTimestamp}, mined block timestamp: ${timestamp})`);
35
+ txsToEvict.push(meta.txHash);
36
+ continue;
37
+ }
38
+ }
39
+ if (txsToEvict.length > 0) {
40
+ this.log.info(`Evicted ${txsToEvict.length} invalid txs after block mined`);
41
+ await pool.deleteTxs(txsToEvict, this.name);
42
+ }
43
+ this.log.debug(`Evicted ${txsToEvict.length} invalid txs after block mined`, {
44
+ txHashes: txsToEvict
45
+ });
46
+ return {
47
+ reason: 'block_mined_invalid_txs',
48
+ success: true,
49
+ txsEvicted: txsToEvict
50
+ };
51
+ } catch (err) {
52
+ this.log.error('Failed to evict invalid transactions after mining', {
53
+ err
54
+ });
55
+ return {
56
+ reason: 'block_mined_invalid_txs',
57
+ success: false,
58
+ txsEvicted: [],
59
+ error: new Error('Failed to evict invalid txs after mining', {
60
+ cause: err
61
+ })
62
+ };
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,17 @@
1
+ import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
2
+ import type { EvictionContext, EvictionResult, EvictionRule, PoolOperations } from './interfaces.js';
3
+ /**
4
+ * Eviction rule that removes invalid transactions after a blockchain reorganization.
5
+ * Only triggers on CHAIN_PRUNED events.
6
+ *
7
+ * Eviction criteria includes:
8
+ * - Transactions that reference pruned block hashes (invalid by definition)
9
+ */
10
+ export declare class InvalidTxsAfterReorgRule implements EvictionRule {
11
+ private worldState;
12
+ readonly name = "InvalidTxsAfterReorg";
13
+ private log;
14
+ constructor(worldState: WorldStateSynchronizer);
15
+ evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult>;
16
+ }
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW52YWxpZF90eHNfYWZ0ZXJfcmVvcmdfcnVsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL21lbV9wb29scy90eF9wb29sX3YyL2V2aWN0aW9uL2ludmFsaWRfdHhzX2FmdGVyX3Jlb3JnX3J1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUc5RSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsY0FBYyxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUdyRzs7Ozs7O0dBTUc7QUFDSCxxQkFBYSx3QkFBeUIsWUFBVyxZQUFZO0lBSy9DLE9BQU8sQ0FBQyxVQUFVO0lBSjlCLFNBQWdCLElBQUksMEJBQTBCO0lBRTlDLE9BQU8sQ0FBQyxHQUFHLENBQStEO0lBRTFFLFlBQW9CLFVBQVUsRUFBRSxzQkFBc0IsRUFBSTtJQUVwRCxLQUFLLENBQUMsT0FBTyxFQUFFLGVBQWUsRUFBRSxJQUFJLEVBQUUsY0FBYyxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0E2RW5GO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalid_txs_after_reorg_rule.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAG9E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGrG;;;;;;GAMG;AACH,qBAAa,wBAAyB,YAAW,YAAY;IAK/C,OAAO,CAAC,UAAU;IAJ9B,SAAgB,IAAI,0BAA0B;IAE9C,OAAO,CAAC,GAAG,CAA+D;IAE1E,YAAoB,UAAU,EAAE,sBAAsB,EAAI;IAEpD,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CA6EnF;CACF"}
@@ -0,0 +1,93 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
4
+ import { EvictionEvent } from './interfaces.js';
5
+ /**
6
+ * Eviction rule that removes invalid transactions after a blockchain reorganization.
7
+ * Only triggers on CHAIN_PRUNED events.
8
+ *
9
+ * Eviction criteria includes:
10
+ * - Transactions that reference pruned block hashes (invalid by definition)
11
+ */ export class InvalidTxsAfterReorgRule {
12
+ worldState;
13
+ name;
14
+ log;
15
+ constructor(worldState){
16
+ this.worldState = worldState;
17
+ this.name = 'InvalidTxsAfterReorg';
18
+ this.log = createLogger('p2p:tx_pool_v2:invalid_txs_after_reorg_rule');
19
+ }
20
+ async evict(context, pool) {
21
+ if (context.event !== EvictionEvent.CHAIN_PRUNED) {
22
+ return {
23
+ reason: 'reorg_invalid_txs',
24
+ success: true,
25
+ txsEvicted: []
26
+ };
27
+ }
28
+ try {
29
+ const pendingTxs = pool.getPendingTxs();
30
+ // Deduplicate block hashes to reduce redundant DB lookups
31
+ const uniqueBlockHashes = new Map();
32
+ const txsByBlockHash = new Map();
33
+ for (const meta of pendingTxs){
34
+ const blockHashStr = meta.anchorBlockHeaderHash;
35
+ if (!txsByBlockHash.has(blockHashStr)) {
36
+ txsByBlockHash.set(blockHashStr, []);
37
+ uniqueBlockHashes.set(blockHashStr, Fr.fromHexString(blockHashStr));
38
+ }
39
+ txsByBlockHash.get(blockHashStr).push(meta.txHash);
40
+ }
41
+ // Ensure world state is synced to this block before accessing the snapshot
42
+ await this.worldState.syncImmediate(context.blockNumber);
43
+ const db = this.worldState.getSnapshot(context.blockNumber);
44
+ // Check which blocks exist in the archive
45
+ const blockHashArray = Array.from(uniqueBlockHashes.values());
46
+ const blocksFromDb = await db.findLeafIndices(MerkleTreeId.ARCHIVE, blockHashArray);
47
+ // Build set of pruned block hashes
48
+ const prunedBlockHashes = new Set();
49
+ let i = 0;
50
+ for (const [blockHashStr] of uniqueBlockHashes){
51
+ if (blocksFromDb[i] === undefined) {
52
+ prunedBlockHashes.add(blockHashStr);
53
+ }
54
+ i++;
55
+ }
56
+ // Identify txs whose anchor block was pruned
57
+ const txsToEvict = [];
58
+ for (const [blockHashStr, txHashes] of txsByBlockHash){
59
+ if (prunedBlockHashes.has(blockHashStr)) {
60
+ txsToEvict.push(...txHashes);
61
+ }
62
+ }
63
+ if (txsToEvict.length > 0) {
64
+ this.log.info(`Evicting ${txsToEvict.length} txs from pool due to referencing pruned blocks`);
65
+ await pool.deleteTxs(txsToEvict, this.name);
66
+ }
67
+ const keptCount = pendingTxs.length - txsToEvict.length;
68
+ if (keptCount > 0) {
69
+ this.log.verbose(`Kept ${keptCount} txs that did not reference pruned blocks`);
70
+ }
71
+ this.log.debug(`Evicted ${txsToEvict.length} invalid txs after reorg`, {
72
+ txHashes: txsToEvict
73
+ });
74
+ return {
75
+ reason: 'reorg_invalid_txs',
76
+ success: true,
77
+ txsEvicted: txsToEvict
78
+ };
79
+ } catch (err) {
80
+ this.log.error('Failed to evict invalid transactions after reorg', {
81
+ err
82
+ });
83
+ return {
84
+ reason: 'reorg_invalid_txs',
85
+ success: false,
86
+ txsEvicted: [],
87
+ error: new Error('Failed to evict invalid txs after reorg', {
88
+ cause: err
89
+ })
90
+ };
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,16 @@
1
+ import type { EvictionConfig, EvictionContext, EvictionResult, EvictionRule, PoolOperations } from './interfaces.js';
2
+ /**
3
+ * Eviction rule that removes low-priority transactions when the pool exceeds configured limits.
4
+ * Only triggers on TXS_ADDED events.
5
+ */
6
+ export declare class LowPriorityEvictionRule implements EvictionRule {
7
+ readonly name = "LowPriorityEviction";
8
+ private log;
9
+ private maxPoolSize;
10
+ constructor(config: {
11
+ maxPoolSize: number;
12
+ });
13
+ evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult>;
14
+ updateConfig(config: EvictionConfig): void;
15
+ }
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG93X3ByaW9yaXR5X2V2aWN0aW9uX3J1bGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvdHhfcG9vbF92Mi9ldmljdGlvbi9sb3dfcHJpb3JpdHlfZXZpY3Rpb25fcnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsZUFBZSxFQUFFLGNBQWMsRUFBRSxZQUFZLEVBQUUsY0FBYyxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFHckg7OztHQUdHO0FBQ0gscUJBQWEsdUJBQXdCLFlBQVcsWUFBWTtJQUMxRCxTQUFnQixJQUFJLHlCQUF5QjtJQUU3QyxPQUFPLENBQUMsR0FBRyxDQUE2RDtJQUN4RSxPQUFPLENBQUMsV0FBVyxDQUFTO0lBRTVCLFlBQVksTUFBTSxFQUFFO1FBQUUsV0FBVyxFQUFFLE1BQU0sQ0FBQTtLQUFFLEVBRTFDO0lBRUssS0FBSyxDQUFDLE9BQU8sRUFBRSxlQUFlLEVBQUUsSUFBSSxFQUFFLGNBQWMsR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBNERuRjtJQUVELFlBQVksQ0FBQyxNQUFNLEVBQUUsY0FBYyxHQUFHLElBQUksQ0FJekM7Q0FDRiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"low_priority_eviction_rule.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGrH;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAC1D,SAAgB,IAAI,yBAAyB;IAE7C,OAAO,CAAC,GAAG,CAA6D;IACxE,OAAO,CAAC,WAAW,CAAS;IAE5B,YAAY,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,EAE1C;IAEK,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CA4DnF;IAED,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAIzC;CACF"}
@@ -0,0 +1,74 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { EvictionEvent } from './interfaces.js';
3
+ /**
4
+ * Eviction rule that removes low-priority transactions when the pool exceeds configured limits.
5
+ * Only triggers on TXS_ADDED events.
6
+ */ export class LowPriorityEvictionRule {
7
+ name = 'LowPriorityEviction';
8
+ log = createLogger('p2p:tx_pool_v2:low_priority_eviction_rule');
9
+ maxPoolSize;
10
+ constructor(config){
11
+ this.maxPoolSize = config.maxPoolSize;
12
+ }
13
+ async evict(context, pool) {
14
+ if (context.event !== EvictionEvent.TXS_ADDED) {
15
+ return {
16
+ reason: 'low_priority',
17
+ success: true,
18
+ txsEvicted: []
19
+ };
20
+ }
21
+ if (this.maxPoolSize === 0) {
22
+ return {
23
+ reason: 'low_priority',
24
+ success: true,
25
+ txsEvicted: []
26
+ };
27
+ }
28
+ try {
29
+ const currentTxCount = pool.getPendingTxCount();
30
+ if (currentTxCount <= this.maxPoolSize) {
31
+ this.log.trace(`Not evicting low priority txs. Pending tx count below limit ${currentTxCount} <= ${this.maxPoolSize}`);
32
+ return {
33
+ reason: 'low_priority',
34
+ success: true,
35
+ txsEvicted: []
36
+ };
37
+ }
38
+ this.log.info(`Evicting low priority txs. Pending tx count above limit: ${currentTxCount} > ${this.maxPoolSize}`);
39
+ const numberToEvict = currentTxCount - this.maxPoolSize;
40
+ const txsToEvict = pool.getLowestPriorityPending(numberToEvict);
41
+ const toEvictSet = new Set(txsToEvict);
42
+ const numNewTxsEvicted = context.newTxHashes.filter((newTxHash)=>toEvictSet.has(newTxHash)).length;
43
+ if (txsToEvict.length > 0) {
44
+ this.log.info(`Evicted ${txsToEvict.length} low priority txs, including ${numNewTxsEvicted} newly added txs`);
45
+ await pool.deleteTxs(txsToEvict, this.name);
46
+ }
47
+ this.log.debug(`Evicted ${txsToEvict.length} low priority txs, including ${numNewTxsEvicted} newly added txs`, {
48
+ txHashes: txsToEvict
49
+ });
50
+ return {
51
+ reason: 'low_priority',
52
+ success: true,
53
+ txsEvicted: txsToEvict
54
+ };
55
+ } catch (err) {
56
+ this.log.error('Failed to evict low priority transactions', {
57
+ err
58
+ });
59
+ return {
60
+ reason: 'low_priority',
61
+ success: false,
62
+ txsEvicted: [],
63
+ error: new Error('Failed to evict low priority txs', {
64
+ cause: err
65
+ })
66
+ };
67
+ }
68
+ }
69
+ updateConfig(config) {
70
+ if (config.maxPendingTxCount !== undefined) {
71
+ this.maxPoolSize = config.maxPendingTxCount;
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,20 @@
1
+ import { type TxMetaData } from '../tx_metadata.js';
2
+ import { type EvictionConfig, type PreAddContext, type PreAddPoolAccess, type PreAddResult, type PreAddRule } from './interfaces.js';
3
+ /**
4
+ * Pre-add rule that checks if the pool is at capacity and handles low-priority eviction.
5
+ *
6
+ * When the pool is at capacity:
7
+ * - If incoming tx has higher priority than the lowest priority tx, evict the lowest and accept incoming
8
+ * - If incoming tx has equal or lower priority than the lowest, ignore incoming (it would be evicted anyway)
9
+ */
10
+ export declare class LowPriorityPreAddRule implements PreAddRule {
11
+ readonly name = "LowPriorityPreAdd";
12
+ private log;
13
+ private maxPoolSize;
14
+ constructor(config: {
15
+ maxPoolSize: number;
16
+ });
17
+ check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, context?: PreAddContext): Promise<PreAddResult>;
18
+ updateConfig(config: EvictionConfig): void;
19
+ }
20
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG93X3ByaW9yaXR5X3ByZV9hZGRfcnVsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL21lbV9wb29scy90eF9wb29sX3YyL2V2aWN0aW9uL2xvd19wcmlvcml0eV9wcmVfYWRkX3J1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLEtBQUssVUFBVSxFQUFtQixNQUFNLG1CQUFtQixDQUFDO0FBQ3JFLE9BQU8sRUFDTCxLQUFLLGNBQWMsRUFDbkIsS0FBSyxhQUFhLEVBQ2xCLEtBQUssZ0JBQWdCLEVBQ3JCLEtBQUssWUFBWSxFQUNqQixLQUFLLFVBQVUsRUFFaEIsTUFBTSxpQkFBaUIsQ0FBQztBQUV6Qjs7Ozs7O0dBTUc7QUFDSCxxQkFBYSxxQkFBc0IsWUFBVyxVQUFVO0lBQ3RELFNBQWdCLElBQUksdUJBQXVCO0lBRTNDLE9BQU8sQ0FBQyxHQUFHLENBQTREO0lBQ3ZFLE9BQU8sQ0FBQyxXQUFXLENBQVM7SUFFNUIsWUFBWSxNQUFNLEVBQUU7UUFBRSxXQUFXLEVBQUUsTUFBTSxDQUFBO0tBQUUsRUFFMUM7SUFFRCxLQUFLLENBQUMsWUFBWSxFQUFFLFVBQVUsRUFBRSxVQUFVLEVBQUUsZ0JBQWdCLEVBQUUsT0FBTyxDQUFDLEVBQUUsYUFBYSxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FxRDVHO0lBRUQsWUFBWSxDQUFDLE1BQU0sRUFBRSxjQUFjLEdBQUcsSUFBSSxDQUl6QztDQUNGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"low_priority_pre_add_rule.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,qBAAa,qBAAsB,YAAW,UAAU;IACtD,SAAgB,IAAI,uBAAuB;IAE3C,OAAO,CAAC,GAAG,CAA4D;IACvE,OAAO,CAAC,WAAW,CAAS;IAE5B,YAAY,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,EAE1C;IAED,KAAK,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAqD5G;IAED,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAIzC;CACF"}
@@ -0,0 +1,73 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { comparePriority } from '../tx_metadata.js';
3
+ import { TxPoolRejectionCode } from './interfaces.js';
4
+ /**
5
+ * Pre-add rule that checks if the pool is at capacity and handles low-priority eviction.
6
+ *
7
+ * When the pool is at capacity:
8
+ * - If incoming tx has higher priority than the lowest priority tx, evict the lowest and accept incoming
9
+ * - If incoming tx has equal or lower priority than the lowest, ignore incoming (it would be evicted anyway)
10
+ */ export class LowPriorityPreAddRule {
11
+ name = 'LowPriorityPreAdd';
12
+ log = createLogger('p2p:tx_pool_v2:low_priority_pre_add_rule');
13
+ maxPoolSize;
14
+ constructor(config){
15
+ this.maxPoolSize = config.maxPoolSize;
16
+ }
17
+ check(incomingMeta, poolAccess, context) {
18
+ // Skip if max pool size is disabled (0 = unlimited)
19
+ if (this.maxPoolSize === 0) {
20
+ return Promise.resolve({
21
+ shouldIgnore: false,
22
+ txHashesToEvict: []
23
+ });
24
+ }
25
+ const currentCount = poolAccess.getPendingTxCount();
26
+ // If pool is not at capacity, accept the tx
27
+ if (currentCount < this.maxPoolSize) {
28
+ return Promise.resolve({
29
+ shouldIgnore: false,
30
+ txHashesToEvict: []
31
+ });
32
+ }
33
+ // Pool is at capacity - need to compare priorities
34
+ const lowestPriorityMeta = poolAccess.getLowestPriorityPendingTx();
35
+ if (!lowestPriorityMeta) {
36
+ // No pending txs (shouldn't happen if count > 0, but handle gracefully)
37
+ return Promise.resolve({
38
+ shouldIgnore: false,
39
+ txHashesToEvict: []
40
+ });
41
+ }
42
+ // Compare incoming tx against lowest priority tx.
43
+ // feeOnly mode (RPC): use strict fee comparison only — avoids churn from hash ordering
44
+ // Default (gossip): use full comparePriority (fee + tx hash tiebreaker) for determinism
45
+ const isHigherPriority = context?.feeComparisonOnly ? incomingMeta.priorityFee > lowestPriorityMeta.priorityFee : comparePriority(incomingMeta, lowestPriorityMeta) > 0;
46
+ if (isHigherPriority) {
47
+ this.log.debug(`Pool at capacity (${currentCount}/${this.maxPoolSize}), evicting ${lowestPriorityMeta.txHash} ` + `(priority ${lowestPriorityMeta.priorityFee}) for ${incomingMeta.txHash} (priority ${incomingMeta.priorityFee})`);
48
+ return Promise.resolve({
49
+ shouldIgnore: false,
50
+ txHashesToEvict: [
51
+ lowestPriorityMeta.txHash
52
+ ]
53
+ });
54
+ }
55
+ // Incoming tx has equal or lower priority - ignore it (it would be evicted anyway)
56
+ this.log.debug(`Pool at capacity (${currentCount}/${this.maxPoolSize}), ignoring ${incomingMeta.txHash} ` + `(priority ${incomingMeta.priorityFee}) - lower than existing minimum (priority ${lowestPriorityMeta.priorityFee})`);
57
+ return Promise.resolve({
58
+ shouldIgnore: true,
59
+ txHashesToEvict: [],
60
+ reason: {
61
+ code: TxPoolRejectionCode.LOW_PRIORITY_FEE,
62
+ message: `Tx does not meet minimum priority fee. Required: ${lowestPriorityMeta.priorityFee + 1n}, got: ${incomingMeta.priorityFee}`,
63
+ minimumPriorityFee: lowestPriorityMeta.priorityFee + 1n,
64
+ txPriorityFee: incomingMeta.priorityFee
65
+ }
66
+ });
67
+ }
68
+ updateConfig(config) {
69
+ if (config.maxPendingTxCount !== undefined) {
70
+ this.maxPoolSize = config.maxPendingTxCount;
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,15 @@
1
+ import { type TxMetaData } from '../tx_metadata.js';
2
+ import type { PreAddContext, PreAddPoolAccess, PreAddResult, PreAddRule } from './interfaces.js';
3
+ /**
4
+ * Pre-add rule that checks for nullifier conflicts between incoming and existing transactions.
5
+ *
6
+ * When an incoming tx shares nullifiers with existing pending txs:
7
+ * - If the incoming tx has strictly higher priority, evict all conflicting txs
8
+ * - If any conflicting tx has equal or higher priority, ignore the incoming tx
9
+ */
10
+ export declare class NullifierConflictRule implements PreAddRule {
11
+ readonly name = "NullifierConflict";
12
+ private log;
13
+ check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, _context?: PreAddContext): Promise<PreAddResult>;
14
+ }
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnVsbGlmaWVyX2NvbmZsaWN0X3J1bGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvdHhfcG9vbF92Mi9ldmljdGlvbi9udWxsaWZpZXJfY29uZmxpY3RfcnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQUUsS0FBSyxVQUFVLEVBQTBCLE1BQU0sbUJBQW1CLENBQUM7QUFDNUUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLGdCQUFnQixFQUFFLFlBQVksRUFBRSxVQUFVLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUVqRzs7Ozs7O0dBTUc7QUFDSCxxQkFBYSxxQkFBc0IsWUFBVyxVQUFVO0lBQ3RELFNBQWdCLElBQUksdUJBQXVCO0lBRTNDLE9BQU8sQ0FBQyxHQUFHLENBQTBEO0lBRXJFLEtBQUssQ0FBQyxZQUFZLEVBQUUsVUFBVSxFQUFFLFVBQVUsRUFBRSxnQkFBZ0IsRUFBRSxRQUFRLENBQUMsRUFBRSxhQUFhLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQVk3RztDQUNGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nullifier_conflict_rule.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEjG;;;;;;GAMG;AACH,qBAAa,qBAAsB,YAAW,UAAU;IACtD,SAAgB,IAAI,uBAAuB;IAE3C,OAAO,CAAC,GAAG,CAA0D;IAErE,KAAK,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAY7G;CACF"}
@@ -0,0 +1,19 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { checkNullifierConflict } from '../tx_metadata.js';
3
+ /**
4
+ * Pre-add rule that checks for nullifier conflicts between incoming and existing transactions.
5
+ *
6
+ * When an incoming tx shares nullifiers with existing pending txs:
7
+ * - If the incoming tx has strictly higher priority, evict all conflicting txs
8
+ * - If any conflicting tx has equal or higher priority, ignore the incoming tx
9
+ */ export class NullifierConflictRule {
10
+ name = 'NullifierConflict';
11
+ log = createLogger('p2p:tx_pool_v2:nullifier_conflict_rule');
12
+ check(incomingMeta, poolAccess, _context) {
13
+ const result = checkNullifierConflict(incomingMeta, (nullifier)=>poolAccess.getTxHashByNullifier(nullifier), (txHash)=>poolAccess.getMetadata(txHash));
14
+ if (result.shouldIgnore) {
15
+ this.log.debug(`Ignoring tx ${incomingMeta.txHash}: ${result.reason?.message}`);
16
+ }
17
+ return Promise.resolve(result);
18
+ }
19
+ }
@@ -0,0 +1,6 @@
1
+ export { AztecKVTxPoolV2 } from './tx_pool_v2.js';
2
+ export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult, type PoolReadAccess, DEFAULT_TX_POOL_V2_CONFIG, } from './interfaces.js';
3
+ export { type TxMetaData, type TxState, buildTxMetaData, comparePriority } from './tx_metadata.js';
4
+ export { TxArchive } from './archive/index.js';
5
+ export { DeletedPool } from './deleted_pool.js';
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvdHhfcG9vbF92Mi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDbEQsT0FBTyxFQUNMLEtBQUssUUFBUSxFQUNiLEtBQUssY0FBYyxFQUNuQixLQUFLLGNBQWMsRUFDbkIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssY0FBYyxFQUNuQix5QkFBeUIsR0FDMUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN6QixPQUFPLEVBQUUsS0FBSyxVQUFVLEVBQUUsS0FBSyxPQUFPLEVBQUUsZUFBZSxFQUFFLGVBQWUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ25HLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUMvQyxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sbUJBQW1CLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool_v2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { AztecKVTxPoolV2 } from './tx_pool_v2.js';
2
+ export { DEFAULT_TX_POOL_V2_CONFIG } from './interfaces.js';
3
+ export { buildTxMetaData, comparePriority } from './tx_metadata.js';
4
+ export { TxArchive } from './archive/index.js';
5
+ export { DeletedPool } from './deleted_pool.js';
@@ -0,0 +1,15 @@
1
+ import { type TelemetryClient } from '@aztec/telemetry-client';
2
+ /** Callback that returns the current estimated metadata memory in bytes. */
3
+ export type MetadataMemoryCallback = () => number;
4
+ /** Instrumentation for TxPoolV2Impl internal operations. */
5
+ export declare class TxPoolV2Instrumentation {
6
+ #private;
7
+ constructor(telemetry: TelemetryClient, metadataMemoryCallback: MetadataMemoryCallback);
8
+ recordEvictions(count: number, reason: string): void;
9
+ recordIgnored(count: number): void;
10
+ recordRejected(count: number): void;
11
+ recordSoftDeletedHits(count: number): void;
12
+ recordMissingOnProtect(count: number): void;
13
+ recordMissingPreviouslyEvicted(count: number): void;
14
+ }
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdHJ1bWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbWVtX3Bvb2xzL3R4X3Bvb2xfdjIvaW5zdHJ1bWVudGF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFNTCxLQUFLLGVBQWUsRUFHckIsTUFBTSx5QkFBeUIsQ0FBQztBQUVqQyw0RUFBNEU7QUFDNUUsTUFBTSxNQUFNLHNCQUFzQixHQUFHLE1BQU0sTUFBTSxDQUFDO0FBRWxELDREQUE0RDtBQUM1RCxxQkFBYSx1QkFBdUI7O0lBU2xDLFlBQVksU0FBUyxFQUFFLGVBQWUsRUFBRSxzQkFBc0IsRUFBRSxzQkFBc0IsRUFtQnJGO0lBRUQsZUFBZSxDQUFDLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLE1BQU0sUUFFNUM7SUFFRCxhQUFhLENBQUMsS0FBSyxFQUFFLE1BQU0sUUFFMUI7SUFFRCxjQUFjLENBQUMsS0FBSyxFQUFFLE1BQU0sUUFFM0I7SUFFRCxxQkFBcUIsQ0FBQyxLQUFLLEVBQUUsTUFBTSxRQUVsQztJQUVELHNCQUFzQixDQUFDLEtBQUssRUFBRSxNQUFNLFFBRW5DO0lBRUQsOEJBQThCLENBQUMsS0FBSyxFQUFFLE1BQU0sUUFFM0M7Q0FDRiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool_v2/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,4EAA4E;AAC5E,MAAM,MAAM,sBAAsB,GAAG,MAAM,MAAM,CAAC;AAElD,4DAA4D;AAC5D,qBAAa,uBAAuB;;IASlC,YAAY,SAAS,EAAE,eAAe,EAAE,sBAAsB,EAAE,sBAAsB,EAmBrF;IAED,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAE5C;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,QAE1B;IAED,cAAc,CAAC,KAAK,EAAE,MAAM,QAE3B;IAED,qBAAqB,CAAC,KAAK,EAAE,MAAM,QAElC;IAED,sBAAsB,CAAC,KAAK,EAAE,MAAM,QAEnC;IAED,8BAA8B,CAAC,KAAK,EAAE,MAAM,QAE3C;CACF"}
@@ -0,0 +1,43 @@
1
+ import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
2
+ /** Instrumentation for TxPoolV2Impl internal operations. */ export class TxPoolV2Instrumentation {
3
+ #evictedCounter;
4
+ #ignoredCounter;
5
+ #rejectedCounter;
6
+ #softDeletedHitsCounter;
7
+ #missingOnProtectCounter;
8
+ #missingPreviouslyEvictedCounter;
9
+ #metadataMemoryGauge;
10
+ constructor(telemetry, metadataMemoryCallback){
11
+ const meter = telemetry.getMeter('TxPoolV2Impl');
12
+ this.#evictedCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_EVICTED_COUNT);
13
+ this.#ignoredCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_IGNORED_COUNT);
14
+ this.#rejectedCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_REJECTED_COUNT);
15
+ this.#softDeletedHitsCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_SOFT_DELETED_HITS);
16
+ this.#missingOnProtectCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_MISSING_ON_PROTECT);
17
+ this.#missingPreviouslyEvictedCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_MISSING_PREVIOUSLY_EVICTED);
18
+ this.#metadataMemoryGauge = meter.createObservableGauge(Metrics.MEMPOOL_TX_POOL_V2_METADATA_MEMORY);
19
+ this.#metadataMemoryGauge.addCallback((result)=>{
20
+ result.observe(metadataMemoryCallback());
21
+ });
22
+ }
23
+ recordEvictions(count, reason) {
24
+ this.#evictedCounter.add(count, {
25
+ [Attributes.TX_POOL_EVICTION_REASON]: reason
26
+ });
27
+ }
28
+ recordIgnored(count) {
29
+ this.#ignoredCounter.add(count);
30
+ }
31
+ recordRejected(count) {
32
+ this.#rejectedCounter.add(count);
33
+ }
34
+ recordSoftDeletedHits(count) {
35
+ this.#softDeletedHitsCounter.add(count);
36
+ }
37
+ recordMissingOnProtect(count) {
38
+ this.#missingOnProtectCounter.add(count);
39
+ }
40
+ recordMissingPreviouslyEvicted(count) {
41
+ this.#missingPreviouslyEvictedCounter.add(count);
42
+ }
43
+ }