@aztec/cli 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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 (149) hide show
  1. package/dest/cmds/aztec_node/block_number.js +1 -1
  2. package/dest/cmds/aztec_node/get_current_min_fee.d.ts +3 -0
  3. package/dest/cmds/aztec_node/get_current_min_fee.d.ts.map +1 -0
  4. package/dest/cmds/aztec_node/{get_current_base_fee.js → get_current_min_fee.js} +2 -2
  5. package/dest/cmds/aztec_node/get_logs.d.ts +30 -4
  6. package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -1
  7. package/dest/cmds/aztec_node/get_logs.js +39 -29
  8. package/dest/cmds/aztec_node/get_node_info.d.ts +1 -1
  9. package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -1
  10. package/dest/cmds/aztec_node/get_node_info.js +0 -2
  11. package/dest/cmds/aztec_node/index.d.ts +1 -1
  12. package/dest/cmds/aztec_node/index.d.ts.map +1 -1
  13. package/dest/cmds/aztec_node/index.js +16 -6
  14. package/dest/cmds/contracts/inspect_contract.js +1 -1
  15. package/dest/cmds/infrastructure/sequencers.d.ts +1 -1
  16. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
  17. package/dest/cmds/infrastructure/sequencers.js +11 -4
  18. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
  19. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
  20. package/dest/cmds/infrastructure/setup_l2_contract.js +12 -7
  21. package/dest/cmds/l1/assume_proven_through.d.ts +3 -2
  22. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
  23. package/dest/cmds/l1/assume_proven_through.js +3 -5
  24. package/dest/cmds/l1/bridge_erc20.d.ts +1 -1
  25. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
  26. package/dest/cmds/l1/bridge_erc20.js +2 -1
  27. package/dest/cmds/l1/compute_genesis_values.d.ts +4 -0
  28. package/dest/cmds/l1/compute_genesis_values.d.ts.map +1 -0
  29. package/dest/cmds/l1/compute_genesis_values.js +17 -0
  30. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +4 -0
  31. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -0
  32. package/dest/cmds/l1/{deploy_l1_contracts.js → deploy_l1_contracts_cmd.js} +39 -5
  33. package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -4
  34. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  35. package/dest/cmds/l1/deploy_new_rollup.js +4 -6
  36. package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
  37. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
  38. package/dest/cmds/l1/get_l1_addresses.js +5 -2
  39. package/dest/cmds/l1/get_l1_balance.js +4 -2
  40. package/dest/cmds/l1/governance_utils.d.ts +1 -1
  41. package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
  42. package/dest/cmds/l1/governance_utils.js +3 -1
  43. package/dest/cmds/l1/index.d.ts +1 -2
  44. package/dest/cmds/l1/index.d.ts.map +1 -1
  45. package/dest/cmds/l1/index.js +17 -10
  46. package/dest/cmds/l1/prover_stats.d.ts +1 -1
  47. package/dest/cmds/l1/prover_stats.d.ts.map +1 -1
  48. package/dest/cmds/l1/prover_stats.js +4 -2
  49. package/dest/cmds/l1/trigger_seed_snapshot.d.ts +1 -1
  50. package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -1
  51. package/dest/cmds/l1/trigger_seed_snapshot.js +2 -1
  52. package/dest/cmds/l1/update_l1_validators.d.ts +3 -3
  53. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  54. package/dest/cmds/l1/update_l1_validators.js +56 -18
  55. package/dest/cmds/misc/generate_secret_and_hash.js +1 -1
  56. package/dest/cmds/misc/index.d.ts +1 -1
  57. package/dest/cmds/misc/index.d.ts.map +1 -1
  58. package/dest/cmds/misc/index.js +1 -1
  59. package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts +2 -0
  60. package/dest/cmds/validator_keys/eth_json_v3_worker.d.ts.map +1 -0
  61. package/dest/cmds/validator_keys/eth_json_v3_worker.js +27 -0
  62. package/dest/cmds/validator_keys/generate_bls_keypair.js +1 -1
  63. package/dest/cmds/validator_keys/index.d.ts +1 -1
  64. package/dest/cmds/validator_keys/index.d.ts.map +1 -1
  65. package/dest/cmds/validator_keys/index.js +7 -6
  66. package/dest/cmds/validator_keys/new.d.ts +7 -1
  67. package/dest/cmds/validator_keys/new.d.ts.map +1 -1
  68. package/dest/cmds/validator_keys/new.js +103 -14
  69. package/dest/cmds/validator_keys/set_funding_account.d.ts +14 -0
  70. package/dest/cmds/validator_keys/set_funding_account.d.ts.map +1 -0
  71. package/dest/cmds/validator_keys/set_funding_account.js +37 -0
  72. package/dest/cmds/validator_keys/shared.d.ts +15 -2
  73. package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
  74. package/dest/cmds/validator_keys/shared.js +102 -24
  75. package/dest/cmds/validator_keys/staker.d.ts +2 -2
  76. package/dest/cmds/validator_keys/staker.d.ts.map +1 -1
  77. package/dest/cmds/validator_keys/staker.js +7 -4
  78. package/dest/cmds/validator_keys/utils.d.ts +12 -2
  79. package/dest/cmds/validator_keys/utils.d.ts.map +1 -1
  80. package/dest/cmds/validator_keys/utils.js +35 -1
  81. package/dest/config/cached_fetch.d.ts +19 -10
  82. package/dest/config/cached_fetch.d.ts.map +1 -1
  83. package/dest/config/cached_fetch.js +110 -32
  84. package/dest/config/chain_l2_config.d.ts +17 -38
  85. package/dest/config/chain_l2_config.d.ts.map +1 -1
  86. package/dest/config/chain_l2_config.js +48 -493
  87. package/dest/config/generated/networks.d.ts +239 -0
  88. package/dest/config/generated/networks.d.ts.map +1 -0
  89. package/dest/config/generated/networks.js +240 -0
  90. package/dest/config/get_l1_config.d.ts +3 -2
  91. package/dest/config/get_l1_config.d.ts.map +1 -1
  92. package/dest/config/get_l1_config.js +3 -1
  93. package/dest/config/network_config.d.ts +2 -2
  94. package/dest/config/network_config.d.ts.map +1 -1
  95. package/dest/config/network_config.js +13 -3
  96. package/dest/utils/aztec.d.ts +7 -14
  97. package/dest/utils/aztec.d.ts.map +1 -1
  98. package/dest/utils/aztec.js +19 -41
  99. package/dest/utils/commands.d.ts +25 -15
  100. package/dest/utils/commands.d.ts.map +1 -1
  101. package/dest/utils/commands.js +34 -22
  102. package/dest/utils/encoding.js +1 -1
  103. package/dest/utils/inspect.d.ts +1 -1
  104. package/dest/utils/inspect.d.ts.map +1 -1
  105. package/dest/utils/inspect.js +15 -12
  106. package/package.json +39 -31
  107. package/src/cmds/aztec_node/block_number.ts +1 -1
  108. package/src/cmds/aztec_node/{get_current_base_fee.ts → get_current_min_fee.ts} +2 -2
  109. package/src/cmds/aztec_node/get_logs.ts +70 -38
  110. package/src/cmds/aztec_node/get_node_info.ts +0 -2
  111. package/src/cmds/aztec_node/index.ts +16 -11
  112. package/src/cmds/contracts/inspect_contract.ts +1 -1
  113. package/src/cmds/infrastructure/sequencers.ts +7 -4
  114. package/src/cmds/infrastructure/setup_l2_contract.ts +12 -7
  115. package/src/cmds/l1/assume_proven_through.ts +4 -7
  116. package/src/cmds/l1/bridge_erc20.ts +2 -1
  117. package/src/cmds/l1/compute_genesis_values.ts +29 -0
  118. package/src/cmds/l1/{deploy_l1_contracts.ts → deploy_l1_contracts_cmd.ts} +39 -23
  119. package/src/cmds/l1/deploy_new_rollup.ts +5 -12
  120. package/src/cmds/l1/get_l1_addresses.ts +4 -2
  121. package/src/cmds/l1/get_l1_balance.ts +2 -2
  122. package/src/cmds/l1/governance_utils.ts +3 -8
  123. package/src/cmds/l1/index.ts +30 -21
  124. package/src/cmds/l1/prover_stats.ts +6 -2
  125. package/src/cmds/l1/trigger_seed_snapshot.ts +2 -1
  126. package/src/cmds/l1/update_l1_validators.ts +50 -30
  127. package/src/cmds/misc/generate_secret_and_hash.ts +1 -1
  128. package/src/cmds/misc/index.ts +1 -1
  129. package/src/cmds/validator_keys/eth_json_v3_worker.ts +30 -0
  130. package/src/cmds/validator_keys/generate_bls_keypair.ts +1 -1
  131. package/src/cmds/validator_keys/index.ts +48 -8
  132. package/src/cmds/validator_keys/new.ts +132 -11
  133. package/src/cmds/validator_keys/set_funding_account.ts +55 -0
  134. package/src/cmds/validator_keys/shared.ts +125 -36
  135. package/src/cmds/validator_keys/staker.ts +5 -4
  136. package/src/cmds/validator_keys/utils.ts +46 -2
  137. package/src/config/cached_fetch.ts +119 -31
  138. package/src/config/chain_l2_config.ts +46 -642
  139. package/src/config/generated/networks.ts +244 -0
  140. package/src/config/get_l1_config.ts +4 -1
  141. package/src/config/network_config.ts +14 -3
  142. package/src/utils/aztec.ts +30 -95
  143. package/src/utils/commands.ts +41 -26
  144. package/src/utils/encoding.ts +1 -1
  145. package/src/utils/inspect.ts +11 -9
  146. package/dest/cmds/aztec_node/get_current_base_fee.d.ts +0 -3
  147. package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +0 -1
  148. package/dest/cmds/l1/deploy_l1_contracts.d.ts +0 -4
  149. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +0 -1
