@aztec/aztec 0.0.1-commit.381b1a9 → 0.0.1-commit.3a4ae741b

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 (41) 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 +5 -1
  4. package/dest/cli/aztec_start_options.js +1 -1
  5. package/dest/cli/cli.js +3 -3
  6. package/dest/cli/cmds/compile.d.ts +1 -1
  7. package/dest/cli/cmds/compile.d.ts.map +1 -1
  8. package/dest/cli/cmds/compile.js +99 -1
  9. package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
  10. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
  11. package/dest/cli/cmds/profile_flamegraph.js +2 -1
  12. package/dest/cli/cmds/profile_gates.d.ts +1 -1
  13. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  14. package/dest/cli/cmds/profile_gates.js +2 -1
  15. package/dest/cli/cmds/start_archiver.d.ts +2 -2
  16. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  17. package/dest/cli/cmds/start_archiver.js +1 -1
  18. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  19. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  20. package/dest/cli/cmds/utils/needs_recompile.js +134 -0
  21. package/dest/cli/util.js +3 -3
  22. package/dest/testing/anvil_test_watcher.js +1 -1
  23. package/dest/testing/cheat_codes.js +1 -1
  24. package/package.json +34 -34
  25. package/scripts/add_crate.sh +102 -0
  26. package/scripts/aztec.sh +4 -2
  27. package/scripts/init.sh +23 -19
  28. package/scripts/new.sh +48 -24
  29. package/scripts/setup_workspace.sh +68 -0
  30. package/src/cli/aztec_start_action.ts +2 -1
  31. package/src/cli/aztec_start_options.ts +1 -1
  32. package/src/cli/cli.ts +3 -3
  33. package/src/cli/cmds/compile.ts +112 -1
  34. package/src/cli/cmds/profile_flamegraph.ts +2 -1
  35. package/src/cli/cmds/profile_gates.ts +2 -1
  36. package/src/cli/cmds/start_archiver.ts +1 -1
  37. package/src/cli/cmds/utils/needs_recompile.ts +151 -0
  38. package/src/cli/util.ts +2 -2
  39. package/src/testing/anvil_test_watcher.ts +1 -1
  40. package/src/testing/cheat_codes.ts +1 -1
  41. package/scripts/setup_project.sh +0 -31
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Creates a contract+test crate pair and adds them to an existing workspace.
5
+ # Usage: add_crate.sh <crate_name>
6
+ # Must be called from a workspace root that already has Nargo.toml with [workspace].
7
+
8
+ crate_name=$1
9
+
10
+ if [ -z "$crate_name" ]; then
11
+ echo "Error: crate name is required"
12
+ exit 1
13
+ fi
14
+
15
+ if [[ "$crate_name" == *"/"* ]] || [[ "$crate_name" == *"\\"* ]]; then
16
+ echo "Error: crate name must not contain path separators"
17
+ exit 1
18
+ fi
19
+
20
+ contract_dir="${crate_name}_contract"
21
+ test_dir="${crate_name}_test"
22
+
23
+ if [ -d "$contract_dir" ]; then
24
+ echo "Error: directory '$contract_dir' already exists"
25
+ exit 1
26
+ fi
27
+ if [ -d "$test_dir" ]; then
28
+ echo "Error: directory '$test_dir' already exists"
29
+ exit 1
30
+ fi
31
+
32
+ # Get the actual aztec version for the git tag.
33
+ AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
34
+
35
+ # Create contract crate
36
+ mkdir -p "$contract_dir/src"
37
+ cat > "$contract_dir/Nargo.toml" << CEOF
38
+ [package]
39
+ name = "${crate_name}_contract"
40
+ type = "contract"
41
+
42
+ [dependencies]
43
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
44
+ CEOF
45
+
46
+ cat > "$contract_dir/src/main.nr" << 'EOF'
47
+ use aztec::macros::aztec;
48
+
49
+ #[aztec]
50
+ pub contract Main {
51
+ use aztec::macros::functions::{external, initializer};
52
+
53
+ #[initializer]
54
+ #[external("private")]
55
+ fn constructor() {}
56
+ }
57
+ EOF
58
+
59
+ # Create test crate
60
+ mkdir -p "$test_dir/src"
61
+ cat > "$test_dir/Nargo.toml" << TEOF
62
+ [package]
63
+ name = "${crate_name}_test"
64
+ type = "lib"
65
+
66
+ [dependencies]
67
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
68
+ ${crate_name}_contract = { path = "../${contract_dir}" }
69
+ TEOF
70
+
71
+ cat > "$test_dir/src/lib.nr" << 'NOIR'
72
+ use aztec::test::helpers::test_environment::TestEnvironment;
73
+ use __CRATE_NAME___contract::Main;
74
+
75
+ #[test]
76
+ unconstrained fn test_constructor() {
77
+ let mut env = TestEnvironment::new();
78
+ let deployer = env.create_light_account();
79
+
80
+ // Deploy the contract with the default constructor:
81
+ let contract_address = env.deploy("@__CRATE_NAME___contract/Main").with_private_initializer(
82
+ deployer,
83
+ Main::interface().constructor(),
84
+ );
85
+
86
+ // Deploy without an initializer:
87
+ let contract_address = env.deploy("@__CRATE_NAME___contract/Main").without_initializer();
88
+ }
89
+ NOIR
90
+
91
+ sed -i "s/__CRATE_NAME__/${crate_name}/g" "$test_dir/src/lib.nr"
92
+
93
+ # Add members to workspace Nargo.toml
94
+ if grep -q 'members\s*=\s*\[\s*\]' Nargo.toml; then
95
+ # Empty array: members = []
96
+ sed -i "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
97
+ else
98
+ # Non-empty array: add before closing ]
99
+ sed -i "s|\(members\s*=\s*\[.*\)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
100
+ fi
101
+
102
+ echo "Created crates '${contract_dir}' and '${test_dir}'"
package/scripts/aztec.sh CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- shopt -s inherit_errexit
4
3
 
