@aztec/cli 0.0.0-test.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.
Files changed (218) hide show
  1. package/README.md +449 -0
  2. package/dest/cmds/contracts/index.d.ts +4 -0
  3. package/dest/cmds/contracts/index.d.ts.map +1 -0
  4. package/dest/cmds/contracts/index.js +12 -0
  5. package/dest/cmds/contracts/inspect_contract.d.ts +3 -0
  6. package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -0
  7. package/dest/cmds/contracts/inspect_contract.js +37 -0
  8. package/dest/cmds/contracts/parse_parameter_struct.d.ts +3 -0
  9. package/dest/cmds/contracts/parse_parameter_struct.d.ts.map +1 -0
  10. package/dest/cmds/contracts/parse_parameter_struct.js +13 -0
  11. package/dest/cmds/devnet/bootstrap_network.d.ts +3 -0
  12. package/dest/cmds/devnet/bootstrap_network.d.ts.map +1 -0
  13. package/dest/cmds/devnet/bootstrap_network.js +196 -0
  14. package/dest/cmds/devnet/faucet.d.ts +4 -0
  15. package/dest/cmds/devnet/faucet.d.ts.map +1 -0
  16. package/dest/cmds/devnet/faucet.js +26 -0
  17. package/dest/cmds/devnet/index.d.ts +4 -0
  18. package/dest/cmds/devnet/index.d.ts.map +1 -0
  19. package/dest/cmds/devnet/index.js +14 -0
  20. package/dest/cmds/infrastructure/index.d.ts +4 -0
  21. package/dest/cmds/infrastructure/index.d.ts.map +1 -0
  22. package/dest/cmds/infrastructure/index.js +24 -0
  23. package/dest/cmds/infrastructure/sequencers.d.ts +13 -0
  24. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -0
  25. package/dest/cmds/infrastructure/sequencers.js +93 -0
  26. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +3 -0
  27. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -0
  28. package/dest/cmds/infrastructure/setup_l2_contract.js +43 -0
  29. package/dest/cmds/l1/advance_epoch.d.ts +3 -0
  30. package/dest/cmds/l1/advance_epoch.d.ts.map +1 -0
  31. package/dest/cmds/l1/advance_epoch.js +10 -0
  32. package/dest/cmds/l1/assume_proven_through.d.ts +3 -0
  33. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -0
  34. package/dest/cmds/l1/assume_proven_through.js +12 -0
  35. package/dest/cmds/l1/bridge_erc20.d.ts +4 -0
  36. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -0
  37. package/dest/cmds/l1/bridge_erc20.js +31 -0
  38. package/dest/cmds/l1/create_l1_account.d.ts +3 -0
  39. package/dest/cmds/l1/create_l1_account.d.ts.map +1 -0
  40. package/dest/cmds/l1/create_l1_account.js +15 -0
  41. package/dest/cmds/l1/deploy_l1_contracts.d.ts +4 -0
  42. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -0
  43. package/dest/cmds/l1/deploy_l1_contracts.js +29 -0
  44. package/dest/cmds/l1/deploy_l1_verifier.d.ts +5 -0
  45. package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +1 -0
  46. package/dest/cmds/l1/deploy_l1_verifier.js +54 -0
  47. package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -0
  48. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -0
  49. package/dest/cmds/l1/deploy_new_rollup.js +19 -0
  50. package/dest/cmds/l1/get_l1_addresses.d.ts +4 -0
  51. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -0
  52. package/dest/cmds/l1/get_l1_addresses.js +18 -0
  53. package/dest/cmds/l1/get_l1_balance.d.ts +4 -0
  54. package/dest/cmds/l1/get_l1_balance.d.ts.map +1 -0
  55. package/dest/cmds/l1/get_l1_balance.js +33 -0
  56. package/dest/cmds/l1/governance_utils.d.ts +50 -0
  57. package/dest/cmds/l1/governance_utils.d.ts.map +1 -0
  58. package/dest/cmds/l1/governance_utils.js +85 -0
  59. package/dest/cmds/l1/index.d.ts +4 -0
  60. package/dest/cmds/l1/index.d.ts.map +1 -0
  61. package/dest/cmds/l1/index.js +208 -0
  62. package/dest/cmds/l1/prover_stats.d.ts +14 -0
  63. package/dest/cmds/l1/prover_stats.d.ts.map +1 -0
  64. package/dest/cmds/l1/prover_stats.js +145 -0
  65. package/dest/cmds/l1/update_l1_validators.d.ts +30 -0
  66. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -0
  67. package/dest/cmds/l1/update_l1_validators.js +186 -0
  68. package/dest/cmds/misc/compute_selector.d.ts +3 -0
  69. package/dest/cmds/misc/compute_selector.d.ts.map +1 -0
  70. package/dest/cmds/misc/compute_selector.js +5 -0
  71. package/dest/cmds/misc/example_contracts.d.ts +3 -0
  72. package/dest/cmds/misc/example_contracts.d.ts.map +1 -0
  73. package/dest/cmds/misc/example_contracts.js +6 -0
  74. package/dest/cmds/misc/generate_bootnode_enr.d.ts +3 -0
  75. package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -0
  76. package/dest/cmds/misc/generate_bootnode_enr.js +5 -0
  77. package/dest/cmds/misc/generate_p2p_private_key.d.ts +3 -0
  78. package/dest/cmds/misc/generate_p2p_private_key.d.ts.map +1 -0
  79. package/dest/cmds/misc/generate_p2p_private_key.js +7 -0
  80. package/dest/cmds/misc/generate_secret_and_hash.d.ts +3 -0
  81. package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -0
  82. package/dest/cmds/misc/generate_secret_and_hash.js +11 -0
  83. package/dest/cmds/misc/generate_secret_key.d.ts +5 -0
  84. package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -0
  85. package/dest/cmds/misc/generate_secret_key.js +6 -0
  86. package/dest/cmds/misc/index.d.ts +4 -0
  87. package/dest/cmds/misc/index.d.ts.map +1 -0
  88. package/dest/cmds/misc/index.js +44 -0
  89. package/dest/cmds/misc/setup_contracts.d.ts +7 -0
  90. package/dest/cmds/misc/setup_contracts.d.ts.map +1 -0
  91. package/dest/cmds/misc/setup_contracts.js +27 -0
  92. package/dest/cmds/misc/update/common.d.ts +17 -0
  93. package/dest/cmds/misc/update/common.d.ts.map +1 -0
  94. package/dest/cmds/misc/update/common.js +3 -0
  95. package/dest/cmds/misc/update/github.d.ts +4 -0
  96. package/dest/cmds/misc/update/github.d.ts.map +1 -0
  97. package/dest/cmds/misc/update/github.js +3 -0
  98. package/dest/cmds/misc/update/noir.d.ts +10 -0
  99. package/dest/cmds/misc/update/noir.d.ts.map +1 -0
  100. package/dest/cmds/misc/update/noir.js +45 -0
  101. package/dest/cmds/misc/update/npm.d.ts +34 -0
  102. package/dest/cmds/misc/update/npm.d.ts.map +1 -0
  103. package/dest/cmds/misc/update/npm.js +127 -0
  104. package/dest/cmds/misc/update/utils.d.ts +14 -0
  105. package/dest/cmds/misc/update/utils.d.ts.map +1 -0
  106. package/dest/cmds/misc/update/utils.js +38 -0
  107. package/dest/cmds/misc/update.d.ts +3 -0
  108. package/dest/cmds/misc/update.d.ts.map +1 -0
  109. package/dest/cmds/misc/update.js +52 -0
  110. package/dest/cmds/pxe/add_contract.d.ts +5 -0
  111. package/dest/cmds/pxe/add_contract.d.ts.map +1 -0
  112. package/dest/cmds/pxe/add_contract.js +29 -0
  113. package/dest/cmds/pxe/block_number.d.ts +3 -0
  114. package/dest/cmds/pxe/block_number.d.ts.map +1 -0
  115. package/dest/cmds/pxe/block_number.js +10 -0
  116. package/dest/cmds/pxe/get_account.d.ts +4 -0
  117. package/dest/cmds/pxe/get_account.d.ts.map +1 -0
  118. package/dest/cmds/pxe/get_account.js +10 -0
  119. package/dest/cmds/pxe/get_accounts.d.ts +3 -0
  120. package/dest/cmds/pxe/get_accounts.d.ts.map +1 -0
  121. package/dest/cmds/pxe/get_accounts.js +25 -0
  122. package/dest/cmds/pxe/get_block.d.ts +3 -0
  123. package/dest/cmds/pxe/get_block.d.ts.map +1 -0
  124. package/dest/cmds/pxe/get_block.js +9 -0
  125. package/dest/cmds/pxe/get_contract_data.d.ts +4 -0
  126. package/dest/cmds/pxe/get_contract_data.d.ts.map +1 -0
  127. package/dest/cmds/pxe/get_contract_data.js +31 -0
  128. package/dest/cmds/pxe/get_current_base_fee.d.ts +3 -0
  129. package/dest/cmds/pxe/get_current_base_fee.d.ts.map +1 -0
  130. package/dest/cmds/pxe/get_current_base_fee.js +7 -0
  131. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +4 -0
  132. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +1 -0
  133. package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +11 -0
  134. package/dest/cmds/pxe/get_logs.d.ts +4 -0
  135. package/dest/cmds/pxe/get_logs.d.ts.map +1 -0
  136. package/dest/cmds/pxe/get_logs.js +51 -0
  137. package/dest/cmds/pxe/get_node_info.d.ts +3 -0
  138. package/dest/cmds/pxe/get_node_info.d.ts.map +1 -0
  139. package/dest/cmds/pxe/get_node_info.js +61 -0
  140. package/dest/cmds/pxe/get_pxe_info.d.ts +3 -0
  141. package/dest/cmds/pxe/get_pxe_info.d.ts.map +1 -0
  142. package/dest/cmds/pxe/get_pxe_info.js +11 -0
  143. package/dest/cmds/pxe/index.d.ts +4 -0
  144. package/dest/cmds/pxe/index.d.ts.map +1 -0
  145. package/dest/cmds/pxe/index.js +55 -0
  146. package/dest/utils/aztec.d.ts +68 -0
  147. package/dest/utils/aztec.d.ts.map +1 -0
  148. package/dest/utils/aztec.js +174 -0
  149. package/dest/utils/commands.d.ts +143 -0
  150. package/dest/utils/commands.d.ts.map +1 -0
  151. package/dest/utils/commands.js +303 -0
  152. package/dest/utils/encoding.d.ts +15 -0
  153. package/dest/utils/encoding.d.ts.map +1 -0
  154. package/dest/utils/encoding.js +103 -0
  155. package/dest/utils/github.d.ts +4 -0
  156. package/dest/utils/github.d.ts.map +1 -0
  157. package/dest/utils/github.js +3 -0
  158. package/dest/utils/index.d.ts +5 -0
  159. package/dest/utils/index.d.ts.map +1 -0
  160. package/dest/utils/index.js +4 -0
  161. package/dest/utils/inspect.d.ts +17 -0
  162. package/dest/utils/inspect.d.ts.map +1 -0
  163. package/dest/utils/inspect.js +177 -0
  164. package/package.json +125 -0
  165. package/src/cmds/contracts/index.ts +34 -0
  166. package/src/cmds/contracts/inspect_contract.ts +51 -0
  167. package/src/cmds/contracts/parse_parameter_struct.ts +27 -0
  168. package/src/cmds/devnet/bootstrap_network.ts +318 -0
  169. package/src/cmds/devnet/faucet.ts +33 -0
  170. package/src/cmds/devnet/index.ts +60 -0
  171. package/src/cmds/infrastructure/index.ts +55 -0
  172. package/src/cmds/infrastructure/sequencers.ts +103 -0
  173. package/src/cmds/infrastructure/setup_l2_contract.ts +47 -0
  174. package/src/cmds/l1/advance_epoch.ts +12 -0
  175. package/src/cmds/l1/assume_proven_through.ts +19 -0
  176. package/src/cmds/l1/bridge_erc20.ts +52 -0
  177. package/src/cmds/l1/create_l1_account.ts +17 -0
  178. package/src/cmds/l1/deploy_l1_contracts.ts +65 -0
  179. package/src/cmds/l1/deploy_l1_verifier.ts +105 -0
  180. package/src/cmds/l1/deploy_new_rollup.ts +58 -0
  181. package/src/cmds/l1/get_l1_addresses.ts +30 -0
  182. package/src/cmds/l1/get_l1_balance.ts +44 -0
  183. package/src/cmds/l1/governance_utils.ts +187 -0
  184. package/src/cmds/l1/index.ts +558 -0
  185. package/src/cmds/l1/prover_stats.ts +202 -0
  186. package/src/cmds/l1/update_l1_validators.ts +238 -0
  187. package/src/cmds/misc/compute_selector.ts +7 -0
  188. package/src/cmds/misc/example_contracts.ts +12 -0
  189. package/src/cmds/misc/generate_bootnode_enr.ts +12 -0
  190. package/src/cmds/misc/generate_p2p_private_key.ts +10 -0
  191. package/src/cmds/misc/generate_secret_and_hash.ts +15 -0
  192. package/src/cmds/misc/generate_secret_key.ts +5 -0
  193. package/src/cmds/misc/index.ts +92 -0
  194. package/src/cmds/misc/setup_contracts.ts +40 -0
  195. package/src/cmds/misc/update/common.ts +16 -0
  196. package/src/cmds/misc/update/github.ts +3 -0
  197. package/src/cmds/misc/update/noir.ts +57 -0
  198. package/src/cmds/misc/update/npm.ts +154 -0
  199. package/src/cmds/misc/update/utils.ts +50 -0
  200. package/src/cmds/misc/update.ts +78 -0
  201. package/src/cmds/pxe/add_contract.ts +41 -0
  202. package/src/cmds/pxe/block_number.ts +9 -0
  203. package/src/cmds/pxe/get_account.ts +16 -0
  204. package/src/cmds/pxe/get_accounts.ts +35 -0
  205. package/src/cmds/pxe/get_block.ts +10 -0
  206. package/src/cmds/pxe/get_contract_data.ts +51 -0
  207. package/src/cmds/pxe/get_current_base_fee.ts +9 -0
  208. package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +25 -0
  209. package/src/cmds/pxe/get_logs.ts +66 -0
  210. package/src/cmds/pxe/get_node_info.ts +71 -0
  211. package/src/cmds/pxe/get_pxe_info.ts +13 -0
  212. package/src/cmds/pxe/index.ts +170 -0
  213. package/src/utils/aztec.ts +250 -0
  214. package/src/utils/commands.ts +384 -0
  215. package/src/utils/encoding.ts +117 -0
  216. package/src/utils/github.ts +3 -0
  217. package/src/utils/index.ts +4 -0
  218. package/src/utils/inspect.ts +208 -0
