@aztec/aztec 0.0.1-commit.21caa21 → 0.0.1-commit.21ecf947b

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 (80) hide show
  1. package/dest/bin/index.js +5 -2
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +6 -5
  5. package/dest/cli/aztec_start_options.d.ts +1 -1
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +16 -27
  8. package/dest/cli/cli.d.ts +1 -1
  9. package/dest/cli/cli.d.ts.map +1 -1
  10. package/dest/cli/cli.js +5 -37
  11. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  12. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  13. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  14. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  15. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  16. package/dest/cli/cmds/start_archiver.js +11 -13
  17. package/dest/cli/cmds/start_bot.d.ts +3 -3
  18. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  19. package/dest/cli/cmds/start_bot.js +10 -6
  20. package/dest/cli/cmds/start_node.js +6 -4
  21. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  22. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  23. package/dest/cli/cmds/start_p2p_bootstrap.js +2 -3
  24. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  25. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  26. package/dest/cli/cmds/start_prover_agent.js +4 -4
  27. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  28. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  29. package/dest/cli/cmds/start_prover_broker.js +4 -4
  30. package/dest/cli/cmds/start_prover_node.js +2 -2
  31. package/dest/cli/util.d.ts +8 -17
  32. package/dest/cli/util.d.ts.map +1 -1
  33. package/dest/cli/util.js +13 -8
  34. package/dest/examples/token.js +5 -5
  35. package/dest/examples/util.d.ts +2 -2
  36. package/dest/examples/util.d.ts.map +1 -1
  37. package/dest/local-network/banana_fpc.d.ts +1 -1
  38. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  39. package/dest/local-network/banana_fpc.js +3 -3
  40. package/dest/local-network/local-network.d.ts +11 -14
  41. package/dest/local-network/local-network.d.ts.map +1 -1
  42. package/dest/local-network/local-network.js +44 -35
  43. package/dest/testing/anvil_test_watcher.d.ts +2 -2
  44. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  45. package/dest/testing/anvil_test_watcher.js +1 -1
  46. package/dest/testing/cheat_codes.d.ts +3 -1
  47. package/dest/testing/cheat_codes.d.ts.map +1 -1
  48. package/dest/testing/epoch_test_settler.d.ts +19 -0
  49. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  50. package/dest/testing/epoch_test_settler.js +62 -0
  51. package/dest/testing/index.d.ts +2 -1
  52. package/dest/testing/index.d.ts.map +1 -1
  53. package/dest/testing/index.js +1 -0
  54. package/package.json +37 -35
  55. package/scripts/aztec.sh +15 -12
  56. package/src/bin/index.ts +6 -2
  57. package/src/cli/aztec_start_action.ts +5 -4
  58. package/src/cli/aztec_start_options.ts +15 -27
  59. package/src/cli/cli.ts +5 -37
  60. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  61. package/src/cli/cmds/start_archiver.ts +7 -18
  62. package/src/cli/cmds/start_bot.ts +9 -6
  63. package/src/cli/cmds/start_node.ts +4 -4
  64. package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
  65. package/src/cli/cmds/start_prover_agent.ts +4 -12
  66. package/src/cli/cmds/start_prover_broker.ts +7 -3
  67. package/src/cli/cmds/start_prover_node.ts +2 -2
  68. package/src/cli/util.ts +20 -25
  69. package/src/examples/token.ts +5 -7
  70. package/src/examples/util.ts +1 -1
  71. package/src/local-network/banana_fpc.ts +11 -7
  72. package/src/local-network/local-network.ts +71 -77
  73. package/src/testing/anvil_test_watcher.ts +2 -2
  74. package/src/testing/cheat_codes.ts +3 -2
  75. package/src/testing/epoch_test_settler.ts +71 -0
  76. package/src/testing/index.ts +1 -0
  77. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  78. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  79. package/dest/cli/cmds/start_blob_sink.js +0 -33
  80. package/src/cli/cmds/start_blob_sink.ts +0 -57
@@ -2,7 +2,7 @@ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
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
- import { getPublicClient } from '@aztec/ethereum';
5
+ import { getPublicClient } from '@aztec/ethereum/client';
6
6
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
7
7
  import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
