@aztec/aztec 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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 (173) hide show
  1. package/dest/bin/index.js +14 -5
  2. package/dest/cli/admin_api_key_store.d.ts +45 -0
  3. package/dest/cli/admin_api_key_store.d.ts.map +1 -0
  4. package/dest/cli/admin_api_key_store.js +98 -0
  5. package/dest/cli/aztec_start_action.d.ts +1 -1
  6. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_action.js +69 -31
  8. package/dest/cli/aztec_start_options.d.ts +2 -2
  9. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  10. package/dest/cli/aztec_start_options.js +53 -48
  11. package/dest/cli/cli.d.ts +1 -1
  12. package/dest/cli/cli.d.ts.map +1 -1
  13. package/dest/cli/cli.js +4 -37
  14. package/dest/cli/cmds/compile.d.ts +4 -0
  15. package/dest/cli/cmds/compile.d.ts.map +1 -0
  16. package/dest/cli/cmds/compile.js +174 -0
  17. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  18. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  19. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  20. package/dest/cli/cmds/profile.d.ts +4 -0
  21. package/dest/cli/cmds/profile.d.ts.map +1 -0
  22. package/dest/cli/cmds/profile.js +8 -0
  23. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  24. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  25. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  26. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  27. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  28. package/dest/cli/cmds/profile_gates.js +76 -0
  29. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  30. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  31. package/dest/cli/cmds/profile_utils.js +50 -0
  32. package/dest/cli/cmds/prover.d.ts +4 -0
  33. package/dest/cli/cmds/prover.d.ts.map +1 -0
  34. package/dest/cli/cmds/prover.js +24 -0
  35. package/dest/cli/cmds/standby.d.ts +56 -0
  36. package/dest/cli/cmds/standby.d.ts.map +1 -0
  37. package/dest/cli/cmds/standby.js +140 -0
  38. package/dest/cli/cmds/start_bot.d.ts +3 -3
  39. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  40. package/dest/cli/cmds/start_bot.js +18 -10
  41. package/dest/cli/cmds/start_node.d.ts +3 -2
  42. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  43. package/dest/cli/cmds/start_node.js +83 -52
  44. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  45. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  46. package/dest/cli/cmds/start_p2p_bootstrap.js +2 -3
  47. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  48. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  49. package/dest/cli/cmds/start_prover_agent.js +8 -20
  50. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  51. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  52. package/dest/cli/cmds/start_prover_broker.js +25 -16
  53. package/dest/cli/cmds/start_txe.d.ts +2 -2
  54. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  55. package/dest/cli/cmds/start_txe.js +6 -5
  56. package/dest/cli/cmds/utils/artifacts.d.ts +26 -0
  57. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  58. package/dest/cli/cmds/utils/artifacts.js +24 -0
  59. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  60. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  61. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  62. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  63. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  64. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  65. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  66. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  67. package/dest/cli/cmds/utils/spawn.js +16 -0
  68. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  69. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  70. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  71. package/dest/cli/util.d.ts +14 -20
  72. package/dest/cli/util.d.ts.map +1 -1
  73. package/dest/cli/util.js +38 -101
  74. package/dest/examples/token.js +12 -12
  75. package/dest/examples/util.d.ts +2 -2
  76. package/dest/examples/util.d.ts.map +1 -1
  77. package/dest/local-network/auth_registry.d.ts +5 -0
  78. package/dest/local-network/auth_registry.d.ts.map +1 -0
  79. package/dest/local-network/auth_registry.js +17 -0
  80. package/dest/local-network/banana_fpc.d.ts +3 -2
  81. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  82. package/dest/local-network/banana_fpc.js +14 -10
  83. package/dest/local-network/local-network.d.ts +18 -41
  84. package/dest/local-network/local-network.d.ts.map +1 -1
  85. package/dest/local-network/local-network.js +98 -76
  86. package/dest/testing/cheat_codes.d.ts +19 -23
  87. package/dest/testing/cheat_codes.d.ts.map +1 -1
  88. package/dest/testing/cheat_codes.js +17 -43
  89. package/dest/testing/epoch_test_settler.d.ts +19 -0
  90. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  91. package/dest/testing/epoch_test_settler.js +42 -0
  92. package/dest/testing/index.d.ts +4 -2
  93. package/dest/testing/index.d.ts.map +1 -1
  94. package/dest/testing/index.js +3 -1
  95. package/dest/testing/local-network.d.ts +51 -0
  96. package/dest/testing/local-network.d.ts.map +1 -0
  97. package/dest/testing/local-network.js +60 -0
  98. package/dest/testing/token_allowed_setup.d.ts +12 -0
  99. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  100. package/dest/testing/token_allowed_setup.js +24 -0
  101. package/package.json +36 -33
  102. package/scripts/add_crate.sh +53 -0
  103. package/scripts/aztec.sh +26 -9
  104. package/scripts/init.sh +23 -19
  105. package/scripts/new.sh +48 -24
  106. package/scripts/setup_workspace.sh +69 -0
  107. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  108. package/scripts/templates/blank/contract/src/main.nr +10 -0
  109. package/scripts/templates/blank/test/Nargo.toml +7 -0
  110. package/scripts/templates/blank/test/src/lib.nr +11 -0
  111. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  112. package/scripts/templates/counter/contract/src/main.nr +48 -0
  113. package/scripts/templates/counter/test/Nargo.toml +7 -0
  114. package/scripts/templates/counter/test/src/lib.nr +32 -0
  115. package/src/bin/index.ts +15 -5
  116. package/src/cli/admin_api_key_store.ts +128 -0
  117. package/src/cli/aztec_start_action.ts +69 -23
  118. package/src/cli/aztec_start_options.ts +61 -55
  119. package/src/cli/cli.ts +4 -37
  120. package/src/cli/cmds/compile.ts +205 -0
  121. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  122. package/src/cli/cmds/profile.ts +26 -0
  123. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  124. package/src/cli/cmds/profile_gates.ts +84 -0
  125. package/src/cli/cmds/profile_utils.ts +58 -0
  126. package/src/cli/cmds/prover.ts +42 -0
  127. package/src/cli/cmds/standby.ts +184 -0
  128. package/src/cli/cmds/start_bot.ts +18 -12
  129. package/src/cli/cmds/start_node.ts +93 -53
  130. package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
  131. package/src/cli/cmds/start_prover_agent.ts +9 -20
  132. package/src/cli/cmds/start_prover_broker.ts +29 -26
  133. package/src/cli/cmds/start_txe.ts +7 -5
  134. package/src/cli/cmds/utils/artifacts.ts +49 -0
  135. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  136. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  137. package/src/cli/cmds/utils/spawn.ts +16 -0
  138. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  139. package/src/cli/util.ts +41 -120
  140. package/src/examples/token.ts +21 -13
  141. package/src/examples/util.ts +1 -1
  142. package/src/local-network/auth_registry.ts +19 -0
  143. package/src/local-network/banana_fpc.ts +17 -9
  144. package/src/local-network/local-network.ts +124 -111
  145. package/src/testing/cheat_codes.ts +18 -49
  146. package/src/testing/epoch_test_settler.ts +47 -0
  147. package/src/testing/index.ts +3 -1
  148. package/src/testing/local-network.ts +97 -0
  149. package/src/testing/token_allowed_setup.ts +26 -0
  150. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  151. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  152. package/dest/cli/cmds/start_archiver.js +0 -50
  153. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  154. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  155. package/dest/cli/cmds/start_blob_sink.js +0 -33
  156. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  157. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  158. package/dest/cli/cmds/start_prover_node.js +0 -108
  159. package/dest/cli/release_version.d.ts +0 -2
  160. package/dest/cli/release_version.d.ts.map +0 -1
  161. package/dest/cli/release_version.js +0 -14
  162. package/dest/testing/anvil_test_watcher.d.ts +0 -34
  163. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  164. package/dest/testing/anvil_test_watcher.js +0 -144
  165. package/scripts/compile.sh +0 -44
  166. package/scripts/extract_function.js +0 -47
  167. package/scripts/flamegraph.sh +0 -59
  168. package/scripts/setup_project.sh +0 -31
  169. package/src/cli/cmds/start_archiver.ts +0 -61
  170. package/src/cli/cmds/start_blob_sink.ts +0 -57
  171. package/src/cli/cmds/start_prover_node.ts +0 -124
  172. package/src/cli/release_version.ts +0 -21
  173. package/src/testing/anvil_test_watcher.ts +0 -166
