@aztec/aztec 0.0.1-commit.b655e406 → 0.0.1-commit.c2595eba

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 (116) hide show
  1. package/README.md +1 -1
  2. package/dest/bin/index.d.ts +1 -1
  3. package/dest/bin/index.js +6 -3
  4. package/dest/cli/aztec_start_action.d.ts +1 -1
  5. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  6. package/dest/cli/aztec_start_action.js +14 -13
  7. package/dest/cli/aztec_start_options.d.ts +1 -1
  8. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  9. package/dest/cli/aztec_start_options.js +23 -32
  10. package/dest/cli/cli.d.ts +1 -1
  11. package/dest/cli/cli.d.ts.map +1 -1
  12. package/dest/cli/cli.js +8 -7
  13. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  14. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  15. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  16. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  17. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  18. package/dest/cli/cmds/start_archiver.js +11 -13
  19. package/dest/cli/cmds/start_bot.d.ts +1 -1
  20. package/dest/cli/cmds/start_bot.js +1 -1
  21. package/dest/cli/cmds/start_node.d.ts +1 -1
  22. package/dest/cli/cmds/start_node.js +4 -4
  23. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  24. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  25. package/dest/cli/cmds/start_p2p_bootstrap.js +2 -3
  26. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  27. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  28. package/dest/cli/cmds/start_prover_agent.js +2 -2
  29. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  30. package/dest/cli/cmds/start_prover_broker.js +2 -2
  31. package/dest/cli/cmds/start_prover_node.d.ts +1 -1
  32. package/dest/cli/cmds/start_prover_node.js +2 -2
  33. package/dest/cli/cmds/start_txe.d.ts +1 -1
  34. package/dest/cli/index.d.ts +1 -1
  35. package/dest/cli/preload_crs.d.ts +1 -1
  36. package/dest/cli/release_version.d.ts +1 -1
  37. package/dest/cli/util.d.ts +8 -8
  38. package/dest/cli/util.d.ts.map +1 -1
  39. package/dest/cli/util.js +3 -3
  40. package/dest/cli/versioning.d.ts +1 -1
  41. package/dest/examples/token.d.ts +1 -1
  42. package/dest/examples/token.js +4 -4
  43. package/dest/examples/util.d.ts +2 -2
  44. package/dest/examples/util.d.ts.map +1 -1
  45. package/dest/index.d.ts +2 -2
  46. package/dest/index.d.ts.map +1 -1
  47. package/dest/index.js +1 -1
  48. package/dest/local-network/banana_fpc.d.ts +10 -0
  49. package/dest/local-network/banana_fpc.d.ts.map +1 -0
  50. package/dest/{sandbox → local-network}/banana_fpc.js +3 -3
  51. package/dest/local-network/index.d.ts +4 -0
  52. package/dest/local-network/index.d.ts.map +1 -0
  53. package/dest/{sandbox → local-network}/index.js +1 -1
  54. package/dest/local-network/local-network.d.ts +71 -0
  55. package/dest/local-network/local-network.d.ts.map +1 -0
  56. package/dest/{sandbox/sandbox.js → local-network/local-network.js} +43 -32
  57. package/dest/local-network/sponsored_fpc.d.ts +5 -0
  58. package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
  59. package/dest/mnemonic.d.ts +1 -1
  60. package/dest/splash.d.ts +1 -1
  61. package/dest/testing/anvil_test_watcher.d.ts +4 -4
  62. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  63. package/dest/testing/anvil_test_watcher.js +16 -14
  64. package/dest/testing/cheat_codes.d.ts +1 -1
  65. package/dest/testing/cheat_codes.d.ts.map +1 -1
  66. package/dest/testing/epoch_test_settler.d.ts +19 -0
  67. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  68. package/dest/testing/epoch_test_settler.js +62 -0
  69. package/dest/testing/index.d.ts +2 -1
  70. package/dest/testing/index.d.ts.map +1 -1
  71. package/dest/testing/index.js +1 -0
  72. package/package.json +41 -37
  73. package/scripts/aztec.sh +63 -0
  74. package/scripts/compile.sh +44 -0
  75. package/scripts/extract_function.js +47 -0
  76. package/scripts/flamegraph.sh +59 -0
  77. package/scripts/init.sh +35 -0
  78. package/scripts/new.sh +59 -0
  79. package/scripts/setup_project.sh +31 -0
  80. package/src/bin/index.ts +7 -3
  81. package/src/cli/aztec_start_action.ts +13 -12
  82. package/src/cli/aztec_start_options.ts +22 -31
  83. package/src/cli/cli.ts +12 -11
  84. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  85. package/src/cli/cmds/start_archiver.ts +7 -18
  86. package/src/cli/cmds/start_bot.ts +1 -1
  87. package/src/cli/cmds/start_node.ts +4 -4
  88. package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
  89. package/src/cli/cmds/start_prover_agent.ts +2 -10
  90. package/src/cli/cmds/start_prover_broker.ts +2 -2
  91. package/src/cli/cmds/start_prover_node.ts +2 -2
  92. package/src/cli/util.ts +7 -7
  93. package/src/examples/token.ts +4 -6
  94. package/src/examples/util.ts +1 -1
  95. package/src/index.ts +2 -2
  96. package/src/{sandbox → local-network}/banana_fpc.ts +11 -7
  97. package/src/{sandbox → local-network}/index.ts +1 -1
  98. package/src/{sandbox/sandbox.ts → local-network/local-network.ts} +77 -79
  99. package/src/{sandbox → local-network}/sponsored_fpc.ts +3 -2
  100. package/src/testing/anvil_test_watcher.ts +16 -14
  101. package/src/testing/cheat_codes.ts +3 -2
  102. package/src/testing/epoch_test_settler.ts +71 -0
  103. package/src/testing/index.ts +1 -0
  104. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  105. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  106. package/dest/cli/cmds/start_blob_sink.js +0 -33
  107. package/dest/sandbox/banana_fpc.d.ts +0 -10
  108. package/dest/sandbox/banana_fpc.d.ts.map +0 -1
  109. package/dest/sandbox/index.d.ts +0 -4
  110. package/dest/sandbox/index.d.ts.map +0 -1
  111. package/dest/sandbox/sandbox.d.ts +0 -74
  112. package/dest/sandbox/sandbox.d.ts.map +0 -1
  113. package/dest/sandbox/sponsored_fpc.d.ts +0 -4
  114. package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
  115. package/src/cli/cmds/start_blob_sink.ts +0 -57
  116. /package/dest/{sandbox → local-network}/sponsored_fpc.js +0 -0
