@aztec/cli 3.0.0-nightly.20251012 → 3.0.0-nightly.20251014

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 +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;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAa3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAkhB/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;AAa3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAkf/E"}
@@ -194,23 +194,5 @@ export function injectCommands(program, log, debugLogger) {
194
194
  const { advanceEpoch } = await import('./advance_epoch.js');
195
195
  await advanceEpoch(options.l1RpcUrls, options.nodeUrl, log);
196
196
  });
197
- program.command('prover-stats', {
198
- hidden: true
199
- }).addOption(l1RpcUrlsOption).addOption(l1ChainIdOption).option('--start-block <number>', 'The L1 block number to start from', parseBigint, 1n).option('--end-block <number>', 'The last L1 block number to query', parseBigint).option('--batch-size <number>', 'The number of blocks to query in each batch', parseBigint, 100n).option('--proving-timeout <number>', 'Cutoff for proving time to consider a block', parseBigint).option('--l1-rollup-address <string>', 'Address of the rollup contract (required if node URL is not set)').option('--node-url <string>', 'JSON RPC URL of an Aztec node to retrieve the rollup contract address (required if L1 rollup address is not set)').option('--raw-logs', 'Output raw logs instead of aggregated stats').action(async (options)=>{
200
- const { proverStats } = await import('./prover_stats.js');
201
- const { l1RpcUrls, chainId, l1RollupAddress, startBlock, endBlock, batchSize, nodeUrl, provingTimeout, rawLogs } = options;
202
- await proverStats({
203
- l1RpcUrls,
204
- chainId,
205
- l1RollupAddress,
206
- startBlock,
207
- endBlock,
208
- batchSize,
209
- nodeUrl,
210
- provingTimeout,
211
- rawLogs,
212
- log
213
- });
214
- });
215
197
  return program;
216
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "3.0.0-nightly.20251012",
3
+ "version": "3.0.0-nightly.20251014",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./contracts": "./dest/cmds/contracts/index.js",
@@ -70,20 +70,20 @@
70
70
  ]
71
71
  },
72
72
  "dependencies": {
73
- "@aztec/accounts": "3.0.0-nightly.20251012",
74
- "@aztec/archiver": "3.0.0-nightly.20251012",
75
- "@aztec/aztec.js": "3.0.0-nightly.20251012",
76
- "@aztec/constants": "3.0.0-nightly.20251012",
77
- "@aztec/entrypoints": "3.0.0-nightly.20251012",
78
- "@aztec/ethereum": "3.0.0-nightly.20251012",
79
- "@aztec/foundation": "3.0.0-nightly.20251012",
80
- "@aztec/l1-artifacts": "3.0.0-nightly.20251012",
81
- "@aztec/node-lib": "3.0.0-nightly.20251012",
82
- "@aztec/p2p": "3.0.0-nightly.20251012",
83
- "@aztec/protocol-contracts": "3.0.0-nightly.20251012",
84
- "@aztec/stdlib": "3.0.0-nightly.20251012",
85
- "@aztec/test-wallet": "3.0.0-nightly.20251012",
86
- "@aztec/world-state": "3.0.0-nightly.20251012",
73
+ "@aztec/accounts": "3.0.0-nightly.20251014",
74
+ "@aztec/archiver": "3.0.0-nightly.20251014",
75
+ "@aztec/aztec.js": "3.0.0-nightly.20251014",
76
+ "@aztec/constants": "3.0.0-nightly.20251014",
77
+ "@aztec/entrypoints": "3.0.0-nightly.20251014",
78
+ "@aztec/ethereum": "3.0.0-nightly.20251014",
79
+ "@aztec/foundation": "3.0.0-nightly.20251014",
80
+ "@aztec/l1-artifacts": "3.0.0-nightly.20251014",
81
+ "@aztec/node-lib": "3.0.0-nightly.20251014",
82
+ "@aztec/p2p": "3.0.0-nightly.20251014",
83
+ "@aztec/protocol-contracts": "3.0.0-nightly.20251014",
84
+ "@aztec/stdlib": "3.0.0-nightly.20251014",
85
+ "@aztec/test-wallet": "3.0.0-nightly.20251014",
86
+ "@aztec/world-state": "3.0.0-nightly.20251014",
87
87
  "@iarna/toml": "^2.2.5",
88
88
  "@libp2p/peer-id-factory": "^3.0.4",
89
89
  "commander": "^12.1.0",
@@ -110,15 +110,15 @@
110
110
  "typescript": "^5.3.3"
111
111
  },
112
112
  "peerDependencies": {
113
- "@aztec/accounts": "3.0.0-nightly.20251012",
114
- "@aztec/bb-prover": "3.0.0-nightly.20251012",
115
- "@aztec/ethereum": "3.0.0-nightly.20251012",
116
- "@aztec/l1-artifacts": "3.0.0-nightly.20251012",
117
- "@aztec/noir-contracts.js": "3.0.0-nightly.20251012",
118
- "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251012",
119
- "@aztec/noir-test-contracts.js": "3.0.0-nightly.20251012",
120
- "@aztec/protocol-contracts": "3.0.0-nightly.20251012",
121
- "@aztec/stdlib": "3.0.0-nightly.20251012"
113
+ "@aztec/accounts": "3.0.0-nightly.20251014",
114
+ "@aztec/bb-prover": "3.0.0-nightly.20251014",
115
+ "@aztec/ethereum": "3.0.0-nightly.20251014",
116
+ "@aztec/l1-artifacts": "3.0.0-nightly.20251014",
117
+ "@aztec/noir-contracts.js": "3.0.0-nightly.20251014",
118
+ "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251014",
119
+ "@aztec/noir-test-contracts.js": "3.0.0-nightly.20251014",
120
+ "@aztec/protocol-contracts": "3.0.0-nightly.20251014",
121
+ "@aztec/stdlib": "3.0.0-nightly.20251014"
122
122
  },
123
123
  "files": [
124
124
  "dest",
@@ -525,37 +525,5 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
525
525
  await advanceEpoch(options.l1RpcUrls, options.nodeUrl, log);
526
526
  });
527
527
 
528
- program
529
- .command('prover-stats', { hidden: true })
530
- .addOption(l1RpcUrlsOption)
531
- .addOption(l1ChainIdOption)
532
- .option('--start-block <number>', 'The L1 block number to start from', parseBigint, 1n)
533
- .option('--end-block <number>', 'The last L1 block number to query', parseBigint)
534
- .option('--batch-size <number>', 'The number of blocks to query in each batch', parseBigint, 100n)
535
- .option('--proving-timeout <number>', 'Cutoff for proving time to consider a block', parseBigint)
536
- .option('--l1-rollup-address <string>', 'Address of the rollup contract (required if node URL is not set)')
537
- .option(
538
- '--node-url <string>',
539
- 'JSON RPC URL of an Aztec node to retrieve the rollup contract address (required if L1 rollup address is not set)',
540
- )
541
- .option('--raw-logs', 'Output raw logs instead of aggregated stats')
542
- .action(async options => {
543
- const { proverStats } = await import('./prover_stats.js');
544
- const { l1RpcUrls, chainId, l1RollupAddress, startBlock, endBlock, batchSize, nodeUrl, provingTimeout, rawLogs } =
545
- options;
546
- await proverStats({
547
- l1RpcUrls,
548
- chainId,
549
- l1RollupAddress,
550
- startBlock,
551
- endBlock,
552
- batchSize,
553
- nodeUrl,
554
- provingTimeout,
555
- rawLogs,
556
- log,
557
- });
558
- });
559
-
560
528
  return program;
561
529
  }