8
8
  import type { LogFn } from '@aztec/foundation/log';
@@ -67,7 +67,7 @@ export async function startProverNode(
67
67
  );
68
68
  }
69
69
 
70
- const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
70
+ const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
71
71
 
72
72
  let broker: ProvingJobBroker;
73
73
  if (proverConfig.proverBrokerUrl) {
package/src/cli/util.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  import type { AztecNodeConfig } from '@aztec/aztec-node';
2
- import { EthAddress } from '@aztec/aztec.js/addresses';
3
- import { Fr } from '@aztec/aztec.js/fields';
4
- import { AccountManager } from '@aztec/aztec.js/wallet';
5
- import type { ViemClient } from '@aztec/ethereum';
2
+ import type { AccountManager } from '@aztec/aztec.js/wallet';
3
+ import type { ViemClient } from '@aztec/ethereum/types';
6
4
  import type { ConfigMappingsType } from '@aztec/foundation/config';
5
+ import { EthAddress } from '@aztec/foundation/eth-address';
6
+ import { jsonStringify } from '@aztec/foundation/json-rpc';
7
7
  import { type LogFn, createLogger } from '@aztec/foundation/log';
8
8
  import type { SharedNodeConfig } from '@aztec/node-lib/config';
9
9
  import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
10
- import { UpdateChecker } from '@aztec/stdlib/update-checker';
11
- import { getTelemetryClient } from '@aztec/telemetry-client';
12
- import type { TestWallet } from '@aztec/test-wallet/server';
10
+ import { getTelemetryClient } from '@aztec/telemetry-client/start';
11
+ import type { EmbeddedWallet } from '@aztec/wallets/embedded';
13
12
 
14
13
  import chalk from 'chalk';
15
14
  import type { Command } from 'commander';
@@ -37,7 +36,7 @@ export function shutdown(logFn: LogFn, exitCode: ExitCode, cb?: Array<() => Prom
37
36
 
38
37
  logFn('Shutting down...', { exitCode });
39
38
  if (cb) {
40
- shutdownPromise = Promise.allSettled(cb).then(() => process.exit(exitCode));
39
+ shutdownPromise = Promise.allSettled(cb.map(fn => fn())).then(() => process.exit(exitCode));
41
40
  } else {
42
41
  // synchronously shuts down the process
43
42
  // no need to set shutdownPromise on this branch of the if statement because no more code will be executed
@@ -69,30 +68,19 @@ export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<voi
69
68
  /**
70
69
  * Creates logs for the initial accounts
71
70
  * @param accounts - The initial accounts
72
- * @param wallet - A TestWallet instance to get the registered accounts
71
+ * @param wallet - A EmbeddedWallet instance to get the registered accounts
73
72
  * @returns A string array containing the initial accounts details
74
73
  */
75
- export async function createAccountLogs(
76
- accountsWithSecretKeys: {
77
- /**
78
- * The account object
79
- */
80
- account: AccountManager;
81
- /**
82
- * The secret key of the account
83
- */
84
- secretKey: Fr;
85
- }[],
86
- wallet: TestWallet,
87
- ) {
74
+ export async function createAccountLogs(accountManagers: AccountManager[], wallet: EmbeddedWallet) {
88
75
  const registeredAccounts = await wallet.getAccounts();
89
76
  const accountLogStrings = [`Initial Accounts:\n\n`];
90
- for (const accountWithSecretKey of accountsWithSecretKeys) {
91
- const completeAddress = await accountWithSecretKey.account.getCompleteAddress();
77
+ for (const accountManager of accountManagers) {
78
+ const account = await accountManager.getAccount();
79
+ const completeAddress = account.getCompleteAddress();
92
80
  if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
93
81
  accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
94
82
  accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
95
- accountLogStrings.push(` Secret Key: ${accountWithSecretKey.secretKey.toString()}\n`);
83
+ accountLogStrings.push(` Secret Key: ${account.getSecretKey().toString()}\n`);
96
84
  accountLogStrings.push(
97
85
  ` Master nullifier public key: ${completeAddress.publicKeys.masterNullifierPublicKey.toString()}\n`,
98
86
  );
@@ -312,6 +300,7 @@ export async function setupUpdateMonitor(
312
300
  updateNodeConfig?: (config: object) => Promise<void>,
313
301
  ) {
314
302
  const logger = createLogger('update-check');
303
+ const { UpdateChecker } = await import('@aztec/stdlib/update-checker');
315
304
  const checker = await UpdateChecker.new({
316
305
  baseURL: updatesLocation,
317
306
  publicClient,
@@ -388,3 +377,9 @@ export async function setupUpdateMonitor(
388
377
 
389
378
  checker.start();
390
379
  }
380
+
381
+ export function stringifyConfig(config: object): string {
382
+ return Object.entries(config)
383
+ .map(([key, value]) => `${key}=${jsonStringify(value)}`)
384
+ .join(' ');
385
+ }
@@ -2,7 +2,7 @@ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
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
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
6
6
 
7
7
  const logger = createLogger('example:token');
8
8
 
@@ -19,7 +19,7 @@ const TRANSFER_AMOUNT = 33n;
19
19
  async function main() {
20
20
  logger.info('Running token contract test on HTTP interface.');
21
21
 
22
- const wallet = await TestWallet.create(node);
22
+ const wallet = await EmbeddedWallet.create(node);
23
23
 
24
24
  // During local network setup we deploy a few accounts. Below we add them to our wallet.
25
25
  const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
@@ -32,14 +32,12 @@ async function main() {
32
32
  logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
33
33
 
34
34
  logger.info('Deploying Token...');
35
- const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18)
36
- .send({ from: alice })
37
- .deployed();
35
+ const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({ from: alice });
38
36
  logger.info('Token deployed');
39
37
 
40
38
  // Mint tokens to Alice
41
39
  logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
42
- await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice }).wait();
40
+ await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice });
43
41
 
44
42
  logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
45
43
 
@@ -48,7 +46,7 @@ async function main() {
48
46
 
49
47
  // We will now transfer tokens from Alice to Bob
50
48
  logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
51
- await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice }).wait();
49
+ await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
52
50
 
53
51
  // Check the new balances
54
52
  const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
@@ -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';
@@ -1,6 +1,6 @@
1
1
  import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
2
  import type { Wallet } from '@aztec/aztec.js/wallet';
3
- import { Fr } from '@aztec/foundation/fields';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
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';
@@ -49,12 +49,16 @@ export async function setupBananaFPC(initialAccounts: InitialAccountData[], wall
49
49
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
50
50
  const admin = getBananaAdmin(initialAccounts);
51
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(),
52
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
53
+ from: admin,
54
+ contractAddressSalt: BANANA_COIN_SALT,
55
+ universalDeploy: true,
56
+ }),
57
+ FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
58
+ from: admin,
59
+ contractAddressSalt: BANANA_FPC_SALT,
60
+ universalDeploy: true,
61
+ }),
58
62
  ]);
59
63
 
60
64
  log(`BananaCoin: ${bananaCoin.address}`);
@@ -1,21 +1,20 @@
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 { AztecNodeService } 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';
9
+ import { createEthereumChain } from '@aztec/ethereum/chain';
10
+ import { waitForPublicClient } from '@aztec/ethereum/client';
11
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
12
+ import { NULL_KEY } from '@aztec/ethereum/constants';
13
+ import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
15
14
  import { EthCheatCodes } from '@aztec/ethereum/test';
16
15
  import { SecretValue } from '@aztec/foundation/config';
17
- import { Fr } from '@aztec/foundation/fields';
18
- import { type LogFn, createLogger } from '@aztec/foundation/log';
16
+ import { EthAddress } from '@aztec/foundation/eth-address';
17
+ import type { LogFn } from '@aztec/foundation/log';
19
18
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
20
19
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
21
20
  import { protocolContractsHash } from '@aztec/protocol-contracts';
@@ -25,16 +24,18 @@ import {
25
24
  getConfigEnvVars as getTelemetryClientConfig,
26
25
  initTelemetryClient,
27
26
  } from '@aztec/telemetry-client';
28
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
27
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
28
+ import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
29
29
  import { getGenesisValues } from '@aztec/world-state/testing';
30
30
 
31
- import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
31
+ import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
32
32
  import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
33
33
  import { foundry } from 'viem/chains';
34
34
 
35
35
  import { createAccountLogs } from '../cli/util.js';
36
36
  import { DefaultMnemonic } from '../mnemonic.js';
37
37
  import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
38
+ import { EpochTestSettler } from '../testing/epoch_test_settler.js';
38
39
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
39
40
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
40
41
 
@@ -49,42 +50,25 @@ const localAnvil = foundry;
49
50
  */
50
51
  export async function deployContractsToL1(
51
52
  aztecNodeConfig: AztecNodeConfig,
52
- hdAccount: HDAccount | PrivateKeyAccount,
53
- contractDeployLogger = logger,
53
+ privateKey: Hex,
54
54
  opts: {
55
- assumeProvenThroughBlockNumber?: number;
56
- salt?: number;
57
55
  genesisArchiveRoot?: Fr;
58
56
  feeJuicePortalInitialBalance?: bigint;
59
57
  } = {},
60
58
  ) {
61
- const chain =
62
- aztecNodeConfig.l1RpcUrls.length > 0
63
- ? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId)
64
- : { chainInfo: localAnvil };
65
-
66
59
  await waitForPublicClient(aztecNodeConfig);
67
60
 
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);
61
+ const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
62
+ ...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
63
+ ...aztecNodeConfig,
64
+ vkTreeRoot: getVKTreeRoot(),
65
+ protocolContractsHash,
66
+ genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
67
+ feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
68
+ aztecTargetCommitteeSize: 0, // no committee in local network
69
+ slasherFlavor: 'none', // no slashing in local network
70
+ realVerifier: false,
71
+ });
88
72
 
89
73
  aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
90
74
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
@@ -96,8 +80,6 @@ export async function deployContractsToL1(
96
80
  export type LocalNetworkConfig = AztecNodeConfig & {
97
81
  /** Mnemonic used to derive the L1 deployer private key.*/
98
82
  l1Mnemonic: string;
99
- /** Salt used to deploy L1 contracts.*/
100
- deployAztecContractsSalt: string;
101
83
  /** Whether to deploy test accounts on local network start.*/
102
84
  testAccounts: boolean;
103
85
  };
@@ -116,7 +98,11 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
116
98
  if ((config.l1RpcUrls?.length || 0) > 1) {
117
99
  logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
118
100
  }
119
- const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
101
+
102
+ const aztecNodeConfig: AztecNodeConfig = {
103
+ ...getConfigEnvVars(),
104
+ ...config,
105
+ };
120
106
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
121
107
  if (
122
108
  aztecNodeConfig.publisherPrivateKeys == undefined ||
@@ -153,15 +139,20 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
153
139
  : [];
154
140
  const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
155
141
 
156
- let watcher: AnvilTestWatcher | undefined = undefined;
157
142
  const dateProvider = new TestDateProvider();
143
+
144
+ let cheatcodes: EthCheatCodes | undefined;
145
+ let rollupAddress: EthAddress | undefined;
146
+ let watcher: AnvilTestWatcher | undefined;
158
147
  if (!aztecNodeConfig.p2pEnabled) {
159
- const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
160
- assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
161
- genesisArchiveRoot,
162
- salt: config.deployAztecContractsSalt ? parseInt(config.deployAztecContractsSalt) : undefined,
163
- feeJuicePortalInitialBalance: fundingNeeded,
164
- });
148
+ ({ rollupAddress } = await deployContractsToL1(
149
+ aztecNodeConfig,
150
+ aztecNodeConfig.validatorPrivateKeys.getValue()[0],
151
+ {
152
+ genesisArchiveRoot,
153
+ feeJuicePortalInitialBalance: fundingNeeded,
154
+ },
155
+ ));
165
156
 
166
157
  const chain =
167
158
  aztecNodeConfig.l1RpcUrls.length > 0
@@ -173,36 +164,38 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
173
164
  transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
174
165
  });
