@aztec/p2p 0.0.0-test.1 → 0.0.1-commit.5476d83

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 (385) hide show
  1. package/dest/bootstrap/bootstrap.d.ts +1 -1
  2. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  3. package/dest/bootstrap/bootstrap.js +22 -9
  4. package/dest/client/factory.d.ts +14 -4
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +60 -24
  7. package/dest/client/index.d.ts +2 -1
  8. package/dest/client/index.d.ts.map +1 -1
  9. package/dest/client/index.js +1 -0
  10. package/dest/client/interface.d.ts +157 -0
  11. package/dest/client/interface.d.ts.map +1 -0
  12. package/dest/client/interface.js +9 -0
  13. package/dest/client/p2p_client.d.ts +72 -187
  14. package/dest/client/p2p_client.d.ts.map +1 -1
  15. package/dest/client/p2p_client.js +373 -177
  16. package/dest/config.d.ts +151 -125
  17. package/dest/config.d.ts.map +1 -1
  18. package/dest/config.js +183 -34
  19. package/dest/enr/generate-enr.d.ts +11 -3
  20. package/dest/enr/generate-enr.d.ts.map +1 -1
  21. package/dest/enr/generate-enr.js +27 -5
  22. package/dest/enr/index.d.ts +1 -1
  23. package/dest/errors/attestation-pool.error.d.ts +7 -0
  24. package/dest/errors/attestation-pool.error.d.ts.map +1 -0
  25. package/dest/errors/attestation-pool.error.js +12 -0
  26. package/dest/errors/reqresp.error.d.ts +1 -1
  27. package/dest/errors/reqresp.error.d.ts.map +1 -1
  28. package/dest/index.d.ts +4 -1
  29. package/dest/index.d.ts.map +1 -1
  30. package/dest/index.js +2 -0
  31. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +68 -8
  32. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  33. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
  34. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  35. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +214 -63
  36. package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
  37. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +21 -6
  38. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
  39. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +126 -25
  40. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +19 -6
  41. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  42. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +111 -21
  43. package/dest/mem_pools/attestation_pool/mocks.d.ts +225 -5
  44. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  45. package/dest/mem_pools/attestation_pool/mocks.js +9 -15
  46. package/dest/mem_pools/index.d.ts +1 -1
  47. package/dest/mem_pools/instrumentation.d.ts +10 -12
  48. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  49. package/dest/mem_pools/instrumentation.js +35 -38
  50. package/dest/mem_pools/interface.d.ts +1 -1
  51. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +62 -13
  52. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  53. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +469 -97
  54. package/dest/mem_pools/tx_pool/index.d.ts +1 -1
  55. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +34 -10
  56. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  57. package/dest/mem_pools/tx_pool/memory_tx_pool.js +133 -36
  58. package/dest/mem_pools/tx_pool/priority.d.ts +1 -1
  59. package/dest/mem_pools/tx_pool/priority.js +1 -1
  60. package/dest/mem_pools/tx_pool/tx_pool.d.ts +65 -9
  61. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  62. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
  63. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  64. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +264 -39
  65. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -2
  66. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  67. package/dest/msg_validators/attestation_validator/attestation_validator.js +45 -9
  68. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
  69. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
  70. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +67 -0
  71. package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
  72. package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
  73. package/dest/msg_validators/attestation_validator/index.js +1 -0
  74. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +6 -2
  75. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
  76. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +73 -12
  77. package/dest/msg_validators/block_proposal_validator/index.d.ts +1 -1
  78. package/dest/msg_validators/index.d.ts +1 -1
  79. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +10 -0
  80. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
  81. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
  82. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
  83. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  84. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +3 -0
  85. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -0
  86. package/dest/msg_validators/tx_validator/allowed_public_setup.js +27 -0
  87. package/dest/msg_validators/tx_validator/archive_cache.d.ts +14 -0
  88. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -0
  89. package/dest/msg_validators/tx_validator/archive_cache.js +22 -0
  90. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +1 -1
  91. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  92. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -4
  93. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  94. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  95. package/dest/msg_validators/tx_validator/data_validator.js +56 -86
  96. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +1 -3
  97. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  98. package/dest/msg_validators/tx_validator/double_spend_validator.js +21 -27
  99. package/dest/msg_validators/tx_validator/factory.d.ts +15 -0
  100. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
  101. package/dest/msg_validators/tx_validator/factory.js +74 -0
  102. package/dest/msg_validators/tx_validator/gas_validator.d.ts +11 -0
  103. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -0
  104. package/dest/msg_validators/tx_validator/gas_validator.js +115 -0
  105. package/dest/msg_validators/tx_validator/index.d.ts +8 -1
  106. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  107. package/dest/msg_validators/tx_validator/index.js +7 -0
  108. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +8 -4
  109. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  110. package/dest/msg_validators/tx_validator/metadata_validator.js +39 -20
  111. package/dest/msg_validators/tx_validator/phases_validator.d.ts +14 -0
  112. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -0
  113. package/dest/msg_validators/tx_validator/phases_validator.js +93 -0
  114. package/dest/msg_validators/tx_validator/test_utils.d.ts +17 -0
  115. package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -0
  116. package/dest/msg_validators/tx_validator/test_utils.js +22 -0
  117. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +12 -0
  118. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -0
  119. package/dest/msg_validators/tx_validator/timestamp_validator.js +32 -0
  120. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +8 -0
  121. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -0
  122. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +24 -0
  123. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +1 -1
  124. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  125. package/dest/msg_validators/tx_validator/tx_proof_validator.js +6 -5
  126. package/dest/services/data_store.d.ts +1 -1
  127. package/dest/services/data_store.d.ts.map +1 -1
  128. package/dest/services/discv5/discV5_service.d.ts +10 -9
  129. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  130. package/dest/services/discv5/discV5_service.js +63 -36
  131. package/dest/services/dummy_service.d.ts +50 -11
  132. package/dest/services/dummy_service.d.ts.map +1 -1
  133. package/dest/services/dummy_service.js +88 -5
  134. package/dest/services/encoding.d.ts +26 -7
  135. package/dest/services/encoding.d.ts.map +1 -1
  136. package/dest/services/encoding.js +73 -5
  137. package/dest/services/gossipsub/scoring.d.ts +1 -1
  138. package/dest/services/index.d.ts +5 -1
  139. package/dest/services/index.d.ts.map +1 -1
  140. package/dest/services/index.js +4 -0
  141. package/dest/services/libp2p/instrumentation.d.ts +20 -0
  142. package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
  143. package/dest/services/libp2p/instrumentation.js +164 -0
  144. package/dest/services/libp2p/libp2p_service.d.ts +78 -89
  145. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  146. package/dest/services/libp2p/libp2p_service.js +698 -246
  147. package/dest/services/peer-manager/interface.d.ts +23 -0
  148. package/dest/services/peer-manager/interface.d.ts.map +1 -0
  149. package/dest/services/peer-manager/interface.js +1 -0
  150. package/dest/services/peer-manager/metrics.d.ts +6 -2
  151. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  152. package/dest/services/peer-manager/metrics.js +22 -2
  153. package/dest/services/peer-manager/peer_manager.d.ts +102 -22
  154. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  155. package/dest/services/peer-manager/peer_manager.js +549 -72
  156. package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
  157. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  158. package/dest/services/peer-manager/peer_scoring.js +40 -2
  159. package/dest/services/reqresp/config.d.ts +11 -9
  160. package/dest/services/reqresp/config.d.ts.map +1 -1
  161. package/dest/services/reqresp/config.js +18 -4
  162. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +2 -2
  163. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  164. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +10 -6
  165. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +31 -17
  166. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  167. package/dest/services/reqresp/connection-sampler/connection_sampler.js +142 -84
  168. package/dest/services/reqresp/index.d.ts +3 -2
  169. package/dest/services/reqresp/index.d.ts.map +1 -1
  170. package/dest/services/reqresp/index.js +2 -1
  171. package/dest/services/reqresp/interface.d.ts +73 -24
  172. package/dest/services/reqresp/interface.d.ts.map +1 -1
  173. package/dest/services/reqresp/interface.js +45 -26
  174. package/dest/services/reqresp/metrics.d.ts +1 -1
  175. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  176. package/dest/services/reqresp/protocols/auth.d.ts +43 -0
  177. package/dest/services/reqresp/protocols/auth.d.ts.map +1 -0
  178. package/dest/services/reqresp/protocols/auth.js +71 -0
  179. package/dest/services/reqresp/protocols/block.d.ts +6 -1
  180. package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
  181. package/dest/services/reqresp/protocols/block.js +28 -5
  182. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +30 -0
  183. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -0
  184. package/dest/services/reqresp/protocols/block_txs/bitvector.js +75 -0
  185. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +11 -0
  186. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -0
  187. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +39 -0
  188. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +47 -0
  189. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -0
  190. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +75 -0
  191. package/dest/services/reqresp/protocols/block_txs/index.d.ts +4 -0
  192. package/dest/services/reqresp/protocols/block_txs/index.d.ts.map +1 -0
  193. package/dest/services/reqresp/protocols/block_txs/index.js +3 -0
  194. package/dest/services/reqresp/protocols/goodbye.d.ts +3 -5
  195. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  196. package/dest/services/reqresp/protocols/goodbye.js +7 -7
  197. package/dest/services/reqresp/protocols/index.d.ts +3 -1
  198. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  199. package/dest/services/reqresp/protocols/index.js +2 -0
  200. package/dest/services/reqresp/protocols/ping.d.ts +1 -3
  201. package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
  202. package/dest/services/reqresp/protocols/status.d.ts +39 -7
  203. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  204. package/dest/services/reqresp/protocols/status.js +72 -5
  205. package/dest/services/reqresp/protocols/tx.d.ts +13 -2
  206. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  207. package/dest/services/reqresp/protocols/tx.js +34 -6
  208. package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
  209. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +6 -4
  210. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  211. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
  212. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  213. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  214. package/dest/services/reqresp/rate-limiter/rate_limits.js +21 -1
  215. package/dest/services/reqresp/reqresp.d.ts +24 -66
  216. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  217. package/dest/services/reqresp/reqresp.js +298 -207
  218. package/dest/services/reqresp/status.d.ts +10 -4
  219. package/dest/services/reqresp/status.d.ts.map +1 -1
  220. package/dest/services/reqresp/status.js +9 -2
  221. package/dest/services/service.d.ts +23 -19
  222. package/dest/services/service.d.ts.map +1 -1
  223. package/dest/services/tx_collection/config.d.ts +25 -0
  224. package/dest/services/tx_collection/config.d.ts.map +1 -0
  225. package/dest/services/tx_collection/config.js +58 -0
  226. package/dest/services/tx_collection/fast_tx_collection.d.ts +50 -0
  227. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -0
  228. package/dest/services/tx_collection/fast_tx_collection.js +300 -0
  229. package/dest/services/tx_collection/index.d.ts +3 -0
  230. package/dest/services/tx_collection/index.d.ts.map +1 -0
  231. package/dest/services/tx_collection/index.js +2 -0
  232. package/dest/services/tx_collection/instrumentation.d.ts +10 -0
  233. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -0
  234. package/dest/services/tx_collection/instrumentation.js +34 -0
  235. package/dest/services/tx_collection/slow_tx_collection.d.ts +52 -0
  236. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
  237. package/dest/services/tx_collection/slow_tx_collection.js +177 -0
  238. package/dest/services/tx_collection/tx_collection.d.ts +109 -0
  239. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -0
  240. package/dest/services/tx_collection/tx_collection.js +128 -0
  241. package/dest/services/tx_collection/tx_collection_sink.d.ts +30 -0
  242. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -0
  243. package/dest/services/tx_collection/tx_collection_sink.js +111 -0
  244. package/dest/services/tx_collection/tx_source.d.ts +18 -0
  245. package/dest/services/tx_collection/tx_source.d.ts.map +1 -0
  246. package/dest/services/tx_collection/tx_source.js +31 -0
  247. package/dest/services/tx_provider.d.ts +49 -0
  248. package/dest/services/tx_provider.d.ts.map +1 -0
  249. package/dest/services/tx_provider.js +210 -0
  250. package/dest/services/tx_provider_instrumentation.d.ts +13 -0
  251. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -0
  252. package/dest/services/tx_provider_instrumentation.js +34 -0
  253. package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
  254. package/dest/test-helpers/get-ports.d.ts +1 -1
  255. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  256. package/dest/test-helpers/index.d.ts +2 -1
  257. package/dest/test-helpers/index.d.ts.map +1 -1
  258. package/dest/test-helpers/index.js +1 -0
  259. package/dest/test-helpers/make-enrs.d.ts +1 -1
  260. package/dest/test-helpers/make-enrs.d.ts.map +1 -1
  261. package/dest/test-helpers/make-enrs.js +4 -5
  262. package/dest/test-helpers/make-test-p2p-clients.d.ts +33 -5
  263. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  264. package/dest/test-helpers/make-test-p2p-clients.js +86 -16
  265. package/dest/test-helpers/mock-pubsub.d.ts +59 -0
  266. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -0
  267. package/dest/test-helpers/mock-pubsub.js +130 -0
  268. package/dest/test-helpers/mock-tx-helpers.d.ts +12 -0
  269. package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -0
  270. package/dest/test-helpers/mock-tx-helpers.js +19 -0
  271. package/dest/test-helpers/reqresp-nodes.d.ts +15 -11
  272. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  273. package/dest/test-helpers/reqresp-nodes.js +62 -28
  274. package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
  275. package/dest/testbench/p2p_client_testbench_worker.js +103 -29
  276. package/dest/testbench/parse_log_file.d.ts +1 -1
  277. package/dest/testbench/parse_log_file.js +4 -4
  278. package/dest/testbench/testbench.d.ts +1 -1
  279. package/dest/testbench/testbench.js +4 -4
  280. package/dest/testbench/worker_client_manager.d.ts +1 -6
  281. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  282. package/dest/testbench/worker_client_manager.js +11 -19
  283. package/dest/types/index.d.ts +4 -2
  284. package/dest/types/index.d.ts.map +1 -1
  285. package/dest/types/index.js +2 -0
  286. package/dest/util.d.ts +24 -16
  287. package/dest/util.d.ts.map +1 -1
  288. package/dest/util.js +75 -69
  289. package/dest/versioning.d.ts +4 -4
  290. package/dest/versioning.d.ts.map +1 -1
  291. package/dest/versioning.js +8 -3
  292. package/package.json +32 -27
  293. package/src/bootstrap/bootstrap.ts +27 -11
  294. package/src/client/factory.ts +136 -45
  295. package/src/client/index.ts +1 -0
  296. package/src/client/interface.ts +198 -0
  297. package/src/client/p2p_client.ts +469 -330
  298. package/src/config.ts +305 -134
  299. package/src/enr/generate-enr.ts +39 -6
  300. package/src/errors/attestation-pool.error.ts +13 -0
  301. package/src/index.ts +4 -0
  302. package/src/mem_pools/attestation_pool/attestation_pool.ts +75 -7
  303. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +264 -65
  304. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +173 -34
  305. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +156 -30
  306. package/src/mem_pools/attestation_pool/mocks.ts +11 -10
  307. package/src/mem_pools/instrumentation.ts +43 -44
  308. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +549 -108
  309. package/src/mem_pools/tx_pool/memory_tx_pool.ts +153 -44
  310. package/src/mem_pools/tx_pool/priority.ts +1 -1
  311. package/src/mem_pools/tx_pool/tx_pool.ts +67 -8
  312. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +217 -34
  313. package/src/msg_validators/attestation_validator/attestation_validator.ts +54 -11
  314. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +91 -0
  315. package/src/msg_validators/attestation_validator/index.ts +1 -0
  316. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +82 -14
  317. package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
  318. package/src/msg_validators/tx_validator/allowed_public_setup.ts +35 -0
  319. package/src/msg_validators/tx_validator/archive_cache.ts +28 -0
  320. package/src/msg_validators/tx_validator/block_header_validator.ts +4 -4
  321. package/src/msg_validators/tx_validator/data_validator.ts +81 -69
  322. package/src/msg_validators/tx_validator/double_spend_validator.ts +19 -17
  323. package/src/msg_validators/tx_validator/factory.ts +109 -0
  324. package/src/msg_validators/tx_validator/gas_validator.ts +134 -0
  325. package/src/msg_validators/tx_validator/index.ts +7 -0
  326. package/src/msg_validators/tx_validator/metadata_validator.ts +58 -21
  327. package/src/msg_validators/tx_validator/phases_validator.ts +116 -0
  328. package/src/msg_validators/tx_validator/test_utils.ts +43 -0
  329. package/src/msg_validators/tx_validator/timestamp_validator.ts +46 -0
  330. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +17 -0
  331. package/src/msg_validators/tx_validator/tx_proof_validator.ts +6 -5
  332. package/src/services/discv5/discV5_service.ts +84 -38
  333. package/src/services/dummy_service.ts +147 -9
  334. package/src/services/encoding.ts +80 -5
  335. package/src/services/index.ts +4 -0
  336. package/src/services/libp2p/instrumentation.ts +167 -0
  337. package/src/services/libp2p/libp2p_service.ts +866 -294
  338. package/src/services/peer-manager/interface.ts +29 -0
  339. package/src/services/peer-manager/metrics.ts +26 -1
  340. package/src/services/peer-manager/peer_manager.ts +654 -78
  341. package/src/services/peer-manager/peer_scoring.ts +46 -3
  342. package/src/services/reqresp/config.ts +26 -9
  343. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +12 -6
  344. package/src/services/reqresp/connection-sampler/connection_sampler.ts +148 -95
  345. package/src/services/reqresp/index.ts +2 -0
  346. package/src/services/reqresp/interface.ts +91 -36
  347. package/src/services/reqresp/metrics.ts +4 -1
  348. package/src/services/reqresp/protocols/auth.ts +83 -0
  349. package/src/services/reqresp/protocols/block.ts +24 -3
  350. package/src/services/reqresp/protocols/block_txs/bitvector.ts +90 -0
  351. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +53 -0
  352. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +79 -0
  353. package/src/services/reqresp/protocols/block_txs/index.ts +3 -0
  354. package/src/services/reqresp/protocols/goodbye.ts +9 -7
  355. package/src/services/reqresp/protocols/index.ts +2 -0
  356. package/src/services/reqresp/protocols/status.ts +117 -5
  357. package/src/services/reqresp/protocols/tx.ts +35 -6
  358. package/src/services/reqresp/rate-limiter/rate_limiter.ts +12 -3
  359. package/src/services/reqresp/rate-limiter/rate_limits.ts +21 -1
  360. package/src/services/reqresp/reqresp.ts +387 -256
  361. package/src/services/reqresp/status.ts +12 -3
  362. package/src/services/service.ts +45 -21
  363. package/src/services/tx_collection/config.ts +84 -0
  364. package/src/services/tx_collection/fast_tx_collection.ts +340 -0
  365. package/src/services/tx_collection/index.ts +2 -0
  366. package/src/services/tx_collection/instrumentation.ts +43 -0
  367. package/src/services/tx_collection/slow_tx_collection.ts +233 -0
  368. package/src/services/tx_collection/tx_collection.ts +215 -0
  369. package/src/services/tx_collection/tx_collection_sink.ts +129 -0
  370. package/src/services/tx_collection/tx_source.ts +37 -0
  371. package/src/services/tx_provider.ts +216 -0
  372. package/src/services/tx_provider_instrumentation.ts +44 -0
  373. package/src/test-helpers/index.ts +1 -0
  374. package/src/test-helpers/make-enrs.ts +4 -5
  375. package/src/test-helpers/make-test-p2p-clients.ts +111 -21
  376. package/src/test-helpers/mock-pubsub.ts +188 -0
  377. package/src/test-helpers/mock-tx-helpers.ts +24 -0
  378. package/src/test-helpers/reqresp-nodes.ts +86 -35
  379. package/src/testbench/p2p_client_testbench_worker.ts +151 -25
  380. package/src/testbench/parse_log_file.ts +4 -4
  381. package/src/testbench/testbench.ts +4 -4
  382. package/src/testbench/worker_client_manager.ts +17 -23
  383. package/src/types/index.ts +2 -0
  384. package/src/util.ts +105 -91
  385. package/src/versioning.ts +11 -4
@@ -5,24 +5,26 @@ function _ts_decorate(decorators, target, key, desc) {
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  }
7
7
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
8
+ import { SlotNumber } from '@aztec/foundation/branded-types';
8
9
  import { createLogger } from '@aztec/foundation/log';
10
+ import { DateProvider } from '@aztec/foundation/timer';
11
+ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
12
+ import { tryStop } from '@aztec/stdlib/interfaces/server';
9
13
  import { Attributes, TraceableL2BlockStream, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
10
14
  import { getP2PDefaultConfig } from '../config.js';
11
15
  import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
12
- /**
13
- * Enum defining the possible states of the p2p client.
14
- */ export var P2PClientState = /*#__PURE__*/ function(P2PClientState) {
15
- P2PClientState[P2PClientState["IDLE"] = 0] = "IDLE";
16
- P2PClientState[P2PClientState["SYNCHING"] = 1] = "SYNCHING";
17
- P2PClientState[P2PClientState["RUNNING"] = 2] = "RUNNING";
18
- P2PClientState[P2PClientState["STOPPED"] = 3] = "STOPPED";
19
- return P2PClientState;
20
- }({});
16
+ import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
17
+ import { TxProvider } from '../services/tx_provider.js';
18
+ import { P2PClientState } from './interface.js';
21
19
  /**
22
20
  * The P2P client implementation.
23
21
  */ export class P2PClient extends WithTracer {
22
+ store;
24
23
  l2BlockSource;
25
24
  p2pService;
25
+ txCollection;
26
+ _dateProvider;
27
+ telemetry;
26
28
  log;
27
29
  /** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */ runningPromise;
28
30
  currentState;
@@ -30,71 +32,115 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
30
32
  syncResolve;
31
33
  latestBlockNumberAtStart;
32
34
  provenBlockNumberAtStart;
35
+ finalizedBlockNumberAtStart;
33
36
  synchedBlockHashes;
34
37
  synchedLatestBlockNumber;
35
38
  synchedProvenBlockNumber;
39
+ synchedFinalizedBlockNumber;
40
+ synchedLatestSlot;
36
41
  txPool;
37
42
  attestationPool;
38
- /** How many slots to keep attestations for. */ keepAttestationsInPoolFor;
39
- /** How many slots to keep proven txs for. */ keepProvenTxsFor;
43
+ config;
40
44
  blockStream;
45
+ txProvider;
46
+ validatorAddresses;
41
47
  /**
42
48
  * In-memory P2P client constructor.
43
49
  * @param store - The client's instance of the KV store.
44
50
  * @param l2BlockSource - P2P client's source for fetching existing blocks.
45
51
  * @param txPool - The client's instance of a transaction pool. Defaults to in-memory implementation.
46
52
  * @param p2pService - The concrete instance of p2p networking to use.
47
- * @param keepProvenTxsFor - How many blocks have to pass after a block is proven before its txs are deleted (zero to delete immediately once proven).
48
53
  * @param log - A logger.
49
- */ constructor(_clientType, store, l2BlockSource, mempools, p2pService, config = {}, telemetry = getTelemetryClient(), log = createLogger('p2p')){
50
- super(telemetry, 'P2PClient'), this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.log = log, this.currentState = 0, this.syncPromise = Promise.resolve(), this.syncResolve = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1;
51
- const { keepProvenTxsInPoolFor, blockCheckIntervalMS, blockRequestBatchSize, keepAttestationsInPoolFor } = {
54
+ */ constructor(_clientType, store, l2BlockSource, mempools, p2pService, txCollection, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p')){
55
+ super(telemetry, 'P2PClient'), this.store = store, this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.txCollection = txCollection, this._dateProvider = _dateProvider, this.telemetry = telemetry, this.log = log, this.currentState = P2PClientState.IDLE, this.syncPromise = Promise.resolve(), this.syncResolve = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1, this.finalizedBlockNumberAtStart = -1, this.validatorAddresses = [];
56
+ this.config = {
52
57
  ...getP2PDefaultConfig(),
53
58
  ...config
54
59
  };
55
- this.keepProvenTxsFor = keepProvenTxsInPoolFor;
56
- this.keepAttestationsInPoolFor = keepAttestationsInPoolFor;
57
- const tracer = telemetry.getTracer('P2PL2BlockStream');
58
- const logger = createLogger('p2p:l2-block-stream');
59
- this.blockStream = new TraceableL2BlockStream(l2BlockSource, this, this, tracer, 'P2PL2BlockStream', logger, {
60
- batchSize: blockRequestBatchSize,
61
- pollIntervalMS: blockCheckIntervalMS
60
+ this.txPool = mempools.txPool;
61
+ this.attestationPool = mempools.attestationPool;
62
+ this.txProvider = new TxProvider(this.txCollection, this.txPool, this, this.log.createChild('tx-provider'), this.telemetry);
63
+ // Default to collecting all txs when we see a valid proposal
64
+ // This can be overridden by the validator client to attest, and it will call getTxsForBlockProposal on its own
65
+ // TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
66
+ // validator-client code into here so we can validate a proposal is reasonable.
67
+ this.registerBlockProposalHandler(async (block, sender)=>{
68
+ this.log.debug(`Received block proposal from ${sender.toString()}`);
69
+ // TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
70
+ const constants = this.txCollection.getConstants();
71
+ const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
72
+ const deadline = new Date(nextSlotTimestampSeconds * 1000);
73
+ const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.payload.header.lastArchiveRoot);
74
+ if (!parentBlock) {
75
+ this.log.debug(`Cannot collect txs for proposal as parent block not found`);
76
+ return;
77
+ }
78
+ const blockNumber = parentBlock.getBlockNumber() + 1;
79
+ await this.txProvider.getTxsForBlockProposal(block, blockNumber, {
80
+ pinnedPeer: sender,
81
+ deadline
82
+ });
83
+ return undefined;
62
84
  });
85
+ // REFACTOR: Try replacing these with an L2TipsStore
63
86
  this.synchedBlockHashes = store.openMap('p2p_pool_block_hashes');
64
87
  this.synchedLatestBlockNumber = store.openSingleton('p2p_pool_last_l2_block');
65
88
  this.synchedProvenBlockNumber = store.openSingleton('p2p_pool_last_proven_l2_block');
66
- this.txPool = mempools.txPool;
67
- this.attestationPool = mempools.attestationPool;
89
+ this.synchedFinalizedBlockNumber = store.openSingleton('p2p_pool_last_finalized_l2_block');
90
+ this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
91
+ }
92
+ registerThisValidatorAddresses(addresses) {
93
+ this.validatorAddresses = [
94
+ ...addresses
95
+ ];
96
+ this.p2pService.registerThisValidatorAddresses(this.validatorAddresses);
97
+ }
98
+ clear() {
99
+ return this.store.clear();
68
100
  }
69
101
  isP2PClient() {
70
102
  return true;
71
103
  }
104
+ getTxProvider() {
105
+ return this.txProvider;
106
+ }
72
107
  getPeers(includePending) {
73
108
  return Promise.resolve(this.p2pService.getPeers(includePending));
74
109
  }
75
110
  getL2BlockHash(number) {
76
111
  return this.synchedBlockHashes.getAsync(number);
77
112
  }
113
+ updateP2PConfig(config) {
114
+ this.txPool.updateConfig(config);
115
+ this.p2pService.updateConfig(config);
116
+ return Promise.resolve();
117
+ }
78
118
  async getL2Tips() {
79
119
  const latestBlockNumber = await this.getSyncedLatestBlockNum();
80
120
  let latestBlockHash;
81
121
  const provenBlockNumber = await this.getSyncedProvenBlockNum();
82
122
  let provenBlockHash;
123
+ const finalizedBlockNumber = await this.getSyncedFinalizedBlockNum();
124
+ let finalizedBlockHash;
83
125
  if (latestBlockNumber > 0) {
84
126
  latestBlockHash = await this.synchedBlockHashes.getAsync(latestBlockNumber);
85
127
  if (typeof latestBlockHash === 'undefined') {
86
- this.log.warn(`Block hash for latest block ${latestBlockNumber} not found`);
87
- throw new Error();
128
+ throw new Error(`Block hash for latest block ${latestBlockNumber} not found in p2p client`);
88
129
  }
89
130
  }
90
131
  if (provenBlockNumber > 0) {
91
132
  provenBlockHash = await this.synchedBlockHashes.getAsync(provenBlockNumber);
92
133
  if (typeof provenBlockHash === 'undefined') {
93
- this.log.warn(`Block hash for proven block ${provenBlockNumber} not found`);
94
- throw new Error();
134
+ throw new Error(`Block hash for proven block ${provenBlockNumber} not found in p2p client`);
135
+ }
136
+ }
137
+ if (finalizedBlockNumber > 0) {
138
+ finalizedBlockHash = await this.synchedBlockHashes.getAsync(finalizedBlockNumber);
139
+ if (typeof finalizedBlockHash === 'undefined') {
140
+ throw new Error(`Block hash for finalized block ${finalizedBlockNumber} not found in p2p client`);
95
141
  }
96
142
  }
97
- return Promise.resolve({
143
+ return {
98
144
  latest: {
99
145
  hash: latestBlockHash,
100
146
  number: latestBlockNumber
@@ -104,10 +150,10 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
104
150
  number: provenBlockNumber
105
151
  },
106
152
  finalized: {
107
- hash: provenBlockHash,
108
- number: provenBlockNumber
153
+ hash: finalizedBlockHash,
154
+ number: finalizedBlockNumber
109
155
  }
110
- });
156
+ };
111
157
  }
112
158
  async handleBlockStreamEvent(event) {
113
159
  this.log.debug(`Handling block stream event ${event.type}`);
@@ -116,16 +162,27 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
116
162
  await this.handleLatestL2Blocks(event.blocks);
117
163
  break;
118
164
  case 'chain-finalized':
119
- break;
165
+ {
166
+ // TODO (alexg): I think we can prune the block hashes map here
167
+ await this.setBlockHash(event.block);
168
+ const from = await this.getSyncedFinalizedBlockNum() + 1;
169
+ const limit = event.block.number - from + 1;
170
+ if (limit > 0) {
171
+ await this.handleFinalizedL2Blocks(await this.l2BlockSource.getBlocks(from, limit));
172
+ }
173
+ break;
174
+ }
120
175
  case 'chain-proven':
121
176
  {
122
- const from = await this.getSyncedProvenBlockNum() + 1;
123
- const limit = event.blockNumber - from + 1;
124
- await this.handleProvenL2Blocks(await this.l2BlockSource.getBlocks(from, limit));
177
+ await this.setBlockHash(event.block);
178
+ this.txCollection.stopCollectingForBlocksUpTo(event.block.number);
179
+ await this.synchedProvenBlockNumber.set(event.block.number);
125
180
  break;
126
181
  }
127
182
  case 'chain-pruned':
128
- await this.handlePruneL2Blocks(event.blockNumber);
183
+ await this.setBlockHash(event.block);
184
+ this.txCollection.stopCollectingForBlocksAfter(event.block.number);
185
+ await this.handlePruneL2Blocks(event.block.number);
129
186
  break;
130
187
  default:
131
188
  {
@@ -134,6 +191,11 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
134
191
  }
135
192
  }
136
193
  }
194
+ async setBlockHash(block) {
195
+ if (block.hash !== undefined) {
196
+ await this.synchedBlockHashes.set(block.number, block.hash.toString());
197
+ }
198
+ }
137
199
  #assertIsReady() {
138
200
  // this.log.info('Checking if p2p client is ready, current state: ', this.currentState);
139
201
  if (!this.isReady()) {
@@ -144,54 +206,106 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
144
206
  * Starts the P2P client.
145
207
  * @returns An empty promise signalling the synching process.
146
208
  */ async start() {
147
- if (this.currentState === 3) {
209
+ if (this.currentState === P2PClientState.STOPPED) {
148
210
  throw new Error('P2P client already stopped');
149
211
  }
150
- if (this.currentState !== 0) {
212
+ if (this.currentState !== P2PClientState.IDLE) {
151
213
  return this.syncPromise;
152
214
  }
153
215
  // get the current latest block numbers
154
- this.latestBlockNumberAtStart = await this.l2BlockSource.getBlockNumber();
155
- this.provenBlockNumberAtStart = await this.l2BlockSource.getProvenBlockNumber();
216
+ const latestBlockNumbers = await this.l2BlockSource.getL2Tips();
217
+ this.latestBlockNumberAtStart = latestBlockNumbers.latest.number;
218
+ this.provenBlockNumberAtStart = latestBlockNumbers.proven.number;
219
+ this.finalizedBlockNumberAtStart = latestBlockNumbers.finalized.number;
156
220
  const syncedLatestBlock = await this.getSyncedLatestBlockNum() + 1;
157
221
  const syncedProvenBlock = await this.getSyncedProvenBlockNum() + 1;
158
- // if there are blocks to be retrieved, go to a synching state
159
- if (syncedLatestBlock <= this.latestBlockNumberAtStart || syncedProvenBlock <= this.provenBlockNumberAtStart) {
160
- this.setCurrentState(1);
222
+ const syncedFinalizedBlock = await this.getSyncedFinalizedBlockNum() + 1;
223
+ if (await this.txPool.isEmpty() && (this.attestationPool === undefined || await this.attestationPool?.isEmpty())) {
224
+ // if mempools are empty, we don't care about syncing prior blocks
225
+ this.initBlockStream(this.latestBlockNumberAtStart);
226
+ this.setCurrentState(P2PClientState.RUNNING);
227
+ this.syncPromise = Promise.resolve();
228
+ await this.p2pService.start();
229
+ this.log.info(`Starting p2p client from block ${this.latestBlockNumberAtStart} with empty mempools`);
230
+ } else if (syncedLatestBlock <= this.latestBlockNumberAtStart || syncedProvenBlock <= this.provenBlockNumberAtStart || syncedFinalizedBlock <= this.finalizedBlockNumberAtStart) {
231
+ // if there are blocks to be retrieved, go to a synching state
232
+ // this gets resolved on `startServiceIfSynched`
233
+ this.initBlockStream();
234
+ this.setCurrentState(P2PClientState.SYNCHING);
161
235
  this.syncPromise = new Promise((resolve)=>{
162
236
  this.syncResolve = resolve;
163
237
  });
164
- this.log.verbose(`Starting sync from ${syncedLatestBlock} (last proven ${syncedProvenBlock})`);
238
+ this.log.info(`Initiating p2p sync from ${syncedLatestBlock}`, {
239
+ syncedLatestBlock,
240
+ syncedProvenBlock,
241
+ syncedFinalizedBlock
242
+ });
165
243
  } else {
166
244
  // if no blocks to be retrieved, go straight to running
167
- this.setCurrentState(2);
245
+ this.initBlockStream();
246
+ this.setCurrentState(P2PClientState.RUNNING);
168
247
  this.syncPromise = Promise.resolve();
169
248
  await this.p2pService.start();
170
- this.log.debug(`Block ${syncedLatestBlock} (proven ${syncedProvenBlock}) already beyond current block`);
249
+ this.log.info(`Starting P2P client synced to ${syncedLatestBlock}`, {
250
+ syncedLatestBlock,
251
+ syncedProvenBlock,
252
+ syncedFinalizedBlock
253
+ });
171
254
  }
172
255
  this.blockStream.start();
173
- this.log.verbose(`Started block downloader from block ${syncedLatestBlock}`);
256
+ await this.txCollection.start();
174
257
  return this.syncPromise;
175
258
  }
259
+ addReqRespSubProtocol(subProtocol, handler, validator) {
260
+ return this.p2pService.addReqRespSubProtocol(subProtocol, handler, validator);
261
+ }
262
+ initBlockStream(startingBlock) {
263
+ if (!this.blockStream) {
264
+ const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
265
+ this.blockStream = new TraceableL2BlockStream(this.l2BlockSource, this, this, this.telemetry.getTracer('P2PL2BlockStream'), 'P2PL2BlockStream', createLogger(`${this.log.module}:l2-block-stream`), {
266
+ batchSize,
267
+ pollIntervalMS,
268
+ startingBlock
269
+ });
270
+ }
271
+ }
176
272
  /**
177
273
  * Allows consumers to stop the instance of the P2P client.
178
274
  * 'ready' will now return 'false' and the running promise that keeps the client synced is interrupted.
179
275
  */ async stop() {
180
276
  this.log.debug('Stopping p2p client...');
277
+ await tryStop(this.txCollection);
278
+ this.log.debug('Stopped tx collection service');
181
279
  await this.p2pService.stop();
182
280
  this.log.debug('Stopped p2p service');
183
- await this.blockStream.stop();
281
+ await this.blockStream?.stop();
184
282
  this.log.debug('Stopped block downloader');
185
283
  await this.runningPromise;
186
- this.setCurrentState(3);
187
- this.log.info('P2P client stopped.');
284
+ this.setCurrentState(P2PClientState.STOPPED);
285
+ this.log.info('P2P client stopped');
286
+ }
287
+ /** Triggers a sync to the archiver. Used for testing. */ async sync() {
288
+ this.initBlockStream();
289
+ await this.blockStream.sync();
188
290
  }
189
291
  broadcastProposal(proposal) {
190
- this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber.toNumber()} to peers`);
292
+ this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
191
293
  return this.p2pService.propagate(proposal);
192
294
  }
295
+ async broadcastAttestations(attestations) {
296
+ this.log.verbose(`Broadcasting ${attestations.length} attestations to peers`);
297
+ await Promise.all(attestations.map((att)=>this.p2pService.propagate(att)));
298
+ }
193
299
  async getAttestationsForSlot(slot, proposalId) {
194
- return await this.attestationPool?.getAttestationsForSlot(slot, proposalId) ?? [];
300
+ return await (proposalId ? this.attestationPool?.getAttestationsForSlotAndProposal(slot, proposalId) : this.attestationPool?.getAttestationsForSlot(slot)) ?? [];
301
+ }
302
+ addAttestations(attestations) {
303
+ return this.attestationPool?.addAttestations(attestations) ?? Promise.resolve();
304
+ }
305
+ deleteAttestation(attestation) {
306
+ return this.attestationPool?.deleteAttestations([
307
+ attestation
308
+ ]) ?? Promise.resolve();
195
309
  }
196
310
  // REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
197
311
  // ^ This pattern is not my favorite (md)
@@ -199,52 +313,27 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
199
313
  this.p2pService.registerBlockReceivedCallback(handler);
200
314
  }
201
315
  /**
202
- * Requests the transactions with the given hashes from the network.
203
- *
204
- * If a transaction can be retrieved, it will be returned, if not an undefined
205
- * will be returned. In place.
206
- *
207
- * @param txHashes - The hashes of the transactions to request.
208
- * @returns A promise that resolves to an array of transactions or undefined.
209
- */ async requestTxs(txHashes) {
210
- const res = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, txHashes);
211
- return Promise.resolve(res ?? []);
212
- }
213
- /**
214
- * Uses the Request Response protocol to request a transaction from the network.
215
- *
216
- * If the underlying request response protocol fails, then we return undefined.
217
- * If it succeeds then we add the transaction to our transaction pool and return.
218
- *
219
- * @param txHash - The hash of the transaction to request.
220
- * @returns A promise that resolves to a transaction or undefined.
221
- */ async requestTxByHash(txHash) {
222
- const tx = await this.p2pService.sendRequest(ReqRespSubProtocol.TX, txHash);
223
- if (tx) {
224
- this.log.debug(`Received tx ${txHash.toString()} from peer`);
225
- await this.txPool.addTxs([
226
- tx
227
- ]);
228
- } else {
229
- this.log.debug(`Failed to receive tx ${txHash.toString()} from peer`);
230
- }
231
- return tx;
232
- }
233
- /**
234
316
  * Uses the batched Request Response protocol to request a set of transactions from the network.
235
- */ async requestTxsByHash(txHashes) {
236
- const txs = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, txHashes) ?? [];
237
- await this.txPool.addTxs(txs);
317
+ */ async requestTxsByHash(txHashes, pinnedPeerId) {
318
+ const timeoutMs = 8000; // Longer timeout for now
319
+ const maxRetryAttempts = 10; // Keep retrying within the timeout
320
+ const requests = chunkTxHashesRequest(txHashes);
321
+ const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
322
+ const txBatches = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, requests, pinnedPeerId, timeoutMs, maxPeers, maxRetryAttempts);
323
+ const txs = txBatches.flat();
324
+ if (txs.length > 0) {
325
+ await this.txPool.addTxs(txs);
326
+ }
238
327
  const txHashesStr = txHashes.map((tx)=>tx.toString()).join(', ');
239
- this.log.debug(`Received batched txs ${txHashesStr} (${txs.length} / ${txHashes.length}}) from peers`);
328
+ this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
329
+ // We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
240
330
  return txs;
241
331
  }
242
- getPendingTxs() {
243
- return Promise.resolve(this.getTxs('pending'));
332
+ getPendingTxs(limit, after) {
333
+ return this.getTxs('pending', limit, after);
244
334
  }
245
- async getPendingTxCount() {
246
- const pendingTxs = await this.txPool.getPendingTxHashes();
247
- return pendingTxs.length;
335
+ getPendingTxCount() {
336
+ return this.txPool.getPendingTxCount();
248
337
  }
249
338
  async *iteratePendingTxs() {
250
339
  for (const txHash of (await this.txPool.getPendingTxHashes())){
@@ -256,22 +345,50 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
256
345
  }
257
346
  /**
258
347
  * Returns all transactions in the transaction pool.
348
+ * @param filter - The type of txs to return
349
+ * @param limit - How many txs to return
350
+ * @param after - If paginating, the last known tx hash. Will return txs after this hash
259
351
  * @returns An array of Txs.
260
- */ async getTxs(filter) {
352
+ */ async getTxs(filter, limit, after) {
353
+ if (limit !== undefined && limit <= 0) {
354
+ throw new TypeError('limit must be greater than 0');
355
+ }
356
+ let txs = undefined;
357
+ let txHashes;
261
358
  if (filter === 'all') {
262
- return this.txPool.getAllTxs();
359
+ txs = await this.txPool.getAllTxs();
360
+ txHashes = await Promise.all(txs.map((tx)=>tx.getTxHash()));
263
361
  } else if (filter === 'mined') {
264
- const minedHashes = await this.txPool.getMinedTxHashes();
265
- const minedTx = await Promise.all(minedHashes.map(([txHash])=>this.txPool.getTxByHash(txHash)));
266
- return minedTx.filter((tx)=>!!tx);
362
+ const minedTxHashes = await this.txPool.getMinedTxHashes();
363
+ txHashes = minedTxHashes.map(([txHash])=>txHash);
267
364
  } else if (filter === 'pending') {
268
- const pendingHashses = await this.txPool.getPendingTxHashes();
269
- const pendingTxs = await Promise.all(pendingHashses.map((txHash)=>this.txPool.getTxByHash(txHash)));
270
- return pendingTxs.filter((tx)=>!!tx);
365
+ txHashes = await this.txPool.getPendingTxHashes();
271
366
  } else {
272
367
  const _ = filter;
273
368
  throw new Error(`Unknown filter ${filter}`);
274
369
  }
370
+ let startIndex = 0;
371
+ let endIndex = undefined;
372
+ if (after) {
373
+ startIndex = txHashes.findIndex((txHash)=>after.equals(txHash));
374
+ // if we can't find the last tx in our set then return an empty array as pagination is no longer valid.
375
+ if (startIndex === -1) {
376
+ return [];
377
+ }
378
+ // increment by one because we don't want to return the same tx again
379
+ startIndex++;
380
+ }
381
+ if (limit !== undefined) {
382
+ endIndex = startIndex + limit;
383
+ }
384
+ txHashes = txHashes.slice(startIndex, endIndex);
385
+ if (txs) {
386
+ txs = txs.slice(startIndex, endIndex);
387
+ } else {
388
+ const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash)));
389
+ txs = maybeTxs.filter((tx)=>!!tx);
390
+ }
391
+ return txs;
275
392
  }
276
393
  /**
277
394
  * Returns a transaction in the transaction pool by its hash.
@@ -281,23 +398,21 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
281
398
  return this.txPool.getTxByHash(txHash);
282
399
  }
283
400
  /**
284
- * Returns a transaction in the transaction pool by its hash.
285
- * If the transaction is not in the pool, it will be requested from the network.
286
- * @param txHash - Hash of the transaction to look for in the pool.
287
- * @returns A single tx or undefined.
288
- */ async getTxByHash(txHash) {
289
- const tx = await this.txPool.getTxByHash(txHash);
290
- if (tx) {
291
- return tx;
292
- }
293
- return this.requestTxByHash(txHash);
401
+ * Returns transactions in the transaction pool by hash.
402
+ * @param txHashes - Hashes of the transactions to look for.
403
+ * @returns The txs found, in the same order as the requested hashes. If a tx is not found, it will be undefined.
404
+ */ getTxsByHashFromPool(txHashes) {
405
+ return this.txPool.getTxsByHash(txHashes);
406
+ }
407
+ hasTxsInPool(txHashes) {
408
+ return this.txPool.hasTxs(txHashes);
294
409
  }
295
410
  /**
296
411
  * Returns transactions in the transaction pool by hash.
297
412
  * If a transaction is not in the pool, it will be requested from the network.
298
413
  * @param txHashes - Hashes of the transactions to look for.
299
- * @returns The txs found, not necessarily on the same order as the hashes.
300
- */ async getTxsByHash(txHashes) {
414
+ * @returns The txs found, or undefined if not found in the order requested.
415
+ */ async getTxsByHash(txHashes, pinnedPeerId) {
301
416
  const txs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash)));
302
417
  const missingTxHashes = txs.map((tx, index)=>[
303
418
  tx,
@@ -306,8 +421,27 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
306
421
  if (missingTxHashes.length === 0) {
307
422
  return txs;
308
423
  }
309
- const missingTxs = await this.requestTxsByHash(missingTxHashes);
310
- return txs.filter((tx)=>!!tx).concat(missingTxs);
424
+ const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
425
+ // TODO: optimize
426
+ // Merge the found txs in order
427
+ const mergingTxs = txHashes.map((txHash)=>{
428
+ // Is it in the txs list from the mempool?
429
+ for (const tx of txs){
430
+ if (tx !== undefined && tx.getTxHash().equals(txHash)) {
431
+ return tx;
432
+ }
433
+ }
434
+ // Is it in the fetched missing txs?
435
+ // Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
436
+ for (const tx of missingTxs){
437
+ if (tx.getTxHash().equals(txHash)) {
438
+ return tx;
439
+ }
440
+ }
441
+ // Otherwise return undefined
442
+ return undefined;
443
+ });
444
+ return mergingTxs;
311
445
  }
312
446
  /**
313
447
  * Returns an archived transaction in the transaction pool by its hash.
@@ -321,11 +455,20 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
321
455
  * @param tx - The tx to verify.
322
456
  * @returns Empty promise.
323
457
  **/ async sendTx(tx) {
324
- this.#assertIsReady();
325
- await this.txPool.addTxs([
458
+ const addedCount = await this.addTxsToPool([
326
459
  tx
327
460
  ]);
328
- this.p2pService.propagate(tx);
461
+ const txAddedSuccessfully = addedCount === 1;
462
+ if (txAddedSuccessfully) {
463
+ await this.p2pService.propagate(tx);
464
+ }
465
+ }
466
+ /**
467
+ * Adds transactions to the pool. Does not send to peers or validate the txs.
468
+ * @param txs - The transactions.
469
+ **/ async addTxsToPool(txs) {
470
+ this.#assertIsReady();
471
+ return await this.txPool.addTxs(txs);
329
472
  }
330
473
  /**
331
474
  * Returns whether the given tx hash is flagged as pending or mined.
@@ -353,7 +496,7 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
353
496
  * Public function to check if the p2p client is fully synced and ready to receive txs.
354
497
  * @returns True if the P2P client is ready to receive txs.
355
498
  */ isReady() {
356
- return this.currentState === 2;
499
+ return this.currentState === P2PClientState.RUNNING;
357
500
  }
358
501
  /**
359
502
  * Public function to check the latest block number that the P2P client is synced to.
@@ -367,6 +510,12 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
367
510
  */ async getSyncedProvenBlockNum() {
368
511
  return await this.synchedProvenBlockNumber.getAsync() ?? INITIAL_L2_BLOCK_NUM - 1;
369
512
  }
513
+ async getSyncedFinalizedBlockNum() {
514
+ return await this.synchedFinalizedBlockNumber.getAsync() ?? INITIAL_L2_BLOCK_NUM - 1;
515
+ }
516
+ /** Returns latest L2 slot for which we have seen an L2 block. */ async getSyncedLatestSlot() {
517
+ return await this.synchedLatestSlot.getAsync() ?? BigInt(0);
518
+ }
370
519
  /**
371
520
  * Method to check the status the p2p client.
372
521
  * @returns Information about p2p client status: state & syncedToBlockNum.
@@ -388,18 +537,7 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
388
537
  */ async markTxsAsMinedFromBlocks(blocks) {
389
538
  for (const block of blocks){
390
539
  const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
391
- await this.txPool.markAsMined(txHashes, block.number);
392
- }
393
- }
394
- /**
395
- * Deletes txs from these blocks.
396
- * @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
397
- * @returns Empty promise.
398
- */ async deleteTxsFromBlocks(blocks) {
399
- this.log.debug(`Deleting txs from blocks ${blocks[0].number} to ${blocks[blocks.length - 1].number}`);
400
- for (const block of blocks){
401
- const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
402
- await this.txPool.deleteTxs(txHashes);
540
+ await this.txPool.markAsMined(txHashes, block.getBlockHeader());
403
541
  }
404
542
  }
405
543
  /**
@@ -410,76 +548,123 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
410
548
  if (!blocks.length) {
411
549
  return Promise.resolve();
412
550
  }
413
- await this.markTxsAsMinedFromBlocks(blocks);
414
- const lastBlockNum = blocks[blocks.length - 1].number;
415
- await Promise.all(blocks.map(async (block)=>this.synchedBlockHashes.set(block.number, (await block.hash()).toString())));
416
- await this.synchedLatestBlockNumber.set(lastBlockNum);
417
- this.log.verbose(`Synched to latest block ${lastBlockNum}`);
551
+ await this.markTxsAsMinedFromBlocks(blocks.map((b)=>b.block));
552
+ await this.startCollectingMissingTxs(blocks.map((b)=>b.block));
553
+ const lastBlock = blocks.at(-1).block;
554
+ await Promise.all(blocks.map(async (block)=>this.setBlockHash({
555
+ number: block.block.number,
556
+ hash: await block.block.hash().then((h)=>h.toString())
557
+ })));
558
+ await this.synchedLatestBlockNumber.set(lastBlock.number);
559
+ await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
560
+ this.log.verbose(`Synched to latest block ${lastBlock.number}`);
418
561
  await this.startServiceIfSynched();
419
562
  }
563
+ /** Request txs for unproven blocks so the prover node has more chances to get them. */ async startCollectingMissingTxs(blocks) {
564
+ try {
565
+ // TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
566
+ // be much lower than the actual one, and it does not update until the pending chain is
567
+ // fully synced. This could lead to a ton of tx collection requests for blocks that
568
+ // are already proven, but the archiver has not yet updated its state. Until this is properly
569
+ // fixed, it is mitigated by the expiration date of collection requests, which depends on
570
+ // the slot number of the block.
571
+ const provenBlockNumber = await this.l2BlockSource.getProvenBlockNumber();
572
+ const unprovenBlocks = blocks.filter((block)=>block.number > provenBlockNumber);
573
+ for (const block of unprovenBlocks){
574
+ const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
575
+ const missingTxHashes = await this.txPool.hasTxs(txHashes).then((availability)=>txHashes.filter((_, index)=>!availability[index]));
576
+ if (missingTxHashes.length > 0) {
577
+ this.log.verbose(`Starting collection of ${missingTxHashes.length} missing txs for unproven mined block ${block.number}`, {
578
+ missingTxHashes,
579
+ blockNumber: block.number,
580
+ blockHash: await block.hash().then((h)=>h.toString())
581
+ });
582
+ this.txCollection.startCollecting(block, missingTxHashes);
583
+ }
584
+ }
585
+ } catch (err) {
586
+ this.log.error(`Error while starting collection of missing txs for unproven blocks`, err);
587
+ }
588
+ }
420
589
  /**
421
- * Handles new proven blocks by deleting the txs in them, or by deleting the txs in blocks `keepProvenTxsFor` ago.
422
- * @param blocks - A list of proven L2 blocks.
590
+ * Handles new finalized blocks by deleting the txs and attestations in them.
591
+ * @param blocks - A list of finalized L2 blocks.
423
592
  * @returns Empty promise.
424
- */ async handleProvenL2Blocks(blocks) {
593
+ */ async handleFinalizedL2Blocks(blocks) {
425
594
  if (!blocks.length) {
426
595
  return Promise.resolve();
427
596
  }
428
- const firstBlockNum = blocks[0].number;
597
+ this.log.debug(`Handling finalized blocks ${blocks.length} up to ${blocks.at(-1)?.number}`);
429
598
  const lastBlockNum = blocks[blocks.length - 1].number;
430
- const lastBlockSlot = blocks[blocks.length - 1].header.globalVariables.slotNumber.toBigInt();
431
- // If keepProvenTxsFor is 0, we delete all txs from all proven blocks.
432
- if (this.keepProvenTxsFor === 0) {
433
- await this.deleteTxsFromBlocks(blocks);
434
- } else if (lastBlockNum - this.keepProvenTxsFor >= INITIAL_L2_BLOCK_NUM) {
435
- const fromBlock = Math.max(INITIAL_L2_BLOCK_NUM, firstBlockNum - this.keepProvenTxsFor);
436
- const toBlock = lastBlockNum - this.keepProvenTxsFor;
437
- const limit = toBlock - fromBlock + 1;
438
- const blocksToDeleteTxsFrom = await this.l2BlockSource.getBlocks(fromBlock, limit, true);
439
- await this.deleteTxsFromBlocks(blocksToDeleteTxsFrom);
440
- }
441
- // We delete attestations older than the last block slot minus the number of slots we want to keep in the pool.
442
- const lastBlockSlotMinusKeepAttestationsInPoolFor = lastBlockSlot - BigInt(this.keepAttestationsInPoolFor);
443
- if (lastBlockSlotMinusKeepAttestationsInPoolFor >= BigInt(INITIAL_L2_BLOCK_NUM)) {
444
- await this.attestationPool?.deleteAttestationsOlderThan(lastBlockSlotMinusKeepAttestationsInPoolFor);
445
- }
446
- await this.synchedProvenBlockNumber.set(lastBlockNum);
447
- this.log.debug(`Synched to proven block ${lastBlockNum}`);
599
+ const lastBlockSlot = blocks[blocks.length - 1].header.getSlot();
600
+ const txHashes = blocks.flatMap((block)=>block.body.txEffects.map((txEffect)=>txEffect.txHash));
601
+ this.log.debug(`Deleting ${txHashes.length} txs from pool from finalized blocks up to ${lastBlockNum}`);
602
+ await this.txPool.deleteTxs(txHashes, {
603
+ permanently: true
604
+ });
605
+ await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
606
+ await this.attestationPool?.deleteAttestationsOlderThan(lastBlockSlot);
607
+ await this.synchedFinalizedBlockNumber.set(lastBlockNum);
608
+ this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
448
609
  await this.startServiceIfSynched();
449
610
  }
450
611
  /**
451
612
  * Updates the tx pool after a chain prune.
452
613
  * @param latestBlock - The block number the chain was pruned to.
453
614
  */ async handlePruneL2Blocks(latestBlock) {
454
- const txsToDelete = [];
615
+ const txsToDelete = new Map();
616
+ const minedTxs = await this.txPool.getMinedTxHashes();
617
+ // Find transactions that reference pruned blocks in their historical header
455
618
  for (const tx of (await this.txPool.getAllTxs())){
456
619
  // every tx that's been generated against a block that has now been pruned is no longer valid
457
- if (tx.data.constants.historicalHeader.globalVariables.blockNumber.toNumber() > latestBlock) {
458
- txsToDelete.push(await tx.getTxHash());
620
+ if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber > latestBlock) {
621
+ const txHash = tx.getTxHash();
622
+ txsToDelete.set(txHash.toString(), txHash);
459
623
  }
460
624
  }
461
- this.log.info(`Detected chain prune. Removing invalid txs count=${txsToDelete.length} newLatestBlock=${latestBlock} previousLatestBlock=${this.getSyncedLatestBlockNum()}`);
625
+ this.log.info(`Detected chain prune. Removing ${txsToDelete.size} txs built against pruned blocks.`, {
626
+ newLatestBlock: latestBlock,
627
+ previousLatestBlock: await this.getSyncedLatestBlockNum(),
628
+ txsToDelete: Array.from(txsToDelete.keys())
629
+ });
462
630
  // delete invalid txs (both pending and mined)
463
- await this.txPool.deleteTxs(txsToDelete);
631
+ await this.txPool.deleteTxs(Array.from(txsToDelete.values()));
464
632
  // everything left in the mined set was built against a block on the proven chain so its still valid
465
- // move back to pending the txs that were reorged out of the chain
633
+ // move back to pending the txs that were reorged out of the chain, unless txPoolDeleteTxsAfterReorg is set,
634
+ // in which case we clean them up to avoid potential reorg loops
466
635
  // NOTE: we can't move _all_ txs back to pending because the tx pool could keep hold of mined txs for longer
467
636
  // (see this.keepProvenTxsFor)
468
- const txsToMoveToPending = [];
469
- for (const [txHash, blockNumber] of (await this.txPool.getMinedTxHashes())){
470
- if (blockNumber > latestBlock) {
471
- txsToMoveToPending.push(txHash);
637
+ const minedTxsFromReorg = [];
638
+ for (const [txHash, blockNumber] of minedTxs){
639
+ // We keep the txsToDelete out of this list as they have already been deleted above
640
+ if (blockNumber > latestBlock && !txsToDelete.has(txHash.toString())) {
641
+ minedTxsFromReorg.push(txHash);
472
642
  }
473
643
  }
474
- this.log.info(`Moving ${txsToMoveToPending.length} mined txs back to pending`);
475
- await this.txPool.markMinedAsPending(txsToMoveToPending);
644
+ if (this.config.txPoolDeleteTxsAfterReorg) {
645
+ this.log.info(`Deleting ${minedTxsFromReorg.length} mined txs from reorg`);
646
+ await this.txPool.deleteTxs(minedTxsFromReorg);
647
+ } else {
648
+ this.log.info(`Moving ${minedTxsFromReorg.length} mined txs from reorg back to pending`);
649
+ await this.txPool.markMinedAsPending(minedTxsFromReorg);
650
+ }
476
651
  await this.synchedLatestBlockNumber.set(latestBlock);
477
652
  // no need to update block hashes, as they will be updated as new blocks are added
478
653
  }
479
654
  async startServiceIfSynched() {
480
- if (this.currentState === 1 && await this.getSyncedLatestBlockNum() >= this.latestBlockNumberAtStart && await this.getSyncedProvenBlockNum() >= this.provenBlockNumberAtStart) {
481
- this.log.debug(`Synched to blocks at start`);
482
- this.setCurrentState(2);
655
+ if (this.currentState !== P2PClientState.SYNCHING) {
656
+ return;
657
+ }
658
+ const syncedFinalizedBlock = await this.getSyncedFinalizedBlockNum();
659
+ const syncedProvenBlock = await this.getSyncedProvenBlockNum();
660
+ const syncedLatestBlock = await this.getSyncedLatestBlockNum();
661
+ if (syncedLatestBlock >= this.latestBlockNumberAtStart && syncedProvenBlock >= this.provenBlockNumberAtStart && syncedFinalizedBlock >= this.finalizedBlockNumberAtStart) {
662
+ this.log.info(`Completed P2P client sync to block ${syncedLatestBlock}. Starting service.`, {
663
+ syncedLatestBlock,
664
+ syncedProvenBlock,
665
+ syncedFinalizedBlock
666
+ });
667
+ this.setCurrentState(P2PClientState.RUNNING);
483
668
  if (this.syncResolve !== undefined) {
484
669
  this.syncResolve();
485
670
  await this.p2pService.start();
@@ -494,12 +679,23 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
494
679
  this.currentState = newState;
495
680
  this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
496
681
  }
682
+ validate(txs) {
683
+ return this.p2pService.validate(txs);
684
+ }
685
+ /**
686
+ * Marks transactions as non-evictable in the pool.
687
+ * @param txHashes - Hashes of the transactions to mark as non-evictable.
688
+ */ markTxsAsNonEvictable(txHashes) {
689
+ return this.txPool.markTxsAsNonEvictable(txHashes);
690
+ }
691
+ handleAuthRequestFromPeer(authRequest, peerId) {
692
+ return this.p2pService.handleAuthRequestFromPeer(authRequest, peerId);
693
+ }
497
694
  }
498
695
  _ts_decorate([
499
696
  trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
500
- [Attributes.BLOCK_NUMBER]: proposal.blockNumber.toNumber(),
501
- [Attributes.SLOT_NUMBER]: proposal.slotNumber.toNumber(),
697
+ [Attributes.SLOT_NUMBER]: proposal.slotNumber,
502
698
  [Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
503
- [Attributes.P2P_ID]: (await proposal.p2pMessageIdentifier()).toString()
699
+ [Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString()
504
700
  }))
505
701
  ], P2PClient.prototype, "broadcastProposal", null);