Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge defi-bridge-project into master (dependent CMake pj support, rollup/ removal, kesha's bigfield fix) #123

Merged
merged 41 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
07e62f6
Fix to bootstrap.sh after move into submodule (#1)
dbanks12 Dec 12, 2022
33e0b2d
Contrived change.
charlielye Dec 12, 2022
f4a7e85
Revert "Contrived change."
charlielye Dec 12, 2022
e1d5577
Revert "Revert "Contrived change.""
charlielye Dec 12, 2022
1c58e01
Introduce cpp to paths.
charlielye Dec 13, 2022
57991a2
More cpp path.
charlielye Dec 13, 2022
1744ff8
Target x86-64 arch so we're compatible with rosetta emulation on m1 m…
charlielye Jan 4, 2023
f2276d3
Target skylake but without avx.
charlielye Jan 4, 2023
b31bd7e
Fix indent.
charlielye Jan 4, 2023
31c3d20
Fixing fuzzer build (#14)
Rumata888 Jan 4, 2023
3b6bc9b
Elide sig check on 'merge' join-split proofs (#42)
ludamad Jan 16, 2023
e5e51ba
join_split: Require same account flag for 'merge' (#70)
ludamad Jan 20, 2023
4bd6d08
Add cmake logic to support building of dependent C++/WASM projects (#54)
dbanks12 Jan 24, 2023
1733b72
Removed all files in rollup/ not necessary for join split tests
dbanks12 Feb 3, 2023
a1f7d02
dockerfile, script, and ci changes now that rollup contents are gone …
dbanks12 Feb 3, 2023
c58691b
remove more unused code from rollup/js dir
dbanks12 Feb 3, 2023
856a374
attempt at merging dbp into master
dbanks12 Feb 6, 2023
503faa0
missed a rollup->grumpkin rename
dbanks12 Feb 6, 2023
4ce8c70
removed standard example
dbanks12 Feb 6, 2023
34b9daf
rename rollup directory to join_split_example
dbanks12 Feb 6, 2023
2cbc9ad
some missing changes to schnorr and dockerfile for merge
dbanks12 Feb 6, 2023
0547b02
fix bigfield manual merge scoping
dbanks12 Feb 6, 2023
d53b1d8
filter out longer join split tests (leave only one full proof test in…
dbanks12 Feb 6, 2023
c73216f
fix dockerfile now that rollup executables were removed
dbanks12 Feb 6, 2023
0fba8b8
rename rollup namespace to join_split_example
dbanks12 Feb 6, 2023
e1473e2
add rollup notes tests back into bb-tests
dbanks12 Feb 6, 2023
1e50799
remove duplicated js test from bb-tests
dbanks12 Feb 6, 2023
e3c2025
manually merged in rollup removal while that pr is in progress
dbanks12 Feb 6, 2023
1ee0794
fix badly merged config.yml
dbanks12 Feb 6, 2023
c17fc52
fix bad schnorr merge
dbanks12 Feb 6, 2023
a592714
remove dbp schnorr change and js test changes before merge into master
dbanks12 Feb 7, 2023
db63525
add blake 3 to executables in aztec cmakelists
dbanks12 Feb 7, 2023
93ffb50
revert dbp schnorr test changes
dbanks12 Feb 7, 2023
b62ef79
Removing all `rollup/` contents except join-split as example (#124)
dbanks12 Feb 7, 2023
b253642
remove vk constants from join-split
dbanks12 Feb 7, 2023
0928de5
merge dbp after rollup removal intomaster-merge branch
dbanks12 Feb 7, 2023
0224ef4
fix config yml bad merge
dbanks12 Feb 7, 2023
14e02a4
revert join_split.test.cpp to use latest master instead of dbp changes
dbanks12 Feb 7, 2023
31f261e
revert verify_signature, fix asset_id hpp
dbanks12 Feb 7, 2023
ff58cb4
revert get_composer_name and fix a namespace
dbanks12 Feb 7, 2023
7e2e041
constants fix
dbanks12 Feb 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 12 additions & 60 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ jobs:
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 3 stdlib_recursion_tests --gtest_filter=-*turbo*
- *save_logs

tx-rollup-tests:
join-split-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
Expand All @@ -218,55 +218,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 1 rollup_proofs_tx_rollup_tests --gtest_filter=-rollup_full_tests.*
- *save_logs

tx-rollup-full-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 1 rollup_proofs_tx_rollup_tests --gtest_filter=rollup_full_tests.*
- *save_logs

root-rollup-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 1 rollup_proofs_root_rollup_tests --gtest_filter=-root_rollup_full_tests.*
- *save_logs

root-rollup-full-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 1 rollup_proofs_root_rollup_tests --gtest_filter=root_rollup_full_tests.*
- *save_logs

root-verifier-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 3 rollup_proofs_root_verifier_tests
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 3 join_split_example_proofs_join_split_tests --gtest_filter=-*full_proof*
- *save_logs

benchmark-aggregator:
Expand Down Expand Up @@ -298,26 +250,26 @@ workflows:
- honk-tests: *bb_test
- barretenberg-tests: *bb_test
- stdlib-primitives-tests: *bb_test
<<<<<<< HEAD
- stdlib-biggroup-tests: *bb_test
- stdlib-recursion-turbo-tests: *bb_test
- stdlib-recursion-ultra-tests: *bb_test
- tx-rollup-tests: *bb_test
- tx-rollup-full-tests: *bb_test
- root-rollup-tests: *bb_test
- root-rollup-full-tests: *bb_test
- root-verifier-tests: *bb_test
=======
- stdlib-recursion-tests: *bb_test
>>>>>>> origin/defi-bridge-project
- join-split-tests: *bb_test
- benchmark-aggregator:
requires:
- barretenberg-tests
- stdlib-primitives-tests
<<<<<<< HEAD
- stdlib-biggroup-tests
- stdlib-recursion-turbo-tests
- stdlib-recursion-ultra-tests
- tx-rollup-tests
- tx-rollup-full-tests
- root-verifier-tests
- root-rollup-tests
- root-rollup-full-tests
=======
- stdlib-recursion-tests
>>>>>>> origin/defi-bridge-project
- join-split-tests
filters:
branches:
only:
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ The structured reference string contains monomials up to x^{2^20}. This SRS was
RUN git clone -b release/10.x --depth 1 https://github.com/llvm/llvm-project.git \
&& cd llvm-project && mkdir build-openmp && cd build-openmp \
&& cmake ../openmp -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLIBOMP_ENABLE_SHARED=OFF \
&& make -j$(nproc) \
&& make install \
&& cmake --build . --parallel \
&& cmake --build . --parallel --target install \
&& cd ../.. && rm -rf llvm-project
```

Expand All @@ -27,12 +27,13 @@ RUN git clone -b release/10.x --depth 1 https://github.com/llvm/llvm-project.git
Run the bootstrap script. (The bootstrap script will build both the native and wasm versions of barretenberg)

```
cd cpp
./bootstrap.sh
```

### Parallelise the build

Make sure your MAKEFLAGS environment variable is set to run jobs equal to number of cores. e.g. `MAKEFLAGS=-j$(nproc)`.
Use the `--parallel` option to `cmake --build <path>` to parallelize builds. This is roughly equivalent to `make -j$(nproc)` but is more portable.

### Formatting

Expand All @@ -44,20 +45,20 @@ If you've installed the C++ Vscode extension you should configure it to format o
Each module has its own tests. e.g. To build and run `ecc` tests:

```
make ecc_tests
cmake --build . --parallel --target ecc_tests
./bin/ecc_tests
```

A shorthand for the above is:

```
make run_ecc_tests
cmake --build . --parallel --target run_ecc_tests
```

Running the entire suite of tests using `ctest`:

```
make test
cmake --build . --parallel --target test
```

You can run specific tests, e.g.
Expand All @@ -71,14 +72,14 @@ You can run specific tests, e.g.
Some modules have benchmarks. The build targets are named `<module_name>_bench`. To build and run, for example `ecc` benchmarks.

```
make ecc_bench
cmake --build . --parallel --target ecc_bench
./src/aztec/ecc/ecc_bench
```

A shorthand for the above is:

```
make run_ecc_bench
cmake --build . --parallel --target run_ecc_bench
```

### CMake Build Options
Expand All @@ -101,10 +102,10 @@ To build:
```
mkdir build-wasm && cd build-wasm
cmake -DTOOLCHAIN=wasm-linux-clang ..
make barretenberg.wasm
cmake --build . --parallel --target barretenberg.wasm
```

The resulting wasm binary will be at `./src/aztec/barretenberg.wasm`.
The resulting wasm binary will be at `./build-wasm/bin/barretenberg.wasm`.

To run the tests, you'll need to install `wasmtime`.

Expand All @@ -115,7 +116,7 @@ curl https://wasmtime.dev/install.sh -sSf | bash
Tests can be built and run like:

```
make ecc_tests
cmake --build . --parallel --target ecc_tests
wasmtime --dir=.. ./bin/ecc_tests
```

Expand All @@ -125,11 +126,11 @@ To build:
```
mkdir build-fuzzing && cd build-fuzzing
cmake -DTOOLCHAIN=x86_64-linux-clang -DFUZZING=ON ..
make
cmake --build . --parallel
```
Fuzzing build turns off building tests and benchmarks, since they are incompatible with libfuzzer interface.

To turn on address sanitizer add `-DADDRESS_SANITIZER=ON`. Note that address sanitizer can be used to explore crashes.
Sometimes you might have to specify the address of llvm-symbolizer. You have to do it with `export ASAN_SYMBOLIZER_PATH=<PATH_TO_SYMBOLIZER>`.
For undefined behaviour sanitizer `-DUNDEFINED_BEHAVIOUR_SANITIZER=ON`.
Note that the fuzzer can be orders of magnitude slower with ASan (2-3x slower) or UBSan on, so it is best to run a non-sanitized build first, minimize the testcase and then run it for a bit of time with sanitizers.
Note that the fuzzer can be orders of magnitude slower with ASan (2-3x slower) or UBSan on, so it is best to run a non-sanitized build first, minimize the testcase and then run it for a bit of time with sanitizers.
3 changes: 2 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ if(FUZZING)

set(WASM OFF)
set(BENCHMARKS OFF)
set(MULTITHREADING OFF)
set(TESTING OFF)
endif()

Expand Down Expand Up @@ -84,4 +85,4 @@ include(cmake/gtest.cmake)
include(cmake/benchmark.cmake)
include(cmake/module.cmake)

add_subdirectory(src/aztec)
add_subdirectory(src/aztec)
42 changes: 21 additions & 21 deletions cpp/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
set -e
set -eu

# Clean.
rm -rf ./build
rm -rf ./build-wasm
rm -rf ./src/wasi-sdk-*

# Install formatting git hook.
HOOKS_DIR=$(git rev-parse --git-path hooks)
Expand All @@ -16,12 +17,12 @@ chmod +x $HOOKS_DIR/pre-commit

# Determine system.
if [[ "$OSTYPE" == "darwin"* ]]; then
OS=macos
OS=macos
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
OS=linux
OS=linux
else
echo "Unknown OS: $OSTYPE"
exit 1
echo "Unknown OS: $OSTYPE"
exit 1
fi

# Download ignition transcripts.
Expand All @@ -32,31 +33,30 @@ cd ..

# Pick native toolchain file.
if [ "$OS" == "macos" ]; then
export BREW_PREFIX=$(brew --prefix)
# Ensure we have toolchain.
if [ ! "$?" -eq 0 ] || [ ! -f "$BREW_PREFIX/opt/llvm/bin/clang++" ]; then
echo "Default clang not sufficient. Install homebrew, and then: brew install llvm libomp clang-format"
exit 1
fi
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
TOOLCHAIN=arm-apple-clang
else
TOOLCHAIN=x86_64-apple-clang
fi
export BREW_PREFIX=$(brew --prefix)
dbanks12 marked this conversation as resolved.
Show resolved Hide resolved
# Ensure we have toolchain.
if [ ! "$?" -eq 0 ] || [ ! -f "$BREW_PREFIX/opt/llvm/bin/clang++" ]; then
echo "Default clang not sufficient. Install homebrew, and then: brew install llvm libomp clang-format"
exit 1
fi
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
TOOLCHAIN=arm-apple-clang
else
TOOLCHAIN=x86_64-apple-clang
fi
else
TOOLCHAIN=x86_64-linux-clang
TOOLCHAIN=x86_64-linux-clang
fi

# Build native.
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=RelWithAssert -DTOOLCHAIN=$TOOLCHAIN ..
make -j$(getconf _NPROCESSORS_ONLN) $@
cmake --build . --parallel ${@/#/--target }
cd ..

# Install the webassembly toolchain.
WASI_VERSION=12
rm -rf ./src/wasi-sdk-*
cd ./src
curl -s -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_VERSION/wasi-sdk-$WASI_VERSION.0-$OS.tar.gz | tar zxfv -
cd ..
Expand All @@ -65,4 +65,4 @@ cd ..
mkdir -p build-wasm && cd build-wasm
cmake -DTOOLCHAIN=wasm-linux-clang ..
cmake --build . --parallel --target barretenberg.wasm
cd ..
cd ..
2 changes: 1 addition & 1 deletion cpp/cmake/arch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ if(WASM)
endif()

if(NOT WASM AND NOT APPLE)
add_compile_options(-march=skylake-avx512)
add_compile_options(-march=skylake)
endif()
5 changes: 4 additions & 1 deletion cpp/cmake/toolchains/wasm-linux-clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR wasm32)
set(triple wasm32-wasi)

set(WASI_SDK_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/src/wasi-sdk-12.0")
if (NOT WASI_SDK_PREFIX)
# can be set by a dependent project
set(WASI_SDK_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/src/wasi-sdk-12.0")
endif()
set(CMAKE_C_COMPILER ${WASI_SDK_PREFIX}/bin/clang)
set(CMAKE_CXX_COMPILER ${WASI_SDK_PREFIX}/bin/clang++)
set(CMAKE_AR ${WASI_SDK_PREFIX}/bin/llvm-ar CACHE STRING "wasi-sdk build")
Expand Down
2 changes: 1 addition & 1 deletion cpp/dockerfiles/Dockerfile.arm64-linux-gcc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM aztecprotocol/crosstool-ng-arm64:latest
WORKDIR /usr/src/barretenberg/cpp
COPY . .
RUN mkdir build && cd build && cmake -DTOOLCHAIN=arm64-linux-gcc .. && make -j$(nproc)
RUN mkdir build && cd build && cmake -DTOOLCHAIN=arm64-linux-gcc .. && cmake --build . --parallel
RUN cd build && qemu-aarch64 ./test/barretenberg_tests
ENTRYPOINT /bin/bash
2 changes: 1 addition & 1 deletion cpp/dockerfiles/Dockerfile.wasm-linux-clang
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /usr/src/barretenberg/cpp
COPY . .
# Build both honk_tests barretenberg.wasm
# This ensures that we aren't using features that would be incompatible with WASM for Honk
RUN mkdir build && cd build && cmake -DTOOLCHAIN=wasm-linux-clang .. && make -j$(nproc) honk_tests barretenberg.wasm
RUN mkdir build && cd build && cmake -DTOOLCHAIN=wasm-linux-clang .. && cmake --build . --parallel --target honk_tests --target barretenberg.wasm

FROM alpine:3.17
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/barretenberg.wasm /usr/src/barretenberg/cpp/build/bin/barretenberg.wasm
Expand Down
10 changes: 4 additions & 6 deletions cpp/dockerfiles/Dockerfile.x86_64-linux-clang
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ RUN apk update \
git \
curl \
perl

WORKDIR /usr/src/barretenberg/cpp

COPY . .
# Only build binaries that are needed upstream.
RUN mkdir build && cd build && cmake .. && make -j$(nproc) db_cli rollup_cli tx_factory keygen
# Build the entire project, as we want to check everything builds under clang
RUN mkdir build && cd build && cmake .. && cmake --build . --parallel

FROM alpine:3.17
RUN apk update && apk add openmp
COPY --from=builder /usr/src/barretenberg/cpp/srs_db /usr/src/barretenberg/cpp/srs_db
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/db_cli /usr/src/barretenberg/cpp/build/bin/db_cli
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/rollup_cli /usr/src/barretenberg/cpp/build/bin/rollup_cli
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/tx_factory /usr/src/barretenberg/cpp/build/bin/tx_factory
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/keygen /usr/src/barretenberg/cpp/build/bin/keygen
2 changes: 1 addition & 1 deletion cpp/dockerfiles/Dockerfile.x86_64-linux-clang-assert
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ WORKDIR /usr/src/barretenberg/cpp

COPY . .
# Build everything to ensure everything builds. All tests will be run from the result of this build.
RUN mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=RelWithAssert -DCI=ON .. && make -j$(nproc)
RUN mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=RelWithAssert -DCI=ON .. && cmake --build . --parallel

FROM alpine:3.17
RUN apk update && apk add curl openmp
Expand Down
7 changes: 3 additions & 4 deletions cpp/dockerfiles/Dockerfile.x86_64-linux-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ RUN apk update \
curl
WORKDIR /usr/src/barretenberg/cpp
COPY . .
# Build the entire project (not just rollup_cli and db_cli), as we want to check everything builds under gcc.
RUN mkdir build && cd build && cmake -DTOOLCHAIN=x86_64-linux-gcc -DCI=ON .. && make -j$(nproc)
# Build the entire project, as we want to check everything builds under gcc.
RUN mkdir build && cd build && cmake -DTOOLCHAIN=x86_64-linux-gcc -DCI=ON .. && cmake --build . --parallel

FROM alpine:3.17
RUN apk update && apk add libstdc++ libgomp
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/db_cli /usr/src/barretenberg/cpp/build/bin/db_cli
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/rollup_cli /usr/src/barretenberg/cpp/build/bin/rollup_cli
COPY --from=builder /usr/src/barretenberg/cpp/srs_db /usr/src/barretenberg/cpp/srs_db
2 changes: 1 addition & 1 deletion cpp/docs/Fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Build with coverage instrumentation:
mkdir build-coverage/
cd build-coverage/
cmake -DFUZZING=ON -DCMAKE_CXX_FLAGS="-fprofile-instr-generate -fcoverage-mapping" ..
make -j$(nproc)
cmake --build . --parallel
```

Then run the fuzzer on the corpus and generate the HTML coverage reports:
Expand Down
Loading