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

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 (310) hide show
  1. package/dest/client/factory.d.ts +7 -6
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +47 -10
  4. package/dest/client/interface.d.ts +40 -22
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +37 -41
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +134 -145
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +2 -2
  10. package/dest/config.d.ts +28 -4
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +19 -2
  13. package/dest/errors/tx-pool.error.d.ts +8 -0
  14. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  15. package/dest/errors/tx-pool.error.js +9 -0
  16. package/dest/index.d.ts +2 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -0
  19. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
  20. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  22. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  23. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  25. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  26. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/index.js +1 -2
  28. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  29. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  31. package/dest/mem_pools/index.d.ts +3 -2
  32. package/dest/mem_pools/index.d.ts.map +1 -1
  33. package/dest/mem_pools/index.js +1 -1
  34. package/dest/mem_pools/interface.d.ts +5 -5
  35. package/dest/mem_pools/interface.d.ts.map +1 -1
  36. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  37. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  38. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  39. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  40. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  41. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  42. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  43. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  44. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  45. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  46. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  47. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  48. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
  49. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  50. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  51. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
  52. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  53. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  54. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +95 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  56. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  58. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
  59. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  60. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
  61. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +74 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  76. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  77. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  78. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  79. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  80. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  81. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  82. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +207 -0
  83. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  84. package/dest/mem_pools/tx_pool_v2/interfaces.js +8 -0
  85. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +97 -0
  86. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  87. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +152 -0
  88. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  89. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  90. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  91. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
  92. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  93. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +355 -0
  94. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +58 -0
  95. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  96. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
  97. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +75 -0
  98. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  99. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +871 -0
  100. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  101. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  102. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  103. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  104. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  105. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  106. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  107. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +18 -5
  108. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  109. package/dest/msg_validators/tx_validator/block_header_validator.js +2 -2
  110. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
  111. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  112. package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
  113. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
  114. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  115. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  116. package/dest/services/data_store.d.ts +1 -1
  117. package/dest/services/data_store.d.ts.map +1 -1
  118. package/dest/services/data_store.js +10 -6
  119. package/dest/services/dummy_service.d.ts +10 -2
  120. package/dest/services/dummy_service.d.ts.map +1 -1
  121. package/dest/services/dummy_service.js +6 -0
  122. package/dest/services/encoding.d.ts +2 -2
  123. package/dest/services/encoding.d.ts.map +1 -1
  124. package/dest/services/encoding.js +4 -3
  125. package/dest/services/gossipsub/index.d.ts +3 -0
  126. package/dest/services/gossipsub/index.d.ts.map +1 -0
  127. package/dest/services/gossipsub/index.js +2 -0
  128. package/dest/services/gossipsub/scoring.d.ts +21 -3
  129. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  130. package/dest/services/gossipsub/scoring.js +24 -7
  131. package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
  132. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  133. package/dest/services/gossipsub/topic_score_params.js +324 -0
  134. package/dest/services/index.d.ts +2 -1
  135. package/dest/services/index.d.ts.map +1 -1
  136. package/dest/services/index.js +1 -0
  137. package/dest/services/libp2p/libp2p_service.d.ts +84 -35
  138. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  139. package/dest/services/libp2p/libp2p_service.js +375 -280
  140. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  141. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  142. package/dest/services/peer-manager/peer_scoring.js +25 -2
  143. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
  144. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  145. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +9 -9
  146. package/dest/services/reqresp/interface.d.ts +10 -1
  147. package/dest/services/reqresp/interface.d.ts.map +1 -1
  148. package/dest/services/reqresp/interface.js +15 -1
  149. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  150. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  151. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +17 -12
  152. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +25 -14
  153. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  154. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +40 -24
  155. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  156. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  157. package/dest/services/reqresp/protocols/tx.js +20 -0
  158. package/dest/services/reqresp/reqresp.d.ts +1 -1
  159. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  160. package/dest/services/reqresp/reqresp.js +11 -4
  161. package/dest/services/service.d.ts +35 -1
  162. package/dest/services/service.d.ts.map +1 -1
  163. package/dest/services/tx_collection/config.d.ts +22 -4
  164. package/dest/services/tx_collection/config.d.ts.map +1 -1
  165. package/dest/services/tx_collection/config.js +49 -3
  166. package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
  167. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  168. package/dest/services/tx_collection/fast_tx_collection.js +27 -17
  169. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  170. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  171. package/dest/services/tx_collection/file_store_tx_collection.js +165 -0
  172. package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
  173. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  174. package/dest/services/tx_collection/file_store_tx_source.js +79 -0
  175. package/dest/services/tx_collection/index.d.ts +3 -2
  176. package/dest/services/tx_collection/index.d.ts.map +1 -1
  177. package/dest/services/tx_collection/index.js +1 -0
  178. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  179. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  180. package/dest/services/tx_collection/instrumentation.js +2 -1
  181. package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
  182. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  183. package/dest/services/tx_collection/proposal_tx_collector.js +4 -5
  184. package/dest/services/tx_collection/slow_tx_collection.d.ts +6 -2
  185. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  186. package/dest/services/tx_collection/slow_tx_collection.js +55 -23
  187. package/dest/services/tx_collection/tx_collection.d.ts +19 -7
  188. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  189. package/dest/services/tx_collection/tx_collection.js +75 -3
  190. package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
  191. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  192. package/dest/services/tx_collection/tx_collection_sink.js +13 -7
  193. package/dest/services/tx_file_store/config.d.ts +16 -0
  194. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  195. package/dest/services/tx_file_store/config.js +22 -0
  196. package/dest/services/tx_file_store/index.d.ts +4 -0
  197. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  198. package/dest/services/tx_file_store/index.js +3 -0
  199. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  200. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  201. package/dest/services/tx_file_store/instrumentation.js +29 -0
  202. package/dest/services/tx_file_store/tx_file_store.d.ts +48 -0
  203. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  204. package/dest/services/tx_file_store/tx_file_store.js +152 -0
  205. package/dest/services/tx_provider.d.ts +3 -3
  206. package/dest/services/tx_provider.d.ts.map +1 -1
  207. package/dest/services/tx_provider.js +5 -4
  208. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  209. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  210. package/dest/test-helpers/mock-pubsub.d.ts +27 -1
  211. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  212. package/dest/test-helpers/mock-pubsub.js +97 -2
  213. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  214. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  215. package/dest/test-helpers/reqresp-nodes.js +2 -1
  216. package/dest/test-helpers/testbench-utils.d.ts +43 -38
  217. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  218. package/dest/test-helpers/testbench-utils.js +130 -60
  219. package/dest/testbench/p2p_client_testbench_worker.js +5 -5
  220. package/package.json +14 -14
  221. package/src/client/factory.ts +89 -14
  222. package/src/client/interface.ts +49 -22
  223. package/src/client/p2p_client.ts +170 -168
  224. package/src/client/test/tx_proposal_collector/README.md +4 -4
  225. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +2 -2
  226. package/src/config.ts +41 -2
  227. package/src/errors/tx-pool.error.ts +12 -0
  228. package/src/index.ts +1 -0
  229. package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
  230. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  231. package/src/mem_pools/attestation_pool/index.ts +9 -2
  232. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  233. package/src/mem_pools/index.ts +4 -1
  234. package/src/mem_pools/interface.ts +4 -4
  235. package/src/mem_pools/tx_pool/README.md +1 -1
  236. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  237. package/src/mem_pools/tx_pool_v2/README.md +275 -0
  238. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  239. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  240. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  241. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  242. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
  243. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +122 -0
  244. package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
  245. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
  246. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  247. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  248. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +87 -0
  249. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
  250. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  251. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  252. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  253. package/src/mem_pools/tx_pool_v2/interfaces.ts +239 -0
  254. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +242 -0
  255. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  256. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
  257. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
  258. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1042 -0
  259. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  260. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  261. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  262. package/src/msg_validators/tx_validator/block_header_validator.ts +18 -8
  263. package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
  264. package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
  265. package/src/services/data_store.ts +10 -7
  266. package/src/services/dummy_service.ts +12 -0
  267. package/src/services/encoding.ts +4 -3
  268. package/src/services/gossipsub/README.md +626 -0
  269. package/src/services/gossipsub/index.ts +2 -0
  270. package/src/services/gossipsub/scoring.ts +29 -5
  271. package/src/services/gossipsub/topic_score_params.ts +451 -0
  272. package/src/services/index.ts +1 -0
  273. package/src/services/libp2p/libp2p_service.ts +377 -282
  274. package/src/services/peer-manager/peer_scoring.ts +25 -0
  275. package/src/services/reqresp/batch-tx-requester/README.md +14 -14
  276. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +12 -12
  277. package/src/services/reqresp/interface.ts +26 -1
  278. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +24 -15
  279. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -24
  280. package/src/services/reqresp/protocols/tx.ts +22 -0
  281. package/src/services/reqresp/reqresp.ts +13 -3
  282. package/src/services/service.ts +40 -0
  283. package/src/services/tx_collection/config.ts +74 -6
  284. package/src/services/tx_collection/fast_tx_collection.ts +28 -26
  285. package/src/services/tx_collection/file_store_tx_collection.ts +198 -0
  286. package/src/services/tx_collection/file_store_tx_source.ts +104 -0
  287. package/src/services/tx_collection/index.ts +2 -1
  288. package/src/services/tx_collection/instrumentation.ts +7 -1
  289. package/src/services/tx_collection/proposal_tx_collector.ts +12 -14
  290. package/src/services/tx_collection/slow_tx_collection.ts +64 -30
  291. package/src/services/tx_collection/tx_collection.ts +109 -13
  292. package/src/services/tx_collection/tx_collection_sink.ts +17 -7
  293. package/src/services/tx_file_store/config.ts +37 -0
  294. package/src/services/tx_file_store/index.ts +3 -0
  295. package/src/services/tx_file_store/instrumentation.ts +36 -0
  296. package/src/services/tx_file_store/tx_file_store.ts +175 -0
  297. package/src/services/tx_provider.ts +8 -7
  298. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  299. package/src/test-helpers/mock-pubsub.ts +133 -3
  300. package/src/test-helpers/reqresp-nodes.ts +2 -1
  301. package/src/test-helpers/testbench-utils.ts +129 -71
  302. package/src/testbench/p2p_client_testbench_worker.ts +5 -5
  303. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  304. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  305. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  306. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  307. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  308. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  309. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  310. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -6,7 +6,7 @@ import {
6
6
  } from '@aztec/foundation/config';
