@aztec/aztec 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 (190) hide show
  1. package/README.md +1 -1
  2. package/dest/bin/index.d.ts +1 -1
  3. package/dest/bin/index.js +13 -6
  4. package/dest/cli/admin_api_key_store.d.ts +45 -0
  5. package/dest/cli/admin_api_key_store.d.ts.map +1 -0
  6. package/dest/cli/admin_api_key_store.js +98 -0
  7. package/dest/cli/aztec_start_action.d.ts +1 -1
  8. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  9. package/dest/cli/aztec_start_action.js +90 -31
  10. package/dest/cli/aztec_start_options.d.ts +2 -2
  11. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  12. package/dest/cli/aztec_start_options.js +60 -53
  13. package/dest/cli/cli.d.ts +1 -1
  14. package/dest/cli/cli.js +7 -7
  15. package/dest/cli/cmds/compile.d.ts +4 -0
  16. package/dest/cli/cmds/compile.d.ts.map +1 -0
  17. package/dest/cli/cmds/compile.js +166 -0
  18. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  19. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  20. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  21. package/dest/cli/cmds/profile.d.ts +4 -0
  22. package/dest/cli/cmds/profile.d.ts.map +1 -0
  23. package/dest/cli/cmds/profile.js +8 -0
  24. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  25. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  26. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  27. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  28. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  29. package/dest/cli/cmds/profile_gates.js +76 -0
  30. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  31. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  32. package/dest/cli/cmds/profile_utils.js +50 -0
  33. package/dest/cli/cmds/standby.d.ts +30 -0
  34. package/dest/cli/cmds/standby.d.ts.map +1 -0
  35. package/dest/cli/cmds/standby.js +97 -0
  36. package/dest/cli/cmds/start_bot.d.ts +3 -3
  37. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  38. package/dest/cli/cmds/start_bot.js +13 -9
  39. package/dest/cli/cmds/start_node.d.ts +3 -2
  40. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  41. package/dest/cli/cmds/start_node.js +79 -39
  42. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  43. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  44. package/dest/cli/cmds/start_p2p_bootstrap.js +2 -3
  45. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  46. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  47. package/dest/cli/cmds/start_prover_agent.js +8 -20
  48. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  49. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  50. package/dest/cli/cmds/start_prover_broker.js +25 -16
  51. package/dest/cli/cmds/start_txe.d.ts +2 -2
  52. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  53. package/dest/cli/cmds/start_txe.js +6 -5
  54. package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
  55. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  56. package/dest/cli/cmds/utils/artifacts.js +24 -0
  57. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  58. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  59. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  60. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  61. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  62. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  63. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  64. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  65. package/dest/cli/cmds/utils/spawn.js +16 -0
  66. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  67. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  68. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  69. package/dest/cli/index.d.ts +1 -1
  70. package/dest/cli/preload_crs.d.ts +1 -1
  71. package/dest/cli/util.d.ts +12 -23
  72. package/dest/cli/util.d.ts.map +1 -1
  73. package/dest/cli/util.js +57 -91
  74. package/dest/cli/versioning.d.ts +1 -1
  75. package/dest/examples/token.d.ts +1 -1
  76. package/dest/examples/token.js +10 -10
  77. package/dest/examples/util.d.ts +2 -2
  78. package/dest/examples/util.d.ts.map +1 -1
  79. package/dest/index.d.ts +2 -2
  80. package/dest/index.d.ts.map +1 -1
  81. package/dest/index.js +1 -1
  82. package/dest/local-network/auth_registry.d.ts +5 -0
  83. package/dest/local-network/auth_registry.d.ts.map +1 -0
  84. package/dest/local-network/auth_registry.js +17 -0
  85. package/dest/local-network/banana_fpc.d.ts +11 -0
  86. package/dest/local-network/banana_fpc.d.ts.map +1 -0
  87. package/dest/{sandbox → local-network}/banana_fpc.js +14 -10
  88. package/dest/local-network/index.d.ts +4 -0
  89. package/dest/local-network/index.d.ts.map +1 -0
  90. package/dest/{sandbox → local-network}/index.js +1 -1
  91. package/dest/local-network/local-network.d.ts +50 -0
  92. package/dest/local-network/local-network.d.ts.map +1 -0
  93. package/dest/local-network/local-network.js +248 -0
  94. package/dest/local-network/sponsored_fpc.d.ts +5 -0
  95. package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
  96. package/dest/mnemonic.d.ts +1 -1
  97. package/dest/splash.d.ts +1 -1
  98. package/dest/testing/anvil_test_watcher.d.ts +26 -6
  99. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  100. package/dest/testing/anvil_test_watcher.js +128 -35
  101. package/dest/testing/cheat_codes.d.ts +18 -17
  102. package/dest/testing/cheat_codes.d.ts.map +1 -1
  103. package/dest/testing/cheat_codes.js +72 -36
  104. package/dest/testing/epoch_test_settler.d.ts +19 -0
  105. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  106. package/dest/testing/epoch_test_settler.js +63 -0
  107. package/dest/testing/index.d.ts +4 -2
  108. package/dest/testing/index.d.ts.map +1 -1
  109. package/dest/testing/index.js +2 -0
  110. package/dest/testing/token_allowed_setup.d.ts +7 -0
  111. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  112. package/dest/testing/token_allowed_setup.js +20 -0
  113. package/package.json +42 -37
  114. package/scripts/add_crate.sh +53 -0
  115. package/scripts/aztec.sh +73 -0
  116. package/scripts/init.sh +39 -0
  117. package/scripts/new.sh +83 -0
  118. package/scripts/setup_workspace.sh +69 -0
  119. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  120. package/scripts/templates/blank/contract/src/main.nr +10 -0
  121. package/scripts/templates/blank/test/Nargo.toml +7 -0
  122. package/scripts/templates/blank/test/src/lib.nr +11 -0
  123. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  124. package/scripts/templates/counter/contract/src/main.nr +48 -0
  125. package/scripts/templates/counter/test/Nargo.toml +7 -0
  126. package/scripts/templates/counter/test/src/lib.nr +32 -0
  127. package/src/bin/index.ts +14 -6
  128. package/src/cli/admin_api_key_store.ts +128 -0
  129. package/src/cli/aztec_start_action.ts +83 -26
  130. package/src/cli/aztec_start_options.ts +68 -59
  131. package/src/cli/cli.ts +11 -11
  132. package/src/cli/cmds/compile.ts +192 -0
  133. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  134. package/src/cli/cmds/profile.ts +26 -0
  135. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  136. package/src/cli/cmds/profile_gates.ts +84 -0
  137. package/src/cli/cmds/profile_utils.ts +58 -0
  138. package/src/cli/cmds/standby.ts +132 -0
  139. package/src/cli/cmds/start_bot.ts +12 -11
  140. package/src/cli/cmds/start_node.ts +90 -44
  141. package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
  142. package/src/cli/cmds/start_prover_agent.ts +9 -20
  143. package/src/cli/cmds/start_prover_broker.ts +29 -26
  144. package/src/cli/cmds/start_txe.ts +7 -5
  145. package/src/cli/cmds/utils/artifacts.ts +44 -0
  146. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  147. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  148. package/src/cli/cmds/utils/spawn.ts +16 -0
  149. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  150. package/src/cli/util.ts +66 -104
  151. package/src/examples/token.ts +11 -11
  152. package/src/examples/util.ts +1 -1
  153. package/src/index.ts +2 -2
  154. package/src/local-network/auth_registry.ts +19 -0
  155. package/src/{sandbox → local-network}/banana_fpc.ts +17 -9
  156. package/src/{sandbox → local-network}/index.ts +1 -1
  157. package/src/local-network/local-network.ts +303 -0
  158. package/src/{sandbox → local-network}/sponsored_fpc.ts +3 -2
  159. package/src/testing/anvil_test_watcher.ts +142 -33
  160. package/src/testing/cheat_codes.ts +92 -38
  161. package/src/testing/epoch_test_settler.ts +69 -0
  162. package/src/testing/index.ts +3 -1
  163. package/src/testing/token_allowed_setup.ts +19 -0
  164. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  165. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  166. package/dest/cli/cmds/start_archiver.js +0 -50
  167. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  168. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  169. package/dest/cli/cmds/start_blob_sink.js +0 -33
  170. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  171. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  172. package/dest/cli/cmds/start_prover_node.js +0 -108
  173. package/dest/cli/release_version.d.ts +0 -2
  174. package/dest/cli/release_version.d.ts.map +0 -1
  175. package/dest/cli/release_version.js +0 -14
  176. package/dest/sandbox/banana_fpc.d.ts +0 -10
  177. package/dest/sandbox/banana_fpc.d.ts.map +0 -1
  178. package/dest/sandbox/index.d.ts +0 -4
  179. package/dest/sandbox/index.d.ts.map +0 -1
  180. package/dest/sandbox/sandbox.d.ts +0 -74
  181. package/dest/sandbox/sandbox.d.ts.map +0 -1
  182. package/dest/sandbox/sandbox.js +0 -183
  183. package/dest/sandbox/sponsored_fpc.d.ts +0 -4
  184. package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
  185. package/src/cli/cmds/start_archiver.ts +0 -61
  186. package/src/cli/cmds/start_blob_sink.ts +0 -57
  187. package/src/cli/cmds/start_prover_node.ts +0 -124
  188. package/src/cli/release_version.ts +0 -21
  189. package/src/sandbox/sandbox.ts +0 -242
  190. /package/dest/{sandbox → local-network}/sponsored_fpc.js +0 -0
