@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.
- package/README.md +23 -0
- package/dest/cmds/aztec_node/block_number.d.ts +3 -0
- package/dest/cmds/aztec_node/block_number.d.ts.map +1 -0
- package/dest/cmds/aztec_node/block_number.js +10 -0
- package/dest/cmds/aztec_node/get_block.d.ts +3 -0
- package/dest/cmds/aztec_node/get_block.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_block.js +10 -0
- package/dest/cmds/aztec_node/get_current_min_fee.d.ts +3 -0
- package/dest/cmds/aztec_node/get_current_min_fee.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_current_min_fee.js +7 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +5 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.js +12 -0
- package/dest/cmds/aztec_node/get_logs.d.ts +33 -0
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_logs.js +61 -0
- package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
- package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_node_info.js +58 -0
- package/dest/cmds/aztec_node/index.d.ts +4 -0
- package/dest/cmds/aztec_node/index.d.ts.map +1 -0
- package/dest/cmds/aztec_node/index.js +38 -0
- package/dest/cmds/infrastructure/index.d.ts +4 -0
- package/dest/cmds/infrastructure/index.d.ts.map +1 -0
- package/dest/cmds/infrastructure/index.js +22 -0
- package/dest/cmds/infrastructure/sequencers.d.ts +12 -0
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -0
- package/dest/cmds/infrastructure/sequencers.js +113 -0
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +3 -0
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -0
- package/dest/cmds/infrastructure/setup_l2_contract.js +35 -0
- package/dest/cmds/l1/advance_epoch.d.ts +3 -0
- package/dest/cmds/l1/advance_epoch.d.ts.map +1 -0
- package/dest/cmds/l1/advance_epoch.js +12 -0
- package/dest/cmds/l1/assume_proven_through.d.ts +4 -0
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -0
- package/dest/cmds/l1/assume_proven_through.js +12 -0
- package/dest/cmds/l1/compute_genesis_values.d.ts +4 -0
- package/dest/cmds/l1/compute_genesis_values.d.ts.map +1 -0
- package/dest/cmds/l1/compute_genesis_values.js +17 -0
- package/dest/cmds/l1/create_l1_account.d.ts +3 -0
- package/dest/cmds/l1/create_l1_account.d.ts.map +1 -0
- package/dest/cmds/l1/create_l1_account.js +15 -0
- package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +4 -0
- package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -0
- package/dest/cmds/l1/deploy_l1_contracts_cmd.js +80 -0
- package/dest/cmds/l1/deploy_new_rollup.d.ts +5 -0
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -0
- package/dest/cmds/l1/deploy_new_rollup.js +26 -0
- package/dest/cmds/l1/get_l1_addresses.d.ts +4 -0
- package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -0
- package/dest/cmds/l1/get_l1_addresses.js +21 -0
- package/dest/cmds/l1/get_l1_balance.d.ts +4 -0
- package/dest/cmds/l1/get_l1_balance.d.ts.map +1 -0
- package/dest/cmds/l1/get_l1_balance.js +35 -0
- package/dest/cmds/l1/governance_utils.d.ts +50 -0
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -0
- package/dest/cmds/l1/governance_utils.js +87 -0
- package/dest/cmds/l1/index.d.ts +4 -0
- package/dest/cmds/l1/index.d.ts.map +1 -0
- package/dest/cmds/l1/index.js +201 -0
- package/dest/cmds/l1/prover_stats.d.ts +14 -0
- package/dest/cmds/l1/prover_stats.d.ts.map +1 -0
- package/dest/cmds/l1/prover_stats.js +147 -0
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts +6 -0
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -0
- package/dest/cmds/l1/trigger_seed_snapshot.js +20 -0
- package/dest/cmds/l1/update_l1_validators.d.ts +45 -0
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -0
- package/dest/cmds/l1/update_l1_validators.js +280 -0
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +3 -0
- package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -0
- package/dest/cmds/misc/generate_bootnode_enr.js +5 -0
- package/dest/cmds/misc/generate_p2p_private_key.d.ts +3 -0
- package/dest/cmds/misc/generate_p2p_private_key.d.ts.map +1 -0
- package/dest/cmds/misc/generate_p2p_private_key.js +7 -0
- package/dest/cmds/misc/generate_secret_key.d.ts +5 -0
- package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -0
- package/dest/cmds/misc/generate_secret_key.js +6 -0
- package/dest/cmds/misc/index.d.ts +4 -0
- package/dest/cmds/misc/index.d.ts.map +1 -0
- package/dest/cmds/misc/index.js +32 -0
- package/dest/cmds/misc/update/common.d.ts +17 -0
- package/dest/cmds/misc/update/common.d.ts.map +1 -0
- package/dest/cmds/misc/update/common.js +3 -0
- package/dest/cmds/misc/update/github.d.ts +3 -0
- package/dest/cmds/misc/update/github.d.ts.map +1 -0
- package/dest/cmds/misc/update/github.js +2 -0
- package/dest/cmds/misc/update/noir.d.ts +10 -0
- package/dest/cmds/misc/update/noir.d.ts.map +1 -0
- package/dest/cmds/misc/update/noir.js +45 -0
- package/dest/cmds/misc/update/npm.d.ts +34 -0
- package/dest/cmds/misc/update/npm.d.ts.map +1 -0
- package/dest/cmds/misc/update/npm.js +123 -0
- package/dest/cmds/misc/update/utils.d.ts +14 -0
- package/dest/cmds/misc/update/utils.d.ts.map +1 -0
- package/dest/cmds/misc/update/utils.js +38 -0
- package/dest/cmds/misc/update.d.ts +3 -0
- package/dest/cmds/misc/update.d.ts.map +1 -0
- package/dest/cmds/misc/update.js +51 -0
- package/dest/cmds/validator_keys/add.d.ts +5 -0
- package/dest/cmds/validator_keys/add.d.ts.map +1 -0
- package/dest/cmds/validator_keys/add.js +83 -0
- package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts +2 -0
- package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts.map +1 -0
- package/dest/cmds/validator_keys/eth_json_v3_worker.js +27 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.js +27 -0
- package/dest/cmds/validator_keys/index.d.ts +4 -0
- package/dest/cmds/validator_keys/index.d.ts.map +1 -0
- package/dest/cmds/validator_keys/index.js +33 -0
- package/dest/cmds/validator_keys/new.d.ts +35 -0
- package/dest/cmds/validator_keys/new.d.ts.map +1 -0
- package/dest/cmds/validator_keys/new.js +220 -0
- package/dest/cmds/validator_keys/set_funding_account.d.ts +14 -0
- package/dest/cmds/validator_keys/set_funding_account.d.ts.map +1 -0
- package/dest/cmds/validator_keys/set_funding_account.js +37 -0
- package/dest/cmds/validator_keys/shared.d.ts +81 -0
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
- package/dest/cmds/validator_keys/shared.js +352 -0
- package/dest/cmds/validator_keys/staker.d.ts +38 -0
- package/dest/cmds/validator_keys/staker.d.ts.map +1 -0
- package/dest/cmds/validator_keys/staker.js +210 -0
- package/dest/cmds/validator_keys/utils.d.ts +35 -0
- package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
- package/dest/cmds/validator_keys/utils.js +86 -0
- package/dest/config/cached_fetch.d.ts +27 -0
- package/dest/config/cached_fetch.d.ts.map +1 -0
- package/dest/config/cached_fetch.js +132 -0
- package/dest/config/chain_l2_config.d.ts +19 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +60 -0
- package/dest/config/enrich_env.d.ts +4 -0
- package/dest/config/enrich_env.d.ts.map +1 -0
- package/dest/config/enrich_env.js +12 -0
- package/dest/config/generated/networks.d.ts +236 -0
- package/dest/config/generated/networks.d.ts.map +1 -0
- package/dest/config/generated/networks.js +237 -0
- package/dest/config/get_l1_config.d.ts +9 -0
- package/dest/config/get_l1_config.d.ts.map +1 -0
- package/dest/config/get_l1_config.js +24 -0
- package/dest/config/index.d.ts +5 -0
- package/dest/config/index.d.ts.map +1 -0
- package/dest/config/index.js +4 -0
- package/dest/config/network_config.d.ts +22 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +119 -0
- package/dest/utils/aztec.d.ts +56 -0
- package/dest/utils/aztec.d.ts.map +1 -0
- package/dest/utils/aztec.js +161 -0
- package/dest/utils/commands.d.ts +161 -0
- package/dest/utils/commands.d.ts.map +1 -0
- package/dest/utils/commands.js +341 -0
- package/dest/utils/encoding.d.ts +15 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/utils/encoding.js +103 -0
- package/dest/utils/github.d.ts +3 -0
- package/dest/utils/github.d.ts.map +1 -0
- package/dest/utils/github.js +2 -0
- package/dest/utils/index.d.ts +6 -0
- package/dest/utils/index.d.ts.map +1 -0
- package/dest/utils/index.js +5 -0
- package/dest/utils/inspect.d.ts +11 -0
- package/dest/utils/inspect.d.ts.map +1 -0
- package/dest/utils/inspect.js +90 -0
- package/dest/utils/setup_contracts.d.ts +3 -0
- package/dest/utils/setup_contracts.d.ts.map +1 -0
- package/dest/utils/setup_contracts.js +16 -0
- package/package.json +141 -0
- package/public_include_metric_prefixes.json +1 -0
- package/src/cmds/aztec_node/block_number.ts +9 -0
- package/src/cmds/aztec_node/get_block.ts +11 -0
- package/src/cmds/aztec_node/get_current_min_fee.ts +9 -0
- package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
- package/src/cmds/aztec_node/get_logs.ts +100 -0
- package/src/cmds/aztec_node/get_node_info.ts +61 -0
- package/src/cmds/aztec_node/index.ts +91 -0
- package/src/cmds/infrastructure/index.ts +51 -0
- package/src/cmds/infrastructure/sequencers.ts +122 -0
- package/src/cmds/infrastructure/setup_l2_contract.ts +40 -0
- package/src/cmds/l1/advance_epoch.ts +14 -0
- package/src/cmds/l1/assume_proven_through.ts +20 -0
- package/src/cmds/l1/compute_genesis_values.ts +29 -0
- package/src/cmds/l1/create_l1_account.ts +16 -0
- package/src/cmds/l1/deploy_l1_contracts_cmd.ts +105 -0
- package/src/cmds/l1/deploy_new_rollup.ts +65 -0
- package/src/cmds/l1/get_l1_addresses.ts +31 -0
- package/src/cmds/l1/get_l1_balance.ts +44 -0
- package/src/cmds/l1/governance_utils.ts +183 -0
- package/src/cmds/l1/index.ts +499 -0
- package/src/cmds/l1/prover_stats.ts +213 -0
- package/src/cmds/l1/trigger_seed_snapshot.ts +32 -0
- package/src/cmds/l1/update_l1_validators.ts +358 -0
- package/src/cmds/misc/generate_bootnode_enr.ts +13 -0
- package/src/cmds/misc/generate_p2p_private_key.ts +9 -0
- package/src/cmds/misc/generate_secret_key.ts +5 -0
- package/src/cmds/misc/index.ts +67 -0
- package/src/cmds/misc/update/common.ts +16 -0
- package/src/cmds/misc/update/github.ts +2 -0
- package/src/cmds/misc/update/noir.ts +56 -0
- package/src/cmds/misc/update/npm.ts +148 -0
- package/src/cmds/misc/update/utils.ts +49 -0
- package/src/cmds/misc/update.ts +71 -0
- package/src/cmds/validator_keys/add.ts +122 -0
- package/src/cmds/validator_keys/eth_json_v3_worker.ts +30 -0
- package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
- package/src/cmds/validator_keys/index.ts +181 -0
- package/src/cmds/validator_keys/new.ts +326 -0
- package/src/cmds/validator_keys/set_funding_account.ts +54 -0
- package/src/cmds/validator_keys/shared.ts +414 -0
- package/src/cmds/validator_keys/staker.ts +300 -0
- package/src/cmds/validator_keys/utils.ts +124 -0
- package/src/config/cached_fetch.ts +154 -0
- package/src/config/chain_l2_config.ts +71 -0
- package/src/config/enrich_env.ts +15 -0
- package/src/config/generated/networks.ts +241 -0
- package/src/config/get_l1_config.ts +31 -0
- package/src/config/index.ts +4 -0
- package/src/config/network_config.ts +150 -0
- package/src/utils/aztec.ts +203 -0
- package/src/utils/commands.ts +434 -0
- package/src/utils/encoding.ts +117 -0
- package/src/utils/github.ts +2 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/inspect.ts +111 -0
- package/src/utils/setup_contracts.ts +19 -0
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY21kcy9taXNjL3VwZGF0ZS9jb21tb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFDSCxNQUFNLE1BQU0saUJBQWlCLEdBQUc7SUFDOUIsNkJBQTZCO0lBQzdCLElBQUksRUFBRSxNQUFNLENBQUM7SUFDYiwrQkFBK0I7SUFDL0IsWUFBWSxFQUFFLEtBQUssQ0FBQztRQUNsQiwyQ0FBMkM7UUFDM0MsSUFBSSxFQUFFLE1BQU0sQ0FBQztRQUNiLHlDQUF5QztRQUN6QyxJQUFJLEVBQUUsTUFBTSxDQUFDO1FBQ2IsdURBQXVEO1FBQ3ZELEVBQUUsRUFBRSxNQUFNLENBQUM7S0FDWixDQUFDLENBQUM7Q0FDSixDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/cmds/misc/update/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,YAAY,EAAE,KAAK,CAAC;QAClB,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,yCAAyC;QACzC,IAAI,EAAE,MAAM,CAAC;QACb,uDAAuD;QACvD,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const GITHUB_OWNER = "AztecProtocol";
|
|
2
|
+
export declare const GITHUB_REPO = "aztec-packages";
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2l0aHViLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY21kcy9taXNjL3VwZGF0ZS9naXRodWIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZUFBTyxNQUFNLFlBQVksa0JBQWtCLENBQUM7QUFDNUMsZUFBTyxNQUFNLFdBQVcsbUJBQW1CLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../src/cmds/misc/update/github.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,kBAAkB,CAAC;AAC5C,eAAO,MAAM,WAAW,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
import type { DependencyChanges } from './common.js';
|
|
3
|
+
/**
|
|
4
|
+
* Updates Aztec.nr dependencies
|
|
5
|
+
* @param contractPath - Path to the contract to be updated
|
|
6
|
+
* @param tag - The tag to update to
|
|
7
|
+
* @param log - Logging function
|
|
8
|
+
*/
|
|
9
|
+
export declare function updateAztecNr(contractPath: string, tag: string, log: LogFn): Promise<DependencyChanges>;
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9pci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2NtZHMvbWlzYy91cGRhdGUvbm9pci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQU14RCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUdyRDs7Ozs7R0FLRztBQUNILHdCQUFzQixhQUFhLENBQUMsWUFBWSxFQUFFLE1BQU0sRUFBRSxHQUFHLEVBQUUsTUFBTSxFQUFFLEdBQUcsRUFBRSxLQUFLLEdBQUcsT0FBTyxDQUFDLGlCQUFpQixDQUFDLENBd0M3RyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noir.d.ts","sourceRoot":"","sources":["../../../../src/cmds/misc/update/noir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAMxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwC7G"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parseNoirPackageConfig } from '@aztec-labs/foundation/noir';
|
|
2
|
+
import TOML from '@iarna/toml';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join, relative, resolve } from 'path';
|
|
5
|
+
import { atomicUpdateFile, prettyPrintNargoToml } from './utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* Updates Aztec.nr dependencies
|
|
8
|
+
* @param contractPath - Path to the contract to be updated
|
|
9
|
+
* @param tag - The tag to update to
|
|
10
|
+
* @param log - Logging function
|
|
11
|
+
*/ export async function updateAztecNr(contractPath, tag, log) {
|
|
12
|
+
const configFilepath = resolve(join(contractPath, 'Nargo.toml'));
|
|
13
|
+
const packageConfig = parseNoirPackageConfig(TOML.parse(await readFile(configFilepath, 'utf-8')));
|
|
14
|
+
const changes = {
|
|
15
|
+
dependencies: [],
|
|
16
|
+
file: configFilepath
|
|
17
|
+
};
|
|
18
|
+
log(`Updating Aztec.nr libraries to ${tag} in ${relative(process.cwd(), changes.file)}`);
|
|
19
|
+
for (const dep of Object.values(packageConfig.dependencies)){
|
|
20
|
+
if (!('git' in dep)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
// remove trailing slash
|
|
24
|
+
const gitUrl = dep.git.toLowerCase().replace(/\/$/, '');
|
|
25
|
+
if (gitUrl !== 'https://github.com/aztecprotocol/aztec-packages') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (dep.tag !== tag) {
|
|
29
|
+
// show the Aztec.nr package name rather than the lib name
|
|
30
|
+
const dirParts = dep.directory?.split('/') ?? [];
|
|
31
|
+
changes.dependencies.push({
|
|
32
|
+
name: dirParts.slice(-2).join('/'),
|
|
33
|
+
from: dep.tag,
|
|
34
|
+
to: tag
|
|
35
|
+
});
|
|
36
|
+
dep.tag = tag;
|
|
37
|
+
dep.directory = dep.directory?.replace('yarn-project/', 'noir-projects/');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (changes.dependencies.length > 0) {
|
|
41
|
+
const contents = prettyPrintNargoToml(packageConfig);
|
|
42
|
+
await atomicUpdateFile(configFilepath, contents);
|
|
43
|
+
}
|
|
44
|
+
return changes;
|
|
45
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
import { type SemVer } from 'semver';
|
|
3
|
+
import type { DependencyChanges } from './common.js';
|
|
4
|
+
/**
|
|
5
|
+
* Looks up a package.json file and returns its contents
|
|
6
|
+
* @param projectPath - Path to Nodejs project
|
|
7
|
+
* @returns The parsed package.json
|
|
8
|
+
*/
|
|
9
|
+
export declare function readPackageJson(projectPath: string): Promise<{
|
|
10
|
+
/** dependencies */
|
|
11
|
+
dependencies?: Record<string, string>;
|
|
12
|
+
/** devDependencies */
|
|
13
|
+
devDependencies?: Record<string, string>;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Queries the npm registry for the latest version of a package
|
|
17
|
+
* @param packageName - The package to query
|
|
18
|
+
* @param distTag - The distribution tag
|
|
19
|
+
* @returns The latest version of the package on that distribution tag
|
|
20
|
+
*/
|
|
21
|
+
export declare function getNewestVersion(packageName: string, distTag?: string): Promise<SemVer>;
|
|
22
|
+
/**
|
|
23
|
+
* Updates a project's \@aztec-labs/* dependencies to the specific version
|
|
24
|
+
* @param projectPath - Path to Nodejs project
|
|
25
|
+
* @param aztecVersion - The version to update to
|
|
26
|
+
* @returns True if the project was updated
|
|
27
|
+
*/
|
|
28
|
+
export declare function updateAztecDeps(projectPath: string, aztecVersion: SemVer, log: LogFn): Promise<DependencyChanges>;
|
|
29
|
+
/**
|
|
30
|
+
* Updates a project's yarn.lock or package-lock.json
|
|
31
|
+
* @param projectPath - Path to Nodejs project
|
|
32
|
+
*/
|
|
33
|
+
export declare function updateLockfile(projectPath: string, log: LogFn): void;
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY21kcy9taXNjL3VwZGF0ZS9ucG0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFLeEQsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFTLE1BQU0sUUFBUSxDQUFDO0FBRTVDLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBWXJEOzs7O0dBSUc7QUFDSCx3QkFBc0IsZUFBZSxDQUFDLFdBQVcsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDO0lBQ2xFLG1CQUFtQjtJQUNuQixZQUFZLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDO0lBQ3RDLHNCQUFzQjtJQUN0QixlQUFlLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDO0NBQzFDLENBQUMsQ0FLRDtBQUVEOzs7OztHQUtHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUFDLFdBQVcsRUFBRSxNQUFNLEVBQUUsT0FBTyxTQUFXLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQWMvRjtBQUVEOzs7OztHQUtHO0FBQ0gsd0JBQXNCLGVBQWUsQ0FDbkMsV0FBVyxFQUFFLE1BQU0sRUFDbkIsWUFBWSxFQUFFLE1BQU0sRUFDcEIsR0FBRyxFQUFFLEtBQUssR0FDVCxPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FrRDVCO0FBRUQ7OztHQUdHO0FBQ0gsd0JBQWdCLGNBQWMsQ0FBQyxXQUFXLEVBQUUsTUFBTSxFQUFFLEdBQUcsRUFBRSxLQUFLLEdBQUcsSUFBSSxDQXVCcEUifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../../../src/cmds/misc/update/npm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAKxD,OAAO,EAAE,KAAK,MAAM,EAAS,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAYrD;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAClE,mBAAmB;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,sBAAsB;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC,CAKD;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,SAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAc/F;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,iBAAiB,CAAC,CAkD5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAuBpE"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join, relative, resolve } from 'path';
|
|
5
|
+
import { parse } from 'semver';
|
|
6
|
+
import { atomicUpdateFile } from './utils.js';
|
|
7
|
+
const deprecatedNpmPackages = new Set([
|
|
8
|
+
'@aztec-labs/cli',
|
|
9
|
+
'@aztec/aztec-local-network'
|
|
10
|
+
]);
|
|
11
|
+
const npmDeprecationMessage = `
|
|
12
|
+
The following packages have been deprecated and will no longer be updated on the npm registry:
|
|
13
|
+
${Array.from(deprecatedNpmPackages).map((pkg)=>` - ${pkg}`).join('\n')}
|
|
14
|
+
Remove them from package.json
|
|
15
|
+
`;
|
|
16
|
+
/**
|
|
17
|
+
* Looks up a package.json file and returns its contents
|
|
18
|
+
* @param projectPath - Path to Nodejs project
|
|
19
|
+
* @returns The parsed package.json
|
|
20
|
+
*/ export async function readPackageJson(projectPath) {
|
|
21
|
+
const configFilepath = resolve(join(projectPath, 'package.json'));
|
|
22
|
+
const pkg = JSON.parse(await readFile(configFilepath, 'utf-8'));
|
|
23
|
+
return pkg;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Queries the npm registry for the latest version of a package
|
|
27
|
+
* @param packageName - The package to query
|
|
28
|
+
* @param distTag - The distribution tag
|
|
29
|
+
* @returns The latest version of the package on that distribution tag
|
|
30
|
+
*/ export async function getNewestVersion(packageName, distTag = 'latest') {
|
|
31
|
+
const url = new URL(packageName, 'https://registry.npmjs.org/');
|
|
32
|
+
const response = await fetch(url);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(`Failed to fetch ${url}`);
|
|
35
|
+
}
|
|
36
|
+
const body = await response.json();
|
|
37
|
+
const latestVersion = parse(body['dist-tags'][distTag]);
|
|
38
|
+
if (!latestVersion) {
|
|
39
|
+
throw new Error(`Failed to get latest version from registry`);
|
|
40
|
+
}
|
|
41
|
+
return latestVersion;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Updates a project's \@aztec-labs/* dependencies to the specific version
|
|
45
|
+
* @param projectPath - Path to Nodejs project
|
|
46
|
+
* @param aztecVersion - The version to update to
|
|
47
|
+
* @returns True if the project was updated
|
|
48
|
+
*/ export async function updateAztecDeps(projectPath, aztecVersion, log) {
|
|
49
|
+
const pkg = await readPackageJson(projectPath);
|
|
50
|
+
const changes = {
|
|
51
|
+
file: resolve(join(projectPath, 'package.json')),
|
|
52
|
+
dependencies: []
|
|
53
|
+
};
|
|
54
|
+
log(`Updating @aztec-labs packages to ${aztecVersion} in ${relative(process.cwd(), changes.file)}`);
|
|
55
|
+
const version = aztecVersion.version;
|
|
56
|
+
let detectedDeprecatedPackages = false;
|
|
57
|
+
for (const depType of [
|
|
58
|
+
'dependencies',
|
|
59
|
+
'devDependencies'
|
|
60
|
+
]){
|
|
61
|
+
const dependencies = pkg[depType];
|
|
62
|
+
if (!dependencies) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
for (const name of Object.keys(dependencies)){
|
|
66
|
+
if (!name.startsWith('@aztec-labs/')) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (deprecatedNpmPackages.has(name)) {
|
|
70
|
+
detectedDeprecatedPackages = true;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (dependencies[name] !== version) {
|
|
74
|
+
changes.dependencies.push({
|
|
75
|
+
name,
|
|
76
|
+
from: dependencies[name],
|
|
77
|
+
to: version
|
|
78
|
+
});
|
|
79
|
+
dependencies[name] = version;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (detectedDeprecatedPackages) {
|
|
84
|
+
log(npmDeprecationMessage);
|
|
85
|
+
}
|
|
86
|
+
if (changes.dependencies.length > 0) {
|
|
87
|
+
const contents = JSON.stringify(pkg, null, 2) + '\n';
|
|
88
|
+
await atomicUpdateFile(resolve(join(projectPath, 'package.json')), contents);
|
|
89
|
+
}
|
|
90
|
+
return changes;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Updates a project's yarn.lock or package-lock.json
|
|
94
|
+
* @param projectPath - Path to Nodejs project
|
|
95
|
+
*/ export function updateLockfile(projectPath, log) {
|
|
96
|
+
const isNpm = existsSync(resolve(join(projectPath, 'package-lock.json')));
|
|
97
|
+
const isYarn = existsSync(resolve(join(projectPath, 'yarn.lock')));
|
|
98
|
+
const isPnpm = existsSync(resolve(join(projectPath, 'pnpm-lock.yaml')));
|
|
99
|
+
if (isPnpm) {
|
|
100
|
+
spawnSync('pnpm', [
|
|
101
|
+
'install'
|
|
102
|
+
], {
|
|
103
|
+
cwd: projectPath,
|
|
104
|
+
stdio: 'inherit'
|
|
105
|
+
});
|
|
106
|
+
} else if (isYarn) {
|
|
107
|
+
spawnSync('yarn', [
|
|
108
|
+
'install'
|
|
109
|
+
], {
|
|
110
|
+
cwd: projectPath,
|
|
111
|
+
stdio: 'inherit'
|
|
112
|
+
});
|
|
113
|
+
} else if (isNpm) {
|
|
114
|
+
spawnSync('npm', [
|
|
115
|
+
'install'
|
|
116
|
+
], {
|
|
117
|
+
cwd: projectPath,
|
|
118
|
+
stdio: 'inherit'
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
log(`No lockfile found in ${projectPath}. Skipping lockfile update...`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NoirPackageConfig } from '@aztec-labs/foundation/noir';
|
|
2
|
+
/**
|
|
3
|
+
* Updates a file in place atomically.
|
|
4
|
+
* @param filePath - Path to file
|
|
5
|
+
* @param contents - New contents to write
|
|
6
|
+
*/
|
|
7
|
+
export declare function atomicUpdateFile(filePath: string, contents: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Pretty prints Nargo.toml contents to a string
|
|
10
|
+
* @param config - Nargo.toml contents
|
|
11
|
+
* @returns The Nargo.toml contents as a string
|
|
12
|
+
*/
|
|
13
|
+
export declare function prettyPrintNargoToml(config: NoirPackageConfig): string;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jbWRzL21pc2MvdXBkYXRlL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFLckU7Ozs7R0FJRztBQUNILHdCQUFzQixnQkFBZ0IsQ0FBQyxRQUFRLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxNQUFNLGlCQXFCeEU7QUFFRDs7OztHQUlHO0FBQ0gsd0JBQWdCLG9CQUFvQixDQUFDLE1BQU0sRUFBRSxpQkFBaUIsR0FBRyxNQUFNLENBVXRFIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/cmds/misc/update/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAKrE;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAqBxE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAUtE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import TOML from '@iarna/toml';
|
|
2
|
+
import { CommanderError } from 'commander';
|
|
3
|
+
import { rename, writeFile } from 'fs/promises';
|
|
4
|
+
/**
|
|
5
|
+
* Updates a file in place atomically.
|
|
6
|
+
* @param filePath - Path to file
|
|
7
|
+
* @param contents - New contents to write
|
|
8
|
+
*/ export async function atomicUpdateFile(filePath, contents) {
|
|
9
|
+
const tmpFilepath = filePath + '.tmp';
|
|
10
|
+
try {
|
|
11
|
+
await writeFile(tmpFilepath, contents, {
|
|
12
|
+
// let's crash if the tmp file already exists
|
|
13
|
+
flag: 'wx'
|
|
14
|
+
});
|
|
15
|
+
await rename(tmpFilepath, filePath);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
if (e instanceof Error && 'code' in e && e.code === 'EEXIST') {
|
|
18
|
+
const commanderError = new CommanderError(1, e.code, `Temporary file already exists: ${tmpFilepath}. Delete this file and try again.`);
|
|
19
|
+
commanderError.nestedError = e.message;
|
|
20
|
+
throw commanderError;
|
|
21
|
+
} else {
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pretty prints Nargo.toml contents to a string
|
|
28
|
+
* @param config - Nargo.toml contents
|
|
29
|
+
* @returns The Nargo.toml contents as a string
|
|
30
|
+
*/ export function prettyPrintNargoToml(config) {
|
|
31
|
+
const withoutDependencies = Object.fromEntries(Object.entries(config).filter(([key])=>key !== 'dependencies'));
|
|
32
|
+
const partialToml = TOML.stringify(withoutDependencies);
|
|
33
|
+
const dependenciesToml = Object.entries(config.dependencies).map(([name, dep])=>{
|
|
34
|
+
const depToml = TOML.stringify.value(dep);
|
|
35
|
+
return `${name} = ${depToml}`;
|
|
36
|
+
});
|
|
37
|
+
return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n';
|
|
38
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
export declare function updateProject(projectPath: string, contracts: string[], aztecVersion: string, log: LogFn): Promise<void>;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBkYXRlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY21kcy9taXNjL3VwZGF0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQVd4RCx3QkFBc0IsYUFBYSxDQUNqQyxXQUFXLEVBQUUsTUFBTSxFQUNuQixTQUFTLEVBQUUsTUFBTSxFQUFFLEVBQ25CLFlBQVksRUFBRSxNQUFNLEVBQ3BCLEdBQUcsRUFBRSxLQUFLLEdBQ1QsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTJDZiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cmds/misc/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAWxD,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,EACnB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,IAAI,CAAC,CA2Cf"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { relative, resolve } from 'path';
|
|
2
|
+
import { parse } from 'semver';
|
|
3
|
+
import { updateAztecNr } from './update/noir.js';
|
|
4
|
+
import { getNewestVersion, updateAztecDeps, updateLockfile } from './update/npm.js';
|
|
5
|
+
const AZTECJS_PACKAGE = '@aztec-labs/aztec.js';
|
|
6
|
+
const UPDATE_DOCS_URL = 'https://docs.aztec.network/developers/guides/local_env/versions-updating';
|
|
7
|
+
export async function updateProject(projectPath, contracts, aztecVersion, log) {
|
|
8
|
+
const targetAztecVersion = aztecVersion === 'latest' ? await getNewestVersion(AZTECJS_PACKAGE, 'latest') : parse(aztecVersion);
|
|
9
|
+
if (!targetAztecVersion) {
|
|
10
|
+
throw new Error(`Invalid aztec version ${aztecVersion}`);
|
|
11
|
+
}
|
|
12
|
+
const projectDependencyChanges = [];
|
|
13
|
+
try {
|
|
14
|
+
const npmChanges = await updateAztecDeps(resolve(process.cwd(), projectPath), targetAztecVersion, log);
|
|
15
|
+
if (npmChanges.dependencies.length > 0) {
|
|
16
|
+
updateLockfile(projectPath, log);
|
|
17
|
+
}
|
|
18
|
+
projectDependencyChanges.push(npmChanges);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
|
|
21
|
+
log(`No package.json found in ${projectPath}. Skipping npm update...`);
|
|
22
|
+
} else {
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (const contract of contracts){
|
|
27
|
+
try {
|
|
28
|
+
projectDependencyChanges.push(await updateAztecNr(resolve(process.cwd(), projectPath, contract), `v${targetAztecVersion.version}`, log));
|
|
29
|
+
} catch (err) {
|
|
30
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
|
|
31
|
+
log(`No Nargo.toml found in ${relative(process.cwd(), contract)}. Skipping...`);
|
|
32
|
+
} else {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
log(`To update Docker containers follow instructions at ${UPDATE_DOCS_URL}`);
|
|
38
|
+
projectDependencyChanges.forEach((changes)=>{
|
|
39
|
+
printChanges(changes, log);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function printChanges(changes, log) {
|
|
43
|
+
log(`\nIn ${relative(process.cwd(), changes.file)}:`);
|
|
44
|
+
if (changes.dependencies.length === 0) {
|
|
45
|
+
log(' No changes');
|
|
46
|
+
} else {
|
|
47
|
+
changes.dependencies.forEach(({ name, from, to })=>{
|
|
48
|
+
log(` Updated ${name} from ${from} to ${to}`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
import type { NewValidatorKeystoreOptions } from './new.js';
|
|
3
|
+
export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
|
|
4
|
+
export declare function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY21kcy92YWxpZGF0b3Jfa2V5cy9hZGQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFPeEQsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxVQUFVLENBQUM7QUFXNUQsTUFBTSxNQUFNLHVCQUF1QixHQUFHLDJCQUEyQixDQUFDO0FBRWxFLHdCQUFzQixnQkFBZ0IsQ0FBQyxRQUFRLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxHQUFHLEVBQUUsS0FBSyxpQkFvR3BHIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/add.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAOxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAW5D,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAElE,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,KAAK,iBAoGpG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { loadKeystoreFile } from '@aztec-labs/node-keystore/loader';
|
|
2
|
+
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
3
|
+
import { dirname, isAbsolute, join } from 'path';
|
|
4
|
+
import { generateMnemonic } from 'viem/accounts';
|
|
5
|
+
import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
6
|
+
import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions } from './utils.js';
|
|
7
|
+
export async function addValidatorKeys(existing, options, log) {
|
|
8
|
+
// validate bls-path inputs before proceeding with key generation
|
|
9
|
+
validateBlsPathOptions(options);
|
|
10
|
+
// validate publisher options
|
|
11
|
+
validatePublisherOptions(options);
|
|
12
|
+
// validate remote signer options
|
|
13
|
+
validateRemoteSignerOptions(options);
|
|
14
|
+
const { dataDir, file, count, publisherCount = 0, publishers, mnemonic, accountIndex = 0, addressIndex, ikm, blsPath, json, feeRecipient: feeRecipientOpt, coinbase: coinbaseOpt, remoteSigner: remoteSignerOpt, password, encryptedKeystoreDir } = options;
|
|
15
|
+
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
16
|
+
const baseAddressIndex = addressIndex ?? 0;
|
|
17
|
+
const keystore = loadKeystoreFile(existing);
|
|
18
|
+
if (!keystore.validators || !Array.isArray(keystore.validators)) {
|
|
19
|
+
throw new Error('Invalid keystore: missing validators array');
|
|
20
|
+
}
|
|
21
|
+
const first = keystore.validators[0] ?? {};
|
|
22
|
+
const feeRecipient = feeRecipientOpt ?? first.feeRecipient;
|
|
23
|
+
if (!feeRecipient) {
|
|
24
|
+
throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
|
|
25
|
+
}
|
|
26
|
+
const coinbase = coinbaseOpt ?? first.coinbase;
|
|
27
|
+
const derivedRemoteSigner = first.attester?.remoteSignerUrl || first.attester?.eth?.remoteSignerUrl;
|
|
28
|
+
const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
|
|
29
|
+
// Ensure we always have a mnemonic for key derivation if none was provided
|
|
30
|
+
const mnemonicToUse = mnemonic ?? generateMnemonic(wordlist);
|
|
31
|
+
// If user explicitly provided --address-index, use it as-is. Otherwise, append after existing validators.
|
|
32
|
+
const effectiveBaseAddressIndex = addressIndex === undefined ? baseAddressIndex + keystore.validators.length : baseAddressIndex;
|
|
33
|
+
const { validators, summaries } = await buildValidatorEntries({
|
|
34
|
+
validatorCount,
|
|
35
|
+
publisherCount,
|
|
36
|
+
publishers,
|
|
37
|
+
accountIndex,
|
|
38
|
+
baseAddressIndex: effectiveBaseAddressIndex,
|
|
39
|
+
mnemonic: mnemonicToUse,
|
|
40
|
+
ikm,
|
|
41
|
+
blsPath,
|
|
42
|
+
feeRecipient,
|
|
43
|
+
coinbase,
|
|
44
|
+
remoteSigner
|
|
45
|
+
});
|
|
46
|
+
keystore.validators.push(...validators);
|
|
47
|
+
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
48
|
+
if (password !== undefined) {
|
|
49
|
+
let targetDir;
|
|
50
|
+
if (encryptedKeystoreDir && encryptedKeystoreDir.length > 0) {
|
|
51
|
+
targetDir = encryptedKeystoreDir;
|
|
52
|
+
} else if (dataDir && dataDir.length > 0) {
|
|
53
|
+
targetDir = dataDir;
|
|
54
|
+
} else {
|
|
55
|
+
targetDir = dirname(existing);
|
|
56
|
+
}
|
|
57
|
+
await writeEthJsonV3ToFile(keystore.validators, {
|
|
58
|
+
outDir: targetDir,
|
|
59
|
+
password
|
|
60
|
+
});
|
|
61
|
+
await writeBlsBn254ToFile(keystore.validators, {
|
|
62
|
+
outDir: targetDir,
|
|
63
|
+
password,
|
|
64
|
+
blsPath
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
let outputPath = existing;
|
|
68
|
+
if (file && file.length > 0) {
|
|
69
|
+
if (isAbsolute(file)) {
|
|
70
|
+
outputPath = file;
|
|
71
|
+
} else if (dataDir && dataDir.length > 0) {
|
|
72
|
+
outputPath = join(dataDir, file);
|
|
73
|
+
} else {
|
|
74
|
+
outputPath = join(dirname(existing), file);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
await writeKeystoreFile(outputPath, keystore);
|
|
78
|
+
if (!json) {
|
|
79
|
+
log(`Updated keystore ${outputPath} with ${validators.length} new validator(s)`);
|
|
80
|
+
logValidatorSummaries(log, summaries);
|
|
81
|
+
}
|
|
82
|
+
maybePrintJson(log, !!json, keystore);
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth_json_v3_worker.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/eth_json_v3_worker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Wallet } from '@ethersproject/wallet';
|
|
2
|
+
import { parentPort, workerData } from 'worker_threads';
|
|
3
|
+
function serializeError(error) {
|
|
4
|
+
if (error instanceof Error) {
|
|
5
|
+
return {
|
|
6
|
+
message: error.message,
|
|
7
|
+
name: error.name,
|
|
8
|
+
stack: error.stack
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
message: String(error)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
void (async ()=>{
|
|
16
|
+
try {
|
|
17
|
+
const { privateKeyHex, password } = workerData;
|
|
18
|
+
const json = await new Wallet(privateKeyHex).encrypt(password);
|
|
19
|
+
parentPort?.postMessage({
|
|
20
|
+
json
|
|
21
|
+
});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
parentPort?.postMessage({
|
|
24
|
+
error: serializeError(error)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
export type GenerateBlsKeypairOptions = {
|
|
3
|
+
mnemonic?: string;
|
|
4
|
+
ikm?: string;
|
|
5
|
+
blsPath?: string;
|
|
6
|
+
g2?: boolean;
|
|
7
|
+
compressed?: boolean;
|
|
8
|
+
json?: boolean;
|
|
9
|
+
out?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVfYmxzX2tleXBhaXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbWRzL3ZhbGlkYXRvcl9rZXlzL2dlbmVyYXRlX2Jsc19rZXlwYWlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBTXhELE1BQU0sTUFBTSx5QkFBeUIsR0FBRztJQUN0QyxRQUFRLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDbEIsR0FBRyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2IsT0FBTyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2pCLEVBQUUsQ0FBQyxFQUFFLE9BQU8sQ0FBQztJQUNiLFVBQVUsQ0FBQyxFQUFFLE9BQU8sQ0FBQztJQUNyQixJQUFJLENBQUMsRUFBRSxPQUFPLENBQUM7SUFDZixHQUFHLENBQUMsRUFBRSxNQUFNLENBQUM7Q0FDZCxDQUFDO0FBRUYsd0JBQXNCLGtCQUFrQixDQUFDLE9BQU8sRUFBRSx5QkFBeUIsRUFBRSxHQUFHLEVBQUUsS0FBSyxpQkFldEYifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_bls_keypair.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/generate_bls_keypair.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAMxD,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,KAAK,iBAetF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { deriveBlsPrivateKey } from '@aztec-labs/foundation/crypto/bls';
|
|
2
|
+
import { writeFile } from 'fs/promises';
|
|
3
|
+
import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
|
|
4
|
+
import { defaultBlsPath } from './utils.js';
|
|
5
|
+
export async function generateBlsKeypair(options, log) {
|
|
6
|
+
const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
|
|
7
|
+
const path = withValidatorIndex(blsPath ?? defaultBlsPath, 0);
|
|
8
|
+
const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
|
|
9
|
+
const pub = await computeBlsPublicKeyCompressed(priv);
|
|
10
|
+
const result = {
|
|
11
|
+
path,
|
|
12
|
+
privateKey: priv,
|
|
13
|
+
publicKey: pub,
|
|
14
|
+
format: compressed ? 'compressed' : 'uncompressed'
|
|
15
|
+
};
|
|
16
|
+
if (out) {
|
|
17
|
+
await writeFile(out, JSON.stringify(result, null, 2), {
|
|
18
|
+
encoding: 'utf-8'
|
|
19
|
+
});
|
|
20
|
+
if (!json) {
|
|
21
|
+
log(`Wrote BLS keypair to ${out}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (json || !out) {
|
|
25
|
+
log(JSON.stringify(result, null, 2));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
export declare function injectCommands(program: Command, log: LogFn): Command;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbWRzL3ZhbGlkYXRvcl9rZXlzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQ3hELE9BQU8sRUFBRSxPQUFPLEVBQVUsTUFBTSxXQUFXLENBQUM7QUFLNUMsd0JBQWdCLGNBQWMsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxLQUFLLFdBOEsxRCJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAK5C,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WA8K1D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Option } from 'commander';
|
|
2
|
+
import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
|
|
3
|
+
import { defaultBlsPath } from './utils.js';
|
|
4
|
+
export function injectCommands(program, log) {
|
|
5
|
+
const group = program.command('validator-keys').aliases([
|
|
6
|
+
'valKeys',
|
|
7
|
+
'valkeys'
|
|
8
|
+
]).description('Manage validator keystores for node operators');
|
|
9
|
+
group.command('new').summary('Generate a new validator keystore JSON').description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts').option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore').option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)').option('--count <N>', 'Number of validators to generate', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress).option('--funding-account <privateKey|address>', 'ETH funding account used to top up publisher EOAs. Provide a private key, or an address together with --remote-signer.').option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).addOption(new Option('--password <str>', 'Shared password for writing ETH JSON V3 and BLS EIP-2335 keystore files').env('AZTEC_KEYSTORE_PASSWORD')).option('--password-file <path>', 'File containing the shared password for writing keystore files').addOption(new Option('--eth-password <str>', 'Password for writing ETH JSON V3 keystore files').env('AZTEC_ETH_KEYSTORE_PASSWORD')).option('--eth-password-file <path>', 'File containing the password for writing ETH JSON V3 keystore files').addOption(new Option('--bls-password <str>', 'Password for writing BLS EIP-2335 keystore files').env('AZTEC_BLS_KEYSTORE_PASSWORD')).option('--bls-password-file <path>', 'File containing the password for writing BLS EIP-2335 keystore files').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries').option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress).option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', (value)=>value.split(',')).option('-c, --l1-chain-id <number>', 'L1 chain ID (required with --staker-output)', (value)=>parseInt(value), 31337).requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (options)=>{
|
|
10
|
+
const { newValidatorKeystore } = await import('./new.js');
|
|
11
|
+
await newValidatorKeystore(options, log);
|
|
12
|
+
});
|
|
13
|
+
group.command('add').summary('Augment an existing validator keystore JSON').description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new').argument('<existing>', 'Path to existing keystore JSON').option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)').option('--file <name>', 'Override output file name. (default: key<N>.json)').option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).option('--empty', 'Generate an empty skeleton without keys').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (existing, options)=>{
|
|
14
|
+
const { addValidatorKeys } = await import('./add.js');
|
|
15
|
+
await addValidatorKeys(existing, options, log);
|
|
16
|
+
});
|
|
17
|
+
group.command('set-funding-account').summary('Set the funding account of an existing keystore').description('Sets the keystore-level ETH funding account used to top up publisher EOAs, replacing any existing one').argument('<existing>', 'Path to existing keystore JSON').argument('<privateKey|address>', 'Funding account: a private key, or an address (needs --remote-signer unless the keystore already defines one)').option('--remote-signer <url>', 'Remote signer URL for the funding account (required with an address unless the keystore already defines one)').option('--password <str>', 'Password for writing the funding key as an encrypted ETH JSON V3 file. Empty string allowed').option('--encrypted-keystore-dir <dir>', 'Output directory for the encrypted funding key file').option('--json', 'Echo resulting JSON to stdout').action(async (existing, fundingAccount, options)=>{
|
|
18
|
+
const { setFundingAccount } = await import('./set_funding_account.js');
|
|
19
|
+
await setFundingAccount(existing, fundingAccount, options, log);
|
|
20
|
+
});
|
|
21
|
+
group.command('staker').summary('Generate staking JSON from keystore').description('Reads a validator keystore and outputs staking data with BLS public keys for each attester (skips mnemonics)').requiredOption('--from <keystore>', 'Path to keystore JSON file').option('--password <password>', 'Password for decrypting encrypted keystores (if not specified in keystore file)').requiredOption('--gse-address <address>', 'GSE contract address', parseEthereumAddress).option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated)', (value)=>value.split(','), [
|
|
22
|
+
'http://localhost:8545'
|
|
23
|
+
]).option('-c, --l1-chain-id <number>', 'L1 chain ID', (value)=>parseInt(value), 31337).option('--output <file>', 'Output file path (if not specified, JSON is written to stdout)').action(async (options)=>{
|
|
24
|
+
const { generateStakerJson } = await import('./staker.js');
|
|
25
|
+
await generateStakerJson(options, log);
|
|
26
|
+
});
|
|
27
|
+
// top-level convenience: aztec generate-bls-keypair
|
|
28
|
+
program.command('generate-bls-keypair').description('Generate a BLS keypair with convenience flags').option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).option('--g2', 'Derive on G2 subgroup').option('--compressed', 'Output compressed public key').option('--json', 'Print JSON output to stdout').option('--out <file>', 'Write output to file').action(async (options)=>{
|
|
29
|
+
const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
|
|
30
|
+
await generateBlsKeypair(options, log);
|
|
31
|
+
});
|
|
32
|
+
return program;
|
|
33
|
+
}
|