@aztec/p2p 0.0.0-test.1 → 0.0.1-commit.24de95ac

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 (339) hide show
  1. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  2. package/dest/bootstrap/bootstrap.js +22 -9
  3. package/dest/client/factory.d.ts +13 -3
  4. package/dest/client/factory.d.ts.map +1 -1
  5. package/dest/client/factory.js +60 -24
  6. package/dest/client/index.d.ts +1 -0
  7. package/dest/client/index.d.ts.map +1 -1
  8. package/dest/client/index.js +1 -0
  9. package/dest/client/interface.d.ts +155 -0
  10. package/dest/client/interface.d.ts.map +1 -0
  11. package/dest/client/interface.js +9 -0
  12. package/dest/client/p2p_client.d.ts +72 -169
  13. package/dest/client/p2p_client.d.ts.map +1 -1
  14. package/dest/client/p2p_client.js +365 -174
  15. package/dest/config.d.ts +123 -103
  16. package/dest/config.d.ts.map +1 -1
  17. package/dest/config.js +173 -34
  18. package/dest/enr/generate-enr.d.ts +10 -2
  19. package/dest/enr/generate-enr.d.ts.map +1 -1
  20. package/dest/enr/generate-enr.js +27 -5
  21. package/dest/index.d.ts +3 -0
  22. package/dest/index.d.ts.map +1 -1
  23. package/dest/index.js +2 -0
  24. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +42 -4
  25. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  26. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +204 -54
  28. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +10 -2
  29. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +93 -15
  31. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +10 -2
  32. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  33. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +86 -18
  34. package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -2
  35. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  36. package/dest/mem_pools/attestation_pool/mocks.js +9 -15
  37. package/dest/mem_pools/instrumentation.d.ts +7 -11
  38. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  39. package/dest/mem_pools/instrumentation.js +25 -37
  40. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +93 -9
  41. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  42. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +469 -97
  43. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +33 -9
  44. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  45. package/dest/mem_pools/tx_pool/memory_tx_pool.js +133 -36
  46. package/dest/mem_pools/tx_pool/priority.js +1 -1
  47. package/dest/mem_pools/tx_pool/tx_pool.d.ts +64 -8
  48. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  50. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +264 -39
  51. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -0
  52. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  53. package/dest/msg_validators/attestation_validator/attestation_validator.js +45 -9
  54. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +5 -1
  55. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
  56. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +61 -12
  57. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +10 -0
  58. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
  59. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
  60. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +3 -0
  61. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -0
  62. package/dest/msg_validators/tx_validator/allowed_public_setup.js +27 -0
  63. package/dest/msg_validators/tx_validator/archive_cache.d.ts +14 -0
  64. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -0
  65. package/dest/msg_validators/tx_validator/archive_cache.js +22 -0
  66. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  67. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -4
  68. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  69. package/dest/msg_validators/tx_validator/data_validator.js +56 -86
  70. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +0 -2
  71. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  72. package/dest/msg_validators/tx_validator/double_spend_validator.js +21 -27
  73. package/dest/msg_validators/tx_validator/factory.d.ts +15 -0
  74. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
  75. package/dest/msg_validators/tx_validator/factory.js +74 -0
  76. package/dest/msg_validators/tx_validator/gas_validator.d.ts +11 -0
  77. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -0
  78. package/dest/msg_validators/tx_validator/gas_validator.js +115 -0
  79. package/dest/msg_validators/tx_validator/index.d.ts +7 -0
  80. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  81. package/dest/msg_validators/tx_validator/index.js +7 -0
  82. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +7 -3
  83. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  84. package/dest/msg_validators/tx_validator/metadata_validator.js +39 -20
  85. package/dest/msg_validators/tx_validator/phases_validator.d.ts +14 -0
  86. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -0
  87. package/dest/msg_validators/tx_validator/phases_validator.js +91 -0
  88. package/dest/msg_validators/tx_validator/test_utils.d.ts +17 -0
  89. package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -0
  90. package/dest/msg_validators/tx_validator/test_utils.js +22 -0
  91. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +12 -0
  92. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -0
  93. package/dest/msg_validators/tx_validator/timestamp_validator.js +32 -0
  94. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +8 -0
  95. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -0
  96. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +24 -0
  97. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  98. package/dest/msg_validators/tx_validator/tx_proof_validator.js +6 -5
  99. package/dest/services/discv5/discV5_service.d.ts +9 -8
  100. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  101. package/dest/services/discv5/discV5_service.js +63 -36
  102. package/dest/services/dummy_service.d.ts +49 -10
  103. package/dest/services/dummy_service.d.ts.map +1 -1
  104. package/dest/services/dummy_service.js +88 -5
  105. package/dest/services/encoding.d.ts +25 -6
  106. package/dest/services/encoding.d.ts.map +1 -1
  107. package/dest/services/encoding.js +73 -5
  108. package/dest/services/index.d.ts +4 -0
  109. package/dest/services/index.d.ts.map +1 -1
  110. package/dest/services/index.js +4 -0
  111. package/dest/services/libp2p/instrumentation.d.ts +18 -0
  112. package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
  113. package/dest/services/libp2p/instrumentation.js +157 -0
  114. package/dest/services/libp2p/libp2p_service.d.ts +87 -42
  115. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  116. package/dest/services/libp2p/libp2p_service.js +500 -218
  117. package/dest/services/peer-manager/interface.d.ts +23 -0
  118. package/dest/services/peer-manager/interface.d.ts.map +1 -0
  119. package/dest/services/peer-manager/interface.js +1 -0
  120. package/dest/services/peer-manager/metrics.d.ts +3 -1
  121. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  122. package/dest/services/peer-manager/metrics.js +11 -2
  123. package/dest/services/peer-manager/peer_manager.d.ts +126 -15
  124. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  125. package/dest/services/peer-manager/peer_manager.js +547 -72
  126. package/dest/services/reqresp/config.d.ts +10 -8
  127. package/dest/services/reqresp/config.d.ts.map +1 -1
  128. package/dest/services/reqresp/config.js +18 -4
  129. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
  130. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  131. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +10 -6
  132. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +30 -13
  133. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  134. package/dest/services/reqresp/connection-sampler/connection_sampler.js +142 -84
  135. package/dest/services/reqresp/index.d.ts +2 -1
  136. package/dest/services/reqresp/index.d.ts.map +1 -1
  137. package/dest/services/reqresp/index.js +2 -1
  138. package/dest/services/reqresp/interface.d.ts +72 -23
  139. package/dest/services/reqresp/interface.d.ts.map +1 -1
  140. package/dest/services/reqresp/interface.js +45 -26
  141. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  142. package/dest/services/reqresp/protocols/auth.d.ts +43 -0
  143. package/dest/services/reqresp/protocols/auth.d.ts.map +1 -0
  144. package/dest/services/reqresp/protocols/auth.js +71 -0
  145. package/dest/services/reqresp/protocols/block.d.ts +5 -0
  146. package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
  147. package/dest/services/reqresp/protocols/block.js +28 -5
  148. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +30 -0
  149. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -0
  150. package/dest/services/reqresp/protocols/block_txs/bitvector.js +75 -0
  151. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +11 -0
  152. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -0
  153. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +39 -0
  154. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +49 -0
  155. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -0
  156. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +75 -0
  157. package/dest/services/reqresp/protocols/block_txs/index.d.ts +4 -0
  158. package/dest/services/reqresp/protocols/block_txs/index.d.ts.map +1 -0
  159. package/dest/services/reqresp/protocols/block_txs/index.js +3 -0
  160. package/dest/services/reqresp/protocols/goodbye.d.ts +2 -4
  161. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  162. package/dest/services/reqresp/protocols/goodbye.js +7 -7
  163. package/dest/services/reqresp/protocols/index.d.ts +2 -0
  164. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  165. package/dest/services/reqresp/protocols/index.js +2 -0
  166. package/dest/services/reqresp/protocols/ping.d.ts +0 -2
  167. package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
  168. package/dest/services/reqresp/protocols/status.d.ts +38 -6
  169. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  170. package/dest/services/reqresp/protocols/status.js +72 -5
  171. package/dest/services/reqresp/protocols/tx.d.ts +12 -1
  172. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  173. package/dest/services/reqresp/protocols/tx.js +34 -6
  174. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +4 -2
  175. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  176. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
  177. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  178. package/dest/services/reqresp/rate-limiter/rate_limits.js +21 -1
  179. package/dest/services/reqresp/reqresp.d.ts +45 -47
  180. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  181. package/dest/services/reqresp/reqresp.js +298 -207
  182. package/dest/services/reqresp/status.d.ts +9 -3
  183. package/dest/services/reqresp/status.d.ts.map +1 -1
  184. package/dest/services/reqresp/status.js +9 -2
  185. package/dest/services/service.d.ts +22 -18
  186. package/dest/services/service.d.ts.map +1 -1
  187. package/dest/services/tx_collection/config.d.ts +25 -0
  188. package/dest/services/tx_collection/config.d.ts.map +1 -0
  189. package/dest/services/tx_collection/config.js +58 -0
  190. package/dest/services/tx_collection/fast_tx_collection.d.ts +56 -0
  191. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -0
  192. package/dest/services/tx_collection/fast_tx_collection.js +300 -0
  193. package/dest/services/tx_collection/index.d.ts +3 -0
  194. package/dest/services/tx_collection/index.d.ts.map +1 -0
  195. package/dest/services/tx_collection/index.js +2 -0
  196. package/dest/services/tx_collection/instrumentation.d.ts +10 -0
  197. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -0
  198. package/dest/services/tx_collection/instrumentation.js +34 -0
  199. package/dest/services/tx_collection/slow_tx_collection.d.ts +54 -0
  200. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
  201. package/dest/services/tx_collection/slow_tx_collection.js +176 -0
  202. package/dest/services/tx_collection/tx_collection.d.ts +110 -0
  203. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -0
  204. package/dest/services/tx_collection/tx_collection.js +128 -0
  205. package/dest/services/tx_collection/tx_collection_sink.d.ts +30 -0
  206. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -0
  207. package/dest/services/tx_collection/tx_collection_sink.js +111 -0
  208. package/dest/services/tx_collection/tx_source.d.ts +18 -0
  209. package/dest/services/tx_collection/tx_source.d.ts.map +1 -0
  210. package/dest/services/tx_collection/tx_source.js +31 -0
  211. package/dest/services/tx_provider.d.ts +49 -0
  212. package/dest/services/tx_provider.d.ts.map +1 -0
  213. package/dest/services/tx_provider.js +210 -0
  214. package/dest/services/tx_provider_instrumentation.d.ts +13 -0
  215. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -0
  216. package/dest/services/tx_provider_instrumentation.js +34 -0
  217. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  218. package/dest/test-helpers/index.d.ts +1 -0
  219. package/dest/test-helpers/index.d.ts.map +1 -1
  220. package/dest/test-helpers/index.js +1 -0
  221. package/dest/test-helpers/make-enrs.d.ts.map +1 -1
  222. package/dest/test-helpers/make-enrs.js +4 -5
  223. package/dest/test-helpers/make-test-p2p-clients.d.ts +32 -4
  224. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  225. package/dest/test-helpers/make-test-p2p-clients.js +86 -16
  226. package/dest/test-helpers/mock-pubsub.d.ts +59 -0
  227. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -0
  228. package/dest/test-helpers/mock-pubsub.js +130 -0
  229. package/dest/test-helpers/mock-tx-helpers.d.ts +12 -0
  230. package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -0
  231. package/dest/test-helpers/mock-tx-helpers.js +19 -0
  232. package/dest/test-helpers/reqresp-nodes.d.ts +14 -10
  233. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  234. package/dest/test-helpers/reqresp-nodes.js +62 -28
  235. package/dest/testbench/p2p_client_testbench_worker.js +96 -25
  236. package/dest/testbench/parse_log_file.js +4 -4
  237. package/dest/testbench/testbench.js +4 -4
  238. package/dest/testbench/worker_client_manager.d.ts +0 -5
  239. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  240. package/dest/testbench/worker_client_manager.js +11 -19
  241. package/dest/types/index.d.ts +3 -1
  242. package/dest/types/index.d.ts.map +1 -1
  243. package/dest/types/index.js +2 -0
  244. package/dest/util.d.ts +22 -15
  245. package/dest/util.d.ts.map +1 -1
  246. package/dest/util.js +64 -67
  247. package/dest/versioning.d.ts +3 -3
  248. package/dest/versioning.d.ts.map +1 -1
  249. package/dest/versioning.js +8 -3
  250. package/package.json +28 -24
  251. package/src/bootstrap/bootstrap.ts +27 -11
  252. package/src/client/factory.ts +136 -45
  253. package/src/client/index.ts +1 -0
  254. package/src/client/interface.ts +195 -0
  255. package/src/client/p2p_client.ts +460 -327
  256. package/src/config.ts +288 -134
  257. package/src/enr/generate-enr.ts +39 -6
  258. package/src/index.ts +4 -0
  259. package/src/mem_pools/attestation_pool/attestation_pool.ts +48 -4
  260. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +241 -55
  261. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +117 -20
  262. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +114 -22
  263. package/src/mem_pools/attestation_pool/mocks.ts +11 -10
  264. package/src/mem_pools/instrumentation.ts +32 -46
  265. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +549 -108
  266. package/src/mem_pools/tx_pool/memory_tx_pool.ts +153 -44
  267. package/src/mem_pools/tx_pool/priority.ts +1 -1
  268. package/src/mem_pools/tx_pool/tx_pool.ts +67 -8
  269. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +217 -34
  270. package/src/msg_validators/attestation_validator/attestation_validator.ts +55 -10
  271. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +66 -14
  272. package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
  273. package/src/msg_validators/tx_validator/allowed_public_setup.ts +35 -0
  274. package/src/msg_validators/tx_validator/archive_cache.ts +28 -0
  275. package/src/msg_validators/tx_validator/block_header_validator.ts +4 -4
  276. package/src/msg_validators/tx_validator/data_validator.ts +81 -69
  277. package/src/msg_validators/tx_validator/double_spend_validator.ts +19 -17
  278. package/src/msg_validators/tx_validator/factory.ts +109 -0
  279. package/src/msg_validators/tx_validator/gas_validator.ts +134 -0
  280. package/src/msg_validators/tx_validator/index.ts +7 -0
  281. package/src/msg_validators/tx_validator/metadata_validator.ts +58 -21
  282. package/src/msg_validators/tx_validator/phases_validator.ts +114 -0
  283. package/src/msg_validators/tx_validator/test_utils.ts +43 -0
  284. package/src/msg_validators/tx_validator/timestamp_validator.ts +46 -0
  285. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +17 -0
  286. package/src/msg_validators/tx_validator/tx_proof_validator.ts +6 -5
  287. package/src/services/discv5/discV5_service.ts +84 -38
  288. package/src/services/dummy_service.ts +147 -9
  289. package/src/services/encoding.ts +80 -5
  290. package/src/services/index.ts +4 -0
  291. package/src/services/libp2p/instrumentation.ts +158 -0
  292. package/src/services/libp2p/libp2p_service.ts +646 -263
  293. package/src/services/peer-manager/interface.ts +29 -0
  294. package/src/services/peer-manager/metrics.ts +16 -1
  295. package/src/services/peer-manager/peer_manager.ts +652 -78
  296. package/src/services/reqresp/config.ts +26 -9
  297. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +12 -6
  298. package/src/services/reqresp/connection-sampler/connection_sampler.ts +148 -95
  299. package/src/services/reqresp/index.ts +2 -0
  300. package/src/services/reqresp/interface.ts +91 -36
  301. package/src/services/reqresp/metrics.ts +4 -1
  302. package/src/services/reqresp/protocols/auth.ts +83 -0
  303. package/src/services/reqresp/protocols/block.ts +24 -3
  304. package/src/services/reqresp/protocols/block_txs/bitvector.ts +90 -0
  305. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +53 -0
  306. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +79 -0
  307. package/src/services/reqresp/protocols/block_txs/index.ts +3 -0
  308. package/src/services/reqresp/protocols/goodbye.ts +9 -7
  309. package/src/services/reqresp/protocols/index.ts +2 -0
  310. package/src/services/reqresp/protocols/status.ts +117 -5
  311. package/src/services/reqresp/protocols/tx.ts +35 -6
  312. package/src/services/reqresp/rate-limiter/rate_limiter.ts +12 -3
  313. package/src/services/reqresp/rate-limiter/rate_limits.ts +21 -1
  314. package/src/services/reqresp/reqresp.ts +387 -256
  315. package/src/services/reqresp/status.ts +12 -3
  316. package/src/services/service.ts +45 -21
  317. package/src/services/tx_collection/config.ts +84 -0
  318. package/src/services/tx_collection/fast_tx_collection.ts +340 -0
  319. package/src/services/tx_collection/index.ts +2 -0
  320. package/src/services/tx_collection/instrumentation.ts +43 -0
  321. package/src/services/tx_collection/slow_tx_collection.ts +232 -0
  322. package/src/services/tx_collection/tx_collection.ts +215 -0
  323. package/src/services/tx_collection/tx_collection_sink.ts +129 -0
  324. package/src/services/tx_collection/tx_source.ts +37 -0
  325. package/src/services/tx_provider.ts +216 -0
  326. package/src/services/tx_provider_instrumentation.ts +44 -0
  327. package/src/test-helpers/index.ts +1 -0
  328. package/src/test-helpers/make-enrs.ts +4 -5
  329. package/src/test-helpers/make-test-p2p-clients.ts +111 -21
  330. package/src/test-helpers/mock-pubsub.ts +188 -0
  331. package/src/test-helpers/mock-tx-helpers.ts +24 -0
  332. package/src/test-helpers/reqresp-nodes.ts +86 -35
  333. package/src/testbench/p2p_client_testbench_worker.ts +145 -22
  334. package/src/testbench/parse_log_file.ts +4 -4
  335. package/src/testbench/testbench.ts +4 -4
  336. package/src/testbench/worker_client_manager.ts +17 -23
  337. package/src/types/index.ts +2 -0
  338. package/src/util.ts +93 -89
  339. package/src/versioning.ts +11 -4
