@aztec/cli 0.0.0-test.1 → 0.0.1-commit.017a351
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 +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/{pxe → aztec_node}/get_node_info.js +13 -16
- 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/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 +13 -15
- 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 +8 -10
- package/dest/cmds/infrastructure/sequencers.d.ts +5 -6
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +38 -18
- 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 +15 -23
- 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 +8 -6
- package/dest/cmds/l1/assume_proven_through.d.ts +3 -2
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +10 -10
- package/dest/cmds/l1/bridge_erc20.d.ts +3 -3
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +6 -5
- 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 +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_cmd.js +80 -0
- package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -3
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +16 -9
- 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 +19 -17
- package/dest/cmds/l1/index.d.ts +1 -1
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +41 -44
- 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 +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 +21 -6
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +198 -104
- 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 +2 -2
- package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.js +2 -2
- package/dest/cmds/misc/generate_p2p_private_key.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +2 -2
- package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +4 -4
- 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 +3 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts.map +1 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.js +4 -0
- 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 +8 -4
- package/dest/cmds/misc/update/common.d.ts +1 -1
- package/dest/cmds/misc/update/github.d.ts +1 -2
- package/dest/cmds/misc/update/github.d.ts.map +1 -1
- package/dest/cmds/misc/update/github.js +0 -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/misc/update.d.ts.map +1 -1
- package/dest/cmds/misc/update.js +2 -3
- 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 +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 +14 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +47 -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 +221 -0
- package/dest/config/generated/networks.d.ts.map +1 -0
- package/dest/config/generated/networks.js +222 -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 +14 -26
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +54 -71
- package/dest/utils/commands.d.ts +34 -17
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +61 -24
- package/dest/utils/encoding.d.ts +1 -1
- package/dest/utils/encoding.js +2 -2
- package/dest/utils/github.d.ts +1 -2
- package/dest/utils/github.d.ts.map +1 -1
- package/dest/utils/github.js +0 -1
- package/dest/utils/index.d.ts +2 -1
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -0
- package/dest/utils/inspect.d.ts +5 -11
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +30 -117
- 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 +61 -37
- 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/{pxe → aztec_node}/get_node_info.ts +15 -25
- package/src/cmds/aztec_node/index.ts +92 -0
- package/src/cmds/contracts/inspect_contract.ts +20 -17
- package/src/cmds/infrastructure/index.ts +8 -11
- package/src/cmds/infrastructure/sequencers.ts +41 -22
- package/src/cmds/infrastructure/setup_l2_contract.ts +18 -25
- package/src/cmds/l1/advance_epoch.ts +7 -5
- package/src/cmds/l1/assume_proven_through.ts +11 -10
- package/src/cmds/l1/bridge_erc20.ts +8 -4
- package/src/cmds/l1/compute_genesis_values.ts +29 -0
- package/src/cmds/l1/deploy_l1_contracts_cmd.ts +106 -0
- package/src/cmds/l1/deploy_new_rollup.ts +22 -15
- 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 +20 -24
- package/src/cmds/l1/index.ts +95 -113
- package/src/cmds/l1/prover_stats.ts +42 -31
- package/src/cmds/l1/trigger_seed_snapshot.ts +32 -0
- package/src/cmds/l1/update_l1_validators.ts +218 -98
- package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
- package/src/cmds/misc/generate_secret_and_hash.ts +4 -4
- package/src/cmds/misc/generate_secret_key.ts +1 -1
- package/src/cmds/misc/get_canonical_sponsored_fpc_address.ts +7 -0
- package/src/cmds/misc/index.ts +14 -5
- package/src/cmds/misc/update/github.ts +0 -1
- package/src/cmds/misc/update/npm.ts +1 -1
- package/src/cmds/misc/update.ts +1 -7
- 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 +155 -0
- package/src/config/chain_l2_config.ts +59 -0
- package/src/config/enrich_env.ts +15 -0
- package/src/config/generated/networks.ts +226 -0
- package/src/config/get_l1_config.ts +31 -0
- package/src/config/index.ts +4 -0
- package/src/config/network_config.ts +151 -0
- package/src/utils/aztec.ts +77 -129
- package/src/utils/commands.ts +78 -28
- package/src/utils/encoding.ts +2 -2
- package/src/utils/github.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/inspect.ts +33 -130
- package/src/utils/setup_contracts.ts +19 -0
- 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 -196
- 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/l1/deploy_l1_contracts.js +0 -29
- package/dest/cmds/l1/deploy_l1_verifier.d.ts +0 -5
- package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +0 -1
- package/dest/cmds/l1/deploy_l1_verifier.js +0 -54
- package/dest/cmds/misc/setup_contracts.d.ts +0 -7
- package/dest/cmds/misc/setup_contracts.d.ts.map +0 -1
- package/dest/cmds/misc/setup_contracts.js +0 -27
- 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_logs.js +0 -51
- 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 -318
- package/src/cmds/devnet/faucet.ts +0 -33
- package/src/cmds/devnet/index.ts +0 -60
- package/src/cmds/l1/deploy_l1_contracts.ts +0 -65
- package/src/cmds/l1/deploy_l1_verifier.ts +0 -105
- package/src/cmds/misc/setup_contracts.ts +0 -40
- 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_logs.ts +0 -66
- package/src/cmds/pxe/get_pxe_info.ts +0 -13
- package/src/cmds/pxe/index.ts +0 -170
package/src/utils/aztec.ts
CHANGED
|
@@ -1,125 +1,96 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ContractArtifact,
|
|
3
|
+
type FunctionAbi,
|
|
4
|
+
FunctionType,
|
|
5
|
+
getAllFunctionAbis,
|
|
6
|
+
loadContractArtifact,
|
|
7
|
+
} from '@aztec/aztec.js/abi';
|
|
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';
|
|
12
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
13
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
|
+
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
6
15
|
import type { NoirPackageConfig } from '@aztec/foundation/noir';
|
|
7
|
-
import {
|
|
8
|
-
import { FunctionType } from '@aztec/stdlib/abi';
|
|
16
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
9
17
|
|
|
10
18
|
import TOML from '@iarna/toml';
|
|
11
19
|
import { readFile } from 'fs/promises';
|
|
12
|
-
import {
|
|
20
|
+
import type { HDAccount, Hex, PrivateKeyAccount } from 'viem';
|
|
13
21
|
|
|
14
22
|
import { encodeArgs } from './encoding.js';
|
|
15
23
|
|
|
24
|
+
const logger = createLogger('cli:utils:aztec');
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
27
|
* Helper to get an ABI function or throw error if it doesn't exist.
|
|
18
28
|
* @param artifact - Contract's build artifact in JSON format.
|
|
19
29
|
* @param fnName - Function name to be found.
|
|
20
30
|
* @returns The function's ABI.
|
|
21
31
|
*/
|
|
22
|
-
export function
|
|
23
|
-
const fn = artifact.
|
|
32
|
+
export function getFunctionAbi(artifact: ContractArtifact, fnName: string): FunctionAbi {
|
|
33
|
+
const fn = getAllFunctionAbis(artifact).find(({ name }) => name === fnName);
|
|
24
34
|
if (!fn) {
|
|
25
35
|
throw Error(`Function ${fnName} not found in contract ABI.`);
|
|
26
36
|
}
|
|
27
37
|
return fn;
|
|
28
38
|
}
|
|
29
39
|
|
|
30
|
-
/**
|
|
31
|
-
* Function to execute the 'deployRollupContracts' command.
|
|
32
|
-
* @param rpcUrls - The RPC URL of the ethereum node.
|
|
33
|
-
* @param chainId - The chain ID of the L1 host.
|
|
34
|
-
* @param privateKey - The private key to be used in contract deployment.
|
|
35
|
-
* @param mnemonic - The mnemonic to be used in contract deployment.
|
|
36
|
-
*/
|
|
37
|
-
export async function deployAztecContracts(
|
|
38
|
-
rpcUrls: string[],
|
|
39
|
-
chainId: number,
|
|
40
|
-
privateKey: string | undefined,
|
|
41
|
-
mnemonic: string,
|
|
42
|
-
mnemonicIndex: number,
|
|
43
|
-
salt: number | undefined,
|
|
44
|
-
initialValidators: EthAddress[],
|
|
45
|
-
genesisArchiveRoot: Fr,
|
|
46
|
-
genesisBlockHash: Fr,
|
|
47
|
-
acceleratedTestDeployments: boolean,
|
|
48
|
-
config: L1ContractsConfig,
|
|
49
|
-
debugLogger: Logger,
|
|
50
|
-
): Promise<DeployL1ContractsReturnType> {
|
|
51
|
-
const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum');
|
|
52
|
-
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
53
|
-
|
|
54
|
-
const account = !privateKey
|
|
55
|
-
? mnemonicToAccount(mnemonic!, { addressIndex: mnemonicIndex })
|
|
56
|
-
: privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
|
|
57
|
-
const chain = createEthereumChain(rpcUrls, chainId);
|
|
58
|
-
|
|
59
|
-
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
60
|
-
|
|
61
|
-
return await deployL1Contracts(
|
|
62
|
-
chain.rpcUrls,
|
|
63
|
-
account,
|
|
64
|
-
chain.chainInfo,
|
|
65
|
-
debugLogger,
|
|
66
|
-
{
|
|
67
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
68
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
69
|
-
protocolContractTreeRoot,
|
|
70
|
-
genesisArchiveRoot,
|
|
71
|
-
genesisBlockHash,
|
|
72
|
-
salt,
|
|
73
|
-
initialValidators,
|
|
74
|
-
acceleratedTestDeployments,
|
|
75
|
-
...config,
|
|
76
|
-
},
|
|
77
|
-
config,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
40
|
export async function deployNewRollupContracts(
|
|
82
41
|
registryAddress: EthAddress,
|
|
83
42
|
rpcUrls: string[],
|
|
84
|
-
chainId: number,
|
|
85
43
|
privateKey: string | undefined,
|
|
44
|
+
chainId: number,
|
|
86
45
|
mnemonic: string,
|
|
87
46
|
mnemonicIndex: number,
|
|
88
|
-
|
|
89
|
-
initialValidators: EthAddress[],
|
|
47
|
+
initialValidators: Operator[],
|
|
90
48
|
genesisArchiveRoot: Fr,
|
|
91
|
-
|
|
49
|
+
feeJuicePortalInitialBalance: bigint,
|
|
92
50
|
config: L1ContractsConfig,
|
|
93
|
-
|
|
94
|
-
): Promise<{
|
|
95
|
-
const {
|
|
51
|
+
realVerifier: boolean,
|
|
52
|
+
): Promise<{ rollup: RollupContract }> {
|
|
53
|
+
const { deployRollupForUpgrade } = await import('@aztec/ethereum/deploy-aztec-l1-contracts');
|
|
96
54
|
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');
|
|
97
55
|
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
|
|
98
56
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!initialValidators || initialValidators.length === 0) {
|
|
68
|
+
// initialize the new rollup with Amin's validator address.
|
|
69
|
+
const aminAddressString = '0x3b218d0F26d15B36C715cB06c949210a0d630637';
|
|
70
|
+
const amin = EthAddress.fromString(aminAddressString);
|
|
71
|
+
|
|
72
|
+
initialValidators = [
|
|
73
|
+
{
|
|
74
|
+
attester: amin,
|
|
75
|
+
withdrawer: amin,
|
|
76
|
+
// No secrets here. The actual keys are not currently used.
|
|
77
|
+
bn254SecretKey: new SecretValue(Fr.fromHexString(aminAddressString).toBigInt()),
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
logger.info('Initializing new rollup with old attesters', { initialValidators });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { rollup } = await deployRollupForUpgrade(privateKey as Hex, rpcUrls[0], chainId, registryAddress, {
|
|
84
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
85
|
+
protocolContractsHash,
|
|
86
|
+
genesisArchiveRoot,
|
|
87
|
+
initialValidators,
|
|
88
|
+
feeJuicePortalInitialBalance,
|
|
89
|
+
realVerifier,
|
|
90
|
+
...config,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return { rollup };
|
|
123
94
|
}
|
|
124
95
|
|
|
125
96
|
/**
|
|
@@ -178,7 +149,7 @@ export async function getContractArtifact(fileDir: string, log: LogFn) {
|
|
|
178
149
|
*/
|
|
179
150
|
export async function prepTx(contractFile: string, functionName: string, _functionArgs: string[], log: LogFn) {
|
|
180
151
|
const contractArtifact = await getContractArtifact(contractFile, log);
|
|
181
|
-
const functionArtifact =
|
|
152
|
+
const functionArtifact = getFunctionAbi(contractArtifact, functionName);
|
|
182
153
|
const functionArgs = encodeArgs(_functionArgs, functionArtifact.parameters);
|
|
183
154
|
const isPrivate = functionArtifact.functionType === FunctionType.PRIVATE;
|
|
184
155
|
|
|
@@ -190,7 +161,7 @@ export async function prepTx(contractFile: string, functionName: string, _functi
|
|
|
190
161
|
* @param hex - A hex string
|
|
191
162
|
* @returns A new string with leading 0x removed
|
|
192
163
|
*/
|
|
193
|
-
export const stripLeadingHex = (hex: string) => {
|
|
164
|
+
export const stripLeadingHex = (hex: string): string => {
|
|
194
165
|
if (hex.length > 2 && hex.startsWith('0x')) {
|
|
195
166
|
return hex.substring(2);
|
|
196
167
|
}
|
|
@@ -198,6 +169,18 @@ export const stripLeadingHex = (hex: string) => {
|
|
|
198
169
|
};
|
|
199
170
|
|
|
200
171
|
/**
|
|
172
|
+
* Adds a leading 0x to a hex string. If a leading 0x is already present the string is returned unchanged.
|
|
173
|
+
* @param hex - A hex string
|
|
174
|
+
* @returns A new string with leading 0x added
|
|
175
|
+
*/
|
|
176
|
+
export const addLeadingHex = (hex: string): `0x${string}` => {
|
|
177
|
+
if (hex.length > 2 && hex.startsWith('0x')) {
|
|
178
|
+
return hex as `0x${string}`;
|
|
179
|
+
}
|
|
180
|
+
return `0x${hex}`;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/*
|
|
201
184
|
* Pretty prints Nargo.toml contents to a string
|
|
202
185
|
* @param config - Nargo.toml contents
|
|
203
186
|
* @returns The Nargo.toml contents as a string
|
|
@@ -213,38 +196,3 @@ export function prettyPrintNargoToml(config: NoirPackageConfig): string {
|
|
|
213
196
|
|
|
214
197
|
return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n';
|
|
215
198
|
}
|
|
216
|
-
|
|
217
|
-
/** Mismatch between server and client versions. */
|
|
218
|
-
class VersionMismatchError extends Error {}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Checks that Private eXecution Environment (PXE) version matches the expected one by this CLI. Throws if not.
|
|
222
|
-
* @param pxe - PXE client.
|
|
223
|
-
* @param expectedVersionRange - Expected version by CLI.
|
|
224
|
-
*/
|
|
225
|
-
export async function checkServerVersion(pxe: PXE, expectedVersionRange: string) {
|
|
226
|
-
const serverName = 'Aztec Node';
|
|
227
|
-
const { nodeVersion } = await pxe.getNodeInfo();
|
|
228
|
-
if (!nodeVersion) {
|
|
229
|
-
throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`);
|
|
230
|
-
}
|
|
231
|
-
if (!nodeVersion || !valid(nodeVersion)) {
|
|
232
|
-
throw new VersionMismatchError(
|
|
233
|
-
`Missing or invalid version identifier for ${serverName} (${nodeVersion ?? 'empty'}).`,
|
|
234
|
-
);
|
|
235
|
-
} else if (!satisfies(nodeVersion, expectedVersionRange)) {
|
|
236
|
-
if (gtr(nodeVersion, expectedVersionRange)) {
|
|
237
|
-
throw new VersionMismatchError(
|
|
238
|
-
`${serverName} is running version ${nodeVersion} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`,
|
|
239
|
-
);
|
|
240
|
-
} else if (ltr(nodeVersion, expectedVersionRange)) {
|
|
241
|
-
throw new VersionMismatchError(
|
|
242
|
-
`${serverName} is running version ${nodeVersion} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`,
|
|
243
|
-
);
|
|
244
|
-
} else {
|
|
245
|
-
throw new VersionMismatchError(
|
|
246
|
-
`${serverName} is running version ${nodeVersion} which does not match the expected by this CLI (${expectedVersionRange}).`,
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
package/src/utils/commands.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
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 { LogCursor, Tag } from '@aztec/stdlib/logs';
|
|
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';
|
|
13
13
|
import { rename, writeFile } from 'fs/promises';
|
|
14
14
|
|
|
15
|
+
export { LogCursor };
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* If we can successfully resolve 'host.docker.internal', then we are running in a container, and we should treat
|
|
17
19
|
* localhost as being host.docker.internal.
|
|
@@ -22,21 +24,20 @@ export const getLocalhost = () =>
|
|
|
22
24
|
.catch(() => 'localhost');
|
|
23
25
|
|
|
24
26
|
export const LOCALHOST = await getLocalhost();
|
|
25
|
-
export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, API_KEY, CLI_VERSION } = process.env;
|
|
27
|
+
export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, MNEMONIC, API_KEY, CLI_VERSION } = process.env;
|
|
26
28
|
|
|
27
29
|
export function addOptions(program: Command, options: Option[]) {
|
|
28
30
|
options.forEach(option => program.addOption(option));
|
|
29
31
|
return program;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
export const
|
|
33
|
-
new Option('-
|
|
34
|
-
.env('
|
|
34
|
+
export const makeNodeOption = (mandatory: boolean) =>
|
|
35
|
+
new Option('-n, --node-url <string>', 'URL of the Aztec node')
|
|
36
|
+
.env('AZTEC_NODE_URL')
|
|
35
37
|
.default(`http://${LOCALHOST}:8080`)
|
|
36
|
-
.conflicts('remote-pxe')
|
|
37
38
|
.makeOptionMandatory(mandatory);
|
|
38
39
|
|
|
39
|
-
export const
|
|
40
|
+
export const nodeOption = makeNodeOption(true);
|
|
40
41
|
|
|
41
42
|
export const l1ChainIdOption = new Option('-c, --l1-chain-id <number>', 'Chain ID of the ethereum host')
|
|
42
43
|
.env('L1_CHAIN_ID')
|
|
@@ -114,6 +115,34 @@ export async function getTxSender(pxe: PXE, _from?: string) {
|
|
|
114
115
|
return from;
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Parses and validates a hex string. Removes leading 0x if present, checks for hex validity,
|
|
120
|
+
* and enforces an optional minimum length.
|
|
121
|
+
* @param hex - The hex string to validate.
|
|
122
|
+
* @param minLen - Optional minimum length (in hex characters, after stripping '0x').
|
|
123
|
+
* @returns The normalized hex string (without leading 0x).
|
|
124
|
+
* @throws InvalidArgumentError if the string is not valid hex or does not meet the minimum length.
|
|
125
|
+
*/
|
|
126
|
+
// minLen is now interpreted as the minimum number of bytes (2 hex characters per byte)
|
|
127
|
+
export function parseHex(hex: string, minLen?: number): `0x${string}` {
|
|
128
|
+
const normalized = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
129
|
+
|
|
130
|
+
if (!/^[0-9a-fA-F]*$/.test(normalized)) {
|
|
131
|
+
throw new InvalidArgumentError('Invalid hex string');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (minLen !== undefined) {
|
|
135
|
+
const minHexLen = minLen * 2;
|
|
136
|
+
if (normalized.length < minHexLen) {
|
|
137
|
+
throw new InvalidArgumentError(
|
|
138
|
+
`Hex string is too short (length ${normalized.length}), minimum byte length is ${minLen} (hex chars: ${minHexLen})`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return `0x${normalized}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
117
146
|
/**
|
|
118
147
|
* Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged.
|
|
119
148
|
* @param hex - A hex string
|
|
@@ -168,7 +197,7 @@ export function parseAztecAddress(address: string): AztecAddress {
|
|
|
168
197
|
try {
|
|
169
198
|
return AztecAddress.fromString(address);
|
|
170
199
|
} catch {
|
|
171
|
-
throw new InvalidArgumentError(`Invalid address: ${address}`);
|
|
200
|
+
throw new InvalidArgumentError(`Invalid Aztec address: ${address}`);
|
|
172
201
|
}
|
|
173
202
|
}
|
|
174
203
|
|
|
@@ -182,7 +211,7 @@ export function parseEthereumAddress(address: string): EthAddress {
|
|
|
182
211
|
try {
|
|
183
212
|
return EthAddress.fromString(address);
|
|
184
213
|
} catch {
|
|
185
|
-
throw new InvalidArgumentError(`Invalid
|
|
214
|
+
throw new InvalidArgumentError(`Invalid Ethereumaddress: ${address}`);
|
|
186
215
|
}
|
|
187
216
|
}
|
|
188
217
|
|
|
@@ -200,16 +229,27 @@ export function parseOptionalAztecAddress(address: string): AztecAddress | undef
|
|
|
200
229
|
}
|
|
201
230
|
|
|
202
231
|
/**
|
|
203
|
-
* Parses an optional
|
|
204
|
-
*
|
|
205
|
-
* @
|
|
206
|
-
* @
|
|
232
|
+
* Parses an optional `<blockNumber>-<txIndexWithinBlock>-<logIndexWithinTx>` triple into a {@link LogCursor},
|
|
233
|
+
* used as the `--after-log` argument of `get-logs` to resume pagination strictly after a previously-seen log.
|
|
234
|
+
* Thin wrapper over {@link LogCursor.parseOptional} that surfaces parse errors as commander's
|
|
235
|
+
* {@link InvalidArgumentError}.
|
|
207
236
|
*/
|
|
208
|
-
export function
|
|
209
|
-
|
|
210
|
-
return
|
|
237
|
+
export function parseOptionalLogCursor(value: string): LogCursor | undefined {
|
|
238
|
+
try {
|
|
239
|
+
return LogCursor.parseOptional(value);
|
|
240
|
+
} catch (err) {
|
|
241
|
+
throw new InvalidArgumentError(err instanceof Error ? err.message : String(err));
|
|
211
242
|
}
|
|
212
|
-
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Parses a log tag from a string. Tags are field-element values; we delegate to the {@link parseField} parser.
|
|
247
|
+
*
|
|
248
|
+
* @param tag - A hex string, integer, or boolean string representing the tag.
|
|
249
|
+
* @returns A {@link Tag} wrapping the parsed field.
|
|
250
|
+
*/
|
|
251
|
+
export function parseTag(tag: string): Tag {
|
|
252
|
+
return new Tag(parseField(tag));
|
|
213
253
|
}
|
|
214
254
|
|
|
215
255
|
/**
|
|
@@ -236,7 +276,11 @@ export function parseOptionalSelector(selector: string): FunctionSelector | unde
|
|
|
236
276
|
* @returns The parsed integer, or undefined if the input string is falsy.
|
|
237
277
|
* @throws If the input is not a valid integer.
|
|
238
278
|
*/
|
|
239
|
-
export function parseOptionalInteger(
|
|
279
|
+
export function parseOptionalInteger(
|
|
280
|
+
value: string,
|
|
281
|
+
min: number = Number.MIN_SAFE_INTEGER,
|
|
282
|
+
max: number = Number.MAX_SAFE_INTEGER,
|
|
283
|
+
): number | undefined {
|
|
240
284
|
if (!value) {
|
|
241
285
|
return undefined;
|
|
242
286
|
}
|
|
@@ -244,6 +288,12 @@ export function parseOptionalInteger(value: string): number | undefined {
|
|
|
244
288
|
if (!Number.isInteger(parsed)) {
|
|
245
289
|
throw new InvalidArgumentError('Invalid integer.');
|
|
246
290
|
}
|
|
291
|
+
if (parsed < min) {
|
|
292
|
+
throw new InvalidArgumentError(`Value must be greater than ${min}.`);
|
|
293
|
+
}
|
|
294
|
+
if (parsed > max) {
|
|
295
|
+
throw new InvalidArgumentError(`Value must be less than ${max}.`);
|
|
296
|
+
}
|
|
247
297
|
return parsed;
|
|
248
298
|
}
|
|
249
299
|
|
|
@@ -287,7 +337,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
|
|
|
287
337
|
}
|
|
288
338
|
try {
|
|
289
339
|
return PublicKeys.fromString(publicKey);
|
|
290
|
-
} catch
|
|
340
|
+
} catch {
|
|
291
341
|
throw new InvalidArgumentError(`Invalid public key: ${publicKey}`);
|
|
292
342
|
}
|
|
293
343
|
}
|
|
@@ -301,7 +351,7 @@ export function parsePublicKey(publicKey: string): PublicKeys | undefined {
|
|
|
301
351
|
export function parsePartialAddress(address: string): Fr {
|
|
302
352
|
try {
|
|
303
353
|
return Fr.fromHexString(address);
|
|
304
|
-
} catch
|
|
354
|
+
} catch {
|
|
305
355
|
throw new InvalidArgumentError(`Invalid partial address: ${address}`);
|
|
306
356
|
}
|
|
307
357
|
}
|
|
@@ -315,7 +365,7 @@ export function parsePartialAddress(address: string): Fr {
|
|
|
315
365
|
export function parseSecretKey(secretKey: string): Fr {
|
|
316
366
|
try {
|
|
317
367
|
return Fr.fromHexString(secretKey);
|
|
318
|
-
} catch
|
|
368
|
+
} catch {
|
|
319
369
|
throw new InvalidArgumentError(`Invalid encryption secret key: ${secretKey}`);
|
|
320
370
|
}
|
|
321
371
|
}
|
|
@@ -348,7 +398,7 @@ export function parseField(field: string): Fr {
|
|
|
348
398
|
}
|
|
349
399
|
|
|
350
400
|
return new Fr(BigInt(field));
|
|
351
|
-
} catch
|
|
401
|
+
} catch {
|
|
352
402
|
throw new InvalidArgumentError(`Invalid field: ${field}`);
|
|
353
403
|
}
|
|
354
404
|
}
|
package/src/utils/encoding.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { ABIParameter, AbiType, StructType } from '@aztec/stdlib/abi';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -35,7 +35,7 @@ function encodeArg(arg: string, abiType: AbiType, name: string): any {
|
|
|
35
35
|
let res: bigint;
|
|
36
36
|
try {
|
|
37
37
|
res = BigInt(arg);
|
|
38
|
-
} catch
|
|
38
|
+
} catch {
|
|
39
39
|
throw new Error(
|
|
40
40
|
`Invalid value passed for ${name}. Could not parse ${arg} as a${kind === 'integer' ? 'n' : ''} ${kind}.`,
|
|
41
41
|
);
|
package/src/utils/github.ts
CHANGED
package/src/utils/index.ts
CHANGED