@aztec/p2p 0.0.1-commit.3d8f95d → 0.0.1-commit.3e3d0c9cd

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 (311) hide show
  1. package/README.md +129 -3
  2. package/dest/client/factory.d.ts +7 -7
  3. package/dest/client/factory.d.ts.map +1 -1
  4. package/dest/client/factory.js +35 -29
  5. package/dest/client/interface.d.ts +14 -19
  6. package/dest/client/interface.d.ts.map +1 -1
  7. package/dest/client/p2p_client.d.ts +9 -18
  8. package/dest/client/p2p_client.d.ts.map +1 -1
  9. package/dest/client/p2p_client.js +62 -96
  10. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
  11. package/dest/config.d.ts +37 -15
  12. package/dest/config.d.ts.map +1 -1
  13. package/dest/config.js +81 -37
  14. package/dest/errors/tx-pool.error.d.ts +8 -0
  15. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  16. package/dest/errors/tx-pool.error.js +9 -0
  17. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -2
  18. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  19. package/dest/mem_pools/attestation_pool/attestation_pool.js +10 -1
  20. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  21. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  22. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  23. package/dest/mem_pools/instrumentation.d.ts +4 -2
  24. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  25. package/dest/mem_pools/instrumentation.js +16 -14
  26. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  27. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  28. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +2 -1
  29. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  30. package/dest/mem_pools/tx_pool/priority.d.ts +2 -2
  31. package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
  32. package/dest/mem_pools/tx_pool/priority.js +4 -4
  33. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
  34. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  35. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -1
  36. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +30 -13
  37. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
  38. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
  39. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
  40. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
  41. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
  42. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  43. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  44. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +7 -3
  45. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
  46. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
  48. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
  49. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  50. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
  51. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
  52. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
  53. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
  54. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
  55. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
  56. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
  57. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  58. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
  59. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
  60. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
  61. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
  62. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
  63. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
  64. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
  65. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
  66. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  67. package/dest/mem_pools/tx_pool_v2/index.js +1 -1
  68. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  69. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  70. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  71. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +24 -6
  72. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  73. package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
  74. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +56 -15
  75. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  76. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +107 -18
  77. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
  78. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  79. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +50 -45
  80. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -5
  81. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  82. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +17 -6
  83. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -5
  84. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  85. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +319 -147
  86. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
  87. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  88. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
  89. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
  90. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  91. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
  92. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
  93. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  94. package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
  95. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
  96. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  97. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
  98. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  99. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  100. package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
  101. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  102. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  103. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  104. package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
  105. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  106. package/dest/msg_validators/tx_validator/factory.js +240 -59
  107. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
  108. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
  109. package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
  110. package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
  111. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  112. package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
  113. package/dest/msg_validators/tx_validator/index.d.ts +3 -1
  114. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  115. package/dest/msg_validators/tx_validator/index.js +2 -0
  116. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
  117. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  118. package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
  119. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  120. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  121. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  122. package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
  123. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  124. package/dest/msg_validators/tx_validator/phases_validator.js +71 -23
  125. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
  126. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  127. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  128. package/dest/services/dummy_service.d.ts +4 -4
  129. package/dest/services/dummy_service.d.ts.map +1 -1
  130. package/dest/services/dummy_service.js +4 -4
  131. package/dest/services/encoding.d.ts +2 -2
  132. package/dest/services/encoding.d.ts.map +1 -1
  133. package/dest/services/encoding.js +9 -8
  134. package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
  135. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  136. package/dest/services/gossipsub/topic_score_params.js +32 -10
  137. package/dest/services/libp2p/libp2p_service.d.ts +16 -13
  138. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  139. package/dest/services/libp2p/libp2p_service.js +111 -93
  140. package/dest/services/peer-manager/metrics.d.ts +3 -1
  141. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  142. package/dest/services/peer-manager/metrics.js +6 -0
  143. package/dest/services/peer-manager/peer_manager.d.ts +1 -1
  144. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  145. package/dest/services/peer-manager/peer_manager.js +2 -1
  146. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -4
  147. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  148. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +45 -55
  149. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -6
  150. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  151. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -13
  152. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  153. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +31 -46
  154. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
  155. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  156. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
  157. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
  158. package/dest/services/reqresp/reqresp.d.ts +1 -1
  159. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  160. package/dest/services/reqresp/reqresp.js +3 -2
  161. package/dest/services/service.d.ts +5 -3
  162. package/dest/services/service.d.ts.map +1 -1
  163. package/dest/services/tx_collection/config.d.ts +13 -1
  164. package/dest/services/tx_collection/config.d.ts.map +1 -1
  165. package/dest/services/tx_collection/config.js +30 -0
  166. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
  167. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  168. package/dest/services/tx_collection/fast_tx_collection.js +39 -33
  169. package/dest/services/tx_collection/file_store_tx_collection.d.ts +38 -29
  170. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
  171. package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
  172. package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
  173. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  174. package/dest/services/tx_collection/file_store_tx_source.js +49 -16
  175. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  176. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  177. package/dest/services/tx_collection/instrumentation.js +2 -1
  178. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  179. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  180. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  181. package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
  182. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  183. package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
  184. package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
  185. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  186. package/dest/services/tx_collection/slow_tx_collection.js +17 -12
  187. package/dest/services/tx_collection/tx_collection.d.ts +9 -6
  188. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  189. package/dest/services/tx_collection/tx_collection.js +26 -10
  190. package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
  191. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  192. package/dest/services/tx_collection/tx_collection_sink.js +13 -22
  193. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  194. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  195. package/dest/services/tx_collection/tx_source.js +19 -2
  196. package/dest/services/tx_file_store/tx_file_store.d.ts +3 -2
  197. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  198. package/dest/services/tx_file_store/tx_file_store.js +9 -6
  199. package/dest/services/tx_provider.d.ts +3 -3
  200. package/dest/services/tx_provider.d.ts.map +1 -1
  201. package/dest/services/tx_provider.js +4 -4
  202. package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
  203. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  204. package/dest/test-helpers/make-test-p2p-clients.js +1 -2
  205. package/dest/test-helpers/mock-pubsub.d.ts +4 -4
  206. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  207. package/dest/test-helpers/mock-pubsub.js +8 -2
  208. package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
  209. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  210. package/dest/test-helpers/reqresp-nodes.js +2 -2
  211. package/dest/test-helpers/testbench-utils.d.ts +8 -3
  212. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  213. package/dest/test-helpers/testbench-utils.js +9 -2
  214. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  215. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  216. package/dest/testbench/p2p_client_testbench_worker.js +15 -14
  217. package/dest/testbench/worker_client_manager.d.ts +3 -1
  218. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  219. package/dest/testbench/worker_client_manager.js +6 -2
  220. package/dest/util.d.ts +3 -3
  221. package/dest/util.d.ts.map +1 -1
  222. package/package.json +14 -14
  223. package/src/client/factory.ts +62 -47
  224. package/src/client/interface.ts +17 -20
  225. package/src/client/p2p_client.ts +68 -126
  226. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
  227. package/src/config.ts +116 -43
  228. package/src/errors/tx-pool.error.ts +12 -0
  229. package/src/mem_pools/attestation_pool/attestation_pool.ts +13 -4
  230. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  231. package/src/mem_pools/instrumentation.ts +17 -13
  232. package/src/mem_pools/tx_pool/README.md +1 -1
  233. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +2 -1
  234. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  235. package/src/mem_pools/tx_pool/priority.ts +4 -4
  236. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
  237. package/src/mem_pools/tx_pool_v2/README.md +52 -28
  238. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
  239. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
  240. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +7 -3
  241. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
  242. package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
  243. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
  244. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
  245. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
  246. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
  247. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
  248. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
  249. package/src/mem_pools/tx_pool_v2/index.ts +1 -1
  250. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  251. package/src/mem_pools/tx_pool_v2/interfaces.ts +26 -6
  252. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +156 -26
  253. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +58 -45
  254. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +34 -8
  255. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +353 -143
  256. package/src/msg_validators/attestation_validator/README.md +49 -0
  257. package/src/msg_validators/proposal_validator/README.md +123 -0
  258. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
  259. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
  260. package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -40
  261. package/src/msg_validators/tx_validator/README.md +119 -0
  262. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
  263. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  264. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  265. package/src/msg_validators/tx_validator/factory.ts +387 -78
  266. package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
  267. package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
  268. package/src/msg_validators/tx_validator/index.ts +2 -0
  269. package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
  270. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  271. package/src/msg_validators/tx_validator/phases_validator.ts +81 -26
  272. package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
  273. package/src/services/dummy_service.ts +6 -6
  274. package/src/services/encoding.ts +7 -7
  275. package/src/services/gossipsub/README.md +29 -14
  276. package/src/services/gossipsub/topic_score_params.ts +49 -13
  277. package/src/services/libp2p/libp2p_service.ts +122 -101
  278. package/src/services/peer-manager/metrics.ts +7 -0
  279. package/src/services/peer-manager/peer_manager.ts +2 -1
  280. package/src/services/reqresp/README.md +229 -0
  281. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +49 -57
  282. package/src/services/reqresp/batch-tx-requester/interface.ts +3 -5
  283. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
  284. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
  285. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
  286. package/src/services/reqresp/reqresp.ts +4 -2
  287. package/src/services/service.ts +11 -2
  288. package/src/services/tx_collection/config.ts +42 -0
  289. package/src/services/tx_collection/fast_tx_collection.ts +51 -30
  290. package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
  291. package/src/services/tx_collection/file_store_tx_source.ts +64 -17
  292. package/src/services/tx_collection/instrumentation.ts +7 -1
  293. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  294. package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
  295. package/src/services/tx_collection/slow_tx_collection.ts +17 -13
  296. package/src/services/tx_collection/tx_collection.ts +45 -14
  297. package/src/services/tx_collection/tx_collection_sink.ts +15 -29
  298. package/src/services/tx_collection/tx_source.ts +22 -3
  299. package/src/services/tx_file_store/tx_file_store.ts +6 -4
  300. package/src/services/tx_provider.ts +2 -2
  301. package/src/test-helpers/make-test-p2p-clients.ts +1 -3
  302. package/src/test-helpers/mock-pubsub.ts +13 -6
  303. package/src/test-helpers/reqresp-nodes.ts +3 -6
  304. package/src/test-helpers/testbench-utils.ts +12 -3
  305. package/src/testbench/p2p_client_testbench_worker.ts +24 -20
  306. package/src/testbench/worker_client_manager.ts +13 -5
  307. package/src/util.ts +8 -2
  308. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
  309. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
  310. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
  311. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
