@aztec/p2p 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240

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 (573) hide show
  1. package/README.md +129 -3
  2. package/dest/bootstrap/bootstrap.d.ts +4 -3
  3. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  4. package/dest/bootstrap/bootstrap.js +13 -5
  5. package/dest/client/factory.d.ts +13 -12
  6. package/dest/client/factory.d.ts.map +1 -1
  7. package/dest/client/factory.js +65 -20
  8. package/dest/client/interface.d.ts +58 -36
  9. package/dest/client/interface.d.ts.map +1 -1
  10. package/dest/client/p2p_client.d.ts +52 -58
  11. package/dest/client/p2p_client.d.ts.map +1 -1
  12. package/dest/client/p2p_client.js +236 -236
  13. package/dest/config.d.ts +163 -84
  14. package/dest/config.d.ts.map +1 -1
  15. package/dest/config.js +156 -43
  16. package/dest/errors/p2p-service.error.d.ts +9 -0
  17. package/dest/errors/p2p-service.error.d.ts.map +1 -0
  18. package/dest/errors/p2p-service.error.js +10 -0
  19. package/dest/errors/reqresp.error.d.ts +1 -20
  20. package/dest/errors/reqresp.error.d.ts.map +1 -1
  21. package/dest/errors/reqresp.error.js +0 -21
  22. package/dest/errors/tx-pool.error.d.ts +8 -0
  23. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  24. package/dest/errors/tx-pool.error.js +9 -0
  25. package/dest/index.d.ts +2 -2
  26. package/dest/index.d.ts.map +1 -1
  27. package/dest/index.js +1 -1
  28. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +162 -106
  29. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/attestation_pool.js +511 -3
  31. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  32. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  33. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +525 -132
  34. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  35. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  36. package/dest/mem_pools/attestation_pool/index.js +1 -2
  37. package/dest/mem_pools/attestation_pool/mocks.d.ts +4 -2
  38. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  39. package/dest/mem_pools/attestation_pool/mocks.js +13 -8
  40. package/dest/mem_pools/index.d.ts +3 -3
  41. package/dest/mem_pools/index.d.ts.map +1 -1
  42. package/dest/mem_pools/index.js +1 -1
  43. package/dest/mem_pools/instrumentation.d.ts +4 -2
  44. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  45. package/dest/mem_pools/instrumentation.js +35 -17
  46. package/dest/mem_pools/interface.d.ts +5 -5
  47. package/dest/mem_pools/interface.d.ts.map +1 -1
  48. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  49. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  50. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  51. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  52. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  53. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  54. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  55. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  56. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  58. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  59. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
  60. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  61. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +94 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +11 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/index.js +12 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +180 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  76. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  77. package/dest/mem_pools/{tx_pool → tx_pool_v2}/eviction/invalid_txs_after_mining_rule.js +16 -35
  78. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  79. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  80. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  81. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  82. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  83. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
  84. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  85. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  86. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +75 -0
  87. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  88. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  89. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  90. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  91. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  92. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  93. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  94. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  95. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  96. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +218 -0
  97. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  98. package/dest/mem_pools/tx_pool_v2/interfaces.js +10 -0
  99. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +137 -0
  100. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  101. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +223 -0
  102. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  103. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  104. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  105. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
  106. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  107. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +337 -0
  108. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +62 -0
  109. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  110. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +167 -0
  111. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +78 -0
  112. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  113. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +914 -0
  114. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +10 -4
  115. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  116. package/dest/msg_validators/attestation_validator/attestation_validator.js +69 -13
  117. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +9 -5
  118. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  119. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +22 -11
  120. package/dest/msg_validators/clock_tolerance.d.ts +32 -0
  121. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  122. package/dest/msg_validators/clock_tolerance.js +95 -0
  123. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +10 -4
  124. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  125. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
  126. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +10 -4
  127. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  128. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
  129. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +21 -8
  130. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  131. package/dest/msg_validators/proposal_validator/proposal_validator.js +123 -53
  132. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
  133. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  134. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +11 -18
  135. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  136. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  137. package/dest/msg_validators/tx_validator/allowed_public_setup.js +25 -21
  138. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  139. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  140. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  141. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  142. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  143. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
  144. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  145. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  146. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
  147. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
  148. package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
  149. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  150. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  151. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  152. package/dest/msg_validators/tx_validator/data_validator.d.ts +4 -1
  153. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  154. package/dest/msg_validators/tx_validator/data_validator.js +40 -3
  155. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
  156. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  157. package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
  158. package/dest/msg_validators/tx_validator/factory.d.ts +138 -5
  159. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  160. package/dest/msg_validators/tx_validator/factory.js +259 -58
  161. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
  162. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
  163. package/dest/msg_validators/tx_validator/fee_payer_balance.js +24 -0
  164. package/dest/msg_validators/tx_validator/gas_validator.d.ts +100 -3
  165. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  166. package/dest/msg_validators/tx_validator/gas_validator.js +146 -67
  167. package/dest/msg_validators/tx_validator/index.d.ts +6 -1
  168. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  169. package/dest/msg_validators/tx_validator/index.js +5 -0
  170. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
  171. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  172. package/dest/msg_validators/tx_validator/metadata_validator.js +6 -6
  173. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  174. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  175. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  176. package/dest/msg_validators/tx_validator/phases_validator.d.ts +24 -3
  177. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  178. package/dest/msg_validators/tx_validator/phases_validator.js +75 -27
  179. package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
  180. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
  181. package/dest/msg_validators/tx_validator/size_validator.js +23 -0
  182. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +22 -5
  183. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  184. package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
  185. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  186. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  187. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  188. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +4 -2
  189. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  190. package/dest/msg_validators/tx_validator/tx_proof_validator.js +4 -2
  191. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
  192. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
  193. package/dest/msg_validators/tx_validator/tx_validation_cache.js +69 -0
  194. package/dest/services/data_store.d.ts +1 -1
  195. package/dest/services/data_store.d.ts.map +1 -1
  196. package/dest/services/data_store.js +14 -10
  197. package/dest/services/discv5/discV5_service.d.ts +2 -1
  198. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  199. package/dest/services/discv5/discV5_service.js +36 -9
  200. package/dest/services/dummy_service.d.ts +33 -17
  201. package/dest/services/dummy_service.d.ts.map +1 -1
  202. package/dest/services/dummy_service.js +56 -15
  203. package/dest/services/encoding.d.ts +7 -3
  204. package/dest/services/encoding.d.ts.map +1 -1
  205. package/dest/services/encoding.js +20 -14
  206. package/dest/services/gossipsub/index.d.ts +3 -0
  207. package/dest/services/gossipsub/index.d.ts.map +1 -0
  208. package/dest/services/gossipsub/index.js +2 -0
  209. package/dest/services/gossipsub/scoring.d.ts +21 -3
  210. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  211. package/dest/services/gossipsub/scoring.js +24 -7
  212. package/dest/services/gossipsub/topic_score_params.d.ts +184 -0
  213. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  214. package/dest/services/gossipsub/topic_score_params.js +363 -0
  215. package/dest/services/index.d.ts +2 -1
  216. package/dest/services/index.d.ts.map +1 -1
  217. package/dest/services/index.js +1 -0
  218. package/dest/services/libp2p/instrumentation.d.ts +3 -1
  219. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  220. package/dest/services/libp2p/instrumentation.js +33 -8
  221. package/dest/services/libp2p/libp2p_service.d.ts +107 -59
  222. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  223. package/dest/services/libp2p/libp2p_service.js +683 -539
  224. package/dest/services/peer-manager/metrics.d.ts +4 -2
  225. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  226. package/dest/services/peer-manager/metrics.js +26 -5
  227. package/dest/services/peer-manager/peer_manager.d.ts +6 -2
  228. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  229. package/dest/services/peer-manager/peer_manager.js +40 -11
  230. package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
  231. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  232. package/dest/services/peer-manager/peer_scoring.js +65 -14
  233. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +51 -0
  234. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  235. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +552 -0
  236. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  237. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  238. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  239. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
  240. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  241. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  242. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +35 -0
  243. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  244. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +136 -0
  245. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +62 -0
  246. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  247. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +176 -0
  248. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +11 -0
  249. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  250. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +7 -0
  251. package/dest/services/reqresp/config.d.ts +3 -3
  252. package/dest/services/reqresp/config.d.ts.map +1 -1
  253. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
  254. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  255. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  256. package/dest/services/reqresp/constants.d.ts +12 -0
  257. package/dest/services/reqresp/constants.d.ts.map +1 -0
  258. package/dest/services/reqresp/constants.js +7 -0
  259. package/dest/services/reqresp/interface.d.ts +27 -18
  260. package/dest/services/reqresp/interface.d.ts.map +1 -1
  261. package/dest/services/reqresp/interface.js +23 -19
  262. package/dest/services/reqresp/metrics.d.ts +6 -5
  263. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  264. package/dest/services/reqresp/metrics.js +16 -5
  265. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
  266. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  267. package/dest/services/reqresp/protocols/block_txs/bitvector.js +12 -0
  268. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  269. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  270. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +29 -9
  271. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
  272. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  273. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +59 -13
  274. package/dest/services/reqresp/protocols/index.d.ts +1 -2
  275. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  276. package/dest/services/reqresp/protocols/index.js +0 -1
  277. package/dest/services/reqresp/protocols/status.d.ts +1 -1
  278. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  279. package/dest/services/reqresp/protocols/status.js +2 -1
  280. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  281. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  282. package/dest/services/reqresp/protocols/tx.js +21 -3
  283. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
  284. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  285. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
  286. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  287. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  288. package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
  289. package/dest/services/reqresp/reqresp.d.ts +12 -29
  290. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  291. package/dest/services/reqresp/reqresp.js +58 -187
  292. package/dest/services/service.d.ts +49 -13
  293. package/dest/services/service.d.ts.map +1 -1
  294. package/dest/services/tx_collection/config.d.ts +11 -11
  295. package/dest/services/tx_collection/config.d.ts.map +1 -1
  296. package/dest/services/tx_collection/config.js +27 -26
  297. package/dest/services/tx_collection/file_store_tx_collection.d.ts +37 -0
  298. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  299. package/dest/services/tx_collection/file_store_tx_collection.js +127 -0
  300. package/dest/services/tx_collection/file_store_tx_source.d.ts +38 -0
  301. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  302. package/dest/services/tx_collection/file_store_tx_source.js +100 -0
  303. package/dest/services/tx_collection/index.d.ts +3 -2
  304. package/dest/services/tx_collection/index.d.ts.map +1 -1
  305. package/dest/services/tx_collection/index.js +1 -0
  306. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  307. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  308. package/dest/services/tx_collection/instrumentation.js +8 -2
  309. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  310. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  311. package/dest/services/tx_collection/request_tracker.js +84 -0
  312. package/dest/services/tx_collection/tx_collection.d.ts +50 -56
  313. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  314. package/dest/services/tx_collection/tx_collection.js +298 -70
  315. package/dest/services/tx_collection/tx_collection_sink.d.ts +19 -9
  316. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  317. package/dest/services/tx_collection/tx_collection_sink.js +28 -31
  318. package/dest/services/tx_collection/tx_source.d.ts +13 -7
  319. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  320. package/dest/services/tx_collection/tx_source.js +26 -7
  321. package/dest/services/tx_file_store/config.d.ts +16 -0
  322. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  323. package/dest/services/tx_file_store/config.js +22 -0
  324. package/dest/services/tx_file_store/index.d.ts +4 -0
  325. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  326. package/dest/services/tx_file_store/index.js +3 -0
  327. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  328. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  329. package/dest/services/tx_file_store/instrumentation.js +29 -0
  330. package/dest/services/tx_file_store/tx_file_store.d.ts +46 -0
  331. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  332. package/dest/services/tx_file_store/tx_file_store.js +142 -0
  333. package/dest/services/tx_provider.d.ts +8 -6
  334. package/dest/services/tx_provider.d.ts.map +1 -1
  335. package/dest/services/tx_provider.js +12 -8
  336. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  337. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  338. package/dest/services/tx_provider_instrumentation.js +5 -5
  339. package/dest/test-helpers/index.d.ts +3 -1
  340. package/dest/test-helpers/index.d.ts.map +1 -1
  341. package/dest/test-helpers/index.js +2 -0
  342. package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
  343. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  344. package/dest/test-helpers/make-test-p2p-clients.js +5 -3
  345. package/dest/test-helpers/mock-pubsub.d.ts +46 -6
  346. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  347. package/dest/test-helpers/mock-pubsub.js +115 -14
  348. package/dest/test-helpers/reqresp-nodes.d.ts +5 -7
  349. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  350. package/dest/test-helpers/reqresp-nodes.js +19 -20
  351. package/dest/test-helpers/test_tx_provider.d.ts +42 -0
  352. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  353. package/dest/test-helpers/test_tx_provider.js +44 -0
  354. package/dest/test-helpers/testbench-utils.d.ts +161 -0
  355. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  356. package/dest/test-helpers/testbench-utils.js +393 -0
  357. package/dest/testbench/p2p_client_testbench_worker.d.ts +26 -2
  358. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  359. package/dest/testbench/p2p_client_testbench_worker.js +270 -144
  360. package/dest/testbench/worker_client_manager.d.ts +57 -6
  361. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  362. package/dest/testbench/worker_client_manager.js +277 -49
  363. package/dest/util.d.ts +13 -8
  364. package/dest/util.d.ts.map +1 -1
  365. package/dest/util.js +35 -14
  366. package/dest/versioning.d.ts +3 -6
  367. package/dest/versioning.d.ts.map +1 -1
  368. package/dest/versioning.js +3 -24
  369. package/package.json +17 -16
  370. package/src/bootstrap/bootstrap.ts +16 -5
  371. package/src/client/factory.ts +135 -39
  372. package/src/client/interface.ts +70 -44
  373. package/src/client/p2p_client.ts +283 -302
  374. package/src/client/test/p2p_client.batch_tx_requester.bench.README.md +197 -0
  375. package/src/config.ts +274 -48
  376. package/src/errors/p2p-service.error.ts +11 -0
  377. package/src/errors/reqresp.error.ts +0 -25
  378. package/src/errors/tx-pool.error.ts +12 -0
  379. package/src/index.ts +1 -1
  380. package/src/mem_pools/attestation_pool/attestation_pool.ts +575 -94
  381. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +633 -149
  382. package/src/mem_pools/attestation_pool/index.ts +9 -2
  383. package/src/mem_pools/attestation_pool/mocks.ts +19 -11
  384. package/src/mem_pools/index.ts +2 -2
  385. package/src/mem_pools/instrumentation.ts +24 -15
  386. package/src/mem_pools/interface.ts +4 -4
  387. package/src/mem_pools/tx_pool_v2/README.md +283 -0
  388. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  389. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  390. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  391. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  392. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +122 -0
  393. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
  394. package/src/mem_pools/tx_pool_v2/eviction/index.ts +28 -0
  395. package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
  396. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +219 -0
  397. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  398. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  399. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
  400. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +99 -0
  401. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +32 -0
  402. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  403. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  404. package/src/mem_pools/tx_pool_v2/interfaces.ts +250 -0
  405. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +349 -0
  406. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  407. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +430 -0
  408. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +238 -0
  409. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1090 -0
  410. package/src/msg_validators/attestation_validator/README.md +49 -0
  411. package/src/msg_validators/attestation_validator/attestation_validator.ts +60 -16
  412. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +29 -16
  413. package/src/msg_validators/clock_tolerance.ts +127 -0
  414. package/src/msg_validators/proposal_validator/README.md +123 -0
  415. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +24 -4
  416. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +35 -7
  417. package/src/msg_validators/proposal_validator/proposal_validator.ts +129 -62
  418. package/src/msg_validators/tx_validator/README.md +127 -0
  419. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +8 -17
  420. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  421. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  422. package/src/msg_validators/tx_validator/archive_cache.ts +2 -2
  423. package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
  424. package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
  425. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  426. package/src/msg_validators/tx_validator/data_validator.ts +50 -3
  427. package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
  428. package/src/msg_validators/tx_validator/factory.ts +424 -56
  429. package/src/msg_validators/tx_validator/fee_payer_balance.ts +44 -0
  430. package/src/msg_validators/tx_validator/gas_validator.ts +211 -77
  431. package/src/msg_validators/tx_validator/index.ts +5 -0
  432. package/src/msg_validators/tx_validator/metadata_validator.ts +18 -7
  433. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  434. package/src/msg_validators/tx_validator/phases_validator.ts +87 -30
  435. package/src/msg_validators/tx_validator/size_validator.ts +22 -0
  436. package/src/msg_validators/tx_validator/timestamp_validator.ts +29 -21
  437. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  438. package/src/msg_validators/tx_validator/tx_proof_validator.ts +10 -3
  439. package/src/msg_validators/tx_validator/tx_validation_cache.ts +102 -0
  440. package/src/services/data_store.ts +14 -19
  441. package/src/services/discv5/discV5_service.ts +39 -6
  442. package/src/services/dummy_service.ts +71 -39
  443. package/src/services/encoding.ts +20 -13
  444. package/src/services/gossipsub/README.md +641 -0
  445. package/src/services/gossipsub/index.ts +2 -0
  446. package/src/services/gossipsub/scoring.ts +29 -5
  447. package/src/services/gossipsub/topic_score_params.ts +519 -0
  448. package/src/services/index.ts +1 -0
  449. package/src/services/libp2p/instrumentation.ts +34 -7
  450. package/src/services/libp2p/libp2p_service.ts +753 -597
  451. package/src/services/peer-manager/metrics.ts +28 -4
  452. package/src/services/peer-manager/peer_manager.ts +46 -11
  453. package/src/services/peer-manager/peer_scoring.ts +56 -6
  454. package/src/services/reqresp/README.md +215 -0
  455. package/src/services/reqresp/batch-tx-requester/README.md +344 -0
  456. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +684 -0
  457. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  458. package/src/services/reqresp/batch-tx-requester/interface.ts +61 -0
  459. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +168 -0
  460. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +249 -0
  461. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +24 -0
  462. package/src/services/reqresp/config.ts +2 -2
  463. package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
  464. package/src/services/reqresp/constants.ts +14 -0
  465. package/src/services/reqresp/interface.ts +48 -46
  466. package/src/services/reqresp/metrics.ts +33 -9
  467. package/src/services/reqresp/protocols/block_txs/bitvector.ts +16 -0
  468. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +37 -12
  469. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
  470. package/src/services/reqresp/protocols/index.ts +0 -1
  471. package/src/services/reqresp/protocols/status.ts +5 -3
  472. package/src/services/reqresp/protocols/tx.ts +23 -3
  473. package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
  474. package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
  475. package/src/services/reqresp/reqresp.ts +68 -224
  476. package/src/services/service.ts +66 -29
  477. package/src/services/tx_collection/config.ts +41 -36
  478. package/src/services/tx_collection/file_store_tx_collection.ts +153 -0
  479. package/src/services/tx_collection/file_store_tx_source.ts +129 -0
  480. package/src/services/tx_collection/index.ts +2 -1
  481. package/src/services/tx_collection/instrumentation.ts +11 -2
  482. package/src/services/tx_collection/request_tracker.ts +127 -0
  483. package/src/services/tx_collection/tx_collection.ts +367 -115
  484. package/src/services/tx_collection/tx_collection_sink.ts +32 -36
  485. package/src/services/tx_collection/tx_source.ts +28 -8
  486. package/src/services/tx_file_store/config.ts +37 -0
  487. package/src/services/tx_file_store/index.ts +3 -0
  488. package/src/services/tx_file_store/instrumentation.ts +36 -0
  489. package/src/services/tx_file_store/tx_file_store.ts +163 -0
  490. package/src/services/tx_provider.ts +17 -11
  491. package/src/services/tx_provider_instrumentation.ts +11 -5
  492. package/src/test-helpers/index.ts +2 -0
  493. package/src/test-helpers/make-test-p2p-clients.ts +7 -6
  494. package/src/test-helpers/mock-pubsub.ts +137 -14
  495. package/src/test-helpers/reqresp-nodes.ts +17 -29
  496. package/src/test-helpers/test_tx_provider.ts +69 -0
  497. package/src/test-helpers/testbench-utils.ts +455 -0
  498. package/src/testbench/p2p_client_testbench_worker.ts +370 -138
  499. package/src/testbench/worker_client_manager.ts +355 -51
  500. package/src/util.ts +40 -19
  501. package/src/versioning.ts +3 -33
  502. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  503. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  504. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  505. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  506. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  507. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  508. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -120
  509. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
  510. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -555
  511. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -18
  512. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
  513. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -56
  514. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -83
  515. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
  516. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -5
  517. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +0 -15
  518. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +0 -1
  519. package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +0 -88
  520. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
  521. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
  522. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
  523. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
  524. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -76
  525. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
  526. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
  527. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
  528. package/dest/mem_pools/tx_pool/index.d.ts +0 -3
  529. package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
  530. package/dest/mem_pools/tx_pool/index.js +0 -2
  531. package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
  532. package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
  533. package/dest/mem_pools/tx_pool/priority.js +0 -15
  534. package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
  535. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
  536. package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
  537. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
  538. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
  539. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
  540. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
  541. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
  542. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -183
  543. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -45
  544. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
  545. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -92
  546. package/dest/services/reqresp/protocols/block.d.ts +0 -9
  547. package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
  548. package/dest/services/reqresp/protocols/block.js +0 -32
  549. package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
  550. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
  551. package/dest/services/tx_collection/fast_tx_collection.js +0 -300
  552. package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -53
  553. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
  554. package/dest/services/tx_collection/slow_tx_collection.js +0 -177
  555. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  556. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
  557. package/src/mem_pools/tx_pool/README.md +0 -255
  558. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -691
  559. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -71
  560. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -93
  561. package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +0 -108
  562. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
  563. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -91
  564. package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
  565. package/src/mem_pools/tx_pool/index.ts +0 -2
  566. package/src/mem_pools/tx_pool/priority.ts +0 -20
  567. package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
  568. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
  569. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -206
  570. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -100
  571. package/src/services/reqresp/protocols/block.ts +0 -37
  572. package/src/services/tx_collection/fast_tx_collection.ts +0 -341
  573. package/src/services/tx_collection/slow_tx_collection.ts +0 -233
