@aztec/end-to-end 0.0.1-commit.24de95ac → 0.0.1-commit.2606882

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 (299) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +17 -2
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/benchmark.js +38 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +23 -17
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  7. package/dest/bench/client_flows/client_flows_benchmark.js +143 -136
  8. package/dest/bench/client_flows/config.d.ts +2 -2
  9. package/dest/bench/client_flows/config.d.ts.map +1 -1
  10. package/dest/bench/client_flows/config.js +18 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts +1 -1
  12. package/dest/bench/client_flows/data_extractor.js +7 -27
  13. package/dest/bench/utils.d.ts +8 -7
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +33 -19
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +12 -10
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +120 -117
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +33 -16
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +124 -70
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +7 -6
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +20 -14
  25. package/dest/e2e_epochs/epochs_test.d.ts +49 -16
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +188 -64
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
  29. package/dest/e2e_fees/bridging_race.notest.js +5 -7
  30. package/dest/e2e_fees/fees_test.d.ts +25 -18
  31. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  32. package/dest/e2e_fees/fees_test.js +162 -141
  33. package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
  34. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  35. package/dest/e2e_l1_publisher/write_json.js +18 -19
  36. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  37. package/dest/e2e_multi_validator/utils.js +1 -1
  38. package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -10
  39. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  40. package/dest/e2e_nested_contract/nested_contract_test.js +32 -40
  41. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  42. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  43. package/dest/e2e_p2p/inactivity_slash_test.js +11 -9
  44. package/dest/e2e_p2p/p2p_network.d.ts +237 -28
  45. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  46. package/dest/e2e_p2p/p2p_network.js +176 -129
  47. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  48. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  49. package/dest/e2e_p2p/reqresp/utils.js +206 -0
  50. package/dest/e2e_p2p/shared.d.ts +44 -15
  51. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  52. package/dest/e2e_p2p/shared.js +102 -68
  53. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  54. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  55. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  56. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  57. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  58. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  59. package/dest/e2e_token_contract/token_contract_test.d.ts +20 -11
  60. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  61. package/dest/e2e_token_contract/token_contract_test.js +103 -93
  62. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  63. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  64. package/dest/fixtures/authwit_proxy.js +34 -0
  65. package/dest/fixtures/e2e_prover_test.d.ts +19 -24
  66. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  67. package/dest/fixtures/e2e_prover_test.js +126 -145
  68. package/dest/fixtures/elu_monitor.d.ts +21 -0
  69. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  70. package/dest/fixtures/elu_monitor.js +102 -0
  71. package/dest/fixtures/fixtures.d.ts +75 -3
  72. package/dest/fixtures/fixtures.d.ts.map +1 -1
  73. package/dest/fixtures/fixtures.js +73 -3
  74. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  75. package/dest/fixtures/get_acvm_config.js +1 -1
  76. package/dest/fixtures/get_bb_config.d.ts +1 -1
  77. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  78. package/dest/fixtures/get_bb_config.js +5 -5
  79. package/dest/fixtures/ha_setup.d.ts +71 -0
  80. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  81. package/dest/fixtures/ha_setup.js +116 -0
  82. package/dest/fixtures/index.d.ts +2 -1
  83. package/dest/fixtures/index.d.ts.map +1 -1
  84. package/dest/fixtures/index.js +1 -0
  85. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  86. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  87. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  88. package/dest/fixtures/logging.d.ts +1 -1
  89. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  90. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  91. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  92. package/dest/fixtures/setup.d.ts +272 -0
  93. package/dest/fixtures/setup.d.ts.map +1 -0
  94. package/dest/fixtures/setup.js +735 -0
  95. package/dest/fixtures/setup_p2p_test.d.ts +22 -11
  96. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  97. package/dest/fixtures/setup_p2p_test.js +57 -38
  98. package/dest/fixtures/token_utils.d.ts +6 -3
  99. package/dest/fixtures/token_utils.d.ts.map +1 -1
  100. package/dest/fixtures/token_utils.js +13 -9
  101. package/dest/fixtures/utils.d.ts +5 -192
  102. package/dest/fixtures/utils.d.ts.map +1 -1
  103. package/dest/fixtures/utils.js +4 -648
  104. package/dest/fixtures/web3signer.d.ts +1 -1
  105. package/dest/fixtures/web3signer.js +1 -1
  106. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  107. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  108. package/dest/fixtures/with_telemetry_utils.js +2 -2
  109. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  110. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  111. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  112. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  113. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  114. package/dest/forward-compatibility/wallet_service.js +109 -0
  115. package/dest/index.d.ts +1 -1
  116. package/dest/install_legacy_contracts.d.cts +10 -0
  117. package/dest/install_legacy_contracts.d.cts.map +1 -0
  118. package/dest/legacy-jest-resolver.d.cts +3 -0
  119. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  120. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  121. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  122. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  123. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  124. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  125. package/dest/quality_of_service/prometheus_client.js +67 -0
  126. package/dest/shared/cross_chain_test_harness.d.ts +9 -6
  127. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  128. package/dest/shared/cross_chain_test_harness.js +34 -30
  129. package/dest/shared/gas_portal_test_harness.d.ts +9 -6
  130. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  131. package/dest/shared/gas_portal_test_harness.js +21 -12
  132. package/dest/shared/index.d.ts +3 -2
  133. package/dest/shared/index.d.ts.map +1 -1
  134. package/dest/shared/index.js +1 -0
  135. package/dest/shared/jest_setup.d.ts +1 -1
  136. package/dest/shared/jest_setup.js +41 -1
  137. package/dest/shared/mock_state_view.d.ts +86 -0
  138. package/dest/shared/mock_state_view.d.ts.map +1 -0
  139. package/dest/shared/mock_state_view.js +186 -0
  140. package/dest/shared/submit-transactions.d.ts +4 -4
  141. package/dest/shared/submit-transactions.d.ts.map +1 -1
  142. package/dest/shared/submit-transactions.js +9 -11
  143. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  144. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  145. package/dest/shared/uniswap_l1_l2.js +87 -50
  146. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  147. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  148. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  149. package/dest/simulators/index.d.ts +1 -1
  150. package/dest/simulators/lending_simulator.d.ts +11 -4
  151. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  152. package/dest/simulators/lending_simulator.js +32 -18
  153. package/dest/simulators/token_simulator.d.ts +1 -1
  154. package/dest/simulators/token_simulator.d.ts.map +1 -1
  155. package/dest/simulators/token_simulator.js +3 -24
  156. package/dest/spartan/setup_test_wallets.d.ts +18 -6
  157. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  158. package/dest/spartan/setup_test_wallets.js +159 -30
  159. package/dest/spartan/tx_metrics.d.ts +102 -0
  160. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  161. package/dest/spartan/tx_metrics.js +475 -0
  162. package/dest/spartan/utils/bot.d.ts +28 -0
  163. package/dest/spartan/utils/bot.d.ts.map +1 -0
  164. package/dest/spartan/utils/bot.js +142 -0
  165. package/dest/spartan/utils/chaos.d.ts +79 -0
  166. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  167. package/dest/spartan/utils/chaos.js +142 -0
  168. package/dest/spartan/utils/clients.d.ts +39 -0
  169. package/dest/spartan/utils/clients.d.ts.map +1 -0
  170. package/dest/spartan/utils/clients.js +90 -0
  171. package/dest/spartan/utils/config.d.ts +19 -0
  172. package/dest/spartan/utils/config.d.ts.map +1 -0
  173. package/dest/spartan/utils/config.js +23 -0
  174. package/dest/spartan/utils/health.d.ts +63 -0
  175. package/dest/spartan/utils/health.d.ts.map +1 -0
  176. package/dest/spartan/utils/health.js +202 -0
  177. package/dest/spartan/utils/helm.d.ts +15 -0
  178. package/dest/spartan/utils/helm.d.ts.map +1 -0
  179. package/dest/spartan/utils/helm.js +47 -0
  180. package/dest/spartan/utils/index.d.ts +11 -0
  181. package/dest/spartan/utils/index.d.ts.map +1 -0
  182. package/dest/spartan/utils/index.js +22 -0
  183. package/dest/spartan/utils/k8s.d.ts +128 -0
  184. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  185. package/dest/spartan/utils/k8s.js +381 -0
  186. package/dest/spartan/utils/nodes.d.ts +40 -0
  187. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  188. package/dest/spartan/utils/nodes.js +461 -0
  189. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  190. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  191. package/dest/spartan/utils/pod_logs.js +74 -0
  192. package/dest/spartan/utils/scripts.d.ts +30 -0
  193. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  194. package/dest/spartan/utils/scripts.js +81 -0
  195. package/dest/spartan/utils.d.ts +2 -218
  196. package/dest/spartan/utils.d.ts.map +1 -1
  197. package/dest/spartan/utils.js +1 -749
  198. package/dest/test-wallet/test_wallet.d.ts +85 -0
  199. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  200. package/dest/test-wallet/test_wallet.js +273 -0
  201. package/dest/test-wallet/utils.d.ts +41 -0
  202. package/dest/test-wallet/utils.d.ts.map +1 -0
  203. package/dest/test-wallet/utils.js +66 -0
  204. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  205. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  206. package/dest/test-wallet/wallet_worker_script.js +53 -0
  207. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  208. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  209. package/dest/test-wallet/worker_wallet.js +155 -0
  210. package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
  211. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  212. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  213. package/package.json +56 -46
  214. package/src/bench/client_flows/benchmark.ts +43 -2
  215. package/src/bench/client_flows/client_flows_benchmark.ts +203 -206
  216. package/src/bench/client_flows/config.ts +9 -1
  217. package/src/bench/client_flows/data_extractor.ts +6 -28
  218. package/src/bench/utils.ts +38 -22
  219. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +141 -152
  220. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +180 -127
  221. package/src/e2e_deploy_contract/deploy_test.ts +25 -17
  222. package/src/e2e_epochs/epochs_test.ts +254 -116
  223. package/src/e2e_fees/bridging_race.notest.ts +6 -12
  224. package/src/e2e_fees/fees_test.ts +215 -229
  225. package/src/e2e_l1_publisher/write_json.ts +20 -19
  226. package/src/e2e_multi_validator/utils.ts +1 -1
  227. package/src/e2e_nested_contract/nested_contract_test.ts +38 -56
  228. package/src/e2e_p2p/inactivity_slash_test.ts +12 -10
  229. package/src/e2e_p2p/p2p_network.ts +246 -201
  230. package/src/e2e_p2p/reqresp/utils.ts +274 -0
  231. package/src/e2e_p2p/shared.ts +132 -82
  232. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  233. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  234. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  235. package/src/e2e_token_contract/token_contract_test.ts +129 -117
  236. package/src/fixtures/authwit_proxy.ts +54 -0
  237. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  238. package/src/fixtures/e2e_prover_test.ts +154 -199
  239. package/src/fixtures/elu_monitor.ts +126 -0
  240. package/src/fixtures/fixtures.ts +95 -5
  241. package/src/fixtures/get_acvm_config.ts +1 -1
  242. package/src/fixtures/get_bb_config.ts +7 -6
  243. package/src/fixtures/ha_setup.ts +188 -0
  244. package/src/fixtures/index.ts +1 -0
  245. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  246. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  247. package/src/fixtures/setup.ts +1056 -0
  248. package/src/fixtures/setup_p2p_test.ts +70 -56
  249. package/src/fixtures/token_utils.ts +9 -8
  250. package/src/fixtures/utils.ts +29 -947
  251. package/src/fixtures/web3signer.ts +1 -1
  252. package/src/fixtures/with_telemetry_utils.ts +2 -2
  253. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  254. package/src/forward-compatibility/wallet_service.ts +104 -0
  255. package/src/guides/up_quick_start.sh +4 -6
  256. package/src/install_legacy_contracts.cjs +75 -0
  257. package/src/legacy-jest-resolver.cjs +112 -0
  258. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  259. package/src/quality_of_service/prometheus_client.ts +113 -0
  260. package/src/shared/cross_chain_test_harness.ts +37 -40
  261. package/src/shared/gas_portal_test_harness.ts +24 -14
  262. package/src/shared/index.ts +2 -1
  263. package/src/shared/jest_setup.ts +51 -1
  264. package/src/shared/mock_state_view.ts +188 -0
  265. package/src/shared/submit-transactions.ts +11 -16
  266. package/src/shared/uniswap_l1_l2.ts +142 -114
  267. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  268. package/src/simulators/lending_simulator.ts +39 -19
  269. package/src/simulators/token_simulator.ts +6 -30
  270. package/src/spartan/DEVELOP.md +7 -0
  271. package/src/spartan/setup_test_wallets.ts +234 -32
  272. package/src/spartan/tx_metrics.ts +434 -0
  273. package/src/spartan/utils/bot.ts +188 -0
  274. package/src/spartan/utils/chaos.ts +253 -0
  275. package/src/spartan/utils/clients.ts +100 -0
  276. package/src/spartan/utils/config.ts +29 -0
  277. package/src/spartan/utils/health.ts +255 -0
  278. package/src/spartan/utils/helm.ts +84 -0
  279. package/src/spartan/utils/index.ts +71 -0
  280. package/src/spartan/utils/k8s.ts +535 -0
  281. package/src/spartan/utils/nodes.ts +543 -0
  282. package/src/spartan/utils/pod_logs.ts +99 -0
  283. package/src/spartan/utils/scripts.ts +99 -0
  284. package/src/spartan/utils.ts +1 -942
  285. package/src/test-wallet/test_wallet.ts +376 -0
  286. package/src/test-wallet/utils.ts +108 -0
  287. package/src/test-wallet/wallet_worker_script.ts +63 -0
  288. package/src/test-wallet/worker_wallet.ts +218 -0
  289. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  290. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  291. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  292. package/dest/fixtures/setup_l1_contracts.js +0 -17
  293. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  294. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  295. package/dest/fixtures/snapshot_manager.js +0 -505
  296. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  297. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  298. package/src/fixtures/setup_l1_contracts.ts +0 -26
  299. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -1,4 +1,4 @@
