@aztec/cli 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2 → 0.77.0-testnet-ignition.21

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 (191) hide show
  1. package/README.md +1 -1
  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/inspect_contract.d.ts +3 -0
  5. package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -0
  6. package/dest/cmds/contracts/inspect_contract.js +3 -3
  7. package/dest/cmds/contracts/parse_parameter_struct.d.ts +3 -0
  8. package/dest/cmds/contracts/parse_parameter_struct.d.ts.map +1 -0
  9. package/dest/cmds/devnet/bootstrap_network.d.ts +3 -0
  10. package/dest/cmds/devnet/bootstrap_network.d.ts.map +1 -0
  11. package/dest/cmds/devnet/bootstrap_network.js +13 -10
  12. package/dest/cmds/devnet/faucet.d.ts +4 -0
  13. package/dest/cmds/devnet/faucet.d.ts.map +1 -0
  14. package/dest/cmds/devnet/index.d.ts +4 -0
  15. package/dest/cmds/devnet/index.d.ts.map +1 -0
  16. package/dest/cmds/devnet/index.js +5 -3
  17. package/dest/cmds/infrastructure/index.d.ts +4 -0
  18. package/dest/cmds/infrastructure/index.d.ts.map +1 -0
  19. package/dest/cmds/infrastructure/index.js +8 -6
  20. package/dest/cmds/infrastructure/sequencers.d.ts +13 -0
  21. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -0
  22. package/dest/cmds/infrastructure/sequencers.js +5 -5
  23. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +3 -0
  24. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -0
  25. package/dest/cmds/infrastructure/setup_l2_contract.js +43 -0
  26. package/dest/cmds/l1/advance_epoch.d.ts +3 -0
  27. package/dest/cmds/l1/advance_epoch.d.ts.map +1 -0
  28. package/dest/cmds/l1/advance_epoch.js +3 -3
  29. package/dest/cmds/l1/assume_proven_through.d.ts +3 -0
  30. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -0
  31. package/dest/cmds/l1/assume_proven_through.js +8 -8
  32. package/dest/cmds/l1/bridge_erc20.d.ts +4 -0
  33. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -0
  34. package/dest/cmds/l1/bridge_erc20.js +3 -3
  35. package/dest/cmds/l1/create_l1_account.d.ts +3 -0
  36. package/dest/cmds/l1/create_l1_account.d.ts.map +1 -0
  37. package/dest/cmds/l1/deploy_l1_contracts.d.ts +4 -0
  38. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -0
  39. package/dest/cmds/l1/deploy_l1_contracts.js +7 -3
  40. package/dest/cmds/l1/deploy_l1_verifier.d.ts +5 -0
  41. package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +1 -0
  42. package/dest/cmds/l1/deploy_l1_verifier.js +4 -4
  43. package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -0
  44. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -0
  45. package/dest/cmds/l1/deploy_new_rollup.js +19 -0
  46. package/dest/cmds/l1/get_l1_addresses.d.ts +4 -0
  47. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -0
  48. package/dest/cmds/l1/get_l1_addresses.js +18 -0
  49. package/dest/cmds/l1/get_l1_balance.d.ts +4 -0
  50. package/dest/cmds/l1/get_l1_balance.d.ts.map +1 -0
  51. package/dest/cmds/l1/get_l1_balance.js +4 -4
  52. package/dest/cmds/l1/governance_utils.d.ts +50 -0
  53. package/dest/cmds/l1/governance_utils.d.ts.map +1 -0
  54. package/dest/cmds/l1/governance_utils.js +85 -0
  55. package/dest/cmds/l1/index.d.ts +4 -0
  56. package/dest/cmds/l1/index.d.ts.map +1 -0
  57. package/dest/cmds/l1/index.js +108 -27
  58. package/dest/cmds/l1/prover_stats.d.ts +14 -0
  59. package/dest/cmds/l1/prover_stats.d.ts.map +1 -0
  60. package/dest/cmds/l1/prover_stats.js +6 -6
  61. package/dest/cmds/l1/update_l1_validators.d.ts +30 -0
  62. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -0
  63. package/dest/cmds/l1/update_l1_validators.js +22 -22
  64. package/dest/cmds/misc/compute_selector.d.ts +3 -0
  65. package/dest/cmds/misc/compute_selector.d.ts.map +1 -0
  66. package/dest/cmds/misc/compute_selector.js +1 -1
  67. package/dest/cmds/misc/example_contracts.d.ts +3 -0
  68. package/dest/cmds/misc/example_contracts.d.ts.map +1 -0
  69. package/dest/cmds/misc/generate_bootnode_enr.d.ts +3 -0
  70. package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -0
  71. package/dest/cmds/misc/generate_bootnode_enr.js +5 -0
  72. package/dest/cmds/misc/generate_p2p_private_key.d.ts +3 -0
  73. package/dest/cmds/misc/generate_p2p_private_key.d.ts.map +1 -0
  74. package/dest/cmds/misc/generate_secret_and_hash.d.ts +3 -0
  75. package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -0
  76. package/dest/cmds/misc/generate_secret_key.d.ts +5 -0
  77. package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -0
  78. package/dest/cmds/misc/index.d.ts +4 -0
  79. package/dest/cmds/misc/index.d.ts.map +1 -0
  80. package/dest/cmds/misc/index.js +9 -1
  81. package/dest/cmds/misc/setup_contracts.d.ts +7 -0
  82. package/dest/cmds/misc/setup_contracts.d.ts.map +1 -0
  83. package/dest/cmds/misc/setup_contracts.js +5 -3
  84. package/dest/cmds/misc/update/common.d.ts +17 -0
  85. package/dest/cmds/misc/update/common.d.ts.map +1 -0
  86. package/dest/cmds/misc/update/github.d.ts +4 -0
  87. package/dest/cmds/misc/update/github.d.ts.map +1 -0
  88. package/dest/cmds/misc/update/noir.d.ts +10 -0
  89. package/dest/cmds/misc/update/noir.d.ts.map +1 -0
  90. package/dest/cmds/misc/update/npm.d.ts +34 -0
  91. package/dest/cmds/misc/update/npm.d.ts.map +1 -0
  92. package/dest/cmds/misc/update/utils.d.ts +14 -0
  93. package/dest/cmds/misc/update/utils.d.ts.map +1 -0
  94. package/dest/cmds/misc/update.d.ts +3 -0
  95. package/dest/cmds/misc/update.d.ts.map +1 -0
  96. package/dest/cmds/pxe/add_contract.d.ts +5 -0
  97. package/dest/cmds/pxe/add_contract.d.ts.map +1 -0
  98. package/dest/cmds/pxe/add_contract.js +6 -4
  99. package/dest/cmds/pxe/block_number.d.ts +3 -0
  100. package/dest/cmds/pxe/block_number.d.ts.map +1 -0
  101. package/dest/cmds/pxe/get_account.d.ts +4 -0
  102. package/dest/cmds/pxe/get_account.d.ts.map +1 -0
  103. package/dest/cmds/pxe/get_accounts.d.ts +3 -0
  104. package/dest/cmds/pxe/get_accounts.d.ts.map +1 -0
  105. package/dest/cmds/pxe/get_block.d.ts +3 -0
  106. package/dest/cmds/pxe/get_block.d.ts.map +1 -0
  107. package/dest/cmds/pxe/get_contract_data.d.ts +4 -0
  108. package/dest/cmds/pxe/get_contract_data.d.ts.map +1 -0
  109. package/dest/cmds/pxe/get_contract_data.js +1 -1
  110. package/dest/cmds/pxe/get_current_base_fee.d.ts +3 -0
  111. package/dest/cmds/pxe/get_current_base_fee.d.ts.map +1 -0
  112. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +4 -0
  113. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +1 -0
  114. package/dest/cmds/pxe/get_logs.d.ts +4 -0
  115. package/dest/cmds/pxe/get_logs.d.ts.map +1 -0
  116. package/dest/cmds/pxe/get_node_info.d.ts +3 -0
  117. package/dest/cmds/pxe/get_node_info.d.ts.map +1 -0
  118. package/dest/cmds/pxe/get_node_info.js +2 -2
  119. package/dest/cmds/pxe/get_pxe_info.d.ts +3 -0
  120. package/dest/cmds/pxe/get_pxe_info.d.ts.map +1 -0
  121. package/dest/cmds/pxe/index.d.ts +4 -0
  122. package/dest/cmds/pxe/index.d.ts.map +1 -0
  123. package/dest/cmds/pxe/index.js +1 -1
  124. package/dest/utils/aztec.d.ts +68 -0
  125. package/dest/utils/aztec.d.ts.map +1 -0
  126. package/dest/utils/aztec.js +34 -23
  127. package/dest/utils/commands.d.ts +143 -0
  128. package/dest/utils/commands.d.ts.map +1 -0
  129. package/dest/utils/commands.js +2 -2
  130. package/dest/utils/encoding.d.ts +15 -0
  131. package/dest/utils/encoding.d.ts.map +1 -0
  132. package/dest/utils/encoding.js +6 -13
  133. package/dest/utils/github.d.ts +4 -0
  134. package/dest/utils/github.d.ts.map +1 -0
  135. package/dest/utils/index.d.ts +5 -0
  136. package/dest/utils/index.d.ts.map +1 -0
  137. package/dest/utils/inspect.d.ts +17 -0
  138. package/dest/utils/inspect.d.ts.map +1 -0
  139. package/dest/utils/inspect.js +4 -4
  140. package/package.json +21 -20
  141. package/src/cmds/contracts/index.ts +2 -2
  142. package/src/cmds/contracts/inspect_contract.ts +5 -5
  143. package/src/cmds/contracts/parse_parameter_struct.ts +2 -2
  144. package/src/cmds/devnet/bootstrap_network.ts +24 -12
  145. package/src/cmds/devnet/faucet.ts +2 -2
  146. package/src/cmds/devnet/index.ts +16 -8
  147. package/src/cmds/infrastructure/index.ts +12 -11
  148. package/src/cmds/infrastructure/sequencers.ts +10 -7
  149. package/src/cmds/infrastructure/setup_l2_contract.ts +47 -0
  150. package/src/cmds/l1/advance_epoch.ts +4 -4
  151. package/src/cmds/l1/assume_proven_through.ts +8 -14
  152. package/src/cmds/l1/bridge_erc20.ts +5 -6
  153. package/src/cmds/l1/create_l1_account.ts +1 -1
  154. package/src/cmds/l1/deploy_l1_contracts.ts +13 -5
  155. package/src/cmds/l1/deploy_l1_verifier.ts +7 -7
  156. package/src/cmds/l1/deploy_new_rollup.ts +58 -0
  157. package/src/cmds/l1/get_l1_addresses.ts +30 -0
  158. package/src/cmds/l1/get_l1_balance.ts +9 -6
  159. package/src/cmds/l1/governance_utils.ts +187 -0
  160. package/src/cmds/l1/index.ts +238 -97
  161. package/src/cmds/l1/prover_stats.ts +21 -11
  162. package/src/cmds/l1/update_l1_validators.ts +25 -25
  163. package/src/cmds/misc/compute_selector.ts +2 -2
  164. package/src/cmds/misc/example_contracts.ts +1 -1
  165. package/src/cmds/misc/generate_bootnode_enr.ts +12 -0
  166. package/src/cmds/misc/generate_p2p_private_key.ts +1 -1
  167. package/src/cmds/misc/generate_secret_and_hash.ts +1 -1
  168. package/src/cmds/misc/index.ts +25 -3
  169. package/src/cmds/misc/setup_contracts.ts +6 -4
  170. package/src/cmds/misc/update/noir.ts +2 -2
  171. package/src/cmds/misc/update/npm.ts +2 -2
  172. package/src/cmds/misc/update/utils.ts +1 -1
  173. package/src/cmds/misc/update.ts +2 -2
  174. package/src/cmds/pxe/add_contract.ts +7 -5
  175. package/src/cmds/pxe/block_number.ts +1 -1
  176. package/src/cmds/pxe/get_account.ts +2 -2
  177. package/src/cmds/pxe/get_accounts.ts +1 -1
  178. package/src/cmds/pxe/get_block.ts +1 -1
  179. package/src/cmds/pxe/get_contract_data.ts +5 -3
  180. package/src/cmds/pxe/get_current_base_fee.ts +1 -1
  181. package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +1 -1
  182. package/src/cmds/pxe/get_logs.ts +2 -2
  183. package/src/cmds/pxe/get_node_info.ts +3 -3
  184. package/src/cmds/pxe/get_pxe_info.ts +1 -1
  185. package/src/cmds/pxe/index.ts +3 -3
  186. package/src/utils/aztec.ts +74 -44
  187. package/src/utils/commands.ts +4 -4
  188. package/src/utils/encoding.ts +7 -13
  189. package/src/utils/inspect.ts +8 -7
  190. package/dest/cmds/infrastructure/setup_protocol_contract.js +0 -31
  191. package/src/cmds/infrastructure/setup_protocol_contract.ts +0 -36
