@aztec/aztec 2.1.0-rc.9 → 3.0.0-devnet.2

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 (71) hide show
  1. package/dest/bin/index.js +4 -6
  2. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  3. package/dest/cli/aztec_start_action.js +2 -14
  4. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  5. package/dest/cli/aztec_start_options.js +2 -8
  6. package/dest/cli/cmds/start_archiver.js +2 -2
  7. package/dest/cli/cmds/start_bot.d.ts +3 -6
  8. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  9. package/dest/cli/cmds/start_bot.js +13 -17
  10. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  11. package/dest/cli/cmds/start_node.js +8 -16
  12. package/dest/cli/cmds/start_prover_node.js +3 -3
  13. package/dest/cli/util.d.ts +6 -4
  14. package/dest/cli/util.d.ts.map +1 -1
  15. package/dest/cli/util.js +4 -4
  16. package/dest/cli/versioning.js +3 -3
  17. package/dest/examples/token.js +18 -16
  18. package/dest/examples/util.d.ts +1 -1
  19. package/dest/examples/util.d.ts.map +1 -1
  20. package/dest/examples/util.js +1 -1
  21. package/dest/index.d.ts +1 -1
  22. package/dest/index.d.ts.map +1 -1
  23. package/dest/index.js +1 -1
  24. package/dest/sandbox/banana_fpc.d.ts +4 -5
  25. package/dest/sandbox/banana_fpc.d.ts.map +1 -1
  26. package/dest/sandbox/banana_fpc.js +14 -18
  27. package/dest/sandbox/index.d.ts +2 -2
  28. package/dest/sandbox/index.d.ts.map +1 -1
  29. package/dest/sandbox/index.js +2 -2
  30. package/dest/sandbox/sandbox.d.ts +2 -12
  31. package/dest/sandbox/sandbox.d.ts.map +1 -1
  32. package/dest/sandbox/sandbox.js +19 -32
  33. package/dest/sandbox/sponsored_fpc.d.ts +3 -3
  34. package/dest/sandbox/sponsored_fpc.d.ts.map +1 -1
  35. package/dest/sandbox/sponsored_fpc.js +7 -8
  36. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  37. package/dest/testing/anvil_test_watcher.js +3 -4
  38. package/dest/testing/cheat_codes.d.ts +6 -7
  39. package/dest/testing/cheat_codes.d.ts.map +1 -1
  40. package/dest/testing/cheat_codes.js +9 -10
  41. package/dest/testing/index.d.ts +0 -1
  42. package/dest/testing/index.d.ts.map +1 -1
  43. package/dest/testing/index.js +0 -1
  44. package/package.json +33 -33
  45. package/src/bin/index.ts +4 -6
  46. package/src/cli/aztec_start_action.ts +2 -11
  47. package/src/cli/aztec_start_options.ts +2 -8
  48. package/src/cli/cmds/start_archiver.ts +2 -2
  49. package/src/cli/cmds/start_bot.ts +22 -13
  50. package/src/cli/cmds/start_node.ts +11 -12
  51. package/src/cli/cmds/start_prover_node.ts +3 -3
  52. package/src/cli/util.ts +8 -6
  53. package/src/cli/versioning.ts +3 -3
  54. package/src/examples/token.ts +20 -17
  55. package/src/examples/util.ts +1 -1
  56. package/src/index.ts +3 -3
  57. package/src/sandbox/banana_fpc.ts +15 -20
  58. package/src/sandbox/index.ts +5 -2
  59. package/src/sandbox/sandbox.ts +21 -32
  60. package/src/sandbox/sponsored_fpc.ts +8 -10
  61. package/src/testing/anvil_test_watcher.ts +2 -5
  62. package/src/testing/cheat_codes.ts +10 -11
  63. package/src/testing/index.ts +0 -1
  64. package/dest/cli/cmds/start_pxe.d.ts +0 -16
  65. package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
  66. package/dest/cli/cmds/start_pxe.js +0 -31
  67. package/dest/testing/aztec_cheat_codes.d.ts +0 -59
  68. package/dest/testing/aztec_cheat_codes.d.ts.map +0 -1
  69. package/dest/testing/aztec_cheat_codes.js +0 -62
  70. package/src/cli/cmds/start_pxe.ts +0 -49
  71. package/src/testing/aztec_cheat_codes.ts +0 -77
@@ -1,19 +1,21 @@
1
- import { getInitialTestAccounts } from '@aztec/accounts/testing';
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
2
  import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
3
- import { Fr } from '@aztec/aztec.js';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
4
  import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
5
5
  import { getL1Config } from '@aztec/cli/config';
6
6
  import { getPublicClient } from '@aztec/ethereum';
7
7
  import { SecretValue } from '@aztec/foundation/config';
8
8
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
9
9
  import type { LogFn } from '@aztec/foundation/log';
10
- import { AztecNodeAdminApiSchema, AztecNodeApiSchema, type PXE } from '@aztec/stdlib/interfaces/client';
10
+ import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
11
+ import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
11
12
  import { P2PApiSchema } from '@aztec/stdlib/interfaces/server';
12
13
  import {
13
14
  type TelemetryClientConfig,
14
15
  initTelemetryClient,
15
16
  telemetryClientConfigMappings,
16
17
  } from '@aztec/telemetry-client';
18
+ import { TestWallet } from '@aztec/test-wallet/server';
17
19
  import { getGenesisValues } from '@aztec/world-state/testing';
18
20
 
19
21
  import { createAztecNode } from '../../sandbox/index.js';
@@ -50,7 +52,7 @@ export async function startNode(
50
52
 
51
53
  await preloadCrsDataForVerifying(nodeConfig, userLog);
52
54
 
53
- const testAccounts = nodeConfig.testAccounts ? (await getInitialTestAccounts()).map(a => a.address) : [];
55
+ const testAccounts = nodeConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
54
56
  const sponsoredFPCAccounts = nodeConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
55
57
  const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
56
58
 
@@ -128,17 +130,14 @@ export async function startNode(
128
130
  // Add node stop function to signal handlers
129
131
  signalHandlers.push(node.stop.bind(node));
130
132
 
131
- // Add a PXE client that connects to this node if requested
132
- let pxe: PXE | undefined;
133
- if (options.pxe) {
134
- const { addPXE } = await import('./start_pxe.js');
135
- ({ pxe } = await addPXE(options, signalHandlers, services, userLog, { node }));
136
- }
137
-
138
133
  // Add a txs bot if requested
139
134
  if (options.bot) {
140
135
  const { addBot } = await import('./start_bot.js');
141
- await addBot(options, signalHandlers, services, { pxe, node, telemetry });
136
+
137
+ const pxeConfig = extractRelevantOptions<PXEConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
138
+ const wallet = await TestWallet.create(node, pxeConfig);
139
+
140
+ await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
142
141
  }
143
142
 
144
143
  if (nodeConfig.autoUpdate !== 'disabled' && nodeConfig.autoUpdateUrl) {
@@ -1,5 +1,5 @@
1
- import { getInitialTestAccounts } from '@aztec/accounts/testing';
2
- import { Fr } from '@aztec/aztec.js';
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
3
  import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
4
4
  import { getL1Config } from '@aztec/cli/config';
5
5
  import { getPublicClient } from '@aztec/ethereum';
@@ -52,7 +52,7 @@ export async function startProverNode(
52
52
  proverConfig.l1Contracts = addresses;
53
53
  proverConfig = { ...proverConfig, ...config };
54
54
 
55
- const testAccounts = proverConfig.testAccounts ? (await getInitialTestAccounts()).map(a => a.address) : [];
55
+ const testAccounts = proverConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
56
56
  const sponsoredFPCAccounts = proverConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
57
57
  const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
58
58
 
package/src/cli/util.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import type { AztecNodeConfig } from '@aztec/aztec-node';
2
- import type { AccountManager, EthAddress, Fr } from '@aztec/aztec.js';
2
+ import { EthAddress } from '@aztec/aztec.js/addresses';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import { AccountManager } from '@aztec/aztec.js/wallet';
3
5
  import type { ViemClient } from '@aztec/ethereum';
4
6
  import type { ConfigMappingsType } from '@aztec/foundation/config';
5
7
  import { type LogFn, createLogger } from '@aztec/foundation/log';
6
8
  import type { SharedNodeConfig } from '@aztec/node-lib/config';
7
- import type { PXEService } from '@aztec/pxe/server';
8
9
  import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
9
10
  import { UpdateChecker } from '@aztec/stdlib/update-checker';
10
11
  import { getTelemetryClient } from '@aztec/telemetry-client';
12
+ import type { TestWallet } from '@aztec/test-wallet/server';
11
13
 
12
14
  import chalk from 'chalk';
13
15
  import type { Command } from 'commander';
@@ -67,7 +69,7 @@ export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<voi
67
69
  /**
68
70
  * Creates logs for the initial accounts
69
71
  * @param accounts - The initial accounts
70
- * @param pxe - A PXE instance to get the registered accounts
72
+ * @param wallet - A TestWallet instance to get the registered accounts
71
73
  * @returns A string array containing the initial accounts details
72
74
  */
73
75
  export async function createAccountLogs(
@@ -81,13 +83,13 @@ export async function createAccountLogs(
81
83
  */
82
84
  secretKey: Fr;
83
85
  }[],
84
- pxe: PXEService,
86
+ wallet: TestWallet,
85
87
  ) {
86
- const registeredAccounts = await pxe.getRegisteredAccounts();
88
+ const registeredAccounts = await wallet.getAccounts();
87
89
  const accountLogStrings = [`Initial Accounts:\n\n`];
88
90
  for (const accountWithSecretKey of accountsWithSecretKeys) {
89
91
  const completeAddress = await accountWithSecretKey.account.getCompleteAddress();
90
- if (registeredAccounts.find(a => a.equals(completeAddress))) {
92
+ if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
91
93
  accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
92
94
  accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
93
95
  accountLogStrings.push(` Secret Key: ${accountWithSecretKey.secretKey.toString()}\n`);
@@ -1,13 +1,13 @@
1
1
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
2
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
2
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
3
3
  import type { ChainConfig } from '@aztec/stdlib/config';
4
4
  import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
5
5
 
6
6
  export function getVersions(config?: ChainConfig): Partial<ComponentsVersions> {
7
7
  return config
8
- ? getComponentsVersionsFromConfig(config, protocolContractTreeRoot, getVKTreeRoot())
8
+ ? getComponentsVersionsFromConfig(config, protocolContractsHash, getVKTreeRoot())
9
9
  : {
10
10
  l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
11
- l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
11
+ l2ProtocolContractsHash: protocolContractsHash.toString(),
12
12
  };
13
13
  }
@@ -1,13 +1,14 @@
1
- import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing';
2
- import { createPXEClient } from '@aztec/aztec.js';
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import { createAztecNodeClient } from '@aztec/aztec.js/node';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
+ import { TestWallet } from '@aztec/test-wallet/server';
5
6
 
6
7
  const logger = createLogger('example:token');
7
8
 
8
- const url = 'http://localhost:8080';
9
+ const nodeUrl = 'http://localhost:8080';
9
10
 
10
- const pxe = createPXEClient(url);
11
+ const node = createAztecNodeClient(nodeUrl);
11
12
 
12
13
  const ALICE_MINT_BALANCE = 333n;
13
14
  const TRANSFER_AMOUNT = 33n;
@@ -18,40 +19,42 @@ const TRANSFER_AMOUNT = 33n;
18
19
  async function main() {
19
20
  logger.info('Running token contract test on HTTP interface.');
20
21
 
21
- const [aliceWallet, bobWallet] = await getDeployedTestAccountsWallets(pxe);
22
- const alice = aliceWallet.getAddress();
23
- const bob = bobWallet.getAddress();
22
+ const wallet = await TestWallet.create(node);
23
+
24
+ // During sandbox setup we deploy a few accounts. Below we add them to our wallet.
25
+ const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
26
+ await wallet.createSchnorrAccount(aliceInitialAccountData.secret, aliceInitialAccountData.salt);
27
+ await wallet.createSchnorrAccount(bobInitialAccountData.secret, bobInitialAccountData.salt);
28
+
29
+ const alice = aliceInitialAccountData.address;
30
+ const bob = bobInitialAccountData.address;
24
31
 
25
32
  logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
26
33
 
27
34
  logger.info('Deploying Token...');
28
- const token = await TokenContract.deploy(aliceWallet, alice, 'TokenName', 'TokenSymbol', 18)
35
+ const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18)
29
36
  .send({ from: alice })
30
37
  .deployed();
31
38
  logger.info('Token deployed');
32
39
 
33
- // Create the contract abstraction and link it to Alice's and Bob's wallet for future signing
34
- const tokenAlice = await TokenContract.at(token.address, aliceWallet);
35
- const tokenBob = await TokenContract.at(token.address, bobWallet);
36
-
37
40
  // Mint tokens to Alice
38
41
  logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
39
- await tokenAlice.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice }).wait();
42
+ await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice }).wait();
40
43
 
41
44
  logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
42
45
 
43
- const balanceAfterMint = await tokenAlice.methods.balance_of_private(alice).simulate({ from: alice });
46
+ const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({ from: alice });
44
47
  logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
45
48
 
46
49
  // We will now transfer tokens from Alice to Bob
47
50
  logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
48
- await tokenAlice.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice }).wait();
51
+ await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice }).wait();
49
52
 
