@aztec/p2p 0.0.1-commit.8afd444 → 0.0.1-commit.8f9871590

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 (277) hide show
  1. package/dest/client/factory.d.ts +5 -5
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +44 -10
  4. package/dest/client/interface.d.ts +37 -15
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +35 -36
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +114 -138
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -1
  10. package/dest/config.d.ts +23 -5
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +16 -1
  13. package/dest/index.d.ts +2 -1
  14. package/dest/index.d.ts.map +1 -1
  15. package/dest/index.js +1 -0
  16. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
  17. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  18. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  19. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  20. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  22. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  23. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/index.js +1 -2
  25. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  26. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  28. package/dest/mem_pools/index.d.ts +3 -2
  29. package/dest/mem_pools/index.d.ts.map +1 -1
  30. package/dest/mem_pools/index.js +1 -1
  31. package/dest/mem_pools/interface.d.ts +5 -5
  32. package/dest/mem_pools/interface.d.ts.map +1 -1
  33. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  34. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  35. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  36. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  37. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  38. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  39. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  40. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +102 -0
  41. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  42. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +242 -0
  43. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  44. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  45. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
  46. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  47. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  48. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
  49. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  50. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  51. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
  52. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  53. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  54. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
  56. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
  58. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  59. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  60. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
  61. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +72 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  73. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  74. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  75. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  76. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +201 -0
  77. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  78. package/dest/mem_pools/tx_pool_v2/interfaces.js +7 -0
  79. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +95 -0
  80. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  81. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +128 -0
  82. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  83. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  84. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  85. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +105 -0
  86. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  87. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +345 -0
  88. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +57 -0
  89. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  90. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +160 -0
  91. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +71 -0
  92. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  93. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +780 -0
  94. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  95. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  96. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  97. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  98. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
  99. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  100. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  101. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
  102. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  103. package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
  104. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
  105. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  106. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  107. package/dest/services/dummy_service.d.ts +10 -2
  108. package/dest/services/dummy_service.d.ts.map +1 -1
  109. package/dest/services/dummy_service.js +6 -0
  110. package/dest/services/encoding.d.ts +2 -2
  111. package/dest/services/encoding.d.ts.map +1 -1
  112. package/dest/services/encoding.js +2 -2
  113. package/dest/services/gossipsub/index.d.ts +3 -0
  114. package/dest/services/gossipsub/index.d.ts.map +1 -0
  115. package/dest/services/gossipsub/index.js +2 -0
  116. package/dest/services/gossipsub/scoring.d.ts +21 -3
  117. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  118. package/dest/services/gossipsub/scoring.js +24 -7
  119. package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
  120. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  121. package/dest/services/gossipsub/topic_score_params.js +324 -0
  122. package/dest/services/libp2p/libp2p_service.d.ts +84 -35
  123. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  124. package/dest/services/libp2p/libp2p_service.js +370 -275
  125. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  126. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  127. package/dest/services/peer-manager/peer_scoring.js +25 -2
  128. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
  129. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  130. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +8 -8
  131. package/dest/services/reqresp/interface.d.ts +10 -1
  132. package/dest/services/reqresp/interface.d.ts.map +1 -1
  133. package/dest/services/reqresp/interface.js +15 -1
  134. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  135. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  136. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +16 -11
  137. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +21 -10
  138. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  139. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +27 -11
  140. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  141. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  142. package/dest/services/reqresp/protocols/tx.js +20 -0
  143. package/dest/services/reqresp/reqresp.d.ts +1 -1
  144. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  145. package/dest/services/reqresp/reqresp.js +11 -4
  146. package/dest/services/service.d.ts +35 -1
  147. package/dest/services/service.d.ts.map +1 -1
  148. package/dest/services/tx_collection/config.d.ts +22 -4
  149. package/dest/services/tx_collection/config.d.ts.map +1 -1
  150. package/dest/services/tx_collection/config.js +49 -3
  151. package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
  152. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  153. package/dest/services/tx_collection/fast_tx_collection.js +27 -17
  154. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  155. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  156. package/dest/services/tx_collection/file_store_tx_collection.js +165 -0
  157. package/dest/services/tx_collection/file_store_tx_source.d.ts +28 -0
  158. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  159. package/dest/services/tx_collection/file_store_tx_source.js +59 -0
  160. package/dest/services/tx_collection/index.d.ts +3 -2
  161. package/dest/services/tx_collection/index.d.ts.map +1 -1
  162. package/dest/services/tx_collection/index.js +1 -0
  163. package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
  164. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  165. package/dest/services/tx_collection/proposal_tx_collector.js +4 -5
  166. package/dest/services/tx_collection/slow_tx_collection.d.ts +6 -2
  167. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  168. package/dest/services/tx_collection/slow_tx_collection.js +55 -23
  169. package/dest/services/tx_collection/tx_collection.d.ts +19 -7
  170. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  171. package/dest/services/tx_collection/tx_collection.js +75 -3
  172. package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
  173. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  174. package/dest/services/tx_collection/tx_collection_sink.js +13 -7
  175. package/dest/services/tx_file_store/config.d.ts +1 -3
  176. package/dest/services/tx_file_store/config.d.ts.map +1 -1
  177. package/dest/services/tx_file_store/config.js +0 -4
  178. package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
  179. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  180. package/dest/services/tx_file_store/tx_file_store.js +8 -5
  181. package/dest/services/tx_provider.d.ts +3 -3
  182. package/dest/services/tx_provider.d.ts.map +1 -1
  183. package/dest/services/tx_provider.js +5 -4
  184. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  185. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  186. package/dest/test-helpers/mock-pubsub.d.ts +27 -1
  187. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  188. package/dest/test-helpers/mock-pubsub.js +97 -2
  189. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  190. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  191. package/dest/test-helpers/reqresp-nodes.js +2 -1
  192. package/dest/test-helpers/testbench-utils.d.ts +40 -38
  193. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  194. package/dest/test-helpers/testbench-utils.js +128 -59
  195. package/dest/testbench/p2p_client_testbench_worker.js +4 -4
  196. package/package.json +14 -14
  197. package/src/client/factory.ts +81 -13
  198. package/src/client/interface.ts +45 -14
  199. package/src/client/p2p_client.ts +151 -161
  200. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -1
  201. package/src/config.ts +34 -2
  202. package/src/index.ts +1 -0
  203. package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
  204. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  205. package/src/mem_pools/attestation_pool/index.ts +9 -2
  206. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  207. package/src/mem_pools/index.ts +4 -1
  208. package/src/mem_pools/interface.ts +4 -4
  209. package/src/mem_pools/tx_pool/README.md +1 -1
  210. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  211. package/src/mem_pools/tx_pool_v2/README.md +275 -0
  212. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  213. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  214. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +310 -0
  215. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
  216. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
  217. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
  218. package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
  219. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
  220. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  221. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  222. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +88 -0
  223. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
  224. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  225. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  226. package/src/mem_pools/tx_pool_v2/interfaces.ts +233 -0
  227. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +211 -0
  228. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  229. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +433 -0
  230. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +218 -0
  231. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +924 -0
  232. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  233. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  234. package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
  235. package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
  236. package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
  237. package/src/services/dummy_service.ts +12 -0
  238. package/src/services/encoding.ts +2 -2
  239. package/src/services/gossipsub/README.md +626 -0
  240. package/src/services/gossipsub/index.ts +2 -0
  241. package/src/services/gossipsub/scoring.ts +29 -5
  242. package/src/services/gossipsub/topic_score_params.ts +451 -0
  243. package/src/services/libp2p/libp2p_service.ts +372 -277
  244. package/src/services/peer-manager/peer_scoring.ts +25 -0
  245. package/src/services/reqresp/batch-tx-requester/README.md +7 -7
  246. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +11 -11
  247. package/src/services/reqresp/interface.ts +26 -1
  248. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
  249. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +38 -15
  250. package/src/services/reqresp/protocols/tx.ts +22 -0
  251. package/src/services/reqresp/reqresp.ts +13 -3
  252. package/src/services/service.ts +40 -0
  253. package/src/services/tx_collection/config.ts +74 -6
  254. package/src/services/tx_collection/fast_tx_collection.ts +28 -26
  255. package/src/services/tx_collection/file_store_tx_collection.ts +198 -0
  256. package/src/services/tx_collection/file_store_tx_source.ts +73 -0
  257. package/src/services/tx_collection/index.ts +2 -1
  258. package/src/services/tx_collection/proposal_tx_collector.ts +12 -14
  259. package/src/services/tx_collection/slow_tx_collection.ts +64 -30
  260. package/src/services/tx_collection/tx_collection.ts +109 -13
  261. package/src/services/tx_collection/tx_collection_sink.ts +17 -7
  262. package/src/services/tx_file_store/config.ts +0 -6
  263. package/src/services/tx_file_store/tx_file_store.ts +9 -7
  264. package/src/services/tx_provider.ts +8 -7
  265. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  266. package/src/test-helpers/mock-pubsub.ts +133 -3
  267. package/src/test-helpers/reqresp-nodes.ts +2 -1
  268. package/src/test-helpers/testbench-utils.ts +127 -71
  269. package/src/testbench/p2p_client_testbench_worker.ts +4 -4
  270. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  271. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  272. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  273. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  274. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  275. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  276. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  277. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -49,7 +49,7 @@ class TestLibP2PService extends LibP2PService {
49
49
  const txHash = tx.getTxHash();
50
50
  const txHashString = txHash.toString();
51
51
  this.logger.verbose(`Received tx ${txHashString} from external peer ${source.toString()}.`);
52
- await this.mempools.txPool.addTxs([
52
+ await this.mempools.txPool.addPendingTxs([
53
53
  tx
54
54
  ]);
55
55
  } else {
@@ -70,7 +70,7 @@ async function generateDeterministicTxs(txCount, seed, config) {
70
70
  if (cached.length >= txCount) {
71
71
  return cached.slice(0, txCount);
72
72
  }
73
- const includeByTimestampBase = BigInt(seed);
73
+ const expirationTimestampBase = BigInt(seed);
74
74
  for(let i = cached.length; i < txCount; i++){
75
75
  const txSeed = seed * 10000 + i;
76
76
  const tx = await mockTx(txSeed, {
@@ -86,7 +86,7 @@ async function generateDeterministicTxs(txCount, seed, config) {
86
86
  hasPublicTeardownCallRequest: false,
87
87
  publicCalldataSize: 0
88
88
  });
89
- tx.data.includeByTimestamp = includeByTimestampBase + BigInt(i);
89
+ tx.data.expirationTimestamp = expirationTimestampBase + BigInt(i);
90
90
  await tx.recomputeHash();
91
91
  cached.push(tx);
92
92
  }
@@ -273,7 +273,7 @@ process.on('message', async (msg)=>{
273
273
  const allTxs = await generateDeterministicTxs(benchCmd.txCount, benchCmd.seed, workerConfig);
274
274
  const txHashes = allTxs.map((tx)=>tx.getTxHash());
275
275
  const blockProposal = await createBlockProposal(benchCmd.blockNumber, txHashes, benchCmd.seed);
276
- await workerAttestationPool.addBlockProposal(blockProposal);
276
+ await workerAttestationPool.tryAddBlockProposal(blockProposal);
277
277
  workerLogger.debug(`[BENCH] Added block proposal with archive ${blockProposal.archive.toString().slice(0, 10)}...`);
278
278
  if (benchCmd.isAggregator) {
279
279
  workerTxPool.clearTxs();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/p2p",
3
- "version": "0.0.1-commit.8afd444",
3
+ "version": "0.0.1-commit.8f9871590",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -67,17 +67,17 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/constants": "0.0.1-commit.8afd444",
71
- "@aztec/epoch-cache": "0.0.1-commit.8afd444",
72
- "@aztec/ethereum": "0.0.1-commit.8afd444",
73
- "@aztec/foundation": "0.0.1-commit.8afd444",
74
- "@aztec/kv-store": "0.0.1-commit.8afd444",
75
- "@aztec/noir-contracts.js": "0.0.1-commit.8afd444",
76
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.8afd444",
77
- "@aztec/protocol-contracts": "0.0.1-commit.8afd444",
78
- "@aztec/simulator": "0.0.1-commit.8afd444",
79
- "@aztec/stdlib": "0.0.1-commit.8afd444",
80
- "@aztec/telemetry-client": "0.0.1-commit.8afd444",
70
+ "@aztec/constants": "0.0.1-commit.8f9871590",
71
+ "@aztec/epoch-cache": "0.0.1-commit.8f9871590",
72
+ "@aztec/ethereum": "0.0.1-commit.8f9871590",
73
+ "@aztec/foundation": "0.0.1-commit.8f9871590",
74
+ "@aztec/kv-store": "0.0.1-commit.8f9871590",
75
+ "@aztec/noir-contracts.js": "0.0.1-commit.8f9871590",
76
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.8f9871590",
77
+ "@aztec/protocol-contracts": "0.0.1-commit.8f9871590",
78
+ "@aztec/simulator": "0.0.1-commit.8f9871590",
79
+ "@aztec/stdlib": "0.0.1-commit.8f9871590",
80
+ "@aztec/telemetry-client": "0.0.1-commit.8f9871590",
81
81
  "@chainsafe/libp2p-gossipsub": "13.0.0",
82
82
  "@chainsafe/libp2p-noise": "^15.0.0",
83
83
  "@chainsafe/libp2p-yamux": "^6.0.2",
@@ -104,8 +104,8 @@
104
104
  "xxhash-wasm": "^1.1.0"
105
105
  },
106
106
  "devDependencies": {
107
- "@aztec/archiver": "0.0.1-commit.8afd444",
108
- "@aztec/world-state": "0.0.1-commit.8afd444",
107
+ "@aztec/archiver": "0.0.1-commit.8f9871590",
108
+ "@aztec/world-state": "0.0.1-commit.8f9871590",
109
109
  "@jest/globals": "^30.0.0",
110
110
  "@types/jest": "^30.0.0",
111
111
  "@types/node": "^22.15.17",
@@ -4,30 +4,36 @@ import { DateProvider } from '@aztec/foundation/timer';
4
4
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
5
5
  import type { DataStoreConfig } from '@aztec/kv-store/config';
6
6
  import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
7
- import type { L2BlockSource } from '@aztec/stdlib/block';
7
+ import type { BlockHash, L2BlockSource } from '@aztec/stdlib/block';
8
8
  import type { ChainConfig } from '@aztec/stdlib/config';
9
9
  import type { ContractDataSource } from '@aztec/stdlib/contract';
10
10
  import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
11
11
  import { P2PClientType } from '@aztec/stdlib/p2p';
12
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
12
13
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
13
14
 
14
15
  import { P2PClient } from '../client/p2p_client.js';
15
16
  import type { P2PConfig } from '../config.js';
16
- import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
17
- import { KvAttestationPool } from '../mem_pools/attestation_pool/kv_attestation_pool.js';
17
+ import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
18
18
  import type { MemPools } from '../mem_pools/interface.js';
19
- import { AztecKVTxPool, type TxPool } from '../mem_pools/tx_pool/index.js';
19
+ import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
20
+ import type { TxMetaData } from '../mem_pools/tx_pool_v2/tx_metadata.js';
21
+ import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
22
+ import { AggregateTxValidator } from '../msg_validators/tx_validator/aggregate_tx_validator.js';
23
+ import { BlockHeaderTxValidator } from '../msg_validators/tx_validator/block_header_validator.js';
24
+ import { DoubleSpendTxValidator } from '../msg_validators/tx_validator/double_spend_validator.js';
20
25
  import { DummyP2PService } from '../services/dummy_service.js';
21
26
  import { LibP2PService } from '../services/index.js';
27
+ import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
22
28
  import { TxCollection } from '../services/tx_collection/tx_collection.js';
23
29
  import { type TxSource, createNodeRpcTxSources } from '../services/tx_collection/tx_source.js';
24
30
  import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
25
31
  import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
26
32
 
27
33
  export type P2PClientDeps<T extends P2PClientType> = {
28
- txPool?: TxPool;
34
+ txPool?: TxPoolV2;
29
35
  store?: AztecAsyncKVStore;
30
- attestationPool?: AttestationPool;
36
+ attestationPool?: AttestationPoolApi;
31
37
  logger?: Logger;
32
38
  txCollectionNodeSources?: TxSource[];
33
39
  p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService<T>>;
@@ -70,14 +76,57 @@ export async function createP2PClient<T extends P2PClientType>(
70
76
  const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME, 1, config, bindings);
71
77
  const l1Constants = await archiver.getL1Constants();
72
78
 
73
- const mempools: MemPools = {
74
- txPool:
75
- deps.txPool ??
76
- new AztecKVTxPool(store, archive, worldStateSynchronizer, telemetry, {
79
+ const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
80
+ const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
81
+
82
+ /** Validator factory for pool re-validation (double-spend + block header only). */
83
+ const createPoolTxValidator = async () => {
84
+ await worldStateSynchronizer.syncImmediate();
85
+ return new AggregateTxValidator<TxMetaData>(
86
+ new DoubleSpendTxValidator<TxMetaData>(
87
+ {
88
+ nullifiersExist: async (nullifiers: Buffer[]) => {
89
+ const merkleTree = worldStateSynchronizer.getCommitted();
90
+ const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
91
+ return indices.map(index => index !== undefined);
92
+ },
93
+ },
94
+ bindings,
95
+ ),
96
+ new BlockHeaderTxValidator<TxMetaData>(
97
+ {
98
+ getArchiveIndices: (archives: BlockHash[]) => {
99
+ const merkleTree = worldStateSynchronizer.getCommitted();
100
+ return merkleTree.findLeafIndices(MerkleTreeId.ARCHIVE, archives);
101
+ },
102
+ },
103
+ bindings,
104
+ ),
105
+ );
106
+ };
107
+
108
+ const txPool =
109
+ deps.txPool ??
110
+ new AztecKVTxPoolV2(
111
+ store,
112
+ archive,
113
+ {
114
+ l2BlockSource: archiver,
115
+ worldStateSynchronizer,
116
+ createTxValidator: createPoolTxValidator,
117
+ },
118
+ telemetry,
119
+ {
77
120
  maxPendingTxCount: config.maxPendingTxCount,
78
121
  archivedTxLimit: config.archivedTxLimit,
79
- }),
80
- attestationPool: deps.attestationPool ?? new KvAttestationPool(attestationStore, telemetry),
122
+ minTxPoolAgeMs: config.minTxPoolAgeMs,
123
+ },
124
+ dateProvider,
125
+ );
126
+
127
+ const mempools: MemPools = {
128
+ txPool,
129
+ attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
81
130
  };
82
131
 
83
132
  const p2pService = await createP2PService<T>(
@@ -106,18 +155,36 @@ export async function createP2PClient<T extends P2PClientType>(
106
155
  });
107
156
  }
108
157
 
158
+ const fileStoreSources = await createFileStoreTxSources(
159
+ config.txCollectionFileStoreUrls,
160
+ txFileStoreBasePath,
161
+ logger.createChild('file-store-tx-source'),
162
+ );
163
+ if (fileStoreSources.length > 0) {
164
+ logger.info(`Using ${fileStoreSources.length} file store sources for tx collection.`, {
165
+ stores: fileStoreSources.map(s => s.getInfo()),
166
+ });
167
+ }
168
+
109
169
  const txCollection = new TxCollection(
110
170
  p2pService.getBatchTxRequesterService(),
111
171
  nodeSources,
112
172
  l1Constants,
113
173
  mempools.txPool,
114
174
  config,
175
+ fileStoreSources,
115
176
  dateProvider,
116
177
  telemetry,
117
178
  logger.createChild('tx-collection'),
118
179
  );
119
180
 
120
- const txFileStore = await TxFileStore.create(mempools.txPool, config, logger.createChild('tx-file-store'), telemetry);
181
+ const txFileStore = await TxFileStore.create(
182
+ mempools.txPool,
183
+ config,
184
+ txFileStoreBasePath,
185
+ logger.createChild('tx-file-store'),
186
+ telemetry,
187
+ );
121
188
 
122
189
  return new P2PClient(
123
190
  clientType,
@@ -127,6 +194,7 @@ export async function createP2PClient<T extends P2PClientType>(
127
194
  p2pService,
128
195
  txCollection,
129
196
  txFileStore,
197
+ epochCache,
130
198
  config,
131
199
  dateProvider,
132
200
  telemetry,
@@ -1,7 +1,8 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
2
3
  import type { P2PApiFull } from '@aztec/stdlib/interfaces/server';
3
4
  import type { BlockProposal, CheckpointAttestation, CheckpointProposal, P2PClientType } from '@aztec/stdlib/p2p';
4
- import type { Tx, TxHash } from '@aztec/stdlib/tx';
5
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
5
6
 
6
7
  import type { PeerId } from '@libp2p/interface';
7
8
  import type { ENR } from '@nethermindeth/enr';
@@ -13,7 +14,12 @@ import type {
13
14
  ReqRespSubProtocolHandler,
14
15
  ReqRespSubProtocolValidators,
15
16
  } from '../services/reqresp/interface.js';
16
- import type { P2PBlockReceivedCallback, P2PCheckpointReceivedCallback } from '../services/service.js';
17
+ import type {
18
+ DuplicateAttestationInfo,
19
+ DuplicateProposalInfo,
20
+ P2PBlockReceivedCallback,
21
+ P2PCheckpointReceivedCallback,
22
+ } from '../services/service.js';
17
23
 
18
24
  /**
19
25
  * Enum defining the possible states of the p2p client.
@@ -79,12 +85,21 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
79
85
  registerCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
80
86
 
81
87
  /**
82
- * Request a list of transactions from another peer by their tx hashes.
83
- * @param txHashes - Hashes of the txs to query.
84
- * @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
85
- * @returns A list of transactions or undefined if the transactions are not found.
88
+ * Registers a callback invoked when a duplicate proposal is detected (equivocation).
89
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
90
+ *
91
+ * @param callback - Function called with info about the duplicate proposal
92
+ */
93
+ registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void;
94
+
95
+ /**
96
+ * Registers a callback invoked when a duplicate attestation is detected (equivocation).
97
+ * A validator signing attestations for different proposals at the same slot.
98
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
99
+ *
100
+ * @param callback - Function called with info about the duplicate attestation
86
101
  */
87
- requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId): Promise<Tx[]>;
102
+ registerDuplicateAttestationCallback(callback: (info: DuplicateAttestationInfo) => void): void;
88
103
 
89
104
  /**
90
105
  * Verifies the 'tx' and, if valid, adds it to local tx pool and forwards it to other peers.
@@ -100,11 +115,10 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
100
115
  addTxsToPool(txs: Tx[]): Promise<number>;
101
116
 
102
117
  /**
103
- * Deletes 'txs' from the pool, given hashes.
104
- * NOT used if we use sendTx as reconcileTxPool will handle this.
105
- * @param txHashes - Hashes to check.
118
+ * Handles failed transaction execution by removing txs from the pool.
119
+ * @param txHashes - Hashes of the transactions that failed execution.
106
120
  **/
107
- deleteTxs(txHashes: TxHash[]): Promise<void>;
121
+ handleFailedExecution(txHashes: TxHash[]): Promise<void>;
108
122
 
109
123
  /**
110
124
  * Returns a transaction in the transaction pool by its hash.
@@ -152,14 +166,28 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
152
166
  /** Returns an iterator over pending txs on the mempool. */
153
167
  iteratePendingTxs(): AsyncIterableIterator<Tx>;
154
168
 
169
+ /** Returns an iterator over pending txs that have been in the pool long enough to be eligible for block building. */
170
+ iterateEligiblePendingTxs(): AsyncIterableIterator<Tx>;
171
+
155
172
  /** Returns the number of pending txs in the mempool. */
156
173
  getPendingTxCount(): Promise<number>;
157
174
 
158
175
  /**
159
- * Marks transactions as non-evictable in the pool.
160
- * @param txHashes - Hashes of the transactions to mark as non-evictable.
176
+ * Protects existing transactions by hash for a given slot.
177
+ * Returns hashes of transactions that weren't found in the pool.
178
+ * @param txHashes - Hashes of the transactions to protect.
179
+ * @param blockHeader - The block header providing slot context.
180
+ * @returns Hashes of transactions not found in the pool.
181
+ */
182
+ protectTxs(txHashes: TxHash[], blockHeader: BlockHeader): Promise<TxHash[]>;
183
+
184
+ /**
185
+ * Prepares the pool for a new slot.
186
+ * Unprotects transactions from earlier slots and validates them before
187
+ * returning to pending state.
188
+ * @param slotNumber - The slot number to prepare for
161
189
  */
162
- markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
190
+ prepareForSlot(slotNumber: SlotNumber): Promise<void>;
163
191
 
164
192
  /**
165
193
  * Starts the p2p client.
@@ -208,6 +236,9 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
208
236
 
209
237
  handleAuthRequestFromPeer(authRequest: AuthRequest, peerId: PeerId): Promise<StatusMessage>;
210
238
 
239
+ /** Checks if any block proposals exist for the given slot. */
240
+ hasBlockProposalsForSlot(slot: SlotNumber): Promise<boolean>;
241
+
211
242
  /** If node running this P2P stack is validator, passes in validator address to P2P layer */
212
243
  registerThisValidatorAddresses(address: EthAddress[]): void;
213
244
  };