@aztec/aztec 0.0.1-commit.2448fdb → 0.0.1-commit.2606882

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 (95) hide show
  1. package/dest/bin/index.js +1 -1
  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 +10 -6
  5. package/dest/cli/aztec_start_options.d.ts +2 -2
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +2 -15
  8. package/dest/cli/cmds/compile.d.ts +1 -1
  9. package/dest/cli/cmds/compile.d.ts.map +1 -1
  10. package/dest/cli/cmds/compile.js +6 -8
  11. package/dest/cli/cmds/profile.d.ts +1 -1
  12. package/dest/cli/cmds/profile.d.ts.map +1 -1
  13. package/dest/cli/cmds/profile.js +1 -1
  14. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  15. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  16. package/dest/cli/cmds/profile_gates.js +21 -3
  17. package/dest/cli/cmds/standby.d.ts +3 -5
  18. package/dest/cli/cmds/standby.d.ts.map +1 -1
  19. package/dest/cli/cmds/standby.js +3 -3
  20. package/dest/cli/cmds/start_bot.d.ts +1 -1
  21. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  22. package/dest/cli/cmds/start_bot.js +3 -3
  23. package/dest/cli/cmds/start_node.d.ts +1 -1
  24. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  25. package/dest/cli/cmds/start_node.js +5 -9
  26. package/dest/cli/cmds/start_prover_agent.js +2 -2
  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 +11 -8
  30. package/dest/cli/cmds/start_txe.d.ts +2 -2
  31. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  32. package/dest/cli/cmds/start_txe.js +6 -5
  33. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +1 -1
  34. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -1
  35. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +2 -3
  36. package/dest/cli/util.js +10 -8
  37. package/dest/local-network/auth_registry.d.ts +5 -0
  38. package/dest/local-network/auth_registry.d.ts.map +1 -0
  39. package/dest/local-network/auth_registry.js +17 -0
  40. package/dest/local-network/banana_fpc.d.ts +3 -2
  41. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  42. package/dest/local-network/banana_fpc.js +11 -7
  43. package/dest/local-network/local-network.d.ts +5 -28
  44. package/dest/local-network/local-network.d.ts.map +1 -1
  45. package/dest/local-network/local-network.js +36 -14
  46. package/dest/testing/anvil_test_watcher.d.ts +15 -3
  47. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  48. package/dest/testing/anvil_test_watcher.js +32 -4
  49. package/dest/testing/cheat_codes.d.ts +10 -5
  50. package/dest/testing/cheat_codes.d.ts.map +1 -1
  51. package/dest/testing/cheat_codes.js +40 -6
  52. package/dest/testing/epoch_test_settler.d.ts +1 -1
  53. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  54. package/dest/testing/epoch_test_settler.js +6 -4
  55. package/dest/testing/index.d.ts +2 -2
  56. package/dest/testing/index.d.ts.map +1 -1
  57. package/package.json +34 -34
  58. package/scripts/add_crate.sh +11 -60
  59. package/scripts/aztec.sh +7 -4
  60. package/scripts/init.sh +5 -5
  61. package/scripts/new.sh +2 -2
  62. package/scripts/setup_workspace.sh +3 -2
  63. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  64. package/scripts/templates/blank/contract/src/main.nr +10 -0
  65. package/scripts/templates/blank/test/Nargo.toml +7 -0
  66. package/scripts/templates/blank/test/src/lib.nr +11 -0
  67. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  68. package/scripts/templates/counter/contract/src/main.nr +48 -0
  69. package/scripts/templates/counter/test/Nargo.toml +7 -0
  70. package/scripts/templates/counter/test/src/lib.nr +32 -0
  71. package/src/bin/index.ts +1 -1
  72. package/src/cli/aztec_start_action.ts +11 -6
  73. package/src/cli/aztec_start_options.ts +9 -23
  74. package/src/cli/cmds/compile.ts +7 -9
  75. package/src/cli/cmds/profile.ts +2 -1
  76. package/src/cli/cmds/profile_gates.ts +20 -4
  77. package/src/cli/cmds/standby.ts +4 -4
  78. package/src/cli/cmds/start_bot.ts +3 -5
  79. package/src/cli/cmds/start_node.ts +5 -9
  80. package/src/cli/cmds/start_prover_agent.ts +2 -2
  81. package/src/cli/cmds/start_prover_broker.ts +10 -11
  82. package/src/cli/cmds/start_txe.ts +7 -5
  83. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +2 -3
  84. package/src/cli/util.ts +9 -9
  85. package/src/local-network/auth_registry.ts +19 -0
  86. package/src/local-network/banana_fpc.ts +12 -8
  87. package/src/local-network/local-network.ts +39 -13
  88. package/src/testing/anvil_test_watcher.ts +43 -3
  89. package/src/testing/cheat_codes.ts +54 -7
  90. package/src/testing/epoch_test_settler.ts +3 -4
  91. package/src/testing/index.ts +1 -1
  92. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  93. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  94. package/dest/cli/cmds/start_archiver.js +0 -48
  95. package/src/cli/cmds/start_archiver.ts +0 -50
@@ -1,5 +1,6 @@
1
1
  import { findBbBinary } from '@aztec/bb.js';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
3
4
 
4
5
  import { execFileSync } from 'child_process';
5
6
  import type { Command } from 'commander';
@@ -25,15 +26,13 @@ async function collectContractArtifacts(): Promise<string[]> {
25
26
  return files.filter(f => Array.isArray(f.content.functions)).map(f => f.filePath);
26
27
  }
27
28
 
28
- /** Strips the `__aztec_nr_internals__` prefix from function names in contract artifacts. */
29
- async function stripInternalPrefixes(artifactPaths: string[]): Promise<void> {
29
+ /** Stamps the Aztec stack version into the contract artifacts. */
30
+ async function stampAztecVersion(artifactPaths: string[]): Promise<void> {
31
+ const version = getPackageVersion();
30
32
  for (const path of artifactPaths) {
31
33
  const artifact = JSON.parse(await readFile(path, 'utf-8'));
32
- for (const fn of artifact.functions) {
33
- if (typeof fn.name === 'string') {
34
- fn.name = fn.name.replace(/^__aztec_nr_internals__/, '');
35
- }
36
- }
34
+ // eslint-disable-next-line camelcase
35
+ artifact.aztec_version = version;
37
36
  await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
38
37
  }
39
38
  }
@@ -162,8 +161,7 @@ async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<vo
162
161
  const bbArgs = artifacts.flatMap(a => ['-i', a]);
163
162
  await run(bb, ['aztec_process', ...bbArgs]);
164
163
 
165
- // TODO: This should be part of bb aztec_process!
166
- await stripInternalPrefixes(artifacts);
164
+ await stampAztecVersion(artifacts);
167
165
  }
168
166
 
169
167
  log('Compilation complete!');