50
53
  // Check the new balances
51
- const aliceBalance = await tokenAlice.methods.balance_of_private(alice).simulate({ from: alice });
54
+ const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
52
55
  logger.info(`Alice's balance ${aliceBalance}`);
53
56
 
54
- const bobBalance = await tokenBob.methods.balance_of_private(bob).simulate({ from: bob });
57
+ const bobBalance = await token.methods.balance_of_private(bob).simulate({ from: bob });
55
58
  logger.info(`Bob's balance ${bobBalance}`);
56
59
  }
57
60
 
@@ -1,4 +1,4 @@
1
- import { EthAddress } from '@aztec/aztec.js';
1
+ import { EthAddress } from '@aztec/aztec.js/addresses';
2
2
  import type { ExtendedViemWalletClient } from '@aztec/ethereum';
3
3
  import { jsonStringify } from '@aztec/foundation/json-rpc';
4
4
 
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export {
2
2
  createSandbox,
3
- getDeployedBananaCoinAddress,
4
- getDeployedBananaFPCAddress,
5
- getDeployedSponsoredFPCAddress,
3
+ registerDeployedBananaCoinInWalletAndGetAddress,
4
+ registerDeployedBananaFPCInWalletAndGetAddress,
5
+ registerDeployedSponsoredFPCInWalletAndGetAddress,
6
6
  } from './sandbox/index.js';
