@aztec/p2p 0.0.1-commit.f295ac2 → 0.0.1-commit.f8ca9b2f3

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 (443) 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 +5 -5
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +47 -13
  7. package/dest/client/interface.d.ts +33 -15
  8. package/dest/client/interface.d.ts.map +1 -1
  9. package/dest/client/p2p_client.d.ts +35 -36
  10. package/dest/client/p2p_client.d.ts.map +1 -1
  11. package/dest/client/p2p_client.js +115 -139
  12. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
  13. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
  14. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
  15. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
  16. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
  17. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
  18. package/dest/config.d.ts +24 -3
  19. package/dest/config.d.ts.map +1 -1
  20. package/dest/config.js +16 -2
  21. package/dest/index.d.ts +2 -1
  22. package/dest/index.d.ts.map +1 -1
  23. package/dest/index.js +1 -0
  24. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +102 -88
  25. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  26. package/dest/mem_pools/attestation_pool/attestation_pool.js +436 -3
  27. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  28. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  29. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  30. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  31. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  32. package/dest/mem_pools/attestation_pool/index.js +1 -2
  33. package/dest/mem_pools/index.d.ts +3 -2
  34. package/dest/mem_pools/index.d.ts.map +1 -1
  35. package/dest/mem_pools/index.js +1 -1
  36. package/dest/mem_pools/instrumentation.d.ts +1 -1
  37. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  38. package/dest/mem_pools/instrumentation.js +2 -2
  39. package/dest/mem_pools/interface.d.ts +5 -5
  40. package/dest/mem_pools/interface.d.ts.map +1 -1
  41. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
  42. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
  44. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
  45. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
  46. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
  48. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +8 -1
  50. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
  51. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
  52. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
  53. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  54. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  55. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  56. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  57. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  58. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  59. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +87 -0
  60. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  61. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +180 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  76. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
  77. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  78. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  79. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
  80. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  81. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  82. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
  83. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  84. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  85. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
  86. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  87. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  88. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
  89. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  90. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  91. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  92. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  93. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  94. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  95. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
  96. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  97. package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
  98. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +93 -0
  99. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  100. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +127 -0
  101. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  102. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  103. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  104. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
  105. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  106. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
  107. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
  108. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  109. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
  110. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
  111. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  112. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +751 -0
  113. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
  114. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  115. package/dest/msg_validators/attestation_validator/attestation_validator.js +41 -10
  116. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
  117. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  118. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -6
  119. package/dest/msg_validators/clock_tolerance.d.ts +21 -0
  120. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  121. package/dest/msg_validators/clock_tolerance.js +37 -0
  122. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
  123. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  124. package/dest/msg_validators/proposal_validator/proposal_validator.js +55 -31
  125. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
  126. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
  127. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +93 -64
  128. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  129. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  130. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  131. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  132. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  133. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
  134. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  135. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  136. package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
  137. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  138. package/dest/msg_validators/tx_validator/data_validator.js +4 -1
  139. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
  140. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  141. package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
  142. package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
  143. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  144. package/dest/msg_validators/tx_validator/factory.js +21 -11
  145. package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
  146. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  147. package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
  148. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  149. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  150. package/dest/msg_validators/tx_validator/index.js +1 -0
  151. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
  152. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  153. package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
  154. package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
  155. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  156. package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
  157. package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
  158. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
  159. package/dest/msg_validators/tx_validator/size_validator.js +23 -0
  160. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +22 -5
  161. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  162. package/dest/msg_validators/tx_validator/timestamp_validator.js +4 -4
  163. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  164. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  165. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  166. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
  167. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  168. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
  169. package/dest/services/data_store.d.ts +1 -1
  170. package/dest/services/data_store.d.ts.map +1 -1
  171. package/dest/services/data_store.js +10 -6
  172. package/dest/services/discv5/discV5_service.js +1 -1
  173. package/dest/services/dummy_service.d.ts +22 -2
  174. package/dest/services/dummy_service.d.ts.map +1 -1
  175. package/dest/services/dummy_service.js +45 -0
  176. package/dest/services/encoding.d.ts +2 -2
  177. package/dest/services/encoding.d.ts.map +1 -1
  178. package/dest/services/encoding.js +4 -5
  179. package/dest/services/gossipsub/index.d.ts +3 -0
  180. package/dest/services/gossipsub/index.d.ts.map +1 -0
  181. package/dest/services/gossipsub/index.js +2 -0
  182. package/dest/services/gossipsub/scoring.d.ts +21 -3
  183. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  184. package/dest/services/gossipsub/scoring.js +24 -7
  185. package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
  186. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  187. package/dest/services/gossipsub/topic_score_params.js +324 -0
  188. package/dest/services/index.d.ts +2 -1
  189. package/dest/services/index.d.ts.map +1 -1
  190. package/dest/services/index.js +1 -0
  191. package/dest/services/libp2p/instrumentation.d.ts +1 -1
  192. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  193. package/dest/services/libp2p/instrumentation.js +14 -3
  194. package/dest/services/libp2p/libp2p_service.d.ts +91 -36
  195. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  196. package/dest/services/libp2p/libp2p_service.js +407 -303
  197. package/dest/services/peer-manager/metrics.d.ts +2 -2
  198. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  199. package/dest/services/peer-manager/metrics.js +20 -5
  200. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  201. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  202. package/dest/services/peer-manager/peer_scoring.js +33 -4
  203. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
  204. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  205. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
  206. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  207. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  208. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  209. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
  210. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  211. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  212. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
  213. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  214. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
  215. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
  216. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  217. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
  218. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
  219. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  220. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
  221. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
  222. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  223. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
  224. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
  225. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  226. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  227. package/dest/services/reqresp/interface.d.ts +14 -3
  228. package/dest/services/reqresp/interface.d.ts.map +1 -1
  229. package/dest/services/reqresp/interface.js +17 -3
  230. package/dest/services/reqresp/metrics.d.ts +6 -5
  231. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  232. package/dest/services/reqresp/metrics.js +17 -5
  233. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
  234. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  235. package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
  236. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  237. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  238. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
  239. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
  240. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  241. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +59 -13
  242. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  243. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  244. package/dest/services/reqresp/protocols/tx.js +20 -0
  245. package/dest/services/reqresp/reqresp.d.ts +6 -1
  246. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  247. package/dest/services/reqresp/reqresp.js +69 -26
  248. package/dest/services/service.d.ts +38 -1
  249. package/dest/services/service.d.ts.map +1 -1
  250. package/dest/services/tx_collection/config.d.ts +10 -1
  251. package/dest/services/tx_collection/config.d.ts.map +1 -1
  252. package/dest/services/tx_collection/config.js +25 -1
  253. package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
  254. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  255. package/dest/services/tx_collection/fast_tx_collection.js +34 -13
  256. package/dest/services/tx_collection/file_store_tx_collection.d.ts +44 -0
  257. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  258. package/dest/services/tx_collection/file_store_tx_collection.js +118 -0
  259. package/dest/services/tx_collection/file_store_tx_source.d.ts +27 -0
  260. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  261. package/dest/services/tx_collection/file_store_tx_source.js +57 -0
  262. package/dest/services/tx_collection/index.d.ts +3 -1
  263. package/dest/services/tx_collection/index.d.ts.map +1 -1
  264. package/dest/services/tx_collection/index.js +2 -0
  265. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  266. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  267. package/dest/services/tx_collection/instrumentation.js +9 -2
  268. package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
  269. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
  270. package/dest/services/tx_collection/proposal_tx_collector.js +49 -0
  271. package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
  272. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  273. package/dest/services/tx_collection/slow_tx_collection.js +48 -19
  274. package/dest/services/tx_collection/tx_collection.d.ts +23 -13
  275. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  276. package/dest/services/tx_collection/tx_collection.js +62 -6
  277. package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
  278. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  279. package/dest/services/tx_collection/tx_collection_sink.js +13 -7
  280. package/dest/services/tx_file_store/config.d.ts +16 -0
  281. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  282. package/dest/services/tx_file_store/config.js +22 -0
  283. package/dest/services/tx_file_store/index.d.ts +4 -0
  284. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  285. package/dest/services/tx_file_store/index.js +3 -0
  286. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  287. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  288. package/dest/services/tx_file_store/instrumentation.js +29 -0
  289. package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
  290. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  291. package/dest/services/tx_file_store/tx_file_store.js +149 -0
  292. package/dest/services/tx_provider.d.ts +5 -5
  293. package/dest/services/tx_provider.d.ts.map +1 -1
  294. package/dest/services/tx_provider.js +5 -4
  295. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  296. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  297. package/dest/services/tx_provider_instrumentation.js +5 -5
  298. package/dest/test-helpers/index.d.ts +3 -1
  299. package/dest/test-helpers/index.d.ts.map +1 -1
  300. package/dest/test-helpers/index.js +2 -0
  301. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  302. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  303. package/dest/test-helpers/mock-pubsub.d.ts +27 -1
  304. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  305. package/dest/test-helpers/mock-pubsub.js +97 -2
  306. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  307. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  308. package/dest/test-helpers/reqresp-nodes.js +2 -1
  309. package/dest/test-helpers/test_tx_provider.d.ts +40 -0
  310. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  311. package/dest/test-helpers/test_tx_provider.js +41 -0
  312. package/dest/test-helpers/testbench-utils.d.ts +158 -0
  313. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  314. package/dest/test-helpers/testbench-utils.js +360 -0
  315. package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
  316. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  317. package/dest/testbench/p2p_client_testbench_worker.js +213 -134
  318. package/dest/testbench/worker_client_manager.d.ts +51 -6
  319. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  320. package/dest/testbench/worker_client_manager.js +226 -44
  321. package/package.json +14 -14
  322. package/src/bootstrap/bootstrap.ts +7 -4
  323. package/src/client/factory.ts +78 -22
  324. package/src/client/interface.ts +39 -14
  325. package/src/client/p2p_client.ts +155 -166
  326. package/src/client/test/tx_proposal_collector/README.md +227 -0
  327. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
  328. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
  329. package/src/config.ts +38 -2
  330. package/src/index.ts +1 -0
  331. package/src/mem_pools/attestation_pool/attestation_pool.ts +488 -91
  332. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  333. package/src/mem_pools/attestation_pool/index.ts +9 -2
  334. package/src/mem_pools/index.ts +4 -1
  335. package/src/mem_pools/instrumentation.ts +2 -1
  336. package/src/mem_pools/interface.ts +4 -4
  337. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
  338. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
  339. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
  340. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
  341. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
  342. package/src/mem_pools/tx_pool_v2/README.md +259 -0
  343. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  344. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  345. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +234 -0
  346. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
  347. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
  348. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
  349. package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
  350. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
  351. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  352. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  353. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
  354. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
  355. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  356. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  357. package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
  358. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +207 -0
  359. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  360. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
  361. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
  362. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +895 -0
  363. package/src/msg_validators/attestation_validator/attestation_validator.ts +26 -14
  364. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +16 -10
  365. package/src/msg_validators/clock_tolerance.ts +51 -0
  366. package/src/msg_validators/proposal_validator/proposal_validator.ts +31 -31
  367. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +91 -67
  368. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  369. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  370. package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
  371. package/src/msg_validators/tx_validator/data_validator.ts +6 -2
  372. package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
  373. package/src/msg_validators/tx_validator/factory.ts +64 -23
  374. package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
  375. package/src/msg_validators/tx_validator/index.ts +1 -0
  376. package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
  377. package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
  378. package/src/msg_validators/tx_validator/size_validator.ts +22 -0
  379. package/src/msg_validators/tx_validator/timestamp_validator.ts +25 -17
  380. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  381. package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
  382. package/src/services/data_store.ts +10 -7
  383. package/src/services/discv5/discV5_service.ts +1 -1
  384. package/src/services/dummy_service.ts +57 -0
  385. package/src/services/encoding.ts +4 -5
  386. package/src/services/gossipsub/README.md +626 -0
  387. package/src/services/gossipsub/index.ts +2 -0
  388. package/src/services/gossipsub/scoring.ts +29 -5
  389. package/src/services/gossipsub/topic_score_params.ts +451 -0
  390. package/src/services/index.ts +1 -0
  391. package/src/services/libp2p/instrumentation.ts +15 -2
  392. package/src/services/libp2p/libp2p_service.ts +437 -316
  393. package/src/services/peer-manager/metrics.ts +21 -4
  394. package/src/services/peer-manager/peer_scoring.ts +29 -1
  395. package/src/services/reqresp/batch-tx-requester/README.md +305 -0
  396. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
  397. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  398. package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
  399. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
  400. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
  401. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
  402. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
  403. package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
  404. package/src/services/reqresp/interface.ts +31 -3
  405. package/src/services/reqresp/metrics.ts +34 -9
  406. package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
  407. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
  408. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
  409. package/src/services/reqresp/protocols/tx.ts +22 -0
  410. package/src/services/reqresp/reqresp.ts +79 -22
  411. package/src/services/service.ts +44 -0
  412. package/src/services/tx_collection/config.ts +41 -1
  413. package/src/services/tx_collection/fast_tx_collection.ts +44 -19
  414. package/src/services/tx_collection/file_store_tx_collection.ts +152 -0
  415. package/src/services/tx_collection/file_store_tx_source.ts +70 -0
  416. package/src/services/tx_collection/index.ts +6 -0
  417. package/src/services/tx_collection/instrumentation.ts +11 -2
  418. package/src/services/tx_collection/proposal_tx_collector.ts +112 -0
  419. package/src/services/tx_collection/slow_tx_collection.ts +57 -28
  420. package/src/services/tx_collection/tx_collection.ts +86 -20
  421. package/src/services/tx_collection/tx_collection_sink.ts +17 -7
  422. package/src/services/tx_file_store/config.ts +37 -0
  423. package/src/services/tx_file_store/index.ts +3 -0
  424. package/src/services/tx_file_store/instrumentation.ts +36 -0
  425. package/src/services/tx_file_store/tx_file_store.ts +173 -0
  426. package/src/services/tx_provider.ts +10 -9
  427. package/src/services/tx_provider_instrumentation.ts +11 -5
  428. package/src/test-helpers/index.ts +2 -0
  429. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  430. package/src/test-helpers/mock-pubsub.ts +133 -3
  431. package/src/test-helpers/reqresp-nodes.ts +2 -1
  432. package/src/test-helpers/test_tx_provider.ts +64 -0
  433. package/src/test-helpers/testbench-utils.ts +422 -0
  434. package/src/testbench/p2p_client_testbench_worker.ts +322 -127
  435. package/src/testbench/worker_client_manager.ts +304 -47
  436. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  437. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  438. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  439. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  440. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  441. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  442. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  443. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -1,3 +1,4 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
4
  import type { BlockProposal, CheckpointAttestation, CheckpointProposalCore, Gossipable } from '@aztec/stdlib/p2p';
@@ -7,6 +8,7 @@ import type { PeerId } from '@libp2p/interface';
7
8
  import type { ENR } from '@nethermindeth/enr';
8
9
  import type EventEmitter from 'events';
9
10
 
11
+ import type { BatchTxRequesterLibP2PService } from './reqresp/batch-tx-requester/interface.js';
10
12
  import type { P2PReqRespConfig } from './reqresp/config.js';
11
13
  import type { StatusMessage } from './reqresp/index.js';
12
14
  import type {
@@ -42,6 +44,32 @@ export type P2PCheckpointReceivedCallback = (
42
44
 
43
45
  export type AuthReceivedCallback = (peerId: PeerId, authRequest: AuthRequest) => Promise<AuthResponse | undefined>;
44
46
 
47
+ /** Minimal info passed to the duplicate proposal callback. */
48
+ export type DuplicateProposalInfo = {
49
+ slot: SlotNumber;
50
+ proposer: EthAddress;
51
+ type: 'checkpoint' | 'block';
52
+ };
53
+
54
+ /**
55
+ * Callback for when a duplicate proposal is detected (equivocation).
56
+ * Invoked on the first duplicate (when count goes from 1 to 2).
57
+ */
58
+ export type P2PDuplicateProposalCallback = (info: DuplicateProposalInfo) => void;
59
+
60
+ /** Minimal info passed to the duplicate attestation callback. */
61
+ export type DuplicateAttestationInfo = {
62
+ slot: SlotNumber;
63
+ attester: EthAddress;
64
+ };
65
+
66
+ /**
67
+ * Callback for when a duplicate attestation is detected (equivocation).
68
+ * A validator signing attestations for different proposals at the same slot.
69
+ * Invoked on the first duplicate (when count goes from 1 to 2).
70
+ */
71
+ export type P2PDuplicateAttestationCallback = (info: DuplicateAttestationInfo) => void;
72
+
45
73
  /**
46
74
  * The interface for a P2P service implementation.
47
75
  */
@@ -85,6 +113,19 @@ export interface P2PService {
85
113
 
86
114
  registerCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
87
115
 
116
+ /**
117
+ * Registers a callback invoked when a duplicate proposal is detected (equivocation).
118
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
119
+ */
120
+ registerDuplicateProposalCallback(callback: P2PDuplicateProposalCallback): void;
121
+
122
+ /**
123
+ * Registers a callback invoked when a duplicate attestation is detected (equivocation).
124
+ * A validator signing attestations for different proposals at the same slot.
125
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
126
+ */
127
+ registerDuplicateAttestationCallback(callback: P2PDuplicateAttestationCallback): void;
128
+
88
129
  getEnr(): ENR | undefined;
89
130
 
90
131
  getPeers(includePending?: boolean): PeerInfo[];
@@ -103,6 +144,9 @@ export interface P2PService {
103
144
 
104
145
  /** If node running this P2P stack is validator, passes in validator address to P2P layer */
105
146
  registerThisValidatorAddresses(address: EthAddress[]): void;
147
+
148
+ /** Get BatchTxRequester service dependencies */
149
+ getBatchTxRequesterService(): BatchTxRequesterLibP2PService;
106
150
  }
107
151
 
108
152
  /**
@@ -1,6 +1,13 @@
1
- import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
1
+ import {
2
+ type ConfigMappingsType,
3
+ booleanConfigHelper,
4
+ enumConfigHelper,
5
+ numberConfigHelper,
6
+ } from '@aztec/foundation/config';
2
7
  import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
3
8
 
9
+ export type MissingTxsCollectorType = 'new' | 'old';
10
+
4
11
  export type TxCollectionConfig = {
5
12
  /** How long to wait before starting reqresp for fast collection */
6
13
  txCollectionFastNodesTimeoutBeforeReqRespMs: number;
@@ -22,6 +29,14 @@ export type TxCollectionConfig = {
22
29
  txCollectionFastMaxParallelRequestsPerNode: number;
23
30
  /** Maximum number of transactions to request from a node in a single batch */
24
31
  txCollectionNodeRpcMaxBatchSize: number;
32
+ /** Which collector implementation to use for missing txs collection */
33
+ txCollectionMissingTxsCollectorType: MissingTxsCollectorType;
34
+ /** A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection */
35
+ txCollectionFileStoreUrls: string[];
36
+ /** Delay in ms before file store collection starts after slow collection is triggered */
37
+ txCollectionFileStoreSlowDelayMs: number;
38
+ /** Delay in ms before file store collection starts after fast collection is triggered */
39
+ txCollectionFileStoreFastDelayMs: number;
25
40
  };
26
41
 
27
42
  export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
@@ -81,4 +96,29 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
81
96
  description: 'Maximum number of transactions to request from a node in a single batch',
82
97
  ...numberConfigHelper(MAX_RPC_TXS_LEN),
83
98
  },
99
+ txCollectionMissingTxsCollectorType: {
100
+ env: 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE',
101
+ description: 'Which collector implementation to use for missing txs collection (new or old)',
102
+ ...enumConfigHelper(['new', 'old'] as const, 'new'),
103
+ },
104
+ txCollectionFileStoreUrls: {
105
+ env: 'TX_COLLECTION_FILE_STORE_URLS',
106
+ description: 'A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection',
107
+ parseEnv: (val: string) =>
108
+ val
109
+ .split(',')
110
+ .map(url => url.trim())
111
+ .filter(url => url.length > 0),
112
+ defaultValue: [],
113
+ },
114
+ txCollectionFileStoreSlowDelayMs: {
115
+ env: 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS',
116
+ description: 'Delay before file store collection starts after slow collection',
117
+ ...numberConfigHelper(24_000),
118
+ },
119
+ txCollectionFileStoreFastDelayMs: {
120
+ env: 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS',
121
+ description: 'Delay before file store collection starts after fast collection',
122
+ ...numberConfigHelper(2_000),
123
+ },
84
124
  };
@@ -2,7 +2,6 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { times } from '@aztec/foundation/collection';
3
3
  import { AbortError, TimeoutError } from '@aztec/foundation/error';
4
4
  import { type Logger, createLogger } from '@aztec/foundation/log';
5
- import { boundInclusive } from '@aztec/foundation/number';
6
5
  import { promiseWithResolvers } from '@aztec/foundation/promise';
7
6
  import { sleep } from '@aztec/foundation/sleep';
8
7
  import { DateProvider, elapsed } from '@aztec/foundation/timer';
@@ -12,25 +11,40 @@ import { type Tx, TxHash } from '@aztec/stdlib/tx';
12
11
 
13
12
  import type { PeerId } from '@libp2p/interface';
14
13
 
15
- import { type ReqRespInterface, ReqRespSubProtocol } from '../reqresp/interface.js';
16
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
14
+ import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
15
+ import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
17
16
  import type { TxCollectionConfig } from './config.js';
17
+ import {
18
+ BatchTxRequesterCollector,
19
+ type MissingTxsCollector,
20
+ SendBatchRequestCollector,
21
+ } from './proposal_tx_collector.js';
18
22
  import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
19
- import type { TxCollectionSink } from './tx_collection_sink.js';
23
+ import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
20
24
  import type { TxSource } from './tx_source.js';
21
25
 
22
26
  export class FastTxCollection {
23
27
  // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
24
28
  protected requests: Set<FastCollectionRequest> = new Set();
29
+ private missingTxsCollector: MissingTxsCollector;
25
30
 
26
31
  constructor(
27
- private reqResp: Pick<ReqRespInterface, 'sendBatchRequest'>,
32
+ p2pService: BatchTxRequesterLibP2PService,
28
33
  private nodes: TxSource[],
29
34
  private txCollectionSink: TxCollectionSink,
30
35
  private config: TxCollectionConfig,
31
36
  private dateProvider: DateProvider = new DateProvider(),
32
37
  private log: Logger = createLogger('p2p:tx_collection_service'),
33
- ) {}
38
+ missingTxsCollector?: MissingTxsCollector,
39
+ ) {
40
+ const batchTxRequesterConfig = this.config as Partial<BatchTxRequesterConfig>;
41
+ const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
42
+ this.missingTxsCollector =
43
+ missingTxsCollector ??
44
+ (missingTxsCollectorType === 'old'
45
+ ? new SendBatchRequestCollector(p2pService)
46
+ : new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
47
+ }
34
48
 
35
49
  public async stop() {
36
50
  this.requests.forEach(request => request.promise.reject(new AbortError(`Stopped collection service`)));
@@ -63,7 +77,7 @@ export class FastTxCollection {
63
77
  // This promise is used to await for the collection to finish during the main collectFast method.
64
78
  // It gets resolved in `foundTxs` when all txs have been collected, or rejected if the request is aborted or hits the deadline.
65
79
  const promise = promiseWithResolvers<void>();
66
- setTimeout(() => promise.reject(new TimeoutError(`Timed out while collecting txs`)), timeout);
80
+ const timeoutTimer = setTimeout(() => promise.reject(new TimeoutError(`Timed out while collecting txs`)), timeout);
67
81
 
68
82
  const request: FastCollectionRequest = {
69
83
  ...input,
@@ -75,6 +89,7 @@ export class FastTxCollection {
75
89
  };
76
90
 
77
91
  const [duration] = await elapsed(() => this.collectFast(request, { ...opts }));
92
+ clearTimeout(timeoutTimer);
78
93
 
79
94
  this.log.verbose(
80
95
  `Collected ${request.foundTxs.size} txs out of ${txHashes.length} for ${input.type} at slot ${blockInfo.slotNumber}`,
@@ -220,6 +235,7 @@ export class FastTxCollection {
220
235
  method: 'fast-node-rpc',
221
236
  ...request.blockInfo,
222
237
  },
238
+ this.getAddContext(request),
223
239
  );
224
240
 
225
241
  // Clear from the active requests the txs we just requested
@@ -241,8 +257,6 @@ export class FastTxCollection {
241
257
  private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
242
258
  const timeoutMs = +request.deadline - this.dateProvider.now();
243
259
  const pinnedPeer = opts.pinnedPeer;
244
- const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
245
- const maxRetryAttempts = 5;
246
260
  const blockInfo = request.blockInfo;
247
261
  const slotNumber = blockInfo.slotNumber;
248
262
  if (timeoutMs < 100) {
@@ -261,19 +275,21 @@ export class FastTxCollection {
261
275
  try {
262
276
  await this.txCollectionSink.collect(
263
277
  async txHashes => {
264
- const txs = await this.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
265
- ReqRespSubProtocol.TX,
266
- chunkTxHashesRequest(txHashes),
267
- pinnedPeer,
268
- timeoutMs,
269
- maxPeers,
270
- maxRetryAttempts,
271
- );
272
-
273
- return txs.flat();
278
+ if (request.type === 'proposal') {
279
+ return await this.missingTxsCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
280
+ } else if (request.type === 'block') {
281
+ const blockTxsSource = {
282
+ txHashes: request.block.body.txEffects.map(e => e.txHash),
283
+ archive: request.block.archive.root,
284
+ };
285
+ return await this.missingTxsCollector.collectTxs(txHashes, blockTxsSource, pinnedPeer, timeoutMs);
286
+ } else {
287
+ throw new Error(`Unknown request type: ${(request as any).type}`);
288
+ }
274
289
  },
275
290
  Array.from(request.missingTxHashes).map(txHash => TxHash.fromString(txHash)),
276
291
  { description: `reqresp for slot ${slotNumber}`, method: 'fast-req-resp', ...opts, ...request.blockInfo },
292
+ this.getAddContext(request),
277
293
  );
278
294
  } catch (err) {
279
295
  this.log.error(`Error sending fast reqresp request for txs`, err, {
@@ -283,6 +299,15 @@ export class FastTxCollection {
283
299
  }
284
300
  }
285
301
 
302
+ /** Returns the TxAddContext for the given request, used by the sink to add txs to the pool correctly. */
303
+ private getAddContext(request: FastCollectionRequest): TxAddContext {
304
+ if (request.type === 'proposal') {
305
+ return { type: 'proposal', blockHeader: request.blockProposal.blockHeader };
306
+ } else {
307
+ return { type: 'mined', block: request.block };
308
+ }
309
+ }
310
+
286
311
  /**
287
312
  * Handle txs by marking them as found for the requests that are waiting for them, and resolves the request if all its txs have been found.
288
313
  * Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
@@ -0,0 +1,152 @@
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { FifoMemoryQueue } from '@aztec/foundation/queue';
3
+ import { Tx, TxHash } from '@aztec/stdlib/tx';
4
+
5
+ import type { FileStoreTxSource } from './file_store_tx_source.js';
6
+ import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
7
+
8
+ // Internal constants (not configurable by node operators)
9
+ const FILE_STORE_DOWNLOAD_CONCURRENCY = 5; // Max concurrent downloads
10
+
11
+ /**
12
+ * Collects txs from file stores as a fallback after P2P methods have been tried.
13
+ * Runs in parallel to slow/fast collection. The delay before starting file store
14
+ * collection is managed by the TxCollection orchestrator, not this class.
15
+ */
16
+ export class FileStoreTxCollection {
17
+ /** Map from tx hash to add context for txs queued for download. */
18
+ private pendingTxs = new Map<string, TxAddContext>();
19
+
20
+ /**
21
+ * Tracks tx hashes found elsewhere, even before startCollecting is called.
22
+ * Needed because the orchestrator delays startCollecting via a real sleep, but foundTxs
23
+ * may arrive during that delay — before the hashes are added to pendingTxs.
24
+ */
25
+ private foundTxHashes = new Set<string>();
26
+
27
+ /** Queue of tx hashes to be downloaded. */
28
+ private downloadQueue = new FifoMemoryQueue<TxHash>();
29
+
30
+ /** Worker promises for concurrent downloads. */
31
+ private workers: Promise<void>[] = [];
32
+
33
+ /** Whether the collection has been started. */
34
+ private started = false;
35
+
36
+ constructor(
37
+ private readonly fileStoreSources: FileStoreTxSource[],
38
+ private readonly txCollectionSink: TxCollectionSink,
39
+ private readonly log: Logger = createLogger('p2p:file_store_tx_collection'),
40
+ ) {}
41
+
42
+ /** Starts the file store collection workers. */
43
+ public start() {
44
+ if (this.fileStoreSources.length === 0) {
45
+ this.log.debug('No file store sources configured, skipping file store collection');
46
+ return;
47
+ }
48
+
49
+ this.started = true;
50
+ this.downloadQueue = new FifoMemoryQueue<TxHash>();
51
+
52
+ // Start concurrent download workers
53
+ for (let i = 0; i < FILE_STORE_DOWNLOAD_CONCURRENCY; i++) {
54
+ this.workers.push(this.downloadQueue.process(txHash => this.processDownload(txHash)));
55
+ }
56
+
57
+ this.log.info(`Started file store tx collection with ${this.fileStoreSources.length} sources`, {
58
+ sources: this.fileStoreSources.map(s => s.getInfo()),
59
+ concurrency: FILE_STORE_DOWNLOAD_CONCURRENCY,
60
+ });
61
+ }
62
+
63
+ /** Stops all collection activity. */
64
+ public async stop() {
65
+ if (!this.started) {
66
+ return;
67
+ }
68
+ this.started = false;
69
+ this.downloadQueue.end();
70
+ await Promise.all(this.workers);
71
+ this.workers = [];
72
+ this.pendingTxs.clear();
73
+ this.foundTxHashes.clear();
74
+ }
75
+
76
+ /** Remove the given tx hashes from pending. */
77
+ public stopCollecting(txHashes: TxHash[]) {
78
+ for (const txHash of txHashes) {
79
+ const hashStr = txHash.toString();
80
+ this.pendingTxs.delete(hashStr);
81
+ }
82
+ }
83
+
84
+ /** Clears all pending state. Items already in the download queue will still be processed but won't be re-queued. */
85
+ public clearPending() {
86
+ this.pendingTxs.clear();
87
+ this.foundTxHashes.clear();
88
+ }
89
+
90
+ /** Queue the given tx hashes for file store collection. */
91
+ public startCollecting(txHashes: TxHash[], context: TxAddContext) {
92
+ for (const txHash of txHashes) {
93
+ const hashStr = txHash.toString();
94
+ if (!this.pendingTxs.has(hashStr) && !this.foundTxHashes.has(hashStr)) {
95
+ this.pendingTxs.set(hashStr, context);
96
+ this.downloadQueue.put(txHash);
97
+ }
98
+ }
99
+ }
100
+
101
+ /** Stop tracking txs that were found elsewhere. */
102
+ public foundTxs(txs: Tx[]) {
103
+ for (const tx of txs) {
104
+ const hashStr = tx.getTxHash().toString();
105
+ this.pendingTxs.delete(hashStr);
106
+ this.foundTxHashes.add(hashStr);
107
+ }
108
+ }
109
+
110
+ /** Processes a single tx hash from the download queue. */
111
+ private async processDownload(txHash: TxHash) {
112
+ const hashStr = txHash.toString();
113
+ const context = this.pendingTxs.get(hashStr);
114
+
115
+ // Skip if already found by another method
116
+ if (!context) {
117
+ return;
118
+ }
119
+
120
+ await this.downloadTx(txHash, context);
121
+ this.pendingTxs.delete(hashStr);
122
+ }
123
+
124
+ /** Attempt to download a tx from file stores (round-robin). */
125
+ private async downloadTx(txHash: TxHash, context: TxAddContext) {
126
+ const startIndex = Math.floor(Math.random() * this.fileStoreSources.length);
127
+ for (let i = startIndex; i < startIndex + this.fileStoreSources.length; i++) {
128
+ const source = this.fileStoreSources[i % this.fileStoreSources.length];
129
+
130
+ try {
131
+ const result = await this.txCollectionSink.collect(
132
+ hashes => source.getTxsByHash(hashes),
133
+ [txHash],
134
+ {
135
+ description: `file-store ${source.getInfo()}`,
136
+ method: 'file-store',
137
+ fileStore: source.getInfo(),
138
+ },
139
+ context,
140
+ );
141
+
142
+ if (result.txs.length > 0) {
143
+ return;
144
+ }
145
+ } catch (err) {
146
+ this.log.trace(`Failed to download tx ${txHash} from ${source.getInfo()}`, { err });
147
+ }
148
+ }
149
+
150
+ this.log.trace(`Tx ${txHash} not found in any file store`);
151
+ }
152
+ }
@@ -0,0 +1,70 @@
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { type ReadOnlyFileStore, createReadOnlyFileStore } from '@aztec/stdlib/file-store';
3
+ import { Tx, type TxHash } from '@aztec/stdlib/tx';
4
+
5
+ import type { TxSource } from './tx_source.js';
6
+
7
+ /** TxSource implementation that downloads txs from a file store. */
8
+ export class FileStoreTxSource implements TxSource {
9
+ private constructor(
10
+ private readonly fileStore: ReadOnlyFileStore,
11
+ private readonly baseUrl: string,
12
+ private readonly log: Logger,
13
+ ) {}
14
+
15
+ /**
16
+ * Creates a FileStoreTxSource from a URL.
17
+ * @param url - The file store URL (s3://, gs://, file://, http://, https://).
18
+ * @param log - Optional logger.
19
+ * @returns The FileStoreTxSource instance, or undefined if creation fails.
20
+ */
21
+ public static async create(
22
+ url: string,
23
+ log: Logger = createLogger('p2p:file_store_tx_source'),
24
+ ): Promise<FileStoreTxSource | undefined> {
25
+ try {
26
+ const fileStore = await createReadOnlyFileStore(url, log);
27
+ if (!fileStore) {
28
+ log.warn(`Failed to create file store for URL: ${url}`);
29
+ return undefined;
30
+ }
31
+ return new FileStoreTxSource(fileStore, url, log);
32
+ } catch (err) {
33
+ log.warn(`Error creating file store for URL: ${url}`, { error: err });
34
+ return undefined;
35
+ }
36
+ }
37
+
38
+ public getInfo(): string {
39
+ return `file-store:${this.baseUrl}`;
40
+ }
41
+
42
+ public getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
43
+ return Promise.all(
44
+ txHashes.map(async txHash => {
45
+ const path = `txs/${txHash.toString()}.bin`;
46
+ try {
47
+ const buffer = await this.fileStore.read(path);
48
+ return Tx.fromBuffer(buffer);
49
+ } catch {
50
+ // Tx not found or error reading - return undefined
51
+ return undefined;
52
+ }
53
+ }),
54
+ );
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Creates FileStoreTxSource instances from URLs.
60
+ * @param urls - Array of file store URLs.
61
+ * @param log - Optional logger.
62
+ * @returns Array of successfully created FileStoreTxSource instances.
63
+ */
64
+ export async function createFileStoreTxSources(
65
+ urls: string[],
66
+ log: Logger = createLogger('p2p:file_store_tx_source'),
67
+ ): Promise<FileStoreTxSource[]> {
68
+ const sources = await Promise.all(urls.map(url => FileStoreTxSource.create(url, log)));
69
+ return sources.filter((s): s is FileStoreTxSource => s !== undefined);
70
+ }
@@ -1,2 +1,8 @@
1
1
  export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
2
2
  export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
3
+ export {
4
+ type MissingTxsCollector,
5
+ BatchTxRequesterCollector,
6
+ SendBatchRequestCollector,
7
+ } from './proposal_tx_collector.js';
8
+ export { FileStoreTxSource, createFileStoreTxSources } from './file_store_tx_source.js';
@@ -1,4 +1,11 @@
1
- import { Attributes, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
1
+ import {
2
+ Attributes,
3
+ type Histogram,
4
+ Metrics,
5
+ type TelemetryClient,
6
+ type UpDownCounter,
7
+ createUpDownCounterWithDefault,
8
+ } from '@aztec/telemetry-client';
2
9
 
3
10
  import type { CollectionMethod } from './tx_collection.js';
4
11
 
@@ -10,7 +17,9 @@ export class TxCollectionInstrumentation {
10
17
  constructor(client: TelemetryClient, name: string) {
11
18
  const meter = client.getMeter(name);
12
19
 
13
- this.txsCollected = meter.createUpDownCounter(Metrics.TX_COLLECTOR_COUNT);
20
+ this.txsCollected = createUpDownCounterWithDefault(meter, Metrics.TX_COLLECTOR_COUNT, {
21
+ [Attributes.TX_COLLECTION_METHOD]: ['fast-req-resp', 'fast-node-rpc', 'slow-req-resp', 'slow-node-rpc'],
22
+ });
14
23
 
15
24
  this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
16
25
 
@@ -0,0 +1,112 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ import type { DateProvider } from '@aztec/foundation/timer';
3
+ import type { Tx, TxHash } from '@aztec/stdlib/tx';
4
+
5
+ import type { PeerId } from '@libp2p/interface';
6
+
7
+ import { BatchTxRequester } from '../reqresp/batch-tx-requester/batch_tx_requester.js';
8
+ import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
9
+ import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
10
+ import type { IBatchRequestTxValidator } from '../reqresp/batch-tx-requester/tx_validator.js';
11
+ import { type BlockTxsSource, ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
12
+
13
+ /**
14
+ * Strategy interface for collecting missing transactions for a block or proposal.
15
+ * Allows swapping between different tx collection implementations for benchmarking.
16
+ */
17
+ export interface MissingTxsCollector {
18
+ /**
19
+ * Collect missing transactions for a block or proposal.
20
+ * @param txHashes - The transaction hashes to collect
21
+ * @param blockTxsSource - The block or proposal containing the transactions
22
+ * @param pinnedPeer - Optional peer expected to have the transactions
23
+ * @param timeoutMs - Timeout in milliseconds
24
+ * @returns The collected transactions
25
+ */
26
+ collectTxs(
27
+ txHashes: TxHash[],
28
+ blockTxsSource: BlockTxsSource,
29
+ pinnedPeer: PeerId | undefined,
30
+ timeoutMs: number,
31
+ ): Promise<Tx[]>;
32
+ }
33
+
34
+ /**
35
+ * Collects transactions using the BatchTxRequester implementation.
36
+ * This uses a smart/dumb peer strategy with parallel workers.
37
+ */
38
+ export class BatchTxRequesterCollector implements MissingTxsCollector {
39
+ constructor(
40
+ private p2pService: BatchTxRequesterLibP2PService,
41
+ private log: Logger,
42
+ private dateProvider: DateProvider,
43
+ private txValidator?: IBatchRequestTxValidator,
44
+ private batchTxRequesterConfig?: Partial<BatchTxRequesterConfig>,
45
+ ) {}
46
+
47
+ async collectTxs(
48
+ txHashes: TxHash[],
49
+ blockTxsSource: BlockTxsSource,
50
+ pinnedPeer: PeerId | undefined,
51
+ timeoutMs: number,
52
+ ): Promise<Tx[]> {
53
+ const {
54
+ batchTxRequesterSmartParallelWorkerCount: smartParallelWorkerCount,
55
+ batchTxRequesterDumbParallelWorkerCount: dumbParallelWorkerCount,
56
+ batchTxRequesterTxBatchSize: txBatchSize,
57
+ batchTxRequesterBadPeerThreshold: badPeerThreshold,
58
+ } = this.batchTxRequesterConfig ?? {};
59
+
60
+ const batchRequester = new BatchTxRequester(
61
+ txHashes,
62
+ blockTxsSource,
63
+ pinnedPeer,
64
+ timeoutMs,
65
+ this.p2pService,
66
+ this.log,
67
+ this.dateProvider,
68
+ {
69
+ smartParallelWorkerCount,
70
+ dumbParallelWorkerCount,
71
+ txBatchSize,
72
+ badPeerThreshold,
73
+ txValidator: this.txValidator,
74
+ },
75
+ );
76
+
77
+ return await BatchTxRequester.collectAllTxs(batchRequester.run());
78
+ }
79
+ }
80
+
81
+ const DEFAULT_MAX_PEERS = 10;
82
+ const DEFAULT_MAX_RETRY_ATTEMPTS = 3;
83
+
84
+ /**
85
+ * Collects transactions using the sendBatchRequest implementation from ReqResp.
86
+ * This is the original implementation that balances requests across peers.
87
+ */
88
+ export class SendBatchRequestCollector implements MissingTxsCollector {
89
+ constructor(
90
+ private p2pService: BatchTxRequesterLibP2PService,
91
+ private maxPeers: number = DEFAULT_MAX_PEERS,
92
+ private maxRetryAttempts: number = DEFAULT_MAX_RETRY_ATTEMPTS,
93
+ ) {}
94
+
95
+ async collectTxs(
96
+ txHashes: TxHash[],
97
+ _blockTxsSource: BlockTxsSource,
98
+ pinnedPeer: PeerId | undefined,
99
+ timeoutMs: number,
100
+ ): Promise<Tx[]> {
101
+ const txs = await this.p2pService.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
102
+ ReqRespSubProtocol.TX,
103
+ chunkTxHashesRequest(txHashes),
104
+ pinnedPeer,
105
+ timeoutMs,
106
+ this.maxPeers,
107
+ this.maxRetryAttempts,
108
+ );
109
+
110
+ return txs.flat();
111
+ }
112
+ }