175
166
 
176
- watcher = new AnvilTestWatcher(
177
- new EthCheatCodes([l1RpcUrl], dateProvider),
178
- l1ContractAddresses.rollupAddress,
179
- publicClient,
180
- dateProvider,
181
- );
167
+ cheatcodes = new EthCheatCodes([l1RpcUrl], dateProvider);
168
+
169
+ watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
182
170
  watcher.setisLocalNetwork(true);
171
+ watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
172
+
183
173
  await watcher.start();
184
174
  }
185
175
 
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
- );
176
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
177
+ // Create a local blob client client inside the local network, no http connectivity
178
+ const blobClient = createBlobClient();
179
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
180
+
181
+ let epochTestSettler: EpochTestSettler | undefined;
182
+ if (!aztecNodeConfig.p2pEnabled) {
183
+ epochTestSettler = new EpochTestSettler(
184
+ cheatcodes!,
185
+ rollupAddress!,
186
+ node.getBlockSource(),
187
+ logger.createChild('epoch-settler'),
188
+ { pollingIntervalMs: 200 },
189
+ );
190
+ await epochTestSettler.start();
191
+ }
194
192
 
195
193
  if (initialAccounts.length) {
196
- const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
197
- const wallet = await TestWallet.create(node, PXEConfig);
194
+ const wallet = await EmbeddedWallet.create(node, { pxeConfig: { proverEnabled: aztecNodeConfig.realProofs } });
198
195
 
199
196
  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);
