@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
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,124 @@ 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
+
168
+ /** Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY */
169
+ debugP2PInstrumentMessages: boolean;
170
+
171
+ /** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
172
+ fishermanMode: boolean;
167
173
  }
168
174
 
175
+ export const DEFAULT_P2P_PORT = 40400;
176
+
169
177
  export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
170
178
  p2pEnabled: {
171
179
  env: 'P2P_ENABLED',
172
180
  description: 'A flag dictating whether the P2P subsystem should be enabled.',
173
181
  ...booleanConfigHelper(),
174
182
  },
183
+ p2pDiscoveryDisabled: {
184
+ env: 'P2P_DISCOVERY_DISABLED',
185
+ description: 'A flag dictating whether the P2P discovery system should be disabled.',
186
+ ...booleanConfigHelper(false),
187
+ },
175
188
  blockCheckIntervalMS: {
176
189
  env: 'P2P_BLOCK_CHECK_INTERVAL_MS',
177
190
  description: 'The frequency in which to check for new L2 blocks.',
@@ -192,34 +205,39 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
192
205
  description: 'Size of queue of L2 blocks to store.',
193
206
  ...numberConfigHelper(1_000),
194
207
  },
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>.',
208
+ listenAddress: {
209
+ env: 'P2P_LISTEN_ADDR',
210
+ defaultValue: '0.0.0.0',
211
+ description: 'The listen address. ipv4 address.',
199
212
  },
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>.',
213
+ p2pPort: {
214
+ env: 'P2P_PORT',
215
+ description: `The port for the P2P service. Defaults to ${DEFAULT_P2P_PORT}`,
216
+ ...numberConfigHelper(DEFAULT_P2P_PORT),
204
217
  },
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.',
218
+ p2pBroadcastPort: {
219
+ env: 'P2P_BROADCAST_PORT',
220
+ description: `The port to broadcast the P2P service on (included in the node's ENR). Defaults to P2P_PORT.`,
209
221
  },
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.',
222
+ p2pIp: {
223
+ env: 'P2P_IP',
224
+ description: 'The IP address for the P2P service. ipv4 address.',
214
225
  },
215
226
  peerIdPrivateKey: {
216
227
  env: 'PEER_ID_PRIVATE_KEY',
217
228
  description: 'An optional peer id private key. If blank, will generate a random key.',
229
+ ...secretStringConfigHelper(),
230
+ },
231
+ peerIdPrivateKeyPath: {
232
+ env: 'PEER_ID_PRIVATE_KEY_PATH',
233
+ description:
234
+ '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
235
  },
219
236
  bootstrapNodes: {
220
237
  env: 'BOOTSTRAP_NODES',
221
238
  parseEnv: (val: string) => val.split(','),
222
239
  description: 'A list of bootstrap peer ENRs to connect to. Separated by commas.',
240
+ defaultValue: [],
223
241
  },
224
242
  bootstrapNodeEnrVersionCheck: {
225
243
  env: 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK',
@@ -242,17 +260,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
242
260
  'If announceUdpAddress or announceTcpAddress are not provided, query for the IP address of the machine. Default is false.',
243
261
  ...booleanConfigHelper(),
244
262
  },
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
263
  gossipsubInterval: {
257
264
  env: 'P2P_GOSSIPSUB_INTERVAL_MS',
258
265
  description: 'The interval of the gossipsub heartbeat to perform maintenance tasks.',
@@ -281,7 +288,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
281
288
  gossipsubFloodPublish: {
282
289
  env: 'P2P_GOSSIPSUB_FLOOD_PUBLISH',
283
290
  description: 'Whether to flood publish messages. - For testing purposes only',
284
- ...booleanConfigHelper(true),
291
+ ...booleanConfigHelper(false),
285
292
  },
286
293
  gossipsubMcacheLength: {
287
294
  env: 'P2P_GOSSIPSUB_MCACHE_LENGTH',
@@ -290,9 +297,14 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
290
297
  },
291
298
  gossipsubMcacheGossip: {
292
299
  env: 'P2P_GOSSIPSUB_MCACHE_GOSSIP',
293
- description: 'How many message cache windows to include when gossiping with other pears.',
300
+ description: 'How many message cache windows to include when gossiping with other peers.',
294
301
  ...numberConfigHelper(3),
295
302
  },
303
+ gossipsubSeenTTL: {
304
+ env: 'P2P_GOSSIPSUB_SEEN_TTL',
305
+ description: 'How long to keep message IDs in the seen cache.',
306
+ ...numberConfigHelper(20 * 60 * 1000),
307
+ },
296
308
  gossipsubTxTopicWeight: {
297
309
  env: 'P2P_GOSSIPSUB_TX_TOPIC_WEIGHT',
298
310
  description: 'The weight of the tx topic for the gossipsub protocol.',
@@ -331,8 +343,103 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
331
343
  'The number of transactions that will be archived. If the limit is set to 0 then archiving will be disabled.',
332
344
  ...numberConfigHelper(0),
333
345
  },
346
+ trustedPeers: {
347
+ env: 'P2P_TRUSTED_PEERS',
348
+ parseEnv: (val: string) => val.split(','),
349
+ description: 'A list of trusted peer ENRs that will always be persisted. Separated by commas.',
350
+ defaultValue: [],
351
+ },
352
+ privatePeers: {
353
+ env: 'P2P_PRIVATE_PEERS',
354
+ parseEnv: (val: string) => val.split(','),
355
+ description:
356
+ 'A list of private peer ENRs that will always be persisted and not be used for discovery. Separated by commas.',
357
+ defaultValue: [],
358
+ },
359
+ preferredPeers: {
360
+ env: 'P2P_PREFERRED_PEERS',
361
+ parseEnv: (val: string) => val.split(','),
362
+ description:
363
+ 'A list of preferred peer ENRs that will always be persisted and not be used for discovery. Separated by commas.',
364
+ defaultValue: [],
365
+ },
366
+ p2pStoreMapSizeKb: {
367
+ env: 'P2P_STORE_MAP_SIZE_KB',
368
+ parseEnv: (val: string | undefined) => (val ? +val : undefined),
369
+ description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
370
+ },
371
+ txPublicSetupAllowList: {
372
+ env: 'TX_PUBLIC_SETUP_ALLOWLIST',
373
+ parseEnv: (val: string) => parseAllowList(val),
374
+ description: 'The list of functions calls allowed to run in setup',
375
+ printDefault: () =>
376
+ 'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
377
+ },
378
+ maxTxPoolSize: {
379
+ env: 'P2P_MAX_TX_POOL_SIZE',
380
+ description: 'The maximum cumulative tx size of pending txs (in bytes) before evicting lower priority txs.',
381
+ ...numberConfigHelper(100_000_000), // 100MB
382
+ },
383
+ txPoolOverflowFactor: {
384
+ env: 'P2P_TX_POOL_OVERFLOW_FACTOR',
385
+ description: 'How much the tx pool can overflow before it starts evicting txs. Must be greater than 1',
386
+ ...floatConfigHelper(1.1), // 10% overflow
387
+ },
388
+ seenMessageCacheSize: {
389
+ env: 'P2P_SEEN_MSG_CACHE_SIZE',
390
+ description: 'The number of messages to keep in the seen message cache',
391
+ ...numberConfigHelper(100_000), // 100K
392
+ },
393
+ p2pDisableStatusHandshake: {
394
+ env: 'P2P_DISABLE_STATUS_HANDSHAKE',
395
+ description: 'True to disable the status handshake on peer connected.',
396
+ ...booleanConfigHelper(false),
397
+ },
398
+ p2pAllowOnlyValidators: {
399
+ env: 'P2P_ALLOW_ONLY_VALIDATORS',
400
+ description: 'True to only permit validators to connect.',
401
+ ...booleanConfigHelper(false),
402
+ },
403
+ p2pMaxFailedAuthAttemptsAllowed: {
404
+ env: 'P2P_MAX_AUTH_FAILED_ATTEMPTS_ALLOWED',
405
+ description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
406
+ ...numberConfigHelper(3),
407
+ },
408
+ dropTransactions: {
409
+ env: 'P2P_DROP_TX',
410
+ description: 'True to simulate discarding transactions. - For testing purposes only',
411
+ ...booleanConfigHelper(false),
412
+ },
413
+ dropTransactionsProbability: {
414
+ env: 'P2P_DROP_TX_CHANCE',
415
+ description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
416
+ ...floatConfigHelper(0),
417
+ },
418
+ disableTransactions: {
419
+ env: 'TRANSACTIONS_DISABLED',
420
+ description:
421
+ 'Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers.',
422
+ ...booleanConfigHelper(false),
423
+ },
424
+ txPoolDeleteTxsAfterReorg: {
425
+ env: 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG',
426
+ description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
427
+ ...booleanConfigHelper(false),
428
+ },
429
+ debugP2PInstrumentMessages: {
430
+ env: 'DEBUG_P2P_INSTRUMENT_MESSAGES',
431
+ description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
432
+ ...booleanConfigHelper(false),
433
+ },
434
+ fishermanMode: {
435
+ env: 'FISHERMAN_MODE',
436
+ description:
437
+ 'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
438
+ ...booleanConfigHelper(false),
439
+ },
334
440
  ...p2pReqRespConfigMappings,
335
441
  ...chainConfigMappings,
442
+ ...txCollectionConfigMappings,
336
443
  };
337
444
 
338
445
  /**
@@ -350,22 +457,86 @@ export function getP2PDefaultConfig(): P2PConfig {
350
457
  /**
351
458
  * Required P2P config values for a bootstrap node.
352
459
  */
353
- export type BootnodeConfig = Pick<P2PConfig, 'udpAnnounceAddress' | 'peerIdPrivateKey' | 'bootstrapNodes'> &
354
- Required<Pick<P2PConfig, 'udpListenAddress'>> &
355
- Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKB'> &
460
+ export type BootnodeConfig = Pick<
461
+ P2PConfig,
462
+ | 'p2pIp'
463
+ | 'p2pPort'
464
+ | 'p2pBroadcastPort'
465
+ | 'peerIdPrivateKey'
466
+ | 'peerIdPrivateKeyPath'
467
+ | 'bootstrapNodes'
468
+ | 'listenAddress'
469
+ | 'queryForIp'
470
+ > &
471
+ Required<Pick<P2PConfig, 'p2pIp' | 'p2pPort'>> &
472
+ Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'> &
356
473
  Pick<ChainConfig, 'l1ChainId'>;
357
474
 
358
475
  const bootnodeConfigKeys: (keyof BootnodeConfig)[] = [
359
- 'udpAnnounceAddress',
476
+ 'p2pIp',
477
+ 'p2pPort',
478
+ 'p2pBroadcastPort',
479
+ 'listenAddress',
360
480
  'peerIdPrivateKey',
361
- 'udpListenAddress',
481
+ 'peerIdPrivateKeyPath',
362
482
  'dataDirectory',
363
- 'dataStoreMapSizeKB',
483
+ 'dataStoreMapSizeKb',
364
484
  'bootstrapNodes',
365
485
  'l1ChainId',
486
+ 'queryForIp',
366
487
  ];
