Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(avm): fewer errors unless testing #7943

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

}
};
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
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
Loading