From 06aea6bcb1949e77a32e9b00fa5a38bd6b50980e Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 25 May 2023 12:42:37 +0000 Subject: [PATCH 01/11] workflow runs benchamarks and commits result to branch --- .github/workflows/bberg_bench.yml | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/bberg_bench.yml diff --git a/.github/workflows/bberg_bench.yml b/.github/workflows/bberg_bench.yml new file mode 100644 index 0000000000..6edda354b1 --- /dev/null +++ b/.github/workflows/bberg_bench.yml @@ -0,0 +1,65 @@ +name: Barretenberg Benchmarks + +# For now, run basically whenever anything happens in a PR +on: + pull_request: + types: ["labeled", "opened", "synchronize", "reopened"] + +# This will cancel previous runs when a branch or PR is updated +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + bberg-bench: + name: Barretenberg Benchmarks + runs-on: ubuntu-latest # run in linux environment + + # env: + # BASE_DIR: ${{ github.workspace }}/cpp + # BUILD_DIR: ${{ github.workspace }}/cpp/build-bench + # BENCH_RESULTS_DIR: ${{ github.workspace }}/cpp/src/barretenberg/benchmark/honk_bench + + steps: + + - name: Checkout barretenberg + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} # checkout HEAD of triggering branch + token: ${{ secrets.GITHUB_TOKEN }} + + # Adding some credentials to avoid complaints from git + - name: Configure git + run: | + git config user.name ledwards2225 + git config user.email l.edwards.d@gmail.com + + # Only run in Linux environment for now + - name: Setup Linux environment + run: | + sudo apt update + sudo apt install libomp-dev cmake ninja-build + + - name: Download SRS elements + working-directory: cpp/srs_db + run: ./download_ignition.sh 3 # only download first 4 transcript files + + - name: Build Honk benchmarks + working-directory: cpp + run: | + cmake --preset bench + cmake --build --preset bench --target honk_bench + + - name: Run Honk benchmarks + working-directory: cpp/build-bench + run: | + bin/honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json + + # Commit benchmark results json to the branch + - name: Commit result + working-directory: cpp + run: | + git add src/barretenberg/benchmark/honk_bench/bench_results.json + git commit -m "add bench results" + git push + \ No newline at end of file From 02c07f404fc4f30ed81166d076cd5d42abae47d0 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 25 May 2023 21:56:01 +0000 Subject: [PATCH 02/11] basic benchmarks for ultra honk --- barretenberg.code-workspace | 6 +- .../benchmark/honk_bench/CMakeLists.txt | 2 +- .../benchmark/honk_bench/honk.bench.cpp | 43 ++++--- .../benchmark/honk_bench/main.bench.cpp | 3 + .../benchmark/honk_bench/ultra_honk.bench.cpp | 114 ++++++++++++++++++ 5 files changed, 144 insertions(+), 24 deletions(-) create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/main.bench.cpp create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp diff --git a/barretenberg.code-workspace b/barretenberg.code-workspace index a95ef89173..573e8606e4 100644 --- a/barretenberg.code-workspace +++ b/barretenberg.code-workspace @@ -87,7 +87,7 @@ // We should disable automatic inclusion of headers unless we decide to follow "WhyIWYU". "clangd.arguments": [ "-header-insertion=never" - ] + ], // // CMake // @@ -114,8 +114,8 @@ // Ensures tests are run from the `build` directory // which ensures SRS can be read "testMate.cpp.test.workingDirectory": "${workspaceFolder}/cpp/build", - // Filter all binaries that are not tests - "testMate.cpp.test.executables": "${workspaceFolder}/cpp/build/bin/*{test,Test,TEST}*", + // Filter all binaries that are not tests or benchmarks + "testMate.cpp.test.executables": "${workspaceFolder}/cpp/{build,build-bench}/bin/*{test,bench}*", // // Other // diff --git a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index f8b6536f8f..a160fed5b9 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -1,4 +1,4 @@ -add_executable(honk_bench honk.bench.cpp) +add_executable(honk_bench main.bench.cpp honk.bench.cpp ultra_honk.bench.cpp) target_link_libraries( honk_bench diff --git a/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp index aa472edd18..3ebef73a9e 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp @@ -8,12 +8,16 @@ using namespace benchmark; +namespace standard_honk_bench { + +using Composer = proof_system::honk::StandardHonkComposer; + constexpr size_t MIN_LOG_NUM_GATES = 16; constexpr size_t MAX_LOG_NUM_GATES = 16; // To get good statistics, number of Repetitions must be sufficient. ~30 Repetitions gives good results. -constexpr size_t NUM_REPETITIONS = 30; +constexpr size_t NUM_REPETITIONS = 1; -void generate_test_plonk_circuit(auto& composer, size_t num_gates) +void generate_test_circuit(auto& composer, size_t num_gates) { plonk::stdlib::field_t a(plonk::stdlib::witness_t(&composer, barretenberg::fr::random_element())); plonk::stdlib::field_t b(plonk::stdlib::witness_t(&composer, barretenberg::fr::random_element())); @@ -29,47 +33,47 @@ void generate_test_plonk_circuit(auto& composer, size_t num_gates) /** * @brief Benchmark: Creation of a Standard Honk prover */ -void create_prover_bench(State& state) noexcept +void create_prover_standard(State& state) noexcept { for (auto _ : state) { state.PauseTiming(); auto num_gates = 1 << (size_t)state.range(0); - auto composer = proof_system::honk::StandardHonkComposer(static_cast(num_gates)); - generate_test_plonk_circuit(composer, static_cast(num_gates)); + auto composer = Composer(static_cast(num_gates)); + generate_test_circuit(composer, static_cast(num_gates)); state.ResumeTiming(); composer.create_prover(); } } -BENCHMARK(create_prover_bench)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); +BENCHMARK(create_prover_standard)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); /** * @brief Benchmark: Creation of a Standard Honk verifier */ -void create_verifier_bench(State& state) noexcept +void create_verifier_standard(State& state) noexcept { for (auto _ : state) { state.PauseTiming(); auto num_gates = 1 << (size_t)state.range(0); - auto composer = proof_system::honk::StandardHonkComposer(static_cast(num_gates)); - generate_test_plonk_circuit(composer, static_cast(num_gates)); + auto composer = Composer(static_cast(num_gates)); + generate_test_circuit(composer, static_cast(num_gates)); state.ResumeTiming(); composer.create_verifier(); } } -BENCHMARK(create_verifier_bench)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); +BENCHMARK(create_verifier_standard)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); /** * @brief Benchmark: Construction of a Standard Honk proof */ -void construct_proof_bench(State& state) noexcept +void construct_proof_standard(State& state) noexcept { auto num_gates = 1 << (size_t)state.range(0); for (auto _ : state) { state.PauseTiming(); - auto composer = proof_system::honk::StandardHonkComposer(static_cast(num_gates)); - generate_test_plonk_circuit(composer, static_cast(num_gates)); + auto composer = Composer(static_cast(num_gates)); + generate_test_circuit(composer, static_cast(num_gates)); auto ext_prover = composer.create_prover(); state.ResumeTiming(); @@ -77,7 +81,7 @@ void construct_proof_bench(State& state) noexcept } state.SetComplexityN(num_gates); // Set up for computation of constant C where prover ~ C*N } -BENCHMARK(construct_proof_bench) +BENCHMARK(construct_proof_standard) ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1) ->Repetitions(NUM_REPETITIONS) ->Complexity(oN); @@ -85,13 +89,13 @@ BENCHMARK(construct_proof_bench) /** * @brief Benchmark: Verification of a Standard Honk proof */ -void verify_proof_bench(State& state) noexcept +void verify_proof_standard(State& state) noexcept { for (auto _ : state) { state.PauseTiming(); auto num_gates = (size_t)state.range(0); - auto composer = proof_system::honk::StandardHonkComposer(static_cast(num_gates)); - generate_test_plonk_circuit(composer, static_cast(num_gates)); + auto composer = Composer(static_cast(num_gates)); + generate_test_circuit(composer, static_cast(num_gates)); auto prover = composer.create_prover(); auto proof = prover.construct_proof(); auto verifier = composer.create_verifier(); @@ -104,6 +108,5 @@ void verify_proof_bench(State& state) noexcept // a long time. (This is because the time limit for benchmarks does not include the time-excluded setup, and // verification itself is pretty fast). // Note: disabling this bench for now since it is not of primary interest -// BENCHMARK(verify_proof_bench)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Iterations(1); - -BENCHMARK_MAIN(); +// BENCHMARK(verify_proof_standard)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Iterations(1); +} // namespace standard_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/main.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/main.bench.cpp new file mode 100644 index 0000000000..71fefa0472 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/main.bench.cpp @@ -0,0 +1,3 @@ +#include + +BENCHMARK_MAIN(); diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp new file mode 100644 index 0000000000..c7b7b47084 --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -0,0 +1,114 @@ +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/honk/proof_system/prover.hpp" +#include "barretenberg/honk/proof_system/verifier.hpp" +#include +#include +#include "barretenberg/honk/composer/ultra_honk_composer.hpp" +#include "barretenberg/stdlib/primitives/field/field.hpp" + +using namespace benchmark; + +namespace ultra_honk_bench { + +using Composer = proof_system::honk::UltraHonkComposer; + +constexpr size_t MIN_LOG_NUM_GATES = 16; +constexpr size_t MAX_LOG_NUM_GATES = 16; +// To get good statistics, number of Repetitions must be sufficient. ~30 Repetitions gives good results. +constexpr size_t NUM_REPETITIONS = 1; + +void generate_test_circuit(auto& composer, size_t num_gates) +{ + for (size_t j = 0; j < (num_gates / 4) - 4; ++j) { + uint64_t left = static_cast(j); + uint64_t right = static_cast(j + 1); + uint32_t left_idx = composer.add_variable(fr(left)); + uint32_t right_idx = composer.add_variable(fr(right)); + uint32_t result_idx = composer.add_variable(fr(left ^ right)); + + uint32_t add_idx = composer.add_variable(fr(left) + fr(right) + composer.get_variable(result_idx)); + composer.create_big_add_gate({ left_idx, right_idx, result_idx, add_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); + } + info("composer.num_gates = ", composer.num_gates); +} + +/** + * @brief Benchmark: Creation of a Standard Honk prover + */ +void create_prover_ultra(State& state) noexcept +{ + for (auto _ : state) { + state.PauseTiming(); + auto num_gates = 1 << (size_t)state.range(0); + auto composer = Composer(); + generate_test_circuit(composer, static_cast(num_gates)); + state.ResumeTiming(); + + composer.create_prover(); + } +} +BENCHMARK(create_prover_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); + +/** + * @brief Benchmark: Creation of a Standard Honk verifier + */ +void create_verifier_ultra(State& state) noexcept +{ + for (auto _ : state) { + state.PauseTiming(); + auto num_gates = 1 << (size_t)state.range(0); + auto composer = Composer(); + generate_test_circuit(composer, static_cast(num_gates)); + state.ResumeTiming(); + + composer.create_verifier(); + } +} +BENCHMARK(create_verifier_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); + +/** + * @brief Benchmark: Construction of a Standard Honk proof + */ +void construct_proof_ultra(State& state) noexcept +{ + auto num_gates = 1 << (size_t)state.range(0); + for (auto _ : state) { + state.PauseTiming(); + auto composer = Composer(); + generate_test_circuit(composer, static_cast(num_gates)); + auto ext_prover = composer.create_prover(); + state.ResumeTiming(); + + auto proof = ext_prover.construct_proof(); + } + state.SetComplexityN(num_gates); // Set up for computation of constant C where prover ~ C*N +} +BENCHMARK(construct_proof_ultra) + ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1) + ->Repetitions(NUM_REPETITIONS) + ->Complexity(oN); + +/** + * @brief Benchmark: Verification of a Standard Honk proof + */ +void verify_proof_ultra(State& state) noexcept +{ + for (auto _ : state) { + state.PauseTiming(); + auto num_gates = (size_t)state.range(0); + auto composer = Composer(); + generate_test_circuit(composer, static_cast(num_gates)); + auto prover = composer.create_prover(); + auto proof = prover.construct_proof(); + auto verifier = composer.create_verifier(); + state.ResumeTiming(); + + verifier.verify_proof(proof); + } +} +// Note: enforcing Iterations == 1 for now. Otherwise proof construction will occur many times and this bench will take +// a long time. (This is because the time limit for benchmarks does not include the time-excluded setup, and +// verification itself is pretty fast). +// Note: disabling this bench for now since it is not of primary interest +// BENCHMARK(verify_proof_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Iterations(1); +} // namespace ultra_honk_bench \ No newline at end of file From d9a53707f7e0ed1bea27de2fb6d242ee0a363458 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 26 May 2023 19:43:37 +0000 Subject: [PATCH 03/11] reorg and make consistent, still using simple circuit --- barretenberg.code-workspace | 2 +- .../benchmark/honk_bench/honk.bench.cpp | 37 ++++++------- .../benchmark/honk_bench/ultra_honk.bench.cpp | 52 +++++++++---------- 3 files changed, 42 insertions(+), 49 deletions(-) diff --git a/barretenberg.code-workspace b/barretenberg.code-workspace index 573e8606e4..0d0d3106e5 100644 --- a/barretenberg.code-workspace +++ b/barretenberg.code-workspace @@ -115,7 +115,7 @@ // which ensures SRS can be read "testMate.cpp.test.workingDirectory": "${workspaceFolder}/cpp/build", // Filter all binaries that are not tests or benchmarks - "testMate.cpp.test.executables": "${workspaceFolder}/cpp/{build,build-bench}/bin/*{test,bench}*", + "testMate.cpp.test.executables": "${workspaceFolder}/cpp/{build}/bin/*{test,bench}*", // // Other // diff --git a/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp index 3ebef73a9e..64229d59e6 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/honk.bench.cpp @@ -15,7 +15,7 @@ using Composer = proof_system::honk::StandardHonkComposer; constexpr size_t MIN_LOG_NUM_GATES = 16; constexpr size_t MAX_LOG_NUM_GATES = 16; // To get good statistics, number of Repetitions must be sufficient. ~30 Repetitions gives good results. -constexpr size_t NUM_REPETITIONS = 1; +constexpr size_t NUM_REPETITIONS = 5; void generate_test_circuit(auto& composer, size_t num_gates) { @@ -48,43 +48,44 @@ void create_prover_standard(State& state) noexcept BENCHMARK(create_prover_standard)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); /** - * @brief Benchmark: Creation of a Standard Honk verifier + * @brief Benchmark: Construction of a Standard Honk proof */ -void create_verifier_standard(State& state) noexcept +void construct_proof_standard(State& state) noexcept { + auto num_gates = 1 << (size_t)state.range(0); for (auto _ : state) { state.PauseTiming(); - auto num_gates = 1 << (size_t)state.range(0); auto composer = Composer(static_cast(num_gates)); generate_test_circuit(composer, static_cast(num_gates)); + auto ext_prover = composer.create_prover(); state.ResumeTiming(); - composer.create_verifier(); + auto proof = ext_prover.construct_proof(); } + state.SetComplexityN(num_gates); // Set up for computation of constant C where prover ~ C*N } -BENCHMARK(create_verifier_standard)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); +BENCHMARK(construct_proof_standard) + ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1) + ->Repetitions(NUM_REPETITIONS) + ->Complexity(oN); /** - * @brief Benchmark: Construction of a Standard Honk proof + * @brief Benchmark: Creation of a Standard Honk verifier */ -void construct_proof_standard(State& state) noexcept +void create_verifier_standard(State& state) noexcept { - auto num_gates = 1 << (size_t)state.range(0); for (auto _ : state) { state.PauseTiming(); + auto num_gates = 1 << (size_t)state.range(0); auto composer = Composer(static_cast(num_gates)); generate_test_circuit(composer, static_cast(num_gates)); - auto ext_prover = composer.create_prover(); state.ResumeTiming(); - auto proof = ext_prover.construct_proof(); + composer.create_verifier(); } - state.SetComplexityN(num_gates); // Set up for computation of constant C where prover ~ C*N } -BENCHMARK(construct_proof_standard) - ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1) - ->Repetitions(NUM_REPETITIONS) - ->Complexity(oN); +// BENCHMARK(create_verifier_standard)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, +// 1)->Repetitions(NUM_REPETITIONS); /** * @brief Benchmark: Verification of a Standard Honk proof @@ -104,9 +105,5 @@ void verify_proof_standard(State& state) noexcept verifier.verify_proof(proof); } } -// Note: enforcing Iterations == 1 for now. Otherwise proof construction will occur many times and this bench will take -// a long time. (This is because the time limit for benchmarks does not include the time-excluded setup, and -// verification itself is pretty fast). -// Note: disabling this bench for now since it is not of primary interest // BENCHMARK(verify_proof_standard)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Iterations(1); } // namespace standard_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index c7b7b47084..b8e00ca07d 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -1,10 +1,9 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" -#include "barretenberg/honk/proof_system/prover.hpp" -#include "barretenberg/honk/proof_system/verifier.hpp" +#include "barretenberg/honk/proof_system/ultra_prover.hpp" +#include "barretenberg/honk/proof_system/ultra_verifier.hpp" #include #include #include "barretenberg/honk/composer/ultra_honk_composer.hpp" -#include "barretenberg/stdlib/primitives/field/field.hpp" using namespace benchmark; @@ -15,11 +14,13 @@ using Composer = proof_system::honk::UltraHonkComposer; constexpr size_t MIN_LOG_NUM_GATES = 16; constexpr size_t MAX_LOG_NUM_GATES = 16; // To get good statistics, number of Repetitions must be sufficient. ~30 Repetitions gives good results. -constexpr size_t NUM_REPETITIONS = 1; +constexpr size_t NUM_REPETITIONS = 5; +// TODO(luke): Make this something useful. Suggestions from Zac: Sha256, keccak, ecdsa, merkle membership proofs w. +// Pedersen, recursion. void generate_test_circuit(auto& composer, size_t num_gates) { - for (size_t j = 0; j < (num_gates / 4) - 4; ++j) { + for (size_t j = 0; j < num_gates; ++j) { uint64_t left = static_cast(j); uint64_t right = static_cast(j + 1); uint32_t left_idx = composer.add_variable(fr(left)); @@ -29,11 +30,10 @@ void generate_test_circuit(auto& composer, size_t num_gates) uint32_t add_idx = composer.add_variable(fr(left) + fr(right) + composer.get_variable(result_idx)); composer.create_big_add_gate({ left_idx, right_idx, result_idx, add_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); } - info("composer.num_gates = ", composer.num_gates); } /** - * @brief Benchmark: Creation of a Standard Honk prover + * @brief Benchmark: Creation of a Ultra Honk prover */ void create_prover_ultra(State& state) noexcept { @@ -44,52 +44,52 @@ void create_prover_ultra(State& state) noexcept generate_test_circuit(composer, static_cast(num_gates)); state.ResumeTiming(); - composer.create_prover(); + auto prover = composer.create_prover(); } } BENCHMARK(create_prover_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); /** - * @brief Benchmark: Creation of a Standard Honk verifier + * @brief Benchmark: Construction of a Ultra Honk proof */ -void create_verifier_ultra(State& state) noexcept +void construct_proof_ultra(State& state) noexcept { + auto num_gates = 1 << (size_t)state.range(0); for (auto _ : state) { state.PauseTiming(); - auto num_gates = 1 << (size_t)state.range(0); auto composer = Composer(); generate_test_circuit(composer, static_cast(num_gates)); + auto ext_prover = composer.create_prover(); state.ResumeTiming(); - composer.create_verifier(); + auto proof = ext_prover.construct_proof(); } + state.SetComplexityN(num_gates); // Set up for computation of constant C where prover ~ C*N } -BENCHMARK(create_verifier_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); +BENCHMARK(construct_proof_ultra) + ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1) + ->Repetitions(NUM_REPETITIONS) + ->Complexity(oN); /** - * @brief Benchmark: Construction of a Standard Honk proof + * @brief Benchmark: Creation of a Ultra Honk verifier */ -void construct_proof_ultra(State& state) noexcept +void create_verifier_ultra(State& state) noexcept { - auto num_gates = 1 << (size_t)state.range(0); for (auto _ : state) { state.PauseTiming(); + auto num_gates = 1 << (size_t)state.range(0); auto composer = Composer(); generate_test_circuit(composer, static_cast(num_gates)); - auto ext_prover = composer.create_prover(); state.ResumeTiming(); - auto proof = ext_prover.construct_proof(); + composer.create_verifier(); } - state.SetComplexityN(num_gates); // Set up for computation of constant C where prover ~ C*N } -BENCHMARK(construct_proof_ultra) - ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1) - ->Repetitions(NUM_REPETITIONS) - ->Complexity(oN); +// BENCHMARK(create_verifier_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); /** - * @brief Benchmark: Verification of a Standard Honk proof + * @brief Benchmark: Verification of a Ultra Honk proof */ void verify_proof_ultra(State& state) noexcept { @@ -106,9 +106,5 @@ void verify_proof_ultra(State& state) noexcept verifier.verify_proof(proof); } } -// Note: enforcing Iterations == 1 for now. Otherwise proof construction will occur many times and this bench will take -// a long time. (This is because the time limit for benchmarks does not include the time-excluded setup, and -// verification itself is pretty fast). -// Note: disabling this bench for now since it is not of primary interest // BENCHMARK(verify_proof_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Iterations(1); } // namespace ultra_honk_bench \ No newline at end of file From 928dbab6744a90a02fc0f5928161dfa952cab65b Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 26 May 2023 19:54:50 +0000 Subject: [PATCH 04/11] add bench results --- .../benchmark/honk_bench/bench_results.json | 614 ++++++++++++++++++ 1 file changed, 614 insertions(+) create mode 100644 cpp/src/barretenberg/benchmark/honk_bench/bench_results.json diff --git a/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json b/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json new file mode 100644 index 0000000000..67285852ad --- /dev/null +++ b/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json @@ -0,0 +1,614 @@ +{ + "context": { + "date": "2023-05-26T19:53:29+00:00", + "host_name": "fv-az491-631", + "executable": "bin/honk_bench", + "num_cpus": 2, + "mhz_per_cpu": 2594, + "cpu_scaling_enabled": false, + "caches": [ + { + "type": "Data", + "level": 1, + "size": 32768, + "num_sharing": 1 + }, + { + "type": "Instruction", + "level": 1, + "size": 32768, + "num_sharing": 1 + }, + { + "type": "Unified", + "level": 2, + "size": 1048576, + "num_sharing": 1 + }, + { + "type": "Unified", + "level": 3, + "size": 37486592, + "num_sharing": 2 + } + ], + "load_avg": [2.71338,2.04248,0.973633], + "library_build_type": "release" + }, + "benchmarks": [ + { + "name": "create_prover_standard/16/repeats:5", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 0, + "threads": 1, + "iterations": 12, + "real_time": 5.5504216499988012e+07, + "cpu_time": 5.5428016666666664e+07, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 1, + "threads": 1, + "iterations": 12, + "real_time": 5.7801632166667603e+07, + "cpu_time": 5.7482741666666597e+07, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 2, + "threads": 1, + "iterations": 12, + "real_time": 5.7450450666668952e+07, + "cpu_time": 5.7233533333333291e+07, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 3, + "threads": 1, + "iterations": 12, + "real_time": 5.7718005583339505e+07, + "cpu_time": 5.7534408333333343e+07, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 4, + "threads": 1, + "iterations": 12, + "real_time": 5.7766381500006974e+07, + "cpu_time": 5.7489225000000007e+07, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5_mean", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "mean", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 5.7248137283334211e+07, + "cpu_time": 5.7033584999999985e+07, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5_median", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "median", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 5.7718005583339497e+07, + "cpu_time": 5.7482741666666605e+07, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5_stddev", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "stddev", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 9.8461925090377196e+05, + "cpu_time": 9.0526274376913963e+05, + "time_unit": "ns" + }, + { + "name": "create_prover_standard/16/repeats:5_cv", + "family_index": 0, + "per_family_instance_index": 0, + "run_name": "create_prover_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "cv", + "aggregate_unit": "percentage", + "iterations": 5, + "real_time": 1.7199149136166030e-02, + "cpu_time": 1.5872450307466028e-02, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 0, + "threads": 1, + "iterations": 1, + "real_time": 4.5438027659999990e+09, + "cpu_time": 3.2067761999999995e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 1, + "threads": 1, + "iterations": 1, + "real_time": 3.2842767270000196e+09, + "cpu_time": 1.9386794000000017e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 2, + "threads": 1, + "iterations": 1, + "real_time": 3.3388418679999747e+09, + "cpu_time": 1.9140537000000002e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 3, + "threads": 1, + "iterations": 1, + "real_time": 3.2109865110000443e+09, + "cpu_time": 1.9802719000000000e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 4, + "threads": 1, + "iterations": 1, + "real_time": 3.3167836069999909e+09, + "cpu_time": 1.9449394000000010e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5_mean", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "mean", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 3.5389382958000054e+09, + "cpu_time": 2.1969441200000005e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5_median", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "median", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 3.3167836069999909e+09, + "cpu_time": 1.9449394000000007e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5_stddev", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "stddev", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 5.6381485822511280e+08, + "cpu_time": 5.6500922889444625e+08, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/16/repeats:5_cv", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "cv", + "aggregate_unit": "percentage", + "iterations": 5, + "real_time": 1.5931751590420365e-01, + "cpu_time": 2.5717960859853195e-01, + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/repeats:5_BigO", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "BigO", + "aggregate_unit": "time", + "cpu_coefficient": 3.3522706909179695e+04, + "real_coefficient": 5.3999912960815520e+04, + "big_o": "N", + "time_unit": "ns" + }, + { + "name": "construct_proof_standard/repeats:5_RMS", + "family_index": 1, + "per_family_instance_index": 0, + "run_name": "construct_proof_standard/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "RMS", + "aggregate_unit": "percentage", + "rms": 2.3002843490124258e-01 + }, + { + "name": "create_prover_ultra/16/repeats:5", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 0, + "threads": 1, + "iterations": 3, + "real_time": 1.8232255199999750e+08, + "cpu_time": 1.8199536666666678e+08, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 1, + "threads": 1, + "iterations": 3, + "real_time": 1.8351760733330974e+08, + "cpu_time": 1.8311056666666779e+08, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 2, + "threads": 1, + "iterations": 3, + "real_time": 1.8638982566667056e+08, + "cpu_time": 1.8603030000000110e+08, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 3, + "threads": 1, + "iterations": 3, + "real_time": 1.8593535066668209e+08, + "cpu_time": 1.8553553333333519e+08, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 4, + "threads": 1, + "iterations": 3, + "real_time": 1.8335277099998847e+08, + "cpu_time": 1.8314713333333185e+08, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5_mean", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "mean", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 1.8430362133332968e+08, + "cpu_time": 1.8396378000000057e+08, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5_median", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "median", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 1.8351760733330971e+08, + "cpu_time": 1.8314713333333188e+08, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5_stddev", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "stddev", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 1.7650325213651452e+06, + "cpu_time": 1.7328047547552765e+06, + "time_unit": "ns" + }, + { + "name": "create_prover_ultra/16/repeats:5_cv", + "family_index": 2, + "per_family_instance_index": 0, + "run_name": "create_prover_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "cv", + "aggregate_unit": "percentage", + "iterations": 5, + "real_time": 9.5767652778396863e-03, + "cpu_time": 9.4192713084894786e-03, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 0, + "threads": 1, + "iterations": 1, + "real_time": 1.0382158091999998e+10, + "cpu_time": 8.1326265999999981e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 1, + "threads": 1, + "iterations": 1, + "real_time": 1.0256200592000027e+10, + "cpu_time": 8.0500114000000057e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 2, + "threads": 1, + "iterations": 1, + "real_time": 1.0365316951000011e+10, + "cpu_time": 8.0008304000000048e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 3, + "threads": 1, + "iterations": 1, + "real_time": 1.0341458550999960e+10, + "cpu_time": 8.1200064000000086e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "iteration", + "repetitions": 5, + "repetition_index": 4, + "threads": 1, + "iterations": 1, + "real_time": 1.0240077385999996e+10, + "cpu_time": 8.0946810999999952e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5_mean", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "mean", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 1.0317042314399998e+10, + "cpu_time": 8.0796311800000048e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5_median", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "median", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 1.0341458550999960e+10, + "cpu_time": 8.0946810999999952e+09, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5_stddev", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "stddev", + "aggregate_unit": "time", + "iterations": 5, + "real_time": 6.4791922778365932e+07, + "cpu_time": 5.4203476177260555e+07, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/16/repeats:5_cv", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/16/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "cv", + "aggregate_unit": "percentage", + "iterations": 5, + "real_time": 6.2800869477808276e-03, + "cpu_time": 6.7086572356710641e-03, + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/repeats:5_BigO", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "BigO", + "aggregate_unit": "time", + "cpu_coefficient": 1.2328538787841803e+05, + "real_coefficient": 1.5742557242431637e+05, + "big_o": "N", + "time_unit": "ns" + }, + { + "name": "construct_proof_ultra/repeats:5_RMS", + "family_index": 3, + "per_family_instance_index": 0, + "run_name": "construct_proof_ultra/repeats:5", + "run_type": "aggregate", + "repetitions": 5, + "threads": 1, + "aggregate_name": "RMS", + "aggregate_unit": "percentage", + "rms": 6.0004054467059538e-03 + } + ] +} From a3fd5aff79c628ab8d8ee79afa407ea7bcbed74b Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 30 May 2023 16:03:10 +0000 Subject: [PATCH 05/11] stdlib building with ultraHonk --- .../honk/composer/ultra_honk_composer.hpp | 63 +++++++++++++++++++ .../stdlib/primitives/composers/composers.hpp | 20 +++--- .../primitives/composers/composers_fwd.hpp | 16 +++-- .../stdlib/primitives/uint/uint.hpp | 1 + 4 files changed, 88 insertions(+), 12 deletions(-) diff --git a/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp b/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp index 4a1b396030..b04c9ebdbe 100644 --- a/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp +++ b/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp @@ -21,8 +21,21 @@ class UltraHonkComposer { using ProvingKey = typename Flavor::ProvingKey; using VerificationKey = typename Flavor::VerificationKey; + static constexpr ComposerType type = ComposerType::PLOOKUP; + static_assert(type == CircuitConstructor::type); + static constexpr merkle::HashType merkle_hash_type = CircuitConstructor::merkle_hash_type; + static constexpr pedersen::CommitmentType commitment_type = CircuitConstructor::commitment_type; + static constexpr size_t DEFAULT_PLOOKUP_RANGE_BITNUM = UltraCircuitConstructor::DEFAULT_PLOOKUP_RANGE_BITNUM; + UltraHonkComposerHelper composer_helper; + + // References to circuit_constructor's members for convenience size_t& num_gates; + std::vector& variables; + // While we always have it set to zero, feels wrong to have a potentially broken dependency + uint32_t& zero_idx; + bool& contains_recursive_proof; + std::vector& recursive_proof_public_input_indices; UltraHonkComposer() : UltraHonkComposer("../srs_db/ignition", 0){}; @@ -35,6 +48,10 @@ class UltraHonkComposer { : circuit_constructor(size_hint) , composer_helper(crs_factory) , num_gates(circuit_constructor.num_gates) + , variables(circuit_constructor.variables) + , zero_idx(circuit_constructor.zero_idx) + , contains_recursive_proof(composer_helper.contains_recursive_proof) + , recursive_proof_public_input_indices(composer_helper.recursive_proof_public_input_indices) { // TODO(#217/#423): Related to issue of ensuring no identically 0 polynomials add_gates_to_ensure_all_polys_are_non_zero(); @@ -51,6 +68,11 @@ class UltraHonkComposer { uint32_t add_variable(const barretenberg::fr& in) { return circuit_constructor.add_variable(in); } + virtual void set_public_input(const uint32_t witness_index) + { + return circuit_constructor.set_public_input(witness_index); + } + barretenberg::fr get_variable(const uint32_t index) const { return circuit_constructor.get_variable(index); } void finalize_circuit() { circuit_constructor.finalize_circuit(); }; @@ -70,8 +92,21 @@ class UltraHonkComposer { circuit_constructor.create_big_add_gate(in, use_next_gate_w_4); }; + void create_bool_gate(const uint32_t a) { circuit_constructor.create_bool_gate(a); } + + void create_poly_gate(const poly_triple& in) { circuit_constructor.create_poly_gate(in); } + + void create_big_mul_gate(const mul_quad& in) { circuit_constructor.create_big_mul_gate(in); } + + void create_balanced_add_gate(const add_quad& in) { circuit_constructor.create_balanced_add_gate(in); } + void create_ecc_add_gate(const ecc_add_gate& in) { circuit_constructor.create_ecc_add_gate(in); }; + void fix_witness(const uint32_t witness_index, const barretenberg::fr& witness_value) + { + circuit_constructor.fix_witness(witness_index, witness_value); + } + void create_new_range_constraint(const uint32_t variable_index, const uint64_t target_range, std::string const msg = "create_new_range_constraint") @@ -91,6 +126,13 @@ class UltraHonkComposer { circuit_constructor.assert_equal(a_variable_idx, b_variable_idx, msg); } + void assert_equal_constant(uint32_t const a_idx, + barretenberg::fr const& b, + std::string const& msg = "assert equal constant") + { + circuit_constructor.assert_equal_constant(a_idx, b, msg); + } + plookup::ReadData create_gates_from_plookup_accumulators( const plookup::MultiTableId& id, const plookup::ReadData& read_values, @@ -174,11 +216,21 @@ class UltraHonkComposer { { circuit_constructor.set_ROM_element(rom_id, index_value, value_witness); }; + void set_ROM_element_pair(const size_t rom_id, + const size_t index_value, + const std::array& value_witnesses) + { + circuit_constructor.set_ROM_element_pair(rom_id, index_value, value_witnesses); + } uint32_t read_ROM_array(const size_t rom_id, const uint32_t index_witness) { return circuit_constructor.read_ROM_array(rom_id, index_witness); }; + std::array read_ROM_array_pair(const size_t rom_id, const uint32_t index_witness) + { + return circuit_constructor.read_ROM_array_pair(rom_id, index_witness); + } void init_RAM_element(const size_t ram_id, const size_t index_value, const uint32_t value_witness) { @@ -192,5 +244,16 @@ class UltraHonkComposer { { circuit_constructor.write_RAM_array(ram_id, index_witness, value_witness); }; + + void create_range_constraint(const uint32_t variable_index, + const size_t num_bits, + std::string const& msg = "create_range_constraint") + { + circuit_constructor.create_range_constraint(variable_index, num_bits, msg); + } + + bool failed() const { return circuit_constructor.failed(); }; + const std::string& err() const { return circuit_constructor.err(); }; + void failure(std::string msg) { circuit_constructor.failure(msg); } }; } // namespace proof_system::honk diff --git a/cpp/src/barretenberg/stdlib/primitives/composers/composers.hpp b/cpp/src/barretenberg/stdlib/primitives/composers/composers.hpp index abc7306f89..7cecc12a4a 100644 --- a/cpp/src/barretenberg/stdlib/primitives/composers/composers.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/composers/composers.hpp @@ -16,7 +16,8 @@ template stdlib_method(plonk::StandardPlonkComposer); \ template stdlib_method(honk::StandardHonkComposer); \ template stdlib_method(plonk::TurboPlonkComposer); \ - template stdlib_method(plonk::UltraPlonkComposer); + template stdlib_method(plonk::UltraPlonkComposer); \ + template stdlib_method(honk::UltraHonkComposer); #define INSTANTIATE_STDLIB_TYPE(stdlib_type) \ template class stdlib_type; \ @@ -25,16 +26,18 @@ template class stdlib_type; \ template class stdlib_type; \ template class stdlib_type; \ - template class stdlib_type; + template class stdlib_type; \ + template class stdlib_type; #define INSTANTIATE_STDLIB_TYPE_VA(stdlib_type, ...) \ template class stdlib_type; \ template class stdlib_type; \ - template class stdlib_type; \ + template class stdlib_type; \ template class stdlib_type; \ template class stdlib_type; \ template class stdlib_type; \ - template class stdlib_type; + template class stdlib_type; \ + template class stdlib_type; #define INSTANTIATE_STDLIB_BASIC_TYPE(stdlib_type) \ template class stdlib_type; \ @@ -52,12 +55,15 @@ #define INSTANTIATE_STDLIB_ULTRA_METHOD(stdlib_method) \ template stdlib_method(proof_system::UltraCircuitConstructor); \ - template stdlib_method(plonk::UltraPlonkComposer); + template stdlib_method(plonk::UltraPlonkComposer); \ + template stdlib_method(honk::UltraHonkComposer); #define INSTANTIATE_STDLIB_ULTRA_TYPE(stdlib_type) \ template class stdlib_type; \ - template class stdlib_type; + template class stdlib_type; \ + template class stdlib_type; #define INSTANTIATE_STDLIB_ULTRA_TYPE_VA(stdlib_type, ...) \ template class stdlib_type; \ - template class stdlib_type; + template class stdlib_type; \ + template class stdlib_type; diff --git a/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp b/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp index 692e228883..0feb53cd17 100644 --- a/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp @@ -10,6 +10,7 @@ class StandardPlonkComposer; namespace proof_system::honk { class StandardHonkComposer; +class UltraHonkComposer; } // namespace proof_system::honk namespace proof_system { class StandardCircuitConstructor; @@ -24,7 +25,8 @@ class UltraCircuitConstructor; extern template class stdlib_type; \ extern template class stdlib_type; \ extern template class stdlib_type; \ - extern template class stdlib_type; + extern template class stdlib_type; \ + extern template class stdlib_type; #define EXTERN_STDLIB_METHOD(stdlib_method) \ extern template stdlib_method(proof_system::StandardCircuitConstructor); \ @@ -33,7 +35,8 @@ class UltraCircuitConstructor; extern template stdlib_method(plonk::StandardPlonkComposer); \ extern template stdlib_method(honk::StandardHonkComposer); \ extern template stdlib_method(plonk::TurboPlonkComposer); \ - extern template stdlib_method(plonk::UltraPlonkComposer); + extern template stdlib_method(plonk::UltraPlonkComposer); \ + extern template stdlib_method(honk::UltraHonkComposer); #define EXTERN_STDLIB_TYPE_VA(stdlib_type, ...) \ extern template class stdlib_type; \ @@ -58,12 +61,15 @@ class UltraCircuitConstructor; #define EXTERN_STDLIB_ULTRA_TYPE(stdlib_type) \ extern template class stdlib_type; \ - extern template class stdlib_type; + extern template class stdlib_type; \ + // extern template class stdlib_type; #define EXTERN_STDLIB_ULTRA_TYPE_VA(stdlib_type, ...) \ extern template class stdlib_type; \ - extern template class stdlib_type; + extern template class stdlib_type; \ + extern template class stdlib_type; #define EXTERN_STDLIB_ULTRA_METHOD(stdlib_method) \ extern template stdlib_method(proof_system::UltraCircuitConstructor); \ - extern template stdlib_method(plonk::UltraPlonkComposer); + extern template stdlib_method(plonk::UltraPlonkComposer); \ + extern template stdlib_method(honk::UltraHonkComposer); diff --git a/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp b/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp index fd7d1e0986..7ba8328f8e 100644 --- a/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/uint/uint.hpp @@ -11,6 +11,7 @@ #include "barretenberg/plonk/composer/standard_plonk_composer.hpp" #include "barretenberg/plonk/composer/turbo_plonk_composer.hpp" #include "barretenberg/plonk/composer/ultra_plonk_composer.hpp" +#include "barretenberg/honk/composer/ultra_honk_composer.hpp" namespace proof_system::plonk { namespace stdlib { From 8122b4313938ca48659816745a3998cdabd20bbe Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 30 May 2023 16:57:56 +0000 Subject: [PATCH 06/11] WiP debugging sha256 build --- .../benchmark/honk_bench/ultra_honk.bench.cpp | 19 ++++++++++++++++++- .../stdlib/hash/sha256/sha256.hpp | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index b8e00ca07d..c05581e8ad 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -4,6 +4,8 @@ #include #include #include "barretenberg/honk/composer/ultra_honk_composer.hpp" +#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" +#include "barretenberg/stdlib/hash/sha256/sha256.hpp" using namespace benchmark; @@ -32,6 +34,20 @@ void generate_test_circuit(auto& composer, size_t num_gates) } } +void generate_sha256_test_circuit(Composer& composer, size_t num_gates) +{ + std::string in; + in.resize(32); + for (size_t i = 0; i < 32; ++i) { + in[i] = 0; + } + size_t num_iterations = 10; + proof_system::plonk::stdlib::packed_byte_array input(&composer, in); + for (size_t i = 0; i < num_iterations; i++) { + input = proof_system::plonk::stdlib::sha256(input); + } +} + /** * @brief Benchmark: Creation of a Ultra Honk prover */ @@ -41,7 +57,8 @@ void create_prover_ultra(State& state) noexcept state.PauseTiming(); auto num_gates = 1 << (size_t)state.range(0); auto composer = Composer(); - generate_test_circuit(composer, static_cast(num_gates)); + generate_sha256_test_circuit(composer, static_cast(num_gates)); + // generate_test_circuit(composer, static_cast(num_gates)); state.ResumeTiming(); auto prover = composer.create_prover(); diff --git a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.hpp b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.hpp index 67d6c2e07a..10670df7d9 100644 --- a/cpp/src/barretenberg/stdlib/hash/sha256/sha256.hpp +++ b/cpp/src/barretenberg/stdlib/hash/sha256/sha256.hpp @@ -10,6 +10,7 @@ namespace proof_system::plonk { class UltraPlonkComposer; class StandardPlonkComposer; class TurboPlonkComposer; +class UltraHonkComposer; } // namespace proof_system::plonk namespace proof_system::plonk { From c92d42e961df809df10ee3a37806110ac06c94e6 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 30 May 2023 20:11:01 +0000 Subject: [PATCH 07/11] ultra bench updated with various stdlib operations --- .github/workflows/bberg_bench.yml | 14 +- .../benchmark/honk_bench/CMakeLists.txt | 3 + .../benchmark/honk_bench/ultra_honk.bench.cpp | 176 +++++++++++------- .../honk/composer/ultra_honk_composer.hpp | 44 ++++- 4 files changed, 162 insertions(+), 75 deletions(-) diff --git a/.github/workflows/bberg_bench.yml b/.github/workflows/bberg_bench.yml index 6edda354b1..436f5766ab 100644 --- a/.github/workflows/bberg_bench.yml +++ b/.github/workflows/bberg_bench.yml @@ -55,11 +55,11 @@ jobs: run: | bin/honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json - # Commit benchmark results json to the branch - - name: Commit result - working-directory: cpp - run: | - git add src/barretenberg/benchmark/honk_bench/bench_results.json - git commit -m "add bench results" - git push + # # Commit benchmark results json to the branch + # - name: Commit result + # working-directory: cpp + # run: | + # git add src/barretenberg/benchmark/honk_bench/bench_results.json + # git commit -m "add bench results" + # git push \ No newline at end of file diff --git a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index a160fed5b9..6eb5f75329 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -3,6 +3,9 @@ add_executable(honk_bench main.bench.cpp honk.bench.cpp ultra_honk.bench.cpp) target_link_libraries( honk_bench stdlib_primitives + stdlib_sha256 + stdlib_keccak + stdlib_merkle_tree env benchmark::benchmark ) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index c05581e8ad..666f882a45 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -1,11 +1,22 @@ +#include "barretenberg/crypto/ecdsa/ecdsa.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/honk/proof_system/ultra_prover.hpp" #include "barretenberg/honk/proof_system/ultra_verifier.hpp" #include #include #include "barretenberg/honk/composer/ultra_honk_composer.hpp" +#include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" +#include "barretenberg/stdlib/hash/keccak/keccak.hpp" +#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" #include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" #include "barretenberg/stdlib/hash/sha256/sha256.hpp" +#include "barretenberg/stdlib/primitives/bool/bool.hpp" +#include "barretenberg/stdlib/primitives/field/field.hpp" +#include "barretenberg/stdlib/primitives/witness/witness.hpp" +#include "barretenberg/stdlib/merkle_tree/merkle_tree.hpp" +#include "barretenberg/stdlib/merkle_tree/membership.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_store.hpp" +#include "barretenberg/stdlib/merkle_tree/memory_tree.hpp" using namespace benchmark; @@ -13,35 +24,25 @@ namespace ultra_honk_bench { using Composer = proof_system::honk::UltraHonkComposer; -constexpr size_t MIN_LOG_NUM_GATES = 16; -constexpr size_t MAX_LOG_NUM_GATES = 16; -// To get good statistics, number of Repetitions must be sufficient. ~30 Repetitions gives good results. -constexpr size_t NUM_REPETITIONS = 5; +// Number of times to perform operation of interest in the benchmark circuits, e.g. # of hashes to perform +constexpr size_t MIN_NUM_ITERATIONS = 10; +constexpr size_t MAX_NUM_ITERATIONS = 10; +// Numeber of times to repeat each benchmark +constexpr size_t NUM_REPETITIONS = 1; -// TODO(luke): Make this something useful. Suggestions from Zac: Sha256, keccak, ecdsa, merkle membership proofs w. -// Pedersen, recursion. -void generate_test_circuit(auto& composer, size_t num_gates) -{ - for (size_t j = 0; j < num_gates; ++j) { - uint64_t left = static_cast(j); - uint64_t right = static_cast(j + 1); - uint32_t left_idx = composer.add_variable(fr(left)); - uint32_t right_idx = composer.add_variable(fr(right)); - uint32_t result_idx = composer.add_variable(fr(left ^ right)); - - uint32_t add_idx = composer.add_variable(fr(left) + fr(right) + composer.get_variable(result_idx)); - composer.create_big_add_gate({ left_idx, right_idx, result_idx, add_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); - } -} - -void generate_sha256_test_circuit(Composer& composer, size_t num_gates) +/** + * @brief Generate test circuit with specified number of sha256 hashes + * + * @param composer + * @param num_iterations + */ +void generate_sha256_test_circuit(Composer& composer, size_t num_iterations) { std::string in; in.resize(32); for (size_t i = 0; i < 32; ++i) { in[i] = 0; } - size_t num_iterations = 10; proof_system::plonk::stdlib::packed_byte_array input(&composer, in); for (size_t i = 0; i < num_iterations; i++) { input = proof_system::plonk::stdlib::sha256(input); @@ -49,79 +50,120 @@ void generate_sha256_test_circuit(Composer& composer, size_t num_gates) } /** - * @brief Benchmark: Creation of a Ultra Honk prover + * @brief Generate test circuit with specified number of keccak hashes + * + * @param composer + * @param num_iterations */ -void create_prover_ultra(State& state) noexcept +void generate_keccak_test_circuit(Composer& composer, size_t num_iterations) { - for (auto _ : state) { - state.PauseTiming(); - auto num_gates = 1 << (size_t)state.range(0); - auto composer = Composer(); - generate_sha256_test_circuit(composer, static_cast(num_gates)); - // generate_test_circuit(composer, static_cast(num_gates)); - state.ResumeTiming(); + std::string in = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"; - auto prover = composer.create_prover(); + proof_system::plonk::stdlib::byte_array input(&composer, in); + for (size_t i = 0; i < num_iterations; i++) { + input = proof_system::plonk::stdlib::keccak::hash(input); } } -BENCHMARK(create_prover_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); /** - * @brief Benchmark: Construction of a Ultra Honk proof + * @brief Generate test circuit with specified number of ecdsa verifications + * + * @param composer + * @param num_iterations */ -void construct_proof_ultra(State& state) noexcept +void generate_ecdsa_verification_test_circuit(Composer& composer, size_t num_iterations) { - auto num_gates = 1 << (size_t)state.range(0); - for (auto _ : state) { - state.PauseTiming(); - auto composer = Composer(); - generate_test_circuit(composer, static_cast(num_gates)); - auto ext_prover = composer.create_prover(); - state.ResumeTiming(); + using curve = proof_system::plonk::stdlib::secp256k1; - auto proof = ext_prover.construct_proof(); + std::string message_string = "Instructions unclear, ask again later."; + + crypto::ecdsa::key_pair account; + account.private_key = curve::fr::random_element(); + account.public_key = curve::g1::one * account.private_key; + + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, account); + + bool first_result = crypto::ecdsa::verify_signature( + message_string, account.public_key, signature); + + std::vector rr(signature.r.begin(), signature.r.end()); + std::vector ss(signature.s.begin(), signature.s.end()); + uint8_t vv = signature.v; + + curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&composer, account.public_key); + + proof_system::plonk::stdlib::ecdsa::signature sig{ curve::byte_array_ct(&composer, rr), + curve::byte_array_ct(&composer, ss), + proof_system::plonk::stdlib::uint8(&composer, + vv) }; + + curve::byte_array_ct message(&composer, message_string); + + for (size_t i = 0; i < num_iterations; i++) { + proof_system::plonk::stdlib::ecdsa:: + verify_signature( + message, public_key, sig); } - state.SetComplexityN(num_gates); // Set up for computation of constant C where prover ~ C*N } -BENCHMARK(construct_proof_ultra) - ->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1) - ->Repetitions(NUM_REPETITIONS) - ->Complexity(oN); /** - * @brief Benchmark: Creation of a Ultra Honk verifier + * @brief Generate test circuit with specified number of merkle membership checks + * + * @param composer + * @param num_iterations */ -void create_verifier_ultra(State& state) noexcept +void generate_merkle_membership_test_circuit(Composer& composer, size_t num_iterations) { - for (auto _ : state) { - state.PauseTiming(); - auto num_gates = 1 << (size_t)state.range(0); - auto composer = Composer(); - generate_test_circuit(composer, static_cast(num_gates)); - state.ResumeTiming(); + using namespace proof_system::plonk::stdlib; + using bool_ct = bool_t; + using field_ct = field_t; + using witness_ct = witness_t; + using witness_ct = witness_t; + using MemStore = merkle_tree::MemoryStore; + using MerkleTree_ct = merkle_tree::MerkleTree; + + MemStore store; + auto db = MerkleTree_ct(store, 3); - composer.create_verifier(); + // Check membership at index 0. + auto zero = field_ct(witness_ct(&composer, fr::zero())).decompose_into_bits(); + field_ct root = witness_ct(&composer, db.root()); + + for (size_t i = 0; i < num_iterations; i++) { + bool_ct is_member = merkle_tree::check_membership( + root, merkle_tree::create_witness_hash_path(composer, db.get_hash_path(0)), field_ct(0), zero); } } -// BENCHMARK(create_verifier_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Repetitions(NUM_REPETITIONS); /** - * @brief Benchmark: Verification of a Ultra Honk proof + * @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided text circuit function */ -void verify_proof_ultra(State& state) noexcept +void construct_proof_ultra(State& state, void (*test_circuit_function)(Composer&, size_t)) noexcept { + auto num_iterations = static_cast(state.range(0)); for (auto _ : state) { state.PauseTiming(); - auto num_gates = (size_t)state.range(0); auto composer = Composer(); - generate_test_circuit(composer, static_cast(num_gates)); - auto prover = composer.create_prover(); - auto proof = prover.construct_proof(); - auto verifier = composer.create_verifier(); + test_circuit_function(composer, num_iterations); + auto ext_prover = composer.create_prover(); state.ResumeTiming(); - verifier.verify_proof(proof); + auto proof = ext_prover.construct_proof(); } } -// BENCHMARK(verify_proof_ultra)->DenseRange(MIN_LOG_NUM_GATES, MAX_LOG_NUM_GATES, 1)->Iterations(1); + +BENCHMARK_CAPTURE(construct_proof_ultra, sha256, &generate_sha256_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof_ultra, keccak, &generate_keccak_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof_ultra, ecdsa_verification, &generate_ecdsa_verification_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); +BENCHMARK_CAPTURE(construct_proof_ultra, merkle_membership, &generate_merkle_membership_test_circuit) + ->DenseRange(MIN_NUM_ITERATIONS, MAX_NUM_ITERATIONS) + ->Repetitions(NUM_REPETITIONS); + } // namespace ultra_honk_bench \ No newline at end of file diff --git a/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp b/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp index b04c9ebdbe..df62eeddc5 100644 --- a/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp +++ b/cpp/src/barretenberg/honk/composer/ultra_honk_composer.hpp @@ -61,11 +61,19 @@ class UltraHonkComposer { std::shared_ptr const& v_key, size_t size_hint = 0); UltraHonkComposer(UltraHonkComposer&& other) = default; - UltraHonkComposer& operator=(UltraHonkComposer&& other) = delete; + UltraHonkComposer& operator=(UltraHonkComposer&& other) + { + circuit_constructor = std::move(other.circuit_constructor); + composer_helper = std::move(other.composer_helper); + return *this; + }; ~UltraHonkComposer() = default; + size_t get_num_gates() const { return circuit_constructor.get_num_gates(); } uint32_t get_zero_idx() { return circuit_constructor.zero_idx; } + bool check_circuit() { return circuit_constructor.check_circuit(); } + uint32_t add_variable(const barretenberg::fr& in) { return circuit_constructor.add_variable(in); } virtual void set_public_input(const uint32_t witness_index) @@ -92,6 +100,8 @@ class UltraHonkComposer { circuit_constructor.create_big_add_gate(in, use_next_gate_w_4); }; + void create_mul_gate(const mul_triple& in) { circuit_constructor.create_mul_gate(in); } + void create_bool_gate(const uint32_t a) { circuit_constructor.create_bool_gate(a); } void create_poly_gate(const poly_triple& in) { circuit_constructor.create_poly_gate(in); } @@ -252,6 +262,38 @@ class UltraHonkComposer { circuit_constructor.create_range_constraint(variable_index, num_bits, msg); } + std::array decompose_non_native_field_double_width_limb( + const uint32_t limb_idx, + const size_t num_limb_bits = (2 * UltraCircuitConstructor::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS)) + { + return circuit_constructor.decompose_non_native_field_double_width_limb(limb_idx, num_limb_bits); + } + + using add_simple = proof_system::UltraCircuitConstructor::add_simple; + std::array evaluate_non_native_field_subtraction( + add_simple limb0, + add_simple limb1, + add_simple limb2, + add_simple limb3, + std::tuple limbp) + { + return circuit_constructor.evaluate_non_native_field_subtraction(limb0, limb1, limb2, limb3, limbp); + } + std::array evaluate_non_native_field_addition(add_simple limb0, + add_simple limb1, + add_simple limb2, + add_simple limb3, + std::tuple limbp) + { + return circuit_constructor.evaluate_non_native_field_addition(limb0, limb1, limb2, limb3, limbp); + }; + + std::array queue_partial_non_native_field_multiplication( + const proof_system::UltraCircuitConstructor::non_native_field_witnesses& input) + { + return circuit_constructor.queue_partial_non_native_field_multiplication(input); + } + bool failed() const { return circuit_constructor.failed(); }; const std::string& err() const { return circuit_constructor.err(); }; void failure(std::string msg) { circuit_constructor.failure(msg); } From 79a95ede925c0744cbf27ce906c2d1023fcadebd Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 30 May 2023 21:09:37 +0000 Subject: [PATCH 08/11] remove github action workflow altogether for now --- .github/workflows/bberg_bench.yml | 65 -- barretenberg.code-workspace | 2 +- .../benchmark/honk_bench/bench_results.json | 614 ------------------ 3 files changed, 1 insertion(+), 680 deletions(-) delete mode 100644 .github/workflows/bberg_bench.yml delete mode 100644 cpp/src/barretenberg/benchmark/honk_bench/bench_results.json diff --git a/.github/workflows/bberg_bench.yml b/.github/workflows/bberg_bench.yml deleted file mode 100644 index 436f5766ab..0000000000 --- a/.github/workflows/bberg_bench.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Barretenberg Benchmarks - -# For now, run basically whenever anything happens in a PR -on: - pull_request: - types: ["labeled", "opened", "synchronize", "reopened"] - -# This will cancel previous runs when a branch or PR is updated -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - bberg-bench: - name: Barretenberg Benchmarks - runs-on: ubuntu-latest # run in linux environment - - # env: - # BASE_DIR: ${{ github.workspace }}/cpp - # BUILD_DIR: ${{ github.workspace }}/cpp/build-bench - # BENCH_RESULTS_DIR: ${{ github.workspace }}/cpp/src/barretenberg/benchmark/honk_bench - - steps: - - - name: Checkout barretenberg - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} # checkout HEAD of triggering branch - token: ${{ secrets.GITHUB_TOKEN }} - - # Adding some credentials to avoid complaints from git - - name: Configure git - run: | - git config user.name ledwards2225 - git config user.email l.edwards.d@gmail.com - - # Only run in Linux environment for now - - name: Setup Linux environment - run: | - sudo apt update - sudo apt install libomp-dev cmake ninja-build - - - name: Download SRS elements - working-directory: cpp/srs_db - run: ./download_ignition.sh 3 # only download first 4 transcript files - - - name: Build Honk benchmarks - working-directory: cpp - run: | - cmake --preset bench - cmake --build --preset bench --target honk_bench - - - name: Run Honk benchmarks - working-directory: cpp/build-bench - run: | - bin/honk_bench --benchmark_format=json > ../src/barretenberg/benchmark/honk_bench/bench_results.json - - # # Commit benchmark results json to the branch - # - name: Commit result - # working-directory: cpp - # run: | - # git add src/barretenberg/benchmark/honk_bench/bench_results.json - # git commit -m "add bench results" - # git push - \ No newline at end of file diff --git a/barretenberg.code-workspace b/barretenberg.code-workspace index 0d0d3106e5..bf2de10d0e 100644 --- a/barretenberg.code-workspace +++ b/barretenberg.code-workspace @@ -115,7 +115,7 @@ // which ensures SRS can be read "testMate.cpp.test.workingDirectory": "${workspaceFolder}/cpp/build", // Filter all binaries that are not tests or benchmarks - "testMate.cpp.test.executables": "${workspaceFolder}/cpp/{build}/bin/*{test,bench}*", + "testMate.cpp.test.executables": "${workspaceFolder}/cpp/{build}/bin/*{test,Test,TEST,bench}*", // // Other // diff --git a/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json b/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json deleted file mode 100644 index 67285852ad..0000000000 --- a/cpp/src/barretenberg/benchmark/honk_bench/bench_results.json +++ /dev/null @@ -1,614 +0,0 @@ -{ - "context": { - "date": "2023-05-26T19:53:29+00:00", - "host_name": "fv-az491-631", - "executable": "bin/honk_bench", - "num_cpus": 2, - "mhz_per_cpu": 2594, - "cpu_scaling_enabled": false, - "caches": [ - { - "type": "Data", - "level": 1, - "size": 32768, - "num_sharing": 1 - }, - { - "type": "Instruction", - "level": 1, - "size": 32768, - "num_sharing": 1 - }, - { - "type": "Unified", - "level": 2, - "size": 1048576, - "num_sharing": 1 - }, - { - "type": "Unified", - "level": 3, - "size": 37486592, - "num_sharing": 2 - } - ], - "load_avg": [2.71338,2.04248,0.973633], - "library_build_type": "release" - }, - "benchmarks": [ - { - "name": "create_prover_standard/16/repeats:5", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 0, - "threads": 1, - "iterations": 12, - "real_time": 5.5504216499988012e+07, - "cpu_time": 5.5428016666666664e+07, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 1, - "threads": 1, - "iterations": 12, - "real_time": 5.7801632166667603e+07, - "cpu_time": 5.7482741666666597e+07, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 2, - "threads": 1, - "iterations": 12, - "real_time": 5.7450450666668952e+07, - "cpu_time": 5.7233533333333291e+07, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 3, - "threads": 1, - "iterations": 12, - "real_time": 5.7718005583339505e+07, - "cpu_time": 5.7534408333333343e+07, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 4, - "threads": 1, - "iterations": 12, - "real_time": 5.7766381500006974e+07, - "cpu_time": 5.7489225000000007e+07, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5_mean", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "mean", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 5.7248137283334211e+07, - "cpu_time": 5.7033584999999985e+07, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5_median", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "median", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 5.7718005583339497e+07, - "cpu_time": 5.7482741666666605e+07, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5_stddev", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "stddev", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 9.8461925090377196e+05, - "cpu_time": 9.0526274376913963e+05, - "time_unit": "ns" - }, - { - "name": "create_prover_standard/16/repeats:5_cv", - "family_index": 0, - "per_family_instance_index": 0, - "run_name": "create_prover_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "cv", - "aggregate_unit": "percentage", - "iterations": 5, - "real_time": 1.7199149136166030e-02, - "cpu_time": 1.5872450307466028e-02, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 0, - "threads": 1, - "iterations": 1, - "real_time": 4.5438027659999990e+09, - "cpu_time": 3.2067761999999995e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 1, - "threads": 1, - "iterations": 1, - "real_time": 3.2842767270000196e+09, - "cpu_time": 1.9386794000000017e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 2, - "threads": 1, - "iterations": 1, - "real_time": 3.3388418679999747e+09, - "cpu_time": 1.9140537000000002e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 3, - "threads": 1, - "iterations": 1, - "real_time": 3.2109865110000443e+09, - "cpu_time": 1.9802719000000000e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 4, - "threads": 1, - "iterations": 1, - "real_time": 3.3167836069999909e+09, - "cpu_time": 1.9449394000000010e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5_mean", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "mean", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 3.5389382958000054e+09, - "cpu_time": 2.1969441200000005e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5_median", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "median", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 3.3167836069999909e+09, - "cpu_time": 1.9449394000000007e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5_stddev", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "stddev", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 5.6381485822511280e+08, - "cpu_time": 5.6500922889444625e+08, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/16/repeats:5_cv", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "cv", - "aggregate_unit": "percentage", - "iterations": 5, - "real_time": 1.5931751590420365e-01, - "cpu_time": 2.5717960859853195e-01, - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/repeats:5_BigO", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "BigO", - "aggregate_unit": "time", - "cpu_coefficient": 3.3522706909179695e+04, - "real_coefficient": 5.3999912960815520e+04, - "big_o": "N", - "time_unit": "ns" - }, - { - "name": "construct_proof_standard/repeats:5_RMS", - "family_index": 1, - "per_family_instance_index": 0, - "run_name": "construct_proof_standard/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "RMS", - "aggregate_unit": "percentage", - "rms": 2.3002843490124258e-01 - }, - { - "name": "create_prover_ultra/16/repeats:5", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 0, - "threads": 1, - "iterations": 3, - "real_time": 1.8232255199999750e+08, - "cpu_time": 1.8199536666666678e+08, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 1, - "threads": 1, - "iterations": 3, - "real_time": 1.8351760733330974e+08, - "cpu_time": 1.8311056666666779e+08, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 2, - "threads": 1, - "iterations": 3, - "real_time": 1.8638982566667056e+08, - "cpu_time": 1.8603030000000110e+08, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 3, - "threads": 1, - "iterations": 3, - "real_time": 1.8593535066668209e+08, - "cpu_time": 1.8553553333333519e+08, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 4, - "threads": 1, - "iterations": 3, - "real_time": 1.8335277099998847e+08, - "cpu_time": 1.8314713333333185e+08, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5_mean", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "mean", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 1.8430362133332968e+08, - "cpu_time": 1.8396378000000057e+08, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5_median", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "median", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 1.8351760733330971e+08, - "cpu_time": 1.8314713333333188e+08, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5_stddev", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "stddev", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 1.7650325213651452e+06, - "cpu_time": 1.7328047547552765e+06, - "time_unit": "ns" - }, - { - "name": "create_prover_ultra/16/repeats:5_cv", - "family_index": 2, - "per_family_instance_index": 0, - "run_name": "create_prover_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "cv", - "aggregate_unit": "percentage", - "iterations": 5, - "real_time": 9.5767652778396863e-03, - "cpu_time": 9.4192713084894786e-03, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 0, - "threads": 1, - "iterations": 1, - "real_time": 1.0382158091999998e+10, - "cpu_time": 8.1326265999999981e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 1, - "threads": 1, - "iterations": 1, - "real_time": 1.0256200592000027e+10, - "cpu_time": 8.0500114000000057e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 2, - "threads": 1, - "iterations": 1, - "real_time": 1.0365316951000011e+10, - "cpu_time": 8.0008304000000048e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 3, - "threads": 1, - "iterations": 1, - "real_time": 1.0341458550999960e+10, - "cpu_time": 8.1200064000000086e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "iteration", - "repetitions": 5, - "repetition_index": 4, - "threads": 1, - "iterations": 1, - "real_time": 1.0240077385999996e+10, - "cpu_time": 8.0946810999999952e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5_mean", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "mean", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 1.0317042314399998e+10, - "cpu_time": 8.0796311800000048e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5_median", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "median", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 1.0341458550999960e+10, - "cpu_time": 8.0946810999999952e+09, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5_stddev", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "stddev", - "aggregate_unit": "time", - "iterations": 5, - "real_time": 6.4791922778365932e+07, - "cpu_time": 5.4203476177260555e+07, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/16/repeats:5_cv", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/16/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "cv", - "aggregate_unit": "percentage", - "iterations": 5, - "real_time": 6.2800869477808276e-03, - "cpu_time": 6.7086572356710641e-03, - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/repeats:5_BigO", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "BigO", - "aggregate_unit": "time", - "cpu_coefficient": 1.2328538787841803e+05, - "real_coefficient": 1.5742557242431637e+05, - "big_o": "N", - "time_unit": "ns" - }, - { - "name": "construct_proof_ultra/repeats:5_RMS", - "family_index": 3, - "per_family_instance_index": 0, - "run_name": "construct_proof_ultra/repeats:5", - "run_type": "aggregate", - "repetitions": 5, - "threads": 1, - "aggregate_name": "RMS", - "aggregate_unit": "percentage", - "rms": 6.0004054467059538e-03 - } - ] -} From b1c78959005d8d27003aa23fad970141443575b7 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 31 May 2023 14:34:09 +0000 Subject: [PATCH 09/11] update compare script --- cpp/src/barretenberg/benchmark/honk_bench/compare_honk_bench.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_bench.sh b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_bench.sh index 59c3a49e24..95cdbb8ed6 100755 --- a/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_bench.sh +++ b/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_bench.sh @@ -24,6 +24,7 @@ echo -e '\nConfiguring and building honk_bench in master branch..' git checkout master > /dev/null rm -rf $BUILD_DIR cmake --preset bench > /dev/null && cmake --build --preset bench --target honk_bench > /dev/null +cd build-bench MASTER_HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench_results_master.json" echo -e '\nRunning honk_bench in master..' bin/honk_bench --benchmark_format=json > $MASTER_HONK_BENCH_RESULTS @@ -33,6 +34,7 @@ echo -e '\nConfiguring and building honk_bench in current feature branch..' git checkout - rm -rf $BUILD_DIR cmake --preset bench > /dev/null && cmake --build --preset bench --target honk_bench > /dev/null +cd build-bench BRANCH_HONK_BENCH_RESULTS="$BENCH_RESULTS_DIR/honk_bench_results_branch.json" echo -e '\nRunning honk_bench in feature branch..' bin/honk_bench --benchmark_format=json > $BRANCH_HONK_BENCH_RESULTS From b35b8259edd391ce7462ab50f1aee0a658540d86 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 31 May 2023 18:28:04 +0000 Subject: [PATCH 10/11] fix gcc build --- .../barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index 666f882a45..1ca94f2a66 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -112,11 +112,11 @@ void generate_ecdsa_verification_test_circuit(Composer& composer, size_t num_ite * * @param composer * @param num_iterations + * @todo (luke): should we consider deeper tree? non-zero leaf values? variable index? */ void generate_merkle_membership_test_circuit(Composer& composer, size_t num_iterations) { using namespace proof_system::plonk::stdlib; - using bool_ct = bool_t; using field_ct = field_t; using witness_ct = witness_t; using witness_ct = witness_t; @@ -126,12 +126,12 @@ void generate_merkle_membership_test_circuit(Composer& composer, size_t num_iter MemStore store; auto db = MerkleTree_ct(store, 3); - // Check membership at index 0. + // Check that the leaf at index 0 has value 0. auto zero = field_ct(witness_ct(&composer, fr::zero())).decompose_into_bits(); field_ct root = witness_ct(&composer, db.root()); for (size_t i = 0; i < num_iterations; i++) { - bool_ct is_member = merkle_tree::check_membership( + merkle_tree::check_membership( root, merkle_tree::create_witness_hash_path(composer, db.get_hash_path(0)), field_ct(0), zero); } } From e92b89eb5c86be2a75a6b4ab0b40514612ba8009 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 2 Jun 2023 00:02:10 +0000 Subject: [PATCH 11/11] fix some typos --- cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp | 2 +- .../barretenberg/stdlib/primitives/composers/composers_fwd.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp index 1ca94f2a66..f794bc603d 100644 --- a/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp +++ b/cpp/src/barretenberg/benchmark/honk_bench/ultra_honk.bench.cpp @@ -27,7 +27,7 @@ using Composer = proof_system::honk::UltraHonkComposer; // Number of times to perform operation of interest in the benchmark circuits, e.g. # of hashes to perform constexpr size_t MIN_NUM_ITERATIONS = 10; constexpr size_t MAX_NUM_ITERATIONS = 10; -// Numeber of times to repeat each benchmark +// Number of times to repeat each benchmark constexpr size_t NUM_REPETITIONS = 1; /** diff --git a/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp b/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp index 0feb53cd17..75b9a7e2e2 100644 --- a/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp +++ b/cpp/src/barretenberg/stdlib/primitives/composers/composers_fwd.hpp @@ -62,7 +62,7 @@ class UltraCircuitConstructor; #define EXTERN_STDLIB_ULTRA_TYPE(stdlib_type) \ extern template class stdlib_type; \ extern template class stdlib_type; \ - // extern template class stdlib_type; + extern template class stdlib_type; #define EXTERN_STDLIB_ULTRA_TYPE_VA(stdlib_type, ...) \ extern template class stdlib_type; \