@@ -1,12 +1,11 @@
1
- import { type InitialAccountData, getInitialTestAccounts } from '@aztec/accounts/testing';
2
- import type { Wallet } from '@aztec/aztec.js';
1
+ import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import type { Wallet } from '@aztec/aztec.js/wallet';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
4
  import type { LogFn } from '@aztec/foundation/log';
5
5
  import { FPCContract } from '@aztec/noir-contracts.js/FPC';
6
6
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
7
7
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
8
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
9
- import type { PXE } from '@aztec/stdlib/interfaces/client';
10
9
 
11
10
  const BANANA_COIN_SALT = new Fr(0);
12
11
  const bananaCoinArgs = {
@@ -46,14 +45,14 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
46
45
  return (await getBananaFPCInstance(initialAccounts)).address;
47
46
  }
48
47
 
49
- export async function setupBananaFPC(initialAccounts: InitialAccountData[], deployer: Wallet, log: LogFn) {
48
+ export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
50
49
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
51
50
  const admin = getBananaAdmin(initialAccounts);
52
51
  const [bananaCoin, fpc] = await Promise.all([
53
- TokenContract.deploy(deployer, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal)
52
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal)
54
53
  .send({ from: admin, contractAddressSalt: BANANA_COIN_SALT, universalDeploy: true })
55
54
  .deployed(),
56
- FPCContract.deploy(deployer, bananaCoinAddress, admin)
55
+ FPCContract.deploy(wallet, bananaCoinAddress, admin)
57
56
  .send({ from: admin, contractAddressSalt: BANANA_FPC_SALT, universalDeploy: true })
58
57
  .deployed(),
59
58
  ]);
