@aztec/p2p 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c

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 (524) hide show
  1. package/dest/bootstrap/bootstrap.d.ts +4 -3
  2. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  3. package/dest/bootstrap/bootstrap.js +4 -4
  4. package/dest/client/factory.d.ts +7 -6
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +53 -14
  7. package/dest/client/interface.d.ts +58 -25
  8. package/dest/client/interface.d.ts.map +1 -1
  9. package/dest/client/p2p_client.d.ts +46 -51
  10. package/dest/client/p2p_client.d.ts.map +1 -1
  11. package/dest/client/p2p_client.js +601 -259
  12. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
  13. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
  14. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
  15. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
  16. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
  17. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
  18. package/dest/config.d.ts +35 -7
  19. package/dest/config.d.ts.map +1 -1
  20. package/dest/config.js +23 -9
  21. package/dest/errors/tx-pool.error.d.ts +8 -0
  22. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  23. package/dest/errors/tx-pool.error.js +9 -0
  24. package/dest/index.d.ts +2 -1
  25. package/dest/index.d.ts.map +1 -1
  26. package/dest/index.js +1 -0
  27. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +111 -76
  28. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  29. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  30. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  31. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  32. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +527 -287
  33. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  34. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  35. package/dest/mem_pools/attestation_pool/index.js +1 -2
  36. package/dest/mem_pools/attestation_pool/mocks.d.ts +9 -6
  37. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  38. package/dest/mem_pools/attestation_pool/mocks.js +16 -12
  39. package/dest/mem_pools/index.d.ts +3 -2
  40. package/dest/mem_pools/index.d.ts.map +1 -1
  41. package/dest/mem_pools/index.js +1 -1
  42. package/dest/mem_pools/instrumentation.d.ts +1 -1
  43. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  44. package/dest/mem_pools/instrumentation.js +5 -14
  45. package/dest/mem_pools/interface.d.ts +5 -5
  46. package/dest/mem_pools/interface.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +15 -10
  48. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +91 -50
  50. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +19 -5
  51. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
  52. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +59 -3
  53. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +79 -5
  54. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
  55. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +47 -0
  56. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
  57. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  58. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +122 -0
  59. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +2 -2
  60. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
  61. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  62. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +4 -4
  63. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
  64. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
  65. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +2 -2
  66. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  67. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
  68. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
  69. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -0
  70. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  71. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  72. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  73. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  74. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  75. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  76. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  77. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  78. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  79. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  80. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  81. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
  82. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  83. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  84. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
  85. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  86. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  87. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +95 -0
  88. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  89. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  90. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  91. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
  92. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  93. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
  94. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  95. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  96. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
  97. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  98. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  99. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  100. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  101. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  102. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
  103. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  104. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  105. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
  106. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  107. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  108. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  109. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  110. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  111. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  112. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  113. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  114. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  115. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
  116. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  117. package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
  118. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +97 -0
  119. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  120. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +152 -0
  121. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  122. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  123. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  124. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
  125. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  126. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +355 -0
  127. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -0
  128. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  129. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
  130. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -0
  131. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  132. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +896 -0
  133. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -4
  134. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  135. package/dest/msg_validators/attestation_validator/attestation_validator.js +51 -18
  136. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -7
  137. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  138. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +22 -13
  139. package/dest/msg_validators/clock_tolerance.d.ts +21 -0
  140. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  141. package/dest/msg_validators/clock_tolerance.js +37 -0
  142. package/dest/msg_validators/index.d.ts +2 -2
  143. package/dest/msg_validators/index.d.ts.map +1 -1
  144. package/dest/msg_validators/index.js +1 -1
  145. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
  146. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
  147. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
  148. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
  149. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
  150. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
  151. package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
  152. package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
  153. package/dest/msg_validators/proposal_validator/index.js +3 -0
  154. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
  155. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
  156. package/dest/msg_validators/proposal_validator/proposal_validator.js +104 -0
  157. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
  158. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
  159. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +212 -0
  160. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  161. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  162. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  163. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  164. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  165. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
  166. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  167. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  168. package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
  169. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  170. package/dest/msg_validators/tx_validator/data_validator.js +4 -1
  171. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
  172. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  173. package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
  174. package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
  175. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  176. package/dest/msg_validators/tx_validator/factory.js +21 -11
  177. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
  178. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
  179. package/dest/msg_validators/tx_validator/fee_payer_balance.js +20 -0
  180. package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
  181. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  182. package/dest/msg_validators/tx_validator/gas_validator.js +11 -16
  183. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  184. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  185. package/dest/msg_validators/tx_validator/index.js +1 -0
  186. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
  187. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  188. package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
  189. package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
  190. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  191. package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
  192. package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
  193. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
  194. package/dest/msg_validators/tx_validator/size_validator.js +23 -0
  195. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +22 -5
  196. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  197. package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
  198. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  199. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  200. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  201. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
  202. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  203. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
  204. package/dest/services/data_store.d.ts +1 -1
  205. package/dest/services/data_store.d.ts.map +1 -1
  206. package/dest/services/data_store.js +10 -6
  207. package/dest/services/discv5/discV5_service.js +1 -1
  208. package/dest/services/dummy_service.d.ts +28 -3
  209. package/dest/services/dummy_service.d.ts.map +1 -1
  210. package/dest/services/dummy_service.js +51 -0
  211. package/dest/services/encoding.d.ts +2 -2
  212. package/dest/services/encoding.d.ts.map +1 -1
  213. package/dest/services/encoding.js +9 -7
  214. package/dest/services/gossipsub/index.d.ts +3 -0
  215. package/dest/services/gossipsub/index.d.ts.map +1 -0
  216. package/dest/services/gossipsub/index.js +2 -0
  217. package/dest/services/gossipsub/scoring.d.ts +21 -3
  218. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  219. package/dest/services/gossipsub/scoring.js +24 -7
  220. package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
  221. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  222. package/dest/services/gossipsub/topic_score_params.js +346 -0
  223. package/dest/services/index.d.ts +2 -1
  224. package/dest/services/index.d.ts.map +1 -1
  225. package/dest/services/index.js +1 -0
  226. package/dest/services/libp2p/instrumentation.d.ts +1 -1
  227. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  228. package/dest/services/libp2p/instrumentation.js +30 -72
  229. package/dest/services/libp2p/libp2p_service.d.ts +106 -33
  230. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  231. package/dest/services/libp2p/libp2p_service.js +984 -317
  232. package/dest/services/peer-manager/metrics.d.ts +2 -2
  233. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  234. package/dest/services/peer-manager/metrics.js +21 -26
  235. package/dest/services/peer-manager/peer_manager.d.ts +2 -2
  236. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  237. package/dest/services/peer-manager/peer_manager.js +0 -10
  238. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  239. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  240. package/dest/services/peer-manager/peer_scoring.js +32 -6
  241. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +48 -0
  242. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  243. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +562 -0
  244. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  245. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  246. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  247. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +46 -0
  248. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  249. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  250. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +34 -0
  251. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  252. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +130 -0
  253. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
  254. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  255. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
  256. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
  257. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  258. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
  259. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
  260. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  261. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
  262. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
  263. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  264. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  265. package/dest/services/reqresp/constants.d.ts +12 -0
  266. package/dest/services/reqresp/constants.d.ts.map +1 -0
  267. package/dest/services/reqresp/constants.js +7 -0
  268. package/dest/services/reqresp/interface.d.ts +12 -1
  269. package/dest/services/reqresp/interface.d.ts.map +1 -1
  270. package/dest/services/reqresp/interface.js +15 -1
  271. package/dest/services/reqresp/metrics.d.ts +6 -5
  272. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  273. package/dest/services/reqresp/metrics.js +17 -21
  274. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
  275. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  276. package/dest/services/reqresp/protocols/block_txs/bitvector.js +12 -0
  277. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  278. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  279. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
  280. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
  281. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  282. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +59 -13
  283. package/dest/services/reqresp/protocols/status.d.ts +1 -1
  284. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  285. package/dest/services/reqresp/protocols/status.js +4 -1
  286. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  287. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  288. package/dest/services/reqresp/protocols/tx.js +20 -0
  289. package/dest/services/reqresp/reqresp.d.ts +6 -1
  290. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  291. package/dest/services/reqresp/reqresp.js +471 -50
  292. package/dest/services/service.d.ts +55 -3
  293. package/dest/services/service.d.ts.map +1 -1
  294. package/dest/services/tx_collection/config.d.ts +22 -1
  295. package/dest/services/tx_collection/config.d.ts.map +1 -1
  296. package/dest/services/tx_collection/config.js +55 -1
  297. package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
  298. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  299. package/dest/services/tx_collection/fast_tx_collection.js +71 -44
  300. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  301. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  302. package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
  303. package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
  304. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  305. package/dest/services/tx_collection/file_store_tx_source.js +90 -0
  306. package/dest/services/tx_collection/index.d.ts +3 -1
  307. package/dest/services/tx_collection/index.d.ts.map +1 -1
  308. package/dest/services/tx_collection/index.js +2 -0
  309. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  310. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  311. package/dest/services/tx_collection/instrumentation.js +11 -13
  312. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  313. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  314. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  315. package/dest/services/tx_collection/proposal_tx_collector.d.ts +49 -0
  316. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
  317. package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
  318. package/dest/services/tx_collection/slow_tx_collection.d.ts +9 -5
  319. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  320. package/dest/services/tx_collection/slow_tx_collection.js +60 -26
  321. package/dest/services/tx_collection/tx_collection.d.ts +29 -16
  322. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  323. package/dest/services/tx_collection/tx_collection.js +79 -7
  324. package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
  325. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  326. package/dest/services/tx_collection/tx_collection_sink.js +26 -29
  327. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  328. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  329. package/dest/services/tx_collection/tx_source.js +19 -2
  330. package/dest/services/tx_file_store/config.d.ts +16 -0
  331. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  332. package/dest/services/tx_file_store/config.js +22 -0
  333. package/dest/services/tx_file_store/index.d.ts +4 -0
  334. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  335. package/dest/services/tx_file_store/index.js +3 -0
  336. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  337. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  338. package/dest/services/tx_file_store/instrumentation.js +29 -0
  339. package/dest/services/tx_file_store/tx_file_store.d.ts +48 -0
  340. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  341. package/dest/services/tx_file_store/tx_file_store.js +152 -0
  342. package/dest/services/tx_provider.d.ts +5 -5
  343. package/dest/services/tx_provider.d.ts.map +1 -1
  344. package/dest/services/tx_provider.js +5 -4
  345. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  346. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  347. package/dest/services/tx_provider_instrumentation.js +7 -20
  348. package/dest/test-helpers/index.d.ts +3 -1
  349. package/dest/test-helpers/index.d.ts.map +1 -1
  350. package/dest/test-helpers/index.js +2 -0
  351. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  352. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  353. package/dest/test-helpers/mock-pubsub.d.ts +29 -2
  354. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  355. package/dest/test-helpers/mock-pubsub.js +103 -2
  356. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  357. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  358. package/dest/test-helpers/reqresp-nodes.js +2 -1
  359. package/dest/test-helpers/test_tx_provider.d.ts +40 -0
  360. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  361. package/dest/test-helpers/test_tx_provider.js +41 -0
  362. package/dest/test-helpers/testbench-utils.d.ts +163 -0
  363. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  364. package/dest/test-helpers/testbench-utils.js +366 -0
  365. package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
  366. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  367. package/dest/testbench/p2p_client_testbench_worker.js +221 -127
  368. package/dest/testbench/worker_client_manager.d.ts +51 -6
  369. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  370. package/dest/testbench/worker_client_manager.js +226 -39
  371. package/dest/util.d.ts +2 -2
  372. package/dest/util.d.ts.map +1 -1
  373. package/package.json +16 -16
  374. package/src/bootstrap/bootstrap.ts +7 -4
  375. package/src/client/factory.ts +96 -24
  376. package/src/client/interface.ts +76 -25
  377. package/src/client/p2p_client.ts +269 -290
  378. package/src/client/test/tx_proposal_collector/README.md +227 -0
  379. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +346 -0
  380. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
  381. package/src/config.ts +49 -13
  382. package/src/errors/tx-pool.error.ts +12 -0
  383. package/src/index.ts +1 -0
  384. package/src/mem_pools/attestation_pool/attestation_pool.ts +510 -78
  385. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +612 -320
  386. package/src/mem_pools/attestation_pool/index.ts +9 -2
  387. package/src/mem_pools/attestation_pool/mocks.ts +20 -13
  388. package/src/mem_pools/index.ts +4 -1
  389. package/src/mem_pools/instrumentation.ts +10 -18
  390. package/src/mem_pools/interface.ts +4 -4
  391. package/src/mem_pools/tx_pool/README.md +29 -14
  392. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +130 -75
  393. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +66 -5
  394. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +119 -4
  395. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +162 -0
  396. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  397. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
  398. package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
  399. package/src/mem_pools/tx_pool_v2/README.md +275 -0
  400. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  401. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  402. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  403. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  404. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
  405. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +122 -0
  406. package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
  407. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
  408. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  409. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  410. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
  411. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
  412. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  413. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  414. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  415. package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
  416. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +242 -0
  417. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  418. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
  419. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
  420. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1069 -0
  421. package/src/msg_validators/attestation_validator/attestation_validator.ts +36 -21
  422. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +21 -18
  423. package/src/msg_validators/clock_tolerance.ts +51 -0
  424. package/src/msg_validators/index.ts +1 -1
  425. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
  426. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
  427. package/src/msg_validators/proposal_validator/index.ts +3 -0
  428. package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
  429. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +230 -0
  430. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  431. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  432. package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
  433. package/src/msg_validators/tx_validator/data_validator.ts +18 -6
  434. package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
  435. package/src/msg_validators/tx_validator/factory.ts +64 -23
  436. package/src/msg_validators/tx_validator/fee_payer_balance.ts +40 -0
  437. package/src/msg_validators/tx_validator/gas_validator.ts +17 -28
  438. package/src/msg_validators/tx_validator/index.ts +1 -0
  439. package/src/msg_validators/tx_validator/metadata_validator.ts +18 -7
  440. package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
  441. package/src/msg_validators/tx_validator/size_validator.ts +22 -0
  442. package/src/msg_validators/tx_validator/timestamp_validator.ts +29 -19
  443. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  444. package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
  445. package/src/services/data_store.ts +10 -7
  446. package/src/services/discv5/discV5_service.ts +1 -1
  447. package/src/services/dummy_service.ts +68 -1
  448. package/src/services/encoding.ts +8 -6
  449. package/src/services/gossipsub/README.md +641 -0
  450. package/src/services/gossipsub/index.ts +2 -0
  451. package/src/services/gossipsub/scoring.ts +29 -5
  452. package/src/services/gossipsub/topic_score_params.ts +487 -0
  453. package/src/services/index.ts +1 -0
  454. package/src/services/libp2p/instrumentation.ts +32 -73
  455. package/src/services/libp2p/libp2p_service.ts +651 -301
  456. package/src/services/peer-manager/metrics.ts +22 -26
  457. package/src/services/peer-manager/peer_manager.ts +1 -2
  458. package/src/services/peer-manager/peer_scoring.ts +28 -4
  459. package/src/services/reqresp/batch-tx-requester/README.md +305 -0
  460. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
  461. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  462. package/src/services/reqresp/batch-tx-requester/interface.ts +53 -0
  463. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -0
  464. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
  465. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
  466. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
  467. package/src/services/reqresp/connection-sampler/connection_sampler.ts +19 -1
  468. package/src/services/reqresp/constants.ts +14 -0
  469. package/src/services/reqresp/interface.ts +29 -1
  470. package/src/services/reqresp/metrics.ts +36 -27
  471. package/src/services/reqresp/protocols/block_txs/bitvector.ts +16 -0
  472. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
  473. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
  474. package/src/services/reqresp/protocols/status.ts +7 -4
  475. package/src/services/reqresp/protocols/tx.ts +22 -0
  476. package/src/services/reqresp/reqresp.ts +79 -22
  477. package/src/services/service.ts +72 -4
  478. package/src/services/tx_collection/config.ts +83 -1
  479. package/src/services/tx_collection/fast_tx_collection.ts +93 -47
  480. package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
  481. package/src/services/tx_collection/file_store_tx_source.ts +117 -0
  482. package/src/services/tx_collection/index.ts +6 -0
  483. package/src/services/tx_collection/instrumentation.ts +11 -13
  484. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  485. package/src/services/tx_collection/proposal_tx_collector.ts +113 -0
  486. package/src/services/tx_collection/slow_tx_collection.ts +68 -35
  487. package/src/services/tx_collection/tx_collection.ts +121 -24
  488. package/src/services/tx_collection/tx_collection_sink.ts +30 -34
  489. package/src/services/tx_collection/tx_source.ts +22 -3
  490. package/src/services/tx_file_store/config.ts +37 -0
  491. package/src/services/tx_file_store/index.ts +3 -0
  492. package/src/services/tx_file_store/instrumentation.ts +36 -0
  493. package/src/services/tx_file_store/tx_file_store.ts +175 -0
  494. package/src/services/tx_provider.ts +10 -9
  495. package/src/services/tx_provider_instrumentation.ts +13 -20
  496. package/src/test-helpers/index.ts +2 -0
  497. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  498. package/src/test-helpers/mock-pubsub.ts +143 -3
  499. package/src/test-helpers/reqresp-nodes.ts +2 -1
  500. package/src/test-helpers/test_tx_provider.ts +64 -0
  501. package/src/test-helpers/testbench-utils.ts +430 -0
  502. package/src/testbench/p2p_client_testbench_worker.ts +348 -123
  503. package/src/testbench/worker_client_manager.ts +304 -42
  504. package/src/util.ts +7 -1
  505. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -37
  506. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  507. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -213
  508. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -30
  509. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  510. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -219
  511. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +0 -15
  512. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +0 -1
  513. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +0 -88
  514. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
  515. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
  516. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -82
  517. package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
  518. package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
  519. package/dest/msg_validators/block_proposal_validator/index.js +0 -1
  520. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -298
  521. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -287
  522. package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +0 -108
  523. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -97
  524. package/src/msg_validators/block_proposal_validator/index.ts +0 -1
