@aztec/cli 2.1.0-rc.3 → 2.1.0-rc.30

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 (52) hide show
  1. package/dest/cmds/l1/deploy_new_rollup.d.ts +1 -1
  2. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  3. package/dest/cmds/l1/deploy_new_rollup.js +2 -2
  4. package/dest/cmds/l1/index.d.ts.map +1 -1
  5. package/dest/cmds/l1/index.js +2 -20
  6. package/dest/cmds/validator_keys/add.d.ts +5 -0
  7. package/dest/cmds/validator_keys/add.d.ts.map +1 -0
  8. package/dest/cmds/validator_keys/add.js +70 -0
  9. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
  10. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
  11. package/dest/cmds/validator_keys/generate_bls_keypair.js +26 -0
  12. package/dest/cmds/validator_keys/index.d.ts +4 -0
  13. package/dest/cmds/validator_keys/index.d.ts.map +1 -0
  14. package/dest/cmds/validator_keys/index.js +20 -0
  15. package/dest/cmds/validator_keys/new.d.ts +26 -0
  16. package/dest/cmds/validator_keys/new.d.ts.map +1 -0
  17. package/dest/cmds/validator_keys/new.js +60 -0
  18. package/dest/cmds/validator_keys/shared.d.ts +68 -0
  19. package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
  20. package/dest/cmds/validator_keys/shared.js +271 -0
  21. package/dest/config/chain_l2_config.d.ts +6 -4
  22. package/dest/config/chain_l2_config.d.ts.map +1 -1
  23. package/dest/config/chain_l2_config.js +82 -65
  24. package/dest/utils/aztec.d.ts +1 -1
  25. package/dest/utils/aztec.d.ts.map +1 -1
  26. package/dest/utils/aztec.js +2 -2
  27. package/dest/utils/commands.d.ts +10 -1
  28. package/dest/utils/commands.d.ts.map +1 -1
  29. package/dest/utils/commands.js +30 -3
  30. package/package.json +28 -24
  31. package/src/cmds/l1/deploy_new_rollup.ts +2 -0
  32. package/src/cmds/l1/index.ts +2 -32
  33. package/src/cmds/validator_keys/add.ts +113 -0
  34. package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
  35. package/src/cmds/validator_keys/index.ts +96 -0
  36. package/src/cmds/validator_keys/new.ts +120 -0
  37. package/src/cmds/validator_keys/shared.ts +321 -0
  38. package/src/config/chain_l2_config.ts +110 -84
  39. package/src/utils/aztec.ts +2 -0
  40. package/src/utils/commands.ts +41 -3
  41. package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
  42. package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
  43. package/dest/cmds/devnet/bootstrap_network.js +0 -216
  44. package/dest/cmds/devnet/faucet.d.ts +0 -4
  45. package/dest/cmds/devnet/faucet.d.ts.map +0 -1
  46. package/dest/cmds/devnet/faucet.js +0 -26
  47. package/dest/cmds/devnet/index.d.ts +0 -4
  48. package/dest/cmds/devnet/index.d.ts.map +0 -1
  49. package/dest/cmds/devnet/index.js +0 -14
  50. package/src/cmds/devnet/bootstrap_network.ts +0 -321
  51. package/src/cmds/devnet/faucet.ts +0 -33
  52. package/src/cmds/devnet/index.ts +0 -60