@@ -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';
@@ -28,63 +27,47 @@ import {
28
27
  import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
29
28
  import { getGenesisValues } from '@aztec/world-state/testing';
30
29
 
31
- import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
30
+ import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
32
31
  import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
33
32
  import { foundry } from 'viem/chains';
34
33
 
35
34
  import { createAccountLogs } from '../cli/util.js';
36
35
  import { DefaultMnemonic } from '../mnemonic.js';
37
36
  import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
37
+ import { EpochTestSettler } from '../testing/epoch_test_settler.js';
38
38
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
39
39
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
40
40
 
41
- const logger = createLogger('sandbox');
41
+ const logger = createLogger('local-network');
42
42
 
43
43
  const localAnvil = foundry;
44
44
 
45
45
  /**
46
- * Function to deploy our L1 contracts to the sandbox L1
46
+ * Function to deploy our L1 contracts to the local network L1
47
47
  * @param aztecNodeConfig - The Aztec Node Config
48
48
  * @param hdAccount - Account for publishing L1 contracts
49
49
  */
50
50
  export async function deployContractsToL1(
51
51
  aztecNodeConfig: AztecNodeConfig,
52
- hdAccount: HDAccount | PrivateKeyAccount,
53
- contractDeployLogger = logger,
52
+ privateKey: Hex,
54
53
  opts: {
55
- assumeProvenThroughBlockNumber?: number;
56
- salt?: number;
57
54
  genesisArchiveRoot?: Fr;
58
55
  feeJuicePortalInitialBalance?: bigint;
59
56
  } = {},
60
57
  ) {
61
- const chain =
62
- aztecNodeConfig.l1RpcUrls.length > 0
63
- ? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId)
64
- : { chainInfo: localAnvil };
65
-
66
58
  await waitForPublicClient(aztecNodeConfig);
67
59
 
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 sandbox
82
- slasherFlavor: 'none', // no slashing in sandbox
83
- realVerifier: false,
84
- },
85
- );
86
-
87
- await deployMulticall3(l1Contracts.l1Client, logger);
60
+ const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
61
+ ...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
62
+ ...aztecNodeConfig,
63
+ vkTreeRoot: getVKTreeRoot(),
64
+ protocolContractsHash,
65
+ genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
66
+ feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
67
+ aztecTargetCommitteeSize: 0, // no committee in local network
68
+ slasherFlavor: 'none', // no slashing in local network
69
+ realVerifier: false,
70
+ });
88
71
 
