@aztec-labs/cli 6.0.0-nightly.20260829

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 (227) hide show
  1. package/README.md +23 -0
  2. package/dest/cmds/aztec_node/block_number.d.ts +3 -0
  3. package/dest/cmds/aztec_node/block_number.d.ts.map +1 -0
  4. package/dest/cmds/aztec_node/block_number.js +10 -0
  5. package/dest/cmds/aztec_node/get_block.d.ts +3 -0
  6. package/dest/cmds/aztec_node/get_block.d.ts.map +1 -0
  7. package/dest/cmds/aztec_node/get_block.js +10 -0
  8. package/dest/cmds/aztec_node/get_current_min_fee.d.ts +3 -0
  9. package/dest/cmds/aztec_node/get_current_min_fee.d.ts.map +1 -0
  10. package/dest/cmds/aztec_node/get_current_min_fee.js +7 -0
  11. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +5 -0
  12. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts.map +1 -0
  13. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.js +12 -0
  14. package/dest/cmds/aztec_node/get_logs.d.ts +33 -0
  15. package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
  16. package/dest/cmds/aztec_node/get_logs.js +61 -0
  17. package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
  18. package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
  19. package/dest/cmds/aztec_node/get_node_info.js +58 -0
  20. package/dest/cmds/aztec_node/index.d.ts +4 -0
  21. package/dest/cmds/aztec_node/index.d.ts.map +1 -0
  22. package/dest/cmds/aztec_node/index.js +38 -0
  23. package/dest/cmds/infrastructure/index.d.ts +4 -0
  24. package/dest/cmds/infrastructure/index.d.ts.map +1 -0
  25. package/dest/cmds/infrastructure/index.js +22 -0
  26. package/dest/cmds/infrastructure/sequencers.d.ts +12 -0
  27. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -0
  28. package/dest/cmds/infrastructure/sequencers.js +113 -0
  29. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +3 -0
  30. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -0
  31. package/dest/cmds/infrastructure/setup_l2_contract.js +35 -0
  32. package/dest/cmds/l1/advance_epoch.d.ts +3 -0
  33. package/dest/cmds/l1/advance_epoch.d.ts.map +1 -0
  34. package/dest/cmds/l1/advance_epoch.js +12 -0
  35. package/dest/cmds/l1/assume_proven_through.d.ts +4 -0
  36. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -0
  37. package/dest/cmds/l1/assume_proven_through.js +12 -0
  38. package/dest/cmds/l1/compute_genesis_values.d.ts +4 -0
  39. package/dest/cmds/l1/compute_genesis_values.d.ts.map +1 -0
  40. package/dest/cmds/l1/compute_genesis_values.js +17 -0
  41. package/dest/cmds/l1/create_l1_account.d.ts +3 -0
  42. package/dest/cmds/l1/create_l1_account.d.ts.map +1 -0
  43. package/dest/cmds/l1/create_l1_account.js +15 -0
  44. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +4 -0
  45. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -0
  46. package/dest/cmds/l1/deploy_l1_contracts_cmd.js +80 -0
  47. package/dest/cmds/l1/deploy_new_rollup.d.ts +5 -0
  48. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -0
  49. package/dest/cmds/l1/deploy_new_rollup.js +26 -0
  50. package/dest/cmds/l1/get_l1_addresses.d.ts +4 -0
  51. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -0
  52. package/dest/cmds/l1/get_l1_addresses.js +21 -0
  53. package/dest/cmds/l1/get_l1_balance.d.ts +4 -0
  54. package/dest/cmds/l1/get_l1_balance.d.ts.map +1 -0
  55. package/dest/cmds/l1/get_l1_balance.js +35 -0
  56. package/dest/cmds/l1/governance_utils.d.ts +50 -0
  57. package/dest/cmds/l1/governance_utils.d.ts.map +1 -0
  58. package/dest/cmds/l1/governance_utils.js +87 -0
  59. package/dest/cmds/l1/index.d.ts +4 -0
  60. package/dest/cmds/l1/index.d.ts.map +1 -0
  61. package/dest/cmds/l1/index.js +201 -0
  62. package/dest/cmds/l1/prover_stats.d.ts +14 -0
  63. package/dest/cmds/l1/prover_stats.d.ts.map +1 -0
  64. package/dest/cmds/l1/prover_stats.js +147 -0
  65. package/dest/cmds/l1/trigger_seed_snapshot.d.ts +6 -0
  66. package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -0
  67. package/dest/cmds/l1/trigger_seed_snapshot.js +20 -0
  68. package/dest/cmds/l1/update_l1_validators.d.ts +45 -0
  69. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -0
  70. package/dest/cmds/l1/update_l1_validators.js +280 -0
  71. package/dest/cmds/misc/generate_bootnode_enr.d.ts +3 -0
  72. package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -0
  73. package/dest/cmds/misc/generate_bootnode_enr.js +5 -0
  74. package/dest/cmds/misc/generate_p2p_private_key.d.ts +3 -0
  75. package/dest/cmds/misc/generate_p2p_private_key.d.ts.map +1 -0
  76. package/dest/cmds/misc/generate_p2p_private_key.js +7 -0
  77. package/dest/cmds/misc/generate_secret_key.d.ts +5 -0
  78. package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -0
  79. package/dest/cmds/misc/generate_secret_key.js +6 -0
  80. package/dest/cmds/misc/index.d.ts +4 -0
  81. package/dest/cmds/misc/index.d.ts.map +1 -0
  82. package/dest/cmds/misc/index.js +32 -0
  83. package/dest/cmds/misc/update/common.d.ts +17 -0
  84. package/dest/cmds/misc/update/common.d.ts.map +1 -0
  85. package/dest/cmds/misc/update/common.js +3 -0
  86. package/dest/cmds/misc/update/github.d.ts +3 -0
  87. package/dest/cmds/misc/update/github.d.ts.map +1 -0
  88. package/dest/cmds/misc/update/github.js +2 -0
  89. package/dest/cmds/misc/update/noir.d.ts +10 -0
  90. package/dest/cmds/misc/update/noir.d.ts.map +1 -0
  91. package/dest/cmds/misc/update/noir.js +45 -0
  92. package/dest/cmds/misc/update/npm.d.ts +34 -0
  93. package/dest/cmds/misc/update/npm.d.ts.map +1 -0
  94. package/dest/cmds/misc/update/npm.js +123 -0
  95. package/dest/cmds/misc/update/utils.d.ts +14 -0
  96. package/dest/cmds/misc/update/utils.d.ts.map +1 -0
  97. package/dest/cmds/misc/update/utils.js +38 -0
  98. package/dest/cmds/misc/update.d.ts +3 -0
  99. package/dest/cmds/misc/update.d.ts.map +1 -0
  100. package/dest/cmds/misc/update.js +51 -0
  101. package/dest/cmds/validator_keys/add.d.ts +5 -0
  102. package/dest/cmds/validator_keys/add.d.ts.map +1 -0
  103. package/dest/cmds/validator_keys/add.js +83 -0
  104. package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts +2 -0
  105. package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts.map +1 -0
  106. package/dest/cmds/validator_keys/eth_json_v3_worker.js +27 -0
  107. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
  108. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
  109. package/dest/cmds/validator_keys/generate_bls_keypair.js +27 -0
  110. package/dest/cmds/validator_keys/index.d.ts +4 -0
  111. package/dest/cmds/validator_keys/index.d.ts.map +1 -0
  112. package/dest/cmds/validator_keys/index.js +33 -0
  113. package/dest/cmds/validator_keys/new.d.ts +35 -0
  114. package/dest/cmds/validator_keys/new.d.ts.map +1 -0
  115. package/dest/cmds/validator_keys/new.js +220 -0
  116. package/dest/cmds/validator_keys/set_funding_account.d.ts +14 -0
  117. package/dest/cmds/validator_keys/set_funding_account.d.ts.map +1 -0
  118. package/dest/cmds/validator_keys/set_funding_account.js +37 -0
  119. package/dest/cmds/validator_keys/shared.d.ts +81 -0
  120. package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
  121. package/dest/cmds/validator_keys/shared.js +352 -0
  122. package/dest/cmds/validator_keys/staker.d.ts +38 -0
  123. package/dest/cmds/validator_keys/staker.d.ts.map +1 -0
  124. package/dest/cmds/validator_keys/staker.js +210 -0
  125. package/dest/cmds/validator_keys/utils.d.ts +35 -0
  126. package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
  127. package/dest/cmds/validator_keys/utils.js +86 -0
  128. package/dest/config/cached_fetch.d.ts +27 -0
  129. package/dest/config/cached_fetch.d.ts.map +1 -0
  130. package/dest/config/cached_fetch.js +132 -0
  131. package/dest/config/chain_l2_config.d.ts +19 -0
  132. package/dest/config/chain_l2_config.d.ts.map +1 -0
  133. package/dest/config/chain_l2_config.js +60 -0
  134. package/dest/config/enrich_env.d.ts +4 -0
  135. package/dest/config/enrich_env.d.ts.map +1 -0
  136. package/dest/config/enrich_env.js +12 -0
  137. package/dest/config/generated/networks.d.ts +236 -0
  138. package/dest/config/generated/networks.d.ts.map +1 -0
  139. package/dest/config/generated/networks.js +237 -0
  140. package/dest/config/get_l1_config.d.ts +9 -0
  141. package/dest/config/get_l1_config.d.ts.map +1 -0
  142. package/dest/config/get_l1_config.js +24 -0
  143. package/dest/config/index.d.ts +5 -0
  144. package/dest/config/index.d.ts.map +1 -0
  145. package/dest/config/index.js +4 -0
  146. package/dest/config/network_config.d.ts +22 -0
  147. package/dest/config/network_config.d.ts.map +1 -0
  148. package/dest/config/network_config.js +119 -0
  149. package/dest/utils/aztec.d.ts +56 -0
  150. package/dest/utils/aztec.d.ts.map +1 -0
  151. package/dest/utils/aztec.js +161 -0
  152. package/dest/utils/commands.d.ts +161 -0
  153. package/dest/utils/commands.d.ts.map +1 -0
  154. package/dest/utils/commands.js +341 -0
  155. package/dest/utils/encoding.d.ts +15 -0
  156. package/dest/utils/encoding.d.ts.map +1 -0
  157. package/dest/utils/encoding.js +103 -0
  158. package/dest/utils/github.d.ts +3 -0
  159. package/dest/utils/github.d.ts.map +1 -0
  160. package/dest/utils/github.js +2 -0
  161. package/dest/utils/index.d.ts +6 -0
  162. package/dest/utils/index.d.ts.map +1 -0
  163. package/dest/utils/index.js +5 -0
  164. package/dest/utils/inspect.d.ts +11 -0
  165. package/dest/utils/inspect.d.ts.map +1 -0
  166. package/dest/utils/inspect.js +90 -0
  167. package/dest/utils/setup_contracts.d.ts +3 -0
  168. package/dest/utils/setup_contracts.d.ts.map +1 -0
  169. package/dest/utils/setup_contracts.js +16 -0
  170. package/package.json +141 -0
  171. package/public_include_metric_prefixes.json +1 -0
  172. package/src/cmds/aztec_node/block_number.ts +9 -0
  173. package/src/cmds/aztec_node/get_block.ts +11 -0
  174. package/src/cmds/aztec_node/get_current_min_fee.ts +9 -0
  175. package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
  176. package/src/cmds/aztec_node/get_logs.ts +100 -0
  177. package/src/cmds/aztec_node/get_node_info.ts +61 -0
  178. package/src/cmds/aztec_node/index.ts +91 -0
  179. package/src/cmds/infrastructure/index.ts +51 -0
  180. package/src/cmds/infrastructure/sequencers.ts +122 -0
  181. package/src/cmds/infrastructure/setup_l2_contract.ts +40 -0
  182. package/src/cmds/l1/advance_epoch.ts +14 -0
  183. package/src/cmds/l1/assume_proven_through.ts +20 -0
  184. package/src/cmds/l1/compute_genesis_values.ts +29 -0
  185. package/src/cmds/l1/create_l1_account.ts +16 -0
  186. package/src/cmds/l1/deploy_l1_contracts_cmd.ts +105 -0
  187. package/src/cmds/l1/deploy_new_rollup.ts +65 -0
  188. package/src/cmds/l1/get_l1_addresses.ts +31 -0
  189. package/src/cmds/l1/get_l1_balance.ts +44 -0
  190. package/src/cmds/l1/governance_utils.ts +183 -0
  191. package/src/cmds/l1/index.ts +499 -0
  192. package/src/cmds/l1/prover_stats.ts +213 -0
  193. package/src/cmds/l1/trigger_seed_snapshot.ts +32 -0
  194. package/src/cmds/l1/update_l1_validators.ts +358 -0
  195. package/src/cmds/misc/generate_bootnode_enr.ts +13 -0
  196. package/src/cmds/misc/generate_p2p_private_key.ts +9 -0
  197. package/src/cmds/misc/generate_secret_key.ts +5 -0
  198. package/src/cmds/misc/index.ts +67 -0
  199. package/src/cmds/misc/update/common.ts +16 -0
  200. package/src/cmds/misc/update/github.ts +2 -0
  201. package/src/cmds/misc/update/noir.ts +56 -0
  202. package/src/cmds/misc/update/npm.ts +148 -0
  203. package/src/cmds/misc/update/utils.ts +49 -0
  204. package/src/cmds/misc/update.ts +71 -0
  205. package/src/cmds/validator_keys/add.ts +122 -0
  206. package/src/cmds/validator_keys/eth_json_v3_worker.ts +30 -0
  207. package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
  208. package/src/cmds/validator_keys/index.ts +181 -0
  209. package/src/cmds/validator_keys/new.ts +326 -0
  210. package/src/cmds/validator_keys/set_funding_account.ts +54 -0
  211. package/src/cmds/validator_keys/shared.ts +414 -0
  212. package/src/cmds/validator_keys/staker.ts +300 -0
  213. package/src/cmds/validator_keys/utils.ts +124 -0
  214. package/src/config/cached_fetch.ts +154 -0
  215. package/src/config/chain_l2_config.ts +71 -0
  216. package/src/config/enrich_env.ts +15 -0
  217. package/src/config/generated/networks.ts +241 -0
  218. package/src/config/get_l1_config.ts +31 -0
  219. package/src/config/index.ts +4 -0
  220. package/src/config/network_config.ts +150 -0
  221. package/src/utils/aztec.ts +203 -0
  222. package/src/utils/commands.ts +434 -0
  223. package/src/utils/encoding.ts +117 -0
  224. package/src/utils/github.ts +2 -0
  225. package/src/utils/index.ts +5 -0
  226. package/src/utils/inspect.ts +111 -0
  227. package/src/utils/setup_contracts.ts +19 -0
