VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

Smart-Contract Role Administration: Trace Reachable Powers and Recovery Limits

Three students in school uniforms work through open books at a classroom table, with textbooks and stationery nearby and study notes on the whiteboard behind them.

中文版 · Blockchain learning guide · Previous article

Blockchain learning · Extension BCX014

Three students in school uniforms work through open books at a classroom table, with textbooks and stationery nearby and study notes on the whiteboard behind them.
Study photograph for illustration; it does not establish that the pictured students are studying blockchain.

A principal can lack permission to edit a record now and still have an authorized route to acquire that permission. Conversely, removing its editor role may accomplish little if it retains the power to grant that role back to itself. A useful access review therefore asks two questions: what does the current membership state permit, and which membership states can the permitted actors reach?

This lesson answers both questions with a complete, small model. Three fictional principals administer a catalogue annotation system. We follow actual membership changes, find the shortest paths to writer permission, distinguish two different revocation outcomes, and prove a limited recovery result. No wallet, real contract, secret, deployment or live privilege change is involved.

The model is deliberately closed. Its negative conclusions depend on the complete rules supplied here. They are not a diagnosis of an unknown deployed application, and a permitted technical transition does not establish organisational approval or anybody’s intention to use it.

Choose your reading route

In this guide

  • To distinguish current permission from future capability, read sections 1–4.
  • To understand why some removals fail to remove reachable power, follow the separate cases in sections 5–7.
  • To reproduce the complete finite-state check and its limits, read sections 8–10.
  • To test your understanding, complete section 11 before reading the model answers and evidence checklist.

Back to contents · Next section

1. The complete membership fixture

There are exactly three principals, A, B and C, and exactly three roles: R for root administration, M for manager administration, and W for writing a harmless catalogue annotation. These names are symbolic identifiers. A person’s job title, seniority or presumed ownership does not add any permission.

Initially A holds R only, B holds M only, and C holds W only. All six other principal-role memberships are false. The writer operation checks actual W membership. Consequently, C can annotate immediately; A and B cannot. The model contains no rule saying that R or M automatically satisfies the writer check.

The fixed administrative relationship is admin(R) = R, admin(M) = R, and admin(W) = M. Read each expression as an authorization condition on changing a membership. A caller needs R to grant or revoke R, needs R to grant or revoke M, and needs M to grant or revoke W.

This relationship is not operational permission inheritance. In particular, the path R to M to W describes possible administrative changes. It does not silently populate the missing M and W memberships for an R holder. The state must actually change before a later operation can rely on those memberships.

Keep two records on your worksheet: the fixed administrative relationship and the changing membership table. Mixing them into one hierarchy diagram is the easiest way to answer the wrong question. The former determines which changes are authorized; the latter determines which changes and annotations are authorized at this moment.

Back to contents · Next section

2. Three transition rules and their boundaries

A grant checks the caller’s current membership in the target role’s administrator role. If that check passes, it adds the target principal’s membership. A revoke uses the same current-state check and removes that membership. The target can be any of A, B or C, including the caller.

A self-renounce is different. With correctly matching caller confirmation, a principal can remove its own selected membership without holding that role’s administrator role. It cannot use this operation to remove somebody else’s membership. In this lesson every successful self-renounce has the required matching confirmation.

Calls that fail their authorization or confirmation check leave the state unchanged. An authorized grant of an already-held role, or removal of an absent membership, also leaves the membership table unchanged. These are self-loops in the state graph. Omitting them from a reachability search does not remove a route to a different state.

All successful changes are atomic. Each next call checks the state produced by the previous call. We supply no simultaneous actions, delayed activation, external modules, new principals, mutable administrator relationships, upgrades, exposed internal grant functions or hidden recovery entry points. No one can recruit an unlisted actor into a supposedly solo trace.

These are educational rules informed by a pinned implementation, rather than a claim that we compiled or executed Solidity. OpenZeppelin’s public grant, revoke and self-renounce interfaces provide the narrow source comparison; our complete configuration and initial memberships are supplied classroom facts. The M-administers-W relationship is explicitly configured, rather than assumed to be the untouched library default. AccessControl v5.4.0.

Back to contents · Next section

3. A’s shortest route to writer membership

Reset to the initial fixture. Allow only A to act. A cannot immediately grant W to itself because that grant requires M and A currently lacks M. Holding R does not bypass this particular check.

A can first grant M to A. The caller A holds R, which is the administrator of M. After this successful transition, A holds both R and M. No annotation has yet been performed, and A still lacks W.

A can then grant W to A. This second call sees the newly acquired M membership, passes its check, and adds W. A now holds R, M and W. A subsequent writer operation would pass its membership check.

The shortest effective-changing path therefore has two grants. Zero changes cannot work because A starts without W. One change cannot work because the only transition that adds A’s W requires A to hold M before that transition, and A does not initially hold it. Granting M is necessary first under the supplied solo rules.

The two-step witness establishes reachable technical capability. It does not establish that A actually performed either call, that an organisation approved it, or that every deployment has this route. An access report should preserve those distinctions: initially no writer permission; reachable writer membership in two authorized model transitions; observed execution not supplied.

