@aztec/p2p 0.0.1-commit.d431d1c → 0.0.1-commit.dbf9cec

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 (476) hide show
  1. package/dest/bootstrap/bootstrap.d.ts +4 -3
  2. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  3. package/dest/bootstrap/bootstrap.js +4 -4
  4. package/dest/client/factory.d.ts +10 -10
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +45 -18
  7. package/dest/client/interface.d.ts +46 -33
  8. package/dest/client/interface.d.ts.map +1 -1
  9. package/dest/client/p2p_client.d.ts +41 -51
  10. package/dest/client/p2p_client.d.ts.map +1 -1
  11. package/dest/client/p2p_client.js +156 -200
  12. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
  13. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
  14. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +304 -0
  15. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
  16. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
  17. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
  18. package/dest/config.d.ts +35 -7
  19. package/dest/config.d.ts.map +1 -1
  20. package/dest/config.js +21 -7
  21. package/dest/errors/tx-pool.error.d.ts +8 -0
  22. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  23. package/dest/errors/tx-pool.error.js +9 -0
  24. package/dest/index.d.ts +2 -1
  25. package/dest/index.d.ts.map +1 -1
  26. package/dest/index.js +1 -0
  27. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
  28. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  29. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  30. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  31. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  32. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  33. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  34. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  35. package/dest/mem_pools/attestation_pool/index.js +1 -2
  36. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  37. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  38. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  39. package/dest/mem_pools/index.d.ts +3 -2
  40. package/dest/mem_pools/index.d.ts.map +1 -1
  41. package/dest/mem_pools/index.js +1 -1
  42. package/dest/mem_pools/instrumentation.d.ts +1 -1
  43. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  44. package/dest/mem_pools/instrumentation.js +2 -2
  45. package/dest/mem_pools/interface.d.ts +5 -5
  46. package/dest/mem_pools/interface.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
  48. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
  50. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
  51. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
  52. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
  53. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
  54. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  55. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +8 -1
  56. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  57. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
  58. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
  59. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
  60. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  61. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  62. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  63. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  64. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  65. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  66. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  67. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  68. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  76. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  77. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
  78. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  79. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  80. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  81. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
  82. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  83. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
  84. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  85. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  86. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
  87. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  88. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  89. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  90. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  91. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  92. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
  93. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  94. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  95. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
  96. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  97. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  98. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  99. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  100. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  101. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  102. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  103. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  104. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  105. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
  106. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  107. package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
  108. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +119 -0
  109. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  110. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +193 -0
  111. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  112. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  113. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  114. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
  115. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  116. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +354 -0
  117. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -0
  118. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  119. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
  120. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -0
  121. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  122. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +905 -0
  123. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
  124. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  125. package/dest/msg_validators/attestation_validator/attestation_validator.js +40 -9
  126. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
  127. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  128. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -6
  129. package/dest/msg_validators/clock_tolerance.d.ts +21 -0
  130. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  131. package/dest/msg_validators/clock_tolerance.js +37 -0
  132. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
  133. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  134. package/dest/msg_validators/proposal_validator/proposal_validator.js +46 -15
  135. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
  136. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
  137. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +66 -11
  138. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
  139. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  140. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
  141. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  142. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  143. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  144. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
  145. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  146. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  147. package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
  148. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  149. package/dest/msg_validators/tx_validator/data_validator.js +4 -1
  150. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
  151. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  152. package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
  153. package/dest/msg_validators/tx_validator/factory.d.ts +118 -5
  154. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  155. package/dest/msg_validators/tx_validator/factory.js +228 -57
  156. package/dest/msg_validators/tx_validator/gas_validator.d.ts +59 -3
  157. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  158. package/dest/msg_validators/tx_validator/gas_validator.js +76 -38
  159. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  160. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  161. package/dest/msg_validators/tx_validator/index.js +1 -0
  162. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
  163. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  164. package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
  165. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  166. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  167. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  168. package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
  169. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  170. package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
  171. package/dest/msg_validators/tx_validator/size_validator.d.ts +3 -1
  172. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -1
  173. package/dest/msg_validators/tx_validator/size_validator.js +4 -1
  174. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +22 -5
  175. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  176. package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
  177. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  178. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  179. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  180. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
  181. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  182. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
  183. package/dest/services/data_store.d.ts +1 -1
  184. package/dest/services/data_store.d.ts.map +1 -1
  185. package/dest/services/data_store.js +10 -6
  186. package/dest/services/discv5/discV5_service.js +1 -1
  187. package/dest/services/dummy_service.d.ts +24 -4
  188. package/dest/services/dummy_service.d.ts.map +1 -1
  189. package/dest/services/dummy_service.js +46 -1
  190. package/dest/services/encoding.d.ts +3 -3
  191. package/dest/services/encoding.d.ts.map +1 -1
  192. package/dest/services/encoding.js +11 -10
  193. package/dest/services/gossipsub/index.d.ts +3 -0
  194. package/dest/services/gossipsub/index.d.ts.map +1 -0
  195. package/dest/services/gossipsub/index.js +2 -0
  196. package/dest/services/gossipsub/scoring.d.ts +21 -3
  197. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  198. package/dest/services/gossipsub/scoring.js +24 -7
  199. package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
  200. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  201. package/dest/services/gossipsub/topic_score_params.js +346 -0
  202. package/dest/services/index.d.ts +2 -1
  203. package/dest/services/index.d.ts.map +1 -1
  204. package/dest/services/index.js +1 -0
  205. package/dest/services/libp2p/instrumentation.d.ts +1 -1
  206. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  207. package/dest/services/libp2p/instrumentation.js +14 -3
  208. package/dest/services/libp2p/libp2p_service.d.ts +101 -43
  209. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  210. package/dest/services/libp2p/libp2p_service.js +455 -363
  211. package/dest/services/peer-manager/metrics.d.ts +2 -2
  212. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  213. package/dest/services/peer-manager/metrics.js +20 -5
  214. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  215. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  216. package/dest/services/peer-manager/peer_scoring.js +33 -4
  217. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +48 -0
  218. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  219. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +539 -0
  220. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  221. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  222. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  223. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +46 -0
  224. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  225. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  226. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +34 -0
  227. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  228. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +130 -0
  229. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +60 -0
  230. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  231. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +173 -0
  232. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
  233. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  234. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
  235. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
  236. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  237. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
  238. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
  239. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  240. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  241. package/dest/services/reqresp/interface.d.ts +14 -3
  242. package/dest/services/reqresp/interface.d.ts.map +1 -1
  243. package/dest/services/reqresp/interface.js +17 -3
  244. package/dest/services/reqresp/metrics.d.ts +6 -5
  245. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  246. package/dest/services/reqresp/metrics.js +17 -5
  247. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
  248. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  249. package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
  250. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  251. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  252. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
  253. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
  254. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  255. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +59 -13
  256. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  257. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  258. package/dest/services/reqresp/protocols/tx.js +20 -0
  259. package/dest/services/reqresp/reqresp.d.ts +6 -1
  260. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  261. package/dest/services/reqresp/reqresp.js +71 -27
  262. package/dest/services/service.d.ts +42 -3
  263. package/dest/services/service.d.ts.map +1 -1
  264. package/dest/services/tx_collection/config.d.ts +22 -1
  265. package/dest/services/tx_collection/config.d.ts.map +1 -1
  266. package/dest/services/tx_collection/config.js +55 -1
  267. package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
  268. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  269. package/dest/services/tx_collection/fast_tx_collection.js +71 -44
  270. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  271. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  272. package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
  273. package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
  274. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  275. package/dest/services/tx_collection/file_store_tx_source.js +90 -0
  276. package/dest/services/tx_collection/index.d.ts +3 -1
  277. package/dest/services/tx_collection/index.d.ts.map +1 -1
  278. package/dest/services/tx_collection/index.js +2 -0
  279. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  280. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  281. package/dest/services/tx_collection/instrumentation.js +10 -2
  282. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  283. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  284. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  285. package/dest/services/tx_collection/proposal_tx_collector.d.ts +49 -0
  286. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
  287. package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
  288. package/dest/services/tx_collection/slow_tx_collection.d.ts +9 -5
  289. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  290. package/dest/services/tx_collection/slow_tx_collection.js +60 -26
  291. package/dest/services/tx_collection/tx_collection.d.ts +29 -16
  292. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  293. package/dest/services/tx_collection/tx_collection.js +79 -7
  294. package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
  295. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  296. package/dest/services/tx_collection/tx_collection_sink.js +26 -29
  297. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  298. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  299. package/dest/services/tx_collection/tx_source.js +19 -2
  300. package/dest/services/tx_file_store/config.d.ts +16 -0
  301. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  302. package/dest/services/tx_file_store/config.js +22 -0
  303. package/dest/services/tx_file_store/index.d.ts +4 -0
  304. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  305. package/dest/services/tx_file_store/index.js +3 -0
  306. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  307. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  308. package/dest/services/tx_file_store/instrumentation.js +29 -0
  309. package/dest/services/tx_file_store/tx_file_store.d.ts +48 -0
  310. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  311. package/dest/services/tx_file_store/tx_file_store.js +152 -0
  312. package/dest/services/tx_provider.d.ts +6 -6
  313. package/dest/services/tx_provider.d.ts.map +1 -1
  314. package/dest/services/tx_provider.js +9 -8
  315. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  316. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  317. package/dest/services/tx_provider_instrumentation.js +5 -5
  318. package/dest/test-helpers/index.d.ts +3 -1
  319. package/dest/test-helpers/index.d.ts.map +1 -1
  320. package/dest/test-helpers/index.js +2 -0
  321. package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
  322. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  323. package/dest/test-helpers/make-test-p2p-clients.js +1 -2
  324. package/dest/test-helpers/mock-pubsub.d.ts +30 -4
  325. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  326. package/dest/test-helpers/mock-pubsub.js +105 -4
  327. package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
  328. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  329. package/dest/test-helpers/reqresp-nodes.js +4 -3
  330. package/dest/test-helpers/test_tx_provider.d.ts +40 -0
  331. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  332. package/dest/test-helpers/test_tx_provider.js +41 -0
  333. package/dest/test-helpers/testbench-utils.d.ts +163 -0
  334. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  335. package/dest/test-helpers/testbench-utils.js +366 -0
  336. package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
  337. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  338. package/dest/testbench/p2p_client_testbench_worker.js +219 -137
  339. package/dest/testbench/worker_client_manager.d.ts +51 -6
  340. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  341. package/dest/testbench/worker_client_manager.js +226 -44
  342. package/dest/util.d.ts +2 -2
  343. package/dest/util.d.ts.map +1 -1
  344. package/package.json +14 -14
  345. package/src/bootstrap/bootstrap.ts +7 -4
  346. package/src/client/factory.ts +83 -36
  347. package/src/client/interface.ts +56 -34
  348. package/src/client/p2p_client.ts +196 -251
  349. package/src/client/test/tx_proposal_collector/README.md +227 -0
  350. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +345 -0
  351. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
  352. package/src/config.ts +47 -11
  353. package/src/errors/tx-pool.error.ts +12 -0
  354. package/src/index.ts +1 -0
  355. package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
  356. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  357. package/src/mem_pools/attestation_pool/index.ts +9 -2
  358. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  359. package/src/mem_pools/index.ts +4 -1
  360. package/src/mem_pools/instrumentation.ts +2 -1
  361. package/src/mem_pools/interface.ts +4 -4
  362. package/src/mem_pools/tx_pool/README.md +1 -1
  363. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
  364. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
  365. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
  366. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
  367. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  368. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
  369. package/src/mem_pools/tx_pool_v2/README.md +275 -0
  370. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  371. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  372. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  373. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
  374. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
  375. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
  376. package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
  377. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
  378. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  379. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  380. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
  381. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
  382. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  383. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  384. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  385. package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
  386. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +297 -0
  387. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  388. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
  389. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
  390. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1083 -0
  391. package/src/msg_validators/attestation_validator/attestation_validator.ts +25 -13
  392. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +16 -10
  393. package/src/msg_validators/clock_tolerance.ts +51 -0
  394. package/src/msg_validators/proposal_validator/proposal_validator.ts +21 -14
  395. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +53 -14
  396. package/src/msg_validators/tx_validator/README.md +115 -0
  397. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
  398. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  399. package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
  400. package/src/msg_validators/tx_validator/data_validator.ts +6 -2
  401. package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
  402. package/src/msg_validators/tx_validator/factory.ts +372 -55
  403. package/src/msg_validators/tx_validator/gas_validator.ts +98 -29
  404. package/src/msg_validators/tx_validator/index.ts +1 -0
  405. package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
  406. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  407. package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
  408. package/src/msg_validators/tx_validator/size_validator.ts +6 -2
  409. package/src/msg_validators/tx_validator/timestamp_validator.ts +29 -21
  410. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  411. package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
  412. package/src/services/data_store.ts +10 -7
  413. package/src/services/discv5/discV5_service.ts +1 -1
  414. package/src/services/dummy_service.ts +59 -2
  415. package/src/services/encoding.ts +9 -9
  416. package/src/services/gossipsub/README.md +641 -0
  417. package/src/services/gossipsub/index.ts +2 -0
  418. package/src/services/gossipsub/scoring.ts +29 -5
  419. package/src/services/gossipsub/topic_score_params.ts +487 -0
  420. package/src/services/index.ts +1 -0
  421. package/src/services/libp2p/instrumentation.ts +15 -2
  422. package/src/services/libp2p/libp2p_service.ts +505 -396
  423. package/src/services/peer-manager/metrics.ts +21 -4
  424. package/src/services/peer-manager/peer_scoring.ts +29 -1
  425. package/src/services/reqresp/batch-tx-requester/README.md +305 -0
  426. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +678 -0
  427. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  428. package/src/services/reqresp/batch-tx-requester/interface.ts +53 -0
  429. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -0
  430. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +244 -0
  431. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
  432. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
  433. package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
  434. package/src/services/reqresp/interface.ts +31 -3
  435. package/src/services/reqresp/metrics.ts +34 -9
  436. package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
  437. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
  438. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
  439. package/src/services/reqresp/protocols/tx.ts +22 -0
  440. package/src/services/reqresp/reqresp.ts +82 -23
  441. package/src/services/service.ts +55 -2
  442. package/src/services/tx_collection/config.ts +83 -1
  443. package/src/services/tx_collection/fast_tx_collection.ts +93 -47
  444. package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
  445. package/src/services/tx_collection/file_store_tx_source.ts +117 -0
  446. package/src/services/tx_collection/index.ts +6 -0
  447. package/src/services/tx_collection/instrumentation.ts +17 -2
  448. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  449. package/src/services/tx_collection/proposal_tx_collector.ts +113 -0
  450. package/src/services/tx_collection/slow_tx_collection.ts +68 -35
  451. package/src/services/tx_collection/tx_collection.ts +121 -24
  452. package/src/services/tx_collection/tx_collection_sink.ts +30 -34
  453. package/src/services/tx_collection/tx_source.ts +22 -3
  454. package/src/services/tx_file_store/config.ts +37 -0
  455. package/src/services/tx_file_store/index.ts +3 -0
  456. package/src/services/tx_file_store/instrumentation.ts +36 -0
  457. package/src/services/tx_file_store/tx_file_store.ts +175 -0
  458. package/src/services/tx_provider.ts +12 -11
  459. package/src/services/tx_provider_instrumentation.ts +11 -5
  460. package/src/test-helpers/index.ts +2 -0
  461. package/src/test-helpers/make-test-p2p-clients.ts +3 -5
  462. package/src/test-helpers/mock-pubsub.ts +146 -9
  463. package/src/test-helpers/reqresp-nodes.ts +4 -6
  464. package/src/test-helpers/test_tx_provider.ts +64 -0
  465. package/src/test-helpers/testbench-utils.ts +430 -0
  466. package/src/testbench/p2p_client_testbench_worker.ts +333 -131
  467. package/src/testbench/worker_client_manager.ts +304 -47
  468. package/src/util.ts +7 -1
  469. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  470. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  471. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  472. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  473. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  474. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  475. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  476. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -1,5 +1,10 @@
