Repository navigation
chore(avm): check full tuple after find_in_dst #13397
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,12 +30,11 @@ template <typename LookupSettings_> class BaseLookupTraceBuilder : public Intera | |
| // find a row dst_row in the target columns {d1, d2, ...} where the values match. | ||
| // Then we increment the count in the counts column at dst_row. | ||
| // The complexity is O(|src_selector|) * O(find_in_dst). | ||
| trace.visit_column(LookupSettings::SRC_SELECTOR, [&](uint32_t row, const FF& src_sel_value) { | ||
| assert(src_sel_value == 1); | ||
| (void)src_sel_value; // Avoid GCC complaining of unused parameter when asserts are disabled. | ||
|
|
||
| trace.visit_column(LookupSettings::SRC_SELECTOR, [&](uint32_t row, const FF&) { | ||
| auto src_values = trace.get_multiple(LookupSettings::SRC_COLUMNS, row); | ||
| uint32_t dst_row = find_in_dst(src_values); // Assumes an efficient implementation. | ||
| assert(src_values == trace.get_multiple(LookupSettings::DST_COLUMNS, dst_row)); | ||
|
|
||
| trace.set(LookupSettings::COUNTS, dst_row, trace.get(LookupSettings::COUNTS, dst_row) + 1); | ||
| }); | ||
| } | ||
|
|
@@ -63,10 +62,7 @@ class LookupIntoDynamicTableGeneric : public BaseLookupTraceBuilder<LookupSettin | |
| void init(TraceContainer& trace) override | ||
| { | ||
| row_idx.reserve(trace.get_column_rows(LookupSettings::DST_SELECTOR)); | ||
| trace.visit_column(LookupSettings::DST_SELECTOR, [&](uint32_t row, const FF& dst_sel_value) { | ||
| assert(dst_sel_value == 1); | ||
| (void)dst_sel_value; // Avoid GCC complaining of unused parameter when asserts are disabled. | ||
|
|
||
| trace.visit_column(LookupSettings::DST_SELECTOR, [&](uint32_t row, const FF&) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a bit strange to see many occurences of a visitor not using the second argument but I guess that it would be a bit of an "overdesign" to define two different visit_column. I suppose we cannot overload the lambda to call without any second argument but we could overload visit_column with a lambda argument taking only one argument.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think it's a bit too much to define 2 visitors. It's not so strange not to use one of the params. However we have to keep an eye on this, if most or many uses ignore the value, then we might need to change the visitor to just provide the row number, and you can optionally get the value yourself. The cost might be similar, or even faster for the cases where we would've ignored the value.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I'm providing the value because I get it for free while iterating the map: https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/cpp/src/barretenberg/vm2/tracegen/trace_container.cpp#L95 Since it's just a reference, the cost should be negligible.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx for the feedback. I was not really worried about performance even though it is a good consideration as well. |
||
| auto dst_values = trace.get_multiple(LookupSettings::DST_COLUMNS, row); | ||
| row_idx.insert({ dst_values, row }); | ||
| }); | ||
|
|
@@ -111,11 +107,8 @@ template <typename LookupSettings> class LookupIntoDynamicTableSequential : publ | |
| // Since the trace does not guarantee visiting rows in order, we need to collect the rows. | ||
| std::vector<uint32_t> src_rows_in_order; | ||
| src_rows_in_order.reserve(trace.get_column_rows(LookupSettings::SRC_SELECTOR)); | ||
| trace.visit_column(LookupSettings::SRC_SELECTOR, [&](uint32_t row, const FF& src_sel_value) { | ||
| assert(src_sel_value == 1); | ||
| (void)src_sel_value; // Avoid GCC complaining of unused parameter when asserts are disabled. | ||
| src_rows_in_order.push_back(row); | ||
| }); | ||
| trace.visit_column(LookupSettings::SRC_SELECTOR, | ||
| [&](uint32_t row, const FF&) { src_rows_in_order.push_back(row); }); | ||
| std::sort(src_rows_in_order.begin(), src_rows_in_order.end()); | ||
|
|
||
| for (uint32_t row : src_rows_in_order) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided this is kind of testing that visit_column works ok, so it's out of place here