Skip to content

Commit

Permalink
feat(avm): run transpiler in ci (#4258)
Browse files Browse the repository at this point in the history
Adds avm-simulator build to ci such that it can be ran within
noir-contracts build

1. Create binary
2. Copy binary in `yarn-project-base`
3. Run binary in noir contracts `build` - in yarn project build
  • Loading branch information
Maddiaa0 authored Jan 29, 2024
1 parent 58b98e3 commit 8b8c472
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ jobs:
name: "Build"
command: cond_spot_run_build noir-compile-acir-tests 32

avm-transpiler:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build"
command: cond_spot_run_build avm-transpiler 32

# Barretenberg
barretenberg-wasm-linux-clang:
docker:
Expand Down Expand Up @@ -1137,6 +1148,9 @@ workflows:
- noir-ecr-manifest
<<: *defaults

# Transpiler
- avm-transpiler: *defaults

# Barretenberg
- barretenberg-x86_64-linux-gcc: *defaults
- barretenberg-x86_64-linux-clang: *defaults
Expand Down Expand Up @@ -1185,6 +1199,7 @@ workflows:
# Yarn Project
- yarn-project-base:
requires:
- avm-transpiler
- l1-contracts
- bb-js
- noir-ecr-manifest
Expand Down
13 changes: 13 additions & 0 deletions avm-transpiler/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:bookworm

WORKDIR /usr/src
COPY ./avm-transpiler ./avm-transpiler
COPY ./noir ./noir

WORKDIR /usr/src/avm-transpiler
RUN apt-get update && apt-get install -y git
RUN ./scripts/bootstrap_native.sh

FROM ubuntu:lunar
COPY --from=0 /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler
ENTRYPOINT ["sh", "-c"]
7 changes: 7 additions & 0 deletions avm-transpiler/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**

!avm-transpiler/
!noir/
**/target/
**/node_modules/
**/packages/
2 changes: 1 addition & 1 deletion avm-transpiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ This component transpiles Aztec public contracts code from Noir's Brillig byteco

```
cargo run <aztec-contract-artifact-json> <transpiled-output-json>
```
```
20 changes: 20 additions & 0 deletions avm-transpiler/scripts/bootstrap_native.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eu

cd $(dirname "$0")/..

# If this project has been subrepod into another project, set build data manually.
export SOURCE_DATE_EPOCH=$(date +%s)
export GIT_DIRTY=false
if [ -f ".gitrepo" ]; then
export GIT_COMMIT=$(awk '/commit =/ {print $3}' .gitrepo)
else
export GIT_COMMIT=$(git rev-parse --verify HEAD)
fi

# Build native.
if [ -n "${DEBUG:-}" ]; then
cargo build
else
cargo build --release
fi
1 change: 1 addition & 0 deletions avm-transpiler/src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> {
bytecode
}

//
//use acvm::acir::brillig::Opcode as BrilligOpcode;
//use acvm::acir::circuit::brillig::Brillig;
//
Expand Down
7 changes: 7 additions & 0 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ yarn-project-base:
- noir
- noir-packages
- boxes-files
- avm-transpiler

yarn-project:
buildDir: yarn-project
Expand Down Expand Up @@ -209,3 +210,9 @@ yellow-paper:
buildDir: yellow-paper
rebuildPatterns:
- ^yellow-paper/

avm-transpiler:
buildDir: .
dockerfile: avm-transpiler/Dockerfile
rebuildPatterns:
- ^avm-transpiler/
2 changes: 1 addition & 1 deletion yarn-project/noir-contracts/package.local.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"build": "yarn clean && yarn build:contracts && tsc -b",
"build:contracts": "./scripts/compile.sh && ./scripts/generate-types.sh",
"build:contracts": "./scripts/compile.sh && ./scripts/transpile.sh && ./scripts/generate-types.sh",
"clean": "rm -rf ./dest .tsbuildinfo ./src ./target"
}
}
2 changes: 1 addition & 1 deletion yarn-project/noir-contracts/scripts/transpile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ set -euo pipefail
echo "Transpiling contracts..."
for contract_json in target/avm_test_*.json; do
echo Transpiling $contract_json...
../../avm-transpiler/target/debug/avm-transpiler $contract_json $contract_json
../../avm-transpiler/target/release/avm-transpiler $contract_json $contract_json
done
3 changes: 3 additions & 0 deletions yarn-project/yarn-project-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/bb.js as bb.js
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir as noir
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir-packages as noir-packages
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/boxes-files as boxes-files
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/avm-transpiler as transpiler

FROM node:18.19.0
RUN apt update && apt install -y jq curl perl && rm -rf /var/lib/apt/lists/* && apt-get clean
Expand All @@ -61,6 +62,8 @@ COPY --from=noir /usr/src/noir/target/release/nargo /usr/src/noir/target/release
COPY --from=noir-packages /usr/src/noir/packages /usr/src/noir/packages
# Copy in boxes
COPY --from=boxes-files /usr/src/boxes /usr/src/boxes
# Copy in transpiler
COPY --from=transpiler /usr/src/avm-transpiler/target/release/avm-transpiler /usr/src/avm-transpiler/target/release/avm-transpiler

# We install a symlink to yarn-project's node_modules at a location that all portalled packages can find as they
# walk up the tree as part of module resolution. The supposedly idiomatic way of supporting module resolution
Expand Down

0 comments on commit 8b8c472

Please sign in to comment.