[New Permission 5/5] smartcontract: enforce topology/resource/index permission flags#3943
Open
juan-malbeclabs wants to merge 1 commit into
Open
[New Permission 5/5] smartcontract: enforce topology/resource/index permission flags#3943juan-malbeclabs wants to merge 1 commit into
juan-malbeclabs wants to merge 1 commit into
Conversation
…ermission flags Replace the direct foundation_allowlist checks in the topology (create/delete/clear/assign-node-segments), resource (create/allocate/deallocate/close), and index (create/delete) instructions with authorize() calls requesting TOPOLOGY_ADMIN/RESOURCE_ADMIN/INDEX_ADMIN. The Permission account is read as the optional trailing account; the variable-length clear and assign-node-segments layouts detect it by PDA match before consuming their link/device lists. Backward compatible: with no Permission account the legacy foundation path still applies. Switch the corresponding SDK commands to execute_authorized_transaction so the payer's Permission PDA is appended when it exists, and add an end-to-end test covering topology creation via a TOPOLOGY_ADMIN Permission account.
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
foundation_allowlistchecks withauthorize()in topology (create/delete/clear/assign-node-segments) →TOPOLOGY_ADMIN, resource (create/allocate/deallocate/close) →RESOURCE_ADMIN, and index (create/delete) →INDEX_ADMIN.Permissionaccount is read as the optional trailing account; the variable-lengthclearandassign-node-segmentslayouts detect it by PDA match before consuming their link/device lists.Permissionaccount the legacy foundation path still applies, so existing callers (controlplane, current SDK) keep working.execute_authorized_transactionso the payer'sPermissionPDA is appended when it exists onchain.Behavior change: the topology instructions now reject unauthorized callers with
NotAllowed(Custom(8)) instead ofUnauthorized(Custom(22)), sinceauthorize()is the single rejection path; affected tests updated.Depends on the 3/4 PR (stacked).
Testing Verification
test_topology_create_with_permission_account_allowed: a non-foundation key holdingTOPOLOGY_ADMINcreates a topology via itsPermissionaccount — exercises the new authorization path through a real processor.Unauthorized→NotAllowed.Reference:
smartcontract/programs/doublezero-serviceability/PERMISSION.md