@aztec/p2p 0.0.0-test.1 → 0.0.1-commit.24de95ac

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 (339) hide show
  1. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  2. package/dest/bootstrap/bootstrap.js +22 -9
  3. package/dest/client/factory.d.ts +13 -3
  4. package/dest/client/factory.d.ts.map +1 -1
  5. package/dest/client/factory.js +60 -24
  6. package/dest/client/index.d.ts +1 -0
  7. package/dest/client/index.d.ts.map +1 -1
  8. package/dest/client/index.js +1 -0
  9. package/dest/client/interface.d.ts +155 -0
  10. package/dest/client/interface.d.ts.map +1 -0
  11. package/dest/client/interface.js +9 -0
  12. package/dest/client/p2p_client.d.ts +72 -169
  13. package/dest/client/p2p_client.d.ts.map +1 -1
  14. package/dest/client/p2p_client.js +365 -174
  15. package/dest/config.d.ts +123 -103
  16. package/dest/config.d.ts.map +1 -1
  17. package/dest/config.js +173 -34
  18. package/dest/enr/generate-enr.d.ts +10 -2
  19. package/dest/enr/generate-enr.d.ts.map +1 -1
  20. package/dest/enr/generate-enr.js +27 -5
  21. package/dest/index.d.ts +3 -0
  22. package/dest/index.d.ts.map +1 -1
  23. package/dest/index.js +2 -0
  24. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +42 -4
  25. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  26. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +204 -54
  28. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +10 -2
  29. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +93 -15
  31. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +10 -2
  32. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  33. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +86 -18
  34. package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -2
  35. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  36. package/dest/mem_pools/attestation_pool/mocks.js +9 -15
  37. package/dest/mem_pools/instrumentation.d.ts +7 -11
  38. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  39. package/dest/mem_pools/instrumentation.js +25 -37
  40. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +93 -9
  41. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  42. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +469 -97
  43. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +33 -9
  44. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  45. package/dest/mem_pools/tx_pool/memory_tx_pool.js +133 -36
  46. package/dest/mem_pools/tx_pool/priority.js +1 -1
  47. package/dest/mem_pools/tx_pool/tx_pool.d.ts +64 -8
  48. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  50. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +264 -39
  51. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -0
  52. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  53. package/dest/msg_validators/attestation_validator/attestation_validator.js +45 -9
  54. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +5 -1
  55. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
  56. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +61 -12
  57. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +10 -0
  58. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
  59. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
  60. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +3 -0
  61. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -0
  62. package/dest/msg_validators/tx_validator/allowed_public_setup.js +27 -0
  63. package/dest/msg_validators/tx_validator/archive_cache.d.ts +14 -0
  64. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -0
  65. package/dest/msg_validators/tx_validator/archive_cache.js +22 -0
  66. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  67. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -4
  68. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  69. package/dest/msg_validators/tx_validator/data_validator.js +56 -86
  70. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +0 -2
  71. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  72. package/dest/msg_validators/tx_validator/double_spend_validator.js +21 -27
  73. package/dest/msg_validators/tx_validator/factory.d.ts +15 -0
  74. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
  75. package/dest/msg_validators/tx_validator/factory.js +74 -0
  76. package/dest/msg_validators/tx_validator/gas_validator.d.ts +11 -0
  77. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -0
  78. package/dest/msg_validators/tx_validator/gas_validator.js +115 -0
  79. package/dest/msg_validators/tx_validator/index.d.ts +7 -0
  80. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  81. package/dest/msg_validators/tx_validator/index.js +7 -0
  82. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +7 -3
  83. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  84. package/dest/msg_validators/tx_validator/metadata_validator.js +39 -20
  85. package/dest/msg_validators/tx_validator/phases_validator.d.ts +14 -0
  86. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -0
  87. package/dest/msg_validators/tx_validator/phases_validator.js +91 -0
  88. package/dest/msg_validators/tx_validator/test_utils.d.ts +17 -0
  89. package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -0
  90. package/dest/msg_validators/tx_validator/test_utils.js +22 -0
  91. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +12 -0
  92. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -0
  93. package/dest/msg_validators/tx_validator/timestamp_validator.js +32 -0
  94. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +8 -0
  95. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -0
  96. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +24 -0
  97. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  98. package/dest/msg_validators/tx_validator/tx_proof_validator.js +6 -5
  99. package/dest/services/discv5/discV5_service.d.ts +9 -8
  100. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  101. package/dest/services/discv5/discV5_service.js +63 -36
  102. package/dest/services/dummy_service.d.ts +49 -10
  103. package/dest/services/dummy_service.d.ts.map +1 -1
  104. package/dest/services/dummy_service.js +88 -5
  105. package/dest/services/encoding.d.ts +25 -6
  106. package/dest/services/encoding.d.ts.map +1 -1
  107. package/dest/services/encoding.js +73 -5
  108. package/dest/services/index.d.ts +4 -0
  109. package/dest/services/index.d.ts.map +1 -1
  110. package/dest/services/index.js +4 -0
  111. package/dest/services/libp2p/instrumentation.d.ts +18 -0
  112. package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
  113. package/dest/services/libp2p/instrumentation.js +157 -0
  114. package/dest/services/libp2p/libp2p_service.d.ts +87 -42
  115. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  116. package/dest/services/libp2p/libp2p_service.js +500 -218
  117. package/dest/services/peer-manager/interface.d.ts +23 -0
  118. package/dest/services/peer-manager/interface.d.ts.map +1 -0
  119. package/dest/services/peer-manager/interface.js +1 -0
  120. package/dest/services/peer-manager/metrics.d.ts +3 -1
  121. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  122. package/dest/services/peer-manager/metrics.js +11 -2
  123. package/dest/services/peer-manager/peer_manager.d.ts +126 -15
  124. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  125. package/dest/services/peer-manager/peer_manager.js +547 -72
  126. package/dest/services/reqresp/config.d.ts +10 -8
  127. package/dest/services/reqresp/config.d.ts.map +1 -1
  128. package/dest/services/reqresp/config.js +18 -4
  129. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
  130. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  131. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +10 -6
  132. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +30 -13
  133. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  134. package/dest/services/reqresp/connection-sampler/connection_sampler.js +142 -84
  135. package/dest/services/reqresp/index.d.ts +2 -1
  136. package/dest/services/reqresp/index.d.ts.map +1 -1
  137. package/dest/services/reqresp/index.js +2 -1
  138. package/dest/services/reqresp/interface.d.ts +72 -23
  139. package/dest/services/reqresp/interface.d.ts.map +1 -1
  140. package/dest/services/reqresp/interface.js +45 -26
  141. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  142. package/dest/services/reqresp/protocols/auth.d.ts +43 -0
  143. package/dest/services/reqresp/protocols/auth.d.ts.map +1 -0
  144. package/dest/services/reqresp/protocols/auth.js +71 -0
  145. package/dest/services/reqresp/protocols/block.d.ts +5 -0
  146. package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
  147. package/dest/services/reqresp/protocols/block.js +28 -5
  148. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +30 -0
  149. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -0
  150. package/dest/services/reqresp/protocols/block_txs/bitvector.js +75 -0
  151. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +11 -0
  152. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -0
  153. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +39 -0
  154. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +49 -0
  155. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -0
  156. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +75 -0
  157. package/dest/services/reqresp/protocols/block_txs/index.d.ts +4 -0
  158. package/dest/services/reqresp/protocols/block_txs/index.d.ts.map +1 -0
  159. package/dest/services/reqresp/protocols/block_txs/index.js +3 -0
  160. package/dest/services/reqresp/protocols/goodbye.d.ts +2 -4
  161. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  162. package/dest/services/reqresp/protocols/goodbye.js +7 -7
  163. package/dest/services/reqresp/protocols/index.d.ts +2 -0
  164. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  165. package/dest/services/reqresp/protocols/index.js +2 -0
  166. package/dest/services/reqresp/protocols/ping.d.ts +0 -2
  167. package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
  168. package/dest/services/reqresp/protocols/status.d.ts +38 -6
  169. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  170. package/dest/services/reqresp/protocols/status.js +72 -5
  171. package/dest/services/reqresp/protocols/tx.d.ts +12 -1
  172. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  173. package/dest/services/reqresp/protocols/tx.js +34 -6
  174. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +4 -2
  175. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  176. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
  177. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  178. package/dest/services/reqresp/rate-limiter/rate_limits.js +21 -1
  179. package/dest/services/reqresp/reqresp.d.ts +45 -47
  180. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  181. package/dest/services/reqresp/reqresp.js +298 -207
  182. package/dest/services/reqresp/status.d.ts +9 -3
  183. package/dest/services/reqresp/status.d.ts.map +1 -1
  184. package/dest/services/reqresp/status.js +9 -2
  185. package/dest/services/service.d.ts +22 -18
  186. package/dest/services/service.d.ts.map +1 -1
  187. package/dest/services/tx_collection/config.d.ts +25 -0
  188. package/dest/services/tx_collection/config.d.ts.map +1 -0
  189. package/dest/services/tx_collection/config.js +58 -0
  190. package/dest/services/tx_collection/fast_tx_collection.d.ts +56 -0
  191. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -0
  192. package/dest/services/tx_collection/fast_tx_collection.js +300 -0
  193. package/dest/services/tx_collection/index.d.ts +3 -0
  194. package/dest/services/tx_collection/index.d.ts.map +1 -0
  195. package/dest/services/tx_collection/index.js +2 -0
  196. package/dest/services/tx_collection/instrumentation.d.ts +10 -0
  197. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -0
  198. package/dest/services/tx_collection/instrumentation.js +34 -0
  199. package/dest/services/tx_collection/slow_tx_collection.d.ts +54 -0
  200. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
  201. package/dest/services/tx_collection/slow_tx_collection.js +176 -0
  202. package/dest/services/tx_collection/tx_collection.d.ts +110 -0
  203. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -0
  204. package/dest/services/tx_collection/tx_collection.js +128 -0
  205. package/dest/services/tx_collection/tx_collection_sink.d.ts +30 -0
  206. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -0
  207. package/dest/services/tx_collection/tx_collection_sink.js +111 -0
  208. package/dest/services/tx_collection/tx_source.d.ts +18 -0
  209. package/dest/services/tx_collection/tx_source.d.ts.map +1 -0
  210. package/dest/services/tx_collection/tx_source.js +31 -0
  211. package/dest/services/tx_provider.d.ts +49 -0
  212. package/dest/services/tx_provider.d.ts.map +1 -0
  213. package/dest/services/tx_provider.js +210 -0
  214. package/dest/services/tx_provider_instrumentation.d.ts +13 -0
  215. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -0
  216. package/dest/services/tx_provider_instrumentation.js +34 -0
  217. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  218. package/dest/test-helpers/index.d.ts +1 -0
  219. package/dest/test-helpers/index.d.ts.map +1 -1
  220. package/dest/test-helpers/index.js +1 -0
  221. package/dest/test-helpers/make-enrs.d.ts.map +1 -1
  222. package/dest/test-helpers/make-enrs.js +4 -5
  223. package/dest/test-helpers/make-test-p2p-clients.d.ts +32 -4
  224. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  225. package/dest/test-helpers/make-test-p2p-clients.js +86 -16
  226. package/dest/test-helpers/mock-pubsub.d.ts +59 -0
  227. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -0
  228. package/dest/test-helpers/mock-pubsub.js +130 -0
  229. package/dest/test-helpers/mock-tx-helpers.d.ts +12 -0
  230. package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -0
  231. package/dest/test-helpers/mock-tx-helpers.js +19 -0
  232. package/dest/test-helpers/reqresp-nodes.d.ts +14 -10
  233. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  234. package/dest/test-helpers/reqresp-nodes.js +62 -28
  235. package/dest/testbench/p2p_client_testbench_worker.js +96 -25
  236. package/dest/testbench/parse_log_file.js +4 -4
  237. package/dest/testbench/testbench.js +4 -4
  238. package/dest/testbench/worker_client_manager.d.ts +0 -5
  239. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  240. package/dest/testbench/worker_client_manager.js +11 -19
  241. package/dest/types/index.d.ts +3 -1
  242. package/dest/types/index.d.ts.map +1 -1
  243. package/dest/types/index.js +2 -0
  244. package/dest/util.d.ts +22 -15
  245. package/dest/util.d.ts.map +1 -1
  246. package/dest/util.js +64 -67
  247. package/dest/versioning.d.ts +3 -3
  248. package/dest/versioning.d.ts.map +1 -1
  249. package/dest/versioning.js +8 -3
  250. package/package.json +28 -24
  251. package/src/bootstrap/bootstrap.ts +27 -11
  252. package/src/client/factory.ts +136 -45
  253. package/src/client/index.ts +1 -0
  254. package/src/client/interface.ts +195 -0
  255. package/src/client/p2p_client.ts +460 -327
  256. package/src/config.ts +288 -134
  257. package/src/enr/generate-enr.ts +39 -6
  258. package/src/index.ts +4 -0
  259. package/src/mem_pools/attestation_pool/attestation_pool.ts +48 -4
  260. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +241 -55
  261. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +117 -20
  262. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +114 -22
  263. package/src/mem_pools/attestation_pool/mocks.ts +11 -10
  264. package/src/mem_pools/instrumentation.ts +32 -46
  265. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +549 -108
  266. package/src/mem_pools/tx_pool/memory_tx_pool.ts +153 -44
  267. package/src/mem_pools/tx_pool/priority.ts +1 -1
  268. package/src/mem_pools/tx_pool/tx_pool.ts +67 -8
  269. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +217 -34
  270. package/src/msg_validators/attestation_validator/attestation_validator.ts +55 -10
  271. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +66 -14
  272. package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
  273. package/src/msg_validators/tx_validator/allowed_public_setup.ts +35 -0
  274. package/src/msg_validators/tx_validator/archive_cache.ts +28 -0
  275. package/src/msg_validators/tx_validator/block_header_validator.ts +4 -4
  276. package/src/msg_validators/tx_validator/data_validator.ts +81 -69
  277. package/src/msg_validators/tx_validator/double_spend_validator.ts +19 -17
  278. package/src/msg_validators/tx_validator/factory.ts +109 -0
  279. package/src/msg_validators/tx_validator/gas_validator.ts +134 -0
  280. package/src/msg_validators/tx_validator/index.ts +7 -0
  281. package/src/msg_validators/tx_validator/metadata_validator.ts +58 -21
  282. package/src/msg_validators/tx_validator/phases_validator.ts +114 -0
  283. package/src/msg_validators/tx_validator/test_utils.ts +43 -0
  284. package/src/msg_validators/tx_validator/timestamp_validator.ts +46 -0
  285. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +17 -0
  286. package/src/msg_validators/tx_validator/tx_proof_validator.ts +6 -5
  287. package/src/services/discv5/discV5_service.ts +84 -38
  288. package/src/services/dummy_service.ts +147 -9
  289. package/src/services/encoding.ts +80 -5
  290. package/src/services/index.ts +4 -0
  291. package/src/services/libp2p/instrumentation.ts +158 -0
  292. package/src/services/libp2p/libp2p_service.ts +646 -263
  293. package/src/services/peer-manager/interface.ts +29 -0
  294. package/src/services/peer-manager/metrics.ts +16 -1
  295. package/src/services/peer-manager/peer_manager.ts +652 -78
  296. package/src/services/reqresp/config.ts +26 -9
  297. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +12 -6
  298. package/src/services/reqresp/connection-sampler/connection_sampler.ts +148 -95
  299. package/src/services/reqresp/index.ts +2 -0
  300. package/src/services/reqresp/interface.ts +91 -36
  301. package/src/services/reqresp/metrics.ts +4 -1
  302. package/src/services/reqresp/protocols/auth.ts +83 -0
  303. package/src/services/reqresp/protocols/block.ts +24 -3
  304. package/src/services/reqresp/protocols/block_txs/bitvector.ts +90 -0
  305. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +53 -0
  306. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +79 -0
  307. package/src/services/reqresp/protocols/block_txs/index.ts +3 -0
  308. package/src/services/reqresp/protocols/goodbye.ts +9 -7
  309. package/src/services/reqresp/protocols/index.ts +2 -0
  310. package/src/services/reqresp/protocols/status.ts +117 -5
  311. package/src/services/reqresp/protocols/tx.ts +35 -6
  312. package/src/services/reqresp/rate-limiter/rate_limiter.ts +12 -3
  313. package/src/services/reqresp/rate-limiter/rate_limits.ts +21 -1
  314. package/src/services/reqresp/reqresp.ts +387 -256
  315. package/src/services/reqresp/status.ts +12 -3
  316. package/src/services/service.ts +45 -21
  317. package/src/services/tx_collection/config.ts +84 -0
  318. package/src/services/tx_collection/fast_tx_collection.ts +340 -0
  319. package/src/services/tx_collection/index.ts +2 -0
  320. package/src/services/tx_collection/instrumentation.ts +43 -0
  321. package/src/services/tx_collection/slow_tx_collection.ts +232 -0
  322. package/src/services/tx_collection/tx_collection.ts +215 -0
  323. package/src/services/tx_collection/tx_collection_sink.ts +129 -0
  324. package/src/services/tx_collection/tx_source.ts +37 -0
  325. package/src/services/tx_provider.ts +216 -0
  326. package/src/services/tx_provider_instrumentation.ts +44 -0
  327. package/src/test-helpers/index.ts +1 -0
  328. package/src/test-helpers/make-enrs.ts +4 -5
  329. package/src/test-helpers/make-test-p2p-clients.ts +111 -21
  330. package/src/test-helpers/mock-pubsub.ts +188 -0
  331. package/src/test-helpers/mock-tx-helpers.ts +24 -0
  332. package/src/test-helpers/reqresp-nodes.ts +86 -35
  333. package/src/testbench/p2p_client_testbench_worker.ts +145 -22
  334. package/src/testbench/parse_log_file.ts +4 -4
  335. package/src/testbench/testbench.ts +4 -4
  336. package/src/testbench/worker_client_manager.ts +17 -23
  337. package/src/types/index.ts +2 -0
  338. package/src/util.ts +93 -89
  339. package/src/versioning.ts +11 -4
