Skip to content

feat: upstream oxide aztec-nr changes#22979

Merged
benesjan merged 20 commits into
backport-to-v4-next-stagingfrom
jan/oxide_infra_deps
May 12, 2026
Merged

feat: upstream oxide aztec-nr changes#22979
benesjan merged 20 commits into
backport-to-v4-next-stagingfrom
jan/oxide_infra_deps

Conversation

@benesjan
Copy link
Copy Markdown
Contributor

@benesjan benesjan commented May 6, 2026

Does the following changes to Aztec.nr to make https://github.com/aztec-labs-eng/oxide possible:

  1. New aztec_utl_getTxEffect oracle - needed by oxide's custom message handler that implements custom TEE-related validation logic,
  2. new aztec_utl_isBlockInArchive oracle - once again needed to verify that the TEE output is legit,
  3. exposing various note message processing functionality - the custom message handler in oxide is fully compatible with the standard note message processing flow (the flow for PRIVATE_NOTE_MSG_TYPE_ID) but it layers the TEE-related validation on top. This means that most of the functionality in Aztec.nr related to PRIVATE_NOTE_MSG_TYPE_ID` was valuable there as well.

Resolves GK-563.

Originally implemented by @sirasistant in arv/oxide_infra_deps to make https://github.com/aztec-labs-eng/oxide possible. I just polished some stuff and implemented tests.

@benesjan benesjan marked this pull request as draft May 6, 2026 07:51
Comment thread noir-projects/aztec-nr/aztec/src/messages/processing/mod.nr
Comment thread noir-projects/aztec-nr/aztec/src/note/confirmed_note.nr
Comment thread docs/docs-developers/docs/resources/migration_notes.md
pub fn encode_private_note_message<Note>(
/// Shared encoder used by [`encode_private_note_message`] and by custom message handlers that use the same format as
/// standard private note message but perform additional validation logic.
pub fn encode_private_note_message_with_msg_type_id<Note>(
Copy link
Copy Markdown
Contributor Author

@benesjan benesjan May 11, 2026

Choose a reason for hiding this comment

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

This is admittedly a bit messy and I am not sure it will survive long-term but I exposed this because in oxide there we have a custom message handler that triggers the standard note message processing pipeline while performing additional logic.

This means that there we have a message encoded exactly the same way as PRIVATE_NOTE_MSG_TYPE_ID message but it travels here via the custom message handler.

Maybe with time we will want to create some standard for a custom message handler that triggers default aztec-nr message handlers but it's too soon for that so think this "messyness" is justified for now.

Copy link
Copy Markdown
Contributor

@mverzilli mverzilli May 12, 2026

Choose a reason for hiding this comment

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

This makes sense 👍. The only thing that I find a bit strange now is that this source file lives under messages/logs.

I don't see the connection with logs, this all seems to be purely about putting notes inside messages

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 being under logs is a pure tech debt from times where the separation between log and messages didn't really exist.

I remember Nico was doing some restructurings like a year ago.

@nventuro was this just forgotten?

Comment thread noir-projects/aztec-nr/aztec/src/note/lifecycle.nr
Comment thread noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/oracle/message_processing.nr
Comment thread yarn-project/txe/src/rpc_translator.ts
Comment thread yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts
@benesjan benesjan marked this pull request as ready for review May 11, 2026 15:35
@benesjan benesjan requested a review from Thunkar as a code owner May 11, 2026 16:03
@benesjan benesjan added claudebox Owned by claudebox. it can push to this PR. ci-draft Run CI on draft PRs. labels May 11, 2026
@benesjan benesjan marked this pull request as draft May 11, 2026 17:38
@benesjan benesjan marked this pull request as ready for review May 11, 2026 18:56
@benesjan benesjan requested review from mverzilli and removed request for LeilaWang and Thunkar May 11, 2026 18:57
Comment thread yarn-project/end-to-end/package.json
Comment on lines +798 to +807
if (txHash.hash.isZero()) {
throw new Error('Invalid tx hash passed into aztec_utl_getTxEffect oracle handler');
}

const txEffect = await this.aztecNode.getTxEffect(txHash);
if (!txEffect || txEffect.l2BlockNumber > this.anchorBlockHeader.getBlockNumber()) {
return null;
}

return txEffect.data;
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.

I don't have context on oxide, so maybe dumb questions, but:

  1. how often will this oracle be invoked?
  2. how often will this oracle be invoked trying to read the same tx effect?

considering we've been trying to get a bit more economical about rpc's, should we consider caching right from the get go? (probably easier to do now than waiting for Grego to get grumpy and having to try to detect these throughout the codebase :P)

Copy link
Copy Markdown
Contributor Author

@benesjan benesjan May 12, 2026

Choose a reason for hiding this comment

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

The oracle is only invoked here and it's triggered only when a note is being delivered. So I would say it's fine as I would not expect users to have that many incoming notes (zk.money is basically a payments app).

Anyway, summoning @Thunkar to give him a chance to contribute some grumpiness to this discussion.

Update: Fixed the link

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.

I think the link is broken. This is 100% going to become an issue for zkmoney, but we can defer optimizations provided this doesn't affect our regular sync flow.

Caching txeffects could be problematic, since we can only be sure of "dropped" status (pending can change at any moment and success can be rekt by a reorg)

Copy link
Copy Markdown
Contributor Author

@benesjan benesjan May 12, 2026

Choose a reason for hiding this comment

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

Caching txeffects could be problematic, since we can only be sure of "dropped" status

Oxide doesn't use the tx status in any way but somehow reflecting that in the API is probably not feasible.

It sucks that the message processing is serial here as this gets triggered in a loop by sync_state.

(so indeed might turn out to be a problem eventually for people receiving a lot of payments)

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.

Nice! Thanks for the in-PR comments, they really provided context that made reviewing more straightforward

…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>
…acle (#23179)

## 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](https://linear.app/aztec-labs/issue/F-651/replace-aztec-utl-getblockhashmembershipwitness-with-aztec-utl)
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](https://linear.app/aztec-labs/issue/F-652/implement-noir-tests-of-aztec-utl-getnotehashmembershipwitness)
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](https://claude.com/claude-code)
@benesjan benesjan enabled auto-merge (squash) May 12, 2026 11:32
@benesjan benesjan merged commit 807d927 into backport-to-v4-next-staging May 12, 2026
11 checks passed
@benesjan benesjan deleted the jan/oxide_infra_deps branch May 12, 2026 11:32
benesjan added a commit that referenced this pull request May 12, 2026
This PR accumulates backport commits throughout the day and will be
auto-merged overnight.

Latest backport: #22979 - feat: upstream oxide aztec-nr changes

🤖 This PR is managed automatically by the backport workflow.
benesjan added a commit that referenced this pull request May 12, 2026
Forward port of #22979 (merged into `backport-to-v4-next-staging`) onto
`merge-train/fairies`.

---------

Co-authored-by: sirasistant <sirasistant@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants