@aztec/p2p 0.0.1-fake-c83136db25 → 0.0.2-commit.217f559981

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 (597) 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 -15
  7. package/dest/client/index.d.ts +1 -1
  8. package/dest/client/interface.d.ts +58 -23
  9. package/dest/client/interface.d.ts.map +1 -1
  10. package/dest/client/p2p_client.d.ts +51 -74
  11. package/dest/client/p2p_client.d.ts.map +1 -1
  12. package/dest/client/p2p_client.js +613 -264
  13. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
  14. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
  15. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
  16. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
  17. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
  18. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
  19. package/dest/config.d.ts +95 -64
  20. package/dest/config.d.ts.map +1 -1
  21. package/dest/config.js +42 -21
  22. package/dest/enr/generate-enr.d.ts +1 -1
  23. package/dest/enr/index.d.ts +1 -1
  24. package/dest/errors/attestation-pool.error.d.ts +7 -0
  25. package/dest/errors/attestation-pool.error.d.ts.map +1 -0
  26. package/dest/errors/attestation-pool.error.js +12 -0
  27. package/dest/errors/reqresp.error.d.ts +1 -1
  28. package/dest/errors/reqresp.error.d.ts.map +1 -1
  29. package/dest/errors/tx-pool.error.d.ts +8 -0
  30. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  31. package/dest/errors/tx-pool.error.js +9 -0
  32. package/dest/index.d.ts +2 -1
  33. package/dest/index.d.ts.map +1 -1
  34. package/dest/index.js +1 -0
  35. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +117 -45
  36. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  37. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  38. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  39. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  40. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +530 -257
  41. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  42. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  43. package/dest/mem_pools/attestation_pool/index.js +1 -2
  44. package/dest/mem_pools/attestation_pool/mocks.d.ts +234 -10
  45. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  46. package/dest/mem_pools/attestation_pool/mocks.js +17 -13
  47. package/dest/mem_pools/index.d.ts +3 -2
  48. package/dest/mem_pools/index.d.ts.map +1 -1
  49. package/dest/mem_pools/index.js +1 -1
  50. package/dest/mem_pools/instrumentation.d.ts +9 -1
  51. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  52. package/dest/mem_pools/instrumentation.js +37 -10
  53. package/dest/mem_pools/interface.d.ts +6 -7
  54. package/dest/mem_pools/interface.d.ts.map +1 -1
  55. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +34 -58
  56. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  57. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +320 -335
  58. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +32 -0
  59. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
  60. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +112 -0
  61. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +157 -0
  62. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
  63. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +52 -0
  64. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
  65. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  66. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +122 -0
  67. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
  68. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  69. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
  70. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
  71. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  72. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +78 -0
  73. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
  74. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  75. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
  76. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
  77. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
  78. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -0
  79. package/dest/mem_pools/tx_pool/index.d.ts +1 -2
  80. package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
  81. package/dest/mem_pools/tx_pool/index.js +0 -1
  82. package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
  83. package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
  84. package/dest/mem_pools/tx_pool/priority.js +6 -1
  85. package/dest/mem_pools/tx_pool/tx_pool.d.ts +17 -6
  86. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  87. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
  88. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  89. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +30 -24
  90. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  91. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  92. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  93. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  94. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  95. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  96. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  97. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  98. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  99. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  100. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  101. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
  102. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  103. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  104. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
  105. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  106. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  107. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +95 -0
  108. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  109. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  110. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  111. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
  112. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  113. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
  114. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  115. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  116. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
  117. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  118. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  119. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  120. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  121. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  122. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
  123. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  124. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  125. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
  126. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  127. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  128. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  129. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  130. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  131. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  132. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  133. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  134. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  135. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
  136. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  137. package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
  138. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +97 -0
  139. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  140. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +152 -0
  141. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  142. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  143. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  144. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
  145. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  146. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +355 -0
  147. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -0
  148. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  149. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
  150. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -0
  151. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  152. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +896 -0
  153. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +7 -6
  154. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  155. package/dest/msg_validators/attestation_validator/attestation_validator.js +57 -24
  156. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
  157. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
  158. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +76 -0
  159. package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
  160. package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
  161. package/dest/msg_validators/attestation_validator/index.js +1 -0
  162. package/dest/msg_validators/clock_tolerance.d.ts +21 -0
  163. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  164. package/dest/msg_validators/clock_tolerance.js +37 -0
  165. package/dest/msg_validators/index.d.ts +2 -2
  166. package/dest/msg_validators/index.d.ts.map +1 -1
  167. package/dest/msg_validators/index.js +1 -1
  168. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
  169. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
  170. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
  171. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
  172. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
  173. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
  174. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
  175. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
  176. package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
  177. package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
  178. package/dest/msg_validators/proposal_validator/index.js +3 -0
  179. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
  180. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
  181. package/dest/msg_validators/proposal_validator/proposal_validator.js +104 -0
  182. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
  183. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
  184. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +212 -0
  185. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  186. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  187. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +1 -1
  188. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  189. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  190. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  191. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
  192. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  193. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  194. package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
  195. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  196. package/dest/msg_validators/tx_validator/data_validator.js +4 -1
  197. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
  198. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  199. package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
  200. package/dest/msg_validators/tx_validator/factory.d.ts +10 -4
  201. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  202. package/dest/msg_validators/tx_validator/factory.js +22 -12
  203. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
  204. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
  205. package/dest/msg_validators/tx_validator/fee_payer_balance.js +20 -0
  206. package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
  207. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  208. package/dest/msg_validators/tx_validator/gas_validator.js +11 -16
  209. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  210. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  211. package/dest/msg_validators/tx_validator/index.js +1 -0
  212. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +4 -3
  213. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  214. package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
  215. package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
  216. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  217. package/dest/msg_validators/tx_validator/phases_validator.js +6 -4
  218. package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
  219. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
  220. package/dest/msg_validators/tx_validator/size_validator.js +23 -0
  221. package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
  222. package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
  223. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +23 -5
  224. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  225. package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
  226. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  227. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  228. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  229. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
  230. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  231. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
  232. package/dest/services/data_store.d.ts +1 -1
  233. package/dest/services/data_store.d.ts.map +1 -1
  234. package/dest/services/data_store.js +10 -6
  235. package/dest/services/discv5/discV5_service.d.ts +1 -1
  236. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  237. package/dest/services/discv5/discV5_service.js +1 -1
  238. package/dest/services/dummy_service.d.ts +28 -3
  239. package/dest/services/dummy_service.d.ts.map +1 -1
  240. package/dest/services/dummy_service.js +51 -0
  241. package/dest/services/encoding.d.ts +25 -4
  242. package/dest/services/encoding.d.ts.map +1 -1
  243. package/dest/services/encoding.js +76 -6
  244. package/dest/services/gossipsub/index.d.ts +3 -0
  245. package/dest/services/gossipsub/index.d.ts.map +1 -0
  246. package/dest/services/gossipsub/index.js +2 -0
  247. package/dest/services/gossipsub/scoring.d.ts +21 -3
  248. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  249. package/dest/services/gossipsub/scoring.js +24 -7
  250. package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
  251. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  252. package/dest/services/gossipsub/topic_score_params.js +346 -0
  253. package/dest/services/index.d.ts +2 -1
  254. package/dest/services/index.d.ts.map +1 -1
  255. package/dest/services/index.js +1 -0
  256. package/dest/services/libp2p/instrumentation.d.ts +3 -1
  257. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  258. package/dest/services/libp2p/instrumentation.js +36 -71
  259. package/dest/services/libp2p/libp2p_service.d.ts +116 -92
  260. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  261. package/dest/services/libp2p/libp2p_service.js +1153 -267
  262. package/dest/services/peer-manager/interface.d.ts +1 -1
  263. package/dest/services/peer-manager/metrics.d.ts +9 -2
  264. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  265. package/dest/services/peer-manager/metrics.js +39 -16
  266. package/dest/services/peer-manager/peer_manager.d.ts +2 -33
  267. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  268. package/dest/services/peer-manager/peer_manager.js +6 -12
  269. package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
  270. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  271. package/dest/services/peer-manager/peer_scoring.js +68 -4
  272. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +48 -0
  273. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  274. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +562 -0
  275. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  276. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  277. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  278. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +46 -0
  279. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  280. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  281. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +34 -0
  282. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  283. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +130 -0
  284. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
  285. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  286. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
  287. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
  288. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  289. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
  290. package/dest/services/reqresp/config.d.ts +1 -1
  291. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
  292. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  293. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
  294. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -4
  295. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  296. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  297. package/dest/services/reqresp/constants.d.ts +12 -0
  298. package/dest/services/reqresp/constants.d.ts.map +1 -0
  299. package/dest/services/reqresp/constants.js +7 -0
  300. package/dest/services/reqresp/index.d.ts +1 -1
  301. package/dest/services/reqresp/interface.d.ts +13 -2
  302. package/dest/services/reqresp/interface.d.ts.map +1 -1
  303. package/dest/services/reqresp/interface.js +16 -2
  304. package/dest/services/reqresp/metrics.d.ts +6 -5
  305. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  306. package/dest/services/reqresp/metrics.js +17 -21
  307. package/dest/services/reqresp/protocols/auth.d.ts +2 -2
  308. package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
  309. package/dest/services/reqresp/protocols/auth.js +2 -2
  310. package/dest/services/reqresp/protocols/block.d.ts +1 -1
  311. package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
  312. package/dest/services/reqresp/protocols/block.js +3 -2
  313. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
  314. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  315. package/dest/services/reqresp/protocols/block_txs/bitvector.js +12 -0
  316. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  317. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  318. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
  319. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +30 -9
  320. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  321. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +60 -14
  322. package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
  323. package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
  324. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  325. package/dest/services/reqresp/protocols/index.d.ts +1 -1
  326. package/dest/services/reqresp/protocols/ping.d.ts +1 -1
  327. package/dest/services/reqresp/protocols/status.d.ts +6 -5
  328. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  329. package/dest/services/reqresp/protocols/status.js +7 -3
  330. package/dest/services/reqresp/protocols/tx.d.ts +8 -3
  331. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  332. package/dest/services/reqresp/protocols/tx.js +20 -0
  333. package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
  334. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +2 -2
  335. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  336. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  337. package/dest/services/reqresp/reqresp.d.ts +6 -41
  338. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  339. package/dest/services/reqresp/reqresp.js +472 -51
  340. package/dest/services/reqresp/status.d.ts +2 -2
  341. package/dest/services/reqresp/status.d.ts.map +1 -1
  342. package/dest/services/service.d.ts +55 -3
  343. package/dest/services/service.d.ts.map +1 -1
  344. package/dest/services/tx_collection/config.d.ts +22 -1
  345. package/dest/services/tx_collection/config.d.ts.map +1 -1
  346. package/dest/services/tx_collection/config.js +56 -2
  347. package/dest/services/tx_collection/fast_tx_collection.d.ts +10 -12
  348. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  349. package/dest/services/tx_collection/fast_tx_collection.js +71 -44
  350. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  351. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  352. package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
  353. package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
  354. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  355. package/dest/services/tx_collection/file_store_tx_source.js +90 -0
  356. package/dest/services/tx_collection/index.d.ts +3 -1
  357. package/dest/services/tx_collection/index.d.ts.map +1 -1
  358. package/dest/services/tx_collection/index.js +2 -0
  359. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  360. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  361. package/dest/services/tx_collection/instrumentation.js +11 -13
  362. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  363. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  364. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  365. package/dest/services/tx_collection/proposal_tx_collector.d.ts +49 -0
  366. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
  367. package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
  368. package/dest/services/tx_collection/slow_tx_collection.d.ts +9 -6
  369. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  370. package/dest/services/tx_collection/slow_tx_collection.js +61 -26
  371. package/dest/services/tx_collection/tx_collection.d.ts +31 -18
  372. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  373. package/dest/services/tx_collection/tx_collection.js +79 -7
  374. package/dest/services/tx_collection/tx_collection_sink.d.ts +19 -9
  375. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  376. package/dest/services/tx_collection/tx_collection_sink.js +26 -29
  377. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  378. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  379. package/dest/services/tx_collection/tx_source.js +19 -2
  380. package/dest/services/tx_file_store/config.d.ts +16 -0
  381. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  382. package/dest/services/tx_file_store/config.js +22 -0
  383. package/dest/services/tx_file_store/index.d.ts +4 -0
  384. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  385. package/dest/services/tx_file_store/index.js +3 -0
  386. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  387. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  388. package/dest/services/tx_file_store/instrumentation.js +29 -0
  389. package/dest/services/tx_file_store/tx_file_store.d.ts +48 -0
  390. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  391. package/dest/services/tx_file_store/tx_file_store.js +152 -0
  392. package/dest/services/tx_provider.d.ts +6 -4
  393. package/dest/services/tx_provider.d.ts.map +1 -1
  394. package/dest/services/tx_provider.js +16 -6
  395. package/dest/services/tx_provider_instrumentation.d.ts +5 -2
  396. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  397. package/dest/services/tx_provider_instrumentation.js +14 -14
  398. package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
  399. package/dest/test-helpers/get-ports.d.ts +1 -1
  400. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  401. package/dest/test-helpers/index.d.ts +3 -1
  402. package/dest/test-helpers/index.d.ts.map +1 -1
  403. package/dest/test-helpers/index.js +2 -0
  404. package/dest/test-helpers/make-enrs.d.ts +1 -1
  405. package/dest/test-helpers/make-test-p2p-clients.d.ts +4 -4
  406. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  407. package/dest/test-helpers/mock-pubsub.d.ts +31 -4
  408. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  409. package/dest/test-helpers/mock-pubsub.js +103 -2
  410. package/dest/test-helpers/mock-tx-helpers.d.ts +2 -2
  411. package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -1
  412. package/dest/test-helpers/mock-tx-helpers.js +1 -1
  413. package/dest/test-helpers/reqresp-nodes.d.ts +2 -2
  414. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  415. package/dest/test-helpers/reqresp-nodes.js +2 -1
  416. package/dest/test-helpers/test_tx_provider.d.ts +40 -0
  417. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  418. package/dest/test-helpers/test_tx_provider.js +41 -0
  419. package/dest/test-helpers/testbench-utils.d.ts +163 -0
  420. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  421. package/dest/test-helpers/testbench-utils.js +366 -0
  422. package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
  423. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  424. package/dest/testbench/p2p_client_testbench_worker.js +221 -120
  425. package/dest/testbench/parse_log_file.d.ts +1 -1
  426. package/dest/testbench/testbench.d.ts +1 -1
  427. package/dest/testbench/worker_client_manager.d.ts +51 -6
  428. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  429. package/dest/testbench/worker_client_manager.js +226 -39
  430. package/dest/types/index.d.ts +1 -1
  431. package/dest/util.d.ts +3 -2
  432. package/dest/util.d.ts.map +1 -1
  433. package/dest/util.js +11 -2
  434. package/dest/versioning.d.ts +1 -1
  435. package/package.json +19 -18
  436. package/src/bootstrap/bootstrap.ts +7 -4
  437. package/src/client/factory.ts +98 -31
  438. package/src/client/interface.ts +77 -23
  439. package/src/client/p2p_client.ts +291 -309
  440. package/src/client/test/tx_proposal_collector/README.md +227 -0
  441. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +346 -0
  442. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
  443. package/src/config.ts +77 -30
  444. package/src/errors/attestation-pool.error.ts +13 -0
  445. package/src/errors/tx-pool.error.ts +12 -0
  446. package/src/index.ts +1 -0
  447. package/src/mem_pools/attestation_pool/attestation_pool.ts +518 -45
  448. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +618 -276
  449. package/src/mem_pools/attestation_pool/index.ts +9 -2
  450. package/src/mem_pools/attestation_pool/mocks.ts +22 -15
  451. package/src/mem_pools/index.ts +4 -1
  452. package/src/mem_pools/instrumentation.ts +48 -10
  453. package/src/mem_pools/interface.ts +5 -7
  454. package/src/mem_pools/tx_pool/README.md +270 -0
  455. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +372 -371
  456. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +132 -0
  457. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +208 -0
  458. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +162 -0
  459. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
  460. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +93 -0
  461. package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
  462. package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
  463. package/src/mem_pools/tx_pool/index.ts +0 -1
  464. package/src/mem_pools/tx_pool/priority.ts +8 -1
  465. package/src/mem_pools/tx_pool/tx_pool.ts +18 -5
  466. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +23 -17
  467. package/src/mem_pools/tx_pool_v2/README.md +275 -0
  468. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  469. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  470. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  471. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  472. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
  473. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +122 -0
  474. package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
  475. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
  476. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  477. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  478. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
  479. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
  480. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  481. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  482. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  483. package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
  484. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +242 -0
  485. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  486. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
  487. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
  488. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1069 -0
  489. package/src/msg_validators/attestation_validator/attestation_validator.ts +45 -32
  490. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +94 -0
  491. package/src/msg_validators/attestation_validator/index.ts +1 -0
  492. package/src/msg_validators/clock_tolerance.ts +51 -0
  493. package/src/msg_validators/index.ts +1 -1
  494. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
  495. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
  496. package/src/msg_validators/proposal_validator/index.ts +3 -0
  497. package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
  498. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +230 -0
  499. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  500. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  501. package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
  502. package/src/msg_validators/tx_validator/data_validator.ts +18 -6
  503. package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
  504. package/src/msg_validators/tx_validator/factory.ts +67 -25
  505. package/src/msg_validators/tx_validator/fee_payer_balance.ts +40 -0
  506. package/src/msg_validators/tx_validator/gas_validator.ts +17 -28
  507. package/src/msg_validators/tx_validator/index.ts +1 -0
  508. package/src/msg_validators/tx_validator/metadata_validator.ts +19 -8
  509. package/src/msg_validators/tx_validator/phases_validator.ts +8 -4
  510. package/src/msg_validators/tx_validator/size_validator.ts +22 -0
  511. package/src/msg_validators/tx_validator/test_utils.ts +1 -1
  512. package/src/msg_validators/tx_validator/timestamp_validator.ts +30 -19
  513. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  514. package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
  515. package/src/services/data_store.ts +10 -7
  516. package/src/services/discv5/discV5_service.ts +1 -1
  517. package/src/services/dummy_service.ts +68 -1
  518. package/src/services/encoding.ts +83 -6
  519. package/src/services/gossipsub/README.md +641 -0
  520. package/src/services/gossipsub/index.ts +2 -0
  521. package/src/services/gossipsub/scoring.ts +29 -5
  522. package/src/services/gossipsub/topic_score_params.ts +487 -0
  523. package/src/services/index.ts +1 -0
  524. package/src/services/libp2p/instrumentation.ts +39 -71
  525. package/src/services/libp2p/libp2p_service.ts +865 -277
  526. package/src/services/peer-manager/metrics.ts +44 -16
  527. package/src/services/peer-manager/peer_manager.ts +7 -4
  528. package/src/services/peer-manager/peer_scoring.ts +70 -3
  529. package/src/services/reqresp/batch-tx-requester/README.md +305 -0
  530. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
  531. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  532. package/src/services/reqresp/batch-tx-requester/interface.ts +53 -0
  533. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -0
  534. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
  535. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
  536. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
  537. package/src/services/reqresp/connection-sampler/connection_sampler.ts +19 -1
  538. package/src/services/reqresp/constants.ts +14 -0
  539. package/src/services/reqresp/interface.ts +30 -2
  540. package/src/services/reqresp/metrics.ts +36 -27
  541. package/src/services/reqresp/protocols/auth.ts +2 -2
  542. package/src/services/reqresp/protocols/block.ts +3 -2
  543. package/src/services/reqresp/protocols/block_txs/bitvector.ts +16 -0
  544. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
  545. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +75 -10
  546. package/src/services/reqresp/protocols/status.ts +16 -12
  547. package/src/services/reqresp/protocols/tx.ts +23 -2
  548. package/src/services/reqresp/reqresp.ts +80 -23
  549. package/src/services/service.ts +72 -4
  550. package/src/services/tx_collection/config.ts +84 -2
  551. package/src/services/tx_collection/fast_tx_collection.ts +96 -49
  552. package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
  553. package/src/services/tx_collection/file_store_tx_source.ts +117 -0
  554. package/src/services/tx_collection/index.ts +6 -0
  555. package/src/services/tx_collection/instrumentation.ts +11 -13
  556. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  557. package/src/services/tx_collection/proposal_tx_collector.ts +113 -0
  558. package/src/services/tx_collection/slow_tx_collection.ts +70 -36
  559. package/src/services/tx_collection/tx_collection.ts +122 -24
  560. package/src/services/tx_collection/tx_collection_sink.ts +30 -34
  561. package/src/services/tx_collection/tx_source.ts +22 -3
  562. package/src/services/tx_file_store/config.ts +37 -0
  563. package/src/services/tx_file_store/index.ts +3 -0
  564. package/src/services/tx_file_store/instrumentation.ts +36 -0
  565. package/src/services/tx_file_store/tx_file_store.ts +175 -0
  566. package/src/services/tx_provider.ts +27 -10
  567. package/src/services/tx_provider_instrumentation.ts +24 -14
  568. package/src/test-helpers/index.ts +2 -0
  569. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  570. package/src/test-helpers/mock-pubsub.ts +144 -4
  571. package/src/test-helpers/mock-tx-helpers.ts +1 -1
  572. package/src/test-helpers/reqresp-nodes.ts +3 -2
  573. package/src/test-helpers/test_tx_provider.ts +64 -0
  574. package/src/test-helpers/testbench-utils.ts +430 -0
  575. package/src/testbench/p2p_client_testbench_worker.ts +349 -117
  576. package/src/testbench/worker_client_manager.ts +304 -42
  577. package/src/util.ts +19 -3
  578. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -28
  579. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  580. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -174
  581. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -23
  582. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  583. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -175
  584. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -79
  585. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
  586. package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -232
  587. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
  588. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
  589. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -70
  590. package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
  591. package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
  592. package/dest/msg_validators/block_proposal_validator/index.js +0 -1
  593. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -235
  594. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -225
  595. package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -278
  596. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -81
  597. package/src/msg_validators/block_proposal_validator/index.ts +0 -1
@@ -1,14 +1,14 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { insertIntoSortedArray } from '@aztec/foundation/array';
2
+ import { BlockNumber } from '@aztec/foundation/branded-types';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
4
  import { toArray } from '@aztec/foundation/iterable';
3
5
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
6
  import type { TypedEventEmitter } from '@aztec/foundation/types';
5
- import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap, AztecAsyncSingleton } from '@aztec/kv-store';
6
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
7
- import { GasFees } from '@aztec/stdlib/gas';
7
+ import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
8
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
9
  import type { MerkleTreeReadOperations, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
9
10
  import { ChonkProof } from '@aztec/stdlib/proofs';
10
11
  import type { TxAddedToPoolStats } from '@aztec/stdlib/stats';
11
- import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
12
12
  import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
13
13
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
14
14
 
@@ -16,49 +16,56 @@ import assert from 'assert';
16
16
  import EventEmitter from 'node:events';
17
17
 
18
18
  import { ArchiveCache } from '../../msg_validators/tx_validator/archive_cache.js';
19
- import { GasTxValidator } from '../../msg_validators/tx_validator/gas_validator.js';
20
19
  import { PoolInstrumentation, PoolName, type PoolStatsCallback } from '../instrumentation.js';
20
+ import { EvictionManager } from './eviction/eviction_manager.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';
29
+ import { InvalidTxsAfterMiningRule } from './eviction/invalid_txs_after_mining_rule.js';
30
+ import { InvalidTxsAfterReorgRule } from './eviction/invalid_txs_after_reorg_rule.js';
31
+ import { LowPriorityEvictionRule } from './eviction/low_priority_eviction_rule.js';
32
+ import { NullifierConflictPreAddRule } from './eviction/nullifier_conflict_pre_add_rule.js';
21
33
  import { getPendingTxPriority } from './priority.js';
22
34
  import type { TxPool, TxPoolEvents, TxPoolOptions } from './tx_pool.js';
23
35
 
24
36
  /**
25
37
  * KV implementation of the Transaction Pool.
26
38
  */
27
- export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<TxPoolEvents>) implements TxPool {
39
+ export class AztecKVTxPool
40
+ extends (EventEmitter as new () => TypedEventEmitter<TxPoolEvents>)
41
+ implements TxPool, TxPoolOperations
42
+ {
28
43
  #store: AztecAsyncKVStore;
29
44
 
30
45
  /** Our tx pool, stored as a Map, with K: tx hash and V: the transaction. */
31
46
  #txs: AztecAsyncMap<string, Buffer>;
32
47
 
33
- /** The maximum cumulative tx size that the pending txs in the pool take up. */
34
- #maxTxPoolSize: number = 0;
35
-
36
- /** The tx evicion logic will kick after pool size is greater than maxTxPoolSize * txPoolOverflowFactor */
37
- txPoolOverflowFactor: number = 1;
48
+ /** Holds the historical block for each tx */
49
+ #pendingTxHashToHistoricalBlockHeaderHash: AztecAsyncMap<string, string>;
38
50
 
39
51
  /** Index from tx hash to the block number in which they were mined, filtered by mined txs. */
40
- #minedTxHashToBlock: AztecAsyncMap<string, number>;
52
+ #minedTxHashToBlock: AztecAsyncMap<string, BlockNumber>;
41
53
 
42
54
  /** Index from tx priority (stored as hex) to its tx hash, filtered by pending txs. */
43
55
  #pendingTxPriorityToHash: AztecAsyncMultiMap<string, string>;
44
56
 
45
- /** Index from tx hash to its tx size (in bytes), filtered by pending txs. */
46
- #pendingTxHashToSize: AztecAsyncMap<string, number>;
47
-
48
- /** Index from tx hash to its header hash, filtered by pending txs. */
49
- #pendingTxHashToHeaderHash: AztecAsyncMap<string, string>;
50
-
51
57
  /** Map from tx hash to the block number it was originally mined in (for soft-deleted txs). */
52
- #deletedMinedTxHashes: AztecAsyncMap<string, number>;
58
+ #deletedMinedTxHashes: AztecAsyncMap<string, BlockNumber>;
53
59
 
54
60
  /** MultiMap from block number to deleted mined tx hashes for efficient cleanup. */
55
- #blockToDeletedMinedTxHash: AztecAsyncMultiMap<number, string>;
61
+ #blockToDeletedMinedTxHash: AztecAsyncMultiMap<BlockNumber, string>;
62
+
63
+ #historicalHeaderToTxHash: AztecAsyncMultiMap<string, string>;
56
64
 
57
- /** The cumulative tx size in bytes that the pending txs in the pool take up. */
58
- #pendingTxSize: AztecAsyncSingleton<number>;
65
+ #feePayerToBalanceEntry: AztecAsyncMultiMap<string, Buffer>;
59
66
 
60
- /** In-memory mapping of pending tx hashes to the hydrated pending tx in the pool. */
61
- #pendingTxs: Map<string, Tx>;
67
+ /** Index from nullifier to pending tx hash */
68
+ #pendingNullifierToTxHash: AztecAsyncMap<string, string>;
62
69
 
63
70
  /** In-memory set of txs that should not be evicted from the pool. */
64
71
  #nonEvictableTxs: Set<string>;
@@ -75,8 +82,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
75
82
  /** Number of txs to archive. */
76
83
  #archivedTxLimit: number = 0;
77
84
 
78
- /** The world state synchronizer used in the node. */
79
- #worldStateSynchronizer: WorldStateSynchronizer;
85
+ #evictionManager: EvictionManager;
80
86
 
81
87
  #log: Logger;
82
88
 
@@ -93,7 +99,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
93
99
  constructor(
94
100
  store: AztecAsyncKVStore,
95
101
  archive: AztecAsyncKVStore,
96
- worldStateSynchronizer: WorldStateSynchronizer,
102
+ worldState: WorldStateSynchronizer,
97
103
  telemetry: TelemetryClient = getTelemetryClient(),
98
104
  config: TxPoolOptions = {},
99
105
  log = createLogger('p2p:tx_pool'),
@@ -101,18 +107,32 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
101
107
  super();
102
108
 
103
109
  this.#log = log;
110
+
111
+ this.#evictionManager = new EvictionManager(this);
112
+ this.#evictionManager.registerRule(new InvalidTxsAfterMiningRule());
113
+ this.#evictionManager.registerRule(new InvalidTxsAfterReorgRule(worldState));
114
+ this.#evictionManager.registerRule(new FeePayerBalanceEvictionRule(worldState));
115
+ this.#evictionManager.registerRule(
116
+ new LowPriorityEvictionRule({
117
+ //NOTE: 0 effectively disables low priority eviction
118
+ maxPoolSize: config.maxPendingTxCount ?? 0,
119
+ }),
120
+ );
121
+ this.#evictionManager.registerPreAddRule(new NullifierConflictPreAddRule());
122
+
104
123
  this.updateConfig(config);
105
124
 
106
125
  this.#txs = store.openMap('txs');
107
126
  this.#minedTxHashToBlock = store.openMap('txHashToBlockMined');
108
127
  this.#pendingTxPriorityToHash = store.openMultiMap('pendingTxFeeToHash');
109
- this.#pendingTxHashToSize = store.openMap('pendingTxHashToSize');
110
- this.#pendingTxHashToHeaderHash = store.openMap('pendingTxHashToHeaderHash');
111
- this.#pendingTxSize = store.openSingleton('pendingTxSize');
112
128
  this.#deletedMinedTxHashes = store.openMap('deletedMinedTxHashes');
113
129
  this.#blockToDeletedMinedTxHash = store.openMultiMap('blockToDeletedMinedTxHash');
114
130
 
115
- this.#pendingTxs = new Map<string, Tx>();
131
+ this.#pendingTxHashToHistoricalBlockHeaderHash = store.openMap('txHistoricalBlock');
132
+ this.#historicalHeaderToTxHash = store.openMultiMap('historicalHeaderToPendingTxHash');
133
+ this.#feePayerToBalanceEntry = store.openMultiMap('feePayerToBalanceEntry');
134
+ this.#pendingNullifierToTxHash = store.openMap('pendingNullifierToTxHash');
135
+
116
136
  this.#nonEvictableTxs = new Set<string>();
117
137
 
118
138
  this.#archivedTxs = archive.openMap('archivedTxs');
@@ -120,7 +140,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
120
140
 
121
141
  this.#store = store;
122
142
  this.#archive = archive;
123
- this.#worldStateSynchronizer = worldStateSynchronizer;
143
+
124
144
  this.#metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL, this.countTxs, () => store.estimateSize());
125
145
  }
126
146
 
@@ -141,6 +161,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
141
161
  }
