@aztec/cli 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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 +2 -428
- 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 +7 -0
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
- package/dest/cmds/{pxe → aztec_node}/get_logs.js +4 -4
- 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/{pxe → aztec_node}/get_node_info.js +3 -8
- 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 +28 -0
- package/dest/cmds/contracts/index.d.ts +1 -1
- package/dest/cmds/contracts/inspect_contract.d.ts +1 -1
- package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
- package/dest/cmds/contracts/inspect_contract.js +4 -10
- package/dest/cmds/contracts/parse_parameter_struct.d.ts +1 -1
- package/dest/cmds/infrastructure/index.d.ts +3 -3
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +7 -9
- package/dest/cmds/infrastructure/sequencers.d.ts +3 -5
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +15 -7
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +2 -2
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.js +10 -25
- package/dest/cmds/l1/advance_epoch.d.ts +2 -2
- package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
- package/dest/cmds/l1/advance_epoch.js +6 -5
- package/dest/cmds/l1/assume_proven_through.d.ts +2 -2
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +8 -6
- package/dest/cmds/l1/bridge_erc20.d.ts +2 -2
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +3 -2
- package/dest/cmds/l1/create_l1_account.d.ts +1 -1
- 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.js → deploy_l1_contracts_cmd.js} +42 -7
- package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -4
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +5 -5
- package/dest/cmds/l1/get_l1_addresses.d.ts +2 -2
- package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
- package/dest/cmds/l1/get_l1_addresses.js +5 -2
- package/dest/cmds/l1/get_l1_balance.d.ts +1 -1
- package/dest/cmds/l1/get_l1_balance.js +4 -2
- package/dest/cmds/l1/governance_utils.d.ts +5 -5
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.js +3 -1
- package/dest/cmds/l1/index.d.ts +1 -2
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +22 -36
- package/dest/cmds/l1/prover_stats.d.ts +1 -1
- package/dest/cmds/l1/prover_stats.d.ts.map +1 -1
- package/dest/cmds/l1/prover_stats.js +32 -30
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts +2 -2
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -1
- package/dest/cmds/l1/trigger_seed_snapshot.js +2 -1
- package/dest/cmds/l1/update_l1_validators.d.ts +10 -5
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +74 -9
- package/dest/cmds/misc/compute_selector.d.ts +1 -1
- package/dest/cmds/misc/example_contracts.d.ts +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
- package/dest/cmds/misc/generate_p2p_private_key.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +2 -2
- package/dest/cmds/misc/generate_secret_key.d.ts +2 -2
- package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_key.js +1 -1
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +1 -1
- package/dest/cmds/misc/index.d.ts +1 -1
- package/dest/cmds/misc/index.d.ts.map +1 -1
- package/dest/cmds/misc/index.js +1 -1
- package/dest/cmds/misc/update/common.d.ts +1 -1
- package/dest/cmds/misc/update/github.d.ts +1 -1
- package/dest/cmds/misc/update/noir.d.ts +1 -1
- package/dest/cmds/misc/update/npm.d.ts +1 -1
- package/dest/cmds/misc/update/npm.js +1 -1
- package/dest/cmds/misc/update/utils.d.ts +1 -1
- package/dest/cmds/misc/update.d.ts +1 -1
- 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/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 +32 -0
- package/dest/cmds/validator_keys/new.d.ts +29 -0
- package/dest/cmds/validator_keys/new.d.ts.map +1 -0
- package/dest/cmds/validator_keys/new.js +134 -0
- package/dest/cmds/validator_keys/shared.d.ts +68 -0
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
- package/dest/cmds/validator_keys/shared.js +274 -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 +25 -0
- package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
- package/dest/cmds/validator_keys/utils.js +52 -0
- package/dest/config/cached_fetch.d.ts +18 -0
- package/dest/config/cached_fetch.d.ts.map +1 -0
- package/dest/config/cached_fetch.js +54 -0
- package/dest/config/chain_l2_config.d.ts +41 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +524 -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/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 +115 -0
- package/dest/utils/aztec.d.ts +8 -20
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +22 -67
- package/dest/utils/commands.d.ts +21 -12
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +38 -11
- package/dest/utils/encoding.d.ts +1 -1
- package/dest/utils/encoding.js +1 -1
- package/dest/utils/github.d.ts +1 -1
- package/dest/utils/index.d.ts +1 -1
- package/dest/utils/inspect.d.ts +5 -11
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +13 -95
- package/dest/utils/setup_contracts.d.ts +2 -4
- package/dest/utils/setup_contracts.d.ts.map +1 -1
- package/dest/utils/setup_contracts.js +2 -22
- package/package.json +43 -28
- 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/{pxe → aztec_node}/get_logs.ts +11 -9
- package/src/cmds/{pxe → aztec_node}/get_node_info.ts +5 -16
- package/src/cmds/aztec_node/index.ts +87 -0
- package/src/cmds/contracts/inspect_contract.ts +4 -11
- package/src/cmds/infrastructure/index.ts +7 -18
- package/src/cmds/infrastructure/sequencers.ts +13 -11
- package/src/cmds/infrastructure/setup_l2_contract.ts +13 -30
- package/src/cmds/l1/advance_epoch.ts +6 -5
- package/src/cmds/l1/assume_proven_through.ts +10 -6
- package/src/cmds/l1/bridge_erc20.ts +5 -2
- package/src/cmds/l1/{deploy_l1_contracts.ts → deploy_l1_contracts_cmd.ts} +44 -24
- package/src/cmds/l1/deploy_new_rollup.ts +6 -9
- package/src/cmds/l1/get_l1_addresses.ts +5 -3
- package/src/cmds/l1/get_l1_balance.ts +2 -2
- package/src/cmds/l1/governance_utils.ts +3 -8
- package/src/cmds/l1/index.ts +28 -66
- package/src/cmds/l1/prover_stats.ts +42 -31
- package/src/cmds/l1/trigger_seed_snapshot.ts +2 -1
- package/src/cmds/l1/update_l1_validators.ts +88 -18
- package/src/cmds/misc/generate_secret_and_hash.ts +2 -2
- package/src/cmds/misc/generate_secret_key.ts +1 -1
- package/src/cmds/misc/index.ts +1 -1
- package/src/cmds/misc/update/npm.ts +1 -1
- package/src/cmds/validator_keys/add.ts +123 -0
- package/src/cmds/validator_keys/generate_bls_keypair.ts +34 -0
- package/src/cmds/validator_keys/index.ts +142 -0
- package/src/cmds/validator_keys/new.ts +207 -0
- package/src/cmds/validator_keys/shared.ts +326 -0
- package/src/cmds/validator_keys/staker.ts +301 -0
- package/src/cmds/validator_keys/utils.ts +81 -0
- package/src/config/cached_fetch.ts +67 -0
- package/src/config/chain_l2_config.ts +694 -0
- package/src/config/enrich_env.ts +15 -0
- package/src/config/get_l1_config.ts +31 -0
- package/src/config/index.ts +4 -0
- package/src/config/network_config.ts +147 -0
- package/src/utils/aztec.ts +27 -118
- package/src/utils/commands.ts +52 -15
- package/src/utils/encoding.ts +1 -1
- package/src/utils/inspect.ts +19 -111
- package/src/utils/setup_contracts.ts +4 -43
- package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
- package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
- package/dest/cmds/devnet/bootstrap_network.js +0 -216
- package/dest/cmds/devnet/faucet.d.ts +0 -4
- package/dest/cmds/devnet/faucet.d.ts.map +0 -1
- package/dest/cmds/devnet/faucet.js +0 -26
- package/dest/cmds/devnet/index.d.ts +0 -4
- package/dest/cmds/devnet/index.d.ts.map +0 -1
- package/dest/cmds/devnet/index.js +0 -14
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +0 -4
- package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/cmds/pxe/add_contract.d.ts +0 -5
- package/dest/cmds/pxe/add_contract.d.ts.map +0 -1
- package/dest/cmds/pxe/add_contract.js +0 -29
- package/dest/cmds/pxe/block_number.d.ts +0 -3
- package/dest/cmds/pxe/block_number.d.ts.map +0 -1
- package/dest/cmds/pxe/block_number.js +0 -10
- package/dest/cmds/pxe/get_account.d.ts +0 -4
- package/dest/cmds/pxe/get_account.d.ts.map +0 -1
- package/dest/cmds/pxe/get_account.js +0 -10
- package/dest/cmds/pxe/get_accounts.d.ts +0 -3
- package/dest/cmds/pxe/get_accounts.d.ts.map +0 -1
- package/dest/cmds/pxe/get_accounts.js +0 -25
- package/dest/cmds/pxe/get_block.d.ts +0 -3
- package/dest/cmds/pxe/get_block.d.ts.map +0 -1
- package/dest/cmds/pxe/get_block.js +0 -9
- package/dest/cmds/pxe/get_contract_data.d.ts +0 -4
- package/dest/cmds/pxe/get_contract_data.d.ts.map +0 -1
- package/dest/cmds/pxe/get_contract_data.js +0 -31
- package/dest/cmds/pxe/get_current_base_fee.d.ts +0 -3
- package/dest/cmds/pxe/get_current_base_fee.d.ts.map +0 -1
- package/dest/cmds/pxe/get_current_base_fee.js +0 -7
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +0 -4
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +0 -1
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +0 -11
- package/dest/cmds/pxe/get_logs.d.ts +0 -4
- package/dest/cmds/pxe/get_logs.d.ts.map +0 -1
- package/dest/cmds/pxe/get_node_info.d.ts +0 -3
- package/dest/cmds/pxe/get_node_info.d.ts.map +0 -1
- package/dest/cmds/pxe/get_pxe_info.d.ts +0 -3
- package/dest/cmds/pxe/get_pxe_info.d.ts.map +0 -1
- package/dest/cmds/pxe/get_pxe_info.js +0 -11
- package/dest/cmds/pxe/index.d.ts +0 -4
- package/dest/cmds/pxe/index.d.ts.map +0 -1
- package/dest/cmds/pxe/index.js +0 -55
- package/src/cmds/devnet/bootstrap_network.ts +0 -321
- package/src/cmds/devnet/faucet.ts +0 -33
- package/src/cmds/devnet/index.ts +0 -60
- package/src/cmds/pxe/add_contract.ts +0 -41
- package/src/cmds/pxe/block_number.ts +0 -9
- package/src/cmds/pxe/get_account.ts +0 -16
- package/src/cmds/pxe/get_accounts.ts +0 -35
- package/src/cmds/pxe/get_block.ts +0 -10
- package/src/cmds/pxe/get_contract_data.ts +0 -51
- package/src/cmds/pxe/get_current_base_fee.ts +0 -9
- package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +0 -25
- package/src/cmds/pxe/get_pxe_info.ts +0 -13
- package/src/cmds/pxe/index.ts +0 -170
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { EnvVar } from '@aztec/foundation/config';
|
|
3
|
+
|
|
4
|
+
export function enrichVar(envVar: EnvVar, value: string | undefined) {
|
|
5
|
+
// Don't override
|
|
6
|
+
if (process.env[envVar] || value === undefined) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
process.env[envVar] = value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function enrichEthAddressVar(envVar: EnvVar, value: string) {
|
|
13
|
+
// EthAddress doesn't like being given empty strings
|
|
14
|
+
enrichVar(envVar, value || EthAddress.ZERO.toString());
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
2
|
+
import { RegistryContract } from '@aztec/ethereum/contracts';
|
|
3
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
|
+
import { getL1ContractsConfig } from '@aztec/ethereum/queries';
|
|
5
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
|
|
7
|
+
export async function getL1Config(
|
|
8
|
+
registryAddress: EthAddress,
|
|
9
|
+
l1RpcUrls: string[],
|
|
10
|
+
l1ChainId: number,
|
|
11
|
+
rollupVersion: number | 'canonical' = 'canonical',
|
|
12
|
+
): Promise<{ addresses: L1ContractAddresses; config: Awaited<ReturnType<typeof getL1ContractsConfig>> }> {
|
|
13
|
+
const publicClient = getPublicClient({ l1RpcUrls, l1ChainId });
|
|
14
|
+
const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress, rollupVersion);
|
|
15
|
+
|
|
16
|
+
const config = await getL1ContractsConfig(publicClient, addresses);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
addresses,
|
|
20
|
+
config,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function getL1RollupAddressFromEnv(l1RpcUrls: string[], l1ChainId: number) {
|
|
25
|
+
const registryAddress = process.env.REGISTRY_CONTRACT_ADDRESS;
|
|
26
|
+
if (!registryAddress || !EthAddress.isAddress(registryAddress)) {
|
|
27
|
+
throw new Error(`Failed to extract registry address`);
|
|
28
|
+
}
|
|
29
|
+
const { addresses } = await getL1Config(EthAddress.fromString(registryAddress), l1RpcUrls, l1ChainId);
|
|
30
|
+
return addresses.rollupAddress;
|
|
31
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { type NetworkConfig, NetworkConfigMapSchema, type NetworkNames } from '@aztec/foundation/config';
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
import { cachedFetch } from './cached_fetch.js';
|
|
7
|
+
import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_CONFIG_URL =
|
|
10
|
+
'https://raw.githubusercontent.com/AztecProtocol/networks/refs/heads/main/network_config.json';
|
|
11
|
+
const FALLBACK_CONFIG_URL = 'https://metadata.aztec.network/network_config.json';
|
|
12
|
+
const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Fetches remote network configuration from GitHub with caching support.
|
|
16
|
+
* Uses the reusable cachedFetch utility. Falls back to metadata.aztec.network if the default URL fails.
|
|
17
|
+
*
|
|
18
|
+
* @param networkName - The network name to fetch config for
|
|
19
|
+
* @param cacheDir - Optional cache directory for storing fetched config
|
|
20
|
+
* @returns Remote configuration for the specified network, or undefined if network not found in config
|
|
21
|
+
* @throws Error if both primary and fallback URLs fail to fetch
|
|
22
|
+
*/
|
|
23
|
+
export async function getNetworkConfig(
|
|
24
|
+
networkName: NetworkNames,
|
|
25
|
+
cacheDir?: string,
|
|
26
|
+
): Promise<NetworkConfig | undefined> {
|
|
27
|
+
// Try with the primary URL (env var or default)
|
|
28
|
+
const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
|
|
29
|
+
|
|
30
|
+
let primaryError: Error | undefined;
|
|
31
|
+
let config: NetworkConfig | undefined;
|
|
32
|
+
|
|
33
|
+
// First try the primary config location
|
|
34
|
+
try {
|
|
35
|
+
config = await fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
primaryError = error as Error;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// If primary fails and we were using the default URL, try the fallback
|
|
41
|
+
if (!config && configLocation === DEFAULT_CONFIG_URL) {
|
|
42
|
+
try {
|
|
43
|
+
config = await fetchNetworkConfigFromUrl(FALLBACK_CONFIG_URL, networkName, cacheDir);
|
|
44
|
+
} catch {
|
|
45
|
+
// Both failed - throw the primary error
|
|
46
|
+
if (primaryError) {
|
|
47
|
+
throw primaryError;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} else if (primaryError) {
|
|
51
|
+
// Primary failed and no fallback to try
|
|
52
|
+
throw primaryError;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Helper function to fetch network config from a specific URL.
|
|
60
|
+
* @param configLocation - The URL or file path to fetch from
|
|
61
|
+
* @param networkName - The network name to fetch config for
|
|
62
|
+
* @param cacheDir - Optional cache directory for storing fetched config
|
|
63
|
+
* @returns Remote configuration for the specified network, or undefined if network not found in config, or undefined if URL invalid
|
|
64
|
+
* @throws Error if fetch/parse fails
|
|
65
|
+
*/
|
|
66
|
+
async function fetchNetworkConfigFromUrl(
|
|
67
|
+
configLocation: string,
|
|
68
|
+
networkName: NetworkNames,
|
|
69
|
+
cacheDir?: string,
|
|
70
|
+
): Promise<NetworkConfig | undefined> {
|
|
71
|
+
let url: URL | undefined;
|
|
72
|
+
try {
|
|
73
|
+
if (configLocation.includes('://')) {
|
|
74
|
+
url = new URL(configLocation);
|
|
75
|
+
} else {
|
|
76
|
+
url = new URL(`file://${configLocation}`);
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
/* no-op */
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!url) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let rawConfig: any;
|
|
87
|
+
|
|
88
|
+
if (url.protocol === 'http:' || url.protocol === 'https:') {
|
|
89
|
+
rawConfig = await cachedFetch(url.href, {
|
|
90
|
+
cacheDurationMs: NETWORK_CONFIG_CACHE_DURATION_MS,
|
|
91
|
+
cacheFile: cacheDir ? join(cacheDir, networkName, 'network_config.json') : undefined,
|
|
92
|
+
});
|
|
93
|
+
} else if (url.protocol === 'file:') {
|
|
94
|
+
rawConfig = JSON.parse(await readFile(url.pathname, 'utf-8'));
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error('Unsupported Aztec network config protocol: ' + url.href);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!rawConfig) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const networkConfigMap = NetworkConfigMapSchema.parse(rawConfig);
|
|
104
|
+
if (networkName in networkConfigMap) {
|
|
105
|
+
return networkConfigMap[networkName];
|
|
106
|
+
} else {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Enriches environment variables with remote network configuration.
|
|
113
|
+
* This function is called before node config initialization to set env vars
|
|
114
|
+
* from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
|
|
115
|
+
*
|
|
116
|
+
* @param networkName - The network name to fetch remote config for
|
|
117
|
+
* @throws Error if network config fetch fails (network errors, parse errors, etc.)
|
|
118
|
+
* Does not throw if the network simply doesn't exist in the config - just returns without enriching
|
|
119
|
+
*/
|
|
120
|
+
export async function enrichEnvironmentWithNetworkConfig(networkName: NetworkNames) {
|
|
121
|
+
if (networkName === 'local') {
|
|
122
|
+
return; // No remote config for local development
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const cacheDir = process.env.DATA_DIRECTORY ? join(process.env.DATA_DIRECTORY, 'cache') : undefined;
|
|
126
|
+
const networkConfig = await getNetworkConfig(networkName, cacheDir);
|
|
127
|
+
|
|
128
|
+
if (!networkConfig) {
|
|
129
|
+
return; // Network not found in config, continue without enriching
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
enrichVar('BOOTSTRAP_NODES', networkConfig.bootnodes.join(','));
|
|
133
|
+
enrichVar('L1_CHAIN_ID', String(networkConfig.l1ChainId));
|
|
134
|
+
enrichVar('SYNC_SNAPSHOTS_URLS', networkConfig.snapshots.join(','));
|
|
135
|
+
|
|
136
|
+
enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', networkConfig.registryAddress.toString());
|
|
137
|
+
if (networkConfig.feeAssetHandlerAddress) {
|
|
138
|
+
enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', networkConfig.feeAssetHandlerAddress.toString());
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (networkConfig.blobFileStoreUrls?.length) {
|
|
142
|
+
enrichVar('BLOB_FILE_STORE_URLS', networkConfig.blobFileStoreUrls.join(','));
|
|
143
|
+
}
|
|
144
|
+
if (networkConfig.blockDurationMs !== undefined) {
|
|
145
|
+
enrichVar('SEQ_BLOCK_DURATION_MS', String(networkConfig.blockDurationMs));
|
|
146
|
+
}
|
|
147
|
+
}
|
package/src/utils/aztec.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { EthAddress, type PXE } from '@aztec/aztec.js';
|
|
2
1
|
import {
|
|
3
2
|
type ContractArtifact,
|
|
4
3
|
type FunctionAbi,
|
|
@@ -6,24 +5,24 @@ import {
|
|
|
6
5
|
getAllFunctionAbis,
|
|
7
6
|
loadContractArtifact,
|
|
8
7
|
} from '@aztec/aztec.js/abi';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
RollupContract,
|
|
14
|
-
} from '@aztec/ethereum';
|
|
8
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
9
|
+
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
10
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
11
|
+
import type { Operator } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
15
12
|
import { SecretValue } from '@aztec/foundation/config';
|
|
16
|
-
import { Fr } from '@aztec/foundation/
|
|
17
|
-
import type
|
|
13
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
|
+
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
18
15
|
import type { NoirPackageConfig } from '@aztec/foundation/noir';
|
|
19
|
-
import {
|
|
16
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
17
|
|
|
21
18
|
import TOML from '@iarna/toml';
|
|
22
19
|
import { readFile } from 'fs/promises';
|
|
23
|
-
import {
|
|
20
|
+
import type { HDAccount, Hex, PrivateKeyAccount } from 'viem';
|
|
24
21
|
|
|
25
22
|
import { encodeArgs } from './encoding.js';
|
|
26
23
|
|
|
24
|
+
const logger = createLogger('cli:utils:aztec');
|
|
25
|
+
|
|
27
26
|
/**
|
|
28
27
|
* Helper to get an ABI function or throw error if it doesn't exist.
|
|
29
28
|
* @param artifact - Contract's build artifact in JSON format.
|
|
@@ -38,86 +37,32 @@ export function getFunctionAbi(artifact: ContractArtifact, fnName: string): Func
|
|
|
38
37
|
return fn;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
/**
|
|
42
|
-
* Function to execute the 'deployRollupContracts' command.
|
|
43
|
-
* @param rpcUrls - The RPC URL of the ethereum node.
|
|
44
|
-
* @param chainId - The chain ID of the L1 host.
|
|
45
|
-
* @param privateKey - The private key to be used in contract deployment.
|
|
46
|
-
* @param mnemonic - The mnemonic to be used in contract deployment.
|
|
47
|
-
*/
|
|
48
|
-
export async function deployAztecContracts(
|
|
49
|
-
rpcUrls: string[],
|
|
50
|
-
chainId: number,
|
|
51
|
-
privateKey: string | undefined,
|
|
52
|
-
mnemonic: string,
|
|
53
|
-
mnemonicIndex: number,
|
|
54
|
-
salt: number | undefined,
|
|
55
|
-
initialValidators: Operator[],
|
|
56
|
-
genesisArchiveRoot: Fr,
|
|
57
|
-
feeJuicePortalInitialBalance: bigint,
|
|
58
|
-
acceleratedTestDeployments: boolean,
|
|
59
|
-
config: L1ContractsConfig,
|
|
60
|
-
realVerifier: boolean,
|
|
61
|
-
createVerificationJson: string | false,
|
|
62
|
-
debugLogger: Logger,
|
|
63
|
-
): Promise<DeployL1ContractsReturnType> {
|
|
64
|
-
const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum');
|
|
65
|
-
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
66
|
-
|
|
67
|
-
const account = !privateKey
|
|
68
|
-
? mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex })
|
|
69
|
-
: privateKeyToAccount(addLeadingHex(privateKey));
|
|
70
|
-
const chain = createEthereumChain(rpcUrls, chainId);
|
|
71
|
-
|
|
72
|
-
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
73
|
-
|
|
74
|
-
const result = await deployL1Contracts(
|
|
75
|
-
chain.rpcUrls,
|
|
76
|
-
account,
|
|
77
|
-
chain.chainInfo,
|
|
78
|
-
debugLogger,
|
|
79
|
-
{
|
|
80
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
81
|
-
protocolContractTreeRoot,
|
|
82
|
-
genesisArchiveRoot,
|
|
83
|
-
salt,
|
|
84
|
-
initialValidators,
|
|
85
|
-
acceleratedTestDeployments,
|
|
86
|
-
feeJuicePortalInitialBalance,
|
|
87
|
-
realVerifier,
|
|
88
|
-
...config,
|
|
89
|
-
},
|
|
90
|
-
config,
|
|
91
|
-
createVerificationJson,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
40
|
export async function deployNewRollupContracts(
|
|
98
41
|
registryAddress: EthAddress,
|
|
99
42
|
rpcUrls: string[],
|
|
100
|
-
chainId: number,
|
|
101
43
|
privateKey: string | undefined,
|
|
44
|
+
chainId: number,
|
|
102
45
|
mnemonic: string,
|
|
103
46
|
mnemonicIndex: number,
|
|
104
|
-
salt: number | undefined,
|
|
105
47
|
initialValidators: Operator[],
|
|
106
48
|
genesisArchiveRoot: Fr,
|
|
107
49
|
feeJuicePortalInitialBalance: bigint,
|
|
108
50
|
config: L1ContractsConfig,
|
|
109
51
|
realVerifier: boolean,
|
|
110
|
-
logger: Logger,
|
|
111
52
|
): Promise<{ rollup: RollupContract; slashFactoryAddress: EthAddress }> {
|
|
112
|
-
const {
|
|
53
|
+
const { deployRollupForUpgrade } = await import('@aztec/ethereum/deploy-aztec-l1-contracts');
|
|
113
54
|
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
114
55
|
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
115
56
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
57
|
+
let account: HDAccount | PrivateKeyAccount;
|
|
58
|
+
if (privateKey) {
|
|
59
|
+
account = privateKeyToAccount(addLeadingHex(privateKey));
|
|
60
|
+
} else {
|
|
61
|
+
account = mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex });
|
|
62
|
+
const privateKeyBuf = account.getHdKey().privateKey;
|
|
63
|
+
const privateKeyHex = Buffer.from(privateKeyBuf!).toString('hex');
|
|
64
|
+
privateKey = `0x${privateKeyHex}`;
|
|
65
|
+
}
|
|
121
66
|
|
|
122
67
|
if (!initialValidators || initialValidators.length === 0) {
|
|
123
68
|
// initialize the new rollup with Amin's validator address.
|
|
@@ -136,23 +81,22 @@ export async function deployNewRollupContracts(
|
|
|
136
81
|
}
|
|
137
82
|
|
|
138
83
|
const { rollup, slashFactoryAddress } = await deployRollupForUpgrade(
|
|
139
|
-
|
|
84
|
+
privateKey as Hex,
|
|
85
|
+
rpcUrls[0],
|
|
86
|
+
chainId,
|
|
87
|
+
registryAddress,
|
|
140
88
|
{
|
|
141
|
-
salt,
|
|
142
89
|
vkTreeRoot: getVKTreeRoot(),
|
|
143
|
-
|
|
90
|
+
protocolContractsHash,
|
|
144
91
|
genesisArchiveRoot,
|
|
145
92
|
initialValidators,
|
|
146
93
|
feeJuicePortalInitialBalance,
|
|
147
94
|
realVerifier,
|
|
148
95
|
...config,
|
|
149
96
|
},
|
|
150
|
-
registryAddress,
|
|
151
|
-
logger,
|
|
152
|
-
config,
|
|
153
97
|
);
|
|
154
98
|
|
|
155
|
-
return { rollup, slashFactoryAddress };
|
|
99
|
+
return { rollup, slashFactoryAddress: EthAddress.fromString(slashFactoryAddress!) };
|
|
156
100
|
}
|
|
157
101
|
|
|
158
102
|
/**
|
|
@@ -258,38 +202,3 @@ export function prettyPrintNargoToml(config: NoirPackageConfig): string {
|
|
|
258
202
|
|
|
259
203
|
return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n';
|
|
260
204
|
}
|
|
261
|
-
|
|
262
|
-
/** Mismatch between server and client versions. */
|
|
263
|
-
class VersionMismatchError extends Error {}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Checks that Private eXecution Environment (PXE) version matches the expected one by this CLI. Throws if not.
|
|
267
|
-
* @param pxe - PXE client.
|
|
268
|
-
* @param expectedVersionRange - Expected version by CLI.
|
|
269
|
-
*/
|
|
270
|
-
export async function checkServerVersion(pxe: PXE, expectedVersionRange: string) {
|
|
271
|
-
const serverName = 'Aztec Node';
|
|
272
|
-
const { nodeVersion } = await pxe.getNodeInfo();
|
|
273
|
-
if (!nodeVersion) {
|
|
274
|
-
throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`);
|
|
275
|
-
}
|
|
276
|
-
if (!nodeVersion || !valid(nodeVersion)) {
|
|
277
|
-
throw new VersionMismatchError(
|
|
278
|
-
`Missing or invalid version identifier for ${serverName} (${nodeVersion ?? 'empty'}).`,
|
|
279
|
-
);
|
|
280
|
-
} else if (!satisfies(nodeVersion, expectedVersionRange)) {
|
|
281
|
-
if (gtr(nodeVersion, expectedVersionRange)) {
|
|
282
|
-
throw new VersionMismatchError(
|
|
283
|
-
`${serverName} is running version ${nodeVersion} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`,
|
|
284
|
-
);
|
|
285
|
-
} else if (ltr(nodeVersion, expectedVersionRange)) {
|
|
286
|
-
throw new VersionMismatchError(
|
|
287
|
-
`${serverName} is running version ${nodeVersion} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`,
|
|
288
|
-
);
|
|
289
|
-
} else {
|
|
290
|
-
throw new VersionMismatchError(
|
|
291
|
-
`${serverName} is running version ${nodeVersion} which does not match the expected by this CLI (${expectedVersionRange}).`,
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
package/src/utils/commands.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { EthAddress } from '@aztec/aztec.js/eth_address';
|
|
4
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
-
import { LogId } from '@aztec/aztec.js/log_id';
|
|
6
|
-
import { TxHash } from '@aztec/aztec.js/tx_hash';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
|
-
import type { PXE } from '@aztec/
|
|
4
|
+
import type { PXE } from '@aztec/pxe/server';
|
|
5
|
+
import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
|
|
6
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
7
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
8
|
+
import { LogId } from '@aztec/stdlib/logs/log-id';
|
|
9
|
+
import { TxHash } from '@aztec/stdlib/tx/tx-hash';
|
|
10
10
|
|
|
11
11
|
import { type Command, CommanderError, InvalidArgumentError, Option } from 'commander';
|
|
12
12
|
import { lookup } from 'dns/promises';
|
|
@@ -29,14 +29,13 @@ export function addOptions(program: Command, options: Option[]) {
|
|
|
29
29
|
return program;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export const
|
|
33
|
-
new Option('-
|
|
34
|
-
.env('
|
|
32
|
+
export const makeNodeOption = (mandatory: boolean) =>
|
|
33
|
+
new Option('-n, --node-url <string>', 'URL of the Aztec node')
|
|
34
|
+
.env('AZTEC_NODE_URL')
|
|
35
35
|
.default(`http://${LOCALHOST}:8080`)
|
|
36
|
-
.conflicts('remote-pxe')
|
|
37
36
|
.makeOptionMandatory(mandatory);
|
|
38
37
|
|
|
39
|
-
export const
|
|
38
|
+
export const nodeOption = makeNodeOption(true);
|
|
40
39
|
|
|
41
40
|
export const l1ChainIdOption = new Option('-c, --l1-chain-id <number>', 'Chain ID of the ethereum host')
|
|
42
41
|
.env('L1_CHAIN_ID')
|
|
@@ -114,6 +113,34 @@ export async function getTxSender(pxe: PXE, _from?: string) {
|
|
|
114
113
|
return from;
|
|
115
114
|
}
|
|
116
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Parses and validates a hex string. Removes leading 0x if present, checks for hex validity,
|
|
118
|
+
* and enforces an optional minimum length.
|
|
119
|
+
* @param hex - The hex string to validate.
|
|
120
|
+
* @param minLen - Optional minimum length (in hex characters, after stripping '0x').
|
|
121
|
+
* @returns The normalized hex string (without leading 0x).
|
|
122
|
+
* @throws InvalidArgumentError if the string is not valid hex or does not meet the minimum length.
|
|
123
|
+
*/
|
|
124
|
+
// minLen is now interpreted as the minimum number of bytes (2 hex characters per byte)
|
|
125
|
+
export function parseHex(hex: string, minLen?: number): `0x${string}` {
|
|
126
|
+
const normalized = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
127
|
+
|
|
128
|
+
if (!/^[0-9a-fA-F]*$/.test(normalized)) {
|
|
129
|
+
throw new InvalidArgumentError('Invalid hex string');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (minLen !== undefined) {
|
|
133
|
+
const minHexLen = minLen * 2;
|
|
134
|
+
if (normalized.length < minHexLen) {
|
|
135
|
+
throw new InvalidArgumentError(
|
|
136
|
+
`Hex string is too short (length ${normalized.length}), minimum byte length is ${minLen} (hex chars: ${minHexLen})`,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return `0x${normalized}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
117
144
|
/**
|
|
118
145
|
* Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged.
|
|
119
146
|
* @param hex - A hex string
|
|
@@ -168,7 +195,7 @@ export function parseAztecAddress(address: string): AztecAddress {
|
|
|
168
195
|
try {
|
|
169
196
|
return AztecAddress.fromString(address);
|
|
170
197
|
} catch {
|
|
171
|
-
throw new InvalidArgumentError(`Invalid address: ${address}`);
|
|
198
|
+
throw new InvalidArgumentError(`Invalid Aztec address: ${address}`);
|
|
172
199
|
}
|
|
173
200
|
}
|
|
174
201
|
|
|
@@ -182,7 +209,7 @@ export function parseEthereumAddress(address: string): EthAddress {
|
|
|
182
209
|
try {
|
|
183
210
|
return EthAddress.fromString(address);
|
|
184
211
|
} catch {
|
|
185
|
-
throw new InvalidArgumentError(`Invalid
|
|
212
|
+
throw new InvalidArgumentError(`Invalid Ethereumaddress: ${address}`);
|
|
186
213
|
}
|
|
187
214
|
}
|
|
188
215
|
|
|
@@ -236,7 +263,11 @@ export function parseOptionalSelector(selector: string): FunctionSelector | unde
|
|
|
236
263
|
* @returns The parsed integer, or undefined if the input string is falsy.
|
|
237
264
|
* @throws If the input is not a valid integer.
|
|
238
265
|
*/
|
|
239
|
-
export function parseOptionalInteger(
|
|
266
|
+
export function parseOptionalInteger(
|
|
267
|
+
value: string,
|
|
268
|
+
min: number = Number.MIN_SAFE_INTEGER,
|
|
269
|
+
max: number = Number.MAX_SAFE_INTEGER,
|
|
270
|
+
): number | undefined {
|
|
240
271
|
if (!value) {
|
|
241
272
|
return undefined;
|
|
242
273
|
}
|
|
@@ -244,6 +275,12 @@ export function parseOptionalInteger(value: string): number | undefined {
|
|
|
244
275
|
if (!Number.isInteger(parsed)) {
|
|
245
276
|
throw new InvalidArgumentError('Invalid integer.');
|
|
246
277
|
}
|
|
278
|
+
if (parsed < min) {
|
|
279
|
+
throw new InvalidArgumentError(`Value must be greater than ${min}.`);
|
|
280
|
+
}
|
|
281
|
+
if (parsed > max) {
|
|
282
|
+
throw new InvalidArgumentError(`Value must be less than ${max}.`);
|
|
283
|
+
}
|
|
247
284
|
return parsed;
|
|
248
285
|
}
|
|
249
286
|
|
package/src/utils/encoding.ts
CHANGED