5
4
  # Re-execute using correct version if we have an .aztecrc file.
6
5
  if [ "${AZTEC_VERSIONED:-0}" -eq 0 ] && [ -f .aztecrc ] && command -v aztec-up &>/dev/null; then
@@ -21,6 +20,9 @@ function aztec {
21
20
 
22
21
  case $cmd in
23
22
  test)
23
+ # Attempt to compile, no-op if there are no changes
24
+ node --no-warnings "$script_dir/../dest/bin/index.js" compile
25
+
24
26
  export LOG_LEVEL="${LOG_LEVEL:-"error;trace:contract_log"}"
25
27
  aztec start --txe --port 8081 &
26
28
  server_pid=$!
@@ -47,7 +49,7 @@ case $cmd in
47
49
  export ETHEREUM_HOSTS=${ETHEREUM_HOSTS:-"http://127.0.0.1:${ANVIL_PORT}"}
48
50
 
49
51
  anvil --version
50
- anvil --silent &
52
+ anvil --silent --port "$ANVIL_PORT" &
51
53
  anvil_pid=$!
52
54
  trap 'kill $anvil_pid &>/dev/null' EXIT
53
55
  fi
package/scripts/init.sh CHANGED
@@ -1,35 +1,39 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- NARGO=${NARGO:-nargo}
5
4
  script_path=$(realpath $(dirname "$0"))
6
5
 
7
- for arg in "$@"; do
8
- if [ "$arg" == "--help" ] || [ "$arg" == "-h" ]; then
9
- cat << 'EOF'
6
+ # Parse arguments
7
+ while [[ $# -gt 0 ]]; do
8
+ case $1 in
9
+ --help|-h)
10
+ cat << 'EOF'
10
11
  Aztec Init - Create a new Aztec Noir project in the current directory
11
12
 
12
- Usage: aztec init [OPTIONS]
13
+ Usage: aztec init
13
14
 
14
15
  Options:
15
- --name <NAME> Name of the package [default: current directory name]
16
- --lib Use a library template
17
16
  -h, --help Print help
18
17
 
19
- This command creates a new Aztec Noir project in the current directory using nargo
20
- and automatically adds the Aztec.nr dependency to your Nargo.toml file.
18
+ This command creates a new Aztec Noir project in the current directory with
19
+ a workspace containing a contract crate and a test crate, and automatically
20
+ adds the Aztec.nr dependency to both.
21
21
 
22
+ If a workspace already exists in the current directory, use
23
+ 'aztec new <name>' instead to add another contract.
22
24
  EOF
23
- exit 0
24
- fi
25
- if [ "$arg" == "--lib" ]; then
26
- is_contract=0
27
- fi
25
+ exit 0
26
+ ;;
27
+ *)
28
+ echo "Error: unexpected argument '$1'"
29
+ echo "Usage: aztec init"
30
+ echo "Run 'aztec init --help' for more information"
31
+ exit 1
32
+ ;;
33
+ esac
28
34
  done
