@aztec/aztec 0.0.1-commit.ff7989d6c → 0.0.1-commit.fff30aa

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 (113) hide show
  1. package/dest/bin/index.js +4 -2
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +27 -9
  5. package/dest/cli/aztec_start_options.d.ts +1 -1
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +14 -2
  8. package/dest/cli/cli.js +3 -3
  9. package/dest/cli/cmds/compile.d.ts +1 -1
  10. package/dest/cli/cmds/compile.d.ts.map +1 -1
  11. package/dest/cli/cmds/compile.js +109 -36
  12. package/dest/cli/cmds/profile.d.ts +4 -0
  13. package/dest/cli/cmds/profile.d.ts.map +1 -0
  14. package/dest/cli/cmds/profile.js +8 -0
  15. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  16. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  17. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  18. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  19. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  20. package/dest/cli/cmds/profile_gates.js +58 -0
  21. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  22. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  23. package/dest/cli/cmds/profile_utils.js +50 -0
  24. package/dest/cli/cmds/standby.d.ts +32 -0
  25. package/dest/cli/cmds/standby.d.ts.map +1 -0
  26. package/dest/cli/cmds/standby.js +97 -0
  27. package/dest/cli/cmds/start_node.d.ts +3 -2
  28. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  29. package/dest/cli/cmds/start_node.js +24 -32
  30. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  31. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  32. package/dest/cli/cmds/start_prover_agent.js +3 -15
  33. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  34. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  35. package/dest/cli/cmds/start_prover_broker.js +12 -6
  36. package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
  37. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  38. package/dest/cli/cmds/utils/artifacts.js +24 -0
  39. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  40. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  41. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  42. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  43. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  44. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  45. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  46. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  47. package/dest/cli/cmds/utils/spawn.js +16 -0
  48. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  49. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  50. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +62 -0
  51. package/dest/cli/util.d.ts +3 -5
  52. package/dest/cli/util.d.ts.map +1 -1
  53. package/dest/cli/util.js +37 -78
  54. package/dest/examples/token.js +4 -4
  55. package/dest/local-network/banana_fpc.js +1 -1
  56. package/dest/local-network/local-network.d.ts +1 -1
  57. package/dest/local-network/local-network.d.ts.map +1 -1
  58. package/dest/local-network/local-network.js +18 -5
  59. package/dest/testing/anvil_test_watcher.d.ts +1 -1
  60. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  61. package/dest/testing/anvil_test_watcher.js +36 -10
  62. package/dest/testing/cheat_codes.d.ts +11 -15
  63. package/dest/testing/cheat_codes.d.ts.map +1 -1
  64. package/dest/testing/cheat_codes.js +34 -32
  65. package/dest/testing/epoch_test_settler.d.ts +1 -1
  66. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  67. package/dest/testing/epoch_test_settler.js +3 -4
  68. package/dest/testing/index.d.ts +2 -1
  69. package/dest/testing/index.d.ts.map +1 -1
  70. package/dest/testing/index.js +1 -0
  71. package/dest/testing/token_allowed_setup.d.ts +7 -0
  72. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  73. package/dest/testing/token_allowed_setup.js +20 -0
  74. package/package.json +35 -34
  75. package/scripts/add_crate.sh +102 -0
  76. package/scripts/aztec.sh +9 -1
  77. package/scripts/init.sh +23 -19
  78. package/scripts/new.sh +48 -24
  79. package/scripts/setup_workspace.sh +68 -0
  80. package/src/bin/index.ts +4 -2
  81. package/src/cli/aztec_start_action.ts +16 -9
  82. package/src/cli/aztec_start_options.ts +14 -2
  83. package/src/cli/cli.ts +3 -3
  84. package/src/cli/cmds/compile.ts +124 -37
  85. package/src/cli/cmds/profile.ts +25 -0
  86. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  87. package/src/cli/cmds/profile_gates.ts +68 -0
  88. package/src/cli/cmds/profile_utils.ts +58 -0
  89. package/src/cli/cmds/standby.ts +132 -0
  90. package/src/cli/cmds/start_node.ts +39 -31
  91. package/src/cli/cmds/start_prover_agent.ts +3 -6
  92. package/src/cli/cmds/start_prover_broker.ts +14 -14
  93. package/src/cli/cmds/utils/artifacts.ts +44 -0
  94. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  95. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  96. package/src/cli/cmds/utils/spawn.ts +16 -0
  97. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +77 -0
  98. package/src/cli/util.ts +41 -74
  99. package/src/examples/token.ts +6 -4
  100. package/src/local-network/banana_fpc.ts +1 -1
  101. package/src/local-network/local-network.ts +13 -3
  102. package/src/testing/anvil_test_watcher.ts +33 -10
  103. package/src/testing/cheat_codes.ts +42 -36
  104. package/src/testing/epoch_test_settler.ts +3 -4
  105. package/src/testing/index.ts +1 -0
  106. package/src/testing/token_allowed_setup.ts +19 -0
  107. package/dest/cli/release_version.d.ts +0 -2
  108. package/dest/cli/release_version.d.ts.map +0 -1
  109. package/dest/cli/release_version.js +0 -14
  110. package/scripts/extract_function.js +0 -47
  111. package/scripts/flamegraph.sh +0 -59
  112. package/scripts/setup_project.sh +0 -31
  113. package/src/cli/release_version.ts +0 -21