@@ -1,5 +1,5 @@
1
1
  import { EthAddress } from '@aztec/aztec.js/addresses';
2
- import type { ExtendedViemWalletClient } from '@aztec/ethereum';
2
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
3
3
  import { jsonStringify } from '@aztec/foundation/json-rpc';
4
4
 
5
5
  import type { Abi, Narrow } from 'abitype';
@@ -0,0 +1,19 @@
1
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
3
+ import type { Wallet } from '@aztec/aztec.js/wallet';
4
+ import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ export async function publishStandardAuthRegistry(
8
+ wallet: Wallet,
9
+ from: AztecAddress,
10
+ waitOpts?: WaitOpts,
11
+ ): Promise<void> {
12
+ const { instance, contractClass } = await getStandardAuthRegistry();
13
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
14
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
15
+ }
16
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
17
+ await publishInstance(wallet, instance).send({ from, wait: waitOpts });
18
+ }
19
+ }
@@ -1,6 +1,7 @@
1
1
  import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
3
  import type { Wallet } from '@aztec/aztec.js/wallet';
3
- import { Fr } from '@aztec/foundation/fields';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import type { LogFn } from '@aztec/foundation/log';
5
6
  import { FPCContract } from '@aztec/noir-contracts.js/FPC';
6
7
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
@@ -45,16 +46,23 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
45
46
  return (await getBananaFPCInstance(initialAccounts)).address;