@@ -1,3 +0,0 @@
1
- import type { LogFn, Logger } from '@aztec/foundation/log';
2
- export declare function bootstrapNetwork(nodeUrl: string, l1Urls: string[], l1ChainId: string, l1PrivateKey: `0x${string}` | undefined, l1Mnemonic: string, addressIndex: number, json: boolean, log: LogFn, debugLog: Logger): Promise<void>;
3
- //# sourceMappingURL=bootstrap_network.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bootstrap_network.d.ts","sourceRoot":"","sources":["../../../src/cmds/devnet/bootstrap_network.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAsB3D,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS,EACvC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,MAAM,iBAsFjB"}
@@ -1,217 +0,0 @@
1
- import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
- import { BatchCall, Fr, L1FeeJuicePortalManager, createAztecNodeClient, retryUntil, waitForProven } from '@aztec/aztec.js';
3
- import { createEthereumChain, createExtendedL1Client, deployL1Contract } from '@aztec/ethereum';
4
- import { TestWallet } from '@aztec/test-wallet/server';
5
- import { getContract } from 'viem';
6
- import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
7
- const waitOpts = {
8
- timeout: 120,
9
- interval: 1
10
- };
11
- const provenWaitOpts = {
12
- provenTimeout: 4800,
13
- interval: 1
14
- };
15
- export async function bootstrapNetwork(nodeUrl, l1Urls, l1ChainId, l1PrivateKey, l1Mnemonic, addressIndex, json, log, debugLog) {
16
- const node = createAztecNodeClient(nodeUrl);
17
- const wallet = await TestWallet.create(node);
18
- // We assume here that the initial test accounts were prefunded with deploy-l1-contracts, and deployed with setup-l2-contracts
19
- // so all we need to do is register them to our pxe.
20
- const [accountData] = await getInitialTestAccountsData();
21
- const accountManager = await wallet.createSchnorrAccount(accountData.secret, accountData.salt, accountData.signingKey);
22
- const defaultAccountAddress = accountManager.address;
23
- const l1Client = createExtendedL1Client(l1Urls, l1PrivateKey ? privateKeyToAccount(l1PrivateKey) : // Note that this account needs to be funded on L1 !
24
- mnemonicToAccount(l1Mnemonic, {
25
- addressIndex
26
- }), createEthereumChain(l1Urls, +l1ChainId).chainInfo);
27
- const { erc20Address, portalAddress } = await deployERC20(l1Client);
28
- const { token, bridge } = await deployToken(wallet, defaultAccountAddress, portalAddress);
29
- await initPortal(node, l1Client, erc20Address, portalAddress, bridge.address);
30
- const fpcAdmin = defaultAccountAddress;
31
- const fpc = await deployFPC(wallet, defaultAccountAddress, token.address, fpcAdmin);
32
- const counter = await deployCounter(wallet, defaultAccountAddress);
33
- await fundFPC(node, counter.address, wallet, defaultAccountAddress, l1Client, fpc.address, debugLog);
34
- if (json) {
35
- log(JSON.stringify({
36
- devCoinL1: erc20Address.toString(),
37
- devCoinPortalL1: portalAddress.toString(),
38
- devCoin: {
39
- address: token.address.toString(),
40
- initHash: token.initHash.toString(),
41
- salt: token.salt.toString()
42
- },
43
- devCoinBridge: {
44
- address: bridge.address.toString(),
45
- initHash: bridge.initHash.toString(),
46
- salt: bridge.salt.toString()
47
- },
48
- devCoinFpc: {
49
- address: fpc.address.toString(),
50
- initHash: fpc.initHash.toString(),
51
- salt: fpc.salt.toString()
52
- },
53
- counter: {
54
- address: counter.address.toString(),
55
- initHash: counter.initHash.toString(),
56
- salt: counter.salt.toString()
57
- }
58
- }, null, 2));
59
- } else {
60
- log(`DevCoin L1: ${erc20Address}`);
61
- log(`DevCoin L1 Portal: ${portalAddress}`);
62
- log(`DevCoin L2: ${token.address}`);
63
- log(`DevCoin L2 init hash: ${token.initHash}`);
64
- log(`DevCoin L2 salt: ${token.salt}`);
65
- log(`DevCoin L2 Bridge: ${bridge.address}`);
66
- log(`DevCoin L2 Bridge init hash: ${bridge.initHash}`);
67
- log(`DevCoin L2 Bridge salt: ${bridge.salt}`);
68
- log(`DevCoin FPC: ${fpc.address}`);
69
- log(`DevCoin FPC init hash: ${fpc.initHash}`);
70
- log(`DevCoin FPC salt: ${fpc.salt}`);
71
- log(`Counter: ${counter.address}`);
72
- log(`Counter init hash: ${counter.initHash}`);
73
- log(`Counter salt: ${counter.salt}`);
74
- }
75
- }
76
- /**
77
- * Step 1. Deploy the L1 contracts, but don't initialize
78
- */ async function deployERC20(l1Client) {
79
- const { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } = await import('@aztec/l1-artifacts');
80
- const erc20 = {
81
- name: 'TestERC20',
82
- contractAbi: TestERC20Abi,
83
- contractBytecode: TestERC20Bytecode
84
- };
85
- const portal = {
86
- name: 'TokenPortal',
87
- contractAbi: TokenPortalAbi,
88
- contractBytecode: TokenPortalBytecode
89
- };
90
- const { address: erc20Address } = await deployL1Contract(l1Client, erc20.contractAbi, erc20.contractBytecode, [
91
- 'DevCoin',
92
- 'DEV',
93
- l1Client.account.address
94
- ]);
95
- const { address: portalAddress } = await deployL1Contract(l1Client, portal.contractAbi, portal.contractBytecode);
96
- return {
97
- erc20Address,
98
- portalAddress
99
- };
100
- }
101
- /**
102
- * Step 2. Deploy the L2 contracts
103
- */ async function deployToken(wallet, defaultAccountAddress, l1Portal) {
104
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
105
- // @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
106
- const { TokenContract } = await import('@aztec/noir-contracts.js/Token');
107
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
108
- // @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
109
- const { TokenBridgeContract } = await import('@aztec/noir-contracts.js/TokenBridge');
110
- const devCoin = await TokenContract.deploy(wallet, defaultAccountAddress, 'DevCoin', 'DEV', 18).send({
111
- from: defaultAccountAddress,
112
- universalDeploy: true
113
- }).deployed(waitOpts);
114
- const bridge = await TokenBridgeContract.deploy(wallet, devCoin.address, l1Portal).send({
115
- from: defaultAccountAddress,
116
- universalDeploy: true
117
- }).deployed(waitOpts);
118
- await new BatchCall(wallet, [
119
- devCoin.methods.set_minter(bridge.address, true),
120
- devCoin.methods.set_admin(bridge.address)
121
- ]).send({
122
- from: defaultAccountAddress
123
- }).wait(waitOpts);
124
- return {
125
- token: {
126
- address: devCoin.address,
127
- initHash: devCoin.instance.initializationHash,
128
- salt: devCoin.instance.salt
129
- },
130
- bridge: {
131
- address: bridge.address,
132
- initHash: bridge.instance.initializationHash,
133
- salt: bridge.instance.salt
134
- }
135
- };
136
- }
137
- /**
138
- * Step 3. Initialize DevCoin's L1 portal
139
- */ async function initPortal(aztecNode, l1Client, erc20, portal, bridge) {
140
- const { TokenPortalAbi } = await import('@aztec/l1-artifacts');
141
- const { l1ContractAddresses: { registryAddress } } = await aztecNode.getNodeInfo();
142
- const contract = getContract({
143
- abi: TokenPortalAbi,
144
- address: portal.toString(),
145
- client: l1Client
146
- });
147
- const hash = await contract.write.initialize([
148
- registryAddress.toString(),
149
- erc20.toString(),
150
- bridge.toString()
151
- ]);
152
- await l1Client.waitForTransactionReceipt({
153
- hash
154
- });
155
- }
156
- async function deployFPC(wallet, defaultAccountAddress, tokenAddress, admin) {
157
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
158
- // @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
159
- const { FPCContract } = await import('@aztec/noir-contracts.js/FPC');
160
- const fpc = await FPCContract.deploy(wallet, tokenAddress, admin).send({
161
- from: defaultAccountAddress,
162
- universalDeploy: true
163
- }).deployed(waitOpts);
164
- const info = {
165
- address: fpc.address,
166
- initHash: fpc.instance.initializationHash,
167
- salt: fpc.instance.salt
168
- };
169
- return info;
170
- }
171
- async function deployCounter(wallet, defaultAccountAddress) {
172
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
173
- // @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
174
- const { CounterContract } = await import('@aztec/noir-test-contracts.js/Counter');
175
- const counter = await CounterContract.deploy(wallet, 1, defaultAccountAddress).send({
176
- from: defaultAccountAddress,
177
- universalDeploy: true
178
- }).deployed(waitOpts);
179
- const info = {
180
- address: counter.address,
181
- initHash: counter.instance.initializationHash,
182
- salt: counter.instance.salt
183
- };
184
- return info;
185
- }
186
- // NOTE: Disabling for now in order to get devnet running
187
- async function fundFPC(node, counterAddress, wallet, defaultAccountAddress, l1Client, fpcAddress, debugLog) {
188
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
189
- // @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
190
- const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
191
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
192
- // @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
193
- const { CounterContract } = await import('@aztec/noir-test-contracts.js/Counter');
194
- const { protocolContractAddresses: { feeJuice } } = await node.getNodeInfo();
195
- const feeJuiceContract = await FeeJuiceContract.at(feeJuice, wallet);
196
- const feeJuicePortal = await L1FeeJuicePortalManager.new(node, l1Client, debugLog);
197
- const { claimAmount, claimSecret, messageLeafIndex, messageHash } = await feeJuicePortal.bridgeTokensPublic(fpcAddress, undefined, true);
198
- await retryUntil(async ()=>await node.getL1ToL2MessageBlock(Fr.fromHexString(messageHash)) !== undefined, 'message sync', 600, 1);
199
- const counter = await CounterContract.at(counterAddress, wallet);
200
- debugLog.info('Incrementing Counter');
201
- // TODO (alexg) remove this once sequencer builds blocks continuously
202
- // advance the chain
203
- await counter.methods.increment(defaultAccountAddress).send({
204
- from: defaultAccountAddress
205
- }).wait(waitOpts);
206
- await counter.methods.increment(defaultAccountAddress).send({
207
- from: defaultAccountAddress
208
- }).wait(waitOpts);
209
- debugLog.info('Claiming FPC');
210
- const receipt = await feeJuiceContract.methods.claim(fpcAddress, claimAmount, claimSecret, messageLeafIndex).send({
211
- from: defaultAccountAddress
212
- }).wait({
213
- ...waitOpts
214
- });
215
- await waitForProven(node, receipt, provenWaitOpts);
216
- debugLog.info('Finished claiming FPC');
217
- }
@@ -1,4 +0,0 @@
1
- import type { EthAddress } from '@aztec/foundation/eth-address';
2
- import type { LogFn } from '@aztec/foundation/log';
3
- export declare function dripFaucet(faucetUrl: string, asset: string, account: EthAddress, json: boolean, log: LogFn): Promise<void>;
4
- //# sourceMappingURL=faucet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"faucet.d.ts","sourceRoot":"","sources":["../../../src/cmds/devnet/faucet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,IAAI,CAAC,CAqBf"}
@@ -1,26 +0,0 @@
1
- import { prettyPrintJSON } from '../../utils/commands.js';
2
- export async function dripFaucet(faucetUrl, asset, account, json, log) {
3
- const url = new URL(`/drip/${account.toString()}`, faucetUrl);
4
- url.searchParams.set('asset', asset);
5
- const res = await fetch(url);
6
- if (res.status === 200) {
7
- if (json) {
8
- log(prettyPrintJSON({
9
- ok: true
10
- }));
11
- } else {
12
- log(`Dripped ${asset} for ${account.toString()}`);
13
- }
14
- } else {
15
- if (json) {
16
- log(prettyPrintJSON({
17
- ok: false
18
- }));
19
- } else if (res.status === 429) {
20
- log(`Rate limited when dripping ${asset} for ${account.toString()}`);
21
- } else {
22
- log(`Failed to drip ${asset} for ${account.toString()}`);
23
- }
24
- process.exit(1);
25
- }
26
- }
@@ -1,4 +0,0 @@
1
- import type { LogFn, Logger } from '@aztec/foundation/log';
2
- import type { Command } from 'commander';
3
- export declare function injectCommands(program: Command, log: LogFn, debugLogger: Logger): Command;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/devnet/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAqD/E"}
@@ -1,14 +0,0 @@
1
- import { ETHEREUM_HOSTS, l1ChainIdOption, nodeOption, parseEthereumAddress } from '../../utils/commands.js';
2
- export function injectCommands(program, log, debugLogger) {
3
- program.command('bootstrap-network').description('Bootstrap a new network').addOption(nodeOption).addOption(l1ChainIdOption).requiredOption('--l1-rpc-urls <string>', 'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)', (arg)=>arg.split(','), [
4
- ETHEREUM_HOSTS
5
- ]).option('--l1-private-key <string>', 'The private key to use for deployment', process.env.PRIVATE_KEY).option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').option('-ai, --address-index <number>', 'The address index to use when calculating an address', (arg)=>BigInt(arg), 0n).option('--json', 'Output the result as JSON').action(async (options)=>{
6
- const { bootstrapNetwork } = await import('./bootstrap_network.js');
7
- await bootstrapNetwork(options[nodeOption.attributeName()], options.l1RpcUrls, options[l1ChainIdOption.attributeName()], options.l1PrivateKey, options.mnemonic, options.addressIndex, options.json, log, debugLogger);
8
- });
9
- program.command('drip-faucet').description('Drip the faucet').requiredOption('-u, --faucet-url <string>', 'Url of the faucet', 'http://localhost:8082').requiredOption('-t, --token <string>', 'The asset to drip', 'eth').requiredOption('-a, --address <string>', 'The Ethereum address to drip to', parseEthereumAddress).option('--json', 'Output the result as JSON').action(async (options)=>{
10
- const { dripFaucet } = await import('./faucet.js');
11
- await dripFaucet(options.faucetUrl, options.token, options.address, options.json, log);
12
- });
13
- return program;
14
- }
@@ -1,331 +0,0 @@
1
- import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
- import {
3
- AztecAddress,
4
- type AztecNode,
5
- BatchCall,
6
- EthAddress,
7
- Fr,
8
- L1FeeJuicePortalManager,
9
- type WaitForProvenOpts,
10
- type WaitOpts,
11
- type Wallet,
12
- createAztecNodeClient,
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
- import { TestWallet } from '@aztec/test-wallet/server';
25
-
26
- import { getContract } from 'viem';
27
- import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
28
-
29
- type ContractDeploymentInfo = {
30
- address: AztecAddress;
31
- initHash: Fr;
32
- salt: Fr;
33
- };
34
-
35
- const waitOpts: WaitOpts = {
36
- timeout: 120,
37
- interval: 1,
38
- };
39
-
40
- const provenWaitOpts: WaitForProvenOpts = {
41
- provenTimeout: 4800,
42
- interval: 1,
43
- };
44
-
45
- export async function bootstrapNetwork(
46
- nodeUrl: string,
47
- l1Urls: string[],
48
- l1ChainId: string,
49
- l1PrivateKey: `0x${string}` | undefined,
50
- l1Mnemonic: string,
51
- addressIndex: number,
52
- json: boolean,
53
- log: LogFn,
54
- debugLog: Logger,
55
- ) {
56
- const node = createAztecNodeClient(nodeUrl);
57
- const wallet = await TestWallet.create(node);
58
-
59
- // We assume here that the initial test accounts were prefunded with deploy-l1-contracts, and deployed with setup-l2-contracts
60
- // so all we need to do is register them to our pxe.
61
- const [accountData] = await getInitialTestAccountsData();
62
- const accountManager = await wallet.createSchnorrAccount(
63
- accountData.secret,
64
- accountData.salt,
65
- accountData.signingKey,
66
- );
67
-
68
- const defaultAccountAddress = accountManager.address;
69
-
70
- const l1Client = createExtendedL1Client(
71
- l1Urls,
72
- l1PrivateKey
73
- ? privateKeyToAccount(l1PrivateKey)
74
- : // We need to use a different account that the main "deployer" account because the "deployer" account creates transactions that send blobs.
75
- // Note that this account needs to be funded on L1 !
76
- mnemonicToAccount(l1Mnemonic, { addressIndex }),
77
- createEthereumChain(l1Urls, +l1ChainId).chainInfo,
78
- );
79
-
80
- const { erc20Address, portalAddress } = await deployERC20(l1Client);
81
-
82
- const { token, bridge } = await deployToken(wallet, defaultAccountAddress, portalAddress);
83
-
84
- await initPortal(node, l1Client, erc20Address, portalAddress, bridge.address);
85
-
86
- const fpcAdmin = defaultAccountAddress;
87
- const fpc = await deployFPC(wallet, defaultAccountAddress, token.address, fpcAdmin);
88
-
89
- const counter = await deployCounter(wallet, defaultAccountAddress);
90
-
91
- await fundFPC(node, counter.address, wallet, defaultAccountAddress, l1Client, fpc.address, debugLog);
92
-
93
- if (json) {
94
- log(
95
- JSON.stringify(
96
- {
97
- devCoinL1: erc20Address.toString(),
98
- devCoinPortalL1: portalAddress.toString(),
99
- devCoin: {
100
- address: token.address.toString(),
101
- initHash: token.initHash.toString(),
102
- salt: token.salt.toString(),
103
- },
104
- devCoinBridge: {
105
- address: bridge.address.toString(),
106
- initHash: bridge.initHash.toString(),
107
- salt: bridge.salt.toString(),
108
- },
109
- devCoinFpc: {
110
- address: fpc.address.toString(),
111
- initHash: fpc.initHash.toString(),
112
- salt: fpc.salt.toString(),
113
- },
114
- counter: {
115
- address: counter.address.toString(),
116
- initHash: counter.initHash.toString(),
117
- salt: counter.salt.toString(),
118
- },
119
- },
120
- null,
121
- 2,
122
- ),
123
- );
124
- } else {
125
- log(`DevCoin L1: ${erc20Address}`);
126
- log(`DevCoin L1 Portal: ${portalAddress}`);
127
- log(`DevCoin L2: ${token.address}`);
128
- log(`DevCoin L2 init hash: ${token.initHash}`);
129
- log(`DevCoin L2 salt: ${token.salt}`);
130
- log(`DevCoin L2 Bridge: ${bridge.address}`);
131
- log(`DevCoin L2 Bridge init hash: ${bridge.initHash}`);
132
- log(`DevCoin L2 Bridge salt: ${bridge.salt}`);
133
- log(`DevCoin FPC: ${fpc.address}`);
134
- log(`DevCoin FPC init hash: ${fpc.initHash}`);
135
- log(`DevCoin FPC salt: ${fpc.salt}`);
136
- log(`Counter: ${counter.address}`);
137
- log(`Counter init hash: ${counter.initHash}`);
138
- log(`Counter salt: ${counter.salt}`);
139
- }
140
- }
141
-
142
- /**
143
- * Step 1. Deploy the L1 contracts, but don't initialize
144
- */
145
- async function deployERC20(l1Client: ExtendedViemWalletClient) {
146
- const { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } = await import('@aztec/l1-artifacts');
147
-
148
- const erc20: ContractArtifacts = {
149
- name: 'TestERC20',
150
- contractAbi: TestERC20Abi,
151
- contractBytecode: TestERC20Bytecode,
152
- };
153
- const portal: ContractArtifacts = {
154
- name: 'TokenPortal',
155
- contractAbi: TokenPortalAbi,
156
- contractBytecode: TokenPortalBytecode,
157
- };
158
-
159
- const { address: erc20Address } = await deployL1Contract(l1Client, erc20.contractAbi, erc20.contractBytecode, [
160
- 'DevCoin',
161
- 'DEV',
162
- l1Client.account.address,
163
- ]);
164
- const { address: portalAddress } = await deployL1Contract(l1Client, portal.contractAbi, portal.contractBytecode);
165
-
166
- return {
167
- erc20Address,
168
- portalAddress,
169
- };
170
- }
171
-
172
- /**
173
- * Step 2. Deploy the L2 contracts
174
- */
175
- async function deployToken(
176
- wallet: Wallet,
177
- defaultAccountAddress: AztecAddress,
178
- l1Portal: EthAddress,
179
- ): Promise<{ token: ContractDeploymentInfo; bridge: ContractDeploymentInfo }> {
180
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
181
- // @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
182
- const { TokenContract } = await import('@aztec/noir-contracts.js/Token');
183
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
184
- // @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
185
- const { TokenBridgeContract } = await import('@aztec/noir-contracts.js/TokenBridge');
186
- const devCoin = await TokenContract.deploy(wallet, defaultAccountAddress, 'DevCoin', 'DEV', 18)
187
- .send({ from: defaultAccountAddress, universalDeploy: true })
188
- .deployed(waitOpts);
189
- const bridge = await TokenBridgeContract.deploy(wallet, devCoin.address, l1Portal)
190
- .send({ from: defaultAccountAddress, universalDeploy: true })
191
- .deployed(waitOpts);
192
-
193
- await new BatchCall(wallet, [
194
- devCoin.methods.set_minter(bridge.address, true),
195
- devCoin.methods.set_admin(bridge.address),
196
- ])
197
- .send({ from: defaultAccountAddress })
198
- .wait(waitOpts);
199
-
200
- return {
201
- token: {
202
- address: devCoin.address,
203
- initHash: devCoin.instance.initializationHash,
204
- salt: devCoin.instance.salt,
205
- },
206
- bridge: {
207
- address: bridge.address,
208
- initHash: bridge.instance.initializationHash,
209
- salt: bridge.instance.salt,
210
- },
211
- };
212
- }
213
-
214
- /**
215
- * Step 3. Initialize DevCoin's L1 portal
216
- */
217
- async function initPortal(
218
- aztecNode: AztecNode,
219
- l1Client: ExtendedViemWalletClient,
220
- erc20: EthAddress,
221
- portal: EthAddress,
222
- bridge: AztecAddress,
223
- ) {
224
- const { TokenPortalAbi } = await import('@aztec/l1-artifacts');
225
- const {
226
- l1ContractAddresses: { registryAddress },
227
- } = await aztecNode.getNodeInfo();
228
-
229
- const contract = getContract({
230
- abi: TokenPortalAbi,
231
- address: portal.toString(),
232
- client: l1Client,
233
- });
234
-
235
- const hash = await contract.write.initialize([registryAddress.toString(), erc20.toString(), bridge.toString()]);
236
-
237
- await l1Client.waitForTransactionReceipt({ hash });
238
- }
239
-
240
- async function deployFPC(
241
- wallet: Wallet,
242
- defaultAccountAddress: AztecAddress,
243
- tokenAddress: AztecAddress,
244
- admin: AztecAddress,
245
- ): Promise<ContractDeploymentInfo> {
246
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
247
- // @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
248
- const { FPCContract } = await import('@aztec/noir-contracts.js/FPC');
249
- const fpc = await FPCContract.deploy(wallet, tokenAddress, admin)
250
- .send({ from: defaultAccountAddress, universalDeploy: true })
251
- .deployed(waitOpts);
252
- const info: ContractDeploymentInfo = {
253
- address: fpc.address,
254
- initHash: fpc.instance.initializationHash,
255
- salt: fpc.instance.salt,
256
- };
257
- return info;
258
- }
259
-
260
- async function deployCounter(wallet: Wallet, defaultAccountAddress: AztecAddress): Promise<ContractDeploymentInfo> {
261
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
262
- // @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
263
- const { CounterContract } = await import('@aztec/noir-test-contracts.js/Counter');
264
- const counter = await CounterContract.deploy(wallet, 1, defaultAccountAddress)
265
- .send({ from: defaultAccountAddress, universalDeploy: true })
266
- .deployed(waitOpts);
267
- const info: ContractDeploymentInfo = {
268
- address: counter.address,
269
- initHash: counter.instance.initializationHash,
270
- salt: counter.instance.salt,
271
- };
272
- return info;
273
- }
274
-
275
- // NOTE: Disabling for now in order to get devnet running
276
- async function fundFPC(
277
- node: AztecNode,
278
- counterAddress: AztecAddress,
279
- wallet: Wallet,
280
- defaultAccountAddress: AztecAddress,
281
- l1Client: ExtendedViemWalletClient,
282
- fpcAddress: AztecAddress,
283
- debugLog: Logger,
284
- ) {
285
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
286
- // @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
287
- const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
288
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
289
- // @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
290
- const { CounterContract } = await import('@aztec/noir-test-contracts.js/Counter');
291
- const {
292
- protocolContractAddresses: { feeJuice },
293
- } = await node.getNodeInfo();
294
-
295
- const feeJuiceContract = await FeeJuiceContract.at(feeJuice, wallet);
296
-
297
- const feeJuicePortal = await L1FeeJuicePortalManager.new(node, l1Client, debugLog);
298
-
299
- const { claimAmount, claimSecret, messageLeafIndex, messageHash } = await feeJuicePortal.bridgeTokensPublic(
300
- fpcAddress,
301
- undefined,
302
- true,
303
- );
304
-
305
- await retryUntil(
306
- async () => (await node.getL1ToL2MessageBlock(Fr.fromHexString(messageHash))) !== undefined,
307
- 'message sync',
308
- 600,
309
- 1,
310
- );
311
-
312
- const counter = await CounterContract.at(counterAddress, wallet);
313
-
314
- debugLog.info('Incrementing Counter');
315
-
316
- // TODO (alexg) remove this once sequencer builds blocks continuously
317
- // advance the chain
318
- await counter.methods.increment(defaultAccountAddress).send({ from: defaultAccountAddress }).wait(waitOpts);
319
- await counter.methods.increment(defaultAccountAddress).send({ from: defaultAccountAddress }).wait(waitOpts);
320
-
321
- debugLog.info('Claiming FPC');
322
-
323
- const receipt = await feeJuiceContract.methods
324
- .claim(fpcAddress, claimAmount, claimSecret, messageLeafIndex)
325
- .send({ from: defaultAccountAddress })
326
- .wait({ ...waitOpts });
327
-
328
- await waitForProven(node, receipt, provenWaitOpts);
329
-
330
- debugLog.info('Finished claiming FPC');
331
- }
@@ -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, nodeOption, parseEthereumAddress } 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(nodeOption)
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[nodeOption.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
- }