@aztec/p2p 0.0.1-commit.4d79d1f2d → 0.0.1-commit.5358163d3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/dest/client/factory.d.ts +6 -6
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +23 -30
  4. package/dest/client/interface.d.ts +14 -19
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +9 -18
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +52 -72
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
  10. package/dest/config.d.ts +20 -14
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +30 -35
  13. package/dest/errors/tx-pool.error.d.ts +8 -0
  14. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  15. package/dest/errors/tx-pool.error.js +9 -0
  16. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -2
  17. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  18. package/dest/mem_pools/attestation_pool/attestation_pool.js +10 -1
  19. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  20. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  22. package/dest/mem_pools/instrumentation.d.ts +4 -2
  23. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  24. package/dest/mem_pools/instrumentation.js +16 -14
  25. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  26. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +30 -13
  27. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
  28. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
  29. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
  30. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
  31. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
  32. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  33. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  34. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -2
  35. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
  36. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  37. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
  38. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
  39. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
  41. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +48 -5
  42. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
  44. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
  45. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
  46. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
  47. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  48. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
  49. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
  50. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
  51. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +14 -4
  52. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
  53. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
  54. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
  55. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
  56. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  57. package/dest/mem_pools/tx_pool_v2/index.js +1 -1
  58. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  59. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  60. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  61. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +20 -6
  62. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  63. package/dest/mem_pools/tx_pool_v2/interfaces.js +4 -1
  64. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +34 -8
  65. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  66. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +76 -10
  67. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
  68. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  69. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +36 -14
  70. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
  71. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  72. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +14 -6
  73. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -5
  74. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  75. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +299 -142
  76. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +2 -1
  77. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  78. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +2 -1
  79. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  80. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -1
  81. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  82. package/dest/msg_validators/proposal_validator/proposal_validator.js +10 -0
  83. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +2 -1
  84. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
  85. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +166 -0
  86. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
  87. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  88. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
  89. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  90. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  91. package/dest/msg_validators/tx_validator/allowed_public_setup.js +25 -10
  92. package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
  93. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  94. package/dest/msg_validators/tx_validator/factory.js +219 -58
  95. package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
  96. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  97. package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
  98. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  99. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  100. package/dest/msg_validators/tx_validator/index.js +1 -0
  101. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  102. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  103. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  104. package/dest/msg_validators/tx_validator/phases_validator.d.ts +2 -2
  105. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  106. package/dest/msg_validators/tx_validator/phases_validator.js +25 -24
  107. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
  108. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  109. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  110. package/dest/services/dummy_service.d.ts +4 -4
  111. package/dest/services/dummy_service.d.ts.map +1 -1
  112. package/dest/services/dummy_service.js +4 -4
  113. package/dest/services/encoding.d.ts +2 -2
  114. package/dest/services/encoding.d.ts.map +1 -1
  115. package/dest/services/encoding.js +9 -8
  116. package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
  117. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  118. package/dest/services/gossipsub/topic_score_params.js +32 -10
  119. package/dest/services/libp2p/libp2p_service.d.ts +16 -13
  120. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  121. package/dest/services/libp2p/libp2p_service.js +77 -84
  122. package/dest/services/peer-manager/metrics.d.ts +3 -1
  123. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  124. package/dest/services/peer-manager/metrics.js +6 -0
  125. package/dest/services/peer-manager/peer_manager.d.ts +1 -1
  126. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  127. package/dest/services/peer-manager/peer_manager.js +2 -1
  128. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
  129. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  130. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +19 -46
  131. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
  132. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  133. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
  134. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  135. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
  136. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
  137. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  138. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
  139. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
  140. package/dest/services/reqresp/reqresp.d.ts +1 -1
  141. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  142. package/dest/services/reqresp/reqresp.js +2 -1
  143. package/dest/services/service.d.ts +5 -3
  144. package/dest/services/service.d.ts.map +1 -1
  145. package/dest/services/tx_collection/config.d.ts +13 -1
  146. package/dest/services/tx_collection/config.d.ts.map +1 -1
  147. package/dest/services/tx_collection/config.js +30 -0
  148. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
  149. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  150. package/dest/services/tx_collection/fast_tx_collection.js +39 -33
  151. package/dest/services/tx_collection/file_store_tx_collection.d.ts +38 -29
  152. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
  153. package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
  154. package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
  155. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  156. package/dest/services/tx_collection/file_store_tx_source.js +49 -16
  157. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  158. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  159. package/dest/services/tx_collection/instrumentation.js +2 -1
  160. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  161. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  162. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  163. package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
  164. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  165. package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
  166. package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
  167. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  168. package/dest/services/tx_collection/slow_tx_collection.js +17 -12
  169. package/dest/services/tx_collection/tx_collection.d.ts +9 -6
  170. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  171. package/dest/services/tx_collection/tx_collection.js +26 -10
  172. package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
  173. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  174. package/dest/services/tx_collection/tx_collection_sink.js +13 -22
  175. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  176. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  177. package/dest/services/tx_collection/tx_source.js +19 -2
  178. package/dest/services/tx_file_store/tx_file_store.d.ts +3 -2
  179. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  180. package/dest/services/tx_file_store/tx_file_store.js +9 -6
  181. package/dest/services/tx_provider.d.ts +3 -3
  182. package/dest/services/tx_provider.d.ts.map +1 -1
  183. package/dest/services/tx_provider.js +4 -4
  184. package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
  185. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  186. package/dest/test-helpers/make-test-p2p-clients.js +1 -2
  187. package/dest/test-helpers/mock-pubsub.d.ts +4 -4
  188. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  189. package/dest/test-helpers/mock-pubsub.js +8 -2
  190. package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
  191. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  192. package/dest/test-helpers/reqresp-nodes.js +2 -2
  193. package/dest/test-helpers/testbench-utils.d.ts +8 -3
  194. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  195. package/dest/test-helpers/testbench-utils.js +7 -1
  196. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  197. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  198. package/dest/testbench/p2p_client_testbench_worker.js +13 -13
  199. package/dest/util.d.ts +2 -2
  200. package/dest/util.d.ts.map +1 -1
  201. package/package.json +14 -14
  202. package/src/client/factory.ts +39 -48
  203. package/src/client/interface.ts +17 -20
  204. package/src/client/p2p_client.ts +60 -104
  205. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -10
  206. package/src/config.ts +44 -42
  207. package/src/errors/tx-pool.error.ts +12 -0
  208. package/src/mem_pools/attestation_pool/attestation_pool.ts +13 -4
  209. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  210. package/src/mem_pools/instrumentation.ts +17 -13
  211. package/src/mem_pools/tx_pool/README.md +1 -1
  212. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  213. package/src/mem_pools/tx_pool_v2/README.md +43 -27
  214. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
  215. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
  216. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -2
  217. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
  218. package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
  219. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +49 -4
  220. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
  221. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
  222. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
  223. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +24 -6
  224. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +3 -3
  225. package/src/mem_pools/tx_pool_v2/index.ts +1 -1
  226. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  227. package/src/mem_pools/tx_pool_v2/interfaces.ts +21 -6
  228. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +107 -17
  229. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -16
  230. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +21 -7
  231. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +331 -138
  232. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +1 -1
  233. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +1 -1
  234. package/src/msg_validators/proposal_validator/proposal_validator.ts +15 -1
  235. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +144 -1
  236. package/src/msg_validators/tx_validator/README.md +115 -0
  237. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
  238. package/src/msg_validators/tx_validator/allowed_public_setup.ts +27 -13
  239. package/src/msg_validators/tx_validator/factory.ts +353 -77
  240. package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
  241. package/src/msg_validators/tx_validator/index.ts +1 -0
  242. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  243. package/src/msg_validators/tx_validator/phases_validator.ts +25 -29
  244. package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
  245. package/src/services/dummy_service.ts +6 -6
  246. package/src/services/encoding.ts +7 -7
  247. package/src/services/gossipsub/README.md +29 -14
  248. package/src/services/gossipsub/topic_score_params.ts +49 -13
  249. package/src/services/libp2p/libp2p_service.ts +89 -92
  250. package/src/services/peer-manager/metrics.ts +7 -0
  251. package/src/services/peer-manager/peer_manager.ts +2 -1
  252. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +20 -48
  253. package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
  254. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
  255. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
  256. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
  257. package/src/services/reqresp/reqresp.ts +3 -1
  258. package/src/services/service.ts +11 -2
  259. package/src/services/tx_collection/config.ts +42 -0
  260. package/src/services/tx_collection/fast_tx_collection.ts +51 -30
  261. package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
  262. package/src/services/tx_collection/file_store_tx_source.ts +64 -17
  263. package/src/services/tx_collection/instrumentation.ts +7 -1
  264. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  265. package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
  266. package/src/services/tx_collection/slow_tx_collection.ts +17 -13
  267. package/src/services/tx_collection/tx_collection.ts +45 -14
  268. package/src/services/tx_collection/tx_collection_sink.ts +15 -29
  269. package/src/services/tx_collection/tx_source.ts +22 -3
  270. package/src/services/tx_file_store/tx_file_store.ts +6 -4
  271. package/src/services/tx_provider.ts +2 -2
  272. package/src/test-helpers/make-test-p2p-clients.ts +0 -2
  273. package/src/test-helpers/mock-pubsub.ts +13 -6
  274. package/src/test-helpers/reqresp-nodes.ts +2 -5
  275. package/src/test-helpers/testbench-utils.ts +11 -3
  276. package/src/testbench/p2p_client_testbench_worker.ts +22 -19
  277. package/src/util.ts +7 -1