46
47
  }
47
48
 
48
- export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
49
+ export async function setupBananaFPC(
50
+ initialAccounts: InitialAccountData[],
51
+ wallet: Wallet,
52
+ log: LogFn,
53
+ waitOpts?: WaitOpts,
54
+ ) {
49
55
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
50
56
  const admin = getBananaAdmin(initialAccounts);
51
- const [bananaCoin, fpc] = await Promise.all([
52
- TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal)
53
- .send({ from: admin, contractAddressSalt: BANANA_COIN_SALT, universalDeploy: true })
54
- .deployed(),
55
- FPCContract.deploy(wallet, bananaCoinAddress, admin)
56
- .send({ from: admin, contractAddressSalt: BANANA_FPC_SALT, universalDeploy: true })
57
- .deployed(),
57
+ const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
58
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
59
+ salt: BANANA_COIN_SALT,
60
+ universalDeploy: true,
61
+ }).send({ from: admin, wait: waitOpts }),
62
+ FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
63
+ from: admin,
64
+ wait: waitOpts,
65
+ }),
58
66
  ]);
59
67
 
60
68
  log(`BananaCoin: ${bananaCoin.address}`);
@@ -1,46 +1,53 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
2
  import { getInitialTestAccountsData } from '@aztec/accounts/testing';