89
72
  aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
90
73
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
@@ -92,31 +75,33 @@ export async function deployContractsToL1(
92
75
  return aztecNodeConfig.l1Contracts;
93
76
  }
94
77
 
95
- /** Sandbox settings. */
96
- export type SandboxConfig = AztecNodeConfig & {
78
+ /** Local network settings. */
79
+ export type LocalNetworkConfig = AztecNodeConfig & {
97
80
  /** Mnemonic used to derive the L1 deployer private key.*/
98
81
  l1Mnemonic: string;
99
- /** Salt used to deploy L1 contracts.*/
100
- deployAztecContractsSalt: string;
101
- /** Whether to deploy test accounts on sandbox start.*/
82
+ /** Whether to deploy test accounts on local network start.*/
102
83
  testAccounts: boolean;
103
84
  };
104
85
 
105
86
  /**
106
87
  * Create and start a new Aztec Node and PXE. Deploys L1 contracts.
107
88
  * Does not start any HTTP services nor populate any initial accounts.
108
- * @param config - Optional Sandbox settings.
89
+ * @param config - Optional local network settings.
109
90
  */
110
- export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog: LogFn) {
111
- // sandbox is meant for test envs. We should only need one l1RpcUrl
91
+ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {}, userLog: LogFn) {
92
+ // local network is meant for test envs. We should only need one l1RpcUrl
112
93
  const l1RpcUrl = config.l1RpcUrls?.[0];
113
94
  if (!l1RpcUrl) {
114
95
  throw new Error('An L1 RPC URL is required');
115
96
  }
116
97
  if ((config.l1RpcUrls?.length || 0) > 1) {
117
- logger.warn(`Multiple L1 RPC URLs provided. Sandbox will only use the first one: ${l1RpcUrl}`);
98
+ logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
118
99
  }
119
- const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
100
+
101
+ const aztecNodeConfig: AztecNodeConfig = {
102
+ ...getConfigEnvVars(),
103
+ ...config,
104
+ };
120
105
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
121
106
  if (
122
107
  aztecNodeConfig.publisherPrivateKeys == undefined ||
@@ -153,15 +138,20 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
153
138
  : [];
154
139
  const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
155
140
 
156
- let watcher: AnvilTestWatcher | undefined = undefined;
157
141
  const dateProvider = new TestDateProvider();
142
+
143
+ let cheatcodes: EthCheatCodes | undefined;
144
+ let rollupAddress: EthAddress | undefined;
145
+ let watcher: AnvilTestWatcher | undefined;
158
146
  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
- });
147
+ ({ rollupAddress } = await deployContractsToL1(
148
+ aztecNodeConfig,
149
+ aztecNodeConfig.validatorPrivateKeys.getValue()[0],
150
+ {
151
+ genesisArchiveRoot,
152
+ feeJuicePortalInitialBalance: fundingNeeded,
153
+ },
154
+ ));
165
155
 
166
156
  const chain =
167
157
  aztecNodeConfig.l1RpcUrls.length > 0
@@ -173,31 +163,38 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
173
163
  transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
174
164
  });
175
165
 
176
- watcher = new AnvilTestWatcher(
177
- new EthCheatCodes([l1RpcUrl], dateProvider),
178
- l1ContractAddresses.rollupAddress,
179
- publicClient,
180
- dateProvider,
181
- );
182
- watcher.setIsSandbox(true);
166
+ cheatcodes = new EthCheatCodes([l1RpcUrl], dateProvider);
167
+
168
+ watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
169
+ watcher.setisLocalNetwork(true);
170
+ watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
171
+
183
172
  await watcher.start();
184
173
  }
185
174
 
