@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.0b941701

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 (236) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +62 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +281 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +321 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +79 -0
  13. package/dest/bench/utils.d.ts +16 -41
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +41 -72
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
  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 +114 -102
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
  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 +104 -104
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +26 -27
  25. package/dest/e2e_epochs/epochs_test.d.ts +65 -22
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +236 -49
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +61 -0
  31. package/dest/e2e_fees/fees_test.d.ts +38 -23
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +162 -183
  34. package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +62 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +281 -27
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +237 -175
  49. package/dest/e2e_p2p/shared.d.ts +44 -8
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +165 -27
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +96 -74
  55. package/dest/fixtures/e2e_prover_test.d.ts +55 -0
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/fixtures/e2e_prover_test.js +278 -0
  58. package/dest/fixtures/fixtures.d.ts +6 -8
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +5 -5
  61. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +3 -15
  64. package/dest/fixtures/get_bb_config.d.ts +2 -2
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/index.d.ts +1 -1
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  69. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  70. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  71. package/dest/fixtures/logging.d.ts +1 -1
  72. package/dest/fixtures/setup.d.ts +218 -0
  73. package/dest/fixtures/setup.d.ts.map +1 -0
  74. package/dest/fixtures/setup.js +690 -0
  75. package/dest/fixtures/setup_p2p_test.d.ts +15 -14
  76. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  77. package/dest/fixtures/setup_p2p_test.js +82 -22
  78. package/dest/fixtures/token_utils.d.ts +10 -4
  79. package/dest/fixtures/token_utils.d.ts.map +1 -1
  80. package/dest/fixtures/token_utils.js +31 -12
  81. package/dest/fixtures/utils.d.ts +5 -153
  82. package/dest/fixtures/utils.d.ts.map +1 -1
  83. package/dest/fixtures/utils.js +4 -552
  84. package/dest/fixtures/web3signer.d.ts +5 -0
  85. package/dest/fixtures/web3signer.d.ts.map +1 -0
  86. package/dest/fixtures/web3signer.js +53 -0
  87. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  88. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  89. package/dest/fixtures/with_telemetry_utils.js +2 -2
  90. package/dest/index.d.ts +1 -1
  91. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  92. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  93. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  94. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  95. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  96. package/dest/quality_of_service/prometheus_client.js +67 -0
  97. package/dest/shared/cross_chain_test_harness.d.ts +44 -27
  98. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  99. package/dest/shared/cross_chain_test_harness.js +105 -51
  100. package/dest/shared/gas_portal_test_harness.d.ts +33 -25
  101. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  102. package/dest/shared/gas_portal_test_harness.js +51 -30
  103. package/dest/shared/index.d.ts +2 -2
  104. package/dest/shared/index.d.ts.map +1 -1
  105. package/dest/shared/jest_setup.d.ts +1 -1
  106. package/dest/shared/jest_setup.js +1 -1
  107. package/dest/shared/submit-transactions.d.ts +6 -4
  108. package/dest/shared/submit-transactions.d.ts.map +1 -1
  109. package/dest/shared/submit-transactions.js +15 -16
  110. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  111. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  112. package/dest/shared/uniswap_l1_l2.js +176 -126
  113. package/dest/simulators/index.d.ts +1 -1
  114. package/dest/simulators/lending_simulator.d.ts +7 -7
  115. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  116. package/dest/simulators/lending_simulator.js +17 -18
  117. package/dest/simulators/token_simulator.d.ts +6 -3
  118. package/dest/simulators/token_simulator.d.ts.map +1 -1
  119. package/dest/simulators/token_simulator.js +16 -13
  120. package/dest/spartan/setup_test_wallets.d.ts +27 -11
  121. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  122. package/dest/spartan/setup_test_wallets.js +233 -62
  123. package/dest/spartan/tx_metrics.d.ts +54 -0
  124. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  125. package/dest/spartan/tx_metrics.js +272 -0
  126. package/dest/spartan/utils/bot.d.ts +27 -0
  127. package/dest/spartan/utils/bot.d.ts.map +1 -0
  128. package/dest/spartan/utils/bot.js +141 -0
  129. package/dest/spartan/utils/chaos.d.ts +79 -0
  130. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  131. package/dest/spartan/utils/chaos.js +142 -0
  132. package/dest/spartan/utils/clients.d.ts +39 -0
  133. package/dest/spartan/utils/clients.d.ts.map +1 -0
  134. package/dest/spartan/utils/clients.js +90 -0
  135. package/dest/spartan/utils/config.d.ts +36 -0
  136. package/dest/spartan/utils/config.d.ts.map +1 -0
  137. package/dest/spartan/utils/config.js +20 -0
  138. package/dest/spartan/utils/health.d.ts +63 -0
  139. package/dest/spartan/utils/health.d.ts.map +1 -0
  140. package/dest/spartan/utils/health.js +202 -0
  141. package/dest/spartan/utils/helm.d.ts +15 -0
  142. package/dest/spartan/utils/helm.d.ts.map +1 -0
  143. package/dest/spartan/utils/helm.js +47 -0
  144. package/dest/spartan/utils/index.d.ts +9 -0
  145. package/dest/spartan/utils/index.d.ts.map +1 -0
  146. package/dest/spartan/utils/index.js +18 -0
  147. package/dest/spartan/utils/k8s.d.ts +98 -0
  148. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  149. package/dest/spartan/utils/k8s.js +257 -0
  150. package/dest/spartan/utils/nodes.d.ts +31 -0
  151. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  152. package/dest/spartan/utils/nodes.js +290 -0
  153. package/dest/spartan/utils/scripts.d.ts +16 -0
  154. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  155. package/dest/spartan/utils/scripts.js +66 -0
  156. package/dest/spartan/utils.d.ts +2 -415
  157. package/dest/spartan/utils.d.ts.map +1 -1
  158. package/dest/spartan/utils.js +1 -445
  159. package/package.json +66 -58
  160. package/src/bench/client_flows/benchmark.ts +363 -0
  161. package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
  162. package/src/bench/client_flows/config.ts +61 -0
  163. package/src/bench/client_flows/data_extractor.ts +89 -0
  164. package/src/bench/utils.ts +41 -85
  165. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
  166. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
  167. package/src/e2e_deploy_contract/deploy_test.ts +40 -48
  168. package/src/e2e_epochs/epochs_test.ts +315 -76
  169. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  170. package/src/e2e_fees/fees_test.ts +220 -258
  171. package/src/e2e_l1_publisher/write_json.ts +82 -0
  172. package/src/e2e_multi_validator/utils.ts +258 -0
  173. package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
  174. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  175. package/src/e2e_p2p/p2p_network.ts +341 -234
  176. package/src/e2e_p2p/shared.ts +253 -40
  177. package/src/e2e_token_contract/token_contract_test.ts +115 -126
  178. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  179. package/src/fixtures/e2e_prover_test.ts +336 -0
  180. package/src/fixtures/fixtures.ts +5 -7
  181. package/src/fixtures/get_acvm_config.ts +4 -12
  182. package/src/fixtures/get_bb_config.ts +18 -13
  183. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  184. package/src/fixtures/setup.ts +1017 -0
  185. package/src/fixtures/setup_p2p_test.ts +127 -39
  186. package/src/fixtures/token_utils.ts +33 -15
  187. package/src/fixtures/utils.ts +27 -820
  188. package/src/fixtures/web3signer.ts +63 -0
  189. package/src/fixtures/with_telemetry_utils.ts +2 -2
  190. package/src/guides/up_quick_start.sh +7 -15
  191. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  192. package/src/quality_of_service/prometheus_client.ts +113 -0
  193. package/src/shared/cross_chain_test_harness.ts +103 -91
  194. package/src/shared/gas_portal_test_harness.ts +59 -50
  195. package/src/shared/index.ts +1 -1
  196. package/src/shared/jest_setup.ts +1 -1
  197. package/src/shared/submit-transactions.ts +18 -20
  198. package/src/shared/uniswap_l1_l2.ts +197 -221
  199. package/src/simulators/lending_simulator.ts +16 -17
  200. package/src/simulators/token_simulator.ts +21 -13
  201. package/src/spartan/DEVELOP.md +128 -0
  202. package/src/spartan/setup_test_wallets.ts +308 -95
  203. package/src/spartan/tx_metrics.ts +250 -0
  204. package/src/spartan/utils/bot.ts +185 -0
  205. package/src/spartan/utils/chaos.ts +253 -0
  206. package/src/spartan/utils/clients.ts +100 -0
  207. package/src/spartan/utils/config.ts +26 -0
  208. package/src/spartan/utils/health.ts +255 -0
  209. package/src/spartan/utils/helm.ts +84 -0
  210. package/src/spartan/utils/index.ts +62 -0
  211. package/src/spartan/utils/k8s.ts +375 -0
  212. package/src/spartan/utils/nodes.ts +323 -0
  213. package/src/spartan/utils/scripts.ts +63 -0
  214. package/src/spartan/utils.ts +1 -582
  215. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  216. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  217. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  218. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  219. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  220. package/dest/fixtures/setup_l1_contracts.js +0 -17
  221. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  222. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  223. package/dest/fixtures/snapshot_manager.js +0 -479
  224. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  225. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  226. package/dest/sample-dapp/connect.js +0 -12
  227. package/dest/sample-dapp/contracts.js +0 -10
  228. package/dest/sample-dapp/deploy.js +0 -35
  229. package/dest/sample-dapp/index.js +0 -98
  230. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  231. package/src/fixtures/setup_l1_contracts.ts +0 -27
  232. package/src/fixtures/snapshot_manager.ts +0 -617
  233. package/src/sample-dapp/connect.mjs +0 -16
  234. package/src/sample-dapp/contracts.mjs +0 -14
  235. package/src/sample-dapp/deploy.mjs +0 -40
  236. package/src/sample-dapp/index.mjs +0 -128
