Skip to content

feat: testing private events from Aztec.nr#20640

Draft
benesjan wants to merge 22 commits intonextfrom
02-18-feat_testing_private_events_from_aztec.nr
Draft

feat: testing private events from Aztec.nr#20640
benesjan wants to merge 22 commits intonextfrom
02-18-feat_testing_private_events_from_aztec.nr

Conversation

@benesjan
Copy link
Copy Markdown
Contributor

@benesjan benesjan commented Feb 18, 2026

Note: We will probably want to merge Serialize and Deserialize traits before merging this as it would make the diff smaller - waiting for response from Mitch to see whether it's a good time to do that change.

Closes https://linear.app/aztec-labs/issue/F-300/feature-access-events-in-aztecnr-tests

Copy link
Copy Markdown
Contributor Author

benesjan commented Feb 18, 2026

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

@benesjan benesjan force-pushed the 02-18-feat_testing_private_events_from_aztec.nr branch from e3ee438 to 21ff0cc Compare February 18, 2026 14:12
@benesjan benesjan force-pushed the 02-18-feat_testing_private_events_from_aztec.nr branch from 557d5c7 to 58006da Compare February 20, 2026 08:12
@benesjan benesjan changed the base branch from merge-train/fairies to graphite-base/20640 February 20, 2026 12:02
@benesjan benesjan force-pushed the 02-18-feat_testing_private_events_from_aztec.nr branch from 58006da to 7d799f3 Compare February 20, 2026 12:02
@benesjan benesjan changed the base branch from graphite-base/20640 to 02-20-fix_txe_committing_after_txs February 20, 2026 12:03
@benesjan benesjan force-pushed the 02-18-feat_testing_private_events_from_aztec.nr branch from 7d799f3 to 74001a2 Compare February 20, 2026 12:06
@benesjan benesjan added ci-draft Run CI on draft PRs. and removed ci-draft Run CI on draft PRs. labels Feb 20, 2026
Base automatically changed from 02-20-fix_txe_committing_after_txs to merge-train/fairies February 23, 2026 10:19
@benesjan benesjan force-pushed the 02-18-feat_testing_private_events_from_aztec.nr branch from 74001a2 to 7dc8ff2 Compare February 26, 2026 04:43
@benesjan benesjan marked this pull request as ready for review February 26, 2026 04:58
@benesjan benesjan requested review from nchamo and removed request for LeilaWang and nventuro February 26, 2026 06:00
@benesjan
Copy link
Copy Markdown
Contributor Author

@nchamo LMK if you would not feel comfortable enough yet to review this. Can re-assing if that's the case.

Copy link
Copy Markdown
Contributor

@nchamo nchamo left a comment

Choose a reason for hiding this comment

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

Great improvement!

// experimental
pub(crate) unconstrained fn get_private_events(
selector: EventSelector,
pub unconstrained fn get_private_events<Event>(
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.

Suggested change
pub unconstrained fn get_private_events<Event>(
/// Experimental - there may be breaking API changes.
pub unconstrained fn get_private_events<Event>(

We want to somehow flag this. I imagine something like get_private_events will very likely take some sort of filter or something.

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.

If we're making this pub, we should also at the very least document that we only search for events in the last block.

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.

Added the docs in f575bfa and this how they get rendered:

image

Do you like it?

BTW do you know if there is a way how the MAX_PRIVATE_EVENTS_PER_TXE_QUERY constant could get rendered there? I tried to Claude it but it says there is no way.

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.

Hmm I wishit were more obvious. Perhaps we could do horizontal separators with ---?

like
---
this

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.

I don't follow. What is supposed to be more obvious? And where do you want me to place the separator?

from: AztecAddress,
to: AztecAddress,
amount: u128,
pub struct Transfer {
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.

We probably want to either make all of these pub, or suggest that they are made pub.

Copy link
Copy Markdown
Contributor Author

@benesjan benesjan Feb 27, 2026

Choose a reason for hiding this comment

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

Documented this in 908c4d6

Is that would you meant by suggesting making them pub, right?

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 meant that the event macro should do it, linking to the doc piece you just wrote. We don't need pub though do we?

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.

I was originally hesitant to make the event macro apply the pub there as it makes it feel a bit more magical (events are just structs but with some extra stuff) but given that by definition they are a piece of data to be consumed by "the world out of the contract" I came to agree that it makes sense to not be annoying here and just auto-expose it.

Addressed in 6da2825

But I have one question about this:

linking to the doc piece you just wrote

Isn't it strange to link from the event macro code docs to the doc piece I wrote given that the event macro docs are way more "low-level"? Or is that not what you meant?

@benesjan benesjan marked this pull request as draft February 27, 2026 03:49
@benesjan benesjan force-pushed the 02-18-feat_testing_private_events_from_aztec.nr branch from 3660419 to 908c4d6 Compare February 27, 2026 06:25
@benesjan benesjan marked this pull request as ready for review February 27, 2026 07:04
@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/a319774110c064b4�a319774110c064b48;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/duplicate_attestation_slash.test.ts (152s) (code: 0) group:e2e-p2p-epoch-flakes

@benesjan benesjan requested a review from nventuro February 27, 2026 07:25
Comment on lines +86 to +87
/// Returns up to `MAX_PRIVATE_EVENTS_PER_TXE_QUERY` private events of type `Event` that were emitted by
/// `contract_address` and available in `scope`.
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.

This is inaccurate as it is missing the fact that it only searches the last block. It also does not explain wtf scope is.

Copy link
Copy Markdown
Contributor Author

@benesjan benesjan Mar 5, 2026

Choose a reason for hiding this comment

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

Somewhat addressed in 3361896

But I am not sure about this:

This is inaccurate as it is missing the fact that it only searches the last block.

Do you mean by that "up to last block"?

By searching only the last block I imagine events emitted in the last block. Or is your mental model here that "last block" contains any state that got accumulated by the chain up to that block?

I don't know the code of TXE enough to be sure here.

@benesjan benesjan marked this pull request as draft March 4, 2026 10:45
benesjan and others added 10 commits March 4, 2026 11:46
Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
Wraps the low-level oracle so users don't need to import and call the
oracle directly. This provides a higher-level API consistent with the
rest of TestEnvironment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Short first paragraph, clarify that only last block is searched, explain
what scope means (event recipient), mention self.emit, and point users
to TestEnvironment method instead of using the oracle directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move experimental warning to top of section as a note block. Use
env.get_private_events instead of importing the oracle directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@benesjan
Copy link
Copy Markdown
Contributor Author

benesjan commented Mar 5, 2026

@nventuro Re-requested a review here even though the PR is not yet finished as I need some clarifications - left the questions in unresolved discussions above.

Also please LMK if merging merge-train/fairies to this branch messed up the Github view of "changes since last review". If it messed it up I will wait with resolving conflicts for after the review finishes next time.

@benesjan benesjan requested a review from nventuro March 5, 2026 05:17
Base automatically changed from merge-train/fairies to next March 26, 2026 04:08
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.

4 participants