Back to contents · Next section

4. B and C answer different questions

Reset again and allow only B to act. B already holds M, so it can grant W to itself in one change. It then retains M and also holds W. The shortest path is one because B initially lacks W but already satisfies the grant’s administrator condition.

B cannot obtain R in this solo model. Adding any R membership requires an R-holding caller. B has none initially, and none of its allowed changes can manufacture the required first R membership. The fact that A exists and holds R does not help a search that permits only B to act.

For C, the shortest writer path has length zero: C already holds W. This does not give C administrative power over W, M or R. A writer membership is an operational permission, not permission to select other writers.

C can self-renounce W. Afterwards C has no roles and cannot restore its own W without another actor’s involvement. This possibility matters even though C cannot grant or revoke roles through an administrator check. A complete transition model must include removal routes as well as acquisition routes.

The comparison is now precise: A has the broadest reachable membership control but cannot write immediately; B can acquire writer status in one grant; C can write immediately but cannot appoint another writer. Ranking them by the number of displayed roles would miss the structure entirely.

Back to contents · Next section

5. Removing a manager does not erase its writer membership

Start a separate case from the original fixture. First B grants W to itself, producing B with M and W. Next A revokes M from B. This second action is authorized because A still holds R, the administrator of M.

The resulting memberships are A:R, B:W and C:W. B has lost manager administration but still passes the writer check. The transition removed the specific B-M membership; no rule cascades that removal into B-W.

This is not a stale interface, a delayed update or a failed revoke. It is the exact successful result of the supplied operation. A report saying “manager removed, therefore former manager cannot annotate” would add a rule that the model does not contain.

To reach a state where B has neither M nor W, the supplied model needs an authorized removal of each relevant membership. For example, before removing B’s M, B could correctly self-renounce W; alternatively an M holder could revoke B’s W. Which route is organisationally acceptable is outside this paper exercise.

The key lesson is to inspect the post-state of the operation actually specified. Revoking an administrative membership changes future administrative capability. It does not automatically undo operational memberships that were granted earlier.

Back to contents · Next section

6. Removing a writer can leave a one-step return path

Use a fresh reset, then let B acquire W again. This time B correctly self-renounces W while retaining M. B temporarily fails the writer check, but it can immediately grant W to itself under the model’s next-call rules.

An M holder revoking B’s W would have the same membership result if B retained M. Whether the removal was called revoke or self-renounce does not change the later administrator check. B still has the prerequisite needed to regrant W.

A snapshot taken between removal and regrant truthfully shows B without W. It does not prove durable exclusion from W. To evaluate that stronger claim, follow every permitted path from the snapshot under the stated acting-principal assumptions.

Compare this case with section 5. There, B kept immediate writer permission after losing M. Here, B loses immediate writer permission but retains a route to recover it. Those are different failures of the same vague statement, “B has been removed.” A useful requirement must name the operational permission, administrative paths, relevant actors and post-state.

Do not convert this comparison into a live removal recipe. Real applications may have additional roles, contracts, aliases, upgrade mechanisms or custom authorization. The value of the toy is that it makes the claim testable before anyone pretends that a single label or successful transaction settles it.

Back to contents · Next section

7. What happens when the last R membership disappears?

Return to the original fixture, then let A correctly self-renounce R. The remaining state is B:M and C:W. Nobody holds R. For this case only, allow A, B and C to cooperate in every subsequent permitted transition.

Even their cooperation cannot recreate R inside this model. Consider every transition type. A grant of R requires an R-holding caller, and there is none. A revoke only removes a membership. A self-renounce only removes the caller’s membership. None can create the first R holder from this state.

This is an invariant argument: if a state has no R membership, every allowed next state also has no R membership. Repeating the argument covers every finite sequence of the supplied transitions, not merely a handful of failed attempts.

Lower-level power has not vanished. B still holds M and can change W memberships. C still holds W and can annotate. B can also self-renounce M, after which no M holder remains and the model cannot create a new one because granting M requires R.

Thus “root administration cannot be restored in the closed model” is justified. “The entire system has stopped” is not. “Every deployed contract becomes permanently unrecoverable after a root removal” is also unsupported: that statement would require knowing all of that deployment’s routes and implementation choices.

Back to contents · Next section

8. Reproduce the complete state-space check

Nine Boolean entries describe the membership table: three roles for each of three principals. There are at most 2 to the power of 9, or 512, possible tables. The administrator relationship and allowed acting principals remain fixed during each search.

A breadth-first search begins with the initial table, records it as seen, and examines each permitted actor’s effective-changing transitions. It adds unseen resulting tables to a queue and remembers a predecessor and action for each. When the queue is exhausted, the seen set is the complete reachable-state set for this finite model.

The search includes authorized grants, authorized revokes and correctly confirmed self-renounces. It checks prerequisites against each current table, not against the original table. The first discovered writer state supplies a shortest transition witness when every effective change has equal unit cost. This length measures calls changing membership, not time, transaction fees or operational difficulty.

