Skip to content

feat!: scoped capsules#21533

Merged
mverzilli merged 157 commits into
merge-train/fairiesfrom
martin/scoped-capsules
Mar 25, 2026
Merged

feat!: scoped capsules#21533
mverzilli merged 157 commits into
merge-train/fairiesfrom
martin/scoped-capsules

Conversation

@mverzilli

@mverzilli mverzilli commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Expands capsules to be addressed not only by contract address but also by scope. This changes loadCapsule, storeCapsule, deleteCapsule, and copyCapsule through various layers, in most cases by introducing a new scope param. This means different things at different layers:

  • CapsuleStore changes how it creates DB row keys to store capsule content, by adding the scope address as part of key computation. Address=ZERO then becomes global scope. Note this means legacy behavior is possible by providing a zero scope (though this should be frowned upon).
  • Corresponding oracles now take a scope param.
  • Transient capsules are also given optional scopes. I initially intended to leave them untouched, but given we currently shadow them with stored capsules on load, that would have caused behavioral drift.

CapsuleArray

  • Makes CapsuleArray's scope aware.
  • Makes CapsuleArray::at work only with explicit scopes, intended to be the default

Contract sync

Contract sync flows rely heavily on capsules so as a ripple of this change we move from a "per contract" sync, to a "per contract and scope" sync. This in turn resulted in simplification of some ad-hoc types such as MessageContext, NoteValidationRequest and EventValidationRequest.

Offchain processing

This is the original canary that triggered this refactor: it was not possible to cleanly implement offchain inboxes isolated by recipient. Since now capsules are always scoped, this is issue gets organically resolved by dispatching messages to different capsules based on each message's recipient.

Closes F-456
Closes F-457
Closes F-458
Closes F-459

@mverzilli mverzilli removed request for Thunkar and nchamo March 23, 2026 11:29
Second part of implementing scopes in capsules. First part at:
#21533

- Makes CapsuleArray's scope aware.
- Introduces a `CapsuleArray::at_global_scope` that defaults to
no-scope, which provides the legacy, unscoped behavior
- Replaces all usages of `CapsuleArray::at` with
`CapsuleArray::at_global_scope`, to allow future PRs to deal with each
case
- Makes `CapsuleArray::at` work only with explicit scopes, intended to
be the default

Closes F-458
Depends on #21588

Uses the new scoped functionalities of capsules from as many places in
the codebase as possible

Note: this PR makes the distinction between stored capsules and volatile
arrays even more painfully clear, as capsules used just for rpc comms
between Aztec.nr and PXE don't really need a scope but at the same time
would be better off not being global to remove concurrency constraints

Closes F-459
@mverzilli mverzilli merged commit 3029216 into merge-train/fairies Mar 25, 2026
25 checks passed
@mverzilli mverzilli deleted the martin/scoped-capsules branch March 25, 2026 09:08
@AztecBot

Copy link
Copy Markdown
Collaborator

❌ Failed to cherry-pick to v4-next due to conflicts. (🤖) View backport run.

AztecBot added a commit that referenced this pull request Mar 25, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Mar 25, 2026
BEGIN_COMMIT_OVERRIDE
fix: interactions clean up (#21933)
fix(stdlib): decode `EthAddress`, `FunctionSelector` and wrapped field
structs in `AbiDecoder` (#21926)
fix: bot gas estimations (#21945)
refactor(aztec-nr): use logging wrappers in
compute_note_hash_and_nullifier (#21897)
feat: add error page mapping for incompatible oracles (#21943)
fix(pxe): robust error handling in message processing (#21093)
fix: make PXE#getSyncedBlockHeader a concurrency=1 job to prevent IDB tx
liveness issues (#21944)
fix(aztec-up): validate semver in uninstall to prevent path traversal
(#21892)
fix(aztec-up): add truncation protection to install scripts (#21896)
feat!: scoped capsules (#21533)
END_COMMIT_OVERRIDE
mverzilli pushed a commit that referenced this pull request Mar 25, 2026
## Summary

Backport of #21533
(feat!: scoped capsules) to v4-next.

The automatic cherry-pick failed due to conflicts in 7 files. This PR
preserves the full cherry-pick history:

1. **Cherry-pick with conflicts** — raw cherry-pick of `3029216084` with
conflict markers committed as-is
2. **Conflict resolution** — resolved all 7 conflicted files:
- `docs/docs-developers/docs/resources/migration_notes.md` — added new
migration notes under TBD
- `noir-projects/aztec-nr/aztec/src/macros/aztec.nr` — took PR's
`$offchain_inbox_sync_option` macro variable + `scope` param
- `noir-projects/aztec-nr/aztec/src/messages/discovery/mod.nr` — added
`scope` param to `get_private_logs` call
-
`yarn-project/pxe/src/contract_function_simulator/noir-structs/message_tx_context.ts`
— accepted deletion (PR removes this file)
-
`yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution.test.ts`
— renamed method + added scope param
- `yarn-project/pxe/src/logs/log_service.ts` — took PR's simplified
single-recipient approach, moved deduplication into
`#getSecretsForSenders`
- `yarn-project/pxe/src/oracle_version.ts` — took PR's oracle interface
hash
3. **Build fixes** — added missing `offchain_inbox_sync_option` variable
definition and updated `generate_sync_state` function signature in
`aztec.nr`

ClaudeBox log: https://claudebox.work/s/358dd3e35e1d8542?run=1
nchamo added a commit that referenced this pull request Mar 26, 2026
BEGIN_COMMIT_OVERRIDE
feat!: scoped capsules (backport #21533) (#21986)
feat(aztec-nr): add initialization check to utility functions (#21751)
refactor(aztec-nr): remove storage from init_test_contract (#21996)
fix(p2p): check peer rate limit before global to prevent quota
starvation (#21997)
chore: remove claude file (#22012)
fix: disallow infinite pubkeys (#22026)
END_COMMIT_OVERRIDE
github-merge-queue Bot pushed a commit that referenced this pull request Mar 27, 2026
Reverting [bad decision of
mine](#21533 (comment))
from a while ago.

## Summary
- Copies the version oracle into `aztec_sublib` so it no longer depends
on the `aztec` (aztecnr) crate
- Removes the `aztec` dependency from `aztec_sublib/Nargo.toml`
- Makes `aztec_sublib` fully independent, allowing it to be audited and
versioned separately from aztecnr

Resolves
https://linear.app/aztec-labs/issue/F-466/extract-oracles-mod-specifically-for-aztec-sublib

## Test plan
- [x] `nargo check --package fee_juice_contract` compiles successfully
- [x] No remaining `aztec::` imports in aztec_sublib

🤖 Generated with [Claude Code](https://claude.com/claude-code)
AztecBot pushed a commit that referenced this pull request Mar 27, 2026
Reverting [bad decision of
mine](#21533 (comment))
from a while ago.

## Summary
- Copies the version oracle into `aztec_sublib` so it no longer depends
on the `aztec` (aztecnr) crate
- Removes the `aztec` dependency from `aztec_sublib/Nargo.toml`
- Makes `aztec_sublib` fully independent, allowing it to be audited and
versioned separately from aztecnr

Resolves
https://linear.app/aztec-labs/issue/F-466/extract-oracles-mod-specifically-for-aztec-sublib

## Test plan
- [x] `nargo check --package fee_juice_contract` compiles successfully
- [x] No remaining `aztec::` imports in aztec_sublib

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants