Skip to content

[New Permission 5/5] smartcontract: enforce topology/resource/index permission flags#3943

Open
juan-malbeclabs wants to merge 1 commit into
jo/permission-trindex-flagsfrom
jo/permission-trindex-enforce
Open

[New Permission 5/5] smartcontract: enforce topology/resource/index permission flags#3943
juan-malbeclabs wants to merge 1 commit into
jo/permission-trindex-flagsfrom
jo/permission-trindex-enforce

Conversation

@juan-malbeclabs

@juan-malbeclabs juan-malbeclabs commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Permission rollout — stacked PR series. Review/merge order:

  1. #3206 — enforce Permission-based authorization in existing instructions
  2. #3942 — define topology/resource/index permission flags (3/4) — stacked on [New Permission 3/5] smartcontract: enforce Permission-based authorization in existing instructions #3206
  3. #3943 — enforce topology/resource/index permission flags (4/4) — stacked on [New Permission 4/5] smartcontract: define topology/resource/index permission flags #3942

Retarget each PR's base to main as its upstream merges.
👉 You are here: #3943 (PR 4/4).

Summary

  • Replaces the direct foundation_allowlist checks with authorize() in topology (create / delete / clear / assign-node-segments) → TOPOLOGY_ADMIN, resource (create / allocate / deallocate / close) → RESOURCE_ADMIN, and index (create / delete) → 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, so existing callers (controlplane, current SDK) keep working.
  • Switches the corresponding SDK commands to execute_authorized_transaction so the payer's Permission PDA is appended when it exists onchain.

Behavior change: the topology instructions now reject unauthorized callers with NotAllowed (Custom(8)) instead of Unauthorized (Custom(22)), since authorize() is the single rejection path; affected tests updated.

Depends on the 3/4 PR (stacked).

Testing Verification

  • New end-to-end test test_topology_create_with_permission_account_allowed: a non-foundation key holding TOPOLOGY_ADMIN creates a topology via its Permission account — exercises the new authorization path through a real processor.
  • topology / index / resource / permission integration suites pass; topology error-code assertions updated UnauthorizedNotAllowed.

Reference: smartcontract/programs/doublezero-serviceability/PERMISSION.md

…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.
@juan-malbeclabs juan-malbeclabs changed the title [New Permission 4/4] smartcontract: enforce topology/resource/index permission flags [New Permission 5/5] smartcontract: enforce topology/resource/index permission flags Jun 27, 2026
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.

1 participant