@aztec/cli 0.84.0 → 0.85.0

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.
@@ -1,4 +1,5 @@
1
1
  import type { LogFn, Logger } from '@aztec/foundation/log';
2
2
  import { type Command } from 'commander';
3
+ export { addL1Validator } from './update_l1_validators.js';
3
4
  export declare function injectCommands(program: Command, log: LogFn, debugLogger: Logger): Command;
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAuBjD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAohB/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAW3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAohB/E"}
@@ -1,6 +1,7 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import { Option } from 'commander';
3
3
  import { ETHEREUM_HOSTS, MNEMONIC, PRIVATE_KEY, l1ChainIdOption, makePxeOption, parseAztecAddress, parseBigint, parseEthereumAddress, pxeOption } from '../../utils/commands.js';
4
+ export { addL1Validator } from './update_l1_validators.js';
4
5
  const l1RpcUrlsOption = new Option('--l1-rpc-urls <string>', 'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)').env('ETHEREUM_HOSTS').default([
5
6
  ETHEREUM_HOSTS
6
7
  ]).makeOptionMandatory(true).argParser((arg)=>arg.split(',').map((url)=>url.trim()));
@@ -93,16 +94,16 @@ export function injectCommands(program, log, debugLogger) {
93
94
  const account = generateL1Account();
94
95
  log(JSON.stringify(account, null, 2));
95
96
  });
96
- program.command('add-l1-validator').description('Adds a validator to the L1 rollup contract.').addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY).option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').addOption(l1ChainIdOption).option('--validator <address>', 'ethereum address of the validator', parseEthereumAddress).option('--rollup <address>', 'ethereum address of the rollup contract', parseEthereumAddress).option('--withdrawer <address>', 'ethereum address of the withdrawer', parseEthereumAddress).action(async (options)=>{
97
+ program.command('add-l1-validator').description('Adds a validator to the L1 rollup contract.').addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use sending the transaction', PRIVATE_KEY).option('-m, --mnemonic <string>', 'The mnemonic to use sending the transaction', 'test test test test test test test test test test test junk').addOption(l1ChainIdOption).option('--attester <address>', 'ethereum address of the attester', parseEthereumAddress).option('--proposer-eoa <address>', 'ethereum address of the proposer EOA', parseEthereumAddress).option('--staking-asset-handler <address>', 'ethereum address of the staking asset handler', parseEthereumAddress).action(async (options)=>{
97
98
  const { addL1Validator } = await import('./update_l1_validators.js');
98
99
  await addL1Validator({
99
100
  rpcUrls: options.l1RpcUrls,
100
101
  chainId: options.l1ChainId,
101
102
  privateKey: options.privateKey,
102
103
  mnemonic: options.mnemonic,
103
- validatorAddress: options.validator,
104
- rollupAddress: options.rollup,
105
- withdrawerAddress: options.withdrawer,
104
+ attesterAddress: options.attester,
105
+ proposerEOAAddress: options.proposerEoa,
106
+ stakingAssetHandlerAddress: options.stakingAssetHandler,
106
107
  log,
107
108
  debugLogger
108
109
  });
@@ -8,6 +8,13 @@ export interface RollupCommandArgs {
8
8
  rollupAddress: EthAddress;
9
9
  withdrawerAddress?: EthAddress;
10
10
  }
11
+ export interface StakingAssetHandlerCommandArgs {
12
+ rpcUrls: string[];
13
+ chainId: number;
14
+ privateKey?: string;
15
+ mnemonic?: string;
16
+ stakingAssetHandlerAddress: EthAddress;
17
+ }
11
18
  export interface LoggerArgs {
12
19
  log: LogFn;
13
20
  debugLogger: Logger;
@@ -16,8 +23,9 @@ export declare function generateL1Account(): {
16
23
  privateKey: `0x${string}`;
17
24
  address: `0x${string}`;
18
25
  };
19
- export declare function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, validatorAddress, rollupAddress, withdrawerAddress, log, debugLogger, }: RollupCommandArgs & LoggerArgs & {
20
- validatorAddress: EthAddress;
26
+ export declare function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, attesterAddress, proposerEOAAddress, stakingAssetHandlerAddress, log, debugLogger, }: StakingAssetHandlerCommandArgs & LoggerArgs & {
27
+ attesterAddress: EthAddress;
28
+ proposerEOAAddress: EthAddress;
21
29
  }): Promise<void>;
