From 3eb498f662b00b3a21e6a7004b8e40478b186021 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Wed, 1 May 2024 16:24:54 +0000 Subject: [PATCH 01/11] feat(nargo): hidden option to show contract artifact paths written to by --- noir/noir-repo/compiler/noirc_driver/src/lib.rs | 4 ++++ .../tooling/nargo_cli/src/cli/compile_cmd.rs | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index d7368f299b84..9c5d6b60d88f 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -103,6 +103,10 @@ pub struct CompileOptions { /// Enable the experimental elaborator pass #[arg(long, hide = true)] pub use_elaborator: bool, + + /// Outputs the paths to any modified artifacts + #[arg(long, hide = true)] + pub show_artifact_paths: bool, } fn parse_expression_width(input: &str) -> Result { diff --git a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs index ecf2e2e9f53a..bd76cf248055 100644 --- a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -142,7 +142,7 @@ pub(super) fn compile_workspace_full( let circuit_dir = workspace.target_directory_path(); for (package, contract) in contract_packages.into_iter().zip(compiled_contracts) { let contract = nargo::ops::transform_contract(contract, compile_options.expression_width); - save_contract(contract, &package, &circuit_dir); + save_contract(contract, &package, &circuit_dir, compile_options.show_artifact_paths); } Ok(()) @@ -200,11 +200,19 @@ pub(super) fn save_program(program: CompiledProgram, package: &Package, circuit_ save_program_to_file(&program_artifact, &package.name, circuit_dir); } -fn save_contract(contract: CompiledContract, package: &Package, circuit_dir: &Path) { +fn save_contract( + contract: CompiledContract, + package: &Package, + circuit_dir: &Path, + show_artifact_paths: bool, +) { let contract_name = contract.name.clone(); - save_contract_to_file( + let artifact_path = save_contract_to_file( &contract.into(), &format!("{}-{}", package.name, contract_name), circuit_dir, ); + if show_artifact_paths { + println!("Saved contract artifact to: {}", artifact_path.display()); + } } From 03fdb67330a15b17f2938fc2c77a94e8be49035f Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Wed, 1 May 2024 21:04:52 +0000 Subject: [PATCH 02/11] feat(sandbox): auto transpile public contract functions in sandbox --- avm-transpiler/Dockerfile | 18 ++++++++--- .../scripts/compile_then_transpile.sh | 32 +++++++++++++++++++ aztec-up/bin/aztec-nargo | 8 +++-- build_manifest.yml | 2 ++ 4 files changed, 53 insertions(+), 7 deletions(-) create mode 100755 avm-transpiler/scripts/compile_then_transpile.sh diff --git a/avm-transpiler/Dockerfile b/avm-transpiler/Dockerfile index 95a4ead89ee3..23ea1b7ba43a 100644 --- a/avm-transpiler/Dockerfile +++ b/avm-transpiler/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:bullseye +FROM rust:bullseye as builder WORKDIR /usr/src COPY ./avm-transpiler ./avm-transpiler @@ -8,6 +8,16 @@ WORKDIR /usr/src/avm-transpiler RUN apt-get update && apt-get install -y git RUN ./scripts/bootstrap_native.sh -FROM ubuntu:focal -COPY --from=0 /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler -ENTRYPOINT ["sh", "-c"] +# to get built nargo binary +FROM aztecprotocol/noir as built-noir + +FROM ubuntu:lunar +# Install Tini as nargo doesn't handle signals properly. +# Install git as nargo needs it to clone. +RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean +ENV PATH="/usr/src/noir/noir-repo/target/release:${PATH}" +ENV PATH="/usr/src/avm-transpiler/target/release:${PATH}" +COPY --from=builder /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler +COPY --from=builder /usr/src/avm-transpiler/scripts/compile_then_transpile.sh /usr/src/avm-transpiler/scripts/compile_then_transpile.sh +COPY --from=built-noir /usr/src/noir/noir-repo/target/release/nargo /usr/src/noir/noir-repo/target/release/nargo +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh new file mode 100755 index 000000000000..69264f282a72 --- /dev/null +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -eu + +NARGO=${NARGO:-nargo} +TRANSPILER=${TRANSPILER:-avm-transpiler} + +if [ "${1:-}" != "compile" ]; then + echo "Usage: $0 compile" + exit 1 +fi +shift # remove the compile arg so we can inject --show-artifact-paths + +# Create a temporary file to capture and parse nargo's stdout while still printing it to the console. +# To avoid a situation where the script fails and the temporary file isn't removed, +# create file descriptors for writing/reading the temporary file and then remove the file. +tmpfile=$(mktemp) +exec 3>"$tmpfile" +exec 4<"$tmpfile" +rm "$tmpfile" + +# Forward all arguments to nargo, tee output to the tmp file +echo "Running nargo ($NARGO compile --show-artifact-paths) with args: $@" +$NARGO compile --show-artifact-paths "$@" | tee /dev/fd/3 + +# Parse nargo's output (captured in the tmp file) to determine which artifacts to transpile +artifacts_to_transpile=$(grep -oP 'Saved contract artifact to: \K.*' <&4) + +# Transpile each artifact +for artifact in "$artifacts_to_transpile"; do + # transpiler input and output files are the same (modify in-place) + $TRANSPILER "$artifact" "$artifact" +done diff --git a/aztec-up/bin/aztec-nargo b/aztec-up/bin/aztec-nargo index 884afc02c736..5bd3022a16ea 100755 --- a/aztec-up/bin/aztec-nargo +++ b/aztec-up/bin/aztec-nargo @@ -5,7 +5,9 @@ export SKIP_NET=1 export PATH=$PATH:$HOME/bin if [ "${1:-}" == "lsp" ]; then - docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/noir $@ + docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/noir $@ +elif [ "${1:-}" == "compile" ]; then + $(dirname $0)/.aztec-run aztecprotocol/avm-transpiler /usr/src/avm-transpiler/scripts/compile_then_transpile.sh $@ else - $(dirname $0)/.aztec-run aztecprotocol/noir $@ -fi \ No newline at end of file + $(dirname $0)/.aztec-run aztecprotocol/noir $@ +fi diff --git a/build_manifest.yml b/build_manifest.yml index 234a09418a3e..4204dfd09366 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -48,6 +48,8 @@ avm-transpiler: rebuildPatterns: - ^avm-transpiler/ - ^noir/ + dependencies: + - noir # Compiles all aztec noir projects using nargo and the avm-transpiler. noir-projects: From 7e00484523ec79d9c68df9a018e52c5b3fa5078f Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Tue, 21 May 2024 16:10:59 +0000 Subject: [PATCH 03/11] [skip ci] aztec-nargo --- .circleci/config.yml | 15 +++++++++++++ avm-transpiler/Dockerfile | 18 ++++------------ .../scripts/compile_then_transpile.sh | 9 ++++---- aztec-nargo/Dockerfile | 21 +++++++++++++++++++ aztec-up/bin/aztec-nargo | 6 ++---- build_manifest.yml | 11 ++++++++++ 6 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 aztec-nargo/Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index c90c37c371a9..5b89058c08b9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -243,6 +243,18 @@ jobs: command: cond_spot_run_build avm-transpiler 32 aztec_manifest_key: avm-transpiler + aztec-nargo: + docker: + - image: aztecprotocol/alpine-build-image + resource_class: small + steps: + - *checkout + - *setup_env + - run: + name: "Build" + command: cond_spot_run_build aztec-nargo 32 + aztec_manifest_key: aztec-nargo + l1-contracts: machine: image: default @@ -492,6 +504,9 @@ workflows: # Transpiler - avm-transpiler: *defaults + # aztec-nargo (nargo & transpiler) + - aztec-nargo: *defaults + # Barretenberg - barretenberg-x86_64-linux-clang: *defaults - barretenberg-x86_64-linux-clang-assert: *defaults diff --git a/avm-transpiler/Dockerfile b/avm-transpiler/Dockerfile index 23ea1b7ba43a..95a4ead89ee3 100644 --- a/avm-transpiler/Dockerfile +++ b/avm-transpiler/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:bullseye as builder +FROM rust:bullseye WORKDIR /usr/src COPY ./avm-transpiler ./avm-transpiler @@ -8,16 +8,6 @@ WORKDIR /usr/src/avm-transpiler RUN apt-get update && apt-get install -y git RUN ./scripts/bootstrap_native.sh -# to get built nargo binary -FROM aztecprotocol/noir as built-noir - -FROM ubuntu:lunar -# Install Tini as nargo doesn't handle signals properly. -# Install git as nargo needs it to clone. -RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean -ENV PATH="/usr/src/noir/noir-repo/target/release:${PATH}" -ENV PATH="/usr/src/avm-transpiler/target/release:${PATH}" -COPY --from=builder /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler -COPY --from=builder /usr/src/avm-transpiler/scripts/compile_then_transpile.sh /usr/src/avm-transpiler/scripts/compile_then_transpile.sh -COPY --from=built-noir /usr/src/noir/noir-repo/target/release/nargo /usr/src/noir/noir-repo/target/release/nargo -ENTRYPOINT ["/usr/bin/tini", "--"] +FROM ubuntu:focal +COPY --from=0 /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler +ENTRYPOINT ["sh", "-c"] diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index 69264f282a72..14f1dfc68dae 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -5,8 +5,7 @@ NARGO=${NARGO:-nargo} TRANSPILER=${TRANSPILER:-avm-transpiler} if [ "${1:-}" != "compile" ]; then - echo "Usage: $0 compile" - exit 1 + $NARGO $@ fi shift # remove the compile arg so we can inject --show-artifact-paths @@ -20,13 +19,13 @@ rm "$tmpfile" # Forward all arguments to nargo, tee output to the tmp file echo "Running nargo ($NARGO compile --show-artifact-paths) with args: $@" -$NARGO compile --show-artifact-paths "$@" | tee /dev/fd/3 +$NARGO compile --show-artifact-paths $@ | tee /dev/fd/3 # Parse nargo's output (captured in the tmp file) to determine which artifacts to transpile artifacts_to_transpile=$(grep -oP 'Saved contract artifact to: \K.*' <&4) # Transpile each artifact for artifact in "$artifacts_to_transpile"; do - # transpiler input and output files are the same (modify in-place) - $TRANSPILER "$artifact" "$artifact" + # transpiler input and output files are the same (modify in-place) + $TRANSPILER "$artifact" "$artifact" done diff --git a/aztec-nargo/Dockerfile b/aztec-nargo/Dockerfile new file mode 100644 index 000000000000..6367bcfb8af5 --- /dev/null +++ b/aztec-nargo/Dockerfile @@ -0,0 +1,21 @@ +# to get built nargo binary +FROM aztecprotocol/noir as built-noir + +# to get built avm-transpiler binary +FROM aztecprotocol/avm-transpiler as built-transpiler + + +FROM ubuntu:lunar +# Install Tini as nargo doesn't handle signals properly. +# Install git as nargo needs it to clone. +RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean +ENV PATH="/usr/src/noir/noir-repo/target/release:${PATH}" +ENV PATH="/usr/src/avm-transpiler/target/release:${PATH}" +COPY --from=built-noir /usr/src/noir/noir-repo/target/release/nargo /usr/src/noir/noir-repo/target/release/nargo +COPY --from=built-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler + +# Grab the compiler script +WORKDIR /usr/src +COPY ./avm-transpiler/scripts/compile_then_transpile.sh ./avm-transpiler/scripts/compile_then_transpile.sh + +ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/avm-transpiler/scripts/avm-transpiler/scripts/compile_then_transpile.sh"] diff --git a/aztec-up/bin/aztec-nargo b/aztec-up/bin/aztec-nargo index 5bd3022a16ea..dfce52ea5fa1 100755 --- a/aztec-up/bin/aztec-nargo +++ b/aztec-up/bin/aztec-nargo @@ -5,9 +5,7 @@ export SKIP_NET=1 export PATH=$PATH:$HOME/bin if [ "${1:-}" == "lsp" ]; then - docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/noir $@ -elif [ "${1:-}" == "compile" ]; then - $(dirname $0)/.aztec-run aztecprotocol/avm-transpiler /usr/src/avm-transpiler/scripts/compile_then_transpile.sh $@ + docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/aztec-nargo $@ else - $(dirname $0)/.aztec-run aztecprotocol/noir $@ + $(dirname $0)/.aztec-run aztecprotocol/aztec-nargo $@ fi diff --git a/build_manifest.yml b/build_manifest.yml index 4204dfd09366..e0f6d26397e0 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -51,6 +51,17 @@ avm-transpiler: dependencies: - noir +aztec-nargo: + buildDir: . + dockerfile: aztec-nargo/Dockerfile + rebuildPatterns: + - ^aztec-nargo/ + - ^avm-transpiler/ + - ^noir/ + dependencies: + - avm-transpiler + - noir + # Compiles all aztec noir projects using nargo and the avm-transpiler. noir-projects: buildDir: noir-projects From 2c1626103a11c362bedf29071d606640d89d5d0e Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Tue, 21 May 2024 19:15:18 +0000 Subject: [PATCH 04/11] fix .aztec-run --- avm-transpiler/scripts/compile_then_transpile.sh | 2 +- aztec-nargo/Dockerfile | 2 +- aztec-up/bin/.aztec-run | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index 14f1dfc68dae..249a9e65867d 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -18,7 +18,7 @@ exec 4<"$tmpfile" rm "$tmpfile" # Forward all arguments to nargo, tee output to the tmp file -echo "Running nargo ($NARGO compile --show-artifact-paths) with args: $@" +#echo "Running nargo ($NARGO compile --show-artifact-paths) with args: $@" $NARGO compile --show-artifact-paths $@ | tee /dev/fd/3 # Parse nargo's output (captured in the tmp file) to determine which artifacts to transpile diff --git a/aztec-nargo/Dockerfile b/aztec-nargo/Dockerfile index 6367bcfb8af5..29c75f8ebd85 100644 --- a/aztec-nargo/Dockerfile +++ b/aztec-nargo/Dockerfile @@ -18,4 +18,4 @@ COPY --from=built-transpiler /usr/src/avm-transpiler/target/release/avm-transpil WORKDIR /usr/src COPY ./avm-transpiler/scripts/compile_then_transpile.sh ./avm-transpiler/scripts/compile_then_transpile.sh -ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/avm-transpiler/scripts/avm-transpiler/scripts/compile_then_transpile.sh"] +ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/avm-transpiler/scripts/compile_then_transpile.sh"] diff --git a/aztec-up/bin/.aztec-run b/aztec-up/bin/.aztec-run index 77cfbcf3c258..421db8d408f2 100755 --- a/aztec-up/bin/.aztec-run +++ b/aztec-up/bin/.aztec-run @@ -100,7 +100,7 @@ done # Dynamic port assignment based on IMAGE containing '/aztec' and not containing 'builder' (to exclude aztec-builder) port_assignment="" -if [[ "$IMAGE" == *"/aztec"* ]] && [[ "$IMAGE" != *"builder"* ]]; then +if [[ "$IMAGE" == *"/aztec"* ]] && [[ "$IMAGE" != *"builder"* ]] && [[ "$IMAGE" != *"aztec-nargo"* ]] ; then port_assignment="-p $AZTEC_PORT:$AZTEC_PORT" fi From ab76200af34e0304ee35b4dd1a25bf2c74d354be Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Thu, 23 May 2024 17:59:30 +0000 Subject: [PATCH 05/11] fix earthly file for aztec-nargo --- .circleci/config.yml | 2 +- avm-transpiler/Dockerfile | 5 +++-- avm-transpiler/Earthfile | 9 ++++----- .../scripts/compile_then_transpile.sh | 2 ++ aztec-nargo/Earthfile | 17 +++++++++++++++++ noir/Earthfile | 9 --------- 6 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 aztec-nargo/Earthfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 5b89058c08b9..672886d4e4fa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -393,7 +393,7 @@ jobs: name: "Release to dockerhub" command: | should_release || exit 0 - deploy_dockerhub noir + deploy_dockerhub aztec-nargo deploy_dockerhub aztec deploy_dockerhub aztec-builder - run: diff --git a/avm-transpiler/Dockerfile b/avm-transpiler/Dockerfile index 95a4ead89ee3..d695622a009e 100644 --- a/avm-transpiler/Dockerfile +++ b/avm-transpiler/Dockerfile @@ -8,6 +8,7 @@ WORKDIR /usr/src/avm-transpiler RUN apt-get update && apt-get install -y git RUN ./scripts/bootstrap_native.sh -FROM ubuntu:focal +FROM ubuntu:noble +COPY --from=0 /usr/src/avm-transpiler/scripts/compile_then_transpile.sh /usr/src/avm-transpiler/scripts/compile_then_transpile.sh COPY --from=0 /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler -ENTRYPOINT ["sh", "-c"] +ENTRYPOINT ["/usr/src/avm-transpiler/target/release/avm-transpiler"] diff --git a/avm-transpiler/Earthfile b/avm-transpiler/Earthfile index 4c3102dec8c9..b327585b7c89 100644 --- a/avm-transpiler/Earthfile +++ b/avm-transpiler/Earthfile @@ -1,9 +1,8 @@ VERSION 0.8 -IMPORT ../noir AS noir source: # we rely on noir source, which this image has - FROM noir+nargo + FROM ../noir+nargo # move noir contents to /usr/src/noir RUN mv /usr/src /noir && mkdir /usr/src && mv /noir /usr/src @@ -18,10 +17,10 @@ source: build: FROM +source RUN ./scripts/bootstrap_native.sh + SAVE ARTIFACT scripts/compile_then_transpile.sh SAVE ARTIFACT target/release/avm-transpiler avm-transpiler run: - #TODO needed? - FROM ubuntu:focal + FROM ubuntu:noble COPY +build/avm-transpiler /usr/src/avm-transpiler - ENTRYPOINT ["sh", "-c"] + ENTRYPOINT ["/usr/src/avm-transpiler"] diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index 249a9e65867d..9f42d06e02ea 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -5,7 +5,9 @@ NARGO=${NARGO:-nargo} TRANSPILER=${TRANSPILER:-avm-transpiler} if [ "${1:-}" != "compile" ]; then + # if not compiling, just pass through to nargo verbatim $NARGO $@ + exit 0 fi shift # remove the compile arg so we can inject --show-artifact-paths diff --git a/aztec-nargo/Earthfile b/aztec-nargo/Earthfile new file mode 100644 index 000000000000..b037b79f2758 --- /dev/null +++ b/aztec-nargo/Earthfile @@ -0,0 +1,17 @@ +VERSION 0.8 + +run: + FROM ubuntu:noble + # Install Tini as nargo doesn't handle signals properly. + # Install git as nargo needs it to clone. + RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean + + # Copy binaries to /usr/bin/ + COPY ../noir+nargo/nargo /usr/bin/nargo + COPY ../avm-transpiler+build/avm-transpiler /usr/bin/avm-transpiler + # Copy in script that calls both binaries + COPY ../avm-transpiler+build/compile_then_transpile.sh /usr/bin/compile_then_transpile.sh + + ENV PATH "/usr/bin:${PATH}" + ENTRYPOINT ["/usr/bin/tini", "--", "/usr/bin/compile_then_transpile.sh"] + SAVE IMAGE aztecprotocol/aztec-nargo diff --git a/noir/Earthfile b/noir/Earthfile index 6c1f5f29607c..526063b6a013 100644 --- a/noir/Earthfile +++ b/noir/Earthfile @@ -199,15 +199,6 @@ packages-test: BUILD +packages-test-node BUILD +packages-test-browser -run: - # When running the container, mount the users home directory to same location. - FROM ubuntu:noble - # Install Tini as nargo doesn't handle signals properly. - # Install git as nargo needs it to clone. - RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean - COPY +build/. /usr/src - ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/nargo"] - build-acir-tests: LOCALLY # Prepare our exact dependency formula, this avoids problems with copied empty folders or build artifacts From 8440c69ad31c0626fad7c64fca06323c11cf3d70 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Thu, 23 May 2024 19:10:13 +0000 Subject: [PATCH 06/11] cleanup old dockerfile --- Earthfile | 2 +- avm-transpiler/Earthfile | 20 ++++++++++---------- aztec-nargo/Dockerfile | 14 ++++++-------- aztec-up/bin/aztec-install | 2 +- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Earthfile b/Earthfile index 2c3da388fc71..8a0c71a237e8 100644 --- a/Earthfile +++ b/Earthfile @@ -24,7 +24,7 @@ test-end-to-end: BUILD ./yarn-project/end-to-end+e2e-tests bench: - RUN echo hi + RUN echo hi release-meta: COPY .release-please-manifest.json /usr/src/.release-please-manifest.json diff --git a/avm-transpiler/Earthfile b/avm-transpiler/Earthfile index b327585b7c89..7905be4e3d57 100644 --- a/avm-transpiler/Earthfile +++ b/avm-transpiler/Earthfile @@ -1,24 +1,24 @@ VERSION 0.8 source: - # we rely on noir source, which this image has - FROM ../noir+nargo + # we rely on noir source, which this image has + FROM ../noir+nargo - # move noir contents to /usr/src/noir - RUN mv /usr/src /noir && mkdir /usr/src && mv /noir /usr/src - # work in avm-transpiler - WORKDIR /usr/src/avm-transpiler + # move noir contents to /usr/src/noir + RUN mv /usr/src /noir && mkdir /usr/src && mv /noir /usr/src + # work in avm-transpiler + WORKDIR /usr/src/avm-transpiler - COPY --dir scripts src Cargo.lock Cargo.toml rust-toolchain.toml . + COPY --dir scripts src Cargo.lock Cargo.toml rust-toolchain.toml . - # for debugging rebuilds - RUN echo CONTENT HASH $(find . -type f -exec sha256sum {} ';' | sort | sha256sum | awk '{print $1}') | tee .content-hash + # for debugging rebuilds + RUN echo CONTENT HASH $(find . -type f -exec sha256sum {} ';' | sort | sha256sum | awk '{print $1}') | tee .content-hash build: FROM +source RUN ./scripts/bootstrap_native.sh - SAVE ARTIFACT scripts/compile_then_transpile.sh SAVE ARTIFACT target/release/avm-transpiler avm-transpiler + SAVE ARTIFACT scripts/compile_then_transpile.sh run: FROM ubuntu:noble diff --git a/aztec-nargo/Dockerfile b/aztec-nargo/Dockerfile index 29c75f8ebd85..b1cdcc35d6e7 100644 --- a/aztec-nargo/Dockerfile +++ b/aztec-nargo/Dockerfile @@ -5,17 +5,15 @@ FROM aztecprotocol/noir as built-noir FROM aztecprotocol/avm-transpiler as built-transpiler -FROM ubuntu:lunar +FROM ubuntu:noble # Install Tini as nargo doesn't handle signals properly. # Install git as nargo needs it to clone. RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean -ENV PATH="/usr/src/noir/noir-repo/target/release:${PATH}" -ENV PATH="/usr/src/avm-transpiler/target/release:${PATH}" -COPY --from=built-noir /usr/src/noir/noir-repo/target/release/nargo /usr/src/noir/noir-repo/target/release/nargo -COPY --from=built-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler -# Grab the compiler script -WORKDIR /usr/src -COPY ./avm-transpiler/scripts/compile_then_transpile.sh ./avm-transpiler/scripts/compile_then_transpile.sh +# Copy binaries to /usr/bin/ +COPY --from=built-noir /usr/src/noir/noir-repo/target/release/nargo /usr/bin/nargo +COPY --from=built-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler /usr/bin/avm-transpiler +# Copy in script that calls both binaries +COPY ./avm-transpiler/scripts/compile_then_transpile.sh /usr/src/avm-transpiler/scripts/compile_then_transpile.sh ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/avm-transpiler/scripts/compile_then_transpile.sh"] diff --git a/aztec-up/bin/aztec-install b/aztec-up/bin/aztec-install index 9764b9a19e74..5a12629a917b 100755 --- a/aztec-up/bin/aztec-install +++ b/aztec-up/bin/aztec-install @@ -105,8 +105,8 @@ export DOCKER_CLI_HINTS=false if [ -z "${SKIP_PULL:-}" ]; then info "Pulling aztec version $VERSION..." + pull_container aztec-nargo pull_container aztec - pull_container noir pull_container aztec-builder fi From 9d2d62b5ac45546d3d474780a7419e3ebe6ac765 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Thu, 23 May 2024 19:15:06 +0000 Subject: [PATCH 07/11] [skip ci] --- avm-transpiler/scripts/compile_then_transpile.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index 9f42d06e02ea..16f1b271c762 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +# This is a wrapper script for nargo. +# Pass any args that you'd normally pass to nargo. +# If the first arg is "compile", +# run nargo and then transpile any created artifacts. +# +# Usage: compile_then_transpile.sh [nargo args] set -eu NARGO=${NARGO:-nargo} From 02daa383ebcfee12a01ceca8c98e7691bef6652d Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Thu, 23 May 2024 19:22:53 +0000 Subject: [PATCH 08/11] formatting fix --- aztec-nargo/Dockerfile | 2 +- aztec-nargo/Earthfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aztec-nargo/Dockerfile b/aztec-nargo/Dockerfile index b1cdcc35d6e7..e945e6520394 100644 --- a/aztec-nargo/Dockerfile +++ b/aztec-nargo/Dockerfile @@ -10,7 +10,7 @@ FROM ubuntu:noble # Install git as nargo needs it to clone. RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean -# Copy binaries to /usr/bin/ +# Copy binaries to /usr/bin COPY --from=built-noir /usr/src/noir/noir-repo/target/release/nargo /usr/bin/nargo COPY --from=built-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler /usr/bin/avm-transpiler # Copy in script that calls both binaries diff --git a/aztec-nargo/Earthfile b/aztec-nargo/Earthfile index b037b79f2758..c8aee15796e6 100644 --- a/aztec-nargo/Earthfile +++ b/aztec-nargo/Earthfile @@ -6,7 +6,7 @@ run: # Install git as nargo needs it to clone. RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean - # Copy binaries to /usr/bin/ + # Copy binaries to /usr/bin COPY ../noir+nargo/nargo /usr/bin/nargo COPY ../avm-transpiler+build/avm-transpiler /usr/bin/avm-transpiler # Copy in script that calls both binaries From 29419ca766177bd3dc84f8c1686fe744e521d4d0 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Thu, 23 May 2024 20:56:01 +0000 Subject: [PATCH 09/11] compile then transpile script should return nargo's return status in passthrough mode --- avm-transpiler/scripts/compile_then_transpile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index 16f1b271c762..8213dad9de48 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -13,7 +13,7 @@ TRANSPILER=${TRANSPILER:-avm-transpiler} if [ "${1:-}" != "compile" ]; then # if not compiling, just pass through to nargo verbatim $NARGO $@ - exit 0 + exit $? fi shift # remove the compile arg so we can inject --show-artifact-paths From 547ad4f9157c6ca15b75f5721ead5429797b25d8 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Fri, 24 May 2024 19:49:09 +0000 Subject: [PATCH 10/11] SKIP_PORT_ASSIGNMENT flag to .aztec-run, simplify compile_then_transpile.sh --- .../scripts/compile_then_transpile.sh | 17 ++++------------- aztec-up/bin/.aztec-run | 4 ++-- aztec-up/bin/aztec | 2 +- aztec-up/bin/aztec-builder | 1 + aztec-up/bin/aztec-nargo | 1 + 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index 8213dad9de48..21c4ab486b62 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -17,20 +17,11 @@ if [ "${1:-}" != "compile" ]; then fi shift # remove the compile arg so we can inject --show-artifact-paths -# Create a temporary file to capture and parse nargo's stdout while still printing it to the console. -# To avoid a situation where the script fails and the temporary file isn't removed, -# create file descriptors for writing/reading the temporary file and then remove the file. -tmpfile=$(mktemp) -exec 3>"$tmpfile" -exec 4<"$tmpfile" -rm "$tmpfile" +# Forward all arguments to nargo, tee output to console +artifacts_to_transpile=$($NARGO compile --show-artifact-paths $@ | tee /dev/tty | grep -oP 'Saved contract artifact to: \K.*') -# Forward all arguments to nargo, tee output to the tmp file -#echo "Running nargo ($NARGO compile --show-artifact-paths) with args: $@" -$NARGO compile --show-artifact-paths $@ | tee /dev/fd/3 - -# Parse nargo's output (captured in the tmp file) to determine which artifacts to transpile -artifacts_to_transpile=$(grep -oP 'Saved contract artifact to: \K.*' <&4) +# NOTE: the output that is teed to /dev/tty will normally not be redirectable by the caller. +# If the script is run via docker, however, the user will see this output on stdout and will be able to redirect. # Transpile each artifact for artifact in "$artifacts_to_transpile"; do diff --git a/aztec-up/bin/.aztec-run b/aztec-up/bin/.aztec-run index 421db8d408f2..8e318fc4c63a 100755 --- a/aztec-up/bin/.aztec-run +++ b/aztec-up/bin/.aztec-run @@ -98,9 +98,9 @@ while [[ "$#" -gt 0 ]]; do esac done -# Dynamic port assignment based on IMAGE containing '/aztec' and not containing 'builder' (to exclude aztec-builder) +# Dynamic port assignment port_assignment="" -if [[ "$IMAGE" == *"/aztec"* ]] && [[ "$IMAGE" != *"builder"* ]] && [[ "$IMAGE" != *"aztec-nargo"* ]] ; then +if [[ -z "${SKIP_PORT_ASSIGNMENT:-}" ]]; then port_assignment="-p $AZTEC_PORT:$AZTEC_PORT" fi diff --git a/aztec-up/bin/aztec b/aztec-up/bin/aztec index 93c53907c142..863952060281 100755 --- a/aztec-up/bin/aztec +++ b/aztec-up/bin/aztec @@ -5,7 +5,7 @@ set -euo pipefail if [ -n "${1-}" ] && [ "$1" != "--help" ]; then if [ "$1" == "cli" ]; then shift - $(dirname $0)/.aztec-run aztecprotocol/cli "$@" + SKIP_PORT_ASSIGNMENTS=1 $(dirname $0)/.aztec-run aztecprotocol/cli "$@" elif [ "$1" == "sandbox" ]; then $(dirname $0)/aztec-sandbox else diff --git a/aztec-up/bin/aztec-builder b/aztec-up/bin/aztec-builder index a676553772fa..cd4cafc81d25 100755 --- a/aztec-up/bin/aztec-builder +++ b/aztec-up/bin/aztec-builder @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +export SKIP_PORT_ASSIGNMENTS=1 export ENV_VARS_TO_INJECT="PXE_URL PRIVATE_KEY DEBUG" export PXE_URL=${PXE_URL:-"http://host.docker.internal:8080"} export ETHEREUM_HOST=${ETHEREUM_HOST:-"http://host.docker.internal:8545"} diff --git a/aztec-up/bin/aztec-nargo b/aztec-up/bin/aztec-nargo index dfce52ea5fa1..c3437a78e084 100755 --- a/aztec-up/bin/aztec-nargo +++ b/aztec-up/bin/aztec-nargo @@ -2,6 +2,7 @@ set -euo pipefail export SKIP_NET=1 +export SKIP_PORT_ASSIGNMENT=1 export PATH=$PATH:$HOME/bin if [ "${1:-}" == "lsp" ]; then From e7513c01402b86cf0f079d18a9f1f41c5d1f7f0f Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Fri, 24 May 2024 20:14:36 +0000 Subject: [PATCH 11/11] typo --- aztec-up/bin/aztec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aztec-up/bin/aztec b/aztec-up/bin/aztec index 863952060281..a00575777c88 100755 --- a/aztec-up/bin/aztec +++ b/aztec-up/bin/aztec @@ -5,7 +5,7 @@ set -euo pipefail if [ -n "${1-}" ] && [ "$1" != "--help" ]; then if [ "$1" == "cli" ]; then shift - SKIP_PORT_ASSIGNMENTS=1 $(dirname $0)/.aztec-run aztecprotocol/cli "$@" + SKIP_PORT_ASSIGNMENT=1 $(dirname $0)/.aztec-run aztecprotocol/cli "$@" elif [ "$1" == "sandbox" ]; then $(dirname $0)/aztec-sandbox else