diff --git a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt index d851d5af2855..16f375379bbb 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt @@ -2,4 +2,4 @@ add_subdirectory(decrypt_bench) add_subdirectory(pippenger_bench) add_subdirectory(plonk_bench) add_subdirectory(honk_bench) -add_subdirectory(relations_bench) +add_subdirectory(relations_bench) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt index 38b08abcb342..fad8d9f141df 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/CMakeLists.txt @@ -1,8 +1,8 @@ # Each source represents a separate benchmark suite set(BENCHMARK_SOURCES -standard_plonk.bench.cpp -ultra_honk.bench.cpp -ultra_plonk.bench.cpp + standard_plonk.bench.cpp + ultra_honk.bench.cpp + ultra_plonk.bench.cpp ) # Required libraries for benchmark suites diff --git a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp index 288f9605c560..242aa86764d5 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/benchmark_utilities.hpp @@ -45,6 +45,9 @@ template void generate_basic_arithmetic_circuit(Builder& buil proof_system::plonk::stdlib::field_t b( proof_system::plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); proof_system::plonk::stdlib::field_t c(&builder); + if (num_gates < 4) { + throw std::runtime_error("too few gates"); + } for (size_t i = 0; i < (num_gates / 4) - 4; ++i) { c = a + b; c = a * c; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt index d6b5a9a0df33..0db876053fb5 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt @@ -1,7 +1,8 @@ # Each source represents a separate benchmark suite set(BENCHMARK_SOURCES -barycentric.bench.cpp -relations.bench.cpp + barycentric.bench.cpp + relations.bench.cpp + widget.bench.cpp ) # Required libraries for benchmark suites @@ -9,6 +10,8 @@ set(LINKED_LIBRARIES polynomials proof_system benchmark::benchmark + transcript + stdlib_primitives ) # Add executable and custom target for each suite, e.g. ultra_honk_bench diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp new file mode 100644 index 000000000000..d1d468b0f8fb --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/widget.bench.cpp @@ -0,0 +1,35 @@ +#include "barretenberg/benchmark/honk_bench/benchmark_utilities.hpp" +#include "barretenberg/honk/flavor/goblin_ultra.hpp" +#include "barretenberg/honk/flavor/ultra.hpp" +#include "barretenberg/plonk/composer/standard_composer.hpp" +#include "barretenberg/plonk/composer/ultra_composer.hpp" +#include "barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp" +#include + +namespace { +auto& engine = numeric::random::get_debug_engine(); +} + +namespace proof_system::plonk { + +template void execute_widget(::benchmark::State& state) +{ + barretenberg::srs::init_crs_factory("../srs_db/ignition"); + auto inner_composer = plonk::UltraComposer(); + auto builder = typename plonk::UltraComposer::CircuitBuilder(); + bench_utils::generate_basic_arithmetic_circuit(builder, 80); + auto inner_prover = inner_composer.create_prover(builder); + auto inner_proof = inner_prover.construct_proof(); + for (auto _ : state) { + Widget widget(inner_composer.circuit_proving_key.get()); + widget.compute_quotient_contribution(barretenberg::fr::random_element(), inner_prover.transcript); + } +} + +void plookup_auxiliary_widget(::benchmark::State& state) noexcept +{ + execute_widget>(state); +} +BENCHMARK(plookup_auxiliary_widget); + +} // namespace proof_system::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp index 1026193bdf7e..2bd77756555c 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp @@ -170,23 +170,12 @@ UltraProver UltraComposer::create_prover(CircuitBuilder& circuit_constructor) UltraProver output_state(circuit_proving_key, create_manifest(circuit_constructor.public_inputs.size())); - std::unique_ptr> permutation_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> plookup_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> arithmetic_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> sort_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> elliptic_widget = - std::make_unique>(circuit_proving_key.get()); - - std::unique_ptr> auxiliary_widget = - std::make_unique>(circuit_proving_key.get()); + auto permutation_widget = std::make_unique>(circuit_proving_key.get()); + auto plookup_widget = std::make_unique>(circuit_proving_key.get()); + auto arithmetic_widget = std::make_unique>(circuit_proving_key.get()); + auto sort_widget = std::make_unique>(circuit_proving_key.get()); + auto elliptic_widget = std::make_unique>(circuit_proving_key.get()); + auto auxiliary_widget = std::make_unique>(circuit_proving_key.get()); output_state.random_widgets.emplace_back(std::move(permutation_widget)); output_state.random_widgets.emplace_back(std::move(plookup_widget)); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp index 311ead04ab04..6b4d3105bdaa 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp @@ -247,6 +247,8 @@ class FFTGetter : public BaseGetter 0); return polynomials.coefficients[id][(ptrdiff_t)index]; } }; @@ -316,6 +318,7 @@ class TransitionWidget : public TransitionWidgetBase { const transcript::StandardTranscript& transcript) override { auto* key = TransitionWidgetBase::key; + ASSERT(key != nullptr); // Get the set IDs for the polynomials required by the widget auto& required_polynomial_ids = FFTKernel::get_required_polynomial_ids(); diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp index ff4abf731139..91d06b788d23 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.cpp @@ -210,7 +210,7 @@ void Transcript::apply_fiat_shamir(const std::string& challenge_name /*, const b if (current_round > 0) { buffer.insert(buffer.end(), current_challenge.data.begin(), current_challenge.data.end()); } - for (auto manifest_element : manifest.get_round_manifest(current_round).elements) { + for (const auto& manifest_element : manifest.get_round_manifest(current_round).elements) { info_togglable("apply_fiat_shamir(): manifest element name match:"); info_togglable("\t element name: ", manifest_element.name); info_togglable(