@aztec/cli 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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.
Files changed (191) hide show
  1. package/README.md +1 -1
  2. package/dest/cmds/aztec_node/block_number.d.ts +1 -1
  3. package/dest/cmds/aztec_node/block_number.js +1 -1
  4. package/dest/cmds/aztec_node/get_block.d.ts +1 -1
  5. package/dest/cmds/aztec_node/get_block.d.ts.map +1 -1
  6. package/dest/cmds/aztec_node/get_block.js +2 -1
  7. package/dest/cmds/aztec_node/get_current_min_fee.d.ts +3 -0
  8. package/dest/cmds/aztec_node/get_current_min_fee.d.ts.map +1 -0
  9. package/dest/cmds/aztec_node/{get_current_base_fee.js → get_current_min_fee.js} +2 -2
  10. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +1 -1
  11. package/dest/cmds/aztec_node/get_logs.d.ts +30 -3
  12. package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -1
  13. package/dest/cmds/aztec_node/get_logs.js +39 -29
  14. package/dest/cmds/aztec_node/get_node_info.d.ts +1 -1
  15. package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -1
  16. package/dest/cmds/aztec_node/get_node_info.js +0 -2
  17. package/dest/cmds/aztec_node/index.d.ts +1 -1
  18. package/dest/cmds/aztec_node/index.d.ts.map +1 -1
  19. package/dest/cmds/aztec_node/index.js +16 -6
  20. package/dest/cmds/contracts/index.d.ts +1 -1
  21. package/dest/cmds/contracts/inspect_contract.d.ts +1 -1
  22. package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
  23. package/dest/cmds/contracts/inspect_contract.js +4 -10
  24. package/dest/cmds/contracts/parse_parameter_struct.d.ts +1 -1
  25. package/dest/cmds/infrastructure/index.d.ts +1 -1
  26. package/dest/cmds/infrastructure/index.d.ts.map +1 -1
  27. package/dest/cmds/infrastructure/index.js +0 -1
  28. package/dest/cmds/infrastructure/sequencers.d.ts +1 -2
  29. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
  30. package/dest/cmds/infrastructure/sequencers.js +11 -4
  31. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
  32. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
  33. package/dest/cmds/infrastructure/setup_l2_contract.js +12 -7
  34. package/dest/cmds/l1/advance_epoch.d.ts +1 -1
  35. package/dest/cmds/l1/assume_proven_through.d.ts +3 -2
  36. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
  37. package/dest/cmds/l1/assume_proven_through.js +3 -4
  38. package/dest/cmds/l1/bridge_erc20.d.ts +1 -1
  39. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
  40. package/dest/cmds/l1/bridge_erc20.js +2 -1
  41. package/dest/cmds/l1/compute_genesis_values.d.ts +4 -0
  42. package/dest/cmds/l1/compute_genesis_values.d.ts.map +1 -0
  43. package/dest/cmds/l1/compute_genesis_values.js +17 -0
  44. package/dest/cmds/l1/create_l1_account.d.ts +1 -1
  45. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +4 -0
  46. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -0
  47. package/dest/cmds/l1/{deploy_l1_contracts.js → deploy_l1_contracts_cmd.js} +39 -5
  48. package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -4
  49. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  50. package/dest/cmds/l1/deploy_new_rollup.js +4 -6
  51. package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
  52. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
  53. package/dest/cmds/l1/get_l1_addresses.js +5 -2
  54. package/dest/cmds/l1/get_l1_balance.d.ts +1 -1
  55. package/dest/cmds/l1/get_l1_balance.js +4 -2
  56. package/dest/cmds/l1/governance_utils.d.ts +5 -5
  57. package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
  58. package/dest/cmds/l1/governance_utils.js +3 -1
  59. package/dest/cmds/l1/index.d.ts +1 -2
  60. package/dest/cmds/l1/index.d.ts.map +1 -1
  61. package/dest/cmds/l1/index.js +17 -10
  62. package/dest/cmds/l1/prover_stats.d.ts +1 -1
  63. package/dest/cmds/l1/prover_stats.d.ts.map +1 -1
  64. package/dest/cmds/l1/prover_stats.js +32 -30
  65. package/dest/cmds/l1/trigger_seed_snapshot.d.ts +2 -2
  66. package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -1
  67. package/dest/cmds/l1/trigger_seed_snapshot.js +2 -1
  68. package/dest/cmds/l1/update_l1_validators.d.ts +7 -7
  69. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  70. package/dest/cmds/l1/update_l1_validators.js +58 -20
  71. package/dest/cmds/misc/compute_selector.d.ts +1 -1
  72. package/dest/cmds/misc/example_contracts.d.ts +1 -1
  73. package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
  74. package/dest/cmds/misc/generate_p2p_private_key.d.ts +1 -1
  75. package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
  76. package/dest/cmds/misc/generate_secret_and_hash.js +1 -1
  77. package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
  78. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +1 -1
  79. package/dest/cmds/misc/index.d.ts +1 -1
  80. package/dest/cmds/misc/index.d.ts.map +1 -1
  81. package/dest/cmds/misc/index.js +1 -1
  82. package/dest/cmds/misc/update/common.d.ts +1 -1
  83. package/dest/cmds/misc/update/github.d.ts +1 -1
  84. package/dest/cmds/misc/update/noir.d.ts +1 -1
  85. package/dest/cmds/misc/update/npm.d.ts +1 -1
  86. package/dest/cmds/misc/update/npm.js +1 -1
  87. package/dest/cmds/misc/update/utils.d.ts +1 -1
  88. package/dest/cmds/misc/update.d.ts +1 -1
  89. package/dest/cmds/validator_keys/add.d.ts +1 -1
  90. package/dest/cmds/validator_keys/add.d.ts.map +1 -1
  91. package/dest/cmds/validator_keys/add.js +20 -7
  92. package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts +2 -0
  93. package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts.map +1 -0
  94. package/dest/cmds/validator_keys/eth_json_v3_worker.js +27 -0
  95. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +1 -1
  96. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -1
  97. package/dest/cmds/validator_keys/generate_bls_keypair.js +3 -2
  98. package/dest/cmds/validator_keys/index.d.ts +1 -1
  99. package/dest/cmds/validator_keys/index.d.ts.map +1 -1
  100. package/dest/cmds/validator_keys/index.js +17 -4
  101. package/dest/cmds/validator_keys/new.d.ts +12 -4
  102. package/dest/cmds/validator_keys/new.d.ts.map +1 -1
  103. package/dest/cmds/validator_keys/new.js +163 -19
  104. package/dest/cmds/validator_keys/shared.d.ts +4 -4
  105. package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
  106. package/dest/cmds/validator_keys/shared.js +97 -51
  107. package/dest/cmds/validator_keys/staker.d.ts +38 -0
  108. package/dest/cmds/validator_keys/staker.d.ts.map +1 -0
  109. package/dest/cmds/validator_keys/staker.js +210 -0
  110. package/dest/cmds/validator_keys/utils.d.ts +25 -0
  111. package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
  112. package/dest/cmds/validator_keys/utils.js +52 -0
  113. package/dest/config/cached_fetch.d.ts +19 -10
  114. package/dest/config/cached_fetch.d.ts.map +1 -1
  115. package/dest/config/cached_fetch.js +110 -32
  116. package/dest/config/chain_l2_config.d.ts +18 -38
  117. package/dest/config/chain_l2_config.d.ts.map +1 -1
  118. package/dest/config/chain_l2_config.js +48 -463
  119. package/dest/config/enrich_env.d.ts +1 -1
  120. package/dest/config/generated/networks.d.ts +239 -0
  121. package/dest/config/generated/networks.d.ts.map +1 -0
  122. package/dest/config/generated/networks.js +240 -0
  123. package/dest/config/get_l1_config.d.ts +3 -2
  124. package/dest/config/get_l1_config.d.ts.map +1 -1
  125. package/dest/config/get_l1_config.js +3 -1
  126. package/dest/config/index.d.ts +1 -1
  127. package/dest/config/network_config.d.ts +7 -4
  128. package/dest/config/network_config.d.ts.map +1 -1
  129. package/dest/config/network_config.js +70 -30
  130. package/dest/utils/aztec.d.ts +7 -14
  131. package/dest/utils/aztec.d.ts.map +1 -1
  132. package/dest/utils/aztec.js +19 -41
  133. package/dest/utils/commands.d.ts +20 -11
  134. package/dest/utils/commands.d.ts.map +1 -1
  135. package/dest/utils/commands.js +26 -15
  136. package/dest/utils/encoding.d.ts +1 -1
  137. package/dest/utils/encoding.js +1 -1
  138. package/dest/utils/github.d.ts +1 -1
  139. package/dest/utils/index.d.ts +1 -1
  140. package/dest/utils/inspect.d.ts +3 -2
  141. package/dest/utils/inspect.d.ts.map +1 -1
  142. package/dest/utils/inspect.js +15 -12
  143. package/dest/utils/setup_contracts.d.ts +1 -1
  144. package/package.json +44 -31
  145. package/public_include_metric_prefixes.json +1 -0
  146. package/src/cmds/aztec_node/block_number.ts +1 -1
  147. package/src/cmds/aztec_node/get_block.ts +2 -1
  148. package/src/cmds/aztec_node/{get_current_base_fee.ts → get_current_min_fee.ts} +2 -2
  149. package/src/cmds/aztec_node/get_logs.ts +70 -37
  150. package/src/cmds/aztec_node/get_node_info.ts +0 -2
  151. package/src/cmds/aztec_node/index.ts +16 -11
  152. package/src/cmds/contracts/inspect_contract.ts +4 -11
  153. package/src/cmds/infrastructure/index.ts +0 -1
  154. package/src/cmds/infrastructure/sequencers.ts +7 -5
  155. package/src/cmds/infrastructure/setup_l2_contract.ts +12 -7
  156. package/src/cmds/l1/assume_proven_through.ts +4 -4
  157. package/src/cmds/l1/bridge_erc20.ts +2 -1
  158. package/src/cmds/l1/compute_genesis_values.ts +29 -0
  159. package/src/cmds/l1/{deploy_l1_contracts.ts → deploy_l1_contracts_cmd.ts} +39 -23
  160. package/src/cmds/l1/deploy_new_rollup.ts +5 -12
  161. package/src/cmds/l1/get_l1_addresses.ts +4 -2
  162. package/src/cmds/l1/get_l1_balance.ts +2 -2
  163. package/src/cmds/l1/governance_utils.ts +3 -8
  164. package/src/cmds/l1/index.ts +30 -21
  165. package/src/cmds/l1/prover_stats.ts +42 -31
  166. package/src/cmds/l1/trigger_seed_snapshot.ts +2 -1
  167. package/src/cmds/l1/update_l1_validators.ts +52 -32
  168. package/src/cmds/misc/generate_secret_and_hash.ts +1 -1
  169. package/src/cmds/misc/index.ts +1 -1
  170. package/src/cmds/misc/update/npm.ts +1 -1
  171. package/src/cmds/validator_keys/add.ts +20 -10
  172. package/src/cmds/validator_keys/eth_json_v3_worker.ts +30 -0
  173. package/src/cmds/validator_keys/generate_bls_keypair.ts +3 -2
  174. package/src/cmds/validator_keys/index.ts +85 -25
  175. package/src/cmds/validator_keys/new.ts +211 -25
  176. package/src/cmds/validator_keys/shared.ts +117 -60
  177. package/src/cmds/validator_keys/staker.ts +301 -0
  178. package/src/cmds/validator_keys/utils.ts +81 -0
  179. package/src/config/cached_fetch.ts +119 -31
  180. package/src/config/chain_l2_config.ts +47 -602
  181. package/src/config/generated/networks.ts +244 -0
  182. package/src/config/get_l1_config.ts +4 -1
  183. package/src/config/network_config.ts +80 -31
  184. package/src/utils/aztec.ts +30 -95
  185. package/src/utils/commands.ts +29 -15
  186. package/src/utils/encoding.ts +1 -1
  187. package/src/utils/inspect.ts +13 -10
  188. package/dest/cmds/aztec_node/get_current_base_fee.d.ts +0 -3
  189. package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +0 -1
  190. package/dest/cmds/l1/deploy_l1_contracts.d.ts +0 -4
  191. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +0 -1
