@aztec/aztec 0.0.1-commit.7035c9bd6 → 0.0.1-commit.71324e566

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 (53) hide show
  1. package/dest/cli/aztec_start_action.d.ts +1 -1
  2. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  3. package/dest/cli/aztec_start_action.js +12 -3
  4. package/dest/cli/aztec_start_options.d.ts +2 -2
  5. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  6. package/dest/cli/aztec_start_options.js +13 -0
  7. package/dest/cli/cmds/compile.d.ts +1 -1
  8. package/dest/cli/cmds/compile.d.ts.map +1 -1
  9. package/dest/cli/cmds/compile.js +3 -14
  10. package/dest/cli/cmds/standby.d.ts +1 -1
  11. package/dest/cli/cmds/standby.js +2 -2
  12. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  13. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  14. package/dest/cli/cmds/start_archiver.js +3 -1
  15. package/dest/cli/cmds/start_node.d.ts +1 -1
  16. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  17. package/dest/cli/cmds/start_node.js +6 -20
  18. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  19. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  20. package/dest/cli/cmds/start_prover_agent.js +3 -15
  21. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  22. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  23. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  24. package/dest/cli/cmds/utils/needs_recompile.d.ts +1 -1
  25. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -1
  26. package/dest/cli/cmds/utils/needs_recompile.js +9 -53
  27. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  28. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  29. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +62 -0
  30. package/dest/local-network/local-network.d.ts +3 -4
  31. package/dest/local-network/local-network.d.ts.map +1 -1
  32. package/dest/local-network/local-network.js +3 -3
  33. package/dest/testing/anvil_test_watcher.d.ts +1 -1
  34. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  35. package/dest/testing/anvil_test_watcher.js +36 -10
  36. package/dest/testing/cheat_codes.d.ts +11 -15
  37. package/dest/testing/cheat_codes.d.ts.map +1 -1
  38. package/dest/testing/cheat_codes.js +34 -32
  39. package/package.json +33 -33
  40. package/scripts/aztec.sh +1 -1
  41. package/src/cli/aztec_start_action.ts +6 -3
  42. package/src/cli/aztec_start_options.ts +19 -2
  43. package/src/cli/cmds/compile.ts +4 -17
  44. package/src/cli/cmds/standby.ts +2 -2
  45. package/src/cli/cmds/start_archiver.ts +7 -1
  46. package/src/cli/cmds/start_node.ts +9 -11
  47. package/src/cli/cmds/start_prover_agent.ts +3 -6
  48. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  49. package/src/cli/cmds/utils/needs_recompile.ts +8 -61
  50. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +77 -0
  51. package/src/local-network/local-network.ts +5 -5
  52. package/src/testing/anvil_test_watcher.ts +33 -10
  53. package/src/testing/cheat_codes.ts +42 -36
@@ -3,12 +3,13 @@ import type { LogFn } from '@aztec/foundation/log';
3
3
 
4
4
  import { execFileSync } from 'child_process';
5
5
  import type { Command } from 'commander';
6
- import { readFile, writeFile } from 'fs/promises';
6
+ import { readFile } from 'fs/promises';
7
7
  import { join } from 'path';
8
8
 
9
9
  import { readArtifactFiles } from './utils/artifacts.js';
10
10
  import { needsRecompile } from './utils/needs_recompile.js';
11
11
  import { run } from './utils/spawn.js';
12
+ import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
12
13
 
13
14
  /** Returns paths to contract artifacts in the target directory. */
14
15
  async function collectContractArtifacts(): Promise<string[]> {
@@ -24,19 +25,6 @@ async function collectContractArtifacts(): Promise<string[]> {
24
25
  return files.filter(f => Array.isArray(f.content.functions)).map(f => f.filePath);
25
26
  }
26
27
 
27
- /** Strips the `__aztec_nr_internals__` prefix from function names in contract artifacts. */
28
- async function stripInternalPrefixes(artifactPaths: string[]): Promise<void> {
29
- for (const path of artifactPaths) {
30
- const artifact = JSON.parse(await readFile(path, 'utf-8'));
31
- for (const fn of artifact.functions) {
32
- if (typeof fn.name === 'string') {
33
- fn.name = fn.name.replace(/^__aztec_nr_internals__/, '');
34
- }
35
- }
36
- await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
37
- }
38
- }
39
-
40
28
  /** Returns the set of package names that are contract crates in the current workspace. */
41
29
  async function getContractPackageNames(): Promise<Set<string>> {
42
30
  const contractNames = new Set<string>();
@@ -139,6 +127,8 @@ async function checkNoTestsInContracts(nargo: string, log: LogFn): Promise<void>
139
127
 
140
128
  /** Compiles Aztec Noir contracts and postprocesses artifacts. */
141
129
  async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<void> {
130
+ await warnIfAztecVersionMismatch(log);
131
+
142
132
  if (!(await needsRecompile())) {
143
133
  log('No source changes detected, skipping compilation.');
144
134
  return;
@@ -158,9 +148,6 @@ async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<vo
158
148
  log('Postprocessing contracts...');
159
149
  const bbArgs = artifacts.flatMap(a => ['-i', a]);
160
150
  await run(bb, ['aztec_process', ...bbArgs]);
161
-
162
- // TODO: This should be part of bb aztec_process!
163
- await stripInternalPrefixes(artifacts);
164
151
  }
165
152
 
166
153
  log('Compilation complete!');
@@ -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(
@@ -20,7 +20,13 @@ export async function startArchiver(
20
20
  const envConfig = getArchiverConfigFromEnv();
21
21
  const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
22
22
  options,
23
- { ...archiverConfigMappings, ...dataConfigMappings, ...blobClientConfigMapping },
23
+ {
24
+ // dataConfigMappings must come first: its l1Contracts only maps rollupAddress,
25
+ // while archiverConfigMappings (spread later) maps all L1 contract addresses.
26
+ ...dataConfigMappings,
27
+ ...archiverConfigMappings,
28
+ ...blobClientConfigMapping,
29
+ },
24
30
  'archiver',
25
31
  );
26
32
 
@@ -9,7 +9,11 @@ import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
9
9
  import type { LogFn } from '@aztec/foundation/log';
10
10
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
11
11
  import { protocolContractsHash } from '@aztec/protocol-contracts';
12
- import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
12
+ import {
13
+ ProvingJobConsumerSchema,
14
+ createProvingJobBrokerClient,
15
+ proverBrokerBackoff,
16
+ } from '@aztec/prover-client/broker';
13
17
  import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
14
18
  import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
15
19
  import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
@@ -65,12 +69,8 @@ export async function startNode(
65
69
  if (nodeConfig.proverBrokerUrl) {
66
70
  // at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
67
71
  // set a lower connection limit such that we don't overload the server
68
- // Keep retrying up to 30s
69
- const fetch = makeTracedFetch(
70
- [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
71
- false,
72
- makeUndiciFetch(new Agent({ connections: 100 })),
73
- );
72
+ // Retry indefinitely until the epoch proving times out and the chain reorgs
73
+ const fetch = makeTracedFetch(proverBrokerBackoff, false, makeUndiciFetch(new Agent({ connections: 100 })));
74
74
  broker = createProvingJobBrokerClient(nodeConfig.proverBrokerUrl, getVersions(nodeConfig), fetch);
75
75
  } else if (options.proverBroker) {
76
76
  ({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
@@ -83,7 +83,7 @@ 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';
@@ -116,12 +116,10 @@ export async function startNode(
116
116
  );
117
117
  }
118
118
 
119
- // TODO(#12272): will clean this up.
120
119
  nodeConfig = {
121
120
  ...nodeConfig,
122
121
  l1Contracts: {
123
122
  ...addresses,
124
- slashFactoryAddress: nodeConfig.l1Contracts.slashFactoryAddress,
125
123
  },
126
124
  ...config,
127
125
  };
@@ -158,7 +156,7 @@ export async function startNode(
158
156
  const telemetry = await initTelemetryClient(telemetryConfig);
159
157
 
160
158
  // Create and start Aztec Node
161
- const node = await createAztecNode(nodeConfig, { telemetry, proverBroker: broker }, { prefilledPublicData });
159
+ const node = await createAztecNode(nodeConfig, { telemetry, proverBroker: broker }, { genesis });
162
160
 
163
161
  // Add node and p2p to services list
164
162
  services.node = [node, AztecNodeApiSchema];
@@ -9,6 +9,7 @@ import {
9
9
  createProofStore,
10
10
  createProvingJobBrokerClient,
11
11
  proverAgentConfigMappings,
12
+ proverBrokerBackoff,
12
13
  } from '@aztec/prover-client/broker';
13
14
  import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node';
14
15
  import { ProverAgentApiSchema } from '@aztec/stdlib/interfaces/server';
@@ -45,12 +46,8 @@ export async function startProverAgent(
45
46
 
46
47
  await preloadCrsDataForServerSideProving(config, userLog);
47
48
 
48
- const fetch = makeTracedFetch(
49
- // retry connections every 3s, up to 30s before giving up
50
- [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
51
- false,
52
- makeUndiciFetch(new Agent({ connections: 10 })),
53
- );
49
+ // Retry indefinitely until the epoch proving times out and the chain reorgs
50
+ const fetch = makeTracedFetch(proverBrokerBackoff, false, makeUndiciFetch(new Agent({ connections: 10 })));
54
51
  const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
55
52
 
56
53
  const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
@@ -0,0 +1,118 @@
1
+ import TOML from '@iarna/toml';
2
+ import { existsSync } from 'fs';
3
+ import { mkdir, readFile, stat } from 'fs/promises';
4
+ import { homedir } from 'os';
5
+ import { dirname, join, resolve } from 'path';
6
+
7
+ import { run } from './spawn.js';
8
+
9
+ /**
10
+ * Recursively collects crate directories starting from startCrateDir by following dependencies declared in Nargo.toml
11
+ * files.
12
+ *
13
+ * When `skipGitDeps` is false (default), git-based deps are followed and fetched into the nargo cache
14
+ * (`$HOME/nargo/<domain>/<repo-path>/<tag>`) if not already present.
15
+ *
16
+ * When `skipGitDeps` is true, git-based deps are ignored entirely.
17
+ */
18
+ export async function collectCrateDirs(startCrateDir: string, opts?: { skipGitDeps?: boolean }): Promise<string[]> {
19
+ const { skipGitDeps = false } = opts ?? {};
20
+ const visited = new Set<string>();
21
+
22
+ async function visit(crateDir: string): Promise<void> {
23
+ const absDir = resolve(crateDir);
24
+ if (visited.has(absDir)) {
25
+ return;
26
+ }
27
+ visited.add(absDir);
28
+
29
+ const tomlPath = join(absDir, 'Nargo.toml');
30
+ const content = await readFile(tomlPath, 'utf-8').catch(() => {
31
+ throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
32
+ });
33
+
34
+ const parsed = TOML.parse(content) as Record<string, any>;
35
+ const members = (parsed.workspace as Record<string, any>)?.members as string[] | undefined;
36
+
37
+ // A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
38
+ if (Array.isArray(members)) {
39
+ // The crate is a workspace root and has members defined so we visit the members
40
+ for (const member of members) {
41
+ await visit(resolve(absDir, member));
42
+ }
43
+ } else {
44
+ // Single crate — follow its deps
45
+ const deps = (parsed.dependencies as Record<string, any>) ?? {};
46
+ for (const dep of Object.values(deps)) {
47
+ if (!dep || typeof dep !== 'object') {
48
+ continue;
49
+ }
50
+ if (typeof dep.path === 'string') {
51
+ // Dependency contains "path" hence it's a local dependency. We just check it's a real directory and then we
52
+ // recursively search through it
53
+ const depPath = resolve(absDir, dep.path);
54
+ const s = await stat(depPath);
55
+ if (!s.isDirectory()) {
56
+ throw new Error(
57
+ `Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`,
58
+ );
59
+ }
60
+ await visit(depPath);
61
+ } else if (!skipGitDeps && typeof dep.git === 'string' && typeof dep.tag === 'string') {
62
+ // Dependency contains "git" hence it's a git dependency. We ensure it has been fetched and fetch it if
63
+ // it's not the case and then we recursively search through it.
64
+ await fetchAndVisit(dep.git, dep.tag, dep.directory);
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ async function fetchAndVisit(gitUrl: string, tag: string, directory?: string): Promise<void> {
71
+ // `directory` is set when the dep lives in a subdirectory of a repository, e.g.:
72
+ // aztec = { git = "https://github.com/AztecProtocol/aztec-packages", tag = "v0.82.0",
73
+ // directory = "noir-projects/aztec-nr/aztec" }
74
+ // In that case nargo clones the whole repo and the crate root is <cachePath>/<directory>.
75
+ const cachePath = nargoGitDepPath(gitUrl, tag);
76
+ const crateDir = directory ? join(cachePath, directory) : cachePath;
77
+ await ensureGitDepCached(gitUrl, tag, cachePath);
78
+ await visit(crateDir);
79
+ }
80
+
81
+ await visit(startCrateDir);
82
+ return [...visited];
83
+ }
84
+
85
+ /**
86
+ * Computes the local nargo cache path for a git dependency, mirroring nargo's own `git_dep_location` function.
87
+ * Path format: `$HOME/nargo/<domain>/<repo-path>/<tag>`
88
+ * e.g. `~/nargo/github.com/AztecProtocol/aztec-packages/v0.82.0`
89
+ *
90
+ * Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
91
+ */
92
+ export function nargoGitDepPath(gitUrl: string, tag: string): string {
93
+ const url = new URL(gitUrl);
94
+ const domain = url.hostname;
95
+ const repoPath = url.pathname.replace(/^\//, '');
96
+ return join(process.env.HOME ?? homedir(), 'nargo', domain, repoPath, tag);
97
+ }
98
+
99
+ /**
100
+ * Ensures a git dep is present in the nargo cache, cloning it if it isn't. Mirrors nargo's `clone_git_repo`.
101
+ * If cloning fails (e.g. no network), throws with a message suggesting `nargo check` to prime the cache.
102
+ *
103
+ * Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
104
+ */
105
+ async function ensureGitDepCached(gitUrl: string, tag: string, cachePath: string): Promise<void> {
106
+ if (existsSync(cachePath)) {
107
+ return;
108
+ }
109
+ await mkdir(dirname(cachePath), { recursive: true });
110
+ try {
111
+ await run('git', ['-c', 'advice.detachedHead=false', 'clone', '--depth', '1', '--branch', tag, gitUrl, cachePath]);
112
+ } catch (err: any) {
113
+ throw new Error(
114
+ `Failed to fetch git dependency ${gitUrl}@${tag}: ${err?.message ?? err}.\n` +
115
+ `Try running \`nargo check\` first to prime the dependency cache.`,
116
+ );
117
+ }
118
+ }
@@ -1,6 +1,7 @@
1
- import TOML from '@iarna/toml';
2
- import { readFile, readdir, stat } from 'fs/promises';
3
- import { join, resolve } from 'path';
1
+ import { readdir, stat } from 'fs/promises';
2
+ import { join } from 'path';
3
+
4
+ import { collectCrateDirs } from './collect_crate_dirs.js';
4
5
 
5
6
  /**
6
7
  * Returns true if recompilation is needed: either no artifacts exist in target/ or any .nr or Nargo.toml source file
@@ -16,7 +17,10 @@ export async function needsRecompile(): Promise<boolean> {
16
17
  return true;
17
18
  }
18
19
 
19
- const crateDirs = await collectCrateDirs('.');
20
+ // Git deps are pinned to a specific tag in Nargo.toml and nargo always fetches an exact tag, so their contents never
21
+ // change without Nargo.toml itself changing — and Nargo.toml is already tracked as a source file. Hence we can
22
+ // safely ignore checking source files of git deps.
23
+ const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
20
24
  return hasNewerSourceFile(crateDirs, oldestArtifactMs);
21
25
  }
22
26
 
@@ -49,63 +53,6 @@ async function getOldestArtifactModificationTime(targetDir: string): Promise<num
49
53
  return oldest;
50
54
  }
51
55
 
52
- /**
53
- * Recursively collects crate directories starting from startCrateDir by following path-based dependencies declared in
54
- * Nargo.toml files. Git-based deps are ignored (they only change when Nargo.toml itself is modified since the deps are
55
- * tagged).
56
- */
57
- async function collectCrateDirs(startCrateDir: string): Promise<string[]> {
58
- // We have a set of visited dirs we check against when entering a new dir because we could stumble upon a directory
59
- // multiple times in case multiple deps shared a dep (e.g. dep A and dep B both sharing dep C).
60
- const visited = new Set<string>();
61
-
62
- async function visit(crateDir: string): Promise<void> {
63
- const absDir = resolve(crateDir);
64
- if (visited.has(absDir)) {
65
- return;
66
- }
67
- visited.add(absDir);
68
-
69
- // Every dep is its own crate and every crate needs to have Nargo.toml defined in the root so we try to load it and
70
- // error out if it's not the case.
71
- const tomlPath = join(absDir, 'Nargo.toml');
72
- const content = await readFile(tomlPath, 'utf-8').catch(() => {
73
- throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
74
- });
75
-
76
- const parsed = TOML.parse(content) as Record<string, any>;
77
-
78
- const members = (parsed.workspace as Record<string, any>)?.members as string[] | undefined;
79
-
80
- // A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
81
- if (Array.isArray(members)) {
82
- // The crate is a workspace root and has members defined so we visit the members
83
- for (const member of members) {
84
- const memberPath = resolve(absDir, member);
85
- await visit(memberPath);
86
- }
87
- } else {
88
- // The crate is not a workspace root so we check for dependencies
89
- const deps = (parsed.dependencies as Record<string, any>) ?? {};
90
- for (const dep of Object.values(deps)) {
91
- if (dep && typeof dep === 'object' && typeof dep.path === 'string') {
92
- const depPath = resolve(absDir, dep.path);
93
- const s = await stat(depPath);
94
- if (!s.isDirectory()) {
95
- throw new Error(
96
- `Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`,
97
- );
98
- }
99
- await visit(depPath);
100
- }
101
- }
102
- }
103
- }
104
-
105
- await visit(startCrateDir);
106
- return [...visited];
107
- }
108
-
109
56
  /**
110
57
  * Walks crate dirs looking for .nr and Nargo.toml files newer than thresholdMs. Short-circuits on the first match.
111
58
  */
@@ -0,0 +1,77 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
3
+
4
+ import TOML from '@iarna/toml';
5
+ import { readFile } from 'fs/promises';
6
+ import { join } from 'path';
7
+
8
+ import { collectCrateDirs } from './collect_crate_dirs.js';
9
+
10
+ /** Returns true if the given git URL points to the AztecProtocol/aztec-nr repository. */
11
+ function isAztecNrGitUrl(gitUrl: string): boolean {
12
+ let url: URL;
13
+ try {
14
+ url = new URL(gitUrl);
15
+ } catch {
16
+ return false;
17
+ }
18
+ if (url.hostname !== 'github.com') {
19
+ return false;
20
+ }
21
+ const repoPath = url.pathname
22
+ .replace(/^\//, '')
23
+ .replace(/\.git$/, '')
24
+ .replace(/\/$/, '');
25
+ return repoPath === 'AztecProtocol/aztec-nr';
26
+ }
27
+
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
+ export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
30
+ const version = cliVersion ?? getPackageVersion();
31
+ if (!version) {
32
+ log(`WARNING: aztec CLI version not found. Skipping dependency compatibility check.`);
33
+ return;
34
+ }
35
+
36
+ const expectedTag = `v${version}`;
37
+ const mismatches: { file: string; depName: string; tag: string }[] = [];
38
+
39
+ const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
40
+
41
+ for (const dir of crateDirs) {
42
+ const tomlPath = join(dir, 'Nargo.toml');
43
+ let content: string;
44
+ try {
45
+ content = await readFile(tomlPath, 'utf-8');
46
+ } catch {
47
+ continue;
48
+ }
49
+
50
+ const parsed = TOML.parse(content) as Record<string, any>;
51
+ const deps = (parsed.dependencies as Record<string, any>) ?? {};
52
+
53
+ for (const [depName, dep] of Object.entries(deps)) {
54
+ // Skip non-object deps (e.g. malformed entries) and anything that isn't a tagged git dep.
55
+ if (!dep || typeof dep !== 'object' || typeof dep.git !== 'string' || typeof dep.tag !== 'string') {
56
+ continue;
57
+ }
58
+ // Only flag deps that are sourced from the aztec-nr repo.
59
+ if (!isAztecNrGitUrl(dep.git)) {
60
+ continue;
61
+ }
62
+ if (dep.tag !== expectedTag) {
63
+ mismatches.push({ file: tomlPath, depName, tag: dep.tag });
64
+ }
65
+ }
66
+ }
67
+
68
+ if (mismatches.length > 0) {
69
+ const details = mismatches.map(m => ` ${m.file} — ${m.depName} (${m.tag})`).join('\n');
70
+ log(
71
+ `WARNING: Aztec dependency version mismatch detected.\n` +
72
+ `The following aztec-nr dependencies do not match the CLI version (${expectedTag}):\n` +
73
+ `${details}\n\n` +
74
+ `See https://docs.aztec.network/errors/9 for how to update your dependencies.`,
75
+ );
76
+ }
77
+ }
@@ -21,7 +21,7 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
21
21
  import { SequencerState } from '@aztec/sequencer-client';
22
22
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
23
23
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
24
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
24
+ import type { GenesisData } from '@aztec/stdlib/world-state';
25
25
  import {
26
26
  type TelemetryClient,
27
27
  getConfigEnvVars as getTelemetryClientConfig,
@@ -70,7 +70,7 @@ export async function deployContractsToL1(
70
70
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
71
71
  feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
72
72
  aztecTargetCommitteeSize: 0, // no committee in local network
73
- slasherFlavor: 'none', // no slashing in local network
73
+ slasherEnabled: false, // no slashing in local network
74
74
  realVerifier: false,
75
75
  });
76
76
 
@@ -151,7 +151,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
151
151
  ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
152
152
  ...prefundAddresses,
153
153
  ];
154
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
154
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
155
155
 
156
156
  const dateProvider = new TestDateProvider();
157
157
 
@@ -190,7 +190,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
190
190
  const telemetry = await initTelemetryClient(getTelemetryClientConfig());
191
191
  // Create a local blob client client inside the local network, no http connectivity
192
192
  const blobClient = createBlobClient();
193
- const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
193
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
194
194
 
195
195
  // Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
196
196
  // transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
@@ -259,7 +259,7 @@ export async function createAztecNode(
259
259
  dateProvider?: DateProvider;
260
260
  proverBroker?: ProvingJobBroker;
261
261
  } = {},
262
- options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
262
+ options: { genesis?: GenesisData } = {},
263
263
  ) {
264
264
  // TODO(#12272): will clean this up. This is criminal.
265
265
  const { l1Contracts, ...rest } = getConfigEnvVars();
@@ -130,14 +130,21 @@ export class AnvilTestWatcher {
130
130
  return;
131
131
  }
132
132
 
133
- const l1Time = (await this.cheatcodes.timestamp()) * 1000;
133
+ const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
134
134
  const wallTime = this.dateProvider.now();
135
135
  if (l1Time > wallTime) {
136
136
  this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
137
137
  this.dateProvider.setTime(l1Time);
138
138
  } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
139
- this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
140
- await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
139
+ // Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
140
+ // `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
141
+ // `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
142
+ // a second apart and one of them is then rejected by anvil as non-monotonic.
143
+ const wallSec = Math.floor(wallTime / 1000);
144
+ const targetSlot = await this.rollup.read.getSlotAt([BigInt(wallSec)]);
145
+ const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([targetSlot]));
146
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
147
+ await this.warpToTimestamp(targetTimestamp);
141
148
  }
142
149
  }
143
150
 
@@ -151,8 +158,9 @@ export class AnvilTestWatcher {
151
158
 
152
159
  if (BigInt(currentSlot) === checkpointLog.slotNumber) {
153
160
  // The current slot has been filled, we should jump to the next slot.
154
- await this.warpToTimestamp(nextSlotTimestamp);
155
- this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
161
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
162
+ this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
163
+ }
156
164
  return;
157
165
  }
158
166
 
@@ -180,9 +188,10 @@ export class AnvilTestWatcher {
180
188
  }
181
189
 
182
190
  if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
183
- await this.warpToTimestamp(nextSlotTimestamp);
191
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
192
+ this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
193
+ }
184
194
  this.unfilledSlotFirstSeen = undefined;
185
- this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
186
195
  }
187
196
 
188
197
  return;
@@ -192,19 +201,33 @@ export class AnvilTestWatcher {
192
201
  // Fallback: warp when the dateProvider time has passed the next slot timestamp.
193
202
  const currentTimestamp = this.dateProvider?.now() ?? Date.now();
194
203
  if (currentTimestamp > nextSlotTimestamp * 1000) {
195
- await this.warpToTimestamp(nextSlotTimestamp);
196
- this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
204
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
205
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
206
+ }
197
207
  }
198
208
  } catch {
199
209
  this.logger.error('mineIfSlotFilled failed');
200
210
  }
201
211
  }
202
212
 
203
- private async warpToTimestamp(timestamp: number) {
213
+ /**
214
+ * Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
215
+ * happened, false when skipped or on error. Callers use the return value to gate success logs.
216
+ */
217
+ private async warpToTimestamp(timestamp: number): Promise<boolean> {
204
218
  try {
219
+ // Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
220
+ // watcher loops can race and pick targets a fraction of a second apart; skip here rather than
221
+ // letting the second one error out noisily.
222
+ const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
223
+ if (timestamp <= lastTimestamp) {
224
+ return false;
225
+ }
205
226
  await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
227
+ return true;
206
228
  } catch (e) {
207
229
  this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
230
+ return false;
208
231
  }
209
232
  }
210
233
  }