Skip to content

Commit

Permalink
Aztec3 (#5)
Browse files Browse the repository at this point in the history
* Fix to bootstrap.sh after move into submodule (#1)

* Updated bootstrap now that bberg may be a submodule, and now that cpp subdir exists

* fix gitignore, wasnt properly ignoring cpp/build*

* fix the barretenberg cpp formatting pre-commit hook now that barretenberg iss its own repo and may be a submodule

* Contrived change.

* Revert "Contrived change."

This reverts commit ea18e58180f70a5e0f0a3419f4beba461d6917cb.

* Revert "Revert "Contrived change.""

This reverts commit 6ad33bccc4e5a1d76467a61b0d18d369fd32988e.

* Introduce cpp to paths.

* More cpp path.

* Cl/mum merge (#4)

* Initial merge. Still has conflicts.

* Tidied up bigfield and biggroup

* Builds.

* Order constants.

* Fix.

* Make more tests pass.

* Update circuit change detection stuff to be local to tests.

* Include header.

* Cleanup and settings.

* Path updates.

* Path updates.

Co-authored-by: Rumata888 <[email protected]>

Co-authored-by: David Banks <[email protected]>
Co-authored-by: Rumata888 <[email protected]>
  • Loading branch information
3 people committed Jan 28, 2023
1 parent 24ebd0c commit 991985c
Show file tree
Hide file tree
Showing 349 changed files with 25,530 additions and 11,157 deletions.
36 changes: 25 additions & 11 deletions barretenberg/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert bb-tests
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 1 bb-tests
- *save_logs

stdlib-primitives-tests:
Expand All @@ -157,10 +157,10 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert stdlib_primitives_tests
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 1 stdlib_primitives_tests
- *save_logs

stdlib-recursion-tests:
stdlib-recursion-turbo-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
Expand All @@ -169,7 +169,19 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert stdlib_recursion_tests
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 1 stdlib_recursion_tests --gtest_filter=*turbo*
- *save_logs

stdlib-recursion-ultra-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 stdlib_recursion_tests --gtest_filter=-*turbo*
- *save_logs

tx-rollup-tests:
Expand All @@ -181,7 +193,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert rollup_proofs_tx_rollup_tests --gtest_filter=-rollup_full_tests.*
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:
Expand All @@ -193,7 +205,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert rollup_proofs_tx_rollup_tests --gtest_filter=rollup_full_tests.*
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:
Expand All @@ -205,7 +217,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert rollup_proofs_root_rollup_tests --gtest_filter=-root_rollup_full_tests.*
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:
Expand All @@ -217,7 +229,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert rollup_proofs_root_rollup_tests --gtest_filter=root_rollup_full_tests.*
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:
Expand All @@ -229,7 +241,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert rollup_proofs_root_verifier_tests
command: cond_spot_run_tests barretenberg-x86_64-linux-clang-assert 3 rollup_proofs_root_verifier_tests
- *save_logs

benchmark-aggregator:
Expand Down Expand Up @@ -260,7 +272,8 @@ workflows:
- wasm-linux-clang
- barretenberg-tests: *bb_test
- stdlib-primitives-tests: *bb_test
- stdlib-recursion-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
Expand All @@ -270,7 +283,8 @@ workflows:
requires:
- barretenberg-tests
- stdlib-primitives-tests
- stdlib-recursion-tests
- stdlib-recursion-turbo-tests
- stdlib-recursion-ultra-tests
- tx-rollup-tests
- tx-rollup-full-tests
- root-verifier-tests
Expand Down
17 changes: 17 additions & 0 deletions barretenberg/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/cpp/src/aztec"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
9 changes: 9 additions & 0 deletions barretenberg/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-vscode.cpptools",
"eamodio.gitlens"
]
}
8 changes: 8 additions & 0 deletions barretenberg/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.associations": {
"*.tf": "terraform",
"*.tfvars": "terraform",
"Makefile.*": "makefile",
"iosfwd": "cpp"
}
}
2 changes: 1 addition & 1 deletion barretenberg/cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
./build*
build*/
src/wasi-sdk-*
src/aztec/plonk/proof_system/proving_key/fixtures
src/aztec/rollup/proofs/*/fixtures
Expand Down
6 changes: 5 additions & 1 deletion barretenberg/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ option(DISABLE_ADX "Disable ADX assembly variant" OFF)
option(MULTITHREADING "Enable multi-threading" ON)
option(TESTING "Build tests" ON)
option(BENCHMARKS "Build benchmarks" ON)
option(DISABLE_TBB "Intel Thread Building Blocks" ON)

if(ARM)
message(STATUS "Compiling for ARM.")
set(DISABLE_ASM ON)
set(DISABLE_ADX ON)
set(RUN_HAVE_STD_REGEX 0)
set(RUN_HAVE_POSIX_REGEX 0)
set(DISABLE_TBB 0)
endif()

if(FUZZING)
Expand All @@ -40,7 +42,7 @@ if(FUZZING)
if(UNDEFINED_BEHAVIOUR_SANITIZER)
set(SANITIZER_OPTIONS ${SANITIZER_OPTIONS} -fsanitize=undefined -fno-sanitize=alignment)
endif()

add_compile_options(-fsanitize=fuzzer-no-link ${SANITIZER_OPTIONS})

set(WASM OFF)
Expand All @@ -53,6 +55,7 @@ if(WASM)
set(DISABLE_ASM ON)
set(MULTITHREADING OFF)
set(BENCHMARKS OFF)
set(DISABLE_TBB 1)
endif()

set(CMAKE_C_STANDARD 11)
Expand All @@ -62,6 +65,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS ON)

include(cmake/build.cmake)
include(GNUInstallDirs)
include(cmake/arch.cmake)
include(cmake/threading.cmake)
include(cmake/gtest.cmake)
Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rm -rf ./build
rm -rf ./build-wasm

# Install formatting git hook.
echo "cd ./barretenberg && ./format.sh staged" > ../.git/hooks/pre-commit
echo "cd ./cpp && ./format.sh staged" > ../.git/hooks/pre-commit
chmod +x ../.git/hooks/pre-commit

# Determine system.
Expand All @@ -22,6 +22,7 @@ fi
# Download ignition transcripts.
cd ./srs_db
./download_ignition.sh 3
./download_ignition_lagrange.sh 12
cd ..

# Pick native toolchain file.
Expand Down
5 changes: 5 additions & 0 deletions barretenberg/cpp/cmake/module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function(barretenberg_module MODULE_NAME)
${MODULE_NAME}
PUBLIC
${ARGN}
${TBB_IMPORTED_TARGETS}
)

set(MODULE_LINK_NAME ${MODULE_NAME})
Expand All @@ -51,6 +52,7 @@ function(barretenberg_module MODULE_NAME)
${MODULE_NAME}_test_objects
PRIVATE
gtest
${TBB_IMPORTED_TARGETS}
)

add_executable(
Expand Down Expand Up @@ -89,6 +91,7 @@ function(barretenberg_module MODULE_NAME)
${ARGN}
gtest
gtest_main
${TBB_IMPORTED_TARGETS}
)

if(NOT WASM AND NOT CI)
Expand Down Expand Up @@ -139,6 +142,7 @@ function(barretenberg_module MODULE_NAME)
${MODULE_NAME}_bench_objects
PRIVATE
benchmark
${TBB_IMPORTED_TARGETS}
)

add_executable(
Expand All @@ -152,6 +156,7 @@ function(barretenberg_module MODULE_NAME)
${MODULE_LINK_NAME}
${ARGN}
benchmark
${TBB_IMPORTED_TARGETS}
)

add_custom_target(
Expand Down
13 changes: 13 additions & 0 deletions barretenberg/cpp/cmake/threading.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ else()
message(STATUS "Multithreading is disabled.")
add_definitions(-DNO_MULTITHREADING -DBOOST_SP_NO_ATOMIC_ACCESS)
endif()

if(DISABLE_TBB)
message(STATUS "Intel Thread Building Blocks is disabled.")
add_definitions(-DNO_TBB)
else()
find_package(TBB REQUIRED tbb)
if(${TBB_FOUND})
message(STATUS "Intel Thread Building Blocks is enabled.")
else()
message(STATUS "Could not locate TBB.")
add_definitions(-DNO_TBB)
endif()
endif()
2 changes: 1 addition & 1 deletion barretenberg/cpp/dockerfiles/Dockerfile.arm64-linux-gcc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM aztecprotocol/crosstool-ng-arm64:latest
WORKDIR /usr/src/barretenberg
WORKDIR /usr/src/barretenberg/cpp
COPY . .
RUN mkdir build && cd build && cmake -DTOOLCHAIN=arm64-linux-gcc .. && make -j$(nproc)
RUN cd build && qemu-aarch64 ./test/barretenberg_tests
Expand Down
6 changes: 3 additions & 3 deletions barretenberg/cpp/dockerfiles/Dockerfile.wasm-linux-clang
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM ubuntu:focal AS builder
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential wget git libssl-dev cmake curl binaryen
RUN curl https://wasmtime.dev/install.sh -sSf | bash /dev/stdin --version v0.25.0
WORKDIR /usr/src/barretenberg/src
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
WORKDIR /usr/src/barretenberg/cpp
COPY . .
RUN mkdir build && cd build && cmake -DTOOLCHAIN=wasm-linux-clang .. && make -j$(nproc) barretenberg.wasm

FROM alpine:3.13
COPY --from=builder /usr/src/barretenberg/build/bin/barretenberg.wasm /usr/src/barretenberg/build/bin/barretenberg.wasm
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/barretenberg.wasm /usr/src/barretenberg/cpp/build/bin/barretenberg.wasm
12 changes: 6 additions & 6 deletions barretenberg/cpp/dockerfiles/Dockerfile.x86_64-linux-clang
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ RUN git clone -b release/10.x --depth 1 https://github.com/llvm/llvm-project.git
&& make -j$(nproc) \
&& make install \
&& cd ../.. && rm -rf llvm-project
WORKDIR /usr/src/barretenberg
WORKDIR /usr/src/barretenberg/cpp
COPY . .
# Only build binaries that are needed upstream.
RUN mkdir build && cd build && cmake -DOpenMP_omp_LIBRARY=/usr/local/lib/libomp.a .. && make -j$(nproc) db_cli rollup_cli tx_factory keygen

FROM alpine:3.13
RUN apk update && apk add llvm10-libs
COPY --from=builder /usr/src/barretenberg/srs_db /usr/src/barretenberg/srs_db
COPY --from=builder /usr/src/barretenberg/build/bin/db_cli /usr/src/barretenberg/build/bin/db_cli
COPY --from=builder /usr/src/barretenberg/build/bin/rollup_cli /usr/src/barretenberg/build/bin/rollup_cli
COPY --from=builder /usr/src/barretenberg/build/bin/tx_factory /usr/src/barretenberg/build/bin/tx_factory
COPY --from=builder /usr/src/barretenberg/build/bin/keygen /usr/src/barretenberg/build/bin/keygen
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ RUN git clone -b release/10.x --depth 1 https://github.com/llvm/llvm-project.git
&& make -j$(nproc) \
&& make install \
&& cd ../.. && rm -rf llvm-project
WORKDIR /usr/src/barretenberg
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 -DOpenMP_omp_LIBRARY=/usr/local/lib/libomp.a -DCI=ON .. && make -j$(nproc)

FROM alpine:3.13
RUN apk update && apk add llvm10-libs curl
COPY --from=builder /usr/src/barretenberg/srs_db /usr/src/barretenberg/srs_db
COPY --from=builder /usr/src/barretenberg/build/bin/*_tests /usr/src/barretenberg/build/bin/
COPY --from=builder /usr/src/barretenberg/cpp/srs_db /usr/src/barretenberg/cpp/srs_db
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/*_tests /usr/src/barretenberg/cpp/build/bin/
6 changes: 3 additions & 3 deletions barretenberg/cpp/dockerfiles/Dockerfile.x86_64-linux-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ RUN apk update \
cmake \
git \
curl
WORKDIR /usr/src/barretenberg
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)

FROM alpine:3.13
RUN apk update && apk add libstdc++ libgomp
COPY --from=builder /usr/src/barretenberg/build/bin/db_cli /usr/src/barretenberg/build/bin/db_cli
COPY --from=builder /usr/src/barretenberg/build/bin/rollup_cli /usr/src/barretenberg/build/bin/rollup_cli
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
3 changes: 2 additions & 1 deletion barretenberg/cpp/scripts/bb-tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ci_failsafe_tests
crypto_aes128_tests
crypto_blake2s_tests
crypto_blake3s_tests
crypto_ecdsa_tests
crypto_pedersen_tests
crypto_schnorr_tests
Expand All @@ -18,6 +18,7 @@ rollup_proofs_standard_example_tests
srs_tests
stdlib_aes128_tests
stdlib_blake2s_tests
stdlib_blake3s_tests
stdlib_ecdsa_tests
stdlib_merkle_tree_tests
stdlib_pedersen_tests
Expand Down
13 changes: 8 additions & 5 deletions barretenberg/cpp/scripts/run_tests
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
set -e

TESTS=$1
NUM_TRANSCRIPTS=$1
TESTS=$2
shift
shift

$(aws ecr get-login --region us-east-2 --no-include-email) 2> /dev/null
Expand All @@ -16,7 +18,8 @@ fi

docker run --rm -t $IMAGE_URI /bin/sh -c "\
set -e; \
cd /usr/src/barretenberg/srs_db; \
./download_ignition.sh 1; \
cd /usr/src/barretenberg/build; \
for BIN in $TESTS; do ./bin/\$BIN $@; done"
cd /usr/src/barretenberg/cpp/srs_db; \
./download_ignition.sh $NUM_TRANSCRIPTS; \
./download_ignition_lagrange.sh 12; \
cd /usr/src/barretenberg/cpp/build; \
for BIN in $TESTS; do ./bin/\$BIN $@; done"
Loading

0 comments on commit 991985c

Please sign in to comment.