[New Permission 1/5] smartcontract: scaffold Permission account state and instruction variants#3204
Open
juan-malbeclabs wants to merge 1 commit intomainfrom
Open
[New Permission 1/5] smartcontract: scaffold Permission account state and instruction variants#3204juan-malbeclabs wants to merge 1 commit intomainfrom
juan-malbeclabs wants to merge 1 commit intomainfrom
Conversation
This was referenced Mar 9, 2026
elitegreg
approved these changes
Mar 9, 2026
Contributor
elitegreg
left a comment
There was a problem hiding this comment.
Left one comment you should addess
| None = 0, | ||
| Activated = 1, | ||
| Suspended = 2, | ||
| Deleting = 3, |
Contributor
There was a problem hiding this comment.
I don't think we need a deleting status. That's state logic was only really needed for transitioning through the activator.
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
Permissionaccount type: Borsh-serialized state with owner, status (None/Activated/Suspended/Deleting), user_payer, and au128permissions bitmaskpermission_flagsconstants covering 15 roles across four tiers (governance, infra management, operational, technical/automated)CreatePermission,UpdatePermission,SuspendPermission,ResumePermission,DeletePermission— dispatched through the entrypoint but returningInvalidInstructionData(stub processors to be filled in the next PR)RequirePermissionAccountsfeature flag (bit 1) that, when set, disables the legacy GlobalState allowlist/authority fallback in favor of Permission-based authorizationSEED_PERMISSIONPDA seed andget_permission_pda()helperDiff Breakdown
Roughly equal split between new state definition/supporting infrastructure and boilerplate processor/dispatch scaffolding.
Key files (click to expand)
smartcontract/programs/doublezero-serviceability/src/state/permission.rs— newPermissionstruct,PermissionStatusenum,permission_flagsbitmask constants,TryFrom<&[u8]>/TryFrom<&AccountInfo>deserialization,Validateimplsmartcontract/programs/doublezero-serviceability/src/instructions.rs— five newDoubleZeroInstructionvariants (97–101) with args structs, dispatch matching, name/debug helpers, and roundtrip testssmartcontract/programs/doublezero-serviceability/src/state/accountdata.rs—AccountData::Permissionvariant,get_permission()accessor,TryFrom<&[u8]>armsmartcontract/programs/doublezero-serviceability/src/entrypoint.rs— routes the five new instruction variants to stub processorssmartcontract/programs/doublezero-serviceability/src/state/feature_flags.rs— addsRequirePermissionAccountsflag (bit 1) with string serializationsmartcontract/programs/doublezero-serviceability/src/pda.rs—get_permission_pda()usingSEED_PERMISSION+ user_payersmartcontract/programs/doublezero-serviceability/src/state/accounttype.rs—AccountType::Permission = 15Testing Verification
make rust-testpasses with the new instruction variants in place