Skip to content

Commit

Permalink
feat: add barretenberg wasm build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed May 5, 2024
1 parent 1e81947 commit cc3d3d0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 30 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ jobs:
timeout-minutes: 25
run: earthly-ci --no-output ./+test

noir-packages-test:
needs: setup
runs-on: ${{ inputs.username || github.actor }}-x86
steps:
- {
uses: actions/checkout@v4,
with: { ref: "${{ github.event.pull_request.head.sha }}" },
}
- uses: ./.github/ci-setup-action
with:
dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}"
concurrency_key: noir-${{ inputs.username || github.actor }}-x86
- name: "Test Noir JS packages"
run: earthly-ci --no-output ./noir+packages-test

noir-projects:
needs: setup
runs-on: ${{ inputs.username || github.actor }}-x86
Expand Down Expand Up @@ -348,7 +363,7 @@ jobs:
working-directory: ./barretenberg/cpp/
timeout-minutes: 15
run: earthly-ci --no-output +bench-ultra-honk --bench_mode=cache

protocol-circuits-gates-report:
needs: setup
runs-on: ${{ inputs.username || github.actor }}-x86
Expand Down Expand Up @@ -393,6 +408,7 @@ jobs:
- yarn-project-formatting
- yarn-project-test
- prover-client-test
- noir-packages-test
if: always()
steps:
- run: |
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/ts/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY --dir src *.json *.js *.cjs .
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm src/barretenberg_wasm/barretenberg-threads.wasm
COPY ../cpp/+preset-wasm/bin/barretenberg.wasm src/barretenberg_wasm/barretenberg.wasm
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm dest/node/barretenberg_wasm/barretenberg-threads.wasm
COPY ../cpp/+preset-wasm/bin/barretenberg.wasm dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm

esm:
RUN yarn build:esm
Expand Down
51 changes: 25 additions & 26 deletions noir/Earthfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
VERSION 0.8

nargo:
LOCALLY
LET git_commit = $(git rev-parse HEAD)
nargo-src:

FROM ../build-images/+build
WORKDIR /usr/src
Expand All @@ -20,12 +18,22 @@ nargo:
noir-repo/.github \
noir-repo

RUN ./noir-repo/.github/scripts/wasm-bindgen-install.sh
# NOTE: we use a fake commit hash here
# we don't want Noir to rebuild everytime the parent repo changes
# just only when it changes
# the commit hash gets injected into version strings
ENV COMMIT_HASH=$(find . -type f -exec sha256sum {} ';' | sort | sha256sum | awk '{print $1}')
RUN echo $COMMIT_HASH > .content-hash

# # borrow Nix's approach to build everything in 1970
ENV SOURCE_TIMESTAMP=1
ENV SOURCE_DATE_EPOCH=1

ENV COMMIT_HASH=$git_commit
nargo:
FROM +nargo-src
RUN ./noir-repo/.github/scripts/wasm-bindgen-install.sh
COPY ./scripts/bootstrap_native.sh ./scripts/bootstrap_native.sh
RUN ./scripts/bootstrap_native.sh
RUN echo CONTENT HASH $COMMIT_HASH | tee .content-hash
SAVE ARTIFACT /usr/src/noir-repo/target/release/nargo nargo
SAVE ARTIFACT /usr/src/noir-repo/target/release/acvm acvm
SAVE IMAGE aztecprotocol/nargo
Expand All @@ -36,15 +44,8 @@ packages-deps:
LOCALLY
LET packages = $(git ls-files "**/package*.json" package*.json)
LET tsconfigs = $(git ls-files "**/tsconfig*.json" tsconfig*.json)
LET git_commit = $(git rev-parse HEAD)

FROM ../build-images/+build

RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
RUN apt update && apt install -y jq libc++1

ENV PATH=/root/.cargo/bin:$PATH
FROM +nargo-src

COPY ../barretenberg/ts/+build/build /usr/src/barretenberg/ts

Expand Down Expand Up @@ -90,23 +91,15 @@ packages-deps:
noir-repo/.github \
noir-repo

ENV GIT_DIRTY=false
ENV GIT_COMMIT=$git_commit
ENV SOURCE_TIMESTAMP=$(date +%s)
ENV SOURCE_DATE_EPOCH=$(date +%s)

SAVE ARTIFACT noir-repo

packages:
FROM +packages-deps

RUN echo CONTENT HASH $GIT_COMMIT | tee .content-hash
COPY ./scripts/bootstrap_packages.sh ./scripts/bootstrap_packages.sh
RUN ./scripts/bootstrap_packages.sh
SAVE ARTIFACT packages
SAVE IMAGE --cache-hint

packages-test-deps:
packages-test-build:
FROM +packages-deps

COPY +nargo/nargo /usr/src/noir/noir-repo/target/release/nargo
Expand All @@ -119,16 +112,22 @@ packages-test-deps:
RUN yarn --immutable

WORKDIR /usr/src/noir/noir-repo
COPY --dir noir-repo/.github/scripts .github/scripts
COPY --dir noir-repo/.github/scripts/wasm-bindgen-install.sh ./.github/scripts/wasm-bindgen-install.sh
RUN ./.github/scripts/wasm-bindgen-install.sh

ENV SOURCE_DATE_EPOCH=$(date +%s)
ENV GIT_DIRTY=false
ENV GIT_COMMIT=$COMMIT_HASH
RUN yarn build
# this builds text fixtures to be used in tests
RUN yarn workspace @noir-lang/noir_wasm run test:build_fixtures

SAVE ARTIFACT /usr/src /usr/src

packages-test-node:
FROM +packages-test-deps
FROM +packages-test-build
ENV NODE_OPTIONS=--max_old_space_size=8192
WORKDIR /usr/src/noir/noir-repo
RUN yarn workspaces foreach \
--parallel \
--verbose \
Expand All @@ -146,7 +145,7 @@ packages-test-node:

packages-test-browser:
FROM node:18
COPY --dir +packages-test-deps/usr/src /usr
COPY --dir +packages-test-build/usr/src /usr
WORKDIR /usr/src/noir/noir-repo
RUN ./.github/scripts/playwright-install.sh
RUN yarn workspaces foreach \
Expand Down
3 changes: 1 addition & 2 deletions noir/scripts/bootstrap_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ cd $ROOT/noir-repo
# Set build data manually.
export SOURCE_DATE_EPOCH=$(date +%s)
export GIT_DIRTY=false
export COMMIT_HASH=${COMMIT_HASH:-$(git rev-parse --verify HEAD)}
export GIT_COMMIT=${GIT_COMMIT:-$COMMIT_HASH}
export GIT_COMMIT=${COMMIT_HASH:-$(git rev-parse --verify HEAD)}

PROJECTS=(
@noir-lang/acvm_js
Expand Down

0 comments on commit cc3d3d0

Please sign in to comment.