29
35
 
30
- echo "Initializing Noir project..."
31
- $NARGO init "$@"
36
+ package_name="$(basename $(pwd))"
32
37
 
33
- if [ "${is_contract:-1}" -eq 1 ]; then
34
- $script_path/setup_project.sh
35
- fi
38
+ echo "Initializing Aztec contract project..."
39
+ $script_path/setup_workspace.sh "$package_name"
package/scripts/new.sh CHANGED
@@ -1,59 +1,83 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- NARGO=${NARGO:-nargo}
5
4
  script_path=$(realpath $(dirname "$0"))
6
5
 
7
- type_arg="--contract"
6
+ project_path=""
8
7
 
9
8
  while [[ $# -gt 0 ]]; do
10
9
  case $1 in
11
10
  --help|-h)
12
11
  cat << 'EOF'
13
- Aztec New - Create a new Aztec Noir project in a new directory
12
+ Aztec New - Create a new Aztec Noir project or add a contract to an existing workspace
14
13
 
15
- Usage: aztec new [OPTIONS] <PATH>
14
+ Usage: aztec new <NAME>
16
15
 
17
16
  Arguments:
18
- <PATH> The path to save the new project
17
+ <NAME> The name for the new contract (also used as the directory name when
18
+ creating a new workspace)
19
19
 
20
20
  Options:
21
- --name <NAME> Name of the package [default: package directory name]
22
- --lib Create a library template instead of a contract
23
21
  -h, --help Print help
24
22
 
25
- This command creates a new Aztec Noir project using nargo and automatically
26
- adds the Aztec.nr dependency to your Nargo.toml file.
23
+ When run outside an existing workspace:
24
+ Creates a new directory with a workspace containing a contract crate and a
25
+ test crate, and automatically adds the Aztec.nr dependency to both.
26
+
27
+ When run inside an existing workspace (Nargo.toml with [workspace] exists):
28
+ Adds a new contract crate and test crate to the existing workspace.
27
29
  EOF
28
30
  exit 0
29
31
  ;;
30
- --lib)
31
- type_arg="--lib"
32
- shift
33
- ;;
34
- --name)
35
- name_arg="--name $2"
36
- shift 2
32
+ -*)
33
+ echo "Error: unknown option '$1'"
34
+ echo "Usage: aztec new <NAME>"
35
+ echo "Run 'aztec new --help' for more information"
36
+ exit 1
37
37
  ;;
38
38
  *)
39
+ if [ -n "$project_path" ]; then
40
+ echo "Error: unexpected argument '$1'"
41
+ echo "Usage: aztec new <NAME>"
42
+ echo "Run 'aztec new --help' for more information"
43
+ exit 1
44
+ fi
39
45
  project_path=$1
40
46
  shift
41
- break
42
47
  ;;
43
48
  esac
44
49
  done
45
50
 
46
51
  if [ -z "$project_path" ]; then
47
- echo "Error: PATH argument is required"
48
- echo "Usage: aztec new [OPTIONS] <PATH>"
52
+ echo "Error: NAME argument is required"
53
+ echo "Usage: aztec new <NAME>"
49
54
  echo "Run 'aztec new --help' for more information"
50
55
  exit 1
51
56
  fi
52
57
 