package/dest/bin/index.js CHANGED
@@ -11,11 +11,12 @@ import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
11
11
  import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/validator_keys';
12
12
  import { getActiveNetworkName } from '@aztec/foundation/config';
13
13
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
14
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
14
15
  import { Command } from 'commander';
15
16
  import { injectCompileCommand } from '../cli/cmds/compile.js';
16
17
  import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
18
+ import { injectProfileCommand } from '../cli/cmds/profile.js';
17
19
  import { injectAztecCommands } from '../cli/index.js';
18
- import { getCliVersion } from '../cli/release_version.js';
19
20
  const NETWORK_FLAG = 'network';
20
21
  const userLog = createConsoleLogger();
21
22
  const debugLogger = createLogger('cli');
@@ -35,7 +36,7 @@ const debugLogger = createLogger('cli');
35
36
  const networkName = getActiveNetworkName(networkValue);
36
37
  await enrichEnvironmentWithNetworkConfig(networkName);
37
38
  enrichEnvironmentWithChainName(networkName);
38
- const cliVersion = getCliVersion();
39
+ const cliVersion = getPackageVersion() ?? 'unknown';
39
40
  let program = new Command('aztec');
40
41
  program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
41
42
  program = injectAztecCommands(program, userLog, debugLogger);
@@ -47,6 +48,7 @@ const debugLogger = createLogger('cli');
47
48
  program = injectMiscCommands(program, userLog);
48
49
  program = injectValidatorKeysCommands(program, userLog);
49
50
  program = injectCompileCommand(program, userLog);
51
+ program = injectProfileCommand(program, userLog);
50
52
  program = injectMigrateCommand(program, userLog);
51
53
  await program.parseAsync(process.argv);
52
54
  }
@@ -1,3 +1,3 @@
1
1
  import type { LogFn, Logger } from '@aztec/foundation/log';