@@ -1,25 +1,18 @@
1
- import {
2
- GSEContract,
3
- RollupContract,
4
- createEthereumChain,
5
- createExtendedL1Client,
6
- createL1TxUtilsFromViemWallet,
7
- getL1ContractsConfigEnvVars,
8
- getPublicClient,
9
- isAnvilTestChain,
10
- } from '@aztec/ethereum';
1
+ import { createEthereumChain, isAnvilTestChain } from '@aztec/ethereum/chain';
2
+ import { createExtendedL1Client, getPublicClient } from '@aztec/ethereum/client';
3
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
4
+ import { GSEContract, RollupContract } from '@aztec/ethereum/contracts';
5
+ import { createL1TxUtils } from '@aztec/ethereum/l1-tx-utils';
11
6
  import { EthCheatCodes } from '@aztec/ethereum/test';
12
7
  import type { EthAddress } from '@aztec/foundation/eth-address';
13
8
  import type { LogFn, Logger } from '@aztec/foundation/log';
14
9
  import { DateProvider } from '@aztec/foundation/timer';
15
- import { RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
10
+ import { RollupAbi, StakingAssetHandlerAbi, TestERC20Abi } from '@aztec/l1-artifacts';
16
11
  import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
17
12
 
18
- import { encodeFunctionData, formatEther, getContract } from 'viem';
13
+ import { encodeFunctionData, formatEther, getContract, maxUint256 } from 'viem';
19
14
  import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
20
15
 
21
- import { addLeadingHex } from '../../utils/aztec.js';
22
-
23
16
  export interface RollupCommandArgs {
24
17
  rpcUrls: string[];
25
18
  chainId: number;
@@ -45,7 +38,6 @@ export interface LoggerArgs {
45
38
  export function generateL1Account() {
46
39
  const privateKey = generatePrivateKey();
47
40
  const account = privateKeyToAccount(privateKey);
48
- account.address;
49
41
  return {
50
42
  privateKey,
51
43
  address: account.address,
@@ -58,8 +50,8 @@ export async function addL1Validator({
58
50
  privateKey,
59
51
  mnemonic,
60
52
  attesterAddress,
53
+ withdrawerAddress,
61
54
  stakingAssetHandlerAddress,
62
- merkleProof,
63
55
  proofParams,
64
56
  blsSecretKey,
65
57
  log,
@@ -68,8 +60,8 @@ export async function addL1Validator({
68
60
  LoggerArgs & {
69
61
  blsSecretKey: bigint; // scalar field element of BN254
70
62
  attesterAddress: EthAddress;
63
+ withdrawerAddress: EthAddress;
71
64
  proofParams: Buffer;
72
- merkleProof: string[];
73
65
  }) {
74
66
  const dualLog = makeDualLog(log, debugLogger);
75
67
  const account = getAccount(privateKey, mnemonic);
@@ -92,33 +84,61 @@ export async function addL1Validator({
92
84
  });
93
85
 
94
86
  const gseAddress = await rollup.read.getGSE();
95
-
96
87
  const gse = new GSEContract(l1Client, gseAddress);
97
-
98
88
  const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
99
89
 
100
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
90
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
101
91
  const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);
102
- const merkleProofArray = merkleProof.map(proof => addLeadingHex(proof));
103
92
 
104
- const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
93
+ // Step 1: Claim STK tokens from the faucet
94
+ dualLog(`Claiming STK tokens from faucet`);
95
+ const { receipt: claimReceipt } = await l1TxUtils.sendAndMonitorTransaction({
105
96
  to: stakingAssetHandlerAddress.toString(),
106
97
  data: encodeFunctionData({
107
98
  abi: StakingAssetHandlerAbi,
108
- functionName: 'addValidator',
99
+ functionName: 'claim',
100
+ args: [proofParamsObj.toViem()],
101
+ }),
102
+ abi: StakingAssetHandlerAbi,
103
+ });
104
+ dualLog(`Claim transaction hash: ${claimReceipt.transactionHash}`);
105
+ await l1Client.waitForTransactionReceipt({ hash: claimReceipt.transactionHash });
106
+
107
+ // Step 2: Approve the rollup to spend STK tokens
108
+ const stakingAssetAddress = await stakingAssetHandler.read.STAKING_ASSET();
109
+ dualLog(`Approving rollup to spend STK tokens`);
110
+ const { receipt: approveReceipt } = await l1TxUtils.sendAndMonitorTransaction({
111
+ to: stakingAssetAddress,
112
+ data: encodeFunctionData({
113
+ abi: TestERC20Abi,
114
+ functionName: 'approve',
115
+ args: [rollupAddress, maxUint256],
116
+ }),
117
+ abi: TestERC20Abi,
118
+ });
119
+ await l1Client.waitForTransactionReceipt({ hash: approveReceipt.transactionHash });
120
+
121
+ // Step 3: Deposit into the rollup to register as a validator
122
+ dualLog(`Depositing into rollup to register validator`);
123
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
124
+ to: rollupAddress,
125
+ data: encodeFunctionData({
126
+ abi: RollupAbi,
127
+ functionName: 'deposit',
109
128
  args: [
110
129
  attesterAddress.toString(),
111
- merkleProofArray,
112
- proofParamsObj.toViem(),
130
+ withdrawerAddress.toString(),
113
131
  registrationTuple.publicKeyInG1,
114
132
  registrationTuple.publicKeyInG2,
115
133
  registrationTuple.proofOfPossession,
134
+ false, // moveWithLatestRollup
116
135
  ],
117
136
  }),
118
- abi: StakingAssetHandlerAbi,
137
+ abi: RollupAbi,
119
138
  });
120
- dualLog(`Transaction hash: ${receipt.transactionHash}`);
139
+ dualLog(`Deposit transaction hash: ${receipt.transactionHash}`);
121
140
  await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
141
+
122
142
  if (isAnvilTestChain(chainId)) {
123
143
  dualLog(`Funding validator on L1`);
124
144
  const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
@@ -173,7 +193,7 @@ export async function addL1ValidatorViaRollup({
173
193
 
174
194
  const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
175
195
 
176
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
196
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
177
197
 
178
198
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
179
199
  to: rollupAddress.toString(),
@@ -220,7 +240,7 @@ export async function removeL1Validator({
220
240
  const account = getAccount(privateKey, mnemonic);
221
241
  const chain = createEthereumChain(rpcUrls, chainId);
222
242
  const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
223
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
243
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
224
244
 
225
245
  dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
226
246
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
@@ -247,7 +267,7 @@ export async function pruneRollup({
247
267
  const account = getAccount(privateKey, mnemonic);
248
268
  const chain = createEthereumChain(rpcUrls, chainId);
249
269
  const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
250
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
270
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
251
271
 
252
272
  dualLog(`Trying prune`);
253
273
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
@@ -299,9 +319,9 @@ export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }: Roll
299
319
  const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
300
320
  const rollup = new RollupContract(publicClient, rollupAddress);
301
321
 
302
- const pendingNum = await rollup.getBlockNumber();
322
+ const pendingNum = await rollup.getCheckpointNumber();
303
323
  log(`Pending block num: ${pendingNum}`);
304
- const provenNum = await rollup.getProvenBlockNumber();
324
+ const provenNum = await rollup.getProvenCheckpointNumber();
305
325
  log(`Proven block num: ${provenNum}`);
306
326
  const validators = await rollup.getAttesters();
307
327
  log(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
@@ -1,5 +1,5 @@
1
1
  import { computeSecretHash } from '@aztec/aztec.js/crypto';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { LogFn } from '@aztec/foundation/log';
4
4
 
5
5
  export async function generateSecretAndHash(log: LogFn) {
@@ -1,5 +1,4 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
- import { printENR } from '@aztec/p2p/enr';
3
2
 
4
3
  import type { Command } from 'commander';
5
4
 
@@ -49,6 +48,7 @@ export function injectCommands(program: Command, log: LogFn) {
49
48
  .description('Decodes and ENR record')
50
49
  .argument('<enr>', 'The encoded ENR string')
51
50
  .action(async (enr: string) => {
51
+ const { printENR } = await import('@aztec/p2p/enr');
52
52
  await printENR(enr, log);
53
53
  });
54
54
 
@@ -9,7 +9,7 @@ import { type SemVer, parse } from 'semver';
9
9
  import type { DependencyChanges } from './common.js';
10
10
  import { atomicUpdateFile } from './utils.js';
11
11
 
12
- const deprecatedNpmPackages = new Set<string>(['@aztec/cli', '@aztec/aztec-sandbox']);
12
+ const deprecatedNpmPackages = new Set<string>(['@aztec/cli', '@aztec/aztec-local-network']);
13
13
  const npmDeprecationMessage = `
14
14
  The following packages have been deprecated and will no longer be updated on the npm registry:
15
15
  ${Array.from(deprecatedNpmPackages)
@@ -16,28 +16,35 @@ import {
16
16
  writeEthJsonV3ToFile,
17
17
  writeKeystoreFile,
18
18
  } from './shared.js';
19
+ import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions } from './utils.js';
19
20
 
20
21
  export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
21
22
 
22
23
  export async function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn) {
24
+ // validate bls-path inputs before proceeding with key generation
25
+ validateBlsPathOptions(options);
26
+ // validate publisher options
27
+ validatePublisherOptions(options);
28
+ // validate remote signer options
29
+ validateRemoteSignerOptions(options);
30
+
23
31
  const {
24
32
  dataDir,
25
33
  file,
26
34
  count,
27
35
  publisherCount = 0,
36
+ publishers,
28
37
  mnemonic,
29
38
  accountIndex = 0,
30
39
  addressIndex,
31
40
  ikm,
32
41
  blsPath,
33
- blsOnly,
34
42
  json,
35
43
  feeRecipient: feeRecipientOpt,
36
44
  coinbase: coinbaseOpt,
37
- fundingAccount: fundingAccountOpt,
38
45
  remoteSigner: remoteSignerOpt,
39
46
  password,
40
- outDir,
47
+ encryptedKeystoreDir,
41
48
  } = options;
42
49
 
43
50
  const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
@@ -55,8 +62,6 @@ export async function addValidatorKeys(existing: string, options: AddValidatorKe
55
62
  throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
56
63
  }
57
64
  const coinbase = (coinbaseOpt as EthAddress | undefined) ?? (first.coinbase as EthAddress | undefined);
58
- const fundingAccount =
59
- (fundingAccountOpt as EthAddress | undefined) ?? (first.fundingAccount as EthAddress | undefined);
60
65
  const derivedRemoteSigner = (first.attester as any)?.remoteSignerUrl || (first.attester as any)?.eth?.remoteSignerUrl;
61
66
  const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
62
67
 
@@ -70,26 +75,31 @@ export async function addValidatorKeys(existing: string, options: AddValidatorKe
70
75
  const { validators, summaries } = await buildValidatorEntries({
71
76
  validatorCount,
72
77
  publisherCount,
78
+ publishers,
73
79
  accountIndex,
74
80
  baseAddressIndex: effectiveBaseAddressIndex,
75
81
  mnemonic: mnemonicToUse,
76
82
  ikm,
77
83
  blsPath,
78
- blsOnly,
79
84
  feeRecipient,
80
85
  coinbase,
81
86
  remoteSigner,
82
- fundingAccount,
83
87
  });
84
88
 
85
89
  keystore.validators.push(...validators);
86
90
 
87
91
  // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
88
92
  if (password !== undefined) {
89
- const targetDir =
90
- outDir && outDir.length > 0 ? outDir : dataDir && dataDir.length > 0 ? dataDir : dirname(existing);
93
+ let targetDir: string;
94
+ if (encryptedKeystoreDir && encryptedKeystoreDir.length > 0) {
95
+ targetDir = encryptedKeystoreDir;
96
+ } else if (dataDir && dataDir.length > 0) {
97
+ targetDir = dataDir;
98
+ } else {
99
+ targetDir = dirname(existing);
100
+ }
91
101
  await writeEthJsonV3ToFile(keystore.validators, { outDir: targetDir, password });
92
- await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password });
102
+ await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password, blsPath });
93
103
  }
94
104
 
95
105
  let outputPath = existing;
@@ -0,0 +1,30 @@
1
+ import { Wallet } from '@ethersproject/wallet';
2
+ import { parentPort, workerData } from 'worker_threads';
3
+
4
+ type EthJsonV3WorkerData = {
5
+ privateKeyHex: string;
6
+ password: string;
7
+ };
8
+
9
+ type SerializedError = {
10
+ message: string;
11
+ name?: string;
12
+ stack?: string;
13
+ };
14
+
15
+ function serializeError(error: unknown): SerializedError {
16
+ if (error instanceof Error) {
17
+ return { message: error.message, name: error.name, stack: error.stack };
18
+ }
19
+ return { message: String(error) };
20
+ }
21
+
22
+ void (async () => {
23
+ try {
24
+ const { privateKeyHex, password } = workerData as EthJsonV3WorkerData;
25
+ const json = await new Wallet(privateKeyHex).encrypt(password);
26
+ parentPort?.postMessage({ json });
27
+ } catch (error) {
28
+ parentPort?.postMessage({ error: serializeError(error) });
29
+ }
30
+ })();
@@ -1,9 +1,10 @@
1
- import { deriveBlsPrivateKey } from '@aztec/foundation/crypto';
1
+ import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
3
 
4
4
  import { writeFile } from 'fs/promises';
5
5
 
6
6
  import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
7
+ import { defaultBlsPath } from './utils.js';
7
8
 
8
9
  export type GenerateBlsKeypairOptions = {
9
10
  mnemonic?: string;
@@ -17,7 +18,7 @@ export type GenerateBlsKeypairOptions = {
17
18
 
18
19
  export async function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn) {
19
20
  const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
20
- const path = withValidatorIndex(blsPath ?? 'm/12381/3600/0/0/0', 0);
21
+ const path = withValidatorIndex(blsPath ?? defaultBlsPath, 0);
21
22
  const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
22
23
  const pub = await computeBlsPublicKeyCompressed(priv);
23
24
  const result = { path, privateKey: priv, publicKey: pub, format: compressed ? 'compressed' : 'uncompressed' };
@@ -1,13 +1,14 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
2
 
3
- import { Command } from 'commander';
3
+ import { Command, Option } from 'commander';
4
4
 
5
5
  import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
6
+ import { defaultBlsPath } from './utils.js';
6
7
 
7
8
  export function injectCommands(program: Command, log: LogFn) {
8
9
  const group = program
9
10
  .command('validator-keys')
10
- .aliases(['valKeys'])
11
+ .aliases(['valKeys', 'valkeys'])
11
12
  .description('Manage validator keystores for node operators');
12
13
 
13
14
  group
@@ -17,28 +18,61 @@ export function injectCommands(program: Command, log: LogFn) {
17
18
  .option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore')
18
19
  .option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)')
19
20
  .option('--count <N>', 'Number of validators to generate', parseOptionalInteger)
20
- .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', value =>
21
+ .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
21
22
  parseOptionalInteger(value, 0),
22
23
  )
24
+ .option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
25
+ value.split(',').map((key: string) => key.trim()),
26
+ )
23
27
  .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
24
28
  .option('--passphrase <str>', 'Optional passphrase for mnemonic')
25
- .option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger)
26
- .option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger)
27
- .option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress)
28
- .option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress)
29
+ .option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
30
+ .option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
31
+ .option(
32
+ '--coinbase <address>',
33
+ 'Coinbase ETH address to use when proposing. Defaults to attester address.',
34
+ parseEthereumAddress,
35
+ )
36
+ // TODO: add funding account back in when implemented
37
+ // .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
29
38
  .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
30
39
  .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
31
- .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
32
- .option('--bls-only', 'Generate only BLS keys')
33
- .option(
34
- '--password <str>',
35
- 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
40
+ .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
41
+ .addOption(
42
+ new Option('--password <str>', 'Shared password for writing ETH JSON V3 and BLS EIP-2335 keystore files').env(
43
+ 'AZTEC_KEYSTORE_PASSWORD',
44
+ ),
45
+ )
46
+ .option('--password-file <path>', 'File containing the shared password for writing keystore files')
47
+ .addOption(
48
+ new Option('--eth-password <str>', 'Password for writing ETH JSON V3 keystore files').env(
49
+ 'AZTEC_ETH_KEYSTORE_PASSWORD',
50
+ ),
51
+ )
52
+ .option('--eth-password-file <path>', 'File containing the password for writing ETH JSON V3 keystore files')
53
+ .addOption(
54
+ new Option('--bls-password <str>', 'Password for writing BLS EIP-2335 keystore files').env(
55
+ 'AZTEC_BLS_KEYSTORE_PASSWORD',
56
+ ),
36
57
  )
37
- .option('--out-dir <dir>', 'Output directory for generated keystore file(s)')
58
+ .option('--bls-password-file <path>', 'File containing the password for writing BLS EIP-2335 keystore files')
59
+ .option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
38
60
  .option('--json', 'Echo resulting JSON to stdout')
61
+ .option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries')
62
+ .option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress)
63
+ .option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', value =>
64
+ value.split(','),
65
+ )
66
+ .option(
67
+ '-c, --l1-chain-id <number>',
68
+ 'L1 chain ID (required with --staker-output)',
69
+ value => parseInt(value),
70
+ 31337,
71
+ )
39
72
  .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
40
73
  .action(async options => {
41
74
  const { newValidatorKeystore } = await import('./new.js');
75
+
42
76
  await newValidatorKeystore(options, log);
43
77
  });
44
78
 
@@ -47,28 +81,35 @@ export function injectCommands(program: Command, log: LogFn) {
47
81
  .summary('Augment an existing validator keystore JSON')
48
82
  .description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new')
49
83
  .argument('<existing>', 'Path to existing keystore JSON')
50
- .option('--data-dir <path>', 'Directory where keystore(s) live')
51
- .option('--file <name>', 'Override output file name')
52
- .option('--count <N>', 'Number of validators to add', parseOptionalInteger)
53
- .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', value =>
84
+ .option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)')
85
+ .option('--file <name>', 'Override output file name. (default: key<N>.json)')
86
+ .option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger)
87
+ .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
54
88
  parseOptionalInteger(value, 0),
55
89
  )
90
+ .option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
91
+ value.split(',').map((key: string) => key.trim()),
92
+ )
56
93
  .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
57
94
  .option('--passphrase <str>', 'Optional passphrase for mnemonic')
58
- .option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger)
59
- .option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger)
60
- .option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress)
61
- .option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress)
95
+ .option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
96
+ .option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
97
+ .option(
98
+ '--coinbase <address>',
99
+ 'Coinbase ETH address to use when proposing. Defaults to attester address.',
100
+ parseEthereumAddress,
101
+ )
102
+ // TODO: add funding account back in when implemented
103
+ // .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
62
104
  .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
63
105
  .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
64
- .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
65
- .option('--bls-only', 'Generate only BLS keys')
106
+ .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
66
107
  .option('--empty', 'Generate an empty skeleton without keys')
67
108
  .option(
68
109
  '--password <str>',
69
110
  'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
70
111
  )
71
- .option('--out-dir <dir>', 'Output directory for generated keystore file(s)')
112
+ .option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
72
113
  .option('--json', 'Echo resulting JSON to stdout')
73
114
  .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
74
115
  .action(async (existing: string, options) => {
@@ -76,13 +117,32 @@ export function injectCommands(program: Command, log: LogFn) {
76
117
  await addValidatorKeys(existing, options, log);
77
118
  });
78
119
 
120
+ group
121
+ .command('staker')
122
+ .summary('Generate staking JSON from keystore')
123
+ .description(
124
+ 'Reads a validator keystore and outputs staking data with BLS public keys for each attester (skips mnemonics)',
125
+ )
126
+ .requiredOption('--from <keystore>', 'Path to keystore JSON file')
127
+ .option('--password <password>', 'Password for decrypting encrypted keystores (if not specified in keystore file)')
128
+ .requiredOption('--gse-address <address>', 'GSE contract address', parseEthereumAddress)
129
+ .option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated)', value => value.split(','), [
130
+ 'http://localhost:8545',
131
+ ])
132
+ .option('-c, --l1-chain-id <number>', 'L1 chain ID', value => parseInt(value), 31337)
133
+ .option('--output <file>', 'Output file path (if not specified, JSON is written to stdout)')
134
+ .action(async options => {
135
+ const { generateStakerJson } = await import('./staker.js');
136
+ await generateStakerJson(options, log);
137
+ });
138
+
79
139
  // top-level convenience: aztec generate-bls-keypair
80
140
  program
81
141
  .command('generate-bls-keypair')
82
142
  .description('Generate a BLS keypair with convenience flags')
83
143
  .option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation')
84
144
  .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
85
- .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
145
+ .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
86
146
  .option('--g2', 'Derive on G2 subgroup')
87
147
  .option('--compressed', 'Output compressed public key')
88
148
  .option('--json', 'Print JSON output to stdout')