Skip to content

Commit

Permalink
feat: CI to test aztec circuits with current commit of bberg (#418)
Browse files Browse the repository at this point in the history
* More generators for aztec3.

* update js vk (because we now use UP for merkle hashing)

* Helpers for ECDSA in A3 (#364)

* Add `stdlib_keccak` in cmake.

Correct an assertion in `to_byte_array` in bigfield.

* Add `random_element` to affine element.

* negate y conditionally.

* Change pedersen hash c_bind to use `pedersen_hash::lookup`.

* c_binds and other ECDSA related fixes (#407)

* Add v to stdlib ecdsa.

* create an engine if its empty.

* Add ecdsa c_bind.

* print v as a uint32.

* Add secp256k1 cbind.

add c_bind.hpp

Change hpp to h.

remove hpp.

* Add ecdsa in cmakelists.

remove stdlib_ecdsa from build.

* hack: (aztec3) introduce barretenberg crypto generator parameters hack (#408)

* hack: introduce BARRETENBERG_CRYPTO_GENERATOR_PARAMETERS_HACK

* doc: concise

* chore: align BARRETENBERG_CRYPTO_GENERATOR_PARAMETERS_HACK usage

* CI to test aztec circuits with current commit of bberg

* build manifest

* chore: align BARRETENBERG_CRYPTO_GENERATOR_PARAMETERS_HACK usage (#411)

* try other branch of aztec packages

* ci rename script

* Update join_split test

* bump aztec version and merge in aztec3-temporary fixes

* aztec commit switched to branch

* bump aztec commit and document

* typo README.md

* Update README.md

---------

Co-authored-by: Suyash Bagad <[email protected]>
Co-authored-by: Suyash Bagad <[email protected]>
Co-authored-by: ludamad <[email protected]>
Co-authored-by: ludamad <[email protected]>
  • Loading branch information
5 people authored May 4, 2023
1 parent 4487114 commit adbbddc
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 7 deletions.
2 changes: 1 addition & 1 deletion barretenberg/.circleci/cond_spot_run_build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LAST_SUCCESSFUL_COMMIT=$(last_successful_commit $REPOSITORY)
echo "Last successful commit: $LAST_SUCCESSFUL_COMMIT"

if check_rebuild "$LAST_SUCCESSFUL_COMMIT" $REPOSITORY; then
spot_run_script $SPEC ../.circleci/remote_build/remote_build $REPOSITORY $@
spot_run_script $SPEC $BUILD_SYSTEM_PATH/remote_build/remote_build $REPOSITORY $@
else
echo "No rebuild necessary. Retagging..."
STAGES=$(cat $DOCKERFILE | sed -n -e 's/^FROM .* AS \(.*\)/\1/p')
Expand Down
13 changes: 13 additions & 0 deletions barretenberg/.circleci/cond_spot_run_test_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
REPOSITORY=$1
SCRIPT_PATH=$2
shift
shift

cd $(query_manifest projectDir $REPOSITORY)

mkdir -p /tmp/test-logs

set -o pipefail
cond_spot_run_script $REPOSITORY $JOB_NAME 32 $SCRIPT_PATH $@ | tee "/tmp/test-logs/$JOB_NAME.log"
69 changes: 68 additions & 1 deletion barretenberg/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ benchmark_add_keys: &benchmark_add_keys
setup_env: &setup_env
run:
name: "Setup environment"
command: cd .circleci && ./setup_env "$CIRCLE_SHA1" "$CIRCLE_TAG" "$CIRCLE_JOB" "$CIRCLE_REPOSITORY_URL" "$CIRCLE_BRANCH"
command: |
cd .circleci && ./setup_env "$CIRCLE_SHA1" "$CIRCLE_TAG" "$CIRCLE_JOB" "$CIRCLE_REPOSITORY_URL" "$CIRCLE_BRANCH"
setup_aztec_commit: &setup_aztec_commit
run:
name: "Setup environment for Aztec Integration Testing"
command: |
# Load the aztec commit into env for use in integration tests
echo "export AZTEC_COMMIT=$(cat cpp/.aztec-packages-commit 2>/dev/null || echo master)" >> "$BASH_ENV"
source "$BASH_ENV"
# This step is used to save logs from various barretenberg test to the workspace so that they can be used later to parse benchmark values out of them
save_logs: &save_logs
Expand Down Expand Up @@ -235,6 +244,56 @@ jobs:
name: "Test"
command: store_test_benchmark_logs barretenberg-x86_64-linux-clang-assert

###################################
# Aztec integration tests
circuits-wasm-linux-clang-builder-runner:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build"
command: cond_spot_run_build barretenberg-circuits-wasm-linux-clang-builder-runner 64

circuits-x86_64-linux-clang-builder-runner:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build"
command: cond_spot_run_build barretenberg-circuits-x86_64-linux-clang-builder-runner 64

circuits-wasm-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- *setup_aztec_commit
- run:
name: "Build"
command: cond_spot_run_test_script barretenberg-circuits-wasm-linux-clang-builder-runner ./scripts/run_aztec_circuits_tests "$AZTEC_COMMIT" 1 wasm scripts/a3-tests -*.skip*:*.circuit*

circuits-x86_64-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- *setup_aztec_commit
- run:
name: "Build"
command: cond_spot_run_test_script barretenberg-circuits-x86_64-linux-clang-builder-runner ./scripts/run_aztec_circuits_tests "$AZTEC_COMMIT" 1 x86_64 scripts/a3-tests -*.skip*
# End Aztec integration tests
###################################

# Repeatable config for defining the workflow below.
bb_test: &bb_test
requires:
Expand Down Expand Up @@ -266,3 +325,11 @@ workflows:
branches:
only:
- master
- circuits-wasm-linux-clang-builder-runner
- circuits-x86_64-linux-clang-builder-runner
- circuits-wasm-tests:
requires:
- circuits-wasm-linux-clang-builder-runner
- circuits-x86_64-tests:
requires:
- circuits-x86_64-linux-clang-builder-runner
6 changes: 6 additions & 0 deletions barretenberg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,9 @@ Alternatively you can build separate test binaries, e.g. honk_tests or numeric_t
### VS Code configuration

A default configuration for VS Code is provided by the file [`barretenberg.code-workspace`](barretenberg.code-workspace). These settings can be overridden by placing configuration files in `.vscode/`.

### Integration tests with Aztec Circuits

CI will automatically run integration tests against Aztec's circuits which live [here](https://github.com/AztecProtocol/aztec-packages/tree/master/circuits). To change which Aztec branch or commit for CI to test against, modify [`.aztec-packages-commit`](./cpp/.aztec-packages-commit).

When working on a PR, you may want to point this file to a adifferent Aztec branch or commit, but then it should probably be pointed back to master before merging.
16 changes: 11 additions & 5 deletions barretenberg/build_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@
"rebuildPatterns": ["^cpp/"],
"dependencies": []
},
"barretenberg.js": {
"buildDir": "js",
"dockerfile": "js/Dockerfile",
"rebuildPatterns": ["^js/"],
"dependencies": ["barretenberg-wasm-linux-clang"]
"barretenberg-circuits-x86_64-linux-clang-builder-runner": {
"buildDir": "cpp",
"dockerfile": "dockerfiles/Dockerfile.circuits-x86_64-linux-clang-builder-runner",
"rebuildPatterns": ["^cpp/"],
"dependencies": []
},
"barretenberg-circuits-wasm-linux-clang-builder-runner": {
"buildDir": "cpp",
"dockerfile": "dockerfiles/Dockerfile.circuits-wasm-linux-clang-builder-runner",
"rebuildPatterns": ["^cpp/"],
"dependencies": []
}
}
1 change: 1 addition & 0 deletions barretenberg/cpp/.aztec-packages-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
master
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:kinetic
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y bash build-essential git libssl-dev cmake ninja-build curl binaryen xz-utils curl

RUN curl https://wasmtime.dev/install.sh -sSf | bash /dev/stdin --version v3.0.1
WORKDIR /usr/src/barretenberg/cpp/src
RUN curl -s -L https://github.com/CraneStation/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz | tar zxfv -
WORKDIR /usr/src/barretenberg/cpp
COPY . .
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine:3.17
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
bash \
build-base \
clang15 \
openmp \
openmp-dev \
cmake \
ninja \
git \
curl \
perl

WORKDIR /usr/src/barretenberg/cpp

COPY . .
52 changes: 52 additions & 0 deletions barretenberg/cpp/scripts/run_aztec_circuits_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -e

# To be called from CI for testing with docker and AWS.
# Can't be called locally unless AWS credentials are set up.
#
# Call from config.yml
# Example:
# command: cond_spot_run_script circuits-wasm-linux-clang-assert 1 wasm scripts/a3-tests -*.skip*:*.circuit*

AZTEC_COMMIT=$1 # Aztec commit/branch to checkout (MANDATORY)
NUM_TRANSCRIPTS=$2 # integer (MANDATORY)
ARCH=$3 # x86_64 or wasm (MUST BE LOWERCASE) (MANDATORY) used in aztec's circuits `run_tests_local`
# TESTS=$4 (MANDATORY) used in aztec's circuits `run_tests_local` (test files rel to circuits/cpp)
# GTEST_FILTER=$5 (optional) used in aztec's circuits `run_tests_local`
# *** See `run_tests_local` for the args forwarded to that script
shift # arg1 (aztec commit) and arg2 (num transcripts) are not forwarded
shift # to aztec's circuits `run_tests_local`

$(aws ecr get-login --region us-east-2 --no-include-email) 2> /dev/null

IMAGE_URI=278380418400.dkr.ecr.us-east-2.amazonaws.com/barretenberg-circuits-${ARCH}-linux-clang-builder-runner:cache-$COMMIT_HASH
docker pull $IMAGE_URI

if [ "$ARCH" != "wasm" ]; then
# x86_64 / anything other than wasm
PRESET=default
CONFIGURE_OPTS="-DCMAKE_BUILD_TYPE=RelWithAssert -DCI=ON"
BUILD_DIR=build
else
PRESET=wasm
BUILD_DIR=build-wasm
fi

echo "*** Running Aztec circuits tests on commit: $AZTEC_COMMIT"
# run tests in docker
RUN_ARGS="$@" # helper var necessary for some reason to pass all args to docker run
docker run --rm -t $IMAGE_URI /bin/sh -c "\
set -e; \
cd /usr/src/; \
git clone https://github.com/AztecProtocol/aztec3-packages.git; \
cd /usr/src/aztec3-packages/circuits/cpp; \
git checkout $AZTEC_COMMIT; \
rm -rf /usr/src/aztec3-packages/circuits/cpp/barretenberg;
mv /usr/src/barretenberg .; \
cmake --preset $PRESET $CONFIGURE_OPTS; \
cmake --build --preset $PRESET; \
cd /usr/src/aztec3-packages/circuits/cpp/barretenberg/cpp/srs_db; \
./download_ignition.sh $NUM_TRANSCRIPTS; \
cd /usr/src/aztec3-packages/circuits/cpp; \
export PATH=\$PATH:~/.wasmtime/bin/; \
./scripts/run_tests_local $RUN_ARGS;"

0 comments on commit adbbddc

Please sign in to comment.