2
2
  export declare function aztecStart(options: any, userLog: LogFn, debugLogger: Logger): Promise<void>;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfc3RhcnRfYWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2F6dGVjX3N0YXJ0X2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFhM0Qsd0JBQXNCLFVBQVUsQ0FBQyxPQUFPLEVBQUUsR0FBRyxFQUFFLE9BQU8sRUFBRSxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUJBd0lqRiJ9
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfc3RhcnRfYWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2F6dGVjX3N0YXJ0X2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFPQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFhM0Qsd0JBQXNCLFVBQVUsQ0FBQyxPQUFPLEVBQUUsR0FBRyxFQUFFLE9BQU8sRUFBRSxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUJBOElqRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"aztec_start_action.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_action.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAa3D,wBAAsB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBAwIjF"}
1
+ {"version":3,"file":"aztec_start_action.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_action.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAa3D,wBAAsB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBA8IjF"}
@@ -1,11 +1,12 @@
1
+ import { getActiveNetworkName } from '@aztec/foundation/config';
1
2
  import { createNamespacedSafeJsonRpcServer, getApiKeyAuthMiddleware, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
2
- import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
3
+ import { AztecNodeAdminApiSchema, AztecNodeApiSchema, AztecNodeDebugApiSchema } from '@aztec/stdlib/interfaces/client';
4
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
3
5
  import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
4
6
  import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
5
7
  import { createLocalNetwork } from '../local-network/index.js';
6
8
  import { github, splash } from '../splash.js';
7
9
  import { resolveAdminApiKey } from './admin_api_key_store.js';
8
- import { getCliVersion } from './release_version.js';
9
10
  import { extractNamespacedOptions, installSignalHandlers } from './util.js';
10
11
  import { getVersions } from './versioning.js';
11
12
  export async function aztecStart(options, userLog, debugLogger) {
@@ -13,13 +14,12 @@ export async function aztecStart(options, userLog, debugLogger) {
13
14
  const signalHandlers = [];
14
15
  const services = {};
15
16
  const adminServices = {};
17
+ const packageVersion = getPackageVersion();
16
18
  let config = undefined;
17
19
  if (options.localNetwork) {
18
- const cliVersion = getCliVersion();
19
- const localNetwork = extractNamespacedOptions(options, 'local-network');
20
- localNetwork.testAccounts = true;
20
+ const localNetwork = extractNamespacedOptions(options, 'localNetwork');
21
21
  userLog(`${splash}\n${github}\n\n`);
22
- userLog(`Setting up Aztec local network ${cliVersion}, please stand by...`);
22
+ userLog(`Setting up Aztec local network ${packageVersion ?? 'unknown'}, please stand by...`);
23
23
  const { node, stop } = await createLocalNetwork({
24
24
  l1Mnemonic: localNetwork.l1Mnemonic,
25
25
  l1RpcUrls: options.l1RpcUrls,
@@ -37,6 +37,14 @@ export async function aztecStart(options, userLog, debugLogger) {
37
37
  node,
38
38
  AztecNodeApiSchema
39
39
  ];
40
+ adminServices.node = [
41
+ node,
42
+ AztecNodeAdminApiSchema
43
+ ];
44
+ services.nodeDebug = [
45
+ node,
46
+ AztecNodeDebugApiSchema
47
+ ];
40
48
  } else {
41
49
  // Route --prover-node through startNode
42
50
  if (options.proverNode && !options.node) {
@@ -44,7 +52,14 @@ export async function aztecStart(options, userLog, debugLogger) {
44
52
  }
45
53
  if (options.node) {
46
54
  const { startNode } = await import('./cmds/start_node.js');
47
- ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
55
+ const networkName = getActiveNetworkName(options.network);
56
+ ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
57
+ if (options.nodeDebug && services.node) {
58
+ services.nodeDebug = [
59
+ services.node[0],
60
+ AztecNodeDebugApiSchema
61
+ ];
62
+ }
48
63
  } else if (options.bot) {
49
64
  const { startBot } = await import('./cmds/start_bot.js');
50
65
  await startBot(options, signalHandlers, services, userLog);
@@ -73,6 +88,9 @@ export async function aztecStart(options, userLog, debugLogger) {
73
88
  }
74
89
  installSignalHandlers(debugLogger.info, signalHandlers);
75
90
  const versions = getVersions(config);
91
+ const versioningOpts = {
92
+ packageVersion
93
+ };
76
94
  // Start the main JSON-RPC server
77
95
  if (Object.entries(services).length > 0) {
78
96
  const rpcServer = createNamespacedSafeJsonRpcServer(services, {
@@ -80,7 +98,7 @@ export async function aztecStart(options, userLog, debugLogger) {
80
98
  log: debugLogger,
81
99
  middlewares: [
82
100
  getOtelJsonRpcPropagationMiddleware(),
83
- getVersioningMiddleware(versions)
101
+ getVersioningMiddleware(versions, versioningOpts)
84
102
  ],
85
103
  maxBatchSize: options.rpcMaxBatchSize,
86
104
  maxBodySizeBytes: options.rpcMaxBodySize
@@ -94,7 +112,7 @@ export async function aztecStart(options, userLog, debugLogger) {
94
112
  if (Object.entries(adminServices).length > 0) {
95
113
  const adminMiddlewares = [
96
114
  getOtelJsonRpcPropagationMiddleware(),
97
- getVersioningMiddleware(versions)
115
+ getVersioningMiddleware(versions, versioningOpts)
98
116
  ];
99
117
  // Resolve the admin API key (auto-generated and persisted, or opt-out)
100
118
  const apiKeyResolution = await resolveAdminApiKey({
@@ -14,4 +14,4 @@ export declare const NETWORK_FLAG = "network";
14
14
  export declare const aztecStartOptions: {
15
15
  [key: string]: AztecStartOption[];
16
16
  };
17
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfc3RhcnRfb3B0aW9ucy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaS9henRlY19zdGFydF9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLE9BQU8sRUFDTCxLQUFLLGFBQWEsRUFDbEIsS0FBSyxNQUFNLEVBSVosTUFBTSwwQkFBMEIsQ0FBQztBQWVsQyxNQUFNLFdBQVcsZ0JBQWdCO0lBQy9CLElBQUksRUFBRSxNQUFNLENBQUM7SUFDYixXQUFXLEVBQUUsTUFBTSxDQUFDO0lBQ3BCLFlBQVksRUFBRSxHQUFHLENBQUM7SUFDbEIsWUFBWSxDQUFDLEVBQUUsQ0FBQyxHQUFHLEVBQUUsR0FBRyxLQUFLLE1BQU0sQ0FBQztJQUNwQyxHQUFHLEVBQUUsTUFBTSxHQUFHLFNBQVMsQ0FBQztJQUN4QixRQUFRLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUNwQixRQUFRLENBQUMsRUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEtBQUssR0FBRyxDQUFDO0NBQ2pDO0FBRUQsZUFBTyxNQUFNLFVBQVUsMEZBb0J0QixDQUFDO0FBdUJGLGVBQU8sTUFBTSxnQkFBZ0IsVUFZNUIsQ0FBQztBQUVGLGVBQU8sTUFBTSxZQUFZLFlBQVksQ0FBQztBQUd0QyxlQUFPLE1BQU0saUJBQWlCLEVBQUU7SUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEdBQUcsZ0JBQWdCLEVBQUUsQ0FBQTtDQXVPbEUsQ0FBQyJ9
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfc3RhcnRfb3B0aW9ucy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaS9henRlY19zdGFydF9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLE9BQU8sRUFDTCxLQUFLLGFBQWEsRUFDbEIsS0FBSyxNQUFNLEVBSVosTUFBTSwwQkFBMEIsQ0FBQztBQWVsQyxNQUFNLFdBQVcsZ0JBQWdCO0lBQy9CLElBQUksRUFBRSxNQUFNLENBQUM7SUFDYixXQUFXLEVBQUUsTUFBTSxDQUFDO0lBQ3BCLFlBQVksRUFBRSxHQUFHLENBQUM7SUFDbEIsWUFBWSxDQUFDLEVBQUUsQ0FBQyxHQUFHLEVBQUUsR0FBRyxLQUFLLE1BQU0sQ0FBQztJQUNwQyxHQUFHLEVBQUUsTUFBTSxHQUFHLFNBQVMsQ0FBQztJQUN4QixRQUFRLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUNwQixRQUFRLENBQUMsRUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEtBQUssR0FBRyxDQUFDO0NBQ2pDO0FBRUQsZUFBTyxNQUFNLFVBQVUsMEZBb0J0QixDQUFDO0FBdUJGLGVBQU8sTUFBTSxnQkFBZ0IsVUFZNUIsQ0FBQztBQUVGLGVBQU8sTUFBTSxZQUFZLFlBQVksQ0FBQztBQUd0QyxlQUFPLE1BQU0saUJBQWlCLEVBQUU7SUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEdBQUcsZ0JBQWdCLEVBQUUsQ0FBQTtDQW1QbEUsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"aztec_start_options.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_options.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,MAAM,EAIZ,MAAM,0BAA0B,CAAC;AAelC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;IACpC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;CACjC;AAED,eAAO,MAAM,UAAU,0FAoBtB,CAAC;AAuBF,eAAO,MAAM,gBAAgB,UAY5B,CAAC;AAEF,eAAO,MAAM,YAAY,YAAY,CAAC;AAGtC,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;CAuOlE,CAAC"}
1
+ {"version":3,"file":"aztec_start_options.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_options.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,MAAM,EAIZ,MAAM,0BAA0B,CAAC;AAelC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;IACpC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;CACjC;AAED,eAAO,MAAM,UAAU,0FAoBtB,CAAC;AAuBF,eAAO,MAAM,gBAAgB,UAY5B,CAAC;AAEF,eAAO,MAAM,YAAY,YAAY,CAAC;AAGtC,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;CAmPlE,CAAC"}
@@ -76,8 +76,7 @@ export const aztecStartOptions = {
76
76
  defaultValue: undefined,
77
77
  env: 'NETWORK'
78
78
  },
79
- configToFlag('--auto-update', sharedNodeConfigMappings.autoUpdate),
80
- configToFlag('--auto-update-url', sharedNodeConfigMappings.autoUpdateUrl),
79
+ configToFlag('--enable-version-check', sharedNodeConfigMappings.enableVersionCheck),
81
80
  configToFlag('--sync-mode', sharedNodeConfigMappings.syncMode),
82
81
  configToFlag('--snapshots-urls', sharedNodeConfigMappings.snapshotsUrls),
83
82
  configToFlag('--fisherman-mode', sharedNodeConfigMappings.fishermanMode)
@@ -94,6 +93,12 @@ export const aztecStartOptions = {
94
93
  description: 'Mnemonic for L1 accounts. Will be used ',
95
94
  defaultValue: DefaultMnemonic,
96
95
  env: 'MNEMONIC'
96
+ },
97
+ {
98
+ flag: '--local-network.testAccounts',
99
+ description: 'Deploy test accounts on local network start',
100
+ env: 'TEST_ACCOUNTS',
101
+ ...booleanConfigHelper(true)
97
102
  }
98
103
  ],
99
104
  API: [
@@ -132,6 +137,13 @@ export const aztecStartOptions = {
132
137
  env: 'AZTEC_RESET_ADMIN_API_KEY',
133
138
  parseVal: (val)=>val === 'true' || val === '1'
134
139
  },
140
+ {
141
+ flag: '--node-debug',
142
+ description: 'Expose debug endpoints (e.g. mineBlock) on the main RPC port',
143
+ defaultValue: false,
144
+ env: 'AZTEC_NODE_DEBUG',
145
+ parseVal: (val)=>val === undefined || val === 'true' || val === '1'
146
+ },
135
147
  {
136
148
  flag: '--api-prefix <value>',
137
149
  description: 'Prefix for API routes on any service that is started',
package/dest/cli/cli.js CHANGED
@@ -24,9 +24,9 @@ import { addOptions, printAztecStartHelpText } from './util.js';
24
24
  program.addHelpText('after', `
25
25
  Additional commands:
26
26
 
27
- init [folder] [options] creates a new Aztec Noir project.
28
- new <path> [options] creates a new Aztec Noir project in a new directory.
29
- test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
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.
30
30
  `);
31
31
  }
32
32
  program.command('preload-crs').description('Preload the points data needed for proving and verifying').action(async (options)=>{
@@ -1,4 +1,4 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
2
  import type { Command } from 'commander';
3
3
  export declare function injectCompileCommand(program: Command, log: LogFn): Command;
4
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcGlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL2NvbXBpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBaUZ6Qyx3QkFBZ0Isb0JBQW9CLENBQUMsT0FBTyxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxHQUFHLE9BQU8sQ0FzQjFFIn0=
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcGlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL2NvbXBpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBdUt6Qyx3QkFBZ0Isb0JBQW9CLENBQUMsT0FBTyxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxHQUFHLE9BQU8sQ0FzQjFFIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiFzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAsB1E"}
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;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuKzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAsB1E"}
@@ -1,45 +1,22 @@
1
- import { execFileSync, spawn } from 'child_process';
2
- import { readFile, readdir, writeFile } from 'fs/promises';
1
+ import { findBbBinary } from '@aztec/bb.js';
2
+ import { execFileSync } from 'child_process';
3
+ import { readFile, writeFile } from 'fs/promises';
3
4
  import { join } from 'path';
4
- /** Spawns a command with inherited stdio and rejects on non-zero exit. */ function run(cmd, args) {
5
- return new Promise((resolve, reject)=>{
6
- const child = spawn(cmd, args, {
7
- stdio: 'inherit'
8
- });
9
- child.on('error', reject);
10
- child.on('close', (code)=>{
11
- if (code !== 0) {
12
- reject(new Error(`${cmd} exited with code ${code}`));
13
- } else {
14
- resolve();
15
- }
16
- });
17
- });
18
- }
19
- /** Returns paths to contract artifacts in the target directory.
20
- * Contract artifacts are identified by having a `functions` array in the JSON.
21
- */ async function collectContractArtifacts() {
5
+ import { readArtifactFiles } from './utils/artifacts.js';
6
+ import { needsRecompile } from './utils/needs_recompile.js';
7
+ import { run } from './utils/spawn.js';
8
+ import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
9
+ /** Returns paths to contract artifacts in the target directory. */ async function collectContractArtifacts() {
22
10
  let files;
23
11
  try {
24
- files = await readdir('target');
12
+ files = await readArtifactFiles('target');
25
13
  } catch (err) {
26
- if (err?.code === 'ENOENT') {
14
+ if (err?.message?.includes('does not exist')) {
27
15
  return [];
28
16
  }
29
- throw new Error(`Failed to read target directory: ${err.message}`);
30
- }
31
- const artifacts = [];
32
- for (const file of files){
33
- if (!file.endsWith('.json')) {
34
- continue;
35
- }
36
- const filePath = join('target', file);
37
- const content = JSON.parse(await readFile(filePath, 'utf-8'));
38
- if (Array.isArray(content.functions)) {
39
- artifacts.push(filePath);
40
- }
17
+ throw err;
41
18
  }
42
- return artifacts;
19
+ return files.filter((f)=>Array.isArray(f.content.functions)).map((f)=>f.filePath);
43
20
  }
44
21
  /** Strips the `__aztec_nr_internals__` prefix from function names in contract artifacts. */ async function stripInternalPrefixes(artifactPaths) {
45
22
  for (const path of artifactPaths){
@@ -52,13 +29,109 @@ import { join } from 'path';
52
29
  await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
53
30
  }
54
31
  }
32
+ /** Returns the set of package names that are contract crates in the current workspace. */ async function getContractPackageNames() {
33
+ const contractNames = new Set();
34
+ let rootToml;
35
+ try {
36
+ rootToml = await readFile('Nargo.toml', 'utf-8');
37
+ } catch {
38
+ return contractNames;
39
+ }
40
+ const membersMatch = rootToml.match(/members\s*=\s*\[([^\]]*)\]/);
41
+ if (membersMatch) {
42
+ const members = membersMatch[1].split(',').map((m)=>m.trim().replace(/^"|"$/g, '')).filter((m)=>m.length > 0);
43
+ for (const member of members){
44
+ try {
45
+ const memberToml = await readFile(join(member, 'Nargo.toml'), 'utf-8');
46
+ if (/type\s*=\s*"contract"/.test(memberToml)) {
47
+ const nameMatch = memberToml.match(/name\s*=\s*"([^"]+)"/);
48
+ if (nameMatch) {
49
+ contractNames.add(nameMatch[1]);
50
+ }
51
+ }
52
+ } catch {
53
+ // Member directory might not exist or have no Nargo.toml; skip.
54
+ }
55
+ }
56
+ } else {
57
+ // Single-crate project (no workspace): check if the root Nargo.toml itself is a contract.
58
+ if (/type\s*=\s*"contract"/.test(rootToml)) {
59
+ const nameMatch = rootToml.match(/name\s*=\s*"([^"]+)"/);
60
+ if (nameMatch) {
61
+ contractNames.add(nameMatch[1]);
62
+ }
63
+ }
64
+ }
65
+ return contractNames;
66
+ }
67
+ /** Checks that no tests exist in contract crates and fails with a helpful message if they do. */ async function checkNoTestsInContracts(nargo, log) {
68
+ const contractPackages = await getContractPackageNames();
69
+ if (contractPackages.size === 0) {
70
+ return;
71
+ }
72
+ let output;
73
+ try {
74
+ // We list tests for all the crates in the workspace
75
+ output = execFileSync(nargo, [
76
+ 'test',
77
+ '--list-tests',
78
+ '--silence-warnings'
79
+ ], {
80
+ encoding: 'utf-8',
81
+ stdio: [
82
+ 'pipe',
83
+ 'pipe',
84
+ 'inherit'
85
+ ]
86
+ });
87
+ } catch {
88
+ // If listing tests fails (e.g. test crate has compile errors), skip the check.
89
+ return;
90
+ }
91
+ // The output of the `nargo test --list-tests` command is as follows:
92
+ // ```
93
+ // crate_name_1 test_name_1
94
+ // crate_name_2 test_name_2
95
+ // ...
96
+ // crate_name_n test_name_n
97
+ // ```
98
+ //
99
+ // We parse the individual lines and then we check if any contract crate appeared in the parsed output.
100
+ const lines = output.trim().split('\n').filter((line)=>line.length > 0);
101
+ const testsInContracts = [];
102
+ for (const line of lines){
103
+ const spaceIndex = line.indexOf(' ');
104
+ if (spaceIndex === -1) {
105
+ continue;
106
+ }
107
+ const packageName = line.substring(0, spaceIndex);
108
+ const testName = line.substring(spaceIndex + 1);
109
+ if (contractPackages.has(packageName)) {
110
+ testsInContracts.push({
111
+ packageName,
112
+ testName
113
+ });
114
+ }
115
+ }
116
+ if (testsInContracts.length > 0) {
117
+ const details = testsInContracts.map((t)=>` ${t.packageName}::${t.testName}`).join('\n');
118
+ 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`);
119
+ }
120
+ }
55
121
  /** Compiles Aztec Noir contracts and postprocesses artifacts. */ async function compileAztecContract(nargoArgs, log) {
122
+ await warnIfAztecVersionMismatch(log);
123
+ if (!await needsRecompile()) {
124
+ log('No source changes detected, skipping compilation.');
125
+ return;
126
+ }
56
127
  const nargo = process.env.NARGO ?? 'nargo';
57
- const bb = process.env.BB ?? 'bb';
128
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
58
129
  await run(nargo, [
59
130
  'compile',
60
131
  ...nargoArgs
61
132
  ]);
133
+ // Ensure contract crates contain no tests (tests belong in the test crate).
134
+ await checkNoTestsInContracts(nargo, log);
62
135
  const artifacts = await collectContractArtifacts();
63
136
  if (artifacts.length > 0) {
64
137
  log('Postprocessing contracts...');
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3Byb2ZpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBS3pDLHdCQUFnQixvQkFBb0IsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxLQUFLLEdBQUcsT0FBTyxDQWlCMUUifQ==
@@ -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,CAiB1E"}
@@ -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').description('Display gate counts for all compiled Aztec artifacts in a target directory.').action((targetDir)=>profileGates(targetDir, 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, log: LogFn): Promise<void>;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV9nYXRlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3Byb2ZpbGVfZ2F0ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUErQm5ELG9GQUFvRjtBQUNwRix3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLEtBQUssR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBaUMvRSJ9
@@ -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;AA+BnD,oFAAoF;AACpF,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/E"}
@@ -0,0 +1,58 @@
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, log) {
27
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
28
+ const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
29
+ if (artifacts.length === 0) {
30
+ log('No artifacts found in target directory.');
31
+ return;
32
+ }
33
+ try {
34
+ const results = await asyncPool(MAX_CONCURRENT, artifacts, async (artifact)=>({
35
+ name: artifact.name,
36
+ gateCount: await getGateCount(bb, artifact.filePath)
37
+ }));
38
+ results.sort((a, b)=>a.name.localeCompare(b.name));
39
+ if (results.length === 0) {
40
+ log('No constrained circuits found.');
41
+ return;
42
+ }
43
+ const maxNameLen = Math.max(...results.map((r)=>r.name.length));
44
+ log('');
45
+ log('Gate counts:');
46
+ log('-'.repeat(maxNameLen + 16));
47
+ for (const { name, gateCount } of results){
48
+ log(`${name.padEnd(maxNameLen)} ${gateCount.toLocaleString().padStart(12)}`);
49
+ }
50
+ log('-'.repeat(maxNameLen + 16));
51
+ log(`Total: ${results.length} circuit(s)`);
52
+ } finally{
53
+ await rm(tmpDir, {
54
+ recursive: true,
55
+ force: true
56
+ });
57
+ }
58
+ }
@@ -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 */ }