22
30
  export declare function removeL1Validator({ rpcUrls, chainId, privateKey, mnemonic, validatorAddress, rollupAddress, log, debugLogger, }: RollupCommandArgs & LoggerArgs & {
23
31
  validatorAddress: EthAddress;
@@ -1 +1 @@
1
- {"version":3,"file":"update_l1_validators.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/update_l1_validators.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAM3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,KAAK,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,iBAAiB;;;EAQhC;AAED,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,UAAU,CAAA;CAAE,iBA+CnE;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,UAAU,CAAA;CAAE,iBAcnE;AAED,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,iBAchC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,aAAa,EACb,SAAS,EACT,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,iBAyBxD;AAED,wBAAsB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,iBAAiB,GAAG,UAAU,iBAwBzG"}
1
+ {"version":3,"file":"update_l1_validators.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/update_l1_validators.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAM3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B,EAAE,UAAU,CAAC;CACxC;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,KAAK,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,iBAAiB;;;EAQhC;AAED,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,GAAG,EACH,WAAW,GACZ,EAAE,8BAA8B,GAAG,UAAU,GAAG;IAAE,eAAe,EAAE,UAAU,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAAE,iBAqC/G;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,UAAU,CAAA;CAAE,iBAcnE;AAED,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,OAAO,EACP,UAAU,EACV,QAAQ,EACR,aAAa,EACb,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,iBAchC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,OAAO,EACP,aAAa,EACb,SAAS,EACT,GAAG,EACH,WAAW,GACZ,EAAE,iBAAiB,GAAG,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,iBAyBxD;AAED,wBAAsB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,iBAAiB,GAAG,UAAU,iBAwBzG"}
@@ -1,6 +1,6 @@
1
1
  import { EthCheatCodes, RollupContract, createEthereumChain, getExpectedAddress, getL1ContractsConfigEnvVars, isAnvilTestChain } from '@aztec/ethereum';
2
- import { ForwarderAbi, ForwarderBytecode, RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
3
- import { createPublicClient, createWalletClient, fallback, getContract, http } from 'viem';
2
+ import { ForwarderAbi, ForwarderBytecode, RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
3
+ import { createPublicClient, createWalletClient, fallback, formatEther, getContract, http } from 'viem';
4
4
  import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
5
5
  export function generateL1Account() {
6
6
  const privateKey = generatePrivateKey();
@@ -11,42 +11,23 @@ export function generateL1Account() {
11
11
  address: account.address
12
12
  };
13
13
  }
14
- export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, validatorAddress, rollupAddress, withdrawerAddress, log, debugLogger }) {
15
- const config = getL1ContractsConfigEnvVars();
14
+ export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, attesterAddress, proposerEOAAddress, stakingAssetHandlerAddress, log, debugLogger }) {
16
15
  const dualLog = makeDualLog(log, debugLogger);
17
16
  const publicClient = getPublicClient(rpcUrls, chainId);
18
17
  const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
19
- const rollup = getContract({
20
- address: rollupAddress.toString(),
21
- abi: RollupAbi,
18
+ const stakingAssetHandler = getContract({
19
+ address: stakingAssetHandlerAddress.toString(),
20
+ abi: StakingAssetHandlerAbi,
22
21
  client: walletClient
23
22
  });
24
- const stakingAsset = getContract({
25
- address: await rollup.read.getStakingAsset(),
26
- abi: TestERC20Abi,
27
- client: walletClient
28
- });
29
- await Promise.all([
30
- await stakingAsset.write.mint([
31
- walletClient.account.address,
32
- config.minimumStake
33
- ], {}),
34
- await stakingAsset.write.approve([
35
- rollupAddress.toString(),
36
- config.minimumStake
37
- ], {})
38
- ].map((txHash)=>publicClient.waitForTransactionReceipt({
39
- hash: txHash
40
- })));
41
- dualLog(`Adding validator ${validatorAddress.toString()} to rollup ${rollupAddress.toString()}`);
42
- const txHash = await rollup.write.deposit([
43
- validatorAddress.toString(),
44
- // TODO(#11451): custom forwarders
45
- getExpectedAddress(ForwarderAbi, ForwarderBytecode, [
46
- validatorAddress.toString()
47
- ], validatorAddress.toString()).address,
48
- withdrawerAddress?.toString() ?? validatorAddress.toString(),
49
- config.minimumStake
23
+ const rollup = await stakingAssetHandler.read.getRollup();
24
+ const forwarderAddress = getExpectedAddress(ForwarderAbi, ForwarderBytecode, [
25
+ proposerEOAAddress.toString()
26
+ ], proposerEOAAddress.toString()).address;
27
+ dualLog(`Adding validator (${attesterAddress}, ${proposerEOAAddress} [forwarder: ${forwarderAddress}]) to rollup ${rollup.toString()}`);
28
+ const txHash = await stakingAssetHandler.write.addValidator([
29
+ attesterAddress.toString(),
30
+ forwarderAddress
50
31
  ]);
51
32
  dualLog(`Transaction hash: ${txHash}`);
52
33
  await publicClient.waitForTransactionReceipt({
@@ -55,15 +36,14 @@ export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, v
55
36
  if (isAnvilTestChain(chainId)) {
56
37
  dualLog(`Funding validator on L1`);
57
38
  const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
58
- await cheatCodes.setBalance(validatorAddress, 10n ** 20n);
39
+ await cheatCodes.setBalance(proposerEOAAddress, 10n ** 20n);
59
40
  } else {
60
41
  const balance = await publicClient.getBalance({
61
- address: validatorAddress.toString()
42
+ address: proposerEOAAddress.toString()
62
43
  });
63
- const balanceInEth = Number(balance) / 10 ** 18;
64
- dualLog(`Validator balance: ${balanceInEth.toFixed(6)} ETH`);
65
- if (balanceInEth === 0) {
66
- dualLog(`WARNING: Validator has no balance. Remember to fund it!`);
44
+ dualLog(`Proposer balance: ${formatEther(balance)} ETH`);
45
+ if (balance === 0n) {
46
+ dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
67
47
  }
68
48
  }
69
49
  }
@@ -0,0 +1,3 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+ export declare function getCanonicalSponsoredFPCAddress(log: LogFn): Promise<void>;
3
+ //# sourceMappingURL=get_canonical_sponsored_fpc_address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_canonical_sponsored_fpc_address.d.ts","sourceRoot":"","sources":["../../../src/cmds/misc/get_canonical_sponsored_fpc_address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,+BAA+B,CAAC,GAAG,EAAE,KAAK,iBAE/D"}
@@ -0,0 +1,4 @@
1
+ import { getSponsoredFPCAddress } from '../../utils/setup_contracts.js';
2
+ export async function getCanonicalSponsoredFPCAddress(log) {
3
+ log(`Canonical SponsoredFPC Address: ${(await getSponsoredFPCAddress()).toString()}`);
4
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/misc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WAqF1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/misc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WA6F1D"}
@@ -35,6 +35,10 @@ export function injectCommands(program, log) {
35
35
  const { generateSecretAndHash } = await import('./generate_secret_and_hash.js');
36
36
  generateSecretAndHash(log);
37
37
  });
38
+ program.command('get-canonical-sponsored-fpc-address').description('Gets the canonical SponsoredFPC address for this any testnet running on the same version as this CLI').action(async ()=>{
39
+ const { getCanonicalSponsoredFPCAddress } = await import('./get_canonical_sponsored_fpc_address.js');
40
+ await getCanonicalSponsoredFPCAddress(log);
41
+ });
38
42
  program.command('update').description('Updates Nodejs and Noir dependencies').argument('[projectPath]', 'Path to the project directory', process.cwd()).option('--contract [paths...]', 'Paths to contracts to update dependencies', []).option('--aztec-version <semver>', 'The version to update Aztec packages to. Defaults to latest', 'latest').action(async (projectPath, options)=>{
39
43
  const { updateProject } = await import('./update.js');
40
44
  const { contract, aztecVersion } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "0.84.0",
3
+ "version": "0.85.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./contracts": "./dest/cmds/contracts/index.js",
@@ -67,15 +67,15 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/archiver": "0.84.0",
71
- "@aztec/aztec.js": "0.84.0",
72
- "@aztec/constants": "0.84.0",
73
- "@aztec/entrypoints": "0.84.0",
74
- "@aztec/foundation": "0.84.0",
75
- "@aztec/l1-artifacts": "0.84.0",
76
- "@aztec/p2p": "0.84.0",
77
- "@aztec/stdlib": "0.84.0",
78
- "@aztec/world-state": "0.84.0",
70
+ "@aztec/archiver": "0.85.0",
71
+ "@aztec/aztec.js": "0.85.0",
72
+ "@aztec/constants": "0.85.0",
73
+ "@aztec/entrypoints": "0.85.0",
74
+ "@aztec/foundation": "0.85.0",
75
+ "@aztec/l1-artifacts": "0.85.0",
76
+ "@aztec/p2p": "0.85.0",
77
+ "@aztec/stdlib": "0.85.0",
78
+ "@aztec/world-state": "0.85.0",
79
79
  "@iarna/toml": "^2.2.5",
80
80
  "@libp2p/peer-id-factory": "^3.0.4",
81
81
  "commander": "^12.1.0",
@@ -87,9 +87,9 @@
87
87
  "viem": "2.23.7"
88
88
  },
89
89
  "devDependencies": {
90
- "@aztec/accounts": "0.84.0",
91
- "@aztec/ethereum": "0.84.0",
92
- "@aztec/protocol-contracts": "0.84.0",
90
+ "@aztec/accounts": "0.85.0",
91
+ "@aztec/ethereum": "0.85.0",
92
+ "@aztec/protocol-contracts": "0.85.0",
93
93
  "@jest/globals": "^29.5.0",
94
94
  "@types/jest": "^29.5.0",
95
95
  "@types/lodash.chunk": "^4.2.9",
@@ -105,14 +105,14 @@
105
105
  "typescript": "^5.0.4"
106
106
  },
107
107
  "peerDependencies": {
108
- "@aztec/accounts": "0.84.0",
109
- "@aztec/bb-prover": "0.84.0",
110
- "@aztec/ethereum": "0.84.0",
111
- "@aztec/l1-artifacts": "0.84.0",
112
- "@aztec/noir-contracts.js": "0.84.0",
113
- "@aztec/noir-protocol-circuits-types": "0.84.0",
114
- "@aztec/protocol-contracts": "0.84.0",
115
- "@aztec/stdlib": "0.84.0"
108
+ "@aztec/accounts": "0.85.0",
109
+ "@aztec/bb-prover": "0.85.0",
110
+ "@aztec/ethereum": "0.85.0",
111
+ "@aztec/l1-artifacts": "0.85.0",
112
+ "@aztec/noir-contracts.js": "0.85.0",
113
+ "@aztec/noir-protocol-circuits-types": "0.85.0",
114
+ "@aztec/protocol-contracts": "0.85.0",
115
+ "@aztec/stdlib": "0.85.0"
116
116
  },
117
117
  "files": [
118
118
  "dest",
@@ -15,6 +15,8 @@ import {
15
15
  pxeOption,
16
16
  } from '../../utils/commands.js';
17
17
 
18
+ export { addL1Validator } from './update_l1_validators.js';
19
+
18
20
  const l1RpcUrlsOption = new Option(
19
21
  '--l1-rpc-urls <string>',
20
22
  'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)',
@@ -279,16 +281,16 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
279
281
  .command('add-l1-validator')
280
282
  .description('Adds a validator to the L1 rollup contract.')
281
283
  .addOption(l1RpcUrlsOption)
282
- .option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY)
284
+ .option('-pk, --private-key <string>', 'The private key to use sending the transaction', PRIVATE_KEY)
283
285
  .option(
284
286
  '-m, --mnemonic <string>',
285
- 'The mnemonic to use in deployment',
287
+ 'The mnemonic to use sending the transaction',
286
288
  'test test test test test test test test test test test junk',
287
289
  )
288
290
  .addOption(l1ChainIdOption)
289
- .option('--validator <address>', 'ethereum address of the validator', parseEthereumAddress)
290
- .option('--rollup <address>', 'ethereum address of the rollup contract', parseEthereumAddress)
291
- .option('--withdrawer <address>', 'ethereum address of the withdrawer', parseEthereumAddress)
291
+ .option('--attester <address>', 'ethereum address of the attester', parseEthereumAddress)
292
+ .option('--proposer-eoa <address>', 'ethereum address of the proposer EOA', parseEthereumAddress)
293
+ .option('--staking-asset-handler <address>', 'ethereum address of the staking asset handler', parseEthereumAddress)
292
294
  .action(async options => {
293
295
  const { addL1Validator } = await import('./update_l1_validators.js');
294
296
  await addL1Validator({
@@ -296,9 +298,9 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
296
298
  chainId: options.l1ChainId,
297
299
  privateKey: options.privateKey,
298
300
  mnemonic: options.mnemonic,
299
- validatorAddress: options.validator,
300
- rollupAddress: options.rollup,
301
- withdrawerAddress: options.withdrawer,
301
+ attesterAddress: options.attester,
302
+ proposerEOAAddress: options.proposerEoa,
303
+ stakingAssetHandlerAddress: options.stakingAssetHandler,
302
304
  log,
303
305
  debugLogger,
304
306
  });
@@ -8,9 +8,9 @@ import {
8
8
  } from '@aztec/ethereum';
9
9
  import type { EthAddress } from '@aztec/foundation/eth-address';
10
10
  import type { LogFn, Logger } from '@aztec/foundation/log';
11
- import { ForwarderAbi, ForwarderBytecode, RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
11
+ import { ForwarderAbi, ForwarderBytecode, RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
12
12
 
13
- import { createPublicClient, createWalletClient, fallback, getContract, http } from 'viem';
13
+ import { createPublicClient, createWalletClient, fallback, formatEther, getContract, http } from 'viem';
14
14
  import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
15
15
 
16
16
  export interface RollupCommandArgs {
@@ -22,6 +22,14 @@ export interface RollupCommandArgs {
22
22
  withdrawerAddress?: EthAddress;
23
23
  }
24
24
 
25
+ export interface StakingAssetHandlerCommandArgs {
26
+ rpcUrls: string[];
27
+ chainId: number;
28
+ privateKey?: string;
29
+ mnemonic?: string;
30
+ stakingAssetHandlerAddress: EthAddress;
31
+ }
32
+
25
33
  export interface LoggerArgs {
26
34
  log: LogFn;
27
35
  debugLogger: Logger;
@@ -42,56 +50,46 @@ export async function addL1Validator({
42
50
  chainId,
43
51
  privateKey,
44
52
  mnemonic,
45
- validatorAddress,
46
- rollupAddress,
47
- withdrawerAddress,
53
+ attesterAddress,
54
+ proposerEOAAddress,
55
+ stakingAssetHandlerAddress,
48
56
  log,
49
57
  debugLogger,
50
- }: RollupCommandArgs & LoggerArgs & { validatorAddress: EthAddress }) {
51
- const config = getL1ContractsConfigEnvVars();
58
+ }: StakingAssetHandlerCommandArgs & LoggerArgs & { attesterAddress: EthAddress; proposerEOAAddress: EthAddress }) {
52
59
  const dualLog = makeDualLog(log, debugLogger);
53
60
  const publicClient = getPublicClient(rpcUrls, chainId);
54
61
  const walletClient = getWalletClient(rpcUrls, chainId, privateKey, mnemonic);
55
- const rollup = getContract({
56
- address: rollupAddress.toString(),
57
- abi: RollupAbi,
58
- client: walletClient,
59
- });
60
62
 
61
- const stakingAsset = getContract({
62
- address: await rollup.read.getStakingAsset(),
63
- abi: TestERC20Abi,
63
+ const stakingAssetHandler = getContract({
64
+ address: stakingAssetHandlerAddress.toString(),
65
+ abi: StakingAssetHandlerAbi,
64
66
  client: walletClient,
65
67
  });
66
68
 
67
- await Promise.all(
68
- [
69
- await stakingAsset.write.mint([walletClient.account.address, config.minimumStake], {} as any),
70
- await stakingAsset.write.approve([rollupAddress.toString(), config.minimumStake], {} as any),
71
- ].map(txHash => publicClient.waitForTransactionReceipt({ hash: txHash })),
72
- );
69
+ const rollup = await stakingAssetHandler.read.getRollup();
73
70
 
74
- dualLog(`Adding validator ${validatorAddress.toString()} to rollup ${rollupAddress.toString()}`);
75
- const txHash = await rollup.write.deposit([
76
- validatorAddress.toString(),
77
- // TODO(#11451): custom forwarders
78
- getExpectedAddress(ForwarderAbi, ForwarderBytecode, [validatorAddress.toString()], validatorAddress.toString())
79
- .address,
80
- withdrawerAddress?.toString() ?? validatorAddress.toString(),
81
- config.minimumStake,
82
- ]);
71
+ const forwarderAddress = getExpectedAddress(
72
+ ForwarderAbi,
73
+ ForwarderBytecode,
74
+ [proposerEOAAddress.toString()],
75
+ proposerEOAAddress.toString(),
76
+ ).address;
77
+
78
+ dualLog(
79
+ `Adding validator (${attesterAddress}, ${proposerEOAAddress} [forwarder: ${forwarderAddress}]) to rollup ${rollup.toString()}`,
80
+ );
81
+ const txHash = await stakingAssetHandler.write.addValidator([attesterAddress.toString(), forwarderAddress]);
83
82
  dualLog(`Transaction hash: ${txHash}`);
84
83
  await publicClient.waitForTransactionReceipt({ hash: txHash });
85
84
  if (isAnvilTestChain(chainId)) {
86
85
  dualLog(`Funding validator on L1`);
87
86
  const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
88
- await cheatCodes.setBalance(validatorAddress, 10n ** 20n);
87
+ await cheatCodes.setBalance(proposerEOAAddress, 10n ** 20n);
89
88
  } else {
90
- const balance = await publicClient.getBalance({ address: validatorAddress.toString() });
91
- const balanceInEth = Number(balance) / 10 ** 18;
92
- dualLog(`Validator balance: ${balanceInEth.toFixed(6)} ETH`);
93
- if (balanceInEth === 0) {
94
- dualLog(`WARNING: Validator has no balance. Remember to fund it!`);
89
+ const balance = await publicClient.getBalance({ address: proposerEOAAddress.toString() });
90
+ dualLog(`Proposer balance: ${formatEther(balance)} ETH`);
91
+ if (balance === 0n) {
92
+ dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
95
93
  }
96
94
  }
97
95
  }
@@ -0,0 +1,7 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+
3
+ import { getSponsoredFPCAddress } from '../../utils/setup_contracts.js';
4
+
5
+ export async function getCanonicalSponsoredFPCAddress(log: LogFn) {
6
+ log(`Canonical SponsoredFPC Address: ${(await getSponsoredFPCAddress()).toString()}`);
7
+ }
@@ -77,6 +77,14 @@ export function injectCommands(program: Command, log: LogFn) {
77
77
  generateSecretAndHash(log);
78
78
  });
79
79
 
80
+ program
81
+ .command('get-canonical-sponsored-fpc-address')
82
+ .description('Gets the canonical SponsoredFPC address for this any testnet running on the same version as this CLI')
83
+ .action(async () => {
84
+ const { getCanonicalSponsoredFPCAddress } = await import('./get_canonical_sponsored_fpc_address.js');
85
+ await getCanonicalSponsoredFPCAddress(log);
86
+ });
87
+
80
88
  program
81
89
  .command('update')
82
90
  .description('Updates Nodejs and Noir dependencies')