Skip to content

Commit 4ab5701

Browse files
committed
feat!: aztec-nargo now directly exposes nargo. aztec-postprocess-contract transpiles and generates vks
## What's done and not done? 1. ✅ Make aztec-nargo just be a direct exposure of the version of nargo in the container. To this end aztec-nargo should from the users experience, just be plain vanilla nargo, but just versioned as we need. 1. ✅ Fix the version number in aztecs nargo build to just be whatever our current noir-ref is, maybe with a -aztec suffix or something to ensure we have more context. - Setting the `GIT_COMMIT` env var to the current noir-ref with `-aztec` appended. ``` % aztec-nargo --version nargo version = 1.0.0-beta.9 noirc version = 1.0.0-beta.9+nightly-2025-08-04-aztec (git version hash: nightly-2025-08-04-aztec, is dirty: false) ``` - **Note that we are appending `-aztec` to `GIT_COMMIT`, which does not end up in the "nargo version", but appears in the noirc version and git version hash.** I don't see a clean/simple way to append `-aztec` to the reported nargo version. 1. ✅ Put the current compile_and_postprocess script behind a command e.g. `aztec-postprocess-contract` , make it no longer run nargo, but rather just transform the artifact with the transpiler and vk generation. 1. **[TODO]** ⚠️ Ensure devrel update docs promptly to reflect the added compile step for aztec. ## An important note on caching and recompiling 1. The transpiler won't re-transpile a contract that is already transpiled. *Yay!* 3. VK caching is still used. *Yay!* 4. Buuuuut... we can no longer use automatically usee nargo's `--show-artifact-paths` to inform what contracts have actually changed and therefore must be post-processed. So, the "update the artifact sequentially with each generated vk" phase runs for every artifact no matter what. If the source hasn't changed, the result will be the same, but the files will be touched.
1 parent 11d9d9e commit 4ab5701

File tree

33 files changed

+202
-83
lines changed

33 files changed

+202
-83
lines changed

avm-transpiler/bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmd=${1:-}
66

77
hash=$(hash_str $(../noir/bootstrap.sh hash) $(cache_content_hash .rebuild_patterns))
88

9-
export GIT_COMMIT="0000000000000000000000000000000000000000"
9+
export GIT_COMMIT="$(cat ../noir/noir-repo-ref | head -n1)-aztec"
1010
export SOURCE_DATE_EPOCH=0
1111
export GIT_DIRTY=false
1212
export RUSTFLAGS="-Dwarnings"

aztec-nargo/README.md

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## `aztec-postprocess-contract`
2+
3+
The Aztec compilation process consists of two steps:
4+
1. `aztec-nargo` which just forwards all arguments to Noir's `nargo` compiler at the version tied to this version of aztec.
5+
2. `aztec-postprocess-contract` which post-processes the compiled contracts to prepare them for use in the Aztec ecosystem.
6+
7+
### `transpile_contract_and_gen_vks.sh`
8+
This script provides the core functionality behind the `aztec-postprocess-contract` command available via aztec-up. It performs postprocessing on compiled Noir contracts:
9+
1. Finds all contract artifacts in `target` directories
10+
2. Transpiles each artifact using the `avm-transpiler`
11+
3. Generates verification keys for each artifact using `bb` (`barretenberg`'s binary)
12+
4. Caches verification keys to speed up subsequent compilations
13+
14+
Example usage: `aztec-postprocess-contract` (via aztec-up) or directly `./transpile_contract_and_gen_vks.sh`

aztec-nargo/compile_then_postprocess.sh renamed to aztec-postprocess-contract/transpile_contract_and_gen_vks.sh

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
#!/usr/bin/env bash
2-
# This is a wrapper script for nargo.
3-
# Pass any args that you'd normally pass to nargo.
4-
# If the first arg is "compile",
5-
# run nargo and then postprocess any created artifacts.
2+
# This script performs postprocessing on compiled Noir contracts.
3+
# It expects to find compiled artifacts and transforms them via
4+
# transpilation and verification key generation.
65
#
7-
# Usage: compile_then_postprocess.sh [nargo args]
6+
# Usage: compile-contract [artifact_path ...]
7+
# If no paths provided, searches for artifacts in target/ directories
88
set -euo pipefail
99

1010
dir=$(dirname $0)
11-
NARGO=${NARGO:-"$dir/../noir/noir-repo/target/release/nargo"}
1211
TRANSPILER=${TRANSPILER:-"$dir/../avm-transpiler/target/release/avm-transpiler"}
1312
BB=${BB:-"$dir/../barretenberg/cpp/build/bin/bb"}
1413

15-
16-
if [ "${1:-}" != "compile" ]; then
17-
# if not compiling, just pass through to nargo verbatim
18-
$NARGO $@
19-
exit $?
20-
fi
21-
shift # remove the compile arg so we can inject --show-artifact-paths
22-
2314
# bb --version returns 00000000.00000000.00000000, so we compute
2415
# the binary hash to ensure we invalidate vk cache artifacts when bb changes
2516
bb_hash=$(sha256sum "$BB" | cut -d' ' -f1)
2617

27-
# Forward all arguments to nargo, tee output to console.
28-
# Nargo should be outputting errors to stderr, but it doesn't. Use tee to duplicate stdout to stderr to display errors.
29-
artifacts_to_process=$($NARGO compile --pedantic-solving --inliner-aggressiveness 0 --show-artifact-paths $@ | tee >(cat >&2) | grep -oP 'Saved contract artifact to: \K.*')
18+
# If artifact paths are provided as arguments, use those
19+
# Otherwise, search for contract artifacts in target directories
20+
if [ $# -gt 0 ]; then
21+
artifacts_to_process="$@"
22+
else
23+
# Find all contract artifacts in target directories
24+
artifacts_to_process=$(find . -name "*.json" -path "*/target/*" | grep -v "/cache/" | grep -v ".function_artifact_" || true)
25+
26+
if [ -z "$artifacts_to_process" ]; then
27+
echo "No contract artifacts found. Please compile your contracts first with 'nargo compile'."
28+
exit 1
29+
fi
30+
fi
3031

3132
# Postprocess each artifact
3233
# `$artifacts_to_process` needs to be unquoted here, otherwise it will break if there are multiple artifacts
@@ -82,3 +83,5 @@ for artifact in $artifacts_to_process; do
8283
mv "$artifact.tmp" "$artifact"
8384
done
8485
done
86+
87+
echo "Contract postprocessing complete!"

aztec-up/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ the user's `PATH` variable in their shell startup script so they can be found.
1111

1212
- `aztec` - The infrastructure container.
1313
- `aztec-cli` - A command-line tool for interacting with infrastructure.
14-
- `aztec-nargo` - A build of `nargo` from `noir` that is guaranteed to be version-aligned. Provides compiler, lsp and more. On `aztec-nargo compile <...>`, automatically transpiles artifacts using `avm-transpiler` and generates verification keys using `bb`.
14+
- `aztec-nargo` - A build of `nargo` from `noir` that is guaranteed to be version-aligned. Provides compiler, lsp and more.
15+
- `aztec-postprocess-contract` - Postprocessing tool for Aztec contracts that transpiles artifacts using `avm-transpiler` and generates verification keys using `bb`.
1516
- `aztec-sandbox` - A wrapper around docker-compose that launches services needed for sandbox testing.
1617
- `aztec-up` - A tool to upgrade the aztec toolchain to the latest, or specific versions.
1718
- `aztec-builder` - A useful tool for projects to generate ABIs and update their dependencies.

aztec-up/bin/aztec-install

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ function title() {
5858
echo -e "${r}"
5959
fi
6060
echo -e "This will install the following scripts and update your PATH if necessary:"
61-
echo -e " ${bold}${g}aztec${r} - a collection of tools to launch subsystems and interact with the aztec network."
62-
echo -e " ${bold}${g}aztec-nargo${r} - aztec's build of nargo, the noir compiler toolchain."
63-
echo -e " ${bold}${g}aztec-up${r} - a tool to upgrade the aztec toolchain to the latest, or specific versions."
64-
echo -e " ${bold}${g}aztec-wallet${r} - our minimalistic CLI wallet"
61+
echo -e " ${bold}${g}aztec${r} - a collection of tools to launch subsystems and interact with the aztec network."
62+
echo -e " ${bold}${g}aztec-nargo${r} - aztec's build of nargo, the noir compiler toolchain."
63+
echo -e " ${bold}${g}aztec-postprocess-contract${r} - postprocessing tool for Aztec contracts (transpilation and VK generation)."
64+
echo -e " ${bold}${g}aztec-up${r} - a tool to upgrade the aztec toolchain to the latest, or specific versions."
65+
echo -e " ${bold}${g}aztec-wallet${r} - our minimalistic CLI wallet"
6566
echo
6667
read -p "Do you wish to continue? (y/n)" -n 1 -r
6768
echo
@@ -162,6 +163,7 @@ install_bin .aztec-run
162163
install_bin aztec
163164
install_bin aztec-up
164165
install_bin aztec-nargo
166+
install_bin aztec-postprocess-contract
165167
install_bin aztec-wallet
166168

167169
update_path_env_var $BIN_PATH

aztec-up/bin/aztec-nargo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ if [[ $PWD != ${HOME}* ]]; then
66
exit 1
77
fi
88

9+
# Special-case nargo's LSP command:
10+
# 1. include --rm for cleanup
11+
# 2. don't specify a user (run as root)
12+
# 3. don't specify a workdir
913
if [ "${1:-}" == "lsp" ]; then
1014
docker run --rm -i \
1115
--name aztec-nargo-lsp \
@@ -16,6 +20,7 @@ if [ "${1:-}" == "lsp" ]; then
1620
exit
1721
fi
1822

23+
# Determine if we need interactive/tty flags
1924
if [ -t 0 ]; then
2025
if [ -t 1 ]; then
2126
args="-ti"
@@ -24,10 +29,11 @@ if [ -t 0 ]; then
2429
fi
2530
fi
2631

32+
# Pass through directly to vanilla nargo
2733
docker run ${args:-} \
2834
--user $(id -u):$(id -g) \
2935
-v $HOME:$HOME \
3036
-e HOME=$HOME \
3137
--workdir="$PWD" \
32-
--entrypoint /usr/src/aztec-nargo/compile_then_postprocess.sh \
38+
--entrypoint=/usr/src/noir/noir-repo/target/release/nargo \
3339
aztecprotocol/aztec "$@"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $PWD != ${HOME}* ]]; then
5+
>&2 echo "Due to how we containerize our applications, we require your working directory to be somewhere within $HOME."
6+
exit 1
7+
fi
8+
9+
# Determine if we need interactive/tty flags
10+
if [ -t 0 ]; then
11+
if [ -t 1 ]; then
12+
args="-ti"
13+
else
14+
args="-i"
15+
fi
16+
fi
17+
18+
# Run the aztec-postprocess-contract script from within the container
19+
docker run ${args:-} \
20+
--user $(id -u):$(id -g) \
21+
-v $HOME:$HOME \
22+
-e HOME=$HOME \
23+
--workdir="$PWD" \
24+
--entrypoint=/usr/src/aztec-postprocess-contract/transpile_contract_and_gen_vks.sh \
25+
aztecprotocol/aztec "$@"

aztec-up/test/counter_contract.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ cp -Rf ./aztec-packages/noir-projects/noir-contracts/contracts/test/counter_cont
5555
cd counter_contract
5656
sed -i 's|\.\./\.\./\.\./\.\./|/home/ubuntu/aztec-packages/noir-projects/|g' Nargo.toml
5757

58-
# Compile and codegen.
58+
# Compile the contract.
5959
aztec-nargo compile
60+
# Post-process the contract.
61+
aztec-postprocess-contract
62+
# Codegen
6063
aztec codegen -o src/artifacts target
6164
if [ ! -d src/artifacts ]; then
6265
echo "Failed to codegen TypeScript."

bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ function build {
229229
noir-projects
230230
l1-contracts
231231
yarn-project
232+
release-image
232233
)
233234
# These projects can be built in parallel.
234235
parallel_cmds=(
235236
boxes/bootstrap.sh
236237
playground/bootstrap.sh
237238
docs/bootstrap.sh
238-
release-image/bootstrap.sh
239239
spartan/bootstrap.sh
240240
aztec-up/bootstrap.sh
241241
)

0 commit comments

Comments
 (0)