@@ -1,2 +1,9 @@
1
- export * from './attestation_pool.js';
2
- export * from './memory_attestation_pool.js';
1
+ export {
2
+ AttestationPool,
3
+ type AttestationPoolApi,
4
+ type TryAddResult,
5
+ createTestAttestationPool,
6
+ MAX_CHECKPOINT_PROPOSALS_PER_SLOT,
7
+ MAX_BLOCK_PROPOSALS_PER_POSITION,
8
+ MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER,
9
+ } from './attestation_pool.js';
@@ -1,12 +1,13 @@
1
+ import { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
2
3
  import { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import {
4
- BlockAttestation,
5
+ CheckpointAttestation,
5
6
  ConsensusPayload,
6
7
  SignatureDomainSeparator,
7
8
  getHashedSignaturePayloadEthSignedMessage,
8
9
  } from '@aztec/stdlib/p2p';
9
- import { makeL2BlockHeader } from '@aztec/stdlib/testing';
10
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
10
11
 
11
12
  import { type LocalAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
12
13
 
@@ -20,26 +21,32 @@ export const generateAccount = (): LocalAccount => {
20
21
  return privateKeyToAccount(privateKey);
21
22
  };
22
23
 
23
- /** Mock Attestation
24
+ /** Mock Checkpoint Attestation
24
25
  *
25
- * @param signer A viem signer to create a signature
26
+ * @param signer A Secp256k1Signer to create a signature
26
27
  * @param slot The slot number the attestation is for
27
- * @returns A Block Attestation
28
+ * @param archive The archive root (defaults to random)
29
+ * @param header The checkpoint header (defaults to random with given slot)
30
+ * @returns A Checkpoint Attestation
28
31
  */
29
- export const mockAttestation = (
32
+ export const mockCheckpointAttestation = (
30
33
  signer: Secp256k1Signer,
31
34
  slot: number = 0,
32
35
  archive: Fr = Fr.random(),
33
- ): BlockAttestation => {
34
- // Use arbitrary numbers for all other than slot
35
- const header = makeL2BlockHeader(1, 2, slot);
36
- const payload = new ConsensusPayload(header.toCheckpointHeader(), archive);
36
+ header?: CheckpointHeader,
37
+ feeAssetPriceModifier: bigint = 0n,
38
+ ): CheckpointAttestation => {
39
+ header = header ?? CheckpointHeader.random({ slotNumber: SlotNumber(slot) });
40
+ const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
37
41
 
38
- const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
42
+ const attestationHash = getHashedSignaturePayloadEthSignedMessage(
43
+ payload,
44
+ SignatureDomainSeparator.checkpointAttestation,
45
+ );
39
46
  const attestationSignature = signer.sign(attestationHash);
40
47
 
41
- const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
48
+ const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.checkpointProposal);
42
49
  const proposerSignature = signer.sign(proposalHash);
43
50
 
44
- return new BlockAttestation(payload, attestationSignature, proposerSignature);
51
+ return new CheckpointAttestation(payload, attestationSignature, proposerSignature);
45
52
  };
@@ -1,3 +1,6 @@
1
- export { type AttestationPool } from './attestation_pool/attestation_pool.js';
1
+ export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
2
2
  export { type MemPools } from './interface.js';
3
+ // Old TxPool exports - kept temporarily for external consumers
3
4
  export { type TxPool } from './tx_pool/tx_pool.js';
5
+ // New TxPoolV2 exports
6
+ export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult } from './tx_pool_v2/index.js';
@@ -7,11 +7,12 @@ import {
7
7
  LmdbMetrics,
8
8
  type LmdbStatsCallback,
9
9
  type Meter,
10
+ type MetricDefinition,
10
11
  Metrics,
11
- type MetricsType,
12
12
  type ObservableGauge,
13
13
  type TelemetryClient,
14
14
  type UpDownCounter,
15
+ createUpDownCounterWithDefault,
15
16
  } from '@aztec/telemetry-client';
16
17
 
17
18
  export enum PoolName {
@@ -20,10 +21,10 @@ export enum PoolName {
20
21
  }
21
22
 
22
23
  type MetricsLabels = {
23
- objectInMempool: MetricsType;
24
- objectSize: MetricsType;
25
- itemsAdded: MetricsType;
26
- itemMinedDelay: MetricsType;
24
+ objectInMempool: MetricDefinition;
25
+ objectSize: MetricDefinition;
26
+ itemsAdded: MetricDefinition;
27
+ itemMinedDelay: MetricDefinition;
27
28
  };
28
29
 
29
30
  /**
@@ -85,14 +86,9 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
85
86
 
86
87
  const metricsLabels = getMetricsLabels(name);
87
88
 
88
- this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool, {
89
- description: 'The current number of transactions in the mempool',
90
- });
89
+ this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool);
91
90
 
92
- this.objectSize = this.meter.createHistogram(metricsLabels.objectSize, {
93
- unit: 'By',
94
- description: 'The size of transactions in the mempool',
95
- });
91
+ this.objectSize = this.meter.createHistogram(metricsLabels.objectSize);
96
92
 
97
93
  this.dbMetrics = new LmdbMetrics(
98
94
  this.meter,
@@ -102,13 +98,9 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
102
98
  dbStats,
103
99
  );
104
100
 
105
- this.addObjectCounter = this.meter.createUpDownCounter(metricsLabels.itemsAdded, {
106
- description: 'The number of transactions added to the mempool',
107
- });
101
+ this.addObjectCounter = createUpDownCounterWithDefault(this.meter, metricsLabels.itemsAdded);
108
102
 
109
- this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay, {
110
- description: 'Delay between transaction added and evicted from the mempool',
111
- });
103
+ this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay);
112
104
 
113
105
  this.meter.addBatchObservableCallback(this.observeStats, [this.objectsInMempool]);
114
106
  }
@@ -1,10 +1,10 @@
1
- import type { AttestationPool } from './attestation_pool/attestation_pool.js';
2
- import type { TxPool } from './tx_pool/tx_pool.js';
1
+ import type { AttestationPoolApi } from './attestation_pool/attestation_pool.js';
2
+ import type { TxPoolV2 } from './tx_pool_v2/interfaces.js';
3
3
 
4
4
  /**
5
5
  * A interface the combines all mempools
6
6
  */
7
7
  export type MemPools = {
8
- txPool: TxPool;
9
- attestationPool: AttestationPool;
8
+ txPool: TxPoolV2;
9
+ attestationPool: AttestationPoolApi;
10
10
  };
@@ -24,7 +24,7 @@ The lifecycle of transactions in the pool is summarised in the following table:
24
24
 
25
25
  **Note on why Soft Delete:**
26
26
  Mined transactions are soft-deleted rather than permanently removed to support:
27
- 1. Reorg handling — If a chain reorganization occurs, soft-deleted transactions are still available in the mempool
27
+ 1. Reorg handling — If a chain reorganization occurs, soft-deleted transactions are still available in the mempool
28
28
  2. Slash condition detection — The epoch prune watcher needs access to transactions from pruned epochs to correctly identify data withholding slash conditions. Without soft-delete, transactions invalidated by reorgs (e.g., built on removed blocks) would be lost, causing false positives for data withholding violations.
29
29
 
30
30
  Mined transactions are permanently deleted via `cleanupDeletedMinedTxs()` once their original block is finalized on L1, ensuring theyremain available during the uncertainty window.
@@ -34,7 +34,7 @@ Alternatively, mined transactions can be permanently deleted immediately by pass
34
34
 
35
35
  | Method | Description |
36
36
  |--------|-------------|
37
- | `addTxs(txs, opts?)` | Adds transactions to the pool. Duplicates are ignored. Returns count of newly added txs. |
37
+ | `addTxs(txs, opts?)` | Adds transactions to the pool. Duplicates and nullifier conflicts are handled. Returns count of newly added txs. |
38
38
  | `deleteTxs(txHashes, opts?)` | Removes transactions from the pool. Supports soft-delete for mined txs. |
39
39
  | `markAsMined(txHashes, blockHeader)` | Marks transactions as included in a block. |
40
40
  | `markMinedAsPending(txHashes, blockNumber)` | Reverts mined transactions to pending (used during reorgs). |
@@ -91,6 +91,7 @@ The pool maintains several KV maps and indexes:
91
91
  | `#txHashToHistoricalBlockHeaderHash` | Anchor block reference for each tx |
92
92
  | `#historicalHeaderToTxHash` | Index from historical block → tx hashes |
93
93
  | `#feePayerToTxHash` | Index from fee payer address → tx hashes |
94
+ | `#pendingNullifierToTxHash` | Index from nullifier → tx hash |
94
95
  | `#archivedTxs` | Archived transactions for historical lookup |
95
96
 
96
97
  #### In-Memory Caches
@@ -117,15 +118,17 @@ The priority is stored as a hex string derived from a 32-byte buffer representat
117
118
  When `addTxs()` is called:
118
119
 
119
120
  1. Check for duplicates (skip if tx already exists)
120
- 2. Store the serialized tx in `#txs`
121
- 3. Index the tx by its anchor block hash
122
- 4. If not already mined, add to pending indexes:
121
+ 2. Check for nullifier conflicts (see Nullifier Deduplication below)
122
+ 3. Store the serialized tx in `#txs`
123
+ 4. Index the tx by its anchor block hash
124
+ 5. If not already mined, add to pending indexes:
123
125
  - Priority-to-hash index (for ordering)
124
126
  - Historical header index (for reorg handling)
125
127
  - Fee payer index (for balance validation)
126
- 5. Record metrics
127
- 6. Trigger eviction rules for `TXS_ADDED` event
128
- 7. Emit `txs-added` event
128
+ - Nullifier-to-tx-hash index (for conflict detection)
129
+ 6. Record metrics
130
+ 7. Trigger eviction rules for `TXS_ADDED` event
131
+ 8. Emit `txs-added` event
129
132
 
130
133
  ### 2. Marking as Mined
131
134
 
@@ -152,6 +155,16 @@ The `deleteTxs()` method handles two cases:
152
155
 
153
156
  Soft-deleted mined transactions are retained for potential future reference and can be permanently cleaned up later via `cleanupDeletedMinedTxs()`.
154
157
 
158
+ ### Nullifier Deduplication
159
+
160
+ The pool prevents nullifier spam attacks by ensuring only one pending transaction can reference each unique nullifier. When an incoming transaction shares nullifiers with existing pending transactions:
161
+
162
+ - **Higher fee wins**: If the incoming tx has a higher priority fee than ALL conflicting txs, those conflicting txs are replaced
163
+ - **Existing tx wins on tie**: If any conflicting tx has an equal or higher fee, the incoming tx is rejected
164
+ - **Partial overlap counts**: Even a single shared nullifier triggers conflict resolution
165
+
166
+ This is enforced at entry time via the `#pendingNullifierToTxHash` index, which maps each nullifier to the tx hash that references it. The index is maintained atomically with tx additions and removals.
167
+
155
168
  ## Eviction System
156
169
 
157
170
  The eviction system automatically removes invalid or low-priority transactions based on configurable rules. See the [`eviction/`](eviction/) subdirectory for implementation details.
@@ -189,7 +202,7 @@ The [`EvictionManager`](eviction/eviction_manager.ts) coordinates eviction by:
189
202
  |-------|---------|---------|
190
203
  | `TXS_ADDED` | New transactions added | Enforce pool size limits |
191
204
  | `BLOCK_MINED` | Block finalized | Remove invalidated transactions |
192
- | `CHAIN_PRUNED` | Chain reorganization | Remove txs referencing pruned blocks |
205
+ | `CHAIN_PRUNED` | Chain reorganization | Remove txs referencing pruned blocks and re-evaluate fee payer balances |
193
206
 
194
207
  ### Eviction Rules
195
208
 
@@ -200,7 +213,7 @@ The [`EvictionManager`](eviction/eviction_manager.ts) coordinates eviction by:
200
213
  Evicts transactions that become invalid after a block is mined:
201
214
 
202
215
  - Duplicate nullifiers: Txs with nullifiers already included in the mined block
203
- - Expired transactions: Txs with `includeByTimestamp` ≤ mined block timestamp
216
+ - Expired transactions: Txs with `expirationTimestamp` ≤ mined block timestamp
204
217
 
205
218
  #### 2. `InvalidTxsAfterReorgRule`
206
219
 
@@ -211,13 +224,15 @@ Evicts transactions that reference blocks no longer in the canonical chain:
211
224
  - Checks each pending tx's anchor block hash against the archive tree
212
225
  - Removes txs whose anchor blocks are not found (pruned)
213
226
 
214
- #### 3. `InsufficientFeePayerBalanceRule`
227
+ #### 3. `FeePayerBalanceEvictionRule`
215
228
 
216
- **Triggers on:** `BLOCK_MINED`, `CHAIN_PRUNED`
229
+ **Triggers on:** `TXS_ADDED`, `BLOCK_MINED`, `CHAIN_PRUNED`
217
230
 
218
- Evicts transactions whose fee payer no longer has sufficient balance:
231
+ Evicts low-priority transactions when a fee payer's pending fee limits exceed their Fee Juice balance:
219
232
 
220
- - Uses `GasTxValidator` to check fee payer balances against current world state
233
+ - Evaluates transactions in priority order so higher-priority claims can fund lower-priority spends
234
+ - Accounts for self-funding claims made during setup
235
+ - Removes evictable txs that do not fit within the running balance
221
236
 
222
237
  #### 4. `LowPriorityEvictionRule`
223
238
 
@@ -5,8 +5,8 @@ import { toArray } from '@aztec/foundation/iterable';
5
5
  import { type Logger, createLogger } from '@aztec/foundation/log';
6
6
  import type { TypedEventEmitter } from '@aztec/foundation/types';
7
7
  import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
8
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
9
- import type { MerkleTreeReadOperations, ReadonlyWorldStateAccess } from '@aztec/stdlib/interfaces/server';
8
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
9
+ import type { MerkleTreeReadOperations, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
10
10
  import { ChonkProof } from '@aztec/stdlib/proofs';
11
11
  import type { TxAddedToPoolStats } from '@aztec/stdlib/stats';
12
12
  import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
@@ -18,11 +18,18 @@ import EventEmitter from 'node:events';
18
18
  import { ArchiveCache } from '../../msg_validators/tx_validator/archive_cache.js';
19
19
  import { PoolInstrumentation, PoolName, type PoolStatsCallback } from '../instrumentation.js';
20
20
  import { EvictionManager } from './eviction/eviction_manager.js';
21
- import type { PendingTxInfo, TxBlockReference, TxPoolOperations } from './eviction/eviction_strategy.js';
22
- import { InsufficientFeePayerBalanceRule } from './eviction/insufficient_fee_payer_balance_rule.js';
21
+ import {
22
+ FeePayerTxInfo,
23
+ type PendingTxInfo,
24
+ type PreAddPoolAccess,
25
+ type TxBlockReference,
26
+ type TxPoolOperations,
27
+ } from './eviction/eviction_strategy.js';
28
+ import { FeePayerBalanceEvictionRule } from './eviction/fee_payer_balance_eviction_rule.js';
23
29
  import { InvalidTxsAfterMiningRule } from './eviction/invalid_txs_after_mining_rule.js';
24
30
  import { InvalidTxsAfterReorgRule } from './eviction/invalid_txs_after_reorg_rule.js';
25
31
  import { LowPriorityEvictionRule } from './eviction/low_priority_eviction_rule.js';
32
+ import { NullifierConflictPreAddRule } from './eviction/nullifier_conflict_pre_add_rule.js';
26
33
  import { getPendingTxPriority } from './priority.js';
27
34
  import type { TxPool, TxPoolEvents, TxPoolOptions } from './tx_pool.js';
28
35
 
@@ -55,7 +62,10 @@ export class AztecKVTxPool
55
62
 
56
63
  #historicalHeaderToTxHash: AztecAsyncMultiMap<string, string>;
57
64
 
58
- #feePayerToTxHash: AztecAsyncMultiMap<string, string>;
65
+ #feePayerToBalanceEntry: AztecAsyncMultiMap<string, Buffer>;
66
+
67
+ /** Index from nullifier to pending tx hash */
68
+ #pendingNullifierToTxHash: AztecAsyncMap<string, string>;
59
69
 
60
70
  /** In-memory set of txs that should not be evicted from the pool. */
61
71
  #nonEvictableTxs: Set<string>;
@@ -89,7 +99,7 @@ export class AztecKVTxPool
89
99
  constructor(
90
100
  store: AztecAsyncKVStore,
91
101
  archive: AztecAsyncKVStore,
92
- worldState: ReadonlyWorldStateAccess,
102
+ worldState: WorldStateSynchronizer,
93
103
  telemetry: TelemetryClient = getTelemetryClient(),
94
104
  config: TxPoolOptions = {},
95
105
  log = createLogger('p2p:tx_pool'),
@@ -101,13 +111,14 @@ export class AztecKVTxPool
101
111
  this.#evictionManager = new EvictionManager(this);
102
112
  this.#evictionManager.registerRule(new InvalidTxsAfterMiningRule());
103
113
  this.#evictionManager.registerRule(new InvalidTxsAfterReorgRule(worldState));
104
- this.#evictionManager.registerRule(new InsufficientFeePayerBalanceRule(worldState));
114
+ this.#evictionManager.registerRule(new FeePayerBalanceEvictionRule(worldState));
105
115
  this.#evictionManager.registerRule(
106
116
  new LowPriorityEvictionRule({
107
117
  //NOTE: 0 effectively disables low priority eviction
108
118
  maxPoolSize: config.maxPendingTxCount ?? 0,
109
119
  }),
110
120
  );
121
+ this.#evictionManager.registerPreAddRule(new NullifierConflictPreAddRule());
111
122
 
112
123
  this.updateConfig(config);
113
124
 
@@ -119,7 +130,8 @@ export class AztecKVTxPool
119
130
 
120
131
  this.#pendingTxHashToHistoricalBlockHeaderHash = store.openMap('txHistoricalBlock');
121
132
  this.#historicalHeaderToTxHash = store.openMultiMap('historicalHeaderToPendingTxHash');
122
- this.#feePayerToTxHash = store.openMultiMap('feePayerToPendingTxHash');
133
+ this.#feePayerToBalanceEntry = store.openMultiMap('feePayerToBalanceEntry');
134
+ this.#pendingNullifierToTxHash = store.openMap('pendingNullifierToTxHash');
123
135
 
124
136
  this.#nonEvictableTxs = new Set<string>();
125
137
 
@@ -171,7 +183,7 @@ export class AztecKVTxPool
171
183
  const key = hash.toString();
172
184
  await this.#minedTxHashToBlock.set(key, blockHeader.globalVariables.blockNumber);
173
185
 
174
- const tx = await this.getPendingTxByHash(hash);
186
+ const tx = await this.getTxByHash(hash);
175
187
  if (tx) {
176
188
  const nullifiers = tx.data.getNonEmptyNullifiers();
177
189
 
@@ -216,8 +228,16 @@ export class AztecKVTxPool
216
228
  const key = hash.toString();
217
229
  await this.#minedTxHashToBlock.delete(key);
218
230
 
231
+ // Clear soft-delete metadata if this tx was previously soft-deleted,
232
+ // so cleanupDeletedMinedTxs won't later hard-delete it while it's pending
233
+ const deletedBlock = await this.#deletedMinedTxHashes.getAsync(key);
234
+ if (deletedBlock !== undefined) {
235
+ await this.#deletedMinedTxHashes.delete(key);
236
+ await this.#blockToDeletedMinedTxHash.deleteValue(deletedBlock, key);
237
+ }
238
+
219
239
  // Rehydrate the tx in the in-memory pending txs mapping
220
- const tx = await this.getPendingTxByHash(hash);
240
+ const tx = await this.getTxByHash(hash);
221
241
  if (tx) {
222
242
  await this.addPendingTxIndicesInDbTx(tx, key);
223
243
  }
@@ -271,6 +291,8 @@ export class AztecKVTxPool
271
291
 
272
292
  /**
273
293
  * Adds a list of transactions to the pool. Duplicates are ignored.
294
+ * Handles nullifier deduplication: if an incoming tx has a nullifier conflict with
295
+ * existing pending txs, it will either replace them (if higher fee) or be rejected.
274
296
  * @param txs - An array of txs to be added to the pool.
275
297
  * @returns count of added transactions
276
298
  */
@@ -280,43 +302,69 @@ export class AztecKVTxPool
280
302
  }
281
303
 
282
304
  const addedTxs: Tx[] = [];
305
+ const uniqueFeePayers: AztecAddress[] = [];
306
+ const replacedTxHashes: TxHash[] = [];
283
307
  const hashesAndStats = txs.map(tx => ({ txHash: tx.getTxHash(), txStats: tx.getStats() }));
284
308
  try {
285
309
  await this.#store.transactionAsync(async () => {
286
- await Promise.all(
287
- txs.map(async (tx, i) => {
288
- const { txHash, txStats } = hashesAndStats[i];
289
- const key = txHash.toString();
290
- if (await this.#txs.hasAsync(key)) {
291
- this.#log.debug(`Tx ${txHash.toString()} already exists in the pool`);
292
- return;
310
+ for (let i = 0; i < txs.length; i++) {
311
+ const tx = txs[i];
312
+ const { txHash, txStats } = hashesAndStats[i];
313
+ const key = txHash.toString();
314
+ if (await this.#txs.hasAsync(key)) {
315
+ this.#log.debug(`Tx ${key} already exists in the pool`);
316
+ continue;
317
+ }
318
+
319
+ const poolAccess = this.getPreAddPoolAccess();
320
+ const { shouldReject, txHashesToEvict } = await this.#evictionManager.runPreAddRules(tx, poolAccess);
321
+ if (shouldReject) {
322
+ continue;
323
+ }
324
+
325
+ for (const txHashToEvict of txHashesToEvict) {
326
+ const txToDelete = await this.getTxByHash(txHashToEvict);
327
+ if (txToDelete) {
328
+ const evictedKey = txHashToEvict.toString();
329
+ await this.deletePendingTxInDbTx(txToDelete, evictedKey);
330
+ replacedTxHashes.push(txHashToEvict);
331
+ this.#log.verbose(`Evicted tx ${evictedKey} due to higher-fee tx ${key}`);
293
332
  }
333
+ }
294
334
 
295
- this.#log.verbose(`Adding tx ${txHash.toString()} to pool`, {
296
- eventName: 'tx-added-to-pool',
297
- ...txStats,
298
- } satisfies TxAddedToPoolStats);
335
+ this.#log.verbose(`Adding tx ${key} to pool`, {
336
+ eventName: 'tx-added-to-pool',
337
+ ...txStats,
338
+ } satisfies TxAddedToPoolStats);
299
339
 
300
- await this.#txs.set(key, tx.toBuffer());
301
- addedTxs.push(tx as Tx);
302
- await this.#pendingTxHashToHistoricalBlockHeaderHash.set(
303
- key,
304
- (await tx.data.constants.anchorBlockHeader.hash()).toString(),
305
- );
340
+ await this.#txs.set(key, tx.toBuffer());
341
+ addedTxs.push(tx);
342
+ insertIntoSortedArray(uniqueFeePayers, tx.data.feePayer, (a, b) => a.toField().cmp(b.toField()), false);
306
343
 
307
- if (!(await this.#minedTxHashToBlock.hasAsync(key))) {
308
- await this.addPendingTxIndicesInDbTx(tx, key);
309
- this.#metrics.recordSize(tx);
310
- }
311
- }),
312
- );
344
+ await this.#pendingTxHashToHistoricalBlockHeaderHash.set(
345
+ key,
346
+ (await tx.data.constants.anchorBlockHeader.hash()).toString(),
347
+ );
348
+
349
+ if (!(await this.#minedTxHashToBlock.hasAsync(key))) {
350
+ await this.addPendingTxIndicesInDbTx(tx, key);
351
+ this.#metrics.recordSize(tx);
352
+ }
353
+ }
313
354
  });
