@aztec/p2p 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d

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 (360) hide show
  1. package/README.md +7 -6
  2. package/dest/bootstrap/bootstrap.d.ts +1 -1
  3. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  4. package/dest/bootstrap/bootstrap.js +22 -6
  5. package/dest/client/factory.d.ts +4 -3
  6. package/dest/client/factory.d.ts.map +1 -1
  7. package/dest/client/factory.js +32 -23
  8. package/dest/client/interface.d.ts +44 -11
  9. package/dest/client/interface.d.ts.map +1 -1
  10. package/dest/client/p2p_client.d.ts +34 -19
  11. package/dest/client/p2p_client.d.ts.map +1 -1
  12. package/dest/client/p2p_client.js +119 -59
  13. package/dest/config.d.ts +150 -107
  14. package/dest/config.d.ts.map +1 -1
  15. package/dest/config.js +77 -26
  16. package/dest/errors/reqresp.error.d.ts +9 -16
  17. package/dest/errors/reqresp.error.d.ts.map +1 -1
  18. package/dest/errors/reqresp.error.js +10 -17
  19. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +98 -56
  20. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool.js +270 -198
  22. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
  23. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +218 -59
  25. package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
  26. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/mocks.js +6 -4
  28. package/dest/mem_pools/instrumentation.d.ts +9 -4
  29. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  30. package/dest/mem_pools/instrumentation.js +28 -9
  31. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +10 -5
  32. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
  33. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +29 -20
  34. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -3
  35. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
  36. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +6 -6
  37. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  38. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  39. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -3
  40. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
  41. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  42. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +3 -1
  43. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -1
  44. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  45. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -0
  46. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
  47. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
  48. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +64 -0
  49. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +1 -1
  50. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
  51. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +3 -4
  52. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +1 -1
  53. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
  54. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +6 -7
  55. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +1 -1
  56. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  57. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +6 -5
  58. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +11 -1
  59. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -1
  60. package/dest/mem_pools/tx_pool_v2/instrumentation.js +24 -0
  61. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +33 -5
  62. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  63. package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
  64. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +5 -2
  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 +8 -5
  67. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +15 -1
  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 +31 -0
  70. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +16 -3
  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 +83 -32
  73. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +50 -6
  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 +243 -127
  76. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +10 -3
  77. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  78. package/dest/msg_validators/attestation_validator/attestation_validator.js +38 -16
  79. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -3
  80. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  81. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +4 -5
  82. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +8 -3
  83. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  84. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +2 -2
  85. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +8 -3
  86. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  87. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +8 -2
  88. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +25 -3
  89. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  90. package/dest/msg_validators/proposal_validator/proposal_validator.js +85 -15
  91. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
  92. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  93. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
  94. package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
  95. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  96. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
  97. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
  98. package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
  99. package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
  100. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  101. package/dest/msg_validators/tx_validator/data_validator.js +1 -0
  102. package/dest/msg_validators/tx_validator/factory.d.ts +14 -15
  103. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  104. package/dest/msg_validators/tx_validator/factory.js +29 -16
  105. package/dest/msg_validators/tx_validator/gas_validator.d.ts +47 -10
  106. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  107. package/dest/msg_validators/tx_validator/gas_validator.js +65 -48
  108. package/dest/msg_validators/tx_validator/index.d.ts +3 -1
  109. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  110. package/dest/msg_validators/tx_validator/index.js +2 -0
  111. package/dest/msg_validators/tx_validator/phases_validator.js +2 -2
  112. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
  113. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  114. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
  115. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
  116. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
  117. package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
  118. package/dest/services/data_store.d.ts +1 -1
  119. package/dest/services/data_store.d.ts.map +1 -1
  120. package/dest/services/data_store.js +5 -5
  121. package/dest/services/discv5/discV5_service.d.ts +13 -2
  122. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  123. package/dest/services/discv5/discV5_service.js +119 -23
  124. package/dest/services/discv5/persisted_enr_store.d.ts +38 -0
  125. package/dest/services/discv5/persisted_enr_store.d.ts.map +1 -0
  126. package/dest/services/discv5/persisted_enr_store.js +145 -0
  127. package/dest/services/dummy_service.d.ts +18 -18
  128. package/dest/services/dummy_service.d.ts.map +1 -1
  129. package/dest/services/dummy_service.js +19 -18
  130. package/dest/services/encoding.d.ts +19 -6
  131. package/dest/services/encoding.d.ts.map +1 -1
  132. package/dest/services/encoding.js +25 -15
  133. package/dest/services/gossipsub/topic_score_params.d.ts +6 -12
  134. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  135. package/dest/services/gossipsub/topic_score_params.js +4 -14
  136. package/dest/services/libp2p/instrumentation.d.ts +6 -1
  137. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  138. package/dest/services/libp2p/instrumentation.js +21 -0
  139. package/dest/services/libp2p/libp2p_service.d.ts +40 -43
  140. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  141. package/dest/services/libp2p/libp2p_service.js +370 -276
  142. package/dest/services/peer-manager/peer_manager.d.ts +26 -2
  143. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  144. package/dest/services/peer-manager/peer_manager.js +103 -17
  145. package/dest/services/peer-manager/peer_scoring.d.ts +30 -1
  146. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  147. package/dest/services/peer-manager/peer_scoring.js +74 -3
  148. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
  149. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  150. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +35 -44
  151. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
  152. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  153. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
  154. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
  155. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
  156. package/dest/services/reqresp/config.d.ts +15 -3
  157. package/dest/services/reqresp/config.d.ts.map +1 -1
  158. package/dest/services/reqresp/config.js +11 -0
  159. package/dest/services/reqresp/interface.d.ts +16 -18
  160. package/dest/services/reqresp/interface.d.ts.map +1 -1
  161. package/dest/services/reqresp/interface.js +10 -20
  162. package/dest/services/reqresp/metrics.d.ts +1 -1
  163. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  164. package/dest/services/reqresp/metrics.js +0 -1
  165. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
  166. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  167. package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
  168. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
  169. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  170. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
  171. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
  172. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  173. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
  174. package/dest/services/reqresp/protocols/index.d.ts +1 -2
  175. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  176. package/dest/services/reqresp/protocols/index.js +0 -1
  177. package/dest/services/reqresp/protocols/tx.d.ts +1 -1
  178. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  179. package/dest/services/reqresp/protocols/tx.js +1 -3
  180. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  181. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  182. package/dest/services/reqresp/rate-limiter/rate_limits.js +3 -13
  183. package/dest/services/reqresp/reqresp.d.ts +7 -29
  184. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  185. package/dest/services/reqresp/reqresp.js +59 -209
  186. package/dest/services/service.d.ts +41 -19
  187. package/dest/services/service.d.ts.map +1 -1
  188. package/dest/services/tx_collection/config.d.ts +2 -23
  189. package/dest/services/tx_collection/config.d.ts.map +1 -1
  190. package/dest/services/tx_collection/config.js +2 -55
  191. package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
  192. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
  193. package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
  194. package/dest/services/tx_collection/index.d.ts +2 -3
  195. package/dest/services/tx_collection/index.d.ts.map +1 -1
  196. package/dest/services/tx_collection/index.js +0 -1
  197. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  198. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  199. package/dest/services/tx_collection/instrumentation.js +0 -2
  200. package/dest/services/tx_collection/tx_collection.d.ts +35 -51
  201. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  202. package/dest/services/tx_collection/tx_collection.js +275 -119
  203. package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
  204. package/dest/services/tx_collection/tx_collection_sink.js +2 -2
  205. package/dest/services/tx_collection/tx_source.d.ts +1 -1
  206. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  207. package/dest/services/tx_collection/tx_source.js +4 -1
  208. package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
  209. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  210. package/dest/services/tx_file_store/tx_file_store.js +4 -14
  211. package/dest/services/tx_provider.d.ts +3 -1
  212. package/dest/services/tx_provider.d.ts.map +1 -1
  213. package/dest/services/tx_provider.js +3 -0
  214. package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
  215. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  216. package/dest/test-helpers/make-test-p2p-clients.js +5 -2
  217. package/dest/test-helpers/mock-pubsub.d.ts +33 -9
  218. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  219. package/dest/test-helpers/mock-pubsub.js +57 -44
  220. package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
  221. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  222. package/dest/test-helpers/reqresp-nodes.js +16 -18
  223. package/dest/test-helpers/test_tx_provider.d.ts +3 -1
  224. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
  225. package/dest/test-helpers/test_tx_provider.js +3 -0
  226. package/dest/test-helpers/testbench-utils.d.ts +15 -14
  227. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  228. package/dest/test-helpers/testbench-utils.js +28 -13
  229. package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
  230. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  231. package/dest/testbench/p2p_client_testbench_worker.js +60 -27
  232. package/dest/testbench/worker_client_manager.d.ts +10 -6
  233. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  234. package/dest/testbench/worker_client_manager.js +51 -8
  235. package/dest/util.d.ts +11 -6
  236. package/dest/util.d.ts.map +1 -1
  237. package/dest/util.js +35 -14
  238. package/dest/versioning.d.ts +3 -6
  239. package/dest/versioning.d.ts.map +1 -1
  240. package/dest/versioning.js +3 -24
  241. package/package.json +17 -17
  242. package/src/bootstrap/bootstrap.ts +17 -3
  243. package/src/client/factory.ts +48 -24
  244. package/src/client/interface.ts +39 -17
  245. package/src/client/p2p_client.ts +135 -92
  246. package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
  247. package/src/config.ts +159 -34
  248. package/src/errors/reqresp.error.ts +13 -19
  249. package/src/mem_pools/attestation_pool/attestation_pool.ts +325 -242
  250. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +238 -63
  251. package/src/mem_pools/attestation_pool/mocks.ts +13 -8
  252. package/src/mem_pools/instrumentation.ts +18 -12
  253. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +30 -20
  254. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +7 -7
  255. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -4
  256. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -2
  257. package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
  258. package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +67 -0
  259. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +1 -3
  260. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -7
  261. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +5 -6
  262. package/src/mem_pools/tx_pool_v2/instrumentation.ts +27 -0
  263. package/src/mem_pools/tx_pool_v2/interfaces.ts +31 -4
  264. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +13 -7
  265. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +35 -0
  266. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +94 -31
  267. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +270 -133
  268. package/src/msg_validators/attestation_validator/attestation_validator.ts +46 -15
  269. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +15 -7
  270. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +15 -3
  271. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +26 -3
  272. package/src/msg_validators/proposal_validator/proposal_validator.ts +94 -12
  273. package/src/msg_validators/tx_validator/README.md +13 -3
  274. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
  275. package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
  276. package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
  277. package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
  278. package/src/msg_validators/tx_validator/data_validator.ts +2 -0
  279. package/src/msg_validators/tx_validator/factory.ts +37 -20
  280. package/src/msg_validators/tx_validator/gas_validator.ts +99 -54
  281. package/src/msg_validators/tx_validator/index.ts +2 -0
  282. package/src/msg_validators/tx_validator/phases_validator.ts +2 -2
  283. package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
  284. package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
  285. package/src/services/data_store.ts +5 -13
  286. package/src/services/discv5/discV5_service.ts +126 -14
  287. package/src/services/discv5/persisted_enr_store.ts +158 -0
  288. package/src/services/dummy_service.ts +25 -44
  289. package/src/services/encoding.ts +28 -20
  290. package/src/services/gossipsub/README.md +33 -11
  291. package/src/services/gossipsub/topic_score_params.ts +9 -18
  292. package/src/services/libp2p/instrumentation.ts +22 -0
  293. package/src/services/libp2p/libp2p_service.ts +433 -302
  294. package/src/services/peer-manager/peer_manager.ts +112 -16
  295. package/src/services/peer-manager/peer_scoring.ts +81 -3
  296. package/src/services/reqresp/README.md +2 -37
  297. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +39 -52
  298. package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
  299. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
  300. package/src/services/reqresp/config.ts +19 -2
  301. package/src/services/reqresp/interface.ts +21 -47
  302. package/src/services/reqresp/metrics.ts +0 -1
  303. package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
  304. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
  305. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
  306. package/src/services/reqresp/protocols/index.ts +0 -1
  307. package/src/services/reqresp/protocols/tx.ts +1 -3
  308. package/src/services/reqresp/rate-limiter/rate_limits.ts +3 -13
  309. package/src/services/reqresp/reqresp.ts +69 -252
  310. package/src/services/service.ts +48 -37
  311. package/src/services/tx_collection/config.ts +3 -80
  312. package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
  313. package/src/services/tx_collection/index.ts +1 -6
  314. package/src/services/tx_collection/instrumentation.ts +1 -7
  315. package/src/services/tx_collection/tx_collection.ts +330 -173
  316. package/src/services/tx_collection/tx_collection_sink.ts +2 -2
  317. package/src/services/tx_collection/tx_source.ts +2 -1
  318. package/src/services/tx_file_store/tx_file_store.ts +5 -17
  319. package/src/services/tx_provider.ts +5 -0
  320. package/src/test-helpers/make-test-p2p-clients.ts +3 -0
  321. package/src/test-helpers/mock-pubsub.ts +61 -60
  322. package/src/test-helpers/reqresp-nodes.ts +12 -22
  323. package/src/test-helpers/test_tx_provider.ts +5 -0
  324. package/src/test-helpers/testbench-utils.ts +35 -26
  325. package/src/testbench/p2p_client_testbench_worker.ts +68 -44
  326. package/src/testbench/worker_client_manager.ts +59 -19
  327. package/src/util.ts +32 -17
  328. package/src/versioning.ts +3 -33
  329. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
  330. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
  331. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -315
  332. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
  333. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
  334. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
  335. package/dest/msg_validators/clock_tolerance.d.ts +0 -21
  336. package/dest/msg_validators/clock_tolerance.d.ts.map +0 -1
  337. package/dest/msg_validators/clock_tolerance.js +0 -38
  338. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
  339. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
  340. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
  341. package/dest/services/reqresp/protocols/block.d.ts +0 -9
  342. package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
  343. package/dest/services/reqresp/protocols/block.js +0 -32
  344. package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
  345. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
  346. package/dest/services/tx_collection/fast_tx_collection.js +0 -311
  347. package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
  348. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
  349. package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
  350. package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
  351. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
  352. package/dest/services/tx_collection/slow_tx_collection.js +0 -211
  353. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -355
  354. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
  355. package/src/msg_validators/clock_tolerance.ts +0 -52
  356. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
  357. package/src/services/reqresp/protocols/block.ts +0 -37
  358. package/src/services/tx_collection/fast_tx_collection.ts +0 -361
  359. package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
  360. package/src/services/tx_collection/slow_tx_collection.ts +0 -266
@@ -1 +1 @@
1
- {"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAoB,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG5F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAEL,KAAK,UAAU,EAGf,KAAK,aAAa,EAElB,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAEZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,KAAK,QAAQ,EAAW,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,KAAK,aAAa,EAAE,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvH,OAAO,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAc,KAAK,eAAe,EAAE,UAAU,EAAiC,MAAM,yBAAyB,CAAC;AAEtH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,cAAc,CAAC;AAGnE,OAA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ACU,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC,CAW9C;YAOa,iBAAiB;YAWjB,oBAAoB;YAkBpB,oBAAoB;YA2CpB,uBAAuB;YAiBvB,mBAAmB;YASnB,YAAY;YAuBZ,uBAAuB;YAQvB,qBAAqB;IAmCnC;;;OAGG;IACH,OAAO,CAAC,eAAe;IAMhB,kCAAkC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAEjF;IAED;;;;OAIG;IACU,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;IAEM,yBAAyB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEjG;CACF"}
@@ -371,13 +371,13 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
371
  return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
372
372
  }
373
373
  var _dec, _dec1, _initProto;
374
- import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
375
374
  import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
376
375
  import { createLogger } from '@aztec/foundation/log';
377
- import { RunningPromise } from '@aztec/foundation/promise';
376
+ import { promiseWithResolvers } from '@aztec/foundation/promise';
378
377
  import { DateProvider } from '@aztec/foundation/timer';