7
7
  import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
8
8
 
9
- export type ProposalTxCollectorType = 'new' | 'old';
9
+ export type MissingTxsCollectorType = 'new' | 'old';
10
10
 
11
11
  export type TxCollectionConfig = {
12
12
  /** How long to wait before starting reqresp for fast collection */
@@ -29,8 +29,26 @@ export type TxCollectionConfig = {
29
29
  txCollectionFastMaxParallelRequestsPerNode: number;
30
30
  /** Maximum number of transactions to request from a node in a single batch */
31
31
  txCollectionNodeRpcMaxBatchSize: number;
32
- /** Which collector implementation to use for proposal tx collection */
33
- txCollectionProposalTxCollectorType: ProposalTxCollectorType;
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;
40
+ /** Number of concurrent workers for fast file store collection */
41
+ txCollectionFileStoreFastWorkerCount: number;
42
+ /** Number of concurrent workers for slow file store collection */
43
+ txCollectionFileStoreSlowWorkerCount: number;
44
+ /** Base backoff time in ms for fast file store collection retries */
45
+ txCollectionFileStoreFastBackoffBaseMs: number;
46
+ /** Base backoff time in ms for slow file store collection retries */
47
+ txCollectionFileStoreSlowBackoffBaseMs: number;
48
+ /** Max backoff time in ms for fast file store collection retries */
49
+ txCollectionFileStoreFastBackoffMaxMs: number;
50
+ /** Max backoff time in ms for slow file store collection retries */
51
+ txCollectionFileStoreSlowBackoffMaxMs: number;
34
52
  };
35
53
 
36
54
  export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
@@ -90,9 +108,59 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
90
108
  description: 'Maximum number of transactions to request from a node in a single batch',
91
109
  ...numberConfigHelper(MAX_RPC_TXS_LEN),
92
110
  },