142
162
  return true;
143
163
  }
164
+
144
165
  /**
145
166
  * Marks transactions as mined in a block and updates the pool state accordingly.
146
167
  * Removes the transactions from the pending set and adds them to the mined set.
@@ -153,68 +174,80 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
153
174
  return Promise.resolve();
154
175
  }
155
176
 
156
- const minedNullifiers = new Set<string>();
157
- const minedFeePayers = new Set<string>();
177
+ const uniqueMinedNullifiers: Fr[] = [];
178
+ const uniqueMinedFeePayers: AztecAddress[] = [];
158
179
 
159
- await this.#store.transactionAsync(async () => {
160
- let pendingTxSize = (await this.#pendingTxSize.getAsync()) ?? 0;
161
- for (const hash of txHashes) {
162
- const key = hash.toString();
180
+ try {
181
+ await this.#store.transactionAsync(async () => {
182
+ for (const hash of txHashes) {
183
+ const key = hash.toString();
184
+ await this.#minedTxHashToBlock.set(key, blockHeader.globalVariables.blockNumber);
185
+
186
+ const tx = await this.getTxByHash(hash);
187
+ if (tx) {
188
+ const nullifiers = tx.data.getNonEmptyNullifiers();
189
+
190
+ nullifiers.forEach(nullifier => insertIntoSortedArray(uniqueMinedNullifiers, nullifier, Fr.cmp, false));
191
+ insertIntoSortedArray(
192
+ uniqueMinedFeePayers,
193
+ tx.data.feePayer,
194
+ (a, b) => a.toField().cmp(b.toField()),
195
+ false,
196
+ );
197
+
198
+ await this.removePendingTxIndicesInDbTx(tx, key);
199
+ }
163
200
 
164
- // If this tx was previously soft-deleted, remove it from the deleted sets
165
- if (await this.#deletedMinedTxHashes.hasAsync(key)) {
166
- const originalBlock = await this.#deletedMinedTxHashes.getAsync(key);
167
- await this.#deletedMinedTxHashes.delete(key);
168
- // Remove from block-to-hash mapping
169
- if (originalBlock !== undefined) {
170
- await this.#blockToDeletedMinedTxHash.deleteValue(originalBlock, key);
201
+ // If this tx was previously soft-deleted, remove it from the deleted sets
202
+ if (await this.#deletedMinedTxHashes.hasAsync(key)) {
203
+ const originalBlock = await this.#deletedMinedTxHashes.getAsync(key);
204
+ await this.#deletedMinedTxHashes.delete(key);
205
+ // Remove from block-to-hash mapping
206
+ if (originalBlock !== undefined) {
207
+ await this.#blockToDeletedMinedTxHash.deleteValue(originalBlock, key);
208
+ }
171
209
  }
172
210
  }
211
+ });
173
212
 
174
- await this.#minedTxHashToBlock.set(key, blockHeader.globalVariables.blockNumber);
175
-
176
- const tx = await this.getPendingTxByHash(hash);
177
- if (tx) {
178
- const nullifiers = tx.data.getNonEmptyNullifiers();
179
- nullifiers.forEach(nullifier => minedNullifiers.add(nullifier.toString()));
180
- minedFeePayers.add(tx.data.feePayer.toString());
181
- pendingTxSize -= tx.getSize();
182
- await this.removePendingTxIndices(tx, key);
183
- }
184
- }
185
- await this.#pendingTxSize.set(pendingTxSize);
213
+ await this.#evictionManager.evictAfterNewBlock(blockHeader, uniqueMinedNullifiers, uniqueMinedFeePayers);
186
214
 
187
- await this.evictInvalidTxsAfterMining(txHashes, blockHeader, minedNullifiers, minedFeePayers);
188
- });
189
- // We update this after the transaction above. This ensures that the non-evictable transactions are not evicted
190
- // until any that have been mined are marked as such.
191
- // The non-evictable set is not considered when evicting transactions that are invalid after a block is mined.
192
- this.#nonEvictableTxs.clear();
215
+ this.#metrics.transactionsRemoved(txHashes.map(hash => hash.toBigInt()));
216
+ } catch (err) {
217
+ this.#log.warn('Unexpected error when marking txs as mined', { err });
218
+ }
193
219
  }
194
220
 
195
- public async markMinedAsPending(txHashes: TxHash[]): Promise<void> {
221
+ public async markMinedAsPending(txHashes: TxHash[], latestBlock: BlockNumber): Promise<void> {
196
222
  if (txHashes.length === 0) {
197
223
  return Promise.resolve();
198
224
  }
199
- await this.#store.transactionAsync(async () => {
200
- let pendingTxSize = (await this.#pendingTxSize.getAsync()) ?? 0;
201
- for (const hash of txHashes) {
202
- const key = hash.toString();
203
- await this.#minedTxHashToBlock.delete(key);
225
+ try {
226
+ await this.#store.transactionAsync(async () => {
227
+ for (const hash of txHashes) {
228
+ const key = hash.toString();
229
+ await this.#minedTxHashToBlock.delete(key);
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
+ }
204
238
 
205
- // Rehydrate the tx in the in-memory pending txs mapping
206
- const tx = await this.getPendingTxByHash(hash);
207
- if (tx) {
208
- await this.addPendingTxIndices(tx, key);
209
- pendingTxSize += tx.getSize();
239
+ // Rehydrate the tx in the in-memory pending txs mapping
240
+ const tx = await this.getTxByHash(hash);
241
+ if (tx) {
242
+ await this.addPendingTxIndicesInDbTx(tx, key);
243
+ }
210
244
  }
211
- }
212
-
213
- await this.#pendingTxSize.set(pendingTxSize);
214
- });
245
+ });
215
246
 
216
- await this.evictInvalidTxsAfterReorg(txHashes);
217
- await this.evictLowPriorityTxs(txHashes);
247
+ await this.#evictionManager.evictAfterChainPrune(latestBlock);
248
+ } catch (err) {
249
+ this.#log.warn('Unexpected error when marking mined txs as pending', { err });
250
+ }
218
251
  }
219
252
 
220
253
  public async getPendingTxHashes(): Promise<TxHash[]> {
@@ -222,38 +255,6 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
222
255
  return vals.map(TxHash.fromString);
223
256
  }
224
257
 
225
- public async getMinedTxHashes(): Promise<[TxHash, number][]> {
226
- const vals = await toArray(this.#minedTxHashToBlock.entriesAsync());
227
- return vals.map(([txHash, blockNumber]) => [TxHash.fromString(txHash), blockNumber]);
228
- }
229
-
230
- public async getPendingTxCount(): Promise<number> {
231
- return (await this.#pendingTxHashToHeaderHash.sizeAsync()) ?? 0;
232
- }
233
-
234
- public async getMinedTxCount(): Promise<number> {
235
- return (await this.#minedTxHashToBlock.sizeAsync()) ?? 0;
236
- }
237
-
238
- public async getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined> {
239
- const key = txHash.toString();
240
- const [isMined, isKnown, isDeleted] = await Promise.all([
241
- this.#minedTxHashToBlock.hasAsync(key),
242
- this.#txs.hasAsync(key),
243
- this.#deletedMinedTxHashes.hasAsync(key),
244
- ]);
245
-
246
- if (isDeleted) {
247
- return 'deleted';
248
- } else if (isMined) {
249
- return 'mined';
250
- } else if (isKnown) {
251
- return 'pending';
252
- } else {
253
- return undefined;
254
- }
255
- }
256
-
257
258
  /**
258
259
  * Checks if a transaction exists in the pool and returns it.
259
260
  * @param txHash - The generated tx hash.
@@ -273,6 +274,11 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
273
274
  return await Promise.all(txHashes.map(txHash => this.#txs.hasAsync(txHash.toString())));
274
275
  }
275
276
 
277
+ async hasTx(txHash: TxHash): Promise<boolean> {
278
+ const result = await this.hasTxs([txHash]);
279
+ return result[0];
280
+ }
281
+
276
282
  /**
277
283
  * Checks if an archived tx exists and returns it.
278
284
  * @param txHash - The tx hash.
@@ -285,44 +291,82 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
285
291
 
286
292
  /**
287
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.
288
296
  * @param txs - An array of txs to be added to the pool.
289
- * @returns Empty promise.
297
+ * @returns count of added transactions
290
298
  */
