Skip to content

feat: governedAsDeclared by name reads the book's adminRole - #11

Merged
0xrajath merged 1 commit into
mainfrom
feat/governed-as-declared-by-name
Oct 13, 2026
Merged

0xrajath merged 1 commit into
mainfrom
feat/governed-as-declared-by-name

Conversation

@0xrajath

@0xrajath 0xrajath commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

governedAsDeclared(target) requires the authority to hold _ROLE_0 on the target, which the Router does not grant: the book declares it owner-governed only, so a correct post-upgrade check of the Router fails on a role it was never meant to hold.

The book already says which contracts the authority holds the admin role on (contracts.<name>.adminRole); the helper should read it rather than demand the role everywhere.

Modifications

  • src/LatticeTest.sol: governedAsDeclared(string name) reads the target, the timelock, the declared admin role and the authority off bookPath() -> owned by the timelock always, _ROLE_0 only where the book declares adminRole. The address form is unchanged. LatticeTestVm gains parseJsonAddress, parseJsonBool, keyExistsJson.
  • test/Governed.t.sol: the name form on a harness with a book of its own, per test file (forge runs tests in parallel): owner-governed only passes on its owner, a declared role is required, another owner fails either way.
  • docs/testing.md: the check's row and the example use the name form.

Result

A release's post-upgrade suite can assert governedAsDeclared("router") and get the book's answer; a target the book declares admin-governed is still held to the role.


Note

Low Risk
Scope is release test helpers and docs; strict address-based checks are unchanged, and new tests cover the book-driven behavior.

Overview
Fixes post-upgrade governance checks for contracts the book marks as owner-governed only (e.g. Router), where governedAsDeclared(address) incorrectly required the authority to hold _ROLE_0.

Adds governedAsDeclared(string name), which loads the contract, timelock, and authority from bookPath() and only enforces admin role when contracts.<name>.adminRole is present and true; missing or false adminRole passes on timelock ownership alone. The address overload is unchanged for callers that always want the role check.

LatticeTestVm gains parseJsonAddress, parseJsonBool, and keyExistsJson for book parsing. test/Governed.t.sol exercises owner-only vs admin-governed paths with per-test book files. docs/testing.md updates the checklist row and example to use governedAsDeclared("exchange").

Reviewed by Cursor Bugbot for commit 510f2c2. Bugbot is set up for automated code reviews on this repo. Configure here.

@0xrajath
0xrajath merged commit 22e47f1 into main Oct 13, 2026
4 checks passed
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.

2 participants