Skip to content

Commit

Permalink
fix: revert bb history
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad committed Sep 26, 2023
1 parent 7f8c6b8 commit 51ff116
Show file tree
Hide file tree
Showing 272 changed files with 15,699 additions and 8,536 deletions.
6 changes: 3 additions & 3 deletions barretenberg/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
;
[subrepo]
remote = https://github.com/AztecProtocol/barretenberg
branch = master
commit = 7edb1644d0ae472a70fc3554b7d2cfc6c5496168
parent = 8465ff6253d597e114b9bf08d5090cf17474aa6e
branch = main
commit = ae9f99c3caf0213882d843577374b03871cc7092
parent = c8a5cfb375b498475503c12cc83fcdba39f2ec5f
method = merge
cmdver = 0.4.6
70 changes: 70 additions & 0 deletions barretenberg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,75 @@
# Changelog

## [0.7.10](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.9...barretenberg-v0.7.10) (2023-09-20)


### Miscellaneous

* **barretenberg:** Synchronize aztec-packages versions

## [0.7.9](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.8...barretenberg-v0.7.9) (2023-09-19)


### Miscellaneous

* **barretenberg:** Synchronize aztec-packages versions

## [0.7.8](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.7...barretenberg-v0.7.8) (2023-09-19)


### Features

* Allow tracing build system with [debug ci] ([#2389](https://github.com/AztecProtocol/aztec-packages/issues/2389)) ([ce311a9](https://github.com/AztecProtocol/aztec-packages/commit/ce311a9b44a8f0327235ccd3bb8f9a8fca97443e))

## [0.7.7](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.6...barretenberg-v0.7.7) (2023-09-18)


### Miscellaneous

* **barretenberg:** Synchronize aztec-packages versions

## [0.7.6](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.5...barretenberg-v0.7.6) (2023-09-18)


### Miscellaneous

* **barretenberg:** Synchronize aztec-packages versions

## [0.7.5](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.4...barretenberg-v0.7.5) (2023-09-15)


### Features

* Protogalaxy interfaces ([#2125](https://github.com/AztecProtocol/aztec-packages/issues/2125)) ([b45dd26](https://github.com/AztecProtocol/aztec-packages/commit/b45dd26214119f0c52c2c4f48ff11f650912fef9))

## [0.7.4](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.3...barretenberg-v0.7.4) (2023-09-15)


### Features

* Elliptic Curve Virtual Machine Circuit ([#1268](https://github.com/AztecProtocol/aztec-packages/issues/1268)) ([f85ecd9](https://github.com/AztecProtocol/aztec-packages/commit/f85ecd921271ec94b551992bcfe16c2b56f72d2e))

## [0.7.3](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.2...barretenberg-v0.7.3) (2023-09-15)


### Miscellaneous

* **barretenberg:** Synchronize aztec-packages versions

## [0.7.2](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.1...barretenberg-v0.7.2) (2023-09-14)


### Features

* ASAN build ([#2307](https://github.com/AztecProtocol/aztec-packages/issues/2307)) ([274c89f](https://github.com/AztecProtocol/aztec-packages/commit/274c89f1916d8af2054d9773dc632f87bb3bf2fc))

## [0.7.1](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.7.0...barretenberg-v0.7.1) (2023-09-14)


### Miscellaneous

* Move barretenberg to top of repo. Make circuits build off barretenberg build. ([#2221](https://github.com/AztecProtocol/aztec-packages/issues/2221)) ([404ec34](https://github.com/AztecProtocol/aztec-packages/commit/404ec34d38e1a9c3fbe7a3cdb6e88c28f62f72e4))

## [0.7.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.6.7...barretenberg-v0.7.0) (2023-09-13)


Expand Down
2 changes: 1 addition & 1 deletion barretenberg/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.7.0 x-release-please-version
v0.7.10 x-release-please-version
4 changes: 3 additions & 1 deletion barretenberg/acir_tests/Dockerfile.bb.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ RUN BIN=../ts/dest/node/main.js FLOW=all_cmds ./run_acir_tests.sh 1_mul
RUN BROWSER=chrome THREAD_MODEL=mt ./run_acir_tests_browser.sh double_verify_proof
# Run 1_mul through bb.js on chrome/webkit testing single threaded browser support.
RUN BROWSER=chrome THREAD_MODEL=st ./run_acir_tests_browser.sh 1_mul
RUN BROWSER=webkit THREAD_MODEL=st ./run_acir_tests_browser.sh 1_mul
# Commenting for now as fails intermittently. Unreproducable on mainframe.
# See https://github.com/AztecProtocol/aztec-packages/issues/2104
#RUN BROWSER=webkit THREAD_MODEL=st ./run_acir_tests_browser.sh 1_mul
4 changes: 1 addition & 3 deletions barretenberg/acir_tests/run_acir_tests_browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ cleanup() {
trap cleanup SIGINT SIGTERM

# Skipping firefox because this headless firefox is so slow.
# Skipping webkit as well due to intermittent errors, see https://github.com/AztecProtocol/aztec-packages/issues/2104
#export BROWSER=${BROWSER:-chrome,webkit}
export BROWSER=${BROWSER:-chrome}
export BROWSER=${BROWSER:-chrome,webkit}

# Can be "mt" or "st".
THREAD_MODEL=${THREAD_MODEL:-mt}
Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/.rebuild_patterns
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^barretenberg/.*\\.(cpp|cc|cxx|c\\+\\+|h|hpp|hxx|h\\+\\+|c|h|inl|inc|ipp|tpp|cmake)$
^barretenberg/.*CMakeLists\\.txt$
^barretenberg/.*Dockerfile.*$
^barretenberg/.*Dockerfile.*$
^barretenberg/cpp/scripts/
10 changes: 9 additions & 1 deletion barretenberg/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24)
project(
Barretenberg
DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover"
VERSION 0.7.0 # x-release-please-version
VERSION 0.7.10 # x-release-please-version
LANGUAGES CXX C
)

Expand Down Expand Up @@ -135,3 +135,11 @@ include(cmake/gtest.cmake)
include(cmake/benchmark.cmake)
include(cmake/module.cmake)
add_subdirectory(src)
if (ENABLE_ASAN AND NOT(FUZZING))
find_program(LLVM_SYMBOLIZER_PATH NAMES llvm-symbolizer-16)
if (NOT(LLVM_SYMBOLIZER_PATH))
message(WARNING "LLVM symbolizer not found, so ASAN output will be limited")
else()
message(AUTHOR_WARNING "Run `export ASAN_SYMBOLIZER_PATH=\"${LLVM_SYMBOLIZER_PATH}\"` before running tests for better ASAN output (at which lines the bugs are).")
endif()
endif()
27 changes: 25 additions & 2 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
"DISABLE_ASM": "ON"
}
},
{"name":"asan",
"displayName": "Debugging build with address sanitizer on Clang-16",
"description": "Build with address sanitizer on clang16 with debugging information",
"inherits":"clang16-dbg",
"binaryDir": "build-asan",
"environment": {
"CMAKE_BUILD_TYPE": "Debug"
},
"cacheVariables": {
"ENABLE_ASAN": "ON",
"DISABLE_ASM": "ON"
}

},
{
"name": "gcc",
"displayName": "Build with GCC",
Expand Down Expand Up @@ -82,7 +96,7 @@
"name": "fuzzing",
"displayName": "Build with fuzzing",
"description": "Build default preset but with fuzzing enabled",
"inherits": "default",
"inherits": "clang16",
"binaryDir": "build-fuzzing",
"cacheVariables": {
"FUZZING": "ON"
Expand Down Expand Up @@ -179,6 +193,10 @@
"name": "clang16-dbg",
"inherits": "default",
"configurePreset": "clang16-dbg"
},{
"name": "asan",
"inherits": "default",
"configurePreset": "asan"
},
{
"name": "gcc",
Expand All @@ -197,7 +215,7 @@
},
{
"name": "fuzzing",
"inherits": "default",
"inherits": "clang16",
"configurePreset": "fuzzing"
},
{
Expand Down Expand Up @@ -260,6 +278,11 @@
"inherits": "default",
"configurePreset": "clang16-dbg"
},
{
"name": "asan",
"inherits": "default",
"configurePreset": "asan"
},
{
"name": "gcc",
"inherits": "default",
Expand Down
5 changes: 2 additions & 3 deletions barretenberg/cpp/dockerfiles/Dockerfile.wasm-linux-clang
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM ubuntu:lunar AS builder
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential wget git libssl-dev cmake ninja-build curl
RUN curl https://wasmtime.dev/install.sh -sSf | bash /dev/stdin --version v3.0.1
RUN apt-get update && apt-get install -y build-essential git cmake ninja-build curl
WORKDIR /usr/src/barretenberg/cpp
COPY ./scripts/install-wasi-sdk.sh ./scripts/install-wasi-sdk.sh
RUN ./scripts/install-wasi-sdk.sh
Expand All @@ -18,4 +17,4 @@ COPY --from=builder /usr/src/barretenberg/cpp/build-wasm/lib/libbarretenberg.a /
COPY --from=builder /usr/src/barretenberg/cpp/build-wasm/lib/libwasi.a /usr/src/barretenberg/cpp/build-wasm/lib/libwasi.a
COPY --from=builder /usr/src/barretenberg/cpp/build-wasm/lib/libenv.a /usr/src/barretenberg/cpp/build-wasm/lib/libenv.a
# Copy wasi-sdk so that consuming projects have the toolchain available.
COPY --from=builder /usr/src/barretenberg/cpp/src/wasi-sdk-20.0 /usr/src/barretenberg/cpp/src/wasi-sdk-20.0
COPY --from=builder /usr/src/barretenberg/cpp/src/wasi-sdk-20.0 /usr/src/barretenberg/cpp/src/wasi-sdk-20.0
40 changes: 27 additions & 13 deletions barretenberg/cpp/docs/Fuzzing.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Fuzzing barretenberg

## Intro

We are gradually introducing fuzzing of various primitives into barretenberg, focusing first and foremost on in-cicruit types. If you are developing / patching a primitive and there is a fuzzer available for it, please take the time to update the fuzzer (if you've added new functionality) and run it for at least a few hours to increase security.

## Build

To build with standard clang:

```bash
cmake --preset fuzzing
cmake --build --preset fuzzing
```

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.
Expand All @@ -27,35 +31,43 @@ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=<path to clang> -DCMA
```

## Currently supported
Currently we have fuzzers for bigfield, bit_array, bool, byte_array, field, safe_uint and uint. Each of them is available in 3 versions: StandardPlonk, TurboPlonk, ALL (differential fuzzing of 2 versions).

Currently we have fuzzers for bigfield, bit_array, bool, byte_array, field, safe_uint and uint. Each of them is available in 2 versions: StandardPlonk, ALL (differential fuzzing of 2 versions).
To compile all fuzzers just type `make`.

## Running the fuzzer

TODO: add information about saved testcases

You can simply run a fuzzer by executing the built executable, for example,

```bash
./bin/stdlib_primitives_bigfield_turbo_fuzzer
./bin/stdlib_primitives_bigfield_standard_fuzzer
```

This is useful if you added a feature/instruction or changed some logic and want to quickly test if there are any really bad bugs.
To run the fuzzer seriously, I'd recommend:

```bash
mkdir ../../../<fuzzer_type>_testcases;
mkdir crashes;
./bin/<fuzzer_executable> -timeout=1 -len_control=500 -workers=8 -jobs=8 -entropic=1 -shrink=1 -artifact_prefix=crashes/ -use_value_profile=1 ../../../<fuzzer_type>_testcases
```

You can watch the progress of the fuzzer in one of the generated logs fuzz-<number>.log
The purpose of each parameter:
+ -timeout=1 - If a testcase takes more than 1 second to execute, it will be treated as a crash
+ -len_control=500 - Slows down the increase of testcase size. Especially important for heavy classes like bigfield, keeps the number of executions per second at a decent rate
+ -worker=8 - The number of threads that can simultaneously execute testcases. Should be less or equal to the number of jobs
+ -jobs=8 - After how many crashes the fuzzer will stop fuzzing. If a crash is executed and the number of jobs is more than workers then the fuzzer will proceed to give the worker a new job. The 8/8 worker/job configuration ensures that the fuzzer will quit after 8 crashes and until the first crash all the workers are busy.
+ -entropic=1 - Entropic should be enabled by default, but in case it isn't, enable it. A better power schedule than the old one.
+ -shrink=1 - If a new testcase is encountered that has the same coverage as some previous one in the corpus and the testcase is smaller, replace the one in the corpus with the new one. Helps keep exec/s higher.
+ -artifact_prefix=crashes/ - Where to save crashes/timeouts/ooms.
+ -use_value_profile=1 - Leverage libfuzzer internal CMP analysis. Very useful, but blows the corpus up.
+ <PATH_TO_CORPUS> (../../../<fuzzer_type>_testcases) - The path to the folder, where corpus testcases are going to be saved and loaded from (also loads testcases from there at the start of fuzzing).

Log structure is described here https://llvm.org/docs/LibFuzzer.html

- -timeout=1 - If a testcase takes more than 1 second to execute, it will be treated as a crash
- -len_control=500 - Slows down the increase of testcase size. Especially important for heavy classes like bigfield, keeps the number of executions per second at a decent rate
- -worker=8 - The number of threads that can simultaneously execute testcases. Should be less or equal to the number of jobs
- -jobs=8 - After how many crashes the fuzzer will stop fuzzing. If a crash is executed and the number of jobs is more than workers then the fuzzer will proceed to give the worker a new job. The 8/8 worker/job configuration ensures that the fuzzer will quit after 8 crashes and until the first crash all the workers are busy.
- -entropic=1 - Entropic should be enabled by default, but in case it isn't, enable it. A better power schedule than the old one.
- -shrink=1 - If a new testcase is encountered that has the same coverage as some previous one in the corpus and the testcase is smaller, replace the one in the corpus with the new one. Helps keep exec/s higher.
- -artifact_prefix=crashes/ - Where to save crashes/timeouts/ooms.
- -use_value_profile=1 - Leverage libfuzzer internal CMP analysis. Very useful, but blows the corpus up.
- <PATH_TO_CORPUS> (../../../<fuzzer_type>\_testcases) - The path to the folder, where corpus testcases are going to be saved and loaded from (also loads testcases from there at the start of fuzzing).

Log structure is described here https://llvm.org/docs/LibFuzzer.html

If you've found an issue, stopped the fuzzer, you can minimize the corpus to get rid of repetitions and then start from a minimized corpus

Expand All @@ -67,10 +79,12 @@ cp ../../../<fuzzer_type>_testcases_minimized/* ../../../<fuzzer_type>_testcases
```

If you've found a crash, you can minimize the crash to make the root cause more obvious:

```bash
mkdir minimized_crashes
./bin/<fuzzer_executable> -minimize_crash=1 -artifact_prefix=minimized_crashes <crash_file>
```

Also, both bigfield and safeuint fuzzer containt the SHOW_INFORMATION preprocessor cases, which enable the printing of instructions and values to make debugging the crash easier.

# Coverage reports
Expand Down
6 changes: 4 additions & 2 deletions barretenberg/cpp/scripts/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# 1. The number of ignition transcripts to download.
# 2. The set of gtest binary names to run.
# 3-n. The arguments to pass to the gtest binaries.
set -exu
[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -eu

NUM_TRANSCRIPTS=$1
TESTS=$2
Expand All @@ -19,7 +20,8 @@ IMAGE_URI=$(calculate_image_uri $REPOSITORY)
retry docker pull $IMAGE_URI

# If there is a file in the scripts directory named $TESTS, those are the tests to run.
if [ -f "$(query_manifest projectDir $REPOSITORY)/scripts/$TESTS" ]; then
cd $(query_manifest projectDir $REPOSITORY)/scripts
if [ -f "$TESTS" ]; then
TESTS=$(cat $TESTS | tr '\n' ' ')
fi

Expand Down
1 change: 0 additions & 1 deletion barretenberg/cpp/src/barretenberg/barretenberg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "numeric/uint256/uint256.hpp"
#include "plonk/proof_system/types/proof.hpp"
#include "plonk/proof_system/verification_key/verification_key.hpp"
#include "proof_system/circuit_builder/turbo_circuit_builder.hpp"
#include "proof_system/circuit_builder/ultra_circuit_builder.hpp"
#include "proof_system/types/circuit_type.hpp"
// TODO(https://github.com/AztecProtocol/barretenberg/issues/491):
Expand Down
11 changes: 8 additions & 3 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ int main(int argc, char* argv[])
std::string vk_path = getOption(args, "-k", "./target/vk");
CRS_PATH = getOption(args, "-c", "./crs");
bool recursive = flagPresent(args, "-r") || flagPresent(args, "--recursive");

// Skip CRS initialization for any command which doesn't require the CRS.
if (command == "info") {
std::string output_path = getOption(args, "-o", "info.json");
acvmInfo(output_path);
return 0;
}

init();

if (command == "prove_and_verify") {
Expand All @@ -355,9 +363,6 @@ int main(int argc, char* argv[])
} else if (command == "vk_as_fields") {
std::string output_path = getOption(args, "-o", vk_path + "_fields.json");
vkAsFields(vk_path, output_path);
} else if (command == "info") {
std::string output_path = getOption(args, "-o", "info.json");
acvmInfo(output_path);
} else {
std::cerr << "Unknown command: " << command << "\n";
return 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Each source represents a separate benchmark suite
set(BENCHMARK_SOURCES
standard_honk.bench.cpp
standard_plonk.bench.cpp
ultra_honk.bench.cpp
ultra_plonk.bench.cpp
Expand All @@ -14,7 +13,7 @@ set(LINKED_LIBRARIES
benchmark::benchmark
)

# Add executable and custom target for each suite, e.g. standard_honk_bench
# Add executable and custom target for each suite, e.g. ultra_honk_bench
foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES})
get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension
add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE} benchmark_utilities.hpp)
Expand Down
Loading

0 comments on commit 51ff116

Please sign in to comment.