@aztec/cli 0.0.1-commit.2f68f620 → 0.0.1-commit.321f6a9
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/dest/cmds/infrastructure/setup_l2_contract.js +5 -5
- package/dest/cmds/validator_keys/index.d.ts +1 -1
- package/dest/cmds/validator_keys/index.d.ts.map +1 -1
- package/dest/cmds/validator_keys/index.js +6 -6
- package/dest/cmds/validator_keys/new.d.ts +2 -1
- package/dest/cmds/validator_keys/new.d.ts.map +1 -1
- package/dest/cmds/validator_keys/new.js +21 -5
- 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 +15 -2
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
- package/dest/cmds/validator_keys/shared.js +34 -0
- package/dest/cmds/validator_keys/utils.d.ts +12 -2
- package/dest/cmds/validator_keys/utils.d.ts.map +1 -1
- package/dest/cmds/validator_keys/utils.js +34 -0
- package/dest/config/chain_l2_config.d.ts +7 -2
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +14 -1
- package/dest/config/generated/networks.d.ts +32 -14
- package/dest/config/generated/networks.d.ts.map +1 -1
- package/dest/config/generated/networks.js +31 -13
- package/dest/utils/commands.d.ts +7 -6
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +10 -9
- package/package.json +30 -30
- package/src/cmds/infrastructure/setup_l2_contract.ts +5 -5
- package/src/cmds/validator_keys/index.ts +30 -4
- package/src/cmds/validator_keys/new.ts +22 -1
- package/src/cmds/validator_keys/set_funding_account.ts +55 -0
- package/src/cmds/validator_keys/shared.ts +37 -1
- package/src/cmds/validator_keys/utils.ts +44 -1
- package/src/config/chain_l2_config.ts +14 -1
- package/src/config/generated/networks.ts +31 -13
- package/src/utils/commands.ts +14 -13
|
@@ -4,7 +4,7 @@ import { TxStatus } from '@aztec/aztec.js/tx';
|
|
|
4
4
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
5
5
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
6
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
7
|
-
import {
|
|
7
|
+
import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
|
|
8
8
|
export async function setupL2Contracts(nodeUrl, testAccounts, json, log) {
|
|
9
9
|
const waitOpts = {
|
|
10
10
|
timeout: 180,
|
|
@@ -17,17 +17,17 @@ export async function setupL2Contracts(nodeUrl, testAccounts, json, log) {
|
|
|
17
17
|
log('setupL2Contracts: Creating PXE client...');
|
|
18
18
|
const node = createAztecNodeClient(nodeUrl);
|
|
19
19
|
const wallet = await EmbeddedWallet.create(node);
|
|
20
|
-
let
|
|
20
|
+
let accountManagers = [];
|
|
21
21
|
if (testAccounts) {
|
|
22
|
-
log('setupL2Contracts:
|
|
22
|
+
log('setupL2Contracts: Creating test accounts...');
|
|
23
23
|
const initialAccountsData = await getInitialTestAccountsData();
|
|
24
|
-
|
|
24
|
+
accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccountsData);
|
|
25
25
|
}
|
|
26
26
|
if (json) {
|
|
27
27
|
const toPrint = {
|
|
28
28
|
...ProtocolContractAddress
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
accountManagers.forEach((a, i)=>{
|
|
31
31
|
toPrint[`testAccount${i}`] = a.address;
|
|
32
32
|
});
|
|
33
33
|
log(JSON.stringify(toPrint, null, 2));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
export declare function injectCommands(program: Command, log: LogFn): Command;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbWRzL3ZhbGlkYXRvcl9rZXlzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELE9BQU8sRUFBRSxPQUFPLEVBQVUsTUFBTSxXQUFXLENBQUM7QUFLNUMsd0JBQWdCLGNBQWMsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxLQUFLLFdBOEsxRCJ9
|
|
@@ -1 +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,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAK5C,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAK5C,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WA8K1D"}
|
|
@@ -6,18 +6,18 @@ export function injectCommands(program, log) {
|
|
|
6
6
|
'valKeys',
|
|
7
7
|
'valkeys'
|
|
8
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)
|
|
10
|
-
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
11
|
-
.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)=>{
|
|
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)=>{
|
|
12
10
|
const { newValidatorKeystore } = await import('./new.js');
|
|
13
11
|
await newValidatorKeystore(options, log);
|
|
14
12
|
});
|
|
15
|
-
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)
|
|
16
|
-
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
17
|
-
.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)=>{
|
|
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)=>{
|
|
18
14
|
const { addValidatorKeys } = await import('./add.js');
|
|
19
15
|
await addValidatorKeys(existing, options, log);
|
|
20
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
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
22
|
'http://localhost:8545'
|
|
23
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,6 +24,7 @@ export type NewValidatorKeystoreOptions = {
|
|
|
24
24
|
json?: boolean;
|
|
25
25
|
feeRecipient: AztecAddress;
|
|
26
26
|
coinbase?: EthAddress;
|
|
27
|
+
fundingAccount?: string;
|
|
27
28
|
remoteSigner?: string;
|
|
28
29
|
stakerOutput?: boolean;
|
|
29
30
|
gseAddress?: EthAddress;
|
|
@@ -31,4 +32,4 @@ export type NewValidatorKeystoreOptions = {
|
|
|
31
32
|
l1ChainId?: number;
|
|
32
33
|
};
|
|
33
34
|
export declare function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn): Promise<void>;
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV3LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY21kcy92YWxpZGF0b3Jfa2V5cy9uZXcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUE0QmhFLE1BQU0sTUFBTSwyQkFBMkIsR0FBRztJQUN4QyxPQUFPLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDakIsSUFBSSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2QsS0FBSyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2YsY0FBYyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ3hCLFVBQVUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ3RCLFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNsQixVQUFVLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDcEIsWUFBWSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ3RCLFlBQVksQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUN0QixpQkFBaUIsQ0FBQyxFQUFFLE9BQU8sQ0FBQztJQUM1QixHQUFHLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDYixPQUFPLENBQUMsR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AAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAkFF,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,EAAE,GAAG,EAAE,KAAK,iBAsL1F"}
|
|
@@ -5,10 +5,10 @@ import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
|
5
5
|
import { readFile, writeFile } from 'fs/promises';
|
|
6
6
|
import { basename, dirname, join } from 'path';
|
|
7
7
|
import { createPublicClient, fallback, http } from 'viem';
|
|
8
|
-
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
|
|
9
|
-
import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, resolveKeystoreOutputPath, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
8
|
+
import { generateMnemonic, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
9
|
+
import { buildValidatorEntries, encryptFundingAccountToFile, logValidatorSummaries, maybePrintJson, resolveFundingAccount, resolveKeystoreOutputPath, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
10
10
|
import { processAttesterAccounts } from './staker.js';
|
|
11
|
-
import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions, validateStakerOutputOptions } from './utils.js';
|
|
11
|
+
import { validateBlsPathOptions, validateFundingAccountOptions, validatePublisherOptions, validateRemoteSignerOptions, validateStakerOutputOptions } from './utils.js';
|
|
12
12
|
function validatePassword(password, source) {
|
|
13
13
|
if (password.length === 0) {
|
|
14
14
|
throw new Error(`${source} cannot be empty`);
|
|
@@ -79,7 +79,9 @@ export async function newValidatorKeystore(options, log) {
|
|
|
79
79
|
validatePublisherOptions(options);
|
|
80
80
|
// validate remote signer options
|
|
81
81
|
validateRemoteSignerOptions(options);
|
|
82
|
-
|
|
82
|
+
// validate funding account option
|
|
83
|
+
validateFundingAccountOptions(options);
|
|
84
|
+
const { dataDir, file, count, publisherCount = 0, publishers, json, coinbase, fundingAccount, accountIndex = 0, addressIndex = 0, feeRecipient, remoteSigner, blsPath, ikm, mnemonic: _mnemonic, password: passwordOption, passwordFile, ethPassword: ethPasswordOption, ethPasswordFile, blsPassword: blsPasswordOption, blsPasswordFile, encryptedKeystoreDir, stakerOutput, gseAddress, l1RpcUrls, l1ChainId } = options;
|
|
83
85
|
const { ethPassword, blsPassword } = await resolvePasswords({
|
|
84
86
|
password: passwordOption,
|
|
85
87
|
passwordFile,
|
|
@@ -113,6 +115,7 @@ export async function newValidatorKeystore(options, log) {
|
|
|
113
115
|
coinbase,
|
|
114
116
|
remoteSigner
|
|
115
117
|
});
|
|
118
|
+
let resolvedFundingAccount = fundingAccount ? resolveFundingAccount(fundingAccount, remoteSigner) : undefined;
|
|
116
119
|
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
117
120
|
if (shouldEncryptKeystores) {
|
|
118
121
|
const encryptedKeystoreOutDir = encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : keystoreOutDir;
|
|
@@ -124,10 +127,19 @@ export async function newValidatorKeystore(options, log) {
|
|
|
124
127
|
outDir: encryptedKeystoreOutDir,
|
|
125
128
|
password: blsPassword
|
|
126
129
|
});
|
|
130
|
+
if (resolvedFundingAccount) {
|
|
131
|
+
resolvedFundingAccount = await encryptFundingAccountToFile(resolvedFundingAccount, {
|
|
132
|
+
outDir: encryptedKeystoreOutDir,
|
|
133
|
+
password: ethPassword
|
|
134
|
+
});
|
|
135
|
+
}
|
|
127
136
|
}
|
|
128
137
|
const keystore = {
|
|
129
138
|
schemaVersion: 1,
|
|
130
|
-
validators
|
|
139
|
+
validators,
|
|
140
|
+
...resolvedFundingAccount ? {
|
|
141
|
+
fundingAccount: resolvedFundingAccount
|
|
142
|
+
} : {}
|
|
131
143
|
};
|
|
132
144
|
await writeKeystoreFile(outputPath, keystore);
|
|
133
145
|
// Generate staker outputs if requested
|
|
@@ -185,6 +197,10 @@ export async function newValidatorKeystore(options, log) {
|
|
|
185
197
|
// print a concise summary of public keys (addresses and BLS pubkeys) if no --json options was selected
|
|
186
198
|
if (!json) {
|
|
187
199
|
logValidatorSummaries(log, summaries);
|
|
200
|
+
if (fundingAccount) {
|
|
201
|
+
const funderAddress = fundingAccount.length === 66 ? privateKeyToAccount(fundingAccount).address : fundingAccount;
|
|
202
|
+
log(`funding account: ${funderAddress}`);
|
|
203
|
+
}
|
|
188
204
|
}
|
|
189
205
|
if (mnemonic && remoteSigner && !json) {
|
|
190
206
|
for(let i = 0; i < validatorCount; i++){
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
export type SetFundingAccountOptions = {
|
|
3
|
+
remoteSigner?: string;
|
|
4
|
+
password?: string;
|
|
5
|
+
encryptedKeystoreDir?: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Sets the top-level funding account of an existing keystore, replacing any previous one. The
|
|
10
|
+
* account may be a private key, or an address paired with a remote signer URL. With a password,
|
|
11
|
+
* a plaintext key is encrypted to an ETH JSON V3 file and stored as a { path, password } reference.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setFundingAccount(existing: string, fundingAccount: string, options: SetFundingAccountOptions, log: LogFn): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0X2Z1bmRpbmdfYWNjb3VudC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NtZHMvdmFsaWRhdG9yX2tleXMvc2V0X2Z1bmRpbmdfYWNjb3VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQVVuRCxNQUFNLE1BQU0sd0JBQXdCLEdBQUc7SUFDckMsWUFBWSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ3RCLFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNsQixvQkFBb0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUM5QixJQUFJLENBQUMsRUFBRSxPQUFPLENBQUM7Q0FDaEIsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBc0IsaUJBQWlCLENBQ3JDLFFBQVEsRUFBRSxNQUFNLEVBQ2hCLGNBQWMsRUFBRSxNQUFNLEVBQ3RCLE9BQU8sRUFBRSx3QkFBd0IsRUFDakMsR0FBRyxFQUFFLEtBQUssaUJBNEJYIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_funding_account.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/set_funding_account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAUnD,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,wBAAwB,EACjC,GAAG,EAAE,KAAK,iBA4BX"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { loadKeystoreFile } from '@aztec/node-keystore/loader';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
|
+
import { encryptFundingAccountToFile, maybePrintJson, resolveFundingAccount, writeKeystoreFile } from './shared.js';
|
|
5
|
+
import { validateFundingAccountOptions } from './utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* Sets the top-level funding account of an existing keystore, replacing any previous one. The
|
|
8
|
+
* account may be a private key, or an address paired with a remote signer URL. With a password,
|
|
9
|
+
* a plaintext key is encrypted to an ETH JSON V3 file and stored as a { path, password } reference.
|
|
10
|
+
*/ export async function setFundingAccount(existing, fundingAccount, options, log) {
|
|
11
|
+
const { remoteSigner, password, encryptedKeystoreDir, json } = options;
|
|
12
|
+
const keystore = loadKeystoreFile(existing);
|
|
13
|
+
const validated = {
|
|
14
|
+
fundingAccount,
|
|
15
|
+
remoteSigner
|
|
16
|
+
};
|
|
17
|
+
validateFundingAccountOptions(validated, !!keystore.remoteSigner);
|
|
18
|
+
let resolved = resolveFundingAccount(validated.fundingAccount, remoteSigner);
|
|
19
|
+
if (password !== undefined) {
|
|
20
|
+
const outDir = encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : dirname(existing);
|
|
21
|
+
resolved = await encryptFundingAccountToFile(resolved, {
|
|
22
|
+
outDir,
|
|
23
|
+
password
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (keystore.fundingAccount) {
|
|
27
|
+
log('Replacing existing funding account in keystore');
|
|
28
|
+
}
|
|
29
|
+
keystore.fundingAccount = resolved;
|
|
30
|
+
await writeKeystoreFile(existing, keystore);
|
|
31
|
+
if (!json) {
|
|
32
|
+
const value = validated.fundingAccount;
|
|
33
|
+
const funderAddress = value.length === 66 ? privateKeyToAccount(value).address : value;
|
|
34
|
+
log(`Set funding account ${funderAddress} in ${existing}`);
|
|
35
|
+
}
|
|
36
|
+
maybePrintJson(log, !!json, keystore);
|
|
37
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
3
|
import type { EthAccount, EthPrivateKey, ValidatorKeyStore } from '@aztec/node-keystore/types';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -28,6 +28,14 @@ export declare function withValidatorIndex(path: string, accountIndex?: number,
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function computeBlsPublicKeyCompressed(privateKeyHex: string): Promise<string>;
|
|
30
30
|
export declare function deriveEthAttester(mnemonic: string, baseAccountIndex: number, addressIndex: number, remoteSigner?: string): EthAccount | EthPrivateKey;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a `--funding-account` value into a keystore `EthAccount`. A 66-char value is a private key
|
|
33
|
+
* (used verbatim). A 42-char value is an address: with an explicit `remoteSigner` URL it becomes an
|
|
34
|
+
* `{ address, remoteSignerUrl }` pair; without one it is stored as a bare address that falls back to
|
|
35
|
+
* the keystore-level remote signer at runtime. Callers must validate the value first (see
|
|
36
|
+
* `validateFundingAccountOptions`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveFundingAccount(fundingAccount: string, remoteSigner?: string): EthAccount;
|
|
31
39
|
export declare function buildValidatorEntries(input: BuildValidatorsInput): Promise<{
|
|
32
40
|
validators: ValidatorKeyStore[];
|
|
33
41
|
summaries: ValidatorSummary[];
|
|
@@ -60,9 +68,14 @@ export declare function writeBlsBn254ToFile(validators: ValidatorKeyStore[], opt
|
|
|
60
68
|
}): Promise<void>;
|
|
61
69
|
/** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */
|
|
62
70
|
export declare function writeEthJsonV3Keystore(outDir: string, fileNameBase: string, password: string, privateKeyHex: string): Promise<string>;
|
|
71
|
+
/** Encrypt a plaintext funding-account key to a JSON V3 file, replacing it with a { path, password } reference. */
|
|
72
|
+
export declare function encryptFundingAccountToFile(account: EthAccount, options: {
|
|
73
|
+
outDir: string;
|
|
74
|
+
password: string;
|
|
75
|
+
}): Promise<EthAccount>;
|
|
63
76
|
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */
|
|
64
77
|
export declare function writeEthJsonV3ToFile(validators: ValidatorKeyStore[], options: {
|
|
65
78
|
outDir: string;
|
|
66
79
|
password: string;
|
|
67
80
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xVQUFVLENBQUMsQ0FFckI7QUFFRCxrR0FBa0c7QUFDbEcsd0JBQXNCLG9CQUFvQixDQUN4QyxVQUFVLEVBQUUsaUJBQWlCLEVBQUUsRUFDL0IsT0FBTyxFQUFFO0lBQUUsTUFBTSxFQUFFLE1BQU0sQ0FBQztJQUFDLFFBQVEsRUFBRSxNQUFNLENBQUE7Q0FBRSxHQUM1QyxPQUFPLENBQUMsSUFBSSxDQUFDLENBeUNmIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/shared.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/shared.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA2DhE,MAAM,MAAM,gBAAgB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEvG,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EA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ED,yGAAyG;AACzG,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9D,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAeD,mHAAmH;AACnH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,UAAU,CAAC,CAErB;AAED,kGAAkG;AAClG,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CAyCf"}
|
|
@@ -3,6 +3,7 @@ import { asyncPool } from '@aztec/foundation/async-pool';
|
|
|
3
3
|
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
|
|
4
4
|
import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
5
5
|
import { computeBn254G1PublicKeyCompressed } from '@aztec/foundation/crypto/bn254';
|
|
6
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
7
|
import { Wallet } from '@ethersproject/wallet';
|
|
7
8
|
import { constants as fsConstants, mkdirSync } from 'fs';
|
|
8
9
|
import { access, writeFile } from 'fs/promises';
|
|
@@ -94,6 +95,22 @@ export function deriveEthAttester(mnemonic, baseAccountIndex, addressIndex, remo
|
|
|
94
95
|
remoteSignerUrl: remoteSigner
|
|
95
96
|
} : '0x' + Buffer.from(acct.getHdKey().privateKey).toString('hex');
|
|
96
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolve a `--funding-account` value into a keystore `EthAccount`. A 66-char value is a private key
|
|
100
|
+
* (used verbatim). A 42-char value is an address: with an explicit `remoteSigner` URL it becomes an
|
|
101
|
+
* `{ address, remoteSignerUrl }` pair; without one it is stored as a bare address that falls back to
|
|
102
|
+
* the keystore-level remote signer at runtime. Callers must validate the value first (see
|
|
103
|
+
* `validateFundingAccountOptions`).
|
|
104
|
+
*/ export function resolveFundingAccount(fundingAccount, remoteSigner) {
|
|
105
|
+
if (fundingAccount.length === 66) {
|
|
106
|
+
return fundingAccount;
|
|
107
|
+
}
|
|
108
|
+
const address = EthAddress.fromString(fundingAccount);
|
|
109
|
+
return remoteSigner ? {
|
|
110
|
+
address,
|
|
111
|
+
remoteSignerUrl: remoteSigner
|
|
112
|
+
} : address;
|
|
113
|
+
}
|
|
97
114
|
export async function buildValidatorEntries(input) {
|
|
98
115
|
const { validatorCount, publisherCount = 0, publishers, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath, feeRecipient, coinbase, remoteSigner } = input;
|
|
99
116
|
const summaries = [];
|
|
@@ -275,6 +292,23 @@ export function maybePrintJson(log, jsonFlag, obj) {
|
|
|
275
292
|
});
|
|
276
293
|
return outPath;
|
|
277
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* If `account` is a plaintext ETH private key, encrypt it to a JSON V3 file and return a
|
|
297
|
+
* { path, password } reference; otherwise return it unchanged.
|
|
298
|
+
*/ async function maybeEncryptEthAccount(account, label, options) {
|
|
299
|
+
if (typeof account === 'string' && account.startsWith('0x') && account.length === 66) {
|
|
300
|
+
const fileBase = `${label}_${account.slice(2, 10)}`;
|
|
301
|
+
const p = await writeEthJsonV3Keystore(options.outDir, fileBase, options.password, account);
|
|
302
|
+
return {
|
|
303
|
+
path: p,
|
|
304
|
+
password: options.password
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return account;
|
|
308
|
+
}
|
|
309
|
+
/** Encrypt a plaintext funding-account key to a JSON V3 file, replacing it with a { path, password } reference. */ export async function encryptFundingAccountToFile(account, options) {
|
|
310
|
+
return await maybeEncryptEthAccount(account, 'funding', options);
|
|
311
|
+
}
|
|
278
312
|
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */ export async function writeEthJsonV3ToFile(validators, options) {
|
|
279
313
|
const tasks = [];
|
|
280
314
|
const maybeQueueEncryptEth = (account, label, setEncryptedAccount)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
export declare const defaultBlsPath = "m/12381/3600/0/0/0";
|
|
3
3
|
export declare function validateBlsPathOptions(options: {
|
|
4
4
|
count?: number;
|
|
@@ -22,4 +22,14 @@ export declare function validatePublisherOptions(options: {
|
|
|
22
22
|
publishers?: string[];
|
|
23
23
|
publisherCount?: number;
|
|
24
24
|
}): void;
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Validates and normalizes the `--funding-account` option in place. The value may be a private key
|
|
27
|
+
* (used as a local signer) or an ETH address. An address needs a remote signer to sign funding txs:
|
|
28
|
+
* either `--remote-signer`, or a keystore that already defines one (pass `hasKeystoreRemoteSigner`),
|
|
29
|
+
* which a bare address inherits at runtime.
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateFundingAccountOptions(options: {
|
|
32
|
+
fundingAccount?: string;
|
|
33
|
+
remoteSigner?: string;
|
|
34
|
+
}, hasKeystoreRemoteSigner?: boolean): void;
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbWRzL3ZhbGlkYXRvcl9rZXlzL3V0aWxzLn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UFBRTtJQUFFLGNBQWMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUFDLFlBQVksQ0FBQyxFQUFFLE1BQU0sQ0FBQTtDQUFFLEVBQzNELHVCQUF1QixVQUFRLFFBaUNoQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,QAWA;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,QAeA;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,QAMhG;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,QAwBnG;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3D,uBAAuB,UAAQ,QAiChC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
2
|
import { ethPrivateKeySchema } from '@aztec/node-keystore/schemas';
|
|
2
3
|
export const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
3
4
|
export function validateBlsPathOptions(options) {
|
|
@@ -50,3 +51,36 @@ export function validatePublisherOptions(options) {
|
|
|
50
51
|
options.publishers = normalizedKeys;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Validates and normalizes the `--funding-account` option in place. The value may be a private key
|
|
56
|
+
* (used as a local signer) or an ETH address. An address needs a remote signer to sign funding txs:
|
|
57
|
+
* either `--remote-signer`, or a keystore that already defines one (pass `hasKeystoreRemoteSigner`),
|
|
58
|
+
* which a bare address inherits at runtime.
|
|
59
|
+
*/ export function validateFundingAccountOptions(options, hasKeystoreRemoteSigner = false) {
|
|
60
|
+
if (!options.fundingAccount) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let value = options.fundingAccount.trim();
|
|
64
|
+
if (!value.startsWith('0x')) {
|
|
65
|
+
value = '0x' + value;
|
|
66
|
+
}
|
|
67
|
+
if (value.length === 66) {
|
|
68
|
+
try {
|
|
69
|
+
ethPrivateKeySchema.parse(value);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new Error(`Invalid funding account private key: ${error instanceof Error ? error.message : String(error)}`);
|
|
72
|
+
}
|
|
73
|
+
} else if (value.length === 42) {
|
|
74
|
+
try {
|
|
75
|
+
EthAddress.fromString(value);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
throw new Error(`Invalid funding account address: ${error instanceof Error ? error.message : String(error)}`);
|
|
78
|
+
}
|
|
79
|
+
if (!options.remoteSigner && !hasKeystoreRemoteSigner) {
|
|
80
|
+
throw new Error('--funding-account as an address requires --remote-signer, or a keystore that already defines a remote signer');
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
throw new Error('Invalid funding account: expected a 32-byte private key or a 20-byte address');
|
|
84
|
+
}
|
|
85
|
+
options.fundingAccount = value;
|
|
86
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { NetworkNames } from '@aztec/foundation/config';
|
|
2
|
+
import { type ConsensusEnvVar } from '@aztec/stdlib/config';
|
|
3
|
+
/** Every generated network config must define every consensus-critical env var. */
|
|
4
|
+
export type ConsensusComplete = Record<ConsensusEnvVar, string | number | boolean>;
|
|
2
5
|
/**
|
|
3
6
|
* Sets up environment for the given network.
|
|
4
7
|
*
|
|
@@ -6,9 +9,11 @@ import type { NetworkNames } from '@aztec/foundation/config';
|
|
|
6
9
|
* and DefaultSlasherConfig (which match the 'defaults' section of defaults.yml).
|
|
7
10
|
*
|
|
8
11
|
* For deployed networks: applies network configuration from generated defaults.yml,
|
|
9
|
-
* merging base defaults with network-specific overrides.
|
|
12
|
+
* merging base defaults with network-specific overrides. Before merging, enforces that operators have not
|
|
13
|
+
* overridden any consensus-critical env var with a value diverging from the network config (throwing unless
|
|
14
|
+
* ALLOW_OVERRIDING_NETWORK_CONFIG is set), so all nodes of a network agree on consensus-critical values.
|
|
10
15
|
*
|
|
11
16
|
* @param networkName - The network name
|
|
12
17
|
*/
|
|
13
18
|
export declare function enrichEnvironmentWithChainName(networkName: NetworkNames): void;
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhaW5fbDJfY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL2NoYWluX2wyX2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUU3RCxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQThCLE1BQU0sc0JBQXNCLENBQUM7QUFjeEYsbUZBQW1GO0FBQ25GLE1BQU0sTUFBTSxpQkFBaUIsR0FBRyxNQUFNLENBQUMsZUFBZSxFQUFFLE1BQU0sR0FBRyxNQUFNLEdBQUcsT0FBTyxDQUFDLENBQUM7QUFpQm5GOzs7Ozs7Ozs7Ozs7R0FZRztBQUNILHdCQUFnQiw4QkFBOEIsQ0FBQyxXQUFXLEVBQUUsWUFBWSxRQXdCdkUifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/config/chain_l2_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/config/chain_l2_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,KAAK,eAAe,EAA8B,MAAM,sBAAsB,CAAC;AAcxF,mFAAmF;AACnF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAiBnF;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,YAAY,QAwBvE"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { checkConsensusEnvOverrides } from '@aztec/stdlib/config';
|
|
1
3
|
import path from 'path';
|
|
2
4
|
import { devnetConfig, mainnetConfig, testnetConfig } from './generated/networks.js';
|
|
3
5
|
const NetworkConfigs = {
|
|
@@ -5,6 +7,12 @@ const NetworkConfigs = {
|
|
|
5
7
|
testnet: testnetConfig,
|
|
6
8
|
mainnet: mainnetConfig
|
|
7
9
|
};
|
|
10
|
+
({
|
|
11
|
+
devnetConfig,
|
|
12
|
+
testnetConfig,
|
|
13
|
+
mainnetConfig
|
|
14
|
+
});
|
|
15
|
+
const log = createLogger('cli:chain_l2_config');
|
|
8
16
|
function enrichEnvironmentWithNetworkConfig(config) {
|
|
9
17
|
for (const [key, value] of Object.entries(config)){
|
|
10
18
|
if (process.env[key] === undefined && value !== undefined) {
|
|
@@ -22,7 +30,9 @@ function getDefaultDataDir(networkName) {
|
|
|
22
30
|
* and DefaultSlasherConfig (which match the 'defaults' section of defaults.yml).
|
|
23
31
|
*
|
|
24
32
|
* For deployed networks: applies network configuration from generated defaults.yml,
|
|
25
|
-
* merging base defaults with network-specific overrides.
|
|
33
|
+
* merging base defaults with network-specific overrides. Before merging, enforces that operators have not
|
|
34
|
+
* overridden any consensus-critical env var with a value diverging from the network config (throwing unless
|
|
35
|
+
* ALLOW_OVERRIDING_NETWORK_CONFIG is set), so all nodes of a network agree on consensus-critical values.
|
|
26
36
|
*
|
|
27
37
|
* @param networkName - The network name
|
|
28
38
|
*/ export function enrichEnvironmentWithChainName(networkName) {
|
|
@@ -38,6 +48,9 @@ function getDefaultDataDir(networkName) {
|
|
|
38
48
|
const configKey = /^v\d+-devnet-\d+$/.test(networkName) ? 'devnet' : networkName;
|
|
39
49
|
const generatedConfig = NetworkConfigs[configKey];
|
|
40
50
|
if (generatedConfig) {
|
|
51
|
+
// The check is pure; this layer owns env mutation, so apply its canonical writes before enriching.
|
|
52
|
+
const canonical = checkConsensusEnvOverrides(generatedConfig, process.env, (msg)=>log.warn(msg));
|
|
53
|
+
Object.assign(process.env, canonical);
|
|
41
54
|
enrichEnvironmentWithNetworkConfig(generatedConfig);
|
|
42
55
|
}
|
|
43
56
|
// Set DATA_DIRECTORY if not already set
|