314
355
 
315
- await this.#evictionManager.evictAfterNewTxs(addedTxs.map(({ txHash }) => txHash));
356
+ await this.#evictionManager.evictAfterNewTxs(
357
+ addedTxs.map(({ txHash }) => txHash),
358
+ uniqueFeePayers,
359
+ );
316
360
  } catch (err) {
317
361
  this.#log.warn('Unexpected error when adding txs', { err });
318
362
  }
319
363
 
364
+ if (replacedTxHashes.length > 0) {
365
+ this.#metrics.transactionsRemoved(replacedTxHashes.map(hash => hash.toBigInt()));
366
+ }
367
+
320
368
  if (addedTxs.length > 0) {
321
369
  this.#metrics.transactionsAdded(addedTxs);
322
370
  this.emit('txs-added', { ...opts, txs: addedTxs });
@@ -348,7 +396,7 @@ export class AztecKVTxPool
348
396
  const minedBlockNumber = await this.#minedTxHashToBlock.getAsync(key);
349
397
  const txIsPending = minedBlockNumber === undefined;
350
398
  if (txIsPending) {
351
- await this.deletePendingTx(tx, key);
399
+ await this.deletePendingTxInDbTx(tx, key);
352
400
  } else {
353
401
  await this.deleteMinedTx(key, minedBlockNumber!, opts?.permanently ?? false);
354
402
  const shouldArchiveTx = this.#archivedTxLimit && !opts?.permanently;
@@ -378,10 +426,11 @@ export class AztecKVTxPool
378
426
  await this.#blockToDeletedMinedTxHash.set(minedBlockNumber, txHash);
379
427
  }
380
428
 
381
- private async deletePendingTx(tx: Tx, txHash: `0x${string}`) {
429
+ // Assumes being called within a DB transaction
430
+ private async deletePendingTxInDbTx(tx: Tx, txHash: `0x${string}`) {
382
431
  // We always permanently delete pending transactions
383
432
  this.#log.trace(`Deleting pending tx ${txHash} from pool`);
384
- await this.removePendingTxIndices(tx, txHash);
433
+ await this.removePendingTxIndicesInDbTx(tx, txHash);
385
434
  await this.#txs.delete(txHash);
386
435
  await this.#pendingTxHashToHistoricalBlockHeaderHash.delete(txHash);
387
436
  }
@@ -414,7 +463,7 @@ export class AztecKVTxPool
414
463
  let historicalBlockHash = await this.#pendingTxHashToHistoricalBlockHeaderHash.getAsync(txHash.toString());
415
464
  // Not all tx might have this index created.
416
465
  if (!historicalBlockHash) {
417
- const tx = await this.getPendingTxByHash(txHash);
466
+ const tx = await this.getTxByHash(txHash);
418
467
  if (!tx) {
419
468
  this.#log.warn(`PendingTxInfo:tx ${txHash} not found`);
420
469
  return undefined;
@@ -447,15 +496,21 @@ export class AztecKVTxPool
447
496
  return result;
448
497
  }
449
498
 
450
- public async getPendingTxsWithFeePayer(feePayers: AztecAddress[]): Promise<PendingTxInfo[]> {
451
- const result: PendingTxInfo[] = [];
452
- for (const feePayer of feePayers) {
453
- const chunk = await toArray(this.#feePayerToTxHash.getValuesAsync(feePayer.toString()));
454
- const infos = await Promise.all(chunk.map(txHash => this.getPendingTxInfo(TxHash.fromString(txHash))));
455
- result.push(...infos.filter((info): info is PendingTxInfo => info !== undefined));
499
+ public async getPendingFeePayers(): Promise<AztecAddress[]> {
500
+ const feePayers: AztecAddress[] = [];
501
+ for await (const feePayer of this.#feePayerToBalanceEntry.keysAsync()) {
502
+ const address = AztecAddress.fromString(feePayer);
503
+ insertIntoSortedArray(feePayers, address, (a, b) => a.toField().cmp(b.toField()), false);
456
504
  }
505
+ return feePayers;
506
+ }
457
507
 
458
- return result;
508
+ public async *getFeePayerTxInfos(feePayer: AztecAddress): AsyncIterable<FeePayerTxInfo> {
509
+ for await (const value of this.#feePayerToBalanceEntry.getValuesAsync(feePayer.toString())) {
510
+ const info = FeePayerTxInfo.decode(value);
511
+ info.isEvictable = !this.#nonEvictableTxs.has(info.txHash.toString());
512
+ yield info;
513
+ }
459
514
  }
460
515
 
461
516
  public async getMinedTxHashes(): Promise<[TxHash, BlockNumber][]> {
@@ -565,24 +620,6 @@ export class AztecKVTxPool
565
620
  return new ArchiveCache(db);
566
621
  }
567
622
 
568
- /**
569
- * Checks if a cached transaction exists in the in-memory pending tx pool and returns it.
570
- * Otherwise, it checks the tx pool, updates the pending tx pool, and returns the tx.
571
- * @param txHash - The generated tx hash.
572
- * @returns The transaction, if found, 'undefined' otherwise.
573
- */
574
- private async getPendingTxByHash(txHash: TxHash | string): Promise<Tx | undefined> {
575
- if (typeof txHash === 'string') {
576
- txHash = TxHash.fromString(txHash);
577
- }
578
-
579
- const tx = await this.getTxByHash(txHash);
580
- if (tx) {
581
- return tx;
582
- }
583
- return undefined;
584
- }
585
-
586
623
  /**
587
624
  * Archives a list of txs for future reference. The number of archived txs is limited by the specified archivedTxLimit.
588
625
  * Note: Pending txs should not be archived, only finalized txs
@@ -640,13 +677,13 @@ export class AztecKVTxPool
640
677
  private async addPendingTxIndicesInDbTx(tx: Tx, txHash: string): Promise<void> {
641
678
  await this.#pendingTxPriorityToHash.set(getPendingTxPriority(tx), txHash);
642
679
  await this.#historicalHeaderToTxHash.set((await tx.data.constants.anchorBlockHeader.hash()).toString(), txHash);
643
- await this.#feePayerToTxHash.set(tx.data.feePayer.toString(), txHash);
644
- }
680
+ await this.#feePayerToBalanceEntry.set(tx.data.feePayer.toString(), await FeePayerTxInfo.encode(tx, txHash));
645
681
 
646
- private async addPendingTxIndices(tx: Tx, txHash: string): Promise<void> {
647
- return await this.#store.transactionAsync(async () => {
648
- await this.addPendingTxIndicesInDbTx(tx, txHash);
649
- });
682
+ // Add nullifier entries for conflict detection
683
+ const nullifiers = tx.data.getNonEmptyNullifiers();
684
+ for (const nullifier of nullifiers) {
685
+ await this.#pendingNullifierToTxHash.set(nullifier.toString(), txHash);
686
+ }
650
687
  }
651
688
 
652
689
  // Assumes being called within a DB transaction
@@ -656,13 +693,16 @@ export class AztecKVTxPool
656
693
  (await tx.data.constants.anchorBlockHeader.hash()).toString(),
657
694
  txHash,
658
695
  );
659
- await this.#feePayerToTxHash.deleteValue(tx.data.feePayer.toString(), txHash);
660
- }
696
+ await this.#feePayerToBalanceEntry.deleteValue(
697
+ tx.data.feePayer.toString(),
698
+ await FeePayerTxInfo.encode(tx, txHash),
699
+ );
661
700
 
662
- private async removePendingTxIndices(tx: Tx, txHash: string): Promise<void> {
663
- return await this.#store.transactionAsync(async () => {
664
- await this.removePendingTxIndicesInDbTx(tx, txHash);
665
- });
701
+ // Remove nullifier entries
702
+ const nullifiers = tx.data.getNonEmptyNullifiers();
703
+ for (const nullifier of nullifiers) {
704
+ await this.#pendingNullifierToTxHash.delete(nullifier.toString());
705
+ }
666
706
  }
667
707
 
668
708
  /**
@@ -688,4 +728,19 @@ export class AztecKVTxPool
688
728
 
689
729
  return txsToEvict;
690
730
  }
731
+
732
+ /**
733
+ * Creates a PreAddPoolAccess object for use by pre-add eviction rules.
734
+ * Provides read-only access to pool state during addTxs transaction.
735
+ */
736
+ private getPreAddPoolAccess(): PreAddPoolAccess {
737
+ return {
738
+ getTxHashByNullifier: async nullifier => {
739
+ const hashStr = await this.#pendingNullifierToTxHash.getAsync(nullifier.toString());
740
+ return hashStr ? TxHash.fromString(hashStr) : undefined;
741
+ },
742
+ getPendingTxByHash: this.getTxByHash.bind(this),
743
+ getTxPriority: getPendingTxPriority,
744
+ };
745
+ }
691
746
  }