@@ -0,0 +1,67 @@
1
+ import type { LogFn } from '@aztec-labs/foundation/log';
2
+ import type { Command } from 'commander';
3
+
4
+ import { l1ChainIdOption, prettyPrintJSON } from '../../utils/commands.js';
5
+
6
+ export function injectCommands(program: Command, log: LogFn) {
7
+ program
8
+ .command('generate-keys')
9
+ .summary('Generates encryption and signing private keys.')
10
+ .description('Generates and encryption and signing private key pair.')
11
+ .option('--json', 'Output the keys in JSON format')
12
+ .action(async ({ json }) => {
13
+ const { generateSecretKey } = await import('./generate_secret_key.js');
14
+ const { secretKey } = generateSecretKey();
15
+ if (json) {
16
+ log(prettyPrintJSON({ secretKey: secretKey.toString() }));
17
+ } else {
18
+ log(`Secret Key: ${secretKey}`);
19
+ }
20
+ });
21
+
22
+ program
23
+ .command('generate-p2p-private-key')
24
+ .summary('Generates a LibP2P peer private key.')
25
+ .description('Generates a private key that can be used for running a node on a LibP2P network.')
26
+ .action(async () => {
27
+ const { generateP2PPrivateKey } = await import('./generate_p2p_private_key.js');
28
+ await generateP2PPrivateKey(log);
29
+ });
30
+
31
+ program
32
+ .command('generate-bootnode-enr')
33
+ .summary('Generates the encoded ENR record for a bootnode.')
34
+ .description('Generates the encoded ENR record for a bootnode.')
35
+ .argument('<privateKey>', 'The peer id private key of the bootnode')
36
+ .argument('<p2pIp>', 'The bootnode P2P IP address')
37
+ .argument('<p2pPort>', 'The bootnode P2P port')
38
+ .addOption(l1ChainIdOption)
39
+ .action(async (privateKey: string, p2pIp: string, p2pPort: number, options) => {
40
+ const { generateEncodedBootnodeENR } = await import('./generate_bootnode_enr.js');
41
+ await generateEncodedBootnodeENR(privateKey, p2pIp, p2pPort, options.l1ChainId, log);
42
+ });
43
+
44
+ program
45
+ .command('decode-enr')
46
+ .summary('Decodes an ENR record')
47
+ .description('Decodes and ENR record')
48
+ .argument('<enr>', 'The encoded ENR string')
49
+ .action(async (enr: string) => {
50
+ const { printENR } = await import('@aztec-labs/p2p/enr');
51
+ await printENR(enr, log);
52
+ });
53
+
54
+ program
55
+ .command('update')
56
+ .description('Updates Nodejs and Noir dependencies')
57
+ .argument('[projectPath]', 'Path to the project directory', process.cwd())
58
+ .option('--contract [paths...]', 'Paths to contracts to update dependencies', [])
59
+ .option('--aztec-version <semver>', 'The version to update Aztec packages to. Defaults to latest', 'latest')
60
+ .action(async (projectPath: string, options) => {
61
+ const { updateProject } = await import('./update.js');
62
+ const { contract, aztecVersion } = options;
63
+ await updateProject(projectPath, contract, aztecVersion, log);
64
+ });
65
+
66
+ return program;
67
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Tracks changes to dependencies
3
+ */
4
+ export type DependencyChanges = {
5
+ /** Which file was changed */
6
+ file: string;
7
+ /** changes done to the file */
8
+ dependencies: Array<{
9
+ /** Name of the dependency being changed */
10
+ name: string;
11
+ /** Previous version of the dependency */
12
+ from: string;
13
+ /** New version of the dependency (after the update) */
14
+ to: string;
15
+ }>;
16
+ };
@@ -0,0 +1,2 @@
1
+ export const GITHUB_OWNER = 'AztecProtocol';
2
+ export const GITHUB_REPO = 'aztec-packages';
@@ -0,0 +1,56 @@
1
+ import type { LogFn } from '@aztec-labs/foundation/log';
2
+ import { parseNoirPackageConfig } from '@aztec-labs/foundation/noir';
3
+ import TOML from '@iarna/toml';
4
+ import { readFile } from 'fs/promises';
5
+ import { join, relative, resolve } from 'path';
6
+
7
+ import type { DependencyChanges } from './common.js';
8
+ import { atomicUpdateFile, prettyPrintNargoToml } from './utils.js';
9
+
10
+ /**
11
+ * Updates Aztec.nr dependencies
12
+ * @param contractPath - Path to the contract to be updated
13
+ * @param tag - The tag to update to
14
+ * @param log - Logging function
15
+ */
16
+ export async function updateAztecNr(contractPath: string, tag: string, log: LogFn): Promise<DependencyChanges> {
17
+ const configFilepath = resolve(join(contractPath, 'Nargo.toml'));
18
+ const packageConfig = parseNoirPackageConfig(TOML.parse(await readFile(configFilepath, 'utf-8')));
19
+ const changes: DependencyChanges = {
20
+ dependencies: [],
21
+ file: configFilepath,
22
+ };
23
+
24
+ log(`Updating Aztec.nr libraries to ${tag} in ${relative(process.cwd(), changes.file)}`);
25
+ for (const dep of Object.values(packageConfig.dependencies)) {
26
+ if (!('git' in dep)) {
27
+ continue;
28
+ }
29
+
30
+ // remove trailing slash
31
+ const gitUrl = dep.git.toLowerCase().replace(/\/$/, '');
32
+ if (gitUrl !== 'https://github.com/aztecprotocol/aztec-packages') {
33
+ continue;
34
+ }
35
+
36
+ if (dep.tag !== tag) {
37
+ // show the Aztec.nr package name rather than the lib name
38
+ const dirParts = dep.directory?.split('/') ?? [];
39
+ changes.dependencies.push({
40
+ name: dirParts.slice(-2).join('/'),
41
+ from: dep.tag,
42
+ to: tag,
43
+ });
44
+
45
+ dep.tag = tag;
46
+ dep.directory = dep.directory?.replace('yarn-project/', 'noir-projects/');
47
+ }
48
+ }
49
+
50
+ if (changes.dependencies.length > 0) {
51
+ const contents = prettyPrintNargoToml(packageConfig);
52
+ await atomicUpdateFile(configFilepath, contents);
53
+ }
54
+
55
+ return changes;
56
+ }
@@ -0,0 +1,148 @@
1
+ import type { LogFn } from '@aztec-labs/foundation/log';
2
+ import { spawnSync } from 'child_process';
3
+ import { existsSync } from 'fs';
4
+ import { readFile } from 'fs/promises';
5
+ import { join, relative, resolve } from 'path';
6
+ import { type SemVer, parse } from 'semver';
7
+
8
+ import type { DependencyChanges } from './common.js';
9
+ import { atomicUpdateFile } from './utils.js';
10
+
11
+ const deprecatedNpmPackages = new Set<string>(['@aztec-labs/cli', '@aztec/aztec-local-network']);
12
+ const npmDeprecationMessage = `
13
+ The following packages have been deprecated and will no longer be updated on the npm registry:
14
+ ${Array.from(deprecatedNpmPackages)
15
+ .map(pkg => ` - ${pkg}`)
16
+ .join('\n')}
17
+ Remove them from package.json
18
+ `;
19
+
20
+ /**
21
+ * Looks up a package.json file and returns its contents
22
+ * @param projectPath - Path to Nodejs project
23
+ * @returns The parsed package.json
24
+ */
25
+ export async function readPackageJson(projectPath: string): Promise<{
26
+ /** dependencies */
27
+ dependencies?: Record<string, string>;
28
+ /** devDependencies */
29
+ devDependencies?: Record<string, string>;
30
+ }> {
31
+ const configFilepath = resolve(join(projectPath, 'package.json'));
32
+ const pkg = JSON.parse(await readFile(configFilepath, 'utf-8'));
33
+
34
+ return pkg;
35
+ }
36
+
37
+ /**
38
+ * Queries the npm registry for the latest version of a package
39
+ * @param packageName - The package to query
40
+ * @param distTag - The distribution tag
41
+ * @returns The latest version of the package on that distribution tag
42
+ */
43
+ export async function getNewestVersion(packageName: string, distTag = 'latest'): Promise<SemVer> {
44
+ const url = new URL(packageName, 'https://registry.npmjs.org/');
45
+ const response = await fetch(url);
46
+ if (!response.ok) {
47
+ throw new Error(`Failed to fetch ${url}`);
48
+ }
49
+
50
+ const body = await response.json();
51
+ const latestVersion = parse(body['dist-tags'][distTag]);
52
+ if (!latestVersion) {
53
+ throw new Error(`Failed to get latest version from registry`);
54
+ }
55
+
56
+ return latestVersion;
57
+ }
58
+
59
+ /**
60
+ * Updates a project's \@aztec-labs/* dependencies to the specific version
61
+ * @param projectPath - Path to Nodejs project
62
+ * @param aztecVersion - The version to update to
63
+ * @returns True if the project was updated
64
+ */
65
+ export async function updateAztecDeps(
66
+ projectPath: string,
67
+ aztecVersion: SemVer,
68
+ log: LogFn,
69
+ ): Promise<DependencyChanges> {
70
+ const pkg = await readPackageJson(projectPath);
71
+ const changes: DependencyChanges = {
72
+ file: resolve(join(projectPath, 'package.json')),
73
+ dependencies: [],
74
+ };
75
+
76
+ log(`Updating @aztec-labs packages to ${aztecVersion} in ${relative(process.cwd(), changes.file)}`);
77
+ const version = aztecVersion.version;
78
+
79
+ let detectedDeprecatedPackages = false;
80
+
81
+ for (const depType of ['dependencies', 'devDependencies'] as const) {
82
+ const dependencies = pkg[depType];
83
+ if (!dependencies) {
84
+ continue;
85
+ }
86
+
87
+ for (const name of Object.keys(dependencies)) {
88
+ if (!name.startsWith('@aztec-labs/')) {
89
+ continue;
90
+ }
91
+
92
+ if (deprecatedNpmPackages.has(name)) {
93
+ detectedDeprecatedPackages = true;
94
+ continue;
95
+ }
96
+
97
+ if (dependencies[name] !== version) {
98
+ changes.dependencies.push({
99
+ name,
100
+ from: dependencies[name],
101
+ to: version,
102
+ });
103
+
104
+ dependencies[name] = version;
105
+ }
106
+ }
107
+ }
108
+
109
+ if (detectedDeprecatedPackages) {
110
+ log(npmDeprecationMessage);
111
+ }
112
+
113
+ if (changes.dependencies.length > 0) {
114
+ const contents = JSON.stringify(pkg, null, 2) + '\n';
115
+ await atomicUpdateFile(resolve(join(projectPath, 'package.json')), contents);
116
+ }
117
+
118
+ return changes;
119
+ }
120
+
121
+ /**
122
+ * Updates a project's yarn.lock or package-lock.json
123
+ * @param projectPath - Path to Nodejs project
124
+ */
125
+ export function updateLockfile(projectPath: string, log: LogFn): void {
126
+ const isNpm = existsSync(resolve(join(projectPath, 'package-lock.json')));
127
+ const isYarn = existsSync(resolve(join(projectPath, 'yarn.lock')));
128
+ const isPnpm = existsSync(resolve(join(projectPath, 'pnpm-lock.yaml')));
129
+
130
+ if (isPnpm) {
131
+ spawnSync('pnpm', ['install'], {
132
+ cwd: projectPath,
133
+ stdio: 'inherit',
134
+ });
135
+ } else if (isYarn) {
136
+ spawnSync('yarn', ['install'], {
137
+ cwd: projectPath,
138
+ stdio: 'inherit',
139
+ });
140
+ } else if (isNpm) {
141
+ spawnSync('npm', ['install'], {
142
+ cwd: projectPath,
143
+ stdio: 'inherit',
144
+ });
145
+ } else {
146
+ log(`No lockfile found in ${projectPath}. Skipping lockfile update...`);
147
+ }
148
+ }
@@ -0,0 +1,49 @@
1
+ import type { NoirPackageConfig } from '@aztec-labs/foundation/noir';
2
+ import TOML from '@iarna/toml';
3
+ import { CommanderError } from 'commander';
4
+ import { rename, writeFile } from 'fs/promises';
5
+
6
+ /**
7
+ * Updates a file in place atomically.
8
+ * @param filePath - Path to file
9
+ * @param contents - New contents to write
10
+ */
11
+ export async function atomicUpdateFile(filePath: string, contents: string) {
12
+ const tmpFilepath = filePath + '.tmp';
13
+ try {
14
+ await writeFile(tmpFilepath, contents, {
15
+ // let's crash if the tmp file already exists
16
+ flag: 'wx',
17
+ });
18
+ await rename(tmpFilepath, filePath);
19
+ } catch (e) {
20
+ if (e instanceof Error && 'code' in e && e.code === 'EEXIST') {
21
+ const commanderError = new CommanderError(
22
+ 1,
23
+ e.code,
24
+ `Temporary file already exists: ${tmpFilepath}. Delete this file and try again.`,
25
+ );
26
+ commanderError.nestedError = e.message;
27
+ throw commanderError;
28
+ } else {
29
+ throw e;
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Pretty prints Nargo.toml contents to a string
36
+ * @param config - Nargo.toml contents
37
+ * @returns The Nargo.toml contents as a string
38
+ */
39
+ export function prettyPrintNargoToml(config: NoirPackageConfig): string {
40
+ const withoutDependencies = Object.fromEntries(Object.entries(config).filter(([key]) => key !== 'dependencies'));
41
+
42
+ const partialToml = TOML.stringify(withoutDependencies);
43
+ const dependenciesToml = Object.entries(config.dependencies).map(([name, dep]) => {
44
+ const depToml = TOML.stringify.value(dep);
45
+ return `${name} = ${depToml}`;
46
+ });
47
+
48
+ return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n';
49
+ }
@@ -0,0 +1,71 @@
1
+ import type { LogFn } from '@aztec-labs/foundation/log';
2
+ import { relative, resolve } from 'path';
3
+ import { parse } from 'semver';
4
+
5
+ import type { DependencyChanges } from './update/common.js';
6
+ import { updateAztecNr } from './update/noir.js';
7
+ import { getNewestVersion, updateAztecDeps, updateLockfile } from './update/npm.js';
8
+
9
+ const AZTECJS_PACKAGE = '@aztec-labs/aztec.js';
10
+ const UPDATE_DOCS_URL = 'https://docs.aztec.network/developers/guides/local_env/versions-updating';
11
+
12
+ export async function updateProject(
13
+ projectPath: string,
14
+ contracts: string[],
15
+ aztecVersion: string,
16
+ log: LogFn,
17
+ ): Promise<void> {
18
+ const targetAztecVersion =
19
+ aztecVersion === 'latest' ? await getNewestVersion(AZTECJS_PACKAGE, 'latest') : parse(aztecVersion);
20
+
21
+ if (!targetAztecVersion) {
22
+ throw new Error(`Invalid aztec version ${aztecVersion}`);
23
+ }
24
+
25
+ const projectDependencyChanges: DependencyChanges[] = [];
26
+ try {
27
+ const npmChanges = await updateAztecDeps(resolve(process.cwd(), projectPath), targetAztecVersion, log);
28
+ if (npmChanges.dependencies.length > 0) {
29
+ updateLockfile(projectPath, log);
30
+ }
31
+
32
+ projectDependencyChanges.push(npmChanges);
33
+ } catch (err) {
34
+ if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
35
+ log(`No package.json found in ${projectPath}. Skipping npm update...`);
36
+ } else {
37
+ throw err;
38
+ }
39
+ }
40
+
41
+ for (const contract of contracts) {
42
+ try {
43
+ projectDependencyChanges.push(
44
+ await updateAztecNr(resolve(process.cwd(), projectPath, contract), `v${targetAztecVersion.version}`, log),
45
+ );
46
+ } catch (err) {
47
+ if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
48
+ log(`No Nargo.toml found in ${relative(process.cwd(), contract)}. Skipping...`);
49
+ } else {
50
+ throw err;
51
+ }
52
+ }
53
+ }
54
+
55
+ log(`To update Docker containers follow instructions at ${UPDATE_DOCS_URL}`);
56
+
57
+ projectDependencyChanges.forEach(changes => {
58
+ printChanges(changes, log);
59
+ });
60
+ }
61
+
62
+ function printChanges(changes: DependencyChanges, log: LogFn): void {
63
+ log(`\nIn ${relative(process.cwd(), changes.file)}:`);
64
+ if (changes.dependencies.length === 0) {
65
+ log(' No changes');
66
+ } else {
67
+ changes.dependencies.forEach(({ name, from, to }) => {
68
+ log(` Updated ${name} from ${from} to ${to}`);
69
+ });
70
+ }
71
+ }
@@ -0,0 +1,122 @@
1
+ import type { EthAddress } from '@aztec-labs/foundation/eth-address';
2
+ import type { LogFn } from '@aztec-labs/foundation/log';
3
+ import { loadKeystoreFile } from '@aztec-labs/node-keystore/loader';
4
+ import type { KeyStore } from '@aztec-labs/node-keystore/types';
5
+ import { wordlist } from '@scure/bip39/wordlists/english.js';
6
+ import { dirname, isAbsolute, join } from 'path';
7
+ import { generateMnemonic } from 'viem/accounts';
8
+
9
+ import type { NewValidatorKeystoreOptions } from './new.js';
10
+ import {
11
+ buildValidatorEntries,
12
+ logValidatorSummaries,
13
+ maybePrintJson,
14
+ writeBlsBn254ToFile,
15
+ writeEthJsonV3ToFile,
16
+ writeKeystoreFile,
17
+ } from './shared.js';
18
+ import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions } from './utils.js';
19
+
20
+ export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
21
+
22
+ export async function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn) {
23
+ // validate bls-path inputs before proceeding with key generation
24
+ validateBlsPathOptions(options);
25
+ // validate publisher options
26
+ validatePublisherOptions(options);
27
+ // validate remote signer options
28
+ validateRemoteSignerOptions(options);
29
+
30
+ const {
31
+ dataDir,
32
+ file,
33
+ count,
34
+ publisherCount = 0,
35
+ publishers,
36
+ mnemonic,
37
+ accountIndex = 0,
38
+ addressIndex,
39
+ ikm,
40
+ blsPath,
41
+ json,
42
+ feeRecipient: feeRecipientOpt,
43
+ coinbase: coinbaseOpt,
44
+ remoteSigner: remoteSignerOpt,
45
+ password,
46
+ encryptedKeystoreDir,
47
+ } = options;
48
+
49
+ const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
50
+ const baseAddressIndex = addressIndex ?? 0;
51
+
52
+ const keystore: KeyStore = loadKeystoreFile(existing);
53
+
54
+ if (!keystore.validators || !Array.isArray(keystore.validators)) {
55
+ throw new Error('Invalid keystore: missing validators array');
56
+ }
57
+
58
+ const first = keystore.validators[0] ?? {};
59
+ const feeRecipient = feeRecipientOpt ?? first.feeRecipient;
60
+ if (!feeRecipient) {
61
+ throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
62
+ }
63
+ const coinbase = (coinbaseOpt as EthAddress | undefined) ?? (first.coinbase as EthAddress | undefined);
64
+ const derivedRemoteSigner = (first.attester as any)?.remoteSignerUrl || (first.attester as any)?.eth?.remoteSignerUrl;
65
+ const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
66
+
67
+ // Ensure we always have a mnemonic for key derivation if none was provided
68
+ const mnemonicToUse = mnemonic ?? generateMnemonic(wordlist);
69
+
70
+ // If user explicitly provided --address-index, use it as-is. Otherwise, append after existing validators.
71
+ const effectiveBaseAddressIndex =
72
+ addressIndex === undefined ? baseAddressIndex + keystore.validators.length : baseAddressIndex;
73
+
74
+ const { validators, summaries } = await buildValidatorEntries({
75
+ validatorCount,
76
+ publisherCount,
77
+ publishers,
78
+ accountIndex,
79
+ baseAddressIndex: effectiveBaseAddressIndex,
80
+ mnemonic: mnemonicToUse,
81
+ ikm,
82
+ blsPath,
83
+ feeRecipient,
84
+ coinbase,
85
+ remoteSigner,
86
+ });
87
+
88
+ keystore.validators.push(...validators);
89
+
90
+ // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
91
+ if (password !== undefined) {
92
+ let targetDir: string;
93
+ if (encryptedKeystoreDir && encryptedKeystoreDir.length > 0) {
94
+ targetDir = encryptedKeystoreDir;
95
+ } else if (dataDir && dataDir.length > 0) {
96
+ targetDir = dataDir;
97
+ } else {
98
+ targetDir = dirname(existing);
99
+ }
100
+ await writeEthJsonV3ToFile(keystore.validators, { outDir: targetDir, password });
101
+ await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password, blsPath });
102
+ }
103
+
104
+ let outputPath = existing;
105
+ if (file && file.length > 0) {
106
+ if (isAbsolute(file)) {
107
+ outputPath = file;
108
+ } else if (dataDir && dataDir.length > 0) {
109
+ outputPath = join(dataDir, file);
110
+ } else {
111
+ outputPath = join(dirname(existing), file);
112
+ }
113
+ }
114
+
115
+ await writeKeystoreFile(outputPath, keystore);
116
+
117
+ if (!json) {
118
+ log(`Updated keystore ${outputPath} with ${validators.length} new validator(s)`);
119
+ logValidatorSummaries(log, summaries);
120
+ }
121
+ maybePrintJson(log, !!json, keystore as unknown as Record<string, any>);
122
+ }
@@ -0,0 +1,30 @@
1
+ import { Wallet } from '@ethersproject/wallet';
2
+ import { parentPort, workerData } from 'worker_threads';
3
+
4
+ type EthJsonV3WorkerData = {
5
+ privateKeyHex: string;
6
+ password: string;
7
+ };
8
+
9
+ type SerializedError = {
10
+ message: string;
11
+ name?: string;
12
+ stack?: string;
13
+ };
14
+
15
+ function serializeError(error: unknown): SerializedError {
16
+ if (error instanceof Error) {
17
+ return { message: error.message, name: error.name, stack: error.stack };
18
+ }
19
+ return { message: String(error) };
20
+ }
21
+
22
+ void (async () => {
23
+ try {
24
+ const { privateKeyHex, password } = workerData as EthJsonV3WorkerData;
25
+ const json = await new Wallet(privateKeyHex).encrypt(password);
26
+ parentPort?.postMessage({ json });
27
+ } catch (error) {
28
+ parentPort?.postMessage({ error: serializeError(error) });
29
+ }
30
+ })();
@@ -0,0 +1,33 @@
1
+ import { deriveBlsPrivateKey } from '@aztec-labs/foundation/crypto/bls';
2
+ import type { LogFn } from '@aztec-labs/foundation/log';
3
+ import { writeFile } from 'fs/promises';
4
+
5
+ import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
6
+ import { defaultBlsPath } from './utils.js';
7
+
8
+ export type GenerateBlsKeypairOptions = {
9
+ mnemonic?: string;
10
+ ikm?: string;
11
+ blsPath?: string;
12
+ g2?: boolean;
13
+ compressed?: boolean;
14
+ json?: boolean;
15
+ out?: string;
16
+ };
17
+
18
+ export async function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn) {
19
+ const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
20
+ const path = withValidatorIndex(blsPath ?? defaultBlsPath, 0);
21
+ const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
22
+ const pub = await computeBlsPublicKeyCompressed(priv);
23
+ const result = { path, privateKey: priv, publicKey: pub, format: compressed ? 'compressed' : 'uncompressed' };
24
+ if (out) {
25
+ await writeFile(out, JSON.stringify(result, null, 2), { encoding: 'utf-8' });
26
+ if (!json) {
27
+ log(`Wrote BLS keypair to ${out}`);
28
+ }
29
+ }
30
+ if (json || !out) {
31
+ log(JSON.stringify(result, null, 2));
32
+ }
33
+ }