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): tracegen interactions assertion #11972

Merged
merged 1 commit into from
Feb 13, 2025
Merged
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
18 changes: 18 additions & 0 deletions barretenberg/cpp/src/barretenberg/vm2/tracegen_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <string>
#include <vector>

#include "barretenberg/common/constexpr_utils.hpp"
#include "barretenberg/common/std_array.hpp"
#include "barretenberg/common/thread.hpp"
#include "barretenberg/numeric/bitop/get_msb.hpp"
Expand Down Expand Up @@ -123,6 +124,22 @@ void print_trace_stats(const TraceContainer& trace)
info("Sum of all column rows: ", total_rows, " (~2^", numeric::get_msb(numeric::round_up_power_2(total_rows)), ")");
}

// Check that inverses have been set, if assertions are enabled.
// WARNING: This will not warn you if the interaction is not exercised.
void check_interactions([[maybe_unused]] const TraceContainer& trace)
{
#ifndef NDEBUG
bb::constexpr_for<0, std::tuple_size_v<typename AvmFlavor::LookupRelations>, 1>([&]<size_t i>() {
using Settings = typename std::tuple_element_t<i, typename AvmFlavor::LookupRelations>::Settings;
if (trace.get_column_rows(Settings::SRC_SELECTOR) != 0 && trace.get_column_rows(Settings::INVERSES) == 0) {
std::cerr << "Inverses not set for " << Settings::NAME << ". Did you forget to run a lookup builder?"
<< std::endl;
std::abort();
}
});
#endif
}

} // namespace

TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events)
Expand Down Expand Up @@ -210,6 +227,7 @@ TraceContainer AvmTraceGenHelper::generate_trace(EventsContainer&& events)
parallel_for(jobs_interactions.size(), [&](size_t i) { jobs_interactions[i]->process(trace); }));
}

check_interactions(trace);
print_trace_stats(trace);
return trace;
}
Expand Down