@@ -11,8 +11,9 @@ export function injectProfileCommand(program: Command, log: LogFn): Command {
11
11
  profile
12
12
  .command('gates')
13
13
  .argument('[target-dir]', 'Path to the compiled artifacts directory', './target')
14
+ .option('--json', 'Output gate counts as JSON instead of a table', false)
14
15
  .description('Display gate counts for all compiled Aztec artifacts in a target directory.')
15
- .action((targetDir: string) => profileGates(targetDir, log));
16
+ .action((targetDir: string, options: { json: boolean }) => profileGates(targetDir, options.json, log));
16
17
 
17
18
  profile
18
19
  .command('flamegraph')
@@ -6,12 +6,13 @@ import { execFile as execFileCb } from 'child_process';
6
6
  import { rm } from 'fs/promises';
7
7
  import { promisify } from 'util';
8
8
 
9
- import { MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
9
+ import { type DiscoveredArtifact, MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
10
10
 
11
11
  const execFile = promisify(execFileCb);
12
12
 
13
13
  interface GateCountResult {
14
14
  name: string;
15
+ type: DiscoveredArtifact['type'];
15
16
  gateCount: number;
16
17
  }
17
18
 
@@ -32,24 +33,39 @@ async function getGateCount(bb: string, artifactPath: string): Promise<number> {
32
33
  }
33
34
 
34
35
  /** Profiles all compiled artifacts in a target directory and prints gate counts. */
35
- export async function profileGates(targetDir: string, log: LogFn): Promise<void> {
36
+ export async function profileGates(targetDir: string, json: boolean, log: LogFn): Promise<void> {
36
37
  const bb = process.env.BB ?? findBbBinary() ?? 'bb';
37
38
  const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
38
39
 
39
40
  if (artifacts.length === 0) {
40
- log('No artifacts found in target directory.');
41
+ if (json) {
42
+ log('[]');
43
+ } else {
44
+ log('No artifacts found in target directory.');
45
+ }
41
46
  return;
42
47
  }
43
48
 
44
49
  try {
45
50
  const results: GateCountResult[] = await asyncPool(MAX_CONCURRENT, artifacts, async artifact => ({
46
51
  name: artifact.name,
52
+ type: artifact.type,
47
53
  gateCount: await getGateCount(bb, artifact.filePath),
48
54
  }));
49
55
  results.sort((a, b) => a.name.localeCompare(b.name));
50
56
 
51
57
  if (results.length === 0) {
52
- log('No constrained circuits found.');
58
+ if (json) {
59
+ log('[]');
60
+ } else {
61
+ log('No constrained circuits found.');
62
+ }
63
+ return;
64
+ }
65
+
66
+ if (json) {
67
+ const entries = results.map(r => ({ name: r.name, type: r.type, gates: r.gateCount }));
68
+ log(JSON.stringify(entries, null, 2));
53
69
  return;
54
70
  }
55
71
 
@@ -28,11 +28,11 @@ export async function computeExpectedGenesisRoot(config: GenesisStateConfig, use
28
28
 
29
29
  userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
30
30
 
31
- const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
31
+ const { genesisArchiveRoot, genesis } = await getGenesisValues(initialFundedAccounts);
32
32
 
33
33
  userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
34
34
 
35
- return { genesisArchiveRoot, prefilledPublicData };
35
+ return { genesisArchiveRoot, genesis };
36
36
  }
37
37
 
38
38
  async function checkRollupCompatibility(
@@ -67,7 +67,7 @@ export async function waitForCompatibleRollup(
67
67
  config: {
68
68
  l1RpcUrls: string[];
69
69
  l1ChainId: number;
70
- l1Contracts: { registryAddress: EthAddress };
70
+ registryAddress: EthAddress;
71
71
  rollupVersion?: number;
72
72
  },
73
73
  expected: { genesisArchiveRoot: Fr; vkTreeRoot: Fr; protocolContractsHash: Fr },
@@ -77,7 +77,7 @@ export async function waitForCompatibleRollup(
77
77
  const publicClient = getPublicClient(config);
78
78
  const rollupVersion: number | 'canonical' = config.rollupVersion ?? 'canonical';
79
79
 
80
- const registry = new RegistryContract(publicClient, config.l1Contracts.registryAddress);
80
+ const registry = new RegistryContract(publicClient, config.registryAddress);
81
81
  const rollupAddress = await registry.getRollupAddress(rollupVersion);
82
82
  const rollup = new RollupContract(publicClient, rollupAddress.toString());
83
83
 
@@ -21,11 +21,9 @@ export async function startBot(
21
21
  services: NamespacedApiHandlers,
22
22
  userLog: LogFn,
23
23
  ) {
24
- const { proverNode, archiver, sequencer, p2pBootstrap, txe, prover } = options;
25
- if (proverNode || archiver || sequencer || p2pBootstrap || txe || prover) {
26
- userLog(
27
- `Starting a bot with --prover-node, --prover, --archiver, --sequencer, --p2p-bootstrap, or --txe is not supported.`,
28
- );
24
+ const { proverNode, sequencer, p2pBootstrap, txe, prover } = options;
25
+ if (proverNode || sequencer || p2pBootstrap || txe || prover) {
26
+ userLog(`Starting a bot with --prover-node, --prover, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
29
27
  process.exit(1);
30
28
  }
31
29
 
@@ -83,12 +83,12 @@ export async function startNode(
83
83
  await preloadCrsDataForVerifying(nodeConfig, userLog);
84
84
 
85
85
  const genesisConfig = getGenesisStateConfigEnvVars();
86
- const { genesisArchiveRoot, prefilledPublicData } = await computeExpectedGenesisRoot(genesisConfig, userLog);
86
+ const { genesisArchiveRoot, genesis } = await computeExpectedGenesisRoot(genesisConfig, userLog);
87
87
 
88
88
  const followsCanonicalRollup =
89
89
  typeof nodeConfig.rollupVersion !== 'number' || (nodeConfig.rollupVersion as unknown as string) === 'canonical';
90
90
 
91
- if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
91
+ if (!nodeConfig.registryAddress || nodeConfig.registryAddress.isZero()) {
92
92
  throw new Error('L1 registry address is required to start Aztec Node');
93
93
  }
94
94
 
@@ -102,7 +102,7 @@ export async function startNode(
102
102
  );
103
103
 
104
104
  const { addresses, config } = await getL1Config(
105
- nodeConfig.l1Contracts.registryAddress,
105
+ nodeConfig.registryAddress,
106
106
  nodeConfig.l1RpcUrls,
107
107
  nodeConfig.l1ChainId,
108
108
  nodeConfig.rollupVersion,
@@ -116,13 +116,9 @@ export async function startNode(
116
116
  );
117
117
  }
118
118
 
119
- // TODO(#12272): will clean this up.
120
119
  nodeConfig = {
121
120
  ...nodeConfig,
122
- l1Contracts: {
123
- ...addresses,
124
- slashFactoryAddress: nodeConfig.l1Contracts.slashFactoryAddress,
125
- },
121
+ ...addresses,
126
122
  ...config,
127
123
  };
128
124
 
@@ -158,7 +154,7 @@ export async function startNode(
158
154
  const telemetry = await initTelemetryClient(telemetryConfig);
159
155
 
160
156
  // Create and start Aztec Node
161
- const node = await createAztecNode(nodeConfig, { telemetry, proverBroker: broker }, { prefilledPublicData });
157
+ const node = await createAztecNode(nodeConfig, { telemetry, proverBroker: broker }, { genesis });
162
158
 
163
159
  // Add node and p2p to services list
164
160
  services.node = [node, AztecNodeApiSchema];
@@ -24,8 +24,8 @@ export async function startProverAgent(
24
24
  services: NamespacedApiHandlers,
25
25
  userLog: LogFn,
26
26
  ) {
27
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
28
- userLog(`Starting a prover agent with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
27
+ if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
28
+ userLog(`Starting a prover agent with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
29
29
  process.exit(1);
30
30
  }
31
31
 
@@ -24,38 +24,37 @@ export async function startProverBroker(
24
24
  services: NamespacedApiHandlers,
25
25
  userLog: LogFn,
26
26
  ): Promise<{ broker: ProvingJobBroker; config: ProverBrokerConfig }> {
27
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
28
- userLog(`Starting a prover broker with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
27
+ if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
28
+ userLog(`Starting a prover broker with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
29
29
  process.exit(1);
30
30
  }
31
31
 
32
- const config: ProverBrokerConfig = {
32
+ const baseConfig: ProverBrokerConfig = {
33
33
  ...getProverNodeBrokerConfigFromEnv(), // get default config from env
34
34
  ...extractRelevantOptions<ProverBrokerConfig>(options, proverBrokerConfigMappings, 'proverBroker'), // override with command line options
35
35
  };
36
36
 
37
- if (!config.l1Contracts.registryAddress || config.l1Contracts.registryAddress.isZero()) {
37
+ if (!baseConfig.registryAddress || baseConfig.registryAddress.isZero()) {
38
38
  throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
39
39
  }
40
40
 
41
41
  const genesisConfig = getGenesisStateConfigEnvVars();
42
42
  const { genesisArchiveRoot } = await computeExpectedGenesisRoot(genesisConfig, userLog);
43
43
  await waitForCompatibleRollup(
44
- config,
44
+ baseConfig,
45
45
  { genesisArchiveRoot, vkTreeRoot: getVKTreeRoot(), protocolContractsHash },
46
46
  options.port,
47
47
  userLog,
48
48
  );
49
49
 
50
50
  const { addresses, config: rollupConfig } = await getL1Config(
51
- config.l1Contracts.registryAddress,
52
- config.l1RpcUrls,
53
- config.l1ChainId,
54
- config.rollupVersion,
51
+ baseConfig.registryAddress,
52
+ baseConfig.l1RpcUrls,
53
+ baseConfig.l1ChainId,
54
+ baseConfig.rollupVersion,
55
55
  );
56
56
 
57
- config.l1Contracts = addresses;
58
- config.rollupVersion = rollupConfig.rollupVersion;
57
+ const config: ProverBrokerConfig = { ...baseConfig, ...addresses, rollupVersion: rollupConfig.rollupVersion };
59
58
 
60
59
  const client = await initTelemetryClient(getTelemetryClientConfig());
61
60
  const broker = await createAndStartProvingBroker(config, client);
@@ -1,15 +1,17 @@
1
1
  import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
2
2
  import type { Logger } from '@aztec/foundation/log';
3
- import { createTXERpcServer } from '@aztec/txe';
3
+ import { createTXERpcServer } from '@aztec/txe/server';
4
4
 
5
- export async function startTXE(options: any, debugLogger: Logger) {
5
+ export async function startTXE(options: any, signalHandlers: Array<() => Promise<void>>, debugLogger: Logger) {
6
6
  debugLogger.info(`Setting up TXE...`);
7
7
 
8
- const txeServer = createTXERpcServer(debugLogger);
9
- const { port } = await startHttpRpcServer(txeServer, {
8
+ const txeServer = await createTXERpcServer(debugLogger);
9
+ const httpServer = await startHttpRpcServer(txeServer, {
10
10
  port: options.port,
11
11
  timeoutMs: 1e3 * 60 * 5,
12
12
  });
13
13
 
14
- debugLogger.info(`TXE listening on port ${port}`);
14
+ signalHandlers.push(() => new Promise<void>(resolve => httpServer.close(() => resolve())));
15
+
16
+ debugLogger.info(`TXE listening on port ${httpServer.port}`);
15
17
  }
@@ -1,5 +1,5 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
2
+ import { DEV_VERSION, getPackageVersion } from '@aztec/stdlib/update-checker';
3
3
 
4
4
  import TOML from '@iarna/toml';
5
5
  import { readFile } from 'fs/promises';
@@ -28,8 +28,7 @@ function isAztecNrGitUrl(gitUrl: string): boolean {
28
28
  /** Warns if any aztec-nr git dependency in a crate's Nargo.toml has a tag that doesn't match the CLI version. */
29
29
  export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
30
30
  const version = cliVersion ?? getPackageVersion();
31
- if (!version) {
32
- log(`WARNING: aztec CLI version not found. Skipping dependency compatibility check.`);
31
+ if (version === DEV_VERSION) {
33
32
  return;
34
33
  }
35
34
 
package/src/cli/util.ts CHANGED
@@ -82,17 +82,17 @@ export async function createAccountLogs(accountManagers: AccountManager[], walle
82
82
  accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
83
83
  accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
84
84
  accountLogStrings.push(` Secret Key: ${account.getSecretKey().toString()}\n`);
85
+ accountLogStrings.push(` Master nullifier public key hash: ${completeAddress.publicKeys.npkMHash.toString()}\n`);
86
+ accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.ivpkM.toString()}\n\n`);
85
87
  accountLogStrings.push(
86
- ` Master nullifier public key: ${completeAddress.publicKeys.masterNullifierPublicKey.toString()}\n`,
88
+ ` Master outgoing viewing public key hash: ${completeAddress.publicKeys.ovpkMHash.toString()}\n\n`,
87
89
  );
90
+ accountLogStrings.push(` Master tagging public key hash: ${completeAddress.publicKeys.tpkMHash.toString()}\n\n`);
88
91
  accountLogStrings.push(
89
- ` Master incoming viewing public key: ${completeAddress.publicKeys.masterIncomingViewingPublicKey.toString()}\n\n`,
92
+ ` Master message-signing public key hash: ${completeAddress.publicKeys.mspkMHash.toString()}\n\n`,
90
93
  );
91
94
  accountLogStrings.push(
92
- ` Master outgoing viewing public key: ${completeAddress.publicKeys.masterOutgoingViewingPublicKey.toString()}\n\n`,
93
- );
94
- accountLogStrings.push(
95
- ` Master tagging public key: ${completeAddress.publicKeys.masterTaggingPublicKey.toString()}\n\n`,
95
+ ` Master fallback public key hash: ${completeAddress.publicKeys.fbpkMHash.toString()}\n\n`,
96
96
  );
97
97
  }
98
98
  }
@@ -272,7 +272,7 @@ export async function preloadCrsDataForVerifying(
272
272
  ): Promise<void> {
273
273
  if (realProofs) {
274
274
  const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
275
- await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16 + 1, undefined, log)]);
275
+ await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16, undefined, log)]);
276
276
  }
277
277
  }
278
278
 
@@ -287,7 +287,7 @@ export async function preloadCrsDataForServerSideProving(
287
287
  ): Promise<void> {
288
288
  if (realProofs) {
289
289
  const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
290
- await Promise.all([Crs.new(2 ** 25 + 1, undefined, log), GrumpkinCrs.new(2 ** 18 + 1, undefined, log)]);
290
+ await Promise.all([Crs.new(2 ** 25, undefined, log), GrumpkinCrs.new(2 ** 18, undefined, log)]);
291
291
  }
292
292
  }
293
293
 
@@ -311,7 +311,7 @@ export async function setupVersionChecker(
311
311
  const checks: Array<VersionCheck> = [];
312
312
  checks.push({
313
313
  name: 'node',
314
- currentVersion: getPackageVersion() ?? 'unknown',
314
+ currentVersion: getPackageVersion(),
315
315
  getLatestVersion: async () => {
316
316
  const cfg = await getNetworkConfig(network, cacheDir);
317
317
  return cfg?.nodeVersion;
@@ -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,4 +1,5 @@
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
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import type { LogFn } from '@aztec/foundation/log';
@@ -45,19 +46,22 @@ 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
57
  const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
52
- TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
53
- from: admin,
54
- contractAddressSalt: BANANA_COIN_SALT,
58
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
59
+ salt: BANANA_COIN_SALT,
55
60
  universalDeploy: true,
56
- }),
57
- FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
61
+ }).send({ from: admin, wait: waitOpts }),
62
+ FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
58
63
  from: admin,
59
- contractAddressSalt: BANANA_FPC_SALT,
60
- universalDeploy: true,
64
+ wait: waitOpts,
61
65
  }),
62
66
  ]);
63
67
 
@@ -11,6 +11,7 @@ import { waitForPublicClient } from '@aztec/ethereum/client';
11
11
  import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
12
12
  import { NULL_KEY } from '@aztec/ethereum/constants';
13
13
  import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
14
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
14
15
  import { EthCheatCodes } from '@aztec/ethereum/test';
15
16
  import { SecretValue } from '@aztec/foundation/config';
16
17
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -21,7 +22,8 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
21
22
  import { SequencerState } from '@aztec/sequencer-client';
22
23
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
23
24
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
24
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
25
+ import { TxStatus } from '@aztec/stdlib/tx';
26
+ import type { GenesisData } from '@aztec/stdlib/world-state';
25
27
  import {
26
28
  type TelemetryClient,
27
29
  getConfigEnvVars as getTelemetryClientConfig,
@@ -40,11 +42,18 @@ import { DefaultMnemonic } from '../mnemonic.js';
40
42
  import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
41
43
  import { EpochTestSettler } from '../testing/epoch_test_settler.js';
42
44
  import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
45
+ import { publishStandardAuthRegistry } from './auth_registry.js';
43
46
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
44
47
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
45
48
 
46
49
  const logger = createLogger('local-network');
47
50
 
51
+ // The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
52
+ // proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
53
+ // pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
54
+ // P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
55
+ const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
56
+
48
57
  const localAnvil = foundry;
49
58
 
50
59
  /**
@@ -59,7 +68,7 @@ export async function deployContractsToL1(
59
68
  genesisArchiveRoot?: Fr;
60
69
  feeJuicePortalInitialBalance?: bigint;
61
70
  } = {},
62
- ) {
71
+ ): Promise<L1ContractAddresses> {
63
72
  await waitForPublicClient(aztecNodeConfig);
64
73
 
65
74
  const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
@@ -70,14 +79,14 @@ export async function deployContractsToL1(
70
79
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
71
80
  feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
72
81
  aztecTargetCommitteeSize: 0, // no committee in local network
73
- slasherFlavor: 'none', // no slashing in local network
82
+ slasherEnabled: false, // no slashing in local network
74
83
  realVerifier: false,
75
84
  });
76
85
 
77
- aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
86
+ Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
78
87
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
79
88
 
80
- return aztecNodeConfig.l1Contracts;
89
+ return l1Contracts.l1ContractAddresses;
81
90
  }
82
91
 
83
92
  /** Local network settings. */
@@ -151,7 +160,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
151
160
  ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
152
161
  ...prefundAddresses,
153
162
  ];
154
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
163
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
155
164
 
156
165
  const dateProvider = new TestDateProvider();
157
166
 
@@ -190,7 +199,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
190
199
  const telemetry = await initTelemetryClient(getTelemetryClientConfig());
191
200
  // Create a local blob client client inside the local network, no http connectivity
192
201
  const blobClient = createBlobClient();
193
- const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
202
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
194
203
 
195
204
  // Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
196
205
  // transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
@@ -205,6 +214,21 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
205
214
  SequencerState.SYNCHRONIZING,
206
215
  ]);