package/src/config.ts CHANGED
@@ -38,7 +38,7 @@ export interface P2PConfig
38
38
  ChainConfig,
39
39
  TxCollectionConfig,
40
40
  TxFileStoreConfig,
41
- Pick<SequencerConfig, 'blockDurationMs'> {
41
+ Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'> {
42
42
  /** A flag dictating whether the P2P subsystem should be enabled. */
43
43
  p2pEnabled: boolean;
44
44
 
@@ -150,8 +150,8 @@ export interface P2PConfig
150
150
  /** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
151
151
  p2pStoreMapSizeKb?: number;
152
152
 
153
- /** Which calls are allowed in the public setup phase of a tx. */
154
- txPublicSetupAllowList: AllowedElement[];
153
+ /** Additional entries to extend the default setup allow list. */
154
+ txPublicSetupAllowListExtend: AllowedElement[];
155
155
 
156
156
  /** The maximum number of pending txs before evicting lower priority txs. */
157
157
  maxPendingTxCount: number;
@@ -173,10 +173,7 @@ export interface P2PConfig
173
173
  /** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
174
174
  disableTransactions: boolean;
175
175
 
176
- /** True to simulate discarding transactions. - For testing purposes only*/
177
- dropTransactions: boolean;
178
-
179
- /** The probability that a transaction is discarded. - For testing purposes only */
176
+ /** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
180
177
  dropTransactionsProbability: number;
181
178
 
182
179
  /** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
@@ -190,6 +187,9 @@ export interface P2PConfig
190
187
 
191
188
  /** Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only). */
192
189
  broadcastEquivocatedProposals?: boolean;
190
+
191
+ /** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
192
+ minTxPoolAgeMs: number;
193
193
  }
194
194
 
195
195
  export const DEFAULT_P2P_PORT = 40400;
@@ -393,12 +393,13 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
393
393
  parseEnv: (val: string | undefined) => (val ? +val : undefined),
394
394
  description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
395
395
  },
396
- txPublicSetupAllowList: {
396
+ txPublicSetupAllowListExtend: {
397
397
  env: 'TX_PUBLIC_SETUP_ALLOWLIST',
398
398
  parseEnv: (val: string) => parseAllowList(val),
399
- description: 'The list of functions calls allowed to run in setup',
399
+ description:
400
+ 'Additional entries to extend the default setup allow list. Format: I:address:selector,C:classId:selector',
400
401
  printDefault: () =>
401
- 'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
402
+ 'Default: AuthRegistry._set_authorized, FeeJuice._increase_public_balance, Token._increase_public_balance, Token.transfer_in_public',
402
403
  },
403
404
  maxPendingTxCount: {
404
405
  env: 'P2P_MAX_PENDING_TX_COUNT',
@@ -427,11 +428,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
427
428
  description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
428
429
  ...numberConfigHelper(3),
429
430
  },
430
- dropTransactions: {
431
- env: 'P2P_DROP_TX',
432
- description: 'True to simulate discarding transactions. - For testing purposes only',
433
- ...booleanConfigHelper(false),
434
- },
435
431
  dropTransactionsProbability: {
436
432
  env: 'P2P_DROP_TX_CHANCE',
437
433
  description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
@@ -464,6 +460,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
464
460
  'Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only).',
465
461
  ...booleanConfigHelper(false),
466
462
  },
463
+ minTxPoolAgeMs: {
464
+ env: 'P2P_MIN_TX_POOL_AGE_MS',
465
+ description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
466
+ ...numberConfigHelper(2_000),
467
+ },
467
468
  ...sharedSequencerConfigMappings,
468
469
  ...p2pReqRespConfigMappings,
469
470
  ...batchTxRequesterConfigMappings,
@@ -523,11 +524,9 @@ export const bootnodeConfigMappings = pickConfigMappings(
523
524
 
524
525
  /**
525
526
  * Parses a string to a list of allowed elements.
526
- * Each encoded is expected to be of one of the following formats
527
- * `I:${address}`
528
- * `I:${address}:${selector}`
529
- * `C:${classId}`
530
- * `C:${classId}:${selector}`
527
+ * Each entry is expected to be of one of the following formats:
528
+ * `I:${address}:${selector}` — instance (contract address) with function selector
529
+ * `C:${classId}:${selector}` — class with function selector
531
530
  *
532
531
  * @param value The string to parse
533
532
  * @returns A list of allowed elements
@@ -540,31 +539,34 @@ export function parseAllowList(value: string): AllowedElement[] {
540
539
  }
541
540
 
542
541
  for (const val of value.split(',')) {
543
- const [typeString, identifierString, selectorString] = val.split(':');
544
- const selector = selectorString !== undefined ? FunctionSelector.fromString(selectorString) : undefined;
542
+ const trimmed = val.trim();
543
+ if (!trimmed) {
544
+ continue;
545
+ }
546
+ const [typeString, identifierString, selectorString] = trimmed.split(':');
547
+
548
+ if (!selectorString) {
549
+ throw new Error(
550
+ `Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
551
+ );
552
+ }
553
+
554
+ const selector = FunctionSelector.fromString(selectorString);
545
555
 
546
556
  if (typeString === 'I') {
547
- if (selector) {
548
- entries.push({
549
- address: AztecAddress.fromString(identifierString),
550
- selector,
551
- });
552
- } else {
553
- entries.push({
554
- address: AztecAddress.fromString(identifierString),
555
- });
556
- }
557
+ entries.push({
558
+ address: AztecAddress.fromString(identifierString),
559
+ selector,
560
+ });
557
561
  } else if (typeString === 'C') {
558
- if (selector) {
559
- entries.push({
560
- classId: Fr.fromHexString(identifierString),
561
- selector,
562
- });
563
- } else {
564
- entries.push({
565
- classId: Fr.fromHexString(identifierString),
566
- });
567
- }
562
+ entries.push({
563
+ classId: Fr.fromHexString(identifierString),
564
+ selector,
565
+ });
566
+ } else {
567
+ throw new Error(
568
+ `Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
569
+ );
568
570
  }
569
571
  }
570
572
 
@@ -0,0 +1,12 @@
1
+ import type { TxPoolRejectionError } from '../mem_pools/tx_pool_v2/eviction/interfaces.js';
2
+
3
+ /** Error thrown when a transaction is not added to the mempool. */
4
+ export class TxPoolError extends Error {
5
+ public readonly data: TxPoolRejectionError;
6
+
7
+ constructor(public readonly reason: TxPoolRejectionError) {
8
+ super(reason.message);
9
+ this.name = 'TxPoolError';
10
+ this.data = reason;
11
+ }
12
+ }
@@ -43,6 +43,7 @@ export type AttestationPoolApi = Pick<
43
43
  | 'deleteOlderThan'
44
44
  | 'getCheckpointAttestationsForSlot'
45
45
  | 'getCheckpointAttestationsForSlotAndProposal'
46
+ | 'hasBlockProposalsForSlot'
46
47
  | 'isEmpty'
47
48
  >;
48
49
 
@@ -254,6 +255,13 @@ export class AttestationPool {
254
255
  return undefined;
255
256
  }
256
257
 
258
+ /** Checks if any block proposals exist for a given slot (at index 0). */
259
+ public async hasBlockProposalsForSlot(slot: SlotNumber): Promise<boolean> {
260
+ const positionKey = this.getBlockPositionKey(slot, 0);
261
+ const count = await this.blockProposalsForSlotAndIndex.getValueCountAsync(positionKey);
262
+ return count > 0;
263
+ }
264
+
257
265
  /**
258
266
  * Attempts to add a checkpoint proposal to the pool.
259
267
  *
@@ -351,11 +359,10 @@ export class AttestationPool {
351
359
  }
352
360
 
353
361
  const address = sender.toString();
362
+ const ownKey = this.getAttestationKey(slotNumber, proposalId, address);
354
363
 
355
- await this.checkpointAttestations.set(
356
- this.getAttestationKey(slotNumber, proposalId, address),
357
- attestation.toBuffer(),
358
- );
364
+ await this.checkpointAttestations.set(ownKey, attestation.toBuffer());
365
+ this.metrics.trackMempoolItemAdded(ownKey);
359
366
 
360
367
  this.log.debug(`Added own checkpoint attestation for slot ${slotNumber} from ${address}`, {
361
368
  signature: attestation.signature.toString(),
@@ -421,6 +428,7 @@ export class AttestationPool {
421
428
  const attestationEndKey = new Fr(oldestSlot).toString();
422
429
  for await (const key of this.checkpointAttestations.keysAsync({ end: attestationEndKey })) {
423
430
  await this.checkpointAttestations.delete(key);
431
+ this.metrics.trackMempoolItemRemoved(key);
424
432
  numberOfAttestations++;
425
433
  }
426
434
 
@@ -518,6 +526,7 @@ export class AttestationPool {
518
526
 
519
527
  // Add the attestation
520
528
  await this.checkpointAttestations.set(key, attestation.toBuffer());
529
+ this.metrics.trackMempoolItemAdded(key);
521
530
 
522
531
  // Track this attestation in the per-signer-per-slot index for duplicate detection
523
532
  const slotSignerKey = this.getSlotSignerKey(slotNumber, signerAddress);
@@ -34,9 +34,10 @@ export const mockCheckpointAttestation = (
34
34
  slot: number = 0,
35
35
  archive: Fr = Fr.random(),
36
36
  header?: CheckpointHeader,
37
+ feeAssetPriceModifier: bigint = 0n,
37
38
  ): CheckpointAttestation => {
38
39
  header = header ?? CheckpointHeader.random({ slotNumber: SlotNumber(slot) });
39
- const payload = new ConsensusPayload(header, archive);
40
+ const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
40
41
 
41
42
  const attestationHash = getHashedSignaturePayloadEthSignedMessage(
42
43
  payload,
@@ -73,7 +73,7 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
73
73
  private defaultAttributes;
74
74
  private meter: Meter;
75
75
 
76
- private txAddedTimestamp: Map<bigint, number> = new Map<bigint, number>();
76
+ private mempoolItemAddedTimestamp: Map<bigint | string, number> = new Map<bigint | string, number>();
77
77
 
78
78
  constructor(
79
79
  telemetry: TelemetryClient,
@@ -114,22 +114,26 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
114
114
  }
115
115
 
116
116
  public transactionsAdded(transactions: Tx[]) {
117
- const timestamp = Date.now();
118
- for (const transaction of transactions) {
119
- this.txAddedTimestamp.set(transaction.txHash.toBigInt(), timestamp);
120
- }
117
+ transactions.forEach(tx => this.trackMempoolItemAdded(tx.txHash.toBigInt()));
121
118
  }
122
119
 
123
120
  public transactionsRemoved(hashes: Iterable<bigint> | Iterable<string>) {
124
- const timestamp = Date.now();
125
121
  for (const hash of hashes) {
126
- const key = BigInt(hash);
127
- const addedAt = this.txAddedTimestamp.get(key);
128
- if (addedAt !== undefined) {
129
- this.txAddedTimestamp.delete(key);
130
- if (addedAt < timestamp) {
131
- this.minedDelay.record(timestamp - addedAt);
132
- }
122
+ this.trackMempoolItemRemoved(BigInt(hash));
123
+ }
124
+ }
125
+
126
+ public trackMempoolItemAdded(key: bigint | string): void {
127
+ this.mempoolItemAddedTimestamp.set(key, Date.now());
128
+ }
129
+
130
+ public trackMempoolItemRemoved(key: bigint | string): void {
131
+ const timestamp = Date.now();
132
+ const addedAt = this.mempoolItemAddedTimestamp.get(key);
133
+ if (addedAt !== undefined) {
134
+ this.mempoolItemAddedTimestamp.delete(key);
135
+ if (addedAt < timestamp) {
136
+ this.minedDelay.record(timestamp - addedAt);
133
137
  }
134
138
  }
135
139
  }
@@ -213,7 +213,7 @@ The [`EvictionManager`](eviction/eviction_manager.ts) coordinates eviction by:
213
213
  Evicts transactions that become invalid after a block is mined:
214
214
 
215
215
  - Duplicate nullifiers: Txs with nullifiers already included in the mined block
216
- - Expired transactions: Txs with `includeByTimestamp` ≤ mined block timestamp
216
+ - Expired transactions: Txs with `expirationTimestamp` ≤ mined block timestamp
217
217
 
218
218
  #### 2. `InvalidTxsAfterReorgRule`
219
219
 
@@ -68,10 +68,10 @@ export class InvalidTxsAfterMiningRule implements EvictionRule {
68
68
  }
69
69
 
70
70
  // Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
71
- const includeByTimestamp = tx.data.includeByTimestamp;
72
- if (includeByTimestamp <= timestamp) {
71
+ const expirationTimestamp = tx.data.expirationTimestamp;
72
+ if (expirationTimestamp <= timestamp) {
73
73
  this.log.verbose(
74
- `Evicting tx ${txHash} from pool due to the tx being expired (includeByTimestamp: ${includeByTimestamp}, mined block timestamp: ${timestamp})`,
74
+ `Evicting tx ${txHash} from pool due to the tx being expired (expirationTimestamp: ${expirationTimestamp}, mined block timestamp: ${timestamp})`,
75
75
  );
76
76
  txsToEvict.push(txHash);
77
77
  continue;
@@ -30,19 +30,20 @@ TxPoolV2 manages transactions through a state machine with clear transitions:
30
30
  └─────────────────────────────────────┘ (reorg)
31
31
  │ │
32
32
  │ handleFinalizedBlock() │ eviction after reorg
33
+ │ / eviction / failed exec │ (validation failure)
33
34
  ▼ ▼
34
35
  ┌─────────────────────────────────────┐ ┌─────────────────────────────────────┐
35
- DELETED │ │ SOFT-DELETED
36
- (hard-deleted or archived) │ │ (kept in DB for debugging)
36
+ SLOT-SOFT-DELETED │ │ PRUNE-SOFT-DELETED
37
+ (kept in DB until next slot) │ │ (kept in DB until finalized)
38
+ └─────────────────────────────────────┘ └─────────────────────────────────────┘
39
+ │ │
40
+ │ prepareForSlot() │ handleFinalizedBlock()
41
+ │ (slot advanced) │ (mined block finalized)
42
+ ▼ ▼
43
+ ┌─────────────────────────────────────┐ ┌─────────────────────────────────────┐
44
+ │ HARD-DELETED │ │ HARD-DELETED │
45
+ │ (permanently removed from DB) │ │ (permanently removed from DB) │
37
46
  └─────────────────────────────────────┘ └─────────────────────────────────────┘
38
-
39
- │ handleFinalizedBlock()
40
- │ (mined block finalized)
41
-
42
- ┌─────────────────────────────────────┐
43
- │ HARD-DELETED │
44
- │ (permanently removed from DB) │
45
- └─────────────────────────────────────┘
46
47
  ```
47
48
 
48
49
  ## Key Components
@@ -62,13 +63,11 @@ Core implementation containing:
62
63
 
63
64
  ### DeletedPool (`deleted_pool.ts`)
64
65
 
65
- Manages soft deletion of transactions from pruned blocks:
66
- - When a reorg (chain prune) occurs, transactions from pruned blocks are tracked with their original mined block number
67
- - When these transactions are later evicted (e.g., failed validation, nullifier conflict), they are "soft-deleted" instead of removed
68
- - Soft-deleted transactions remain in the database for debugging and potential resubmission
69
- - When the original mined block is finalized on the new chain, soft-deleted transactions are permanently hard-deleted
66
+ Manages all transaction deletions in the pool with two soft-deletion mechanisms:
67
+ - **Slot-based**: Non-pruned txs are kept in DB until the next slot, allowing other nodes to fetch them via reqresp
68
+ - **Prune-based**: Txs from pruned blocks are kept in DB until their original mined block is finalized
70
69
 
71
- This ensures transactions from reorged blocks are kept around until we're certain they won't be needed.
70
+ All deletions go through `DeletedPool.deleteTx()`, which routes to the appropriate path based on whether the tx is tracked as being from a pruned block.
72
71
 
73
72
  ### TxMetaData (`tx_metadata.ts`)
74
73
 
@@ -80,33 +79,46 @@ Lightweight metadata stored alongside each transaction:
80
79
  - `claimAmount`: Fee payer's claim from bridging
81
80
  - `feeLimit`: Maximum fee the tx can pay
82
81
  - `nullifiers`: For conflict detection
83
- - `includeByTimestamp`: Expiration timestamp
82
+ - `expirationTimestamp`: Expiration timestamp
84
83
  - `minedL2BlockId`: Set when mined (undefined otherwise)
85
84
 
86
85
  State is derived by TxPoolIndices:
87
86
  - `mined` if `minedL2BlockId` is set
88
87
  - `protected` if in protection map
89
- - `deleted` if soft-deleted (from a pruned block, evicted but kept in DB)
88
+ - `deleted` if soft-deleted (slot-based or prune-based, evicted but kept in DB)
90
89
  - `pending` otherwise
91
90
 
92
91
  ## Soft Deletion
93
92
 
94
- When a chain reorganization occurs, transactions that were mined in pruned blocks are handled specially:
93
+ Deleted transactions are kept in the database for a grace period before being permanently removed. There are two soft-deletion mechanisms:
94
+
95
+ ### Slot-Based Soft Deletion
96
+
97
+ When a transaction is deleted from the pool (eviction, validation failure, failed execution) and is **not** from a pruned block, it is "slot-soft-deleted":
98
+
99
+ 1. **Soft Delete**: The tx is removed from indices but kept in the database, tagged with the current slot number
100
+ 2. **Retrieval**: Slot-soft-deleted txs can still be retrieved via `getTxByHash` and return status `'deleted'` from `getTxStatus`
101
+ 3. **Hard Delete**: When `prepareForSlot` advances to a new slot, txs deleted in earlier slots are permanently removed
102
+ 4. **Re-addition**: If a slot-soft-deleted tx is re-added to the pool, the slot-deleted tracking is cleared
103
+
104
+ This allows other nodes to still fetch recently-deleted transactions via reqresp during the current slot.
105
+
106
+ ### Prune-Based Soft Deletion
107
+
108
+ When a chain reorganization occurs, transactions that were mined in pruned blocks are handled with longer retention:
95
109
 
96
110
  1. **Tracking**: When `handlePrunedBlocks` is called, all un-mined transactions are tracked by their original mined block number
97
- 2. **Soft Delete**: If these transactions are later evicted (failed validation, nullifier conflict, etc.), they are "soft-deleted" - removed from indices but kept in the database
98
- 3. **Retrieval**: Soft-deleted transactions can still be retrieved via `getTxByHash` and `hasTxs`, and return status `'deleted'` from `getTxStatus`
111
+ 2. **Soft Delete**: If these transactions are later evicted (failed validation, nullifier conflict, etc.), they are "prune-soft-deleted" - removed from indices but kept in the database
112
+ 3. **Retrieval**: Prune-soft-deleted txs can still be retrieved via `getTxByHash` and return status `'deleted'` from `getTxStatus`
99
113
  4. **Hard Delete**: When `handleFinalizedBlock` is called and the finalized block number reaches or exceeds the transaction's original mined block, the transaction is permanently removed
114
+ 5. **Re-addition**: If a prune-soft-deleted tx is re-added, the `softDeleted` flag is reset to `false` but the prune tracking is preserved, so a subsequent deletion still uses the prune path
100
115
 
101
- This design allows:
102
- - Debugging reorg scenarios by keeping transaction data available
103
- - Potential resubmission of transactions that failed validation after a reorg
104
- - Clean eventual cleanup once we're certain the transaction won't be needed
116
+ Prune-soft-deleted transactions are **not** affected by slot cleanup - they survive across slot boundaries until finalized.
105
117
 
106
- **Example scenario:**
118
+ **Prune example:**
107
119
  1. Tx mined at block 10
108
120
  2. Chain prunes to block 5 (tx becomes un-mined, tracked as minedAtBlock=10)
109
- 3. Tx fails validation and is soft-deleted
121
+ 3. Tx fails validation and is prune-soft-deleted
110
122
  4. Block 9 finalized → tx still in DB (minedAtBlock=10 > finalized=9)
111
123
  5. Block 10 finalized → tx hard-deleted (minedAtBlock=10 ≤ finalized=10)
112
124
 
@@ -117,6 +129,10 @@ If the tx is re-mined at a higher block before being soft-deleted:
117
129
  4. Block 10 finalized → tx still in DB
118
130
  5. Block 15 finalized → tx hard-deleted
119
131
 
132
+ ### Hydration
133
+
134
+ On node restart, slot-soft-deleted transactions are immediately hard-deleted (they are stale by definition). Prune-soft-deleted transactions are loaded from the database and tracked normally.
135
+
120
136
  ## Architecture: Pre-add vs Post-event Rules
121
137
 
122
138
  **Pre-add rules** (run during `addPendingTxs`):
@@ -1,6 +1,6 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
1
+ import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import type { Logger } from '@aztec/foundation/log';
3
- import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
3
+ import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSet } from '@aztec/kv-store';
4
4
 
5
5
  /**
6
6
  * State stored for each transaction from a pruned block.
@@ -39,15 +39,17 @@ function deserializeState(buffer: Buffer): DeletedTxState {
39
39
  * When a chain prune (reorg) happens, transactions from pruned blocks are tracked here.
40
40
  * This class is responsible for ALL deletion decisions:
41
41
  *
42
- * - Transactions from pruned blocks are "soft deleted" - removed from indices but kept
43
- * in the database for later re-execution
44
- * - Transactions NOT from pruned blocks are "hard deleted" - completely removed from DB
42
+ * - Transactions from pruned blocks are "prune-soft-deleted" - removed from indices but kept
43
+ * in the database for later re-execution until their mined block is finalized
44
+ * - Transactions NOT from pruned blocks are "slot-soft-deleted" - kept in the database
45
+ * until the next slot, so other nodes can still fetch them via reqresp
45
46
  *
46
- * When a block is finalized, soft-deleted transactions that were originally mined at or
47
- * before that block number are permanently (hard) deleted.
47
+ * When a block is finalized, prune-soft-deleted transactions that were originally mined at or
48
+ * before that block number are permanently (hard) deleted. Slot-soft-deleted transactions
49
+ * are hard-deleted when `prepareForSlot` advances to a new slot.
48
50
  */
49
51
  export class DeletedPool {
50
- /** Persisted map: txHash -> DeletedTxState (serialized) */
52
+ /** Persisted map: txHash -> DeletedTxState (serialized) - for prune-based soft deletions */
51
53
  #deletedTxsDB: AztecAsyncMap<string, Buffer>;
52
54
 
53
55
  /** Reference to the main txs database for hard deletion */
@@ -56,16 +58,27 @@ export class DeletedPool {
56
58
  /** In-memory state for transactions from pruned blocks */
57
59
  #state: Map<string, DeletedTxState> = new Map();
58
60
 
61
+ /** In-memory tracking: txHash -> slot at which the tx was deleted */
62
+ #slotDeletedTxs: Map<string, SlotNumber> = new Map();
63
+
64
+ /** Persisted set tracking which txs are slot-deleted, for hydration cleanup. */
65
+ #slotDeletedDB: AztecAsyncSet<string>;
66
+
67
+ /** Current slot number, updated by cleanupSlotDeleted */
68
+ #currentSlot: SlotNumber = SlotNumber(0);
69
+
59
70
  #log: Logger;
60
71
 
61
72
  constructor(store: AztecAsyncKVStore, txsDB: AztecAsyncMap<string, Buffer>, log: Logger) {
62
73
  this.#deletedTxsDB = store.openMap('deleted_txs');
74
+ this.#slotDeletedDB = store.openSet('slot_deleted_txs');
63
75
  this.#txsDB = txsDB;
64
76
  this.#log = log;
65
77
  }
66
78
 
67
79
  /**
68
80
  * Loads state from the database on startup.
81
+ * Slot-deleted txs are stale after restart and are immediately hard-deleted.
69
82
  */
70
83
  async hydrateFromDatabase(): Promise<void> {
71
84
  let prunedCount = 0;
@@ -83,6 +96,18 @@ export class DeletedPool {
83
96
  if (prunedCount > 0 || softDeletedCount > 0) {
84
97
  this.#log.info(`Loaded ${prunedCount} txs from pruned blocks, ${softDeletedCount} soft-deleted`);
85
98
  }
99
+
100
+ // Slot-deleted txs are stale after restart - hard-delete them all
101
+ let slotDeletedCount = 0;
102
+ for await (const txHash of this.#slotDeletedDB.entriesAsync()) {
103
+ await this.#txsDB.delete(txHash);
104
+ await this.#slotDeletedDB.delete(txHash);
105
+ slotDeletedCount++;
106
+ }
107
+
108
+ if (slotDeletedCount > 0) {
109
+ this.#log.info(`Hard-deleted ${slotDeletedCount} stale slot-deleted txs on startup`);
110
+ }
86
111
  }
87
112
 
88
113
  /**
@@ -117,33 +142,31 @@ export class DeletedPool {
117
142
  }
118
143
 
119
144
  if (count > 0) {
120
- this.#log.debug(`Marked ${count} transactions from pruned blocks`);
145
+ this.#log.info(`Marked ${count} transactions from pruned blocks`);
121
146
  }
122
147
  }
123
148
 
124
149
  /**
125
150
  * Deletes a transaction. This is the single entry point for ALL deletions.
151
+ * The tx is always soft-deleted (kept in DB):
126
152
  *
127
- * - If the tx is from a pruned block: soft-delete (keep in DB, mark as deleted)
128
- * - If the tx is NOT from a pruned block: hard-delete (remove from DB)
129
- *
130
- * @returns 'soft' if soft-deleted, 'hard' if hard-deleted
153
+ * - If the tx is from a pruned block: prune-soft-delete (kept until finalized)
154
+ * - If the tx is NOT from a pruned block: slot-soft-delete (kept until next slot)
131
155
  */
132
- async deleteTx(txHash: string): Promise<'soft' | 'hard'> {
156
+ async deleteTx(txHash: string): Promise<void> {
133
157
  const existing = this.#state.get(txHash);
134
158
  if (existing !== undefined) {
135
- // Soft delete - keep in DB
159
+ // Prune-soft-delete - keep in DB until finalized
136
160
  const state: DeletedTxState = {
137
161
  minedAtBlock: existing.minedAtBlock,
138
162
  softDeleted: true,
139
163
  };
140
164
  this.#state.set(txHash, state);
141
165
  await this.#deletedTxsDB.set(txHash, serializeState(state));
142
- return 'soft';
143
166
  } else {
144
- // Hard delete - remove from DB
145
- await this.#txsDB.delete(txHash);
146
- return 'hard';
167
+ // Slot-soft-delete - keep in DB until next slot
168
+ this.#slotDeletedTxs.set(txHash, this.#currentSlot);
169
+ await this.#slotDeletedDB.add(txHash);
147
170
  }
148
171
  }
149
172
 
@@ -176,10 +199,10 @@ export class DeletedPool {
176
199
  }
177
200
 
178
201
  /**
179
- * Checks if a transaction is soft-deleted.
202
+ * Checks if a transaction is soft-deleted (either prune-based or slot-based).
180
203
  */
181
204
  isSoftDeleted(txHash: string): boolean {
182
- return this.#state.get(txHash)?.softDeleted ?? false;
205
+ return (this.#state.get(txHash)?.softDeleted ?? false) || this.#slotDeletedTxs.has(txHash);
183
206
  }
184
207
 
185
208
  /**
@@ -214,10 +237,63 @@ export class DeletedPool {
214
237
  await this.#txsDB.delete(txHash);
215
238
  }
216
239
 
217
- this.#log.debug(`Finalized ${toHardDelete.length} txs from pruned blocks at block ${finalizedBlockNumber}`);
240
+ this.#log.debug(`Finalized ${toHardDelete.length} txs from pruned blocks at block ${finalizedBlockNumber}`, {
241
+ txHashes: toHardDelete,
242
+ });
218
243
  return toHardDelete;
219
244
  }
220
245
 
246
+ /**
247
+ * Cleans up slot-deleted transactions from previous slots.
248
+ * Called at the start of prepareForSlot. Updates #currentSlot and hard-deletes
249
+ * any txs that were deleted in an earlier slot.
250
+ */
251
+ async cleanupSlotDeleted(currentSlot: SlotNumber): Promise<void> {
252
+ const previousSlot = this.#currentSlot;
253
+ this.#currentSlot = currentSlot;
254
+
255
+ const toHardDelete: string[] = [];
256
+ for (const [txHash, deletedAtSlot] of this.#slotDeletedTxs) {
257
+ if (deletedAtSlot < currentSlot) {
258
+ toHardDelete.push(txHash);
259
+ }
260
+ }
261
+
262
+ if (toHardDelete.length === 0) {
263
+ return;
264
+ }
265
+
266
+ for (const txHash of toHardDelete) {
267
+ this.#slotDeletedTxs.delete(txHash);
268
+ await this.#slotDeletedDB.delete(txHash);
269
+ await this.#txsDB.delete(txHash);
270
+ }
271
+
272
+ this.#log.debug(
273
+ `Cleaned up ${toHardDelete.length} slot-deleted txs from slot ${previousSlot} (now slot ${currentSlot})`,
274
+ { txHashes: toHardDelete },
275
+ );
276
+ }
277
+
278
+ /**
279
+ * Clears soft-deletion status for a transaction being re-added to the pool.
280
+ * Removes slot-deleted tracking entirely, and resets the prune-soft-deleted flag
281
+ * while preserving the prune tracking itself (so a subsequent delete still uses
282
+ * the prune path).
283
+ */
284
+ async clearSoftDeleted(txHash: string): Promise<void> {
285
+ if (this.#slotDeletedTxs.has(txHash)) {
286
+ this.#slotDeletedTxs.delete(txHash);
287
+ await this.#slotDeletedDB.delete(txHash);
288
+ }
289
+ const existing = this.#state.get(txHash);
290
+ if (existing?.softDeleted) {
291
+ const state: DeletedTxState = { minedAtBlock: existing.minedAtBlock, softDeleted: false };
292
+ this.#state.set(txHash, state);
293
+ await this.#deletedTxsDB.set(txHash, serializeState(state));
294
+ }
295
+ }
296
+
221
297
  /**
222
298
  * Gets the count of transactions from pruned blocks.
223
299
  */
@@ -225,6 +301,17 @@ export class DeletedPool {
225
301
  return this.#state.size;
226
302
  }
227
303
 
304
+ /** Gets the count of soft-deleted transactions (both prune-based and slot-based). */
305
+ getSoftDeletedCount(): number {
306
+ let count = this.#slotDeletedTxs.size;
307
+ for (const state of this.#state.values()) {
308
+ if (state.softDeleted) {
309
+ count++;
310
+ }
311
+ }
312
+ return count;
313
+ }
314
+
228
315
  /**
229
316
  * Gets all transaction hashes from pruned blocks.
230
317
  */