@@ -1,115 +1,123 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { compactArray } from '@aztec/foundation/collection';
2
+ import { times } from '@aztec/foundation/collection';
3
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
- import { type PromiseWithResolvers, RunningPromise } from '@aztec/foundation/promise';
5
- import { DateProvider } from '@aztec/foundation/timer';
6
- import type { L2BlockInfo, L2BlockNew } from '@aztec/stdlib/block';
4
+ import { sleep } from '@aztec/foundation/sleep';
5
+ import { DateProvider, elapsed } from '@aztec/foundation/timer';
6
+ import type { L2Block, L2BlockInfo } from '@aztec/stdlib/block';
7
7
  import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
8
8
  import type { BlockProposal } from '@aztec/stdlib/p2p';
9
- import { Tx, TxHash } from '@aztec/stdlib/tx';
9
+ import type { Tx } from '@aztec/stdlib/tx';
10
+ import { TxHash } from '@aztec/stdlib/tx';
10
11
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
11
12
 
12
13
  import type { PeerId } from '@libp2p/interface';
13
14
 
14
- import type { TxPool } from '../../mem_pools/index.js';
15
- import type { TxPoolEvents } from '../../mem_pools/tx_pool/tx_pool.js';
16
- import type { ReqRespInterface } from '../reqresp/interface.js';
15
+ import type { TxPoolV2, TxPoolV2Events } from '../../mem_pools/tx_pool_v2/interfaces.js';
16
+ import { BatchTxRequester } from '../reqresp/batch-tx-requester/batch_tx_requester.js';
17
+ import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
18
+ import type { BlockTxsSource } from '../reqresp/index.js';
17
19
  import type { TxCollectionConfig } from './config.js';
