@aztec/cli 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c

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 (48) hide show
  1. package/dest/cmds/aztec_node/get_current_min_fee.d.ts +3 -0
  2. package/dest/cmds/aztec_node/get_current_min_fee.d.ts.map +1 -0
  3. package/dest/cmds/aztec_node/{get_current_base_fee.js → get_current_min_fee.js} +2 -2
  4. package/dest/cmds/aztec_node/index.js +3 -3
  5. package/dest/cmds/infrastructure/sequencers.d.ts +1 -1
  6. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
  7. package/dest/cmds/infrastructure/sequencers.js +2 -1
  8. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
  9. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
  10. package/dest/cmds/infrastructure/setup_l2_contract.js +4 -3
  11. package/dest/cmds/l1/assume_proven_through.d.ts +3 -2
  12. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
  13. package/dest/cmds/l1/assume_proven_through.js +3 -5
  14. package/dest/cmds/l1/compute_genesis_values.d.ts +4 -0
  15. package/dest/cmds/l1/compute_genesis_values.d.ts.map +1 -0
  16. package/dest/cmds/l1/compute_genesis_values.js +17 -0
  17. package/dest/cmds/l1/index.d.ts +1 -1
  18. package/dest/cmds/l1/index.d.ts.map +1 -1
  19. package/dest/cmds/l1/index.js +7 -2
  20. package/dest/cmds/l1/update_l1_validators.d.ts +3 -3
  21. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  22. package/dest/cmds/l1/update_l1_validators.js +52 -17
  23. package/dest/config/chain_l2_config.d.ts +12 -39
  24. package/dest/config/chain_l2_config.d.ts.map +1 -1
  25. package/dest/config/chain_l2_config.js +35 -512
  26. package/dest/config/generated/networks.d.ts +211 -0
  27. package/dest/config/generated/networks.d.ts.map +1 -0
  28. package/dest/config/generated/networks.js +212 -0
  29. package/dest/config/network_config.d.ts +1 -1
  30. package/dest/config/network_config.js +1 -1
  31. package/dest/utils/inspect.d.ts +1 -1
  32. package/dest/utils/inspect.d.ts.map +1 -1
  33. package/dest/utils/inspect.js +4 -1
  34. package/package.json +35 -30
  35. package/src/cmds/aztec_node/{get_current_base_fee.ts → get_current_min_fee.ts} +2 -2
  36. package/src/cmds/aztec_node/index.ts +3 -3
  37. package/src/cmds/infrastructure/sequencers.ts +2 -1
  38. package/src/cmds/infrastructure/setup_l2_contract.ts +5 -4
  39. package/src/cmds/l1/assume_proven_through.ts +4 -7
  40. package/src/cmds/l1/compute_genesis_values.ts +29 -0
  41. package/src/cmds/l1/index.ts +23 -4
  42. package/src/cmds/l1/update_l1_validators.ts +46 -20
  43. package/src/config/chain_l2_config.ts +35 -670
  44. package/src/config/generated/networks.ts +216 -0
  45. package/src/config/network_config.ts +1 -1
  46. package/src/utils/inspect.ts +4 -1
  47. package/dest/cmds/aztec_node/get_current_base_fee.d.ts +0 -3
  48. package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +0 -1
@@ -1,23 +1,20 @@
1
1
  import { createAztecNodeClient } from '@aztec/aztec.js/node';
2
2
  import { RollupCheatCodes } from '@aztec/ethereum/test';
3
- import { BlockNumber } from '@aztec/foundation/branded-types';
3
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
4
  import type { LogFn } from '@aztec/foundation/log';
5
5
  import { DateProvider } from '@aztec/foundation/timer';
6
6
 
7
7
  export async function assumeProvenThrough(
8
- blockNumberOrLatest: number | undefined,
8
+ checkpointOrLatest: CheckpointNumber | undefined,
9
9
  l1RpcUrls: string[],
10
10
  nodeUrl: string,
11
11
  log: LogFn,
12
12
  ) {
13
13
  const aztecNode = createAztecNodeClient(nodeUrl);
14
14
  const rollupAddress = await aztecNode.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
15
- const blockNumber: BlockNumber = blockNumberOrLatest
16
- ? BlockNumber(blockNumberOrLatest)
17
- : await aztecNode.getBlockNumber();
18
15
 
19
16
  const rollupCheatCodes = RollupCheatCodes.create(l1RpcUrls, { rollupAddress }, new DateProvider());
20
17
 
21
- await rollupCheatCodes.markAsProven(blockNumber);
22
- log(`Assumed proven through block ${blockNumber}`);
18
+ await rollupCheatCodes.markAsProven(checkpointOrLatest);
19
+ log(`Assumed proven through checkpoint ${checkpointOrLatest ?? 'latest'}`);
23
20
  }
