@aztec/cli 3.0.0-nightly.20251110 → 3.0.0-nightly.20251112
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 +1 -1
- package/dest/cmds/misc/update/npm.js +1 -1
- package/dest/cmds/validator_keys/add.d.ts.map +1 -1
- package/dest/cmds/validator_keys/add.js +1 -2
- package/dest/cmds/validator_keys/index.d.ts.map +1 -1
- package/dest/cmds/validator_keys/index.js +10 -3
- package/dest/cmds/validator_keys/new.d.ts +4 -1
- package/dest/cmds/validator_keys/new.d.ts.map +1 -1
- package/dest/cmds/validator_keys/new.js +82 -8
- package/dest/cmds/validator_keys/shared.d.ts +0 -1
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
- package/dest/cmds/validator_keys/shared.js +2 -14
- 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 +206 -0
- package/dest/config/chain_l2_config.d.ts +1 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +11 -3
- package/package.json +25 -25
- package/src/cmds/misc/update/npm.ts +1 -1
- package/src/cmds/validator_keys/add.ts +0 -2
- package/src/cmds/validator_keys/index.ts +31 -3
- package/src/cmds/validator_keys/new.ts +97 -9
- package/src/cmds/validator_keys/shared.ts +1 -9
- package/src/cmds/validator_keys/staker.ts +298 -0
- package/src/config/chain_l2_config.ts +14 -4
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The Aztec CLI `aztec-cli` is a command-line interface (CLI) tool for interacting
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
1. In your terminal, download the
|
|
7
|
+
1. In your terminal, download the local network by running
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
bash -i <(curl -s https://install.aztec.network)
|
|
@@ -6,7 +6,7 @@ import { parse } from 'semver';
|
|
|
6
6
|
import { atomicUpdateFile } from './utils.js';
|
|
7
7
|
const deprecatedNpmPackages = new Set([
|
|
8
8
|
'@aztec/cli',
|
|
9
|
-
'@aztec/aztec-
|
|
9
|
+
'@aztec/aztec-local-network'
|
|
10
10
|
]);
|
|
11
11
|
const npmDeprecationMessage = `
|
|
12
12
|
The following packages have been deprecated and will no longer be updated on the npm registry:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/add.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAU5D,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAElE,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/add.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAU5D,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAElE,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,KAAK,iBAyFpG"}
|
|
@@ -4,7 +4,7 @@ import { dirname, isAbsolute, join } from 'path';
|
|
|
4
4
|
import { generateMnemonic } from 'viem/accounts';
|
|
5
5
|
import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
6
6
|
export async function addValidatorKeys(existing, options, log) {
|
|
7
|
-
const { dataDir, file, count, publisherCount = 0, mnemonic, accountIndex = 0, addressIndex, ikm, blsPath,
|
|
7
|
+
const { dataDir, file, count, publisherCount = 0, mnemonic, accountIndex = 0, addressIndex, ikm, blsPath, json, feeRecipient: feeRecipientOpt, coinbase: coinbaseOpt, fundingAccount: fundingAccountOpt, remoteSigner: remoteSignerOpt, password, outDir } = options;
|
|
8
8
|
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
9
9
|
const baseAddressIndex = addressIndex ?? 0;
|
|
10
10
|
const keystore = loadKeystoreFile(existing);
|
|
@@ -32,7 +32,6 @@ export async function addValidatorKeys(existing, options, log) {
|
|
|
32
32
|
mnemonic: mnemonicToUse,
|
|
33
33
|
ikm,
|
|
34
34
|
blsPath,
|
|
35
|
-
blsOnly,
|
|
36
35
|
feeRecipient,
|
|
37
36
|
coinbase,
|
|
38
37
|
remoteSigner,
|
|
@@ -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,EAAE,MAAM,WAAW,CAAC;AAIpC,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,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WAqH1D"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
|
|
2
2
|
export function injectCommands(program, log) {
|
|
3
3
|
const group = program.command('validator-keys').aliases([
|
|
4
|
-
'valKeys'
|
|
4
|
+
'valKeys',
|
|
5
|
+
'valkeys'
|
|
5
6
|
]).description('Manage validator keystores for node operators');
|
|
6
|
-
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 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', 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 m/12381/3600/0/0/0)').option('--
|
|
7
|
+
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 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', 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 m/12381/3600/0/0/0)').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--out-dir <dir>', 'Output directory for generated keystore file(s)').option('--json', 'Echo resulting JSON to stdout').option('--staker-output', 'Generate staker output JSON files for each attester').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)=>{
|
|
7
8
|
const { newValidatorKeystore } = await import('./new.js');
|
|
8
9
|
await newValidatorKeystore(options, log);
|
|
9
10
|
});
|
|
10
|
-
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').option('--file <name>', 'Override output file name').option('--count <N>', 'Number of validators to add', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', 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 m/12381/3600/0/0/0)').option('--
|
|
11
|
+
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').option('--file <name>', 'Override output file name').option('--count <N>', 'Number of validators to add', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', 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 m/12381/3600/0/0/0)').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('--out-dir <dir>', 'Output directory for generated 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)=>{
|
|
11
12
|
const { addValidatorKeys } = await import('./add.js');
|
|
12
13
|
await addValidatorKeys(existing, options, log);
|
|
13
14
|
});
|
|
15
|
+
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(','), [
|
|
16
|
+
'http://localhost:8545'
|
|
17
|
+
]).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)=>{
|
|
18
|
+
const { generateStakerJson } = await import('./staker.js');
|
|
19
|
+
await generateStakerJson(options, log);
|
|
20
|
+
});
|
|
14
21
|
// top-level convenience: aztec generate-bls-keypair
|
|
15
22
|
program.command('generate-bls-keypair').description('Generate a BLS keypair with convenience flags').option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)').option('--g2', 'Derive on G2 subgroup').option('--compressed', 'Output compressed public key').option('--json', 'Print JSON output to stdout').option('--out <file>', 'Write output to file').action(async (options)=>{
|
|
16
23
|
const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
|
|
@@ -13,7 +13,6 @@ export type NewValidatorKeystoreOptions = {
|
|
|
13
13
|
separatePublisher?: boolean;
|
|
14
14
|
ikm?: string;
|
|
15
15
|
blsPath?: string;
|
|
16
|
-
blsOnly?: boolean;
|
|
17
16
|
password?: string;
|
|
18
17
|
outDir?: string;
|
|
19
18
|
json?: boolean;
|
|
@@ -21,6 +20,10 @@ export type NewValidatorKeystoreOptions = {
|
|
|
21
20
|
coinbase?: EthAddress;
|
|
22
21
|
remoteSigner?: string;
|
|
23
22
|
fundingAccount?: EthAddress;
|
|
23
|
+
stakerOutput?: boolean;
|
|
24
|
+
gseAddress?: EthAddress;
|
|
25
|
+
l1RpcUrls?: string[];
|
|
26
|
+
l1ChainId?: number;
|
|
24
27
|
};
|
|
25
28
|
export declare function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn): Promise<void>;
|
|
26
29
|
//# sourceMappingURL=new.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/new.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/new.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAmBhE,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,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,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,EAAE,GAAG,EAAE,KAAK,iBA+J1F"}
|
|
@@ -1,13 +1,37 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
+
import { GSEContract, createEthereumChain } from '@aztec/ethereum';
|
|
1
3
|
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
2
|
-
import {
|
|
4
|
+
import { writeFile } from 'fs/promises';
|
|
5
|
+
import { basename, dirname, join } from 'path';
|
|
6
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
3
7
|
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
|
|
4
8
|
import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, resolveKeystoreOutputPath, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
9
|
+
import { processAttesterAccounts } from './staker.js';
|
|
5
10
|
export async function newValidatorKeystore(options, log) {
|
|
6
|
-
const { dataDir, file, count, publisherCount = 0, json, coinbase, accountIndex = 0, addressIndex = 0, feeRecipient, remoteSigner, fundingAccount,
|
|
11
|
+
const { dataDir, file, count, publisherCount = 0, json, coinbase, accountIndex = 0, addressIndex = 0, feeRecipient, remoteSigner, fundingAccount, blsPath, ikm, mnemonic: _mnemonic, password, outDir, stakerOutput, gseAddress, l1RpcUrls, l1ChainId } = options;
|
|
12
|
+
// Validate staker output requirements
|
|
13
|
+
if (stakerOutput) {
|
|
14
|
+
if (!gseAddress) {
|
|
15
|
+
throw new Error('--gse-address is required when using --staker-output');
|
|
16
|
+
}
|
|
17
|
+
if (!l1RpcUrls || l1RpcUrls.length === 0) {
|
|
18
|
+
throw new Error('--l1-rpc-urls is required when using --staker-output');
|
|
19
|
+
}
|
|
20
|
+
if (l1ChainId === undefined) {
|
|
21
|
+
throw new Error('--l1-chain-id is required when using --staker-output');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
7
24
|
if (remoteSigner && !_mnemonic) {
|
|
8
25
|
throw new Error('Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.');
|
|
9
26
|
}
|
|
10
27
|
const mnemonic = _mnemonic ?? generateMnemonic(wordlist);
|
|
28
|
+
if (!_mnemonic && !json) {
|
|
29
|
+
log('No mnemonic provided, generating new one...');
|
|
30
|
+
log(`Using new mnemonic:`);
|
|
31
|
+
log('');
|
|
32
|
+
log(mnemonic);
|
|
33
|
+
log('');
|
|
34
|
+
}
|
|
11
35
|
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
12
36
|
const { outputPath } = await resolveKeystoreOutputPath(dataDir, file);
|
|
13
37
|
const { validators, summaries } = await buildValidatorEntries({
|
|
@@ -18,7 +42,6 @@ export async function newValidatorKeystore(options, log) {
|
|
|
18
42
|
mnemonic,
|
|
19
43
|
ikm,
|
|
20
44
|
blsPath,
|
|
21
|
-
blsOnly,
|
|
22
45
|
feeRecipient,
|
|
23
46
|
coinbase,
|
|
24
47
|
remoteSigner,
|
|
@@ -41,13 +64,59 @@ export async function newValidatorKeystore(options, log) {
|
|
|
41
64
|
validators
|
|
42
65
|
};
|
|
43
66
|
await writeKeystoreFile(outputPath, keystore);
|
|
44
|
-
|
|
45
|
-
|
|
67
|
+
// Generate staker outputs if requested
|
|
68
|
+
const allStakerOutputs = [];
|
|
69
|
+
if (stakerOutput && gseAddress && l1RpcUrls && l1ChainId !== undefined) {
|
|
70
|
+
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
71
|
+
const publicClient = createPublicClient({
|
|
72
|
+
chain: chain.chainInfo,
|
|
73
|
+
transport: fallback(l1RpcUrls.map((url)=>http(url)))
|
|
74
|
+
});
|
|
75
|
+
const gse = new GSEContract(publicClient, gseAddress);
|
|
76
|
+
const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
|
|
77
|
+
// Extract keystore base name without extension for unique staker output filenames
|
|
78
|
+
const keystoreBaseName = basename(outputPath, '.json');
|
|
79
|
+
// Process each validator
|
|
80
|
+
for(let i = 0; i < validators.length; i++){
|
|
81
|
+
const validator = validators[i];
|
|
82
|
+
const outputs = await processAttesterAccounts(validator.attester, gse, password);
|
|
83
|
+
// Save each attester's staker output
|
|
84
|
+
for(let j = 0; j < outputs.length; j++){
|
|
85
|
+
const attesterIndex = i + 1;
|
|
86
|
+
const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_attester${attesterIndex}_staker_output.json`);
|
|
87
|
+
await writeFile(stakerOutputPath, prettyPrintJSON(outputs[j]), 'utf-8');
|
|
88
|
+
allStakerOutputs.push(outputs[j]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const outputData = !_mnemonic ? {
|
|
93
|
+
...keystore,
|
|
94
|
+
generatedMnemonic: mnemonic
|
|
95
|
+
} : keystore;
|
|
96
|
+
// Handle JSON output
|
|
97
|
+
if (json) {
|
|
98
|
+
if (stakerOutput && allStakerOutputs.length > 0) {
|
|
99
|
+
const combinedOutput = {
|
|
100
|
+
keystore: outputData,
|
|
101
|
+
staker: allStakerOutputs
|
|
102
|
+
};
|
|
103
|
+
maybePrintJson(log, json, combinedOutput);
|
|
104
|
+
} else {
|
|
105
|
+
maybePrintJson(log, json, outputData);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
46
108
|
log(`Wrote validator keystore to ${outputPath}`);
|
|
109
|
+
if (stakerOutput && allStakerOutputs.length > 0) {
|
|
110
|
+
const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
|
|
111
|
+
log(`Wrote ${allStakerOutputs.length} staker output file(s) to ${keystoreOutDir}`);
|
|
112
|
+
log('');
|
|
113
|
+
}
|
|
47
114
|
}
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
115
|
+
// print a concise summary of public keys (addresses and BLS pubkeys) if no --json options was selected
|
|
116
|
+
if (!json) {
|
|
117
|
+
logValidatorSummaries(log, summaries);
|
|
118
|
+
}
|
|
119
|
+
if (mnemonic && remoteSigner && !json) {
|
|
51
120
|
for(let i = 0; i < validatorCount; i++){
|
|
52
121
|
const addrIdx = addressIndex + i;
|
|
53
122
|
const acct = mnemonicToAccount(mnemonic, {
|
|
@@ -57,4 +126,9 @@ export async function newValidatorKeystore(options, log) {
|
|
|
57
126
|
log(`attester address: ${acct.address} remoteSignerUrl: ${remoteSigner}`);
|
|
58
127
|
}
|
|
59
128
|
}
|
|
129
|
+
// Log staker outputs if not in JSON mode
|
|
130
|
+
if (!json && stakerOutput && allStakerOutputs.length > 0) {
|
|
131
|
+
log('\nStaker outputs:');
|
|
132
|
+
log(prettyPrintJSON(allStakerOutputs));
|
|
133
|
+
}
|
|
60
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,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;AAShE,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,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,M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AAC,IAAI,CAAC,CA2Cf"}
|
|
@@ -33,7 +33,7 @@ export function deriveEthAttester(mnemonic, baseAccountIndex, addressIndex, remo
|
|
|
33
33
|
} : '0x' + Buffer.from(acct.getHdKey().privateKey).toString('hex');
|
|
34
34
|
}
|
|
35
35
|
export async function buildValidatorEntries(input) {
|
|
36
|
-
const { validatorCount, publisherCount = 0, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath,
|
|
36
|
+
const { validatorCount, publisherCount = 0, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath, feeRecipient, coinbase, remoteSigner, fundingAccount } = input;
|
|
37
37
|
const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
38
38
|
const summaries = [];
|
|
39
39
|
const validators = await Promise.all(Array.from({
|
|
@@ -42,20 +42,8 @@ export async function buildValidatorEntries(input) {
|
|
|
42
42
|
const addressIndex = baseAddressIndex + i;
|
|
43
43
|
const basePath = blsPath ?? defaultBlsPath;
|
|
44
44
|
const perValidatorPath = withValidatorIndex(basePath, addressIndex);
|
|
45
|
-
const blsPrivKey =
|
|
45
|
+
const blsPrivKey = ikm || mnemonic ? deriveBlsPrivateKey(mnemonic, ikm, perValidatorPath) : undefined;
|
|
46
46
|
const blsPubCompressed = blsPrivKey ? await computeBlsPublicKeyCompressed(blsPrivKey) : undefined;
|
|
47
|
-
if (blsOnly) {
|
|
48
|
-
const attester = {
|
|
49
|
-
bls: blsPrivKey
|
|
50
|
-
};
|
|
51
|
-
summaries.push({
|
|
52
|
-
attesterBls: blsPubCompressed
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
attester,
|
|
56
|
-
feeRecipient
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
47
|
const ethAttester = deriveEthAttester(mnemonic, accountIndex, addressIndex, remoteSigner);
|
|
60
48
|
const attester = blsPrivKey ? {
|
|
61
49
|
eth: ethAttester,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GSEContract } from '@aztec/ethereum';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
import type { AttesterAccounts } from '@aztec/node-keystore/types';
|
|
5
|
+
export type StakerOptions = {
|
|
6
|
+
from: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
output?: string;
|
|
9
|
+
gseAddress: EthAddress;
|
|
10
|
+
l1RpcUrls: string[];
|
|
11
|
+
l1ChainId: number;
|
|
12
|
+
};
|
|
13
|
+
export type StakerOutput = {
|
|
14
|
+
attester: string;
|
|
15
|
+
publicKeyG1: {
|
|
16
|
+
x: string;
|
|
17
|
+
y: string;
|
|
18
|
+
};
|
|
19
|
+
publicKeyG2: {
|
|
20
|
+
x0: string;
|
|
21
|
+
x1: string;
|
|
22
|
+
y0: string;
|
|
23
|
+
y1: string;
|
|
24
|
+
};
|
|
25
|
+
proofOfPossession: {
|
|
26
|
+
x: string;
|
|
27
|
+
y: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Process AttesterAccounts (which can be a single attester, array, or mnemonic)
|
|
32
|
+
*/
|
|
33
|
+
export declare function processAttesterAccounts(attesterAccounts: AttesterAccounts, gse: GSEContract, password?: string): Promise<StakerOutput[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Main staker command function
|
|
36
|
+
*/
|
|
37
|
+
export declare function generateStakerJson(options: StakerOptions, log: LogFn): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=staker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staker.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/staker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAuB,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAEV,gBAAgB,EAKjB,MAAM,4BAA4B,CAAC;AAOpC,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QACX,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,WAAW,EAAE;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,iBAAiB,EAAE;QACjB,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;CACH,CAAC;AA2KF;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,WAAW,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC,CAqBzB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C1F"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
+
import { GSEContract, createEthereumChain } from '@aztec/ethereum';
|
|
3
|
+
import { computeBn254G1PublicKey, computeBn254G2PublicKey } from '@aztec/foundation/crypto';
|
|
4
|
+
import { decryptBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
5
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
6
|
+
import { loadKeystoreFile } from '@aztec/node-keystore/loader';
|
|
7
|
+
import { Wallet } from '@ethersproject/wallet';
|
|
8
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
9
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
10
|
+
import { privateKeyToAddress } from 'viem/accounts';
|
|
11
|
+
/**
|
|
12
|
+
* Check if an object is a MnemonicConfig
|
|
13
|
+
*/ function isMnemonicConfig(obj) {
|
|
14
|
+
return typeof obj === 'object' && obj !== null && 'mnemonic' in obj;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if a value is an encrypted keystore file config
|
|
18
|
+
*/ function isEncryptedKeyFileConfig(value) {
|
|
19
|
+
return typeof value === 'object' && value !== null && 'path' in value;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a BLSAccount is a private key string (not an encrypted keystore file)
|
|
23
|
+
*/ function isBlsPrivateKey(bls) {
|
|
24
|
+
return typeof bls === 'string' && bls.startsWith('0x');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check if an EthAccount is a private key string (66 chars: 0x + 64 hex)
|
|
28
|
+
*/ function isEthPrivateKey(eth) {
|
|
29
|
+
return typeof eth === 'string' && eth.startsWith('0x') && eth.length === 66;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check if a string is an Ethereum address (42 chars: 0x + 40 hex)
|
|
33
|
+
*/ function isEthAddress(value) {
|
|
34
|
+
return typeof value === 'string' && /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decrypt a BLS private key from an encrypted keystore file
|
|
38
|
+
*/ function decryptBlsKey(bls, password) {
|
|
39
|
+
if (isBlsPrivateKey(bls)) {
|
|
40
|
+
return bls;
|
|
41
|
+
}
|
|
42
|
+
if (isEncryptedKeyFileConfig(bls)) {
|
|
43
|
+
if (!password && !bls.password) {
|
|
44
|
+
return undefined; // Can't decrypt without password
|
|
45
|
+
}
|
|
46
|
+
const pwd = password ?? bls.password;
|
|
47
|
+
return decryptBn254Keystore(bls.path, pwd);
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Decrypt an Ethereum private key from an encrypted keystore file
|
|
53
|
+
*/ async function decryptEthKey(eth, password) {
|
|
54
|
+
if (isEthPrivateKey(eth)) {
|
|
55
|
+
return eth;
|
|
56
|
+
}
|
|
57
|
+
if (isEncryptedKeyFileConfig(eth)) {
|
|
58
|
+
if (!password && !eth.password) {
|
|
59
|
+
return undefined; // Can't decrypt without password
|
|
60
|
+
}
|
|
61
|
+
const pwd = password ?? eth.password;
|
|
62
|
+
const json = readFileSync(eth.path, 'utf-8');
|
|
63
|
+
const wallet = await Wallet.fromEncryptedJson(json, pwd);
|
|
64
|
+
return wallet.privateKey;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extract Ethereum address from an EthAccount (or private key)
|
|
70
|
+
*/ async function getEthAddress(eth, password) {
|
|
71
|
+
// Case 1: It's a private key string - derive the address
|
|
72
|
+
if (isEthPrivateKey(eth)) {
|
|
73
|
+
return privateKeyToAddress(eth);
|
|
74
|
+
}
|
|
75
|
+
// Case 2: It's just an address string directly (EthRemoteSignerAccount can be just EthAddress)
|
|
76
|
+
if (isEthAddress(eth)) {
|
|
77
|
+
return eth;
|
|
78
|
+
}
|
|
79
|
+
// Case 3: It's an object with an address property (remote signer config)
|
|
80
|
+
if (typeof eth === 'object' && eth !== null && 'address' in eth) {
|
|
81
|
+
return eth.address;
|
|
82
|
+
}
|
|
83
|
+
// Case 4: It's an encrypted keystore file - decrypt and derive address
|
|
84
|
+
if (isEncryptedKeyFileConfig(eth)) {
|
|
85
|
+
const privateKey = await decryptEthKey(eth, password);
|
|
86
|
+
if (privateKey) {
|
|
87
|
+
return privateKeyToAddress(privateKey);
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Extract BLS private key and Ethereum address from an AttesterAccount
|
|
95
|
+
*/ async function extractAttesterInfo(attester, password) {
|
|
96
|
+
// Case 1: attester is { eth: EthAccount, bls?: BLSAccount }
|
|
97
|
+
if (typeof attester === 'object' && attester !== null && 'eth' in attester) {
|
|
98
|
+
const ethAddress = await getEthAddress(attester.eth, password);
|
|
99
|
+
const blsPrivateKey = attester.bls ? decryptBlsKey(attester.bls, password) : undefined;
|
|
100
|
+
return {
|
|
101
|
+
blsPrivateKey,
|
|
102
|
+
ethAddress
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// Case 2: attester is just an EthAccount directly (no BLS key)
|
|
106
|
+
return {
|
|
107
|
+
blsPrivateKey: undefined,
|
|
108
|
+
ethAddress: await getEthAddress(attester, password)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Process a single attester entry and output staking JSON
|
|
113
|
+
*/ async function processAttester(attester, gse, password) {
|
|
114
|
+
const { blsPrivateKey, ethAddress } = await extractAttesterInfo(attester, password);
|
|
115
|
+
// Skip if no BLS private key or no Ethereum address
|
|
116
|
+
if (!blsPrivateKey || !ethAddress) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
// Derive G1 and G2 public keys
|
|
120
|
+
const g1PublicKey = await computeBn254G1PublicKey(blsPrivateKey);
|
|
121
|
+
const g2PublicKey = await computeBn254G2PublicKey(blsPrivateKey);
|
|
122
|
+
// Generate proof of possession
|
|
123
|
+
const bn254SecretKeyFieldElement = Fr.fromString(blsPrivateKey);
|
|
124
|
+
const registrationTuple = await gse.makeRegistrationTuple(bn254SecretKeyFieldElement.toBigInt());
|
|
125
|
+
return {
|
|
126
|
+
attester: String(ethAddress),
|
|
127
|
+
publicKeyG1: {
|
|
128
|
+
x: '0x' + g1PublicKey.x.toString(16).padStart(64, '0'),
|
|
129
|
+
y: '0x' + g1PublicKey.y.toString(16).padStart(64, '0')
|
|
130
|
+
},
|
|
131
|
+
publicKeyG2: {
|
|
132
|
+
x0: '0x' + g2PublicKey.x.c0.toString(16).padStart(64, '0'),
|
|
133
|
+
x1: '0x' + g2PublicKey.x.c1.toString(16).padStart(64, '0'),
|
|
134
|
+
y0: '0x' + g2PublicKey.y.c0.toString(16).padStart(64, '0'),
|
|
135
|
+
y1: '0x' + g2PublicKey.y.c1.toString(16).padStart(64, '0')
|
|
136
|
+
},
|
|
137
|
+
proofOfPossession: {
|
|
138
|
+
x: '0x' + registrationTuple.proofOfPossession.x.toString(16),
|
|
139
|
+
y: '0x' + registrationTuple.proofOfPossession.y.toString(16)
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Process AttesterAccounts (which can be a single attester, array, or mnemonic)
|
|
145
|
+
*/ export async function processAttesterAccounts(attesterAccounts, gse, password) {
|
|
146
|
+
// Skip mnemonic configs
|
|
147
|
+
if (isMnemonicConfig(attesterAccounts)) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
// Handle array of attesters
|
|
151
|
+
if (Array.isArray(attesterAccounts)) {
|
|
152
|
+
const results = [];
|
|
153
|
+
for (const attester of attesterAccounts){
|
|
154
|
+
const result = await processAttester(attester, gse, password);
|
|
155
|
+
if (result) {
|
|
156
|
+
results.push(result);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return results;
|
|
160
|
+
}
|
|
161
|
+
// Handle single attester
|
|
162
|
+
const result = await processAttester(attesterAccounts, gse, password);
|
|
163
|
+
return result ? [
|
|
164
|
+
result
|
|
165
|
+
] : [];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Main staker command function
|
|
169
|
+
*/ export async function generateStakerJson(options, log) {
|
|
170
|
+
const { from, password, gseAddress, l1RpcUrls, l1ChainId, output } = options;
|
|
171
|
+
// Load the keystore file
|
|
172
|
+
const keystore = loadKeystoreFile(from);
|
|
173
|
+
if (!gseAddress) {
|
|
174
|
+
throw new Error('GSE contract address is required');
|
|
175
|
+
}
|
|
176
|
+
log(`Calling GSE contract ${gseAddress} on chain ${l1ChainId}, using ${l1RpcUrls.join(', ')} to get staker outputs`);
|
|
177
|
+
if (!keystore.validators || keystore.validators.length === 0) {
|
|
178
|
+
log('No validators found in keystore');
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const allOutputs = [];
|
|
182
|
+
// L1 client for proof of possession
|
|
183
|
+
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
184
|
+
const publicClient = createPublicClient({
|
|
185
|
+
chain: chain.chainInfo,
|
|
186
|
+
transport: fallback(l1RpcUrls.map((url)=>http(url)))
|
|
187
|
+
});
|
|
188
|
+
const gse = new GSEContract(publicClient, gseAddress);
|
|
189
|
+
// Process each validator
|
|
190
|
+
for (const validator of keystore.validators){
|
|
191
|
+
const outputs = await processAttesterAccounts(validator.attester, gse, password);
|
|
192
|
+
allOutputs.push(...outputs);
|
|
193
|
+
}
|
|
194
|
+
if (allOutputs.length === 0) {
|
|
195
|
+
log('No attesters with BLS keys found (skipping mnemonics and encrypted keystores without password)');
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const jsonOutput = prettyPrintJSON(allOutputs);
|
|
199
|
+
// Write to file if output is specified, otherwise log to stdout
|
|
200
|
+
if (output) {
|
|
201
|
+
writeFileSync(output, jsonOutput, 'utf-8');
|
|
202
|
+
log(`Wrote staking data to ${output}`);
|
|
203
|
+
} else {
|
|
204
|
+
log(jsonOutput);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -15,6 +15,7 @@ export type L2ChainConfig = L1ContractsConfig & Omit<SlasherConfig, 'slashValida
|
|
|
15
15
|
autoUpdate: SharedNodeConfig['autoUpdate'];
|
|
16
16
|
autoUpdateUrl?: string;
|
|
17
17
|
maxTxPoolSize: number;
|
|
18
|
+
publicMetricsOptOut: boolean;
|
|
18
19
|
publicIncludeMetrics?: string[];
|
|
19
20
|
publicMetricsCollectorUrl?: string;
|
|
20
21
|
publicMetricsCollectFrom?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/config/chain_l2_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAYrE,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,IAAI,CAAC,aAAa,EAAE,sBAAsB,GAAG,uBAAuB,CAAC,GAAG;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IACpC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAIhC,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,E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C;IACpC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAIhC,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uBAAuB,EAAE,MAAM,CAAC;IAGhC,eAAe,EAAE,OAAO,CAAC;IACzB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AA+CJ,eAAO,MAAM,4BAA4B,EAAE,aA+E1C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAoDxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAoDlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAsFlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAoFlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,aAoDjC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,YAAY,GAAG,aAAa,GAAG,SAAS,CAgBrF;AAMD,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,YAAY,QAsGzE"}
|
|
@@ -58,7 +58,8 @@ export const stagingIgnitionL2ChainConfig = {
|
|
|
58
58
|
],
|
|
59
59
|
autoUpdate: 'config-and-version',
|
|
60
60
|
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/staging-ignition.json',
|
|
61
|
-
maxTxPoolSize:
|
|
61
|
+
maxTxPoolSize: 0,
|
|
62
|
+
publicMetricsOptOut: false,
|
|
62
63
|
publicIncludeMetrics,
|
|
63
64
|
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
|
|
64
65
|
publicMetricsCollectFrom: [
|
|
@@ -123,6 +124,7 @@ export const stagingPublicL2ChainConfig = {
|
|
|
123
124
|
],
|
|
124
125
|
autoUpdate: 'config-and-version',
|
|
125
126
|
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/staging-public.json',
|
|
127
|
+
publicMetricsOptOut: false,
|
|
126
128
|
publicIncludeMetrics,
|
|
127
129
|
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
|
|
128
130
|
publicMetricsCollectFrom: [
|
|
@@ -160,6 +162,7 @@ export const nextNetL2ChainConfig = {
|
|
|
160
162
|
snapshotsUrls: [],
|
|
161
163
|
autoUpdate: 'config-and-version',
|
|
162
164
|
autoUpdateUrl: '',
|
|
165
|
+
publicMetricsOptOut: true,
|
|
163
166
|
publicIncludeMetrics,
|
|
164
167
|
publicMetricsCollectorUrl: '',
|
|
165
168
|
publicMetricsCollectFrom: [
|
|
@@ -200,6 +203,7 @@ export const testnetL2ChainConfig = {
|
|
|
200
203
|
autoUpdate: 'config-and-version',
|
|
201
204
|
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/testnet.json',
|
|
202
205
|
maxTxPoolSize: 100_000_000,
|
|
206
|
+
publicMetricsOptOut: false,
|
|
203
207
|
publicIncludeMetrics,
|
|
204
208
|
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
|
|
205
209
|
publicMetricsCollectFrom: [
|
|
@@ -267,12 +271,14 @@ export const mainnetL2ChainConfig = {
|
|
|
267
271
|
],
|
|
268
272
|
autoUpdate: 'notify',
|
|
269
273
|
autoUpdateUrl: 'https://storage.googleapis.com/aztec-mainnet/auto-update/mainnet.json',
|
|
270
|
-
maxTxPoolSize:
|
|
274
|
+
maxTxPoolSize: 0,
|
|
275
|
+
publicMetricsOptOut: true,
|
|
271
276
|
publicIncludeMetrics,
|
|
272
277
|
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
|
|
273
278
|
publicMetricsCollectFrom: [
|
|
274
279
|
'sequencer'
|
|
275
280
|
],
|
|
281
|
+
blobAllowEmptySources: true,
|
|
276
282
|
/** How many seconds an L1 slot lasts. */ ethereumSlotDuration: 12,
|
|
277
283
|
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 72,
|
|
278
284
|
/** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
|
|
@@ -284,7 +290,7 @@ export const mainnetL2ChainConfig = {
|
|
|
284
290
|
slashingRoundSizeInEpochs: 4,
|
|
285
291
|
slashingExecutionDelayInRounds: 28,
|
|
286
292
|
slashingLifetimeInRounds: 34,
|
|
287
|
-
slashingVetoer: EthAddress.
|
|
293
|
+
slashingVetoer: EthAddress.fromString('0xBbB4aF368d02827945748b28CD4b2D42e4A37480'),
|
|
288
294
|
slashingOffsetInRounds: 2,
|
|
289
295
|
slashingDisableDuration: 259_200,
|
|
290
296
|
slasherFlavor: 'tally',
|
|
@@ -330,6 +336,7 @@ export const devnetL2ChainConfig = {
|
|
|
330
336
|
snapshotsUrls: [],
|
|
331
337
|
autoUpdate: 'config-and-version',
|
|
332
338
|
autoUpdateUrl: '',
|
|
339
|
+
publicMetricsOptOut: true,
|
|
333
340
|
publicIncludeMetrics,
|
|
334
341
|
publicMetricsCollectorUrl: '',
|
|
335
342
|
publicMetricsCollectFrom: [
|
|
@@ -432,6 +439,7 @@ export function enrichEnvironmentWithChainConfig(networkName) {
|
|
|
432
439
|
if (config.publicMetricsCollectFrom) {
|
|
433
440
|
enrichVar('PUBLIC_OTEL_COLLECT_FROM', config.publicMetricsCollectFrom.join(','));
|
|
434
441
|
}
|
|
442
|
+
enrichVar('PUBLIC_OTEL_OPT_OUT', config.publicMetricsOptOut.toString());
|
|
435
443
|
// Deployment stuff
|
|
436
444
|
enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
|
|
437
445
|
enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
|