@@ -1,9 +1,9 @@
1
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
1
2
  import { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
4
 
4
5
  import { type Command, Option } from 'commander';
5
6
 
6
- import { getL1RollupAddressFromEnv } from '../../config/get_l1_config.js';
7
7
  import {
8
8
  ETHEREUM_HOSTS,
9
9
  MNEMONIC,
@@ -15,8 +15,6 @@ import {
15
15
  parseEthereumAddress,
16
16
  } from '../../utils/commands.js';
17
17
 
18
- export { addL1Validator } from './update_l1_validators.js';
19
-
20
18
  const l1RpcUrlsOption = new Option(
21
19
  '--l1-rpc-urls <string>',
22
20
  'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)',
@@ -42,31 +40,25 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
42
40
  )
43
41
  .option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', arg => parseInt(arg), 0)
44
42
  .addOption(l1ChainIdOption)
45
- .option('--salt <number>', 'The optional salt to use in deployment', arg => parseInt(arg))
46
43
  .option('--json', 'Output the contract addresses in JSON format')
47
44
  .option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts')
48
45
  .option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract')
49
- .option('--accelerated-test-deployments', 'Fire and forget deployment transactions, use in testing only', false)
50
46
  .option('--real-verifier', 'Deploy the real verifier', false)
51
47
  .option('--existing-token <address>', 'Use an existing ERC20 for both fee and staking', parseEthereumAddress)
52
- .option('--create-verification-json [path]', 'Create JSON file for etherscan contract verification', false)
53
48
  .action(async options => {
54
- const { deployL1Contracts } = await import('./deploy_l1_contracts.js');
49
+ const { deployL1ContractsCmd } = await import('./deploy_l1_contracts_cmd.js');
55
50
 
56
51
  const initialValidators =
57
52
  options.validators?.split(',').map((validator: string) => EthAddress.fromString(validator)) || [];
58
- await deployL1Contracts(
53
+ await deployL1ContractsCmd(
59
54
  options.l1RpcUrls,
60
55
  options.l1ChainId,
61
56
  options.privateKey,
62
57
  options.mnemonic,
63
58
  options.mnemonicIndex,
64
- options.salt,
65
59
  options.testAccounts,
66
60
  options.sponsoredFpc,
67
- options.acceleratedTestDeployments,
68
61
  options.json,
69
- options.createVerificationJson,
70
62
  initialValidators,
71
63
  options.realVerifier,
72
64
  options.existingToken,
@@ -89,12 +81,10 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
89
81
  )
90
82
  .option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', arg => parseInt(arg), 0)
91
83
  .addOption(l1ChainIdOption)
92
- .option('--salt <number>', 'The optional salt to use in deployment', arg => parseInt(arg))
93
84
  .option('--json', 'Output the contract addresses in JSON format')
94
85
  .option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts')
95
86
  .option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract')
96
87
  .option('--real-verifier', 'Deploy the real verifier', false)
97
- .option('--create-verification-json [path]', 'Create JSON file for etherscan contract verification', false)
98
88
  .action(async options => {
99
89
  const { deployNewRollup } = await import('./deploy_new_rollup.js');
100
90
 
@@ -107,18 +97,33 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
107
97
  options.privateKey,
108
98
  options.mnemonic,
109
99
  options.mnemonicIndex,
110
- options.salt,
111
100
  options.testAccounts,
112
101
  options.sponsoredFpc,
113
102
  options.json,
114
103
  initialValidators,
115
104
  options.realVerifier,
116
- options.createVerificationJson,
117
105
  log,
118
- debugLogger,
119
106
  );
120
107
  });
121
108
 
109
+ program
110
+ .command('compute-genesis-values')
111
+ .description('Computes genesis values (VK tree root, protocol contracts hash, genesis archive root).')
112
+ .addOption(
113
+ new Option('--test-accounts <boolean>', 'Include initial test accounts in genesis state')
114
+ .env('TEST_ACCOUNTS')
115
+ .argParser(arg => arg === 'true'),
116
+ )
117
+ .addOption(
118
+ new Option('--sponsored-fpc <boolean>', 'Include sponsored FPC contract in genesis state')
119
+ .env('SPONSORED_FPC')
120
+ .argParser(arg => arg === 'true'),
121
+ )
122
+ .action(async options => {
123
+ const { computeGenesisValuesCmd } = await import('./compute_genesis_values.js');
124
+ await computeGenesisValuesCmd(options.testAccounts, options.sponsoredFpc, log);
125
+ });
126
+
122
127
  program
123
128
  .command('deposit-governance-tokens')
124
129
  .description('Deposits governance tokens to the governance contract.')
@@ -313,7 +318,11 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
313
318
  .action(async options => {
314
319
  const { addL1ValidatorViaRollup } = await import('./update_l1_validators.js');
315
320
 
316
- const rollupAddress = options.rollup ?? (await getL1RollupAddressFromEnv(options.l1RpcUrls, options.l1ChainId));
321
+ let rollupAddress = options.rollup;
322
+ if (!rollupAddress) {
323
+ const { getL1RollupAddressFromEnv } = await import('../../config/get_l1_config.js');
324
+ rollupAddress = await getL1RollupAddressFromEnv(options.l1RpcUrls, options.l1ChainId);
325
+ }
317
326
 
318
327
  await addL1ValidatorViaRollup({
319
328
  rpcUrls: options.l1RpcUrls,
@@ -507,14 +516,14 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
507
516
  program
508
517
  .command('set-proven-through', { hidden: true })
509
518
  .description(
510
- 'Instructs the L1 rollup contract to assume all blocks until the given number are automatically proven.',
519
+ 'Instructs the L1 rollup contract to assume all blocks until the given checkpoint are automatically proven.',
511
520
  )
512
- .argument('[blockNumber]', 'The target block number, defaults to the latest pending block number.', parseBigint)
521
+ .argument('[checkpoint]', 'The target checkpoint, defaults to the latest pending checkpoint.', parseBigint)
513
522
  .addOption(l1RpcUrlsOption)
514
523
  .addOption(nodeOption)
515
- .action(async (blockNumber, options) => {
524
+ .action(async (checkpoint, options) => {
516
525
  const { assumeProvenThrough } = await import('./assume_proven_through.js');
517
- await assumeProvenThrough(blockNumber, options.l1RpcUrls, options.nodeUrl, log);
526
+ await assumeProvenThrough(CheckpointNumber.fromBigInt(checkpoint), options.l1RpcUrls, options.nodeUrl, log);
518
527
  });
519
528
 
520
529
  program
@@ -1,5 +1,6 @@
1
1
  import { retrieveL2ProofVerifiedEvents } from '@aztec/archiver';
2
- import { type ViemPublicClient, createEthereumChain } from '@aztec/ethereum';
2
+ import { createEthereumChain } from '@aztec/ethereum/chain';
3
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
3
4
  import { compactArray, mapValues, unique } from '@aztec/foundation/collection';
4
5
  import { EthAddress } from '@aztec/foundation/eth-address';
5
6
  import { type LogFn, type Logger, createLogger } from '@aztec/foundation/log';
@@ -46,7 +47,10 @@ export async function proverStats(opts: {
46
47
  .then(a => a.rollupAddress);
47
48
 
48
49
  const chain = createEthereumChain(l1RpcUrls, chainId).chainInfo;
49
- const publicClient = createPublicClient({ chain, transport: fallback(l1RpcUrls.map(url => http(url))) });
50
+ const publicClient = createPublicClient({
51
+ chain,
52
+ transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
53
+ });
50
54
  const lastBlockNum = endBlock ?? (await publicClient.getBlockNumber());
51
55
  debugLog.verbose(`Querying events on rollup at ${rollup.toString()} from ${startBlock} up to ${lastBlockNum}`);
52
56
 
@@ -1,4 +1,5 @@
1
- import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
1
+ import { createEthereumChain } from '@aztec/ethereum/chain';
2
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
2
3
  import type { LogFn } from '@aztec/foundation/log';
3
4
  import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
4
5
 
@@ -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({
@@ -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
 
@@ -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,4 +1,4 @@
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';
@@ -1,6 +1,6 @@
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
6
  import { defaultBlsPath } from './utils.js';
@@ -33,15 +33,31 @@ export function injectCommands(program: Command, log: LogFn) {
33
33
  'Coinbase ETH address to use when proposing. Defaults to attester address.',
34
34
  parseEthereumAddress,
35
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')
36
+ .option(
37
+ '--funding-account <privateKey|address>',
38
+ 'ETH funding account used to top up publisher EOAs. Provide a private key, or an address together with --remote-signer.',
39
+ )
38
40
  .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
39
41
  .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
40
42
  .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
41
- .option(
42
- '--password <str>',
43
- 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
43
+ .addOption(
44
+ new Option('--password <str>', 'Shared password for writing ETH JSON V3 and BLS EIP-2335 keystore files').env(
45
+ 'AZTEC_KEYSTORE_PASSWORD',
46
+ ),
44
47
  )
48
+ .option('--password-file <path>', 'File containing the shared password for writing keystore files')
49
+ .addOption(
50
+ new Option('--eth-password <str>', 'Password for writing ETH JSON V3 keystore files').env(
51
+ 'AZTEC_ETH_KEYSTORE_PASSWORD',
52
+ ),
53
+ )
54
+ .option('--eth-password-file <path>', 'File containing the password for writing ETH JSON V3 keystore files')
55
+ .addOption(
56
+ new Option('--bls-password <str>', 'Password for writing BLS EIP-2335 keystore files').env(
57
+ 'AZTEC_BLS_KEYSTORE_PASSWORD',
58
+ ),
59
+ )
60
+ .option('--bls-password-file <path>', 'File containing the password for writing BLS EIP-2335 keystore files')
45
61
  .option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
46
62
  .option('--json', 'Echo resulting JSON to stdout')
47
63
  .option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries')
@@ -85,8 +101,6 @@ export function injectCommands(program: Command, log: LogFn) {
85
101
  'Coinbase ETH address to use when proposing. Defaults to attester address.',
86
102
  parseEthereumAddress,
87
103
  )
88
- // TODO: add funding account back in when implemented
89
- // .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
90
104
  .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
91
105
  .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
92
106
  .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
@@ -103,6 +117,32 @@ export function injectCommands(program: Command, log: LogFn) {
103
117
  await addValidatorKeys(existing, options, log);
104
118
  });
105
119
 
120
+ group
121
+ .command('set-funding-account')
122
+ .summary('Set the funding account of an existing keystore')
123
+ .description(
124
+ 'Sets the keystore-level ETH funding account used to top up publisher EOAs, replacing any existing one',
125
+ )
126
+ .argument('<existing>', 'Path to existing keystore JSON')
127
+ .argument(
128
+ '<privateKey|address>',
129
+ 'Funding account: a private key, or an address (needs --remote-signer unless the keystore already defines one)',
130
+ )
131
+ .option(
132
+ '--remote-signer <url>',
133
+ 'Remote signer URL for the funding account (required with an address unless the keystore already defines one)',
134
+ )
135
+ .option(
136
+ '--password <str>',
137
+ 'Password for writing the funding key as an encrypted ETH JSON V3 file. Empty string allowed',
138
+ )
139
+ .option('--encrypted-keystore-dir <dir>', 'Output directory for the encrypted funding key file')
140
+ .option('--json', 'Echo resulting JSON to stdout')
141
+ .action(async (existing: string, fundingAccount: string, options) => {
142
+ const { setFundingAccount } = await import('./set_funding_account.js');
143
+ await setFundingAccount(existing, fundingAccount, options, log);
144
+ });
145
+
106
146
  group
107
147
  .command('staker')
108
148
  .summary('Generate staking JSON from keystore')