Commit dcd1f65
authored
chore(aztec-nr): mark emit_event_in_public as #[inline_never] to shrink public dispatch (#23161)
## Summary
Work towards resolving
AztecProtocol/aztec-nr#35
- Mark `emit_event_in_public` `#[inline_never]` (and `unconstrained`,
required by the attribute) so it stops being copied into every public
call site.
- Propagate `unconstrained` to `ContractSelfPublic::emit` so it can
still call the helper.
- Mirrors the existing precedent on `assert_is_initialized_public`
(`aztec-nr/aztec/src/macros/functions/initialization_utils.nr:100`) from
#22869
## Bytecode impact
Measured via `nargo compile --inliner-aggressiveness 0` + `bb
aztec_process`, reading `public_dispatch` packed bytecode size on
`public_fns_with_emit_repro_contract`:
| State | AVM bytes | Δ |
|-------------------|-----------|----------------|
| Baseline | 5,576 | — |
| `#[inline_never]` | 4,601 | -975 (-17.5%) |
Roughly 65 bytes saved per emit call site across the 15 functions. Real
contracts with many public functions emitting the same event shape
should see the same per-site savings.
## Additional Context
- `--inliner-aggressiveness` cannot achieve this on its own: for
`public_dispatch` the noirc driver pins aggressiveness to 0
(`noir/noir-repo/compiler/noirc_driver/src/lib.rs:743-744`)
- `ContractSelfPublic::emit` becoming `unconstrained` is a small surface
change. All `#[external(\"public\")]` bodies are already unconstrained,
so contract code calling `self.emit(...)` directly is unaffected1 parent 28d61cd commit dcd1f65
2 files changed
Lines changed: 3 additions & 2 deletions
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
0 commit comments