@aztec/p2p 0.0.1-commit.993d52e → 0.0.1-commit.9badcec54

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 (331) hide show
  1. package/README.md +129 -3
  2. package/dest/client/factory.d.ts +2 -2
  3. package/dest/client/factory.d.ts.map +1 -1
  4. package/dest/client/factory.js +24 -10
  5. package/dest/client/interface.d.ts +9 -2
  6. package/dest/client/interface.d.ts.map +1 -1
  7. package/dest/client/p2p_client.d.ts +3 -2
  8. package/dest/client/p2p_client.d.ts.map +1 -1
  9. package/dest/client/p2p_client.js +46 -38
  10. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +17 -6
  11. package/dest/config.d.ts +124 -106
  12. package/dest/config.d.ts.map +1 -1
  13. package/dest/config.js +87 -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/index.d.ts +1 -2
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +0 -1
  20. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +7 -5
  21. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  22. package/dest/mem_pools/attestation_pool/attestation_pool.js +16 -9
  23. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
  24. package/dest/mem_pools/index.d.ts +1 -2
  25. package/dest/mem_pools/index.d.ts.map +1 -1
  26. package/dest/mem_pools/instrumentation.d.ts +4 -2
  27. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  28. package/dest/mem_pools/instrumentation.js +16 -14
  29. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  30. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  31. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +2 -1
  32. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
  33. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +9 -5
  34. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  35. package/dest/mem_pools/tx_pool_v2/interfaces.js +1 -0
  36. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +13 -7
  37. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  38. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +13 -3
  39. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
  40. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  41. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +26 -43
  42. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
  43. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  44. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +6 -0
  45. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +2 -1
  46. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +29 -5
  48. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
  49. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  50. package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -11
  51. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +4 -2
  52. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  53. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
  54. package/dest/msg_validators/clock_tolerance.d.ts +12 -1
  55. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
  56. package/dest/msg_validators/clock_tolerance.js +54 -3
  57. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
  58. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  59. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
  60. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
  61. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  62. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
  63. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +14 -9
  64. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  65. package/dest/msg_validators/proposal_validator/proposal_validator.js +65 -55
  66. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  67. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  68. package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
  69. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  70. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  71. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  72. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  73. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  74. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  75. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  76. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  77. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  78. package/dest/msg_validators/tx_validator/data_validator.js +35 -2
  79. package/dest/msg_validators/tx_validator/factory.d.ts +23 -4
  80. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  81. package/dest/msg_validators/tx_validator/factory.js +36 -10
  82. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
  83. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
  84. package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
  85. package/dest/msg_validators/tx_validator/gas_validator.d.ts +13 -4
  86. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  87. package/dest/msg_validators/tx_validator/gas_validator.js +49 -17
  88. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  89. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  90. package/dest/msg_validators/tx_validator/index.js +1 -0
  91. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
  92. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  93. package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
  94. package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
  95. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  96. package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
  97. package/dest/services/data_store.d.ts +1 -1
  98. package/dest/services/data_store.d.ts.map +1 -1
  99. package/dest/services/data_store.js +5 -5
  100. package/dest/services/dummy_service.d.ts +6 -3
  101. package/dest/services/dummy_service.d.ts.map +1 -1
  102. package/dest/services/dummy_service.js +6 -1
  103. package/dest/services/encoding.d.ts +5 -1
  104. package/dest/services/encoding.d.ts.map +1 -1
  105. package/dest/services/encoding.js +7 -1
  106. package/dest/services/gossipsub/topic_score_params.d.ts +13 -2
  107. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  108. package/dest/services/gossipsub/topic_score_params.js +21 -4
  109. package/dest/services/libp2p/instrumentation.d.ts +3 -1
  110. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  111. package/dest/services/libp2p/instrumentation.js +14 -0
  112. package/dest/services/libp2p/libp2p_service.d.ts +15 -25
  113. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  114. package/dest/services/libp2p/libp2p_service.js +176 -127
  115. package/dest/services/peer-manager/metrics.d.ts +3 -1
  116. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  117. package/dest/services/peer-manager/metrics.js +6 -0
  118. package/dest/services/peer-manager/peer_manager.d.ts +6 -2
  119. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  120. package/dest/services/peer-manager/peer_manager.js +39 -11
  121. package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
  122. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  123. package/dest/services/peer-manager/peer_scoring.js +32 -10
  124. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -8
  125. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  126. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +82 -101
  127. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
  128. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  129. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
  130. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  131. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
  132. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
  133. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  134. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
  135. package/dest/services/reqresp/config.d.ts +3 -3
  136. package/dest/services/reqresp/config.d.ts.map +1 -1
  137. package/dest/services/reqresp/interface.d.ts +14 -9
  138. package/dest/services/reqresp/interface.d.ts.map +1 -1
  139. package/dest/services/reqresp/interface.js +10 -11
  140. package/dest/services/reqresp/metrics.d.ts +1 -1
  141. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  142. package/dest/services/reqresp/metrics.js +0 -1
  143. package/dest/services/reqresp/protocols/index.d.ts +1 -2
  144. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  145. package/dest/services/reqresp/protocols/index.js +0 -1
  146. package/dest/services/reqresp/protocols/tx.d.ts +1 -1
  147. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  148. package/dest/services/reqresp/protocols/tx.js +1 -3
  149. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
  150. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  151. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
  152. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  153. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  154. package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
  155. package/dest/services/reqresp/reqresp.d.ts +4 -2
  156. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  157. package/dest/services/reqresp/reqresp.js +30 -12
  158. package/dest/services/service.d.ts +5 -2
  159. package/dest/services/service.d.ts.map +1 -1
  160. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
  161. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  162. package/dest/services/tx_collection/fast_tx_collection.js +57 -73
  163. package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
  164. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  165. package/dest/services/tx_collection/file_store_tx_source.js +39 -29
  166. package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
  167. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  168. package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
  169. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  170. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  171. package/dest/services/tx_collection/request_tracker.js +84 -0
  172. package/dest/services/tx_collection/slow_tx_collection.js +1 -1
  173. package/dest/services/tx_collection/tx_collection.d.ts +3 -6
  174. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  175. package/dest/services/tx_collection/tx_source.d.ts +6 -5
  176. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  177. package/dest/services/tx_collection/tx_source.js +9 -7
  178. package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
  179. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  180. package/dest/test-helpers/mock-pubsub.d.ts +11 -3
  181. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  182. package/dest/test-helpers/mock-pubsub.js +35 -10
  183. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  184. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  185. package/dest/test-helpers/reqresp-nodes.js +1 -2
  186. package/dest/test-helpers/testbench-utils.d.ts +1 -1
  187. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  188. package/dest/test-helpers/testbench-utils.js +23 -3
  189. package/dest/testbench/p2p_client_testbench_worker.js +68 -16
  190. package/dest/testbench/worker_client_manager.d.ts +10 -1
  191. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  192. package/dest/testbench/worker_client_manager.js +55 -3
  193. package/dest/util.d.ts +1 -1
  194. package/package.json +14 -14
  195. package/src/client/factory.ts +43 -14
  196. package/src/client/interface.ts +9 -1
  197. package/src/client/p2p_client.ts +50 -39
  198. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -9
  199. package/src/config.ts +129 -45
  200. package/src/errors/p2p-service.error.ts +11 -0
  201. package/src/index.ts +0 -1
  202. package/src/mem_pools/attestation_pool/attestation_pool.ts +17 -12
  203. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
  204. package/src/mem_pools/index.ts +0 -3
  205. package/src/mem_pools/instrumentation.ts +17 -13
  206. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
  207. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
  208. package/src/mem_pools/tx_pool_v2/interfaces.ts +9 -4
  209. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +23 -7
  210. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
  211. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +16 -1
  212. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +31 -5
  213. package/src/msg_validators/attestation_validator/README.md +49 -0
  214. package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -9
  215. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +4 -1
  216. package/src/msg_validators/clock_tolerance.ts +72 -3
  217. package/src/msg_validators/proposal_validator/README.md +123 -0
  218. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +17 -4
  219. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +23 -7
  220. package/src/msg_validators/proposal_validator/proposal_validator.ts +74 -58
  221. package/src/msg_validators/tx_validator/README.md +5 -1
  222. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  223. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  224. package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
  225. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  226. package/src/msg_validators/tx_validator/data_validator.ts +42 -1
  227. package/src/msg_validators/tx_validator/factory.ts +43 -3
  228. package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
  229. package/src/msg_validators/tx_validator/gas_validator.ts +65 -16
  230. package/src/msg_validators/tx_validator/index.ts +1 -0
  231. package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
  232. package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
  233. package/src/services/data_store.ts +5 -13
  234. package/src/services/dummy_service.ts +8 -2
  235. package/src/services/encoding.ts +9 -1
  236. package/src/services/gossipsub/topic_score_params.ts +36 -4
  237. package/src/services/libp2p/instrumentation.ts +14 -0
  238. package/src/services/libp2p/libp2p_service.ts +175 -143
  239. package/src/services/peer-manager/metrics.ts +7 -0
  240. package/src/services/peer-manager/peer_manager.ts +45 -11
  241. package/src/services/peer-manager/peer_scoring.ts +27 -5
  242. package/src/services/reqresp/README.md +229 -0
  243. package/src/services/reqresp/batch-tx-requester/README.md +46 -7
  244. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +78 -111
  245. package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
  246. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
  247. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
  248. package/src/services/reqresp/config.ts +2 -2
  249. package/src/services/reqresp/interface.ts +21 -11
  250. package/src/services/reqresp/metrics.ts +0 -1
  251. package/src/services/reqresp/protocols/index.ts +0 -1
  252. package/src/services/reqresp/protocols/tx.ts +1 -3
  253. package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
  254. package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
  255. package/src/services/reqresp/reqresp.ts +40 -13
  256. package/src/services/service.ts +6 -1
  257. package/src/services/tx_collection/fast_tx_collection.ts +57 -83
  258. package/src/services/tx_collection/file_store_tx_source.ts +43 -31
  259. package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
  260. package/src/services/tx_collection/request_tracker.ts +127 -0
  261. package/src/services/tx_collection/slow_tx_collection.ts +1 -1
  262. package/src/services/tx_collection/tx_collection.ts +3 -5
  263. package/src/services/tx_collection/tx_source.ts +8 -7
  264. package/src/test-helpers/make-test-p2p-clients.ts +1 -1
  265. package/src/test-helpers/mock-pubsub.ts +31 -5
  266. package/src/test-helpers/reqresp-nodes.ts +3 -3
  267. package/src/test-helpers/testbench-utils.ts +30 -3
  268. package/src/testbench/p2p_client_testbench_worker.ts +72 -15
  269. package/src/testbench/worker_client_manager.ts +68 -6
  270. package/src/util.ts +1 -1
  271. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
  272. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
  273. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
  274. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
  275. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
  276. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
  277. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
  278. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
  279. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
  280. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
  281. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
  282. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
  283. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
  284. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
  285. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
  286. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
  287. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
  288. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
  289. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
  290. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
  291. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
  292. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
  293. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
  294. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
  295. package/dest/mem_pools/tx_pool/index.d.ts +0 -3
  296. package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
  297. package/dest/mem_pools/tx_pool/index.js +0 -2
  298. package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
  299. package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
  300. package/dest/mem_pools/tx_pool/priority.js +0 -15
  301. package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
  302. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
  303. package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
  304. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
  305. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
  306. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
  307. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -24
  308. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
  309. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -378
  310. package/dest/services/reqresp/protocols/block.d.ts +0 -9
  311. package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
  312. package/dest/services/reqresp/protocols/block.js +0 -32
  313. package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
  314. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
  315. package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
  316. package/src/mem_pools/tx_pool/README.md +0 -270
  317. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
  318. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
  319. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
  320. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
  321. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
  322. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
  323. package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
  324. package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
  325. package/src/mem_pools/tx_pool/index.ts +0 -2
  326. package/src/mem_pools/tx_pool/priority.ts +0 -20
  327. package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
  328. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
  329. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -373
  330. package/src/services/reqresp/protocols/block.ts +0 -37
  331. package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