@@ -5,14 +5,20 @@ export declare enum ReqRespStatus {
5
5
  SUCCESS = 0,
6
6
  RATE_LIMIT_EXCEEDED = 1,
7
7
  BADLY_FORMED_REQUEST = 2,
8
+ INTERNAL_ERROR = 3,
9
+ NOT_FOUND = 4,
10
+ FAILURE = 126,
8
11
  UNKNOWN = 127
9
12
  }
13
+ export type UnsuccessfulReqRespStatus = Exclude<ReqRespStatus, ReqRespStatus.SUCCESS>;
10
14
  export declare class ReqRespStatusError extends Error {
11
15
  /**
12
16
  * The status code
13
17
  */
14
- status: ReqRespStatus;
15
- constructor(status: ReqRespStatus);
18
+ readonly status: UnsuccessfulReqRespStatus;
19
+ constructor(status: UnsuccessfulReqRespStatus, cause?: {
20
+ cause?: Error;
21
+ });
16
22
  }
17
23
  /**
18
24
  * Parse the status chunk
@@ -27,5 +33,5 @@ export declare function parseStatusChunk(chunk: Uint8Array): ReqRespStatus;
27
33
  * @param status
28
34
  * @returns
29
35
  */
30
- export declare function prettyPrintReqRespStatus(status: ReqRespStatus): "SUCCESS" | "RATE_LIMIT_EXCEEDED" | "BADLY_FORMED_REQUEST" | "UNKNOWN";
36
+ export declare function prettyPrintReqRespStatus(status: ReqRespStatus): "SUCCESS" | "RATE_LIMIT_EXCEEDED" | "BADLY_FORMED_REQUEST" | "FAILURE" | "INTERNAL_ERROR" | "UNKNOWN" | undefined;
31
37
  //# sourceMappingURL=status.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/services/reqresp/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,aAAa;IACvB,OAAO,IAAI;IACX,mBAAmB,IAAI;IACvB,oBAAoB,IAAI;IACxB,OAAO,MAAM;CACd;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;gBAEV,MAAM,EAAE,aAAa;CAIlC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAWjE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,0EAW7D"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/services/reqresp/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,aAAa;IACvB,OAAO,IAAI;IACX,mBAAmB,IAAI;IACvB,oBAAoB,IAAI;IACxB,cAAc,IAAI;IAClB,SAAS,IAAI;IACb,OAAO,MAAM;IACb,OAAO,MAAM;CACd;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;AAEtF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC;gBAE/B,MAAM,EAAE,yBAAyB,EAAE,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAIzE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAWjE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,qHAe7D"}
@@ -4,6 +4,9 @@
4
4
  ReqRespStatus[ReqRespStatus["SUCCESS"] = 0] = "SUCCESS";
5
5
  ReqRespStatus[ReqRespStatus["RATE_LIMIT_EXCEEDED"] = 1] = "RATE_LIMIT_EXCEEDED";
6
6
  ReqRespStatus[ReqRespStatus["BADLY_FORMED_REQUEST"] = 2] = "BADLY_FORMED_REQUEST";
7
+ ReqRespStatus[ReqRespStatus["INTERNAL_ERROR"] = 3] = "INTERNAL_ERROR";
8
+ ReqRespStatus[ReqRespStatus["NOT_FOUND"] = 4] = "NOT_FOUND";
9
+ ReqRespStatus[ReqRespStatus["FAILURE"] = 126] = "FAILURE";
7
10
  ReqRespStatus[ReqRespStatus["UNKNOWN"] = 127] = "UNKNOWN";
8
11
  return ReqRespStatus;
9
12
  }({});
@@ -11,8 +14,8 @@ export class ReqRespStatusError extends Error {
11
14
  /**
12
15
  * The status code
13
16
  */ status;
14
- constructor(status){
15
- super(`ReqResp Error: ${prettyPrintReqRespStatus(status)}`);
17
+ constructor(status, cause){
18
+ super(`ReqResp Error: ${prettyPrintReqRespStatus(status)}`, cause);
16
19
  this.status = status;
17
20
  }
18
21
  }
@@ -45,6 +48,10 @@ export class ReqRespStatusError extends Error {
45
48
  return 'RATE_LIMIT_EXCEEDED';
46
49
  case 2:
47
50
  return 'BADLY_FORMED_REQUEST';
51
+ case 126:
52
+ return 'FAILURE';
53
+ case 3:
54
+ return 'INTERNAL_ERROR';
48
55
  case 127:
49
56
  return 'UNKNOWN';
50
57
  }
@@ -1,14 +1,20 @@
1
- /// <reference types="node" resolution-mode="require"/>
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
3
  import type { BlockAttestation, BlockProposal, Gossipable } from '@aztec/stdlib/p2p';
4
- import type { ENR } from '@chainsafe/enr';
4
+ import type { Tx } from '@aztec/stdlib/tx';
5
5
  import type { PeerId } from '@libp2p/interface';
6
+ import type { ENR } from '@nethermindeth/enr';
6
7
  import type EventEmitter from 'events';
7
- import type { ReqRespSubProtocol, SubProtocolMap } from './reqresp/interface.js';
8
+ import type { P2PReqRespConfig } from './reqresp/config.js';
9
+ import type { StatusMessage } from './reqresp/index.js';
10
+ import type { ReqRespSubProtocol, ReqRespSubProtocolHandler, ReqRespSubProtocolValidators, SubProtocolMap } from './reqresp/interface.js';
11
+ import type { AuthRequest, AuthResponse } from './reqresp/protocols/auth.js';
8
12
  export declare enum PeerDiscoveryState {
9
13
  RUNNING = "running",
10
14
  STOPPED = "stopped"
11
15
  }
16
+ export type P2PBlockReceivedCallback = (block: BlockProposal, sender: PeerId) => Promise<BlockAttestation[] | undefined>;
17
+ export type AuthReceivedCallback = (peerId: PeerId, authRequest: AuthRequest) => Promise<AuthResponse | undefined>;
12
18
  /**
13
19
  * The interface for a P2P service implementation.
14
20
  */
@@ -27,15 +33,7 @@ export interface P2PService {
27
33
  * Called to have the given transaction propagated through the P2P network.
28
34
  * @param message - The message to be propagated.
29
35
  */
30
- propagate<T extends Gossipable>(message: T): void;
31
- /**
32
- * Request information from peers via the request response protocol.
33
- *
34
- * @param protocol - The request response protocol to use
35
- * @param request - The request type, corresponding to the protocol
36
- * @returns The response type, corresponding to the protocol
37
- */
38
- sendRequest<Protocol extends ReqRespSubProtocol>(protocol: Protocol, request: InstanceType<SubProtocolMap[Protocol]['request']>): Promise<InstanceType<SubProtocolMap[Protocol]['response']> | undefined>;
36
+ propagate<T extends Gossipable>(message: T): Promise<void>;
39
37
  /**
40
38
  * Send a batch of requests to peers, and return the responses
41
39
  *
@@ -43,10 +41,16 @@ export interface P2PService {
43
41
  * @param requests - The requests to send to the peers
44
42
  * @returns The responses to the requests
45
43
  */
46
- sendBatchRequest<Protocol extends ReqRespSubProtocol>(protocol: Protocol, requests: InstanceType<SubProtocolMap[Protocol]['request']>[]): Promise<InstanceType<SubProtocolMap[Protocol]['response']>[] | undefined>;
47
- registerBlockReceivedCallback(callback: (block: BlockProposal) => Promise<BlockAttestation | undefined>): void;
44
+ sendBatchRequest<Protocol extends ReqRespSubProtocol>(protocol: Protocol, requests: InstanceType<SubProtocolMap[Protocol]['request']>[], pinnedPeerId?: PeerId, timeoutMs?: number, maxPeers?: number, maxRetryAttempts?: number): Promise<InstanceType<SubProtocolMap[Protocol]['response']>[]>;
45
+ registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
48
46
  getEnr(): ENR | undefined;
49
47
  getPeers(includePending?: boolean): PeerInfo[];
48
+ validate(txs: Tx[]): Promise<void>;
49
+ addReqRespSubProtocol(subProtocol: ReqRespSubProtocol, handler: ReqRespSubProtocolHandler, validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol]): Promise<void>;
50
+ handleAuthRequestFromPeer(authRequest: AuthRequest, peerId: PeerId): Promise<StatusMessage>;
51
+ updateConfig(config: Partial<P2PReqRespConfig>): void;
52
+ /** If node running this P2P stack is validator, passes in validator address to P2P layer */
53
+ registerThisValidatorAddresses(address: EthAddress[]): void;
50
54
  }
51
55
  /**
52
56
  * The interface for a peer discovery service implementation.
@@ -61,10 +65,10 @@ export interface PeerDiscoveryService extends EventEmitter {
61
65
  * */
62
66
  stop(): Promise<void>;
63
67
  /**
64
- * Gets all peers.
65
- * @returns An array of peer ENRs.
68
+ * Gets all KadValues.
69
+ * @returns An array of ENRs.
66
70
  */
67
- getAllPeers(): ENR[];
71
+ getKadValues(): ENR[];
68
72
  /**
69
73
  * Runs findRandomNode query.
70
74
  */
@@ -82,6 +86,6 @@ export interface PeerDiscoveryService extends EventEmitter {
82
86
  emit(event: 'peer:discovered', enr: ENR): boolean;
83
87
  getStatus(): PeerDiscoveryState;
84
88
  getEnr(): ENR | undefined;
85
- bootstrapNodes: string[];
89
+ bootstrapNodeEnrs: ENR[];
86
90
  }
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AE,CAAC;IAEtB;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEzC;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;IACjE,IAAI,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;IAElD,SAAS,IAAI,kBAAkB,CAAC;IAEhC,MAAM,IAAI,GAAG,GAAG,SAAS,CAAC;IAE1B,iBAAiB,EAAE,GAAG,EAAE,CAAC;CAC1B"}
@@ -0,0 +1,25 @@
1
+ import { type ConfigMappingsType } from '@aztec/foundation/config';
2
+ export type TxCollectionConfig = {
3
+ /** How long to wait before starting reqresp for fast collection */
4
+ txCollectionFastNodesTimeoutBeforeReqRespMs: number;
5
+ /** How often to collect from configured nodes */
6
+ txCollectionSlowNodesIntervalMs: number;
7
+ /** How ofter to collect from peers */
8
+ txCollectionSlowReqRespIntervalMs: number;
9
+ /** How long to wait for a reqresp response during slow collection */
10
+ txCollectionSlowReqRespTimeoutMs: number;
11
+ /** How often to reconcile found txs with the tx pool */
12
+ txCollectionReconcileIntervalMs: number;
13
+ /** Whether to disable the slow collection loop if we are dealing with any immediate requests */
14
+ txCollectionDisableSlowDuringFastRequests: boolean;
15
+ /** How many ms to wait between retried request to a node via RPC during fast collection */
16
+ txCollectionFastNodeIntervalMs: number;
17
+ /** A comma-separated list of Aztec node RPC URLs to use for tx collection */
18
+ txCollectionNodeRpcUrls: string[];
19
+ /** Maximum number of parallel requests to make to a node during fast collection */
20
+ txCollectionFastMaxParallelRequestsPerNode: number;
21
+ /** Maximum number of transactions to request from a node in a single batch */
22
+ txCollectionNodeRpcMaxBatchSize: number;
23
+ };
24
+ export declare const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>;
25
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA2C,MAAM,0BAA0B,CAAC;AAG5G,MAAM,MAAM,kBAAkB,GAAG;IAC/B,oEAAoE;IACpE,2CAA2C,EAAE,MAAM,CAAC;IACpD,iDAAiD;IACjD,+BAA+B,EAAE,MAAM,CAAC;IACxC,sCAAsC;IACtC,iCAAiC,EAAE,MAAM,CAAC;IAC1C,qEAAqE;IACrE,gCAAgC,EAAE,MAAM,CAAC;IACzC,wDAAwD;IACxD,+BAA+B,EAAE,MAAM,CAAC;IACxC,gGAAgG;IAChG,yCAAyC,EAAE,OAAO,CAAC;IACnD,2FAA2F;IAC3F,8BAA8B,EAAE,MAAM,CAAC;IACvC,6EAA6E;IAC7E,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAClC,mFAAmF;IACnF,0CAA0C,EAAE,MAAM,CAAC;IACnD,8EAA8E;IAC9E,+BAA+B,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,CAAC,kBAAkB,CAyD7E,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
2
+ import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/server';
3
+ export const txCollectionConfigMappings = {
4
+ txCollectionFastNodesTimeoutBeforeReqRespMs: {
5
+ env: 'TX_COLLECTION_FAST_NODES_TIMEOUT_BEFORE_REQ_RESP_MS',
6
+ description: 'How long to wait before starting reqresp for fast collection',
7
+ ...numberConfigHelper(200)
8
+ },
9
+ txCollectionSlowNodesIntervalMs: {
10
+ env: 'TX_COLLECTION_SLOW_NODES_INTERVAL_MS',
11
+ description: 'How often to collect from configured nodes in the slow collection loop',
12
+ ...numberConfigHelper(12_000)
13
+ },
14
+ txCollectionSlowReqRespIntervalMs: {
15
+ env: 'TX_COLLECTION_SLOW_REQ_RESP_INTERVAL_MS',
16
+ description: 'How often to collect from peers via reqresp in the slow collection loop',
17
+ ...numberConfigHelper(12_000)
18
+ },
19
+ txCollectionSlowReqRespTimeoutMs: {
20
+ env: 'TX_COLLECTION_SLOW_REQ_RESP_TIMEOUT_MS',
21
+ description: 'How long to wait for a reqresp response during slow collection',
22
+ ...numberConfigHelper(20_000)
23
+ },
24
+ txCollectionReconcileIntervalMs: {
25
+ env: 'TX_COLLECTION_RECONCILE_INTERVAL_MS',
26
+ description: 'How often to reconcile found txs from the tx pool',
27
+ ...numberConfigHelper(60_000)
28
+ },
29
+ txCollectionDisableSlowDuringFastRequests: {
30
+ env: 'TX_COLLECTION_DISABLE_SLOW_DURING_FAST_REQUESTS',
31
+ description: 'Whether to disable the slow collection loop if we are dealing with any immediate requests',
32
+ ...booleanConfigHelper(true)
33
+ },
34
+ txCollectionFastNodeIntervalMs: {
35
+ env: 'TX_COLLECTION_FAST_NODE_INTERVAL_MS',
36
+ description: 'How many ms to wait between retried request to a node via RPC during fast collection',
37
+ ...numberConfigHelper(500)
38
+ },
39
+ txCollectionNodeRpcUrls: {
40
+ env: 'TX_COLLECTION_NODE_RPC_URLS',
41
+ fallback: [
42
+ 'PROVER_COORDINATION_NODE_URLS'
43
+ ],
44
+ description: 'A comma-separated list of Aztec node RPC URLs to use for tx collection',
45
+ parseEnv: (val)=>val.split(',').map((url)=>url.trim().replace(/\/$/, '')).filter((url)=>url.length > 0),
46
+ defaultValue: []
47
+ },
48
+ txCollectionFastMaxParallelRequestsPerNode: {
49
+ env: 'TX_COLLECTION_FAST_MAX_PARALLEL_REQUESTS_PER_NODE',
50
+ description: 'Maximum number of parallel requests to make to a node during fast collection',
51
+ ...numberConfigHelper(4)
52
+ },
53
+ txCollectionNodeRpcMaxBatchSize: {
54
+ env: 'TX_COLLECTION_NODE_RPC_MAX_BATCH_SIZE',
55
+ description: 'Maximum number of transactions to request from a node in a single batch',
56
+ ...numberConfigHelper(MAX_RPC_TXS_LEN)
57
+ }
58
+ };
@@ -0,0 +1,56 @@
1
+ import { type Logger } from '@aztec/foundation/log';
2
+ import { DateProvider } from '@aztec/foundation/timer';
3
+ import type { BlockProposal } from '@aztec/stdlib/p2p';
4
+ import { type Tx, TxHash } from '@aztec/stdlib/tx';
5
+ import type { PeerId } from '@libp2p/interface';
6
+ import { type ReqRespInterface } from '../reqresp/interface.js';
7
+ import type { TxCollectionConfig } from './config.js';
8
+ import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
9
+ import type { TxCollectionSink } from './tx_collection_sink.js';
10
+ import type { TxSource } from './tx_source.js';
11
+ export declare class FastTxCollection {
12
+ private reqResp;
13
+ private nodes;
14
+ private txCollectionSink;
15
+ private config;
16
+ private dateProvider;
17
+ private log;
18
+ protected requests: Set<FastCollectionRequest>;
19
+ constructor(reqResp: Pick<ReqRespInterface, 'sendBatchRequest'>, nodes: TxSource[], txCollectionSink: TxCollectionSink, config: TxCollectionConfig, dateProvider?: DateProvider, log?: Logger);
20
+ stop(): Promise<void>;
21
+ getFastCollectionRequests(): Set<FastCollectionRequest>;
22
+ collectFastFor(input: FastCollectionRequestInput, txHashes: TxHash[] | string[], opts: {
23
+ deadline: Date;
24
+ pinnedPeer?: PeerId;
25
+ }): Promise<Tx[]>;
26
+ protected collectFast(request: FastCollectionRequest, opts: {
27
+ proposal?: BlockProposal;
28
+ deadline: Date;
29
+ pinnedPeer?: PeerId;
30
+ }): Promise<void>;
31
+ /**
32
+ * Starts collecting txs from all configured nodes. We send `txCollectionFastMaxParallelRequestsPerNode` requests
33
+ * in parallel to each node. We keep track of the number of attempts made to collect each tx, so we can prioritize
34
+ * the txs that have been requested less often whenever we need to send a new batch of requests. We ensure that no
35
+ * tx is requested more than once at the same time to the same node.
36
+ */
37
+ private collectFastFromNodes;
38
+ private collectFastFromNode;
39
+ private collectFastViaReqResp;
40
+ /**
41
+ * Handle txs by marking them as found for the requests that are waiting for them, and resolves the request if all its txs have been found.
42
+ * Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
43
+ */
44
+ foundTxs(txs: Tx[]): void;
45
+ /**
46
+ * Stop collecting all txs for blocks less than or requal to the block number specified.
47
+ * To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
48
+ */
49
+ stopCollectingForBlocksUpTo(blockNumber: number): void;
50
+ /**
51
+ * Stop collecting all txs for blocks greater than the block number specified.
52
+ * To be called when there is a chain prune and previously mined txs are no longer relevant.
53
+ */
54
+ stopCollectingForBlocksAfter(blockNumber: number): void;
55
+ }
56
+ //# sourceMappingURL=fast_tx_collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fast_tx_collection.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/fast_tx_collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EAAE,YAAY,EAAW,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAEpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,GAAG;IARb,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,qBAAqB,CAAC,CAAa;gBAGjD,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,EACnD,KAAK,EAAE,QAAQ,EAAE,EACjB,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,GAAE,YAAiC,EAC/C,GAAG,GAAE,MAAkD;IAGpD,IAAI;IAKV,yBAAyB;IAInB,cAAc,CACzB,KAAK,EAAE,0BAA0B,EACjC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAC7B,IAAI,EAAE;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;cA4C/B,WAAW,CACzB,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE;QAAE,QAAQ,CAAC,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAiDzE;;;;;OAKG;YACW,oBAAoB;YAYpB,mBAAmB;YAiFnB,qBAAqB;IA6CnC;;;OAGG;IACI,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE;IA0BzB;;;OAGG;IACI,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAS7D;;;OAGG;IACI,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAQ/D"}
@@ -0,0 +1,300 @@
1
+ import { times } from '@aztec/foundation/collection';
2
+ import { AbortError, TimeoutError } from '@aztec/foundation/error';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ import { boundInclusive } from '@aztec/foundation/number';
5
+ import { promiseWithResolvers } from '@aztec/foundation/promise';
6
+ import { sleep } from '@aztec/foundation/sleep';
7
+ import { DateProvider, elapsed } from '@aztec/foundation/timer';
8
+ import { TxHash } from '@aztec/stdlib/tx';
9
+ import { ReqRespSubProtocol } from '../reqresp/interface.js';
10
+ import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
11
+ export class FastTxCollection {
12
+ reqResp;
13
+ nodes;
14
+ txCollectionSink;
15
+ config;
16
+ dateProvider;
17
+ log;
18
+ // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
19
+ requests;
20
+ constructor(reqResp, nodes, txCollectionSink, config, dateProvider = new DateProvider(), log = createLogger('p2p:tx_collection_service')){
21
+ this.reqResp = reqResp;
22
+ this.nodes = nodes;
23
+ this.txCollectionSink = txCollectionSink;
24
+ this.config = config;
25
+ this.dateProvider = dateProvider;
26
+ this.log = log;
27
+ this.requests = new Set();
28
+ }
29
+ async stop() {
30
+ this.requests.forEach((request)=>request.promise.reject(new AbortError(`Stopped collection service`)));
31
+ await Promise.resolve();
32
+ }
33
+ getFastCollectionRequests() {
34
+ return this.requests;
35
+ }
36
+ async collectFastFor(input, txHashes, opts) {
37
+ const timeout = opts.deadline.getTime() - this.dateProvider.now();
38
+ if (timeout <= 0) {
39
+ this.log.warn(`Deadline for fast tx collection is in the past (${timeout}ms)`, {
40
+ deadline: opts.deadline.getTime(),
41
+ now: this.dateProvider.now()
42
+ });
43
+ return [];
44
+ }
45
+ const blockInfo = input.type === 'proposal' ? {
46
+ ...input.blockProposal.toBlockInfo(),
47
+ blockNumber: input.blockNumber
48
+ } : {
49
+ ...input.block.toBlockInfo()
50
+ };
51
+ // This promise is used to await for the collection to finish during the main collectFast method.
52
+ // It gets resolved in `foundTxs` when all txs have been collected, or rejected if the request is aborted or hits the deadline.
53
+ const promise = promiseWithResolvers();
54
+ setTimeout(()=>promise.reject(new TimeoutError(`Timed out while collecting txs`)), timeout);
55
+ const request = {
56
+ ...input,
57
+ blockInfo,
58
+ promise,
59
+ foundTxs: new Map(),
60
+ missingTxHashes: new Set(txHashes.map((t)=>t.toString())),
61
+ deadline: opts.deadline
62
+ };
63
+ const [duration] = await elapsed(()=>this.collectFast(request, {
64
+ ...opts
65
+ }));
66
+ this.log.verbose(`Collected ${request.foundTxs.size} txs out of ${txHashes.length} for ${input.type} at slot ${blockInfo.slotNumber}`, {
67
+ ...blockInfo,
68
+ duration,
69
+ requestType: input.type,
70
+ missingTxs: [
71
+ ...request.missingTxHashes
72
+ ]
73
+ });
74
+ return [
75
+ ...request.foundTxs.values()
76
+ ];
77
+ }
78
+ async collectFast(request, opts) {
79
+ this.requests.add(request);
80
+ const { blockInfo } = request;
81
+ this.log.debug(`Starting fast collection of ${request.missingTxHashes.size} txs for ${request.type} at slot ${blockInfo.slotNumber}`, {
82
+ ...blockInfo,
83
+ requestType: request.type,
84
+ deadline: opts.deadline
85
+ });
86
+ try {
87
+ // Start blasting all nodes for the txs. We give them a little time to respond before we start reqresp.
88
+ // And keep an eye on the request promise to ensure we don't wait longer than the deadline or return as soon
89
+ // as we have collected all txs, whatever the source.
90
+ const nodeCollectionPromise = this.collectFastFromNodes(request, opts);
91
+ const waitBeforeReqResp = sleep(this.config.txCollectionFastNodesTimeoutBeforeReqRespMs);
92
+ await Promise.race([
93
+ request.promise.promise,
94
+ waitBeforeReqResp
95
+ ]);
96
+ // If we have collected all txs, we can stop here
97
+ if (request.missingTxHashes.size === 0) {
98
+ this.log.debug(`All txs collected for slot ${blockInfo.slotNumber} without reqresp`, blockInfo);
99
+ return;
100
+ }
101
+ // Start blasting reqresp for the remaining txs. Note that node collection keeps running in parallel.
102
+ // We stop when we have collected all txs, timed out, or both node collection and reqresp have given up.
103
+ const collectionPromise = Promise.allSettled([
104
+ this.collectFastViaReqResp(request, opts),
105
+ nodeCollectionPromise
106
+ ]);
107
+ await Promise.race([
108
+ collectionPromise,
109
+ request.promise.promise
110
+ ]);
111
+ } catch (err) {
112
+ // Log and swallow all errors
113
+ const logCtx = {
114
+ ...blockInfo,
115
+ errorMessage: err instanceof Error ? err.message : undefined,
116
+ missingTxs: [
117
+ ...request.missingTxHashes
118
+ ].map((txHash)=>txHash.toString())
119
+ };
120
+ if (err instanceof Error && err.name === 'TimeoutError') {
121
+ this.log.warn(`Timed out collecting txs for ${request.type} at slot ${blockInfo.slotNumber}`, logCtx);
122
+ } else if (err instanceof Error && err.name === 'AbortError') {
123
+ this.log.warn(`Aborted collecting txs for ${request.type} at slot ${blockInfo.slotNumber}`, logCtx);
124
+ } else {
125
+ this.log.error(`Error collecting txs for ${request.type} for slot ${blockInfo.slotNumber}`, err, logCtx);
126
+ }
127
+ } finally{
128
+ // Ensure no unresolved promises and remove the request from the set
129
+ request.promise.resolve();
130
+ this.requests.delete(request);
131
+ }
132
+ }
133
+ /**
134
+ * Starts collecting txs from all configured nodes. We send `txCollectionFastMaxParallelRequestsPerNode` requests
135
+ * in parallel to each node. We keep track of the number of attempts made to collect each tx, so we can prioritize
136
+ * the txs that have been requested less often whenever we need to send a new batch of requests. We ensure that no
137
+ * tx is requested more than once at the same time to the same node.
138
+ */ async collectFastFromNodes(request, opts) {
139
+ if (this.nodes.length === 0) {
140
+ return;
141
+ }
142
+ // Keep a shared priority queue of all txs pending to be requested, sorted by the number of attempts made to collect them.
143
+ const attemptsPerTx = [
144
+ ...request.missingTxHashes
145
+ ].map((txHash)=>({
146
+ txHash,
147
+ attempts: 0,
148
+ found: false
149
+ }));
150
+ // Returns once we have finished all node loops. Each loop finishes when the deadline is hit, or all txs have been collected.
151
+ await Promise.allSettled(this.nodes.map((node)=>this.collectFastFromNode(request, node, attemptsPerTx, opts)));
152
+ }
153
+ async collectFastFromNode(request, node, attemptsPerTx, opts) {
154
+ const notFinished = ()=>this.dateProvider.now() <= +opts.deadline && request.missingTxHashes.size > 0 && this.requests.has(request);
155
+ const maxParallelRequests = this.config.txCollectionFastMaxParallelRequestsPerNode;
156
+ const maxBatchSize = this.config.txCollectionNodeRpcMaxBatchSize;
157
+ const activeRequestsToThisNode = new Set(); // Track the txs being actively requested to this node
158
+ const processBatch = async ()=>{
159
+ while(notFinished()){
160
+ // Pull tx hashes from the attemptsPerTx array, which is sorted by attempts,
161
+ // so we prioritize txs that have been requested less often.
162
+ const batch = [];
163
+ let index = 0;
164
+ while(batch.length < maxBatchSize){
165
+ const txToRequest = attemptsPerTx[index++];
166
+ if (!txToRequest) {
167
+ break;
168
+ } else if (!request.missingTxHashes.has(txToRequest.txHash)) {
169
+ // Mark as found if it was found somewhere else, we'll then remove it from the array.
170
+ // We don't delete it now since 'array.splice' is pretty expensive, so we do it after sorting.
171
+ txToRequest.found = true;
172
+ } else if (!activeRequestsToThisNode.has(txToRequest.txHash)) {
173
+ // If the tx is not alredy being requested to this node, add it to the current batch and increase attempts.
174
+ // Note that we increase the attempts *before* making the request, so the next `collectFastFromNode` that
175
+ // needs to grab txs to send, will pick txs that have been requested less often, instead of all requesting
176
+ // the same txs at the same time.
177
+ batch.push(txToRequest);
178
+ activeRequestsToThisNode.add(txToRequest.txHash);
179
+ txToRequest.attempts++;
180
+ }
181
+ }
182
+ // After modifying the array by removing txs or updating attempts, re-sort it and trim the found txs from the end.
183
+ attemptsPerTx.sort((a, b)=>a.found === b.found ? a.attempts - b.attempts : Number(a.found) - Number(b.found));
184
+ const firstFoundTxIndex = attemptsPerTx.findIndex((tx)=>tx.found);
185
+ if (firstFoundTxIndex !== -1) {
186
+ attemptsPerTx.length = firstFoundTxIndex;
187
+ }
188
+ // If we see no more txs to request, we can stop this "process" loop
189
+ if (batch.length === 0) {
190
+ return;
191
+ }
192
+ // Collect this batch from the node
193
+ await this.txCollectionSink.collect((txHashes)=>node.getTxsByHash(txHashes), batch.map(({ txHash })=>TxHash.fromString(txHash)), {
194
+ description: `fast ${node.getInfo()}`,
195
+ node: node.getInfo(),
196
+ method: 'fast-node-rpc',
197
+ ...request.blockInfo
198
+ });
199
+ // Clear from the active requests the txs we just requested
200
+ for (const requestedTx of batch){
201
+ activeRequestsToThisNode.delete(requestedTx.txHash);
202
+ }
203
+ // Sleep a bit until hitting the node again (or not, depending on config)
204
+ if (notFinished()) {
205
+ await sleep(this.config.txCollectionFastNodeIntervalMs);
206
+ }
207
+ }
208
+ };
209
+ // Kick off N parallel requests to the node, up to the maxParallelRequests limit
210
+ await Promise.all(times(maxParallelRequests, processBatch));
211
+ }
212
+ async collectFastViaReqResp(request, opts) {
213
+ const timeoutMs = +request.deadline - this.dateProvider.now();
214
+ const pinnedPeer = opts.pinnedPeer;
215
+ const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
216
+ const maxRetryAttempts = 5;
217
+ const blockInfo = request.blockInfo;
218
+ const slotNumber = blockInfo.slotNumber;
219
+ if (timeoutMs < 100) {
220
+ this.log.warn(`Not initiating fast reqresp for txs for ${request.type} at slot ${blockInfo.slotNumber} due to timeout`, {
221
+ timeoutMs,
222
+ ...blockInfo
223
+ });
224
+ return;
225
+ }
226
+ this.log.debug(`Starting fast reqresp for ${request.missingTxHashes.size} txs for ${request.type} at slot ${blockInfo.slotNumber}`, {
227
+ ...blockInfo,
228
+ timeoutMs,
229
+ pinnedPeer
230
+ });
231
+ try {
232
+ await this.txCollectionSink.collect(async (txHashes)=>{
233
+ const txs = await this.reqResp.sendBatchRequest(ReqRespSubProtocol.TX, chunkTxHashesRequest(txHashes), pinnedPeer, timeoutMs, maxPeers, maxRetryAttempts);
234
+ return txs.flat();
235
+ }, Array.from(request.missingTxHashes).map((txHash)=>TxHash.fromString(txHash)), {
236
+ description: `reqresp for slot ${slotNumber}`,
237
+ method: 'fast-req-resp',
238
+ ...opts,
239
+ ...request.blockInfo
240
+ });
241
+ } catch (err) {
242
+ this.log.error(`Error sending fast reqresp request for txs`, err, {
243
+ txs: [
244
+ ...request.missingTxHashes
245
+ ],
246
+ ...blockInfo
247
+ });
248
+ }
249
+ }
250
+ /**
251
+ * Handle txs by marking them as found for the requests that are waiting for them, and resolves the request if all its txs have been found.
252
+ * Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
253
+ */ foundTxs(txs) {
254
+ for (const request of this.requests){
255
+ for (const tx of txs){
256
+ const txHash = tx.txHash.toString();
257
+ // Remove the tx hash from the missing set, and add it to the found set.
258
+ if (request.missingTxHashes.has(txHash)) {
259
+ request.missingTxHashes.delete(txHash);
260
+ request.foundTxs.set(txHash, tx);
261
+ this.log.trace(`Found tx ${txHash} for fast collection request`, {
262
+ ...request.blockInfo,
263
+ txHash: tx.txHash.toString(),
264
+ type: request.type
265
+ });
266
+ // If we found all txs for this request, we resolve the promise
267
+ if (request.missingTxHashes.size === 0) {
268
+ this.log.trace(`All txs found for fast collection request`, {
269
+ ...request.blockInfo,
270
+ type: request.type
271
+ });
272
+ request.promise.resolve();
273
+ }
274
+ }
275
+ }
276
+ }
277
+ }
278
+ /**
279
+ * Stop collecting all txs for blocks less than or requal to the block number specified.
280
+ * To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
281
+ */ stopCollectingForBlocksUpTo(blockNumber) {
282
+ for (const request of this.requests){
283
+ if (request.blockInfo.blockNumber <= blockNumber) {
284
+ request.promise.reject(new AbortError(`Stopped collecting txs up to block ${blockNumber}`));
285
+ this.requests.delete(request);
286
+ }
287
+ }
288
+ }
289
+ /**
290
+ * Stop collecting all txs for blocks greater than the block number specified.
291
+ * To be called when there is a chain prune and previously mined txs are no longer relevant.
292
+ */ stopCollectingForBlocksAfter(blockNumber) {
293
+ for (const request of this.requests){
294
+ if (request.blockInfo.blockNumber > blockNumber) {
295
+ request.promise.reject(new AbortError(`Stopped collecting txs after block ${blockNumber}`));
296
+ this.requests.delete(request);
297
+ }
298
+ }
299
+ }
300
+ }
@@ -0,0 +1,3 @@
1
+ export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
2
+ export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,KAAK,QAAQ,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { TxCollection } from './tx_collection.js';
2
+ export { createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
@@ -0,0 +1,10 @@
1
+ import { type TelemetryClient } from '@aztec/telemetry-client';
2
+ import type { CollectionMethod } from './tx_collection.js';
3
+ export declare class TxCollectionInstrumentation {
4
+ private txsCollected;
5
+ private collectionDurationPerTx;
6
+ private collectionDurationPerRequest;
7
+ constructor(client: TelemetryClient, name: string);
8
+ increaseTxsFor(what: CollectionMethod, count: number, duration: number): void;
9
+ }
10
+ //# sourceMappingURL=instrumentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,uBAAuB,CAAY;IAC3C,OAAO,CAAC,4BAA4B,CAAY;gBAEpC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAoBjD,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAMvE"}