53
- echo "Creating new Noir project at $project_path..."
54
- $NARGO new $type_arg ${name_arg:-} $project_path
58
+ package_name="$(basename $project_path)"
59
+
60
+ # Validate that the name contains only valid Noir identifier characters
61
+ if ! [[ "$package_name" =~ ^[a-zA-Z][a-zA-Z0-9_]*$ ]]; then
62
+ echo "Error: '$package_name' is not a valid contract name"
63
+ echo "Name must start with a letter and contain only letters, digits, and underscores"
64
+ exit 1
65
+ fi
66
+
67
+ # Check if we're inside an existing workspace
68
+ if [ -f "Nargo.toml" ] && grep -q '\[workspace\]' Nargo.toml; then
69
+ # Add crate pair to existing workspace
70
+ echo "Adding contract '$package_name' to existing workspace..."
71
+ $script_path/add_crate.sh "$package_name"
72
+ else
73
+ # Create new workspace
74
+ if [ -d "$project_path" ] && [ "$(ls -A $project_path 2>/dev/null)" ]; then
75
+ echo "Error: $project_path already exists and is not empty"
76
+ exit 1
77
+ fi
55
78
 
56
- if [ "$type_arg" == "--contract" ]; then
57
- cd $project_path
58
- $script_path/setup_project.sh
79
+ echo "Creating new Aztec contract project at $project_path..."
80
+ mkdir -p "$project_path"
81
+ cd "$project_path"
82
+ $script_path/setup_workspace.sh "$package_name"
59
83
  fi
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Creates an Aztec contract workspace with a contract crate and a test crate.
5
+ # Usage: setup_workspace.sh <package_name>
6
+ # Must be called from the workspace root directory.
7
+
8
+ package_name=$1
9
+ script_path=$(realpath $(dirname "$0"))
10
+
11
+ if [ -z "$package_name" ]; then
12
+ echo "Error: package name is required"
13
+ exit 1
14
+ fi
15
+
16
+ if [ -f "Nargo.toml" ]; then
17
+ echo "Error: Nargo.toml already exists in the current directory."
18
+ echo "To add another contract crate to this workspace, use 'aztec new <name>' instead."
19
+ exit 1
20
+ fi
21
+
22
+ # Create workspace root Nargo.toml with empty members (add_crate.sh will populate)
23
+ cat > Nargo.toml << 'EOF'
24
+ [workspace]
25
+ members = []
26
+ EOF
27
+
28
+ # Create the first crate pair
29
+ $script_path/add_crate.sh "$package_name"
30
+
31
+ # Create README
32
+ cat > README.md << REOF
33
+ # ${package_name}
34
+
35
+ An Aztec Noir contract project.
36
+
37
+ ## Compile
38
+
39
+ \`\`\`bash
40
+ aztec compile
41
+ \`\`\`
42
+
43
+ This compiles all contract crates and outputs artifacts to \`target/\`.
44
+
45
+ ## Test
46
+
47
+ \`\`\`bash
48
+ aztec test
49
+ \`\`\`
50
+
51
+ This runs all tests in the workspace.
52
+
53
+ ## Generate TypeScript bindings
54
+
55
+ \`\`\`bash
56
+ aztec codegen target -o src/artifacts
57
+ \`\`\`
58
+
59
+ This generates TypeScript contract artifacts from the compiled output in \`target/\` into \`src/artifacts/\`.
60
+ REOF
61
+
62
+ # Create .gitignore
63
+ cat > .gitignore << 'GEOF'
64
+ target/
65
+ codegenCache.json
66
+ GEOF
67
+
68
+ echo "Created Aztec contract workspace with crates '${package_name}_contract' and '${package_name}_test'"
@@ -7,7 +7,7 @@ import {
7
7
  } from '@aztec/foundation/json-rpc/server';
8
8
  import type { LogFn, Logger } from '@aztec/foundation/log';
9
9
  import type { ChainConfig } from '@aztec/stdlib/config';
10
- import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
10
+ import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
11
11
  import { getPackageVersion } from '@aztec/stdlib/update-checker';
12
12
  import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
13
13
  import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
@@ -50,6 +50,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
50
50
  // Start Node and PXE JSON-RPC server
51
51
  signalHandlers.push(stop);
52
52
  services.node = [node, AztecNodeApiSchema];
53
+ adminServices.node = [node, AztecNodeAdminApiSchema];
53
54
  } else {
54
55
  // Route --prover-node through startNode
55
56
  if (options.proverNode && !options.node) {
@@ -12,7 +12,6 @@ import {
12
12
  isBooleanConfigValue,
13
13
  omitConfigMappings,
14
14
  } from '@aztec/foundation/config';
15
- import { dataConfigMappings } from '@aztec/kv-store/config';
16
15
  import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
17
16
  import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
18
17
  import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker/config';
@@ -20,6 +19,7 @@ import { proverNodeConfigMappings } from '@aztec/prover-node/config';
20
19
  import { allPxeConfigMappings } from '@aztec/pxe/config';
21
20
  import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
22
21
  import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
22
+ import { dataConfigMappings } from '@aztec/stdlib/kv-store';
23
23
  import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
24
24
  import { worldStateConfigMappings } from '@aztec/world-state/config';
25
25
 
package/src/cli/cli.ts CHANGED
@@ -37,9 +37,9 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
37
37
  `
38
38
  Additional commands:
39
39
 
40
- init [folder] [options] creates a new Aztec Noir project.
41
- new <path> [options] creates a new Aztec Noir project in a new directory.
42
- test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
40
+ init creates a new Aztec Noir workspace in the current directory.
41
+ new <name> creates a new Aztec Noir workspace in its own directory (or creates a new contract-test crates pair and adds it to the current workspace if run in workspace).
42
+ test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
43
43
  `,
44
44
  );
45
45
  }
@@ -1,10 +1,13 @@
1
+ import { findBbBinary } from '@aztec/bb.js';
1
2
  import type { LogFn } from '@aztec/foundation/log';
2
3
 
3
4
  import { execFileSync } from 'child_process';
4
5
  import type { Command } from 'commander';
5
6
  import { readFile, writeFile } from 'fs/promises';
7
+ import { join } from 'path';
6
8
 
7
9
  import { readArtifactFiles } from './utils/artifacts.js';
10
+ import { needsRecompile } from './utils/needs_recompile.js';
8
11
  import { run } from './utils/spawn.js';
9
12
 
10
13
  /** Returns paths to contract artifacts in the target directory. */
@@ -34,13 +37,121 @@ async function stripInternalPrefixes(artifactPaths: string[]): Promise<void> {
34
37
  }
35
38
  }
36
39
 
40
+ /** Returns the set of package names that are contract crates in the current workspace. */
41
+ async function getContractPackageNames(): Promise<Set<string>> {
42
+ const contractNames = new Set<string>();
43
+
44
+ let rootToml: string;
45
+ try {
46
+ rootToml = await readFile('Nargo.toml', 'utf-8');
47
+ } catch {
48
+ return contractNames;
49
+ }
50
+
51
+ const membersMatch = rootToml.match(/members\s*=\s*\[([^\]]*)\]/);
52
+ if (membersMatch) {
53
+ const members = membersMatch[1]
54
+ .split(',')
55
+ .map(m => m.trim().replace(/^"|"$/g, ''))
56
+ .filter(m => m.length > 0);
57
+
58
+ for (const member of members) {
59
+ try {
60
+ const memberToml = await readFile(join(member, 'Nargo.toml'), 'utf-8');
61
+ if (/type\s*=\s*"contract"/.test(memberToml)) {
62
+ const nameMatch = memberToml.match(/name\s*=\s*"([^"]+)"/);
63
+ if (nameMatch) {
64
+ contractNames.add(nameMatch[1]);
65
+ }
66
+ }
67
+ } catch {
68
+ // Member directory might not exist or have no Nargo.toml; skip.
69
+ }
70
+ }
71
+ } else {
72
+ // Single-crate project (no workspace): check if the root Nargo.toml itself is a contract.
73
+ if (/type\s*=\s*"contract"/.test(rootToml)) {
74
+ const nameMatch = rootToml.match(/name\s*=\s*"([^"]+)"/);
75
+ if (nameMatch) {
76
+ contractNames.add(nameMatch[1]);
77
+ }
78
+ }
79
+ }
80
+
81
+ return contractNames;
82
+ }
83
+
84
+ /** Checks that no tests exist in contract crates and fails with a helpful message if they do. */
85
+ async function checkNoTestsInContracts(nargo: string, log: LogFn): Promise<void> {
86
+ const contractPackages = await getContractPackageNames();
87
+ if (contractPackages.size === 0) {
88
+ return;
89
+ }
90
+
91
+ let output: string;
92
+ try {
93
+ // We list tests for all the crates in the workspace
94
+ output = execFileSync(nargo, ['test', '--list-tests', '--silence-warnings'], {
95
+ encoding: 'utf-8',
96
+ stdio: ['pipe', 'pipe', 'inherit'],
97
+ });
98
+ } catch {
99
+ // If listing tests fails (e.g. test crate has compile errors), skip the check.
100
+ return;
101
+ }
102
+
103
+ // The output of the `nargo test --list-tests` command is as follows:
104
+ // ```
105
+ // crate_name_1 test_name_1
106
+ // crate_name_2 test_name_2
107
+ // ...
108
+ // crate_name_n test_name_n
109
+ // ```
110
+ //
111
+ // We parse the individual lines and then we check if any contract crate appeared in the parsed output.
112
+ const lines = output
113
+ .trim()
114
+ .split('\n')
115
+ .filter(line => line.length > 0);
116
+ const testsInContracts: { packageName: string; testName: string }[] = [];
117
+
118
+ for (const line of lines) {
119
+ const spaceIndex = line.indexOf(' ');
120
+ if (spaceIndex === -1) {
121
+ continue;
122
+ }
123
+ const packageName = line.substring(0, spaceIndex);
124
+ const testName = line.substring(spaceIndex + 1);
125
+ if (contractPackages.has(packageName)) {
126
+ testsInContracts.push({ packageName, testName });
127
+ }
128
+ }
129
+
130
+ if (testsInContracts.length > 0) {
131
+ const details = testsInContracts.map(t => ` ${t.packageName}::${t.testName}`).join('\n');
132
+ log(
133
+ `WARNING: Found tests in contract crate(s):\n${details}\n\n` +
134
+ `Tests should be in a dedicated test crate, not in the contract crate.\n` +
135
+ `Learn more: https://docs.aztec.network/errors/1`,
136
+ );
137
+ }
138
+ }
139
+
37
140
  /** Compiles Aztec Noir contracts and postprocesses artifacts. */
38
141
  async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<void> {
142
+ if (!(await needsRecompile())) {
143
+ log('No source changes detected, skipping compilation.');
144
+ return;
145
+ }
146
+
39
147
  const nargo = process.env.NARGO ?? 'nargo';
40
- const bb = process.env.BB ?? 'bb';
148
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
41
149
 
42
150
  await run(nargo, ['compile', ...nargoArgs]);
43
151
 
152
+ // Ensure contract crates contain no tests (tests belong in the test crate).
153
+ await checkNoTestsInContracts(nargo, log);
154
+
44
155
  const artifacts = await collectContractArtifacts();
45
156
 
46
157
  if (artifacts.length > 0) {
@@ -1,3 +1,4 @@
1
+ import { findBbBinary } from '@aztec/bb.js';
1
2
  import type { LogFn } from '@aztec/foundation/log';
2
3
 
3
4
  import { readFile, rename, rm, writeFile } from 'fs/promises';
@@ -33,7 +34,7 @@ export async function profileFlamegraph(artifactPath: string, functionName: stri
33
34
  await writeFile(functionArtifact, makeFunctionArtifact(artifact, func));
34
35
 
35
36
  const profiler = process.env.PROFILER_PATH ?? 'noir-profiler';
36
- const bb = process.env.BB ?? 'bb';
37
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
37
38
 
38
39
  await run(profiler, [
39
40
  'gates',
@@ -1,3 +1,4 @@
1
+ import { findBbBinary } from '@aztec/bb.js';
1
2
  import { asyncPool } from '@aztec/foundation/async-pool';
2
3
  import type { LogFn } from '@aztec/foundation/log';
3
4
 
@@ -32,7 +33,7 @@ async function getGateCount(bb: string, artifactPath: string): Promise<number> {
32
33
 
33
34
  /** Profiles all compiled artifacts in a target directory and prints gate counts. */
34
35
  export async function profileGates(targetDir: string, log: LogFn): Promise<void> {
35
- const bb = process.env.BB ?? 'bb';
36
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
36
37
  const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
37
38
 
38
39
  if (artifacts.length === 0) {
@@ -3,8 +3,8 @@ import { createLogger } from '@aztec/aztec.js/log';
3
3
  import { type BlobClientConfig, blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
4
4
  import { getL1Config } from '@aztec/cli/config';
5
5
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
6
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
7
6
  import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
7
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
8
8
  import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
9
9
 
10
10
  import { extractRelevantOptions } from '../util.js';