Skip to content

fix(aztec-nr): check_notes_order lexicographic multi-key sort#21973

Merged
nchamo merged 6 commits into
merge-train/fairiesfrom
fix/check-notes-order-lexicographic
Apr 13, 2026
Merged

fix(aztec-nr): check_notes_order lexicographic multi-key sort#21973
nchamo merged 6 commits into
merge-train/fairiesfrom
fix/check-notes-order-lexicographic

Conversation

@nchamo

@nchamo nchamo commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Problem

check_notes_order in note_getter.nr validates each sort criterion independently instead of lexicographically. When multiple .sort() calls are used on NoteGetterOptions, each sort key is checked against adjacent notes regardless of whether a prior key already determined the ordering.

This means a valid lexicographic ordering like [A=1, B=10] then [A=2, B=5] sorted by (A ASC, B ASC) would fail: A passes (1 <= 2), but B fails (10 > 5), even though B is irrelevant because A already decided the order.

The oracle (sortNotes in pick_notes.ts) correctly implements lexicographic sorting via recursion, only advancing to the next sort key when values are equal. The constrained Noir verifier was out of sync with the oracle's behavior. Currently latent because no in-tree contract uses multiple sort keys.

Fixes F-490

@nchamo nchamo requested a review from nventuro as a code owner March 24, 2026 20:20
@nchamo nchamo self-assigned this Mar 24, 2026
@nchamo nchamo requested a review from mverzilli March 25, 2026 12:27
Base automatically changed from merge-train/fairies to next March 26, 2026 04:08
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
@nchamo nchamo changed the base branch from next to merge-train/fairies March 27, 2026 11:38
Base automatically changed from merge-train/fairies to next March 27, 2026 15:50
@nventuro nventuro requested a review from benesjan March 31, 2026 20:06
@nventuro

Copy link
Copy Markdown
Contributor

@benesjan can you take a look?

@nventuro nventuro changed the base branch from next to merge-train/fairies March 31, 2026 20:07
@benesjan benesjan force-pushed the fix/check-notes-order-lexicographic branch from 9073b78 to 8983bd5 Compare April 1, 2026 13:17

benesjan commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr

@benesjan benesjan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice!

Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/note_getter.nr Outdated
@AztecBot

Copy link
Copy Markdown
Collaborator

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/cbd9d28959250000�cbd9d289592500008;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/rediscovery.test.ts (129s) (code: 0) group:e2e-p2p-epoch-flakes

@nchamo nchamo merged commit a907987 into merge-train/fairies Apr 13, 2026
13 checks passed
@nchamo nchamo deleted the fix/check-notes-order-lexicographic branch April 13, 2026 12:57
@AztecBot

Copy link
Copy Markdown
Collaborator

✅ Successfully backported to backport-to-v4-next-staging #22492.

github-merge-queue Bot pushed a commit that referenced this pull request Apr 13, 2026
BEGIN_COMMIT_OVERRIDE
fix(aztec-nr): check_notes_order lexicographic multi-key sort (#21973)
END_COMMIT_OVERRIDE
AztecBot added a commit that referenced this pull request Apr 13, 2026
BEGIN_COMMIT_OVERRIDE
cherry-pick: chore: Update Noir to nightly-2026-04-10 (#22393)
chore: backport #22393 (Update Noir to nightly-2026-04-10) to v4-next
(#22485)
fix: add @aztec/accounts to backwards compatibility test infra (#22490)
fix(aztec-nr): check_notes_order lexicographic multi-key sort (#21973)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants