Skip to content

Commit

Permalink
docs: clarify comment on collapse (#7038)
Browse files Browse the repository at this point in the history
Turns out it's very important to make sure the storage is indeed clean -
otherwise we could have `eq` return false for equivalent arrays.
  • Loading branch information
nventuro authored Jun 14, 2024
1 parent c6ab392 commit 6237ddd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions noir-projects/aztec-nr/aztec/src/utils.nr
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ fn verify_collapse_hints<T, N>(
}
last_index = Option::some(input_index);
} else {
// We don't technically need to check past the length of the BoundedVec since those slots should not be
// accessible, but its fairly cheap to prevent dirty data from being stored there.
assert_eq(collapsed.get_unchecked(i), dep::std::unsafe::zeroed(), "Dirty collapsed vec");
// BoundedVec assumes that the unused parts of the storage are zeroed out (e.g. in the Eq impl), so we make
// sure that this property holds.
assert_eq(collapsed.get_unchecked(i), dep::std::unsafe::zeroed(), "Dirty collapsed vec storage");
}
}
// We now know that:
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/utils/test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn verify_collapse_hints_wrong_vec_order() {
verify_collapse_hints(original, collapsed, collapsed_to_input_index_mapping);
}

#[test(should_fail_with="Dirty collapsed vec")]
#[test(should_fail_with="Dirty collapsed vec storage")]
fn verify_collapse_hints_dirty_storage() {
let original = [Option::some(7), Option::none(), Option::some(3)];

Expand Down

0 comments on commit 6237ddd

Please sign in to comment.