@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
@@ -0,0 +1,43 @@
1
+ import { Buffer32 } from '@aztec/foundation/buffer';
2
+ import { Signature } from '@aztec/foundation/eth-signature';
3
+ import { Fr } from '@aztec/foundation/fields';
4
+ import { BufferReader } from '@aztec/foundation/serialize';
5
+ import { StatusMessage } from './status.js';
6
+ export declare const VALIDATOR_AUTH_DOMAIN_SEPARATOR = "Aztec Validator Challenge:";
7
+ export declare const VALIDATOR_AUTH_FULL_CHALLENGE_ENCODED_LENGTH: number;
8
+ export declare class AuthRequest {
9
+ readonly status: StatusMessage;
10
+ readonly challenge: Fr;
11
+ constructor(status: StatusMessage, challenge: Fr);
12
+ /**
13
+ * Deserializes the AuthRequest object from a Buffer.
14
+ * @param buffer - Buffer or BufferReader object to deserialize.
15
+ * @returns An instance of StatusMessage.
16
+ */
17
+ static fromBuffer(buffer: Buffer | BufferReader): AuthRequest;
18
+ /**
19
+ * Serializes the AuthRequest object into a Buffer.
20
+ * @returns Buffer representation of the StatusMessage object.
21
+ */
22
+ toBuffer(): Buffer<ArrayBufferLike>;
23
+ getPayloadToSign(): Buffer32;
24
+ static random(): AuthRequest;
25
+ }
26
+ export declare class AuthResponse {
27
+ readonly status: StatusMessage;
28
+ readonly signature: Signature;
29
+ constructor(status: StatusMessage, signature: Signature);
30
+ /**
31
+ * Deserializes the AuthResponse object from a Buffer.
32
+ * @param buffer - Buffer or BufferReader object to deserialize.
33
+ * @returns An instance of StatusMessage.
34
+ */
35
+ static fromBuffer(buffer: Buffer | BufferReader): AuthResponse;
36
+ /**
37
+ * Serializes the AuthRequest object into a Buffer.
38
+ * @returns Buffer representation of the StatusMessage object.
39
+ */
40
+ toBuffer(): Buffer<ArrayBufferLike>;
41
+ static random(): AuthResponse;
42
+ }
43
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3JlcXJlc3AvcHJvdG9jb2xzL2F1dGgudHMiXSwibmFtZXMiOltdLC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H,QAAQ,4BAEP;IAED,MAAM,CAAC,MAAM,IAAI,YAAY,CAE5B;CACF"}
@@ -0,0 +1,71 @@
1
+ import { Buffer32 } from '@aztec/foundation/buffer';
2
+ import { keccak256 } from '@aztec/foundation/crypto';
3
+ import { Signature } from '@aztec/foundation/eth-signature';
4
+ import { Fr } from '@aztec/foundation/fields';
5
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
6
+ import { StatusMessage } from './status.js';
7
+ export const VALIDATOR_AUTH_DOMAIN_SEPARATOR = 'Aztec Validator Challenge:';
8
+ export const VALIDATOR_AUTH_FULL_CHALLENGE_ENCODED_LENGTH = VALIDATOR_AUTH_DOMAIN_SEPARATOR.length + Fr.random().toString().length;
9
+ /*
10
+ * P2P Auth Message
11
+ * Superset of the StatusMessage, used to establish a handshake between peers and authenticate them.
12
+ */ export class AuthRequest {
13
+ status;
14
+ challenge;
15
+ constructor(status, challenge){
16
+ this.status = status;
17
+ this.challenge = challenge;
18
+ }
19
+ /**
20
+ * Deserializes the AuthRequest object from a Buffer.
21
+ * @param buffer - Buffer or BufferReader object to deserialize.
22
+ * @returns An instance of StatusMessage.
23
+ */ static fromBuffer(buffer) {
24
+ const reader = BufferReader.asReader(buffer);
25
+ return new AuthRequest(StatusMessage.fromBuffer(reader), Fr.fromBuffer(reader));
26
+ }
27
+ /**
28
+ * Serializes the AuthRequest object into a Buffer.
29
+ * @returns Buffer representation of the StatusMessage object.
30
+ */ toBuffer() {
31
+ return serializeToBuffer([
32
+ this.status,
33
+ this.challenge
34
+ ]);
35
+ }
36
+ getPayloadToSign() {
37
+ const fullChallenge = VALIDATOR_AUTH_DOMAIN_SEPARATOR + this.challenge.toString();
38
+ return Buffer32.fromBuffer(keccak256(Buffer.from(fullChallenge, 'utf-8')));
39
+ }
40
+ static random() {
41
+ return new AuthRequest(StatusMessage.random(), Fr.random());
42
+ }
43
+ }
44
+ export class AuthResponse {
45
+ status;
46
+ signature;
47
+ constructor(status, signature){
48
+ this.status = status;
49
+ this.signature = signature;
50
+ }
51
+ /**
52
+ * Deserializes the AuthResponse object from a Buffer.
53
+ * @param buffer - Buffer or BufferReader object to deserialize.
54
+ * @returns An instance of StatusMessage.
55
+ */ static fromBuffer(buffer) {
56
+ const reader = BufferReader.asReader(buffer);
57
+ return new AuthResponse(StatusMessage.fromBuffer(reader), Signature.fromBuffer(reader));
58
+ }
59
+ /**
60
+ * Serializes the AuthRequest object into a Buffer.
61
+ * @returns Buffer representation of the StatusMessage object.
62
+ */ toBuffer() {
63
+ return serializeToBuffer([
64
+ this.status,
65
+ this.signature
66
+ ]);
67
+ }
68
+ static random() {
69
+ return new AuthResponse(StatusMessage.random(), Signature.random());
70
+ }
71
+ }
@@ -1,4 +1,9 @@
1
1
  import type { L2BlockSource } from '@aztec/stdlib/block';
2
2
  import type { ReqRespSubProtocolHandler } from '../interface.js';
3
+ /**
4
+ * Handler for L2 Block requests
5
+ * @param l2BlockSource - source for L2 blocks
6
+ * @returns the Block request handler
7
+ * */
3
8
  export declare function reqRespBlockHandler(l2BlockSource: L2BlockSource): ReqRespSubProtocolHandler;
4
- //# sourceMappingURL=block.d.ts.map
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2suZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9zZXJ2aWNlcy9yZXFyZXNwL3Byb3RvY29scy9ibG9jay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUl6RCxPQUFPLEtBQUssRUFBRSx5QkFBeUIsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBR2pFOzs7O0tBSUs7QUFDTCx3QkFBZ0IsbUJBQW1CLENBQUMsYUFBYSxFQUFFLGFBQWEsR0FBRyx5QkFBeUIsQ0FzQjNGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/block.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,yBAAyB,CAO3F"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/block.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAGjE;;;;KAIK;AACL,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,yBAAyB,CAsB3F"}
@@ -1,8 +1,31 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
- export function reqRespBlockHandler(l2BlockSource) {
3
- return async (_peerId, msg)=>{
4
- const blockNumber = Fr.fromBuffer(msg);
5
- const foundBlock = await l2BlockSource.getBlock(Number(blockNumber));
6
- return foundBlock ? foundBlock.toBuffer() : Buffer.alloc(0);
2
+ import { ReqRespStatus, ReqRespStatusError } from '../status.js';
3
+ /**
4
+ * Handler for L2 Block requests
5
+ * @param l2BlockSource - source for L2 blocks
6
+ * @returns the Block request handler
7
+ * */ export function reqRespBlockHandler(l2BlockSource) {
8
+ /**
9
+ * @param peerId - the peer ID of the requester
10
+ * @param msg - the block request message, which is expected to contain valid block number as a Buffer
11
+ * @returns a Buffer containing the requested block data, or an empty Buffer if the block is not found
12
+ * @throws ReqRespStatusError if the input msg is not a valid block number
13
+ * */ return async (_peerId, msg)=>{
14
+ let blockNumber;
15
+ try {
16
+ blockNumber = Fr.fromBuffer(msg);
17
+ } catch (err) {
18
+ throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, {
19
+ cause: err
20
+ });
21
+ }
22
+ try {
23
+ const foundBlock = await l2BlockSource.getBlock(Number(blockNumber));
24
+ return foundBlock ? foundBlock.toBuffer() : Buffer.alloc(0);
25
+ } catch (err) {
26
+ throw new ReqRespStatusError(ReqRespStatus.INTERNAL_ERROR, {
27
+ cause: err
28
+ });
29
+ }
7
30
  };
8
31
  }
@@ -0,0 +1,30 @@
1
+ import { BufferReader } from '@aztec/foundation/serialize';
2
+ /**
3
+ * BitVector helper class for representing and serializing bit vectors
4
+ */
5
+ export declare class BitVector {
6
+ private buffer;
7
+ private length;
8
+ constructor(buffer: Buffer, length: number);
9
+ static init(length: number, indices: number[]): BitVector;
10
+ getLength(): number;
11
+ isSet(index: number): boolean;
12
+ /**
13
+ * Returns all indices which are set to true
14
+ * */
15
+ getTrueIndices(): number[];
16
+ /**
17
+ * Serializes the BitVector object into a Buffer
18
+ *
19
+ * @returns Buffer representation of the BitVector object
20
+ * */
21
+ toBuffer(): Buffer;
22
+ /**
23
+ * Deserializes buffer into new BitVector
24
+ *
25
+ * @returns A new BitVector instance
26
+ * */
27
+ static fromBuffer(buffer: Buffer | BufferReader): BitVector;
28
+ static byteLength(length: number): number;
29
+ }
30
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYml0dmVjdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvc2VydmljZXMvcmVxcmVzcC9wcm90b2NvbHMvYmxvY2tfdHhzL2JpdHZlY3Rvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFxQixNQUFNLDZCQUE2QixDQUFDO0FBRTlFOztHQUVHO0FBQ0gscUJBQWEsU0FBUztJQUNwQixPQUFPLENBQUMsTUFBTSxDQUFTO0lBQ3ZCLE9BQU8sQ0FBQyxNQUFNLENBQVM7SUFFdkIsWUFBWSxNQUFNLE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jB;IAED;;;;SAIK;IACL,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAM1D;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,UAE/B;CACF"}
@@ -0,0 +1,75 @@
1
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
2
+ /**
3
+ * BitVector helper class for representing and serializing bit vectors
4
+ */ export class BitVector {
5
+ buffer;
6
+ length;
7
+ constructor(buffer, length){
8
+ this.buffer = buffer;
9
+ this.length = length;
10
+ }
11
+ /*
12
+ * Creates new BitVector instance
13
+ * @param length - Length of the bit vector
14
+ * @param indices - Array of indices to set to 1 in the bit vector
15
+ *
16
+ * @returns A new BitVector instance with specified length and set indices
17
+ * */ static init(length, indices) {
18
+ if (indices.length > length) {
19
+ throw new Error('Indices length exceeds specified length');
20
+ }
21
+ const buffer = Buffer.alloc(BitVector.byteLength(length));
22
+ indices.forEach((idx)=>{
23
+ const invalidIndex = idx < 0 || idx >= length;
24
+ if (invalidIndex) {
25
+ throw new Error(`Index ${idx} is out of bounds for BitVector of length ${length}`);
26
+ }
27
+ const byteIndex = Math.floor(idx / 8);
28
+ const bitIndex = idx % 8;
29
+ buffer[byteIndex] |= 1 << bitIndex;
30
+ });
31
+ return new BitVector(buffer, length);
32
+ }
33
+ getLength() {
34
+ return this.length;
35
+ }
36
+ /*
37
+ * Checks if element at index is set to true
38
+ *
39
+ * @param index - Index of the bit to check
40
+ *
41
+ * @returns True if the bit at index is set, false otherwise
42
+ * */ isSet(index) {
43
+ return index >= 0 && index < this.length && !!(this.buffer[Math.floor(index / 8)] & 1 << index % 8);
44
+ }
45
+ /**
46
+ * Returns all indices which are set to true
47
+ * */ getTrueIndices() {
48
+ return Array.from({
49
+ length: this.length
50
+ }, (_, i)=>i).filter((i)=>this.isSet(i));
51
+ }
52
+ /**
53
+ * Serializes the BitVector object into a Buffer
54
+ *
55
+ * @returns Buffer representation of the BitVector object
56
+ * */ toBuffer() {
57
+ return serializeToBuffer([
58
+ this.length,
59
+ this.buffer
60
+ ]);
61
+ }
62
+ /**
63
+ * Deserializes buffer into new BitVector
64
+ *
65
+ * @returns A new BitVector instance
66
+ * */ static fromBuffer(buffer) {
67
+ const reader = BufferReader.asReader(buffer);
68
+ const length = reader.readNumber();
69
+ const bitBuffer = reader.readBytes(BitVector.byteLength(length));
70
+ return new BitVector(bitBuffer, length);
71
+ }
72
+ static byteLength(length) {
73
+ return Math.ceil(length / 8);
74
+ }
75
+ }
@@ -0,0 +1,11 @@
1
+ import type { AttestationPool } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
2
+ import type { TxPool } from '../../../../mem_pools/index.js';
3
+ import type { ReqRespSubProtocolHandler } from '../../interface.js';
4
+ /**
5
+ * Handler for block txs requests
6
+ * @param attestationPool - the attestation pool to check for block proposals
7
+ * @param mempools - the mempools containing the tx pool
8
+ * @returns the BlockTxs request handler
9
+ */
10
+ export declare function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool: TxPool): ReqRespSubProtocolHandler;
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfdHhzX2hhbmRsZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9zZXJ2aWNlcy9yZXFyZXNwL3Byb3RvY29scy9ibG9ja190eHMvYmxvY2tfdHhzX2hhbmRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sNERBQTRELENBQUM7QUFDbEcsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQUUseUJBQXlCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUtwRTs7Ozs7R0FLRztBQUNILHdCQUFnQixzQkFBc0IsQ0FBQyxlQUFlLEVBQUUsZUFBZSxFQUFFLE1BQU0sRUFBRSxNQUFNLEdBQUcseUJBQXlCLENBbUNsSCJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block_txs_handler.d.ts","sourceRoot":"","sources":["../../../../../src/services/reqresp/protocols/block_txs/block_txs_handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAC;AAClG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAKpE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,yBAAyB,CAmClH"}
@@ -0,0 +1,39 @@
1
+ import { TxArray } from '@aztec/stdlib/tx';
2
+ import { ReqRespStatus, ReqRespStatusError } from '../../status.js';
3
+ import { BitVector } from './bitvector.js';
4
+ import { BlockTxsRequest, BlockTxsResponse } from './block_txs_reqresp.js';
5
+ /**
6
+ * Handler for block txs requests
7
+ * @param attestationPool - the attestation pool to check for block proposals
8
+ * @param mempools - the mempools containing the tx pool
9
+ * @returns the BlockTxs request handler
10
+ */ export function reqRespBlockTxsHandler(attestationPool, txPool) {
11
+ /**
12
+ * Handler for block txs requests
13
+ * @param msg - the block txs request message
14
+ * @returns the block txs response message
15
+ * @throws if msg is not a valid block txs request
16
+ */ return async (_peerId, msg)=>{
17
+ let request;
18
+ try {
19
+ request = BlockTxsRequest.fromBuffer(msg);
20
+ } catch (err) {
21
+ throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, {
22
+ cause: err
23
+ });
24
+ }
25
+ const blockProposal = await attestationPool.getBlockProposal(request.blockHash.toString());
26
+ if (!blockProposal) {
27
+ throw new ReqRespStatusError(ReqRespStatus.NOT_FOUND);
28
+ }
29
+ const txsAvailableInPool = await txPool.hasTxs(blockProposal.txHashes);
30
+ //Map txs in the pool to their indices in the block proposal
31
+ const availableIndices = txsAvailableInPool.map((hasTx, idx)=>hasTx ? idx : -1).filter((idx)=>idx !== -1);
32
+ const responseBitVector = BitVector.init(blockProposal.txHashes.length, availableIndices);
33
+ const requestedIndices = new Set(request.txIndices.getTrueIndices());
34
+ const requestedTxsHashes = blockProposal.txHashes.filter((_, idx)=>requestedIndices.has(idx));
35
+ const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter((tx)=>!!tx);
36
+ const response = new BlockTxsResponse(request.blockHash, new TxArray(...responseTxs), responseBitVector);
37
+ return response.toBuffer();
38
+ };
39
+ }
@@ -0,0 +1,47 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { BufferReader } from '@aztec/foundation/serialize';
3
+ import { TxArray } from '@aztec/stdlib/tx';
4
+ import { BitVector } from './bitvector.js';
5
+ /**
6
+ * Request message for requesting specific transactions from a block
7
+ */
8
+ export declare class BlockTxsRequest {
9
+ readonly blockHash: Fr;
10
+ readonly txIndices: BitVector;
11
+ constructor(blockHash: Fr, txIndices: BitVector);
12
+ /**
13
+ * Deserializes the BlockTxRequest object from a Buffer
14
+ * @param buffer - Buffer or BufferReader object to deserialize
15
+ * @returns An instance of BlockTxRequest
16
+ */
17
+ static fromBuffer(buffer: Buffer | BufferReader): BlockTxsRequest;
18
+ /**
19
+ * Serializes the BlockTxRequest object into a Buffer
20
+ * @returns Buffer representation of the BlockTxRequest object
21
+ */
22
+ toBuffer(): Buffer;
23
+ }
24
+ /**
25
+ * Response message containing requested transactions from a block
26
+ */
27
+ export declare class BlockTxsResponse {
28
+ readonly blockHash: Fr;
29
+ readonly txs: TxArray;
30
+ readonly txIndices: BitVector;
31
+ constructor(blockHash: Fr, txs: TxArray, txIndices: BitVector);
32
+ /**
33
+ * Deserializes the BlockTxResponse object from a Buffer
34
+ * @param buffer - Buffer or BufferReader object to deserialize
35
+ * @returns An instance of BlockTxResponse
36
+ */
37
+ static fromBuffer(buffer: Buffer | BufferReader): BlockTxsResponse;
38
+ /**
39
+ * Serializes the BlockTxResponse object into a Buffer
40
+ * @dev: In current implementation, txIndices is serialized as Buffer of unknown length,
41
+ * thus we serialize it last
42
+ * @returns Buffer representation of the BlockTxResponse object
43
+ */
44
+ toBuffer(): Buffer;
45
+ static empty(): BlockTxsResponse;
46
+ }
47
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfdHhzX3JlcXJlc3AuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9zZXJ2aWNlcy9yZXFyZXNwL3Byb3RvY29scy9ibG9ja190eHMvYmxvY2tfdHhzX3JlcXJlc3AudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQzlDLE9BQU8sRUFBRSxZQUFZLEVBQXFCLE1BQU0sNkJBQTZCLENBQUM7QUFDOUUsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTNDLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUUzQzs7R0FFRztBQUNILHFCQUFhLGVBQWU7SUFFeEIsUUFBUSxDQUFDLFNBQVMsRUFBRSxFQUFFO0lBR3RCLFFBQVEsQ0FBQyxTQUFTLEVBQUUsU0FBUztJQUovQixZQUNXLFNBQVMsRUFBRSxFQUFFLEVBR2IsU0FBUyxFQUFFLFNBQVMsRUFDM0I7SUFFSjs7OztPQUlHO0lBQ0gsTUFBTSxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLFlBQVksR0FBRyxlQUFlLENBTWhFO0lBRUQ7OztPQUdHO0lBQ0gsUUFBUSxJQUFJLE1BQU0sQ0FFakI7Q0FDRjtBQUVEOztHQUVH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gB;IAEzB,QAAQ,CAAC,SAAS,EAAE,EAAE;IACtB,QAAQ,CAAC,GAAG,EAAE,OAAO;IAGrB,QAAQ,CAAC,SAAS,EAAE,SAAS;IAL/B,YACW,SAAS,EAAE,EAAE,EACb,GAAG,EAAE,OAAO,EAGZ,SAAS,EAAE,SAAS,EAC3B;IAEJ;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB,CAOjE;IAED;;;;;OAKG;IACH,QAAQ,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,KAAK,IAAI,gBAAgB,CAE/B;CACF"}
@@ -0,0 +1,75 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
+ import { TxArray } from '@aztec/stdlib/tx';
4
+ import { BitVector } from './bitvector.js';
5
+ /**
6
+ * Request message for requesting specific transactions from a block
7
+ */ export class BlockTxsRequest {
8
+ blockHash;
9
+ txIndices;
10
+ constructor(blockHash, // BitVector indicating which txs from the proposal we are requesting
11
+ // 1 means we want the tx, 0 means we don't
12
+ txIndices){
13
+ this.blockHash = blockHash;
14
+ this.txIndices = txIndices;
15
+ }
16
+ /**
17
+ * Deserializes the BlockTxRequest object from a Buffer
18
+ * @param buffer - Buffer or BufferReader object to deserialize
19
+ * @returns An instance of BlockTxRequest
20
+ */ static fromBuffer(buffer) {
21
+ const reader = BufferReader.asReader(buffer);
22
+ const blockHash = Fr.fromBuffer(reader);
23
+ const txIndices = BitVector.fromBuffer(reader);
24
+ return new BlockTxsRequest(blockHash, txIndices);
25
+ }
26
+ /**
27
+ * Serializes the BlockTxRequest object into a Buffer
28
+ * @returns Buffer representation of the BlockTxRequest object
29
+ */ toBuffer() {
30
+ return serializeToBuffer([
31
+ this.blockHash,
32
+ this.txIndices.toBuffer()
33
+ ]);
34
+ }
35
+ }
36
+ /**
37
+ * Response message containing requested transactions from a block
38
+ */ export class BlockTxsResponse {
39
+ blockHash;
40
+ txs;
41
+ txIndices;
42
+ constructor(blockHash, txs, // BitVector indicating which txs from the proposal are available at the peer
43
+ // 1 means the tx is available, 0 means it is not
44
+ txIndices){
45
+ this.blockHash = blockHash;
46
+ this.txs = txs;
47
+ this.txIndices = txIndices;
48
+ }
49
+ /**
50
+ * Deserializes the BlockTxResponse object from a Buffer
51
+ * @param buffer - Buffer or BufferReader object to deserialize
52
+ * @returns An instance of BlockTxResponse
53
+ */ static fromBuffer(buffer) {
54
+ const reader = BufferReader.asReader(buffer);
55
+ const blockHash = Fr.fromBuffer(reader);
56
+ const txs = TxArray.fromBuffer(reader);
57
+ const txIndices = BitVector.fromBuffer(reader);
58
+ return new BlockTxsResponse(blockHash, txs, txIndices);
59
+ }
60
+ /**
61
+ * Serializes the BlockTxResponse object into a Buffer
62
+ * @dev: In current implementation, txIndices is serialized as Buffer of unknown length,
63
+ * thus we serialize it last
64
+ * @returns Buffer representation of the BlockTxResponse object
65
+ */ toBuffer() {
66
+ return serializeToBuffer([
67
+ this.blockHash,
68
+ this.txs.toBuffer(),
69
+ this.txIndices.toBuffer()
70
+ ]);
71
+ }
72
+ static empty() {
73
+ return new BlockTxsResponse(Fr.ZERO, new TxArray(), BitVector.init(0, []));
74
+ }
75
+ }
@@ -0,0 +1,4 @@
1
+ export * from './block_txs_handler.js';
2
+ export * from './bitvector.js';
3
+ export * from './block_txs_reqresp.js';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9zZXJ2aWNlcy9yZXFyZXNwL3Byb3RvY29scy9ibG9ja190eHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyx3QkFBd0IsQ0FBQztBQUN2QyxjQUFjLGdCQUFnQixDQUFDO0FBQy9CLGNBQWMsd0JBQXdCLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/reqresp/protocols/block_txs/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './block_txs_handler.js';
2
+ export * from './bitvector.js';
3
+ export * from './block_txs_reqresp.js';
@@ -1,7 +1,5 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import type { PeerId } from '@libp2p/interface';
4
- import type { PeerManager } from '../../peer-manager/peer_manager.js';
2
+ import type { PeerManagerInterface } from '../../peer-manager/interface.js';
5
3
  import { type ReqRespSubProtocolHandler } from '../interface.js';
6
4
  import type { ReqResp } from '../reqresp.js';
7
5
  /**
@@ -47,5 +45,5 @@ export declare class GoodbyeProtocolHandler {
47
45
  * @param peerManager - The peer manager.
48
46
  * @returns A resolved promise with the goodbye response.
49
47
  */
50
- export declare function reqGoodbyeHandler(peerManager: PeerManager): ReqRespSubProtocolHandler;
51
- //# sourceMappingURL=goodbye.d.ts.map
48
+ export declare function reqGoodbyeHandler(peerManager: PeerManagerInterface): ReqRespSubProtocolHandler;
49
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ29vZGJ5ZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3JlcXJlc3AvcHJvdG9jb2xzL2dvb2RieWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFaEQsT0FBTyxLQUFLLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM1RSxPQUFPLEV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":"","sources":["../../../../src/services/reqresp/protocols/goodbye.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAsB,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;GAEG;AACH,oBAAY,aAAa;IACvB,0FAA0F;IAC1F,QAAQ,IAAM;IACd,sIAAsI;IACtI,SAAS,IAAM;IACf,gFAAgF;IAChF,SAAS,IAAM;IACf,2EAA2E;IAC3E,MAAM,IAAM;IACZ,2BAA2B;IAC3B,aAAa,IAAM;IACnB,qBAAqB;IACrB,OAAO,IAAM;CACd;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CASjE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAgBjE;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,MAAM,CAAwC;gBAElC,OAAO,EAAE,OAAO;IAEvB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,yBAAyB,CASrF"}
1
+ {"version":3,"file":"goodbye.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/goodbye.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAsB,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;GAEG;AACH,oBAAY,aAAa;IACvB,0FAA0F;IAC1F,QAAQ,IAAM;IACd,sIAAsI;IACtI,SAAS,IAAM;IACf,gFAAgF;IAChF,SAAS,IAAM;IACf,2EAA2E;IAC3E,MAAM,IAAM;IACZ,2BAA2B;IAC3B,aAAa,IAAM;IACnB,qBAAqB;IACrB,OAAO,IAAM;CACd;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CASjE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAgBjE;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,MAAM,CAAwC;IAEtD,YAAoB,OAAO,EAAE,OAAO,EAAI;IAE3B,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAO7E;CACF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,GAAG,yBAAyB,CAW9F"}
@@ -22,7 +22,7 @@ export function decodeGoodbyeReason(buffer) {
22
22
  throw new Error('Invalid goodbye reason buffer length');
23
23
  }
