Skip to content

refactor!: merging event emission functions#16126

Merged
benesjan merged 1 commit intonextfrom
07-31-refactor_merging_event_emission_functions
Sep 1, 2025
Merged

refactor!: merging event emission functions#16126
benesjan merged 1 commit intonextfrom
07-31-refactor_merging_event_emission_functions

Conversation

@benesjan
Copy link
Copy Markdown
Contributor

@benesjan benesjan commented Jul 31, 2025

Summary

This PR consolidates the event emission API by merging emit_event_in_private_log and emit_event_as_offchain_message into a single emit_event_in_private function with configurable delivery modes.

Key Changes

  • Unified API: Replaced PrivateLogContentConstraintsEnum with MessageDeliveryEnum that provides clear delivery mode options
  • Two Primary Modes:
    • CONSTRAINED_ONCHAIN: Constrained encryption + tagging + private log stream (for smart contract decisions)
    • UNCONSTRAINED_OFFCHAIN: Unconstrained encryption + offchain delivery (for trusted/incentivized scenarios)
  • Enhanced Documentation: Comprehensive documentation explaining the three dimensions of message delivery (encryption constraints, delivery mechanism, tagging constraints) and their use cases
  • Backward Compatibility: Maintained UNCONSTRAINED_ONCHAIN mode for existing code (marked for future removal)

Benefits

  • Clearer Intent: Developers can now choose delivery modes based on their specific security and trust requirements
  • Simplified API: Single function handles all private event emission scenarios
  • Improved Security Model: Explicit guidance on when to use each delivery mode

Breaking Changes

  • emit_event_in_private_logemit_event_in_private
  • emit_event_as_offchain_messageemit_event_in_private with UNCONSTRAINED_OFFCHAIN mode
  • PrivateLogContentMessageDelivery

All contract examples and tests have been updated to use the new API.

Copy link
Copy Markdown
Contributor Author

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

Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
}
}

// TODO: rename to emit_event_in_public
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.

The naming is now inconsistent. Would the reviewer agree with the rename? If yes, will tackle in a followup PR.

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.

It's just the _log suffix no? Sure, I don't think it's very important. We may want to change these to be methods soon anyway.

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.

Sure, I don't think it's very important.

I thought you are a "cute code" kind of person 😔

We may want to change these to be methods soon anyway.

WDYM by this? Methods of context?

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.

Methods of the event type. So you'd do something like event.emit instead of emit_event(event)

Comment thread yarn-project/end-to-end/src/e2e_offchain_effect.test.ts
@benesjan benesjan marked this pull request as ready for review July 31, 2025 09:12
@benesjan benesjan changed the title refactor: merging event emission functions refactor!: merging event emission functions Jul 31, 2025
@benesjan benesjan requested a review from nventuro July 31, 2025 10:05
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/event/event_interface.nr Outdated
@benesjan benesjan marked this pull request as draft August 29, 2025 07:53
@benesjan benesjan force-pushed the 07-31-refactor_merging_event_emission_functions branch 3 times, most recently from 33bb6af to 6c58546 Compare September 1, 2025 07:51
@benesjan benesjan marked this pull request as ready for review September 1, 2025 08:05
@benesjan benesjan requested a review from nventuro September 1, 2025 08:57
Copy link
Copy Markdown
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the responses to the review comments!

}
}

// TODO: rename to emit_event_in_public
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.

Methods of the event type. So you'd do something like event.emit instead of emit_event(event)

@AztecBot AztecBot force-pushed the 07-31-refactor_merging_event_emission_functions branch from 6c58546 to 66dbaad Compare September 1, 2025 20:00
@AztecBot AztecBot enabled auto-merge September 1, 2025 20:00
## Summary
This PR consolidates the event emission API by merging `emit_event_in_private_log` and `emit_event_as_offchain_message` into a single `emit_event_in_private` function with configurable delivery modes.

## Key Changes
- **Unified API**: Replaced `PrivateLogContentConstraintsEnum` with `MessageDeliveryEnum` that provides clear delivery mode options
- **Two Primary Modes**:
  - `CONSTRAINED_ONCHAIN`: Constrained encryption + tagging + private log stream (for smart contract decisions)
  - `UNCONSTRAINED_OFFCHAIN`: Unconstrained encryption + offchain delivery (for trusted/incentivized scenarios)
- **Enhanced Documentation**: Comprehensive documentation explaining the three dimensions of message delivery (encryption constraints, delivery mechanism, tagging constraints) and their use cases
- **Backward Compatibility**: Maintained `UNCONSTRAINED_ONCHAIN` mode for existing code (marked for future removal)

## Benefits
- **Clearer Intent**: Developers can now choose delivery modes based on their specific security and trust requirements
- **Simplified API**: Single function handles all private event emission scenarios
- **Improved Security Model**: Explicit guidance on when to use each delivery mode

## Breaking Changes
- `emit_event_in_private_log` → `emit_event_in_private`
- `emit_event_as_offchain_message` → `emit_event_in_private` with `UNCONSTRAINED_OFFCHAIN` mode
- `PrivateLogContent` → `MessageDelivery`

All contract examples and tests have been updated to use the new API.
@AztecBot AztecBot force-pushed the 07-31-refactor_merging_event_emission_functions branch from 66dbaad to 0a136a7 Compare September 1, 2025 20:03
@AztecBot AztecBot added this pull request to the merge queue Sep 1, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2025
@benesjan benesjan added this pull request to the merge queue Sep 1, 2025
Merged via the queue into next with commit 59fdfe7 Sep 1, 2025
15 checks passed
@benesjan benesjan deleted the 07-31-refactor_merging_event_emission_functions branch September 1, 2025 22:20
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