@@ -1,12 +1,13 @@
1
1
  import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
2
2
  import type { EpochCacheInterface } from '@aztec/epoch-cache';
3
- import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
4
  import { createLogger } from '@aztec/foundation/log';
5
5
  import { RunningPromise } from '@aztec/foundation/promise';
6
6
  import { DateProvider } from '@aztec/foundation/timer';
7
7
  import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
8
8
  import { L2TipsKVStore } from '@aztec/kv-store/stores';
9
9
  import {
10
+ type CheckpointId,
10
11
  type EthAddress,
11
12
  type L2Block,
12
13
  type L2BlockId,
@@ -17,14 +18,8 @@ import {
17
18
  type L2TipsStore,
18
19
  } from '@aztec/stdlib/block';
19
20
  import type { ContractDataSource } from '@aztec/stdlib/contract';
20
- import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
21
21
  import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
22
- import {
23
- type BlockProposal,
24
- CheckpointAttestation,
25
- type CheckpointProposal,
26
- type P2PClientType,
27
- } from '@aztec/stdlib/p2p';
22
+ import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
28
23
  import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
29
24
  import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
30
25
 
@@ -32,6 +27,7 @@ import type { PeerId } from '@libp2p/interface';
32
27
  import type { ENR } from '@nethermindeth/enr';
33
28
 
34
29
  import { type P2PConfig, getP2PDefaultConfig } from '../config.js';
30
+ import { TxPoolError } from '../errors/tx-pool.error.js';
35
31
  import type { AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
36
32
  import type { MemPools } from '../mem_pools/interface.js';
37
33
  import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
@@ -41,7 +37,6 @@ import {
41
37
  type ReqRespSubProtocolHandler,
42
38
  type ReqRespSubProtocolValidators,
43
39
  } from '../services/reqresp/interface.js';
44
- import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
45
40
  import type {
46
41
  DuplicateAttestationInfo,
47
42
  DuplicateProposalInfo,
@@ -57,10 +52,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
57
52
  /**
58
53
  * The P2P client implementation.
59
54
  */
60
- export class P2PClient<T extends P2PClientType = P2PClientType.Full>
61
- extends WithTracer
62
- implements P2P, P2P<P2PClientType.Prover>
63
- {
55
+ export class P2PClient extends WithTracer implements P2P {
64
56
  /** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
65
57
  private runningPromise!: Promise<void>;
66
58
 
@@ -92,7 +84,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
92
84
  private slotMonitor: RunningPromise | undefined;
93
85
 
94
86
  constructor(
95
- _clientType: T,
96
87
  private store: AztecAsyncKVStore,
97
88
  private l2BlockSource: L2BlockSource & ContractDataSource,
98
89
  mempools: MemPools,
@@ -119,27 +110,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
119
110
  this.telemetry,
120
111
  );
121
112
 
122
- // Default to collecting all txs when we see a valid proposal
123
- // This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
124
- // Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
125
- // TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
126
- // validator-client code into here so we can validate a proposal is reasonable.
127
- this.registerBlockProposalHandler(async (block, sender) => {
128
- this.log.debug(`Received block proposal from ${sender.toString()}`);
129
- // TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
130
- const constants = this.txCollection.getConstants();
131
- const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
132
- const deadline = new Date(nextSlotTimestampSeconds * 1000);
133
- const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
134
- if (!parentBlock) {
135
- this.log.debug(`Cannot collect txs for proposal as parent block not found`);
136
- return false;
137
- }
138
- const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
139
- await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
140
- return true;
141
- });
142
-
143
113
  this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
144
114
  this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
145
115
  }
@@ -165,6 +135,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
165
135
  return Promise.resolve(this.p2pService.getPeers(includePending));
166
136
  }
167
137
 
138
+ public getGossipMeshPeerCount(topicType: TopicType): Promise<number> {
139
+ return Promise.resolve(this.p2pService.getGossipMeshPeerCount(topicType));
140
+ }
141
+
168
142
  public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
169
143
  return this.l2Tips.getL2BlockHash(number);
170
144
  }
@@ -200,7 +174,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
200
174
  break;
201
175
  case 'chain-pruned':
202
176
  this.txCollection.stopCollectingForBlocksAfter(event.block.number);
203
- await this.handlePruneL2Blocks(event.block);
177
+ await this.handlePruneL2Blocks(event.block, event.checkpoint);
204
178
  break;
205
179
  case 'chain-checkpointed':
206
180
  break;
@@ -404,6 +378,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
404
378
  return this.attestationPool.addOwnCheckpointAttestations(attestations);
405
379
  }
406
380
 
381
+ public hasBlockProposalsForSlot(slot: SlotNumber): Promise<boolean> {
382
+ return this.attestationPool.hasBlockProposalsForSlot(slot);
383
+ }
384
+
407
385
  // REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
408
386
  // ^ This pattern is not my favorite (md)
409
387
  public registerBlockProposalHandler(handler: P2PBlockReceivedCallback): void {
@@ -422,36 +400,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
422
400
  this.p2pService.registerDuplicateAttestationCallback(callback);
423
401
  }
424
402
 
425
- /**
426
- * Uses the batched Request Response protocol to request a set of transactions from the network.
427
- */
428
- private async requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<Tx[]> {
429
- const timeoutMs = 8000; // Longer timeout for now
430
- const maxRetryAttempts = 10; // Keep retrying within the timeout
431
- const requests = chunkTxHashesRequest(txHashes);
432
- const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
433
-
434
- const txBatches = await this.p2pService.sendBatchRequest(
435
- ReqRespSubProtocol.TX,
436
- requests,
437
- pinnedPeerId,
438
- timeoutMs,
439
- maxPeers,
440
- maxRetryAttempts,
441
- );
442
-
443
- const txs = txBatches.flat();
444
- if (txs.length > 0) {
445
- await this.txPool.addPendingTxs(txs);
446
- }
447
-
448
- const txHashesStr = txHashes.map(tx => tx.toString()).join(', ');
449
- this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
450
-
451
- // We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
452
- return txs;
453
- }
454
-
455
403
  public async getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
456
404
  if (limit !== undefined && limit <= 0) {
457
405
  throw new TypeError('limit must be greater than 0');
@@ -488,6 +436,15 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
488
436
  }
489
437
  }
490
438
 
439
+ public async *iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
440
+ for (const txHash of await this.txPool.getEligiblePendingTxHashes()) {
441
+ const tx = await this.txPool.getTxByHash(txHash);
442
+ if (tx) {
443
+ yield tx;
444
+ }
445
+ }
446
+ }
447
+
491
448
  /**
492
449
  * Returns a transaction in the transaction pool by its hash.
493
450
  * @param txHash - Hash of the transaction to look for in the pool.
@@ -510,49 +467,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
510
467
  return this.txPool.hasTxs(txHashes);
511
468
  }
512
469
 
513
- /**
514
- * Returns transactions in the transaction pool by hash.
515
- * If a transaction is not in the pool, it will be requested from the network.
516
- * @param txHashes - Hashes of the transactions to look for.
517
- * @returns The txs found, or undefined if not found in the order requested.
518
- */
519
- async getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]> {
520
- const txs = await Promise.all(txHashes.map(txHash => this.txPool.getTxByHash(txHash)));
521
- const missingTxHashes = txs
522
- .map((tx, index) => [tx, index] as const)
523
- .filter(([tx, _index]) => !tx)
524
- .map(([_tx, index]) => txHashes[index]);
525
-
526
- if (missingTxHashes.length === 0) {
527
- return txs as Tx[];
528
- }
529
-
530
- const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
531
- // TODO: optimize
532
- // Merge the found txs in order
533
- const mergingTxs = txHashes.map(txHash => {
534
- // Is it in the txs list from the mempool?
535
- for (const tx of txs) {
536
- if (tx !== undefined && tx.getTxHash().equals(txHash)) {
537
- return tx;
538
- }
539
- }
540
-
541
- // Is it in the fetched missing txs?
542
- // Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
543
- for (const tx of missingTxs) {
544
- if (tx.getTxHash().equals(txHash)) {
545
- return tx;
546
- }
547
- }
548
-
549
- // Otherwise return undefined
550
- return undefined;
551
- });
552
-
553
- return mergingTxs;
554
- }
555
-
556
470
  /**
557
471
  * Returns an archived transaction in the transaction pool by its hash.
558
472
  * @param txHash - Hash of the archived transaction to look for.
@@ -569,23 +483,22 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
569
483
  **/
570
484
  public async sendTx(tx: Tx): Promise<void> {
571
485
  this.#assertIsReady();
572
- const result = await this.txPool.addPendingTxs([tx]);
486
+ const result = await this.txPool.addPendingTxs([tx], { feeComparisonOnly: true });
573
487
  if (result.accepted.length === 1) {
574
488
  await this.p2pService.propagate(tx);
575
- } else {
576
- this.log.warn(
577
- `Tx ${tx.getTxHash()} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`,
578
- );
489
+ return;
579
490
  }
580
- }
581
491
 
582
- /**
583
- * Adds transactions to the pool. Does not send to peers or validate the txs.
584
- * @param txs - The transactions.
585
- **/
586
- public async addTxsToPool(txs: Tx[]): Promise<number> {
587
- this.#assertIsReady();
588
- return (await this.txPool.addPendingTxs(txs)).accepted.length;
492
+ const txHashStr = tx.getTxHash().toString();
493
+ const reason = result.errors?.get(txHashStr);
494
+ if (reason) {
495
+ this.log.warn(`Tx ${txHashStr} not added to pool: ${reason.message}`);
496
+ throw new TxPoolError(reason);
497
+ }
498
+
499
+ this.log.warn(
500
+ `Tx ${txHashStr} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`,
501
+ );
589
502
  }
590
503
 
591
504
  /**
@@ -746,10 +659,39 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
746
659
 
747
660
  /**
748
661
  * Updates the tx pool after a chain prune.
662
+ * Detects epoch prunes (checkpoint number changed) and deletes all txs in that case.
749
663
  * @param latestBlock - The block ID the chain was pruned to.
664
+ * @param newCheckpoint - The checkpoint ID after the prune.
665
+ */
666
+ private async handlePruneL2Blocks(latestBlock: L2BlockId, newCheckpoint: CheckpointId): Promise<void> {
667
+ const deleteAllTxs = this.config.txPoolDeleteTxsAfterReorg && (await this.isEpochPrune(newCheckpoint));
668
+ await this.txPool.handlePrunedBlocks(latestBlock, { deleteAllTxs });
669
+ }
670
+
671
+ /**
672
+ * Returns true if the prune is an epoch prune (new checkpoint number is less than old).
673
+ * If the checkpoint number stays the same or increases, the prune is within a checkpoint.
750
674
  */
751
- private async handlePruneL2Blocks(latestBlock: L2BlockId): Promise<void> {
752
- await this.txPool.handlePrunedBlocks(latestBlock);
675
+ private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
676
+ const tips = await this.l2Tips.getL2Tips();
677
+ const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
678
+ if (oldCheckpointNumber <= CheckpointNumber.INITIAL) {
679
+ return false;
680
+ }
681
+ const newCheckpointNumber = newCheckpoint.number;
682
+ // We check that the new checkpoint number is less than the old checkpoint number in order to consider it an epoch prune.
683
+ // To be more certain that it is an epoch prune, we will check that at least 2 checkpoints were removed.
684
+ // This means we should avoid thinking checkpoints removed by L1 re-orgs are epoch prunes
685
+ const thresholdForEpochPrune = CheckpointNumber(oldCheckpointNumber - 2);
686
+ const isEpochPrune = newCheckpointNumber <= thresholdForEpochPrune;
687
+ if (isEpochPrune) {
688
+ this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, {
689
+ oldCheckpointNumber,
690
+ newCheckpointNumber,
691
+ thresholdForEpochPrune,
692
+ });
693
+ }
694
+ return isEpochPrune;
753
695
  }
754
696
 
755
697
  /** Checks if the slot has changed and calls prepareForSlot if so. */
@@ -799,8 +741,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
799
741
  this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
800
742
  }
801
743
 
802
- public validate(txs: Tx[]): Promise<void> {
803
- return this.p2pService.validate(txs);
744
+ public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
745
+ return this.p2pService.validateTxsReceivedInBlockProposal(txs);
804
746
  }
805
747
 
806
748
  /**
@@ -3,12 +3,12 @@ import { SecretValue } from '@aztec/foundation/config';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { sleep } from '@aztec/foundation/sleep';
5
5
  import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
6
- import type { DataStoreConfig } from '@aztec/kv-store/config';
7
6
  import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
8
7
  import type { L2BlockSource } from '@aztec/stdlib/block';
9
8
  import type { ContractDataSource } from '@aztec/stdlib/contract';
10
9
  import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
11
- import { P2PClientType, PeerErrorSeverity } from '@aztec/stdlib/p2p';
10
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
11
+ import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
12
12
  import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
13
13
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
14
14
 
@@ -16,14 +16,12 @@ import type { PeerId } from '@libp2p/interface';
16
16
  import { peerIdFromString } from '@libp2p/peer-id';
17
17
 
18
18
  import type { P2PConfig } from '../../../config.js';
19
+ import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
19
20
  import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
20
21
  import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
22
+ import { MissingTxsTracker } from '../../../services/tx_collection/missing_txs_tracker.js';
21
23
  import {
22
- BatchTxRequesterCollector,
23
- SendBatchRequestCollector,
24
- } from '../../../services/tx_collection/proposal_tx_collector.js';
25
- import { AlwaysTrueCircuitVerifier } from '../../../test-helpers/reqresp-nodes.js';
26
- import {
24
+ AlwaysTrueCircuitVerifier,
27
25
  BENCHMARK_CONSTANTS,
28
26
  InMemoryAttestationPool,
29
27
  InMemoryTxPool,
@@ -31,7 +29,7 @@ import {
31
29
  calculateInternalTimeout,
32
30
  createMockEpochCache,
33
31
  createMockWorldStateSynchronizer,
34
- } from '../../../test-helpers/testbench-utils.js';
32
+ } from '../../../test-helpers/index.js';
35
33
  import { createP2PClient } from '../../index.js';
36
34
  import type { P2PClient } from '../../p2p_client.js';
37
35
  import {
@@ -116,7 +114,6 @@ async function startClient(config: P2PConfig, clientIndex: number) {
116
114
  };
117
115
 
118
116
  client = await createP2PClient(
119
- P2PClientType.Full,
120
117
  config as P2PConfig & DataStoreConfig,
121
118
  l2BlockSource as L2BlockSource & ContractDataSource,
122
119
  proofVerifier as ClientProtocolCircuitVerifier,
@@ -214,7 +211,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
214
211
  if (collectorType === 'batch-requester') {
215
212
  const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
216
213
  const fetched = await executeTimeout(
217
- (_signal: AbortSignal) => collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs),
214
+ (_signal: AbortSignal) =>
215
+ collector.collectTxs(
216
+ MissingTxsTracker.fromArray(parsedTxHashes),
217
+ parsedProposal,
218
+ pinnedPeer,
219
+ internalTimeoutMs,
220
+ ),
218
221
  timeoutMs,
219
222
  () => new Error(`Collector timed out after ${timeoutMs}ms`),
220
223
  );
@@ -226,7 +229,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
226
229
  BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
227
230
  );
228
231
  const fetched = await executeTimeout(
229
- (_signal: AbortSignal) => collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs),
232
+ (_signal: AbortSignal) =>
233
+ collector.collectTxs(
234
+ MissingTxsTracker.fromArray(parsedTxHashes),
235
+ parsedProposal,
236
+ pinnedPeer,
237
+ internalTimeoutMs,
238
+ ),
230
239
  timeoutMs,
231
240
  () => new Error(`Collector timed out after ${timeoutMs}ms`),
232
241
  );
package/src/config.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  type ConfigMappingsType,
3
3
  SecretValue,
4
+ bigintConfigHelper,
4
5
  booleanConfigHelper,
5
6
  getConfigFromMappings,
6
7
  getDefaultConfig,
@@ -10,7 +11,6 @@ import {
10
11
  secretStringConfigHelper,
11
12
  } from '@aztec/foundation/config';
12
13
  import { Fr } from '@aztec/foundation/curves/bn254';
13
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
14
14
  import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
15
15
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
16
16
  import {
@@ -20,6 +20,7 @@ import {
20
20
  chainConfigMappings,
21
21
  sharedSequencerConfigMappings,
22
22
  } from '@aztec/stdlib/config';
23
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
23
24
 
24
25
  import {
25
26
  type BatchTxRequesterConfig,
@@ -38,7 +39,16 @@ export interface P2PConfig
38
39
  ChainConfig,
39
40
  TxCollectionConfig,
40
41
  TxFileStoreConfig,
41
- Pick<SequencerConfig, 'blockDurationMs'> {
42
+ Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'> {
43
+ /** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
44
+ validateMaxTxsPerBlock?: number;
45
+
46
+ /** Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected. */
47
+ validateMaxL2BlockGas?: number;
48
+
49
+ /** Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected. */
50
+ validateMaxDABlockGas?: number;
51
+
42
52
  /** A flag dictating whether the P2P subsystem should be enabled. */
43
53
  p2pEnabled: boolean;
44
54
 
@@ -150,8 +160,8 @@ export interface P2PConfig
150
160
  /** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
151
161
  p2pStoreMapSizeKb?: number;
152
162
 
153
- /** Which calls are allowed in the public setup phase of a tx. */
154
- txPublicSetupAllowList: AllowedElement[];
163
+ /** Additional entries to extend the default setup allow list. */
164
+ txPublicSetupAllowListExtend: AllowedElement[];
155
165
 
156
166
  /** The maximum number of pending txs before evicting lower priority txs. */
157
167
  maxPendingTxCount: number;
@@ -173,10 +183,7 @@ export interface P2PConfig
173
183
  /** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
174
184
  disableTransactions: boolean;
175
185
 
176
- /** True to simulate discarding transactions. - For testing purposes only*/
177
- dropTransactions: boolean;
178
-
179
- /** The probability that a transaction is discarded. - For testing purposes only */
186
+ /** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
180
187
  dropTransactionsProbability: number;
181
188
 
182
189
  /** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
@@ -190,11 +197,33 @@ export interface P2PConfig
190
197
 
191
198
  /** Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only). */
192
199
  broadcastEquivocatedProposals?: boolean;
200
+
201
+ /** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
202
+ minTxPoolAgeMs: number;
203
+
204
+ /** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
205
+ priceBumpPercentage: bigint;
193
206
  }
194
207
 
195
208
  export const DEFAULT_P2P_PORT = 40400;
196
209
 
197
210
  export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
211
+ validateMaxTxsPerBlock: {
212
+ env: 'VALIDATOR_MAX_TX_PER_BLOCK',
213
+ description:
214
+ 'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
215
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
216
+ },
217
+ validateMaxL2BlockGas: {
218
+ env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
219
+ description: 'Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected.',
220
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
221
+ },
222
+ validateMaxDABlockGas: {
223
+ env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
224
+ description: 'Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected.',
225
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
226
+ },
198
227
  p2pEnabled: {
199
228
  env: 'P2P_ENABLED',
200
229
  description: 'A flag dictating whether the P2P subsystem should be enabled.',
@@ -393,12 +422,13 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
393
422
  parseEnv: (val: string | undefined) => (val ? +val : undefined),
394
423
  description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
395
424
  },
396
- txPublicSetupAllowList: {
425
+ txPublicSetupAllowListExtend: {
397
426
  env: 'TX_PUBLIC_SETUP_ALLOWLIST',
398
427
  parseEnv: (val: string) => parseAllowList(val),
399
- description: 'The list of functions calls allowed to run in setup',
428
+ description:
429
+ 'Additional entries to extend the default setup allow list. Format: I:address:selector[:flags],C:classId:selector[:flags]. Flags: os (onlySelf), rn (rejectNullMsgSender), cl=N (calldataLength), joined with +.',
400
430
  printDefault: () =>
401
- 'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
431
+ 'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
402
432
  },
403
433
  maxPendingTxCount: {
404
434
  env: 'P2P_MAX_PENDING_TX_COUNT',
@@ -427,11 +457,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
427
457
  description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
428
458
  ...numberConfigHelper(3),
429
459
  },
430
- dropTransactions: {
431
- env: 'P2P_DROP_TX',
432
- description: 'True to simulate discarding transactions. - For testing purposes only',
433
- ...booleanConfigHelper(false),
434
- },
435
460
  dropTransactionsProbability: {
436
461
  env: 'P2P_DROP_TX_CHANCE',
437
462
  description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
@@ -464,6 +489,17 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
464
489
  'Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only).',
465
490
  ...booleanConfigHelper(false),
466
491
  },
492
+ minTxPoolAgeMs: {
493
+ env: 'P2P_MIN_TX_POOL_AGE_MS',
494
+ description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
495
+ ...numberConfigHelper(2_000),
496
+ },
497
+ priceBumpPercentage: {
498
+ env: 'P2P_RPC_PRICE_BUMP_PERCENTAGE',
499
+ description:
500
+ 'Minimum percentage fee increase required to replace an existing tx via RPC. Even at 0%, replacement still requires paying at least 1 unit more.',
501
+ ...bigintConfigHelper(10n),
502
+ },
467
503
  ...sharedSequencerConfigMappings,
468
504
  ...p2pReqRespConfigMappings,
469
505
  ...batchTxRequesterConfigMappings,
@@ -521,13 +557,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
521
557
  bootnodeConfigKeys,
522
558
  );
523
559
 
560
+ /**
561
+ * Parses a `+`-separated flags string into validation properties for an allow list entry.
562
+ * Supported flags: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
563
+ */
564
+ function parseFlags(
565
+ flags: string,
566
+ entry: string,
567
+ ): { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } {
568
+ const result: { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } = {};
569
+ for (const flag of flags.split('+')) {
570
+ if (flag === 'os') {
571
+ result.onlySelf = true;
572
+ } else if (flag === 'rn') {
573
+ result.rejectNullMsgSender = true;
574
+ } else if (flag.startsWith('cl=')) {
575
+ const n = parseInt(flag.slice(3), 10);
576
+ if (isNaN(n) || n < 0) {
577
+ throw new Error(
578
+ `Invalid allow list entry "${entry}": invalid calldataLength in flag "${flag}". Expected a non-negative integer.`,
579
+ );
580
+ }
581
+ result.calldataLength = n;
582
+ } else {
583
+ throw new Error(`Invalid allow list entry "${entry}": unknown flag "${flag}". Supported flags: os, rn, cl=N.`);
584
+ }
585
+ }
586
+ return result;
587
+ }
588
+
524
589
  /**
525
590
  * Parses a string to a list of allowed elements.
526
- * Each encoded is expected to be of one of the following formats
527
- * `I:${address}`
528
- * `I:${address}:${selector}`
529
- * `C:${classId}`
530
- * `C:${classId}:${selector}`
591
+ * Each entry is expected to be of one of the following formats:
592
+ * `I:${address}:${selector}` — instance (contract address) with function selector
593
+ * `C:${classId}:${selector}` — class with function selector
594
+ *
595
+ * An optional flags segment can be appended after the selector:
596
+ * `I:${address}:${selector}:${flags}` or `C:${classId}:${selector}:${flags}`
597
+ * where flags is a `+`-separated list of: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
531
598
  *
532
599
  * @param value The string to parse
533
600
  * @returns A list of allowed elements
@@ -540,31 +607,37 @@ export function parseAllowList(value: string): AllowedElement[] {
540
607
  }
541
608
 
542
609
  for (const val of value.split(',')) {
543
- const [typeString, identifierString, selectorString] = val.split(':');
544
- const selector = selectorString !== undefined ? FunctionSelector.fromString(selectorString) : undefined;
610
+ const trimmed = val.trim();
611
+ if (!trimmed) {
612
+ continue;
613
+ }
614
+ const [typeString, identifierString, selectorString, flagsString] = trimmed.split(':');
615
+
616
+ if (!selectorString) {
617
+ throw new Error(
618
+ `Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
619
+ );
620
+ }
621
+
622
+ const selector = FunctionSelector.fromString(selectorString);
623
+ const flags = flagsString ? parseFlags(flagsString, trimmed) : {};
545
624
 
546
625
  if (typeString === 'I') {
547
- if (selector) {
548
- entries.push({
549
- address: AztecAddress.fromString(identifierString),
550
- selector,
551
- });
552
- } else {
553
- entries.push({
554
- address: AztecAddress.fromString(identifierString),
555
- });
556
- }
626
+ entries.push({
627
+ address: AztecAddress.fromString(identifierString),
628
+ selector,
629
+ ...flags,
630
+ });
557
631
  } else if (typeString === 'C') {
558
- if (selector) {
559
- entries.push({
560
- classId: Fr.fromHexString(identifierString),
561
- selector,
562
- });
563
- } else {
564
- entries.push({
565
- classId: Fr.fromHexString(identifierString),
566
- });
567
- }
632
+ entries.push({
633
+ classId: Fr.fromHexString(identifierString),
634
+ selector,
635
+ ...flags,
636
+ });
637
+ } else {
638
+ throw new Error(
639
+ `Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
640
+ );
568
641
  }
569
642
  }
570
643
 
@@ -0,0 +1,12 @@
1
+ import type { TxPoolRejectionError } from '../mem_pools/tx_pool_v2/eviction/interfaces.js';
2
+
3
+ /** Error thrown when a transaction is not added to the mempool. */
4
+ export class TxPoolError extends Error {
5
+ public readonly data: TxPoolRejectionError;
6
+
7
+ constructor(public readonly reason: TxPoolRejectionError) {
8
+ super(reason.message);
9
+ this.name = 'TxPoolError';
10
+ this.data = reason;
11
+ }
12
+ }