@@ -0,0 +1,55 @@
1
+ import type { LogFn, Logger } from '@aztec/foundation/log';
2
+
3
+ import type { Command } from 'commander';
4
+
5
+ import { ETHEREUM_HOSTS, l1ChainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js';
6
+
7
+ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger) {
8
+ program
9
+ .command('setup-protocol-contracts')
10
+ .description('Bootstrap the blockchain by initializing all the protocol contracts')
11
+ .addOption(pxeOption)
12
+ .option('--testAccounts', 'Deploy funded test accounts.')
13
+ .option('--json', 'Output the contract addresses in JSON format')
14
+ .option('--skipProofWait', "Don't wait for proofs to land.")
15
+ .action(async options => {
16
+ const { setupL2Contracts } = await import('./setup_l2_contract.js');
17
+ await setupL2Contracts(options.rpcUrl, options.testAccounts, options.json, options.skipProofWait, log);
18
+ });
19
+
20
+ program
21
+ .command('sequencers')
22
+ .argument('<command>', 'Command to run: list, add, remove, who-next')
23
+ .argument('[who]', 'Who to add/remove')
24
+ .description('Manages or queries registered sequencers on the L1 rollup contract.')
25
+ .requiredOption<string[]>(
26
+ '--l1-rpc-urls <string>',
27
+ 'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)',
28
+ (arg: string) => arg.split(','),
29
+ [ETHEREUM_HOSTS],
30
+ )
31
+ .option(
32
+ '-m, --mnemonic <string>',
33
+ 'The mnemonic for the sender of the tx',
34
+ 'test test test test test test test test test test test junk',
35
+ )
36
+ .option('--block-number <number>', 'Block number to query next sequencer for', parseOptionalInteger)
37
+ .addOption(pxeOption)
38
+ .addOption(l1ChainIdOption)
39
+ .action(async (command, who, options) => {
40
+ const { sequencers } = await import('./sequencers.js');
41
+ await sequencers({
42
+ command: command,
43
+ who,
44
+ mnemonic: options.mnemonic,
45
+ rpcUrl: options.rpcUrl,
46
+ l1RpcUrls: options.l1RpcUrls.split(','),
47
+ chainId: options.l1ChainId,
48
+ blockNumber: options.blockNumber,
49
+ log,
50
+ debugLogger,
51
+ });
52
+ });
53
+
54
+ return program;
55
+ }
@@ -0,0 +1,103 @@
1
+ import { createCompatibleClient } from '@aztec/aztec.js';
2
+ import { createEthereumChain, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
3
+ import type { LogFn, Logger } from '@aztec/foundation/log';
4
+ import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
5
+
6
+ import { createPublicClient, createWalletClient, fallback, getContract, http } from 'viem';
7
+ import { mnemonicToAccount } from 'viem/accounts';
8
+
9
+ export async function sequencers(opts: {
10
+ command: 'list' | 'add' | 'remove' | 'who-next';
11
+ who?: string;
12
+ mnemonic?: string;
13
+ rpcUrl: string;
14
+ l1RpcUrls: string[];
15
+ chainId: number;
16
+ blockNumber?: number;
17
+ log: LogFn;
18
+ debugLogger: Logger;
19
+ }) {
20
+ const { command, who: maybeWho, mnemonic, rpcUrl, l1RpcUrls, chainId, log, debugLogger } = opts;
21
+ const client = await createCompatibleClient(rpcUrl, debugLogger);
22
+ const { l1ContractAddresses } = await client.getNodeInfo();
23
+
24
+ const chain = createEthereumChain(l1RpcUrls, chainId);
25
+ const publicClient = createPublicClient({
26
+ chain: chain.chainInfo,
27
+ transport: fallback(l1RpcUrls.map(url => http(url))),
28
+ });
29
+
30
+ const walletClient = mnemonic
31
+ ? createWalletClient({
32
+ account: mnemonicToAccount(mnemonic),
33
+ chain: chain.chainInfo,
34
+ transport: fallback(l1RpcUrls.map(url => http(url))),
35
+ })
36
+ : undefined;
37
+
38
+ const rollup = getContract({
39
+ address: l1ContractAddresses.rollupAddress.toString(),
40
+ abi: RollupAbi,
41
+ client: publicClient,
42
+ });
43
+
44
+ const writeableRollup = walletClient
45
+ ? getContract({
46
+ address: l1ContractAddresses.rollupAddress.toString(),
47
+ abi: RollupAbi,
48
+ client: walletClient,
49
+ })
50
+ : undefined;
51
+
52
+ const who = (maybeWho as `0x{string}`) ?? walletClient?.account.address.toString();
53
+
54
+ if (command === 'list') {
55
+ const sequencers = await rollup.read.getAttesters();
56
+ if (sequencers.length === 0) {
57
+ log(`No sequencers registered on rollup`);
58
+ } else {
59
+ log(`Registered sequencers on rollup:`);
60
+ for (const sequencer of sequencers) {
61
+ log(' ' + sequencer.toString());
62
+ }
63
+ }
64
+ } else if (command === 'add') {
65
+ if (!who || !writeableRollup || !walletClient) {
66
+ throw new Error(`Missing sequencer address`);
67
+ }
68
+
69
+ log(`Adding ${who} as sequencer`);
70
+
71
+ const stakingAsset = getContract({
72
+ address: await rollup.read.getStakingAsset(),
73
+ abi: TestERC20Abi,
74
+ client: walletClient,
75
+ });
76
+
77
+ const config = getL1ContractsConfigEnvVars();
78
+
79
+ await Promise.all(
80
+ [
81
+ await stakingAsset.write.mint([walletClient.account.address, config.minimumStake], {} as any),
82
+ await stakingAsset.write.approve([rollup.address, config.minimumStake], {} as any),
83
+ ].map(txHash => publicClient.waitForTransactionReceipt({ hash: txHash })),
84
+ );
85
+
86
+ const hash = await writeableRollup.write.deposit([who, who, who, config.minimumStake]);
87
+ await publicClient.waitForTransactionReceipt({ hash });
88
+ log(`Added in tx ${hash}`);
89
+ } else if (command === 'remove') {
90
+ if (!who || !writeableRollup) {
91
+ throw new Error(`Missing sequencer address`);
92
+ }
93
+ log(`Removing ${who} as sequencer`);
94
+ const hash = await writeableRollup.write.initiateWithdraw([who, who]);
95
+ await publicClient.waitForTransactionReceipt({ hash });
96
+ log(`Removed in tx ${hash}`);
97
+ } else if (command === 'who-next') {
98
+ const next = await rollup.read.getCurrentProposer();
99
+ log(`Sequencer expected to build is ${next}`);
100
+ } else {
101
+ throw new Error(`Unknown command ${command}`);
102
+ }
103
+ }
@@ -0,0 +1,47 @@
1
+ import { type InitialAccountData, deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import { type AztecAddress, SignerlessWallet, type WaitOpts, createPXEClient, makeFetch } from '@aztec/aztec.js';
3
+ import { jsonStringify } from '@aztec/foundation/json-rpc';
4
+ import type { LogFn } from '@aztec/foundation/log';
5
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
+
7
+ import { setupCanonicalL2FeeJuice } from '../misc/setup_contracts.js';
8
+
9
+ export async function setupL2Contracts(
10
+ rpcUrl: string,
11
+ testAccounts: boolean,
12
+ json: boolean,
13
+ skipProofWait: boolean,
14
+ log: LogFn,
15
+ ) {
16
+ const waitOpts: WaitOpts = {
17
+ timeout: 180,
18
+ interval: 1,
19
+ proven: !skipProofWait,
20
+ provenTimeout: 600,
21
+ };
22
+ log('setupL2Contracts: Wait options' + jsonStringify(waitOpts));
23
+ log('setupL2Contracts: Creating PXE client...');
24
+ const pxe = createPXEClient(rpcUrl, {}, makeFetch([1, 1, 1, 1, 1], false));
25
+ const wallet = new SignerlessWallet(pxe);
26
+
27
+ log('setupL2Contracts: Getting fee juice portal address...');
28
+ // Deploy Fee Juice
29
+ const feeJuicePortalAddress = (await wallet.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress;
30
+ log('setupL2Contracts: Setting up fee juice portal...');
31
+ await setupCanonicalL2FeeJuice(wallet, feeJuicePortalAddress, waitOpts, log);
32
+
33
+ let deployedAccounts: InitialAccountData[] = [];
34
+ if (testAccounts) {
35
+ log('setupL2Contracts: Deploying test accounts...');
36
+ deployedAccounts = await getInitialTestAccounts();
37
+ await deployFundedSchnorrAccounts(pxe, deployedAccounts, waitOpts);
38
+ }
39
+
40
+ if (json) {
41
+ const toPrint: Record<string, AztecAddress> = { ...ProtocolContractAddress };
42
+ deployedAccounts.forEach((a, i) => {
43
+ toPrint[`testAccount${i}`] = a.address;
44
+ });
45
+ log(JSON.stringify(toPrint, null, 2));
46
+ }
47
+ }
@@ -0,0 +1,12 @@
1
+ import { CheatCodes, createPXEClient, makeFetch } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+
4
+ export async function advanceEpoch(l1RpcUrls: string[], rpcUrl: string, log: LogFn) {
5
+ const pxe = createPXEClient(rpcUrl, {}, makeFetch([], true));
6
+ const rollupAddress = await pxe.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
7
+
8
+ const cheat = CheatCodes.createRollup(l1RpcUrls, { rollupAddress });
9
+
10
+ await cheat.advanceToNextEpoch();
11
+ log(`Warped time to advance to next epoch`);
12
+ }
@@ -0,0 +1,19 @@
1
+ import { EthCheatCodes, RollupCheatCodes, createPXEClient, makeFetch } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+
4
+ export async function assumeProvenThrough(
5
+ blockNumberOrLatest: number | undefined,
6
+ l1RpcUrls: string[],
7
+ rpcUrl: string,
8
+ log: LogFn,
9
+ ) {
10
+ const pxe = createPXEClient(rpcUrl, {}, makeFetch([], true));
11
+ const rollupAddress = await pxe.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
12
+ const blockNumber = blockNumberOrLatest ?? (await pxe.getBlockNumber());
13
+
14
+ const ethCheatCode = new EthCheatCodes(l1RpcUrls);
15
+ const rollupCheatCodes = new RollupCheatCodes(ethCheatCode, { rollupAddress });
16
+
17
+ await rollupCheatCodes.markAsProven(blockNumber);
18
+ log(`Assumed proven through block ${blockNumber}`);
19
+ }
@@ -0,0 +1,52 @@
1
+ import { type AztecAddress, type EthAddress, type Fr, L1ToL2TokenPortalManager } from '@aztec/aztec.js';
2
+ import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
3
+ import type { LogFn, Logger } from '@aztec/foundation/log';
4
+
5
+ import { prettyPrintJSON } from '../../utils/commands.js';
6
+
7
+ export async function bridgeERC20(
8
+ amount: bigint,
9
+ recipient: AztecAddress,
10
+ l1RpcUrls: string[],
11
+ chainId: number,
12
+ privateKey: string | undefined,
13
+ mnemonic: string,
14
+ tokenAddress: EthAddress,
15
+ portalAddress: EthAddress,
16
+ privateTransfer: boolean,
17
+ mint: boolean,
18
+ json: boolean,
19
+ log: LogFn,
20
+ debugLogger: Logger,
21
+ ) {
22
+ // Prepare L1 client
23
+ const chain = createEthereumChain(l1RpcUrls, chainId);
24
+ const { publicClient, walletClient } = createL1Clients(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
25
+
26
+ // Setup portal manager
27
+ const manager = new L1ToL2TokenPortalManager(portalAddress, tokenAddress, publicClient, walletClient, debugLogger);
28
+ let claimSecret: Fr;
29
+ let messageHash: `0x${string}`;
30
+ if (privateTransfer) {
31
+ ({ claimSecret, messageHash } = await manager.bridgeTokensPrivate(recipient, amount, mint));
32
+ } else {
33
+ ({ claimSecret, messageHash } = await manager.bridgeTokensPublic(recipient, amount, mint));
34
+ }
35
+
36
+ if (json) {
37
+ log(
38
+ prettyPrintJSON({
39
+ claimAmount: amount,
40
+ claimSecret: claimSecret,
41
+ }),
42
+ );
43
+ } else {
44
+ if (mint) {
45
+ log(`Minted ${amount} tokens on L1 and pushed to L2 portal`);
46
+ } else {
47
+ log(`Bridged ${amount} tokens to L2 portal`);
48
+ }
49
+ log(`claimAmount=${amount},claimSecret=${claimSecret}\n,messageHash=${messageHash}`);
50
+ log(`Note: You need to wait for two L2 blocks before pulling them from the L2 side`);
51
+ }
52
+ }
@@ -0,0 +1,17 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+
3
+ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
4
+
5
+ import { prettyPrintJSON } from '../../utils/commands.js';
6
+
7
+ export function createL1Account(json: boolean, log: LogFn) {
8
+ const privateKey = generatePrivateKey();
9
+ const account = privateKeyToAccount(privateKey);
10
+
11
+ if (json) {
12
+ log(prettyPrintJSON({ privateKey, address: account.address }));
13
+ } else {
14
+ log(`Private Key: ${privateKey}`);
15
+ log(`Address: ${account.address}`);
16
+ }
17
+ }
@@ -0,0 +1,65 @@
1
+ import { getInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import type { LogFn, Logger } from '@aztec/foundation/log';
5
+ import { getGenesisValues } from '@aztec/world-state/testing';
6
+
7
+ import { deployAztecContracts } from '../../utils/aztec.js';
8
+
9
+ export async function deployL1Contracts(
10
+ rpcUrls: string[],
11
+ chainId: number,
12
+ privateKey: string | undefined,
13
+ mnemonic: string,
14
+ mnemonicIndex: number,
15
+ salt: number | undefined,
16
+ testAccounts: boolean,
17
+ acceleratedTestDeployments: boolean,
18
+ json: boolean,
19
+ initialValidators: EthAddress[],
20
+ log: LogFn,
21
+ debugLogger: Logger,
22
+ ) {
23
+ const config = getL1ContractsConfigEnvVars();
24
+
25
+ const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
26
+ const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
27
+
28
+ const { l1ContractAddresses } = await deployAztecContracts(
29
+ rpcUrls,
30
+ chainId,
31
+ privateKey,
32
+ mnemonic,
33
+ mnemonicIndex,
34
+ salt,
35
+ initialValidators,
36
+ genesisArchiveRoot,
37
+ genesisBlockHash,
38
+ acceleratedTestDeployments,
39
+ config,
40
+ debugLogger,
41
+ );
42
+
43
+ if (json) {
44
+ log(
45
+ JSON.stringify(
46
+ Object.fromEntries(Object.entries(l1ContractAddresses).map(([k, v]) => [k, v.toString()])),
47
+ null,
48
+ 2,
49
+ ),
50
+ );
51
+ } else {
52
+ log(`Rollup Address: ${l1ContractAddresses.rollupAddress.toString()}`);
53
+ log(`Registry Address: ${l1ContractAddresses.registryAddress.toString()}`);
54
+ log(`L1 -> L2 Inbox Address: ${l1ContractAddresses.inboxAddress.toString()}`);
55
+ log(`L2 -> L1 Outbox Address: ${l1ContractAddresses.outboxAddress.toString()}`);
56
+ log(`Fee Juice Address: ${l1ContractAddresses.feeJuiceAddress.toString()}`);
57
+ log(`Staking Asset Address: ${l1ContractAddresses.stakingAssetAddress.toString()}`);
58
+ log(`Fee Juice Portal Address: ${l1ContractAddresses.feeJuicePortalAddress.toString()}`);
59
+ log(`CoinIssuer Address: ${l1ContractAddresses.coinIssuerAddress.toString()}`);
60
+ log(`RewardDistributor Address: ${l1ContractAddresses.rewardDistributorAddress.toString()}`);
61
+ log(`GovernanceProposer Address: ${l1ContractAddresses.governanceProposerAddress.toString()}`);
62
+ log(`Governance Address: ${l1ContractAddresses.governanceAddress.toString()}`);
63
+ log(`SlashFactory Address: ${l1ContractAddresses.slashFactoryAddress?.toString()}`);
64
+ }
65
+ }
@@ -0,0 +1,105 @@
1
+ import { createCompatibleClient } from '@aztec/aztec.js';
2
+ import { createEthereumChain, createL1Clients, deployL1Contract } from '@aztec/ethereum';
3
+ import type { LogFn, Logger } from '@aztec/foundation/log';
4
+ import { HonkVerifierAbi, HonkVerifierBytecode } from '@aztec/l1-artifacts';
5
+
6
+ import { InvalidOptionArgumentError } from 'commander';
7
+ import { type Hex, getContract } from 'viem';
8
+
9
+ export async function deployUltraHonkVerifier(
10
+ rollupAddress: Hex | undefined,
11
+ ethRpcUrls: string[],
12
+ l1ChainId: string,
13
+ privateKey: string | undefined,
14
+ mnemonic: string,
15
+ pxeRpcUrl: string,
16
+ bbBinaryPath: string,
17
+ bbWorkingDirectory: string,
18
+ log: LogFn,
19
+ debugLogger: Logger,
20
+ ) {
21
+ if (!bbBinaryPath || !bbWorkingDirectory) {
22
+ throw new InvalidOptionArgumentError('Missing path to bb binary and working directory');
23
+ }
24
+
25
+ const { publicClient, walletClient } = createL1Clients(
26
+ ethRpcUrls,
27
+ privateKey ?? mnemonic,
28
+ createEthereumChain(ethRpcUrls, l1ChainId).chainInfo,
29
+ );
30
+
31
+ if (!rollupAddress && pxeRpcUrl) {
32
+ const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
33
+ const { l1ContractAddresses } = await pxe.getNodeInfo();
34
+ rollupAddress = l1ContractAddresses.rollupAddress.toString();
35
+ }
36
+
37
+ if (!rollupAddress) {
38
+ throw new InvalidOptionArgumentError('Missing rollup address');
39
+ }
40
+
41
+ const { RollupAbi } = await import('@aztec/l1-artifacts');
42
+
43
+ const rollup = getContract({
44
+ abi: RollupAbi,
45
+ address: rollupAddress,
46
+ client: walletClient,
47
+ });
48
+
49
+ const { address: verifierAddress } = await deployL1Contract(
50
+ walletClient,
51
+ publicClient,
52
+ HonkVerifierAbi,
53
+ HonkVerifierBytecode,
54
+ );
55
+ log(`Deployed honk verifier at ${verifierAddress}`);
56
+
57
+ await rollup.write.setEpochVerifier([verifierAddress.toString()]);
58
+
59
+ log(`Rollup accepts only real proofs now`);
60
+ }
61
+
62
+ export async function deployMockVerifier(
63
+ rollupAddress: Hex | undefined,
64
+ ethRpcUrls: string[],
65
+ l1ChainId: string,
66
+ privateKey: string | undefined,
67
+ mnemonic: string,
68
+ pxeRpcUrl: string,
69
+ log: LogFn,
70
+ debugLogger: Logger,
71
+ ) {
72
+ const { publicClient, walletClient } = createL1Clients(
73
+ ethRpcUrls,
74
+ privateKey ?? mnemonic,
75
+ createEthereumChain(ethRpcUrls, l1ChainId).chainInfo,
76
+ );
77
+ const { MockVerifierAbi, MockVerifierBytecode, RollupAbi } = await import('@aztec/l1-artifacts');
78
+
79
+ const { address: mockVerifierAddress } = await deployL1Contract(
80
+ walletClient,
81
+ publicClient,
82
+ MockVerifierAbi,
83
+ MockVerifierBytecode,
84
+ );
85
+ log(`Deployed MockVerifier at ${mockVerifierAddress.toString()}`);
86
+
87
+ if (!rollupAddress && pxeRpcUrl) {
88
+ const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
89
+ const { l1ContractAddresses } = await pxe.getNodeInfo();
90
+ rollupAddress = l1ContractAddresses.rollupAddress.toString();
91
+ }
92
+
93
+ if (!rollupAddress) {
94
+ throw new InvalidOptionArgumentError('Missing rollup address');
95
+ }
96
+
97
+ const rollup = getContract({
98
+ abi: RollupAbi,
99
+ address: rollupAddress,
100
+ client: walletClient,
101
+ });
102
+
103
+ await rollup.write.setEpochVerifier([mockVerifierAddress.toString()]);
104
+ log(`Rollup accepts only fake proofs now`);
105
+ }
@@ -0,0 +1,58 @@
1
+ import { getInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import type { LogFn, Logger } from '@aztec/foundation/log';
5
+ import { getGenesisValues } from '@aztec/world-state/testing';
6
+
7
+ import { deployNewRollupContracts } from '../../utils/aztec.js';
8
+
9
+ export async function deployNewRollup(
10
+ registryAddress: EthAddress,
11
+ rpcUrls: string[],
12
+ chainId: number,
13
+ privateKey: string | undefined,
14
+ mnemonic: string,
15
+ mnemonicIndex: number,
16
+ salt: number | undefined,
17
+ testAccounts: boolean,
18
+ json: boolean,
19
+ initialValidators: EthAddress[],
20
+ log: LogFn,
21
+ debugLogger: Logger,
22
+ ) {
23
+ const config = getL1ContractsConfigEnvVars();
24
+
25
+ const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
26
+ const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
27
+
28
+ const { payloadAddress, rollup } = await deployNewRollupContracts(
29
+ registryAddress,
30
+ rpcUrls,
31
+ chainId,
32
+ privateKey,
33
+ mnemonic,
34
+ mnemonicIndex,
35
+ salt,
36
+ initialValidators,
37
+ genesisArchiveRoot,
38
+ genesisBlockHash,
39
+ config,
40
+ debugLogger,
41
+ );
42
+
43
+ if (json) {
44
+ log(
45
+ JSON.stringify(
46
+ {
47
+ payloadAddress: payloadAddress.toString(),
48
+ rollupAddress: rollup.address,
49
+ },
50
+ null,
51
+ 2,
52
+ ),
53
+ );
54
+ } else {
55
+ log(`Payload Address: ${payloadAddress.toString()}`);
56
+ log(`Rollup Address: ${rollup.address}`);
57
+ }
58
+ }
@@ -0,0 +1,30 @@
1
+ import { EthAddress } from '@aztec/aztec.js';
2
+ import { RegistryContract, type ViemPublicClient, createEthereumChain } from '@aztec/ethereum';
3
+ import type { LogFn } from '@aztec/foundation/log';
4
+
5
+ import { createPublicClient, fallback, http } from 'viem';
6
+
7
+ export async function getL1Addresses(
8
+ registryAddress: EthAddress,
9
+ rollupVersion: number | bigint | 'canonical',
10
+ rpcUrls: string[],
11
+ chainId: number,
12
+ json: boolean,
13
+ log: LogFn,
14
+ ) {
15
+ const chain = createEthereumChain(rpcUrls, chainId);
16
+ const publicClient: ViemPublicClient = createPublicClient({
17
+ chain: chain.chainInfo,
18
+ transport: fallback(rpcUrls.map(url => http(url))),
19
+ pollingInterval: 100,
20
+ });
21
+ const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress.toString(), rollupVersion);
22
+
23
+ if (json) {
24
+ log(JSON.stringify(addresses, null, 2));
25
+ } else {
26
+ for (const [key, value] of Object.entries(addresses)) {
27
+ log(`${key}: ${value.toString()}`);
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,44 @@
1
+ import { createEthereumChain } from '@aztec/ethereum';
2
+ import type { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { LogFn } from '@aztec/foundation/log';
4
+ import { TestERC20Abi } from '@aztec/l1-artifacts';
5
+
6
+ import { createPublicClient, fallback, getContract, http } from 'viem';
7
+
8
+ import { prettyPrintJSON } from '../../utils/commands.js';
9
+
10
+ export async function getL1Balance(
11
+ who: EthAddress,
12
+ token: EthAddress | undefined,
13
+ l1RpcUrls: string[],
14
+ chainId: number,
15
+ json: boolean,
16
+ log: LogFn,
17
+ ) {
18
+ const chain = createEthereumChain(l1RpcUrls, chainId);
19
+ const publicClient = createPublicClient({
20
+ chain: chain.chainInfo,
21
+ transport: fallback(l1RpcUrls.map(url => http(url))),
22
+ });
23
+
24
+ let balance = 0n;
25
+ if (token) {
26
+ const gasL1 = getContract({
27
+ address: token.toString(),
28
+ abi: TestERC20Abi,
29
+ client: publicClient,
30
+ });
31
+
32
+ balance = await gasL1.read.balanceOf([who.toString()]);
33
+ } else {
34
+ balance = await publicClient.getBalance({
35
+ address: who.toString(),
36
+ });
37
+ }
38
+
39
+ if (json) {
40
+ log(prettyPrintJSON({ balance }));
41
+ } else {
42
+ log(`L1 balance of ${who.toString()} is ${balance.toString()}`);
43
+ }
44
+ }