93
- txCollectionProposalTxCollectorType: {
94
- env: 'TX_COLLECTION_PROPOSAL_TX_COLLECTOR_TYPE',
95
- description: 'Which collector implementation to use for proposal tx collection (new or old)',
111
+ txCollectionMissingTxsCollectorType: {
112
+ env: 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE',
113
+ description: 'Which collector implementation to use for missing txs collection (new or old)',
96
114
  ...enumConfigHelper(['new', 'old'] as const, 'new'),
97
115
  },
116
+ txCollectionFileStoreUrls: {
117
+ env: 'TX_COLLECTION_FILE_STORE_URLS',
118
+ description: 'A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection',
119
+ parseEnv: (val: string) =>
120
+ val
121
+ .split(',')
122
+ .map(url => url.trim())
123
+ .filter(url => url.length > 0),
124
+ defaultValue: [],
125
+ },
126
+ txCollectionFileStoreSlowDelayMs: {
127
+ env: 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS',
128
+ description: 'Delay before file store collection starts after slow collection',
129
+ ...numberConfigHelper(24_000),
130
+ },
131
+ txCollectionFileStoreFastDelayMs: {
132
+ env: 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS',
133
+ description: 'Delay before file store collection starts after fast collection',
134
+ ...numberConfigHelper(2_000),
135
+ },
136
+ txCollectionFileStoreFastWorkerCount: {
137
+ env: 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT',
138
+ description: 'Number of concurrent workers for fast file store collection',
139
+ ...numberConfigHelper(5),
140
+ },
141
+ txCollectionFileStoreSlowWorkerCount: {
142
+ env: 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT',
143
+ description: 'Number of concurrent workers for slow file store collection',
144
+ ...numberConfigHelper(2),
145
+ },
146
+ txCollectionFileStoreFastBackoffBaseMs: {
147
+ env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS',
148
+ description: 'Base backoff time in ms for fast file store collection retries',
149
+ ...numberConfigHelper(1_000),
150
+ },
151
+ txCollectionFileStoreSlowBackoffBaseMs: {
152
+ env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS',
153
+ description: 'Base backoff time in ms for slow file store collection retries',
154
+ ...numberConfigHelper(5_000),
155
+ },
156
+ txCollectionFileStoreFastBackoffMaxMs: {
157
+ env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS',
158
+ description: 'Max backoff time in ms for fast file store collection retries',
159
+ ...numberConfigHelper(5_000),
160
+ },
161
+ txCollectionFileStoreSlowBackoffMaxMs: {
162
+ env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS',
163
+ description: 'Max backoff time in ms for slow file store collection retries',
164
+ ...numberConfigHelper(30_000),
165
+ },
98
166
  };
@@ -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';
@@ -14,37 +13,35 @@ import type { PeerId } from '@libp2p/interface';
14
13
 
15
14
  import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
16
15
  import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
17
- import { ReqRespSubProtocol } from '../reqresp/interface.js';
18
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
19
16
  import type { TxCollectionConfig } from './config.js';
20
17
  import {
21
18
  BatchTxRequesterCollector,
22
- type ProposalTxCollector,
19
+ type MissingTxsCollector,
23
20
  SendBatchRequestCollector,
24
21
  } from './proposal_tx_collector.js';
25
22
  import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
26
- import type { TxCollectionSink } from './tx_collection_sink.js';
23
+ import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
27
24
  import type { TxSource } from './tx_source.js';
28
25
 
29
26
  export class FastTxCollection {
30
27
  // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
31
28
  protected requests: Set<FastCollectionRequest> = new Set();
32
- private proposalTxCollector: ProposalTxCollector;
29
+ private missingTxsCollector: MissingTxsCollector;
33
30
 
34
31
  constructor(
35
- private p2pService: BatchTxRequesterLibP2PService,
32
+ p2pService: BatchTxRequesterLibP2PService,
36
33
  private nodes: TxSource[],
37
34
  private txCollectionSink: TxCollectionSink,
38
35
  private config: TxCollectionConfig,
39
36
  private dateProvider: DateProvider = new DateProvider(),
40
37
  private log: Logger = createLogger('p2p:tx_collection_service'),
41
- proposalTxCollector?: ProposalTxCollector,
38
+ missingTxsCollector?: MissingTxsCollector,
42
39
  ) {
43
40
  const batchTxRequesterConfig = this.config as Partial<BatchTxRequesterConfig>;
44
- const proposalCollectorType = this.config.txCollectionProposalTxCollectorType;
45
- this.proposalTxCollector =
46
- proposalTxCollector ??
47
- (proposalCollectorType === 'old'
41
+ const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
42
+ this.missingTxsCollector =
43
+ missingTxsCollector ??
44
+ (missingTxsCollectorType === 'old'
48
45
  ? new SendBatchRequestCollector(p2pService)
49
46
  : new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
50
47
  }
@@ -80,7 +77,7 @@ export class FastTxCollection {
80
77
  // This promise is used to await for the collection to finish during the main collectFast method.
81
78
  // It gets resolved in `foundTxs` when all txs have been collected, or rejected if the request is aborted or hits the deadline.
82
79
  const promise = promiseWithResolvers<void>();
83
- 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);
84
81
 
85
82
  const request: FastCollectionRequest = {
86
83
  ...input,
@@ -92,6 +89,7 @@ export class FastTxCollection {
92
89
  };
93
90
 
94
91
  const [duration] = await elapsed(() => this.collectFast(request, { ...opts }));
92
+ clearTimeout(timeoutTimer);
95
93
 
96
94
  this.log.verbose(
97
95
  `Collected ${request.foundTxs.size} txs out of ${txHashes.length} for ${input.type} at slot ${blockInfo.slotNumber}`,
@@ -237,6 +235,7 @@ export class FastTxCollection {
237
235
  method: 'fast-node-rpc',
238
236
  ...request.blockInfo,
239
237
  },
238
+ this.getAddContext(request),
240
239
  );
241
240
 
242
241
  // Clear from the active requests the txs we just requested
@@ -258,8 +257,6 @@ export class FastTxCollection {
258
257
  private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
259
258
  const timeoutMs = +request.deadline - this.dateProvider.now();
260
259
  const pinnedPeer = opts.pinnedPeer;
261
- const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
262
- const maxRetryAttempts = 5;
263
260
  const blockInfo = request.blockInfo;
264
261
  const slotNumber = blockInfo.slotNumber;
265
262
  if (timeoutMs < 100) {
@@ -279,24 +276,20 @@ export class FastTxCollection {
279
276
  await this.txCollectionSink.collect(
280
277
  async txHashes => {
281
278
  if (request.type === 'proposal') {
282
- return await this.proposalTxCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
279
+ return await this.missingTxsCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
283
280
  } else if (request.type === 'block') {
284
- const txs = await this.p2pService.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
285
- ReqRespSubProtocol.TX,
286
- chunkTxHashesRequest(txHashes),
287
- pinnedPeer,
288
- timeoutMs,
289
- maxPeers,
290
- maxRetryAttempts,
291
- );
292
-
293
- return txs.flat();
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);
294
286
  } else {
295
287
  throw new Error(`Unknown request type: ${(request as any).type}`);
296
288
  }
297
289
  },
298
290
  Array.from(request.missingTxHashes).map(txHash => TxHash.fromString(txHash)),
299
291
  { description: `reqresp for slot ${slotNumber}`, method: 'fast-req-resp', ...opts, ...request.blockInfo },
292
+ this.getAddContext(request),
300
293
  );
301
294
  } catch (err) {
302
295
  this.log.error(`Error sending fast reqresp request for txs`, err, {
@@ -306,6 +299,15 @@ export class FastTxCollection {
306
299
  }
307
300
  }
308
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
+
309
311
  /**
310
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.
311
313
  * Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
@@ -0,0 +1,198 @@
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { type PromiseWithResolvers, promiseWithResolvers } from '@aztec/foundation/promise';
3
+ import { sleep } from '@aztec/foundation/sleep';
4
+ import { DateProvider } from '@aztec/foundation/timer';
5
+ import { Tx, TxHash } from '@aztec/stdlib/tx';
6
+
7
+ import type { FileStoreTxSource } from './file_store_tx_source.js';
8
+ import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
9
+
10
+ /** Configuration for a FileStoreTxCollection instance. */
11
+ export type FileStoreCollectionConfig = {
12
+ workerCount: number;
13
+ backoffBaseMs: number;
14
+ backoffMaxMs: number;
15
+ };
16
+
17
+ type FileStoreTxEntry = {
18
+ txHash: string;
19
+ context: TxAddContext;
20
+ deadline: Date;
21
+ attempts: number;
22
+ lastAttemptTime: number;
23
+ nextSourceIndex: number;
24
+ };
25
+
26
+ /**
27
+ * Collects txs from file stores as a fallback after P2P methods have been tried.
28
+ * Uses a shared worker pool that pulls entries with priority (fewest attempts first),
29
+ * retries with round-robin across sources, and applies exponential backoff between
30
+ * full cycles through all sources.
31
+ */
32
+ export class FileStoreTxCollection {
33
+ /** Map from tx hash string to entry for all pending downloads. */
34
+ private entries = new Map<string, FileStoreTxEntry>();
35
+
36
+ /** Worker promises for the shared worker pool. */
37
+ private workers: Promise<void>[] = [];
38
+
39
+ /** Whether the worker pool is running. */
40
+ private running = false;
41
+
42
+ /** Signal used to wake sleeping workers when new entries arrive or stop is called. */
43
+ private wakeSignal: PromiseWithResolvers<void>;
44
+
45
+ constructor(
46
+ private readonly sources: FileStoreTxSource[],
47
+ private readonly txCollectionSink: TxCollectionSink,
48
+ private readonly config: FileStoreCollectionConfig,
49
+ private readonly dateProvider: DateProvider = new DateProvider(),
50
+ private readonly log: Logger = createLogger('p2p:file_store_tx_collection'),
51
+ ) {
52
+ this.wakeSignal = promiseWithResolvers<void>();
53
+ }
54
+
55
+ /** Starts the shared worker pool. */
56
+ public start(): void {
57
+ if (this.sources.length === 0) {
58
+ this.log.debug('No file store sources configured');
59
+ return;
60
+ }
61
+ this.running = true;
62
+ for (let i = 0; i < this.config.workerCount; i++) {
63
+ this.workers.push(this.workerLoop());
64
+ }
65
+ }
66
+
67
+ /** Stops all workers and clears state. */
68
+ public async stop(): Promise<void> {
69
+ this.running = false;
70
+ this.wake();
71
+ await Promise.all(this.workers);
72
+ this.workers = [];
73
+ this.entries.clear();
74
+ }
75
+
76
+ /** Adds entries to the shared map and wakes workers. */
77
+ public startCollecting(txHashes: TxHash[], context: TxAddContext, deadline: Date): void {
78
+ if (this.sources.length === 0 || txHashes.length === 0) {
79
+ return;
80
+ }
81
+ if (+deadline <= this.dateProvider.now()) {
82
+ return;
83
+ }
84
+
85
+ for (const txHash of txHashes) {
86
+ const hashStr = txHash.toString();
87
+ if (!this.entries.has(hashStr)) {
88
+ this.entries.set(hashStr, {
89
+ txHash: hashStr,
90
+ context,
91
+ deadline,
92
+ attempts: 0,
93
+ lastAttemptTime: 0,
94
+ nextSourceIndex: Math.floor(Math.random() * this.sources.length),
95
+ });
96
+ }
97
+ }
98
+ this.wake();
99
+ }
100
+
101
+ /** Removes entries for txs that have been found elsewhere. */
102
+ public foundTxs(txs: Tx[]): void {
103
+ for (const tx of txs) {
104
+ this.entries.delete(tx.getTxHash().toString());
105
+ }
106
+ }
107
+
108
+ /** Clears all pending entries. */
109
+ public clearPending(): void {
110
+ this.entries.clear();
111
+ }
112
+
113
+ private async workerLoop(): Promise<void> {
114
+ while (this.running) {
115
+ const action = this.getNextAction();
116
+ if (action.type === 'sleep') {
117
+ await action.promise;
118
+ continue;
119
+ }
120
+
121
+ const entry = action.entry;
122
+ const source = this.sources[entry.nextSourceIndex % this.sources.length];
123
+ entry.nextSourceIndex++;
124
+ entry.attempts++;
125
+ entry.lastAttemptTime = this.dateProvider.now();
126
+
127
+ try {
128
+ const result = await this.txCollectionSink.collect(
129
+ hashes => source.getTxsByHash(hashes),
130
+ [TxHash.fromString(entry.txHash)],
131
+ { description: `file-store ${source.getInfo()}`, method: 'file-store', fileStore: source.getInfo() },
132
+ entry.context,
133
+ );
134
+ if (result.txs.length > 0) {
135
+ this.entries.delete(entry.txHash);
136
+ }
137
+ } catch (err) {
138
+ this.log.trace(`Error downloading tx ${entry.txHash} from ${source.getInfo()}`, { err });
139
+ }
140
+ }
141
+ }
142
+
143
+ /** Single-pass scan: removes expired entries, finds the best ready entry, or computes sleep time. */
144
+ private getNextAction(): { type: 'process'; entry: FileStoreTxEntry } | { type: 'sleep'; promise: Promise<void> } {
145
+ const now = this.dateProvider.now();
146
+ let best: FileStoreTxEntry | undefined;
147
+ let earliestReadyAt = Infinity;
148
+
149
+ for (const [key, entry] of this.entries) {
150
+ if (+entry.deadline <= now) {
151
+ this.entries.delete(key);
152
+ continue;
153
+ }
154
+ const backoffMs = this.getBackoffMs(entry);
155
+ const readyAt = entry.lastAttemptTime + backoffMs;
156
+ if (readyAt > now) {
157
+ earliestReadyAt = Math.min(earliestReadyAt, readyAt);
158
+ continue;
159
+ }
160
+ if (!best || entry.attempts < best.attempts) {
161
+ best = entry;
162
+ }
163
+ }
164
+
165
+ if (best) {
166
+ return { type: 'process', entry: best };
167
+ }
168
+ if (earliestReadyAt < Infinity) {
169
+ return { type: 'sleep', promise: this.sleepOrWake(earliestReadyAt - now) };
170
+ }
171
+ return { type: 'sleep', promise: this.waitForWake() };
172
+ }
173
+
174
+ /** Computes backoff for an entry. Backoff applies after a full cycle through all sources. */
175
+ private getBackoffMs(entry: FileStoreTxEntry): number {
176
+ const fullCycles = Math.floor(entry.attempts / this.sources.length);
177
+ if (fullCycles === 0) {
178
+ return 0;
179
+ }
180
+ return Math.min(this.config.backoffBaseMs * Math.pow(2, fullCycles - 1), this.config.backoffMaxMs);
181
+ }
182
+
183
+ /** Resolves the current wake signal and creates a new one. */
184
+ private wake(): void {
185
+ this.wakeSignal.resolve();
186
+ this.wakeSignal = promiseWithResolvers<void>();
187
+ }
188
+
189
+ /** Waits until the wake signal is resolved. */
190
+ private async waitForWake(): Promise<void> {
191
+ await this.wakeSignal.promise;
192
+ }
193
+
194
+ /** Sleeps for the given duration or until the wake signal is resolved. */
195
+ private async sleepOrWake(ms: number): Promise<void> {
196
+ await Promise.race([sleep(ms), this.wakeSignal.promise]);
197
+ }
198
+ }
@@ -0,0 +1,104 @@
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { Timer } from '@aztec/foundation/timer';
3
+ import { type ReadOnlyFileStore, createReadOnlyFileStore } from '@aztec/stdlib/file-store';
4
+ import { Tx, type TxHash } from '@aztec/stdlib/tx';
5
+ import {
6
+ type Histogram,
7
+ Metrics,
8
+ type TelemetryClient,
9
+ type UpDownCounter,
10
+ getTelemetryClient,
11
+ } from '@aztec/telemetry-client';
12
+
13
+ import type { TxSource } from './tx_source.js';
14
+
15
+ /** TxSource implementation that downloads txs from a file store. */
16
+ export class FileStoreTxSource implements TxSource {
17
+ private downloadsSuccess: UpDownCounter;
18
+ private downloadsFailed: UpDownCounter;
19
+ private downloadDuration: Histogram;
20
+ private downloadSize: Histogram;
21
+
22
+ private constructor(
23
+ private readonly fileStore: ReadOnlyFileStore,
24
+ private readonly baseUrl: string,
25
+ private readonly basePath: string,
26
+ private readonly log: Logger,
27
+ telemetry: TelemetryClient,
28
+ ) {
29
+ const meter = telemetry.getMeter('file-store-tx-source');
30
+ this.downloadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_SUCCESS);
31
+ this.downloadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_FAILED);
32
+ this.downloadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_DURATION);
33
+ this.downloadSize = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_SIZE);
34
+ }
35
+
36
+ /**
37
+ * Creates a FileStoreTxSource from a URL.
38
+ * @param url - The file store URL (s3://, gs://, file://, http://, https://).
39
+ * @param basePath - Base path for tx files within the store.
40
+ * @param log - Optional logger.
41
+ * @param telemetry - Optional telemetry client.
42
+ * @returns The FileStoreTxSource instance, or undefined if creation fails.
43
+ */
44
+ public static async create(
45
+ url: string,
46
+ basePath: string,
47
+ log: Logger = createLogger('p2p:file_store_tx_source'),
48
+ telemetry: TelemetryClient = getTelemetryClient(),
49
+ ): Promise<FileStoreTxSource | undefined> {
50
+ try {
51
+ const fileStore = await createReadOnlyFileStore(url, log);
52
+ if (!fileStore) {
53
+ log.warn(`Failed to create file store for URL: ${url}`);
54
+ return undefined;
55
+ }
56
+ return new FileStoreTxSource(fileStore, url, basePath, log, telemetry);
57
+ } catch (err) {
58
+ log.warn(`Error creating file store for URL: ${url}`, { error: err });
59
+ return undefined;
60
+ }
61
+ }
62
+
63
+ public getInfo(): string {
64
+ return `file-store:${this.baseUrl}`;
65
+ }
66
+
67
+ public getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
68
+ return Promise.all(
69
+ txHashes.map(async txHash => {
70
+ const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
71
+ const timer = new Timer();
72
+ try {
73
+ const buffer = await this.fileStore.read(path);
74
+ this.downloadsSuccess.add(1);
75
+ this.downloadDuration.record(Math.ceil(timer.ms()));
76
+ this.downloadSize.record(buffer.length);
77
+ return Tx.fromBuffer(buffer);
78
+ } catch {
79
+ this.downloadsFailed.add(1);
80
+ // Tx not found or error reading - return undefined
81
+ return undefined;
82
+ }
83
+ }),
84
+ );
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Creates FileStoreTxSource instances from URLs.
90
+ * @param urls - Array of file store URLs.
91
+ * @param basePath - Base path for tx files within each store.
92
+ * @param log - Optional logger.
93
+ * @param telemetry - Optional telemetry client.
94
+ * @returns Array of successfully created FileStoreTxSource instances.
95
+ */
96
+ export async function createFileStoreTxSources(
97
+ urls: string[],
98
+ basePath: string,
99
+ log: Logger = createLogger('p2p:file_store_tx_source'),
100
+ telemetry: TelemetryClient = getTelemetryClient(),
101
+ ): Promise<FileStoreTxSource[]> {
102
+ const sources = await Promise.all(urls.map(url => FileStoreTxSource.create(url, basePath, log, telemetry)));
103
+ return sources.filter((s): s is FileStoreTxSource => s !== undefined);
104
+ }
@@ -1,7 +1,8 @@
1
1
  export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
2
2
  export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
3
3
  export {
4
- type ProposalTxCollector,
4
+ type MissingTxsCollector,
5
5
  BatchTxRequesterCollector,
6
6
  SendBatchRequestCollector,
7
7
  } from './proposal_tx_collector.js';
8
+ export { FileStoreTxSource, createFileStoreTxSources } from './file_store_tx_source.js';
@@ -18,7 +18,13 @@ export class TxCollectionInstrumentation {
18
18
  const meter = client.getMeter(name);
19
19
 
20
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'],
21
+ [Attributes.TX_COLLECTION_METHOD]: [
22
+ 'fast-req-resp',
23
+ 'fast-node-rpc',
24
+ 'slow-req-resp',
25
+ 'slow-node-rpc',
26
+ 'file-store',
27
+ ],
22
28
  });
23
29
 
24
30
  this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
@@ -1,6 +1,5 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
2
  import type { DateProvider } from '@aztec/foundation/timer';
3
- import type { BlockProposal } from '@aztec/stdlib/p2p';
4
3
  import type { Tx, TxHash } from '@aztec/stdlib/tx';
5
4
 
6
5
  import type { PeerId } from '@libp2p/interface';
@@ -9,25 +8,24 @@ import { BatchTxRequester } from '../reqresp/batch-tx-requester/batch_tx_request
9
8
  import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
10
9
  import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
11
10
  import type { IBatchRequestTxValidator } from '../reqresp/batch-tx-requester/tx_validator.js';
12
- import { ReqRespSubProtocol } from '../reqresp/interface.js';
13
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
11
+ import { type BlockTxsSource, ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
14
12
 
15
13
  /**
16
- * Strategy interface for collecting transactions for block proposals.
14
+ * Strategy interface for collecting missing transactions for a block or proposal.
17
15
  * Allows swapping between different tx collection implementations for benchmarking.
18
16
  */
19
- export interface ProposalTxCollector {
17
+ export interface MissingTxsCollector {
20
18
  /**
21
- * Collect transactions for a block proposal.
19
+ * Collect missing transactions for a block or proposal.
22
20
  * @param txHashes - The transaction hashes to collect
23
- * @param blockProposal - The block proposal containing the transactions
24
- * @param pinnedPeer - Optional peer that sent the proposal (expected to have all txs)
21
+ * @param blockTxsSource - The block or proposal containing the transactions
22
+ * @param pinnedPeer - Optional peer expected to have the transactions
25
23
  * @param timeoutMs - Timeout in milliseconds
26
24
  * @returns The collected transactions
27
25
  */
28
26
  collectTxs(
29
27
  txHashes: TxHash[],
30
- blockProposal: BlockProposal,
28
+ blockTxsSource: BlockTxsSource,
31
29
  pinnedPeer: PeerId | undefined,
32
30
  timeoutMs: number,
33
31
  ): Promise<Tx[]>;
@@ -37,7 +35,7 @@ export interface ProposalTxCollector {
37
35
  * Collects transactions using the BatchTxRequester implementation.
38
36
  * This uses a smart/dumb peer strategy with parallel workers.
39
37
  */
40
- export class BatchTxRequesterCollector implements ProposalTxCollector {
38
+ export class BatchTxRequesterCollector implements MissingTxsCollector {
41
39
  constructor(
42
40
  private p2pService: BatchTxRequesterLibP2PService,
43
41
  private log: Logger,
@@ -48,7 +46,7 @@ export class BatchTxRequesterCollector implements ProposalTxCollector {
48
46
 
49
47
  async collectTxs(
50
48
  txHashes: TxHash[],
51
- blockProposal: BlockProposal,
49
+ blockTxsSource: BlockTxsSource,
52
50
  pinnedPeer: PeerId | undefined,
53
51
  timeoutMs: number,
54
52
  ): Promise<Tx[]> {
@@ -61,7 +59,7 @@ export class BatchTxRequesterCollector implements ProposalTxCollector {
61
59
 
62
60
  const batchRequester = new BatchTxRequester(
63
61
  txHashes,
64
- blockProposal,
62
+ blockTxsSource,
65
63
  pinnedPeer,
66
64
  timeoutMs,
67
65
  this.p2pService,
@@ -87,7 +85,7 @@ const DEFAULT_MAX_RETRY_ATTEMPTS = 3;
87
85
  * Collects transactions using the sendBatchRequest implementation from ReqResp.
88
86
  * This is the original implementation that balances requests across peers.
89
87
  */
90
- export class SendBatchRequestCollector implements ProposalTxCollector {
88
+ export class SendBatchRequestCollector implements MissingTxsCollector {
91
89
  constructor(
92
90
  private p2pService: BatchTxRequesterLibP2PService,
93
91
  private maxPeers: number = DEFAULT_MAX_PEERS,
@@ -96,7 +94,7 @@ export class SendBatchRequestCollector implements ProposalTxCollector {
96
94
 
97
95
  async collectTxs(
98
96
  txHashes: TxHash[],
99
- _blockProposal: BlockProposal,
97
+ _blockTxsSource: BlockTxsSource,
100
98
  pinnedPeer: PeerId | undefined,
101
99
  timeoutMs: number,
102
100
  ): Promise<Tx[]> {