@@ -3,12 +3,12 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
4
  import { DateProvider } from '@aztec/foundation/timer';
5
5
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
6
- import type { DataStoreConfig } from '@aztec/kv-store/config';
7
6
  import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
8
7
  import type { L2BlockSource } from '@aztec/stdlib/block';
9
8
  import type { ChainConfig } from '@aztec/stdlib/config';
10
9
  import type { ContractDataSource } from '@aztec/stdlib/contract';
11
10
  import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
11
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
12
12
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
13
13
 
14
14
  import { P2PClient } from '../client/p2p_client.js';
@@ -17,7 +17,12 @@ import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestati
17
17
  import type { MemPools } from '../mem_pools/interface.js';
18
18
  import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
19
19
  import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
20
- import { createTxValidatorForTransactionsEnteringPendingTxPool } from '../msg_validators/index.js';
20
+ import {
21
+ createCheckAllowedSetupCalls,
22
+ createTxValidatorForReqResponseReceivedTxs,
23
+ createTxValidatorForTransactionsEnteringPendingTxPool,
24
+ getDefaultAllowedSetupFunctions,
25
+ } from '../msg_validators/index.js';
21
26
  import { DummyP2PService } from '../services/dummy_service.js';
22
27
  import { LibP2PService } from '../services/index.js';
23
28
  import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
@@ -75,6 +80,33 @@ export async function createP2PClient(
75
80
  const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
76
81
  const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
77
82
 
83
+ const allowedInSetup = [
84
+ ...(await getDefaultAllowedSetupFunctions()),
85
+ ...(inputConfig.txPublicSetupAllowListExtend ?? []),
86
+ ];
87
+ const checkAllowedSetupCalls = createCheckAllowedSetupCalls(
88
+ archiver,
89
+ allowedInSetup,
90
+ () => epochCache.getEpochAndSlotInNextL1Slot().ts,
91
+ );
92
+
93
+ const createTxValidator = async () => {
94
+ // We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
95
+ const currentBlockNumber = await archiver.getBlockNumber();
96
+ const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
97
+ const l1Constants = await archiver.getL1Constants();
98
+ return createTxValidatorForTransactionsEnteringPendingTxPool(
99
+ worldStateSynchronizer,
100
+ nextSlotTimestamp,
101
+ BlockNumber(currentBlockNumber + 1),
102
+ {
103
+ rollupManaLimit: l1Constants.rollupManaLimit,
104
+ maxBlockL2Gas: config.validateMaxL2BlockGas,
105
+ maxBlockDAGas: config.validateMaxDABlockGas,
106
+ },
107
+ );
108
+ };
109
+
78
110
  const txPool =
79
111
  deps.txPool ??
80
112
  new AztecKVTxPoolV2(
@@ -83,22 +115,15 @@ export async function createP2PClient(
83
115
  {
84
116
  l2BlockSource: archiver,
85
117
  worldStateSynchronizer,
86
- createTxValidator: async () => {
87
- // We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
88
- const currentBlockNumber = await archiver.getBlockNumber();
89
- const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
90
- return createTxValidatorForTransactionsEnteringPendingTxPool(
91
- worldStateSynchronizer,
92
- nextSlotTimestamp,
93
- BlockNumber(currentBlockNumber + 1),
94
- );
95
- },
118
+ checkAllowedSetupCalls,
119
+ createTxValidator,
96
120
  },
97
121
  telemetry,
98
122
  {
99
123
  maxPendingTxCount: config.maxPendingTxCount,
100
124
  archivedTxLimit: config.archivedTxLimit,
101
125
  minTxPoolAgeMs: config.minTxPoolAgeMs,
126
+ dropTransactionsProbability: config.dropTransactionsProbability,
102
127
  priceBumpPercentage: config.priceBumpPercentage,
103
128
  },
104
129
  dateProvider,
@@ -124,9 +149,12 @@ export async function createP2PClient(
124
149
  telemetry,
125
150
  );
126
151
 
152
+ const txValidatorForTxCollection = createTxValidatorForReqResponseReceivedTxs(proofVerifier, config);
127
153
  const nodeSources = [
128
- ...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, config),
129
- ...(deps.rpcTxProviders ?? []).map((node, i) => new NodeRpcTxSource(node, `node-rpc-provider-${i}`)),
154
+ ...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, txValidatorForTxCollection, config),
155
+ ...(deps.rpcTxProviders ?? []).map(
156
+ (node, i) => new NodeRpcTxSource(node, txValidatorForTxCollection, `node-rpc-provider-${i}`),
157
+ ),
130
158
  ...(deps.txCollectionNodeSources ?? []),
131
159
  ];
132
160
  if (nodeSources.length > 0) {
@@ -138,6 +166,7 @@ export async function createP2PClient(
138
166
  const fileStoreSources = await createFileStoreTxSources(
139
167
  config.txCollectionFileStoreUrls,
140
168
  txFileStoreBasePath,
169
+ txValidatorForTxCollection,
141
170
  logger.createChild('file-store-tx-source'),
142
171
  telemetry,
143
172
  );
@@ -82,7 +82,15 @@ export type P2P = P2PClient & {
82
82
  *
83
83
  * @param handler - A function taking a received checkpoint proposal and producing attestations
84
84
  */
85
- registerCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
85
+ registerValidatorCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
86
+
87
+ /**
88
+ * Registers a callback that runs for ALL nodes (not just validators) when a checkpoint proposal is received.
89
+ * Used to set the proposed checkpoint number on the archiver so the sequencer can build on top of it.
90
+ *
91
+ * @param handler - A function taking a received checkpoint proposal
92
+ */
93
+ registerAllNodesCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
86
94
 
87
95
  /**
88
96
  * Registers a callback invoked when a duplicate proposal is detected (equivocation).
@@ -1,4 +1,3 @@
1
- import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
2
1
  import type { EpochCacheInterface } from '@aztec/epoch-cache';
3
2
  import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
3
  import { createLogger } from '@aztec/foundation/log';
@@ -9,6 +8,7 @@ import { L2TipsKVStore } from '@aztec/kv-store/stores';
9
8
  import {
10
9
  type CheckpointId,
11
10
  type EthAddress,
11
+ GENESIS_BLOCK_HEADER_HASH,
12
12
  type L2Block,
13
13
  type L2BlockId,
14
14
  type L2BlockSource,
@@ -18,7 +18,6 @@ import {
18
18
  type L2TipsStore,
19
19
  } from '@aztec/stdlib/block';
20
20
  import type { ContractDataSource } from '@aztec/stdlib/contract';
21
- import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
22
21
  import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
23
22
  import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
24
23
  import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
@@ -111,27 +110,6 @@ export class P2PClient extends WithTracer implements P2P {
111
110
  this.telemetry,
112
111
  );
113
112
 
114
- // Default to collecting all txs when we see a valid proposal
115
- // This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
116
- // Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
117
- // TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
118
- // validator-client code into here so we can validate a proposal is reasonable.
119
- this.registerBlockProposalHandler(async (block, sender) => {
120
- this.log.debug(`Received block proposal from ${sender.toString()}`);
121
- // TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
122
- const constants = this.txCollection.getConstants();
123
- const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
124
- const deadline = new Date(nextSlotTimestampSeconds * 1000);
125
- const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
126
- if (!parentBlock) {
127
- this.log.debug(`Cannot collect txs for proposal as parent block not found`);
128
- return false;
129
- }
130
- const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
131
- await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
132
- return true;
133
- });
134
-
135
113
  this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
136
114
  this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
137
115
  }
@@ -279,7 +257,11 @@ export class P2PClient extends WithTracer implements P2P {
279
257
  });
280
258
  }
281
259
 
282
- this.blockStream!.start();
260
+ // Should never happen: all branches above call initBlockStream()
261
+ if (!this.blockStream) {
262
+ throw new Error('Block stream not initialized');
263
+ }
264
+ this.blockStream.start();
283
265
  await this.txCollection.start();
284
266
  this.txFileStore?.start();
285
267
 
@@ -341,7 +323,11 @@ export class P2PClient extends WithTracer implements P2P {
341
323
  /** Triggers a sync to the archiver. Used for testing. */
342
324
  public async sync() {
343
325
  this.initBlockStream();
344
- await this.blockStream!.sync();
326
+ // Should never happen: initBlockStream() creates blockStream if absent
327
+ if (!this.blockStream) {
328
+ throw new Error('Block stream not initialized');
329
+ }
330
+ await this.blockStream.sync();
345
331
  }
346
332
 
347
333
  @trackSpan('p2pClient.broadcastProposal', async proposal => ({
@@ -379,6 +365,8 @@ export class P2PClient extends WithTracer implements P2P {
379
365
  // Store our own last-block proposal so we can respond to req/resp requests for it.
380
366
  await this.attestationPool.tryAddBlockProposal(blockProposal);
381
367
  }
368
+ // Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
369
+ await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
382
370
  return this.p2pService.propagate(proposal);
383
371
  }
384
372
 
@@ -410,8 +398,12 @@ export class P2PClient extends WithTracer implements P2P {
410
398
  this.p2pService.registerBlockReceivedCallback(handler);
411
399
  }
412
400
 
413
- public registerCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
414
- this.p2pService.registerCheckpointReceivedCallback(handler);
401
+ public registerValidatorCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
402
+ this.p2pService.registerValidatorCheckpointReceivedCallback(handler);
403
+ }
404
+
405
+ public registerAllNodesCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
406
+ this.p2pService.registerAllNodesCheckpointReceivedCallback(handler);
415
407
  }
416
408
 
417
409
  public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
@@ -691,31 +683,50 @@ export class P2PClient extends WithTracer implements P2P {
691
683
  }
692
684
 
693
685
  /**
694
- * Returns true if the prune crossed a checkpoint boundary.
695
- * If the old and new checkpoint numbers are the same, the prune is within a single checkpoint.
696
- * If they differ, the prune spans across checkpoints (epoch prune).
686
+ * Returns true if the prune is an epoch prune (new checkpoint number is less than old).
687
+ * If the checkpoint number stays the same or increases, the prune is within a checkpoint.
697
688
  */
698
689
  private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
699
690
  const tips = await this.l2Tips.getL2Tips();
700
691
  const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
701
- if (oldCheckpointNumber <= CheckpointNumber.ZERO) {
692
+ if (oldCheckpointNumber <= CheckpointNumber.INITIAL) {
702
693
  return false;
703
694
  }
704
- const isEpochPrune = oldCheckpointNumber !== newCheckpoint.number;
705
- this.log.info(
706
- `Detected epoch prune: ${isEpochPrune}. Old checkpoint: ${oldCheckpointNumber}, new checkpoint: ${newCheckpoint.number}`,
707
- );
695
+ const newCheckpointNumber = newCheckpoint.number;
696
+ // We check that the new checkpoint number is less than the old checkpoint number in order to consider it an epoch prune.
697
+ // To be more certain that it is an epoch prune, we will check that at least 2 checkpoints were removed.
698
+ // This means we should avoid thinking checkpoints removed by L1 re-orgs are epoch prunes
699
+ const thresholdForEpochPrune = CheckpointNumber(oldCheckpointNumber - 2);
700
+ const isEpochPrune = newCheckpointNumber <= thresholdForEpochPrune;
701
+ if (isEpochPrune) {
702
+ this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, {
703
+ oldCheckpointNumber,
704
+ newCheckpointNumber,
705
+ thresholdForEpochPrune,
706
+ });
707
+ }
708
708
  return isEpochPrune;
709
709
  }
710
710
 
711
711
  /** Checks if the slot has changed and calls prepareForSlot if so. */
712
712
  private async maybeCallPrepareForSlot(): Promise<void> {
713
- const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
714
- if (currentSlot <= this.lastSlotProcessed) {
713
+ // If we have a proposed checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
714
+ const l2Tips = await this.l2Tips.getL2Tips();
715
+ const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
716
+
717
+ let slot;
718
+ if (this.epochCache.isProposerPipeliningEnabled() && hasProposedCheckpoint) {
719
+ const { targetSlot } = this.epochCache.getTargetAndNextSlot();
720
+ slot = targetSlot;
721
+ } else {
722
+ const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
723
+ slot = currentSlot;
724
+ }
725
+ if (slot <= this.lastSlotProcessed) {
715
726
  return;
716
727
  }
717
- this.lastSlotProcessed = currentSlot;
718
- await this.txPool.prepareForSlot(currentSlot);
728
+ this.lastSlotProcessed = slot;
729
+ await this.txPool.prepareForSlot(slot);
719
730
  }
720
731
 
721
732
  private async startServiceIfSynched() {
@@ -3,11 +3,11 @@ 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';
10
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
11
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';
@@ -19,7 +19,7 @@ import type { P2PConfig } from '../../../config.js';
19
19
  import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
20
20
  import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
21
21
  import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
22
- import { MissingTxsTracker } from '../../../services/tx_collection/missing_txs_tracker.js';
22
+ import { RequestTracker } from '../../../services/tx_collection/request_tracker.js';
23
23
  import {
24
24
  AlwaysTrueCircuitVerifier,
25
25
  BENCHMARK_CONSTANTS,
@@ -213,10 +213,9 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
213
213
  const fetched = await executeTimeout(
214
214
  (_signal: AbortSignal) =>
215
215
  collector.collectTxs(
216
- MissingTxsTracker.fromArray(parsedTxHashes),
216
+ RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)),
217
217
  parsedProposal,
218
218
  pinnedPeer,
219
- internalTimeoutMs,
220
219
  ),
221
220
  timeoutMs,
222
221
  () => new Error(`Collector timed out after ${timeoutMs}ms`),
@@ -231,10 +230,9 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
231
230
  const fetched = await executeTimeout(
232
231
  (_signal: AbortSignal) =>
233
232
  collector.collectTxs(
234
- MissingTxsTracker.fromArray(parsedTxHashes),
233
+ RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)),
235
234
  parsedProposal,
236
235
  pinnedPeer,
237
- internalTimeoutMs,
238
236
  ),
239
237
  timeoutMs,
240
238
  () => new Error(`Collector timed out after ${timeoutMs}ms`),
@@ -261,9 +259,20 @@ async function stopClient() {
261
259
  attestationPool = undefined;
262
260
  }
263
261
 
262
+ function gracefulExit(code: number = 0) {
263
+ try {
264
+ if (process.connected) {
265
+ process.disconnect();
266
+ }
267
+ } catch {
268
+ // IPC channel already closed
269
+ }
270
+ setTimeout(() => process.exit(code), 5000).unref();
271
+ }
272
+
264
273
  process.on('disconnect', () => {
265
274
  ipcDisconnected = true;
266
- void stopClient().finally(() => process.exit(0));
275
+ void stopClient();
267
276
  });
268
277
 
269
278
  process.on('error', err => {
@@ -327,7 +336,7 @@ process.on('message', (msg: WorkerCommand) => {
327
336
  case 'STOP': {
328
337
  await stopClient();
329
338
  await sendMessage({ type: 'STOPPED', requestId });
330
- process.exit(0);
339
+ gracefulExit(0);
331
340
  break;
332
341
  }
333
342
  default: {
@@ -338,7 +347,8 @@ process.on('message', (msg: WorkerCommand) => {
338
347
  } catch (err: any) {
339
348
  await sendMessage({ type: 'ERROR', requestId, error: err?.message ?? String(err) });
340
349
  if (msg.type === 'START') {
341
- process.exit(1);
350
+ await stopClient();
351
+ gracefulExit(1);
342
352
  }
343
353
  }
344
354
  })();
package/src/config.ts CHANGED
@@ -11,7 +11,6 @@ import {
11
11
  secretStringConfigHelper,
12
12
  } from '@aztec/foundation/config';
13
13
  import { Fr } from '@aztec/foundation/curves/bn254';
14
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
15
14
  import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
16
15
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
17
16
  import {
@@ -21,6 +20,7 @@ import {
21
20
  chainConfigMappings,
22
21
  sharedSequencerConfigMappings,
23
22
  } from '@aztec/stdlib/config';
23
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
24
24
 
25
25
  import {
26
26
  type BatchTxRequesterConfig,
@@ -39,7 +39,26 @@ export interface P2PConfig
39
39
  ChainConfig,
40
40
  TxCollectionConfig,
41
41
  TxFileStoreConfig,
42
- Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'> {
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
+
43
62
  /** A flag dictating whether the P2P subsystem should be enabled. */
44
63
  p2pEnabled: boolean;
45
64
 
@@ -58,6 +77,9 @@ export interface P2PConfig
58
77
  /** The frequency in which to check for new peers. */
59
78
  peerCheckIntervalMS: number;
60
79
 
80
+ /** How long to ban a peer after it fails MAX_DIAL_ATTEMPTS dials. */
81
+ peerFailedBanTimeMs: number;
82
+
61
83
  /** Size of queue of L2 blocks to store. */
62
84
  l2QueueSize: number;
63
85
 
@@ -151,8 +173,8 @@ export interface P2PConfig
151
173
  /** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
152
174
  p2pStoreMapSizeKb?: number;
153
175
 
154
- /** Which calls are allowed in the public setup phase of a tx. */
155
- txPublicSetupAllowList: AllowedElement[];
176
+ /** Additional entries to extend the default setup allow list. */
177
+ txPublicSetupAllowListExtend: AllowedElement[];
156
178
 
157
179
  /** The maximum number of pending txs before evicting lower priority txs. */
158
180
  maxPendingTxCount: number;
@@ -174,10 +196,7 @@ export interface P2PConfig
174
196
  /** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
175
197
  disableTransactions: boolean;
176
198
 
177
- /** True to simulate discarding transactions. - For testing purposes only*/
178
- dropTransactions: boolean;
179
-
180
- /** 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 */
181
200
  dropTransactionsProbability: number;
182
201
 
183
202
  /** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
@@ -202,6 +221,28 @@ export interface P2PConfig
202
221
  export const DEFAULT_P2P_PORT = 40400;
203
222
 
204
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
+ },
205
246
  p2pEnabled: {
206
247
  env: 'P2P_ENABLED',
207
248
  description: 'A flag dictating whether the P2P subsystem should be enabled.',
@@ -232,6 +273,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
232
273
  description: 'The frequency in which to check for new peers.',
233
274
  ...numberConfigHelper(30_000),
234
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
+ },
235
281
  l2QueueSize: {
236
282
  env: 'P2P_L2_QUEUE_SIZE',
237
283
  description: 'Size of queue of L2 blocks to store.',
@@ -325,7 +371,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
325
371
  gossipsubMcacheLength: {
326
372
  env: 'P2P_GOSSIPSUB_MCACHE_LENGTH',
327
373
  description: 'The number of gossipsub interval message cache windows to keep.',
328
- ...numberConfigHelper(6),
374
+ ...numberConfigHelper(12),
329
375
  },
330
376
  gossipsubMcacheGossip: {
331
377
  env: 'P2P_GOSSIPSUB_MCACHE_GOSSIP',
@@ -397,15 +443,16 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
397
443
  },
398
444
  p2pStoreMapSizeKb: {
399
445
  env: 'P2P_STORE_MAP_SIZE_KB',
400
- parseEnv: (val: string | undefined) => (val ? +val : undefined),
446
+ parseEnv: (val: string) => +val,
401
447
  description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
402
448
  },
403
- txPublicSetupAllowList: {
449
+ txPublicSetupAllowListExtend: {
404
450
  env: 'TX_PUBLIC_SETUP_ALLOWLIST',
405
451
  parseEnv: (val: string) => parseAllowList(val),
406
- 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 +.',
407
454
  printDefault: () =>
408
- 'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
455
+ 'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
409
456
  },
410
457
  maxPendingTxCount: {
411
458
  env: 'P2P_MAX_PENDING_TX_COUNT',
@@ -434,11 +481,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
434
481
  description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
435
482
  ...numberConfigHelper(3),
436
483
  },
437
- dropTransactions: {
438
- env: 'P2P_DROP_TX',
439
- description: 'True to simulate discarding transactions. - For testing purposes only',
440
- ...booleanConfigHelper(false),
441
- },
442
484
  dropTransactionsProbability: {
443
485
  env: 'P2P_DROP_TX_CHANCE',
444
486
  description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
@@ -460,6 +502,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
460
502
  description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
461
503
  ...booleanConfigHelper(false),
462
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
+ },
463
510
  fishermanMode: {
464
511
  env: 'FISHERMAN_MODE',
465
512
  description:
@@ -539,13 +586,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
539
586
  bootnodeConfigKeys,
540
587
  );
541
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
+
542
618
  /**
543
619
  * Parses a string to a list of allowed elements.
544
- * Each encoded is expected to be of one of the following formats
545
- * `I:${address}`
546
- * `I:${address}:${selector}`
547
- * `C:${classId}`
548
- * `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).
549
627
  *
550
628
  * @param value The string to parse
551
629
  * @returns A list of allowed elements
@@ -558,31 +636,37 @@ export function parseAllowList(value: string): AllowedElement[] {
558
636
  }
559
637
 
560
638
  for (const val of value.split(',')) {
561
- const [typeString, identifierString, selectorString] = val.split(':');
562
- 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) : {};
563
653
 
564
654
  if (typeString === 'I') {
565
- if (selector) {
566
- entries.push({
567
- address: AztecAddress.fromString(identifierString),
568
- selector,
569
- });
570
- } else {
571
- entries.push({
572
- address: AztecAddress.fromString(identifierString),
573
- });
574
- }
655
+ entries.push({
656
+ address: AztecAddress.fromString(identifierString),
657
+ selector,
658
+ ...flags,
659
+ });
575
660
  } else if (typeString === 'C') {
576
- if (selector) {
577
- entries.push({
578
- classId: Fr.fromHexString(identifierString),
579
- selector,
580
- });
581
- } else {
582
- entries.push({
583
- classId: Fr.fromHexString(identifierString),
584
- });
585
- }
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
+ );
586
670
  }
587
671
  }
588
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
+ }
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';