@@ -62,22 +61,18 @@ export async function setupBananaFPC(initialAccounts: InitialAccountData[], depl
62
61
  log(`FPC: ${fpc.address}`);
63
62
  }
64
63
 
65
- export async function getDeployedBananaCoinAddress(pxe: PXE) {
66
- const initialAccounts = await getInitialTestAccounts();
67
- const bananaCoin = await getBananaCoinAddress(initialAccounts);
68
- const contracts = await pxe.getContracts();
69
- if (!contracts.find(c => c.equals(bananaCoin))) {
70
- throw new Error('BananaCoin not deployed.');
71
- }
72
- return bananaCoin;
64
+ export async function registerDeployedBananaCoinInWalletAndGetAddress(wallet: Wallet) {
65
+ const initialAccounts = await getInitialTestAccountsData();
66
+ const bananaCoin = await getBananaCoinInstance(initialAccounts);
67
+ // The following is no-op if the contract is already registered
68
+ await wallet.registerContract(bananaCoin, TokenContract.artifact);
69
+ return bananaCoin.address;
73
70
  }
74
71
 
75
- export async function getDeployedBananaFPCAddress(pxe: PXE) {
76
- const initialAccounts = await getInitialTestAccounts();
72
+ export async function registerDeployedBananaFPCInWalletAndGetAddress(wallet: Wallet) {
73
+ const initialAccounts = await getInitialTestAccountsData();
77
74
  const fpc = await getBananaFPCInstance(initialAccounts);
78
- const contracts = await pxe.getContracts();
79
- if (!contracts.find(c => c.equals(fpc.address))) {
80
- throw new Error('BananaFPC not deployed.');
81
- }
75
+ // The following is no-op if the contract is already registered
76
+ await wallet.registerContract(fpc, FPCContract.artifact);
82
77
  return fpc.address;
83
78
  }
@@ -1,4 +1,7 @@
1
1
  export * from './sandbox.js';
2
2
 
3
- export { getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './banana_fpc.js';
4
- export { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
3
+ export {
4
+ registerDeployedBananaCoinInWalletAndGetAddress,
5
+ registerDeployedBananaFPCInWalletAndGetAddress,
6
+ } from './banana_fpc.js';
7
+ export { registerDeployedSponsoredFPCInWalletAndGetAddress } from './sponsored_fpc.js';
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
- import { getSchnorrWallet } from '@aztec/accounts/schnorr';
3
- import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
4
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
- import { EthAddress } from '@aztec/aztec.js';
4
+ import { EthAddress } from '@aztec/aztec.js/addresses';
6
5
  import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
7
- import { setupSponsoredFPC } from '@aztec/cli/cli-utils';
8
6
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
9
7
  import {
10
8
  NULL_KEY,
@@ -20,15 +18,14 @@ import { Fr } from '@aztec/foundation/fields';
20
18
  import { type LogFn, createLogger } from '@aztec/foundation/log';
21
19
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
22
20
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
23
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
24
- import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
25
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
21
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
26
22
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
27
23
  import {
28
24
  type TelemetryClient,
29
25
  getConfigEnvVars as getTelemetryClientConfig,
30
26
  initTelemetryClient,
31
27
  } from '@aztec/telemetry-client';
28
+ import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
32
29
  import { getGenesisValues } from '@aztec/world-state/testing';
33
30
 
34
31
  import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
@@ -77,7 +74,7 @@ export async function deployContractsToL1(
77
74
  ...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
78
75
  ...aztecNodeConfig,
79
76
  vkTreeRoot: getVKTreeRoot(),
80
- protocolContractTreeRoot,
77
+ protocolContractsHash,
81
78
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
82
79
  salt: opts.salt,
83
80
  feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
@@ -101,8 +98,6 @@ export type SandboxConfig = AztecNodeConfig & {
101
98
  l1Mnemonic: string;
102
99
  /** Salt used to deploy L1 contracts.*/
103
100
  deployAztecContractsSalt: string;
104
- /** Whether to expose PXE service on sandbox start.*/
105
- noPXE: boolean;
106
101
  /** Whether to deploy test accounts on sandbox start.*/
107
102
  testAccounts: boolean;
108
103
  };
@@ -145,7 +140,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
145
140
  userLog(`Not setting up test accounts as we are connecting to a network`);
146
141
  } else {
147
142
  userLog(`Setting up test accounts`);
148
- return await getInitialTestAccounts();
143
+ return await getInitialTestAccountsData();
149
144
  }
150
145
  }
151
146
  return [];
@@ -179,7 +174,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
179
174
  });
180
175
 
181
176
  watcher = new AnvilTestWatcher(
182
- new EthCheatCodes([l1RpcUrl]),
177
+ new EthCheatCodes([l1RpcUrl], dateProvider),
183
178
  l1ContractAddresses.rollupAddress,
184
179
  publicClient,
185
180
  dateProvider,
@@ -196,22 +191,26 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
196
191
  { telemetry, blobSinkClient, dateProvider },
197
192
  { prefilledPublicData },
198
193
  );
199
- const pxeServiceConfig = { proverEnabled: aztecNodeConfig.realProofs };
200
- const pxe = await createAztecPXE(node, pxeServiceConfig);
201
194
 
202
195
  if (initialAccounts.length) {
196
+ const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
197
+ const wallet = await TestWallet.create(node, PXEConfig);
198
+
203
199
  userLog('Setting up funded test accounts...');
204
- const accounts = await deployFundedSchnorrAccounts(pxe, initialAccounts);
205
- const accountsWithSecrets = accounts.map((account, i) => ({
206
- account,
200
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
201
+ const accountsWithSecrets = accountManagers.map((manager, i) => ({
202
+ account: manager,
207
203
  secretKey: initialAccounts[i].secret,
208
204
  }));
209
- const accLogs = await createAccountLogs(accountsWithSecrets, pxe);
205
+ const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
210
206
  userLog(accLogs.join(''));
211
207
 
212
- const deployer = await getSchnorrWallet(pxe, initialAccounts[0].address, initialAccounts[0].signingKey);
213
- await setupBananaFPC(initialAccounts, deployer, userLog);
214
- await setupSponsoredFPC(pxe, userLog);
208
+ await setupBananaFPC(initialAccounts, wallet, userLog);
209
+
210
+ userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
211
+
212
+ // We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
213
+ await wallet.stop();
215
214
  }
216
215
 
217
216
  const stop = async () => {
@@ -219,7 +218,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
219
218
  await watcher?.stop();
220
219
  };
221
220
 
222
- return { node, pxe, stop };
221
+ return { node, stop };
223
222
  }
224
223
 
225
224
  /**
@@ -241,13 +240,3 @@ export async function createAztecNode(
241
240
  const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
242
241
  return node;
243
242
  }
244
-
245
- /**
246
- * Create and start a new Aztec PXE HTTP Server
247
- * @param config - Optional PXE settings.
248
- */
249
- export async function createAztecPXE(node: AztecNode, config: Partial<PXEServiceConfig> = {}) {
250
- const pxeServiceConfig: PXEServiceConfig = { ...getPXEServiceConfig(), ...config };
251
- const pxe = await createPXEService(node, pxeServiceConfig);
252
- return pxe;
253
- }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  type ContractInstanceWithAddress,
3
- Fr,
4
- type PXE,
5
3
  getContractInstanceFromInstantiationParams,
6
- } from '@aztec/aztec.js';
4
+ } from '@aztec/aztec.js/contracts';
5
+ import { Fr } from '@aztec/aztec.js/fields';
6
+ import type { Wallet } from '@aztec/aztec.js/wallet';
7
7
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
8
8
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
9
9
 
@@ -17,11 +17,9 @@ export async function getSponsoredFPCAddress() {
17
17
  return (await getSponsoredFPCInstance()).address;
18
18
  }
19
19
 
20
- export async function getDeployedSponsoredFPCAddress(pxe: PXE) {
21
- const fpc = await getSponsoredFPCAddress();
22
- const contracts = await pxe.getContracts();
23
- if (!contracts.find(c => c.equals(fpc))) {
24
- throw new Error('SponsoredFPC not deployed.');
25
- }
26
- return fpc;
20
+ export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet) {
21
+ const fpc = await getSponsoredFPCInstance();
22
+ // The following is no-op if the contract is already registered
23
+ await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
24
+ return fpc.address;
27
25
  }
@@ -50,6 +50,7 @@ export class AnvilTestWatcher {
50
50
  }
51
51
 
52
52
  setIsMarkingAsProven(isMarkingAsProven: boolean) {
53
+ this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
53
54
  this.isMarkingAsProven = isMarkingAsProven;
54
55
  }
55
56
 
@@ -132,7 +133,6 @@ export class AnvilTestWatcher {
132
133
  try {
133
134
  await this.cheatcodes.warp(nextSlotTimestamp, {
134
135
  resetBlockInterval: true,
135
- updateDateProvider: this.dateProvider,
136
136
  });
137
137
  } catch (e) {
138
138
  this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
@@ -150,10 +150,7 @@ export class AnvilTestWatcher {
150
150
  const currentTimestamp = this.dateProvider?.now() ?? Date.now();
151
151
  if (currentTimestamp > nextSlotTimestamp * 1000) {
152
152
  try {
153
- await this.cheatcodes.warp(nextSlotTimestamp, {
154
- resetBlockInterval: true,
155
- updateDateProvider: this.dateProvider,
156
- });
153
+ await this.cheatcodes.warp(nextSlotTimestamp, { resetBlockInterval: true });
157
154
  } catch (e) {
158
155
  this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
159
156
  }
@@ -1,31 +1,30 @@
1
- import { retryUntil } from '@aztec/aztec.js';
2
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import { retryUntil } from '@aztec/foundation/retry';
3
+ import type { DateProvider } from '@aztec/foundation/timer';
3
4
  import type { SequencerClient } from '@aztec/sequencer-client';
4
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
5
-
6
- import { AztecCheatCodes } from './aztec_cheat_codes.js';
5
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
6
 
8
7
  /**
9
8
  * A class that provides utility functions for interacting with the chain.
9
+ * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
10
+ * they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
11
+ * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
10
12
  */
11
13
  export class CheatCodes {
12
14
  constructor(
13
15
  /** Cheat codes for L1.*/
14
16
  public eth: EthCheatCodes,
15
- /** Cheat codes for Aztec L2. */
16
- public aztec: AztecCheatCodes,
17
17
  /** Cheat codes for the Aztec Rollup contract on L1. */
18
18
  public rollup: RollupCheatCodes,
19
19
  ) {}
20
20
 
21
- static async create(rpcUrls: string[], pxe: PXE): Promise<CheatCodes> {
22
- const ethCheatCodes = new EthCheatCodes(rpcUrls);
23
- const aztecCheatCodes = new AztecCheatCodes(pxe);
21
+ static async create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes> {
22
+ const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
24
23
  const rollupCheatCodes = new RollupCheatCodes(
25
24
  ethCheatCodes,
26
- await pxe.getNodeInfo().then(n => n.l1ContractAddresses),
25
+ await node.getNodeInfo().then(n => n.l1ContractAddresses),
27
26
  );
28
- return new CheatCodes(ethCheatCodes, aztecCheatCodes, rollupCheatCodes);
27
+ return new CheatCodes(ethCheatCodes, rollupCheatCodes);
29
28
  }
30
29
 
31
30
  /**
@@ -1,4 +1,3 @@
1
1
  export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
2
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
- export { AztecCheatCodes } from './aztec_cheat_codes.js';
4
3
  export { CheatCodes } from './cheat_codes.js';
@@ -1,16 +0,0 @@
1
- import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
2
- import type { LogFn } from '@aztec/foundation/log';
3
- import { type CliPXEOptions, type PXEService, type PXEServiceConfig } from '@aztec/pxe/server';
4
- import { type AztecNode } from '@aztec/stdlib/interfaces/client';
5
- export type { PXEServiceConfig, CliPXEOptions };
6
- export declare function startPXE(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, userLog: LogFn): Promise<{
7
- pxe: PXEService;
8
- config: PXEServiceConfig & CliPXEOptions;
9
- }>;
10
- export declare function addPXE(options: any, _signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, userLog: LogFn, deps?: {
11
- node?: AztecNode;
12
- }): Promise<{
13
- pxe: PXEService;
14
- config: PXEServiceConfig & CliPXEOptions;
15
- }>;
16
- //# sourceMappingURL=start_pxe.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start_pxe.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_pxe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EAGtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,SAAS,EAAoC,MAAM,iCAAiC,CAAC;AAMnG,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;AAEhD,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAAA;CAAE,CAAC,CAExE;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,GAAG,EACZ,eAAe,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACxC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,EACd,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,SAAS,CAAA;CAAO,GAC9B,OAAO,CAAC;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAAA;CAAE,CAAC,CAgBxE"}
@@ -1,31 +0,0 @@
1
- import { allPxeConfigMappings, createPXEService } from '@aztec/pxe/server';
2
- import { PXESchema, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
3
- import { makeTracedFetch } from '@aztec/telemetry-client';
4
- import { extractRelevantOptions } from '../util.js';
5
- import { getVersions } from '../versioning.js';
6
- export async function startPXE(options, signalHandlers, services, userLog) {
7
- return await addPXE(options, signalHandlers, services, userLog, {});
8
- }
9
- export async function addPXE(options, _signalHandlers, services, userLog, deps = {}) {
10
- const pxeConfig = extractRelevantOptions(options, allPxeConfigMappings, 'pxe');
11
- const nodeUrl = pxeConfig.nodeUrl;
12
- if (!nodeUrl && !deps.node) {
13
- userLog('Aztec Node URL (nodeUrl | AZTEC_NODE_URL) option is required to start PXE without --node option');
14
- process.exit(1);
15
- }
16
- const node = deps.node ?? createAztecNodeClient(nodeUrl, getVersions(pxeConfig), makeTracedFetch([
17
- 1,
18
- 2,
19
- 3
20
- ], true));
21
- const pxe = await createPXEService(node, pxeConfig);
22
- // Add PXE to services list
23
- services.pxe = [
24
- pxe,
25
- PXESchema
26
- ];
27
- return {
28
- pxe,
29
- config: pxeConfig
30
- };
31
- }