@@ -0,0 +1,29 @@
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
4
+ import { getGenesisValues } from '@aztec/world-state/testing';
5
+
6
+ import { getSponsoredFPCAddress } from '../../utils/setup_contracts.js';
7
+
8
+ /** Computes and prints genesis values needed for L1 contract deployment. */
9
+ export async function computeGenesisValuesCmd(testAccounts: boolean, sponsoredFPC: boolean, log: LogFn) {
10
+ const initialAccounts = testAccounts ? await getInitialTestAccountsData() : [];
11
+ const sponsoredFPCAddresses = sponsoredFPC ? await getSponsoredFPCAddress() : [];
12
+ const initialFundedAccounts = initialAccounts.map(a => a.address).concat(sponsoredFPCAddresses);
13
+ const { genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts);
14
+
15
+ const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types/vk-tree');
16
+ const vkTreeRoot = getVKTreeRoot();
17
+
18
+ log(
19
+ JSON.stringify(
20
+ {
21
+ vkTreeRoot: vkTreeRoot.toString(),
22
+ protocolContractsHash: protocolContractsHash.toString(),
23
+ genesisArchiveRoot: genesisArchiveRoot.toString(),
24
+ },
25
+ null,
26
+ 2,
27
+ ),
28
+ );
29
+ }
@@ -1,3 +1,4 @@
1
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
1
2
  import { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
4
 
@@ -105,6 +106,24 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
105
106
  );
106
107
  });
107
108
 
109
+ program
110
+ .command('compute-genesis-values')
111
+ .description('Computes genesis values (VK tree root, protocol contracts hash, genesis archive root).')
112
+ .addOption(
113
+ new Option('--test-accounts <boolean>', 'Include initial test accounts in genesis state')
114
+ .env('TEST_ACCOUNTS')
115
+ .argParser(arg => arg === 'true'),
116
+ )
117
+ .addOption(
118
+ new Option('--sponsored-fpc <boolean>', 'Include sponsored FPC contract in genesis state')
119
+ .env('SPONSORED_FPC')
120
+ .argParser(arg => arg === 'true'),
121
+ )
122
+ .action(async options => {
123
+ const { computeGenesisValuesCmd } = await import('./compute_genesis_values.js');
124
+ await computeGenesisValuesCmd(options.testAccounts, options.sponsoredFpc, log);
125
+ });
126
+
108
127
  program
109
128
  .command('deposit-governance-tokens')
110
129
  .description('Deposits governance tokens to the governance contract.')
@@ -497,14 +516,14 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
497
516
  program
498
517
  .command('set-proven-through', { hidden: true })
499
518
  .description(
500
- 'Instructs the L1 rollup contract to assume all blocks until the given number are automatically proven.',
519
+ 'Instructs the L1 rollup contract to assume all blocks until the given checkpoint are automatically proven.',
501
520
  )
502
- .argument('[blockNumber]', 'The target block number, defaults to the latest pending block number.', parseBigint)
521
+ .argument('[checkpoint]', 'The target checkpoint, defaults to the latest pending checkpoint.', parseBigint)
503
522
  .addOption(l1RpcUrlsOption)
504
523
  .addOption(nodeOption)
505
- .action(async (blockNumber, options) => {
524
+ .action(async (checkpoint, options) => {
506
525
  const { assumeProvenThrough } = await import('./assume_proven_through.js');
507
- await assumeProvenThrough(blockNumber, options.l1RpcUrls, options.nodeUrl, log);
526
+ await assumeProvenThrough(CheckpointNumber.fromBigInt(checkpoint), options.l1RpcUrls, options.nodeUrl, log);
508
527
  });
509
528
 
510
529
  program
@@ -2,19 +2,17 @@ import { createEthereumChain, isAnvilTestChain } from '@aztec/ethereum/chain';
2
2
  import { createExtendedL1Client, getPublicClient } from '@aztec/ethereum/client';
3
3
  import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
4
4
  import { GSEContract, RollupContract } from '@aztec/ethereum/contracts';
5
- import { createL1TxUtilsFromViemWallet } from '@aztec/ethereum/l1-tx-utils';
5
+ import { createL1TxUtils } from '@aztec/ethereum/l1-tx-utils';
6
6
  import { EthCheatCodes } from '@aztec/ethereum/test';
7
7
  import type { EthAddress } from '@aztec/foundation/eth-address';
8
8
  import type { LogFn, Logger } from '@aztec/foundation/log';
9
9
  import { DateProvider } from '@aztec/foundation/timer';
10
- import { RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
10
+ import { RollupAbi, StakingAssetHandlerAbi, TestERC20Abi } from '@aztec/l1-artifacts';
11
11
  import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
12
12
 
13
- import { encodeFunctionData, formatEther, getContract } from 'viem';
13
+ import { encodeFunctionData, formatEther, getContract, maxUint256 } from 'viem';
14
14
  import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
15
15
 
16
- import { addLeadingHex } from '../../utils/aztec.js';
17
-
18
16
  export interface RollupCommandArgs {
19
17
  rpcUrls: string[];
20
18
  chainId: number;
@@ -53,8 +51,8 @@ export async function addL1Validator({
53
51
  privateKey,
54
52
  mnemonic,
55
53
  attesterAddress,
54
+ withdrawerAddress,
56
55
  stakingAssetHandlerAddress,
57
- merkleProof,
58
56
  proofParams,
59
57
  blsSecretKey,
60
58
  log,
@@ -63,8 +61,8 @@ export async function addL1Validator({
63
61
  LoggerArgs & {
64
62
  blsSecretKey: bigint; // scalar field element of BN254
65
63
  attesterAddress: EthAddress;
64
+ withdrawerAddress: EthAddress;
66
65
  proofParams: Buffer;
67
- merkleProof: string[];
68
66
  }) {
69
67
  const dualLog = makeDualLog(log, debugLogger);
70
68
  const account = getAccount(privateKey, mnemonic);
@@ -87,33 +85,61 @@ export async function addL1Validator({
87
85
  });
88
86
 
89
87
  const gseAddress = await rollup.read.getGSE();
90
-
91
88
  const gse = new GSEContract(l1Client, gseAddress);
92
-
93
89
  const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
94
90
 
95
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
91
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
96
92
  const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);
97
- const merkleProofArray = merkleProof.map(proof => addLeadingHex(proof));
98
93
 
99
- const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
94
+ // Step 1: Claim STK tokens from the faucet
95
+ dualLog(`Claiming STK tokens from faucet`);
96
+ const { receipt: claimReceipt } = await l1TxUtils.sendAndMonitorTransaction({
100
97
  to: stakingAssetHandlerAddress.toString(),
101
98
  data: encodeFunctionData({
102
99
  abi: StakingAssetHandlerAbi,
103
- functionName: 'addValidator',
100
+ functionName: 'claim',
101
+ args: [proofParamsObj.toViem()],
102
+ }),
103
+ abi: StakingAssetHandlerAbi,
104
+ });
105
+ dualLog(`Claim transaction hash: ${claimReceipt.transactionHash}`);
106
+ await l1Client.waitForTransactionReceipt({ hash: claimReceipt.transactionHash });
107
+
108
+ // Step 2: Approve the rollup to spend STK tokens
109
+ const stakingAssetAddress = await stakingAssetHandler.read.STAKING_ASSET();
110
+ dualLog(`Approving rollup to spend STK tokens`);
111
+ const { receipt: approveReceipt } = await l1TxUtils.sendAndMonitorTransaction({
112
+ to: stakingAssetAddress,
113
+ data: encodeFunctionData({
114
+ abi: TestERC20Abi,
115
+ functionName: 'approve',
116
+ args: [rollupAddress, maxUint256],
117
+ }),
118
+ abi: TestERC20Abi,
119
+ });
120
+ await l1Client.waitForTransactionReceipt({ hash: approveReceipt.transactionHash });
121
+
122
+ // Step 3: Deposit into the rollup to register as a validator
123
+ dualLog(`Depositing into rollup to register validator`);
124
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
125
+ to: rollupAddress,
126
+ data: encodeFunctionData({
127
+ abi: RollupAbi,
128
+ functionName: 'deposit',
104
129
  args: [
105
130
  attesterAddress.toString(),
106
- merkleProofArray,
107
- proofParamsObj.toViem(),
131
+ withdrawerAddress.toString(),
108
132
  registrationTuple.publicKeyInG1,
109
133
  registrationTuple.publicKeyInG2,
110
134
  registrationTuple.proofOfPossession,
135
+ false, // moveWithLatestRollup
111
136
  ],
112
137
  }),
113
- abi: StakingAssetHandlerAbi,
138
+ abi: RollupAbi,
114
139
  });
115
- dualLog(`Transaction hash: ${receipt.transactionHash}`);
140
+ dualLog(`Deposit transaction hash: ${receipt.transactionHash}`);
116
141
  await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
142
+
117
143
  if (isAnvilTestChain(chainId)) {
118
144
  dualLog(`Funding validator on L1`);
119
145
  const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
@@ -168,7 +194,7 @@ export async function addL1ValidatorViaRollup({
168
194
 
169
195
  const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
170
196
 
171
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
197
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
172
198
 
173
199
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
174
200
  to: rollupAddress.toString(),
@@ -215,7 +241,7 @@ export async function removeL1Validator({
215
241
  const account = getAccount(privateKey, mnemonic);
216
242
  const chain = createEthereumChain(rpcUrls, chainId);
217
243
  const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
218
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
244
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
219
245
 
220
246
  dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
221
247
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
@@ -242,7 +268,7 @@ export async function pruneRollup({
242
268
  const account = getAccount(privateKey, mnemonic);
243
269
  const chain = createEthereumChain(rpcUrls, chainId);
244
270
  const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
245
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
271
+ const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
246
272
 
247
273
  dualLog(`Trying prune`);
248
274
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({