package/dest/cli/cli.d.ts CHANGED
@@ -6,4 +6,4 @@ import { Command } from 'commander';
6
6
  * @param debugLogger - logger for logging debug messages.
7
7
  */
8
8
  export declare function injectAztecCommands(program: Command, userLog: LogFn, debugLogger: Logger): Command;
9
- //# sourceMappingURL=cli.d.ts.map
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2NsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFM0QsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUtwQzs7OztHQUlHO0FBQ0gsd0JBQWdCLG1CQUFtQixDQUFDLE9BQU8sRUFBRSxPQUFPLEVBQUUsT0FBTyxFQUFFLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0EyQ2xHIn0=
package/dest/cli/cli.js CHANGED
@@ -20,15 +20,15 @@ import { addOptions, printAztecStartHelpText } from './util.js';
20
20
  program.configureHelp({
21
21
  sortSubcommands: true
22
22
  });
23
- program.addHelpText('after', `
23
+ if (process.env.AZTEC_SHELL_WRAPPER) {
24
+ program.addHelpText('after', `
25
+ Additional commands:
24
26
 
25
- Additional commands:
26
-
27
- test [options]: starts a dockerized TXE node via
28
- $ aztec start --txe
29
- then runs
30
- $ aztec-nargo test --silence-warnings --oracle-resolver=<TXE_ADDRESS> [options]
27
+ init creates a new Aztec Noir workspace in the current directory.
28
+ new <name> creates a new Aztec Noir workspace in its own directory (or creates a new contract-test crates pair and adds it to the current workspace if run in workspace).
29
+ test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
31
30
  `);
31
+ }
32
32
  program.command('preload-crs').description('Preload the points data needed for proving and verifying').action(async (options)=>{
33
33
  const { preloadCrs } = await import('./preload_crs.js');
34
34
  return await preloadCrs(options, userLog, debugLogger);
@@ -0,0 +1,4 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+ import type { Command } from 'commander';
3
+ export declare function injectCompileCommand(program: Command, log: LogFn): Command;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcGlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL2NvbXBpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFJbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBb0t6Qyx3QkFBZ0Isb0JBQW9CLENBQUMsT0FBTyxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxHQUFHLE9BQU8sQ0FzQjFFIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoKzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAsB1E"}
@@ -0,0 +1,166 @@
1
+ import { findBbBinary } from '@aztec/bb.js';
2
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
3
+ import { execFileSync } from 'child_process';
4
+ import { readFile, writeFile } from 'fs/promises';
5
+ import { join } from 'path';
6
+ import { readArtifactFiles } from './utils/artifacts.js';
7
+ import { needsRecompile } from './utils/needs_recompile.js';
8
+ import { run } from './utils/spawn.js';
9
+ import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
10
+ /** Returns paths to contract artifacts in the target directory. */ async function collectContractArtifacts() {
11
+ let files;
12
+ try {
13
+ files = await readArtifactFiles('target');
14
+ } catch (err) {
15
+ if (err?.message?.includes('does not exist')) {
16
+ return [];
17
+ }
18
+ throw err;
19
+ }
20
+ return files.filter((f)=>Array.isArray(f.content.functions)).map((f)=>f.filePath);
21
+ }
22
+ /** Stamps the Aztec stack version into the contract artifacts. */ async function stampAztecVersion(artifactPaths) {
23
+ const version = getPackageVersion();
24
+ for (const path of artifactPaths){
25
+ const artifact = JSON.parse(await readFile(path, 'utf-8'));
26
+ // eslint-disable-next-line camelcase
27
+ artifact.aztec_version = version;
28
+ await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
29
+ }
30
+ }
31
+ /** Returns the set of package names that are contract crates in the current workspace. */ async function getContractPackageNames() {
32
+ const contractNames = new Set();
33
+ let rootToml;
34
+ try {
35
+ rootToml = await readFile('Nargo.toml', 'utf-8');
36
+ } catch {
37
+ return contractNames;
38
+ }
39
+ const membersMatch = rootToml.match(/members\s*=\s*\[([^\]]*)\]/);
40
+ if (membersMatch) {
41
+ const members = membersMatch[1].split(',').map((m)=>m.trim().replace(/^"|"$/g, '')).filter((m)=>m.length > 0);
42
+ for (const member of members){
43
+ try {
44
+ const memberToml = await readFile(join(member, 'Nargo.toml'), 'utf-8');
45
+ if (/type\s*=\s*"contract"/.test(memberToml)) {
46
+ const nameMatch = memberToml.match(/name\s*=\s*"([^"]+)"/);
47
+ if (nameMatch) {
48
+ contractNames.add(nameMatch[1]);
49
+ }
50
+ }
51
+ } catch {
52
+ // Member directory might not exist or have no Nargo.toml; skip.
53
+ }
54
+ }
55
+ } else {
56
+ // Single-crate project (no workspace): check if the root Nargo.toml itself is a contract.
57
+ if (/type\s*=\s*"contract"/.test(rootToml)) {
58
+ const nameMatch = rootToml.match(/name\s*=\s*"([^"]+)"/);
59
+ if (nameMatch) {
60
+ contractNames.add(nameMatch[1]);
61
+ }
62
+ }
63
+ }
64
+ return contractNames;
65
+ }
66
+ /** Checks that no tests exist in contract crates and fails with a helpful message if they do. */ async function checkNoTestsInContracts(nargo, log) {
67
+ const contractPackages = await getContractPackageNames();
68
+ if (contractPackages.size === 0) {
69
+ return;
70
+ }
71
+ let output;
72
+ try {
73
+ // We list tests for all the crates in the workspace
74
+ output = execFileSync(nargo, [
75
+ 'test',
76
+ '--list-tests',
77
+ '--silence-warnings'
78
+ ], {
79
+ encoding: 'utf-8',
80
+ stdio: [
81
+ 'pipe',
82
+ 'pipe',
83
+ 'inherit'
84
+ ]
85
+ });
86
+ } catch {
87
+ // If listing tests fails (e.g. test crate has compile errors), skip the check.
88
+ return;
89
+ }
90
+ // The output of the `nargo test --list-tests` command is as follows:
91
+ // ```
92
+ // crate_name_1 test_name_1
93
+ // crate_name_2 test_name_2
94
+ // ...
95
+ // crate_name_n test_name_n
96
+ // ```
97
+ //
98
+ // We parse the individual lines and then we check if any contract crate appeared in the parsed output.
99
+ const lines = output.trim().split('\n').filter((line)=>line.length > 0);
100
+ const testsInContracts = [];
101
+ for (const line of lines){
102
+ const spaceIndex = line.indexOf(' ');
103
+ if (spaceIndex === -1) {
104
+ continue;
105
+ }
106
+ const packageName = line.substring(0, spaceIndex);
107
+ const testName = line.substring(spaceIndex + 1);
108
+ if (contractPackages.has(packageName)) {
109
+ testsInContracts.push({
110
+ packageName,
111
+ testName
112
+ });
113
+ }
114
+ }
115
+ if (testsInContracts.length > 0) {
116
+ const details = testsInContracts.map((t)=>` ${t.packageName}::${t.testName}`).join('\n');
117
+ log(`WARNING: Found tests in contract crate(s):\n${details}\n\n` + `Tests should be in a dedicated test crate, not in the contract crate.\n` + `Learn more: https://docs.aztec.network/errors/1`);
118
+ }
119
+ }
120
+ /** Compiles Aztec Noir contracts and postprocesses artifacts. */ async function compileAztecContract(nargoArgs, log) {
121
+ await warnIfAztecVersionMismatch(log);
122
+ if (!await needsRecompile()) {
123
+ log('No source changes detected, skipping compilation.');
124
+ return;
125
+ }
126
+ const nargo = process.env.NARGO ?? 'nargo';
127
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
128
+ await run(nargo, [
129
+ 'compile',
130
+ ...nargoArgs
131
+ ]);
132
+ // Ensure contract crates contain no tests (tests belong in the test crate).
133
+ await checkNoTestsInContracts(nargo, log);
134
+ const artifacts = await collectContractArtifacts();
135
+ if (artifacts.length > 0) {
136
+ log('Postprocessing contracts...');
137
+ const bbArgs = artifacts.flatMap((a)=>[
138
+ '-i',
139
+ a
140
+ ]);
141
+ await run(bb, [
142
+ 'aztec_process',
143
+ ...bbArgs
144
+ ]);
145
+ await stampAztecVersion(artifacts);
146
+ }
147
+ log('Compilation complete!');
148
+ }
149
+ export function injectCompileCommand(program, log) {
150
+ program.command('compile').argument('[nargo-args...]').passThroughOptions().allowUnknownOption().description('Compile Aztec Noir contracts using nargo and postprocess them to generate transpiled artifacts and verification keys. All options are forwarded to nargo compile.').addHelpText('after', ()=>{
151
+ // Show nargo's own compile options so users see all available flags in one place.
152
+ const nargo = process.env.NARGO ?? 'nargo';
153
+ try {
154
+ const output = execFileSync(nargo, [
155
+ 'compile',
156
+ '--help'
157
+ ], {
158
+ encoding: 'utf-8'
159
+ });
160
+ return `\nUnderlying nargo compile options:\n\n${output}`;
161
+ } catch {
162
+ return '\n(Run "nargo compile --help" to see available nargo options)';
163
+ }
164
+ }).action((nargoArgs)=>compileAztecContract(nargoArgs, log));
165
+ return program;
166
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function injectMigrateCommand(program: Command, log: (msg: string) => void): Command;
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlncmF0ZV9oYV9kYi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL21pZ3JhdGVfaGFfZGIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBRXpDLHdCQUFnQixvQkFBb0IsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEtBQUssSUFBSSxHQUFHLE9BQU8sQ0FzQzFGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_ha_db.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/migrate_ha_db.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAsC1F"}
@@ -0,0 +1,27 @@
1
+ import { runMigrations } from '@aztec/validator-ha-signer/migrations';
2
+ export function injectMigrateCommand(program, log) {
3
+ const migrateCommand = program.command('migrate-ha-db').description('Run validator-ha-signer database migrations');
4
+ migrateCommand.command('up').description('Apply pending migrations').requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL).option('--verbose', 'Enable verbose output', false).action(async (options)=>{
5
+ const migrations = await runMigrations(options.databaseUrl, {
6
+ direction: 'up',
7
+ verbose: options.verbose
8
+ });
9
+ if (migrations.length > 0) {
10
+ log(`Applied migrations: ${migrations.join(', ')}`);
11
+ } else {
12
+ log('No migrations to apply - schema is up to date');
13
+ }
14
+ });
15
+ migrateCommand.command('down').description('Rollback the last migration').requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL).option('--verbose', 'Enable verbose output', false).action(async (options)=>{
16
+ const migrations = await runMigrations(options.databaseUrl, {
17
+ direction: 'down',
18
+ verbose: options.verbose
19
+ });
20
+ if (migrations.length > 0) {
21
+ log(`Rolled back migrations: ${migrations.join(', ')}`);
22
+ } else {
23
+ log('No migrations to rollback');
24
+ }
25
+ });
26
+ return program;
27
+ }
@@ -0,0 +1,4 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+ import type { Command } from 'commander';
3
+ export declare function injectProfileCommand(program: Command, log: LogFn): Command;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3Byb2ZpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBS3pDLHdCQUFnQixvQkFBb0IsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxLQUFLLEdBQUcsT0FBTyxDQWtCMUUifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAkB1E"}
@@ -0,0 +1,8 @@
1
+ import { profileFlamegraph } from './profile_flamegraph.js';
2
+ import { profileGates } from './profile_gates.js';
3
+ export function injectProfileCommand(program, log) {
4
+ const profile = program.command('profile').description('Profile compiled Aztec artifacts.');
5
+ profile.command('gates').argument('[target-dir]', 'Path to the compiled artifacts directory', './target').option('--json', 'Output gate counts as JSON instead of a table', false).description('Display gate counts for all compiled Aztec artifacts in a target directory.').action((targetDir, options)=>profileGates(targetDir, options.json, log));
6
+ profile.command('flamegraph').argument('<contract-artifact>', 'Path to the compiled contract artifact JSON').argument('<function>', 'Name of the contract function to profile').description('Generate a gate count flamegraph SVG for a contract function.').action((artifactPath, functionName)=>profileFlamegraph(artifactPath, functionName, log));
7
+ return program;
8
+ }
@@ -0,0 +1,4 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+ /** Generates a gate count flamegraph SVG for a single contract function. */
3
+ export declare function profileFlamegraph(artifactPath: string, functionName: string, log: LogFn): Promise<void>;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV9mbGFtZWdyYXBoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvcHJvZmlsZV9mbGFtZWdyYXBoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBU25ELDRFQUE0RTtBQUM1RSx3QkFBc0IsaUJBQWlCLENBQUMsWUFBWSxFQUFFLE1BQU0sRUFBRSxZQUFZLEVBQUUsTUFBTSxFQUFFLEdBQUcsRUFBRSxLQUFLLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQW9EN0cifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile_flamegraph.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_flamegraph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD,4EAA4E;AAC5E,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAoD7G"}
@@ -0,0 +1,52 @@
1
+ import { findBbBinary } from '@aztec/bb.js';
2
+ import { readFile, rename, rm, writeFile } from 'fs/promises';
3
+ import { basename, dirname, join } from 'path';
4
+ import { makeFunctionArtifact } from './profile_utils.js';
5
+ import { run } from './utils/spawn.js';
6
+ /** Generates a gate count flamegraph SVG for a single contract function. */ export async function profileFlamegraph(artifactPath, functionName, log) {
7
+ const raw = await readFile(artifactPath, 'utf-8');
8
+ const artifact = JSON.parse(raw);
9
+ if (!Array.isArray(artifact.functions)) {
10
+ throw new Error(`${artifactPath} does not appear to be a contract artifact (no functions array)`);
11
+ }
12
+ const func = artifact.functions.find((f)=>f.name === functionName);
13
+ if (!func) {
14
+ const available = artifact.functions.map((f)=>f.name).join(', ');
15
+ throw new Error(`Function "${functionName}" not found in artifact. Available: ${available}`);
16
+ }
17
+ if (func.is_unconstrained) {
18
+ throw new Error(`Function "${functionName}" is unconstrained and cannot be profiled`);
19
+ }
20
+ const outputDir = dirname(artifactPath);
21
+ const contractName = basename(artifactPath, '.json');
22
+ const functionArtifact = join(outputDir, `${contractName}-${functionName}.json`);
23
+ try {
24
+ await writeFile(functionArtifact, makeFunctionArtifact(artifact, func));
25
+ const profiler = process.env.PROFILER_PATH ?? 'noir-profiler';
26
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
27
+ await run(profiler, [
28
+ 'gates',
29
+ '--artifact-path',
30
+ functionArtifact,
31
+ '--backend-path',
32
+ bb,
33
+ '--backend-gates-command',
34
+ 'gates',
35
+ '--output',
36
+ outputDir,
37
+ '--scheme',
38
+ 'chonk',
39
+ '--include_gates_per_opcode'
40
+ ]);
41
+ // noir-profiler names the SVG using the internal function name which
42
+ // retains the __aztec_nr_internals__ prefix in the bytecode metadata.
43
+ const srcSvg = join(outputDir, `__aztec_nr_internals__${functionName}_gates.svg`);
44
+ const destSvg = join(outputDir, `${contractName}-${functionName}-flamegraph.svg`);
45
+ await rename(srcSvg, destSvg);
46
+ log(`Flamegraph written to ${destSvg}`);
47
+ } finally{
48
+ await rm(functionArtifact, {
49
+ force: true
50
+ });
51
+ }
52
+ }
@@ -0,0 +1,4 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+ /** Profiles all compiled artifacts in a target directory and prints gate counts. */
3
+ export declare function profileGates(targetDir: string, json: boolean, log: LogFn): Promise<void>;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV9nYXRlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3Byb2ZpbGVfZ2F0ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFnQ25ELG9GQUFvRjtBQUNwRix3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FnRDlGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile_gates.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_gates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAgCnD,oFAAoF;AACpF,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAgD9F"}
@@ -0,0 +1,76 @@
1
+ import { findBbBinary } from '@aztec/bb.js';
2
+ import { asyncPool } from '@aztec/foundation/async-pool';
3
+ import { execFile as execFileCb } from 'child_process';
4
+ import { rm } from 'fs/promises';
5
+ import { promisify } from 'util';
6
+ import { MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
7
+ const execFile = promisify(execFileCb);
8
+ /** Parses circuit_size from bb gates JSON output: { "functions": [{ "circuit_size": N }] } */ function parseGateCount(stdout) {
9
+ const parsed = JSON.parse(stdout);
10
+ const size = parsed?.functions?.[0]?.circuit_size;
11
+ if (typeof size !== 'number') {
12
+ throw new Error('Failed to parse circuit_size from bb gates output');
13
+ }
14
+ return size;
15
+ }
16
+ /** Runs bb gates on a single artifact file and returns the gate count. */ async function getGateCount(bb, artifactPath) {
17
+ const { stdout } = await execFile(bb, [
18
+ 'gates',
19
+ '--scheme',
20
+ 'chonk',
21
+ '-b',
22
+ artifactPath
23
+ ]);
24
+ return parseGateCount(stdout);
25
+ }
26
+ /** Profiles all compiled artifacts in a target directory and prints gate counts. */ export async function profileGates(targetDir, json, log) {
27
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
28
+ const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
29
+ if (artifacts.length === 0) {
30
+ if (json) {
31
+ log('[]');
32
+ } else {
33
+ log('No artifacts found in target directory.');
34
+ }
35
+ return;
36
+ }
37
+ try {
38
+ const results = await asyncPool(MAX_CONCURRENT, artifacts, async (artifact)=>({
39
+ name: artifact.name,
40
+ type: artifact.type,
41
+ gateCount: await getGateCount(bb, artifact.filePath)
42
+ }));
43
+ results.sort((a, b)=>a.name.localeCompare(b.name));
44
+ if (results.length === 0) {
45
+ if (json) {
46
+ log('[]');
47
+ } else {
48
+ log('No constrained circuits found.');
49
+ }
50
+ return;
51
+ }
52
+ if (json) {
53
+ const entries = results.map((r)=>({
54
+ name: r.name,
55
+ type: r.type,
56
+ gates: r.gateCount
57
+ }));
58
+ log(JSON.stringify(entries, null, 2));
59
+ return;
60
+ }
61
+ const maxNameLen = Math.max(...results.map((r)=>r.name.length));
62
+ log('');
63
+ log('Gate counts:');
64
+ log('-'.repeat(maxNameLen + 16));
65
+ for (const { name, gateCount } of results){
66
+ log(`${name.padEnd(maxNameLen)} ${gateCount.toLocaleString().padStart(12)}`);
67
+ }
68
+ log('-'.repeat(maxNameLen + 16));
69
+ log(`Total: ${results.length} circuit(s)`);
70
+ } finally{
71
+ await rm(tmpDir, {
72
+ recursive: true,
73
+ force: true
74
+ });
75
+ }
76
+ }
@@ -0,0 +1,18 @@
1
+ import type { CompiledArtifact, ContractFunction } from './utils/artifacts.js';
2
+ export declare const MAX_CONCURRENT = 4;
3
+ export interface DiscoveredArtifact {
4
+ name: string;
5
+ filePath: string;
6
+ type: 'contract-function' | 'program';
7
+ }
8
+ /**
9
+ * Reads a target directory and returns a list of discovered artifacts with temp files
10
+ * created for contract functions. Caller must clean up tmpDir when done.
11
+ */
12
+ export declare function discoverArtifacts(targetDir: string): Promise<{
13
+ artifacts: DiscoveredArtifact[];
14
+ tmpDir: string;
15
+ }>;
16
+ /** Extracts a contract function as a standalone program artifact JSON string. */
17
+ export declare function makeFunctionArtifact(artifact: CompiledArtifact, func: ContractFunction): string;
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV91dGlscy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3Byb2ZpbGVfdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUcvRSxlQUFPLE1BQU0sY0FBYyxJQUFJLENBQUM7QUFFaEMsTUFBTSxXQUFXLGtCQUFrQjtJQUNqQyxJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ2IsUUFBUSxFQUFFLE1BQU0sQ0FBQztJQUNqQixJQUFJLEVBQUUsbUJBQW1CLEdBQUcsU0FBUyxDQUFDO0NBQ3ZDO0FBRUQ7OztHQUdHO0FBQ0gsd0JBQXNCLGlCQUFpQixDQUNyQyxTQUFTLEVBQUUsTUFBTSxHQUNoQixPQUFPLENBQUM7SUFBRSxTQUFTLEVBQUUsa0JBQWtCLEVBQUUsQ0FBQztJQUFDLE1BQU0sRUFBRSxNQUFNLENBQUE7Q0FBRSxDQUFDLENBc0I5RDtBQUVELGlGQUFpRjtBQUNqRix3QkFBZ0Isb0JBQW9CLENBQUMsUUFBUSxFQUFFLGdCQUFnQixFQUFFLElBQUksRUFBRSxnQkFBZ0IsVUFXdEYifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile_utils.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG/E,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB9D;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,UAWtF"}
@@ -0,0 +1,50 @@
1
+ import { mkdtemp, writeFile } from 'fs/promises';
2
+ import { tmpdir } from 'os';
3
+ import { join } from 'path';
4
+ import { readArtifactFiles } from './utils/artifacts.js';
5
+ export const MAX_CONCURRENT = 4;
6
+ /**
7
+ * Reads a target directory and returns a list of discovered artifacts with temp files
8
+ * created for contract functions. Caller must clean up tmpDir when done.
9
+ */ export async function discoverArtifacts(targetDir) {
10
+ const files = await readArtifactFiles(targetDir);
11
+ const tmpDir = await mkdtemp(join(tmpdir(), 'aztec-profile-'));
12
+ const artifacts = [];
13
+ for (const file of files){
14
+ if (Array.isArray(file.content.functions)) {
15
+ for (const func of file.content.functions){
16
+ if (!func.bytecode || func.is_unconstrained) {
17
+ continue;
18
+ }
19
+ const name = `${file.name}::${func.name}`;
20
+ const tmpPath = join(tmpDir, `${file.name}-${func.name}.json`);
21
+ await writeFile(tmpPath, makeFunctionArtifact(file.content, func));
22
+ artifacts.push({
23
+ name,
24
+ filePath: tmpPath,
25
+ type: 'contract-function'
26
+ });
27
+ }
28
+ } else if (file.content.bytecode) {
29
+ artifacts.push({
30
+ name: file.name,
31
+ filePath: file.filePath,
32
+ type: 'program'
33
+ });
34
+ }
35
+ }
36
+ return {
37
+ artifacts,
38
+ tmpDir
39
+ };
40
+ }
41
+ /** Extracts a contract function as a standalone program artifact JSON string. */ export function makeFunctionArtifact(artifact, func) {
42
+ /* eslint-disable camelcase */ return JSON.stringify({
43
+ noir_version: artifact.noir_version,
44
+ hash: 0,
45
+ abi: func.abi,
46
+ bytecode: func.bytecode,
47
+ debug_symbols: func.debug_symbols,
48
+ file_map: artifact.file_map
49
+ });
50
+ /* eslint-enable camelcase */ }
@@ -0,0 +1,30 @@
1
+ import type { Fr } from '@aztec/aztec.js/fields';
2
+ import type { GenesisStateConfig } from '@aztec/ethereum/config';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import type { LogFn } from '@aztec/foundation/log';
5
+ /**
6
+ * Computes the expected genesis archive root from the genesis state config.
7
+ * Reads test accounts and sponsored FPC addresses as specified, then computes
8
+ * the genesis values including the archive root and prefilled public data.
9
+ */
10
+ export declare function computeExpectedGenesisRoot(config: GenesisStateConfig, userLog: LogFn): Promise<{
11
+ genesisArchiveRoot: Fr;
12
+ genesis: import("@aztec/stdlib/world-state").GenesisData;
13
+ }>;
14
+ /**
15
+ * Waits until the canonical rollup's genesis archive root, VK tree root, and protocol contracts hash
16
+ * all match the expected local values. If the rollup is not yet compatible (e.g. during L1 contract upgrades),
17
+ * enters standby mode: starts a lightweight HTTP server for K8s liveness probes and polls every 60s
18
+ * until a compatible rollup appears.
19
+ */
20
+ export declare function waitForCompatibleRollup(config: {
21
+ l1RpcUrls: string[];
22
+ l1ChainId: number;
23
+ registryAddress: EthAddress;
24
+ rollupVersion?: number;
25
+ }, expected: {
26
+ genesisArchiveRoot: Fr;
27
+ vkTreeRoot: Fr;
28
+ protocolContractsHash: Fr;
29
+ }, port: number | undefined, userLog: LogFn): Promise<void>;
30
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhbmRieS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YW5kYnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHakQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUVqRSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUVoRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQVNuRDs7OztHQUlHO0FBQ0gsd0JBQXNCLDBCQUEwQixDQUFDLE1BQU0sRUFBRSxrQkFBa0IsRUFBRSxPQUFPLEVBQUUsS0FBSzs7O0dBYTFGO0FBd0JEOzs7OztHQUtHO0FBQ0gsd0JBQXNCLHVCQUF1QixDQUMzQyxNQUFNLEVBQUU7SUFDTixTQUFTLEVBQUUsTUFBTSxFQUFFLENBQUM7SUFDcEIsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixlQUFlLEVBQUUsVUFBVSxDQUFDO0lBQzVCLGFBQWEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUN4QixFQUNELFFBQVEsRUFBRTtJQUFFLGtCQUFrQixFQUFFLEVBQUUsQ0FBQztJQUFDLFVBQVUsRUFBRSxFQUFFLENBQUM7SUFBQyxxQkFBcUIsRUFBRSxFQUFFLENBQUE7Q0FBRSxFQUMvRSxJQUFJLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDeEIsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUMsSUFBSSxDQUFDLENBd0RmIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standby.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/standby.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK;;;GAa1F;AAwBD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,UAAU,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,EACD,QAAQ,EAAE;IAAE,kBAAkB,EAAE,EAAE,CAAC;IAAC,UAAU,EAAE,EAAE,CAAC;IAAC,qBAAqB,EAAE,EAAE,CAAA;CAAE,EAC/E,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,KAAK,GACb,OAAO,CAAC,IAAI,CAAC,CAwDf"}
@@ -0,0 +1,97 @@
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
3
+ import { getPublicClient } from '@aztec/ethereum/client';
4
+ import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
5
+ import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
6
+ import { retryUntil } from '@aztec/foundation/retry';
7
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
+ import { getGenesisValues } from '@aztec/world-state/testing';
9
+ import Koa from 'koa';
10
+ const ROLLUP_POLL_INTERVAL_S = 60;
11
+ /**
12
+ * Computes the expected genesis archive root from the genesis state config.
13
+ * Reads test accounts and sponsored FPC addresses as specified, then computes
14
+ * the genesis values including the archive root and prefilled public data.
15
+ */ export async function computeExpectedGenesisRoot(config, userLog) {
16
+ const testAccounts = config.testAccounts ? (await getInitialTestAccountsData()).map((a)=>a.address) : [];
17
+ const sponsoredFPCAccounts = config.sponsoredFPC ? [
18
+ await getSponsoredFPCAddress()
19
+ ] : [];
20
+ const prefundAddresses = (config.prefundAddresses ?? []).map((a)=>AztecAddress.fromString(a));
21
+ const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses);
22
+ userLog(`Initial funded accounts: ${initialFundedAccounts.map((a)=>a.toString()).join(', ')}`);
23
+ const { genesisArchiveRoot, genesis } = await getGenesisValues(initialFundedAccounts);
24
+ userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
25
+ return {
26
+ genesisArchiveRoot,
27
+ genesis
28
+ };
29
+ }
30
+ async function checkRollupCompatibility(rollup, expected) {
31
+ const mismatches = [];
32
+ const [l1Genesis, l1Vk, l1Protocol] = await Promise.all([
33
+ rollup.getGenesisArchiveTreeRoot(),
34
+ rollup.getVkTreeRoot(),
35
+ rollup.getProtocolContractsHash()
36
+ ]);
37
+ if (!l1Genesis.equals(expected.genesisArchiveRoot)) {
38
+ mismatches.push(`genesis archive root (expected ${expected.genesisArchiveRoot}, got ${l1Genesis})`);
39
+ }
40
+ if (!l1Vk.equals(expected.vkTreeRoot)) {
41
+ mismatches.push(`VK tree root (expected ${expected.vkTreeRoot}, got ${l1Vk})`);
42
+ }
43
+ if (!l1Protocol.equals(expected.protocolContractsHash)) {
44
+ mismatches.push(`protocol contracts hash (expected ${expected.protocolContractsHash}, got ${l1Protocol})`);
45
+ }
46
+ return mismatches;
47
+ }
48
+ /**
49
+ * Waits until the canonical rollup's genesis archive root, VK tree root, and protocol contracts hash
50
+ * all match the expected local values. If the rollup is not yet compatible (e.g. during L1 contract upgrades),
51
+ * enters standby mode: starts a lightweight HTTP server for K8s liveness probes and polls every 60s
52
+ * until a compatible rollup appears.
53
+ */ export async function waitForCompatibleRollup(config, expected, port, userLog) {
54
+ const publicClient = getPublicClient(config);
55
+ const rollupVersion = config.rollupVersion ?? 'canonical';
56
+ const registry = new RegistryContract(publicClient, config.registryAddress);
57
+ const rollupAddress = await registry.getRollupAddress(rollupVersion);
58
+ const rollup = new RollupContract(publicClient, rollupAddress.toString());
59
+ let mismatches;
60
+ try {
61
+ mismatches = await checkRollupCompatibility(rollup, expected);
62
+ } catch (err) {
63
+ throw new Error(`Could not retrieve rollup config from canonical rollup at ${rollupAddress}: ${err.message}`);
64
+ }
65
+ if (mismatches.length === 0) {
66
+ return;
67
+ }
68
+ userLog(`Rollup at ${rollupAddress} is incompatible: ${mismatches.join('; ')}. ` + `Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_S}s for a compatible rollup...`);
69
+ const standbyServer = await startHttpRpcServer({
70
+ getApp: ()=>new Koa(),
71
+ isHealthy: ()=>true
72
+ }, {
73
+ port
74
+ });
75
+ userLog(`Standby status server listening on port ${standbyServer.port}`);
76
+ try {
77
+ await retryUntil(async ()=>{
78
+ const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
79
+ const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
80
+ let currentMismatches;
81
+ try {
82
+ currentMismatches = await checkRollupCompatibility(currentRollup, expected);
83
+ } catch {
84
+ userLog(`Failed to fetch rollup config from rollup at ${currentRollupAddress}. Retrying...`);
85
+ return undefined;
86
+ }
87
+ if (currentMismatches.length === 0) {
88
+ userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
89
+ return true;
90
+ }
91
+ userLog(`Still waiting. Rollup at ${currentRollupAddress}: ${currentMismatches.join('; ')}.`);
92
+ return undefined;
93
+ }, 'compatible rollup', 0, ROLLUP_POLL_INTERVAL_S);
94
+ } finally{
95
+ await new Promise((resolve, reject)=>standbyServer.close((err)=>err ? reject(err) : resolve()));
96
+ }
97
+ }
@@ -2,7 +2,7 @@ import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
3
  import { type AztecNode, type AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
4
4
  import type { TelemetryClient } from '@aztec/telemetry-client';
5
- import { TestWallet } from '@aztec/test-wallet/server';
5
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
6
6
  export declare function startBot(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, userLog: LogFn): Promise<void>;
7
- export declare function addBot(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, wallet: TestWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin?: AztecNodeAdmin): Promise<void>;
8
- //# sourceMappingURL=start_bot.d.ts.map
7
+ export declare function addBot(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin?: AztecNodeAdmin, userLog?: LogFn): Promise<void>;
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFDL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUFFLEtBQUssY0FBYyxFQUF5QixNQUFNLGlDQUFpQyxDQUFDO0FBQzdHLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBTS9ELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUt6RCx3QkFBc0IsUUFBUSxDQUM1QixPQUFPLEVBQUUsR0FBRyxFQUNaLGNBQWMsRUFBRSxDQUFDLE1BQU0sT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLEVBQUUsRUFDdkMsUUFBUSxFQUFFLHFCQUFxQixFQUMvQixPQUFPLEVBQUUsS0FBSyxpQkFzQmY7QUFFRCx3QkFBc0IsTUFBTSxDQUMxQixPQUFPLEVBQUUsR0FBRyxFQUNaLGNBQWMsRUFBRSxDQUFDLE1BQU0sT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLEVBQUUsRUFDdkMsUUFBUSxFQUFFLHFCQUFxQixFQUMvQixNQUFNLEVBQUUsY0FBYyxFQUN0QixTQUFTLEVBQUUsU0FBUyxFQUNwQixTQUFTLEVBQUUsZUFBZSxFQUMxQixjQUFjLENBQUMsRUFBRSxjQUFjLEVBQy9CLE9BQU8sQ0FBQyxFQUFFLEtBQUssaUJBbUJoQiJ9