Skip to content

Commit

Permalink
chore(avm): fewer errors unless testing (#7943)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro authored Aug 14, 2024
1 parent f6a7019 commit 33b65a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,14 @@ bool AvmCircuitBuilder::check_circuit() const

std::string errors;
std::mutex m;
const bool verbose_errors = std::getenv("AVM_VERBOSE_ERRORS") != nullptr;
auto signal_error = [&](const std::string& error) {
std::lock_guard<std::mutex> lock(m);
errors += error + "\n";
if (verbose_errors) {
errors += error + "\n";
} else if (errors.empty()) {
errors = "Circuit check failed. Use AVM_VERBOSE_ERRORS=1 to see more details.";
}
};
bb::parallel_for(checks.size(), [&](size_t i) { checks[i](signal_error); });
if (!errors.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void validate_trace(std::vector<Row>&& trace,
bool with_proof,
bool expect_proof_failure)
{
setenv("AVM_VERBOSE_ERRORS", "1", 1);
auto circuit_builder = AvmCircuitBuilder();
circuit_builder.set_trace(std::move(trace));
EXPECT_TRUE(circuit_builder.check_circuit());
Expand Down
7 changes: 6 additions & 1 deletion bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,14 @@ bool {{name}}CircuitBuilder::check_circuit() const {

std::string errors;
std::mutex m;
const bool verbose_errors = std::getenv("AVM_VERBOSE_ERRORS") != nullptr;
auto signal_error = [&](const std::string& error) {
std::lock_guard<std::mutex> lock(m);
errors += error + "\n";
if (verbose_errors) {
errors += error + "\n";
} else if (errors.empty()) {
errors = "Circuit check failed. Use AVM_VERBOSE_ERRORS=1 to see more details.";
}
};
bb::parallel_for(checks.size(), [&](size_t i) { checks[i](signal_error); });
if (!errors.empty()) {
Expand Down

0 comments on commit 33b65a9

Please sign in to comment.