291
299
  public async addTxs(txs: Tx[], opts: { source?: string } = {}): Promise<number> {
300
+ if (txs.length === 0) {
301
+ return Promise.resolve(0);
302
+ }
303
+
292
304
  const addedTxs: Tx[] = [];
305
+ const uniqueFeePayers: AztecAddress[] = [];
306
+ const replacedTxHashes: TxHash[] = [];
293
307
  const hashesAndStats = txs.map(tx => ({ txHash: tx.getTxHash(), txStats: tx.getStats() }));
294
- await this.#store.transactionAsync(async () => {
295
- let pendingTxSize = (await this.#pendingTxSize.getAsync()) ?? 0;
296
- await Promise.all(
297
- txs.map(async (tx, i) => {
308
+ try {
309
+ await this.#store.transactionAsync(async () => {
310
+ for (let i = 0; i < txs.length; i++) {
311
+ const tx = txs[i];
298
312
  const { txHash, txStats } = hashesAndStats[i];
299
313
  const key = txHash.toString();
300
314
  if (await this.#txs.hasAsync(key)) {
301
- this.#log.debug(`Tx ${txHash.toString()} already exists in the pool`);
302
- return;
315
+ this.#log.debug(`Tx ${key} already exists in the pool`);
316
+ continue;
303
317
  }
304
318
 
305
- this.#log.verbose(`Adding tx ${txHash.toString()} to pool`, {
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}`);
332
+ }
333
+ }
334
+
335
+ this.#log.verbose(`Adding tx ${key} to pool`, {
306
336
  eventName: 'tx-added-to-pool',
307
337
  ...txStats,
308
338
  } satisfies TxAddedToPoolStats);
309
339
 
310
340
  await this.#txs.set(key, tx.toBuffer());
311
- addedTxs.push(tx as Tx);
341
+ addedTxs.push(tx);
342
+ insertIntoSortedArray(uniqueFeePayers, tx.data.feePayer, (a, b) => a.toField().cmp(b.toField()), false);
343
+
344
+ await this.#pendingTxHashToHistoricalBlockHeaderHash.set(
345
+ key,
346
+ (await tx.data.constants.anchorBlockHeader.hash()).toString(),
347
+ );
312
348
 
313
349
  if (!(await this.#minedTxHashToBlock.hasAsync(key))) {
314
- pendingTxSize += tx.getSize();
315
- await this.addPendingTxIndices(tx, key);
350
+ await this.addPendingTxIndicesInDbTx(tx, key);
316
351
  this.#metrics.recordSize(tx);
317
352
  }
318
- }),
353
+ }
354
+ });
355
+
356
+ await this.#evictionManager.evictAfterNewTxs(
357
+ addedTxs.map(({ txHash }) => txHash),
358
+ uniqueFeePayers,
319
359
  );
360
+ } catch (err) {
361
+ this.#log.warn('Unexpected error when adding txs', { err });
362
+ }
320
363
 
321
- await this.#pendingTxSize.set(pendingTxSize);
322
- await this.evictLowPriorityTxs(hashesAndStats.map(({ txHash }) => txHash));
323
- });
364
+ if (replacedTxHashes.length > 0) {
365
+ this.#metrics.transactionsRemoved(replacedTxHashes.map(hash => hash.toBigInt()));
366
+ }
324
367
 
325
368
  if (addedTxs.length > 0) {
369
+ this.#metrics.transactionsAdded(addedTxs);
326
370
  this.emit('txs-added', { ...opts, txs: addedTxs });
327
371
  }
328
372
  return addedTxs.length;
@@ -334,54 +378,63 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
334
378
  * @param txHashes - An array of tx hashes to be deleted from the tx pool.
335
379
  * @returns Empty promise.
336
380
  */
337
- public deleteTxs(txHashes: TxHash[], opts: { eviction?: boolean; permanently?: boolean } = {}): Promise<void> {
381
+ public deleteTxs(txHashes: TxHash[], opts?: { permanently?: boolean }): Promise<void> {
338
382
  if (txHashes.length === 0) {
339
383
  return Promise.resolve();
340
384
  }
385
+
341
386
  const deletedTxs: Tx[] = [];
342
387
  const poolDbTx = this.#store.transactionAsync(async () => {
343
- let pendingTxSize = (await this.#pendingTxSize.getAsync()) ?? 0;
344
388
  for (const hash of txHashes) {
345
389
  const key = hash.toString();
346
390
  const tx = await this.getTxByHash(hash);
391
+ if (!tx) {
392
+ this.#log.trace(`Skipping deletion of missing tx ${key} from pool`);
393
+ continue;
394
+ }
347
395
 
348
- if (tx) {
349
- const minedBlockNumber = await this.#minedTxHashToBlock.getAsync(key);
350
-
351
- if (minedBlockNumber !== undefined) {
352
- await this.#minedTxHashToBlock.delete(key);
353
- if (opts.permanently) {
354
- // Permanently delete mined transactions if specified
355
- this.#log.trace(`Deleting mined tx ${key} from pool`);
356
- await this.#txs.delete(key);
357
- } else {
358
- // Soft-delete mined transactions: remove from mined set but keep in storage
359
- this.#log.trace(`Soft-deleting mined tx ${key} from pool`);
360
- await this.#deletedMinedTxHashes.set(key, minedBlockNumber);
361
- await this.#blockToDeletedMinedTxHash.set(minedBlockNumber, key);
362
- }
363
- } else {
364
- // Permanently delete pending transactions
365
- this.#log.trace(`Deleting pending tx ${key} from pool`);
366
- pendingTxSize -= tx.getSize();
367
- await this.removePendingTxIndices(tx, key);
368
- await this.#txs.delete(key);
369
- }
370
-
371
- if (!opts.eviction && this.#archivedTxLimit) {
396
+ const minedBlockNumber = await this.#minedTxHashToBlock.getAsync(key);
397
+ const txIsPending = minedBlockNumber === undefined;
398
+ if (txIsPending) {
399
+ await this.deletePendingTxInDbTx(tx, key);
400
+ } else {
401
+ await this.deleteMinedTx(key, minedBlockNumber!, opts?.permanently ?? false);
402
+ const shouldArchiveTx = this.#archivedTxLimit && !opts?.permanently;
403
+ if (shouldArchiveTx) {
372
404
  deletedTxs.push(tx);
373
405
  }
374
- } else {
375
- this.#log.trace(`Skipping deletion of missing tx ${key} from pool`);
376
406
  }
377
407
  }
378
-
379
- await this.#pendingTxSize.set(pendingTxSize);
380
408
  });
409
+ this.#metrics.transactionsRemoved(txHashes.map(hash => hash.toBigInt()));
381
410
  this.#log.debug(`Deleted ${txHashes.length} txs from pool`, { txHashes });
411
+
382
412
  return this.#archivedTxLimit ? poolDbTx.then(() => this.archiveTxs(deletedTxs)) : poolDbTx;
383
413
  }
384
414
 
415
+ private async deleteMinedTx(txHash: `0x${string}`, minedBlockNumber: BlockNumber, permanently: boolean) {
416
+ await this.#minedTxHashToBlock.delete(txHash);
417
+ if (permanently) {
418
+ this.#log.trace(`Deleting mined tx ${txHash} from pool`);
419
+ await this.#txs.delete(txHash);
420
+ return;
421
+ }
422
+
423
+ // Soft-delete mined transactions: remove from mined set but keep in storage
424
+ this.#log.trace(`Soft-deleting mined tx ${txHash} from pool`);
425
+ await this.#deletedMinedTxHashes.set(txHash, minedBlockNumber);
426
+ await this.#blockToDeletedMinedTxHash.set(minedBlockNumber, txHash);
427
+ }
428
+
429
+ // Assumes being called within a DB transaction
430
+ private async deletePendingTxInDbTx(tx: Tx, txHash: `0x${string}`) {
431
+ // We always permanently delete pending transactions
432
+ this.#log.trace(`Deleting pending tx ${txHash} from pool`);
433
+ await this.removePendingTxIndicesInDbTx(tx, txHash);
434
+ await this.#txs.delete(txHash);
435
+ await this.#pendingTxHashToHistoricalBlockHeaderHash.delete(txHash);
436
+ }
437
+
385
438
  /**
386
439
  * Gets all the transactions stored in the pool.
387
440
  * @returns Array of tx objects in the order they were added to the pool.
@@ -400,30 +453,107 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
400
453
  return vals.map(x => TxHash.fromString(x));
401
454
  }
402
455
 
403
- public updateConfig({ maxTxPoolSize, txPoolOverflowFactor, archivedTxLimit }: TxPoolOptions): void {
404
- if (typeof maxTxPoolSize === 'number') {
405
- assert(maxTxPoolSize >= 0, 'maxTxPoolSize must be greater or equal to 0');
406
- this.#maxTxPoolSize = maxTxPoolSize;
456
+ public async getPendingTxInfos(): Promise<PendingTxInfo[]> {
457
+ const vals = await toArray(this.#pendingTxPriorityToHash.valuesAsync());
458
+ const results = await Promise.all(vals.map(val => this.getPendingTxInfo(TxHash.fromString(val))));
459
+ return results.filter((info): info is PendingTxInfo => info !== undefined);
460
+ }
407
461
 
408
- if (maxTxPoolSize === 0) {
409
- this.#log.info(`Disabling maximum tx mempool size. Tx eviction stopped`);
410
- } else {
411
- this.#log.info(`Setting maximum tx mempool size`, { maxTxPoolSize });
462
+ private async getPendingTxInfo(txHash: TxHash): Promise<PendingTxInfo | undefined> {
463
+ let historicalBlockHash = await this.#pendingTxHashToHistoricalBlockHeaderHash.getAsync(txHash.toString());
464
+ // Not all tx might have this index created.
465
+ if (!historicalBlockHash) {
466
+ const tx = await this.getTxByHash(txHash);
467
+ if (!tx) {
468
+ this.#log.warn(`PendingTxInfo:tx ${txHash} not found`);
469
+ return undefined;
412
470
  }
471
+
472
+ historicalBlockHash = (await tx.data.constants.anchorBlockHeader.hash()).toString();
473
+ await this.#pendingTxHashToHistoricalBlockHeaderHash.set(txHash.toString(), historicalBlockHash);
474
+ }
475
+
476
+ return {
477
+ txHash,
478
+ blockHash: Fr.fromString(historicalBlockHash),
479
+ isEvictable: !this.#nonEvictableTxs.has(txHash.toString()),
480
+ };
481
+ }
482
+
483
+ public async getPendingTxsReferencingBlocks(blockHashes: Fr[]): Promise<TxBlockReference[]> {
484
+ const result: TxBlockReference[] = [];
485
+ for (const blockHash of blockHashes) {
486
+ const chunk = await toArray(this.#historicalHeaderToTxHash.getValuesAsync(blockHash.toString()));
487
+ result.push(
488
+ ...chunk.map(txHash => ({
489
+ txHash: TxHash.fromString(txHash),
490
+ blockHash,
491
+ isEvictable: !this.#nonEvictableTxs.has(txHash),
492
+ })),
493
+ );
494
+ }
495
+
496
+ return result;
497
+ }
498
+
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);
413
504
  }
505
+ return feePayers;
506
+ }
414
507
 
415
- if (typeof txPoolOverflowFactor === 'number') {
416
- assert(txPoolOverflowFactor >= 1, 'txPoolOveflowFactor must be greater or equal to 1');
417
- this.txPoolOverflowFactor = txPoolOverflowFactor;
418
- this.#log.info(`Allowing tx pool size to grow above limit`, { maxTxPoolSize, txPoolOverflowFactor });
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;
419
513
  }
514
+ }
515
+
516
+ public async getMinedTxHashes(): Promise<[TxHash, BlockNumber][]> {
517
+ const vals = await toArray(this.#minedTxHashToBlock.entriesAsync());
518
+ return vals.map(([txHash, blockNumber]) => [TxHash.fromString(txHash), blockNumber]);
519
+ }
520
+
521
+ public async getPendingTxCount(): Promise<number> {
522
+ return (await this.#pendingTxPriorityToHash.sizeAsync()) ?? 0;
523
+ }
524
+
525
+ public async getMinedTxCount(): Promise<number> {
526
+ return (await this.#minedTxHashToBlock.sizeAsync()) ?? 0;
527
+ }
420
528
 
421
- if (typeof archivedTxLimit === 'number') {
422
- assert(archivedTxLimit >= 0, 'archivedTxLimit must be greater or equal to 0');
423
- this.#archivedTxLimit = archivedTxLimit;
529
+ public async getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined> {
530
+ const key = txHash.toString();
531
+ const [isMined, isKnown, isDeleted] = await Promise.all([
532
+ this.#minedTxHashToBlock.hasAsync(key),
533
+ this.#txs.hasAsync(key),
534
+ this.#deletedMinedTxHashes.hasAsync(key),
535
+ ]);
536
+
537
+ if (isDeleted) {
538
+ return 'deleted';
539
+ } else if (isMined) {
540
+ return 'mined';
541
+ } else if (isKnown) {
542
+ return 'pending';
543
+ } else {
544
+ return undefined;
545
+ }
546
+ }
547
+
548
+ public updateConfig(cfg: TxPoolOptions): void {
549
+ if (typeof cfg.archivedTxLimit === 'number') {
550
+ assert(cfg.archivedTxLimit >= 0, 'archivedTxLimit must be greater or equal to 0');
551
+ this.#archivedTxLimit = cfg.archivedTxLimit;
424
552
  }
425
553
 
426
- // deletedMinedCleanupThresholdMs is no longer used in block-based cleanup
554
+ if (this.#evictionManager) {
555
+ this.#evictionManager.updateConfig(cfg);
556
+ }
427
557
  }
428
558
 
429
559
  public markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void> {
@@ -431,17 +561,26 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
431
561
  return Promise.resolve();
432
562
  }
433
563
 
564
+ public clearNonEvictableTxs(): Promise<void> {
565
+ // Clear the non-evictable set after completing the DB updates above.
566
+ // This ensures pinned (non-evictable) txs are protected while we mark mined txs,
567
+ // but they won't remain pinned indefinitely across blocks. Note that eviction rules
568
+ // (including post-mining invalidation) respect the non-evictable flag while it is set.
569
+ this.#nonEvictableTxs.clear();
570
+ return Promise.resolve();
571
+ }
572
+
434
573
  /**
435
574
  * Permanently deletes deleted mined transactions from blocks up to and including the specified block number.
436
575
  * @param blockNumber - Block number threshold. Deleted mined txs from this block or earlier will be permanently deleted.
437
576
  * @returns The number of transactions permanently deleted.
438
577
  */
439
- public async cleanupDeletedMinedTxs(blockNumber: number): Promise<number> {
578
+ public async cleanupDeletedMinedTxs(blockNumber: BlockNumber): Promise<number> {
440
579
  let deletedCount = 0;
441
- const txHashesToDelete: string[] = [];
442
- const blocksToDelete: number[] = [];
443
-
444
580
  await this.#store.transactionAsync(async () => {
581
+ const txHashesToDelete: string[] = [];
582
+ const blocksToDelete: BlockNumber[] = [];
583
+
445
584
  // Iterate through all entries and check block numbers
446
585
  for await (const [block, txHash] of this.#blockToDeletedMinedTxHash.entriesAsync()) {
447
586
  if (block <= blockNumber) {
@@ -455,6 +594,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
455
594
  deletedCount++;
456
595
  }
457
596
  }
597
+ this.#metrics.transactionsRemoved(txHashesToDelete);
458
598
 
459
599
  // Clean up block-to-hash mapping - delete all values for each block
460
600
  for (const block of blocksToDelete) {
@@ -471,15 +611,6 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
471
611
  return deletedCount;
472
612
  }
473
613
 
474
- /**
475
- * Creates a GasTxValidator instance.
476
- * @param db - DB for the validator to use
477
- * @returns A GasTxValidator instance
478
- */
479
- protected createGasTxValidator(db: MerkleTreeReadOperations): GasTxValidator {
480
- return new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, GasFees.empty());
481
- }
482
-
483
614
  /**
484
615
  * Creates an ArchiveCache instance.
485
616
  * @param db - DB for the cache to use
@@ -489,34 +620,9 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
489
620
  return new ArchiveCache(db);
490
621
  }
491
622
 
492
- /**
493
- * Checks if a cached transaction exists in the in-memory pending tx pool and returns it.
494
- * Otherwise, it checks the tx pool, updates the pending tx pool, and returns the tx.
495
- * @param txHash - The generated tx hash.
496
- * @returns The transaction, if found, 'undefined' otherwise.
497
- */
498
- private async getPendingTxByHash(txHash: TxHash | string): Promise<Tx | undefined> {
499
- let key;
500
- if (typeof txHash === 'string') {
501
- key = txHash;
502
- txHash = TxHash.fromString(txHash);
503
- } else {
504
- key = txHash.toString();
505
- }
506
-
507
- if (this.#pendingTxs.has(key)) {
508
- return this.#pendingTxs.get(key);
509
- }
510
- const tx = await this.getTxByHash(txHash);
511
- if (tx) {
512
- this.#pendingTxs.set(key, tx);
513
- return tx;
514
- }
515
- return undefined;
516
- }
517
-
518
623
  /**
519
624
  * Archives a list of txs for future reference. The number of archived txs is limited by the specified archivedTxLimit.
625
+ * Note: Pending txs should not be archived, only finalized txs
520
626
  * @param txs - The list of transactions to archive.
521
627
  * @returns Empty promise.
522
628
  */
@@ -524,6 +630,10 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
524
630
  if (txs.length === 0) {
525
631
  return;
526
632
  }
633
+ if (this.#archivedTxLimit === 0) {
634
+ return;
635
+ }
636
+
527
637
  try {
528
638
  const txHashes = await Promise.all(txs.map(tx => tx.getTxHash()));
529
639
  await this.#archive.transactionAsync(async () => {
@@ -563,183 +673,74 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
563
673
  }
564
674
  }
565
675
 
566
- /**
567
- * Evicts pending txs with the lowest priority fees from the pool to accomodate the max tx count and cumulative max tx size
568
- * after new txs are added.
569
- *
570
- * @param newTxHashes - The tx hashes of the new txs added to the pool.
571
- * @returns The total number of txs evicted from the pool and the number of new txs that were evicted.
572
- */
573
- private async evictLowPriorityTxs(
574
- newTxHashes: TxHash[],
575
- ): Promise<{ numLowPriorityTxsEvicted: number; numNewTxsEvicted: number }> {
576
- if (this.#maxTxPoolSize === undefined || this.#maxTxPoolSize === 0) {
577
- return { numLowPriorityTxsEvicted: 0, numNewTxsEvicted: 0 };
578
- }
579
-
580
- let numNewTxsEvicted = 0;
581
- const txsToEvict: TxHash[] = [];
582
-
583
- let pendingTxsSize = (await this.#pendingTxSize.getAsync()) ?? 0;
584
- if (pendingTxsSize > this.#maxTxPoolSize * this.txPoolOverflowFactor) {
585
- for await (const txHash of this.#pendingTxPriorityToHash.valuesAsync()) {
586
- if (this.#nonEvictableTxs.has(txHash.toString())) {
587
- continue;
588
- }
589
- const txSize =
590
- (await this.#pendingTxHashToSize.getAsync(txHash.toString())) ??
591
- (await this.getPendingTxByHash(txHash))?.getSize();
592
-
593
- this.#log.verbose(`Evicting tx ${txHash} from pool due to low priority to satisfy max tx size limit`, {
594
- txHash,
595
- txSize,
596
- });
597
-
598
- txsToEvict.push(TxHash.fromString(txHash));
676
+ // Assumes being called within a DB transaction
677
+ private async addPendingTxIndicesInDbTx(tx: Tx, txHash: string): Promise<void> {
678
+ await this.#pendingTxPriorityToHash.set(getPendingTxPriority(tx), txHash);
679
+ await this.#historicalHeaderToTxHash.set((await tx.data.constants.anchorBlockHeader.hash()).toString(), txHash);
680
+ await this.#feePayerToBalanceEntry.set(tx.data.feePayer.toString(), await FeePayerTxInfo.encode(tx, txHash));
599
681
 
600
- if (txSize) {
601
- pendingTxsSize -= txSize;
602
- if (pendingTxsSize <= this.#maxTxPoolSize) {
603
- break;
604
- }
605
- }
606
- }
607
- numNewTxsEvicted += newTxHashes.filter(txHash => txsToEvict.includes(txHash)).length;
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);
608
686
  }
687
+ }
609
688
 
610
- if (txsToEvict.length > 0) {
611
- await this.deleteTxs(txsToEvict, { eviction: true });
689
+ // Assumes being called within a DB transaction
690
+ private async removePendingTxIndicesInDbTx(tx: Tx, txHash: string): Promise<void> {
691
+ await this.#pendingTxPriorityToHash.deleteValue(getPendingTxPriority(tx), txHash);
692
+ await this.#historicalHeaderToTxHash.deleteValue(
693
+ (await tx.data.constants.anchorBlockHeader.hash()).toString(),
694
+ txHash,
695
+ );
696
+ await this.#feePayerToBalanceEntry.deleteValue(
697
+ tx.data.feePayer.toString(),
698
+ await FeePayerTxInfo.encode(tx, txHash),
699
+ );
700
+
701
+ // Remove nullifier entries
702
+ const nullifiers = tx.data.getNonEmptyNullifiers();
703
+ for (const nullifier of nullifiers) {
704
+ await this.#pendingNullifierToTxHash.delete(nullifier.toString());
612
705
  }
613
- return {
614
- numLowPriorityTxsEvicted: txsToEvict.length,
615
- numNewTxsEvicted,
616
- };
617
706
  }
618
707
 
619
708
  /**
620
- * Evicts invalid pending txs from the pool after a txs from a block are mined.
621
- * Eviction criteria includes:
622
- * - txs with nullifiers that are already included in the mined block
623
- * - txs with an insufficient fee payer balance
624
- * - txs with an expiration timestamp lower than that of the mined block
625
- *
626
- * @param minedTxHashes - The tx hashes of the txs mined in the block.
627
- * @param blockHeader - The header of the mined block.
628
- * @returns The total number of txs evicted from the pool.
709
+ * Returns up to `limit` lowest-priority evictable pending tx hashes without hydrating transactions.
710
+ * Iterates the priority index in ascending order and skips non-evictable txs.
629
711
  */
630
- private async evictInvalidTxsAfterMining(
631
- minedTxHashes: TxHash[],
632
- blockHeader: BlockHeader,
633
- minedNullifiers: Set<string>,
634
- minedFeePayers: Set<string>,
635
- ): Promise<number> {
636
- if (minedTxHashes.length === 0) {
637
- return 0;
638
- }
639
-
640
- const { blockNumber, timestamp } = blockHeader.globalVariables;
641
-
642
- // Wait for world state to be synced to at least the mined block number
643
- await this.#worldStateSynchronizer.syncImmediate(blockNumber);
644
-
645
- const db = this.#worldStateSynchronizer.getCommitted();
646
- const gasTxValidator = this.createGasTxValidator(db);
647
-
712
+ public async getLowestPriorityEvictable(limit: number): Promise<TxHash[]> {
648
713
  const txsToEvict: TxHash[] = [];
649
- for await (const txHash of this.#pendingTxPriorityToHash.valuesAsync()) {
650
- const tx = await this.getPendingTxByHash(txHash);
651
- if (!tx) {
652
- continue;
653
- }
654
-
655
- // Evict pending txs that share nullifiers with mined txs
656
- const txNullifiers = tx.data.getNonEmptyNullifiers();
657
- if (txNullifiers.some(nullifier => minedNullifiers.has(nullifier.toString()))) {
658
- this.#log.verbose(`Evicting tx ${txHash} from pool due to a duplicate nullifier with a mined tx`);
659
- txsToEvict.push(TxHash.fromString(txHash));
660
- continue;
661
- }
714
+ if (limit <= 0) {
715
+ return txsToEvict;
716
+ }
662
717
 
663
- // Evict pending txs with an insufficient fee payer balance
664
- if (
665
- minedFeePayers.has(tx.data.feePayer.toString()) &&
666
- (await gasTxValidator.validateTxFee(tx)).result === 'invalid'
667
- ) {
668
- this.#log.verbose(`Evicting tx ${txHash} from pool due to an insufficient fee payer balance`);
669
- txsToEvict.push(TxHash.fromString(txHash));
718
+ for await (const txHashStr of this.#pendingTxPriorityToHash.valuesAsync()) {
719
+ if (this.#nonEvictableTxs.has(txHashStr)) {
670
720
  continue;
671
721
  }
672
722
 
673
- // Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
674
- const includeByTimestamp = tx.data.includeByTimestamp;
675
- if (includeByTimestamp <= timestamp) {
676
- this.#log.verbose(
677
- `Evicting tx ${txHash} from pool due to the tx being expired (includeByTimestamp: ${includeByTimestamp}, mined block timestamp: ${timestamp})`,
678
- );
679
- txsToEvict.push(TxHash.fromString(txHash));
680
- continue;
723
+ txsToEvict.push(TxHash.fromString(txHashStr));
724
+ if (txsToEvict.length >= limit) {
725
+ break;
681
726
  }
682
727
  }
683
728
 
684
- if (txsToEvict.length > 0) {
685
- await this.deleteTxs(txsToEvict, { eviction: true });
686
- }
687
- return txsToEvict.length;
729
+ return txsToEvict;
688
730
  }
689
731
 
690
732
  /**
691
- * Evicts pending txs that no longer have valid archive roots or fee payer balances from the pool after a reorg.
692
- *
693
- * @param txHashes - The tx hashes of the txs that were moved from mined to pending.
694
- * @returns The total number of txs evicted from the pool.
733
+ * Creates a PreAddPoolAccess object for use by pre-add eviction rules.
734
+ * Provides read-only access to pool state during addTxs transaction.
695
735
  */
696
- private async evictInvalidTxsAfterReorg(txHashes: TxHash[]): Promise<number> {
697
- if (txHashes.length === 0) {
698
- return 0;
699
- }
700
-
701
- await this.#worldStateSynchronizer.syncImmediate();
702
- const db = this.#worldStateSynchronizer.getCommitted();
703
- const archiveCache = this.createArchiveCache(db);
704
- const gasTxValidator = this.createGasTxValidator(db);
705
-
706
- const txsToEvict: TxHash[] = [];
707
-
708
- for await (const [txHash, headerHash] of this.#pendingTxHashToHeaderHash.entriesAsync()) {
709
- const tx = await this.getPendingTxByHash(txHash);
710
- if (!tx) {
711
- continue;
712
- }
713
-
714
- const [index] = await archiveCache.getArchiveIndices([Fr.fromString(headerHash)]);
715
- if (index === undefined) {
716
- this.#log.verbose(`Evicting tx ${txHash} from pool due to an invalid archive root`);
717
- txsToEvict.push(TxHash.fromString(txHash));
718
- continue;
719
- }
720
-
721
- if ((await gasTxValidator.validateTxFee(tx)).result === 'invalid') {
722
- this.#log.verbose(`Evicting tx ${txHash} from pool due to an insufficient fee payer balance`);
723
- txsToEvict.push(TxHash.fromString(txHash));
724
- }
725
- }
726
-
727
- if (txsToEvict.length > 0) {
728
- await this.deleteTxs(txsToEvict, { eviction: true });
729
- }
730
- return txsToEvict.length;
731
- }
732
-
733
- private async addPendingTxIndices(tx: Tx, txHash: string): Promise<void> {
734
- await this.#pendingTxPriorityToHash.set(getPendingTxPriority(tx), txHash);
735
- await this.#pendingTxHashToSize.set(txHash, tx.getSize());
736
- await this.#pendingTxHashToHeaderHash.set(txHash, (await tx.data.constants.anchorBlockHeader.hash()).toString());
737
- }
738
-
739
- private async removePendingTxIndices(tx: Tx, txHash: string): Promise<void> {
740
- await this.#pendingTxPriorityToHash.deleteValue(getPendingTxPriority(tx), txHash);
741
- await this.#pendingTxHashToSize.delete(txHash);
742
- await this.#pendingTxHashToHeaderHash.delete(txHash);
743
- this.#pendingTxs.delete(txHash);
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
+ };
744
745
  }
745
746
  }