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

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 (407) hide show
  1. package/dest/bootstrap/bootstrap.d.ts +4 -3
  2. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  3. package/dest/bootstrap/bootstrap.js +4 -4
  4. package/dest/client/factory.d.ts +3 -3
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +11 -8
  7. package/dest/client/interface.d.ts +9 -2
  8. package/dest/client/interface.d.ts.map +1 -1
  9. package/dest/client/p2p_client.d.ts +7 -4
  10. package/dest/client/p2p_client.d.ts.map +1 -1
  11. package/dest/client/p2p_client.js +24 -7
  12. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
  13. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
  14. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
  15. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
  16. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
  17. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
  18. package/dest/config.d.ts +16 -3
  19. package/dest/config.d.ts.map +1 -1
  20. package/dest/config.js +7 -2
  21. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +94 -87
  22. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  23. package/dest/mem_pools/attestation_pool/attestation_pool.js +411 -3
  24. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  25. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  26. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +351 -85
  27. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  28. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  29. package/dest/mem_pools/attestation_pool/index.js +1 -2
  30. package/dest/mem_pools/index.d.ts +2 -2
  31. package/dest/mem_pools/index.d.ts.map +1 -1
  32. package/dest/mem_pools/index.js +1 -1
  33. package/dest/mem_pools/instrumentation.d.ts +1 -1
  34. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  35. package/dest/mem_pools/instrumentation.js +2 -2
  36. package/dest/mem_pools/interface.d.ts +3 -3
  37. package/dest/mem_pools/interface.d.ts.map +1 -1
  38. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
  39. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
  41. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
  42. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
  43. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
  44. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
  45. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  46. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +8 -1
  47. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
  48. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
  50. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  51. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  52. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  53. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  54. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  55. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  56. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  58. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
  59. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  60. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  61. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  76. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
  77. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  78. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  79. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
  80. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  81. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  82. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
  83. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  84. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  85. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  86. package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
  87. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  88. package/dest/mem_pools/tx_pool_v2/index.js +4 -0
  89. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
  90. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  91. package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
  92. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
  93. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  94. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +95 -0
  95. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  96. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  97. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  98. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
  99. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  100. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
  101. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
  102. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  103. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
  104. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
  105. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  106. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +748 -0
  107. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
  108. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  109. package/dest/msg_validators/attestation_validator/attestation_validator.js +41 -10
  110. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
  111. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  112. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -6
  113. package/dest/msg_validators/clock_tolerance.d.ts +21 -0
  114. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  115. package/dest/msg_validators/clock_tolerance.js +37 -0
  116. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
  117. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  118. package/dest/msg_validators/proposal_validator/proposal_validator.js +55 -31
  119. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
  120. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
  121. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +93 -64
  122. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  123. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  124. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  125. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +5 -4
  126. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  127. package/dest/msg_validators/tx_validator/block_header_validator.js +3 -2
  128. package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
  129. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  130. package/dest/msg_validators/tx_validator/data_validator.js +4 -1
  131. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -2
  132. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  133. package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -2
  134. package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
  135. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  136. package/dest/msg_validators/tx_validator/factory.js +21 -11
  137. package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
  138. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  139. package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
  140. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  141. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  142. package/dest/msg_validators/tx_validator/index.js +1 -0
  143. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
  144. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  145. package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
  146. package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
  147. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  148. package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
  149. package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
  150. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
  151. package/dest/msg_validators/tx_validator/size_validator.js +23 -0
  152. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
  153. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  154. package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
  155. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  156. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  157. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  158. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
  159. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  160. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
  161. package/dest/services/data_store.d.ts +1 -1
  162. package/dest/services/data_store.d.ts.map +1 -1
  163. package/dest/services/data_store.js +10 -6
  164. package/dest/services/discv5/discV5_service.js +1 -1
  165. package/dest/services/dummy_service.d.ts +18 -2
  166. package/dest/services/dummy_service.d.ts.map +1 -1
  167. package/dest/services/dummy_service.js +42 -0
  168. package/dest/services/encoding.d.ts +1 -1
  169. package/dest/services/encoding.d.ts.map +1 -1
  170. package/dest/services/encoding.js +2 -3
  171. package/dest/services/gossipsub/index.d.ts +3 -0
  172. package/dest/services/gossipsub/index.d.ts.map +1 -0
  173. package/dest/services/gossipsub/index.js +2 -0
  174. package/dest/services/gossipsub/scoring.d.ts +21 -3
  175. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  176. package/dest/services/gossipsub/scoring.js +24 -7
  177. package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
  178. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  179. package/dest/services/gossipsub/topic_score_params.js +324 -0
  180. package/dest/services/index.d.ts +2 -1
  181. package/dest/services/index.d.ts.map +1 -1
  182. package/dest/services/index.js +1 -0
  183. package/dest/services/libp2p/instrumentation.d.ts +1 -1
  184. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  185. package/dest/services/libp2p/instrumentation.js +14 -3
  186. package/dest/services/libp2p/libp2p_service.d.ts +81 -34
  187. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  188. package/dest/services/libp2p/libp2p_service.js +356 -288
  189. package/dest/services/peer-manager/metrics.d.ts +2 -2
  190. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  191. package/dest/services/peer-manager/metrics.js +20 -5
  192. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  193. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  194. package/dest/services/peer-manager/peer_scoring.js +33 -4
  195. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
  196. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  197. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
  198. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  199. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  200. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  201. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
  202. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  203. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  204. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
  205. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  206. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
  207. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
  208. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  209. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
  210. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
  211. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  212. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
  213. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
  214. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  215. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
  216. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
  217. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  218. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  219. package/dest/services/reqresp/interface.d.ts +5 -3
  220. package/dest/services/reqresp/interface.d.ts.map +1 -1
  221. package/dest/services/reqresp/interface.js +2 -2
  222. package/dest/services/reqresp/metrics.d.ts +6 -5
  223. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  224. package/dest/services/reqresp/metrics.js +17 -5
  225. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
  226. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  227. package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
  228. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +6 -4
  229. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  230. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
  231. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +23 -6
  232. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  233. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +44 -13
  234. package/dest/services/reqresp/reqresp.d.ts +6 -1
  235. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  236. package/dest/services/reqresp/reqresp.js +58 -22
  237. package/dest/services/service.d.ts +21 -1
  238. package/dest/services/service.d.ts.map +1 -1
  239. package/dest/services/tx_collection/config.d.ts +4 -1
  240. package/dest/services/tx_collection/config.d.ts.map +1 -1
  241. package/dest/services/tx_collection/config.js +9 -1
  242. package/dest/services/tx_collection/fast_tx_collection.d.ts +5 -4
  243. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  244. package/dest/services/tx_collection/fast_tx_collection.js +17 -10
  245. package/dest/services/tx_collection/index.d.ts +2 -1
  246. package/dest/services/tx_collection/index.d.ts.map +1 -1
  247. package/dest/services/tx_collection/index.js +1 -0
  248. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  249. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  250. package/dest/services/tx_collection/instrumentation.js +9 -2
  251. package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
  252. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
  253. package/dest/services/tx_collection/proposal_tx_collector.js +49 -0
  254. package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -3
  255. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  256. package/dest/services/tx_collection/tx_collection.d.ts +8 -8
  257. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  258. package/dest/services/tx_collection/tx_collection.js +5 -5
  259. package/dest/services/tx_file_store/config.d.ts +18 -0
  260. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  261. package/dest/services/tx_file_store/config.js +26 -0
  262. package/dest/services/tx_file_store/index.d.ts +4 -0
  263. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  264. package/dest/services/tx_file_store/index.js +3 -0
  265. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  266. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  267. package/dest/services/tx_file_store/instrumentation.js +29 -0
  268. package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
  269. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  270. package/dest/services/tx_file_store/tx_file_store.js +149 -0
  271. package/dest/services/tx_provider.d.ts +3 -3
  272. package/dest/services/tx_provider.d.ts.map +1 -1
  273. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  274. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  275. package/dest/services/tx_provider_instrumentation.js +5 -5
  276. package/dest/test-helpers/index.d.ts +3 -1
  277. package/dest/test-helpers/index.d.ts.map +1 -1
  278. package/dest/test-helpers/index.js +2 -0
  279. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  280. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  281. package/dest/test-helpers/reqresp-nodes.js +2 -1
  282. package/dest/test-helpers/test_tx_provider.d.ts +40 -0
  283. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  284. package/dest/test-helpers/test_tx_provider.js +41 -0
  285. package/dest/test-helpers/testbench-utils.d.ts +152 -0
  286. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  287. package/dest/test-helpers/testbench-utils.js +308 -0
  288. package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
  289. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  290. package/dest/testbench/p2p_client_testbench_worker.js +212 -133
  291. package/dest/testbench/worker_client_manager.d.ts +51 -6
  292. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  293. package/dest/testbench/worker_client_manager.js +226 -44
  294. package/package.json +14 -14
  295. package/src/bootstrap/bootstrap.ts +7 -4
  296. package/src/client/factory.ts +13 -14
  297. package/src/client/interface.ts +13 -1
  298. package/src/client/p2p_client.ts +37 -13
  299. package/src/client/test/tx_proposal_collector/README.md +227 -0
  300. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
  301. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
  302. package/src/config.ts +22 -2
  303. package/src/mem_pools/attestation_pool/attestation_pool.ts +444 -90
  304. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +436 -100
  305. package/src/mem_pools/attestation_pool/index.ts +9 -2
  306. package/src/mem_pools/index.ts +1 -1
  307. package/src/mem_pools/instrumentation.ts +2 -1
  308. package/src/mem_pools/interface.ts +2 -2
  309. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
  310. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
  311. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
  312. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
  313. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
  314. package/src/mem_pools/tx_pool_v2/README.md +209 -0
  315. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  316. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  317. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
  318. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
  319. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
  320. package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
  321. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
  322. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  323. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  324. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
  325. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
  326. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  327. package/src/mem_pools/tx_pool_v2/index.ts +11 -0
  328. package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
  329. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +161 -0
  330. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  331. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
  332. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
  333. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +882 -0
  334. package/src/msg_validators/attestation_validator/attestation_validator.ts +26 -14
  335. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +16 -10
  336. package/src/msg_validators/clock_tolerance.ts +51 -0
  337. package/src/msg_validators/proposal_validator/proposal_validator.ts +31 -31
  338. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +91 -67
  339. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  340. package/src/msg_validators/tx_validator/block_header_validator.ts +6 -5
  341. package/src/msg_validators/tx_validator/data_validator.ts +6 -2
  342. package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
  343. package/src/msg_validators/tx_validator/factory.ts +64 -23
  344. package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
  345. package/src/msg_validators/tx_validator/index.ts +1 -0
  346. package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
  347. package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
  348. package/src/msg_validators/tx_validator/size_validator.ts +22 -0
  349. package/src/msg_validators/tx_validator/timestamp_validator.ts +6 -3
  350. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  351. package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
  352. package/src/services/data_store.ts +10 -7
  353. package/src/services/discv5/discV5_service.ts +1 -1
  354. package/src/services/dummy_service.ts +51 -0
  355. package/src/services/encoding.ts +2 -3
  356. package/src/services/gossipsub/README.md +626 -0
  357. package/src/services/gossipsub/index.ts +2 -0
  358. package/src/services/gossipsub/scoring.ts +29 -5
  359. package/src/services/gossipsub/topic_score_params.ts +451 -0
  360. package/src/services/index.ts +1 -0
  361. package/src/services/libp2p/instrumentation.ts +15 -2
  362. package/src/services/libp2p/libp2p_service.ts +390 -302
  363. package/src/services/peer-manager/metrics.ts +21 -4
  364. package/src/services/peer-manager/peer_scoring.ts +29 -1
  365. package/src/services/reqresp/batch-tx-requester/README.md +305 -0
  366. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
  367. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  368. package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
  369. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
  370. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
  371. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
  372. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
  373. package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
  374. package/src/services/reqresp/interface.ts +5 -2
  375. package/src/services/reqresp/metrics.ts +34 -9
  376. package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
  377. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -11
  378. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +57 -9
  379. package/src/services/reqresp/reqresp.ts +66 -19
  380. package/src/services/service.ts +24 -0
  381. package/src/services/tx_collection/config.ts +15 -1
  382. package/src/services/tx_collection/fast_tx_collection.ts +30 -17
  383. package/src/services/tx_collection/index.ts +5 -0
  384. package/src/services/tx_collection/instrumentation.ts +11 -2
  385. package/src/services/tx_collection/proposal_tx_collector.ts +112 -0
  386. package/src/services/tx_collection/slow_tx_collection.ts +2 -2
  387. package/src/services/tx_collection/tx_collection.ts +8 -8
  388. package/src/services/tx_file_store/config.ts +43 -0
  389. package/src/services/tx_file_store/index.ts +3 -0
  390. package/src/services/tx_file_store/instrumentation.ts +36 -0
  391. package/src/services/tx_file_store/tx_file_store.ts +173 -0
  392. package/src/services/tx_provider.ts +2 -2
  393. package/src/services/tx_provider_instrumentation.ts +11 -5
  394. package/src/test-helpers/index.ts +2 -0
  395. package/src/test-helpers/reqresp-nodes.ts +2 -1
  396. package/src/test-helpers/test_tx_provider.ts +64 -0
  397. package/src/test-helpers/testbench-utils.ts +362 -0
  398. package/src/testbench/p2p_client_testbench_worker.ts +321 -126
  399. package/src/testbench/worker_client_manager.ts +304 -47
  400. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  401. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  402. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  403. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  404. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  405. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  406. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  407. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -1,7 +1,9 @@