24
24
  return buffer[0];
25
- } catch (error) {
25
+ } catch {
26
26
  return 6;
27
27
  }
28
28
  }
@@ -76,12 +76,12 @@ export function decodeGoodbyeReason(buffer) {
76
76
  * @param peerManager - The peer manager.
77
77
  * @returns A resolved promise with the goodbye response.
78
78
  */ export function reqGoodbyeHandler(peerManager) {
79
- return (peerId, _msg)=>{
80
- const reason = decodeGoodbyeReason(_msg);
79
+ return (peerId, msg)=>{
80
+ const reason = decodeGoodbyeReason(msg);
81
81
  peerManager.goodbyeReceived(peerId, reason);
82
- // Return a buffer of length 1 as an acknowledgement: this is allowed to fail
83
- return Promise.resolve(Buffer.from([
84
- 0x0
85
- ]));
82
+ // NOTE: In the current implementation this won't be sent to peer,
83
+ // as the connection to peer has been already closed by peerManager.goodbyeReceived
84
+ // We have this just to satisfy interface
85
+ return Promise.resolve(Buffer.alloc(0));
86
86
  };
87
87
  }
@@ -6,4 +6,6 @@ export * from './status.js';
6
6
  export * from './tx.js';
7
7
  export * from './goodbye.js';
8
8
  export * from './block.js';
9
- //# sourceMappingURL=index.d.ts.map
9
+ export * from './auth.js';
10
+ export * from './block_txs/index.js';
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9zZXJ2aWNlcy9yZXFyZXNwL3Byb3RvY29scy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUNILGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsU0FBUyxDQUFDO0FBQ3hCLGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsc0JBQXNCLENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
@@ -5,3 +5,5 @@ export * from './status.js';
5
5
  export * from './tx.js';
6
6
  export * from './goodbye.js';
7
7
  export * from './block.js';
8
+ export * from './auth.js';
9
+ export * from './block_txs/index.js';
@@ -1,9 +1,7 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  /**
4
2
  * Handles the ping request.
5
3
  * @param _msg - The ping request message.
6
4
  * @returns A resolved promise with the pong response.
7
5
  */
8
6
  export declare function pingHandler(_msg: any): Promise<Buffer>;
9
- //# sourceMappingURL=ping.d.ts.map
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3JlcXJlc3AvcHJvdG9jb2xzL3BpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7R0FJRztBQUNILHdCQUFnQixXQUFXLENBQUMsSUFBSSxFQUFFLEdBQUcsR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBRXREIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/ping.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtD"}
1
+ {"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/ping.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtD"}