1
- import { randomBytes } from '@aztec/foundation/crypto';
1
+ import { randomBytes } from '@aztec/foundation/crypto/random';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import { sleep } from '@aztec/foundation/sleep';
4
4
  import { RemoteSigner } from '@aztec/node-keystore';
@@ -7,12 +7,12 @@ import {
7
7
  } from '@aztec/telemetry-client';
8
8
  import { OTelPinoStream } from '@aztec/telemetry-client/otel-pino-stream';
9
9
 
10
- export function getEndToEndTestTelemetryClient(metricsPort?: number): TelemetryClient {
10
+ export async function getEndToEndTestTelemetryClient(metricsPort?: number): Promise<TelemetryClient> {
11
11
  if (metricsPort) {
12
12
  const otelStream = new OTelPinoStream({ levels });
13
13
  registerLoggingStream(otelStream);
14
14
  }
15
- return initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
15
+ return await initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
16
16
  }
17
17
 
18
18
  /**
@@ -0,0 +1,14 @@
1
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
+ import { WalletSchema } from '@aztec/aztec.js/wallet';
3
+ import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
4
+
5
+ /**
6
+ * Creates a JSON-RPC client that connects to a remote wallet service.
7
+ * The returned object implements the {@link Wallet} interface, proxying all calls over HTTP to the specified URL.
8
+ */
9
+ export function createWalletClient(url: string): Wallet {
10
+ return createSafeJsonRpcClient<Wallet>(url, WalletSchema, {
11
+ namespaceMethods: 'wallet',
12
+ fetch: makeFetch([1, 2, 3], false),
13
+ });
14
+ }
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env -S node --no-warnings
2
+ /**
3
+ * Standalone entrypoint that spins up a local Aztec network (L1 + node) and exposes a {@link NodeEmbeddedWallet} over
4
+ * JSON-RPC.
5
+ *
6
+ * Intended for forward-compatibility testing: an **old** release image runs this script so that **new** tests can send
7
+ * new artifacts to old runtime code (loadContractArtifact, ACIR simulator, class-ID computation, entrypoint encoding,
8
+ * etc.).
9
+ */
10
+ import { getSchnorrAccountContractAddress } from '@aztec/accounts/schnorr';
11
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
12
+ import { createLocalNetwork } from '@aztec/aztec';
13
+ import { Fr } from '@aztec/aztec.js/fields';
14
+ import { WalletSchema } from '@aztec/aztec.js/wallet';
15
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
16
+ import { createNamespacedSafeJsonRpcServer, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
17
+ import { createLogger } from '@aztec/foundation/log';
18
+ import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
19
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
20
+
21
+ const logger = createLogger('wallet-service');
22
+
23
+ const { ETHEREUM_HOSTS = 'http://localhost:8545', NODE_PORT = '8080', WALLET_PORT = '8081' } = process.env;
24
+
25
+ async function main() {
26
+ const l1RpcUrls = ETHEREUM_HOSTS.split(',').map(url => url.trim());
27
+
28
+ // Some tests (e.g. AMM) need 4 accounts but only 3 are funded via genesis. Generate deterministic keys for a 4th
29
+ // account so we can compute its address before network startup and include it in genesis funding. We cannot do this
30
+ // in the test because Wallet interface does not expose account creation functionality (only TestWallet exposes that
31
+ // but that's not used in forward compatibility testing).
32
+ const extraAccountSecret = Fr.fromHexString('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef');
33
+ const extraAccountSalt = Fr.ZERO;
34
+ const extraAccountSigningKey = GrumpkinScalar.random();
35
+ const extraAccountAddress = await getSchnorrAccountContractAddress(
36
+ extraAccountSecret,
37
+ extraAccountSalt,
38
+ extraAccountSigningKey,
39
+ );
40
+
41
+ logger.info('Starting wallet service...', { l1RpcUrls });
42
+
43
+ // createLocalNetwork deploys L1 contracts, starts the node, and optionally deploys funded test accounts (when
44
+ // TEST_ACCOUNTS=true via env). We are not proving anything just like is done when local network is started by
45
+ // the `aztecStart` function. The extra account address is passed via prefundAddresses so it gets fee juice at genesis.
46
+ const { node, stop: stopNetwork } = await createLocalNetwork(
47
+ { l1RpcUrls, realProofs: false, prefundAddresses: [extraAccountAddress.toString()] },
48
+ logger.info,
49
+ );
50
+
51
+ // Create an ephemeral embedded wallet backed by the local node.
52
+ const wallet = await EmbeddedWallet.create(node, { ephemeral: true });
53
+
54
+ // Re-register the initial test accounts so they are available via wallet.getAccounts(). createLocalNetwork deploys
55
+ // them onchain but uses a temporary wallet that is then stopped.
56
+ //
57
+ // We use the non-lazy import path (@aztec/accounts/testing, not /lazy) to avoid the dynamic JSON import that is
58
+ // incompatible with Node.js import attribute enforcement.
59
+ const testAccountsData = await getInitialTestAccountsData();
60
+ const accounts = await Promise.all(
61
+ testAccountsData.map(({ secret, salt, signingKey }) => wallet.createSchnorrAccount(secret, salt, signingKey)),
62
+ );
63
+
64
+ // Register and deploy the 4th account.
65
+ const extraAccount = await wallet.createSchnorrAccount(extraAccountSecret, extraAccountSalt, extraAccountSigningKey);
66
+ const deployMethod = await extraAccount.getDeployMethod();
67
+ await deployMethod.send({ from: accounts[0].address });
68
+
69
+ logger.info('Embedded wallet created', {
70
+ accounts: [...accounts, extraAccount].map(a => a.address.toString()),
71
+ });
72
+
73
+ // Contract artifacts are large, so allow generous body sizes for RPC requests.
74
+ const rpcOptions = { maxBodySizeBytes: '50mb' };
75
+
76
+ // Serve node RPC
77
+ const nodeRpcServer = createNamespacedSafeJsonRpcServer({ node: [node, AztecNodeApiSchema] }, rpcOptions);
78
+ const nodeHttpServer = await startHttpRpcServer(nodeRpcServer, { port: NODE_PORT });
79
+ logger.info(`Node JSON-RPC server listening on port ${nodeHttpServer.port}`);
80
+
81
+ // Serve wallet RPC
82
+ const walletRpcServer = createNamespacedSafeJsonRpcServer({ wallet: [wallet, WalletSchema] }, rpcOptions);
83
+ const walletHttpServer = await startHttpRpcServer(walletRpcServer, { port: WALLET_PORT });
84
+ logger.info(`Wallet JSON-RPC server listening on port ${walletHttpServer.port}`);
85
+
86
+ const shutdown = async () => {
87
+ logger.info('Shutting down...');
88
+ nodeHttpServer.close();
89
+ walletHttpServer.close();
90
+ await wallet.stop();
91
+ await stopNetwork();
92
+ process.exit(0);
93
+ };
94
+
95
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
96
+ process.once('SIGINT', shutdown);
97
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
98
+ process.once('SIGTERM', shutdown);
99
+ }
100
+
101
+ main().catch(err => {
102
+ logger.error('Wallet service failed to start', err);
103
+ process.exit(1);
104
+ });
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # Run locally from end-to-end folder while running anvil and sandbox with:
2
+ # Run locally from end-to-end folder while running anvil and local network with:
3
3
  # PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh
4
4
  set -eux
5
5
 
@@ -18,10 +18,10 @@ aztec-wallet() {
18
18
 
19
19
  aztec-wallet import-test-accounts
20
20
 
21
- # docs:start:declare-accounts
22
21
  aztec-wallet create-account -a alice -f test0
23
22
  aztec-wallet create-account -a bob -f test0
24
- # docs:end:declare-accounts
23
+
24
+ aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
25
25
 
26
26
  DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
27
27
  TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
@@ -38,9 +38,7 @@ fi
38
38
 
39
39
  TRANSFER_AMOUNT=42
40
40
 
41
- aztec-wallet create-authwit transfer_in_private accounts:test0 -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f alice
42
-
43
- aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -aw authwits:last -f test0
41
+ aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
44
42
 
45
43
  # Test end result
46
44
  ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ // Installs pinned legacy @aztec/* contract-artifact packages into .legacy-contracts/<version>/.
3
+ //
4
+ // Called from two places:
5
+ // - bootstrap.sh ci-compat-e2e: pre-populates the cache on the host before hermetic test
6
+ // containers launch. The containers run with --net=none (see ci3/docker_isolate), so on-demand
7
+ // installs from inside them fail with EAI_AGAIN.
8
+ // - legacy-jest-resolver.cjs: on-demand install for local dev, where jest runs with network.
9
+ //
10
+ // Idempotent: no-op when all packages are already present.
11
+ /* eslint-disable @typescript-eslint/no-require-imports */
12
+
13
+ const path = require('path');
14
+ const fs = require('fs');
15
+ const { execFileSync } = require('child_process');
16
+
17
+ const REDIRECTED = ['@aztec/noir-contracts.js', '@aztec/noir-test-contracts.js', '@aztec/accounts'];
18
+
19
+ const e2eRoot = path.resolve(__dirname, '..');
20
+
21
+ function cacheRoot(version) {
22
+ return path.join(e2eRoot, '.legacy-contracts', version);
23
+ }
24
+
25
+ function pkgJsonPath(version, pkg) {
26
+ return path.join(cacheRoot(version), 'node_modules', pkg, 'package.json');
27
+ }
28
+
29
+ function installLegacyContracts(version) {
30
+ if (!version) {
31
+ throw new Error('installLegacyContracts: version is required');
32
+ }
33
+ if (REDIRECTED.every(pkg => fs.existsSync(pkgJsonPath(version, pkg)))) {
34
+ return;
35
+ }
36
+
37
+ const cacheDir = cacheRoot(version);
38
+ fs.mkdirSync(cacheDir, { recursive: true });
39
+
40
+ // Seed a standalone package.json so `npm install --prefix` treats cacheRoot as its own project. Without this, npm
41
+ // walks up and finds the yarn-project workspace root, which breaks on `workspace:` protocol deps and risks
42
+ // clobbering the monorepo's node_modules.
43
+ const seed = path.join(cacheDir, 'package.json');
44
+ if (!fs.existsSync(seed)) {
45
+ fs.writeFileSync(seed, JSON.stringify({ name: 'legacy-contracts-cache', private: true }));
46
+ }
47
+
48
+ const specs = REDIRECTED.map(pkg => `${pkg}@${version}`);
49
+ process.stderr.write(`[legacy-contracts] installing ${specs.join(' ')} into ${cacheDir}\n`);
50
+ // --prefix: install into cacheRoot instead of cwd, so the cache is isolated from the monorepo.
51
+ // --no-save: don't write the installed packages back to the seeded package.json.
52
+ // --ignore-scripts: skip lifecycle scripts (preinstall/postinstall) of the legacy packages and their transitive
53
+ // deps; we only want the files on disk, not to run any build steps.
54
+ // --legacy-peer-deps: tolerate peer-dependency mismatches between the pinned legacy @aztec/* graph and whatever
55
+ // current versions npm would otherwise try to reconcile.
56
+ execFileSync(
57
+ 'npm',
58
+ ['install', '--prefix', cacheDir, '--no-save', '--ignore-scripts', '--legacy-peer-deps', ...specs],
59
+ { stdio: 'inherit' },
60
+ );
61
+
62
+ // Verify versions on disk match the requested version.
63
+ for (const pkg of REDIRECTED) {
64
+ const onDisk = JSON.parse(fs.readFileSync(pkgJsonPath(version, pkg), 'utf8')).version;
65
+ if (onDisk !== version) {
66
+ throw new Error(`[legacy-contracts] ${pkg} on disk is ${onDisk}, expected ${version}`);
67
+ }
68
+ }
69
+ }
70
+
71
+ module.exports = { installLegacyContracts, REDIRECTED, cacheRoot };
72
+
73
+ if (require.main === module) {
74
+ installLegacyContracts(process.argv[2]);
75
+ }
@@ -0,0 +1,112 @@
1
+ // Custom Jest resolver. When CONTRACT_ARTIFACTS_VERSION is set, redirects *only* JSON artifact files under
2
+ // @aztec/noir-contracts.js/artifacts/, @aztec/noir-test-contracts.js/artifacts/, and @aztec/accounts/artifacts/ to a local cache of the pinned
3
+ // legacy versions. TypeScript wrapper classes (e.g. Token.ts) continue to load from the current workspace and use the
4
+ // current @aztec/aztec.js — only the artifact JSON (the deployed-contract ABI / bytecode / notes surface) is swapped.
5
+ //
6
+ // Why JSON-only: the JSON artifact is the actual interchange surface a "deployed contract" exposes. The TS wrapper is
7
+ // generated client-side ergonomics that's tightly coupled to the current @aztec/aztec.js API. Redirecting the wrapper
8
+ // would couple this test to a moving aztec.js surface and break at import time on unrelated breaking changes; we want
9
+ // to fail only on actual artifact-compat regressions.
10
+ //
11
+ // Cache population lives in install_legacy_contracts.cjs — invoked lazily here for local dev, and eagerly
12
+ // by bootstrap.sh ci-compat-e2e before hermetic test containers (which run with --net=none) launch.
13
+ //
14
+ // Missing artifacts: legacy version directories are immutable, so an artifact missing from the cache means the
15
+ // contract was added after the pinned release — there's nothing to compat-test. Rather than failing or silently
16
+ // falling back to the workspace artifact (which would turn the compat run into a regular e2e run that always
17
+ // passes), we log the miss and exit the process cleanly with code 0. The test never runs, but the per-test CI
18
+ // log captures the explanatory line so the reason is auditable. This keeps the change scoped to this resolver,
19
+ // avoiding a new exit-code contract in the shared ci3 test runner.
20
+ //
21
+ // Activated by env var; passthrough otherwise.
22
+ /* eslint-disable @typescript-eslint/no-require-imports */
23
+
24
+ const path = require('path');
25
+ const fs = require('fs');
26
+ const { installLegacyContracts, REDIRECTED, cacheRoot } = require('./install_legacy_contracts.cjs');
27
+
28
+ const version = process.env.CONTRACT_ARTIFACTS_VERSION;
29
+ const cacheDir = version ? cacheRoot(version) : null;
30
+
31
+ function pkgJsonPath(name) {
32
+ return path.join(cacheDir, 'node_modules', name, 'package.json');
33
+ }
34
+
35
+ // Kept in a separate module (not inlined) because bootstrap.sh ci-compat-e2e also calls it directly
36
+ // via `node .../install_legacy_contracts.cjs <version>` to pre-populate the cache on the host before
37
+ // hermetic --net=none test containers launch. Inlining here would force us to duplicate the logic
38
+ // in bash or re-run jest just to trigger the install.
39
+ if (version) {
40
+ installLegacyContracts(version);
41
+ }
42
+
43
+ let bannerPrinted = false;
44
+ const seen = new Set();
45
+
46
+ function printBannerOnce() {
47
+ if (bannerPrinted || !version) {
48
+ return;
49
+ }
50
+ bannerPrinted = true;
51
+ const lines = ['='.repeat(60), `[legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=${version}`];
52
+ for (const p of REDIRECTED) {
53
+ const v = JSON.parse(fs.readFileSync(pkgJsonPath(p), 'utf8')).version;
54
+ if (v !== version) {
55
+ throw new Error(`[legacy-contracts] ${p} on disk is ${v}, expected ${version}`);
56
+ }
57
+ lines.push(`[legacy-contracts][jest] redirecting ${p}/artifacts/*.json -> .legacy-contracts/${version}/...`);
58
+ }
59
+ lines.push('='.repeat(60));
60
+ process.stderr.write(lines.join('\n') + '\n');
61
+ }
62
+
63
+ // Match a resolved absolute path against the workspace artifacts dirs and return the legacy cache equivalent, or null
64
+ // if it's not an artifact path we should redirect.
65
+ function legacyArtifactPath(resolved) {
66
+ if (!resolved.endsWith('.json')) {
67
+ return null;
68
+ }
69
+ for (const pkg of REDIRECTED) {
70
+ // pkg = '@aztec/noir-contracts.js' -> match '/noir-contracts.js/artifacts/'
71
+ const dirName = pkg.split('/')[1];
72
+ const marker = `/${dirName}/artifacts/`;
73
+ const idx = resolved.indexOf(marker);
74
+ if (idx === -1) {
75
+ continue;
76
+ }
77
+ const basename = resolved.slice(idx + marker.length);
78
+ return path.join(cacheDir, 'node_modules', pkg, 'artifacts', basename);
79
+ }
80
+ return null;
81
+ }
82
+
83
+ module.exports = function legacyResolver(request, options) {
84
+ // Always run the default resolver first. We only inspect (and possibly rewrite) the *result*; this catches both
85
+ // bare-specifier imports of `@aztec/noir-contracts.js/artifacts/foo.json` and the relative `../artifacts/foo.json`
86
+ // imports inside the workspace TS wrapper classes — both resolve to the same workspace artifact path that we then
87
+ // redirect.
88
+ const resolved = options.defaultResolver(request, options);
89
+ if (!version) {
90
+ return resolved;
91
+ }
92
+ printBannerOnce();
93
+ const legacy = legacyArtifactPath(resolved);
94
+ if (!legacy) {
95
+ return resolved;
96
+ }
97
+ if (!fs.existsSync(legacy)) {
98
+ // Contract was added after this historical release, there is nothing to compat-test for it. Exit the process
99
+ // cleanly with code 0 so the test runner reports the run as passed.
100
+ fs.writeSync(
101
+ 2,
102
+ `[legacy-contracts][jest] artifact ${path.basename(legacy)} not in legacy cache @${version}; ` +
103
+ `assumed added after this release. No compat coverage applicable for this version, treating as passed.\n`,
104
+ );
105
+ process.exit(0);
106
+ }
107
+ if (!seen.has(resolved)) {
108
+ seen.add(resolved);
109
+ process.stderr.write(`[legacy-contracts][jest] redirected ${path.basename(legacy)} -> ${legacy}\n`);
110
+ }
111
+ return legacy;
112
+ };
@@ -25,7 +25,7 @@ const DEFAULT_CONFIG: AlertCheckerConfig = {
25
25
  grafanaCredentials: 'admin:admin',
26
26
  };
27
27
 
28
- export class AlertChecker {
28
+ export class GrafanaClient {
29
29
  private config: AlertCheckerConfig;
30
30
  private logger: Logger;
31
31
 
@@ -0,0 +1,113 @@
1
+ export type PromteheusClientOptions = {
2
+ server: URL;
3
+ };
4
+
5
+ export class PrometheusClient {
6
+ constructor(
7
+ private config: PromteheusClientOptions,
8
+ private httpClient: typeof fetch = fetch,
9
+ ) {}
10
+
11
+ public async querySingleValue(query: string, time = new Date()): Promise<number> {
12
+ const resp = await this.queryRaw(query, time);
13
+ if (resp.status === 'success') {
14
+ if (resp.data.resultType === 'vector') {
15
+ if (resp.data.result.length === 0) {
16
+ return 0;
17
+ }
18
+ const [_, value] = resp.data.result[0].value;
19
+ return parseFloat(value);
20
+ }
21
+ }
22
+
23
+ throw new TypeError('Unsupported response body', { cause: JSON.stringify(resp) });
24
+ }
25
+
26
+ public queryRaw(query: string, time = new Date()): Promise<PrometheusResponse> {
27
+ const searchParams = new URLSearchParams();
28
+ searchParams.set('query', query);
29
+ searchParams.set('time', String(Math.trunc(time.getTime() / 1000)));
30
+ searchParams.set('limit', '10');
31
+
32
+ return this.callPrometheus('query', searchParams);
33
+ }
34
+
35
+ public queryRangeRaw(
36
+ query: string,
37
+ step: PrometheusDuration,
38
+ start: Date,
39
+ end = new Date(),
40
+ ): Promise<PrometheusResponse> {
41
+ const searchParams = new URLSearchParams();
42
+ searchParams.set('query', query);
43
+ searchParams.set('step', step);
44
+ searchParams.set('start', String(Math.trunc(start.getTime() / 1000)));
45
+ searchParams.set('end', String(Math.trunc(end.getTime() / 1000)));
46
+ searchParams.set('limit', '10');
47
+
48
+ return this.callPrometheus('query_range', searchParams);
49
+ }
50
+
51
+ private async callPrometheus(api: string, searchParams: URLSearchParams): Promise<PrometheusResponse> {
52
+ const url = new URL('api/v1/' + api, this.config.server);
53
+ for (const [name, value] of searchParams) {
54
+ url.searchParams.append(name, value);
55
+ }
56
+
57
+ const resp = await this.httpClient(url, { method: 'GET' });
58
+ if (!resp.ok || resp.status !== 200) {
59
+ throw new Error('Invalid HTTP response from Prometheus', {
60
+ cause: {
61
+ url,
62
+ status: resp.status,
63
+ statusText: resp.statusText,
64
+ },
65
+ });
66
+ }
67
+
68
+ const body = await resp.json();
69
+ if ('status' in body && (body.status === 'error' || body.status === 'success')) {
70
+ return body;
71
+ }
72
+
73
+ throw new Error('Invalid response from Prometheus', {
74
+ cause: {
75
+ url,
76
+ body,
77
+ },
78
+ });
79
+ }
80
+ }
81
+
82
+ export type PrometheusDuration = `${number}s` | `${number}m` | `${number}h`;
83
+
84
+ export type PrometheusData =
85
+ | {
86
+ resultType: 'vector';
87
+ result: Array<{
88
+ metric: unknown;
89
+ value: [unixTimestamp: number, value: string];
90
+ }>;
91
+ }
92
+ | {
93
+ resultType: 'matrix';
94
+ result: Array<{
95
+ metric: unknown;
96
+ values: [unixTimestamp: number, value: string];
97
+ }>;
98
+ }
99
+ | {
100
+ resultType: 'scalar' | 'string';
101
+ result: unknown;
102
+ };
103
+
104
+ export type PrometheusResponse =
105
+ | {
106
+ status: 'error';
107
+ errorType: string;
108
+ error: string;
109
+ }
110
+ | {
111
+ status: 'success';
112
+ data: PrometheusData;
113
+ };