Skip to content

Conversation

@kashbrti
Copy link
Contributor

@kashbrti kashbrti commented Sep 2, 2025

a small PR doing the following as a part of the databus audit

  • added tests to check the handling of constant or unnormalized indexes
  • removed some ugliness with dangling witnesses and replaced them with set_variable
  • some minor cleanups

@kashbrti kashbrti changed the base branch from next to merge-train/barretenberg September 2, 2025 10:37
w_value = index.get_value();
value.assert_equal(calldata_array[index]);
if (!has_valid_witness_assignments) {
index.is_zero();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we actually need to do this? This if is only reached when mocking. We were already checking that the index value is zero with the copy constraint. But if it's only in mock cases, do we need to assert it's zero in circuit? I think the change I made causes issues because the mock would have an extra gate, so probably vk generation will be wrong

@kashbrti kashbrti requested a review from suyash67 September 2, 2025 11:03
@kashbrti kashbrti changed the title chore: small cleanups in databus chore: audit databus - small cleanups and tests coverage Sep 3, 2025
Copy link
Contributor

@ledwards2225 ledwards2225 left a comment

Choose a reason for hiding this comment

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

LG!

if (has_valid_witness_assignments) {
// If witness are assigned, we use the correct value for w
w_value = index.get_value();

Copy link
Contributor

Choose a reason for hiding this comment

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

much better! can you update the comment to say why this is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's a comment inside the if. but will add some extra explanation

* @brief An expository test demonstrating the functionality of the databus in a small use case when the entries are
* constant witnesses
*/
TEST(Databus, ConstantEntryAccess)
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if the read indices are constant witnesses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

handled in another test. I chucked both cases for the indices in the same test.

* @brief An expository test demonstrating the functionality of the databus in a small use case where the indices are
* constant and/or unnormalized
*/
TEST(Databus, ConstantAndUnnormalizedIndices)
Copy link
Contributor

Choose a reason for hiding this comment

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

ah!

@kashbrti kashbrti merged commit 99f9020 into merge-train/barretenberg Sep 5, 2025
6 checks passed
@kashbrti kashbrti deleted the kb/databus_small_refactor branch September 5, 2025 09:56
github-merge-queue bot pushed a commit that referenced this pull request Sep 5, 2025
BEGIN_COMMIT_OVERRIDE
chore: databus internal audit - small cleanups and tests coverage
(#16703)
chore: `stdlib::poseidon2` internal audit (#16534)
END_COMMIT_OVERRIDE
mralj pushed a commit that referenced this pull request Oct 13, 2025
…6703)

a small PR doing the following as a part of the `databus` audit
- added tests to check the handling of constant or unnormalized indexes 
- removed some ugliness with dangling witnesses and replaced them with
`set_variable`
- some minor cleanups
ludamad pushed a commit that referenced this pull request Dec 16, 2025
…6703)

a small PR doing the following as a part of the `databus` audit
- added tests to check the handling of constant or unnormalized indexes 
- removed some ugliness with dangling witnesses and replaced them with
`set_variable`
- some minor cleanups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants