@aztec/cli 0.82.0 → 0.82.1

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/infrastructure/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,WAgD/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/infrastructure/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,WAwD/E"}
@@ -1,8 +1,8 @@
1
1
  import { ETHEREUM_HOSTS, l1ChainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js';
2
2
  export function injectCommands(program, log, debugLogger) {
3
- program.command('setup-protocol-contracts').description('Bootstrap the blockchain by initializing all the protocol contracts').addOption(pxeOption).option('--testAccounts', 'Deploy funded test accounts.').option('--json', 'Output the contract addresses in JSON format').option('--skipProofWait', "Don't wait for proofs to land.").action(async (options)=>{
3
+ program.command('setup-protocol-contracts').description('Bootstrap the blockchain by initializing all the protocol contracts').addOption(pxeOption).option('--testAccounts', 'Deploy funded test accounts.').option('--sponsoredFPC', 'Deploy a sponsored FPC.').option('--json', 'Output the contract addresses in JSON format').option('--skipProofWait', "Don't wait for proofs to land.").action(async (options)=>{
4
4
  const { setupL2Contracts } = await import('./setup_l2_contract.js');
5
- await setupL2Contracts(options.rpcUrl, options.testAccounts, options.json, options.skipProofWait, log);
5
+ await setupL2Contracts(options.rpcUrl, options.testAccounts, options.sponsoredFPC, options.json, options.skipProofWait, log);
6
6
  });
7
7
  program.command('sequencers').argument('<command>', 'Command to run: list, add, remove, who-next').argument('[who]', 'Who to add/remove').description('Manages or queries registered sequencers on the L1 rollup contract.').requiredOption('--l1-rpc-urls <string>', 'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)', (arg)=>arg.split(','), [
8
8
  ETHEREUM_HOSTS
@@ -1,3 +1,3 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
- export declare function setupL2Contracts(rpcUrl: string, testAccounts: boolean, json: boolean, skipProofWait: boolean, log: LogFn): Promise<void>;
2
+ export declare function setupL2Contracts(rpcUrl: string, testAccounts: boolean, sponsoredFPC: boolean, json: boolean, skipProofWait: boolean, log: LogFn): Promise<void>;
3
3
  //# sourceMappingURL=setup_l2_contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup_l2_contract.d.ts","sourceRoot":"","sources":["../../../src/cmds/infrastructure/setup_l2_contract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,EACrB,IAAI,EAAE,OAAO,EACb,aAAa,EAAE,OAAO,EACtB,GAAG,EAAE,KAAK,iBAsCX"}
1
+ {"version":3,"file":"setup_l2_contract.d.ts","sourceRoot":"","sources":["../../../src/cmds/infrastructure/setup_l2_contract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,IAAI,EAAE,OAAO,EACb,aAAa,EAAE,OAAO,EACtB,GAAG,EAAE,KAAK,iBA2CX"}
@@ -2,8 +2,8 @@ import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/acco
2
2
  import { createPXEClient, makeFetch } from '@aztec/aztec.js';
3
3
  import { jsonStringify } from '@aztec/foundation/json-rpc';
4
4
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
- import { setupCanonicalL2FeeJuice } from '../misc/setup_contracts.js';
6
- export async function setupL2Contracts(rpcUrl, testAccounts, json, skipProofWait, log) {
5
+ import { setupCanonicalL2FeeJuice, setupSponsoredFPC } from '../../utils/setup_contracts.js';
6
+ export async function setupL2Contracts(rpcUrl, testAccounts, sponsoredFPC, json, skipProofWait, log) {
7
7
  const waitOpts = {
8
8
  timeout: 180,
9
9
  interval: 1
@@ -34,6 +34,10 @@ export async function setupL2Contracts(rpcUrl, testAccounts, json, skipProofWait
34
34
  deployedAccounts = await getInitialTestAccounts();
35
35
  await deployFundedSchnorrAccounts(pxe, deployedAccounts, waitOpts);
36
36
  }
37
+ if (sponsoredFPC) {
38
+ log('setupL2Contracts: Setting up sponsored FPC...');
39
+ await setupSponsoredFPC(pxe, log, waitOpts, waitForProvenOptions);
40
+ }
37
41
  if (json) {
38
42
  const toPrint = {
39
43
  ...ProtocolContractAddress
@@ -1,4 +1,4 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
- export declare function deployL1Contracts(rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, testAccounts: boolean, acceleratedTestDeployments: boolean, json: boolean, initialValidators: EthAddress[], log: LogFn, debugLogger: Logger): Promise<void>;
3
+ export declare function deployL1Contracts(rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, testAccounts: boolean, sponsoredFPC: boolean, acceleratedTestDeployments: boolean, json: boolean, initialValidators: EthAddress[], log: LogFn, debugLogger: Logger): Promise<void>;
4
4
  //# sourceMappingURL=deploy_l1_contracts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy_l1_contracts.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/deploy_l1_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAK3D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,YAAY,EAAE,OAAO,EACrB,0BAA0B,EAAE,OAAO,EACnC,IAAI,EAAE,OAAO,EACb,iBAAiB,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,iBA6CpB"}
1
+ {"version":3,"file":"deploy_l1_contracts.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/deploy_l1_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAM3D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,0BAA0B,EAAE,OAAO,EACnC,IAAI,EAAE,OAAO,EACb,iBAAiB,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,iBAgDpB"}
@@ -2,10 +2,12 @@ import { getInitialTestAccounts } from '@aztec/accounts/testing';
2
2
  import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
3
3
  import { getGenesisValues } from '@aztec/world-state/testing';
4
4
  import { deployAztecContracts } from '../../utils/aztec.js';
5
- export async function deployL1Contracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, testAccounts, acceleratedTestDeployments, json, initialValidators, log, debugLogger) {
5
+ import { getSponsoredFPCAddress } from '../../utils/setup_contracts.js';
6
+ export async function deployL1Contracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, testAccounts, sponsoredFPC, acceleratedTestDeployments, json, initialValidators, log, debugLogger) {
6
7
  const config = getL1ContractsConfigEnvVars();
7
8
  const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
8
- const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address));
9
+ const sponsoredFPCAddress = sponsoredFPC ? await getSponsoredFPCAddress() : [];
10
+ const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address).concat(sponsoredFPCAddress));
9
11
  const { l1ContractAddresses } = await deployAztecContracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, initialValidators, genesisArchiveRoot, genesisBlockHash, acceleratedTestDeployments, config, debugLogger);
10
12
  if (json) {
11
13
  log(JSON.stringify(Object.fromEntries(Object.entries(l1ContractAddresses).map(([k, v])=>[
@@ -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;AAsBjD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAshB/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;AAsBjD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAwhB/E"}
@@ -6,10 +6,10 @@ const l1RpcUrlsOption = new Option('--l1-rpc-urls <string>', 'List of Ethereum h
6
6
  ]).makeOptionMandatory(true).argParser((arg)=>arg.split(',').map((url)=>url.trim()));
7
7
  export function injectCommands(program, log, debugLogger) {
8
8
  const { BB_BINARY_PATH, BB_WORKING_DIRECTORY } = process.env;
9
- program.command('deploy-l1-contracts').description('Deploys all necessary Ethereum contracts for Aztec.').addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY).option('--validators <string>', 'Comma separated list of validators').option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', (arg)=>parseInt(arg), 0).addOption(l1ChainIdOption).option('--salt <number>', 'The optional salt to use in deployment', (arg)=>parseInt(arg)).option('--json', 'Output the contract addresses in JSON format').option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts').option('--accelerated-test-deployments', 'Fire and forget deployment transactions, use in testing only', false).action(async (options)=>{
9
+ program.command('deploy-l1-contracts').description('Deploys all necessary Ethereum contracts for Aztec.').addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY).option('--validators <string>', 'Comma separated list of validators').option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', (arg)=>parseInt(arg), 0).addOption(l1ChainIdOption).option('--salt <number>', 'The optional salt to use in deployment', (arg)=>parseInt(arg)).option('--json', 'Output the contract addresses in JSON format').option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts').option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract').option('--accelerated-test-deployments', 'Fire and forget deployment transactions, use in testing only', false).action(async (options)=>{
10
10
  const { deployL1Contracts } = await import('./deploy_l1_contracts.js');
11
11
  const initialValidators = options.validators?.split(',').map((validator)=>EthAddress.fromString(validator)) || [];
12
- await deployL1Contracts(options.l1RpcUrls, options.l1ChainId, options.privateKey, options.mnemonic, options.mnemonicIndex, options.salt, options.testAccounts, options.acceleratedTestDeployments, options.json, initialValidators, log, debugLogger);
12
+ await deployL1Contracts(options.l1RpcUrls, options.l1ChainId, options.privateKey, options.mnemonic, options.mnemonicIndex, options.salt, options.testAccounts, options.sponsoredFPC, options.acceleratedTestDeployments, options.json, initialValidators, log, debugLogger);
13
13
  });
14
14
  program.command('deploy-new-rollup').description('Deploys a new rollup contract and a payload to upgrade the registry with it.').requiredOption('-r, --registry-address <string>', 'The address of the registry contract', parseEthereumAddress).addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY).option('--validators <string>', 'Comma separated list of validators').option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', (arg)=>parseInt(arg), 0).addOption(l1ChainIdOption).option('--salt <number>', 'The optional salt to use in deployment', (arg)=>parseInt(arg)).option('--json', 'Output the contract addresses in JSON format').option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts').action(async (options)=>{
15
15
  const { deployNewRollup } = await import('./deploy_new_rollup.js');
@@ -2,4 +2,5 @@ export * from './commands.js';
2
2
  export * from './aztec.js';
3
3
  export * from './encoding.js';
4
4
  export * from './github.js';
5
+ export * from './setup_contracts.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
@@ -2,3 +2,4 @@ export * from './commands.js';
2
2
  export * from './aztec.js';
3
3
  export * from './encoding.js';
4
4
  export * from './github.js';
5
+ export * from './setup_contracts.js';
@@ -4,4 +4,6 @@ import type { LogFn } from '@aztec/foundation/log';
4
4
  * Deploys the contract to pay for gas on L2.
5
5
  */
6
6
  export declare function setupCanonicalL2FeeJuice(pxe: PXE, feeJuicePortalAddress: EthAddress, log: LogFn, waitOpts?: import("@aztec/aztec.js").WaitOpts, waitForProvenOptions?: WaitForProvenOpts): Promise<void>;
7
+ export declare function getSponsoredFPCAddress(): Promise<import("@aztec/aztec.js").AztecAddress>;
8
+ export declare function setupSponsoredFPC(pxe: PXE, log: LogFn, waitOpts?: import("@aztec/aztec.js").WaitOpts, waitForProvenOptions?: WaitForProvenOpts): Promise<void>;
7
9
  //# sourceMappingURL=setup_contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup_contracts.d.ts","sourceRoot":"","sources":["../../src/utils/setup_contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAGf,KAAK,GAAG,EAGR,KAAK,iBAAiB,EAGvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,qBAAqB,EAAE,UAAU,EACjC,GAAG,EAAE,KAAK,EACV,QAAQ,qCAAkB,EAC1B,oBAAoB,CAAC,EAAE,iBAAiB,iBA+BzC;AASD,wBAAsB,sBAAsB,oDAM3C;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,KAAK,EACV,QAAQ,qCAAkB,EAC1B,oBAAoB,CAAC,EAAE,iBAAiB,iBAsBzC"}
@@ -0,0 +1,64 @@
1
+ import { DefaultWaitOpts, FeeJuicePaymentMethod, Fr, SignerlessWallet, SponsoredFeePaymentMethod, getContractInstanceFromDeployParams, waitForProven } from '@aztec/aztec.js';
2
+ import { FEE_JUICE_INITIAL_MINT, SPONSORED_FPC_SALT } from '@aztec/constants';
3
+ import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
4
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
+ import { Gas } from '@aztec/stdlib/gas';
6
+ /**
7
+ * Deploys the contract to pay for gas on L2.
8
+ */ export async function setupCanonicalL2FeeJuice(pxe, feeJuicePortalAddress, log, waitOpts = DefaultWaitOpts, waitForProvenOptions) {
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ // @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
11
+ const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
12
+ const deployer = new SignerlessWallet(pxe);
13
+ const feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, deployer);
14
+ const portalAddress = await pxe.getPublicStorageAt(feeJuiceContract.address, feeJuiceContract.artifact.storageLayout.portal_address.slot);
15
+ if (portalAddress.isZero()) {
16
+ log('setupCanonicalL2FeeJuice: Calling initialize on fee juice contract...');
17
+ const paymentMethod = new FeeJuicePaymentMethod(ProtocolContractAddress.FeeJuice);
18
+ const receipt = await feeJuiceContract.methods.initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT).send({
19
+ fee: {
20
+ paymentMethod,
21
+ gasSettings: {
22
+ teardownGasLimits: Gas.empty()
23
+ }
24
+ }
25
+ }).wait(waitOpts);
26
+ if (waitForProvenOptions !== undefined) {
27
+ await waitForProven(pxe, receipt, waitForProvenOptions);
28
+ }
29
+ } else {
30
+ log('setupCanonicalL2FeeJuice: Fee juice contract already initialized. Fee Juice Portal address: ' + portalAddress.toString());
31
+ }
32
+ }
33
+ async function getSponsoredFPCContract() {
34
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
35
+ // @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
36
+ const { SponsoredFPCContract } = await import('@aztec/noir-contracts.js/SponsoredFPC');
37
+ return SponsoredFPCContract;
38
+ }
39
+ export async function getSponsoredFPCAddress() {
40
+ const SponsoredFPCContract = await getSponsoredFPCContract();
41
+ const sponsoredFPCInstance = await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
42
+ salt: new Fr(SPONSORED_FPC_SALT)
43
+ });
44
+ return sponsoredFPCInstance.address;
45
+ }
46
+ export async function setupSponsoredFPC(pxe, log, waitOpts = DefaultWaitOpts, waitForProvenOptions) {
47
+ const SponsoredFPCContract = await getSponsoredFPCContract();
48
+ const address = await getSponsoredFPCAddress();
49
+ const paymentMethod = new SponsoredFeePaymentMethod(address);
50
+ const { l1ChainId: chainId, protocolVersion } = await pxe.getNodeInfo();
51
+ const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
52
+ const deployTx = SponsoredFPCContract.deploy(deployer).send({
53
+ contractAddressSalt: new Fr(SPONSORED_FPC_SALT),
54
+ universalDeploy: true,
55
+ fee: {
56
+ paymentMethod
57
+ }
58
+ });
59
+ const deployed = await deployTx.deployed(waitOpts);
60
+ if (waitForProvenOptions !== undefined) {
61
+ await waitForProven(pxe, await deployTx.getReceipt(), waitForProvenOptions);
62
+ }
63
+ log(`SponsoredFPC: ${deployed.address}`);
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "0.82.0",
3
+ "version": "0.82.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./contracts": "./dest/cmds/contracts/index.js",
@@ -67,14 +67,15 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/archiver": "0.82.0",
71
- "@aztec/aztec.js": "0.82.0",
72
- "@aztec/constants": "0.82.0",
73
- "@aztec/foundation": "0.82.0",
74
- "@aztec/l1-artifacts": "0.82.0",
75
- "@aztec/p2p": "0.82.0",
76
- "@aztec/stdlib": "0.82.0",
77
- "@aztec/world-state": "0.82.0",
70
+ "@aztec/archiver": "0.82.1",
71
+ "@aztec/aztec.js": "0.82.1",
72
+ "@aztec/constants": "0.82.1",
73
+ "@aztec/entrypoints": "0.82.1",
74
+ "@aztec/foundation": "0.82.1",
75
+ "@aztec/l1-artifacts": "0.82.1",
76
+ "@aztec/p2p": "0.82.1",
77
+ "@aztec/stdlib": "0.82.1",
78
+ "@aztec/world-state": "0.82.1",
78
79
  "@iarna/toml": "^2.2.5",
79
80
  "@libp2p/peer-id-factory": "^3.0.4",
80
81
  "commander": "^12.1.0",
@@ -86,9 +87,9 @@
86
87
  "viem": "2.23.7"
87
88
  },
88
89
  "devDependencies": {
89
- "@aztec/accounts": "0.82.0",
90
- "@aztec/ethereum": "0.82.0",
91
- "@aztec/protocol-contracts": "0.82.0",
90
+ "@aztec/accounts": "0.82.1",
91
+ "@aztec/ethereum": "0.82.1",
92
+ "@aztec/protocol-contracts": "0.82.1",
92
93
  "@jest/globals": "^29.5.0",
93
94
  "@types/jest": "^29.5.0",
94
95
  "@types/lodash.chunk": "^4.2.9",
@@ -104,14 +105,14 @@
104
105
  "typescript": "^5.0.4"
105
106
  },
106
107
  "peerDependencies": {
107
- "@aztec/accounts": "0.82.0",
108
- "@aztec/bb-prover": "0.82.0",
109
- "@aztec/ethereum": "0.82.0",
110
- "@aztec/l1-artifacts": "0.82.0",
111
- "@aztec/noir-contracts.js": "0.82.0",
112
- "@aztec/noir-protocol-circuits-types": "0.82.0",
113
- "@aztec/protocol-contracts": "0.82.0",
114
- "@aztec/stdlib": "0.82.0"
108
+ "@aztec/accounts": "0.82.1",
109
+ "@aztec/bb-prover": "0.82.1",
110
+ "@aztec/ethereum": "0.82.1",
111
+ "@aztec/l1-artifacts": "0.82.1",
112
+ "@aztec/noir-contracts.js": "0.82.1",
113
+ "@aztec/noir-protocol-circuits-types": "0.82.1",
114
+ "@aztec/protocol-contracts": "0.82.1",
115
+ "@aztec/stdlib": "0.82.1"
115
116
  },
116
117
  "files": [
117
118
  "dest",
@@ -10,11 +10,19 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
10
10
  .description('Bootstrap the blockchain by initializing all the protocol contracts')
11
11
  .addOption(pxeOption)
12
12
  .option('--testAccounts', 'Deploy funded test accounts.')
13
+ .option('--sponsoredFPC', 'Deploy a sponsored FPC.')
13
14
  .option('--json', 'Output the contract addresses in JSON format')
14
15
  .option('--skipProofWait', "Don't wait for proofs to land.")
15
16
  .action(async options => {
16
17
  const { setupL2Contracts } = await import('./setup_l2_contract.js');
17
- await setupL2Contracts(options.rpcUrl, options.testAccounts, options.json, options.skipProofWait, log);
18
+ await setupL2Contracts(
19
+ options.rpcUrl,
20
+ options.testAccounts,
21
+ options.sponsoredFPC,
22
+ options.json,
23
+ options.skipProofWait,
24
+ log,
25
+ );
18
26
  });
19
27
 
20
28
  program
@@ -4,11 +4,12 @@ import { jsonStringify } from '@aztec/foundation/json-rpc';
4
4
  import type { LogFn } from '@aztec/foundation/log';
5
5
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
6
 
7
- import { setupCanonicalL2FeeJuice } from '../misc/setup_contracts.js';
7
+ import { setupCanonicalL2FeeJuice, setupSponsoredFPC } from '../../utils/setup_contracts.js';
8
8
 
9
9
  export async function setupL2Contracts(
10
10
  rpcUrl: string,
11
11
  testAccounts: boolean,
12
+ sponsoredFPC: boolean,
12
13
  json: boolean,
13
14
  skipProofWait: boolean,
14
15
  log: LogFn,
@@ -42,6 +43,11 @@ export async function setupL2Contracts(
42
43
  await deployFundedSchnorrAccounts(pxe, deployedAccounts, waitOpts);
43
44
  }
44
45
 
46
+ if (sponsoredFPC) {
47
+ log('setupL2Contracts: Setting up sponsored FPC...');
48
+ await setupSponsoredFPC(pxe, log, waitOpts, waitForProvenOptions);
49
+ }
50
+
45
51
  if (json) {
46
52
  const toPrint: Record<string, AztecAddress> = { ...ProtocolContractAddress };
47
53
  deployedAccounts.forEach((a, i) => {
@@ -5,6 +5,7 @@ import type { LogFn, Logger } from '@aztec/foundation/log';
5
5
  import { getGenesisValues } from '@aztec/world-state/testing';
6
6
 
7
7
  import { deployAztecContracts } from '../../utils/aztec.js';
8
+ import { getSponsoredFPCAddress } from '../../utils/setup_contracts.js';
8
9
 
9
10
  export async function deployL1Contracts(
10
11
  rpcUrls: string[],
@@ -14,6 +15,7 @@ export async function deployL1Contracts(
14
15
  mnemonicIndex: number,
15
16
  salt: number | undefined,
16
17
  testAccounts: boolean,
18
+ sponsoredFPC: boolean,
17
19
  acceleratedTestDeployments: boolean,
18
20
  json: boolean,
19
21
  initialValidators: EthAddress[],
@@ -23,7 +25,10 @@ export async function deployL1Contracts(
23
25
  const config = getL1ContractsConfigEnvVars();
24
26
 
25
27
  const initialFundedAccounts = testAccounts ? await getInitialTestAccounts() : [];
26
- const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
28
+ const sponsoredFPCAddress = sponsoredFPC ? await getSponsoredFPCAddress() : [];
29
+ const { genesisBlockHash, genesisArchiveRoot } = await getGenesisValues(
30
+ initialFundedAccounts.map(a => a.address).concat(sponsoredFPCAddress),
31
+ );
27
32
 
28
33
  const { l1ContractAddresses } = await deployAztecContracts(
29
34
  rpcUrls,
@@ -42,6 +42,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
42
42
  .option('--salt <number>', 'The optional salt to use in deployment', arg => parseInt(arg))
43
43
  .option('--json', 'Output the contract addresses in JSON format')
44
44
  .option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts')
45
+ .option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract')
45
46
  .option('--accelerated-test-deployments', 'Fire and forget deployment transactions, use in testing only', false)
46
47
  .action(async options => {
47
48
  const { deployL1Contracts } = await import('./deploy_l1_contracts.js');
@@ -56,6 +57,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
56
57
  options.mnemonicIndex,
57
58
  options.salt,
58
59
  options.testAccounts,
60
+ options.sponsoredFPC,
59
61
  options.acceleratedTestDeployments,
60
62
  options.json,
61
63
  initialValidators,
@@ -2,3 +2,4 @@ export * from './commands.js';
2
2
  export * from './aztec.js';
3
3
  export * from './encoding.js';
4
4
  export * from './github.js';
5
+ export * from './setup_contracts.js';
@@ -2,12 +2,16 @@ import {
2
2
  DefaultWaitOpts,
3
3
  type EthAddress,
4
4
  FeeJuicePaymentMethod,
5
+ Fr,
5
6
  type PXE,
6
7
  SignerlessWallet,
8
+ SponsoredFeePaymentMethod,
7
9
  type WaitForProvenOpts,
10
+ getContractInstanceFromDeployParams,
8
11
  waitForProven,
9
12
  } from '@aztec/aztec.js';
10
- import { FEE_JUICE_INITIAL_MINT } from '@aztec/constants';
13
+ import { FEE_JUICE_INITIAL_MINT, SPONSORED_FPC_SALT } from '@aztec/constants';
14
+ import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
11
15
  import type { LogFn } from '@aztec/foundation/log';
12
16
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
13
17
  import { Gas } from '@aztec/stdlib/gas';
@@ -52,3 +56,46 @@ export async function setupCanonicalL2FeeJuice(
52
56
  );
53
57
  }
54
58
  }
59
+
60
+ async function getSponsoredFPCContract() {
61
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
62
+ // @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
63
+ const { SponsoredFPCContract } = await import('@aztec/noir-contracts.js/SponsoredFPC');
64
+ return SponsoredFPCContract;
65
+ }
66
+
67
+ export async function getSponsoredFPCAddress() {
68
+ const SponsoredFPCContract = await getSponsoredFPCContract();
69
+ const sponsoredFPCInstance = await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
70
+ salt: new Fr(SPONSORED_FPC_SALT),
71
+ });
72
+ return sponsoredFPCInstance.address;
73
+ }
74
+
75
+ export async function setupSponsoredFPC(
76
+ pxe: PXE,
77
+ log: LogFn,
78
+ waitOpts = DefaultWaitOpts,
79
+ waitForProvenOptions?: WaitForProvenOpts,
80
+ ) {
81
+ const SponsoredFPCContract = await getSponsoredFPCContract();
82
+ const address = await getSponsoredFPCAddress();
83
+ const paymentMethod = new SponsoredFeePaymentMethod(address);
84
+ const { l1ChainId: chainId, protocolVersion } = await pxe.getNodeInfo();
85
+
86
+ const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
87
+
88
+ const deployTx = SponsoredFPCContract.deploy(deployer).send({
89
+ contractAddressSalt: new Fr(SPONSORED_FPC_SALT),
90
+ universalDeploy: true,
91
+ fee: { paymentMethod },
92
+ });
93
+
94
+ const deployed = await deployTx.deployed(waitOpts);
95
+
96
+ if (waitForProvenOptions !== undefined) {
97
+ await waitForProven(pxe, await deployTx.getReceipt(), waitForProvenOptions);
98
+ }
99
+
100
+ log(`SponsoredFPC: ${deployed.address}`);
101
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup_contracts.d.ts","sourceRoot":"","sources":["../../../src/cmds/misc/setup_contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAEf,KAAK,GAAG,EAER,KAAK,iBAAiB,EAEvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,qBAAqB,EAAE,UAAU,EACjC,GAAG,EAAE,KAAK,EACV,QAAQ,qCAAkB,EAC1B,oBAAoB,CAAC,EAAE,iBAAiB,iBA+BzC"}
@@ -1,31 +0,0 @@
1
- import { DefaultWaitOpts, FeeJuicePaymentMethod, SignerlessWallet, waitForProven } from '@aztec/aztec.js';
2
- import { FEE_JUICE_INITIAL_MINT } from '@aztec/constants';
3
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
- import { Gas } from '@aztec/stdlib/gas';
5
- /**
6
- * Deploys the contract to pay for gas on L2.
7
- */ export async function setupCanonicalL2FeeJuice(pxe, feeJuicePortalAddress, log, waitOpts = DefaultWaitOpts, waitForProvenOptions) {
8
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
- // @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
10
- const { FeeJuiceContract } = await import('@aztec/noir-contracts.js/FeeJuice');
11
- const deployer = new SignerlessWallet(pxe);
12
- const feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, deployer);
13
- const portalAddress = await pxe.getPublicStorageAt(feeJuiceContract.address, feeJuiceContract.artifact.storageLayout.portal_address.slot);
14
- if (portalAddress.isZero()) {
15
- log('setupCanonicalL2FeeJuice: Calling initialize on fee juice contract...');
16
- const paymentMethod = new FeeJuicePaymentMethod(ProtocolContractAddress.FeeJuice);
17
- const receipt = await feeJuiceContract.methods.initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT).send({
18
- fee: {
19
- paymentMethod,
20
- gasSettings: {
21
- teardownGasLimits: Gas.empty()
22
- }
23
- }
24
- }).wait(waitOpts);
25
- if (waitForProvenOptions !== undefined) {
26
- await waitForProven(pxe, receipt, waitForProvenOptions);
27
- }
28
- } else {
29
- log('setupCanonicalL2FeeJuice: Fee juice contract already initialized. Fee Juice Portal address: ' + portalAddress.toString());
30
- }
31
- }