Repository navigation
test(contracts): add governance lifecycle suite (closes #693) - #695
Conversation
Adds contracts/test/GovernanceLifecycle.t.sol — 57 tests exercising the full propose → vote → queue → execute path against every GOVERNANCE_ROLE-gated setter (29 setters across FeeRouter, CapacityBond, DecdnGovernor, ContentBlacklist, SafetyReserve, PublisherRegistry). Deploys real contracts (no mocks), hands GOVERNANCE_ROLE to the Timelock in setUp() to mirror the production deploy ordering issue #694 will supply, and seeds served-bytes via real routeSettlement so the vote-weight / proposal-threshold / quorum pipeline is genuinely exercised end-to-end. Each setter gets a happy-path + (where bounds exist) an out-of-bounds revert test; three canaries guard the role hand-off, executor identity, and vote-source wiring. Closes #693. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 26589452026 |
Contracts coverageLine coverage: 76.92% (973/1265 lines) |
There was a problem hiding this comment.
Code Review
This pull request introduces GovernanceLifecycle.t.sol to test the full governance lifecycle (propose, vote, queue, and execute) for all governable target contracts. The review identifies critical access control issues in the deployment setup: the deployer fails to renounce TIMELOCK_ADMIN_ROLE on the Timelock, and retains DEFAULT_ADMIN_ROLE on the target contracts, leaving potential backdoors. It is recommended to properly transfer and renounce these administrative roles, and update the canary tests to verify these security boundaries.
There was a problem hiding this comment.
Pull request overview
Adds an end-to-end Foundry test suite that exercises the real on-chain governance path (propose → vote → queue → execute) against all governable setters across the protocol’s core contracts, validating that parameter updates (and expected reverts) actually flow through DecdnGovernor and the TimelockController.
Changes:
- Introduces
GovernanceLifecycle.t.solwith table-style lifecycle tests for setter happy paths and out-of-bounds revert paths acrossFeeRouter,CapacityBond,ContentBlacklist,SafetyReserve,PublisherRegistry, plus Governor self-params. - Deploys production-shaped contract graph in
setUp()and seeds served-bytes-based vote weight to satisfy proposal threshold + quorum requirements. - Adds canary tests to validate core assumptions (role wiring, timelock executor binding, non-zero voting pipeline).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses review feedback on #695: - Hand off DEFAULT_ADMIN_ROLE (OZ AccessControl meta-admin) to the Timelock in addition to GOVERNANCE_ROLE on every target. Without this, the deployer could re-grant itself GOVERNANCE_ROLE at any time via AccessControl.grantRole, bypassing the Timelock entirely. - Extend the canary to assert GOVERNANCE_ROLE + DEFAULT_ADMIN_ROLE are held by Timelock and not by the deployer on all five targets (was only checking router + bond). - Read votingDelay/votingPeriod/getMinDelay from the deployed contracts in lifecycle helpers instead of duplicating constants, so a future schedule change in DecdnGovernor doesn't silently desync the test. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
contracts/test/GovernanceLifecycle.t.sol— 57 tests exercising the full propose → vote → queue → execute path against everyGOVERNANCE_ROLE-gated setter (29 setters across 6 contracts).FeeRouter,CapacityBond,DecdnGovernor,ContentBlacklist,SafetyReserve,PublisherRegistry, andTimelockController; performs the role hand-off insetUp()to mirror the production deploy ordering Production DeployProtocol.s.sol with atomic deployer→Timelock role handoff #694 will supply.GOVERNANCE_ROLEactually held by Timelock on every target (with no deployer back door), Governor's executor IS the Timelock, and the served-bytes voting pipeline yields non-zero weight.Test plan
forge fmt --checkFOUNDRY_PROFILE=ci forge build --deny warningsforge test— 210/210 passslither— no medium-or-higher findingsaderyn— no high findingsCoverage
FeeRouter.sol: 86.89% lines / 87.42% statementsDecdnGovernor.sol: 80.68% lines / 78.95% statementsRemaining gaps in
CapacityBond/SafetyReserve/ContentBlacklist/PublisherRegistryare non-lifecycle branches (slashing, claims, appeals) that are out of scope for this issue.Out of scope (follow-ups)
CapacityBond.setAlpha/setK/setMaxCapacityPerOperator/setAgeRampMonths— ADR 016 lists these as governable but they ship as immutables today. A separate issue should add the setters and amend this test file.voteCapBps/ageRampMonths/windowEpochs) — high-value follow-up but distinct from the lifecycle wiring this issue requires.withdrawTo/payout/ratifyAppeal/reverseAppeal(governance-gated state actions, not parameter setters) — correctly excluded per issue text; worth tracking separately.Closes #693.
🤖 Generated with Claude Code