Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

permission_registry source realm

Constants 1

const MaxResources, MaxResourcesPerAdmin, MaxPermissionsPerResource, MaxHoldersPerPermission, MaxNameLen, ReservationPeriod, MaxRenderResources, MaxRenderPermissions, MaxRenderHolders

 1const (
 2	// MaxResources bounds total registry state. Raised from the upstream
 3	// 200 as part of the R1 remediation: with a per-admin quota now
 4	// carrying the anti-monopoly duty, the global cap is a pure state
 5	// bound rather than the sole defense against namespace exhaustion.
 6	MaxResources = 1000
 7
 8	// MaxResourcesPerAdmin bounds how many resources one address may hold
 9	// at once. R1 (audit 2026-09-21): the upstream design had only a
10	// global cap on a permissionless shared registry, so one unprivileged
11	// key could occupy every slot for ~200 cheap transactions and
12	// permanently deny the registry to every other tenant. DeleteResource
13	// is admin-only, so the squat was irreversible.
14	MaxResourcesPerAdmin = 20
15
16	MaxPermissionsPerResource = 50
17	MaxHoldersPerPermission   = 200
18	MaxNameLen                = 64
19
20	// ReservationPeriod is how long a deleted resource name stays
21	// reserved. Finite (re-audit 2026-09-02): eternal tombstones let an
22	// attacker cycle create/delete to lock the namespace forever.
23	ReservationPeriod = int64(90 * 24 * 3600) // 90 days
24
25	// Render bounds (Y3, audit 2026-09-21). Render walks the whole
26	// registry and is reachable by any viewer through gnoweb and
27	// vm/qrender, so its cost is borne by third parties rather than by
28	// whoever grew the state. Uncapped, the declared limits allowed
29	// 1000*50*200 rendered holder entries. The full data stays available
30	// through ListResources / GetPermissions / Has, which are bounded per
31	// call by construction.
32	MaxRenderResources   = 20
33	MaxRenderPermissions = 8
34	MaxRenderHolders     = 10
35)
source

Functions 13

func AcceptAdmin

crossing Action
1func AcceptAdmin(cur realm, resourceName string)
source

AcceptAdmin completes a pending handoff; only the nominee may call it. The nominee's quota is checked HERE — at consent time — so a nomination can never push an account past MaxResourcesPerAdmin without that account agreeing to carry the resource.

func CancelAdminTransfer

crossing Action
1func CancelAdminTransfer(cur realm, resourceName string)
source

CancelAdminTransfer withdraws a pending nomination. Only the current admin can call this.

func CreateResource

crossing Action
1func CreateResource(cur realm, resourceName string)
source

CreateResource registers a new named resource. The caller becomes its admin and is the only address that can grant or revoke permissions on it. A deleted resource name stays reserved for its former admin and its original creator until the reservation expires.

Each address may administer at most MaxResourcesPerAdmin resources at once, and the registry holds at most MaxResources in total.

func DeleteResource

crossing Action
1func DeleteResource(cur realm, resourceName string)
source

DeleteResource removes a resource and every permission under it. Only the resource admin can call this. The name stays reserved for the caller and for the original creator: nobody else can re-create it and inherit its consumers until the reservation expires.

func GetAdmin

Action
1func GetAdmin(resourceName string) string
source

GetAdmin returns the admin address of a resource.

func GetPendingAdmin

Action
1func GetPendingAdmin(resourceName string) string
source

GetPendingAdmin returns the nominated admin awaiting acceptance for a resource, or "none".

func GetPermissions

Action
1func GetPermissions(resourceName string, addr address) string
source

GetPermissions returns all permission names granted to addr on a resource, as a comma-separated string. Returns "none" if the address has no permissions.

func Grant

crossing Action
1func Grant(cur realm, resourceName, permission string, addr address)
source

Grant gives an address a named permission on a resource. Only the resource admin can call this. Panics if the permission is already granted to avoid silent no-ops.

func Has

Action
1func Has(resourceName, permission string, addr address) bool
source

Has returns true if addr holds the named permission on the resource. Returns false (never panics) for unknown resources or permissions.

INTEGRATOR CONTRACT (Y7): Has takes the subject address explicitly and performs NO caller authentication — it answers "does this address hold this permission", not "may my caller do this". A consuming realm must derive addr from its own crossing entrypoint's cur.Previous().Address() and pass it in. Deriving it inside a non-crossing helper via unsafe.PreviousRealm() resolves the consumer's own caller's caller and is a Class-2 designation-forgery bug in the consumer.

func ListResources

Action
1func ListResources() string
source

ListResources returns all registered resource names as a comma-separated string in registration order. Returns "none" if no resources exist.

func Render

1func Render(path string) string
source

Render returns a markdown overview. Never panics. Output is bounded by MaxRenderResources / MaxRenderPermissions / MaxRenderHolders (Y3); truncated sections name the query to use for complete data.

func Revoke

crossing Action
1func Revoke(cur realm, resourceName, permission string, addr address)
source

Revoke removes a permission from an address. Only the resource admin can call this. Panics if the permission was not granted. A permission left with no holders is pruned from the resource's permission list.

func TransferAdmin

crossing Action
1func TransferAdmin(cur realm, resourceName string, newAdmin address)
source

TransferAdmin nominates a new admin for a resource. Only the current admin can call this, and the handoff does NOT take effect until the nominee calls AcceptAdmin.

Y4 (audit 2026-09-21): the upstream one-step transfer made a well-formed-but-unowned destination permanently fatal. address.IsValid only checks bech32 form, so a mistyped address passed the check and left the resource with an admin nobody controls — it could never again be granted on, revoked from, transferred or deleted, and its slot was lost from both the global cap and the former admin's quota forever. Nomination is reversible; only the nominee's consent is final.

Types 1

type Reservation

struct
1type Reservation struct {
2	Admin   address
3	Creator address
4	Expires time.Time
5}
source

Reservation holds a deleted resource name for its former admin AND its original creator, and expires.

Imports 5

  • chain/runtime/unsafe stdlib
  • sort stdlib
  • strconv stdlib
  • strings stdlib
  • time stdlib

Source Files 2