@@ -1,321 +0,0 @@
1
- import { getInitialTestAccountsManagers } from '@aztec/accounts/testing';
2
- import {
3
- AztecAddress,
4
- BatchCall,
5
- EthAddress,
6
- Fr,
7
- L1FeeJuicePortalManager,
8
- type PXE,
9
- type WaitForProvenOpts,
10
- type WaitOpts,
11
- type Wallet,
12
- createCompatibleClient,
13
- retryUntil,
14
- waitForProven,
15
- } from '@aztec/aztec.js';
16
- import {
17
- type ContractArtifacts,
18
- type ExtendedViemWalletClient,
19
- createEthereumChain,
20
- createExtendedL1Client,
21
- deployL1Contract,
22
- } from '@aztec/ethereum';
23
- import type { LogFn, Logger } from '@aztec/foundation/log';
24
-
25
- import { getContract } from 'viem';
26
- import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
27
-
28
- type ContractDeploymentInfo = {
29
- address: AztecAddress;
30
- initHash: Fr;
31
- salt: Fr;
32
- };
33
-
34
- const waitOpts: WaitOpts = {
35
- timeout: 120,
36
- interval: 1,
37
- };
38
-
39
- const provenWaitOpts: WaitForProvenOpts = {
40
- provenTimeout: 4800,
41
- interval: 1,
42
- };
43
-
44
- export async function bootstrapNetwork(
45
- pxeUrl: string,
46
- l1Urls: string[],
47
- l1ChainId: string,
48
- l1PrivateKey: `0x${string}` | undefined,
49
- l1Mnemonic: string,
50
- addressIndex: number,
51
- json: boolean,
52
- log: LogFn,
53
- debugLog: Logger,
54
- ) {
55
- const pxe = await createCompatibleClient(pxeUrl, debugLog);
56
-
57
- // We assume here that the initial test accounts were prefunded with deploy-l1-contracts, and deployed with setup-l2-contracts
58
- // so all we need to do is register them to our pxe.
59
- const [accountManager] = await getInitialTestAccountsManagers(pxe);
60
- await accountManager.register();
61
-
62
- const wallet = await accountManager.getWallet();
63
- const defaultAccountAddress = wallet.getAddress();
64
-
65
- const l1Client = createExtendedL1Client(
66
- l1Urls,
67
- l1PrivateKey
68
- ? privateKeyToAccount(l1PrivateKey)
69
- : // We need to use a different account that the main "deployer" account because the "deployer" account creates transactions that send blobs.
70
- // Note that this account needs to be funded on L1 !
71
- mnemonicToAccount(l1Mnemonic, { addressIndex }),
72
- createEthereumChain(l1Urls, +l1ChainId).chainInfo,
73
- );
74
-
75
- const { erc20Address, portalAddress } = await deployERC20(l1Client);
76
-
77
- const { token, bridge } = await deployToken(wallet, defaultAccountAddress, portalAddress);
78
-
79
- await initPortal(pxe, l1Client, erc20Address, portalAddress, bridge.address);
80
-
81
- const fpcAdmin = wallet.getAddress();
82
- const fpc = await deployFPC(wallet, defaultAccountAddress, token.address, fpcAdmin);
83
-
84
- const counter = await deployCounter(wallet, defaultAccountAddress);
85
-
86
- await fundFPC(pxe, counter.address, wallet, defaultAccountAddress, l1Client, fpc.address, debugLog);
87
-
88
- if (json) {
89
- log(
90
- JSON.stringify(
91
- {
92
- devCoinL1: erc20Address.toString(),
93
- devCoinPortalL1: portalAddress.toString(),
94
- devCoin: {
95
- address: token.address.toString(),
96
- initHash: token.initHash.toString(),
97
- salt: token.salt.toString(),
98
- },
99
- devCoinBridge: {
100
- address: bridge.address.toString(),
101
- initHash: bridge.initHash.toString(),
102
- salt: bridge.salt.toString(),
103
- },
104
- devCoinFpc: {
105
- address: fpc.address.toString(),
106
- initHash: fpc.initHash.toString(),
107
- salt: fpc.salt.toString(),
108
- },
109
- counter: {
110
- address: counter.address.toString(),
111
- initHash: counter.initHash.toString(),
112
- salt: counter.salt.toString(),
113
- },
114
- },
115
- null,
116
- 2,
117
- ),
118
- );
119
- } else {
120
- log(`DevCoin L1: ${erc20Address}`);
121
- log(`DevCoin L1 Portal: ${portalAddress}`);
122
- log(`DevCoin L2: ${token.address}`);
123
- log(`DevCoin L2 init hash: ${token.initHash}`);
124
- log(`DevCoin L2 salt: ${token.salt}`);
125
- log(`DevCoin L2 Bridge: ${bridge.address}`);
126
- log(`DevCoin L2 Bridge init hash: ${bridge.initHash}`);
127
- log(`DevCoin L2 Bridge salt: ${bridge.salt}`);
128
- log(`DevCoin FPC: ${fpc.address}`);
129
- log(`DevCoin FPC init hash: ${fpc.initHash}`);
130
- log(`DevCoin FPC salt: ${fpc.salt}`);
131
- log(`Counter: ${counter.address}`);
132
- log(`Counter init hash: ${counter.initHash}`);
133
- log(`Counter salt: ${counter.salt}`);
134
- }
135
- }
136
-
137
- /**
138
- * Step 1. Deploy the L1 contracts, but don't initialize
139
- */
140
- async function deployERC20(l1Client: ExtendedViemWalletClient) {
141
- const { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } = await import('@aztec/l1-artifacts');
142
-
143
- const erc20: ContractArtifacts = {
144
- name: 'TestERC20',
145
- contractAbi: TestERC20Abi,
146
- contractBytecode: TestERC20Bytecode,
147
- };
148
- const portal: ContractArtifacts = {
149
- name: 'TokenPortal',
150
- contractAbi: TokenPortalAbi,
151
- contractBytecode: TokenPortalBytecode,
152
- };
153
-
154
- const { address: erc20Address } = await deployL1Contract(l1Client, erc20.contractAbi, erc20.contractBytecode, [
155
- 'DevCoin',
156
- 'DEV',
157
- l1Client.account.address,
158
- ]);
159
- const { address: portalAddress } = await deployL1Contract(l1Client, portal.contractAbi, portal.contractBytecode);
160
-
161
- return {
162
- erc20Address,
163
- portalAddress,
164
- };
165
- }
166
-
167
- /**
168
- * Step 2. Deploy the L2 contracts
169
- */
170
- async function deployToken(
171
- wallet: Wallet,
172
- defaultAccountAddress: AztecAddress,
173
- l1Portal: EthAddress,
174
- ): Promise<{ token: ContractDeploymentInfo; bridge: ContractDeploymentInfo }> {
175
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
176
- // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
177
- const { TokenContract } = await import('@aztec/noir-contracts.js/Token');
178
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
179
- // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
180
- const { TokenBridgeContract } = await import('@aztec/noir-contracts.js/TokenBridge');
181
- const devCoin = await TokenContract.deploy(wallet, defaultAccountAddress, 'DevCoin', 'DEV', 18)
182
- .send({ from: defaultAccountAddress, universalDeploy: true })
183
- .deployed(waitOpts);
184
- const bridge = await TokenBridgeContract.deploy(wallet, devCoin.address, l1Portal)
185
- .send({ from: defaultAccountAddress, universalDeploy: true })
186
- .deployed(waitOpts);
187
-
188
- await new BatchCall(wallet, [
189
- devCoin.methods.set_minter(bridge.address, true),
190
- devCoin.methods.set_admin(bridge.address),
191
- ])
192
- .send({ from: defaultAccountAddress })
193
- .wait(waitOpts);
194
-
195
- return {
196
- token: {
197
- address: devCoin.address,
198
- initHash: devCoin.instance.initializationHash,
199
- salt: devCoin.instance.salt,
200
- },
201
- bridge: {
202
- address: bridge.address,
203
- initHash: bridge.instance.initializationHash,
204
- salt: bridge.instance.salt,
205
- },
206
- };
207
- }
208
-
209
- /**
210
- * Step 3. Initialize DevCoin's L1 portal
211
- */
212
- async function initPortal(
213
- pxe: PXE,
214
- l1Client: ExtendedViemWalletClient,
215
- erc20: EthAddress,
216
- portal: EthAddress,
217
- bridge: AztecAddress,
218
- ) {
219
- const { TokenPortalAbi } = await import('@aztec/l1-artifacts');
220
- const {
221
- l1ContractAddresses: { registryAddress },
222
- } = await pxe.getNodeInfo();
223
-
224
- const contract = getContract({
225
- abi: TokenPortalAbi,
226
- address: portal.toString(),
227
- client: l1Client,
228
- });
229
-
230
- const hash = await contract.write.initialize([registryAddress.toString(), erc20.toString(), bridge.toString()]);
231
-
232
- await l1Client.waitForTransactionReceipt({ hash });
233
- }
234
-
235
- async function deployFPC(
236
- wallet: Wallet,
237
- defaultAccountAddress: AztecAddress,
238
- tokenAddress: AztecAddress,
239
- admin: AztecAddress,
240
- ): Promise<ContractDeploymentInfo> {
241
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
242
- // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
243
- const { FPCContract } = await import('@aztec/noir-contracts.js/FPC');
244
- const fpc = await FPCContract.deploy(wallet, tokenAddress, admin)
245
- .send({ from: defaultAccountAddress, universalDeploy: true })
246
- .deployed(waitOpts);
247
- const info: ContractDeploymentInfo = {
248
- address: fpc.address,
249
- initHash: fpc.instance.initializationHash,
250
- salt: fpc.instance.salt,
251
- };
252
- return info;
253
- }
254
-
255
- async function deployCounter(wallet: Wallet, defaultAccountAddress: AztecAddress): Promise<ContractDeploymentInfo> {
256
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
257
- // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
258
- const { CounterContract } = await import('@aztec/noir-test-contracts.js/Counter');
259
- const counter = await CounterContract.deploy(wallet, 1, defaultAccountAddress)
260
- .send({ from: defaultAccountAddress, universalDeploy: true })
261
- .deployed(waitOpts);
262
- const info: ContractDeploymentInfo = {
263
- address: counter.address,
264
- initHash: counter.instance.initializationHash,
265
- salt: counter.instance.salt,
266
- };
267
- return info;
268
- }
269
-
270
- // NOTE: Disabling for now in order to get devnet running
271
- async function fundFPC(
272
- pxe: PXE,
273
- counterAddress: AztecAddress,
274
- wallet: Wallet,
275
- defaultAccountAddress: AztecAddress,
276
- l1Client: ExtendedViemWalletClient,
277
- fpcAddress: AztecAddress,
278
- debugLog: Logger,
279
- ) {
280
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
281
- // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
282
- const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
283
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
284
- // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
285
- const { CounterContract } = await import('@aztec/noir-test-contracts.js/Counter');
286
- const {
287
- protocolContractAddresses: { feeJuice },
288
- } = await wallet.getPXEInfo();
289
-
290
- const feeJuiceContract = await FeeJuiceContract.at(feeJuice, wallet);
291
-
292
- const feeJuicePortal = await L1FeeJuicePortalManager.new(wallet, l1Client, debugLog);
293
-
294
- const { claimAmount, claimSecret, messageLeafIndex, messageHash } = await feeJuicePortal.bridgeTokensPublic(
295
- fpcAddress,
296
- undefined,
297
- true,
298
- );
299
-
300
- await retryUntil(async () => await pxe.isL1ToL2MessageSynced(Fr.fromHexString(messageHash)), 'message sync', 600, 1);
301
-
302
- const counter = await CounterContract.at(counterAddress, wallet);
303
-
304
- debugLog.info('Incrementing Counter');
305
-
306
- // TODO (alexg) remove this once sequencer builds blocks continuously
307
- // advance the chain
308
- await counter.methods.increment(wallet.getAddress()).send({ from: defaultAccountAddress }).wait(waitOpts);
309
- await counter.methods.increment(wallet.getAddress()).send({ from: defaultAccountAddress }).wait(waitOpts);
310
-
311
- debugLog.info('Claiming FPC');
312
-
313
- const receipt = await feeJuiceContract.methods
314
- .claim(fpcAddress, claimAmount, claimSecret, messageLeafIndex)
315
- .send({ from: defaultAccountAddress })
316
- .wait({ ...waitOpts });
317
-
318
- await waitForProven(pxe, receipt, provenWaitOpts);
319
-
320
- debugLog.info('Finished claiming FPC');
321
- }
@@ -1,33 +0,0 @@
1
- import type { EthAddress } from '@aztec/foundation/eth-address';
2
- import type { LogFn } from '@aztec/foundation/log';
3
-
4
- import { prettyPrintJSON } from '../../utils/commands.js';
5
-
6
- export async function dripFaucet(
7
- faucetUrl: string,
8
- asset: string,
9
- account: EthAddress,
10
- json: boolean,
11
- log: LogFn,
12
- ): Promise<void> {
13
- const url = new URL(`/drip/${account.toString()}`, faucetUrl);
14
- url.searchParams.set('asset', asset);
15
- const res = await fetch(url);
16
- if (res.status === 200) {
17
- if (json) {
18
- log(prettyPrintJSON({ ok: true }));
19
- } else {
20
- log(`Dripped ${asset} for ${account.toString()}`);
21
- }
22
- } else {
23
- if (json) {
24
- log(prettyPrintJSON({ ok: false }));
25
- } else if (res.status === 429) {
26
- log(`Rate limited when dripping ${asset} for ${account.toString()}`);
27
- } else {
28
- log(`Failed to drip ${asset} for ${account.toString()}`);
29
- }
30
-
31
- process.exit(1);
32
- }
33
- }
@@ -1,60 +0,0 @@
1
- import type { LogFn, Logger } from '@aztec/foundation/log';
2
-
3
- import type { Command } from 'commander';
4
-
5
- import { ETHEREUM_HOSTS, l1ChainIdOption, parseEthereumAddress, pxeOption } from '../../utils/commands.js';
6
-
7
- export function injectCommands(program: Command, log: LogFn, debugLogger: Logger) {
8
- program
9
- .command('bootstrap-network')
10
- .description('Bootstrap a new network')
11
- .addOption(pxeOption)
12
- .addOption(l1ChainIdOption)
13
- .requiredOption<string[]>(
14
- '--l1-rpc-urls <string>',
15
- 'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)',
16
- (arg: string) => arg.split(','),
17
- [ETHEREUM_HOSTS],
18
- )
19
- .option('--l1-private-key <string>', 'The private key to use for deployment', process.env.PRIVATE_KEY)
20
- .option(
21
- '-m, --mnemonic <string>',
22
- 'The mnemonic to use in deployment',
23
- 'test test test test test test test test test test test junk',
24
- )
25
- .option(
26
- '-ai, --address-index <number>',
27
- 'The address index to use when calculating an address',
28
- arg => BigInt(arg),
29
- 0n,
30
- )
31
- .option('--json', 'Output the result as JSON')
32
- .action(async options => {
33
- const { bootstrapNetwork } = await import('./bootstrap_network.js');
34
- await bootstrapNetwork(
35
- options[pxeOption.attributeName()],
36
- options.l1RpcUrls,
37
- options[l1ChainIdOption.attributeName()],
38
- options.l1PrivateKey,
39
- options.mnemonic,
40
- options.addressIndex,
41
- options.json,
42
- log,
43
- debugLogger,
44
- );
45
- });
46
-
47
- program
48
- .command('drip-faucet')
49
- .description('Drip the faucet')
50
- .requiredOption('-u, --faucet-url <string>', 'Url of the faucet', 'http://localhost:8082')
51
- .requiredOption('-t, --token <string>', 'The asset to drip', 'eth')
52
- .requiredOption('-a, --address <string>', 'The Ethereum address to drip to', parseEthereumAddress)
53
- .option('--json', 'Output the result as JSON')
54
- .action(async options => {
55
- const { dripFaucet } = await import('./faucet.js');
56
- await dripFaucet(options.faucetUrl, options.token, options.address, options.json, log);
57
- });
58
-
59
- return program;
60
- }