197
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
198
+ const accLogs = await createAccountLogs(accountManagers, wallet);
206
199
  userLog(accLogs.join(''));
207
200
 
208
201
  await setupBananaFPC(initialAccounts, wallet, userLog);
@@ -216,6 +209,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
216
209
  const stop = async () => {
217
210
  await node.stop();
218
211
  await watcher?.stop();
212
+ await epochTestSettler?.stop();
219
213
  };
220
214
 
221
215
  return { node, stop };
@@ -227,7 +221,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
227
221
  */
228
222
  export async function createAztecNode(
229
223
  config: Partial<AztecNodeConfig> = {},
230
- deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface; dateProvider?: DateProvider } = {},
224
+ deps: { telemetry?: TelemetryClient; blobClient?: BlobClientInterface; dateProvider?: DateProvider } = {},
231
225
  options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
232
226
  ) {
233
227
  // TODO(#12272): will clean this up. This is criminal.
@@ -1,5 +1,5 @@
1
- import type { ViemClient } from '@aztec/ethereum';
2
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import type { ViemClient } from '@aztec/ethereum/types';
3
3
  import { SlotNumber } from '@aztec/foundation/branded-types';
4
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { type Logger, createLogger } from '@aztec/foundation/log';
@@ -125,7 +125,7 @@ export class AnvilTestWatcher {
125
125
  async warpTimeIfNeeded() {
126
126
  try {
127
127
  const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
128
- const pendingCheckpointNumber = BigInt(await this.rollup.read.getPendingCheckpointNumber());
128
+ const pendingCheckpointNumber = await this.rollup.read.getPendingCheckpointNumber();
129
129
  const checkpointLog = await this.rollup.read.getCheckpoint([pendingCheckpointNumber]);
130
130
  const nextSlot = SlotNumber(currentSlot + 1);
131
131
  const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]));
@@ -1,4 +1,5 @@
1
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
3
  import { retryUntil } from '@aztec/foundation/retry';
3
4
  import type { DateProvider } from '@aztec/foundation/timer';
4
5
  import type { SequencerClient } from '@aztec/sequencer-client';
@@ -37,7 +38,7 @@ export class CheatCodes {
37
38
  * @param targetTimestamp - The target timestamp to warp to (in seconds)
38
39
  */
39
40
  async warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number) {
40
- const currentL2BlockNumber = await node.getBlockNumber();
41
+ const currentL2BlockNumber: BlockNumber = await node.getBlockNumber();
41
42
 
42
43
  // We warp the L1 timestamp
43
44
  await this.eth.warp(targetTimestamp, { resetBlockInterval: true });
@@ -49,7 +50,7 @@ export class CheatCodes {
49
50
 
50
51
  await retryUntil(
51
52
  async () => {
52
- const newL2BlockNumber = await node.getBlockNumber();
53
+ const newL2BlockNumber: BlockNumber = await node.getBlockNumber();
53
54
  return newL2BlockNumber > currentL2BlockNumber;
54
55
  },
55
56
  'new block after warping L2 time',
@@ -0,0 +1,71 @@
1
+ import { Fr } from '@aztec/aztec.js/fields';
2
+ import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
+ import type { Logger } from '@aztec/foundation/log';
5
+ import { EpochMonitor } from '@aztec/prover-node';
6
+ import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
7
+ import { computeL2ToL1MembershipWitnessFromMessagesInEpoch } from '@aztec/stdlib/messaging';
8
+
9
+ export class EpochTestSettler {
10
+ private rollupCheatCodes: RollupCheatCodes;
11
+ private epochMonitor?: EpochMonitor;
12
+
13
+ constructor(
14
+ cheatcodes: EthCheatCodes,
15
+ rollupAddress: EthAddress,
16
+ private l2BlockSource: L2BlockSource,
17
+ private log: Logger,
18
+ private options: { pollingIntervalMs: number; provingDelayMs?: number },
19
+ ) {
20
+ this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, { rollupAddress });
21
+ }
22
+
23
+ async start() {
24
+ const { epochDuration } = await this.rollupCheatCodes.getConfig();
25
+ this.epochMonitor = new EpochMonitor(this.l2BlockSource, { epochDuration: Number(epochDuration) }, this.options);
26
+ this.epochMonitor.start(this);
27
+ }
28
+
29
+ async stop() {
30
+ await this.epochMonitor?.stop();
31
+ }
32
+
33
+ async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
34
+ const checkpointedBlocks = await this.l2BlockSource.getCheckpointedBlocksForEpoch(epoch);
35
+ const blocks = checkpointedBlocks.map(b => b.block);
36
+ this.log.info(
37
+ `Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`,
38
+ { blocks: blocks.map(b => b.toBlockInfo()) },
39
+ );
40
+ const messagesInEpoch: Fr[][][][] = [];
41
+ let previousSlotNumber = SlotNumber.ZERO;
42
+ let checkpointIndex = -1;
43
+
44
+ for (const block of blocks) {
45
+ const slotNumber = block.header.globalVariables.slotNumber;
46
+ if (slotNumber !== previousSlotNumber) {
47
+ checkpointIndex++;
48
+ messagesInEpoch[checkpointIndex] = [];
49
+ previousSlotNumber = slotNumber;
50
+ }
51
+ messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
52
+ }
53
+
54
+ const [firstMessage] = messagesInEpoch.flat(3);
55
+ if (firstMessage) {
56
+ const { root: outHash } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, firstMessage);
57
+ await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
58
+ } else {
59
+ this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
60
+ }
61
+
62
+ const lastCheckpoint = checkpointedBlocks.at(-1)?.checkpointNumber;
63
+ if (lastCheckpoint !== undefined) {
64
+ await this.rollupCheatCodes.markAsProven(lastCheckpoint);
65
+ } else {
66
+ this.log.warn(`No checkpoint found for epoch ${epoch}`);
67
+ }
68
+
69
+ return true;
70
+ }
71
+ }
@@ -1,3 +1,4 @@
1
1
  export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
2
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
3
  export { CheatCodes } from './cheat_codes.js';
4
+ export { EpochTestSettler } from './epoch_test_settler.js';
@@ -1,3 +0,0 @@
1
- import type { LogFn } from '@aztec/foundation/log';
2
- export declare function startBlobSink(options: any, signalHandlers: (() => Promise<void>)[], userLog: LogFn): Promise<void>;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYmxvYl9zaW5rLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfYmxvYl9zaW5rLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBS25ELHdCQUFzQixhQUFhLENBQUMsT0FBTyxFQUFFLEdBQUcsRUFBRSxjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQUUsT0FBTyxFQUFFLEtBQUssaUJBNEN4RyJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"start_blob_sink.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_blob_sink.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,wBAAsB,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,iBA4CxG"}
@@ -1,33 +0,0 @@
1
- import { blobSinkConfigMappings, createBlobSinkServer, getBlobSinkConfigFromEnv } from '@aztec/blob-sink/server';
2
- import { getL1Config } from '@aztec/cli/config';
3
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
4
- import { extractRelevantOptions } from '../util.js';
5
- export async function startBlobSink(options, signalHandlers, userLog) {
6
- if (options.prover || options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
7
- userLog(`Starting a blob sink with --node, --sequencer, --pxe, --p2p-bootstrap, --prover or --txe is not supported.`);
8
- process.exit(1);
9
- }
10
- let blobSinkConfig = {
11
- ...getBlobSinkConfigFromEnv(),
12
- ...extractRelevantOptions(options, blobSinkConfigMappings, 'blobSink')
13
- };
14
- if (!blobSinkConfig.l1Contracts?.registryAddress || blobSinkConfig.l1Contracts.registryAddress.isZero()) {
15
- throw new Error('REGISTRY_CONTRACT_ADDRESS not set');
16
- }
17
- if (!blobSinkConfig.l1RpcUrls || blobSinkConfig.l1RpcUrls.length === 0) {
18
- throw new Error('ETHEREUM_HOSTS not set');
19
- }
20
- if (typeof blobSinkConfig.l1ChainId !== 'number') {
21
- throw new Error('L1_CHAIN_ID');
22
- }
23
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
24
- const { config: chainConfig, addresses } = await getL1Config(blobSinkConfig.l1Contracts.registryAddress, blobSinkConfig.l1RpcUrls, blobSinkConfig.l1ChainId, blobSinkConfig.rollupVersion);
25
- blobSinkConfig = {
26
- ...blobSinkConfig,
27
- l1Contracts: addresses,
28
- ...chainConfig
29
- };
30
- const blobSink = await createBlobSinkServer(blobSinkConfig, telemetry);
31
- signalHandlers.push(blobSink.stop.bind(blobSink));
32
- await blobSink.start();
33
- }
@@ -1,57 +0,0 @@
1
- import {
2
- type BlobSinkConfig,
3
- blobSinkConfigMappings,
4
- createBlobSinkServer,
5
- getBlobSinkConfigFromEnv,
6
- } from '@aztec/blob-sink/server';
7
- import { getL1Config } from '@aztec/cli/config';
8
- import type { LogFn } from '@aztec/foundation/log';
9
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
10
-
11
- import { extractRelevantOptions } from '../util.js';
12
-
13
- export async function startBlobSink(options: any, signalHandlers: (() => Promise<void>)[], userLog: LogFn) {
14
- if (options.prover || options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
15
- userLog(
16
- `Starting a blob sink with --node, --sequencer, --pxe, --p2p-bootstrap, --prover or --txe is not supported.`,
17
- );
18
- process.exit(1);
19
- }
20
-
21
- let blobSinkConfig: BlobSinkConfig = {
22
- ...getBlobSinkConfigFromEnv(), // get default config from env
23
- ...extractRelevantOptions<BlobSinkConfig>(options, blobSinkConfigMappings, 'blobSink'), // override with command line options
24
- };
25
-
26
- if (!blobSinkConfig.l1Contracts?.registryAddress || blobSinkConfig.l1Contracts.registryAddress.isZero()) {
27
- throw new Error('REGISTRY_CONTRACT_ADDRESS not set');
28
- }
29
-
30
- if (!blobSinkConfig.l1RpcUrls || blobSinkConfig.l1RpcUrls.length === 0) {
31
- throw new Error('ETHEREUM_HOSTS not set');
32
- }
33
-
34
- if (typeof blobSinkConfig.l1ChainId !== 'number') {
35
- throw new Error('L1_CHAIN_ID');
36
- }
37
-
38
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
39
-
40
- const { config: chainConfig, addresses } = await getL1Config(
41
- blobSinkConfig.l1Contracts.registryAddress,
42
- blobSinkConfig.l1RpcUrls,
43
- blobSinkConfig.l1ChainId,
44
- blobSinkConfig.rollupVersion,
45
- );
46
-
47
- blobSinkConfig = {
48
- ...blobSinkConfig,
49
- l1Contracts: addresses,
50
- ...chainConfig,
51
- };
52
-
53
- const blobSink = await createBlobSinkServer(blobSinkConfig, telemetry);
54
- signalHandlers.push(blobSink.stop.bind(blobSink));
55
-
56
- await blobSink.start();
57
- }