@aztec/p2p 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.d939eb5aa

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 (420) 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 +37 -30
  5. package/dest/client/interface.d.ts +22 -20
  6. package/dest/client/interface.d.ts.map +1 -1
  7. package/dest/client/p2p_client.d.ts +11 -19
  8. package/dest/client/p2p_client.d.ts.map +1 -1
  9. package/dest/client/p2p_client.js +92 -104
  10. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +20 -10
  11. package/dest/config.d.ts +128 -96
  12. package/dest/config.d.ts.map +1 -1
  13. package/dest/config.js +97 -38
  14. package/dest/errors/p2p-service.error.d.ts +9 -0
  15. package/dest/errors/p2p-service.error.d.ts.map +1 -0
  16. package/dest/errors/p2p-service.error.js +10 -0
  17. package/dest/errors/tx-pool.error.d.ts +8 -0
  18. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  19. package/dest/errors/tx-pool.error.js +9 -0
  20. package/dest/index.d.ts +1 -2
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +0 -1
  23. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +10 -6
  24. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  25. package/dest/mem_pools/attestation_pool/attestation_pool.js +21 -9
  26. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
  27. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  28. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  29. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  30. package/dest/mem_pools/index.d.ts +1 -2
  31. package/dest/mem_pools/index.d.ts.map +1 -1
  32. package/dest/mem_pools/instrumentation.d.ts +4 -2
  33. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  34. package/dest/mem_pools/instrumentation.js +16 -14
  35. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +30 -13
  36. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
  37. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
  38. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
  39. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
  41. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  42. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +7 -3
  44. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
  45. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  46. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
  47. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
  48. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
  50. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
  51. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
  52. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
  53. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
  54. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +9 -7
  55. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
  56. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  57. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
  58. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
  59. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
  60. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
  61. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
  62. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
  63. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
  64. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
  65. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  66. package/dest/mem_pools/tx_pool_v2/index.js +1 -1
  67. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  68. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  69. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  70. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +28 -10
  71. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  72. package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
  73. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +56 -15
  74. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  75. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +113 -20
  76. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
  77. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  78. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +50 -45
  79. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -5
  80. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  81. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +17 -6
  82. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -5
  83. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  84. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +319 -147
  85. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
  86. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  87. package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -11
  88. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +4 -2
  89. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  90. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
  91. package/dest/msg_validators/clock_tolerance.d.ts +12 -1
  92. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
  93. package/dest/msg_validators/clock_tolerance.js +54 -3
  94. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +7 -4
  95. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  96. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
  97. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +7 -4
  98. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  99. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
  100. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +15 -8
  101. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  102. package/dest/msg_validators/proposal_validator/proposal_validator.js +67 -47
  103. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
  104. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  105. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
  106. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  107. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  108. package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
  109. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  110. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  111. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  112. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  113. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  114. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  115. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  116. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  117. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  118. package/dest/msg_validators/tx_validator/data_validator.js +35 -2
  119. package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
  120. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  121. package/dest/msg_validators/tx_validator/factory.js +247 -60
  122. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
  123. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
  124. package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
  125. package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
  126. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  127. package/dest/msg_validators/tx_validator/gas_validator.js +112 -43
  128. package/dest/msg_validators/tx_validator/index.d.ts +3 -1
  129. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  130. package/dest/msg_validators/tx_validator/index.js +2 -0
  131. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
  132. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  133. package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
  134. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  135. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  136. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  137. package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
  138. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  139. package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
  140. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
  141. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  142. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  143. package/dest/services/data_store.d.ts +1 -1
  144. package/dest/services/data_store.d.ts.map +1 -1
  145. package/dest/services/data_store.js +5 -5
  146. package/dest/services/dummy_service.d.ts +8 -5
  147. package/dest/services/dummy_service.d.ts.map +1 -1
  148. package/dest/services/dummy_service.js +10 -5
  149. package/dest/services/encoding.d.ts +6 -2
  150. package/dest/services/encoding.d.ts.map +1 -1
  151. package/dest/services/encoding.js +16 -9
  152. package/dest/services/gossipsub/topic_score_params.d.ts +30 -7
  153. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  154. package/dest/services/gossipsub/topic_score_params.js +53 -14
  155. package/dest/services/libp2p/libp2p_service.d.ts +29 -36
  156. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  157. package/dest/services/libp2p/libp2p_service.js +224 -197
  158. package/dest/services/peer-manager/metrics.d.ts +3 -1
  159. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  160. package/dest/services/peer-manager/metrics.js +6 -0
  161. package/dest/services/peer-manager/peer_manager.d.ts +6 -2
  162. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  163. package/dest/services/peer-manager/peer_manager.js +39 -11
  164. package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
  165. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  166. package/dest/services/peer-manager/peer_scoring.js +32 -10
  167. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +12 -8
  168. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  169. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +83 -106
  170. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -7
  171. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  172. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -13
  173. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  174. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +31 -46
  175. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
  176. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  177. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
  178. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
  179. package/dest/services/reqresp/config.d.ts +3 -3
  180. package/dest/services/reqresp/config.d.ts.map +1 -1
  181. package/dest/services/reqresp/interface.d.ts +14 -9
  182. package/dest/services/reqresp/interface.d.ts.map +1 -1
  183. package/dest/services/reqresp/interface.js +10 -11
  184. package/dest/services/reqresp/metrics.d.ts +1 -1
  185. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  186. package/dest/services/reqresp/metrics.js +0 -1
  187. package/dest/services/reqresp/protocols/index.d.ts +1 -2
  188. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  189. package/dest/services/reqresp/protocols/index.js +0 -1
  190. package/dest/services/reqresp/protocols/tx.d.ts +1 -1
  191. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  192. package/dest/services/reqresp/protocols/tx.js +1 -3
  193. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
  194. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  195. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
  196. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  197. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  198. package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
  199. package/dest/services/reqresp/reqresp.d.ts +4 -2
  200. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  201. package/dest/services/reqresp/reqresp.js +30 -12
  202. package/dest/services/service.d.ts +9 -4
  203. package/dest/services/service.d.ts.map +1 -1
  204. package/dest/services/tx_collection/config.d.ts +13 -1
  205. package/dest/services/tx_collection/config.d.ts.map +1 -1
  206. package/dest/services/tx_collection/config.js +30 -0
  207. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
  208. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  209. package/dest/services/tx_collection/fast_tx_collection.js +65 -75
  210. package/dest/services/tx_collection/file_store_tx_collection.d.ts +38 -29
  211. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
  212. package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
  213. package/dest/services/tx_collection/file_store_tx_source.d.ts +17 -6
  214. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  215. package/dest/services/tx_collection/file_store_tx_source.js +53 -10
  216. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  217. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  218. package/dest/services/tx_collection/instrumentation.js +2 -1
  219. package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -7
  220. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  221. package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
  222. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  223. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  224. package/dest/services/tx_collection/request_tracker.js +84 -0
  225. package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
  226. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  227. package/dest/services/tx_collection/slow_tx_collection.js +17 -12
  228. package/dest/services/tx_collection/tx_collection.d.ts +9 -9
  229. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  230. package/dest/services/tx_collection/tx_collection.js +26 -10
  231. package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
  232. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  233. package/dest/services/tx_collection/tx_collection_sink.js +13 -22
  234. package/dest/services/tx_collection/tx_source.d.ts +13 -7
  235. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  236. package/dest/services/tx_collection/tx_source.js +26 -7
  237. package/dest/services/tx_file_store/tx_file_store.d.ts +3 -2
  238. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  239. package/dest/services/tx_file_store/tx_file_store.js +9 -6
  240. package/dest/services/tx_provider.d.ts +3 -3
  241. package/dest/services/tx_provider.d.ts.map +1 -1
  242. package/dest/services/tx_provider.js +4 -4
  243. package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
  244. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  245. package/dest/test-helpers/make-test-p2p-clients.js +1 -2
  246. package/dest/test-helpers/mock-pubsub.d.ts +14 -6
  247. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  248. package/dest/test-helpers/mock-pubsub.js +43 -12
  249. package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
  250. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  251. package/dest/test-helpers/reqresp-nodes.js +3 -4
  252. package/dest/test-helpers/testbench-utils.d.ts +8 -3
  253. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  254. package/dest/test-helpers/testbench-utils.js +30 -4
  255. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  256. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  257. package/dest/testbench/p2p_client_testbench_worker.js +78 -26
  258. package/dest/testbench/worker_client_manager.d.ts +10 -1
  259. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  260. package/dest/testbench/worker_client_manager.js +55 -3
  261. package/dest/util.d.ts +3 -3
  262. package/dest/util.d.ts.map +1 -1
  263. package/package.json +14 -14
  264. package/src/client/factory.ts +68 -48
  265. package/src/client/interface.ts +26 -21
  266. package/src/client/p2p_client.ts +102 -135
  267. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +33 -14
  268. package/src/config.ts +146 -44
  269. package/src/errors/p2p-service.error.ts +11 -0
  270. package/src/errors/tx-pool.error.ts +12 -0
  271. package/src/index.ts +0 -1
  272. package/src/mem_pools/attestation_pool/attestation_pool.ts +25 -12
  273. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
  274. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  275. package/src/mem_pools/index.ts +0 -3
  276. package/src/mem_pools/instrumentation.ts +17 -13
  277. package/src/mem_pools/tx_pool_v2/README.md +52 -28
  278. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
  279. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
  280. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +7 -3
  281. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
  282. package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
  283. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
  284. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
  285. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +8 -8
  286. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
  287. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
  288. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
  289. package/src/mem_pools/tx_pool_v2/index.ts +1 -1
  290. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  291. package/src/mem_pools/tx_pool_v2/interfaces.ts +30 -10
  292. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +164 -28
  293. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +58 -45
  294. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +34 -8
  295. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +353 -143
  296. package/src/msg_validators/attestation_validator/README.md +49 -0
  297. package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -9
  298. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +4 -1
  299. package/src/msg_validators/clock_tolerance.ts +72 -3
  300. package/src/msg_validators/proposal_validator/README.md +123 -0
  301. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +17 -4
  302. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +23 -7
  303. package/src/msg_validators/proposal_validator/proposal_validator.ts +79 -49
  304. package/src/msg_validators/tx_validator/README.md +119 -0
  305. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
  306. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  307. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  308. package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
  309. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  310. package/src/msg_validators/tx_validator/data_validator.ts +42 -1
  311. package/src/msg_validators/tx_validator/factory.ts +394 -78
  312. package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
  313. package/src/msg_validators/tx_validator/gas_validator.ts +145 -33
  314. package/src/msg_validators/tx_validator/index.ts +2 -0
  315. package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
  316. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  317. package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
  318. package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
  319. package/src/services/data_store.ts +5 -13
  320. package/src/services/dummy_service.ts +13 -7
  321. package/src/services/encoding.ts +16 -8
  322. package/src/services/gossipsub/README.md +29 -14
  323. package/src/services/gossipsub/topic_score_params.ts +85 -17
  324. package/src/services/libp2p/libp2p_service.ts +240 -225
  325. package/src/services/peer-manager/metrics.ts +7 -0
  326. package/src/services/peer-manager/peer_manager.ts +45 -11
  327. package/src/services/peer-manager/peer_scoring.ts +27 -5
  328. package/src/services/reqresp/README.md +229 -0
  329. package/src/services/reqresp/batch-tx-requester/README.md +46 -7
  330. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +79 -112
  331. package/src/services/reqresp/batch-tx-requester/interface.ts +3 -6
  332. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
  333. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
  334. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
  335. package/src/services/reqresp/config.ts +2 -2
  336. package/src/services/reqresp/interface.ts +21 -11
  337. package/src/services/reqresp/metrics.ts +0 -1
  338. package/src/services/reqresp/protocols/index.ts +0 -1
  339. package/src/services/reqresp/protocols/tx.ts +1 -3
  340. package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
  341. package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
  342. package/src/services/reqresp/reqresp.ts +40 -13
  343. package/src/services/service.ts +17 -3
  344. package/src/services/tx_collection/config.ts +42 -0
  345. package/src/services/tx_collection/fast_tx_collection.ts +71 -76
  346. package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
  347. package/src/services/tx_collection/file_store_tx_source.ts +69 -10
  348. package/src/services/tx_collection/instrumentation.ts +7 -1
  349. package/src/services/tx_collection/proposal_tx_collector.ts +9 -13
  350. package/src/services/tx_collection/request_tracker.ts +127 -0
  351. package/src/services/tx_collection/slow_tx_collection.ts +17 -13
  352. package/src/services/tx_collection/tx_collection.ts +46 -17
  353. package/src/services/tx_collection/tx_collection_sink.ts +15 -29
  354. package/src/services/tx_collection/tx_source.ts +28 -8
  355. package/src/services/tx_file_store/tx_file_store.ts +6 -4
  356. package/src/services/tx_provider.ts +2 -2
  357. package/src/test-helpers/make-test-p2p-clients.ts +1 -3
  358. package/src/test-helpers/mock-pubsub.ts +44 -11
  359. package/src/test-helpers/reqresp-nodes.ts +5 -8
  360. package/src/test-helpers/testbench-utils.ts +41 -6
  361. package/src/testbench/p2p_client_testbench_worker.ts +89 -29
  362. package/src/testbench/worker_client_manager.ts +68 -6
  363. package/src/util.ts +8 -2
  364. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
  365. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
  366. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
  367. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
  368. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
  369. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
  370. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
  371. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
  372. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
  373. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
  374. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
  375. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
  376. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
  377. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
  378. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
  379. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
  380. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
  381. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
  382. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
  383. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
  384. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
  385. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
  386. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
  387. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
  388. package/dest/mem_pools/tx_pool/index.d.ts +0 -3
  389. package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
  390. package/dest/mem_pools/tx_pool/index.js +0 -2
  391. package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
  392. package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
  393. package/dest/mem_pools/tx_pool/priority.js +0 -15
  394. package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
  395. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
  396. package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
  397. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
  398. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
  399. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
  400. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
  401. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
  402. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
  403. package/dest/services/reqresp/protocols/block.d.ts +0 -9
  404. package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
  405. package/dest/services/reqresp/protocols/block.js +0 -32
  406. package/src/mem_pools/tx_pool/README.md +0 -270
  407. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
  408. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
  409. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
  410. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
  411. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
  412. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
  413. package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
  414. package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
  415. package/src/mem_pools/tx_pool/index.ts +0 -2
  416. package/src/mem_pools/tx_pool/priority.ts +0 -20
  417. package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
  418. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
  419. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
  420. package/src/services/reqresp/protocols/block.ts +0 -37
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,26 @@ export interface P2PConfig
38
39
  ChainConfig,
39
40
  TxCollectionConfig,
40
41
  TxFileStoreConfig,
41
- Pick<SequencerConfig, 'blockDurationMs'> {
42
+ Pick<
43
+ SequencerConfig,
44
+ | 'blockDurationMs'
45
+ | 'expectedBlockProposalsPerSlot'
46
+ | 'l1PublishingTime'
47
+ | 'maxTxsPerBlock'
48
+ | 'attestationPropagationTime'
49
+ > {
50
+ /** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
51
+ validateMaxTxsPerBlock?: number;
52
+
53
+ /** Maximum transactions per checkpoint for validation. Used as fallback for maxTxsPerBlock when that is not set. */
54
+ validateMaxTxsPerCheckpoint?: number;
55
+
56
+ /** Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected. */
57
+ validateMaxL2BlockGas?: number;
58
+
59
+ /** Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected. */
60
+ validateMaxDABlockGas?: number;
61
+
42
62
  /** A flag dictating whether the P2P subsystem should be enabled. */
43
63
  p2pEnabled: boolean;
44
64
 
@@ -57,6 +77,9 @@ export interface P2PConfig
57
77
  /** The frequency in which to check for new peers. */
58
78
  peerCheckIntervalMS: number;
59
79
 
80
+ /** How long to ban a peer after it fails MAX_DIAL_ATTEMPTS dials. */
81
+ peerFailedBanTimeMs: number;
82
+
60
83
  /** Size of queue of L2 blocks to store. */
61
84
  l2QueueSize: number;
62
85
 
@@ -150,8 +173,8 @@ export interface P2PConfig
150
173
  /** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
151
174
  p2pStoreMapSizeKb?: number;
152
175
 
153
- /** Which calls are allowed in the public setup phase of a tx. */
154
- txPublicSetupAllowList: AllowedElement[];
176
+ /** Additional entries to extend the default setup allow list. */
177
+ txPublicSetupAllowListExtend: AllowedElement[];
155
178
 
156
179
  /** The maximum number of pending txs before evicting lower priority txs. */
157
180
  maxPendingTxCount: number;
@@ -173,10 +196,7 @@ export interface P2PConfig
173
196
  /** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
174
197
  disableTransactions: boolean;
175
198
 
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 */
199
+ /** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
180
200
  dropTransactionsProbability: number;
181
201
 
182
202
  /** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
@@ -190,11 +210,39 @@ export interface P2PConfig
190
210
 
191
211
  /** Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only). */
192
212
  broadcastEquivocatedProposals?: boolean;
213
+
214
+ /** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
215
+ minTxPoolAgeMs: number;
216
+
217
+ /** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
218
+ priceBumpPercentage: bigint;
193
219
  }
194
220
 
195
221
  export const DEFAULT_P2P_PORT = 40400;
196
222
 
197
223
  export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
224
+ validateMaxTxsPerBlock: {
225
+ env: 'VALIDATOR_MAX_TX_PER_BLOCK',
226
+ description:
227
+ 'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
228
+ parseEnv: (val: string) => parseInt(val, 10),
229
+ },
230
+ validateMaxTxsPerCheckpoint: {
231
+ env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
232
+ description:
233
+ 'Maximum transactions per checkpoint for validation. Used as fallback for maxTxsPerBlock when that is not set.',
234
+ parseEnv: (val: string) => parseInt(val, 10),
235
+ },
236
+ validateMaxL2BlockGas: {
237
+ env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
238
+ description: 'Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected.',
239
+ parseEnv: (val: string) => parseInt(val, 10),
240
+ },
241
+ validateMaxDABlockGas: {
242
+ env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
243
+ description: 'Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected.',
244
+ parseEnv: (val: string) => parseInt(val, 10),
245
+ },
198
246
  p2pEnabled: {
199
247
  env: 'P2P_ENABLED',
200
248
  description: 'A flag dictating whether the P2P subsystem should be enabled.',
@@ -225,6 +273,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
225
273
  description: 'The frequency in which to check for new peers.',
226
274
  ...numberConfigHelper(30_000),
227
275
  },
276
+ peerFailedBanTimeMs: {
277
+ env: 'P2P_PEER_FAILED_BAN_TIME_MS',
278
+ description: 'How long to ban a peer after it fails maximum dial attempts.',
279
+ ...numberConfigHelper(5 * 60 * 1000),
280
+ },
228
281
  l2QueueSize: {
229
282
  env: 'P2P_L2_QUEUE_SIZE',
230
283
  description: 'Size of queue of L2 blocks to store.',
@@ -390,15 +443,16 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
390
443
  },
391
444
  p2pStoreMapSizeKb: {
392
445
  env: 'P2P_STORE_MAP_SIZE_KB',
393
- parseEnv: (val: string | undefined) => (val ? +val : undefined),
446
+ parseEnv: (val: string) => +val,
394
447
  description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
395
448
  },
396
- txPublicSetupAllowList: {
449
+ txPublicSetupAllowListExtend: {
397
450
  env: 'TX_PUBLIC_SETUP_ALLOWLIST',
398
451
  parseEnv: (val: string) => parseAllowList(val),
399
- description: 'The list of functions calls allowed to run in setup',
452
+ description:
453
+ '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
454
  printDefault: () =>
401
- 'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
455
+ 'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
402
456
  },
403
457
  maxPendingTxCount: {
404
458
  env: 'P2P_MAX_PENDING_TX_COUNT',
@@ -427,11 +481,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
427
481
  description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
428
482
  ...numberConfigHelper(3),
429
483
  },
430
- dropTransactions: {
431
- env: 'P2P_DROP_TX',
432
- description: 'True to simulate discarding transactions. - For testing purposes only',
433
- ...booleanConfigHelper(false),
434
- },
435
484
  dropTransactionsProbability: {
436
485
  env: 'P2P_DROP_TX_CHANCE',
437
486
  description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
@@ -453,6 +502,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
453
502
  description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
454
503
  ...booleanConfigHelper(false),
455
504
  },
505
+ l1PublishingTime: {
506
+ env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
507
+ description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
508
+ parseEnv: (val: string) => parseInt(val, 10),
509
+ },
456
510
  fishermanMode: {
457
511
  env: 'FISHERMAN_MODE',
458
512
  description:
@@ -464,6 +518,17 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
464
518
  'Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only).',
465
519
  ...booleanConfigHelper(false),
466
520
  },
521
+ minTxPoolAgeMs: {
522
+ env: 'P2P_MIN_TX_POOL_AGE_MS',
523
+ description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
524
+ ...numberConfigHelper(2_000),
525
+ },
526
+ priceBumpPercentage: {
527
+ env: 'P2P_RPC_PRICE_BUMP_PERCENTAGE',
528
+ description:
529
+ 'Minimum percentage fee increase required to replace an existing tx via RPC. Even at 0%, replacement still requires paying at least 1 unit more.',
530
+ ...bigintConfigHelper(10n),
531
+ },
467
532
  ...sharedSequencerConfigMappings,
468
533
  ...p2pReqRespConfigMappings,
469
534
  ...batchTxRequesterConfigMappings,
@@ -521,13 +586,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
521
586
  bootnodeConfigKeys,
522
587
  );
523
588
 
589
+ /**
590
+ * Parses a `+`-separated flags string into validation properties for an allow list entry.
591
+ * Supported flags: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
592
+ */
593
+ function parseFlags(
594
+ flags: string,
595
+ entry: string,
596
+ ): { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } {
597
+ const result: { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } = {};
598
+ for (const flag of flags.split('+')) {
599
+ if (flag === 'os') {
600
+ result.onlySelf = true;
601
+ } else if (flag === 'rn') {
602
+ result.rejectNullMsgSender = true;
603
+ } else if (flag.startsWith('cl=')) {
604
+ const n = parseInt(flag.slice(3), 10);
605
+ if (isNaN(n) || n < 0) {
606
+ throw new Error(
607
+ `Invalid allow list entry "${entry}": invalid calldataLength in flag "${flag}". Expected a non-negative integer.`,
608
+ );
609
+ }
610
+ result.calldataLength = n;
611
+ } else {
612
+ throw new Error(`Invalid allow list entry "${entry}": unknown flag "${flag}". Supported flags: os, rn, cl=N.`);
613
+ }
614
+ }
615
+ return result;
616
+ }
617
+
524
618
  /**
525
619
  * 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}`
620
+ * Each entry is expected to be of one of the following formats:
621
+ * `I:${address}:${selector}` — instance (contract address) with function selector
622
+ * `C:${classId}:${selector}` — class with function selector
623
+ *
624
+ * An optional flags segment can be appended after the selector:
625
+ * `I:${address}:${selector}:${flags}` or `C:${classId}:${selector}:${flags}`
626
+ * where flags is a `+`-separated list of: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
531
627
  *
532
628
  * @param value The string to parse
533
629
  * @returns A list of allowed elements
@@ -540,31 +636,37 @@ export function parseAllowList(value: string): AllowedElement[] {
540
636
  }
541
637
 
542
638
  for (const val of value.split(',')) {
543
- const [typeString, identifierString, selectorString] = val.split(':');
544
- const selector = selectorString !== undefined ? FunctionSelector.fromString(selectorString) : undefined;
639
+ const trimmed = val.trim();
640
+ if (!trimmed) {
641
+ continue;
642
+ }
643
+ const [typeString, identifierString, selectorString, flagsString] = trimmed.split(':');
644
+
645
+ if (!selectorString) {
646
+ throw new Error(
647
+ `Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
648
+ );
649
+ }
650
+
651
+ const selector = FunctionSelector.fromString(selectorString);
652
+ const flags = flagsString ? parseFlags(flagsString, trimmed) : {};
545
653
 
546
654
  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
- }
655
+ entries.push({
656
+ address: AztecAddress.fromString(identifierString),
657
+ selector,
658
+ ...flags,
659
+ });
557
660
  } 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
- }
661
+ entries.push({
662
+ classId: Fr.fromHexString(identifierString),
663
+ selector,
664
+ ...flags,
665
+ });
666
+ } else {
667
+ throw new Error(
668
+ `Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
669
+ );
568
670
  }
569
671
  }
570
672
 
@@ -0,0 +1,11 @@
1
+ /** Checkpoint Proposal Received Callback Not Registered Error
2
+ *
3
+ * Error triggered if the allNodesCheckpointReceivedCallback is not registered
4
+ * @category Errors
5
+ */
6
+ export class CheckpointProposalReceivedCallbackNotRegisteredError extends Error {
7
+ constructor() {
8
+ super('FATAL (allNodesCheckpointReceivedCallback): All nodes should register a checkpoint proposal handler');
9
+ this.name = 'CheckpointProposalReceivedCallbackNotRegisteredError';
10
+ }
11
+ }
@@ -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
+ }
package/src/index.ts CHANGED
@@ -6,7 +6,6 @@ export * from './client/index.js';
6
6
  export * from './enr/index.js';
7
7
  export * from './config.js';
8
8
  export * from './mem_pools/attestation_pool/index.js';
9
- export * from './mem_pools/tx_pool/index.js';
10
9
  export * from './mem_pools/tx_pool_v2/index.js';
11
10
  export * from './msg_validators/index.js';
12
11
  export * from './services/index.js';
@@ -26,10 +26,10 @@ export type TryAddResult = {
26
26
  count: number;
27
27
  };
28
28
 
29
- export const MAX_CHECKPOINT_PROPOSALS_PER_SLOT = 5;
30
- export const MAX_BLOCK_PROPOSALS_PER_POSITION = 3;
29
+ export const MAX_CHECKPOINT_PROPOSALS_PER_SLOT = 2;
30
+ export const MAX_BLOCK_PROPOSALS_PER_POSITION = 2;
31
31
  /** Maximum attestations a single signer can make per slot before being rejected. */
32
- export const MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER = 3;
32
+ export const MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER = 2;
33
33
 
34
34
  /** Public API interface for attestation pools. Used for typing mocks and test implementations. */
35
35
  export type AttestationPoolApi = Pick<
@@ -43,6 +43,7 @@ export type AttestationPoolApi = Pick<
43
43
  | 'deleteOlderThan'
44
44
  | 'getCheckpointAttestationsForSlot'
45
45
  | 'getCheckpointAttestationsForSlotAndProposal'
46
+ | 'hasBlockProposalsForSlot'
46
47
  | 'isEmpty'
47
48
  >;
48
49
 
@@ -153,14 +154,16 @@ export class AttestationPool {
153
154
  /** Maximum indexWithinCheckpoint value (2^10 - 1 = 1023). */
154
155
  private static readonly MAX_INDEX = (1 << AttestationPool.INDEX_BITS) - 1;
155
156
 
156
- /** Creates a position key for block proposals: (slot << 10) | indexWithinCheckpoint. */
157
+ /** Creates a position key for block proposals: slot * 1024 + indexWithinCheckpoint.
158
+ * Uses multiplication instead of bit-shift to avoid 32-bit signed integer overflow
159
+ * (bit-shift overflows after slot ~2^21, roughly 278 days of uptime). */
157
160
  private getBlockPositionKey(slot: number, indexWithinCheckpoint: number): number {
158
161
  if (indexWithinCheckpoint > AttestationPool.MAX_INDEX) {
159
162
  throw new Error(
160
163
  `Value for indexWithinCheckpoint ${indexWithinCheckpoint} exceeds maximum ${AttestationPool.MAX_INDEX}`,
161
164
  );
162
165
  }
163
- return (slot << AttestationPool.INDEX_BITS) | indexWithinCheckpoint;
166
+ return slot * (1 << AttestationPool.INDEX_BITS) + indexWithinCheckpoint;
164
167
  }
165
168
 
166
169
  /**
@@ -254,6 +257,13 @@ export class AttestationPool {
254
257
  return undefined;
255
258
  }
256
259
 
260
+ /** Checks if any block proposals exist for a given slot (at index 0). */
261
+ public async hasBlockProposalsForSlot(slot: SlotNumber): Promise<boolean> {
262
+ const positionKey = this.getBlockPositionKey(slot, 0);
263
+ const count = await this.blockProposalsForSlotAndIndex.getValueCountAsync(positionKey);
264
+ return count > 0;
265
+ }
266
+
257
267
  /**
258
268
  * Attempts to add a checkpoint proposal to the pool.
259
269
  *
@@ -270,7 +280,7 @@ export class AttestationPool {
270
280
  * @returns Result indicating whether the proposal was added and duplicate detection info
271
281
  */
272
282
  public async tryAddCheckpointProposal(proposal: CheckpointProposalCore): Promise<TryAddResult> {
273
- return await this.store.transactionAsync(async () => {
283
+ const result = await this.store.transactionAsync(async () => {
274
284
  const proposalId = proposal.archive.toString();
275
285
 
276
286
  // Check if already exists
@@ -296,6 +306,8 @@ export class AttestationPool {
296
306
 
297
307
  return { added: true, alreadyExists: false, count: count + 1 };
298
308
  });
309
+
310
+ return result;
299
311
  }
300
312
 
301
313
  /** Internal method - must be called within a transaction. */
@@ -337,7 +349,7 @@ export class AttestationPool {
337
349
  await this.store.transactionAsync(async () => {
338
350
  for (const attestation of attestations) {
339
351
  const slotNumber = attestation.payload.header.slotNumber;
340
- const proposalId = attestation.archive;
352
+ const proposalId = attestation.archive.toString();
341
353
  const sender = attestation.getSender();
342
354
 
343
355
  // Skip attestations with invalid signatures
@@ -351,11 +363,10 @@ export class AttestationPool {
351
363
  }
352
364
 
353
365
  const address = sender.toString();
366
+ const ownKey = this.getAttestationKey(slotNumber, proposalId, address);
354
367
 
355
- await this.checkpointAttestations.set(
356
- this.getAttestationKey(slotNumber, proposalId, address),
357
- attestation.toBuffer(),
358
- );
368
+ await this.checkpointAttestations.set(ownKey, attestation.toBuffer());
369
+ this.metrics.trackMempoolItemAdded(ownKey);
359
370
 
360
371
  this.log.debug(`Added own checkpoint attestation for slot ${slotNumber} from ${address}`, {
361
372
  signature: attestation.signature.toString(),
@@ -421,6 +432,7 @@ export class AttestationPool {
421
432
  const attestationEndKey = new Fr(oldestSlot).toString();
422
433
  for await (const key of this.checkpointAttestations.keysAsync({ end: attestationEndKey })) {
423
434
  await this.checkpointAttestations.delete(key);
435
+ this.metrics.trackMempoolItemRemoved(key);
424
436
  numberOfAttestations++;
425
437
  }
426
438
 
@@ -444,7 +456,7 @@ export class AttestationPool {
444
456
 
445
457
  // Delete block proposals for slots < oldestSlot, using blockProposalsForSlotAndIndex as index
446
458
  // Key format: (slot << INDEX_BITS) | indexWithinCheckpoint
447
- const blockPositionEndKey = oldestSlot << AttestationPool.INDEX_BITS;
459
+ const blockPositionEndKey = oldestSlot * (1 << AttestationPool.INDEX_BITS);
448
460
  for await (const positionKey of this.blockProposalsForSlotAndIndex.keysAsync({ end: blockPositionEndKey })) {
449
461
  const proposalIds = await toArray(this.blockProposalsForSlotAndIndex.getValuesAsync(positionKey));
450
462
  for (const proposalId of proposalIds) {
@@ -518,6 +530,7 @@ export class AttestationPool {
518
530
 
519
531
  // Add the attestation
520
532
  await this.checkpointAttestations.set(key, attestation.toBuffer());
533
+ this.metrics.trackMempoolItemAdded(key);
521
534
 
522
535
  // Track this attestation in the per-signer-per-slot index for duplicate detection
523
536
  const slotSignerKey = this.getSlotSignerKey(slotNumber, signerAddress);
@@ -446,12 +446,12 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
446
446
  const result2 = await ap.tryAddBlockProposal(proposal2);
447
447
  expect(result2.count).toBe(2);
448
448
 
449
- // Add a third proposal for same position
449
+ // Third proposal for same position should be rejected (cap is 2)
450
450
  const proposal3 = await mockBlockProposalWithIndex(signers[2], slotNumber, indexWithinCheckpoint);
451
451
  const result3 = await ap.tryAddBlockProposal(proposal3);
452
452
 
453
- expect(result3.added).toBe(true);
454
- expect(result3.count).toBe(3);
453
+ expect(result3.added).toBe(false);
454
+ expect(result3.count).toBe(2);
455
455
  });
456
456
 
457
457
  it('should return added=false when exceeding capacity', async () => {
@@ -666,12 +666,12 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
666
666
  const result2 = await ap.tryAddCheckpointProposal(proposal2);
667
667
  expect(result2.count).toBe(2);
668
668
 
669
- // Add a third proposal for same slot
669
+ // Third proposal for same slot should be rejected (cap is 2)
670
670
  const proposal3 = await mockCheckpointProposalCoreForPool(signers[2], slotNumber);
671
671
  const result3 = await ap.tryAddCheckpointProposal(proposal3);
672
672
 
673
- expect(result3.added).toBe(true);
674
- expect(result3.count).toBe(3);
673
+ expect(result3.added).toBe(false);
674
+ expect(result3.count).toBe(2);
675
675
  });
676
676
 
677
677
  it('should not count attestations as proposals for duplicate detection', async () => {
@@ -34,9 +34,10 @@ export const mockCheckpointAttestation = (
34
34
  slot: number = 0,
35
35
  archive: Fr = Fr.random(),
36
36
  header?: CheckpointHeader,
37
+ feeAssetPriceModifier: bigint = 0n,
37
38
  ): CheckpointAttestation => {
38
39
  header = header ?? CheckpointHeader.random({ slotNumber: SlotNumber(slot) });
39
- const payload = new ConsensusPayload(header, archive);
40
+ const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
40
41
 
41
42
  const attestationHash = getHashedSignaturePayloadEthSignedMessage(
42
43
  payload,
@@ -1,6 +1,3 @@
1
1
  export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
2
2
  export { type MemPools } from './interface.js';
3
- // Old TxPool exports - kept temporarily for external consumers
4
- export { type TxPool } from './tx_pool/tx_pool.js';
5
- // New TxPoolV2 exports
6
3
  export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult } from './tx_pool_v2/index.js';
@@ -73,7 +73,7 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
73
73
  private defaultAttributes;
74
74
  private meter: Meter;
75
75
 
76
- private txAddedTimestamp: Map<bigint, number> = new Map<bigint, number>();
76
+ private mempoolItemAddedTimestamp: Map<bigint | string, number> = new Map<bigint | string, number>();
77
77
 
78
78
  constructor(
79
79
  telemetry: TelemetryClient,
@@ -114,22 +114,26 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
114
114
  }
115
115
 
116
116
  public transactionsAdded(transactions: Tx[]) {
117
- const timestamp = Date.now();
118
- for (const transaction of transactions) {
119
- this.txAddedTimestamp.set(transaction.txHash.toBigInt(), timestamp);
120
- }
117
+ transactions.forEach(tx => this.trackMempoolItemAdded(tx.txHash.toBigInt()));
121
118
  }
122
119
 
123
120
  public transactionsRemoved(hashes: Iterable<bigint> | Iterable<string>) {
124
- const timestamp = Date.now();
125
121
  for (const hash of hashes) {
126
- const key = BigInt(hash);
127
- const addedAt = this.txAddedTimestamp.get(key);
128
- if (addedAt !== undefined) {
129
- this.txAddedTimestamp.delete(key);
130
- if (addedAt < timestamp) {
131
- this.minedDelay.record(timestamp - addedAt);
132
- }
122
+ this.trackMempoolItemRemoved(BigInt(hash));
123
+ }
124
+ }
125
+
126
+ public trackMempoolItemAdded(key: bigint | string): void {
127
+ this.mempoolItemAddedTimestamp.set(key, Date.now());
128
+ }
129
+
130
+ public trackMempoolItemRemoved(key: bigint | string): void {
131
+ const timestamp = Date.now();
132
+ const addedAt = this.mempoolItemAddedTimestamp.get(key);
133
+ if (addedAt !== undefined) {
134
+ this.mempoolItemAddedTimestamp.delete(key);
135
+ if (addedAt < timestamp) {
136
+ this.minedDelay.record(timestamp - addedAt);
133
137
  }
134
138
  }
135
139
  }