Skip to content

feat(pxe): add class IDs and view context to auth request#23633

Merged
nchamo merged 4 commits into
merge-train/fairiesfrom
nchamo/f-641-improve-utilitycallauthorizationrequest-with-class-ids-and
May 29, 2026
Merged

feat(pxe): add class IDs and view context to auth request#23633
nchamo merged 4 commits into
merge-train/fairiesfrom
nchamo/f-641-improve-utilitycallauthorizationrequest-with-class-ids-and

Conversation

@nchamo
Copy link
Copy Markdown
Contributor

@nchamo nchamo commented May 28, 2026

Why

UtilityCallAuthorizationRequest included the caller and target contract addresses but not their class IDs. Without class IDs, hook authors couldn't verify the contract implementation behind a given address, making it impossible to write authorization policies based on what code a contract runs rather than just its identity.

Fix

Adds callerClassId and targetClassId to the authorization request so hooks can match on contract implementations. Also expands callerContext to distinguish 'private view' from 'private', makes functionName required (it was always available), and updates the docs to explain why cross-contract utility calls are restricted and how to authorize them in Noir tests.

Fixes F-641

@nchamo nchamo requested a review from nventuro as a code owner May 28, 2026 17:20
@nchamo nchamo self-assigned this May 28, 2026
The hook receives a `UtilityCallAuthorizationRequest` with the caller address, target address, function selector, function name, arguments, and caller context (`'private'` or `'utility'`). Return `{ authorized: true }` to allow or `{ authorized: false, reason: '...' }` to deny with a message.
The hook receives a `UtilityCallAuthorizationRequest` with the caller and target addresses, their contract class IDs, function selector, function name, arguments, and caller context (`'private'`, `'private view'`, or `'utility'`). Return `{ authorized: true }` to allow or `{ authorized: false, reason: '...' }` to deny with a message.

##### In Noir tests
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.

This was added in another PR, but we hadn't documented it properly

}

/// Authorizes cross-contract utility calls to the given target contracts during this call.
/// Authorizes cross-contract utility calls to given targets.
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 boss had asked to shorten these titles after the last PR was merged, so I'm doing it here

@nchamo nchamo requested a review from dbanks12 May 28, 2026 17:56
Copy link
Copy Markdown
Contributor

@dbanks12 dbanks12 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines -812 to +819
callerContext: ('isPrivate' in this ? 'private' : 'utility') as 'private' | 'utility',
callerContext: this.callerContext,
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.

much cleaner

Comment on lines +80 to +89
unconstrained fn cross_contract_utility_call_from_private_view_succeeds_with_authorization() {
let (env, account, addr_a, addr_b) = setup();

let result: Field = env.view_private_opts(
account,
ViewPrivateOptions::new().with_authorized_utility_call_targets([addr_b]),
NestedUtility::at(addr_a).delegate_pow_view(addr_b, 2, 3),
);
assert_eq(result, 8);
}
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.

okay so this is using auth for the NESTED utility call, right? So not for the top-level private view call, but the nested call to pow_utility? hence why the auth is for addr-b

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.

Exactly, all the tests here are for the nested utility calls

…/f-641-improve-utilitycallauthorizationrequest-with-class-ids-and

# Conflicts:
#	yarn-project/end-to-end/src/e2e_nested_utility_calls.test.ts
@nchamo nchamo enabled auto-merge (squash) May 29, 2026 18:14
@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/209f13c26472f68c�209f13c26472f68c8;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/duplicate_proposal_slash.test.ts (229s) (code: 0) group:e2e-p2p-epoch-flakes

@nchamo nchamo merged commit ccb2c58 into merge-train/fairies May 29, 2026
14 checks passed
@nchamo nchamo deleted the nchamo/f-641-improve-utilitycallauthorizationrequest-with-class-ids-and branch May 29, 2026 18:42
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