@aztec/p2p 0.0.1-commit.3d8f95d → 0.0.1-commit.3fd054f6

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 (330) hide show
  1. package/README.md +129 -3
  2. package/dest/client/factory.d.ts +7 -7
  3. package/dest/client/factory.d.ts.map +1 -1
  4. package/dest/client/factory.js +35 -29
  5. package/dest/client/interface.d.ts +14 -19
  6. package/dest/client/interface.d.ts.map +1 -1
  7. package/dest/client/p2p_client.d.ts +9 -18
  8. package/dest/client/p2p_client.d.ts.map +1 -1
  9. package/dest/client/p2p_client.js +68 -100
  10. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
  11. package/dest/config.d.ts +43 -15
  12. package/dest/config.d.ts.map +1 -1
  13. package/dest/config.js +91 -37
  14. package/dest/errors/tx-pool.error.d.ts +8 -0
  15. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  16. package/dest/errors/tx-pool.error.js +9 -0
  17. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +7 -5
  18. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  19. package/dest/mem_pools/attestation_pool/attestation_pool.js +13 -4
  20. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
  21. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  22. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  23. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  24. package/dest/mem_pools/instrumentation.d.ts +4 -2
  25. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  26. package/dest/mem_pools/instrumentation.js +16 -14
  27. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  28. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  29. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +2 -1
  30. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  31. package/dest/mem_pools/tx_pool/priority.d.ts +2 -2
  32. package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
  33. package/dest/mem_pools/tx_pool/priority.js +4 -4
  34. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
  35. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  36. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -1
  37. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +30 -13
  38. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
  39. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
  40. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
  41. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
  42. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
  43. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  44. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  45. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +7 -3
  46. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
  47. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  48. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
  49. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
  50. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  51. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
  52. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
  53. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
  54. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
  56. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
  57. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
  58. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  59. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
  60. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
  61. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
  62. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
  63. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
  64. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
  65. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
  66. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
  67. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  68. package/dest/mem_pools/tx_pool_v2/index.js +1 -1
  69. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  70. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  71. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  72. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +28 -10
  73. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  74. package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
  75. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +56 -15
  76. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  77. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +107 -18
  78. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
  79. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  80. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +50 -45
  81. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -5
  82. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  83. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +17 -6
  84. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -5
  85. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  86. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +319 -147
  87. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
  88. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  89. package/dest/msg_validators/attestation_validator/attestation_validator.js +5 -4
  90. package/dest/msg_validators/clock_tolerance.d.ts +1 -1
  91. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
  92. package/dest/msg_validators/clock_tolerance.js +4 -3
  93. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
  94. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  95. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
  96. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
  97. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  98. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
  99. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
  100. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  101. package/dest/msg_validators/proposal_validator/proposal_validator.js +53 -41
  102. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
  103. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  104. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
  105. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  106. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  107. package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
  108. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  109. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  110. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  111. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  112. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  113. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  114. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  115. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  116. package/dest/msg_validators/tx_validator/data_validator.js +35 -2
  117. package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
  118. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  119. package/dest/msg_validators/tx_validator/factory.js +247 -60
  120. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
  121. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
  122. package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
  123. package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
  124. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  125. package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
  126. package/dest/msg_validators/tx_validator/index.d.ts +3 -1
  127. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  128. package/dest/msg_validators/tx_validator/index.js +2 -0
  129. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
  130. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  131. package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
  132. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  133. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  134. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  135. package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
  136. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  137. package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
  138. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
  139. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  140. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  141. package/dest/services/dummy_service.d.ts +4 -4
  142. package/dest/services/dummy_service.d.ts.map +1 -1
  143. package/dest/services/dummy_service.js +4 -4
  144. package/dest/services/encoding.d.ts +6 -2
  145. package/dest/services/encoding.d.ts.map +1 -1
  146. package/dest/services/encoding.js +16 -9
  147. package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
  148. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  149. package/dest/services/gossipsub/topic_score_params.js +32 -10
  150. package/dest/services/libp2p/libp2p_service.d.ts +18 -20
  151. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  152. package/dest/services/libp2p/libp2p_service.js +190 -140
  153. package/dest/services/peer-manager/metrics.d.ts +3 -1
  154. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  155. package/dest/services/peer-manager/metrics.js +6 -0
  156. package/dest/services/peer-manager/peer_manager.d.ts +1 -1
  157. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  158. package/dest/services/peer-manager/peer_manager.js +6 -3
  159. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +12 -8
  160. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  161. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +83 -106
  162. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -7
  163. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  164. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -13
  165. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  166. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +31 -46
  167. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
  168. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  169. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
  170. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
  171. package/dest/services/reqresp/reqresp.d.ts +1 -1
  172. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  173. package/dest/services/reqresp/reqresp.js +19 -10
  174. package/dest/services/service.d.ts +5 -3
  175. package/dest/services/service.d.ts.map +1 -1
  176. package/dest/services/tx_collection/config.d.ts +13 -1
  177. package/dest/services/tx_collection/config.d.ts.map +1 -1
  178. package/dest/services/tx_collection/config.js +30 -0
  179. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
  180. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  181. package/dest/services/tx_collection/fast_tx_collection.js +65 -75
  182. package/dest/services/tx_collection/file_store_tx_collection.d.ts +38 -29
  183. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
  184. package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
  185. package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
  186. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  187. package/dest/services/tx_collection/file_store_tx_source.js +49 -16
  188. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  189. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  190. package/dest/services/tx_collection/instrumentation.js +2 -1
  191. package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -7
  192. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  193. package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
  194. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  195. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  196. package/dest/services/tx_collection/request_tracker.js +84 -0
  197. package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
  198. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  199. package/dest/services/tx_collection/slow_tx_collection.js +17 -12
  200. package/dest/services/tx_collection/tx_collection.d.ts +9 -9
  201. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  202. package/dest/services/tx_collection/tx_collection.js +26 -10
  203. package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
  204. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  205. package/dest/services/tx_collection/tx_collection_sink.js +13 -22
  206. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  207. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  208. package/dest/services/tx_collection/tx_source.js +19 -2
  209. package/dest/services/tx_file_store/tx_file_store.d.ts +3 -2
  210. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  211. package/dest/services/tx_file_store/tx_file_store.js +9 -6
  212. package/dest/services/tx_provider.d.ts +3 -3
  213. package/dest/services/tx_provider.d.ts.map +1 -1
  214. package/dest/services/tx_provider.js +4 -4
  215. package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
  216. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  217. package/dest/test-helpers/make-test-p2p-clients.js +1 -2
  218. package/dest/test-helpers/mock-pubsub.d.ts +4 -4
  219. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  220. package/dest/test-helpers/mock-pubsub.js +8 -2
  221. package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
  222. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  223. package/dest/test-helpers/reqresp-nodes.js +2 -2
  224. package/dest/test-helpers/testbench-utils.d.ts +8 -3
  225. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  226. package/dest/test-helpers/testbench-utils.js +29 -4
  227. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  228. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  229. package/dest/testbench/p2p_client_testbench_worker.js +15 -14
  230. package/dest/testbench/worker_client_manager.d.ts +3 -1
  231. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  232. package/dest/testbench/worker_client_manager.js +6 -2
  233. package/dest/util.d.ts +3 -3
  234. package/dest/util.d.ts.map +1 -1
  235. package/package.json +14 -14
  236. package/src/client/factory.ts +62 -47
  237. package/src/client/interface.ts +17 -20
  238. package/src/client/p2p_client.ts +74 -130
  239. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +18 -11
  240. package/src/config.ts +133 -43
  241. package/src/errors/tx-pool.error.ts +12 -0
  242. package/src/mem_pools/attestation_pool/attestation_pool.ts +16 -7
  243. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
  244. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  245. package/src/mem_pools/instrumentation.ts +17 -13
  246. package/src/mem_pools/tx_pool/README.md +1 -1
  247. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +2 -1
  248. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  249. package/src/mem_pools/tx_pool/priority.ts +4 -4
  250. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
  251. package/src/mem_pools/tx_pool_v2/README.md +52 -28
  252. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
  253. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
  254. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +7 -3
  255. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
  256. package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
  257. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
  258. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
  259. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
  260. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
  261. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
  262. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
  263. package/src/mem_pools/tx_pool_v2/index.ts +1 -1
  264. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  265. package/src/mem_pools/tx_pool_v2/interfaces.ts +30 -10
  266. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +156 -26
  267. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +58 -45
  268. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +34 -8
  269. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +353 -143
  270. package/src/msg_validators/attestation_validator/README.md +49 -0
  271. package/src/msg_validators/attestation_validator/attestation_validator.ts +5 -4
  272. package/src/msg_validators/clock_tolerance.ts +4 -3
  273. package/src/msg_validators/proposal_validator/README.md +123 -0
  274. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
  275. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
  276. package/src/msg_validators/proposal_validator/proposal_validator.ts +69 -45
  277. package/src/msg_validators/tx_validator/README.md +119 -0
  278. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
  279. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  280. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  281. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  282. package/src/msg_validators/tx_validator/data_validator.ts +42 -1
  283. package/src/msg_validators/tx_validator/factory.ts +394 -78
  284. package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
  285. package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
  286. package/src/msg_validators/tx_validator/index.ts +2 -0
  287. package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
  288. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  289. package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
  290. package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
  291. package/src/services/dummy_service.ts +6 -6
  292. package/src/services/encoding.ts +16 -8
  293. package/src/services/gossipsub/README.md +29 -14
  294. package/src/services/gossipsub/topic_score_params.ts +49 -13
  295. package/src/services/libp2p/libp2p_service.ts +198 -161
  296. package/src/services/peer-manager/metrics.ts +7 -0
  297. package/src/services/peer-manager/peer_manager.ts +7 -3
  298. package/src/services/reqresp/README.md +229 -0
  299. package/src/services/reqresp/batch-tx-requester/README.md +46 -7
  300. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +79 -112
  301. package/src/services/reqresp/batch-tx-requester/interface.ts +3 -6
  302. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
  303. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
  304. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
  305. package/src/services/reqresp/reqresp.ts +22 -12
  306. package/src/services/service.ts +11 -2
  307. package/src/services/tx_collection/config.ts +42 -0
  308. package/src/services/tx_collection/fast_tx_collection.ts +71 -76
  309. package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
  310. package/src/services/tx_collection/file_store_tx_source.ts +64 -17
  311. package/src/services/tx_collection/instrumentation.ts +7 -1
  312. package/src/services/tx_collection/proposal_tx_collector.ts +9 -13
  313. package/src/services/tx_collection/request_tracker.ts +127 -0
  314. package/src/services/tx_collection/slow_tx_collection.ts +17 -13
  315. package/src/services/tx_collection/tx_collection.ts +46 -17
  316. package/src/services/tx_collection/tx_collection_sink.ts +15 -29
  317. package/src/services/tx_collection/tx_source.ts +22 -3
  318. package/src/services/tx_file_store/tx_file_store.ts +6 -4
  319. package/src/services/tx_provider.ts +2 -2
  320. package/src/test-helpers/make-test-p2p-clients.ts +1 -3
  321. package/src/test-helpers/mock-pubsub.ts +13 -6
  322. package/src/test-helpers/reqresp-nodes.ts +3 -6
  323. package/src/test-helpers/testbench-utils.ts +40 -6
  324. package/src/testbench/p2p_client_testbench_worker.ts +22 -20
  325. package/src/testbench/worker_client_manager.ts +13 -5
  326. package/src/util.ts +8 -2
  327. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
  328. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
  329. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
  330. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
@@ -8,8 +8,7 @@ import type { L2Block } from '@aztec/stdlib/block';
8
8
  import { type L1RollupConstants, getEpochAtSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
9
9
  import { type Tx, TxHash } from '@aztec/stdlib/tx';
10
10
 
11
- import { type ReqRespInterface, ReqRespSubProtocol } from '../reqresp/interface.js';
12
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
11
+ import { type ReqRespInterface, ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
13
12
  import type { TxCollectionConfig } from './config.js';
14
13
  import type { FastTxCollection } from './fast_tx_collection.js';
15
14
  import type { MissingTxInfo } from './tx_collection.js';
@@ -120,8 +119,8 @@ export class SlowTxCollection {
120
119
  const txHashes = entries.map(([txHash]) => TxHash.fromString(txHash));
121
120
  for (const batch of chunk(txHashes, this.config.txCollectionNodeRpcMaxBatchSize)) {
122
121
  await this.txCollectionSink.collect(
123
- hashes => node.getTxsByHash(hashes),
124
- batch,
122
+ () => node.getTxsByHash(batch),
123
+ batch.map(h => h.toString()),
125
124
  {
126
125
  description: `node ${node.getInfo()}`,
127
126
  node: node.getInfo(),
@@ -166,18 +165,18 @@ export class SlowTxCollection {
166
165
  const txHashes = entries.map(([txHash]) => TxHash.fromString(txHash));
167
166
  const maxPeers = boundInclusive(Math.ceil(txHashes.length / 3), 4, 16);
168
167
  await this.txCollectionSink.collect(
169
- async hashes => {
168
+ async () => {
170
169
  const txs = await this.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
171
170
  ReqRespSubProtocol.TX,
172
- chunkTxHashesRequest(hashes),
171
+ chunkTxHashesRequest(txHashes),
173
172
  pinnedPeer,
174
173
  timeoutMs,
175
174
  maxPeers,
176
175
  maxRetryAttempts,
177
176
  );
178
- return txs.flat();
177
+ return { validTxs: txs.flat(), invalidTxHashes: [] };
179
178
  },
180
- txHashes,
179
+ txHashes.map(h => h.toString()),
181
180
  { description: 'slow reqresp', timeoutMs, method: 'slow-req-resp' },
182
181
  { type: 'mined', block },
183
182
  );
@@ -197,7 +196,7 @@ export class SlowTxCollection {
197
196
  // from mined unproven blocks it has seen in the past.
198
197
  const fastRequests = this.fastCollection.getFastCollectionRequests();
199
198
  const fastCollectionTxs: Set<string> = new Set(
200
- ...Array.from(fastRequests.values()).flatMap(r => r.missingTxHashes),
199
+ fastRequests.values().flatMap(r => Array.from(r.requestTracker.missingTxHashes)),
201
200
  );
202
201
 
203
202
  // Return all missing txs that are not in fastCollectionTxs and are ready for reqresp if requested
@@ -254,9 +253,14 @@ export class SlowTxCollection {
254
253
 
255
254
  /** Computes the proof submission deadline for a given slot, a tx mined in this slot is no longer interesting after this deadline */
256
255
  private getDeadlineForSlot(slotNumber: SlotNumber): Date {
257
- const epoch = getEpochAtSlot(slotNumber, this.constants);
258
- const submissionEndEpoch = EpochNumber(epoch + this.constants.proofSubmissionEpochs);
259
- const submissionEndTimestamp = getTimestampRangeForEpoch(submissionEndEpoch, this.constants)[1];
260
- return new Date(Number(submissionEndTimestamp) * 1000);
256
+ return getProofDeadlineForSlot(slotNumber, this.constants);
261
257
  }
262
258
  }
259
+
260
+ /** Computes the proof submission deadline for a given slot. A tx mined in this slot is no longer interesting after this deadline. */
261
+ export function getProofDeadlineForSlot(slotNumber: SlotNumber, constants: L1RollupConstants): Date {
262
+ const epoch = getEpochAtSlot(slotNumber, constants);
263
+ const submissionEndEpoch = EpochNumber(epoch + constants.proofSubmissionEpochs);
264
+ const submissionEndTimestamp = getTimestampRangeForEpoch(submissionEndEpoch, constants)[1];
265
+ return new Date(Number(submissionEndTimestamp) * 1000);
266
+ }
@@ -1,13 +1,14 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { compactArray } from '@aztec/foundation/collection';
3
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
- import { type PromiseWithResolvers, RunningPromise } from '@aztec/foundation/promise';
4
+ import { RunningPromise } from '@aztec/foundation/promise';
5
5
  import { sleep } from '@aztec/foundation/sleep';
6
6
  import { DateProvider } from '@aztec/foundation/timer';
7
7
  import type { L2Block, L2BlockInfo } from '@aztec/stdlib/block';
8
8
  import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
9
9
  import type { BlockProposal } from '@aztec/stdlib/p2p';
10
- import { Tx, TxHash } from '@aztec/stdlib/tx';
10
+ import type { Tx } from '@aztec/stdlib/tx';
11
+ import { TxHash } from '@aztec/stdlib/tx';
11
12
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
12
13
 
13
14
  import type { PeerId } from '@libp2p/interface';
@@ -18,7 +19,8 @@ import type { TxCollectionConfig } from './config.js';
18
19
  import { FastTxCollection } from './fast_tx_collection.js';
19
20
  import { FileStoreTxCollection } from './file_store_tx_collection.js';
20
21
  import type { FileStoreTxSource } from './file_store_tx_source.js';
21
- import { SlowTxCollection } from './slow_tx_collection.js';
22
+ import type { IRequestTracker } from './request_tracker.js';
23
+ import { SlowTxCollection, getProofDeadlineForSlot } from './slow_tx_collection.js';
22
24
  import { type TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
23
25
  import type { TxSource } from './tx_source.js';
24
26
 
@@ -31,11 +33,8 @@ export type FastCollectionRequestInput =
31
33
  | { type: 'proposal'; blockProposal: BlockProposal; blockNumber: BlockNumber };
32
34
 
33
35
  export type FastCollectionRequest = FastCollectionRequestInput & {
34
- missingTxHashes: Set<string>;
35
- deadline: Date;
36
+ requestTracker: IRequestTracker;
36
37
  blockInfo: L2BlockInfo;
37
- promise: PromiseWithResolvers<void>;
38
- foundTxs: Map<string, Tx>;
39
38
  };
40
39
 
41
40
  /**
@@ -56,8 +55,11 @@ export class TxCollection {
56
55
  /** Fast collection methods */
57
56
  protected readonly fastCollection: FastTxCollection;
58
57
 
59
- /** File store collection */
60
- protected readonly fileStoreCollection: FileStoreTxCollection;
58
+ /** File store collection for slow (mined block) path */
59
+ protected readonly fileStoreSlowCollection: FileStoreTxCollection;
60
+
61
+ /** File store collection for fast (proposal/proving) path */
62
+ protected readonly fileStoreFastCollection: FileStoreTxCollection;
61
63
 
62
64
  /** Loop for periodically reconciling found transactions from the tx pool in case we missed some */
63
65
  private readonly reconcileFoundTxsLoop: RunningPromise;
@@ -111,7 +113,28 @@ export class TxCollection {
111
113
  );
112
114
 
113
115
  this.hasFileStoreSources = fileStoreSources.length > 0;
114
- this.fileStoreCollection = new FileStoreTxCollection(fileStoreSources, this.txCollectionSink, this.log);
116
+ this.fileStoreSlowCollection = new FileStoreTxCollection(
117
+ fileStoreSources,
118
+ this.txCollectionSink,
119
+ {
120
+ workerCount: config.txCollectionFileStoreSlowWorkerCount,
121
+ backoffBaseMs: config.txCollectionFileStoreSlowBackoffBaseMs,
122
+ backoffMaxMs: config.txCollectionFileStoreSlowBackoffMaxMs,
123
+ },
124
+ this.dateProvider,
125
+ this.log,
126
+ );
127
+ this.fileStoreFastCollection = new FileStoreTxCollection(
128
+ fileStoreSources,
129
+ this.txCollectionSink,
130
+ {
131
+ workerCount: config.txCollectionFileStoreFastWorkerCount,
132
+ backoffBaseMs: config.txCollectionFileStoreFastBackoffBaseMs,
133
+ backoffMaxMs: config.txCollectionFileStoreFastBackoffMaxMs,
134
+ },
135
+ this.dateProvider,
136
+ this.log,
137
+ );
115
138
 
116
139
  this.reconcileFoundTxsLoop = new RunningPromise(
117
140
  () => this.reconcileFoundTxsWithPool(),
@@ -137,7 +160,8 @@ export class TxCollection {
137
160
  public start(): Promise<void> {
138
161
  this.started = true;
139
162
  this.slowCollection.start();
140
- this.fileStoreCollection.start();
163
+ this.fileStoreSlowCollection.start();
164
+ this.fileStoreFastCollection.start();
141
165
  this.reconcileFoundTxsLoop.start();
142
166
 
143
167
  // TODO(palla/txs): Collect mined unproven tx hashes for txs we dont have in the pool and populate missingTxs on startup
@@ -150,7 +174,8 @@ export class TxCollection {
150
174
  await Promise.all([
151
175
  this.slowCollection.stop(),
152
176
  this.fastCollection.stop(),
153
- this.fileStoreCollection.stop(),
177
+ this.fileStoreSlowCollection.stop(),
178
+ this.fileStoreFastCollection.stop(),
154
179
  this.reconcileFoundTxsLoop.stop(),
155
180
  ]);
156
181
 
@@ -175,6 +200,7 @@ export class TxCollection {
175
200
  // Delay file store collection to give P2P methods time to find txs first
176
201
  if (this.hasFileStoreSources) {
177
202
  const context: TxAddContext = { type: 'mined', block };
203
+ const deadline = getProofDeadlineForSlot(block.header.getSlot(), this.constants);
178
204
  sleep(this.config.txCollectionFileStoreSlowDelayMs)
179
205
  .then(() => {
180
206
  if (this.started) {
@@ -182,7 +208,7 @@ export class TxCollection {
182
208
  const stillMissing = new Set(this.slowCollection.getMissingTxHashes().map(h => h.toString()));
183
209
  const remaining = txHashes.filter(h => stillMissing.has(h.toString()));
184
210
  if (remaining.length > 0) {
185
- this.fileStoreCollection.startCollecting(remaining, context);
211
+ this.fileStoreSlowCollection.startCollecting(remaining, context, deadline);
186
212
  }
187
213
  }
188
214
  })
@@ -223,7 +249,7 @@ export class TxCollection {
223
249
  sleep(this.config.txCollectionFileStoreFastDelayMs)
224
250
  .then(() => {
225
251
  if (this.started) {
226
- this.fileStoreCollection.startCollecting(hashes, context);
252
+ this.fileStoreFastCollection.startCollecting(hashes, context, opts.deadline);
227
253
  }
228
254
  })
229
255
  .catch(err => this.log.error('Error in file store fast delay', err));
@@ -245,7 +271,8 @@ export class TxCollection {
245
271
  private foundTxs(txs: Tx[]) {
246
272
  this.slowCollection.foundTxs(txs);
247
273
  this.fastCollection.foundTxs(txs);
248
- this.fileStoreCollection.foundTxs(txs);
274
+ this.fileStoreSlowCollection.foundTxs(txs);
275
+ this.fileStoreFastCollection.foundTxs(txs);
249
276
  }
250
277
 
251
278
  /**
@@ -255,7 +282,8 @@ export class TxCollection {
255
282
  public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
256
283
  this.slowCollection.stopCollectingForBlocksUpTo(blockNumber);
257
284
  this.fastCollection.stopCollectingForBlocksUpTo(blockNumber);
258
- this.fileStoreCollection.clearPending();
285
+ this.fileStoreSlowCollection.clearPending();
286
+ this.fileStoreFastCollection.clearPending();
259
287
  }
260
288
 
261
289
  /**
@@ -265,7 +293,8 @@ export class TxCollection {
265
293
  public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
266
294
  this.slowCollection.stopCollectingForBlocksAfter(blockNumber);
267
295
  this.fastCollection.stopCollectingForBlocksAfter(blockNumber);
268
- this.fileStoreCollection.clearPending();
296
+ this.fileStoreSlowCollection.clearPending();
297
+ this.fileStoreFastCollection.clearPending();
269
298
  }
270
299
 
271
300
  /** Every now and then, check if the pool has received one of the txs we are looking for, just to catch any race conditions */
@@ -2,14 +2,15 @@ import type { Logger } from '@aztec/foundation/log';
2
2
  import { elapsed } from '@aztec/foundation/timer';
3
3
  import type { TypedEventEmitter } from '@aztec/foundation/types';
4
4
  import type { L2Block } from '@aztec/stdlib/block';
5
- import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
5
+ import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
6
6
  import type { TelemetryClient } from '@aztec/telemetry-client';
7
7
 
8
8
  import EventEmitter from 'node:events';
9
9
 
10
- import type { TxPoolV2, TxPoolV2Events } from '../../mem_pools/tx_pool_v2/interfaces.js';
10
+ import type { TxPoolV2, TxPoolV2Events } from '../../mem_pools/index.js';
11
11
  import { TxCollectionInstrumentation } from './instrumentation.js';
12
12
  import type { CollectionMethod } from './tx_collection.js';
13
+ import type { TxSourceCollectionResult } from './tx_source.js';
13
14
 
14
15
  /** Context determining how collected txs should be added to the pool. */
15
16
  export type TxAddContext = { type: 'proposal'; blockHeader: BlockHeader } | { type: 'mined'; block: L2Block };
@@ -31,52 +32,37 @@ export class TxCollectionSink extends (EventEmitter as new () => TypedEventEmitt
31
32
  }
32
33
 
33
34
  public async collect(
34
- collectValidTxsFn: (txHashes: TxHash[]) => Promise<(Tx | undefined)[]>,
35
- requested: TxHash[],
35
+ collectValidTxsFn: () => Promise<TxSourceCollectionResult>,
36
+ requested: string[],
36
37
  info: Record<string, any> & { description: string; method: CollectionMethod },
37
38
  context: TxAddContext,
38
39
  ) {
39
40
  this.log.trace(`Requesting ${requested.length} txs via ${info.description}`, {
40
41
  ...info,
41
- requestedTxs: requested.map(t => t.toString()),
42
+ requestedTxs: requested,
42
43
  });
43
44
 
44
45
  // Execute collection function and measure the time taken, catching any errors.
45
- const [duration, txs] = await elapsed(async () => {
46
+ const [duration, { validTxs, invalidTxHashes }] = await elapsed(async () => {
46
47
  try {
47
- const response = await collectValidTxsFn(requested);
48
- return response.filter(tx => tx !== undefined);
48
+ return await collectValidTxsFn();
49
49
  } catch (err) {
50
50
  this.log.error(`Error collecting txs via ${info.description}`, err, {
51
51
  ...info,
52
- requestedTxs: requested.map(hash => hash.toString()),
52
+ requestedTxs: requested,
53
53
  });
54
- return [] as Tx[];
54
+ return { validTxs: [] as Tx[], invalidTxHashes: [] as string[] };
55
55
  }
56
56
  });
57
57
 
58
- if (txs.length === 0) {
58
+ if (validTxs.length === 0 && invalidTxHashes.length === 0) {
59
59
  this.log.trace(`No txs found via ${info.description}`, {
60
60
  ...info,
61
- requestedTxs: requested.map(t => t.toString()),
61
+ requestedTxs: requested,
62
62
  });
63
- return { txs, requested, duration };
63
+ return { txs: validTxs, requested, duration };
64
64
  }
65
65
 
66
- // Validate tx hashes for all collected txs from external sources
67
- const validTxs: Tx[] = [];
68
- const invalidTxHashes: string[] = [];
69
- await Promise.all(
70
- txs.map(async tx => {
71
- const isValid = await tx.validateTxHash();
72
- if (isValid) {
73
- validTxs.push(tx);
74
- } else {
75
- invalidTxHashes.push(tx.getTxHash().toString());
76
- }
77
- }),
78
- );
79
-
80
66
  if (invalidTxHashes.length > 0) {
81
67
  this.log.warn(`Rejecting ${invalidTxHashes.length} txs with invalid hashes from ${info.description}`, {
82
68
  ...info,
@@ -87,7 +73,7 @@ export class TxCollectionSink extends (EventEmitter as new () => TypedEventEmitt
87
73
  if (validTxs.length === 0) {
88
74
  this.log.trace(`No valid txs found via ${info.description} after validation`, {
89
75
  ...info,
90
- requestedTxs: requested.map(t => t.toString()),
76
+ requestedTxs: requested,
91
77
  invalidTxHashes,
92
78
  });
93
79
  return { txs: [], requested, duration };
@@ -99,7 +85,7 @@ export class TxCollectionSink extends (EventEmitter as new () => TypedEventEmitt
99
85
  ...info,
100
86
  duration,
101
87
  txs: validTxs.map(t => t.getTxHash().toString()),
102
- requestedTxs: requested.map(t => t.toString()),
88
+ requestedTxs: requested,
103
89
  rejectedCount: invalidTxHashes.length,
104
90
  },
105
91
  );
@@ -6,9 +6,11 @@ import type { Tx, TxHash } from '@aztec/stdlib/tx';
6
6
  import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
7
7
  import { makeTracedFetch } from '@aztec/telemetry-client';
8
8
 
9
+ export type TxSourceCollectionResult = { validTxs: Tx[]; invalidTxHashes: string[] };
10
+
9
11
  export interface TxSource {
10
12
  getInfo(): string;
11
- getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
13
+ getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult>;
12
14
  }
13
15
 
14
16
  export class NodeRpcTxSource implements TxSource {
@@ -26,8 +28,25 @@ export class NodeRpcTxSource implements TxSource {
26
28
  return this.info;
27
29
  }
28
30
 
29
- public getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
30
- return this.client.getTxsByHash(txHashes);
31
+ public async getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult> {
32
+ return this.verifyTxs(await this.client.getTxsByHash(txHashes));
33
+ }
34
+
35
+ private async verifyTxs(txs: Tx[]): Promise<TxSourceCollectionResult> {
36
+ // Validate tx hashes for all collected txs from external sources
37
+ const validTxs: Tx[] = [];
38
+ const invalidTxHashes: string[] = [];
39
+ await Promise.all(
40
+ txs.map(async tx => {
41
+ const isValid = await tx.validateTxHash();
42
+ if (isValid) {
43
+ validTxs.push(tx);
44
+ } else {
45
+ invalidTxHashes.push(tx.getTxHash().toString());
46
+ }
47
+ }),
48
+ );
49
+ return { validTxs: validTxs, invalidTxHashes: invalidTxHashes };
31
50
  }
32
51
  }
33
52
 
@@ -31,6 +31,7 @@ export class TxFileStore {
31
31
  private readonly config: TxFileStoreConfig,
32
32
  private readonly instrumentation: TxFileStoreInstrumentation,
33
33
  private readonly log: Logger,
34
+ private readonly basePath: string,
34
35
  ) {
35
36
  this.handleTxsAdded = (args: { txs: Tx[]; source?: string }) => {
36
37
  this.enqueueTxs(args.txs);
@@ -50,6 +51,7 @@ export class TxFileStore {
50
51
  static async create(
51
52
  txPool: TxPoolV2,
52
53
  config: TxFileStoreConfig,
54
+ basePath: string,
53
55
  log: Logger = createLogger('p2p:tx_file_store'),
54
56
  telemetry: TelemetryClient = getTelemetryClient(),
55
57
  fileStoreOverride?: FileStore,
@@ -71,8 +73,8 @@ export class TxFileStore {
71
73
  }
72
74
 
73
75
  const instrumentation = new TxFileStoreInstrumentation(telemetry, 'TxFileStore');
74
- log.info('Created tx file store', { url: config.txFileStoreUrl });
75
- return new TxFileStore(fileStore, txPool, config, instrumentation, log);
76
+ log.info('Created tx file store', { url: config.txFileStoreUrl, basePath });
77
+ return new TxFileStore(fileStore, txPool, config, instrumentation, log, basePath);
76
78
  }
77
79
 
78
80
  /** Starts listening to TxPool events and uploading txs. */
@@ -122,7 +124,7 @@ export class TxFileStore {
122
124
 
123
125
  private async uploadTx(tx: Tx): Promise<void> {
124
126
  const txHash = tx.getTxHash().toString();
125
- const path = `txs/${txHash}.bin`;
127
+ const path = `${this.basePath}/txs/${txHash}.bin`;
126
128
  const timer = new Timer();
127
129
 
128
130
  if (this.recentUploads.has(txHash)) {
@@ -144,7 +146,7 @@ export class TxFileStore {
144
146
  }
145
147
 
146
148
  await retry(
147
- () => this.fileStore.save(path, tx.toBuffer(), { compress: false }),
149
+ () => this.fileStore.save(path, tx.toBuffer(), { compress: true }),
148
150
  `Uploading tx ${txHash}`,
149
151
  makeBackoff([0.1, 0.5, 2]),
150
152
  this.log,
@@ -25,7 +25,7 @@ export class TxProvider implements ITxProvider {
25
25
  constructor(
26
26
  private txCollection: TxCollection,
27
27
  private txPool: TxPoolV2,
28
- private txValidator: Pick<P2PClient, 'validate'>,
28
+ private blockProposalTransactionValidator: Pick<P2PClient, 'validateTxsReceivedInBlockProposal'>,
29
29
  private log: Logger = createLogger('p2p:tx-collector'),
30
30
  client: TelemetryClient = getTelemetryClient(),
31
31
  ) {
@@ -227,7 +227,7 @@ export class TxProvider implements ITxProvider {
227
227
  if (txs.length === 0) {
228
228
  return;
229
229
  }
230
- await this.txValidator.validate(txs);
230
+ await this.blockProposalTransactionValidator.validateTxsReceivedInBlockProposal(txs);
231
231
  await this.txPool.addProtectedTxs(txs, blockHeader);
232
232
  }
233
233
  }
@@ -4,10 +4,9 @@ import { SecretValue } from '@aztec/foundation/config';
4
4
  import { type Logger, createLogger } from '@aztec/foundation/log';
5
5
  import { retryUntil } from '@aztec/foundation/retry';
6
6
  import { sleep } from '@aztec/foundation/sleep';
7
- import type { DataStoreConfig } from '@aztec/kv-store/config';
8
7
  import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
9
8
  import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
10
- import { P2PClientType } from '@aztec/stdlib/p2p';
9
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
11
10
 
12
11
  import { createP2PClient } from '../client/index.js';
13
12
  import type { P2PClient } from '../client/p2p_client.js';
@@ -98,7 +97,6 @@ export async function makeTestP2PClient(
98
97
  const kvStore = await openTmpStore('test');
99
98
 
100
99
  const client = await createP2PClient(
101
- P2PClientType.Full,
102
100
  config,
103
101
  l2BlockSource,
104
102
  proofVerifier,
@@ -4,7 +4,6 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
4
  import type { L2BlockSource } from '@aztec/stdlib/block';
5
5
  import type { ContractDataSource } from '@aztec/stdlib/contract';
6
6
  import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
7
- import { P2PClientType } from '@aztec/stdlib/p2p';
8
7
  import type { TelemetryClient } from '@aztec/telemetry-client';
9
8
 
10
9
  import type { GossipsubEvents, GossipsubMessage } from '@chainsafe/libp2p-gossipsub';
@@ -42,11 +41,10 @@ type GossipSubService = PubSubLibp2p['services']['pubsub'];
42
41
  * Given a mock gossip sub network, returns a factory function that creates an instance LibP2PService connected to it.
43
42
  * Designed to be used in tests in P2PClientDeps.p2pServiceFactory.
44
43
  */
45
- export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
44
+ export function getMockPubSubP2PServiceFactory(
46
45
  network: MockGossipSubNetwork,
47
- ): (...args: Parameters<(typeof LibP2PService<T>)['new']>) => Promise<LibP2PService<T>> {
46
+ ): (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService> {
48
47
  return (
49
- clientType: P2PClientType,
50
48
  config: P2PConfig,
51
49
  peerId: PeerId,
52
50
  deps: {
@@ -66,8 +64,7 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
66
64
  const peerManager = new DummyPeerManager(peerId, network);
67
65
  const reqresp: ReqRespInterface = new MockReqResp(peerId, network);
68
66
  const peerDiscoveryService = new DummyPeerDiscoveryService();
69
- const service = new LibP2PService<T>(
70
- clientType as T,
67
+ const service = new LibP2PService(
71
68
  config,
72
69
  libp2p,
73
70
  peerDiscoveryService,
@@ -270,6 +267,16 @@ class MockGossipSubService extends TypedEventEmitter<GossipsubEvents> implements
270
267
  { msgId, propagationSource, acceptance },
271
268
  );
272
269
  }
270
+
271
+ getMeshPeers(topic?: TopicStr): PeerIdStr[] {
272
+ if (topic && !this.subscribedTopics.has(topic)) {
273
+ return [];
274
+ }
275
+ return this.network
276
+ .getPeers()
277
+ .filter(peer => !this.peerId.equals(peer))
278
+ .map(peer => peer.toString());
279
+ }
273
280
  }
274
281
 
275
282
  /**
@@ -2,7 +2,6 @@ import type { EpochCache } from '@aztec/epoch-cache';
2
2
  import { timesParallel } from '@aztec/foundation/collection';
3
3
  import { SecretValue } from '@aztec/foundation/config';
4
4
  import { createLogger } from '@aztec/foundation/log';
5
- import type { DataStoreConfig } from '@aztec/kv-store/config';
6
5
  import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
7
6
  import type { L2BlockSource } from '@aztec/stdlib/block';
8
7
  import { type ChainConfig, emptyChainConfig } from '@aztec/stdlib/config';
@@ -12,7 +11,7 @@ import type {
12
11
  IVCProofVerificationResult,
13
12
  WorldStateSynchronizer,
14
13
  } from '@aztec/stdlib/interfaces/server';
15
- import type { P2PClientType } from '@aztec/stdlib/p2p';
14
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
16
15
  import type { Tx } from '@aztec/stdlib/tx';
17
16
  import { compressComponentVersions } from '@aztec/stdlib/versioning';
18
17
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
@@ -107,8 +106,7 @@ export async function createLibp2pNode(
107
106
  *
108
107
  *
109
108
  */
110
- export async function createTestLibP2PService<T extends P2PClientType>(
111
- clientType: T,
109
+ export async function createTestLibP2PService(
112
110
  boostrapAddrs: string[] = [],
113
111
  archiver: L2BlockSource & ContractDataSource,
114
112
  worldStateSynchronizer: WorldStateSynchronizer,
@@ -159,8 +157,7 @@ export async function createTestLibP2PService<T extends P2PClientType>(
159
157
  p2pNode.services.pubsub.score.params.appSpecificScore = (peerId: string) =>
160
158
  peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
161
159
 
162
- return new LibP2PService<T>(
163
- clientType,
160
+ return new LibP2PService(
164
161
  config,
165
162
  p2pNode as PubSubLibp2p,
166
163
  discoveryService,
@@ -59,7 +59,7 @@ export class InMemoryTxPool extends EventEmitter implements TxPoolV2 {
59
59
 
60
60
  // === Core Operations (TxPoolV2) ===
61
61
 
62
- addPendingTxs(txs: Tx[], opts?: { source?: string }): Promise<AddTxsResult> {
62
+ addPendingTxs(txs: Tx[], opts?: { source?: string; feeComparisonOnly?: boolean }): Promise<AddTxsResult> {
63
63
  const accepted: TxHash[] = [];
64
64
  const newTxs: Tx[] = [];
65
65
  for (const tx of txs) {
@@ -76,7 +76,7 @@ export class InMemoryTxPool extends EventEmitter implements TxPoolV2 {
76
76
  return Promise.resolve({ accepted, ignored: [], rejected: [] });
77
77
  }
78
78
 
79
- canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored' | 'rejected'> {
79
+ canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'> {
80
80
  const key = tx.getTxHash().toString();
81
81
  if (this.txsByHash.has(key)) {
82
82
  return Promise.resolve('ignored');
@@ -123,7 +123,7 @@ export class InMemoryTxPool extends EventEmitter implements TxPoolV2 {
123
123
  return Promise.resolve();
124
124
  }
125
125
 
126
- handlePrunedBlocks(_latestBlock: L2BlockId): Promise<void> {
126
+ handlePrunedBlocks(_latestBlock: L2BlockId, _options?: { deleteAllTxs?: boolean }): Promise<void> {
127
127
  return Promise.resolve();
128
128
  }
129
129
 
@@ -163,6 +163,10 @@ export class InMemoryTxPool extends EventEmitter implements TxPoolV2 {
163
163
  return Promise.resolve([...this.txsByHash.keys()].map(key => TxHash.fromString(key)));
164
164
  }
165
165
 
166
+ getEligiblePendingTxHashes(): Promise<TxHash[]> {
167
+ return this.getPendingTxHashes();
168
+ }
169
+
166
170
  getPendingTxCount(): Promise<number> {
167
171
  return Promise.resolve(this.txsByHash.size);
168
172
  }
@@ -252,6 +256,10 @@ export class InMemoryAttestationPool {
252
256
  return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
253
257
  }
254
258
 
259
+ hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
260
+ return Promise.resolve(false);
261
+ }
262
+
255
263
  isEmpty(): Promise<boolean> {
256
264
  return Promise.resolve(this.proposals.size === 0);
257
265
  }
@@ -265,17 +273,41 @@ export class InMemoryAttestationPool {
265
273
  * Creates a mock EpochCache for testing.
266
274
  */
267
275
  export function createMockEpochCache(): EpochCacheInterface {
268
- return {
276
+ const cache: EpochCacheInterface = {
269
277
  getCommittee: () => Promise.resolve({ committee: [], seed: 1n, epoch: EpochNumber.ZERO, isEscapeHatchOpen: false }),
270
278
  getProposerIndexEncoding: () => '0x' as `0x${string}`,
271
- getEpochAndSlotNow: () => ({ epoch: EpochNumber.ZERO, slot: SlotNumber.ZERO, ts: 0n, nowMs: 0n }),
279
+ getSlotNow: () => SlotNumber.ZERO,
280
+ getTargetSlot: () => SlotNumber.ZERO,
281
+ getEpochNow: () => EpochNumber.ZERO,
282
+ getTargetEpoch: () => EpochNumber.ZERO,
283
+ getEpochAndSlotNow: () => ({
284
+ epoch: EpochNumber.ZERO,
285
+ slot: SlotNumber.ZERO,
286
+ ts: 0n,
287
+ nowMs: 0n,
288
+ }),
289
+ isProposerPipeliningEnabled: () => false,
272
290
  computeProposerIndex: () => 0n,
273
291
  getCurrentAndNextSlot: () => ({ currentSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
292
+ getTargetAndNextSlot: () => ({ targetSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
274
293
  getProposerAttesterAddressInSlot: () => Promise.resolve(undefined),
275
- getEpochAndSlotInNextL1Slot: () => ({ epoch: EpochNumber.ZERO, slot: SlotNumber.ZERO, ts: 0n, now: 0n }),
294
+ getEpochAndSlotInNextL1Slot: () => ({
295
+ epoch: EpochNumber.ZERO,
296
+ slot: SlotNumber.ZERO,
297
+ ts: 0n,
298
+ nowSeconds: 0n,
299
+ }),
300
+ getTargetEpochAndSlotInNextL1Slot: () => ({
301
+ epoch: EpochNumber.ZERO,
302
+ slot: SlotNumber.ZERO,
303
+ ts: 0n,
304
+ nowSeconds: 0n,
305
+ }),
276
306
  isInCommittee: () => Promise.resolve(false),
277
307
  getRegisteredValidators: () => Promise.resolve([]),
278
308
  filterInCommittee: () => Promise.resolve([]),
309
+ isEscapeHatchOpen: () => Promise.resolve(false),
310
+ isEscapeHatchOpenAtSlot: () => Promise.resolve(false),
279
311
  getL1Constants: () => ({
280
312
  l1StartBlock: 0n,
281
313
  l1GenesisTime: 0n,
@@ -284,8 +316,10 @@ export function createMockEpochCache(): EpochCacheInterface {
284
316
  ethereumSlotDuration: 1,
285
317
  proofSubmissionEpochs: 1,
286
318
  targetCommitteeSize: 48,
319
+ rollupManaLimit: Number.MAX_SAFE_INTEGER,
287
320
  }),
288
321
  };
322
+ return cache;
289
323
  }
290
324
 
291
325
  /**