The independently reproduced results are 512 states for A acting alone, 16 for B acting alone, and 2 for C acting alone. The root-lost case, with all three cooperating, has 16 reachable states. These results come from Python finite-state enumeration; they are not Solidity execution or a general contract-verification certificate.

The counts deserve an explanation rather than blind trust. For B, the three W memberships admit eight combinations. B can establish any desired combination while retaining M, then either retain or self-renounce M. That gives eight times two states; A’s R remains fixed. For C, only retaining or renouncing C’s W is possible.

A can reach every table because it can first establish the administrative memberships needed to set all desired entries, and arrange its own removals last. In particular, it can prepare lower memberships while retaining the necessary authority, remove any unwanted other R holders, and remove its own R only after root-dependent changes are complete. Final self-removals need no administrator. This explains how even tables with no remaining administrator can be reachable from the powerful initial position.

Back to contents · Next section

9. Why the root-lost count is still sixteen

In the root-lost starting state, all three R entries stay false. A’s and C’s M entries also stay false because granting M requires R. Only B’s M can change, through B’s self-renounce.

While B retains M, it can establish any of the eight W combinations. Each combination can also be reached with B’s M absent by establishing that combination first and renouncing M afterwards. Cooperative self-renounces do not create any additional kind of membership table beyond these possibilities.

Sixteen reachable tables therefore coexist with zero reachable R restoration. A state count alone does not tell you whether the particular goal you care about is reachable. The goal predicate must be checked separately: does any reached table contain any R holder?

Likewise, a smaller reachable set is not automatically safer. C’s two-state set includes voluntarily losing its only permission; the root-lost set contains continuing work and further loss of administration. Counts summarize a specified model. They do not grade governance quality, human reliability or resilience by themselves.

Back to contents · Next section

10. Check the implementation boundary before transferring the result

The pinned base AccessControl source exposes internal mutation functions and virtual extension points. A derived application may add routes beyond the public transition surface used here. A screenshot of memberships or an incomplete list of events cannot prove those routes absent. AccessControl v5.4.0.

A separate extension, AccessControlDefaultAdminRules, constrains default-administrator handling with a delayed two-step transfer and restrictions on direct public grants and revokes of that role. Its renunciation has additional conditions. Our direct R transitions therefore cannot be copied unchanged into a model of that extension. AccessControlDefaultAdminRules v5.4.0.

An actual review would need the exact program and configuration, the complete relevant principal set, every role-changing entry point, the operation’s real authorization predicate, and a justified state reference. Additional timing or recovery rules require additional state variables and transitions. Changing the model means recomputing its conclusions.

A missing route in the evidence is an unresolved question. A route proved absent from an explicitly complete finite model supports a bounded negative conclusion. Keeping those two situations separate is the difference between an auditable argument and an overconfident diagram.

Back to contents · Next section

11. Exercises and model answers

  1. At baseline, can A annotate? Can A grant W directly to itself? Give the shortest successful alternative.
  2. B acquires W, then A revokes B’s M. Does B still annotate, and why?
  3. B holds M and W, then renounces W. Is the lack of W durable against B acting alone?
  4. C renounces W at baseline. Can C alone regain it?
  5. Remove A’s sole R at baseline. Does B’s continued ability to appoint writers contradict root irrecoverability?
  6. Suppose an extra recovery function is added. May the old root-lost proof be reused without examining it?

Answers: 1. Both immediate actions fail their relevant checks. A first grants itself M, then W, giving a two-change witness. 2. Yes. Removing M does not remove the separately held W. 3. No. Retained M authorizes a one-grant return to W. 4. No; C has no administrator membership and self-renounce creates none. 5. No. M administers W, while restoration of R requires R. 6. No. The transition set has changed, so both the invariant and enumeration require reconsideration.

For an extension, ask whether the original model permits two R holders. It does: A can grant R to B while retaining its own R. That answer is about the supplied base-style rules, not the separately mentioned one-holder extension. This contrast is a quick test of whether a reader has silently merged two different programs.

Back to contents · Next section

12. Write a conclusion that the evidence actually supports

A good worksheet ends with four separate statements: current operational membership, a reachable-path witness or bounded impossibility proof, the acting-principal assumptions, and the evidence boundary. For A, write “no initial W; two-grant solo route to W under the fixed model.” For the root-lost case, write “no R restoration under any supplied cooperative transition sequence; lower-role actions remain possible.”

Preserve the initial table, administrator relation, exact transition rules, reset points and final tables beside those conclusions. If using enumeration, retain the state encoding, full transition generator, goal checks and expected counts. That evidence lets another reader reproduce the result and detect an omitted operation such as self-renounce.

The practical habit is simple: review changing authority as a state machine. A current role list answers a current-state question. A complete transition model answers which powers can be acquired, retained or lost next.

Back to contents · Next section

Sources and version notes

Primary code checked on 12 October 2026. The lesson uses pinned v5.4.0 sources, not an assertion about every newer release or derived deployment.

All principals, catalogue operations and membership traces are fictional. The complete enumeration is an educational model, not advice to change live access or a claim of production recovery assurance.

Back to contents