3
- import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
- import { EthAddress } from '@aztec/aztec.js/addresses';
5
- import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
3
+ import { createAztecNodeService } from '@aztec/aztec-node';
4
+ import { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
5
+ import { Fr } from '@aztec/aztec.js/fields';
6
+ import { createLogger } from '@aztec/aztec.js/log';
7
+ import { type BlobClientInterface, createBlobClient } from '@aztec/blob-client/client';
6
8
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
7
- import {
8
- NULL_KEY,
9
- createEthereumChain,
10
- deployL1Contracts,
11
- deployMulticall3,
12
- getL1ContractsConfigEnvVars,
13
- waitForPublicClient,
14
- } from '@aztec/ethereum';
15
- import { EthCheatCodes } from '@aztec/ethereum/test';
9
+ import { waitForPublicClient } from '@aztec/ethereum/client';
10
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
11
+ import { NULL_KEY } from '@aztec/ethereum/constants';
12
+ import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
13
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
16
14
  import { SecretValue } from '@aztec/foundation/config';
17
- import { Fr } from '@aztec/foundation/fields';
18
- import { type LogFn, createLogger } from '@aztec/foundation/log';
15
+ import { EthAddress } from '@aztec/foundation/eth-address';
16
+ import type { LogFn } from '@aztec/foundation/log';
19
17
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
20
18
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
21
19
  import { protocolContractsHash } from '@aztec/protocol-contracts';
22
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
20
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
21
+ import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
22
+ import { TxStatus } from '@aztec/stdlib/tx';
23
+ import type { GenesisData } from '@aztec/stdlib/world-state';
23
24
  import {
24
25
  type TelemetryClient,
25
26
  getConfigEnvVars as getTelemetryClientConfig,
26
27
  initTelemetryClient,
27
28
  } from '@aztec/telemetry-client';
28
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
29
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
30
+ import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
29
31
  import { getGenesisValues } from '@aztec/world-state/testing';
30
32
 
31
- import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
33
+ import type { Hex } from 'viem';
32
34
  import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
33
35
  import { foundry } from 'viem/chains';
34
36
 
35
37
  import { createAccountLogs } from '../cli/util.js';
36
38
  import { DefaultMnemonic } from '../mnemonic.js';
37
- import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
39
+ import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
40
+ import { publishStandardAuthRegistry } from './auth_registry.js';
38
41
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
39
42
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
40
43
 
41
44
  const logger = createLogger('local-network');
42
45
 
43
- const localAnvil = foundry;
46
+ // The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
47
+ // proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
48
+ // pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
49
+ // P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
50
+ const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
44
51
 
45
52
  /**
46
53
  * Function to deploy our L1 contracts to the local network L1
@@ -49,57 +56,40 @@ const localAnvil = foundry;
49
56
  */
50
57
  export async function deployContractsToL1(
51
58
  aztecNodeConfig: AztecNodeConfig,
52
- hdAccount: HDAccount | PrivateKeyAccount,
53
- contractDeployLogger = logger,
59
+ privateKey: Hex,
54
60
  opts: {
55
- assumeProvenThroughBlockNumber?: number;
56
- salt?: number;
57
61
  genesisArchiveRoot?: Fr;
58
62
  feeJuicePortalInitialBalance?: bigint;
59
63
  } = {},
60
- ) {
61
- const chain =
62
- aztecNodeConfig.l1RpcUrls.length > 0
63
- ? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId)
64
- : { chainInfo: localAnvil };
65
-
64
+ ): Promise<L1ContractAddresses> {
66
65
  await waitForPublicClient(aztecNodeConfig);
67
66
 
68
- const l1Contracts = await deployL1Contracts(
69
- aztecNodeConfig.l1RpcUrls,
70
- hdAccount,
71
- chain.chainInfo,
72
- contractDeployLogger,
73
- {
74
- ...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
75
- ...aztecNodeConfig,
76
- vkTreeRoot: getVKTreeRoot(),
77
- protocolContractsHash,
78
- genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
79
- salt: opts.salt,
80
- feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
81
- aztecTargetCommitteeSize: 0, // no committee in local network
82
- slasherFlavor: 'none', // no slashing in local network
83
- realVerifier: false,
84
- },
85
- );
86
-
87
- await deployMulticall3(l1Contracts.l1Client, logger);
88
-
89
- aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
67
+ const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
68
+ ...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
69
+ ...aztecNodeConfig,
70
+ vkTreeRoot: getVKTreeRoot(),
71
+ protocolContractsHash,
72
+ genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
73
+ feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
74
+ aztecTargetCommitteeSize: 0, // no committee in local network
75
+ slasherEnabled: false, // no slashing in local network
76
+ realVerifier: false,
77
+ });
78
+
79
+ Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
90
80
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
91
81
 
92
- return aztecNodeConfig.l1Contracts;
82
+ return l1Contracts.l1ContractAddresses;
93
83
  }
94
84
 
95
85
  /** Local network settings. */
96
86
  export type LocalNetworkConfig = AztecNodeConfig & {
97
87
  /** Mnemonic used to derive the L1 deployer private key.*/
98
88
  l1Mnemonic: string;
99
- /** Salt used to deploy L1 contracts.*/
100
- deployAztecContractsSalt: string;
101
89
  /** Whether to deploy test accounts on local network start.*/
102
90
  testAccounts: boolean;
91
+ /** Override the default per-address fee juice granted at genesis to funded addresses. */
92
+ initialAccountFeeJuice?: Fr;
103
93
  };
104
94
 
