@aztec/cli 0.0.0-test.1 → 0.0.1-commit.b655e406
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 -427
- 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 +9 -0
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts +3 -0
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_current_base_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 +6 -0
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
- package/dest/cmds/{pxe → aztec_node}/get_logs.js +4 -4
- package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
- package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
- package/dest/cmds/{pxe → aztec_node}/get_node_info.js +14 -15
- package/dest/cmds/aztec_node/index.d.ts.map +1 -0
- package/dest/cmds/aztec_node/index.js +28 -0
- package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
- package/dest/cmds/contracts/inspect_contract.js +9 -5
- package/dest/cmds/infrastructure/index.d.ts +2 -2
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +8 -9
- package/dest/cmds/infrastructure/sequencers.d.ts +4 -4
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +29 -16
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.js +11 -24
- package/dest/cmds/l1/advance_epoch.d.ts +1 -1
- 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 +1 -1
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +9 -8
- package/dest/cmds/l1/bridge_erc20.d.ts +2 -2
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +5 -5
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +2 -2
- package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.js +23 -6
- package/dest/cmds/l1/deploy_new_rollup.d.ts +2 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +17 -8
- package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
- package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.js +17 -17
- package/dest/cmds/l1/index.d.ts +1 -0
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +33 -43
- 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 +19 -0
- package/dest/cmds/l1/update_l1_validators.d.ts +17 -2
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +159 -103
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
- 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_secret_and_hash.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +3 -3
- package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
- 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.map +1 -1
- package/dest/cmds/misc/index.js +7 -3
- package/dest/cmds/misc/update/github.d.ts +0 -1
- 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.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 +70 -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 +26 -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 +20 -0
- package/dest/cmds/validator_keys/new.d.ts +26 -0
- package/dest/cmds/validator_keys/new.d.ts.map +1 -0
- package/dest/cmds/validator_keys/new.js +60 -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 +271 -0
- package/dest/config/cached_fetch.d.ts +18 -0
- package/dest/config/cached_fetch.d.ts.map +1 -0
- package/dest/config/cached_fetch.js +54 -0
- package/dest/config/chain_l2_config.d.ts +39 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +475 -0
- package/dest/config/enrich_env.d.ts +4 -0
- package/dest/config/enrich_env.d.ts.map +1 -0
- package/dest/config/enrich_env.js +12 -0
- package/dest/config/get_l1_config.d.ts +8 -0
- package/dest/config/get_l1_config.d.ts.map +1 -0
- package/dest/config/get_l1_config.js +22 -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 +19 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +79 -0
- package/dest/utils/aztec.d.ts +12 -17
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +54 -49
- package/dest/utils/commands.d.ts +17 -9
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +40 -14
- package/dest/utils/encoding.js +1 -1
- package/dest/utils/github.d.ts +0 -1
- package/dest/utils/github.d.ts.map +1 -1
- package/dest/utils/github.js +0 -1
- package/dest/utils/index.d.ts +1 -0
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -0
- package/dest/utils/inspect.d.ts +3 -10
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +19 -109
- 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 +44 -33
- package/src/cmds/aztec_node/block_number.ts +9 -0
- package/src/cmds/aztec_node/get_block.ts +10 -0
- package/src/cmds/aztec_node/get_current_base_fee.ts +9 -0
- package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
- package/src/cmds/{pxe → aztec_node}/get_logs.ts +8 -7
- package/src/cmds/{pxe → aztec_node}/get_node_info.ts +15 -23
- package/src/cmds/aztec_node/index.ts +87 -0
- package/src/cmds/contracts/inspect_contract.ts +16 -6
- package/src/cmds/infrastructure/index.ts +8 -10
- package/src/cmds/infrastructure/sequencers.ts +36 -19
- package/src/cmds/infrastructure/setup_l2_contract.ts +13 -25
- package/src/cmds/l1/advance_epoch.ts +7 -5
- package/src/cmds/l1/assume_proven_through.ts +8 -7
- package/src/cmds/l1/bridge_erc20.ts +7 -4
- package/src/cmds/l1/deploy_l1_contracts.ts +32 -7
- package/src/cmds/l1/deploy_new_rollup.ts +23 -9
- package/src/cmds/l1/get_l1_addresses.ts +1 -1
- package/src/cmds/l1/governance_utils.ts +18 -17
- package/src/cmds/l1/index.ts +74 -101
- package/src/cmds/l1/trigger_seed_snapshot.ts +31 -0
- package/src/cmds/l1/update_l1_validators.ts +194 -94
- package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
- package/src/cmds/misc/generate_secret_and_hash.ts +3 -3
- 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 +13 -4
- package/src/cmds/misc/update/github.ts +0 -1
- package/src/cmds/misc/update.ts +1 -7
- package/src/cmds/validator_keys/add.ts +113 -0
- package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
- package/src/cmds/validator_keys/index.ts +96 -0
- package/src/cmds/validator_keys/new.ts +120 -0
- package/src/cmds/validator_keys/shared.ts +321 -0
- package/src/config/cached_fetch.ts +67 -0
- package/src/config/chain_l2_config.ts +627 -0
- package/src/config/enrich_env.ts +15 -0
- package/src/config/get_l1_config.ts +28 -0
- package/src/config/index.ts +4 -0
- package/src/config/network_config.ts +102 -0
- package/src/utils/aztec.ts +78 -65
- package/src/utils/commands.ts +54 -18
- package/src/utils/encoding.ts +1 -1
- package/src/utils/github.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/inspect.ts +23 -123
- 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.map +0 -1
- package/dest/cmds/devnet/index.js +0 -14
- 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_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_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_pxe_info.ts +0 -13
- package/src/cmds/pxe/index.ts +0 -170
- /package/dest/cmds/{devnet → aztec_node}/index.d.ts +0 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
+
import { computeBn254G1PublicKeyCompressed, deriveBlsPrivateKey } from '@aztec/foundation/crypto';
|
|
3
|
+
import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
4
|
+
import { Wallet } from '@ethersproject/wallet';
|
|
5
|
+
import { constants as fsConstants, mkdirSync } from 'fs';
|
|
6
|
+
import { access, writeFile } from 'fs/promises';
|
|
7
|
+
import { homedir } from 'os';
|
|
8
|
+
import { dirname, isAbsolute, join } from 'path';
|
|
9
|
+
import { mnemonicToAccount } from 'viem/accounts';
|
|
10
|
+
export function withValidatorIndex(path, index) {
|
|
11
|
+
const parts = path.split('/');
|
|
12
|
+
if (parts.length >= 4 && parts[0] === 'm' && parts[1] === '12381' && parts[2] === '3600') {
|
|
13
|
+
parts[3] = String(index);
|
|
14
|
+
return parts.join('/');
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compute a compressed BN254 G1 public key from a private key.
|
|
20
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
21
|
+
* @returns Compressed G1 point (32 bytes with sign bit in MSB)
|
|
22
|
+
*/ export async function computeBlsPublicKeyCompressed(privateKeyHex) {
|
|
23
|
+
return await computeBn254G1PublicKeyCompressed(privateKeyHex);
|
|
24
|
+
}
|
|
25
|
+
export function deriveEthAttester(mnemonic, baseAccountIndex, addressIndex, remoteSigner) {
|
|
26
|
+
const acct = mnemonicToAccount(mnemonic, {
|
|
27
|
+
accountIndex: baseAccountIndex,
|
|
28
|
+
addressIndex
|
|
29
|
+
});
|
|
30
|
+
return remoteSigner ? {
|
|
31
|
+
address: acct.address,
|
|
32
|
+
remoteSignerUrl: remoteSigner
|
|
33
|
+
} : '0x' + Buffer.from(acct.getHdKey().privateKey).toString('hex');
|
|
34
|
+
}
|
|
35
|
+
export async function buildValidatorEntries(input) {
|
|
36
|
+
const { validatorCount, publisherCount = 0, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath, blsOnly, feeRecipient, coinbase, remoteSigner, fundingAccount } = input;
|
|
37
|
+
const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
38
|
+
const summaries = [];
|
|
39
|
+
const validators = await Promise.all(Array.from({
|
|
40
|
+
length: validatorCount
|
|
41
|
+
}, async (_unused, i)=>{
|
|
42
|
+
const addressIndex = baseAddressIndex + i;
|
|
43
|
+
const basePath = blsPath ?? defaultBlsPath;
|
|
44
|
+
const perValidatorPath = withValidatorIndex(basePath, addressIndex);
|
|
45
|
+
const blsPrivKey = blsOnly || ikm || mnemonic ? deriveBlsPrivateKey(mnemonic, ikm, perValidatorPath) : undefined;
|
|
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
|
+
const ethAttester = deriveEthAttester(mnemonic, accountIndex, addressIndex, remoteSigner);
|
|
60
|
+
const attester = blsPrivKey ? {
|
|
61
|
+
eth: ethAttester,
|
|
62
|
+
bls: blsPrivKey
|
|
63
|
+
} : ethAttester;
|
|
64
|
+
let publisherField;
|
|
65
|
+
const publisherAddresses = [];
|
|
66
|
+
if (publisherCount > 0) {
|
|
67
|
+
const publishersBaseIndex = baseAddressIndex + validatorCount + i * publisherCount;
|
|
68
|
+
const publisherAccounts = Array.from({
|
|
69
|
+
length: publisherCount
|
|
70
|
+
}, (_unused2, j)=>{
|
|
71
|
+
const publisherAddressIndex = publishersBaseIndex + j;
|
|
72
|
+
const pubAcct = mnemonicToAccount(mnemonic, {
|
|
73
|
+
accountIndex,
|
|
74
|
+
addressIndex: publisherAddressIndex
|
|
75
|
+
});
|
|
76
|
+
publisherAddresses.push(pubAcct.address);
|
|
77
|
+
return remoteSigner ? {
|
|
78
|
+
address: pubAcct.address,
|
|
79
|
+
remoteSignerUrl: remoteSigner
|
|
80
|
+
} : '0x' + Buffer.from(pubAcct.getHdKey().privateKey).toString('hex');
|
|
81
|
+
});
|
|
82
|
+
publisherField = publisherCount === 1 ? publisherAccounts[0] : publisherAccounts;
|
|
83
|
+
}
|
|
84
|
+
const acct = mnemonicToAccount(mnemonic, {
|
|
85
|
+
accountIndex,
|
|
86
|
+
addressIndex
|
|
87
|
+
});
|
|
88
|
+
const attesterEthAddress = acct.address;
|
|
89
|
+
summaries.push({
|
|
90
|
+
attesterEth: attesterEthAddress,
|
|
91
|
+
attesterBls: blsPubCompressed,
|
|
92
|
+
publisherEth: publisherAddresses.length > 0 ? publisherAddresses : undefined
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
attester,
|
|
96
|
+
...publisherField !== undefined ? {
|
|
97
|
+
publisher: publisherField
|
|
98
|
+
} : {},
|
|
99
|
+
feeRecipient,
|
|
100
|
+
coinbase,
|
|
101
|
+
fundingAccount
|
|
102
|
+
};
|
|
103
|
+
}));
|
|
104
|
+
return {
|
|
105
|
+
validators,
|
|
106
|
+
summaries
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export async function resolveKeystoreOutputPath(dataDir, file) {
|
|
110
|
+
const defaultDataDir = join(homedir(), '.aztec', 'keystore');
|
|
111
|
+
const resolvedDir = dataDir && dataDir.length > 0 ? dataDir : defaultDataDir;
|
|
112
|
+
let outputPath;
|
|
113
|
+
if (file && file.length > 0) {
|
|
114
|
+
outputPath = isAbsolute(file) ? file : join(resolvedDir, file);
|
|
115
|
+
} else {
|
|
116
|
+
let index = 1;
|
|
117
|
+
while(true){
|
|
118
|
+
const candidate = join(resolvedDir, `key${index}.json`);
|
|
119
|
+
try {
|
|
120
|
+
await access(candidate, fsConstants.F_OK);
|
|
121
|
+
index += 1;
|
|
122
|
+
} catch {
|
|
123
|
+
outputPath = candidate;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
resolvedDir,
|
|
130
|
+
outputPath: outputPath
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export async function writeKeystoreFile(path, keystore) {
|
|
134
|
+
mkdirSync(dirname(path), {
|
|
135
|
+
recursive: true
|
|
136
|
+
});
|
|
137
|
+
await writeFile(path, JSON.stringify(keystore, null, 2), {
|
|
138
|
+
encoding: 'utf-8'
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export function logValidatorSummaries(log, summaries) {
|
|
142
|
+
const lines = [];
|
|
143
|
+
for(let i = 0; i < summaries.length; i++){
|
|
144
|
+
const v = summaries[i];
|
|
145
|
+
lines.push(`acc${i + 1}:`);
|
|
146
|
+
lines.push(` attester:`);
|
|
147
|
+
if (v.attesterEth) {
|
|
148
|
+
lines.push(` eth: ${v.attesterEth}`);
|
|
149
|
+
}
|
|
150
|
+
if (v.attesterBls) {
|
|
151
|
+
lines.push(` bls: ${v.attesterBls}`);
|
|
152
|
+
}
|
|
153
|
+
if (v.publisherEth && v.publisherEth.length > 0) {
|
|
154
|
+
lines.push(` publisher:`);
|
|
155
|
+
for (const addr of v.publisherEth){
|
|
156
|
+
lines.push(` - ${addr}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (lines.length > 0) {
|
|
161
|
+
log(lines.join('\n'));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export function maybePrintJson(log, jsonFlag, obj) {
|
|
165
|
+
if (jsonFlag) {
|
|
166
|
+
log(prettyPrintJSON(obj));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Writes a BN254 keystore file for a BN254 BLS private key.
|
|
171
|
+
* Returns the absolute path to the written file.
|
|
172
|
+
*
|
|
173
|
+
* @param outDir - Directory to write the keystore file to
|
|
174
|
+
* @param fileNameBase - Base name for the keystore file (will be sanitized)
|
|
175
|
+
* @param password - Password for encrypting the private key
|
|
176
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string (32 bytes)
|
|
177
|
+
* @param pubkeyHex - Public key as hex string
|
|
178
|
+
* @param derivationPath - BIP-44 style derivation path
|
|
179
|
+
* @returns Absolute path to the written keystore file
|
|
180
|
+
*/ export async function writeBn254BlsKeystore(outDir, fileNameBase, password, privateKeyHex, pubkeyHex, derivationPath) {
|
|
181
|
+
mkdirSync(outDir, {
|
|
182
|
+
recursive: true
|
|
183
|
+
});
|
|
184
|
+
const keystore = createBn254Keystore(password, privateKeyHex, pubkeyHex, derivationPath);
|
|
185
|
+
const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
186
|
+
const outPath = join(outDir, `keystore-${safeBase}.json`);
|
|
187
|
+
await writeFile(outPath, JSON.stringify(keystore, null, 2), {
|
|
188
|
+
encoding: 'utf-8'
|
|
189
|
+
});
|
|
190
|
+
return outPath;
|
|
191
|
+
}
|
|
192
|
+
/** Replace plaintext BLS keys in validators with { path, password } pointing to BN254 keystore files. */ export async function writeBlsBn254ToFile(validators, options) {
|
|
193
|
+
for(let i = 0; i < validators.length; i++){
|
|
194
|
+
const v = validators[i];
|
|
195
|
+
if (!v || typeof v !== 'object' || !('attester' in v)) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const att = v.attester;
|
|
199
|
+
// Shapes: { bls: <hex> } or { eth: <ethAccount>, bls?: <hex> } or plain EthAccount
|
|
200
|
+
const blsKey = typeof att === 'object' && 'bls' in att ? att.bls : undefined;
|
|
201
|
+
if (!blsKey || typeof blsKey !== 'string') {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const pub = await computeBlsPublicKeyCompressed(blsKey);
|
|
205
|
+
const path = 'm/12381/3600/0/0/0';
|
|
206
|
+
const fileBase = `${String(i + 1)}_${pub.slice(2, 18)}`;
|
|
207
|
+
const keystorePath = await writeBn254BlsKeystore(options.outDir, fileBase, options.password, blsKey, pub, path);
|
|
208
|
+
if (typeof att === 'object') {
|
|
209
|
+
att.bls = {
|
|
210
|
+
path: keystorePath,
|
|
211
|
+
password: options.password
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */ export async function writeEthJsonV3Keystore(outDir, fileNameBase, password, privateKeyHex) {
|
|
217
|
+
const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
218
|
+
mkdirSync(outDir, {
|
|
219
|
+
recursive: true
|
|
220
|
+
});
|
|
221
|
+
const wallet = new Wallet(privateKeyHex);
|
|
222
|
+
const json = await wallet.encrypt(password);
|
|
223
|
+
const outPath = join(outDir, `keystore-eth-${safeBase}.json`);
|
|
224
|
+
await writeFile(outPath, json, {
|
|
225
|
+
encoding: 'utf-8'
|
|
226
|
+
});
|
|
227
|
+
return outPath;
|
|
228
|
+
}
|
|
229
|
+
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */ export async function writeEthJsonV3ToFile(validators, options) {
|
|
230
|
+
const maybeEncryptEth = async (account, label)=>{
|
|
231
|
+
if (typeof account === 'string' && account.startsWith('0x') && account.length === 66) {
|
|
232
|
+
const fileBase = `${label}_${account.slice(2, 10)}`;
|
|
233
|
+
const p = await writeEthJsonV3Keystore(options.outDir, fileBase, options.password, account);
|
|
234
|
+
return {
|
|
235
|
+
path: p,
|
|
236
|
+
password: options.password
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return account;
|
|
240
|
+
};
|
|
241
|
+
for(let i = 0; i < validators.length; i++){
|
|
242
|
+
const v = validators[i];
|
|
243
|
+
if (!v || typeof v !== 'object') {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
// attester may be string (eth), object with eth, or remote signer
|
|
247
|
+
const att = v.attester;
|
|
248
|
+
if (typeof att === 'string') {
|
|
249
|
+
v.attester = await maybeEncryptEth(att, `attester_${i + 1}`);
|
|
250
|
+
} else if (att && typeof att === 'object' && 'eth' in att) {
|
|
251
|
+
att.eth = await maybeEncryptEth(att.eth, `attester_${i + 1}`);
|
|
252
|
+
}
|
|
253
|
+
// publisher can be single or array
|
|
254
|
+
if ('publisher' in v) {
|
|
255
|
+
const pub = v.publisher;
|
|
256
|
+
if (Array.isArray(pub)) {
|
|
257
|
+
const out = [];
|
|
258
|
+
for(let j = 0; j < pub.length; j++){
|
|
259
|
+
out.push(await maybeEncryptEth(pub[j], `publisher_${i + 1}_${j + 1}`));
|
|
260
|
+
}
|
|
261
|
+
v.publisher = out;
|
|
262
|
+
} else if (pub !== undefined) {
|
|
263
|
+
v.publisher = await maybeEncryptEth(pub, `publisher_${i + 1}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Optional fundingAccount within validator
|
|
267
|
+
if ('fundingAccount' in v) {
|
|
268
|
+
v.fundingAccount = await maybeEncryptEth(v.fundingAccount, `funding_${i + 1}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface CachedFetchOptions {
|
|
2
|
+
/** Cache duration in milliseconds */
|
|
3
|
+
cacheDurationMs: number;
|
|
4
|
+
/** The cache file */
|
|
5
|
+
cacheFile?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fetches data from a URL with file-based caching support.
|
|
9
|
+
* This utility can be used by both remote config and bootnodes fetching.
|
|
10
|
+
*
|
|
11
|
+
* @param url - The URL to fetch from
|
|
12
|
+
* @param networkName - Network name for cache directory structure
|
|
13
|
+
* @param options - Caching and error handling options
|
|
14
|
+
* @param cacheDir - Optional cache directory (defaults to no caching)
|
|
15
|
+
* @returns The fetched and parsed JSON data, or undefined if fetch fails and throwOnError is false
|
|
16
|
+
*/
|
|
17
|
+
export declare function cachedFetch<T = any>(url: string, options: CachedFetchOptions, fetch?: typeof globalThis.fetch, log?: import("@aztec/aztec.js/log").Logger): Promise<T | undefined>;
|
|
18
|
+
//# sourceMappingURL=cached_fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached_fetch.d.ts","sourceRoot":"","sources":["../../src/config/cached_fetch.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,GAAG,EACvC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,EAC3B,KAAK,0BAAmB,EACxB,GAAG,uCAA+B,GACjC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAuCxB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
+
import { mkdir, readFile, stat, writeFile } from 'fs/promises';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
/**
|
|
5
|
+
* Fetches data from a URL with file-based caching support.
|
|
6
|
+
* This utility can be used by both remote config and bootnodes fetching.
|
|
7
|
+
*
|
|
8
|
+
* @param url - The URL to fetch from
|
|
9
|
+
* @param networkName - Network name for cache directory structure
|
|
10
|
+
* @param options - Caching and error handling options
|
|
11
|
+
* @param cacheDir - Optional cache directory (defaults to no caching)
|
|
12
|
+
* @returns The fetched and parsed JSON data, or undefined if fetch fails and throwOnError is false
|
|
13
|
+
*/ export async function cachedFetch(url, options, fetch = globalThis.fetch, log = createLogger('cached_fetch')) {
|
|
14
|
+
const { cacheDurationMs, cacheFile } = options;
|
|
15
|
+
// Try to read from cache first
|
|
16
|
+
try {
|
|
17
|
+
if (cacheFile) {
|
|
18
|
+
const info = await stat(cacheFile);
|
|
19
|
+
if (info.mtimeMs + cacheDurationMs > Date.now()) {
|
|
20
|
+
const cachedData = JSON.parse(await readFile(cacheFile, 'utf-8'));
|
|
21
|
+
return cachedData;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
log.trace('Failed to read data from cache');
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const response = await fetch(url);
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const data = await response.json();
|
|
34
|
+
try {
|
|
35
|
+
if (cacheFile) {
|
|
36
|
+
await mkdir(dirname(cacheFile), {
|
|
37
|
+
recursive: true
|
|
38
|
+
});
|
|
39
|
+
await writeFile(cacheFile, JSON.stringify(data), 'utf-8');
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
log.warn('Failed to cache data on disk: ' + cacheFile, {
|
|
43
|
+
cacheFile,
|
|
44
|
+
err
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
} catch (err) {
|
|
49
|
+
log.warn(`Failed to fetch from ${url}`, {
|
|
50
|
+
err
|
|
51
|
+
});
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type L1ContractsConfig } from '@aztec/ethereum';
|
|
2
|
+
import type { NetworkNames } from '@aztec/foundation/config';
|
|
3
|
+
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
4
|
+
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
export type L2ChainConfig = L1ContractsConfig & Omit<SlasherConfig, 'slashValidatorsNever' | 'slashValidatorsAlways'> & {
|
|
6
|
+
l1ChainId: number;
|
|
7
|
+
testAccounts: boolean;
|
|
8
|
+
sponsoredFPC: boolean;
|
|
9
|
+
p2pEnabled: boolean;
|
|
10
|
+
p2pBootstrapNodes: string[];
|
|
11
|
+
seqMinTxsPerBlock: number;
|
|
12
|
+
seqMaxTxsPerBlock: number;
|
|
13
|
+
realProofs: boolean;
|
|
14
|
+
snapshotsUrls: string[];
|
|
15
|
+
autoUpdate: SharedNodeConfig['autoUpdate'];
|
|
16
|
+
autoUpdateUrl?: string;
|
|
17
|
+
maxTxPoolSize: number;
|
|
18
|
+
publicIncludeMetrics?: string[];
|
|
19
|
+
publicMetricsCollectorUrl?: string;
|
|
20
|
+
publicMetricsCollectFrom?: string[];
|
|
21
|
+
skipArchiverInitialSync?: boolean;
|
|
22
|
+
blobAllowEmptySources?: boolean;
|
|
23
|
+
dbMapSizeKb: number;
|
|
24
|
+
archiverStoreMapSizeKb: number;
|
|
25
|
+
noteHashTreeMapSizeKb: number;
|
|
26
|
+
nullifierTreeMapSizeKb: number;
|
|
27
|
+
publicDataTreeMapSizeKb: number;
|
|
28
|
+
sentinelEnabled: boolean;
|
|
29
|
+
disableTransactions: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare const stagingIgnitionL2ChainConfig: L2ChainConfig;
|
|
32
|
+
export declare const stagingPublicL2ChainConfig: L2ChainConfig;
|
|
33
|
+
export declare const nextNetL2ChainConfig: L2ChainConfig;
|
|
34
|
+
export declare const testnetL2ChainConfig: L2ChainConfig;
|
|
35
|
+
export declare const mainnetL2ChainConfig: L2ChainConfig;
|
|
36
|
+
export declare const devnetL2ChainConfig: L2ChainConfig;
|
|
37
|
+
export declare function getL2ChainConfig(networkName: NetworkNames): L2ChainConfig | undefined;
|
|
38
|
+
export declare function enrichEnvironmentWithChainConfig(networkName: NetworkNames): void;
|
|
39
|
+
//# sourceMappingURL=chain_l2_config.d.ts.map
|
|
@@ -0,0 +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,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,aA8E1C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAmDxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAmDlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAqFlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAkFlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,aAmDjC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,YAAY,GAAG,aAAa,GAAG,SAAS,CAgBrF;AAMD,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,YAAY,QAoGzE"}
|