package/src/config.ts CHANGED
@@ -1,78 +1,64 @@
1
1
  import {
2
2
  type ConfigMappingsType,
3
+ SecretValue,
3
4
  booleanConfigHelper,
5
+ floatConfigHelper,
4
6
  getConfigFromMappings,
5
7
  getDefaultConfig,
6
8
  numberConfigHelper,
7
9
  pickConfigMappings,
10
+ secretStringConfigHelper,
8
11
  } from '@aztec/foundation/config';
12
+ import { Fr } from '@aztec/foundation/fields';
9
13
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
10
- import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
14
+ import { FunctionSelector } from '@aztec/stdlib/abi';
15
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
16
+ import { type AllowedElement, type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
11
17
 
12
18
  import { type P2PReqRespConfig, p2pReqRespConfigMappings } from './services/reqresp/config.js';
19
+ import { type TxCollectionConfig, txCollectionConfigMappings } from './services/tx_collection/config.js';
13
20
 
14
21
  /**
15
22
  * P2P client configuration values.
16
23
  */
17
- export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
18
- /**
19
- * A flag dictating whether the P2P subsystem should be enabled.
20
- */
24
+ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionConfig {
25
+ /** A flag dictating whether the P2P subsystem should be enabled. */
21
26
  p2pEnabled: boolean;
22
27
 
23
- /**
24
- * The frequency in which to check for new L2 blocks.
25
- */
28
+ /** The frequency in which to check for new L2 blocks. */
26
29
  blockCheckIntervalMS: number;
27
30
 
28
- /**
29
- * The number of blocks to fetch in a single batch.
30
- */
31
+ /** The number of blocks to fetch in a single batch. */
31
32
  blockRequestBatchSize: number;
32
33
 
33
- /**
34
- * DEBUG: Disable colocation penalty - for testing purposes only
35
- */
34
+ /** DEBUG: Disable colocation penalty - for testing purposes only */
36
35
  debugDisableColocationPenalty: boolean;
37
36
 
38
- /**
39
- * The frequency in which to check for new peers.
40
- */
37
+ /** The frequency in which to check for new peers. */
41
38
  peerCheckIntervalMS: number;
42
39
 
43
- /**
44
- * Size of queue of L2 blocks to store.
45
- */
40
+ /** Size of queue of L2 blocks to store. */
46
41
  l2QueueSize: number;
47
42
 
48
- /**
49
- * The announce address for TCP.
50
- */
51
- tcpAnnounceAddress?: string;
52
-
53
- /**
54
- * The announce address for UDP.
55
- */
56
- udpAnnounceAddress?: string;
57
-
58
- /**
59
- * The listen address for TCP.
60
- */
61
- tcpListenAddress: string;
62
-
63
- /**
64
- * The listen address for UDP.
65
- */
66
- udpListenAddress: string;
67
-
68
- /**
69
- * An optional peer id private key. If blank, will generate a random key.
70
- */
71
- peerIdPrivateKey?: string;
72
-
73
- /**
74
- * A list of bootstrap peers to connect to.
75
- */
43
+ /** The port for the P2P service. */
44
+ p2pPort: number;
45
+
46
+ /** The port to broadcast the P2P service on (included in the node's ENR). */
47
+ p2pBroadcastPort?: number;
48
+
49
+ /** The IP address for the P2P service. */
50
+ p2pIp?: string;
51
+
52
+ /** The listen address. */
53
+ listenAddress: string;
54
+
55
+ /** An optional peer id private key. If blank, will generate a random key. */
56
+ peerIdPrivateKey?: SecretValue<string>;
57
+
58
+ /** An optional path to store generated peer id private keys. If blank, will default to storing any generated keys in the data directory. */
59
+ peerIdPrivateKeyPath?: string;
60
+
61
+ /** A list of bootstrap peers to connect to. */
76
62
  bootstrapNodes: string[];
77
63
 
78
64
  /** Whether to execute the version check in the bootstrap node ENR. */
@@ -81,97 +67,118 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
81
67
  /** Whether to consider any configured bootnodes as full peers, e.g. for transaction gossiping */
82
68
  bootstrapNodesAsFullPeers: boolean;
83
69
 
84
- /**
85
- * The maximum number of peers (a peer count above this will cause the node to refuse connection attempts)
86
- */
70
+ /** The maximum number of peers (a peer count above this will cause the node to refuse connection attempts) */
87
71
  maxPeerCount: number;
88
72
 
89
- /**
90
- * If announceUdpAddress or announceTcpAddress are not provided, query for the IP address of the machine. Default is false.
91
- */
73
+ /** If announceUdpAddress or announceTcpAddress are not provided, query for the IP address of the machine. Default is false. */
92
74
  queryForIp: boolean;
93
75
 
94
- /** How many blocks have to pass after a block is proven before its txs are deleted (zero to delete immediately once proven) */
95
- keepProvenTxsInPoolFor: number;
96
-
97
- /** How many slots to keep attestations for. */
98
- keepAttestationsInPoolFor: number;
99
-
100
- /**
101
- * The interval of the gossipsub heartbeat to perform maintenance tasks.
102
- */
76
+ /** The interval of the gossipsub heartbeat to perform maintenance tasks. */
103
77
  gossipsubInterval: number;
104
78
 
105
- /**
106
- * The D parameter for the gossipsub protocol.
107
- */
79
+ /** The D parameter for the gossipsub protocol. */
108
80
  gossipsubD: number;
109
81
 
110
- /**
111
- * The Dlo parameter for the gossipsub protocol.
112
- */
82
+ /** The Dlo parameter for the gossipsub protocol. */
113
83
  gossipsubDlo: number;
114
84
 
115
- /**
116
- * The Dhi parameter for the gossipsub protocol.
117
- */
85
+ /** The Dhi parameter for the gossipsub protocol. */
118
86
  gossipsubDhi: number;
119
87
 
120
- /**
121
- * The Dlazy parameter for the gossipsub protocol.
122
- */
88
+ /** The Dlazy parameter for the gossipsub protocol. */
123
89
  gossipsubDLazy: number;
124
90
 
125
- /**
126
- * Whether to flood publish messages. - For testing purposes only
127
- */
91
+ /** Whether to flood publish messages. - For testing purposes only */
128
92
  gossipsubFloodPublish: boolean;
129
93
 
130
- /**
131
- * The number of gossipsub interval message cache windows to keep.
132
- */
94
+ /** The number of gossipsub interval message cache windows to keep. */
133
95
  gossipsubMcacheLength: number;
134
96
 
135
- /**
136
- * How many message cache windows to include when gossiping with other pears.
137
- */
97
+ /** How many message cache windows to include when gossiping with other pears. */
138
98
  gossipsubMcacheGossip: number;
139
99
 
140
- /**
141
- * The 'age' (in # of L2 blocks) of a processed tx after which we heavily penalize a peer for re-sending it.
142
- */
100
+ /** How long to keep message IDs in the seen cache (ms). */
101
+ gossipsubSeenTTL: number;
102
+
103
+ /** The 'age' (in # of L2 blocks) of a processed tx after which we heavily penalize a peer for re-sending it. */
143
104
  doubleSpendSeverePeerPenaltyWindow: number;
144
105
 
145
- /**
146
- * The weight of the tx topic for the gossipsub protocol. This determines how much the score for this specific topic contributes to the overall peer score.
147
- */
106
+ /** The weight of the tx topic for the gossipsub protocol. This determines how much the score for this specific topic contributes to the overall peer score. */
148
107
  gossipsubTxTopicWeight: number;
149
108
 
150
- /**
151
- * This is the weight applied to the penalty for delivering invalid messages.
152
- */
109
+ /** This is the weight applied to the penalty for delivering invalid messages. */
153
110
  gossipsubTxInvalidMessageDeliveriesWeight: number;
154
111
 
155
- /**
156
- * determines how quickly the penalty for invalid message deliveries decays over time. Between 0 and 1.
157
- */
112
+ /** determines how quickly the penalty for invalid message deliveries decays over time. Between 0 and 1. */
158
113
  gossipsubTxInvalidMessageDeliveriesDecay: number;
159
114
 
160
- /**
161
- * The values for the peer scoring system. Passed as a comma separated list of values in order: low, mid, high tolerance errors.
162
- */
115
+ /** The values for the peer scoring system. Passed as a comma separated list of values in order: low, mid, high tolerance errors. */
163
116
  peerPenaltyValues: number[];
164
117
 
165
118
  /** Limit of transactions to archive in the tx pool. Once the archived tx limit is reached, the oldest archived txs will be purged. */
166
119
  archivedTxLimit: number;
120
+
121
+ /** A list of trusted peers. */
122
+ trustedPeers: string[];
123
+
124
+ /** A list of private peers. */
125
+ privatePeers: string[];
126
+
127
+ /** A list of preferred peers. */
128
+ preferredPeers: string[];
129
+
130
+ /** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
131
+ p2pStoreMapSizeKb?: number;
132
+
133
+ /** Which calls are allowed in the public setup phase of a tx. */
134
+ txPublicSetupAllowList: AllowedElement[];
135
+
136
+ /** The maximum cumulative tx size (in bytes) of pending txs before evicting lower priority txs. */
137
+ maxTxPoolSize: number;
138
+
139
+ /** If the pool is full, it will still accept a few more txs until it reached maxTxPoolOverspillFactor * maxTxPoolSize. Then it will evict */
140
+ txPoolOverflowFactor: number;
141
+
142
+ /** The node's seen message ID cache size */
143
+ seenMessageCacheSize: number;
144
+
145
+ /** True to disable the status handshake on peer connected. */
146
+ p2pDisableStatusHandshake?: boolean;
147
+
148
+ /** True to only permit validators to connect */
149
+ p2pAllowOnlyValidators?: boolean;
150
+
151
+ /** True to disable participating in discovery */
152
+ p2pDiscoveryDisabled?: boolean;
153
+ /** Number of auth attempts to allow before peer is banned. Number is inclusive*/
154
+ p2pMaxFailedAuthAttemptsAllowed: number;
155
+
156
+ /** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
157
+ disableTransactions: boolean;
158
+
159
+ /** True to simulate discarding transactions. - For testing purposes only*/
160
+ dropTransactions: boolean;
161
+
162
+ /** The probability that a transaction is discarded. - For testing purposes only */
163
+ dropTransactionsProbability: number;
164
+
165
+ /** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
166
+ txPoolDeleteTxsAfterReorg: boolean;
167
167
  }
168
168
 
169
+ export const DEFAULT_P2P_PORT = 40400;
170
+
169
171
  export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
170
172
  p2pEnabled: {
171
173
  env: 'P2P_ENABLED',
172
174
  description: 'A flag dictating whether the P2P subsystem should be enabled.',
173
175
  ...booleanConfigHelper(),
174
176
  },
177
+ p2pDiscoveryDisabled: {
178
+ env: 'P2P_DISCOVERY_DISABLED',
179
+ description: 'A flag dictating whether the P2P discovery system should be disabled.',
180
+ ...booleanConfigHelper(false),
181
+ },
175
182
  blockCheckIntervalMS: {
176
183
  env: 'P2P_BLOCK_CHECK_INTERVAL_MS',
177
184
  description: 'The frequency in which to check for new L2 blocks.',
@@ -192,34 +199,39 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
192
199
  description: 'Size of queue of L2 blocks to store.',
193
200
  ...numberConfigHelper(1_000),
194
201
  },
195
- tcpListenAddress: {
196
- env: 'P2P_TCP_LISTEN_ADDR',
197
- defaultValue: '0.0.0.0:40400',
198
- description: 'The listen address for TCP. Format: <IP_ADDRESS>:<PORT>.',
202
+ listenAddress: {
203
+ env: 'P2P_LISTEN_ADDR',
204
+ defaultValue: '0.0.0.0',
205
+ description: 'The listen address. ipv4 address.',
199
206
  },
200
- udpListenAddress: {
201
- env: 'P2P_UDP_LISTEN_ADDR',
202
- defaultValue: '0.0.0.0:40400',
203
- description: 'The listen address for UDP. Format: <IP_ADDRESS>:<PORT>.',
207
+ p2pPort: {
208
+ env: 'P2P_PORT',
209
+ description: `The port for the P2P service. Defaults to ${DEFAULT_P2P_PORT}`,
210
+ ...numberConfigHelper(DEFAULT_P2P_PORT),
204
211
  },
205
- tcpAnnounceAddress: {
206
- env: 'P2P_TCP_ANNOUNCE_ADDR',
207
- description:
208
- 'The announce address for TCP. Format: <IP_ADDRESS>:<PORT>. Leave IP_ADDRESS blank to query for public IP.',
212
+ p2pBroadcastPort: {
213
+ env: 'P2P_BROADCAST_PORT',
214
+ description: `The port to broadcast the P2P service on (included in the node's ENR). Defaults to P2P_PORT.`,
209
215
  },
210
- udpAnnounceAddress: {
211
- env: 'P2P_UDP_ANNOUNCE_ADDR',
212
- description:
213
- 'The announce address for UDP. Format: <IP_ADDRESS>:<PORT>. Leave IP_ADDRESS blank to query for public IP.',
216
+ p2pIp: {
217
+ env: 'P2P_IP',
218
+ description: 'The IP address for the P2P service. ipv4 address.',
214
219
  },
215
220
  peerIdPrivateKey: {
216
221
  env: 'PEER_ID_PRIVATE_KEY',
217
222
  description: 'An optional peer id private key. If blank, will generate a random key.',
223
+ ...secretStringConfigHelper(),
224
+ },
225
+ peerIdPrivateKeyPath: {
226
+ env: 'PEER_ID_PRIVATE_KEY_PATH',
227
+ description:
228
+ 'An optional path to store generated peer id private keys. If blank, will default to storing any generated keys in the root of the data directory.',
218
229
  },
219
230
  bootstrapNodes: {
220
231
  env: 'BOOTSTRAP_NODES',
221
232
  parseEnv: (val: string) => val.split(','),
222
233
  description: 'A list of bootstrap peer ENRs to connect to. Separated by commas.',
234
+ defaultValue: [],
223
235
  },
224
236
  bootstrapNodeEnrVersionCheck: {
225
237
  env: 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK',
@@ -242,17 +254,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
242
254
  'If announceUdpAddress or announceTcpAddress are not provided, query for the IP address of the machine. Default is false.',
243
255
  ...booleanConfigHelper(),
244
256
  },
245
- keepProvenTxsInPoolFor: {
246
- env: 'P2P_TX_POOL_KEEP_PROVEN_FOR',
247
- description:
248
- 'How many blocks have to pass after a block is proven before its txs are deleted (zero to delete immediately once proven)',
249
- ...numberConfigHelper(0),
250
- },
251
- keepAttestationsInPoolFor: {
252
- env: 'P2P_ATTESTATION_POOL_KEEP_FOR',
253
- description: 'How many slots to keep attestations for.',
254
- ...numberConfigHelper(96),
255
- },
256
257
  gossipsubInterval: {
257
258
  env: 'P2P_GOSSIPSUB_INTERVAL_MS',
258
259
  description: 'The interval of the gossipsub heartbeat to perform maintenance tasks.',
@@ -281,7 +282,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
281
282
  gossipsubFloodPublish: {
282
283
  env: 'P2P_GOSSIPSUB_FLOOD_PUBLISH',
283
284
  description: 'Whether to flood publish messages. - For testing purposes only',
284
- ...booleanConfigHelper(true),
285
+ ...booleanConfigHelper(false),
285
286
  },
286
287
  gossipsubMcacheLength: {
287
288
  env: 'P2P_GOSSIPSUB_MCACHE_LENGTH',
@@ -290,9 +291,14 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
290
291
  },
291
292
  gossipsubMcacheGossip: {
292
293
  env: 'P2P_GOSSIPSUB_MCACHE_GOSSIP',
293
- description: 'How many message cache windows to include when gossiping with other pears.',
294
+ description: 'How many message cache windows to include when gossiping with other peers.',
294
295
  ...numberConfigHelper(3),
295
296
  },
297
+ gossipsubSeenTTL: {
298
+ env: 'P2P_GOSSIPSUB_SEEN_TTL',
299
+ description: 'How long to keep message IDs in the seen cache.',
300
+ ...numberConfigHelper(20 * 60 * 1000),
301
+ },
296
302
  gossipsubTxTopicWeight: {
297
303
  env: 'P2P_GOSSIPSUB_TX_TOPIC_WEIGHT',
298
304
  description: 'The weight of the tx topic for the gossipsub protocol.',
@@ -331,8 +337,92 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
331
337
  'The number of transactions that will be archived. If the limit is set to 0 then archiving will be disabled.',
332
338
  ...numberConfigHelper(0),
333
339
  },
340
+ trustedPeers: {
341
+ env: 'P2P_TRUSTED_PEERS',
342
+ parseEnv: (val: string) => val.split(','),
343
+ description: 'A list of trusted peer ENRs that will always be persisted. Separated by commas.',
344
+ defaultValue: [],
345
+ },
346
+ privatePeers: {
347
+ env: 'P2P_PRIVATE_PEERS',
348
+ parseEnv: (val: string) => val.split(','),
349
+ description:
350
+ 'A list of private peer ENRs that will always be persisted and not be used for discovery. Separated by commas.',
351
+ defaultValue: [],
352
+ },
353
+ preferredPeers: {
354
+ env: 'P2P_PREFERRED_PEERS',
355
+ parseEnv: (val: string) => val.split(','),
356
+ description:
357
+ 'A list of preferred peer ENRs that will always be persisted and not be used for discovery. Separated by commas.',
358
+ defaultValue: [],
359
+ },
360
+ p2pStoreMapSizeKb: {
361
+ env: 'P2P_STORE_MAP_SIZE_KB',
362
+ parseEnv: (val: string | undefined) => (val ? +val : undefined),
363
+ description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
364
+ },
365
+ txPublicSetupAllowList: {
366
+ env: 'TX_PUBLIC_SETUP_ALLOWLIST',
367
+ parseEnv: (val: string) => parseAllowList(val),
368
+ description: 'The list of functions calls allowed to run in setup',
369
+ printDefault: () =>
370
+ 'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
371
+ },
372
+ maxTxPoolSize: {
373
+ env: 'P2P_MAX_TX_POOL_SIZE',
374
+ description: 'The maximum cumulative tx size of pending txs (in bytes) before evicting lower priority txs.',
375
+ ...numberConfigHelper(100_000_000), // 100MB
376
+ },
377
+ txPoolOverflowFactor: {
378
+ env: 'P2P_TX_POOL_OVERFLOW_FACTOR',
379
+ description: 'How much the tx pool can overflow before it starts evicting txs. Must be greater than 1',
380
+ ...floatConfigHelper(1.1), // 10% overflow
381
+ },
382
+ seenMessageCacheSize: {
383
+ env: 'P2P_SEEN_MSG_CACHE_SIZE',
384
+ description: 'The number of messages to keep in the seen message cache',
385
+ ...numberConfigHelper(100_000), // 100K
386
+ },
387
+ p2pDisableStatusHandshake: {
388
+ env: 'P2P_DISABLE_STATUS_HANDSHAKE',
389
+ description: 'True to disable the status handshake on peer connected.',
390
+ ...booleanConfigHelper(false),
391
+ },
392
+ p2pAllowOnlyValidators: {
393
+ env: 'P2P_ALLOW_ONLY_VALIDATORS',
394
+ description: 'True to only permit validators to connect.',
395
+ ...booleanConfigHelper(false),
396
+ },
397
+ p2pMaxFailedAuthAttemptsAllowed: {
398
+ env: 'P2P_MAX_AUTH_FAILED_ATTEMPTS_ALLOWED',
399
+ description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
400
+ ...numberConfigHelper(3),
401
+ },
402
+ dropTransactions: {
403
+ env: 'P2P_DROP_TX',
404
+ description: 'True to simulate discarding transactions. - For testing purposes only',
405
+ ...booleanConfigHelper(false),
406
+ },
407
+ dropTransactionsProbability: {
408
+ env: 'P2P_DROP_TX_CHANCE',
409
+ description: 'The probability that a transaction is discarded. - For testing purposes only',
410
+ ...floatConfigHelper(0),
411
+ },
412
+ disableTransactions: {
413
+ env: 'TRANSACTIONS_DISABLED',
414
+ description:
415
+ 'Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers.',
416
+ ...booleanConfigHelper(false),
417
+ },
418
+ txPoolDeleteTxsAfterReorg: {
419
+ env: 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG',
420
+ description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
421
+ ...booleanConfigHelper(false),
422
+ },
334
423
  ...p2pReqRespConfigMappings,
335
424
  ...chainConfigMappings,
425
+ ...txCollectionConfigMappings,
336
426
  };
337
427
 
338
428
  /**
@@ -350,22 +440,86 @@ export function getP2PDefaultConfig(): P2PConfig {
350
440
  /**
351
441
  * Required P2P config values for a bootstrap node.
352
442
  */
353
- export type BootnodeConfig = Pick<P2PConfig, 'udpAnnounceAddress' | 'peerIdPrivateKey' | 'bootstrapNodes'> &
354
- Required<Pick<P2PConfig, 'udpListenAddress'>> &
355
- Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKB'> &
443
+ export type BootnodeConfig = Pick<
444
+ P2PConfig,
445
+ | 'p2pIp'
446
+ | 'p2pPort'
447
+ | 'p2pBroadcastPort'
448
+ | 'peerIdPrivateKey'
449
+ | 'peerIdPrivateKeyPath'
450
+ | 'bootstrapNodes'
451
+ | 'listenAddress'
452
+ | 'queryForIp'
453
+ > &
454
+ Required<Pick<P2PConfig, 'p2pIp' | 'p2pPort'>> &
455
+ Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'> &
356
456
  Pick<ChainConfig, 'l1ChainId'>;
357
457
 
358
458
  const bootnodeConfigKeys: (keyof BootnodeConfig)[] = [
359
- 'udpAnnounceAddress',
459
+ 'p2pIp',
460
+ 'p2pPort',
461
+ 'p2pBroadcastPort',
462
+ 'listenAddress',
360
463
  'peerIdPrivateKey',
361
- 'udpListenAddress',
464
+ 'peerIdPrivateKeyPath',
362
465
  'dataDirectory',
363
- 'dataStoreMapSizeKB',
466
+ 'dataStoreMapSizeKb',
364
467
  'bootstrapNodes',
365
468
  'l1ChainId',
469
+ 'queryForIp',
366
470
  ];
367
471
 
368
472
  export const bootnodeConfigMappings = pickConfigMappings(
369
473
  { ...p2pConfigMappings, ...dataConfigMappings, ...chainConfigMappings },
370
474
  bootnodeConfigKeys,
371
475
  );
476
+
477
+ /**
478
+ * Parses a string to a list of allowed elements.
479
+ * Each encoded is expected to be of one of the following formats
480
+ * `I:${address}`
481
+ * `I:${address}:${selector}`
482
+ * `C:${classId}`
483
+ * `C:${classId}:${selector}`
484
+ *
485
+ * @param value The string to parse
486
+ * @returns A list of allowed elements
487
+ */
488
+ export function parseAllowList(value: string): AllowedElement[] {
489
+ const entries: AllowedElement[] = [];
490
+
491
+ if (!value) {
492
+ return entries;
493
+ }
494
+
495
+ for (const val of value.split(',')) {
496
+ const [typeString, identifierString, selectorString] = val.split(':');
497
+ const selector = selectorString !== undefined ? FunctionSelector.fromString(selectorString) : undefined;
498
+
499
+ if (typeString === 'I') {
500
+ if (selector) {
501
+ entries.push({
502
+ address: AztecAddress.fromString(identifierString),
503
+ selector,
504
+ });
505
+ } else {
506
+ entries.push({
507
+ address: AztecAddress.fromString(identifierString),
508
+ });
509
+ }
510
+ } else if (typeString === 'C') {
511
+ if (selector) {
512
+ entries.push({
513
+ classId: Fr.fromHexString(identifierString),
514
+ selector,
515
+ });
516
+ } else {
517
+ entries.push({
518
+ classId: Fr.fromHexString(identifierString),
519
+ });
520
+ }
521
+ }
522
+ }
523
+
524
+ return entries;
525
+ }
@@ -1,22 +1,26 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
2
  import { type ChainConfig, emptyChainConfig } from '@aztec/stdlib/config';
3
+ import type { ComponentsVersions } from '@aztec/stdlib/versioning';
3
4
 
4
- import { ENR, SignableENR } from '@chainsafe/enr';
5
5
  import type { PeerId } from '@libp2p/interface';
6
- import { multiaddr } from '@multiformats/multiaddr';
6
+ import { type Multiaddr, multiaddr } from '@multiformats/multiaddr';
7
+ import { ENR, SignableENR } from '@nethermindeth/enr';
7
8
 
8
- import { AZTEC_ENR_KEY } from '../types/index.js';
9
+ import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from '../types/index.js';
9
10
  import { convertToMultiaddr, createLibP2PPeerIdFromPrivateKey } from '../util.js';
10
- import { setAztecEnrKey } from '../versioning.js';
11
+ import { setAztecClientVersionEnrKey, setAztecEnrKey } from '../versioning.js';
12
+
13
+ export { ENR };
11
14
 
12
15
  export async function createBootnodeENRandPeerId(
13
16
  privateKey: string,
14
- udpAnnounceAddress: string,
17
+ p2pIp: string,
18
+ p2pBroadcastPort: number,
15
19
  l1ChainId: number,
16
20
  ): Promise<{ enr: SignableENR; peerId: PeerId }> {
17
21
  const peerId = await createLibP2PPeerIdFromPrivateKey(privateKey);
18
22
  const enr = SignableENR.createFromPeerId(peerId);
19
- const publicAddr = multiaddr(convertToMultiaddr(udpAnnounceAddress, 'udp'));
23
+ const publicAddr = multiaddr(convertToMultiaddr(p2pIp, p2pBroadcastPort, 'udp'));
20
24
  enr.setLocationMultiaddr(publicAddr);
21
25
 
22
26
  const config: ChainConfig = {
@@ -28,12 +32,41 @@ export async function createBootnodeENRandPeerId(
28
32
  return { enr, peerId };
29
33
  }
30
34
 
35
+ export function createNodeENR(
36
+ peerId: PeerId,
37
+ multiAddrUdp: Multiaddr | undefined,
38
+ multiAddrTcp: Multiaddr | undefined,
39
+ chainConfig: ChainConfig,
40
+ packageVersion: string,
41
+ ): { enr: SignableENR; versions: ComponentsVersions } {
42
+ // create ENR from PeerId
43
+ const enr = SignableENR.createFromPeerId(peerId);
44
+ // Add aztec identification to ENR
45
+ const versions = setAztecEnrKey(enr, chainConfig);
46
+ // Add aztec client version to ENR
47
+ setAztecClientVersionEnrKey(enr, packageVersion);
48
+
49
+ // set location multiaddr in ENR record
50
+ if (multiAddrUdp) {
51
+ enr.setLocationMultiaddr(multiAddrUdp);
52
+ }
53
+ if (multiAddrTcp) {
54
+ enr.setLocationMultiaddr(multiAddrTcp);
55
+ }
56
+
57
+ return { enr, versions };
58
+ }
59
+
31
60
  export async function printENR(enr: string, log: LogFn) {
32
61
  const decoded = ENR.decodeTxt(enr);
33
62
  log(`PeerID: ${await decoded.peerId()}`);
34
63
  log(`IP: ${decoded.ip}`);
35
64
  log(`UDP: ${decoded.udp}`);
36
65
  log(`TCP: ${decoded.tcp}`);
66
+
37
67
  const aztec = decoded.kvs.get(AZTEC_ENR_KEY);
38
68
  log(`Aztec version: ${aztec?.toString()}`);
69
+
70
+ const aztecClientVersion = decoded.kvs.get(AZTEC_ENR_CLIENT_VERSION_KEY);
71
+ log(`Aztec client version ${aztecClientVersion ? aztecClientVersion!.toString() : 'N/A'}`);
39
72
  }
package/src/index.ts CHANGED
@@ -1,5 +1,9 @@
1
+ export { createSecp256k1PeerId } from '@libp2p/peer-id-factory';
2
+ export type { PeerId } from '@libp2p/interface';
3
+
1
4
  export * from './bootstrap/bootstrap.js';
2
5
  export * from './client/index.js';
6
+ export * from './enr/index.js';
3
7
  export * from './config.js';
4
8
  export * from './mem_pools/attestation_pool/index.js';
5
9
  export * from './mem_pools/tx_pool/index.js';