@aztec/p2p 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97

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 (605) hide show
  1. package/README.md +129 -3
  2. package/dest/bootstrap/bootstrap.d.ts +4 -3
  3. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  4. package/dest/bootstrap/bootstrap.js +13 -5
  5. package/dest/client/factory.d.ts +13 -12
  6. package/dest/client/factory.d.ts.map +1 -1
  7. package/dest/client/factory.js +65 -21
  8. package/dest/client/index.d.ts +1 -1
  9. package/dest/client/interface.d.ts +72 -35
  10. package/dest/client/interface.d.ts.map +1 -1
  11. package/dest/client/p2p_client.d.ts +59 -86
  12. package/dest/client/p2p_client.d.ts.map +1 -1
  13. package/dest/client/p2p_client.js +677 -339
  14. package/dest/config.d.ts +169 -87
  15. package/dest/config.d.ts.map +1 -1
  16. package/dest/config.js +176 -56
  17. package/dest/enr/generate-enr.d.ts +1 -1
  18. package/dest/enr/index.d.ts +1 -1
  19. package/dest/errors/attestation-pool.error.d.ts +7 -0
  20. package/dest/errors/attestation-pool.error.d.ts.map +1 -0
  21. package/dest/errors/attestation-pool.error.js +12 -0
  22. package/dest/errors/p2p-service.error.d.ts +9 -0
  23. package/dest/errors/p2p-service.error.d.ts.map +1 -0
  24. package/dest/errors/p2p-service.error.js +10 -0
  25. package/dest/errors/reqresp.error.d.ts +1 -20
  26. package/dest/errors/reqresp.error.d.ts.map +1 -1
  27. package/dest/errors/reqresp.error.js +0 -21
  28. package/dest/errors/tx-pool.error.d.ts +8 -0
  29. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  30. package/dest/errors/tx-pool.error.js +9 -0
  31. package/dest/index.d.ts +2 -2
  32. package/dest/index.d.ts.map +1 -1
  33. package/dest/index.js +1 -1
  34. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +154 -57
  35. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  36. package/dest/mem_pools/attestation_pool/attestation_pool.js +511 -3
  37. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  38. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  39. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +651 -294
  40. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  41. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  42. package/dest/mem_pools/attestation_pool/index.js +1 -2
  43. package/dest/mem_pools/attestation_pool/mocks.d.ts +234 -10
  44. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  45. package/dest/mem_pools/attestation_pool/mocks.js +19 -13
  46. package/dest/mem_pools/index.d.ts +3 -3
  47. package/dest/mem_pools/index.d.ts.map +1 -1
  48. package/dest/mem_pools/index.js +1 -1
  49. package/dest/mem_pools/instrumentation.d.ts +11 -1
  50. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  51. package/dest/mem_pools/instrumentation.js +55 -10
  52. package/dest/mem_pools/interface.d.ts +6 -7
  53. package/dest/mem_pools/interface.d.ts.map +1 -1
  54. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  55. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  56. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  57. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +39 -0
  58. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  59. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +97 -0
  60. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  61. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  62. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +94 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +11 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/index.js +12 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
  76. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
  77. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
  78. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +180 -0
  79. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  80. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
  81. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  82. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  83. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
  84. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  85. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  86. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  87. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  88. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  89. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
  90. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  91. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  92. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +75 -0
  93. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  94. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  95. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  96. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  97. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  98. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  99. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  100. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  101. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  102. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +218 -0
  103. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  104. package/dest/mem_pools/tx_pool_v2/interfaces.js +10 -0
  105. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +137 -0
  106. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  107. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +223 -0
  108. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  109. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  110. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  111. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
  112. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  113. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +337 -0
  114. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +62 -0
  115. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  116. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +167 -0
  117. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +78 -0
  118. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  119. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +914 -0
  120. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +14 -7
  121. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  122. package/dest/msg_validators/attestation_validator/attestation_validator.js +84 -26
  123. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +24 -0
  124. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
  125. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +75 -0
  126. package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
  127. package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
  128. package/dest/msg_validators/attestation_validator/index.js +1 -0
  129. package/dest/msg_validators/clock_tolerance.d.ts +32 -0
  130. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  131. package/dest/msg_validators/clock_tolerance.js +90 -0
  132. package/dest/msg_validators/index.d.ts +2 -2
  133. package/dest/msg_validators/index.d.ts.map +1 -1
  134. package/dest/msg_validators/index.js +1 -1
  135. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
  136. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
  137. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +15 -0
  138. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
  139. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +14 -0
  140. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +15 -0
  141. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
  142. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +20 -0
  143. package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
  144. package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
  145. package/dest/msg_validators/proposal_validator/index.js +3 -0
  146. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +26 -0
  147. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
  148. package/dest/msg_validators/proposal_validator/proposal_validator.js +150 -0
  149. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
  150. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  151. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +11 -18
  152. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  153. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  154. package/dest/msg_validators/tx_validator/allowed_public_setup.js +25 -21
  155. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  156. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  157. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  158. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  159. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  160. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
  161. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  162. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  163. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
  164. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
  165. package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
  166. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  167. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  168. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  169. package/dest/msg_validators/tx_validator/data_validator.d.ts +4 -1
  170. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  171. package/dest/msg_validators/tx_validator/data_validator.js +40 -3
  172. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
  173. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  174. package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
  175. package/dest/msg_validators/tx_validator/factory.d.ts +140 -6
  176. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  177. package/dest/msg_validators/tx_validator/factory.js +259 -58
  178. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
  179. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
  180. package/dest/msg_validators/tx_validator/fee_payer_balance.js +24 -0
  181. package/dest/msg_validators/tx_validator/gas_validator.d.ts +100 -3
  182. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  183. package/dest/msg_validators/tx_validator/gas_validator.js +146 -67
  184. package/dest/msg_validators/tx_validator/index.d.ts +6 -1
  185. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  186. package/dest/msg_validators/tx_validator/index.js +5 -0
  187. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +4 -3
  188. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  189. package/dest/msg_validators/tx_validator/metadata_validator.js +6 -6
  190. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  191. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  192. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  193. package/dest/msg_validators/tx_validator/phases_validator.d.ts +24 -3
  194. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  195. package/dest/msg_validators/tx_validator/phases_validator.js +78 -28
  196. package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
  197. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
  198. package/dest/msg_validators/tx_validator/size_validator.js +23 -0
  199. package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
  200. package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
  201. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +23 -5
  202. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  203. package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
  204. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  205. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  206. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  207. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +4 -2
  208. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  209. package/dest/msg_validators/tx_validator/tx_proof_validator.js +4 -2
  210. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
  211. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
  212. package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
  213. package/dest/services/data_store.d.ts +1 -1
  214. package/dest/services/data_store.d.ts.map +1 -1
  215. package/dest/services/data_store.js +14 -10
  216. package/dest/services/discv5/discV5_service.d.ts +2 -1
  217. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  218. package/dest/services/discv5/discV5_service.js +36 -9
  219. package/dest/services/dummy_service.d.ts +36 -16
  220. package/dest/services/dummy_service.d.ts.map +1 -1
  221. package/dest/services/dummy_service.js +58 -14
  222. package/dest/services/encoding.d.ts +7 -3
  223. package/dest/services/encoding.d.ts.map +1 -1
  224. package/dest/services/encoding.js +23 -15
  225. package/dest/services/gossipsub/index.d.ts +3 -0
  226. package/dest/services/gossipsub/index.d.ts.map +1 -0
  227. package/dest/services/gossipsub/index.js +2 -0
  228. package/dest/services/gossipsub/scoring.d.ts +21 -3
  229. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  230. package/dest/services/gossipsub/scoring.js +24 -7
  231. package/dest/services/gossipsub/topic_score_params.d.ts +184 -0
  232. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  233. package/dest/services/gossipsub/topic_score_params.js +363 -0
  234. package/dest/services/index.d.ts +2 -1
  235. package/dest/services/index.d.ts.map +1 -1
  236. package/dest/services/index.js +1 -0
  237. package/dest/services/libp2p/instrumentation.d.ts +5 -1
  238. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  239. package/dest/services/libp2p/instrumentation.js +49 -70
  240. package/dest/services/libp2p/libp2p_service.d.ts +118 -109
  241. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  242. package/dest/services/libp2p/libp2p_service.js +1286 -430
  243. package/dest/services/peer-manager/interface.d.ts +1 -1
  244. package/dest/services/peer-manager/metrics.d.ts +11 -2
  245. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  246. package/dest/services/peer-manager/metrics.js +45 -16
  247. package/dest/services/peer-manager/peer_manager.d.ts +7 -34
  248. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  249. package/dest/services/peer-manager/peer_manager.js +46 -23
  250. package/dest/services/peer-manager/peer_scoring.d.ts +12 -2
  251. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  252. package/dest/services/peer-manager/peer_scoring.js +99 -13
  253. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +44 -0
  254. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  255. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +534 -0
  256. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  257. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  258. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  259. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
  260. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  261. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  262. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +35 -0
  263. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  264. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +136 -0
  265. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +62 -0
  266. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  267. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +176 -0
  268. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +11 -0
  269. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  270. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +7 -0
  271. package/dest/services/reqresp/config.d.ts +3 -3
  272. package/dest/services/reqresp/config.d.ts.map +1 -1
  273. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -4
  274. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  275. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  276. package/dest/services/reqresp/constants.d.ts +12 -0
  277. package/dest/services/reqresp/constants.d.ts.map +1 -0
  278. package/dest/services/reqresp/constants.js +7 -0
  279. package/dest/services/reqresp/index.d.ts +1 -1
  280. package/dest/services/reqresp/interface.d.ts +27 -18
  281. package/dest/services/reqresp/interface.d.ts.map +1 -1
  282. package/dest/services/reqresp/interface.js +23 -19
  283. package/dest/services/reqresp/metrics.d.ts +6 -5
  284. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  285. package/dest/services/reqresp/metrics.js +16 -21
  286. package/dest/services/reqresp/protocols/auth.d.ts +2 -2
  287. package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
  288. package/dest/services/reqresp/protocols/auth.js +2 -2
  289. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +8 -3
  290. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  291. package/dest/services/reqresp/protocols/block_txs/bitvector.js +15 -2
  292. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  293. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  294. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +35 -14
  295. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +37 -11
  296. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  297. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +85 -21
  298. package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
  299. package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
  300. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  301. package/dest/services/reqresp/protocols/index.d.ts +1 -2
  302. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  303. package/dest/services/reqresp/protocols/index.js +0 -1
  304. package/dest/services/reqresp/protocols/ping.d.ts +1 -1
  305. package/dest/services/reqresp/protocols/status.d.ts +6 -5
  306. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  307. package/dest/services/reqresp/protocols/status.js +7 -3
  308. package/dest/services/reqresp/protocols/tx.d.ts +8 -3
  309. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  310. package/dest/services/reqresp/protocols/tx.js +21 -3
  311. package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
  312. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +6 -5
  313. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  314. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
  315. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  316. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  317. package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
  318. package/dest/services/reqresp/reqresp.d.ts +12 -69
  319. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  320. package/dest/services/reqresp/reqresp.js +448 -199
  321. package/dest/services/reqresp/status.d.ts +2 -2
  322. package/dest/services/reqresp/status.d.ts.map +1 -1
  323. package/dest/services/service.d.ts +62 -13
  324. package/dest/services/service.d.ts.map +1 -1
  325. package/dest/services/tx_collection/config.d.ts +11 -11
  326. package/dest/services/tx_collection/config.d.ts.map +1 -1
  327. package/dest/services/tx_collection/config.js +28 -27
  328. package/dest/services/tx_collection/file_store_tx_collection.d.ts +37 -0
  329. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  330. package/dest/services/tx_collection/file_store_tx_collection.js +127 -0
  331. package/dest/services/tx_collection/file_store_tx_source.d.ts +38 -0
  332. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  333. package/dest/services/tx_collection/file_store_tx_source.js +100 -0
  334. package/dest/services/tx_collection/index.d.ts +3 -2
  335. package/dest/services/tx_collection/index.d.ts.map +1 -1
  336. package/dest/services/tx_collection/index.js +1 -0
  337. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  338. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  339. package/dest/services/tx_collection/instrumentation.js +9 -13
  340. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  341. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  342. package/dest/services/tx_collection/request_tracker.js +84 -0
  343. package/dest/services/tx_collection/tx_collection.d.ts +51 -57
  344. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  345. package/dest/services/tx_collection/tx_collection.js +298 -70
  346. package/dest/services/tx_collection/tx_collection_sink.d.ts +20 -10
  347. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  348. package/dest/services/tx_collection/tx_collection_sink.js +28 -31
  349. package/dest/services/tx_collection/tx_source.d.ts +13 -7
  350. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  351. package/dest/services/tx_collection/tx_source.js +26 -7
  352. package/dest/services/tx_file_store/config.d.ts +16 -0
  353. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  354. package/dest/services/tx_file_store/config.js +22 -0
  355. package/dest/services/tx_file_store/index.d.ts +4 -0
  356. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  357. package/dest/services/tx_file_store/index.js +3 -0
  358. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  359. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  360. package/dest/services/tx_file_store/instrumentation.js +29 -0
  361. package/dest/services/tx_file_store/tx_file_store.d.ts +46 -0
  362. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  363. package/dest/services/tx_file_store/tx_file_store.js +142 -0
  364. package/dest/services/tx_provider.d.ts +9 -5
  365. package/dest/services/tx_provider.d.ts.map +1 -1
  366. package/dest/services/tx_provider.js +23 -10
  367. package/dest/services/tx_provider_instrumentation.d.ts +5 -2
  368. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  369. package/dest/services/tx_provider_instrumentation.js +14 -14
  370. package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
  371. package/dest/test-helpers/get-ports.d.ts +1 -1
  372. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  373. package/dest/test-helpers/index.d.ts +3 -1
  374. package/dest/test-helpers/index.d.ts.map +1 -1
  375. package/dest/test-helpers/index.js +2 -0
  376. package/dest/test-helpers/make-enrs.d.ts +1 -1
  377. package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
  378. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  379. package/dest/test-helpers/make-test-p2p-clients.js +5 -3
  380. package/dest/test-helpers/mock-pubsub.d.ts +48 -8
  381. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  382. package/dest/test-helpers/mock-pubsub.js +115 -14
  383. package/dest/test-helpers/mock-tx-helpers.d.ts +2 -2
  384. package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -1
  385. package/dest/test-helpers/mock-tx-helpers.js +1 -1
  386. package/dest/test-helpers/reqresp-nodes.d.ts +5 -7
  387. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  388. package/dest/test-helpers/reqresp-nodes.js +19 -20
  389. package/dest/test-helpers/test_tx_provider.d.ts +42 -0
  390. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  391. package/dest/test-helpers/test_tx_provider.js +44 -0
  392. package/dest/test-helpers/testbench-utils.d.ts +161 -0
  393. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  394. package/dest/test-helpers/testbench-utils.js +391 -0
  395. package/dest/testbench/p2p_client_testbench_worker.d.ts +26 -2
  396. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  397. package/dest/testbench/p2p_client_testbench_worker.js +275 -131
  398. package/dest/testbench/parse_log_file.d.ts +1 -1
  399. package/dest/testbench/testbench.d.ts +1 -1
  400. package/dest/testbench/worker_client_manager.d.ts +57 -6
  401. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  402. package/dest/testbench/worker_client_manager.js +277 -44
  403. package/dest/types/index.d.ts +1 -1
  404. package/dest/util.d.ts +14 -8
  405. package/dest/util.d.ts.map +1 -1
  406. package/dest/util.js +41 -11
  407. package/dest/versioning.d.ts +3 -6
  408. package/dest/versioning.d.ts.map +1 -1
  409. package/dest/versioning.js +3 -24
  410. package/package.json +20 -18
  411. package/src/bootstrap/bootstrap.ts +16 -5
  412. package/src/client/factory.ts +137 -46
  413. package/src/client/interface.ts +87 -43
  414. package/src/client/p2p_client.ts +352 -418
  415. package/src/client/test/p2p_client.batch_tx_requester.bench.README.md +197 -0
  416. package/src/config.ts +302 -65
  417. package/src/errors/attestation-pool.error.ts +13 -0
  418. package/src/errors/p2p-service.error.ts +11 -0
  419. package/src/errors/reqresp.error.ts +0 -25
  420. package/src/errors/tx-pool.error.ts +12 -0
  421. package/src/index.ts +1 -1
  422. package/src/mem_pools/attestation_pool/attestation_pool.ts +588 -56
  423. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +760 -319
  424. package/src/mem_pools/attestation_pool/index.ts +9 -2
  425. package/src/mem_pools/attestation_pool/mocks.ts +29 -17
  426. package/src/mem_pools/index.ts +2 -2
  427. package/src/mem_pools/instrumentation.ts +56 -10
  428. package/src/mem_pools/interface.ts +5 -7
  429. package/src/mem_pools/tx_pool_v2/README.md +283 -0
  430. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  431. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +112 -0
  432. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  433. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  434. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +122 -0
  435. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
  436. package/src/mem_pools/tx_pool_v2/eviction/index.ts +28 -0
  437. package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
  438. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +219 -0
  439. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  440. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  441. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
  442. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +99 -0
  443. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +32 -0
  444. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  445. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  446. package/src/mem_pools/tx_pool_v2/interfaces.ts +250 -0
  447. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +349 -0
  448. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  449. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +430 -0
  450. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +238 -0
  451. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1090 -0
  452. package/src/msg_validators/attestation_validator/README.md +49 -0
  453. package/src/msg_validators/attestation_validator/attestation_validator.ts +78 -33
  454. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +101 -0
  455. package/src/msg_validators/attestation_validator/index.ts +1 -0
  456. package/src/msg_validators/clock_tolerance.ts +121 -0
  457. package/src/msg_validators/index.ts +1 -1
  458. package/src/msg_validators/proposal_validator/README.md +123 -0
  459. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +30 -0
  460. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +41 -0
  461. package/src/msg_validators/proposal_validator/index.ts +3 -0
  462. package/src/msg_validators/proposal_validator/proposal_validator.ts +159 -0
  463. package/src/msg_validators/tx_validator/README.md +127 -0
  464. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +8 -17
  465. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  466. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  467. package/src/msg_validators/tx_validator/archive_cache.ts +2 -2
  468. package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
  469. package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
  470. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  471. package/src/msg_validators/tx_validator/data_validator.ts +62 -7
  472. package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
  473. package/src/msg_validators/tx_validator/factory.ts +427 -58
  474. package/src/msg_validators/tx_validator/fee_payer_balance.ts +44 -0
  475. package/src/msg_validators/tx_validator/gas_validator.ts +211 -77
  476. package/src/msg_validators/tx_validator/index.ts +5 -0
  477. package/src/msg_validators/tx_validator/metadata_validator.ts +31 -12
  478. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  479. package/src/msg_validators/tx_validator/phases_validator.ts +90 -31
  480. package/src/msg_validators/tx_validator/size_validator.ts +22 -0
  481. package/src/msg_validators/tx_validator/test_utils.ts +1 -1
  482. package/src/msg_validators/tx_validator/timestamp_validator.ts +30 -19
  483. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  484. package/src/msg_validators/tx_validator/tx_proof_validator.ts +10 -3
  485. package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
  486. package/src/services/data_store.ts +14 -19
  487. package/src/services/discv5/discV5_service.ts +39 -6
  488. package/src/services/dummy_service.ts +76 -38
  489. package/src/services/encoding.ts +22 -13
  490. package/src/services/gossipsub/README.md +641 -0
  491. package/src/services/gossipsub/index.ts +2 -0
  492. package/src/services/gossipsub/scoring.ts +29 -5
  493. package/src/services/gossipsub/topic_score_params.ts +519 -0
  494. package/src/services/index.ts +1 -0
  495. package/src/services/libp2p/instrumentation.ts +54 -72
  496. package/src/services/libp2p/libp2p_service.ts +1032 -480
  497. package/src/services/peer-manager/metrics.ts +51 -16
  498. package/src/services/peer-manager/peer_manager.ts +53 -15
  499. package/src/services/peer-manager/peer_scoring.ts +96 -7
  500. package/src/services/reqresp/README.md +215 -0
  501. package/src/services/reqresp/batch-tx-requester/README.md +344 -0
  502. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +660 -0
  503. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  504. package/src/services/reqresp/batch-tx-requester/interface.ts +61 -0
  505. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +168 -0
  506. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +249 -0
  507. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +24 -0
  508. package/src/services/reqresp/config.ts +2 -2
  509. package/src/services/reqresp/connection-sampler/connection_sampler.ts +19 -1
  510. package/src/services/reqresp/constants.ts +14 -0
  511. package/src/services/reqresp/interface.ts +48 -46
  512. package/src/services/reqresp/metrics.ts +35 -27
  513. package/src/services/reqresp/protocols/auth.ts +2 -2
  514. package/src/services/reqresp/protocols/block_txs/bitvector.ts +19 -2
  515. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +44 -17
  516. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +109 -17
  517. package/src/services/reqresp/protocols/index.ts +0 -1
  518. package/src/services/reqresp/protocols/status.ts +16 -12
  519. package/src/services/reqresp/protocols/tx.ts +24 -5
  520. package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
  521. package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
  522. package/src/services/reqresp/reqresp.ts +68 -224
  523. package/src/services/service.ts +83 -31
  524. package/src/services/tx_collection/config.ts +42 -37
  525. package/src/services/tx_collection/file_store_tx_collection.ts +153 -0
  526. package/src/services/tx_collection/file_store_tx_source.ts +129 -0
  527. package/src/services/tx_collection/index.ts +2 -1
  528. package/src/services/tx_collection/instrumentation.ts +5 -13
  529. package/src/services/tx_collection/request_tracker.ts +127 -0
  530. package/src/services/tx_collection/tx_collection.ts +368 -115
  531. package/src/services/tx_collection/tx_collection_sink.ts +32 -36
  532. package/src/services/tx_collection/tx_source.ts +28 -8
  533. package/src/services/tx_file_store/config.ts +37 -0
  534. package/src/services/tx_file_store/index.ts +3 -0
  535. package/src/services/tx_file_store/instrumentation.ts +36 -0
  536. package/src/services/tx_file_store/tx_file_store.ts +163 -0
  537. package/src/services/tx_provider.ts +34 -12
  538. package/src/services/tx_provider_instrumentation.ts +24 -14
  539. package/src/test-helpers/index.ts +2 -0
  540. package/src/test-helpers/make-test-p2p-clients.ts +7 -6
  541. package/src/test-helpers/mock-pubsub.ts +138 -15
  542. package/src/test-helpers/mock-tx-helpers.ts +1 -1
  543. package/src/test-helpers/reqresp-nodes.ts +18 -30
  544. package/src/test-helpers/test_tx_provider.ts +69 -0
  545. package/src/test-helpers/testbench-utils.ts +453 -0
  546. package/src/testbench/p2p_client_testbench_worker.ts +387 -128
  547. package/src/testbench/worker_client_manager.ts +355 -46
  548. package/src/util.ts +47 -16
  549. package/src/versioning.ts +3 -33
  550. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -30
  551. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  552. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -190
  553. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -25
  554. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  555. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -197
  556. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -150
  557. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
  558. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -617
  559. package/dest/mem_pools/tx_pool/index.d.ts +0 -4
  560. package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
  561. package/dest/mem_pools/tx_pool/index.js +0 -3
  562. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -80
  563. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
  564. package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -238
  565. package/dest/mem_pools/tx_pool/priority.d.ts +0 -8
  566. package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
  567. package/dest/mem_pools/tx_pool/priority.js +0 -10
  568. package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -122
  569. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
  570. package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
  571. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
  572. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
  573. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -394
  574. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
  575. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
  576. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -70
  577. package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
  578. package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
  579. package/dest/msg_validators/block_proposal_validator/index.js +0 -1
  580. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -45
  581. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
  582. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -92
  583. package/dest/services/reqresp/protocols/block.d.ts +0 -9
  584. package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
  585. package/dest/services/reqresp/protocols/block.js +0 -31
  586. package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -56
  587. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
  588. package/dest/services/tx_collection/fast_tx_collection.js +0 -300
  589. package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -54
  590. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
  591. package/dest/services/tx_collection/slow_tx_collection.js +0 -176
  592. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -256
  593. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -253
  594. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -750
  595. package/src/mem_pools/tx_pool/index.ts +0 -3
  596. package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -283
  597. package/src/mem_pools/tx_pool/priority.ts +0 -13
  598. package/src/mem_pools/tx_pool/tx_pool.ts +0 -135
  599. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -313
  600. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -81
  601. package/src/msg_validators/block_proposal_validator/index.ts +0 -1
  602. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -100
  603. package/src/services/reqresp/protocols/block.ts +0 -36
  604. package/src/services/tx_collection/fast_tx_collection.ts +0 -340
  605. package/src/services/tx_collection/slow_tx_collection.ts +0 -232
