@aztec/p2p 0.0.1-commit.ef17749e1 → 0.0.1-commit.f103f88

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 (283) hide show
  1. package/README.md +129 -3
  2. package/dest/client/factory.d.ts +1 -1
  3. package/dest/client/factory.d.ts.map +1 -1
  4. package/dest/client/factory.js +23 -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 -14
  10. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +17 -6
  11. package/dest/config.d.ts +111 -95
  12. package/dest/config.d.ts.map +1 -1
  13. package/dest/config.js +27 -2
  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 +11 -8
  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/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  27. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  28. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +2 -1
  29. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
  30. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +7 -5
  31. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  32. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +9 -2
  33. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  34. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +13 -3
  35. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
  36. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  37. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +3 -0
  38. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
  39. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +19 -5
  41. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
  42. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  43. package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -11
  44. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +4 -2
  45. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  46. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
  47. package/dest/msg_validators/clock_tolerance.d.ts +12 -1
  48. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
  49. package/dest/msg_validators/clock_tolerance.js +54 -3
  50. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +2 -1
  51. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  52. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +2 -1
  53. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  54. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -1
  55. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  56. package/dest/msg_validators/proposal_validator/proposal_validator.js +19 -11
  57. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  58. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  59. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  60. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  61. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  62. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  63. package/dest/msg_validators/tx_validator/data_validator.js +35 -2
  64. package/dest/msg_validators/tx_validator/factory.d.ts +23 -4
  65. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  66. package/dest/msg_validators/tx_validator/factory.js +36 -10
  67. package/dest/msg_validators/tx_validator/gas_validator.d.ts +13 -4
  68. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  69. package/dest/msg_validators/tx_validator/gas_validator.js +49 -17
  70. package/dest/msg_validators/tx_validator/phases_validator.d.ts +21 -1
  71. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  72. package/dest/msg_validators/tx_validator/phases_validator.js +28 -1
  73. package/dest/services/data_store.d.ts +1 -1
  74. package/dest/services/data_store.d.ts.map +1 -1
  75. package/dest/services/data_store.js +5 -5
  76. package/dest/services/dummy_service.d.ts +6 -3
  77. package/dest/services/dummy_service.d.ts.map +1 -1
  78. package/dest/services/dummy_service.js +6 -1
  79. package/dest/services/encoding.d.ts +5 -1
  80. package/dest/services/encoding.d.ts.map +1 -1
  81. package/dest/services/encoding.js +7 -1
  82. package/dest/services/gossipsub/topic_score_params.d.ts +13 -2
  83. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  84. package/dest/services/gossipsub/topic_score_params.js +21 -4
  85. package/dest/services/libp2p/libp2p_service.d.ts +15 -25
  86. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  87. package/dest/services/libp2p/libp2p_service.js +151 -118
  88. package/dest/services/peer-manager/peer_manager.d.ts +6 -2
  89. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  90. package/dest/services/peer-manager/peer_manager.js +37 -10
  91. package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
  92. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  93. package/dest/services/peer-manager/peer_scoring.js +32 -10
  94. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -8
  95. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  96. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +69 -65
  97. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
  98. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  99. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
  100. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  101. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
  102. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +3 -1
  103. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  104. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +3 -0
  105. package/dest/services/reqresp/config.d.ts +3 -3
  106. package/dest/services/reqresp/config.d.ts.map +1 -1
  107. package/dest/services/reqresp/interface.d.ts +14 -9
  108. package/dest/services/reqresp/interface.d.ts.map +1 -1
  109. package/dest/services/reqresp/interface.js +10 -11
  110. package/dest/services/reqresp/metrics.d.ts +1 -1
  111. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  112. package/dest/services/reqresp/metrics.js +0 -1
  113. package/dest/services/reqresp/protocols/index.d.ts +1 -2
  114. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  115. package/dest/services/reqresp/protocols/index.js +0 -1
  116. package/dest/services/reqresp/protocols/tx.d.ts +1 -1
  117. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  118. package/dest/services/reqresp/protocols/tx.js +1 -3
  119. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
  120. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  121. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
  122. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  123. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  124. package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
  125. package/dest/services/reqresp/reqresp.d.ts +4 -2
  126. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  127. package/dest/services/reqresp/reqresp.js +28 -11
  128. package/dest/services/service.d.ts +5 -2
  129. package/dest/services/service.d.ts.map +1 -1
  130. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
  131. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  132. package/dest/services/tx_collection/fast_tx_collection.js +57 -73
  133. package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
  134. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  135. package/dest/services/tx_collection/file_store_tx_source.js +39 -29
  136. package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
  137. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  138. package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
  139. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  140. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  141. package/dest/services/tx_collection/request_tracker.js +84 -0
  142. package/dest/services/tx_collection/slow_tx_collection.js +1 -1
  143. package/dest/services/tx_collection/tx_collection.d.ts +3 -6
  144. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  145. package/dest/services/tx_collection/tx_source.d.ts +6 -5
  146. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  147. package/dest/services/tx_collection/tx_source.js +9 -7
  148. package/dest/test-helpers/mock-pubsub.d.ts +11 -3
  149. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  150. package/dest/test-helpers/mock-pubsub.js +35 -10
  151. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  152. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  153. package/dest/test-helpers/reqresp-nodes.js +1 -2
  154. package/dest/test-helpers/testbench-utils.d.ts +1 -1
  155. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  156. package/dest/test-helpers/testbench-utils.js +23 -3
  157. package/dest/testbench/p2p_client_testbench_worker.js +66 -15
  158. package/dest/testbench/worker_client_manager.d.ts +8 -1
  159. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  160. package/dest/testbench/worker_client_manager.js +49 -1
  161. package/package.json +14 -14
  162. package/src/client/factory.ts +41 -13
  163. package/src/client/interface.ts +9 -1
  164. package/src/client/p2p_client.ts +50 -17
  165. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +18 -8
  166. package/src/config.ts +48 -3
  167. package/src/errors/p2p-service.error.ts +11 -0
  168. package/src/index.ts +0 -1
  169. package/src/mem_pools/attestation_pool/attestation_pool.ts +12 -8
  170. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
  171. package/src/mem_pools/index.ts +0 -3
  172. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
  173. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
  174. package/src/mem_pools/tx_pool_v2/interfaces.ts +6 -4
  175. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +19 -3
  176. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +13 -1
  177. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +20 -5
  178. package/src/msg_validators/attestation_validator/README.md +49 -0
  179. package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -9
  180. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +4 -1
  181. package/src/msg_validators/clock_tolerance.ts +72 -3
  182. package/src/msg_validators/proposal_validator/README.md +123 -0
  183. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +4 -1
  184. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +4 -1
  185. package/src/msg_validators/proposal_validator/proposal_validator.ts +17 -10
  186. package/src/msg_validators/tx_validator/README.md +5 -1
  187. package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
  188. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  189. package/src/msg_validators/tx_validator/data_validator.ts +42 -1
  190. package/src/msg_validators/tx_validator/factory.ts +43 -3
  191. package/src/msg_validators/tx_validator/gas_validator.ts +65 -16
  192. package/src/msg_validators/tx_validator/phases_validator.ts +31 -1
  193. package/src/services/data_store.ts +5 -13
  194. package/src/services/dummy_service.ts +8 -2
  195. package/src/services/encoding.ts +9 -1
  196. package/src/services/gossipsub/topic_score_params.ts +36 -4
  197. package/src/services/libp2p/libp2p_service.ts +150 -134
  198. package/src/services/peer-manager/peer_manager.ts +43 -10
  199. package/src/services/peer-manager/peer_scoring.ts +27 -5
  200. package/src/services/reqresp/README.md +229 -0
  201. package/src/services/reqresp/batch-tx-requester/README.md +46 -7
  202. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +64 -69
  203. package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
  204. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
  205. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +5 -0
  206. package/src/services/reqresp/config.ts +2 -2
  207. package/src/services/reqresp/interface.ts +21 -11
  208. package/src/services/reqresp/metrics.ts +0 -1
  209. package/src/services/reqresp/protocols/index.ts +0 -1
  210. package/src/services/reqresp/protocols/tx.ts +1 -3
  211. package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
  212. package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
  213. package/src/services/reqresp/reqresp.ts +37 -12
  214. package/src/services/service.ts +6 -1
  215. package/src/services/tx_collection/fast_tx_collection.ts +57 -83
  216. package/src/services/tx_collection/file_store_tx_source.ts +43 -31
  217. package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
  218. package/src/services/tx_collection/request_tracker.ts +127 -0
  219. package/src/services/tx_collection/slow_tx_collection.ts +1 -1
  220. package/src/services/tx_collection/tx_collection.ts +3 -5
  221. package/src/services/tx_collection/tx_source.ts +8 -7
  222. package/src/test-helpers/mock-pubsub.ts +31 -5
  223. package/src/test-helpers/reqresp-nodes.ts +2 -2
  224. package/src/test-helpers/testbench-utils.ts +30 -3
  225. package/src/testbench/p2p_client_testbench_worker.ts +70 -14
  226. package/src/testbench/worker_client_manager.ts +55 -1
  227. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
  228. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
  229. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
  230. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
  231. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
  232. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
  233. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
  234. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
  235. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
  236. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
  237. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
  238. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
  239. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
  240. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
  241. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
  242. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
  243. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
  244. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
  245. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
  246. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
  247. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
  248. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
  249. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
  250. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
  251. package/dest/mem_pools/tx_pool/index.d.ts +0 -3
  252. package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
  253. package/dest/mem_pools/tx_pool/index.js +0 -2
  254. package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
  255. package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
  256. package/dest/mem_pools/tx_pool/priority.js +0 -15
  257. package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
  258. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
  259. package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
  260. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
  261. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
  262. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
  263. package/dest/services/reqresp/protocols/block.d.ts +0 -9
  264. package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
  265. package/dest/services/reqresp/protocols/block.js +0 -32
  266. package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
  267. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
  268. package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
  269. package/src/mem_pools/tx_pool/README.md +0 -270
  270. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
  271. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
  272. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
  273. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
  274. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
  275. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
  276. package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
  277. package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
  278. package/src/mem_pools/tx_pool/index.ts +0 -2
  279. package/src/mem_pools/tx_pool/priority.ts +0 -20
  280. package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
  281. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
  282. package/src/services/reqresp/protocols/block.ts +0 -37
  283. package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