1
1
  // Request response metrics
2
- import { Attributes, Metrics } from '@aztec/telemetry-client';
2
+ import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
3
3
  import type { TelemetryClient, Tracer, UpDownCounter } from '@aztec/telemetry-client';
4
4
 
5
+ import { ReqRespSubProtocol } from './interface.js';
6
+
5
7
  export class ReqRespMetrics {
6
8
  public readonly tracer: Tracer;
7
9
 
@@ -18,27 +20,50 @@ export class ReqRespMetrics {
18
20
  this.tracer = telemetryClient.getTracer(name);
19
21
 
20
22
  const meter = telemetryClient.getMeter(name);
21
- this.sentRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_SENT_REQUESTS);
22
- this.receivedRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_RECEIVED_REQUESTS);
23
+ const protocolAttrs = {
24
+ [Attributes.P2P_REQ_RESP_PROTOCOL]: [
25
+ ReqRespSubProtocol.PING,
26
+ ReqRespSubProtocol.STATUS,
27
+ ReqRespSubProtocol.GOODBYE,
28
+ ReqRespSubProtocol.TX,
29
+ ReqRespSubProtocol.BLOCK,
30
+ ReqRespSubProtocol.AUTH,
31
+ ReqRespSubProtocol.BLOCK_TXS,
32
+ ],
33
+ };
34
+ this.sentRequests = createUpDownCounterWithDefault(meter, Metrics.P2P_REQ_RESP_SENT_REQUESTS, protocolAttrs);
35
+ this.receivedRequests = createUpDownCounterWithDefault(
36
+ meter,
37
+ Metrics.P2P_REQ_RESP_RECEIVED_REQUESTS,
38
+ protocolAttrs,
39
+ );
23
40
 
24
- this.failedOutboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS);
41
+ this.failedOutboundRequests = createUpDownCounterWithDefault(
42
+ meter,
43
+ Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS,
44
+ protocolAttrs,
45
+ );
25
46
 
26
- this.failedInboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS);
47
+ this.failedInboundRequests = createUpDownCounterWithDefault(
48
+ meter,
49
+ Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS,
50
+ protocolAttrs,
51
+ );
27
52
  }
28
53
 
29
- public recordRequestSent(protocol: string) {
54
+ public recordRequestSent(protocol: ReqRespSubProtocol) {
30
55
  this.sentRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
31
56
  }
32
57
 
33
- public recordRequestReceived(protocol: string) {
58
+ public recordRequestReceived(protocol: ReqRespSubProtocol) {
34
59
  this.receivedRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
35
60
  }
36
61
 
37
- public recordRequestError(protocol: string) {
62
+ public recordRequestError(protocol: ReqRespSubProtocol) {
38
63
  this.failedOutboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
39
64
  }
40
65
 
41
- public recordResponseError(protocol: string) {
66
+ public recordResponseError(protocol: ReqRespSubProtocol) {
42
67
  this.failedInboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
43
68
  }
44
69
  }
@@ -64,6 +64,13 @@ export class BitVector {
64
64
  return Array.from({ length: this.length }, (_, i) => i).filter(i => this.isSet(i));
65
65
  }
66
66
 
67
+ /**
68
+ * Returns true if no indices are set to true
69
+ * */
70
+ isEmpty(): boolean {
71
+ return this.getTrueIndices().length === 0;
72
+ }
73
+
67
74
  /**
68
75
  * Serializes the BitVector object into a Buffer
69
76
  *
@@ -1,8 +1,10 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { L2BlockSource } from '@aztec/stdlib/block';
1
3
  import { TxArray } from '@aztec/stdlib/tx';
2
4
 
3
5
  import type { PeerId } from '@libp2p/interface';
4
6
 
5
- import type { AttestationPool } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
7
+ import type { AttestationPoolApi } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
6
8
  import type { TxPool } from '../../../../mem_pools/index.js';
7
9
  import type { ReqRespSubProtocolHandler } from '../../interface.js';
8
10
  import { ReqRespStatus, ReqRespStatusError } from '../../status.js';
@@ -12,10 +14,15 @@ import { BlockTxsRequest, BlockTxsResponse } from './block_txs_reqresp.js';
12
14
  /**
13
15
  * Handler for block txs requests
14
16
  * @param attestationPool - the attestation pool to check for block proposals
15
- * @param mempools - the mempools containing the tx pool
17
+ * @param archiver - the archiver to look up blocks by archive root
18
+ * @param txPool - the tx pool to fetch transactions from
16
19
  * @returns the BlockTxs request handler
17
20
  */
18
- export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool: TxPool): ReqRespSubProtocolHandler {
21
+ export function reqRespBlockTxsHandler(
22
+ attestationPool: AttestationPoolApi,
23
+ archiver: L2BlockSource,
24
+ txPool: TxPool,
25
+ ): ReqRespSubProtocolHandler {
19
26
  /**
20
27
  * Handler for block txs requests
21
28
  * @param msg - the block txs request message
@@ -29,24 +36,40 @@ export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool:
29
36
  } catch (err: any) {
30
37
  throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, { cause: err });
31
38
  }
39
+ // First try attestation pool, then fall back to archiver
40
+ let txHashes = (await attestationPool.getBlockProposal(request.archiveRoot.toString()))?.txHashes;
41
+ if (!txHashes) {
42
+ txHashes = (await archiver.getL2BlockByArchive(request.archiveRoot))?.body.txEffects.map(effect => effect.txHash);
43
+ }
32
44
 
33
- const blockProposal = await attestationPool.getBlockProposal(request.blockHash.toString());
45
+ let requestedTxsHashes;
46
+ if (request.txHashes.length > 0) {
47
+ requestedTxsHashes = request.txHashes;
48
+ }
34
49
 
35
- if (!blockProposal) {
50
+ // This is scenario in which we don't have this block the peer is requesting from us
51
+ // But peer has sent requested tx hashes, so we can send them the transactions
52
+ if (!txHashes && requestedTxsHashes !== undefined) {
53
+ const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
54
+ const response = new BlockTxsResponse(Fr.zero(), new TxArray(...responseTxs), BitVector.init(0, []));
55
+ return response.toBuffer();
56
+ }
57
+
58
+ // If we don't have this block and peer has not sent requested tx hashes
59
+ if (!txHashes) {
36
60
  throw new ReqRespStatusError(ReqRespStatus.NOT_FOUND);
37
61
  }
38
62
 
39
- const txsAvailableInPool = await txPool.hasTxs(blockProposal.txHashes);
40
- //Map txs in the pool to their indices in the block proposal
63
+ const txsAvailableInPool = await txPool.hasTxs(txHashes);
64
+ // Map txs in the pool to their indices in the block
41
65
  const availableIndices = txsAvailableInPool.map((hasTx, idx) => (hasTx ? idx : -1)).filter(idx => idx !== -1);
42
- const responseBitVector = BitVector.init(blockProposal.txHashes.length, availableIndices);
66
+ const responseBitVector = BitVector.init(txHashes.length, availableIndices);
43
67
 
44
68
  const requestedIndices = new Set(request.txIndices.getTrueIndices());
45
- const requestedTxsHashes = blockProposal.txHashes.filter((_, idx) => requestedIndices.has(idx));
69
+ requestedTxsHashes = txHashes.filter((_, idx) => requestedIndices.has(idx));
46
70
 
47
71
  const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
48
-
49
- const response = new BlockTxsResponse(request.blockHash, new TxArray(...responseTxs), responseBitVector);
72
+ const response = new BlockTxsResponse(request.archiveRoot, new TxArray(...responseTxs), responseBitVector);
50
73
 
51
74
  return response.toBuffer();
52
75
  };
@@ -1,20 +1,67 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
- import { TxArray } from '@aztec/stdlib/tx';
3
+ import { TxArray, type TxHash, TxHashArray } from '@aztec/stdlib/tx';
4
4
 
5
5
  import { BitVector } from './bitvector.js';
6
6
 
7
+ /** Minimal interface for a block source that provides tx hashes and an archive root. */
8
+ export interface BlockTxsSource {
9
+ txHashes: TxHash[];
10
+ archive: Fr;
11
+ }
12
+
7
13
  /**
8
14
  * Request message for requesting specific transactions from a block
9
15
  */
10
16
  export class BlockTxsRequest {
11
17
  constructor(
12
- readonly blockHash: Fr, // 32 byte hash of the proposed block header
18
+ // Archive root after the proposed block is applied (proposal identifier)
19
+ readonly archiveRoot: Fr,
20
+ // Hashes of txs we are requesting
21
+ readonly txHashes: TxHashArray,
13
22
  // BitVector indicating which txs from the proposal we are requesting
14
23
  // 1 means we want the tx, 0 means we don't
24
+ // If we know peer has the Block Proposal then we can use this BitVector
25
+ // Otherwise we can use this optimization
15
26
  readonly txIndices: BitVector,
16
27
  ) {}
17
28
 
29
+ /**
30
+ * Creates new BlockTxsRequest given a block txs source and missing tx hashes.
31
+ *
32
+ * @param blockTxsSource - The block or proposal for which we are making the request
33
+ * @param missingTxHashes - Tx hashes from the source we are missing
34
+ * @param includeFullTxHashes - Whether to include full list of missing tx hashes in the request or just Bitvector indices
35
+ *
36
+ * @returns undefined if there were no missingTxHashes matching the source hashes, otherwise
37
+ * returns new BlockTxsRequest
38
+ */
39
+ static fromTxsSourceAndMissingTxs(
40
+ blockTxsSource: BlockTxsSource,
41
+ missingTxHashes: TxHash[],
42
+ includeFullTxHashes = false,
43
+ ): BlockTxsRequest | undefined {
44
+ if (missingTxHashes.length === 0) {
45
+ return undefined; // No missing txs to request
46
+ }
47
+
48
+ const missingHashesSet = new Set(missingTxHashes.map(t => t.toString()));
49
+
50
+ // We cannot request txs that are not part of the block
51
+ if (!missingHashesSet.isSubsetOf(new Set(blockTxsSource.txHashes.map(t => t.toString())))) {
52
+ return undefined;
53
+ }
54
+
55
+ const missingIndices = blockTxsSource.txHashes
56
+ .map((hash, idx) => (missingHashesSet.has(hash.toString()) ? idx : -1))
57
+ .filter(i => i != -1);
58
+
59
+ const requestBitVector = BitVector.init(blockTxsSource.txHashes.length, missingIndices);
60
+ const hashes = includeFullTxHashes ? new TxHashArray(...missingTxHashes) : new TxHashArray();
61
+
62
+ return new BlockTxsRequest(blockTxsSource.archive, hashes, requestBitVector);
63
+ }
64
+
18
65
  /**
19
66
  * Deserializes the BlockTxRequest object from a Buffer
20
67
  * @param buffer - Buffer or BufferReader object to deserialize
@@ -22,10 +69,11 @@ export class BlockTxsRequest {
22
69
  */
23
70
  static fromBuffer(buffer: Buffer | BufferReader): BlockTxsRequest {
24
71
  const reader = BufferReader.asReader(buffer);
25
- const blockHash = Fr.fromBuffer(reader);
72
+ const archiveRoot = Fr.fromBuffer(reader);
73
+ const txHashes = TxHashArray.fromBuffer(reader);
26
74
  const txIndices = BitVector.fromBuffer(reader);
27
75
 
28
- return new BlockTxsRequest(blockHash, txIndices);
76
+ return new BlockTxsRequest(archiveRoot, txHashes, txIndices);
29
77
  }
30
78
 
31
79
  /**
@@ -33,7 +81,7 @@ export class BlockTxsRequest {
33
81
  * @returns Buffer representation of the BlockTxRequest object
34
82
  */
35
83
  toBuffer(): Buffer {
36
- return serializeToBuffer([this.blockHash, this.txIndices.toBuffer()]);
84
+ return serializeToBuffer([this.archiveRoot, this.txHashes.toBuffer(), this.txIndices.toBuffer()]);
37
85
  }
38
86
  }
39
87
 
@@ -42,7 +90,7 @@ export class BlockTxsRequest {
42
90
  */
43
91
  export class BlockTxsResponse {
44
92
  constructor(
45
- readonly blockHash: Fr,
93
+ readonly archiveRoot: Fr,
46
94
  readonly txs: TxArray, // List of transactions we requested and peer has
47
95
  // BitVector indicating which txs from the proposal are available at the peer
48
96
  // 1 means the tx is available, 0 means it is not
@@ -56,11 +104,11 @@ export class BlockTxsResponse {
56
104
  */
57
105
  static fromBuffer(buffer: Buffer | BufferReader): BlockTxsResponse {
58
106
  const reader = BufferReader.asReader(buffer);
59
- const blockHash = Fr.fromBuffer(reader);
107
+ const archiveRoot = Fr.fromBuffer(reader);
60
108
  const txs = TxArray.fromBuffer(reader);
61
109
  const txIndices = BitVector.fromBuffer(reader);
62
110
 
63
- return new BlockTxsResponse(blockHash, txs, txIndices);
111
+ return new BlockTxsResponse(archiveRoot, txs, txIndices);
64
112
  }
65
113
 
66
114
  /**
@@ -70,7 +118,7 @@ export class BlockTxsResponse {
70
118
  * @returns Buffer representation of the BlockTxResponse object
71
119
  */
72
120
  toBuffer(): Buffer {
73
- return serializeToBuffer([this.blockHash, this.txs.toBuffer(), this.txIndices.toBuffer()]);
121
+ return serializeToBuffer([this.archiveRoot, this.txs.toBuffer(), this.txIndices.toBuffer()]);
74
122
  }
75
123
 
76
124
  static empty(): BlockTxsResponse {
@@ -111,6 +111,13 @@ export class ReqResp implements ReqRespInterface {
111
111
  return this.metrics.tracer;
112
112
  }
113
113
 
114
+ /**
115
+ * Get the connection sampler instance
116
+ */
117
+ getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'> {
118
+ return this.connectionSampler;
119
+ }
120
+
114
121
  /**
115
122
  * Start the reqresp service
116
123
  */
@@ -212,6 +219,14 @@ export class ReqResp implements ReqRespInterface {
212
219
  const responseValidator = this.subProtocolValidators[subProtocol] ?? DEFAULT_SUB_PROTOCOL_VALIDATORS[subProtocol];
213
220
  const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = new Array(requests.length);
214
221
  const requestBuffers = requests.map(req => req.toBuffer());
222
+ const isEmptyResponse = (value: unknown): boolean => {
223
+ // Some responses serialize to a non-empty buffer even when they contain no items (e.g., empty TxArray).
224
+ if (!value || typeof value !== 'object') {
225
+ return false;
226
+ }
227
+ const length = (value as { length?: number }).length;
228
+ return typeof length === 'number' && length === 0;
229
+ };
215
230
 
216
231
  const requestFunction = async (signal: AbortSignal) => {
217
232
  // Track which requests still need to be processed
@@ -252,7 +267,9 @@ export class ReqResp implements ReqRespInterface {
252
267
  for (const requestIndex of pendingRequestIndices) {
253
268
  const peer = batchSampler.getPeerForRequest(requestIndex);
254
269
  if (!peer) {
255
- break;
270
+ // No peer available for this specific index (all peers exhausted for it)
271
+ // Skip this index for now - it stays in pendingRequestIndices for retry
272
+ continue;
256
273
  }
257
274
  const peerAsString = peer.toString();
258
275
  if (!requestBatches.has(peerAsString)) {
@@ -271,6 +288,12 @@ export class ReqResp implements ReqRespInterface {
271
288
  });
272
289
  }
273
290
 
291
+ // If no requests could be assigned (all peers exhausted for all indices), exit early
292
+ if (requestBatches.size === 0) {
293
+ this.logger.warn('No peers available for any pending request indices, stopping batch request');
294
+ break;
295
+ }
296
+
274
297
  // Make parallel requests for each peer's batch
275
298
  // A batch entry will look something like this:
276
299
  // PeerId0: [0, 1, 2, 3]
@@ -282,38 +305,61 @@ export class ReqResp implements ReqRespInterface {
282
305
  const batchResults = await Promise.all(
283
306
  Array.from(requestBatches.entries()).map(async ([peerAsString, { peerId: peer, indices }]) => {
284
307
  try {
308
+ const markIndexFailed = (index: number) => batchSampler.markPeerFailedForIndex(peer, index);
285
309
  // Requests all going to the same peer are sent synchronously
286
310
  const peerResults: { index: number; response: InstanceType<SubProtocolMap[SubProtocol]['response']> }[] =
287
311
  [];
312
+ let shouldReplacePeer = false;
313
+ const handleFailure = (status: ReqRespStatus, index: number) => {
314
+ this.logger.warn(
315
+ `Request to peer ${peerAsString} failed with status ${prettyPrintReqRespStatus(status)}`,
316
+ );
317
+ markIndexFailed(index);
318
+ return status === ReqRespStatus.RATE_LIMIT_EXCEEDED;
319
+ };
320
+
288
321
  for (const index of indices) {
289
- this.logger.trace(`Sending request ${index} to peer ${peerAsString}`);
322
+ this.logger.info(`Sending request ${index} to peer ${peerAsString}`);
290
323
  const response = await this.sendRequestToPeer(peer, subProtocol, requestBuffers[index]);
291
324
 
292
325
  // Check the status of the response buffer
293
326
  if (response.status !== ReqRespStatus.SUCCESS) {
294
- this.logger.debug(
295
- `Request to peer ${peerAsString} failed with status ${prettyPrintReqRespStatus(response.status)}`,
296
- );
297
-
298
- // If we hit a rate limit or some failure, we remove the peer and return the results,
299
- // they will be split among remaining peers and the new sampled peer
300
- batchSampler.removePeerAndReplace(peer);
301
- return { peer, results: peerResults };
327
+ shouldReplacePeer = handleFailure(response.status, index);
328
+ if (shouldReplacePeer) {
329
+ break;
330
+ }
331
+ continue;
302
332
  }
303
333
 
304
- if (response && response.data.length > 0) {
305
- const object = responseFromBuffer(subProtocol, response.data);
306
- const isValid = await responseValidator(requests[index], object, peer);
334
+ if (response.data.length === 0) {
335
+ markIndexFailed(index);
336
+ continue;
337
+ }
307
338
 
308
- if (isValid) {
309
- peerResults.push({ index, response: object });
310
- }
339
+ const object = responseFromBuffer(subProtocol, response.data);
340
+ if (isEmptyResponse(object)) {
341
+ markIndexFailed(index);
342
+ continue;
343
+ }
344
+
345
+ const isValid = await responseValidator(requests[index], object, peer);
346
+ if (!isValid) {
347
+ markIndexFailed(index);
348
+ continue;
311
349
  }
350
+
351
+ peerResults.push({ index, response: object });
352
+ }
353
+
354
+ // If peer had a hard failure (rate limit), replace it for future iterations
355
+ if (shouldReplacePeer) {
356
+ this.logger.warn(`Peer ${peerAsString} hit a hard failure, removing from sampler`);
357
+ batchSampler.removePeerAndReplace(peer);
312
358
  }
313
359
 
314
360
  return { peer, results: peerResults };
315
361
  } catch (error) {
316
- this.logger.debug(`Failed batch request to peer ${peerAsString}:`, error);
362
+ this.logger.warn(`Failed batch request to peer ${peerAsString}:`, error);
317
363
  batchSampler.removePeerAndReplace(peer);
318
364
  return { peer, results: [] };
319
365
  }
@@ -334,7 +380,7 @@ export class ReqResp implements ReqRespInterface {
334
380
  }
335
381
 
336
382
  if (retryAttempts >= maxRetryAttempts) {
337
- this.logger.debug(`Max retry attempts ${maxRetryAttempts} reached for batch request`);
383
+ this.logger.warn(`Max retry attempts ${maxRetryAttempts} reached for batch request`);
338
384
  }
339
385
 
340
386
  return responses;
@@ -347,7 +393,7 @@ export class ReqResp implements ReqRespInterface {
347
393
  () => new CollectiveReqRespTimeoutError(),
348
394
  );
349
395
  } catch (e: any) {
350
- this.logger.debug(`${e.message} | subProtocol: ${subProtocol}`);
396
+ this.logger.warn(`${e.message} | subProtocol: ${subProtocol}`);
351
397
  return [];
352
398
  }
353
399
  }
@@ -409,6 +455,7 @@ export class ReqResp implements ReqRespInterface {
409
455
  );
410
456
  return resp;
411
457
  } catch (e: any) {
458
+ this.logger.warn(`SUBPROTOCOL: ${subProtocol}\n`, e);
412
459
  // On error we immediately abort the stream, this is preferred way,
413
460
  // because it signals to the sender that error happened, whereas
414
461
  // closing the stream only closes our side and is much slower
@@ -1,3 +1,4 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
4
  import type { BlockProposal, CheckpointAttestation, CheckpointProposalCore, Gossipable } from '@aztec/stdlib/p2p';
@@ -7,6 +8,7 @@ import type { PeerId } from '@libp2p/interface';
7
8
  import type { ENR } from '@nethermindeth/enr';
8
9
  import type EventEmitter from 'events';
9
10
 
11
+ import type { BatchTxRequesterLibP2PService } from './reqresp/batch-tx-requester/interface.js';
10
12
  import type { P2PReqRespConfig } from './reqresp/config.js';
11
13
  import type { StatusMessage } from './reqresp/index.js';
12
14
  import type {
@@ -42,6 +44,19 @@ export type P2PCheckpointReceivedCallback = (
42
44
 
43
45
  export type AuthReceivedCallback = (peerId: PeerId, authRequest: AuthRequest) => Promise<AuthResponse | undefined>;
44
46
 
47
+ /** Minimal info passed to the duplicate proposal callback. */
48
+ export type DuplicateProposalInfo = {
49
+ slot: SlotNumber;
50
+ proposer: EthAddress;
51
+ type: 'checkpoint' | 'block';
52
+ };
53
+
54
+ /**
55
+ * Callback for when a duplicate proposal is detected (equivocation).
56
+ * Invoked on the first duplicate (when count goes from 1 to 2).
57
+ */
58
+ export type P2PDuplicateProposalCallback = (info: DuplicateProposalInfo) => void;
59
+
45
60
  /**
46
61
  * The interface for a P2P service implementation.
47
62
  */
@@ -85,6 +100,12 @@ export interface P2PService {
85
100
 
86
101
  registerCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
87
102
 
103
+ /**
104
+ * Registers a callback invoked when a duplicate proposal is detected (equivocation).
105
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
106
+ */
107
+ registerDuplicateProposalCallback(callback: P2PDuplicateProposalCallback): void;
108
+
88
109
  getEnr(): ENR | undefined;
89
110
 
90
111
  getPeers(includePending?: boolean): PeerInfo[];
@@ -103,6 +124,9 @@ export interface P2PService {
103
124
 
104
125
  /** If node running this P2P stack is validator, passes in validator address to P2P layer */
105
126
  registerThisValidatorAddresses(address: EthAddress[]): void;
127
+
128
+ /** Get BatchTxRequester service dependencies */
129
+ getBatchTxRequesterService(): BatchTxRequesterLibP2PService;
106
130
  }
107
131
 
108
132
  /**
@@ -1,6 +1,13 @@
1
- import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
1
+ import {
2
+ type ConfigMappingsType,
3
+ booleanConfigHelper,
4
+ enumConfigHelper,
5
+ numberConfigHelper,
6
+ } from '@aztec/foundation/config';
2
7
  import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
3
8
 
9
+ export type MissingTxsCollectorType = 'new' | 'old';
10
+
4
11
  export type TxCollectionConfig = {
5
12
  /** How long to wait before starting reqresp for fast collection */
6
13
  txCollectionFastNodesTimeoutBeforeReqRespMs: number;
@@ -22,6 +29,8 @@ export type TxCollectionConfig = {
22
29
  txCollectionFastMaxParallelRequestsPerNode: number;
23
30
  /** Maximum number of transactions to request from a node in a single batch */
24
31
  txCollectionNodeRpcMaxBatchSize: number;
32
+ /** Which collector implementation to use for missing txs collection */
33
+ txCollectionMissingTxsCollectorType: MissingTxsCollectorType;
25
34
  };
26
35
 
27
36
  export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
@@ -81,4 +90,9 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
81
90
  description: 'Maximum number of transactions to request from a node in a single batch',
82
91
  ...numberConfigHelper(MAX_RPC_TXS_LEN),
83
92
  },
93
+ txCollectionMissingTxsCollectorType: {
94
+ env: 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE',
95
+ description: 'Which collector implementation to use for missing txs collection (new or old)',
96
+ ...enumConfigHelper(['new', 'old'] as const, 'new'),
97
+ },
84
98
  };
@@ -2,7 +2,6 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { times } from '@aztec/foundation/collection';
3
3
  import { AbortError, TimeoutError } from '@aztec/foundation/error';
4
4
  import { type Logger, createLogger } from '@aztec/foundation/log';
5
- import { boundInclusive } from '@aztec/foundation/number';
6
5
  import { promiseWithResolvers } from '@aztec/foundation/promise';
7
6
  import { sleep } from '@aztec/foundation/sleep';
8
7
  import { DateProvider, elapsed } from '@aztec/foundation/timer';
@@ -12,9 +11,14 @@ import { type Tx, TxHash } from '@aztec/stdlib/tx';
12
11
 
13
12
  import type { PeerId } from '@libp2p/interface';
14
13
 
15
- import { type ReqRespInterface, ReqRespSubProtocol } from '../reqresp/interface.js';
16
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
14
+ import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
15
+ import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
17
16
  import type { TxCollectionConfig } from './config.js';
17
+ import {
18
+ BatchTxRequesterCollector,
19
+ type MissingTxsCollector,
20
+ SendBatchRequestCollector,
21
+ } from './proposal_tx_collector.js';
18
22
  import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
19
23
  import type { TxCollectionSink } from './tx_collection_sink.js';
20
24
  import type { TxSource } from './tx_source.js';
@@ -22,15 +26,25 @@ import type { TxSource } from './tx_source.js';
22
26
  export class FastTxCollection {
23
27
  // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
24
28
  protected requests: Set<FastCollectionRequest> = new Set();
29
+ private missingTxsCollector: MissingTxsCollector;
25
30
 
26
31
  constructor(
27
- private reqResp: Pick<ReqRespInterface, 'sendBatchRequest'>,
32
+ p2pService: BatchTxRequesterLibP2PService,
28
33
  private nodes: TxSource[],
29
34
  private txCollectionSink: TxCollectionSink,
30
35
  private config: TxCollectionConfig,
31
36
  private dateProvider: DateProvider = new DateProvider(),
32
37
  private log: Logger = createLogger('p2p:tx_collection_service'),
33
- ) {}
38
+ missingTxsCollector?: MissingTxsCollector,
39
+ ) {
40
+ const batchTxRequesterConfig = this.config as Partial<BatchTxRequesterConfig>;
41
+ const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
42
+ this.missingTxsCollector =
43
+ missingTxsCollector ??
44
+ (missingTxsCollectorType === 'old'
45
+ ? new SendBatchRequestCollector(p2pService)
46
+ : new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
47
+ }
34
48
 
35
49
  public async stop() {
36
50
  this.requests.forEach(request => request.promise.reject(new AbortError(`Stopped collection service`)));
@@ -241,8 +255,6 @@ export class FastTxCollection {
241
255
  private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
242
256
  const timeoutMs = +request.deadline - this.dateProvider.now();
243
257
  const pinnedPeer = opts.pinnedPeer;
244
- const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
245
- const maxRetryAttempts = 5;
246
258
  const blockInfo = request.blockInfo;
247
259
  const slotNumber = blockInfo.slotNumber;
248
260
  if (timeoutMs < 100) {
@@ -261,16 +273,17 @@ export class FastTxCollection {
261
273
  try {
262
274
  await this.txCollectionSink.collect(
263
275
  async txHashes => {
264
- const txs = await this.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
265
- ReqRespSubProtocol.TX,
266
- chunkTxHashesRequest(txHashes),
267
- pinnedPeer,
268
- timeoutMs,
269
- maxPeers,
270
- maxRetryAttempts,
271
- );
272
-
273
- return txs.flat();
276
+ if (request.type === 'proposal') {
277
+ return await this.missingTxsCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
278
+ } else if (request.type === 'block') {
279
+ const blockTxsSource = {
280
+ txHashes: request.block.body.txEffects.map(e => e.txHash),
281
+ archive: request.block.archive.root,
282
+ };
283
+ return await this.missingTxsCollector.collectTxs(txHashes, blockTxsSource, pinnedPeer, timeoutMs);
284
+ } else {
285
+ throw new Error(`Unknown request type: ${(request as any).type}`);
286
+ }
274
287
  },
275
288
  Array.from(request.missingTxHashes).map(txHash => TxHash.fromString(txHash)),
276
289
  { description: `reqresp for slot ${slotNumber}`, method: 'fast-req-resp', ...opts, ...request.blockInfo },
@@ -1,2 +1,7 @@
1
1
  export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
2
2
  export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
3
+ export {
4
+ type MissingTxsCollector,
5
+ BatchTxRequesterCollector,
6
+ SendBatchRequestCollector,
7
+ } from './proposal_tx_collector.js';
@@ -1,4 +1,11 @@
1
- import { Attributes, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
1
+ import {
2
+ Attributes,
3
+ type Histogram,
4
+ Metrics,
5
+ type TelemetryClient,
6
+ type UpDownCounter,
7
+ createUpDownCounterWithDefault,
8
+ } from '@aztec/telemetry-client';
2
9
 
3
10
  import type { CollectionMethod } from './tx_collection.js';
4
11
 
@@ -10,7 +17,9 @@ export class TxCollectionInstrumentation {
10
17
  constructor(client: TelemetryClient, name: string) {
11
18
  const meter = client.getMeter(name);
12
19
 
13
- this.txsCollected = meter.createUpDownCounter(Metrics.TX_COLLECTOR_COUNT);
20
+ this.txsCollected = createUpDownCounterWithDefault(meter, Metrics.TX_COLLECTOR_COUNT, {
21
+ [Attributes.TX_COLLECTION_METHOD]: ['fast-req-resp', 'fast-node-rpc', 'slow-req-resp', 'slow-node-rpc'],
22
+ });
14
23
 
15
24
  this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
16
25