@@ -1,56 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,300 +0,0 @@
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
- }
@@ -1,54 +0,0 @@
1
- import { type Logger } from '@aztec/foundation/log';
2
- import { DateProvider } from '@aztec/foundation/timer';
3
- import type { L2Block } from '@aztec/stdlib/block';
4
- import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
5
- import { type Tx, TxHash } from '@aztec/stdlib/tx';
6
- import { type ReqRespInterface } from '../reqresp/interface.js';
7
- import type { TxCollectionConfig } from './config.js';
8
- import type { FastTxCollection } from './fast_tx_collection.js';
9
- import type { TxCollectionSink } from './tx_collection_sink.js';
10
- import type { TxSource } from './tx_source.js';
11
- export declare class SlowTxCollection {
12
- private reqResp;
13
- private nodes;
14
- private txCollectionSink;
15
- private fastCollection;
16
- private constants;
17
- private config;
18
- private dateProvider;
19
- private log;
20
- /** Map from tx hash to missing tx info to collect via slow loop */
21
- private missingTxs;
22
- /** One slow collection loop for each node tx source we have */
23
- private nodesSlowCollectionLoops;
24
- /** Slow collection loop for reqresp which collects txs from peers */
25
- private reqrespSlowCollectionLoop;
26
- constructor(reqResp: Pick<ReqRespInterface, 'sendBatchRequest'>, nodes: TxSource[], txCollectionSink: TxCollectionSink, fastCollection: Pick<FastTxCollection, 'getFastCollectionRequests'>, constants: L1RollupConstants, config: TxCollectionConfig, dateProvider?: DateProvider, log?: Logger);
27
- getMissingTxHashes(): TxHash[];
28
- start(): void;
29
- stop(): Promise<void>;
30
- trigger(): Promise<void>;
31
- /** Starts collecting the given tx hashes for the given L2Block in the slow loop */
32
- startCollecting(block: L2Block, txHashes: TxHash[]): void;
33
- /** Entrypoint for the node slow collection loop */
34
- private collectMissingTxsFromNode;
35
- /** Entrypoint for the reqresp slow collection loop */
36
- private collectMissingTxsViaReqResp;
37
- /** Retrieves all missing txs for the slow collection process. This is, all missing txs that are not part of a fast request. */
38
- private getMissingTxsForSlowCollection;
39
- /** Stop collecting the given txs since we have found them. Called whenever tx pool emits a tx-added event. */
40
- foundTxs(txs: Tx[]): void;
41
- /**
42
- * Stop collecting all txs for blocks less than or requal to the block number specified.
43
- * To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
44
- */
45
- stopCollectingForBlocksUpTo(blockNumber: number): void;
46
- /**
47
- * Stop collecting all txs for blocks greater than the block number specified.
48
- * To be called when there is a chain prune and previously mined txs are no longer relevant.
49
- */
50
- stopCollectingForBlocksAfter(blockNumber: number): void;
51
- /** Computes the proof submission deadline for a given slot, a tx mined in this slot is no longer interesting after this deadline */
52
- private getDeadlineForSlot;
53
- }
54
- //# sourceMappingURL=slow_tx_collection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slow_tx_collection.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/slow_tx_collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,KAAK,iBAAiB,EAA6C,MAAM,6BAA6B,CAAC;AAChH,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAEpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,gBAAgB;IAWzB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,GAAG;IAjBb,mEAAmE;IACnE,OAAO,CAAC,UAAU,CAAyC;IAE3D,+DAA+D;IAC/D,OAAO,CAAC,wBAAwB,CAAmB;IAEnD,qEAAqE;IACrE,OAAO,CAAC,yBAAyB,CAAiB;gBAGxC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,EACnD,KAAK,EAAE,QAAQ,EAAE,EACjB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,IAAI,CAAC,gBAAgB,EAAE,2BAA2B,CAAC,EACnE,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,kBAAkB,EAC1B,YAAY,GAAE,YAAiC,EAC/C,GAAG,GAAE,MAAkD;IAkB1D,kBAAkB;IAIlB,KAAK;IAKC,IAAI;IAOJ,OAAO;IAOpB,mFAAmF;IAC5E,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE;IAsBzD,mDAAmD;YACrC,yBAAyB;IAgCvC,sDAAsD;YACxC,2BAA2B;IAsCzC,+HAA+H;IAC/H,OAAO,CAAC,8BAA8B;IAqBtC,8GAA8G;IACvG,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI;IAMhC;;;OAGG;IACI,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQ7D;;;OAGG;IACI,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQ9D,oIAAoI;IACpI,OAAO,CAAC,kBAAkB;CAM3B"}
@@ -1,176 +0,0 @@
1
- import { chunk } from '@aztec/foundation/collection';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { boundInclusive } from '@aztec/foundation/number';
4
- import { RunningPromise } from '@aztec/foundation/promise';
5
- import { DateProvider } from '@aztec/foundation/timer';
6
- import { getEpochAtSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
7
- import { TxHash } from '@aztec/stdlib/tx';
8
- import { ReqRespSubProtocol } from '../reqresp/interface.js';
9
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
10
- export class SlowTxCollection {
11
- reqResp;
12
- nodes;
13
- txCollectionSink;
14
- fastCollection;
15
- constants;
16
- config;
17
- dateProvider;
18
- log;
19
- /** Map from tx hash to missing tx info to collect via slow loop */ missingTxs;
20
- /** One slow collection loop for each node tx source we have */ nodesSlowCollectionLoops;
21
- /** Slow collection loop for reqresp which collects txs from peers */ reqrespSlowCollectionLoop;
22
- constructor(reqResp, nodes, txCollectionSink, fastCollection, constants, config, dateProvider = new DateProvider(), log = createLogger('p2p:tx_collection_service')){
23
- this.reqResp = reqResp;
24
- this.nodes = nodes;
25
- this.txCollectionSink = txCollectionSink;
26
- this.fastCollection = fastCollection;
27
- this.constants = constants;
28
- this.config = config;
29
- this.dateProvider = dateProvider;
30
- this.log = log;
31
- this.missingTxs = new Map();
32
- this.nodesSlowCollectionLoops = this.nodes.map((node)=>new RunningPromise(()=>this.collectMissingTxsFromNode(node), this.log, this.config.txCollectionSlowNodesIntervalMs));
33
- this.reqrespSlowCollectionLoop = new RunningPromise(()=>this.collectMissingTxsViaReqResp(), this.log, this.config.txCollectionSlowReqRespIntervalMs);
34
- }
35
- getMissingTxHashes() {
36
- return Array.from(this.missingTxs.keys()).map(TxHash.fromString);
37
- }
38
- start() {
39
- this.nodesSlowCollectionLoops.forEach((loop)=>loop.start());
40
- this.reqrespSlowCollectionLoop.start();
41
- }
42
- async stop() {
43
- await Promise.all([
44
- this.reqrespSlowCollectionLoop.stop(),
45
- ...this.nodesSlowCollectionLoops.map((loop)=>loop.stop())
46
- ]);
47
- }
48
- async trigger() {
49
- await Promise.all([
50
- this.reqrespSlowCollectionLoop.trigger(),
51
- ...this.nodesSlowCollectionLoops.map((loop)=>loop.trigger())
52
- ]);
53
- }
54
- /** Starts collecting the given tx hashes for the given L2Block in the slow loop */ startCollecting(block, txHashes) {
55
- const slot = block.header.getSlot();
56
- const deadline = this.getDeadlineForSlot(slot);
57
- if (+deadline < this.dateProvider.now()) {
58
- this.log.debug(`Skipping collection of txs for block ${block.number} at slot ${slot} as it is already expired`, {
59
- blockNumber: block.number,
60
- slot: slot.toString(),
61
- txHashes: txHashes.map((txHash)=>txHash.toString()),
62
- deadline: +deadline,
63
- now: this.dateProvider.now()
64
- });
65
- }
66
- for (const txHash of txHashes){
67
- this.missingTxs.set(txHash.toString(), {
68
- blockNumber: block.number,
69
- deadline: this.getDeadlineForSlot(block.header.getSlot()),
70
- readyForReqResp: this.nodes.length === 0
71
- });
72
- }
73
- }
74
- /** Entrypoint for the node slow collection loop */ async collectMissingTxsFromNode(node) {
75
- // If we have any fast requests, we skip the slow collection for this node if configured to do so
76
- const requests = this.fastCollection.getFastCollectionRequests();
77
- if (this.config.txCollectionDisableSlowDuringFastRequests && requests.size > 0) {
78
- this.log.trace(`Skipping node slow collection due to active fast requests`);
79
- return;
80
- }
81
- // Gather all missing txs that are not in fast collection and request them from the node
82
- const missingTxs = this.getMissingTxsForSlowCollection();
83
- const missingTxHashes = missingTxs.map(([txHash])=>txHash).map(TxHash.fromString);
84
- if (missingTxHashes.length === 0) {
85
- return;
86
- }
87
- // Request in chunks to avoid hitting RPC limits
88
- for (const batch of chunk(missingTxHashes, this.config.txCollectionNodeRpcMaxBatchSize)){
89
- await this.txCollectionSink.collect((txHashes)=>node.getTxsByHash(txHashes), batch, {
90
- description: `node ${node.getInfo()}`,
91
- node: node.getInfo(),
92
- method: 'slow-node-rpc'
93
- });
94
- }
95
- // Mark every tx that is still missing as ready for reqresp.
96
- // Note that we can just mark all requested txs as ready for reqresp, without filtering out the ones
97
- // we retrieved, since the ones already found will have been removed from `missingTxs`.
98
- missingTxs.forEach(([_txHash, info])=>{
99
- info.readyForReqResp = true;
100
- });
101
- }
102
- /** Entrypoint for the reqresp slow collection loop */ async collectMissingTxsViaReqResp() {
103
- // If we have any fast requests, we skip the slow collection if configured to do so
104
- const requests = this.fastCollection.getFastCollectionRequests();
105
- if (this.config.txCollectionDisableSlowDuringFastRequests && requests.size > 0) {
106
- this.log.trace(`Skipping reqresp slow collection due to active fast requests`);
107
- return;
108
- }
109
- // Gather all missing txs that are not in fast collection and are ready for reqresp
110
- // A tx is flagged as ready for reqresp if it has been requested from a node at least once
111
- const missingTxs = this.getMissingTxsForSlowCollection({
112
- onlyReqRespReady: true
113
- });
114
- if (missingTxs.length === 0) {
115
- return;
116
- }
117
- const pinnedPeer = undefined;
118
- const timeoutMs = this.config.txCollectionSlowReqRespTimeoutMs;
119
- const maxPeers = boundInclusive(Math.ceil(missingTxs.length / 3), 4, 16);
120
- const maxRetryAttempts = 3;
121
- // Send a batch request via reqresp for the missing txs
122
- await this.txCollectionSink.collect(async (txHashes)=>{
123
- const txs = await this.reqResp.sendBatchRequest(ReqRespSubProtocol.TX, chunkTxHashesRequest(txHashes), pinnedPeer, timeoutMs, maxPeers, maxRetryAttempts);
124
- return txs.flat();
125
- }, missingTxs.map(([txHash])=>TxHash.fromString(txHash)), {
126
- description: 'slow reqresp',
127
- timeoutMs,
128
- method: 'slow-req-resp'
129
- });
130
- }
131
- /** Retrieves all missing txs for the slow collection process. This is, all missing txs that are not part of a fast request. */ getMissingTxsForSlowCollection(opts = {}) {
132
- // Remove expired txs from missingTxs
133
- const now = this.dateProvider.now();
134
- const expiredTxs = Array.from(this.missingTxs.entries()).filter(([_, value])=>+value.deadline < now);
135
- expiredTxs.forEach(([txHash])=>this.missingTxs.delete(txHash));
136
- // Gather all txs that are marked for fast collection, we do not want to collect them via slow collection.
137
- // There are some situations where a tx is in both slow and fast collection, for example when a prover node
138
- // is fast-collecting missing txs for proving an epoch, and still has the tx in the slow collection loops
139
- // from mined unproven blocks it has seen in the past.
140
- const fastRequests = this.fastCollection.getFastCollectionRequests();
141
- const fastCollectionTxs = new Set(...Array.from(fastRequests.values()).flatMap((r)=>r.missingTxHashes));
142
- // Return all missing txs that are not in fastCollectionTxs and are ready for reqresp if requested
143
- return Array.from(this.missingTxs.entries()).filter(([txHash, _])=>!fastCollectionTxs.has(txHash)).filter(([_, value])=>!opts.onlyReqRespReady || value.readyForReqResp);
144
- }
145
- /** Stop collecting the given txs since we have found them. Called whenever tx pool emits a tx-added event. */ foundTxs(txs) {
146
- for (const txHash of txs.map((tx)=>tx.txHash)){
147
- this.missingTxs.delete(txHash.toString());
148
- }
149
- }
150
- /**
151
- * Stop collecting all txs for blocks less than or requal to the block number specified.
152
- * To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
153
- */ stopCollectingForBlocksUpTo(blockNumber) {
154
- for (const [txHash, info] of this.missingTxs.entries()){
155
- if (info.blockNumber <= blockNumber) {
156
- this.missingTxs.delete(txHash);
157
- }
158
- }
159
- }
160
- /**
161
- * Stop collecting all txs for blocks greater than the block number specified.
162
- * To be called when there is a chain prune and previously mined txs are no longer relevant.
163
- */ stopCollectingForBlocksAfter(blockNumber) {
164
- for (const [txHash, info] of this.missingTxs.entries()){
165
- if (info.blockNumber > blockNumber) {
166
- this.missingTxs.delete(txHash);
167
- }
168
- }
169
- }
170
- /** Computes the proof submission deadline for a given slot, a tx mined in this slot is no longer interesting after this deadline */ getDeadlineForSlot(slotNumber) {
171
- const epoch = getEpochAtSlot(slotNumber, this.constants);
172
- const submissionEndEpoch = epoch + BigInt(this.constants.proofSubmissionEpochs);
173
- const submissionEndTimestamp = getTimestampRangeForEpoch(submissionEndEpoch, this.constants)[1];
174
- return new Date(Number(submissionEndTimestamp) * 1000);
175
- }
176
- }