1
- import { AVM_MAX_PROCESSABLE_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS } from '@aztec/constants';
2
- import { createLogger } from '@aztec/foundation/log';
1
+ import {
2
+ MAX_PROCESSABLE_L2_GAS,
3
+ PRIVATE_TX_L2_GAS_OVERHEAD,
4
+ PUBLIC_TX_L2_GAS_OVERHEAD,
5
+ TX_DA_GAS_OVERHEAD,
6
+ } from '@aztec/constants';
7
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
8
  import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
4
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
10
  import { Gas, GasFees } from '@aztec/stdlib/gas';
@@ -16,20 +21,106 @@ import {
16
21
 
17
22
  import { getFeePayerClaimAmount, getTxFeeLimit } from './fee_payer_balance.js';
18
23
 
24
+ /** Structural interface for types that carry gas limit data, used by {@link GasLimitsValidator}. */
25
+ export interface HasGasLimitData {
26
+ txHash: { toString(): string };
27
+ data: {
28
+ // We just need to know whether there is something here or not
29
+ forPublic?: unknown;
30
+ constants: {
31
+ txContext: {
32
+ gasSettings: { gasLimits: Gas };
33
+ };
34
+ };
35
+ };
36
+ }
37
+
38
+ /**
39
+ * Validates that a transaction's gas limits are within acceptable bounds.
40
+ *
41
+ * Rejects transactions whose gas limits fall below the fixed minimums (FIXED_DA_GAS,
42
+ * FIXED_L2_GAS) or exceed the AVM's maximum processable L2 gas. This is a cheap,
43
+ * stateless check that operates on gas settings alone.
44
+ *
45
+ * Generic over T so it can validate both full {@link Tx} objects and {@link TxMetaData}
46
+ * (used during pending pool migration).
47
+ *
48
+ * Used by: pending pool migration (via factory), and indirectly by {@link GasTxValidator}.
49
+ */
50
+ export class GasLimitsValidator<T extends HasGasLimitData> implements TxValidator<T> {
51
+ #log: Logger;
52
+
53
+ constructor(bindings?: LoggerBindings) {
54
+ this.#log = createLogger('sequencer:tx_validator:tx_gas', bindings);
55
+ }
56
+
57
+ validateTx(tx: T): Promise<TxValidationResult> {
58
+ return Promise.resolve(this.validateGasLimit(tx));
59
+ }
60
+
61
+ /** Checks gas limits are >= fixed minimums and <= AVM max processable L2 gas. */
62
+ validateGasLimit(tx: T): TxValidationResult {
63
+ const gasLimits = tx.data.constants.txContext.gasSettings.gasLimits;
64
+ const minGasLimits = new Gas(
65
+ TX_DA_GAS_OVERHEAD,
66
+ tx.data.forPublic ? PUBLIC_TX_L2_GAS_OVERHEAD : PRIVATE_TX_L2_GAS_OVERHEAD,
67
+ );
68
+
69
+ if (minGasLimits.gtAny(gasLimits)) {
70
+ this.#log.verbose(`Rejecting transaction due to the gas limit(s) not being above the minimum gas limit`, {
71
+ gasLimits,
72
+ minGasLimits,
73
+ });
74
+ return { result: 'invalid', reason: [TX_ERROR_INSUFFICIENT_GAS_LIMIT] };
75
+ }
76
+
77
+ if (gasLimits.l2Gas > MAX_PROCESSABLE_L2_GAS) {
78
+ this.#log.verbose(`Rejecting transaction due to the gas limit(s) being higher than the maximum processable gas`, {
79
+ gasLimits,
80
+ minGasLimits,
81
+ });
82
+ return { result: 'invalid', reason: [TX_ERROR_GAS_LIMIT_TOO_HIGH] };
83
+ }
84
+
85
+ return { result: 'valid' };
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Validates that a transaction can pay its gas fees.
91
+ *
92
+ * Runs three checks in order:
93
+ * 1. **Gas limits** (delegates to {@link GasLimitsValidator}) — rejects if limits are
94
+ * out of bounds.
95
+ * 2. **Max fee per gas** — skips (not rejects) the tx if its maxFeesPerGas is below
96
+ * the current block's gas fees. We skip rather than reject because the tx may
97
+ * become eligible in a later block with lower fees.
98
+ * 3. **Fee payer balance** — reads the fee payer's FeeJuice balance from public state,
99
+ * adds any pending claim from a setup-phase `_increase_public_balance` call, and
100
+ * rejects if the total is less than the tx's fee limit (gasLimits * maxFeePerGas).
101
+ *
102
+ * Used by: gossip (stage 1), RPC, and block building validators.
103
+ */
19
104
  export class GasTxValidator implements TxValidator<Tx> {
20
- #log = createLogger('sequencer:tx_validator:tx_gas');
105
+ #log: Logger;
21
106
  #publicDataSource: PublicStateSource;
22
107
  #feeJuiceAddress: AztecAddress;
23
108
  #gasFees: GasFees;
24
109
 
25
- constructor(publicDataSource: PublicStateSource, feeJuiceAddress: AztecAddress, gasFees: GasFees) {
110
+ constructor(
111
+ publicDataSource: PublicStateSource,
112
+ feeJuiceAddress: AztecAddress,
113
+ gasFees: GasFees,
114
+ private bindings?: LoggerBindings,
115
+ ) {
116
+ this.#log = createLogger('sequencer:tx_validator:tx_gas', bindings);
26
117
  this.#publicDataSource = publicDataSource;
27
118
  this.#feeJuiceAddress = feeJuiceAddress;
28
119
  this.#gasFees = gasFees;
29
120
  }
30
121
 
31
122
  async validateTx(tx: Tx): Promise<TxValidationResult> {
32
- const gasLimitValidation = this.#validateGasLimit(tx);
123
+ const gasLimitValidation = new GasLimitsValidator(this.bindings).validateGasLimit(tx);
33
124
  if (gasLimitValidation.result === 'invalid') {
34
125
  return Promise.resolve(gasLimitValidation);
35
126
  }
@@ -63,31 +154,9 @@ export class GasTxValidator implements TxValidator<Tx> {
63
154
  }
64
155
 
65
156
  /**
66
- * Check whether the tx's gas limit is above the minimum amount.
157
+ * Checks the fee payer has enough FeeJuice balance to cover the tx's fee limit.
158
+ * Accounts for any pending claim from a setup-phase `_increase_public_balance` call.
67
159
  */
68
- #validateGasLimit(tx: Tx): TxValidationResult {
69
- const gasLimits = tx.data.constants.txContext.gasSettings.gasLimits;
70
- const minGasLimits = new Gas(FIXED_DA_GAS, FIXED_L2_GAS);
71
-
72
- if (minGasLimits.gtAny(gasLimits)) {
73
- this.#log.verbose(`Rejecting transaction due to the gas limit(s) not being above the minimum gas limit`, {
74
- gasLimits,
75
- minGasLimits,
76
- });
77
- return { result: 'invalid', reason: [TX_ERROR_INSUFFICIENT_GAS_LIMIT] };
78
- }
79
-
80
- if (gasLimits.l2Gas > AVM_MAX_PROCESSABLE_L2_GAS) {
81
- this.#log.verbose(`Rejecting transaction due to the gas limit(s) being higher than the maximum processable gas`, {
82
- gasLimits,
83
- minGasLimits,
84
- });
85
- return { result: 'invalid', reason: [TX_ERROR_GAS_LIMIT_TOO_HIGH] };
86
- }
87
-
88
- return { result: 'valid' };
89
- }
90
-
91
160
  public async validateTxFee(tx: Tx): Promise<TxValidationResult> {
92
161
  const feePayer = tx.data.feePayer;
93
162
 
@@ -12,3 +12,4 @@ export * from './archive_cache.js';
12
12
  export * from './tx_permitted_validator.js';
13
13
  export * from './timestamp_validator.js';
14
14
  export * from './size_validator.js';
15
+ export * from './factory.js';
@@ -1,5 +1,5 @@
1
1
  import type { Fr } from '@aztec/foundation/curves/bn254';
2
- import { createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
3
  import {
4
4
  type AnyTx,
5
5
  TX_ERROR_INCORRECT_L1_CHAIN_ID,
@@ -11,7 +11,7 @@ import {
11
11
  } from '@aztec/stdlib/tx';
12
12
 
13
13
  export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
14
- #log = createLogger('p2p:tx_validator:tx_metadata');
14
+ #log: Logger;
15
15
 
16
16
  constructor(
17
17
  private values: {
@@ -20,7 +20,10 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
20
20
  vkTreeRoot: Fr;
21
21
  protocolContractsHash: Fr;
22
22
  },
23
- ) {}
23
+ bindings?: LoggerBindings,
24
+ ) {
25
+ this.#log = createLogger('p2p:tx_validator:tx_metadata', bindings);
26
+ }
24
27
 
25
28
  validateTx(tx: T): Promise<TxValidationResult> {
26
29
  const errors = [];
@@ -0,0 +1,30 @@
1
+ import type { NullifierSource } from '@aztec/p2p';
2
+ import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
3
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
4
+
5
+ /**
6
+ * Implements a nullifier source by checking a DB and an in-memory collection.
7
+ * Intended for validating transactions as they are added to a block.
8
+ */
9
+ export class NullifierCache implements NullifierSource {
10
+ nullifiers: Set<string>;
11
+
12
+ constructor(private db: MerkleTreeReadOperations) {
13
+ this.nullifiers = new Set();
14
+ }
15
+
16
+ public async nullifiersExist(nullifiers: Buffer[]): Promise<boolean[]> {
17
+ const cacheResults = nullifiers.map(n => this.nullifiers.has(n.toString()));
18
+ const toCheckDb = nullifiers.filter((_n, index) => !cacheResults[index]);
19
+ const dbHits = await this.db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, toCheckDb);
20
+
21
+ let dbIndex = 0;
22
+ return nullifiers.map((_n, index) => cacheResults[index] || dbHits[dbIndex++] !== undefined);
23
+ }
24
+
25
+ public addNullifiers(nullifiers: Buffer[]) {
26
+ for (const nullifier of nullifiers) {
27
+ this.nullifiers.add(nullifier.toString());
28
+ }
29
+ }
30
+ }
@@ -1,4 +1,4 @@
1
- import { createLogger } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
3
3
  import type { ContractDataSource } from '@aztec/stdlib/contract';
4
4
  import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
@@ -14,15 +14,17 @@ import {
14
14
  import type { UInt64 } from '@aztec/stdlib/types';
15
15
 
16
16
  export class PhasesTxValidator implements TxValidator<Tx> {
17
- #log = createLogger('sequencer:tx_validator:tx_phases');
17
+ #log: Logger;
18
18
  private contractsDB: PublicContractsDB;
19
19
 
20
20
  constructor(
21
21
  contracts: ContractDataSource,
22
22
  private setupAllowList: AllowedElement[],
23
23
  private timestamp: UInt64,
24
+ bindings?: LoggerBindings,
24
25
  ) {
25
- this.contractsDB = new PublicContractsDB(contracts);
26
+ this.#log = createLogger('sequencer:tx_validator:tx_phases', bindings);
27
+ this.contractsDB = new PublicContractsDB(contracts, bindings);
26
28
  }
27
29
 
28
30
  async validateTx(tx: Tx): Promise<TxValidationResult> {
@@ -1,9 +1,13 @@
1
- import { createLogger } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import { MAX_TX_SIZE_KB } from '@aztec/stdlib/p2p';
3
3
  import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
4
4
 
5
5
  export class SizeTxValidator implements TxValidator<Tx> {
6
- #log = createLogger('sequencer:tx_validator:tx_size');
6
+ #log: Logger;
7
+
8
+ constructor(bindings?: LoggerBindings) {
9
+ this.#log = createLogger('p2p:tx_validator:tx_size', bindings);
10
+ }
7
11
 
8
12
  validateTx(tx: Tx): Promise<TxValidationResult> {
9
13
  const txSize = tx.getSize();
@@ -1,16 +1,25 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import {
4
- type AnyTx,
5
- TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP,
6
- type TxValidationResult,
7
- type TxValidator,
8
- getTxHash,
9
- } from '@aztec/stdlib/tx';
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
+ import { TX_ERROR_INVALID_EXPIRATION_TIMESTAMP, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
10
4
  import type { UInt64 } from '@aztec/stdlib/types';
11
5
 
12
- export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
13
- #log = createLogger('p2p:tx_validator:timestamp');
6
+ /** Structural interface for timestamp validation. */
7
+ export interface HasTimestampData {
8
+ txHash: { toString(): string };
9
+ data: {
10
+ expirationTimestamp: bigint;
11
+ constants: {
12
+ anchorBlockHeader: {
13
+ globalVariables: {
14
+ blockNumber: BlockNumber;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ }
20
+
21
+ export class TimestampTxValidator<T extends HasTimestampData> implements TxValidator<T> {
22
+ #log: Logger;
14
23
 
15
24
  constructor(
16
25
  private values: {
@@ -20,28 +29,27 @@ export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
20
29
  // Block number in which the tx is considered to be included.
21
30
  blockNumber: BlockNumber;
22
31
  },
23
- ) {}
32
+ bindings?: LoggerBindings,
33
+ ) {
34
+ this.#log = createLogger('p2p:tx_validator:timestamp', bindings);
35
+ }
24
36
 
25
37
  validateTx(tx: T): Promise<TxValidationResult> {
26
- const includeByTimestamp = tx.data.includeByTimestamp;
27
- // If building block 1, we skip the expiration check. For details on why see the `validate_include_by_timestamp`
38
+ const expirationTimestamp = tx.data.expirationTimestamp;
39
+ // If building block 1, we skip the expiration check. For details on why see the `validate_expiration_timestamp`
28
40
  // function in `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
29
41
  const buildingBlock1 = this.values.blockNumber === 1;
30
42
 
31
- if (!buildingBlock1 && includeByTimestamp < this.values.timestamp) {
43
+ if (!buildingBlock1 && expirationTimestamp < this.values.timestamp) {
32
44
  if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber === 0) {
33
45
  this.#log.warn(
34
46
  `A tx built against a genesis block failed to be included in block 1 which is the only block in which txs built against a genesis block are allowed to be included.`,
35
47
  );
36
48
  }
37
49
  this.#log.verbose(
38
- `Rejecting tx ${getTxHash(
39
- tx,
40
- )} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${
41
- this.values.timestamp
42
- }.`,
50
+ `Rejecting tx ${tx.txHash} for low expiration timestamp. Tx expiration timestamp: ${expirationTimestamp}, timestamp: ${this.values.timestamp}.`,
43
51
  );
44
- return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP] });
52
+ return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_INVALID_EXPIRATION_TIMESTAMP] });
45
53
  } else {
46
54
  return Promise.resolve({ result: 'valid' });
47
55
  }
@@ -1,10 +1,15 @@
1
- import { createLogger } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import type { Tx, TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
3
3
 
4
4
  export class TxPermittedValidator implements TxValidator<Tx> {
5
- #log = createLogger('p2p:tx_validator:tx_permitted');
5
+ #log: Logger;
6
6
 
7
- constructor(private permitted: boolean) {}
7
+ constructor(
8
+ private permitted: boolean,
9
+ bindings?: LoggerBindings,
10
+ ) {
11
+ this.#log = createLogger('p2p:tx_validator:tx_permitted', bindings);
12
+ }
8
13
 
9
14
  validateTx(tx: Tx): Promise<TxValidationResult> {
10
15
  if (!this.permitted) {
@@ -1,11 +1,16 @@
1
- import { createLogger } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
3
3
  import { TX_ERROR_INVALID_PROOF, Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
4
4
 
5
5
  export class TxProofValidator implements TxValidator<Tx> {
6
- #log = createLogger('p2p:tx_validator:private_proof');
6
+ #log: Logger;
7
7
 
8
- constructor(private verifier: ClientProtocolCircuitVerifier) {}
8
+ constructor(
9
+ private verifier: ClientProtocolCircuitVerifier,
10
+ bindings?: LoggerBindings,
11
+ ) {
12
+ this.#log = createLogger('p2p:tx_validator:proof', bindings);
13
+ }
9
14
 
10
15
  async validateTx(tx: Tx): Promise<TxValidationResult> {
11
16
  const result = await this.verifier.verifyProof(tx);
@@ -24,6 +24,7 @@ class KeyNotFoundError extends Error {
24
24
  }
25
25
 
26
26
  export class AztecDatastore implements Datastore {
27
+ #db: AztecAsyncKVStore;
27
28
  #memoryDatastore: Map<string, MemoryItem>;
28
29
  #dbDatastore: AztecAsyncMap<string, Uint8Array>;
29
30
 
@@ -32,9 +33,9 @@ export class AztecDatastore implements Datastore {
32
33
  private maxMemoryItems: number;
33
34
 
34
35
  constructor(db: AztecAsyncKVStore, { maxMemoryItems } = { maxMemoryItems: 50 }) {
36
+ this.#db = db;
35
37
  this.#memoryDatastore = new Map();
36
38
  this.#dbDatastore = db.openMap('p2p_datastore');
37
-
38
39
  this.maxMemoryItems = maxMemoryItems;
39
40
  }
40
41
 
@@ -106,13 +107,15 @@ export class AztecDatastore implements Datastore {
106
107
  });
107
108
  },
108
109
  commit: async () => {
109
- for (const op of this.#batchOps) {
110
- if (op.type === 'put' && op.value) {
111
- await this.put(op.key, op.value);
112
- } else if (op.type === 'del') {
113
- await this.delete(op.key);
110
+ await this.#db.transactionAsync(async () => {
111
+ for (const op of this.#batchOps) {
112
+ if (op.type === 'put' && op.value) {
113
+ await this.put(op.key, op.value);
114
+ } else if (op.type === 'del') {
115
+ await this.delete(op.key);
116
+ }
114
117
  }
115
- }
118
+ });
116
119
  this.#batchOps = []; // Clear operations after commit
117
120
  },
118
121
  };
@@ -87,7 +87,7 @@ export class DiscV5Service extends EventEmitter implements PeerDiscoveryService
87
87
  this.packageVersion,
88
88
  ));
89
89
 
90
- const metricsRegistry = new OtelMetricsAdapter(telemetry);
90
+ const metricsRegistry = new OtelMetricsAdapter(telemetry, this.logger.getBindings());
91
91
  this.discv5 = Discv5.create({
92
92
  enr: this.enr,
93
93
  peerId,
@@ -1,6 +1,6 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
- import type { Gossipable, PeerErrorSeverity } from '@aztec/stdlib/p2p';
3
+ import type { Gossipable, PeerErrorSeverity, TopicType } from '@aztec/stdlib/p2p';
4
4
  import { Tx, TxHash } from '@aztec/stdlib/tx';
5
5
 
6
6
  import type { PeerId } from '@libp2p/interface';
@@ -8,7 +8,9 @@ import type { ENR } from '@nethermindeth/enr';
8
8
  import EventEmitter from 'events';
9
9
 
10
10
  import type { PeerManagerInterface } from './peer-manager/interface.js';
11
+ import type { BatchTxRequesterLibP2PService } from './reqresp/batch-tx-requester/interface.js';
11
12
  import type { P2PReqRespConfig } from './reqresp/config.js';
13
+ import type { ConnectionSampler } from './reqresp/connection-sampler/connection_sampler.js';
12
14
  import { type AuthRequest, StatusMessage } from './reqresp/index.js';
13
15
  import type {
14
16
  ReqRespInterface,
@@ -24,6 +26,8 @@ import { ReqRespStatus } from './reqresp/status.js';
24
26
  import {
25
27
  type P2PBlockReceivedCallback,
26
28
  type P2PCheckpointReceivedCallback,
29
+ type P2PDuplicateAttestationCallback,
30
+ type P2PDuplicateProposalCallback,
27
31
  type P2PService,
28
32
  type PeerDiscoveryService,
29
33
  PeerDiscoveryState,
@@ -40,6 +44,10 @@ export class DummyP2PService implements P2PService {
40
44
  return [];
41
45
  }
42
46
 
47
+ getGossipMeshPeerCount(_topicType: TopicType): number {
48
+ return 0;
49
+ }
50
+
43
51
  /**
44
52
  * Starts the dummy implementation.
45
53
  * @returns A resolved promise.
@@ -80,6 +88,16 @@ export class DummyP2PService implements P2PService {
80
88
  */
81
89
  public registerCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
82
90
 
91
+ /**
92
+ * Register a callback for when a duplicate proposal is detected
93
+ */
94
+ public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {}
95
+
96
+ /**
97
+ * Register a callback for when a duplicate attestation is detected
98
+ */
99
+ public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {}
100
+
83
101
  /**
84
102
  * Sends a request to a peer.
85
103
  * @param _protocol - The protocol to send the request on.
@@ -106,6 +124,15 @@ export class DummyP2PService implements P2PService {
106
124
  return Promise.resolve([]);
107
125
  }
108
126
 
127
+ public sendRequestToPeer(
128
+ _peerId: PeerId,
129
+ _subProtocol: ReqRespSubProtocol,
130
+ _payload: Buffer,
131
+ _dialTimeout?: number,
132
+ ): Promise<ReqRespResponse> {
133
+ return Promise.resolve({ status: ReqRespStatus.SUCCESS, data: Buffer.from([]) });
134
+ }
135
+
109
136
  /**
110
137
  * Returns the ENR of the peer.
111
138
  * @returns The ENR of the peer, otherwise undefined.
@@ -114,7 +141,7 @@ export class DummyP2PService implements P2PService {
114
141
  return undefined;
115
142
  }
116
143
 
117
- validate(_txs: Tx[]): Promise<void> {
144
+ validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
118
145
  return Promise.resolve();
119
146
  }
120
147
 
@@ -132,6 +159,27 @@ export class DummyP2PService implements P2PService {
132
159
 
133
160
  //this is no-op
134
161
  registerThisValidatorAddresses(_address: EthAddress[]): void {}
162
+
163
+ /**
164
+ * Get dummy BatchTxRequesterLibP2PService for testing
165
+ */
166
+ getBatchTxRequesterService(): BatchTxRequesterLibP2PService {
167
+ return {
168
+ reqResp: this, // The dummy service implements ReqRespInterface
169
+ connectionSampler: new DummyReqResp().getConnectionSampler(),
170
+ txValidatorConfig: {
171
+ l1ChainId: 1,
172
+ rollupVersion: 1,
173
+ proofVerifier: {
174
+ verifyProof: () => Promise.resolve({ valid: true, durationMs: 0, totalDurationMs: 0 }),
175
+ stop: () => Promise.resolve(),
176
+ },
177
+ },
178
+ peerScoring: {
179
+ penalizePeer: (_peerId, _penalty) => {},
180
+ },
181
+ };
182
+ }
135
183
  }
136
184
 
137
185
  /**
@@ -268,6 +316,15 @@ export class DummyReqResp implements ReqRespInterface {
268
316
  return Promise.resolve({ status: ReqRespStatus.SUCCESS, data: Buffer.from([]) });
269
317
  }
270
318
 
319
+ /**
320
+ * Get dummy connection sampler for testing
321
+ */
322
+ getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'> {
323
+ return {
324
+ getPeerListSortedByConnectionCountAsc: () => [],
325
+ };
326
+ }
327
+
271
328
  addSubProtocol(
272
329
  _subProtocol: ReqRespSubProtocol,
273
330
  _handler: ReqRespSubProtocolHandler,
@@ -1,11 +1,11 @@
1
1
  // Taken from lodestar: https://github.com/ChainSafe/lodestar
2
- import { sha256 } from '@aztec/foundation/crypto/sha256';
3
2
  import { createLogger } from '@aztec/foundation/log';
4
3
  import { MAX_TX_SIZE_KB, TopicType, getTopicFromString } from '@aztec/stdlib/p2p';
5
4
 
6
5
  import type { RPC } from '@chainsafe/libp2p-gossipsub/message';
7
6
  import type { DataTransform } from '@chainsafe/libp2p-gossipsub/types';
8
7
  import type { Message } from '@libp2p/interface';
8
+ import { webcrypto } from 'node:crypto';
9
9
  import { compressSync, uncompressSync } from 'snappy';
10
10
  import xxhashFactory from 'xxhash-wasm';
11
11
 
@@ -44,11 +44,10 @@ export function msgIdToStrFn(msgId: Uint8Array): string {
44
44
  * @param message - The libp2p message
45
45
  * @returns The message identifier
46
46
  */
47
- export function getMsgIdFn(message: Message) {
48
- const { topic } = message;
49
-
50
- const vec = [Buffer.from(topic), message.data];
51
- return sha256(Buffer.concat(vec)).subarray(0, 20);
47
+ export async function getMsgIdFn({ topic, data }: Message): Promise<Uint8Array> {
48
+ const buffer = Buffer.concat([Buffer.from(topic), data]);
49
+ const hash = await webcrypto.subtle.digest('SHA-256', buffer);
50
+ return Buffer.from(hash.slice(0, 20));
52
51
  }
53
52
 
54
53
  const DefaultMaxSizesKb: Record<TopicType, number> = {
@@ -58,7 +57,8 @@ const DefaultMaxSizesKb: Record<TopicType, number> = {
58
57
  // Proposals may carry some tx objects, so we allow a larger size capped at 10mb
59
58
  // Note this may not be enough for carrying all tx objects in a block
60
59
  [TopicType.block_proposal]: 1024 * 10,
61
- // TODO(palla/mbps): Check size for checkpoint proposal
60
+ // Checkpoint proposals carry almost the same data as a block proposal (see the lastBlockProposal)
61
+ // Only diff is an additional header, which is pretty small compared to the 10mb limit
62
62
  [TopicType.checkpoint_proposal]: 1024 * 10,
63
63
  };
64
64
 
@@ -78,11 +78,11 @@ export class SnappyTransform implements DataTransform {
78
78
  return this.inboundTransformData(Buffer.from(data), topic);
79
79
  }
80
80
 
81
- public inboundTransformData(data: Buffer, topic?: TopicType): Buffer {
81
+ public inboundTransformData(data: Buffer, topic?: TopicType, maxSizeKbOverride?: number): Buffer {
82
82
  if (data.length === 0) {
83
83
  return data;
84
84
  }
85
- const maxSizeKb = this.maxSizesKb[topic!] ?? this.defaultMaxSizeKb;
85
+ const maxSizeKb = maxSizeKbOverride ?? this.maxSizesKb[topic!] ?? this.defaultMaxSizeKb;
86
86
  const { decompressedSize } = readSnappyPreamble(data);
87
87
  if (decompressedSize > maxSizeKb * 1024) {
88
88
  this.logger.warn(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);