@@ -0,0 +1,63 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+
3
+ import { execSync, spawn } from 'child_process';
4
+ import path from 'path';
5
+
6
+ /**
7
+ * @param scriptPath - The path to the script, relative to the project root
8
+ * @param args - The arguments to pass to the script
9
+ * @param logger - The logger to use
10
+ * @returns The exit code of the script
11
+ */
12
+ function runScript(scriptPath: string, args: string[], logger: Logger, env?: Record<string, string>) {
13
+ const childProcess = spawn(scriptPath, args, {
14
+ stdio: ['ignore', 'pipe', 'pipe'],
15
+ env: env ? { ...process.env, ...env } : process.env,
16
+ });
17
+ return new Promise<number>((resolve, reject) => {
18
+ childProcess.on('close', (code: number | null) => resolve(code ?? 0));
19
+ childProcess.on('error', reject);
20
+ childProcess.stdout?.on('data', (data: Buffer) => {
21
+ logger.info(data.toString());
22
+ });
23
+ childProcess.stderr?.on('data', (data: Buffer) => {
24
+ logger.error(data.toString());
25
+ });
26
+ });
27
+ }
28
+
29
+ /**
30
+ * Returns the absolute path to the git repository root
31
+ */
32
+ export function getGitProjectRoot(): string {
33
+ try {
34
+ const rootDir = execSync('git rev-parse --show-toplevel', {
35
+ encoding: 'utf-8',
36
+ stdio: ['ignore', 'pipe', 'ignore'],
37
+ }).trim();
38
+
39
+ return rootDir;
40
+ } catch (error) {
41
+ throw new Error(`Failed to determine git project root: ${error}`);
42
+ }
43
+ }
44
+
45
+ export function getAztecBin() {
46
+ return path.join(getGitProjectRoot(), 'yarn-project/aztec/dest/bin/index.js');
47
+ }
48
+
49
+ /**
50
+ * Runs the Aztec binary
51
+ * @param args - The arguments to pass to the Aztec binary
52
+ * @param logger - The logger to use
53
+ * @param env - Optional environment variables to set for the process
54
+ * @returns The exit code of the Aztec binary
55
+ */
56
+ export function runAztecBin(args: string[], logger: Logger, env?: Record<string, string>) {
57
+ return runScript('node', [getAztecBin(), ...args], logger, env);
58
+ }
59
+
60
+ export function runProjectScript(script: string, args: string[], logger: Logger, env?: Record<string, string>) {
61
+ const scriptPath = script.startsWith('/') ? script : path.join(getGitProjectRoot(), script);
62
+ return runScript(scriptPath, args, logger, env);
63
+ }
@@ -1,582 +1 @@
1
- import { createAztecNodeClient, createLogger, sleep } from '@aztec/aztec.js';
2
- import type { RollupCheatCodes } from '@aztec/aztec.js/ethereum';
3
- import type { Logger } from '@aztec/foundation/log';
4
- import type { SequencerConfig } from '@aztec/sequencer-client';
5
-
6
- import { ChildProcess, exec, execSync, spawn } from 'child_process';
7
- import path from 'path';
8
- import { promisify } from 'util';
9
- import { z } from 'zod';
10
-
11
- import { AlertChecker, type AlertConfig } from '../quality_of_service/alert_checker.js';
12
-
13
- const execAsync = promisify(exec);
14
-
15
- const logger = createLogger('e2e:k8s-utils');
16
-
17
- const ethereumHostsSchema = z.string().refine(
18
- str =>
19
- str.split(',').every(url => {
20
- try {
21
- new URL(url.trim());
22
- return true;
23
- } catch {
24
- return false;
25
- }
26
- }),
27
- 'ETHEREUM_HOSTS must be a comma-separated list of valid URLs',
28
- );
29
-
30
- const k8sLocalConfigSchema = z.object({
31
- ETHEREUM_SLOT_DURATION: z.coerce.number().min(1, 'ETHEREUM_SLOT_DURATION env variable must be set'),
32
- AZTEC_SLOT_DURATION: z.coerce.number().min(1, 'AZTEC_SLOT_DURATION env variable must be set'),
33
- AZTEC_EPOCH_DURATION: z.coerce.number().min(1, 'AZTEC_EPOCH_DURATION env variable must be set'),
34
- AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().min(1, 'AZTEC_PROOF_SUBMISSION_WINDOW env variable must be set'),
35
- INSTANCE_NAME: z.string().min(1, 'INSTANCE_NAME env variable must be set'),
36
- NAMESPACE: z.string().min(1, 'NAMESPACE env variable must be set'),
37
- CONTAINER_NODE_PORT: z.coerce.number().default(8080),
38
- CONTAINER_SEQUENCER_PORT: z.coerce.number().default(8080),
39
- CONTAINER_PROVER_NODE_PORT: z.coerce.number().default(8080),
40
- CONTAINER_PXE_PORT: z.coerce.number().default(8080),
41
- CONTAINER_ETHEREUM_PORT: z.coerce.number().default(8545),
42
- CONTAINER_METRICS_PORT: z.coerce.number().default(80),
43
- GRAFANA_PASSWORD: z.string().optional(),
44
- METRICS_API_PATH: z.string().default('/api/datasources/proxy/uid/spartan-metrics-prometheus/api/v1'),
45
- SPARTAN_DIR: z.string().min(1, 'SPARTAN_DIR env variable must be set'),
46
- ETHEREUM_HOSTS: ethereumHostsSchema.optional(),
47
- L1_ACCOUNT_MNEMONIC: z.string().default('test test test test test test test test test test test junk'),
48
- SEPOLIA_RUN: z.string().default('false'),
49
- K8S: z.literal('local'),
50
- });
51
-
52
- const k8sGCloudConfigSchema = k8sLocalConfigSchema.extend({
53
- K8S: z.literal('gcloud'),
54
- CLUSTER_NAME: z.string().min(1, 'CLUSTER_NAME env variable must be set'),
55
- REGION: z.string().min(1, 'REGION env variable must be set'),
56
- });
57
-
58
- const directConfigSchema = z.object({
59
- PXE_URL: z.string().url('PXE_URL must be a valid URL'),
60
- NODE_URL: z.string().url('NODE_URL must be a valid URL'),
61
- ETHEREUM_HOSTS: ethereumHostsSchema,
62
- K8S: z.literal('false'),
63
- });
64
-
65
- const envSchema = z.discriminatedUnion('K8S', [k8sLocalConfigSchema, k8sGCloudConfigSchema, directConfigSchema]);
66
-
67
- export type K8sLocalConfig = z.infer<typeof k8sLocalConfigSchema>;
68
- export type K8sGCloudConfig = z.infer<typeof k8sGCloudConfigSchema>;
69
- export type DirectConfig = z.infer<typeof directConfigSchema>;
70
- export type EnvConfig = z.infer<typeof envSchema>;
71
-
72
- export function isK8sConfig(config: EnvConfig): config is K8sLocalConfig | K8sGCloudConfig {
73
- return config.K8S === 'local' || config.K8S === 'gcloud';
74
- }
75
-
76
- export function isGCloudConfig(config: EnvConfig): config is K8sGCloudConfig {
77
- return config.K8S === 'gcloud';
78
- }
79
-
80
- export function setupEnvironment(env: unknown): EnvConfig {
81
- const config = envSchema.parse(env);
82
- if (isGCloudConfig(config)) {
83
- const command = `gcloud container clusters get-credentials ${config.CLUSTER_NAME} --region=${config.REGION}`;
84
- execSync(command);
85
- }
86
- return config;
87
- }
88
-
89
- export async function startPortForward({
90
- resource,
91
- namespace,
92
- containerPort,
93
- hostPort,
94
- }: {
95
- resource: string;
96
- namespace: string;
97
- containerPort: number;
98
- // If not provided, the port will be chosen automatically
99
- hostPort?: number;
100
- }): Promise<{
101
- process: ChildProcess;
102
- port: number;
103
- }> {
104
- const hostPortAsString = hostPort ? hostPort.toString() : '';
105
-
106
- logger.info(`kubectl port-forward -n ${namespace} ${resource} ${hostPortAsString}:${containerPort}`);
107
-
108
- const process = spawn(
109
- 'kubectl',
110
- ['port-forward', '-n', namespace, resource, `${hostPortAsString}:${containerPort}`],
111
- {
112
- detached: true,
113
- windowsHide: true,
114
- stdio: ['ignore', 'pipe', 'pipe'],
115
- },
116
- );
117
-
118
- let isResolved = false;
119
- const connected = new Promise<number>(resolve => {
120
- process.stdout?.on('data', data => {
121
- const str = data.toString() as string;
122
- if (!isResolved && str.includes('Forwarding from')) {
123
- isResolved = true;
124
- logger.info(str);
125
- const port = str.search(/:\d+/);
126
- if (port === -1) {
127
- throw new Error('Port not found in port forward output');
128
- }
129
- const portNumber = parseInt(str.slice(port + 1));
130
- logger.info(`Port forward connected: ${portNumber}`);
131
- logger.info(`Port forward connected: ${portNumber}`);
132
- resolve(portNumber);
133
- } else {
134
- logger.silent(str);
135
- }
136
- });
137
- process.stderr?.on('data', data => {
138
- logger.info(data.toString());
139
- // It's a strange thing:
140
- // If we don't pipe stderr, then the port forwarding does not work.
141
- // Log to silent because this doesn't actually report errors,
142
- // just extremely verbose debug logs.
143
- logger.silent(data.toString());
144
- });
145
- process.on('close', () => {
146
- if (!isResolved) {
147
- isResolved = true;
148
- logger.warn('Port forward closed before connection established');
149
- resolve(0);
150
- }
151
- });
152
- process.on('error', error => {
153
- logger.error(`Port forward error: ${error}`);
154
- resolve(0);
155
- });
156
- process.on('exit', code => {
157
- logger.info(`Port forward exited with code ${code}`);
158
- resolve(0);
159
- });
160
- });
161
-
162
- const port = await connected;
163
-
164
- return { process, port };
165
- }
166
-
167
- export async function deleteResourceByName({
168
- resource,
169
- namespace,
170
- name,
171
- force = false,
172
- }: {
173
- resource: string;
174
- namespace: string;
175
- name: string;
176
- force?: boolean;
177
- }) {
178
- const command = `kubectl delete ${resource} ${name} -n ${namespace} --ignore-not-found=true --wait=true ${
179
- force ? '--force' : ''
180
- }`;
181
- logger.info(`command: ${command}`);
182
- const { stdout } = await execAsync(command);
183
- return stdout;
184
- }
185
-
186
- export async function deleteResourceByLabel({
187
- resource,
188
- namespace,
189
- label,
190
- }: {
191
- resource: string;
192
- namespace: string;
193
- label: string;
194
- }) {
195
- const command = `kubectl delete ${resource} -l ${label} -n ${namespace} --ignore-not-found=true --wait=true`;
196
- logger.info(`command: ${command}`);
197
- const { stdout } = await execAsync(command);
198
- return stdout;
199
- }
200
-
201
- export async function waitForResourceByLabel({
202
- resource,
203
- label,
204
- namespace,
205
- condition = 'Ready',
206
- timeout = '10m',
207
- }: {
208
- resource: string;
209
- label: string;
210
- namespace: string;
211
- condition?: string;
212
- timeout?: string;
213
- }) {
214
- const command = `kubectl wait ${resource} -l ${label} --for=condition=${condition} -n ${namespace} --timeout=${timeout}`;
215
- logger.info(`command: ${command}`);
216
- const { stdout } = await execAsync(command);
217
- return stdout;
218
- }
219
-
220
- export function getChartDir(spartanDir: string, chartName: string) {
221
- return path.join(spartanDir.trim(), chartName);
222
- }
223
-
224
- function valuesToArgs(values: Record<string, string | number>) {
225
- return Object.entries(values)
226
- .map(([key, value]) => `--set ${key}=${value}`)
227
- .join(' ');
228
- }
229
-
230
- function createHelmCommand({
231
- instanceName,
232
- helmChartDir,
233
- namespace,
234
- valuesFile,
235
- timeout,
236
- values,
237
- reuseValues = false,
238
- }: {
239
- instanceName: string;
240
- helmChartDir: string;
241
- namespace: string;
242
- valuesFile: string | undefined;
243
- timeout: string;
244
- values: Record<string, string | number>;
245
- reuseValues?: boolean;
246
- }) {
247
- const valuesFileArgs = valuesFile ? `--values ${helmChartDir}/values/${valuesFile}` : '';
248
- const reuseValuesArgs = reuseValues ? '--reuse-values' : '';
249
- return `helm upgrade --install ${instanceName} ${helmChartDir} --namespace ${namespace} ${valuesFileArgs} ${reuseValuesArgs} --wait --timeout=${timeout} ${valuesToArgs(
250
- values,
251
- )}`;
252
- }
253
-
254
- async function execHelmCommand(args: Parameters<typeof createHelmCommand>[0]) {
255
- const helmCommand = createHelmCommand(args);
256
- logger.info(`helm command: ${helmCommand}`);
257
- const { stdout } = await execAsync(helmCommand);
258
- return stdout;
259
- }
260
-
261
- /**
262
- * Installs a Helm chart with the given parameters.
263
- * @param instanceName - The name of the Helm chart instance.
264
- * @param targetNamespace - The namespace with the resources to be affected by the Helm chart.
265
- * @param valuesFile - The values file to use for the Helm chart.
266
- * @param chaosMeshNamespace - The namespace to install the Helm chart in.
267
- * @param timeout - The timeout for the Helm command.
268
- * @param clean - Whether to clean up the Helm chart before installing it.
269
- * @returns The stdout of the Helm command.
270
- * @throws If the Helm command fails.
271
- *
272
- * Example usage:
273
- * ```typescript
274
- * const stdout = await installChaosMeshChart({ instanceName: 'force-reorg', targetNamespace: 'smoke', valuesFile: 'prover-failure.yaml'});
275
- * console.log(stdout);
276
- * ```
277
- */
278
- export async function installChaosMeshChart({
279
- instanceName,
280
- targetNamespace,
281
- valuesFile,
282
- helmChartDir,
283
- chaosMeshNamespace = 'chaos-mesh',
284
- timeout = '5m',
285
- clean = true,
286
- values = {},
287
- logger,
288
- }: {
289
- instanceName: string;
290
- targetNamespace: string;
291
- valuesFile: string;
292
- helmChartDir: string;
293
- chaosMeshNamespace?: string;
294
- timeout?: string;
295
- clean?: boolean;
296
- values?: Record<string, string | number>;
297
- logger: Logger;
298
- }) {
299
- if (clean) {
300
- // uninstall the helm chart if it exists
301
- logger.info(`Uninstalling helm chart ${instanceName}`);
302
- await execAsync(`helm uninstall ${instanceName} --namespace ${chaosMeshNamespace} --wait --ignore-not-found`);
303
- // and delete the podchaos resource
304
- const deleteArgs = {
305
- resource: 'podchaos',
306
- namespace: chaosMeshNamespace,
307
- name: `${targetNamespace}-${instanceName}`,
308
- };
309
- logger.info(`Deleting podchaos resource`);
310
- await deleteResourceByName(deleteArgs).catch(e => {
311
- logger.error(`Error deleting podchaos resource: ${e}`);
312
- logger.info(`Force deleting podchaos resource`);
313
- return deleteResourceByName({ ...deleteArgs, force: true });
314
- });
315
- }
316
-
317
- return execHelmCommand({
318
- instanceName,
319
- helmChartDir,
320
- namespace: chaosMeshNamespace,
321
- valuesFile,
322
- timeout,
323
- values: { ...values, 'global.targetNamespace': targetNamespace },
324
- });
325
- }
326
-
327
- export function applyProverFailure({
328
- namespace,
329
- spartanDir,
330
- durationSeconds,
331
- logger,
332
- }: {
333
- namespace: string;
334
- spartanDir: string;
335
- durationSeconds: number;
336
- logger: Logger;
337
- }) {
338
- return installChaosMeshChart({
339
- instanceName: 'prover-failure',
340
- targetNamespace: namespace,
341
- valuesFile: 'prover-failure.yaml',
342
- helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
343
- values: {
344
- 'proverFailure.duration': `${durationSeconds}s`,
345
- },
346
- logger,
347
- });
348
- }
349
-
350
- export function applyProverKill({
351
- namespace,
352
- spartanDir,
353
- logger,
354
- }: {
355
- namespace: string;
356
- spartanDir: string;
357
- logger: Logger;
358
- }) {
359
- return installChaosMeshChart({
360
- instanceName: 'prover-kill',
361
- targetNamespace: namespace,
362
- valuesFile: 'prover-kill.yaml',
363
- helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
364
- clean: true,
365
- logger,
366
- });
367
- }
368
-
369
- export function applyProverBrokerKill({
370
- namespace,
371
- spartanDir,
372
- logger,
373
- }: {
374
- namespace: string;
375
- spartanDir: string;
376
- logger: Logger;
377
- }) {
378
- return installChaosMeshChart({
379
- instanceName: 'prover-broker-kill',
380
- targetNamespace: namespace,
381
- valuesFile: 'prover-broker-kill.yaml',
382
- helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
383
- clean: true,
384
- logger,
385
- });
386
- }
387
-
388
- export function applyBootNodeFailure({
389
- namespace,
390
- spartanDir,
391
- durationSeconds,
392
- logger,
393
- }: {
394
- namespace: string;
395
- spartanDir: string;
396
- durationSeconds: number;
397
- logger: Logger;
398
- }) {
399
- return installChaosMeshChart({
400
- instanceName: 'boot-node-failure',
401
- targetNamespace: namespace,
402
- valuesFile: 'boot-node-failure.yaml',
403
- helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
404
- values: {
405
- 'bootNodeFailure.duration': `${durationSeconds}s`,
406
- },
407
- logger,
408
- });
409
- }
410
-
411
- export function applyValidatorKill({
412
- namespace,
413
- spartanDir,
414
- logger,
415
- }: {
416
- namespace: string;
417
- spartanDir: string;
418
- logger: Logger;
419
- }) {
420
- return installChaosMeshChart({
421
- instanceName: 'validator-kill',
422
- targetNamespace: namespace,
423
- valuesFile: 'validator-kill.yaml',
424
- helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
425
- logger,
426
- });
427
- }
428
-
429
- export function applyNetworkShaping({
430
- valuesFile,
431
- namespace,
432
- spartanDir,
433
- logger,
434
- }: {
435
- valuesFile: string;
436
- namespace: string;
437
- spartanDir: string;
438
- logger: Logger;
439
- }) {
440
- return installChaosMeshChart({
441
- instanceName: 'network-shaping',
442
- targetNamespace: namespace,
443
- valuesFile,
444
- helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
445
- logger,
446
- });
447
- }
448
-
449
- export async function awaitL2BlockNumber(
450
- rollupCheatCodes: RollupCheatCodes,
451
- blockNumber: bigint,
452
- timeoutSeconds: number,
453
- logger: Logger,
454
- ) {
455
- logger.info(`Waiting for L2 Block ${blockNumber}`);
456
- let tips = await rollupCheatCodes.getTips();
457
- const endTime = Date.now() + timeoutSeconds * 1000;
458
- while (tips.pending < blockNumber && Date.now() < endTime) {
459
- logger.info(`At L2 Block ${tips.pending}`);
460
- await sleep(1000);
461
- tips = await rollupCheatCodes.getTips();
462
- }
463
- if (tips.pending < blockNumber) {
464
- throw new Error(`Timeout waiting for L2 Block ${blockNumber}, only reached ${tips.pending}`);
465
- } else {
466
- logger.info(`Reached L2 Block ${tips.pending}`);
467
- }
468
- }
469
-
470
- export async function restartBot(namespace: string, logger: Logger) {
471
- logger.info(`Restarting bot`);
472
- await deleteResourceByLabel({ resource: 'pods', namespace, label: 'app=bot' });
473
- await sleep(10 * 1000);
474
- await waitForResourceByLabel({ resource: 'pods', namespace, label: 'app=bot' });
475
- logger.info(`Bot restarted`);
476
- }
477
-
478
- export async function enableValidatorDynamicBootNode(
479
- instanceName: string,
480
- namespace: string,
481
- spartanDir: string,
482
- logger: Logger,
483
- ) {
484
- logger.info(`Enabling validator dynamic boot node`);
485
- await execHelmCommand({
486
- instanceName,
487
- namespace,
488
- helmChartDir: getChartDir(spartanDir, 'aztec-network'),
489
- values: {
490
- 'validator.dynamicBootNode': 'true',
491
- },
492
- valuesFile: undefined,
493
- timeout: '15m',
494
- reuseValues: true,
495
- });
496
-
497
- logger.info(`Validator dynamic boot node enabled`);
498
- }
499
-
500
- export async function runAlertCheck(config: EnvConfig, alerts: AlertConfig[], logger: Logger) {
501
- if (isK8sConfig(config)) {
502
- const { process, port } = await startPortForward({
503
- resource: `svc/metrics-grafana`,
504
- namespace: 'metrics',
505
- containerPort: config.CONTAINER_METRICS_PORT,
506
- });
507
- const alertChecker = new AlertChecker(logger, {
508
- grafanaEndpoint: `http://localhost:${port}${config.METRICS_API_PATH}`,
509
- grafanaCredentials: `admin:${config.GRAFANA_PASSWORD}`,
510
- });
511
- await alertChecker.runAlertCheck(alerts);
512
- process.kill();
513
- } else {
514
- logger.info('Not running alert check in non-k8s environment');
515
- }
516
- }
517
-
518
- export async function updateSequencerConfig(url: string, config: Partial<SequencerConfig>) {
519
- const node = createAztecNodeClient(url);
520
- await node.setConfig(config);
521
- }
522
-
523
- export async function getSequencers(namespace: string) {
524
- const command = `kubectl get pods -l app=validator -n ${namespace} -o jsonpath='{.items[*].metadata.name}'`;
525
- const { stdout } = await execAsync(command);
526
- return stdout.split(' ');
527
- }
528
-
529
- export async function updateK8sSequencersConfig(args: {
530
- containerPort: number;
531
- namespace: string;
532
- config: Partial<SequencerConfig>;
533
- }) {
534
- const { containerPort, namespace, config } = args;
535
- const sequencers = await getSequencers(namespace);
536
- for (const sequencer of sequencers) {
537
- const { process, port } = await startPortForward({
538
- resource: `pod/${sequencer}`,
539
- namespace,
540
- containerPort,
541
- });
542
-
543
- const url = `http://localhost:${port}`;
544
- await updateSequencerConfig(url, config);
545
- process.kill();
546
- }
547
- }
548
-
549
- export async function updateSequencersConfig(env: EnvConfig, config: Partial<SequencerConfig>) {
550
- if (isK8sConfig(env)) {
551
- await updateK8sSequencersConfig({
552
- containerPort: env.CONTAINER_NODE_PORT,
553
- namespace: env.NAMESPACE,
554
- config,
555
- });
556
- } else {
557
- await updateSequencerConfig(env.NODE_URL, config);
558
- }
559
- }
560
-
561
- /**
562
- * Rolls the Aztec pods in the given namespace.
563
- * @param namespace - The namespace to roll the Aztec pods in.
564
- * @dev - IMPORTANT: This function DOES NOT delete the underlying PVCs.
565
- * This means that the pods will be restarted with the same persistent storage.
566
- * This is useful for testing, but you should be aware of the implications.
567
- */
568
- export async function rollAztecPods(namespace: string) {
569
- await deleteResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=boot-node' });
570
- await deleteResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=prover-node' });
571
- await deleteResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=prover-broker' });
572
- await deleteResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=prover-agent' });
573
- await deleteResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=validator' });
574
- await deleteResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=pxe' });
575
- await sleep(10 * 1000);
576
- await waitForResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=boot-node' });
577
- await waitForResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=prover-node' });
578
- await waitForResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=prover-broker' });
579
- await waitForResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=prover-agent' });
580
- await waitForResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=validator' });
581
- await waitForResourceByLabel({ resource: 'pods', namespace: namespace, label: 'app=pxe' });
582
- }
1
+ export * from './utils/index.js';
@@ -1,56 +0,0 @@
1
- import type { InitialAccountData } from '@aztec/accounts/testing';
2
- import { type AccountWalletWithSecretKey, type AztecNode, type CheatCodes, type CompleteAddress, type DeployL1ContractsReturnType, EthAddress, type Logger } from '@aztec/aztec.js';
3
- import { type ClientProtocolCircuitVerifier } from '@aztec/bb-prover';
4
- import type { BlobSinkServer } from '@aztec/blob-sink/server';
5
- import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
- import type { PXEService } from '@aztec/pxe/server';
7
- import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
8
- import { TokenSimulator } from '../simulators/token_simulator.js';
9
- /**
10
- * Largely taken from the e2e_token_contract test file. We deploy 2 accounts and a token contract.
11
- * However, we then setup a second PXE with a full prover instance.
12
- * We configure this instance with all of the accounts and contracts.
13
- * We then prove and verify transactions created via this full prover PXE.
14
- */
15
- export declare class FullProverTest {
16
- private minNumberOfTxsPerBlock;
17
- private realProofs;
18
- static TOKEN_NAME: string;
19
- static TOKEN_SYMBOL: string;
20
- static TOKEN_DECIMALS: bigint;
21
- private snapshotManager;
22
- logger: Logger;
23
- deployedAccounts: InitialAccountData[];
24
- wallets: AccountWalletWithSecretKey[];
25
- accounts: CompleteAddress[];
26
- fakeProofsAsset: TokenContract;
27
- tokenSim: TokenSimulator;
28
- aztecNode: AztecNode;
29
- pxe: PXEService;
30
- cheatCodes: CheatCodes;
31
- blobSink: BlobSinkServer;
32
- private provenComponents;
33
- private bbConfigCleanup?;
34
- private acvmConfigCleanup?;
35
- circuitProofVerifier?: ClientProtocolCircuitVerifier;
36
- provenAssets: TokenContract[];
37
- private context;
38
- private proverNode;
39
- private simulatedProverNode;
40
- l1Contracts: DeployL1ContractsReturnType;
41
- proverAddress: EthAddress;
42
- constructor(testName: string, minNumberOfTxsPerBlock: number, coinbase: EthAddress, realProofs?: boolean);
43
- /**
44
- * Adds two state shifts to snapshot manager.
45
- * 1. Add 2 accounts.
46
- * 2. Publicly deploy accounts, deploy token contract
47
- */
48
- applyBaseSnapshots(): Promise<void>;
49
- setup(): Promise<this>;
50
- private mintL1ERC20;
51
- snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
52
- teardown(): Promise<void>;
53
- applyMintSnapshot(): Promise<void>;
54
- deployVerifier(): Promise<void>;
55
- }
56
- //# sourceMappingURL=e2e_prover_test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"e2e_prover_test.d.ts","sourceRoot":"","sources":["../../src/e2e_prover/e2e_prover_test.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,UAAU,EACV,KAAK,MAAM,EAIZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAqB,KAAK,6BAA6B,EAAuB,MAAM,kBAAkB,CAAC;AAE9G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQpD,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AASlE;;;;;GAKG;AAEH,qBAAa,cAAc;IA4BvB,OAAO,CAAC,sBAAsB;IAE9B,OAAO,CAAC,UAAU;IA7BpB,MAAM,CAAC,UAAU,SAAU;IAC3B,MAAM,CAAC,YAAY,SAAS;IAC5B,MAAM,CAAC,cAAc,SAAO;IAC5B,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,kBAAkB,EAAE,CAAM;IAC5C,OAAO,EAAE,0BAA0B,EAAE,CAAM;IAC3C,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,eAAe,EAAG,aAAa,CAAC;IAChC,QAAQ,EAAG,cAAc,CAAC;IAC1B,SAAS,EAAG,SAAS,CAAC;IACtB,GAAG,EAAG,UAAU,CAAC;IACjB,UAAU,EAAG,UAAU,CAAC;IACxB,QAAQ,EAAG,cAAc,CAAC;IAC1B,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,eAAe,CAAC,CAAsB;IAC9C,OAAO,CAAC,iBAAiB,CAAC,CAAsB;IAChD,oBAAoB,CAAC,EAAE,6BAA6B,CAAC;IACrD,YAAY,EAAE,aAAa,EAAE,CAAM;IACnC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,mBAAmB,CAAc;IAClC,WAAW,EAAG,2BAA2B,CAAC;IAC1C,aAAa,EAAG,UAAU,CAAC;gBAGhC,QAAQ,EAAE,MAAM,EACR,sBAAsB,EAAE,MAAM,EACtC,QAAQ,EAAE,UAAU,EACZ,UAAU,UAAO;IAW3B;;;;OAIG;IACG,kBAAkB;IAqDlB,KAAK;YA0JG,WAAW;IAQzB,QAAQ,YACA,MAAM,SACL,CAAC,OAAO,EAAE,iBAAiB,KAAK,QAAQ,CAAC,CAAC,YACxC,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,QAAQ,IAAI,CAAC,KACtE,QAAQ,IAAI,CAAC,CAAwD;IAElE,QAAQ;IAeR,iBAAiB;IAiDjB,cAAc;CA4BrB"}