186
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
187
- // Create a local blob sink client inside the sandbox, no http connectivity
188
- const blobSinkClient = createBlobSinkClient();
189
- const node = await createAztecNode(
190
- aztecNodeConfig,
191
- { telemetry, blobSinkClient, dateProvider },
192
- { prefilledPublicData },
193
- );
175
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
176
+ // Create a local blob client client inside the local network, no http connectivity
177
+ const blobClient = createBlobClient();
178
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
179
+
180
+ let epochTestSettler: EpochTestSettler | undefined;
181
+ if (!aztecNodeConfig.p2pEnabled) {
182
+ epochTestSettler = new EpochTestSettler(
183
+ cheatcodes!,
184
+ rollupAddress!,
185
+ node.getBlockSource(),
186
+ logger.createChild('epoch-settler'),
187
+ { pollingIntervalMs: 200 },
188
+ );
189
+ await epochTestSettler.start();
190
+ }
194
191
 
195
192
  if (initialAccounts.length) {
196
193
  const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
197
194
  const wallet = await TestWallet.create(node, PXEConfig);
198
195
 
199
196
  userLog('Setting up funded test accounts...');
200
- const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
197
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
201
198
  const accountsWithSecrets = accountManagers.map((manager, i) => ({
202
199
  account: manager,
203
200
  secretKey: initialAccounts[i].secret,
@@ -216,6 +213,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
216
213
  const stop = async () => {
217
214
  await node.stop();
218
215
  await watcher?.stop();
216
+ await epochTestSettler?.stop();
219
217
  };
220
218
 
221
219
  return { node, stop };
@@ -227,7 +225,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
227
225
  */
228
226
  export async function createAztecNode(
229
227
  config: Partial<AztecNodeConfig> = {},
230
- deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface; dateProvider?: DateProvider } = {},
228
+ deps: { telemetry?: TelemetryClient; blobClient?: BlobClientInterface; dateProvider?: DateProvider } = {},
231
229
  options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
232
230
  ) {
233
231
  // TODO(#12272): will clean this up. This is criminal.
@@ -1,3 +1,4 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
1
2
  import {
2
3
  type ContractInstanceWithAddress,
3
4
  getContractInstanceFromInstantiationParams,
@@ -13,11 +14,11 @@ async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
13
14
  });
14
15
  }
15
16
 
16
- export async function getSponsoredFPCAddress() {
17
+ export async function getSponsoredFPCAddress(): Promise<AztecAddress> {
17
18
  return (await getSponsoredFPCInstance()).address;
18
19
  }
19
20
 
20
- export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet) {
21
+ export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet): Promise<AztecAddress> {
21
22
  const fpc = await getSponsoredFPCInstance();
22
23
  // The following is no-op if the contract is already registered
23
24
  await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
@@ -1,5 +1,6 @@
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
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
4
5
  import { type Logger, createLogger } from '@aztec/foundation/log';
5
6
  import { RunningPromise } from '@aztec/foundation/running-promise';
@@ -16,11 +17,11 @@ import { type GetContractReturnType, getAddress, getContract } from 'viem';
16
17
  * block within the slot. And if so, it will time travel into the next slot.
17
18
  */
18
19
  export class AnvilTestWatcher {
19
- private isSandbox: boolean = false;
20
+ private isLocalNetwork: boolean = false;
20
21
 
21
22
  private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
22
23
  private rollupCheatCodes: RollupCheatCodes;
23
- private l2SlotDuration!: bigint;
24
+ private l2SlotDuration!: number;
24
25
 
25
26
  private filledRunningPromise?: RunningPromise;
26
27
  private syncDateProviderPromise?: RunningPromise;
@@ -54,8 +55,8 @@ export class AnvilTestWatcher {
54
55
  this.isMarkingAsProven = isMarkingAsProven;
55
56
  }
56
57
 
57
- setIsSandbox(isSandbox: boolean) {
58
- this.isSandbox = isSandbox;
58
+ setisLocalNetwork(isLocalNetwork: boolean) {
59
+ this.isLocalNetwork = isLocalNetwork;
59
60
  }
60
61
 
61
62
  async start() {
@@ -68,7 +69,7 @@ export class AnvilTestWatcher {
68
69
 
69
70
  // If auto mining is not supported (e.g., we are on a real network), then we
70
71
  // will simple do nothing. But if on an anvil or the like, this make sure that
71
- // the sandbox and tests don't break because time is frozen and we never get to
72
+ // the local network and tests don't break because time is frozen and we never get to
72
73
  // the next slot.
73
74
  const isAutoMining = await this.cheatcodes.isAutoMining();
74
75
 
@@ -105,7 +106,7 @@ export class AnvilTestWatcher {
105
106
  }
106
107
 
107
108
  async syncDateProviderToL1IfBehind() {
108
- // this doesn't apply to the sandbox, because we don't have a date provider in the sandbox
109
+ // this doesn't apply to the local network, because we don't have a date provider in the local network
109
110
  if (!this.dateProvider) {
110
111
  return;
111
112
  }
@@ -123,12 +124,13 @@ export class AnvilTestWatcher {
123
124
 
124
125
  async warpTimeIfNeeded() {
125
126
  try {
126
- const currentSlot = await this.rollup.read.getCurrentSlot();
127
- const pendingBlockNumber = BigInt(await this.rollup.read.getPendingBlockNumber());
128
- const blockLog = await this.rollup.read.getBlock([pendingBlockNumber]);
129
- const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([currentSlot + 1n]));
127
+ const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
128
+ const pendingCheckpointNumber = await this.rollup.read.getPendingCheckpointNumber();
129
+ const checkpointLog = await this.rollup.read.getCheckpoint([pendingCheckpointNumber]);
130
+ const nextSlot = SlotNumber(currentSlot + 1);
131
+ const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]));
130
132
 
131
- if (currentSlot === blockLog.slotNumber) {
133
+ if (BigInt(currentSlot) === checkpointLog.slotNumber) {
132
134
  // We should jump to the next slot
133
135
  try {
134
136
  await this.cheatcodes.warp(nextSlotTimestamp, {
@@ -142,8 +144,8 @@ export class AnvilTestWatcher {
142
144
  return;
143
145
  }
144
146
 
145
- // If we are not in sandbox, we don't need to warp time
146
- if (!this.isSandbox) {
147
+ // If we are not in local network, we don't need to warp time
148
+ if (!this.isLocalNetwork) {
147
149
  return;
148
150
  }
149
151
 
@@ -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=start_blob_sink.d.ts.map
@@ -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,10 +0,0 @@
1
- import { type InitialAccountData } from '@aztec/accounts/testing';
2
- import type { Wallet } from '@aztec/aztec.js/wallet';
3
- import type { LogFn } from '@aztec/foundation/log';
4
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- export declare function getBananaCoinAddress(initialAccounts: InitialAccountData[]): Promise<AztecAddress>;
6
- export declare function getBananaFPCAddress(initialAccounts: InitialAccountData[]): Promise<AztecAddress>;
7
- export declare function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn): Promise<void>;
8
- export declare function registerDeployedBananaCoinInWalletAndGetAddress(wallet: Wallet): Promise<AztecAddress>;
9
- export declare function registerDeployedBananaFPCInWalletAndGetAddress(wallet: Wallet): Promise<AztecAddress>;
10
- //# sourceMappingURL=banana_fpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"banana_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/banana_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA8B,MAAM,yBAAyB,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAwB3D,wBAAsB,oBAAoB,CAAC,eAAe,EAAE,kBAAkB,EAAE,yBAE/E;AAWD,wBAAsB,mBAAmB,CAAC,eAAe,EAAE,kBAAkB,EAAE,yBAE9E;AAED,wBAAsB,cAAc,CAAC,eAAe,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAcrG;AAED,wBAAsB,+CAA+C,CAAC,MAAM,EAAE,MAAM,yBAMnF;AAED,wBAAsB,8CAA8C,CAAC,MAAM,EAAE,MAAM,yBAMlF"}
@@ -1,4 +0,0 @@
1
- export * from './sandbox.js';
2
- export { registerDeployedBananaCoinInWalletAndGetAddress, registerDeployedBananaFPCInWalletAndGetAddress, } from './banana_fpc.js';
3
- export { registerDeployedSponsoredFPCInWalletAndGetAddress } from './sponsored_fpc.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,+CAA+C,EAC/C,8CAA8C,GAC/C,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iDAAiD,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env -S node --no-warnings
2
- import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
3
- import { EthAddress } from '@aztec/aztec.js/addresses';
4
- import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
5
- import { Fr } from '@aztec/foundation/fields';
6
- import { type LogFn } from '@aztec/foundation/log';
7
- import { DateProvider } from '@aztec/foundation/timer';
8
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
9
- import { type TelemetryClient } from '@aztec/telemetry-client';
10
- import { type HDAccount, type PrivateKeyAccount } from 'viem';
11
- /**
12
- * Function to deploy our L1 contracts to the sandbox L1
13
- * @param aztecNodeConfig - The Aztec Node Config
14
- * @param hdAccount - Account for publishing L1 contracts
15
- */
16
- export declare function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, hdAccount: HDAccount | PrivateKeyAccount, contractDeployLogger?: import("@aztec/foundation/log").Logger, opts?: {
17
- assumeProvenThroughBlockNumber?: number;
18
- salt?: number;
19
- genesisArchiveRoot?: Fr;
20
- feeJuicePortalInitialBalance?: bigint;
21
- }): Promise<{
22
- rollupAddress: EthAddress;
23
- registryAddress: EthAddress;
24
- inboxAddress: EthAddress;
25
- outboxAddress: EthAddress;
26
- feeJuiceAddress: EthAddress;
27
- feeJuicePortalAddress: EthAddress;
28
- coinIssuerAddress: EthAddress;
29
- rewardDistributorAddress: EthAddress;
30
- governanceProposerAddress: EthAddress;
31
- governanceAddress: EthAddress;
32
- stakingAssetAddress: EthAddress;
33
- } & {
34
- slashFactoryAddress?: EthAddress | undefined;
35
- feeAssetHandlerAddress?: EthAddress | undefined;
36
- stakingAssetHandlerAddress?: EthAddress | undefined;
37
- zkPassportVerifierAddress?: EthAddress | undefined;
38
- gseAddress?: EthAddress | undefined;
39
- dateGatedRelayerAddress?: EthAddress | undefined;
40
- } & {
41
- rollupAddress: EthAddress;
42
- } & {
43
- rollupAddress: EthAddress;
44
- }>;
45
- /** Sandbox settings. */
46
- export type SandboxConfig = AztecNodeConfig & {
47
- /** Mnemonic used to derive the L1 deployer private key.*/
48
- l1Mnemonic: string;
49
- /** Salt used to deploy L1 contracts.*/
50
- deployAztecContractsSalt: string;
51
- /** Whether to deploy test accounts on sandbox start.*/
52
- testAccounts: boolean;
53
- };
54
- /**
55
- * Create and start a new Aztec Node and PXE. Deploys L1 contracts.
56
- * Does not start any HTTP services nor populate any initial accounts.
57
- * @param config - Optional Sandbox settings.
58
- */
59
- export declare function createSandbox(config: Partial<SandboxConfig> | undefined, userLog: LogFn): Promise<{
60
- node: AztecNodeService;
61
- stop: () => Promise<void>;
62
- }>;
63
- /**
64
- * Create and start a new Aztec RPC HTTP Server
65
- * @param config - Optional Aztec node settings.
66
- */
67
- export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?: {
68
- telemetry?: TelemetryClient;
69
- blobSinkClient?: BlobSinkClientInterface;
70
- dateProvider?: DateProvider;
71
- }, options?: {
72
- prefilledPublicData?: PublicDataTreeLeaf[];
73
- }): Promise<AztecNodeService>;
74
- //# sourceMappingURL=sandbox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAY7F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAoB,MAAM,yBAAyB,CAAC;AAGzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAA2D,MAAM,MAAM,CAAC;AAcvH;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GAAG,iBAAiB,EACxC,oBAAoB,yCAAS,EAC7B,IAAI,GAAE;IACJ,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,EAAE,CAAC;IACxB,4BAA4B,CAAC,EAAE,MAAM,CAAC;CAClC;;;;;;;;;;;;;;;;;;;;;;;GAkCP;AAED,wBAAwB;AACxB,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,wBAAwB,EAAE,MAAM,CAAC;IACjC,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,YAAK,EAAE,OAAO,EAAE,KAAK;;;GAgHtF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,cAAc,CAAC,EAAE,uBAAuB,CAAC;IAAC,YAAY,CAAC,EAAE,YAAY,CAAA;CAAO,EACjH,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAW7D"}
@@ -1,4 +0,0 @@
1
- import type { Wallet } from '@aztec/aztec.js/wallet';
2
- export declare function getSponsoredFPCAddress(): Promise<import("@aztec/aztec.js/addresses").AztecAddress>;
3
- export declare function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet): Promise<import("@aztec/aztec.js/addresses").AztecAddress>;
4
- //# sourceMappingURL=sponsored_fpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sponsored_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fpc.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAUrD,wBAAsB,sBAAsB,8DAE3C;AAED,wBAAsB,iDAAiD,CAAC,MAAM,EAAE,MAAM,6DAKrF"}