379
378
  import { L2TipsKVStore } from '@aztec/kv-store/stores';
380
- import { L2BlockStream } from '@aztec/stdlib/block';
379
+ import { EventDrivenL2BlockStream } from '@aztec/stdlib/block';
380
+ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
381
381
  import { tryStop } from '@aztec/stdlib/interfaces/server';
382
382
  import { Attributes, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
383
383
  import { getP2PDefaultConfig } from '../config.js';
@@ -422,7 +422,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
422
422
  /** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */ runningPromise;
423
423
  currentState;
424
424
  syncPromise;
425
- syncResolve;
425
+ syncResolvers;
426
426
  latestBlockNumberAtStart;
427
427
  provenBlockNumberAtStart;
428
428
  finalizedBlockNumberAtStart;
@@ -435,9 +435,8 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
435
435
  txProvider;
436
436
  validatorAddresses;
437
437
  /** Tracks the last slot for which we called prepareForSlot */ lastSlotProcessed;
438
- /** Polls for slot changes and calls prepareForSlot on the tx pool */ slotMonitor;
439
- constructor(store, l2BlockSource, mempools, p2pService, txCollection, txFileStore, epochCache, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p')){
440
- super(telemetry, 'P2PClient'), this.store = store, this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.txCollection = txCollection, this.txFileStore = txFileStore, this.epochCache = epochCache, this._dateProvider = _dateProvider, this.telemetry = telemetry, this.log = log, this.currentState = (_initProto(this), P2PClientState.IDLE), this.syncPromise = Promise.resolve(), this.syncResolve = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1, this.finalizedBlockNumberAtStart = -1, this.validatorAddresses = [], this.lastSlotProcessed = SlotNumber.ZERO;
438
+ constructor(store, l2BlockSource, mempools, p2pService, txCollection, txFileStore, epochCache, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p'), initialBlockHash){
439
+ super(telemetry, 'P2PClient'), this.store = store, this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.txCollection = txCollection, this.txFileStore = txFileStore, this.epochCache = epochCache, this._dateProvider = _dateProvider, this.telemetry = telemetry, this.log = log, this.currentState = (_initProto(this), P2PClientState.IDLE), this.syncPromise = Promise.resolve(), this.syncResolvers = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1, this.finalizedBlockNumberAtStart = -1, this.validatorAddresses = [], this.lastSlotProcessed = SlotNumber.ZERO;
441
440
  this.config = {
442
441
  ...getP2PDefaultConfig(),
443
442
  ...config
@@ -445,7 +444,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
445
444
  this.txPool = mempools.txPool;
446
445
  this.attestationPool = mempools.attestationPool;
447
446
  this.txProvider = new TxProvider(this.txCollection, this.txPool, this, this.log.createChild('tx-provider'), this.telemetry);
448
- this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
447
+ this.l2Tips = new L2TipsKVStore(store, 'p2p_client', initialBlockHash);
449
448
  this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
450
449
  }
451
450
  registerThisValidatorAddresses(addresses) {
@@ -466,6 +465,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
466
465
  getPeers(includePending) {
467
466
  return Promise.resolve(this.p2pService.getPeers(includePending));
468
467
  }
468
+ getP2PConnectivity() {
469
+ return Promise.resolve(this.p2pService.getP2PConnectivity());
470
+ }
469
471
  getGossipMeshPeerCount(topicType) {
470
472
  return Promise.resolve(this.p2pService.getGossipMeshPeerCount(topicType));
471
473
  }
@@ -491,7 +493,10 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
491
493
  const from = BlockNumber(oldFinalizedBlockNum + 1);
492
494
  const limit = event.block.number - from + 1;
493
495
  if (limit > 0) {
494
- const oldBlocks = await this.l2BlockSource.getBlocks(from, limit);
496
+ const oldBlocks = await this.l2BlockSource.getBlocksData({
497
+ from,
498
+ limit
499
+ });
495
500
  await this.handleFinalizedL2Blocks(oldBlocks);
496
501
  }
497
502
  break;
@@ -501,10 +506,12 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
501
506
  break;
502
507
  case 'chain-pruned':
503
508
  this.txCollection.stopCollectingForBlocksAfter(event.block.number);
504
- await this.handlePruneL2Blocks(event.block, event.checkpoint);
509
+ await this.handlePruneL2Blocks(event.block, event.checkpointed.checkpoint);
505
510
  break;
506
511
  case 'chain-checkpointed':
507
512
  break;
513
+ case 'chain-proposed':
514
+ break;
508
515
  default:
509
516
  {
510
517
  const _ = event;
@@ -552,9 +559,8 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
552
559
  // this gets resolved on `startServiceIfSynched`
553
560
  this.initBlockStream();
554
561
  this.setCurrentState(P2PClientState.SYNCHING);
555
- this.syncPromise = new Promise((resolve)=>{
556
- this.syncResolve = resolve;
557
- });
562
+ this.syncResolvers = promiseWithResolvers();
563
+ this.syncPromise = this.syncResolvers.promise;
558
564
  this.log.info(`Initiating p2p sync from ${syncedLatestBlock}`, {
559
565
  syncedLatestBlock,
560
566
  syncedProvenBlock,
@@ -572,21 +578,21 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
572
578
  syncedFinalizedBlock
573
579
  });
574
580
  }
581
+ // Should never happen: all branches above call initBlockStream()
582
+ if (!this.blockStream) {
583
+ throw new Error('Block stream not initialized');
584
+ }
575
585
  this.blockStream.start();
576
- await this.txCollection.start();
577
586
  this.txFileStore?.start();
578
- // Start slot monitor to call prepareForSlot when the slot changes
579
- this.slotMonitor = new RunningPromise(()=>this.maybeCallPrepareForSlot(), this.log, this.config.slotCheckIntervalMS);
580
- this.slotMonitor.start();
581
587
  return this.syncPromise;
582
588
  }
583
- addReqRespSubProtocol(subProtocol, handler, validator) {
584
- return this.p2pService.addReqRespSubProtocol(subProtocol, handler, validator);
589
+ addReqRespSubProtocol(subProtocol, handler) {
590
+ return this.p2pService.addReqRespSubProtocol(subProtocol, handler);
585
591
  }
586
592
  initBlockStream(startingBlock) {
587
593
  if (!this.blockStream) {
588
594
  const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
589
- this.blockStream = new L2BlockStream(this.l2BlockSource, this, this, createLogger(`${this.log.module}:l2-block-stream`), {
595
+ this.blockStream = new EventDrivenL2BlockStream(this.l2BlockSource, this, this, createLogger(`${this.log.module}:l2-block-stream`), {
590
596
  batchSize,
591
597
  pollIntervalMS,
592
598
  startingBlock
@@ -598,8 +604,6 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
598
604
  * 'ready' will now return 'false' and the running promise that keeps the client synced is interrupted.
599
605
  */ async stop() {
600
606
  this.log.debug('Stopping p2p client...');
601
- await this.slotMonitor?.stop();
602
- this.log.debug('Stopped slot monitor');
603
607
  await tryStop(this.txCollection);
604
608
  this.log.debug('Stopped tx collection service');
605
609
  await this.txFileStore?.stop();
@@ -616,6 +620,10 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
616
620
  }
617
621
  /** Triggers a sync to the archiver. Used for testing. */ async sync() {
618
622
  this.initBlockStream();
623
+ // Should never happen: initBlockStream() creates blockStream if absent
624
+ if (!this.blockStream) {
625
+ throw new Error('Block stream not initialized');
626
+ }
619
627
  await this.blockStream.sync();
620
628
  }
621
629
  async broadcastProposal(proposal) {
@@ -642,23 +650,40 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
642
650
  // Store our own last-block proposal so we can respond to req/resp requests for it.
643
651
  await this.attestationPool.tryAddBlockProposal(blockProposal);
644
652
  }
645
- // Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
646
- await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
653
+ const checkpointCore = proposal.toCore();
654
+ const { count } = await this.attestationPool.tryAddCheckpointProposal(checkpointCore);
655
+ if (count > 1) {
656
+ if (this.config.broadcastEquivocatedProposals) {
657
+ this.log.warn(`Broadcasting equivocated checkpoint proposal for slot ${proposal.slotNumber}`, {
658
+ slot: proposal.slotNumber,
659
+ archive: proposal.archive.toString(),
660
+ count
661
+ });
662
+ } else {
663
+ throw new Error(`Attempted to broadcast a duplicate checkpoint proposal for slot ${proposal.slotNumber}`);
664
+ }
665
+ }
647
666
  return this.p2pService.propagate(proposal);
648
667
  }
649
668
  async broadcastCheckpointAttestations(attestations) {
650
669
  this.log.verbose(`Broadcasting ${attestations.length} checkpoint attestations to peers`);
651
670
  await Promise.all(attestations.map((att)=>this.p2pService.propagate(att)));
652
671
  }
653
- async getCheckpointAttestationsForSlot(slot, proposalId) {
654
- return await (proposalId ? this.attestationPool.getCheckpointAttestationsForSlotAndProposal(slot, proposalId) : this.attestationPool.getCheckpointAttestationsForSlot(slot));
672
+ async getCheckpointAttestationsForSlot(slot, proposalPayloadHash) {
673
+ return await (proposalPayloadHash ? this.attestationPool.getCheckpointAttestationsForSlotAndProposal(slot, proposalPayloadHash) : this.attestationPool.getCheckpointAttestationsForSlot(slot));
655
674
  }
656
675
  addOwnCheckpointAttestations(attestations) {
657
676
  return this.attestationPool.addOwnCheckpointAttestations(attestations);
658
677
  }
678
+ getProposalsForSlot(slot) {
679
+ return this.attestationPool.getProposalsForSlot(slot);
680
+ }
659
681
  hasBlockProposalsForSlot(slot) {
660
682
  return this.attestationPool.hasBlockProposalsForSlot(slot);
661
683
  }
684
+ hasCheckpointProposalForSlot(slot) {
685
+ return this.attestationPool.hasCheckpointProposalForSlot(slot);
686
+ }
662
687
  // REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
663
688
  // ^ This pattern is not my favorite (md)
664
689
  registerBlockProposalHandler(handler) {
@@ -673,10 +698,16 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
673
698
  registerDuplicateProposalCallback(callback) {
674
699
  this.p2pService.registerDuplicateProposalCallback(callback);
675
700
  }
701
+ registerOversizedProposalCallback(callback) {
702
+ this.p2pService.registerOversizedProposalCallback(callback);
703
+ }
676
704
  registerDuplicateAttestationCallback(callback) {
677
705
  this.p2pService.registerDuplicateAttestationCallback(callback);
678
706
  }
679
- async getPendingTxs(limit, after) {
707
+ registerCheckpointAttestationCallback(callback) {
708
+ this.p2pService.registerCheckpointAttestationCallback(callback);
709
+ }
710
+ async getPendingTxs(limit, after, options) {
680
711
  if (limit !== undefined && limit <= 0) {
681
712
  throw new TypeError('limit must be greater than 0');
682
713
  }
@@ -691,23 +722,30 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
691
722
  }
692
723
  const endIndex = limit !== undefined ? startIndex + limit : undefined;
693
724
  txHashes = txHashes.slice(startIndex, endIndex);
694
- const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash)));
725
+ // This is a public-facing API (exposed via both the node and the p2p RPC), so proofs are opt-in.
726
+ const includeProof = !!options?.includeProof;
727
+ const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash, {
728
+ includeProof
729
+ })));
695
730
  return maybeTxs.filter((tx)=>!!tx);
696
731
  }
697
732
  getPendingTxCount() {
698
733
  return this.txPool.getPendingTxCount();
699
734
  }
700
- async *iteratePendingTxs() {
735
+ hasEligiblePendingTxs(minCount) {
736
+ return this.txPool.hasEligiblePendingTxs(minCount);
737
+ }
738
+ async *iteratePendingTxs(opts) {
701
739
  for (const txHash of (await this.txPool.getPendingTxHashes())){
702
- const tx = await this.txPool.getTxByHash(txHash);
740
+ const tx = await this.txPool.getTxByHash(txHash, opts);
703
741
  if (tx) {
704
742
  yield tx;
705
743
  }
706
744
  }
707
745
  }
708
- async *iterateEligiblePendingTxs() {
746
+ async *iterateEligiblePendingTxs(opts) {
709
747
  for (const txHash of (await this.txPool.getEligiblePendingTxHashes())){
710
- const tx = await this.txPool.getTxByHash(txHash);
748
+ const tx = await this.txPool.getTxByHash(txHash, opts);
711
749
  if (tx) {
712
750
  yield tx;
713
751
  }
@@ -716,16 +754,18 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
716
754
  /**
717
755
  * Returns a transaction in the transaction pool by its hash.
718
756
  * @param txHash - Hash of the transaction to look for in the pool.
757
+ * @param opts - Set `includeProof: false` to skip loading the tx proof from the DB.
719
758
  * @returns A single tx or undefined.
720
- */ getTxByHashFromPool(txHash) {
721
- return this.txPool.getTxByHash(txHash);
759
+ */ getTxByHashFromPool(txHash, opts) {
760
+ return this.txPool.getTxByHash(txHash, opts);
722
761
  }
723
762
  /**
724
763
  * Returns transactions in the transaction pool by hash.
725
764
  * @param txHashes - Hashes of the transactions to look for.
765
+ * @param opts - Set `includeProof: false` to skip loading tx proofs from the DB.
726
766
  * @returns The txs found, in the same order as the requested hashes. If a tx is not found, it will be undefined.
727
- */ getTxsByHashFromPool(txHashes) {
728
- return this.txPool.getTxsByHash(txHashes);
767
+ */ getTxsByHashFromPool(txHashes, opts) {
768
+ return this.txPool.getTxsByHash(txHashes, opts);
729
769
  }
730
770
  hasTxsInPool(txHashes) {
731
771
  return this.txPool.hasTxs(txHashes);
@@ -813,7 +853,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
813
853
  * @returns Information about p2p client status: state & syncedToBlockNum.
814
854
  */ async getStatus() {
815
855
  const blockNumber = await this.getSyncedLatestBlockNum();
816
- const blockHash = blockNumber === 0 ? GENESIS_BLOCK_HEADER_HASH.toString() : await this.l2BlockSource.getBlockHeader(blockNumber).then((header)=>header?.hash()).then((hash)=>hash?.toString());
856
+ const blockHash = await this.l2BlockSource.getBlockData({
857
+ number: blockNumber
858
+ }).then((data)=>data?.header.hash()).then((hash)=>hash?.toString());
817
859
  return {
818
860
  state: this.currentState,
819
861
  syncedToL2Block: {
@@ -839,13 +881,17 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
839
881
  if (!blocks.length) {
840
882
  return;
841
883
  }
842
- await this.handleMinedBlocks(blocks);
843
- await this.maybeCallPrepareForSlot();
844
- await this.startCollectingMissingTxs(blocks);
845
884
  const lastBlock = blocks.at(-1);
846
- await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
885
+ const lastSlot = lastBlock.header.getSlot();
886
+ // Mark txs mined before releasing protections: a block landing at this slot supersedes any
887
+ // protection for txs it includes, so mined-marking must run first to keep just-landed txs from
888
+ // being unprotected into pending where they could be evicted before they are recorded as mined.
889
+ await this.handleMinedBlocks(blocks);
890
+ await this.maybeCallPrepareForSlot(lastSlot);
891
+ await this.collectingMissingTxs(blocks);
892
+ await this.synchedLatestSlot.set(BigInt(lastSlot));
847
893
  }
848
- /** Request txs for unproven blocks so the prover node has more chances to get them. */ async startCollectingMissingTxs(blocks) {
894
+ /** Request txs for unproven blocks so the prover node can prove. */ async collectingMissingTxs(blocks) {
849
895
  try {
850
896
  // TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
851
897
  // be much lower than the actual one, and it does not update until the pending chain is
@@ -853,7 +899,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
853
899
  // are already proven, but the archiver has not yet updated its state. Until this is properly
854
900
  // fixed, it is mitigated by the expiration date of collection requests, which depends on
855
901
  // the slot number of the block.
856
- const provenBlockNumber = await this.l2BlockSource.getProvenBlockNumber();
902
+ const provenBlockNumber = await this.l2BlockSource.getBlockNumber({
903
+ tag: 'proven'
904
+ }) ?? BlockNumber.ZERO;
857
905
  const unprovenBlocks = blocks.filter((block)=>block.number > provenBlockNumber);
858
906
  for (const block of unprovenBlocks){
859
907
  const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
@@ -864,7 +912,19 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
864
912
  blockNumber: block.number,
865
913
  blockHash: await block.hash().then((h)=>h.toString())
866
914
  });
867
- this.txCollection.startCollecting(block, missingTxHashes);
915
+ // Both `slashDataWithholdingToleranceSlots` and `p2pMissingTxCollectionDeadlineSlots`
916
+ // count *full slots after the block slot* — value N means collection runs until
917
+ // `slotStart(block.slot + N + 1)`. Take the larger of the two so collection never
918
+ // gives up before the data-withholding slash verdict is rendered.
919
+ const blockSlot = block.header.getSlot();
920
+ const toleranceSlots = this.config.slashDataWithholdingToleranceSlots;
921
+ const configuredSlots = this.config.p2pMissingTxCollectionDeadlineSlots ?? 0;
922
+ const deadlineSlot = SlotNumber(blockSlot + Math.max(toleranceSlots, configuredSlots) + 1);
923
+ const deadlineSeconds = getTimestampForSlot(deadlineSlot, this.epochCache.getL1Constants());
924
+ const deadline = new Date(Number(deadlineSeconds) * 1000);
925
+ await this.txCollection.collectFastForBlock(block, missingTxHashes, {
926
+ deadline
927
+ });
868
928
  }
869
929
  }
870
930
  } catch (err) {
@@ -919,18 +979,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
919
979
  }
920
980
  return isEpochPrune;
921
981
  }
922
- /** Checks if the slot has changed and calls prepareForSlot if so. */ async maybeCallPrepareForSlot() {
923
- // If we have a proposed checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
924
- const l2Tips = await this.l2Tips.getL2Tips();
925
- const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
926
- let slot;
927
- if (this.epochCache.isProposerPipeliningEnabled() && hasProposedCheckpoint) {
928
- const { targetSlot } = this.epochCache.getTargetAndNextSlot();
929
- slot = targetSlot;
930
- } else {
931
- const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
932
- slot = currentSlot;
933
- }
982
+ /** Calls prepareForSlot for the given slot if it advances past the last slot we prepared for. */ async maybeCallPrepareForSlot(slot) {
934
983
  if (slot <= this.lastSlotProcessed) {
935
984
  return;
936
985
  }
@@ -952,9 +1001,20 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
952
1001
  syncedFinalizedBlock
953
1002
  });
954
1003
  this.setCurrentState(P2PClientState.RUNNING);
955
- if (this.syncResolve !== undefined) {
956
- this.syncResolve();
957
- await this.p2pService.start();
1004
+ if (this.syncResolvers !== undefined) {
1005
+ // A throw here would be swallowed by the block stream event handler, so we reject the promise returned by
1006
+ // start instead, which makes node startup fail rather than run on with a dead p2p stack.
1007
+ try {
1008
+ await this.p2pService.start();
1009
+ } catch (err) {
1010
+ this.log.fatal(`Failed to start p2p service`, {
1011
+ err,
1012
+ syncedLatestBlock
1013
+ });
1014
+ this.syncResolvers.reject(err);
1015
+ return;
1016
+ }
1017
+ this.syncResolvers.resolve();
958
1018
  }
959
1019
  }
960
1020
  }