367
488
 
368
489
  export const bootnodeConfigMappings = pickConfigMappings(
369
490
  { ...p2pConfigMappings, ...dataConfigMappings, ...chainConfigMappings },
370
491
  bootnodeConfigKeys,
371
492
  );
493
+
494
+ /**
495
+ * Parses a string to a list of allowed elements.
496
+ * Each encoded is expected to be of one of the following formats
497
+ * `I:${address}`
498
+ * `I:${address}:${selector}`
499
+ * `C:${classId}`
500
+ * `C:${classId}:${selector}`
501
+ *
502
+ * @param value The string to parse
503
+ * @returns A list of allowed elements
504
+ */
505
+ export function parseAllowList(value: string): AllowedElement[] {
506
+ const entries: AllowedElement[] = [];
507
+
508
+ if (!value) {
509
+ return entries;
510
+ }
511
+
512
+ for (const val of value.split(',')) {
513
+ const [typeString, identifierString, selectorString] = val.split(':');
514
+ const selector = selectorString !== undefined ? FunctionSelector.fromString(selectorString) : undefined;
515
+
516
+ if (typeString === 'I') {
517
+ if (selector) {
518
+ entries.push({
519
+ address: AztecAddress.fromString(identifierString),
520
+ selector,
521
+ });
522
+ } else {
523
+ entries.push({
524
+ address: AztecAddress.fromString(identifierString),
525
+ });
526
+ }
527
+ } else if (typeString === 'C') {
528
+ if (selector) {
529
+ entries.push({
530
+ classId: Fr.fromHexString(identifierString),
531
+ selector,
532
+ });
533
+ } else {
534
+ entries.push({
535
+ classId: Fr.fromHexString(identifierString),
536
+ });
537
+ }
538
+ }
539
+ }
540
+
541
+ return entries;
542
+ }
@@ -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
  }
@@ -0,0 +1,13 @@
1
+ export class AttestationPoolError extends Error {
2
+ constructor(message?: string) {
3
+ super(message);
4
+ this.name = 'AttestationPoolError';
5
+ }
6
+ }
7
+
8
+ export class ProposalSlotCapExceededError extends AttestationPoolError {
9
+ constructor(message?: string) {
10
+ super(message);
11
+ this.name = 'ProposalSlotCapExceededError';
12
+ }
13
+ }
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';