[New Permission 2b/5] smartcontract: implement Permission account CRUD#3209
Open
juan-malbeclabs wants to merge 1 commit intojo/permission-authorizefrom
Open
[New Permission 2b/5] smartcontract: implement Permission account CRUD#3209juan-malbeclabs wants to merge 1 commit intojo/permission-authorizefrom
juan-malbeclabs wants to merge 1 commit intojo/permission-authorizefrom
Conversation
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
Err(InvalidInstructionData)placeholders from the scaffolding PR with full implementationsauthorize()requiringPERMISSION_ADMIN;createadditionally requiresPERMISSION_ADMINon the caller's own Permission account (or falls back to foundation allowlist)PERMISSION.md: permission model reference, flag definitions, authorization rules, legacy mapping table, and CLI usage examplestests/permission_test.rs: program-level integration tests covering the full CRUD lifecycle, authorization enforcement, and edge cases (double-create, suspend-then-resume, delete-when-suspended, unauthorized access)Diff Breakdown
Tests account for nearly half the diff — processor logic and test coverage are roughly balanced.
Key files (click to expand)
smartcontract/programs/doublezero-serviceability/src/processors/permission/create.rs— validates PDA, checks for double-create, callsauthorize(PERMISSION_ADMIN), writesPermissionaccount on-chainsmartcontract/programs/doublezero-serviceability/src/processors/permission/update.rs— replaces bitmask, callsauthorize(PERMISSION_ADMIN)smartcontract/programs/doublezero-serviceability/src/processors/permission/suspend.rs— transitionsActivated → Suspendedsmartcontract/programs/doublezero-serviceability/src/processors/permission/resume.rs— transitionsSuspended → Activatedsmartcontract/programs/doublezero-serviceability/src/processors/permission/delete.rs— transitions toDeleting, reclaims lamportssmartcontract/programs/doublezero-serviceability/tests/permission_test.rs— full lifecycle tests, authorization failure casessmartcontract/programs/doublezero-serviceability/PERMISSION.md— permission model referenceTesting Verification
tests/permission_test.rscovers: create/update/suspend/resume/delete success paths, unauthorized caller rejection, double-create rejection, state transition invariantsmake rust-testpasses with all new tests