105
95
  /**
@@ -116,15 +106,49 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
116
106
  if ((config.l1RpcUrls?.length || 0) > 1) {
117
107
  logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
118
108
  }
119
- const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
109
+
110
+ // The local network deploys a banana FPC with Token contracts, so include Token entries
111
+ // in the setup allowlist so FPC-based fee payments work out of the box.
112
+ const tokenAllowList = await getTokenAllowedSetupFunctions();
113
+
114
+ const envConfig = getConfigEnvVars();
115
+ const aztecNodeConfig: AztecNodeConfig = {
116
+ ...envConfig,
117
+ ...config,
118
+ skipOrphanProposedBlockPruning: true,
119
+ // The local network builds node config from env without a DATA_DIRECTORY, so the validator's
120
+ // local signing protection runs against an ephemeral store. That is acceptable for this dev
121
+ // network; production validators must persist it and fail-fast when the data directory is unset.
122
+ allowEphemeralSigningProtection: config.allowEphemeralSigningProtection ?? true,
123
+ txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
124
+ // The local network runs against anvil with no committee, so it defaults to the deterministic
125
+ // AutomineSequencer, which owns L1 time control (warps the dateProvider and L1 timestamps to slot
126
+ // boundaries as it builds), replacing the deleted AnvilTestWatcher. This remains true when p2p is
127
+ // enabled for local peer testing; local-network is not a mode for connecting to an existing network.
128
+ useAutomineSequencer: config.useAutomineSequencer ?? true,
129
+ // The AutomineSequencer owns epoch proving in the local network — it writes epoch out hashes to
130
+ // the L1 Outbox and advances the proven tip as checkpoints land, through the same serial queue as
131
+ // its builds — replacing the standalone EpochTestSettler that used to race the build loop.
132
+ automineEnableProveEpoch: config.automineEnableProveEpoch ?? true,
133
+ // Defaults for the local network / sandbox; callers (e.g. the CLI) may override. No real proving
134
+ // happens here — the AutomineSequencer synthetically settles epochs. Short epochs let it write out
135
+ // hashes quickly (so users can consume L2-to-L1 messages without a long wait), with a wider
136
+ // proof-submission window so the synthetic settler has headroom before the rollup would prune an
137
+ // unproven checkpoint.
138
+ realProofs: config.realProofs ?? false,
139
+ aztecEpochDuration: config.aztecEpochDuration ?? 4,
140
+ aztecProofSubmissionEpochs: config.aztecProofSubmissionEpochs ?? 2,
141
+ };
120
142
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
121
143
  if (
122
- aztecNodeConfig.publisherPrivateKeys == undefined ||
123
- !aztecNodeConfig.publisherPrivateKeys.length ||
124
- aztecNodeConfig.publisherPrivateKeys[0].getValue() === NULL_KEY
144
+ aztecNodeConfig.sequencerPublisherPrivateKeys == undefined ||
145
+ !aztecNodeConfig.sequencerPublisherPrivateKeys.length ||
146
+ aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY
125
147
  ) {
126
148
  const privKey = hdAccount.getHdKey().privateKey;
127
- aztecNodeConfig.publisherPrivateKeys = [new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const)];
149
+ aztecNodeConfig.sequencerPublisherPrivateKeys = [
150
+ new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const),
151
+ ];
128
152
  }
129
153
  if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
130
154
  const privKey = hdAccount.getHdKey().privateKey;
@@ -137,7 +161,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
137
161
  const initialAccounts = await (async () => {
138
162
  if (config.testAccounts === true || config.testAccounts === undefined) {
139
163
  if (aztecNodeConfig.p2pEnabled) {
140
- userLog(`Not setting up test accounts as we are connecting to a network`);
164
+ userLog(`Not setting up test accounts when p2p is enabled`);
141
165
  } else {
142
166
  userLog(`Setting up test accounts`);
143
167
  return await getInitialTestAccountsData();
@@ -148,64 +172,46 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
148
172
 
149
173
  const bananaFPC = await getBananaFPCAddress(initialAccounts);
150
174
  const sponsoredFPC = await getSponsoredFPCAddress();
151
- const fundedAddresses = initialAccounts.length
152
- ? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC]
153
- : [];
154
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
175
+ const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a));
176
+ const fundedAddresses = [
177
+ ...initialAccounts.map(a => a.address),
178
+ ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
179
+ ...prefundAddresses,
180
+ ];
181
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(
182
+ fundedAddresses,
183
+ config.initialAccountFeeJuice,
184
+ );
155
185
 
156
- let watcher: AnvilTestWatcher | undefined = undefined;
157
186
  const dateProvider = new TestDateProvider();
187
+
158
188
  if (!aztecNodeConfig.p2pEnabled) {
159
- const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
160
- assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
189
+ await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
161
190
  genesisArchiveRoot,
162
- salt: config.deployAztecContractsSalt ? parseInt(config.deployAztecContractsSalt) : undefined,
163
191
  feeJuicePortalInitialBalance: fundingNeeded,
164
192
  });
165
-
166
- const chain =
167
- aztecNodeConfig.l1RpcUrls.length > 0
168
- ? createEthereumChain([l1RpcUrl], aztecNodeConfig.l1ChainId)
169
- : { chainInfo: localAnvil };
170
-
171
- const publicClient = createPublicClient({
172
- chain: chain.chainInfo,
173
- transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
174
- });
175
-
176
- watcher = new AnvilTestWatcher(
177
- new EthCheatCodes([l1RpcUrl], dateProvider),
178
- l1ContractAddresses.rollupAddress,
179
- publicClient,
180
- dateProvider,
181
- );
182
- watcher.setisLocalNetwork(true);
183
- await watcher.start();
184
193
  }
185
194
 
186
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
187
- // Create a local blob sink client inside the local network, no http connectivity
188
- const blobSinkClient = createBlobSinkClient();
189
- const node = await createAztecNode(
190
- aztecNodeConfig,
191
- { telemetry, blobSinkClient, dateProvider },
192
- { prefilledPublicData },
193
- );
195
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
196
+ // Create a local blob client client inside the local network, no http connectivity
197
+ const blobClient = createBlobClient();
198
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
194
199
 
195
200
  if (initialAccounts.length) {
196
- const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
197
- const wallet = await TestWallet.create(node, PXEConfig);
201
+ const wallet = await EmbeddedWallet.create(node, {
202
+ pxeConfig: { proverEnabled: aztecNodeConfig.realProofs },
203
+ ephemeral: true,
204
+ });
198
205
 
199
206
  userLog('Setting up funded test accounts...');
200
- const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
201
- const accountsWithSecrets = accountManagers.map((manager, i) => ({
202
- account: manager,
203
- secretKey: initialAccounts[i].secret,
204
- }));
205
- const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
207
+ const accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccounts);
208
+ const accLogs = await createAccountLogs(accountManagers, wallet);
206
209
  userLog(accLogs.join(''));
207
210
 
208
- await setupBananaFPC(initialAccounts, wallet, userLog);
211
+ userLog('Publishing standard AuthRegistry contract...');
212
+ await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
213
+
214
+ await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
209
215
 
210
216
  userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
211
217
 
@@ -215,7 +221,6 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
215
221
 
216
222
  const stop = async () => {
217
223
  await node.stop();
218
- await watcher?.stop();
219
224
  };
220
225
 
221
226
  return { node, stop };
@@ -227,16 +232,24 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
227
232
  */
