Skip to content

feat!: scoped capsule arrays#21588

Merged
mverzilli merged 9 commits into
martin/scoped-capsulesfrom
martin/default-to-scoped-capsules
Mar 23, 2026
Merged

feat!: scoped capsule arrays#21588
mverzilli merged 9 commits into
martin/scoped-capsulesfrom
martin/default-to-scoped-capsules

Conversation

@mverzilli

@mverzilli mverzilli commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

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

@mverzilli mverzilli marked this pull request as ready for review March 16, 2026 17:03
@mverzilli mverzilli requested a review from nventuro as a code owner March 16, 2026 17:03
@mverzilli mverzilli requested a review from Thunkar March 16, 2026 17:03
@mverzilli mverzilli requested a review from benesjan March 16, 2026 17:51

@benesjan benesjan left a comment

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.

Will properly review once this gets resolved but what came to my mind is that in the AcessScopes type we have ALL_SCOPES and here we call the same thing global scope or no scope. That should be aligned.

@mverzilli

Copy link
Copy Markdown
Contributor Author

Will properly review once this gets resolved but what came to my mind is that in the AcessScopes type we have ALL_SCOPES and here we call the same thing global scope or no scope. That should be aligned.

I see what you mean but I don't think they are the same thing (leaving aside naming difficulties): ALL_SCOPES denotes "all the addresses known to PXE", whereas what we're calling global here means "shared contract storage space"

@mverzilli mverzilli requested a review from nchamo March 17, 2026 12:04
Comment on lines +29 to +30
pub unconstrained fn at_global_scope(contract_address: AztecAddress, base_slot: Field) -> Self {
Self { contract_address, base_slot, scope: Option::none() }

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.

Omg it reaches so far outside of the internals. We need to get rid of global scopes asap. Would it make sense to do that now and then rebase this pr on top, without these bits?

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'm not sure I parse what you're proposing. I split the scoped capsules work in 3 logical step to make it easier to review and discuss implications of the changes, not necessarily to ship it in steps. So if what we want is to make sure that at_global_scope doesn't exist in the version we merge, I can:

  1. Tackle complete obliteration of global scopes in refactor: forbid globally scoped capsules #21614 (downstream of this)
  2. Once I get the whole stack approved, "fold" everything back on to feat!: scoped capsules #21533 (upstream of this)
  3. Merge the result, where global scopes won't exist anymore

Would that address your concern here?

@mverzilli mverzilli removed the request for review from Thunkar March 18, 2026 11:11
parameter. This enables multiple independent namespaces within the same contract's capsule storage. If you need to keep
the previous (global) behavior, call said methods with `Option::none()` as scope.

`CapsuleArray::at` now requires a `scope: AztecAddress` argument that isolates the array's data to that scope. For the previous (global) behavior, use the new `CapsuleArray::at_global_scope` constructor.

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.

Given that this goes away in #21614, eithre remove this from migration notes, or remove it here.

@mverzilli mverzilli merged commit 2698db9 into martin/scoped-capsules Mar 23, 2026
11 checks passed
@mverzilli mverzilli deleted the martin/default-to-scoped-capsules branch March 23, 2026 11:31
mverzilli added a commit that referenced this pull request Mar 24, 2026
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
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.

3 participants