@@ -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,16 +115,8 @@ 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
  {
@@ -125,9 +149,12 @@ export async function createP2PClient(
125
149
  telemetry,
126
150
  );
127
151
 
152
+ const txValidatorForTxCollection = createTxValidatorForReqResponseReceivedTxs(proofVerifier, config);
128
153
  const nodeSources = [
129
- ...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, config),
130
- ...(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
+ ),
131
158
  ...(deps.txCollectionNodeSources ?? []),
132
159
  ];
133
160
  if (nodeSources.length > 0) {
@@ -139,6 +166,7 @@ export async function createP2PClient(
139
166
  const fileStoreSources = await createFileStoreTxSources(
140
167
  config.txCollectionFileStoreUrls,
141
168
  txFileStoreBasePath,
169
+ txValidatorForTxCollection,
142
170
  logger.createChild('file-store-tx-source'),
143
171
  telemetry,
144
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,
@@ -257,7 +257,11 @@ export class P2PClient extends WithTracer implements P2P {
257
257
  });
258
258
  }
259
259
 
260
- 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();
261
265
  await this.txCollection.start();
262
266
  this.txFileStore?.start();
263
267
 
@@ -319,7 +323,11 @@ export class P2PClient extends WithTracer implements P2P {
319
323
  /** Triggers a sync to the archiver. Used for testing. */
320
324
  public async sync() {
321
325
  this.initBlockStream();
322
- 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();
323
331
  }
324
332
 
325
333
  @trackSpan('p2pClient.broadcastProposal', async proposal => ({
@@ -357,6 +365,8 @@ export class P2PClient extends WithTracer implements P2P {
357
365
  // Store our own last-block proposal so we can respond to req/resp requests for it.
358
366
  await this.attestationPool.tryAddBlockProposal(blockProposal);
359
367
  }
368
+ // Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
369
+ await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
360
370
  return this.p2pService.propagate(proposal);
361
371
  }
362
372
 
@@ -388,8 +398,12 @@ export class P2PClient extends WithTracer implements P2P {
388
398
  this.p2pService.registerBlockReceivedCallback(handler);
389
399
  }
390
400
 
391
- public registerCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
392
- 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);
393
407
  }
394
408
 
395
409
  public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
@@ -669,31 +683,50 @@ export class P2PClient extends WithTracer implements P2P {
669
683
  }
670
684
 
671
685
  /**
672
- * Returns true if the prune crossed a checkpoint boundary.
673
- * If the old and new checkpoint numbers are the same, the prune is within a single checkpoint.
674
- * 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.
675
688
  */
676
689
  private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
677
690
  const tips = await this.l2Tips.getL2Tips();
678
691
  const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
679
- if (oldCheckpointNumber <= CheckpointNumber.ZERO) {
692
+ if (oldCheckpointNumber <= CheckpointNumber.INITIAL) {
680
693
  return false;
681
694
  }
682
- const isEpochPrune = oldCheckpointNumber !== newCheckpoint.number;
683
- this.log.info(
684
- `Detected epoch prune: ${isEpochPrune}. Old checkpoint: ${oldCheckpointNumber}, new checkpoint: ${newCheckpoint.number}`,
685
- );
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
+ }
686
708
  return isEpochPrune;
687
709
  }
688
710
 
689
711
  /** Checks if the slot has changed and calls prepareForSlot if so. */
690
712
  private async maybeCallPrepareForSlot(): Promise<void> {
691
- const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
692
- 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) {
693
726
  return;
694
727
  }
695
- this.lastSlotProcessed = currentSlot;
696
- await this.txPool.prepareForSlot(currentSlot);
728
+ this.lastSlotProcessed = slot;
729
+ await this.txPool.prepareForSlot(slot);
697
730
  }
698
731
 
699
732
  private async startServiceIfSynched() {
@@ -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
@@ -39,10 +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
+ > {
43
50
  /** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
44
51
  validateMaxTxsPerBlock?: number;
45
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
+
46
62
  /** A flag dictating whether the P2P subsystem should be enabled. */
47
63
  p2pEnabled: boolean;
48
64
 
@@ -61,6 +77,9 @@ export interface P2PConfig
61
77
  /** The frequency in which to check for new peers. */
62
78
  peerCheckIntervalMS: number;
63
79
 
80
+ /** How long to ban a peer after it fails MAX_DIAL_ATTEMPTS dials. */
81
+ peerFailedBanTimeMs: number;
82
+
64
83
  /** Size of queue of L2 blocks to store. */
65
84
  l2QueueSize: number;
66
85
 
@@ -206,7 +225,23 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
206
225
  env: 'VALIDATOR_MAX_TX_PER_BLOCK',
207
226
  description:
208
227
  'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
209
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
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),
210
245
  },
211
246
  p2pEnabled: {
212
247
  env: 'P2P_ENABLED',
@@ -238,6 +273,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
238
273
  description: 'The frequency in which to check for new peers.',
239
274
  ...numberConfigHelper(30_000),
240
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
+ },
241
281
  l2QueueSize: {
242
282
  env: 'P2P_L2_QUEUE_SIZE',
243
283
  description: 'Size of queue of L2 blocks to store.',
@@ -403,7 +443,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
403
443
  },
404
444
  p2pStoreMapSizeKb: {
405
445
  env: 'P2P_STORE_MAP_SIZE_KB',
406
- parseEnv: (val: string | undefined) => (val ? +val : undefined),
446
+ parseEnv: (val: string) => +val,
407
447
  description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
408
448
  },
409
449
  txPublicSetupAllowListExtend: {
@@ -462,6 +502,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
462
502
  description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
463
503
  ...booleanConfigHelper(false),
464
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
+ },
465
510
  fishermanMode: {
466
511
  env: 'FISHERMAN_MODE',
467
512
  description:
@@ -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';
@@ -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<
@@ -154,14 +154,16 @@ export class AttestationPool {
154
154
  /** Maximum indexWithinCheckpoint value (2^10 - 1 = 1023). */
155
155
  private static readonly MAX_INDEX = (1 << AttestationPool.INDEX_BITS) - 1;
156
156
 
157
- /** 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). */
158
160
  private getBlockPositionKey(slot: number, indexWithinCheckpoint: number): number {
159
161
  if (indexWithinCheckpoint > AttestationPool.MAX_INDEX) {
160
162
  throw new Error(
161
163
  `Value for indexWithinCheckpoint ${indexWithinCheckpoint} exceeds maximum ${AttestationPool.MAX_INDEX}`,
162
164
  );
163
165
  }
164
- return (slot << AttestationPool.INDEX_BITS) | indexWithinCheckpoint;
166
+ return slot * (1 << AttestationPool.INDEX_BITS) + indexWithinCheckpoint;
165
167
  }
166
168
 
167
169
  /**
@@ -278,7 +280,7 @@ export class AttestationPool {
278
280
  * @returns Result indicating whether the proposal was added and duplicate detection info
279
281
  */
280
282
  public async tryAddCheckpointProposal(proposal: CheckpointProposalCore): Promise<TryAddResult> {
281
- return await this.store.transactionAsync(async () => {
283
+ const result = await this.store.transactionAsync(async () => {
282
284
  const proposalId = proposal.archive.toString();
283
285
 
284
286
  // Check if already exists
@@ -304,6 +306,8 @@ export class AttestationPool {
304
306
 
305
307
  return { added: true, alreadyExists: false, count: count + 1 };
306
308
  });
309
+
310
+ return result;
307
311
  }
308
312
 
309
313
  /** Internal method - must be called within a transaction. */
@@ -345,7 +349,7 @@ export class AttestationPool {
345
349
  await this.store.transactionAsync(async () => {
346
350
  for (const attestation of attestations) {
347
351
  const slotNumber = attestation.payload.header.slotNumber;
348
- const proposalId = attestation.archive;
352
+ const proposalId = attestation.archive.toString();
349
353
  const sender = attestation.getSender();
350
354
 
351
355
  // Skip attestations with invalid signatures
@@ -452,7 +456,7 @@ export class AttestationPool {
452
456
 
453
457
  // Delete block proposals for slots < oldestSlot, using blockProposalsForSlotAndIndex as index
454
458
  // Key format: (slot << INDEX_BITS) | indexWithinCheckpoint
455
- const blockPositionEndKey = oldestSlot << AttestationPool.INDEX_BITS;
459
+ const blockPositionEndKey = oldestSlot * (1 << AttestationPool.INDEX_BITS);
456
460
  for await (const positionKey of this.blockProposalsForSlotAndIndex.keysAsync({ end: blockPositionEndKey })) {
457
461
  const proposalIds = await toArray(this.blockProposalsForSlotAndIndex.getValuesAsync(positionKey));
458
462
  for (const proposalId of proposalIds) {
@@ -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 () => {
@@ -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';
@@ -29,7 +29,8 @@ export class FeePayerBalanceEvictionRule implements EvictionRule {
29
29
 
30
30
  if (context.event === EvictionEvent.BLOCK_MINED) {
31
31
  const blockNumber = context.block.getBlockNumber();
32
- await this.worldState.syncImmediate(blockNumber);
32
+ const blockHash = await context.block.hash();
33
+ await this.worldState.syncImmediate(blockNumber, blockHash);
33
34
  return await this.evictForFeePayers(context.feePayers, this.worldState.getSnapshot(blockNumber), pool);
34
35
  }
35
36
 
@@ -1,5 +1,5 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
1
  import { createLogger } from '@aztec/foundation/log';
2
+ import { BlockHash } from '@aztec/stdlib/block';
3
3
  import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
4
4
  import { MerkleTreeId } from '@aztec/stdlib/trees';
5
5
 
@@ -33,14 +33,14 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
33
33
  const pendingTxs = pool.getPendingTxs();
34
34
 
35
35
  // Deduplicate block hashes to reduce redundant DB lookups
36
- const uniqueBlockHashes = new Map<string, Fr>();
36
+ const uniqueBlockHashes = new Map<string, BlockHash>();
37
37
  const txsByBlockHash = new Map<string, string[]>();
38
38
 
39
39
  for (const meta of pendingTxs) {
40
40
  const blockHashStr = meta.anchorBlockHeaderHash;
41
41
  if (!txsByBlockHash.has(blockHashStr)) {
42
42
  txsByBlockHash.set(blockHashStr, []);
43
- uniqueBlockHashes.set(blockHashStr, Fr.fromHexString(blockHashStr));
43
+ uniqueBlockHashes.set(blockHashStr, BlockHash.fromString(blockHashStr));
44
44
  }
45
45
  txsByBlockHash.get(blockHashStr)!.push(meta.txHash);
46
46
  }
@@ -72,6 +72,8 @@ export type TxPoolV2Dependencies = {
72
72
  worldStateSynchronizer: WorldStateSynchronizer;
73
73
  /** Factory that creates a validator for re-validating pool transactions using metadata */
74
74
  createTxValidator: () => Promise<TxValidator<TxMetaData>>;
75
+ /** Checks whether a tx's setup-phase calls are on the allow list. Precomputed at receipt time. */
76
+ checkAllowedSetupCalls: (tx: Tx) => Promise<boolean>;
75
77
  };
76
78
 
77
79
  /**
@@ -158,10 +160,10 @@ export interface TxPoolV2 extends TypedEventEmitter<TxPoolV2Events> {
158
160
  handleMinedBlock(block: L2Block): Promise<void>;
159
161
 
160
162
  /**
161
- * Prepares the pool for a new slot.
162
- * Unprotects transactions from earlier slots and validates them before
163
- * returning to pending state.
164
- * @param slotNumber - The slot number to prepare for
163
+ * Prepares the pool for a new slot by unprotecting transactions from earlier
164
+ * slots and re-validating them before returning to pending state.
165
+ * @param slotNumber - The pipeline slot we are building for (i.e. the slot
166
+ * the resulting blocks will target on L1).
165
167
  */
166
168
  prepareForSlot(slotNumber: SlotNumber): Promise<void>;
167
169