@aztec/p2p 0.0.1-commit.6d63667d → 0.0.1-commit.7ac86ea28

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 (291) hide show
  1. package/dest/client/factory.d.ts +7 -6
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +46 -11
  4. package/dest/client/interface.d.ts +43 -23
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +38 -42
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +145 -145
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -6
  10. package/dest/config.d.ts +23 -4
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +16 -1
  13. package/dest/errors/tx-pool.error.d.ts +8 -0
  14. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  15. package/dest/errors/tx-pool.error.js +9 -0
  16. package/dest/index.d.ts +2 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -0
  19. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
  20. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  22. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  23. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  25. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  26. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/index.js +1 -2
  28. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  29. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  31. package/dest/mem_pools/index.d.ts +3 -2
  32. package/dest/mem_pools/index.d.ts.map +1 -1
  33. package/dest/mem_pools/index.js +1 -1
  34. package/dest/mem_pools/interface.d.ts +5 -5
  35. package/dest/mem_pools/interface.d.ts.map +1 -1
  36. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  37. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
  38. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  39. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
  40. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
  41. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
  42. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
  43. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  44. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  45. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +4 -1
  46. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
  47. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  48. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +10 -4
  49. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
  50. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  51. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
  52. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +48 -5
  53. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
  54. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
  56. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +5 -3
  57. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +1 -1
  58. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  59. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +8 -4
  60. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
  61. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
  62. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +14 -4
  63. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
  64. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
  65. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
  66. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -1
  67. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  68. package/dest/mem_pools/tx_pool_v2/index.js +1 -0
  69. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  70. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  71. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  72. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +16 -4
  73. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  74. package/dest/mem_pools/tx_pool_v2/interfaces.js +3 -1
  75. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +31 -5
  76. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  77. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +62 -5
  78. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
  79. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  80. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +27 -4
  81. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +8 -3
  82. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  83. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +11 -6
  84. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +12 -4
  85. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  86. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +239 -109
  87. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  88. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  89. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  90. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  91. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
  92. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  93. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  94. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
  95. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  96. package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
  97. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
  98. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  99. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  100. package/dest/services/dummy_service.d.ts +12 -3
  101. package/dest/services/dummy_service.d.ts.map +1 -1
  102. package/dest/services/dummy_service.js +9 -0
  103. package/dest/services/encoding.d.ts +2 -2
  104. package/dest/services/encoding.d.ts.map +1 -1
  105. package/dest/services/encoding.js +4 -3
  106. package/dest/services/gossipsub/index.d.ts +3 -0
  107. package/dest/services/gossipsub/index.d.ts.map +1 -0
  108. package/dest/services/gossipsub/index.js +2 -0
  109. package/dest/services/gossipsub/scoring.d.ts +21 -3
  110. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  111. package/dest/services/gossipsub/scoring.js +24 -7
  112. package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
  113. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  114. package/dest/services/gossipsub/topic_score_params.js +346 -0
  115. package/dest/services/libp2p/libp2p_service.d.ts +85 -35
  116. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  117. package/dest/services/libp2p/libp2p_service.js +370 -267
  118. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  119. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  120. package/dest/services/peer-manager/peer_scoring.js +25 -2
  121. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
  122. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  123. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +5 -9
  124. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
  125. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  126. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
  127. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  128. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
  129. package/dest/services/reqresp/interface.d.ts +10 -1
  130. package/dest/services/reqresp/interface.d.ts.map +1 -1
  131. package/dest/services/reqresp/interface.js +15 -1
  132. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +4 -3
  133. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  134. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
  135. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  136. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +15 -0
  137. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  138. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  139. package/dest/services/reqresp/protocols/tx.js +20 -0
  140. package/dest/services/reqresp/reqresp.d.ts +1 -1
  141. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  142. package/dest/services/reqresp/reqresp.js +11 -4
  143. package/dest/services/service.d.ts +38 -2
  144. package/dest/services/service.d.ts.map +1 -1
  145. package/dest/services/tx_collection/config.d.ts +19 -1
  146. package/dest/services/tx_collection/config.d.ts.map +1 -1
  147. package/dest/services/tx_collection/config.js +46 -0
  148. package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -1
  149. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  150. package/dest/services/tx_collection/fast_tx_collection.js +56 -36
  151. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  152. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  153. package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
  154. package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
  155. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  156. package/dest/services/tx_collection/file_store_tx_source.js +90 -0
  157. package/dest/services/tx_collection/index.d.ts +2 -1
  158. package/dest/services/tx_collection/index.d.ts.map +1 -1
  159. package/dest/services/tx_collection/index.js +1 -0
  160. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  161. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  162. package/dest/services/tx_collection/instrumentation.js +2 -1
  163. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  164. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  165. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  166. package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
  167. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  168. package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
  169. package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
  170. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  171. package/dest/services/tx_collection/slow_tx_collection.js +60 -26
  172. package/dest/services/tx_collection/tx_collection.d.ts +23 -10
  173. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  174. package/dest/services/tx_collection/tx_collection.js +75 -3
  175. package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
  176. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  177. package/dest/services/tx_collection/tx_collection_sink.js +26 -29
  178. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  179. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  180. package/dest/services/tx_collection/tx_source.js +19 -2
  181. package/dest/services/tx_file_store/config.d.ts +1 -3
  182. package/dest/services/tx_file_store/config.d.ts.map +1 -1
  183. package/dest/services/tx_file_store/config.js +0 -4
  184. package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
  185. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  186. package/dest/services/tx_file_store/tx_file_store.js +9 -6
  187. package/dest/services/tx_provider.d.ts +3 -3
  188. package/dest/services/tx_provider.d.ts.map +1 -1
  189. package/dest/services/tx_provider.js +5 -4
  190. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  191. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  192. package/dest/test-helpers/mock-pubsub.d.ts +29 -2
  193. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  194. package/dest/test-helpers/mock-pubsub.js +103 -2
  195. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  196. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  197. package/dest/test-helpers/reqresp-nodes.js +2 -1
  198. package/dest/test-helpers/testbench-utils.d.ts +43 -38
  199. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  200. package/dest/test-helpers/testbench-utils.js +128 -59
  201. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  202. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  203. package/dest/testbench/p2p_client_testbench_worker.js +10 -10
  204. package/dest/util.d.ts +2 -2
  205. package/dest/util.d.ts.map +1 -1
  206. package/package.json +14 -14
  207. package/src/client/factory.ts +86 -15
  208. package/src/client/interface.ts +59 -23
  209. package/src/client/p2p_client.ts +184 -167
  210. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -9
  211. package/src/config.ts +34 -2
  212. package/src/errors/tx-pool.error.ts +12 -0
  213. package/src/index.ts +1 -0
  214. package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
  215. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  216. package/src/mem_pools/attestation_pool/index.ts +9 -2
  217. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  218. package/src/mem_pools/index.ts +4 -1
  219. package/src/mem_pools/interface.ts +4 -4
  220. package/src/mem_pools/tx_pool/README.md +1 -1
  221. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  222. package/src/mem_pools/tx_pool_v2/README.md +76 -10
  223. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
  224. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
  225. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +4 -1
  226. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +15 -4
  227. package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
  228. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +49 -4
  229. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
  230. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
  231. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +8 -7
  232. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +24 -6
  233. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +3 -3
  234. package/src/mem_pools/tx_pool_v2/index.ts +1 -0
  235. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  236. package/src/mem_pools/tx_pool_v2/interfaces.ts +16 -4
  237. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +90 -9
  238. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +32 -5
  239. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +17 -6
  240. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +274 -104
  241. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  242. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  243. package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
  244. package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
  245. package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
  246. package/src/services/dummy_service.ts +17 -1
  247. package/src/services/encoding.ts +4 -3
  248. package/src/services/gossipsub/README.md +641 -0
  249. package/src/services/gossipsub/index.ts +2 -0
  250. package/src/services/gossipsub/scoring.ts +29 -5
  251. package/src/services/gossipsub/topic_score_params.ts +487 -0
  252. package/src/services/libp2p/libp2p_service.ts +367 -271
  253. package/src/services/peer-manager/peer_scoring.ts +25 -0
  254. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +6 -6
  255. package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
  256. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
  257. package/src/services/reqresp/interface.ts +26 -1
  258. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +4 -3
  259. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
  260. package/src/services/reqresp/protocols/tx.ts +22 -0
  261. package/src/services/reqresp/reqresp.ts +13 -3
  262. package/src/services/service.ts +50 -1
  263. package/src/services/tx_collection/config.ts +68 -0
  264. package/src/services/tx_collection/fast_tx_collection.ts +65 -32
  265. package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
  266. package/src/services/tx_collection/file_store_tx_source.ts +117 -0
  267. package/src/services/tx_collection/index.ts +1 -0
  268. package/src/services/tx_collection/instrumentation.ts +7 -1
  269. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  270. package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
  271. package/src/services/tx_collection/slow_tx_collection.ts +66 -33
  272. package/src/services/tx_collection/tx_collection.ts +113 -16
  273. package/src/services/tx_collection/tx_collection_sink.ts +30 -34
  274. package/src/services/tx_collection/tx_source.ts +22 -3
  275. package/src/services/tx_file_store/config.ts +0 -6
  276. package/src/services/tx_file_store/tx_file_store.ts +10 -8
  277. package/src/services/tx_provider.ts +8 -7
  278. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  279. package/src/test-helpers/mock-pubsub.ts +143 -3
  280. package/src/test-helpers/reqresp-nodes.ts +2 -1
  281. package/src/test-helpers/testbench-utils.ts +127 -71
  282. package/src/testbench/p2p_client_testbench_worker.ts +22 -15
  283. package/src/util.ts +7 -1
  284. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  285. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  286. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  287. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  288. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  289. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  290. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  291. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -2,7 +2,7 @@ import type { EpochCacheInterface } from '@aztec/epoch-cache';