207
216
  watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
217
+ // Under proposer pipelining the L1 publish for slot N happens during wall-clock slot N,
218
+ // but the proposer for slot N has already built the checkpoint during slot N-1 and is
219
+ // waiting for L1 to advance. We need to fast-forward L1 to wake that wait — and the wait
220
+ // we have to break first is `waitForValidParentCheckpointOnL1`, which blocks the
221
+ // checkpoint_proposal_job's background submission task until the archiver has synced past
222
+ // the build slot. That wait happens *before* `PUBLISHING_CHECKPOINT` is set, so a hook on
223
+ // that state transition would be circular (L1 has to advance before the state we'd use to
224
+ // advance L1 fires). The earliest pre-wait signal is `block-proposed`, which the sequencer
225
+ // emits once each block is built. In sandbox single-block-per-slot mode this is
226
+ // effectively "checkpoint built", and the watcher warp is harmless if a subsequent
227
+ // assembly/validation/parent-wait step aborts: L1 just sits one slot ahead, which the
228
+ // cascade absorbs.
229
+ if (watcher) {
230
+ sequencer.on('block-proposed', ({ slot }) => watcher!.setProposedTargetSlot(Number(slot)));
231
+ }
208
232
  }
209
233
 
210
234
  let epochTestSettler: EpochTestSettler | undefined;
@@ -226,11 +250,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
226
250
  });
227
251
 
228
252
  userLog('Setting up funded test accounts...');
229
- const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
253
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts, setupWaitOpts);
230
254
  const accLogs = await createAccountLogs(accountManagers, wallet);
231
255
  userLog(accLogs.join(''));
232
256
 
233
- await setupBananaFPC(initialAccounts, wallet, userLog);
257
+ userLog('Publishing standard AuthRegistry contract...');
258
+ await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
259
+
260
+ await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
234
261
 
235
262
  userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
236
263
 
@@ -259,14 +286,13 @@ export async function createAztecNode(
259
286
  dateProvider?: DateProvider;
260
287
  proverBroker?: ProvingJobBroker;
261
288
  } = {},
262
- options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
289
+ options: { genesis?: GenesisData } = {},
263
290
  ) {
264
291
  // TODO(#12272): will clean this up. This is criminal.
265
- const { l1Contracts, ...rest } = getConfigEnvVars();
292
+ // Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
266
293
  const aztecNodeConfig: AztecNodeConfig = {
267
- ...rest,
294
+ ...getConfigEnvVars(),
268
295
  ...config,
269
- l1Contracts: { ...l1Contracts, ...config.l1Contracts },
270
296
  };
271
297
  const node = await AztecNodeService.createAndSync(
272
298
  aztecNodeConfig,
@@ -9,6 +9,11 @@ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
9
9
 
10
10
  import { type GetContractReturnType, getAddress, getContract } from 'viem';
11
11
 
12
+ export type AnvilTestWatcherOpts = {
13
+ isLocalNetwork?: boolean;
14
+ isMarkingAsProven?: boolean;
15
+ };
16
+
12
17
  /**
13
18
  * Represents a watcher for a rollup contract.
14
19
  *
@@ -17,7 +22,8 @@ import { type GetContractReturnType, getAddress, getContract } from 'viem';
17
22
  * block within the slot. And if so, it will time travel into the next slot.
18
23
  */
19
24
  export class AnvilTestWatcher {
20
- private isLocalNetwork: boolean = false;
25
+ private isLocalNetwork;
26
+ private isMarkingAsProven;
21
27
 
22
28
  private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
23
29
  private rollupCheatCodes: RollupCheatCodes;
@@ -29,8 +35,6 @@ export class AnvilTestWatcher {
29
35
 
30
36
  private logger: Logger = createLogger(`aztecjs:utils:watcher`);
31
37
 
32
- private isMarkingAsProven = true;
33
-
34
38
  // Optional callback to check if there are pending txs in the mempool.
35
39
  private getPendingTxCount?: () => Promise<number>;
36
40
 
@@ -40,11 +44,18 @@ export class AnvilTestWatcher {
40
44
  // Tracks when we first observed the current unfilled slot with pending txs (real wall time).
41
45
  private unfilledSlotFirstSeen?: { slot: number; realTime: number };
42
46
 
47
+ // Latest target slot for which the proposer has built a block destined for L1 but which has
48
+ // not yet been committed. Set by the proposer-pipelining hook from `block-proposed` events so
49
+ // the watcher can advance L1 (and the injected date provider) to the target slot ahead of the
50
+ // publisher's `sendRequestsAt` sleep, instead of waiting a full wall-clock slot.
51
+ private proposedTargetSlot?: number;
52
+
43
53
  constructor(
44
54
  private cheatcodes: EthCheatCodes,
45
55
  rollupAddress: EthAddress,
46
56
  l1Client: ViemClient,
47
57
  private dateProvider?: TestDateProvider,
58
+ opts: AnvilTestWatcherOpts = {},
48
59
  ) {
49
60
  this.rollup = getContract({
50
61
  address: getAddress(rollupAddress.toString()),
@@ -56,6 +67,9 @@ export class AnvilTestWatcher {
56
67
  rollupAddress,
57
68
  });
58
69
 
70
+ this.isLocalNetwork = opts.isLocalNetwork ?? false;
71
+ this.isMarkingAsProven = opts.isMarkingAsProven ?? true;
72
+
59
73
  this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
60
74
  }
61
75
 
@@ -78,6 +92,18 @@ export class AnvilTestWatcher {
78
92
  this.isSequencerBuilding = fn;
79
93
  }
80
94
 
95
+ /**
96
+ * Records the target slot for which the proposer has built a block destined for L1. Used by
97
+ * the local-network watcher to fast-forward L1 (and the injected date provider) ahead of the
98
+ * pipelined publisher's `sendRequestsAt` sleep so it ends promptly instead of waiting a full
99
+ * wall-clock slot. Only ratchets up — late warps for stale slots are no-ops.
100
+ */
101
+ setProposedTargetSlot(slot: number) {
102
+ if (this.proposedTargetSlot === undefined || slot > this.proposedTargetSlot) {
103
+ this.proposedTargetSlot = slot;
104
+ }
105
+ }
106
+
81
107
  async start() {
82
108
  if (this.filledRunningPromise) {
83
109
  throw new Error('Watcher already watching for filled slot');
@@ -169,6 +195,20 @@ export class AnvilTestWatcher {
169
195
  return;
170
196
  }
171
197
 
198
+ // Pipelined-publish shortcut: if the proposer has built a block destined for a slot
199
+ // beyond the current L1 slot, fast-forward L1 to that slot's timestamp so the publisher's
200
+ // `sendRequestsAt(targetSlot)` sleep ends and the multicall mines inside the target slot.
201
+ // Without this, the publisher waits up to a full real-time slot for wall clock to catch up.
202
+ if (this.proposedTargetSlot !== undefined && this.proposedTargetSlot > currentSlot) {
203
+ const targetSlotTimestamp = Number(
204
+ await this.rollup.read.getTimestampForSlot([BigInt(this.proposedTargetSlot)]),
205
+ );
206
+ if (await this.warpToTimestamp(targetSlotTimestamp)) {
207
+ this.logger.info(`Warped L1 to target slot ${this.proposedTargetSlot} for pipelined publish`);
208
+ }
209
+ return;
210
+ }
211
+
172
212
  // If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
173
213
  // sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
174
214
  // the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building