18
- import { FastTxCollection } from './fast_tx_collection.js';
19
- import { SlowTxCollection } from './slow_tx_collection.js';
20
- import { TxCollectionSink } from './tx_collection_sink.js';
20
+ import { FileStoreTxCollection } from './file_store_tx_collection.js';
21
+ import type { FileStoreTxSource } from './file_store_tx_source.js';
22
+ import { type IRequestTracker, RequestTracker } from './request_tracker.js';
23
+ import { type TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
21
24
  import type { TxSource } from './tx_source.js';
22
25
 
23
- export type CollectionMethod = 'fast-req-resp' | 'fast-node-rpc' | 'slow-req-resp' | 'slow-node-rpc';
24
-
25
- export type MissingTxInfo = { blockNumber: BlockNumber; deadline: Date; readyForReqResp: boolean };
26
+ export type CollectionMethod = 'fast-req-resp' | 'fast-node-rpc' | 'file-store';
26
27
 
27
28
  export type FastCollectionRequestInput =
28
- | { type: 'block'; block: L2BlockNew }
29
+ | { type: 'block'; block: L2Block }
29
30
  | { type: 'proposal'; blockProposal: BlockProposal; blockNumber: BlockNumber };
30
31
 
31
32
  export type FastCollectionRequest = FastCollectionRequestInput & {
32
- missingTxHashes: Set<string>;
33
- deadline: Date;
33
+ requestTracker: IRequestTracker;
34
34
  blockInfo: L2BlockInfo;
35
- promise: PromiseWithResolvers<void>;
36
- foundTxs: Map<string, Tx>;
37
35
  };
38
36
 
39
37
  /**
40
- * Coordinates tx collection from remote RPC nodes and reqresp.
38
+ * Collect missing transactions for a block or proposal via reqresp.
39
+ * @param requestTracker - The missing transactions tracker
40
+ * @param blockTxsSource - The block or proposal containing the transactions
41
+ * @param pinnedPeer - Optional peer expected to have the transactions
42
+ * @returns The collected transactions
43
+ */
44
+ export type IReqRespTxsCollector = (
45
+ requestTracker: IRequestTracker,
46
+ blockTxsSource: BlockTxsSource,
47
+ pinnedPeer: PeerId | undefined,
48
+ ) => Promise<Tx[]>;
49
+
50
+ /**
51
+ * Coordinates tx collection from remote RPC nodes, reqresp, and file store.
41
52
  *
42
- * The slow collection loops are used for periodically collecting missing txs from mined blocks,
43
- * from remote RPC nodes and via reqresp. The fast collection methods are used to quickly gather
44
- * txs, usually for attesting to block proposals or preparing to prove an epoch. The slow and fast
45
- * collection instances both send their txs to the collection sink, which handles metrics and adds
46
- * them to the tx pool. Whenever a tx is added to either the sink or the pool, this service is notified
47
- * via events and notifies the slow and fast collection loops to stop collecting that tx, so that we don't
48
- * collect the same tx multiple times.
53
+ * Runs a sequential pipeline: node RPC reqresp file store. Node collection starts immediately,
54
+ * reqresp starts after a configured delay, and file store (if configured) starts after a further
55
+ * delay. All paths send txs to the collection sink, which handles metrics and adds them to the
56
+ * tx pool. Whenever a tx is added to the sink or the pool, this service is notified and stops
57
+ * collecting that tx across all in-flight requests.
49
58
  */
50
59
  export class TxCollection {
51
- /** Slow collection background loops */
52
- protected readonly slowCollection: SlowTxCollection;
60
+ // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
61
+ protected requests: Set<FastCollectionRequest> = new Set();
53
62
 
54
- /** Fast collection methods */
55
- protected readonly fastCollection: FastTxCollection;
63
+ /** The collector for txs via reqresp */
64
+ protected reqRespTxsCollector?: IReqRespTxsCollector;
56
65
 
57
- /** Loop for periodically reconciling found transactions from the tx pool in case we missed some */
58
- private readonly reconcileFoundTxsLoop: RunningPromise;
66
+ /** File store collection for the fast (proposal/proving) path */
67
+ protected readonly fileStoreFastCollection: FileStoreTxCollection;
59
68
 
60
- /** Handles txs found by the slow and fast collection loops */
69
+ /** Handles txs found by collection paths before adding to the pool */
61
70
  private readonly txCollectionSink: TxCollectionSink;
62
71
 
63
72
  /** Handler for the txs-added event from the tx pool */
64
- protected readonly handleTxsAddedToPool: TxPoolEvents['txs-added'];
73
+ protected readonly handleTxsAddedToPool: TxPoolV2Events['txs-added'];
65
74
 
66
75
  /** Handler for the txs-added event from the tx collection sink */
67
- protected readonly handleTxsFound: TxPoolEvents['txs-added'];
76
+ protected readonly handleTxsFound: TxPoolV2Events['txs-added'];
68
77
 
69
78
  constructor(
70
- private readonly reqResp: Pick<ReqRespInterface, 'sendBatchRequest'>,
79
+ private readonly p2pService: BatchTxRequesterLibP2PService,
71
80
  private readonly nodes: TxSource[],
72
81
  private readonly constants: L1RollupConstants,
73
- private readonly txPool: TxPool,
82
+ private readonly txPool: TxPoolV2,
74
83
  private readonly config: TxCollectionConfig,
84
+ fileStoreSources: FileStoreTxSource[] = [],
75
85
  private readonly dateProvider: DateProvider = new DateProvider(),
76
86
  telemetryClient: TelemetryClient = getTelemetryClient(),
77
87
  private readonly log: Logger = createLogger('p2p:tx_collection_service'),
78
88
  ) {
79
89
  this.txCollectionSink = new TxCollectionSink(this.txPool, telemetryClient, this.log);
80
90
 
81
- this.fastCollection = new FastTxCollection(
82
- this.reqResp,
83
- this.nodes,
84
- this.txCollectionSink,
85
- this.config,
86
- this.dateProvider,
87
- this.log,
88
- );
89
-
90
- this.slowCollection = new SlowTxCollection(
91
- this.reqResp,
92
- this.nodes,
91
+ this.reqRespTxsCollector = (requestTracker, blockTxsSource, pinnedPeer) =>
92
+ BatchTxRequester.collectAllTxs(
93
+ new BatchTxRequester(
94
+ requestTracker,
95
+ blockTxsSource,
96
+ pinnedPeer,
97
+ this.p2pService,
98
+ this.log,
99
+ this.dateProvider,
100
+ ).run(),
101
+ );
102
+
103
+ this.fileStoreFastCollection = new FileStoreTxCollection(
104
+ fileStoreSources,
93
105
  this.txCollectionSink,
94
- this.fastCollection,
95
- constants,
96
- this.config,
106
+ {
107
+ workerCount: config.txCollectionFileStoreFastWorkerCount,
108
+ backoffBaseMs: config.txCollectionFileStoreFastBackoffBaseMs,
109
+ backoffMaxMs: config.txCollectionFileStoreFastBackoffMaxMs,
110
+ },
97
111
  this.dateProvider,
98
112
  this.log,
99
113
  );
100
114
 
101
- this.reconcileFoundTxsLoop = new RunningPromise(
102
- () => this.reconcileFoundTxsWithPool(),
103
- this.log,
104
- this.config.txCollectionReconcileIntervalMs,
105
- );
106
-
107
- this.handleTxsFound = (args: Parameters<TxPoolEvents['txs-added']>[0]) => {
115
+ this.handleTxsFound = (args: Parameters<TxPoolV2Events['txs-added']>[0]) => {
108
116
  this.foundTxs(args.txs);
109
117
  };
110
118
  this.txCollectionSink.on('txs-added', this.handleTxsFound);
111
119
 
112
- this.handleTxsAddedToPool = (args: Parameters<TxPoolEvents['txs-added']>[0]) => {
120
+ this.handleTxsAddedToPool = (args: Parameters<TxPoolV2Events['txs-added']>[0]) => {
113
121
  const { txs, source } = args;
114
122
  if (source !== 'tx-collection') {
115
123
  this.foundTxs(txs);
@@ -118,51 +126,24 @@ export class TxCollection {
118
126
  this.txPool.on('txs-added', this.handleTxsAddedToPool);
119
127
  }
120
128
 
121
- /** Starts all collection loops. */
122
- public start(): Promise<void> {
123
- this.slowCollection.start();
124
- this.reconcileFoundTxsLoop.start();
125
-
126
- // TODO(palla/txs): Collect mined unproven tx hashes for txs we dont have in the pool and populate missingTxs on startup
127
- return Promise.resolve();
128
- }
129
-
130
- /** Stops all activity. */
131
- public async stop() {
132
- await Promise.all([this.slowCollection.stop(), this.fastCollection.stop(), this.reconcileFoundTxsLoop.stop()]);
129
+ /** Stops all activity. Cancels in-flight requests; file store workers self-terminate. */
130
+ public stop() {
131
+ this.requests.forEach(request => {
132
+ request.requestTracker.cancel();
133
+ });
133
134
 
134
135
  this.txPool.removeListener('txs-added', this.handleTxsAddedToPool);
135
136
  this.txCollectionSink.removeListener('txs-added', this.handleTxsFound);
136
137
  }
137
138
 
138
- /** Force trigger the slow collection and reconciliation loops */
139
- public async trigger() {
140
- await Promise.all([this.reconcileFoundTxsLoop.trigger(), this.slowCollection.trigger()]);
141
- }
142
-
143
139
  /** Returns L1 rollup constants. */
144
140
  public getConstants(): L1RollupConstants {
145
141
  return this.constants;
146
142
  }
147
143
 
148
- /** Starts collecting the given tx hashes for the given L2Block in the slow loop */
149
- public startCollecting(block: L2BlockNew, txHashes: TxHash[]) {
150
- return this.slowCollection.startCollecting(block, txHashes);
151
- }
152
-
153
- /** Collects the set of txs for the given block proposal as fast as possible */
154
- public collectFastForProposal(
155
- blockProposal: BlockProposal,
156
- blockNumber: BlockNumber,
157
- txHashes: TxHash[] | string[],
158
- opts: { deadline: Date; pinnedPeer?: PeerId },
159
- ) {
160
- return this.collectFastFor({ type: 'proposal', blockProposal, blockNumber }, txHashes, opts);
161
- }
162
-
163
144
  /** Collects the set of txs for the given mined block as fast as possible */
164
145
  public collectFastForBlock(
165
- block: L2BlockNew,
146
+ block: L2Block,
166
147
  txHashes: TxHash[] | string[],
167
148
  opts: { deadline: Date; pinnedPeer?: PeerId },
168
149
  ) {
@@ -170,27 +151,307 @@ export class TxCollection {
170
151
  }
171
152
 
172
153
  /** Collects the set of txs for the given proposal or block as fast as possible */
173
- public collectFastFor(
154
+ public async collectFastFor(
174
155
  input: FastCollectionRequestInput,
175
156
  txHashes: TxHash[] | string[],
176
157
  opts: { deadline: Date; pinnedPeer?: PeerId },
177
158
  ) {
178
- return this.fastCollection.collectFastFor(input, txHashes, opts);
159
+ const timeout = opts.deadline.getTime() - this.dateProvider.now();
160
+ if (timeout <= 0) {
161
+ this.log.warn(`Deadline for fast tx collection is in the past (${timeout}ms)`, {
162
+ deadline: opts.deadline.getTime(),
163
+ now: this.dateProvider.now(),
164
+ });
165
+ return [];
166
+ }
167
+
168
+ const hashes = txHashes.map(h => (typeof h === 'string' ? TxHash.fromString(h) : h));
169
+
170
+ const blockInfo: L2BlockInfo =
171
+ input.type === 'proposal'
172
+ ? { ...input.blockProposal.toBlockInfo(), blockNumber: input.blockNumber }
173
+ : { ...input.block.toBlockInfo() };
174
+
175
+ const request: FastCollectionRequest = {
176
+ ...input,
177
+ blockInfo,
178
+ requestTracker: RequestTracker.create(hashes, opts.deadline, this.dateProvider),
179
+ };
180
+
181
+ const [duration] = await elapsed(() => this.collectFast(request, { pinnedPeer: opts.pinnedPeer }));
182
+
183
+ this.log.verbose(
184
+ `Collected ${request.requestTracker.collectedTxs.length} txs out of ${hashes.length} for ${input.type} at slot ${blockInfo.slotNumber}`,
185
+ {
186
+ ...blockInfo,
187
+ duration,
188
+ requestType: input.type,
189
+ missingTxs: [...request.requestTracker.missingTxHashes],
190
+ },
191
+ );
192
+ return request.requestTracker.collectedTxs;
179
193
  }
180
194
 
181
- /** Mark the given txs as found. Stops collecting them. */
195
+ protected async collectFast(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
196
+ this.requests.add(request);
197
+ const { blockInfo } = request;
198
+
199
+ this.log.debug(
200
+ `Starting fast collection of ${request.requestTracker.numberOfMissingTxs} txs for ${request.type} at slot ${blockInfo.slotNumber}`,
201
+ { ...blockInfo, requestType: request.type, deadline: request.requestTracker.deadline },
202
+ );
203
+
204
+ try {
205
+ // 1. Start node collection in the background.
206
+ // Note: this will be a noop if no nodes are configured.
207
+ const nodeCollectionPromise = this.collectFastFromNodes(request);
208
+
209
+ // 2. Wait before starting reqresp, interruptible by cancellation or node exhaustion.
210
+ await Promise.race([
211
+ request.requestTracker.cancellationToken,
212
+ sleep(this.config.txCollectionFastNodesTimeoutBeforeReqRespMs),
213
+ nodeCollectionPromise, // If node collection has finished (or if there are no nodes configured), we can exit early.
214
+ ]);
215
+
216
+ // 3. Start reqresp in the background (runs in parallel with node collection).
217
+ // Note: this will be a noop if all TXs were already found.
218
+ const reqRespPromise = this.collectFastViaReqResp(request, opts);
219
+
220
+ // 4. Wait before starting file store, interruptible by cancellation.
221
+ await Promise.race([
222
+ request.requestTracker.cancellationToken,
223
+ sleep(this.config.txCollectionFileStoreFastDelayMs),
224
+ reqRespPromise, // If reqresp has finished, we can exit early.
225
+ ]);
226
+
227
+ // 5. Start file store collection in the background. Self-terminates on tracker cancel / all-found.
228
+ // Note: this will be a noop if all TXs were already found.
229
+ const fileStorePromise = this.fileStoreFastCollection.startCollecting(
230
+ request.requestTracker,
231
+ this.getAddContext(request),
232
+ );
233
+
234
+ // 6. Wait for all paths to settle.
235
+ // NOTE: The request will automatically be cancelled after `opt.deadline` is reached.
236
+ await Promise.allSettled([reqRespPromise, nodeCollectionPromise, fileStorePromise]);
237
+ } catch (err) {
238
+ this.log.error(`Error collecting txs for ${request.type} for slot ${blockInfo.slotNumber}`, err, {
239
+ ...blockInfo,
240
+ missingTxs: request.requestTracker.missingTxHashes.values().map(txHash => txHash.toString()),
241
+ });
242
+ } finally {
243
+ request.requestTracker.cancel();
244
+ this.requests.delete(request);
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Starts collecting txs from all configured nodes. We send `txCollectionFastMaxParallelRequestsPerNode` requests
250
+ * in parallel to each node. We keep track of the number of attempts made to collect each tx, so we can prioritize
251
+ * the txs that have been requested less often whenever we need to send a new batch of requests. We ensure that no
252
+ * tx is requested more than once at the same time to the same node.
253
+ */
254
+ private async collectFastFromNodes(request: FastCollectionRequest): Promise<void> {
255
+ if (this.nodes.length === 0) {
256
+ return;
257
+ }
258
+
259
+ // Keep a shared priority queue of all txs pending to be requested, sorted by the number of attempts made to collect them.
260
+ const attemptsPerTx = [...request.requestTracker.missingTxHashes].map(txHash => ({
261
+ txHash,
262
+ attempts: 0,
263
+ found: false,
264
+ }));
265
+
266
+ // Returns once we have finished all node loops. Each loop finishes when the deadline is hit, or all txs have been collected.
267
+ await Promise.allSettled(this.nodes.map(node => this.collectFastFromNode(request, node, attemptsPerTx)));
268
+ }
269
+
270
+ private async collectFastFromNode(
271
+ request: FastCollectionRequest,
272
+ node: TxSource,
273
+ attemptsPerTx: { txHash: string; attempts: number; found: boolean }[],
274
+ ) {
275
+ const notFinished = () => !request.requestTracker.checkCancelled();
276
+
277
+ const maxParallelRequests = this.config.txCollectionFastMaxParallelRequestsPerNode;
278
+ const maxBatchSize = this.config.txCollectionNodeRpcMaxBatchSize;
279
+ const activeRequestsToThisNode = new Set<string>(); // Track the txs being actively requested to this node
280
+
281
+ const processBatch = async () => {
282
+ while (notFinished()) {
283
+ // Pull tx hashes from the attemptsPerTx array, which is sorted by attempts,
284
+ // so we prioritize txs that have been requested less often.
285
+ const batch = [];
286
+ let index = 0;
287
+ while (batch.length < maxBatchSize) {
288
+ const txToRequest = attemptsPerTx[index++];
289
+ if (!txToRequest) {
290
+ // No more txs to process
291
+ break;
292
+ } else if (!request.requestTracker.isMissing(txToRequest.txHash)) {
293
+ // Mark as found if it was found somewhere else, we'll then remove it from the array.
294
+ // We don't delete it now since 'array.splice' is pretty expensive, so we do it after sorting.
295
+ txToRequest.found = true;
296
+ } else if (!activeRequestsToThisNode.has(txToRequest.txHash)) {
297
+ // If the tx is not already being requested to this node, add it to the current batch and increase attempts.
298
+ // Note that we increase the attempts *before* making the request, so the next `collectFastFromNode` that
299
+ // needs to grab txs to send, will pick txs that have been requested less often, instead of all requesting
300
+ // the same txs at the same time.
301
+ batch.push(txToRequest);
302
+ activeRequestsToThisNode.add(txToRequest.txHash);
303
+ txToRequest.attempts++;
304
+ }
305
+ }
306
+
307
+ // After modifying the array by removing txs or updating attempts, re-sort it and trim the found txs from the end.
308
+ attemptsPerTx.sort((a, b) =>
309
+ a.found === b.found ? a.attempts - b.attempts : Number(a.found) - Number(b.found),
310
+ );
311
+ const firstFoundTxIndex = attemptsPerTx.findIndex(tx => tx.found);
312
+ if (firstFoundTxIndex !== -1) {
313
+ attemptsPerTx.length = firstFoundTxIndex;
314
+ }
315
+
316
+ // If we see no more txs to request, we can stop this "process" loop
317
+ if (batch.length === 0) {
318
+ return;
319
+ }
320
+
321
+ const txHashes = batch.map(({ txHash }) => txHash);
322
+ // Collect this batch from the node
323
+ await this.txCollectionSink.collect(
324
+ async () => {
325
+ const result = await node.getTxsByHash(txHashes.map(TxHash.fromString));
326
+ for (const tx of result.validTxs) {
327
+ request.requestTracker.markFetched(tx);
328
+ }
329
+ return result;
330
+ },
331
+ txHashes,
332
+ {
333
+ description: `fast ${node.getInfo()}`,
334
+ node: node.getInfo(),
335
+ method: 'fast-node-rpc',
336
+ ...request.blockInfo,
337
+ },
338
+ this.getAddContext(request),
339
+ );
340
+
341
+ // Clear from the active requests the txs we just requested
342
+ for (const requestedTx of batch) {
343
+ activeRequestsToThisNode.delete(requestedTx.txHash);
344
+ }
345
+
346
+ // Sleep a bit until hitting the node again, but wake up immediately on cancellation
347
+ if (notFinished()) {
348
+ await Promise.race([
349
+ sleep(this.config.txCollectionFastNodeIntervalMs),
350
+ request.requestTracker.cancellationToken,
351
+ ]);
352
+ }
353
+ }
354
+ };
355
+
356
+ // Kick off N parallel requests to the node, up to the maxParallelRequests limit
357
+ await Promise.all(times(maxParallelRequests, processBatch));
358
+ }
359
+
360
+ private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
361
+ const pinnedPeer = opts.pinnedPeer;
362
+ const blockInfo = request.blockInfo;
363
+ const slotNumber = blockInfo.slotNumber;
364
+ if (request.requestTracker.timeoutMs < 100) {
365
+ this.log.warn(
366
+ `Not initiating fast reqresp for txs for ${request.type} at slot ${blockInfo.slotNumber} due to timeout`,
367
+ { timeoutMs: request.requestTracker.timeoutMs, ...blockInfo },
368
+ );
369
+ return;
370
+ }
371
+
372
+ if (request.requestTracker.checkCancelled()) {
373
+ this.log.debug(`No txs to collect via reqresp for ${request.type} at slot ${blockInfo.slotNumber}`, {
374
+ ...blockInfo,
375
+ });
376
+ return;
377
+ }
378
+
379
+ this.log.debug(
380
+ `Starting fast reqresp for ${request.requestTracker.numberOfMissingTxs} txs for ${request.type} at slot ${blockInfo.slotNumber}`,
381
+ { ...blockInfo, timeoutMs: request.requestTracker.timeoutMs, pinnedPeer },
382
+ );
383
+
384
+ try {
385
+ await this.txCollectionSink.collect(
386
+ async () => {
387
+ let blockTxsSource: BlockTxsSource;
388
+ if (request.type === 'proposal') {
389
+ blockTxsSource = request.blockProposal;
390
+ } else if (request.type === 'block') {
391
+ blockTxsSource = {
392
+ txHashes: request.block.body.txEffects.map(e => e.txHash),
393
+ archive: request.block.archive.root,
394
+ };
395
+ } else {
396
+ throw new Error(`Unknown request type: ${(request as { type: string }).type}`);
397
+ }
398
+
399
+ const result = await this.reqRespTxsCollector!(request.requestTracker, blockTxsSource, pinnedPeer);
400
+ return { validTxs: result, invalidTxHashes: [] };
401
+ },
402
+ Array.from(request.requestTracker.missingTxHashes),
403
+ { description: `reqresp for slot ${slotNumber}`, method: 'fast-req-resp', ...opts, ...request.blockInfo },
404
+ this.getAddContext(request),
405
+ );
406
+ } catch (err) {
407
+ this.log.error(`Error sending fast reqresp request for txs`, err, {
408
+ txs: [...request.requestTracker.missingTxHashes],
409
+ ...blockInfo,
410
+ });
411
+ }
412
+ }
413
+
414
+ /** Returns the TxAddContext for the given request, used by the sink to add txs to the pool correctly. */
415
+ private getAddContext(request: FastCollectionRequest): TxAddContext {
416
+ if (request.type === 'proposal') {
417
+ return { type: 'proposal', blockHeader: request.blockProposal.blockHeader };
418
+ } else {
419
+ return { type: 'mined', block: request.block };
420
+ }
421
+ }
422
+
423
+ /** Mark the given txs as found. Stops collecting them across all in-flight requests. */
182
424
  private foundTxs(txs: Tx[]) {
183
- this.slowCollection.foundTxs(txs);
184
- this.fastCollection.foundTxs(txs);
425
+ for (const request of this.requests) {
426
+ for (const tx of txs) {
427
+ if (request.requestTracker.markFetched(tx)) {
428
+ this.log.trace(`Found tx ${tx.txHash.toString()} for fast collection request`, {
429
+ ...request.blockInfo,
430
+ txHash: tx.txHash.toString(),
431
+ type: request.type,
432
+ });
433
+ if (request.requestTracker.allFetched()) {
434
+ this.log.trace(`All txs found for fast collection request`, {
435
+ ...request.blockInfo,
436
+ type: request.type,
437
+ });
438
+ break;
439
+ }
440
+ }
441
+ }
442
+ }
185
443
  }
186
444
 
187
445
  /**
188
- * Stop collecting all txs for blocks less than or requal to the block number specified.
446
+ * Stop collecting all txs for blocks less than or equal to the block number specified.
189
447
  * To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
190
448
  */
191
449
  public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
192
- this.slowCollection.stopCollectingForBlocksUpTo(blockNumber);
193
- this.fastCollection.stopCollectingForBlocksUpTo(blockNumber);
450
+ for (const request of this.requests) {
451
+ if (request.blockInfo.blockNumber <= blockNumber) {
452
+ request.requestTracker.cancel();
453
+ }
454
+ }
194
455
  }
195
456
 
196
457
  /**
@@ -198,19 +459,10 @@ export class TxCollection {
198
459
  * To be called when there is a chain prune and previously mined txs are no longer relevant.
199
460
  */
200
461
  public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
201
- this.slowCollection.stopCollectingForBlocksAfter(blockNumber);
202
- this.fastCollection.stopCollectingForBlocksAfter(blockNumber);
203
- }
204
-
205
- /** Every now and then, check if the pool has received one of the txs we are looking for, just to catch any race conditions */
206
- private async reconcileFoundTxsWithPool() {
207
- const missingTxHashes = this.slowCollection.getMissingTxHashes();
208
- const foundTxs = compactArray(await this.txPool.getTxsByHash(missingTxHashes));
209
- if (foundTxs.length > 0) {
210
- this.log.verbose(`Found ${foundTxs.length} txs in the pool during reconciliation`, {
211
- foundTxs: foundTxs.map(t => t.getTxHash().toString()),
212
- });
213
- this.foundTxs(foundTxs);
462
+ for (const request of this.requests) {
463
+ if (request.blockInfo.blockNumber > blockNumber) {
464
+ request.requestTracker.cancel();
465
+ }
214
466
  }
215
467
  }
216
468
  }