Skip to content

refactor(aztec-nr): Option-returning block hash membership witness oracle#23179

Merged
benesjan merged 1 commit into
jan/oxide_infra_depsfrom
jan/block-hash-witness-v2-option
May 12, 2026
Merged

refactor(aztec-nr): Option-returning block hash membership witness oracle#23179
benesjan merged 1 commit into
jan/oxide_infra_depsfrom
jan/block-hash-witness-v2-option

Conversation

@benesjan
Copy link
Copy Markdown
Contributor

Summary

  • Replaces aztec_utl_isBlockInArchive with aztec_utl_getBlockHashMembershipWitnessV2, which returns Option<MembershipWitness<ARCHIVE_HEIGHT>> instead of a bool. Callers wanting existence-only can use .is_some().
  • Exposes a new get_maybe_block_hash_membership_witness Noir wrapper for callers that want to handle absence.
  • Refactors get_block_hash_membership_witness to call the V2 oracle and .expect() on the Option, producing a richer panic message that includes the block hash and anchor block hash.
  • TXE and PXE handlers updated accordingly. The legacy V1 TS handlers are kept for now and marked with a TODO linking F-651 for follow-up cleanup once Noir-side callers (currently still pointing at the V1 oracle through get_block_hash_membership_witness) are migrated.
  • Adds direct in-tree Noir tests for both get_block_hash_membership_witness and get_maybe_block_hash_membership_witness (success path and unknown-hash path).
  • Flags get_note_hash_membership_witness with a TODO pointing at F-652 for analogous test coverage.

Motivation: discussion at #22979 (comment)aztec_utl_isBlockInArchive only existed because the witness oracle panicked on miss; the Option-returning V2 collapses that surface and lets callers handle absence in Noir.

Test plan

  • nargo test in noir-projects/aztec-nr/aztec — new tests in oracle::get_membership_witness::test pass (note: blocked locally by a pre-existing TXE bootstrap issue affecting all private_context tests; expect CI to run them cleanly).
  • yarn build in yarn-project — PXE and TXE packages build cleanly.

🤖 Generated with Claude Code

…s oracle

- Replace `aztec_utl_isBlockInArchive` with `aztec_utl_getBlockHashMembershipWitnessV2`, which returns `Option<MembershipWitness<ARCHIVE_HEIGHT>>`. Callers wanting existence-only can use `.is_some()`.
- Expose `get_maybe_block_hash_membership_witness` as a Noir wrapper around the V2 oracle.
- Refactor `get_block_hash_membership_witness` to call the V2 oracle and `.expect()` the Option, surfacing a richer error message that includes the block hash and anchor block hash.
- Update TXE and PXE handlers accordingly. The legacy V1 TS handlers are kept for now (TODO links to F-651 for cleanup).
- Add `mod test` covering both V1 and V2 wrappers (success path and unknown-hash path).
- Flag `get_note_hash_membership_witness` for follow-up tests (F-652).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@benesjan benesjan requested a review from nventuro as a code owner May 12, 2026 10:43
) -> MembershipWitness<NOTE_HASH_TREE_HEIGHT> {}

#[oracle(aztec_utl_getBlockHashMembershipWitness)]
#[oracle(aztec_utl_getBlockHashMembershipWitnessV2)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that us not using the aztec_utl_getBlockHashMembershipWitness here means that the TS implementation is now basically a dead code and not tested but given that the code there is almost the same as aztec_utl_getBlockHashMembershipWitnessV2 and given that it's only a few simple lines I am not worried about regression there that would rug people.

Comment on lines +49 to +55
pub unconstrained fn get_maybe_block_hash_membership_witness(
anchor_block_header: BlockHeader,
block_hash: Field,
) -> Option<MembershipWitness<ARCHIVE_HEIGHT>> {
let anchor_block_hash = anchor_block_header.hash();
is_block_in_archive_oracle(anchor_block_hash, block_hash)
get_block_hash_membership_witness_oracle(anchor_block_hash, block_hash)
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Decided to expose this function along with get_note_hash_membership_witness because I think for most of the use-cases people will just want to use get_note_hash_membership_witness. But if they want to handle the none case or just use this to check for existence (like oxide does) or to have a custom error message they can use this one.

get_block_hash_membership_witness_oracle(anchor_block_hash, block_hash)
}

mod test {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This PR was a good opportunity to sneak in some tests. Created a separate issue for the get_note_hash_membership_witness function as sneaking tests of that in here is too unrelated.

@benesjan benesjan requested review from mverzilli and removed request for nventuro May 12, 2026 11:07
Comment thread noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr
Copy link
Copy Markdown
Contributor

@mverzilli mverzilli left a comment

Choose a reason for hiding this comment

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

Looks good, just a nit on naming

@benesjan benesjan merged commit a7e77c5 into jan/oxide_infra_deps May 12, 2026
11 checks passed
@benesjan benesjan deleted the jan/block-hash-witness-v2-option branch May 12, 2026 11:31
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.

2 participants