@@ -1,9 +1,9 @@
1
1
  import { createCompatibleClient } from '@aztec/aztec.js';
2
2
  import { createEthereumChain, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
3
- import { type LogFn, type Logger } from '@aztec/foundation/log';
3
+ import type { LogFn, Logger } from '@aztec/foundation/log';
4
4
  import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
5
5
 
6
- import { createPublicClient, createWalletClient, getContract, http } from 'viem';
6
+ import { createPublicClient, createWalletClient, fallback, getContract, http } from 'viem';
7
7
  import { mnemonicToAccount } from 'viem/accounts';
8
8
 
9
9
  export async function sequencers(opts: {
@@ -11,24 +11,27 @@ export async function sequencers(opts: {
11
11
  who?: string;
12
12
  mnemonic?: string;
13
13
  rpcUrl: string;
14
- l1RpcUrl: string;
14
+ l1RpcUrls: string[];
15
15
  chainId: number;
16
16
  blockNumber?: number;
17
17
  log: LogFn;
18
18
  debugLogger: Logger;
19
19
  }) {
20
- const { command, who: maybeWho, mnemonic, rpcUrl, l1RpcUrl, chainId, log, debugLogger } = opts;
20
+ const { command, who: maybeWho, mnemonic, rpcUrl, l1RpcUrls, chainId, log, debugLogger } = opts;
21
21
  const client = await createCompatibleClient(rpcUrl, debugLogger);
22
22
  const { l1ContractAddresses } = await client.getNodeInfo();
23
23
 
24
- const chain = createEthereumChain(l1RpcUrl, chainId);
25
- const publicClient = createPublicClient({ chain: chain.chainInfo, transport: http(chain.rpcUrl) });
24
+ const chain = createEthereumChain(l1RpcUrls, chainId);
25
+ const publicClient = createPublicClient({
26
+ chain: chain.chainInfo,
27
+ transport: fallback(l1RpcUrls.map(url => http(url))),
28
+ });
26
29
 
27
30
  const walletClient = mnemonic
28
31
  ? createWalletClient({
29
32
  account: mnemonicToAccount(mnemonic),
30
33
  chain: chain.chainInfo,
31
- transport: http(chain.rpcUrl),
34
+ transport: fallback(l1RpcUrls.map(url => http(url))),
32
35
  })
33
36
  : undefined;
34
37
 
@@ -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
+ }
@@ -1,11 +1,11 @@
1
1
  import { CheatCodes, createPXEClient, makeFetch } from '@aztec/aztec.js';
2
- import { type LogFn } from '@aztec/foundation/log';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
3
 
4
- export async function advanceEpoch(l1RpcUrl: string, rpcUrl: string, log: LogFn) {
5
- const pxe = createPXEClient(rpcUrl, makeFetch([], true));
4
+ export async function advanceEpoch(l1RpcUrls: string[], rpcUrl: string, log: LogFn) {
5
+ const pxe = createPXEClient(rpcUrl, {}, makeFetch([], true));
6
6
  const rollupAddress = await pxe.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
7
7
 
8
- const cheat = CheatCodes.createRollup(l1RpcUrl, { rollupAddress });
8
+ const cheat = CheatCodes.createRollup(l1RpcUrls, { rollupAddress });
9
9
 
10
10
  await cheat.advanceToNextEpoch();
11
11
  log(`Warped time to advance to next epoch`);
@@ -1,25 +1,19 @@
1
- import { createPXEClient, makeFetch } from '@aztec/aztec.js';
2
- import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
3
- import { type LogFn } from '@aztec/foundation/log';
4
-
5
- import { setAssumeProvenThrough } from '../../utils/aztec.js';
1
+ import { EthCheatCodes, RollupCheatCodes, createPXEClient, makeFetch } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
6
3
 
7
4
  export async function assumeProvenThrough(
8
5
  blockNumberOrLatest: number | undefined,
9
- l1RpcUrl: string,
6
+ l1RpcUrls: string[],
10
7
  rpcUrl: string,
11
- chainId: number,
12
- privateKey: string | undefined,
13
- mnemonic: string,
14
8
  log: LogFn,
15
9
  ) {
16
- const chain = createEthereumChain(l1RpcUrl, chainId);
17
- const { walletClient } = createL1Clients(chain.rpcUrl, privateKey ?? mnemonic, chain.chainInfo);
18
-
19
- const pxe = createPXEClient(rpcUrl, makeFetch([], true));
10
+ const pxe = createPXEClient(rpcUrl, {}, makeFetch([], true));
20
11
  const rollupAddress = await pxe.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
21
12
  const blockNumber = blockNumberOrLatest ?? (await pxe.getBlockNumber());
22
13
 
23
- await setAssumeProvenThrough(blockNumber, rollupAddress, walletClient);
14
+ const ethCheatCode = new EthCheatCodes(l1RpcUrls);
15
+ const rollupCheatCodes = new RollupCheatCodes(ethCheatCode, { rollupAddress });
16
+
17
+ await rollupCheatCodes.markAsProven(blockNumber);
24
18
  log(`Assumed proven through block ${blockNumber}`);
25
19
  }
@@ -1,14 +1,13 @@
1
- import { L1ToL2TokenPortalManager } from '@aztec/aztec.js';
2
- import { type AztecAddress, type EthAddress, type Fr } from '@aztec/circuits.js';
1
+ import { type AztecAddress, type EthAddress, type Fr, L1ToL2TokenPortalManager } from '@aztec/aztec.js';
3
2
  import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
4
- import { type LogFn, type Logger } from '@aztec/foundation/log';
3
+ import type { LogFn, Logger } from '@aztec/foundation/log';
5
4
 
6
5
  import { prettyPrintJSON } from '../../utils/commands.js';
7
6
 
8
7
  export async function bridgeERC20(
9
8
  amount: bigint,
10
9
  recipient: AztecAddress,
11
- l1RpcUrl: string,
10
+ l1RpcUrls: string[],
12
11
  chainId: number,
13
12
  privateKey: string | undefined,
14
13
  mnemonic: string,
@@ -21,8 +20,8 @@ export async function bridgeERC20(
21
20
  debugLogger: Logger,
22
21
  ) {
23
22
  // Prepare L1 client
24
- const chain = createEthereumChain(l1RpcUrl, chainId);
25
- const { publicClient, walletClient } = createL1Clients(chain.rpcUrl, privateKey ?? mnemonic, chain.chainInfo);
23
+ const chain = createEthereumChain(l1RpcUrls, chainId);
24
+ const { publicClient, walletClient } = createL1Clients(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
26
25
 
27
26
  // Setup portal manager
28
27
  const manager = new L1ToL2TokenPortalManager(portalAddress, tokenAddress, publicClient, walletClient, debugLogger);
@@ -1,4 +1,4 @@
1
- import { type LogFn } from '@aztec/foundation/log';
1
+ import type { LogFn } from '@aztec/foundation/log';
2
2
 
3
3
  import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
4
4
 
@@ -1,16 +1,19 @@
1
+ import { getInitialTestAccounts } from '@aztec/accounts/testing';
1
2
  import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
2
- import { type EthAddress } from '@aztec/foundation/eth-address';
3
- import { type LogFn, type Logger } from '@aztec/foundation/log';
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';
4
6
 
5
7
  import { deployAztecContracts } from '../../utils/aztec.js';
6
8
 
7
9
  export async function deployL1Contracts(
8
- rpcUrl: string,
10
+ rpcUrls: string[],
9
11
  chainId: number,
10
12
  privateKey: string | undefined,
11
13
  mnemonic: string,
12
14
  mnemonicIndex: number,
13
15
  salt: number | undefined,
16
+ testAccounts: boolean,
14
17
  json: boolean,
15
18
  initialValidators: EthAddress[],
16
19
  log: LogFn,
@@ -18,14 +21,19 @@ export async function deployL1Contracts(
18
21
  ) {
19
22
  const config = getL1ContractsConfigEnvVars();
20
23
 
24
+ const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
25
+ const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
26
+
21
27
  const { l1ContractAddresses } = await deployAztecContracts(
22
- rpcUrl,
28
+ rpcUrls,
23
29
  chainId,
24
30
  privateKey,
25
31
  mnemonic,
26
32
  mnemonicIndex,
27
33
  salt,
28
34
  initialValidators,
35
+ genesisArchiveRoot,
36
+ genesisBlockHash,
29
37
  config,
30
38
  debugLogger,
31
39
  );
@@ -50,6 +58,6 @@ export async function deployL1Contracts(
50
58
  log(`RewardDistributor Address: ${l1ContractAddresses.rewardDistributorAddress.toString()}`);
51
59
  log(`GovernanceProposer Address: ${l1ContractAddresses.governanceProposerAddress.toString()}`);
52
60
  log(`Governance Address: ${l1ContractAddresses.governanceAddress.toString()}`);
53
- log(`SlashFactory Address: ${l1ContractAddresses.slashFactoryAddress.toString()}`);
61
+ log(`SlashFactory Address: ${l1ContractAddresses.slashFactoryAddress?.toString()}`);
54
62
  }
55
63
  }
@@ -1,6 +1,6 @@
1
1
  import { createCompatibleClient } from '@aztec/aztec.js';
2
2
  import { createEthereumChain, createL1Clients, deployL1Contract } from '@aztec/ethereum';
3
- import { type LogFn, type Logger } from '@aztec/foundation/log';
3
+ import type { LogFn, Logger } from '@aztec/foundation/log';
4
4
  import { HonkVerifierAbi, HonkVerifierBytecode } from '@aztec/l1-artifacts';
5
5
 
6
6
  import { InvalidOptionArgumentError } from 'commander';
@@ -8,7 +8,7 @@ import { type Hex, getContract } from 'viem';
8
8
 
9
9
  export async function deployUltraHonkVerifier(
10
10
  rollupAddress: Hex | undefined,
11
- ethRpcUrl: string,
11
+ ethRpcUrls: string[],
12
12
  l1ChainId: string,
13
13
  privateKey: string | undefined,
14
14
  mnemonic: string,
@@ -23,9 +23,9 @@ export async function deployUltraHonkVerifier(
23
23
  }
24
24
 
25
25
  const { publicClient, walletClient } = createL1Clients(
26
- ethRpcUrl,
26
+ ethRpcUrls,
27
27
  privateKey ?? mnemonic,
28
- createEthereumChain(ethRpcUrl, l1ChainId).chainInfo,
28
+ createEthereumChain(ethRpcUrls, l1ChainId).chainInfo,
29
29
  );
30
30
 
31
31
  if (!rollupAddress && pxeRpcUrl) {
@@ -61,7 +61,7 @@ export async function deployUltraHonkVerifier(
61
61
 
62
62
  export async function deployMockVerifier(
63
63
  rollupAddress: Hex | undefined,
64
- ethRpcUrl: string,
64
+ ethRpcUrls: string[],
65
65
  l1ChainId: string,
66
66
  privateKey: string | undefined,
67
67
  mnemonic: string,
@@ -70,9 +70,9 @@ export async function deployMockVerifier(
70
70
  debugLogger: Logger,
71
71
  ) {
72
72
  const { publicClient, walletClient } = createL1Clients(
73
- ethRpcUrl,
73
+ ethRpcUrls,
74
74
  privateKey ?? mnemonic,
75
- createEthereumChain(ethRpcUrl, l1ChainId).chainInfo,
75
+ createEthereumChain(ethRpcUrls, l1ChainId).chainInfo,
76
76
  );
77
77
  const { MockVerifierAbi, MockVerifierBytecode, RollupAbi } = await import('@aztec/l1-artifacts');
78
78
 
@@ -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
+ }
@@ -1,22 +1,25 @@
1
- import { type EthAddress } from '@aztec/circuits.js';
2
1
  import { createEthereumChain } from '@aztec/ethereum';
3
- import { type LogFn } from '@aztec/foundation/log';
2
+ import type { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { LogFn } from '@aztec/foundation/log';
4
4
  import { TestERC20Abi } from '@aztec/l1-artifacts';
5
5
 
6
- import { createPublicClient, getContract, http } from 'viem';
6
+ import { createPublicClient, fallback, getContract, http } from 'viem';
7
7
 
8
8
  import { prettyPrintJSON } from '../../utils/commands.js';
9
9
 
10
10
  export async function getL1Balance(
11
11
  who: EthAddress,
12
12
  token: EthAddress | undefined,
13
- l1RpcUrl: string,
13
+ l1RpcUrls: string[],
14
14
  chainId: number,
15
15
  json: boolean,
16
16
  log: LogFn,
17
17
  ) {
18
- const chain = createEthereumChain(l1RpcUrl, chainId);
19
- const publicClient = createPublicClient({ chain: chain.chainInfo, transport: http(chain.rpcUrl) });
18
+ const chain = createEthereumChain(l1RpcUrls, chainId);
19
+ const publicClient = createPublicClient({
20
+ chain: chain.chainInfo,
21
+ transport: fallback(l1RpcUrls.map(url => http(url))),
22
+ });
20
23
 
21
24
  let balance = 0n;
22
25
  if (token) {
@@ -0,0 +1,187 @@
1
+ import {
2
+ FeeJuiceContract,
3
+ GovernanceContract,
4
+ ProposalState,
5
+ RegistryContract,
6
+ createEthereumChain,
7
+ createL1Clients,
8
+ } from '@aztec/ethereum';
9
+ import type { LogFn, Logger } from '@aztec/foundation/log';
10
+
11
+ export async function depositGovernanceTokens({
12
+ registryAddress,
13
+ rpcUrls,
14
+ chainId,
15
+ privateKey,
16
+ mnemonic,
17
+ mnemonicIndex,
18
+ recipient,
19
+ amount,
20
+ debugLogger,
21
+ mint,
22
+ }: {
23
+ registryAddress: `0x${string}`;
24
+ rpcUrls: string[];
25
+ chainId: number;
26
+ privateKey: string | undefined;
27
+ mnemonic: string;
28
+ mnemonicIndex: number;
29
+ recipient: `0x${string}`;
30
+ amount: bigint;
31
+ debugLogger: Logger;
32
+ mint: boolean;
33
+ }) {
34
+ debugLogger.info(`Depositing ${amount} governance tokens to ${recipient}`);
35
+ const chain = createEthereumChain(rpcUrls, chainId);
36
+ const { publicClient, walletClient } = createL1Clients(
37
+ rpcUrls,
38
+ privateKey ?? mnemonic,
39
+ chain.chainInfo,
40
+ mnemonicIndex,
41
+ );
42
+
43
+ const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress, 'canonical');
44
+ const governanceAddress = addresses.governanceAddress.toString();
45
+ const tokenAddress = addresses.feeJuiceAddress.toString();
46
+
47
+ const feeJuice = new FeeJuiceContract(tokenAddress, publicClient, walletClient);
48
+ const governance = new GovernanceContract(governanceAddress, publicClient, walletClient);
49
+ if (mint) {
50
+ await feeJuice.mint(recipient, amount);
51
+ debugLogger.info(`Minted ${amount} tokens to ${recipient}`);
52
+ }
53
+
54
+ await feeJuice.approve(governanceAddress, amount);
55
+ debugLogger.info(`Approved ${amount} tokens for governance`);
56
+
57
+ await governance.deposit(recipient, amount);
58
+ debugLogger.info(`Deposited ${amount} tokens to ${recipient}`);
59
+ }
60
+
61
+ export async function proposeWithLock({
62
+ payloadAddress,
63
+ registryAddress,
64
+ rpcUrls,
65
+ chainId,
66
+ privateKey,
67
+ mnemonic,
68
+ mnemonicIndex,
69
+ json,
70
+ debugLogger,
71
+ log,
72
+ }: {
73
+ payloadAddress: `0x${string}`;
74
+ registryAddress: `0x${string}`;
75
+ rpcUrls: string[];
76
+ chainId: number;
77
+ privateKey: string | undefined;
78
+ mnemonic: string;
79
+ mnemonicIndex: number;
80
+ debugLogger: Logger;
81
+ log: LogFn;
82
+ json: boolean;
83
+ }) {
84
+ debugLogger.info(`Proposing with lock from ${payloadAddress} to ${registryAddress}`);
85
+ const chain = createEthereumChain(rpcUrls, chainId);
86
+ const clients = createL1Clients(rpcUrls, privateKey ?? mnemonic, chain.chainInfo, mnemonicIndex);
87
+
88
+ const addresses = await RegistryContract.collectAddresses(clients.publicClient, registryAddress, 'canonical');
89
+ const governanceAddress = addresses.governanceAddress.toString();
90
+
91
+ const governance = new GovernanceContract(governanceAddress, clients.publicClient, clients.walletClient);
92
+
93
+ const proposalId = await governance.proposeWithLock({
94
+ payloadAddress,
95
+ withdrawAddress: clients.walletClient.account.address,
96
+ });
97
+ if (json) {
98
+ log(JSON.stringify({ proposalId }, null, 2));
99
+ } else {
100
+ log(`Proposed with lock`);
101
+ log(`Proposal ID: ${proposalId}`);
102
+ }
103
+ }
104
+
105
+ export async function voteOnGovernanceProposal({
106
+ proposalId,
107
+ voteAmount,
108
+ inFavor,
109
+ waitTilActive,
110
+ registryAddress,
111
+ rpcUrls,
112
+ chainId,
113
+ privateKey,
114
+ mnemonic,
115
+ mnemonicIndex,
116
+ debugLogger,
117
+ }: {
118
+ proposalId: bigint;
119
+ voteAmount: bigint | undefined;
120
+ inFavor: boolean;
121
+ waitTilActive: boolean;
122
+ registryAddress: `0x${string}`;
123
+ rpcUrls: string[];
124
+ chainId: number;
125
+ privateKey: string | undefined;
126
+ mnemonic: string;
127
+ mnemonicIndex: number;
128
+ debugLogger: Logger;
129
+ }) {
130
+ debugLogger.info(
131
+ `Voting on proposal ${proposalId} with ${voteAmount ? voteAmount : 'all'} tokens in favor: ${inFavor}`,
132
+ );
133
+ const chain = createEthereumChain(rpcUrls, chainId);
134
+ const clients = createL1Clients(rpcUrls, privateKey ?? mnemonic, chain.chainInfo, mnemonicIndex);
135
+
136
+ const addresses = await RegistryContract.collectAddresses(clients.publicClient, registryAddress, 'canonical');
137
+ const governanceAddress = addresses.governanceAddress.toString();
138
+
139
+ const governance = new GovernanceContract(governanceAddress, clients.publicClient, clients.walletClient);
140
+ const state = await governance.getProposalState(proposalId);
141
+ if (state !== ProposalState.Active && !waitTilActive) {
142
+ debugLogger.warn(`Proposal is not active, but waitTilActive is false. Not voting.`);
143
+ return;
144
+ }
145
+
146
+ await governance.awaitProposalActive({ proposalId, logger: debugLogger });
147
+ await governance.vote({ proposalId, voteAmount, inFavor, retries: 10, logger: debugLogger });
148
+ }
149
+
150
+ export async function executeGovernanceProposal({
151
+ proposalId,
152
+ waitTilExecutable,
153
+ registryAddress,
154
+ rpcUrls,
155
+ chainId,
156
+ privateKey,
157
+ mnemonic,
158
+ mnemonicIndex,
159
+ debugLogger,
160
+ }: {
161
+ proposalId: bigint;
162
+ waitTilExecutable: boolean;
163
+ registryAddress: `0x${string}`;
164
+ rpcUrls: string[];
165
+ chainId: number;
166
+ privateKey: string | undefined;
167
+ mnemonic: string;
168
+ mnemonicIndex: number;
169
+ debugLogger: Logger;
170
+ }) {
171
+ debugLogger.info(`Executing proposal ${proposalId}`);
172
+ const chain = createEthereumChain(rpcUrls, chainId);
173
+ const clients = createL1Clients(rpcUrls, privateKey ?? mnemonic, chain.chainInfo, mnemonicIndex);
174
+
175
+ const addresses = await RegistryContract.collectAddresses(clients.publicClient, registryAddress, 'canonical');
176
+ const governanceAddress = addresses.governanceAddress.toString();
177
+
178
+ const governance = new GovernanceContract(governanceAddress, clients.publicClient, clients.walletClient);
179
+ const state = await governance.getProposalState(proposalId);
180
+ if (state !== ProposalState.Executable && !waitTilExecutable) {
181
+ debugLogger.warn(`Proposal is not executable, but waitTilExecutable is false. Not executing.`);
182
+ return;
183
+ }
184
+
185
+ await governance.awaitProposalExecutable({ proposalId, logger: debugLogger });
186
+ await governance.executeProposal({ proposalId, retries: 10, logger: debugLogger });
187
+ }