2
2
  import { type CheckpointAttestation, PeerErrorSeverity, type ValidationResult } from '@aztec/stdlib/p2p';
3
3
  import { Attributes, Metrics, type TelemetryClient, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
4
4
 
5
- import type { AttestationPool } from '../../mem_pools/attestation_pool/attestation_pool.js';
5
+ import type { AttestationPoolApi } from '../../mem_pools/attestation_pool/attestation_pool.js';
6
6
  import { CheckpointAttestationValidator } from './attestation_validator.js';
7
7
 
8
8
  /**
@@ -18,7 +18,7 @@ export class FishermanAttestationValidator extends CheckpointAttestationValidato
18
18
 
19
19
  constructor(
20
20
  epochCache: EpochCacheInterface,
21
- private attestationPool: AttestationPool,
21
+ private attestationPool: AttestationPoolApi,
22
22
  telemetryClient: TelemetryClient,
23
23
  ) {
24
24
  super(epochCache);
@@ -1,6 +1,6 @@
1
- import type { ProcessedTx, Tx, TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
1
+ import type { TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
2
2
 
3
- export class AggregateTxValidator<T extends Tx | ProcessedTx> implements TxValidator<T> {
3
+ export class AggregateTxValidator<T> implements TxValidator<T> {
4
4
  #validators: TxValidator<T>[];
5
5
  constructor(...validators: TxValidator<T>[]) {
6
6
  if (validators.length === 0) {
@@ -1,12 +1,24 @@
1
1
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import type { BlockHash } from '@aztec/stdlib/block';
3
- import { type AnyTx, TX_ERROR_BLOCK_HEADER, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
3
+ import { TX_ERROR_BLOCK_HEADER, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
4
4
 
5
5
  export interface ArchiveSource {
6
6
  getArchiveIndices: (archives: BlockHash[]) => Promise<(bigint | undefined)[]>;
7
7
  }
8
8
 
9
- export class BlockHeaderTxValidator<T extends AnyTx> implements TxValidator<T> {
9
+ /** Structural interface for block header validation. */
10
+ export interface HasBlockHeaderData {
11
+ txHash: { toString(): string };
12
+ data: {
13
+ constants: {
14
+ anchorBlockHeader: {
15
+ hash(): Promise<BlockHash>;
16
+ };
17
+ };
18
+ };
19
+ }
20
+
21
+ export class BlockHeaderTxValidator<T extends HasBlockHeaderData> implements TxValidator<T> {
10
22
  #log: Logger;
11
23
  #archiveSource: ArchiveSource;
12
24
 
@@ -18,7 +30,7 @@ export class BlockHeaderTxValidator<T extends AnyTx> implements TxValidator<T> {
18
30
  async validateTx(tx: T): Promise<TxValidationResult> {
19
31
  const [index] = await this.#archiveSource.getArchiveIndices([await tx.data.constants.anchorBlockHeader.hash()]);
20
32
  if (index === undefined) {
21
- this.#log.verbose(`Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} for referencing an unknown block header`);
33
+ this.#log.verbose(`Rejecting tx ${tx.txHash} for referencing an unknown block header`);
22
34
  return { result: 'invalid', reason: [TX_ERROR_BLOCK_HEADER] };
23
35
  }
24
36
  return { result: 'valid' };
@@ -1,9 +1,8 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
1
2
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
3
  import {
3
- type AnyTx,
4
4
  TX_ERROR_DUPLICATE_NULLIFIER_IN_TX,
5
5
  TX_ERROR_EXISTING_NULLIFIER,
6
- Tx,
7
6
  type TxValidationResult,
8
7
  type TxValidator,
9
8
  } from '@aztec/stdlib/tx';
@@ -12,7 +11,13 @@ export interface NullifierSource {
12
11
  nullifiersExist: (nullifiers: Buffer[]) => Promise<boolean[]>;
13
12
  }
14
13
 
15
- export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
14
+ /** Structural interface for double-spend validation. */
15
+ export interface HasNullifierData {
16
+ txHash: { toString(): string };
17
+ data: { getNonEmptyNullifiers(): Fr[] };
18
+ }
19
+
20
+ export class DoubleSpendTxValidator<T extends HasNullifierData> implements TxValidator<T> {
16
21
  #log: Logger;
17
22
  #nullifierSource: NullifierSource;
18
23
 
@@ -22,17 +27,17 @@ export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
22
27
  }
23
28
 
24
29
  async validateTx(tx: T): Promise<TxValidationResult> {
25
- const nullifiers = tx instanceof Tx ? tx.data.getNonEmptyNullifiers() : tx.txEffect.nullifiers;
30
+ const nullifiers = tx.data.getNonEmptyNullifiers();
26
31
 
27
32
  // Ditch this tx if it has repeated nullifiers
28
33
  const uniqueNullifiers = new Set(nullifiers.map(n => n.toBigInt()));
29
34
  if (uniqueNullifiers.size !== nullifiers.length) {
30
- this.#log.verbose(`Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} for emitting duplicate nullifiers`);
35
+ this.#log.verbose(`Rejecting tx ${tx.txHash} for emitting duplicate nullifiers`);
31
36
  return { result: 'invalid', reason: [TX_ERROR_DUPLICATE_NULLIFIER_IN_TX] };
32
37
  }
33
38
 
34
39
  if ((await this.#nullifierSource.nullifiersExist(nullifiers.map(n => n.toBuffer()))).some(Boolean)) {
35
- this.#log.verbose(`Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} for repeating a nullifier`);
40
+ this.#log.verbose(`Rejecting tx ${tx.txHash} for repeating a nullifier`);
36
41
  return { result: 'invalid', reason: [TX_ERROR_EXISTING_NULLIFIER] };
37
42
  }
38
43
 
@@ -1,15 +1,24 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { type Logger, type LoggerBindings, 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';
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> {
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> {
13
22
  #log: Logger;
14
23
 
15
24
  constructor(
@@ -26,25 +35,21 @@ export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
26
35
  }
27
36
 
28
37
  validateTx(tx: T): Promise<TxValidationResult> {
29
- const includeByTimestamp = tx.data.includeByTimestamp;
30
- // 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`
31
40
  // function in `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
32
41
  const buildingBlock1 = this.values.blockNumber === 1;
33
42
 
34
- if (!buildingBlock1 && includeByTimestamp < this.values.timestamp) {
43
+ if (!buildingBlock1 && expirationTimestamp < this.values.timestamp) {
35
44
  if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber === 0) {
36
45
  this.#log.warn(
37
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.`,
38
47
  );
39
48
  }
40
49
  this.#log.verbose(
41
- `Rejecting tx ${getTxHash(
42
- tx,
43
- )} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${
44
- this.values.timestamp
45
- }.`,
50
+ `Rejecting tx ${tx.txHash} for low expiration timestamp. Tx expiration timestamp: ${expirationTimestamp}, timestamp: ${this.values.timestamp}.`,
46
51
  );
47
- return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP] });
52
+ return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_INVALID_EXPIRATION_TIMESTAMP] });
48
53
  } else {
49
54
  return Promise.resolve({ result: 'valid' });
50
55
  }
@@ -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';
@@ -26,6 +26,8 @@ import { ReqRespStatus } from './reqresp/status.js';
26
26
  import {
27
27
  type P2PBlockReceivedCallback,
28
28
  type P2PCheckpointReceivedCallback,
29
+ type P2PDuplicateAttestationCallback,
30
+ type P2PDuplicateProposalCallback,
29
31
  type P2PService,
30
32
  type PeerDiscoveryService,
31
33
  PeerDiscoveryState,
@@ -42,6 +44,10 @@ export class DummyP2PService implements P2PService {
42
44
  return [];
43
45
  }
44
46
 
47
+ getGossipMeshPeerCount(_topicType: TopicType): number {
48
+ return 0;
49
+ }
50
+
45
51
  /**
46
52
  * Starts the dummy implementation.
47
53
  * @returns A resolved promise.
@@ -82,6 +88,16 @@ export class DummyP2PService implements P2PService {
82
88
  */
83
89
  public registerCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
84
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
+
85
101
  /**
86
102
  * Sends a request to a peer.
87
103
  * @param _protocol - The protocol to send the request on.
@@ -58,7 +58,8 @@ const DefaultMaxSizesKb: Record<TopicType, number> = {
58
58
  // Proposals may carry some tx objects, so we allow a larger size capped at 10mb
59
59
  // Note this may not be enough for carrying all tx objects in a block
60
60
  [TopicType.block_proposal]: 1024 * 10,
61
- // TODO(palla/mbps): Check size for checkpoint proposal
61
+ // Checkpoint proposals carry almost the same data as a block proposal (see the lastBlockProposal)
62
+ // Only diff is an additional header, which is pretty small compared to the 10mb limit
62
63
  [TopicType.checkpoint_proposal]: 1024 * 10,
63
64
  };
64
65
 
@@ -78,11 +79,11 @@ export class SnappyTransform implements DataTransform {
78
79
  return this.inboundTransformData(Buffer.from(data), topic);
79
80
  }
80
81
 
81
- public inboundTransformData(data: Buffer, topic?: TopicType): Buffer {
82
+ public inboundTransformData(data: Buffer, topic?: TopicType, maxSizeKbOverride?: number): Buffer {
82
83
  if (data.length === 0) {
83
84
  return data;
84
85
  }
85
- const maxSizeKb = this.maxSizesKb[topic!] ?? this.defaultMaxSizeKb;
86
+ const maxSizeKb = maxSizeKbOverride ?? this.maxSizesKb[topic!] ?? this.defaultMaxSizeKb;
86
87
  const { decompressedSize } = readSnappyPreamble(data);
87
88
  if (decompressedSize > maxSizeKb * 1024) {
88
89
  this.logger.warn(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);