From 3d2a89ba617f4985c1ef5ca33c00a25c4e23a5ff Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 14 Jan 2025 03:12:22 +0000 Subject: [PATCH 1/5] remove debug_logging flag --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 3 +-- barretenberg/cpp/src/barretenberg/common/log.cpp | 3 --- barretenberg/cpp/src/barretenberg/common/log.hpp | 5 +---- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 4552e66deb5..ba972bd23cb 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -1314,8 +1314,7 @@ int main(int argc, char* argv[]) { try { std::vector args(argv + 1, argv + argc); - debug_logging = flag_present(args, "-d") || flag_present(args, "--debug_logging"); - verbose_logging = debug_logging || flag_present(args, "-v") || flag_present(args, "--verbose_logging"); + verbose_logging = flag_present(args, "-v") || flag_present(args, "--verbose_logging"); if (args.empty()) { std::cerr << "No command provided.\n"; return 1; diff --git a/barretenberg/cpp/src/barretenberg/common/log.cpp b/barretenberg/cpp/src/barretenberg/common/log.cpp index 60c9679cedb..a3917413603 100644 --- a/barretenberg/cpp/src/barretenberg/common/log.cpp +++ b/barretenberg/cpp/src/barretenberg/common/log.cpp @@ -7,6 +7,3 @@ bool verbose_logging = std::getenv("BB_VERBOSE") == nullptr ? false : std::strin #else bool verbose_logging = true; #endif - -// Used for `debug` in log.hpp. -bool debug_logging = false; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/log.hpp b/barretenberg/cpp/src/barretenberg/common/log.hpp index dcf5d841dc0..19486b16307 100644 --- a/barretenberg/cpp/src/barretenberg/common/log.hpp +++ b/barretenberg/cpp/src/barretenberg/common/log.hpp @@ -47,13 +47,10 @@ template std::string benchmark_format(Args... args) return os.str(); } -extern bool debug_logging; #ifndef NDEBUG template inline void debug(Args... args) { - if (debug_logging) { - logstr(format(args...).c_str()); - } + logstr(format(args...).c_str()); } #else template inline void debug(Args... /*unused*/) {} From 7f4f8b70e8d261019ff160383adfe3994841ecb0 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 14 Jan 2025 03:12:34 +0000 Subject: [PATCH 2/5] add debug statement to the failure function --- .../stdlib_circuit_builders/circuit_builder_base_impl.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp index e3e4bbcfe9d..e787d08679c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp @@ -287,6 +287,8 @@ template void CircuitBuilderBase::set_err(std::string msg) template void CircuitBuilderBase::failure(std::string msg) { _failed = true; + debug("Builder failed to build. This is not an error for the write_vk flow. Are you building the circuit with " + "invalid witnesses?"); set_err(std::move(msg)); } } // namespace bb \ No newline at end of file From 23666c4fa6839b4a303a09cef8ee611488a74a97 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 14 Jan 2025 15:41:13 +0000 Subject: [PATCH 3/5] add has_dummy_witnesses var to builder and check during failure() --- .../stdlib_circuit_builders/circuit_builder_base.hpp | 3 ++- .../circuit_builder_base_impl.hpp | 10 +++++++--- .../stdlib_circuit_builders/ultra_circuit_builder.hpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp index b2eedbd74e5..93219164a63 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp @@ -18,6 +18,7 @@ template class CircuitBuilderBase { using EmbeddedCurve = std::conditional_t, curve::BN254, curve::Grumpkin>; size_t num_gates = 0; + bool has_dummy_witnesses; std::vector public_inputs; std::vector variables; @@ -56,7 +57,7 @@ template class CircuitBuilderBase { static constexpr uint32_t REAL_VARIABLE = UINT32_MAX - 1; static constexpr uint32_t FIRST_VARIABLE_IN_CLASS = UINT32_MAX - 2; - CircuitBuilderBase(size_t size_hint = 0); + CircuitBuilderBase(size_t size_hint = 0, bool has_dummy_witnesses = false); CircuitBuilderBase(const CircuitBuilderBase& other) = default; CircuitBuilderBase(CircuitBuilderBase&& other) noexcept = default; diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp index e787d08679c..caffb649e88 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp @@ -3,7 +3,9 @@ #include "circuit_builder_base.hpp" namespace bb { -template CircuitBuilderBase::CircuitBuilderBase(size_t size_hint) +template +CircuitBuilderBase::CircuitBuilderBase(size_t size_hint, bool has_dummy_witnesses) + : has_dummy_witnesses(has_dummy_witnesses) { variables.reserve(size_hint * 3); variable_names.reserve(size_hint * 3); @@ -286,9 +288,11 @@ template void CircuitBuilderBase::set_err(std::string msg) template void CircuitBuilderBase::failure(std::string msg) { + if (!has_dummy_witnesses) { + // We have a builder failure when we have real witnesses which is a mistake. + ASSERT(0 && "Builder failure when we have real witnesses"); + } _failed = true; - debug("Builder failed to build. This is not an error for the write_vk flow. Are you building the circuit with " - "invalid witnesses?"); set_err(std::move(msg)); } } // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp index c70c8d062e0..86dc5210ce1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp @@ -359,7 +359,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase& public_inputs, size_t varnum, bool recursive = false) - : CircuitBuilderBase(size_hint) + : CircuitBuilderBase(size_hint, witness_values.empty()) { // TODO(https://github.com/AztecProtocol/barretenberg/issues/870): reserve space in blocks here somehow? From 5f3c9929159e3e51901078318d92caefd6ececa3 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 14 Jan 2025 18:47:23 +0000 Subject: [PATCH 4/5] default false --- .../stdlib_circuit_builders/circuit_builder_base.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp index 93219164a63..8587fcf98b5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp @@ -18,7 +18,8 @@ template class CircuitBuilderBase { using EmbeddedCurve = std::conditional_t, curve::BN254, curve::Grumpkin>; size_t num_gates = 0; - bool has_dummy_witnesses; + // true if we have dummy witnesses (in the write_vk case) + bool has_dummy_witnesses = false; std::vector public_inputs; std::vector variables; From 25deae00c47dbab084185ca8b215b1b87ee0ef19 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 14 Jan 2025 21:27:59 +0000 Subject: [PATCH 5/5] change to info statement to not have to fix all the failed tests --- .../stdlib_circuit_builders/circuit_builder_base_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp index caffb649e88..620d10757de 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base_impl.hpp @@ -290,7 +290,7 @@ template void CircuitBuilderBase::failure(std::string msg) { if (!has_dummy_witnesses) { // We have a builder failure when we have real witnesses which is a mistake. - ASSERT(0 && "Builder failure when we have real witnesses"); + info("Builder failure when we have real witnesses!"); // not a catch-all error } _failed = true; set_err(std::move(msg));