[New Permission 3/5] smartcontract: enforce Permission-based authorization in existing instructions#3206
Open
juan-malbeclabs wants to merge 4 commits into
Open
[New Permission 3/5] smartcontract: enforce Permission-based authorization in existing instructions#3206juan-malbeclabs wants to merge 4 commits into
juan-malbeclabs wants to merge 4 commits into
Conversation
fcc211f to
cb87d98
Compare
53175e4 to
7c2c64c
Compare
cb87d98 to
a6b59b4
Compare
7c2c64c to
5bdc49e
Compare
a6b59b4 to
cdf8668
Compare
elitegreg
reviewed
Mar 12, 2026
elitegreg
requested changes
Mar 12, 2026
de2986e to
426ea94
Compare
e63b15f to
8bc4aee
Compare
elitegreg
requested changes
Mar 13, 2026
48a5b44 to
5504a1f
Compare
- Add execute_authorized_transaction_quiet to DoubleZeroClient trait and DZClient impl, restoring quiet mode for ban and closeaccount commands that was lost when switching to execute_authorized_transaction - Restore onchain allocation support in CreateSubscribeUserCommand SDK command (feature-flag-gated ResourceExtension PDA logic removed in permission enforcement refactor) - Restore atomic path tests and fixture resource extension PDA fields in create_subscribe_user_test.rs
1a8d0db to
f9a4ff5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
authorize()into all existing instruction processors that require privileged access:accesspass/{close,set},multicastgroup/subscribe, anduser/{ban,closeaccount,create,create_subscribe,delete,requestban}— each processor now appends the caller's Permission PDA as an optional trailing accountprocessors/user/create_core.rs(328 lines) by absorbing its logic directly intocreate.rs, eliminating a layer of indirection that was only needed before the authorization refactorDZClient::build_and_send()helper in the Rust SDK that automatically checks for and appends the caller's Permission PDA as a trailing account when it exists on-chain, making permission account usage transparent to callersuser,tenant,accesspass,permission) to usebuild_and_send()so they automatically include the Permission accountDiff Breakdown
Net code reduction overall — the authorization refactor removed more duplication than it added.
Key files (click to expand)
smartcontract/programs/doublezero-serviceability/src/processors/user/create.rs— absorbscreate_core.rs, addsauthorize()call; now the single source of truth for user creationsmartcontract/programs/doublezero-serviceability/src/processors/user/create_subscribe.rs— refactored to callauthorize(), with account layout updated to accept optional trailing Permission PDAsmartcontract/sdk/rs/src/client.rs— newbuild_and_send()method: looks up caller's Permission PDA, appends it as a read-only trailing account if it exists, then signs and sends the transactionsmartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/subscribe.rs— addsauthorize()forACCESS_PASS_ADMINcheck; old inline allowlist check replacedsmartcontract/programs/doublezero-serviceability/src/processors/user/create_core.rs— deleted (328 lines); logic consolidated intocreate.rssmartcontract/sdk/rs/src/commands/user/create_subscribe.rs— gutted (299 lines removed) as the user-creation logic it duplicated is now fully in the program processorsmartcontract/programs/doublezero-serviceability/src/processors/accesspass/close.rs— addsauthorize()forACCESS_PASS_ADMINsmartcontract/sdk/rs/src/doublezeroclient.rs— addsget_permission_pda_for_payer()convenience method used bybuild_and_send()Testing Verification
tests/create_subscribe_user_test.rsupdated to reflect the simplified processor — existing passing tests confirm the create_core consolidation is behavior-preservingtests/permission_test.rs(from PR 3) covers theauthorize()enforcement paths invoked by these processorsmake rust-testpasses with all affected processors and SDK commands