228
233
  export async function createAztecNode(
229
234
  config: Partial<AztecNodeConfig> = {},
230
- deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface; dateProvider?: DateProvider } = {},
231
- options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
235
+ deps: {
236
+ telemetry?: TelemetryClient;
237
+ blobClient?: BlobClientInterface;
238
+ dateProvider?: DateProvider;
239
+ proverBroker?: ProvingJobBroker;
240
+ } = {},
241
+ options: { genesis?: GenesisData } = {},
232
242
  ) {
233
243
  // TODO(#12272): will clean this up. This is criminal.
234
- const { l1Contracts, ...rest } = getConfigEnvVars();
244
+ // Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
235
245
  const aztecNodeConfig: AztecNodeConfig = {
236
- ...rest,
246
+ ...getConfigEnvVars(),
237
247
  ...config,
238
- l1Contracts: { ...l1Contracts, ...config.l1Contracts },
239
248
  };
240
- const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
249
+ const node = await createAztecNodeService(
250
+ aztecNodeConfig,
251
+ { ...deps, proverNodeDeps: { broker: deps.proverBroker } },
252
+ options,
253
+ );
241
254
  return node;
242
255
  }
@@ -1,15 +1,10 @@
1
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
- import { BlockNumber } from '@aztec/foundation/branded-types';
3
- import { retryUntil } from '@aztec/foundation/retry';
4
2
  import type { DateProvider } from '@aztec/foundation/timer';
5
- import type { SequencerClient } from '@aztec/sequencer-client';
6
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
+ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
7
4
 
8
5
  /**
9
- * A class that provides utility functions for interacting with the chain.
10
- * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
11
- * they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
12
- * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
6
+ * Wrapper for Aztec Debug API.
7
+ * @deprecated use the AztecNode debug API directly.
13
8
  */
14
9
  export class CheatCodes {
15
10
  constructor(
@@ -29,51 +24,25 @@ export class CheatCodes {
29
24
  }
30
25
 
31
26
  /**
32
- * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
33
- * the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
34
- * by the slot number, which advances in fixed intervals.
35
- * This is useful for testing time-dependent contract behavior.
36
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
37
- * @param node - The Aztec node used to query if a new block has been mined.
38
- * @param targetTimestamp - The target timestamp to warp to (in seconds)
27
+ * Warps the L1 timestamp to at least `targetTimestamp` and mines an L2 block advancing the L2 timestamp to at least
28
+ * the target. Forwards to the node's debug API, which serializes the warp through the automine sequencer queue.
29
+ * @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
30
+ * @param targetTimestamp - The target timestamp to warp to (in seconds).
31
+ * @deprecated Call `node.warpL2TimeAtLeastTo(targetTimestamp)` on the node debug API directly.
39
32
  */
40
- async warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number) {
41
- const currentL2BlockNumber: BlockNumber = await node.getBlockNumber();
42
-
43
- // We warp the L1 timestamp
44
- await this.eth.warp(targetTimestamp, { resetBlockInterval: true });
45
-
46
- // Wait until an L2 block is mined
47
- const sequencer = sequencerClient.getSequencer();
48
- const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
49
- sequencer.updateConfig({ minTxsPerBlock: 0 });
50
-
51
- await retryUntil(
52
- async () => {
53
- const newL2BlockNumber: BlockNumber = await node.getBlockNumber();
54
- return newL2BlockNumber > currentL2BlockNumber;
55
- },
56
- 'new block after warping L2 time',
57
- 36,
58
- 1,
59
- );
60
-
61
- // Restore original minTxsPerBlock
62
- sequencer.updateConfig({ minTxsPerBlock });
33
+ warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number): Promise<void> {
34
+ return node.warpL2TimeAtLeastTo(Number(targetTimestamp));
63
35
  }
64
36
 
65
37
  /**
66
- * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
67
- * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
68
- * number, which advances in fixed intervals.
69
- * This is useful for testing time-dependent contract behavior.
70
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
71
- * @param node - The Aztec node used to query if a new block has been mined.
72
- * @param duration - The duration to advance time by (in seconds)
38
+ * Warps the L1 timestamp forward by at least `duration` seconds and mines an L2 block advancing the L2 timestamp at
39
+ * least by the duration. Forwards to the node's debug API, which serializes the warp through the automine sequencer
40
+ * queue.
41
+ * @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
42
+ * @param duration - The duration to advance time by (in seconds).
43
+ * @deprecated Call `node.warpL2TimeAtLeastBy(duration)` on the node debug API directly.
73
44
  */
74
- async warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number) {
75
- const currentTimestamp = await this.eth.timestamp();
76
- const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
77
- await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
45
+ warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number): Promise<void> {
46
+ return node.warpL2TimeAtLeastBy(Number(duration));
78
47
  }
79
48
  }
@@ -0,0 +1,47 @@
1
+ import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import type { EpochNumber } from '@aztec/foundation/branded-types';
3
+ import type { Logger } from '@aztec/foundation/log';
4
+ import { settleEpochOutbox } from '@aztec/prover-client/test';
5
+ import { EpochMonitor } from '@aztec/prover-node';
6
+ import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
7
+
8
+ export class EpochTestSettler {
9
+ private rollupCheatCodes: RollupCheatCodes;
10
+ private epochMonitor?: EpochMonitor;
11
+
12
+ constructor(
13
+ cheatcodes: EthCheatCodes,
14
+ rollupAddress: EthAddress,
15
+ private l2BlockSource: L2BlockSource,
16
+ private log: Logger,
17
+ private options: { pollingIntervalMs: number; provingDelayMs?: number },
18
+ ) {
19
+ this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, { rollupAddress });
20
+ }
21
+
22
+ async start() {
23
+ const { epochDuration } = await this.rollupCheatCodes.getConfig();
24
+ this.epochMonitor = new EpochMonitor(this.l2BlockSource, { epochDuration: Number(epochDuration) }, this.options);
25
+ this.epochMonitor.start(this);
26
+ }
27
+
28
+ async stop() {
29
+ await this.epochMonitor?.stop();
30
+ }
31
+
32
+ async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
33
+ const lastCheckpoint = await settleEpochOutbox({
34
+ rollupCheatCodes: this.rollupCheatCodes,
35
+ l2BlockSource: this.l2BlockSource,
36
+ epoch,
37
+ log: this.log,
38
+ });
39
+ if (lastCheckpoint !== undefined) {
40
+ await this.rollupCheatCodes.markAsProven(lastCheckpoint);
41
+ } else {
42
+ this.log.warn(`No checkpoint found for epoch ${epoch}`);
43
+ }
44
+
45
+ return true;
46
+ }
47
+ }
@@ -1,3 +1,5 @@
1
- export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
1
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
2
  export { CheatCodes } from './cheat_codes.js';
3
+ export { EpochTestSettler } from './epoch_test_settler.js';
4
+ export { setupLocalNetwork, TEST_FEE_PADDING, type LocalNetwork, type LocalNetworkOptions } from './local-network.js';
5
+ export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
@@ -0,0 +1,97 @@
1
+ import type { AztecNodeService } from '@aztec/aztec-node';
2
+ import type { AztecNodeConfig } from '@aztec/aztec-node/config';
3
+ import type { Fr } from '@aztec/aztec.js/fields';
4
+ import { startAnvil } from '@aztec/ethereum/test';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ import { foundry } from 'viem/chains';
8
+
9
+ import { createLocalNetwork } from '../local-network/local-network.js';
10
+
11
+ /** A running in-process local network: an inline Aztec node backed by its own anvil L1. */
12
+ export interface LocalNetwork extends AsyncDisposable {
13
+ /** Fully-synced Aztec node, ready to serve client requests. */
14
+ node: AztecNodeService;
15
+ /** RPC URL of the spawned anvil instance. */
16
+ l1RpcUrl: string;
17
+ /** Chain id used on L1 (foundry's default 31337). */
18
+ l1ChainId: number;
19
+ /** Stops every process started by the fixture: node and anvil. Also invoked by `await using`. */
20
+ stop: () => Promise<void>;
21
+ }
22
+
23
+ /** Options for {@link setupLocalNetwork}. */
24
+ export interface LocalNetworkOptions {
25
+ /**
26
+ * Addresses that should hold fee juice at genesis. Saves each of these the round-trip of bridging
27
+ * + claiming fee juice before they can pay for gas.
28
+ */
29
+ fundedAddresses?: AztecAddress[];
30
+ /** Override the default per-address genesis fee juice granted to {@link fundedAddresses}. */
31
+ initialAccountFeeJuice?: Fr;
32
+ /** Node config overrides, e.g. `realProofs`, `aztecEpochDuration`, `p2pEnabled`. */
33
+ config?: Partial<AztecNodeConfig>;
34
+ }
35
+
36
+ /**
37
+ * Spin up an in-process local network with the given addresses pre-funded.
38
+ *
39
+ * Each call spawns its own anvil on an OS-assigned random port and runs the Aztec node inline via
40
+ * the same {@link createLocalNetwork} codepath that backs `aztec start --local-network` (with the
41
+ * sandbox account/FPC/token setup skipped). Distinct ports let independent suites run in parallel.
42
+ * The caller must `await result.stop()` in its teardown (or hold the result with `await using`).
43
+ *
44
+ * Requires a Foundry toolchain (`anvil`/`forge`), installed via `aztec-up` or `foundryup`. Binaries
45
+ * are located in the standard install directories or on `PATH`; set `$ANVIL_BIN` / `$FORGE_BIN` to
46
+ * pin specific ones.
47
+ */
48
+ export async function setupLocalNetwork(opts: LocalNetworkOptions = {}): Promise<LocalNetwork> {
49
+ // `--port 0` → anvil binds an ephemeral port that `startAnvil` reads back, so parallel suites
50
+ // never collide on a fixed port.
51
+ const { rpcUrl, stop: stopAnvil } = await startAnvil({ port: 0 });
52
+
53
+ try {
54
+ const { node, stop: stopNode } = await createLocalNetwork(
55
+ {
56
+ ...opts.config,
57
+ l1RpcUrls: [rpcUrl],
58
+ testAccounts: false,
59
+ prefundAddresses: (opts.fundedAddresses ?? []).map(a => a.toString()),
60
+ initialAccountFeeJuice: opts.initialAccountFeeJuice,
61
+ },
62
+ () => {},
63
+ );
64
+
65
+ // Stop the node before anvil (its teardown still talks to L1); the finally guarantees anvil is
66
+ // reaped even if node shutdown throws.
67
+ const stop = async () => {
68
+ try {
69
+ await stopNode();
70
+ } finally {
71
+ await stopAnvil();
72
+ }
73
+ };
74
+
75
+ return {
76
+ node,
77
+ l1RpcUrl: rpcUrl,
78
+ l1ChainId: foundry.id,
79
+ stop,
80
+ [Symbol.asyncDispose]: stop,
81
+ };
82
+ } catch (err) {
83
+ await stopAnvil();
84
+ throw err;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Min-fee padding multiplier for test wallets whose txs may mine well after their fee estimate.
90
+ * The automine sequencer builds one block per tx and advances L1 time in big jumps, and proposer
91
+ * pipelining evolves the fee-asset price across the build/publish gap (~20x observed in CI), so the
92
+ * network's congestion base fee can swing sharply between the wallet's fee estimate and the block
93
+ * the tx actually lands in. The default wallet padding isn't enough and trips
94
+ * `maxFeesPerGas.feePerL2Gas must be >= gasFees.feePerL2Gas`. Apply via
95
+ * `wallet.setMinFeePadding(TEST_FEE_PADDING)` on every test wallet that sends txs.
96
+ */
97
+ export const TEST_FEE_PADDING = 30;