Skip to content

feat: re-gate config & treasury functions to GOVERNANCE_ROLE#172

Open
0xpanicError wants to merge 8 commits into
masterfrom
stake-1673
Open

feat: re-gate config & treasury functions to GOVERNANCE_ROLE#172
0xpanicError wants to merge 8 commits into
masterfrom
stake-1673

Conversation

@0xpanicError

@0xpanicError 0xpanicError commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Implements STAKE-1673: the 14 config & treasury functions were gated by onlyRoleRegistryOwner, so once RoleRegistry ownership moves to the 2-day timelock (STAKE-1676) they would freeze behind the delay. This PR re-gates them to a consolidated GOVERNANCE_ROLE so they stay fast at the governance multisig, and adds the timelock contract that will take RoleRegistry ownership.

Core gate

  • New GOVERNANCE_ROLE public constant, OnlyGovernanceMultisig() error, and onlyGovernanceMultisig modifier (hasRole(GOVERNANCE_ROLE, msg.sender)) in UpgradeableProxy.

Re-gated: config (9)

  • SettlementDispatcherV2: setDestinationData, setLiquidAssetWithdrawQueue, setRefundWallet, setFraxConfig, setMidasRedemptionVault, setCCTPConfig, setSettlementRecipients
  • TopUpFactory: setTokenConfig, setRecoveryWallet

Re-gated: treasury (5)

  • SettlementDispatcherV2.withdrawFunds, TopUpFactory.recoverFunds, TopUpDest.withdraw, CashbackDispatcher.withdrawFunds, LiquidUSDLiquifierOPModule.withdrawFunds

Left on owner (upgrade vectors, per ticket)

  • DebtManagerCore.setAdminImpl, BeaconFactory.upgradeBeaconImplementation — verified these are the only remaining onlyRoleRegistryOwner call sites.

Timelock

  • EtherFiTimelock (thin wrapper over OZ 5.2 TimelockController) + scripts/DeployTimelock.s.sol: 2-day delay, current governance multisig (read as RoleRegistry.owner()) as sole proposer & executor, no admin (the timelock administers its own roles behind the delay).
  • Deployment and the roleRegistry.transferOwnership(timelock) handoff happen in STAKE-1676 — the transfer must be sent by the multisig via scripts/gnosis-txs/, and only after GOVERNANCE_ROLE (keccak256("GOVERNANCE_ROLE")) is granted to it.

Certora

  • Added GOVERNANCE_ROLE to the contract_extensions exclude list in CashModuleCore.conf: the public constant now exists on both CashModuleCoreHarness and CashModuleSetters, and shared inherited functions must be excluded from the merge (same handling as the other inherited role constants).

Tests

  • Granted GOVERNANCE_ROLE to the test owner in the five setups that deploy a RoleRegistry; updated the seven existing unauthorized-caller tests to expect OnlyGovernanceMultisig.
  • New gating unit test per contract covering: role holder passes, non-holder reverts, RoleRegistry owner without the role is no longer accepted.
  • New EtherFiTimelock suite: role wiring, min-delay enforcement, schedule→execute of RoleRegistry owner actions after the 2-day delay, premature/unauthorized schedule & execute reverts, no multisig bypass once ownership is transferred, delay changes only via the timelock itself.

Expected CI status

The upgrade-bytecode-verification tests fail on this branch by design (21 tests): the public GOVERNANCE_ROLE getter compiles into every contract inheriting UpgradeableProxy, so local bytecode diverges from all currently-deployed impls until the STAKE-1676 redeploy. All other tests pass (1018 passed locally).

🤖 Generated with Claude Code


Note

High Risk
Changes who can run treasury withdrawals and bridge/settlement configuration, and adds operational scripts that upgrade proxies and transfer RoleRegistry ownership to a timelock—mistakes could lock ops or move critical admin control.

Overview
Introduces GOVERNANCE_ROLE on UpgradeableProxy (onlyGovernanceMultisig) so config and treasury calls stay with the governance multisig after RoleRegistry ownership moves to a timelock. 14 functions that used onlyRoleRegistryOwner now use onlyGovernanceMultisig across SettlementDispatcherV2, TopUpFactory, TopUpDest, CashbackDispatcher, and LiquidUSDLiquifierOPModule; upgrade paths (DebtManagerCore.setAdminImpl, BeaconFactory.upgradeBeaconImplementation) stay owner-gated.

Adds EtherFiTimelock (OZ TimelockController wrapper), DeployTimelock.s.sol (CREATE3 via Nick’s factory, 2-day delay), Create3Deployer, and per-chain STAKE-1676 migration scripts that deploy new impls, emit two-step Gnosis bundles (upgrade + grant role + schedule handover; later execute handover), and fork-simulate the end state. Certora CashModuleCore.conf excludes inherited GOVERNANCE_ROLE; tests grant the role in setups and assert owner-without-role is rejected.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@0xpanicError 0xpanicError changed the title feat: re-gate config & treasury functions to GOVERNANCE_ROLE (STAKE-1673) feat: re-gate config & treasury functions to GOVERNANCE_ROLE Jul 7, 2026

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 1968a09d-353c-4d89-992e-3e1e9e21c47c
  • Commit: c31b233
JobResultVERIFIED
EtherFiSafe.…0
CashModuleCo…2

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8bf4d36. Configure here.

Comment thread src/utils/UpgradeableProxy.sol

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: f53abd2f-ba74-4f1d-9872-a7004db21201
  • Commit: 8bf4d36
JobResultERROR
EtherFiSafe.…0
CashModuleCo…1

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: c94c3ab8-6d4f-4129-9dea-8e2f5ff21710
  • Commit: 081836e
JobResultERRORVERIFIED
EtherFiSafe.…014
CashModuleCo…10

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: ecfb6cd0-b5f6-4638-a1ec-97bceb803c97
  • Commit: 784e182
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 1e49c16b-6dab-44d8-8d66-c9bebbbc26a6
  • Commit: ec4c2a0
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: de379059-0d62-414c-80bc-9f014d3b1e15
  • Commit: 58274ab
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 1edc4f64-bade-4dc3-8c1a-38dd0156599d
  • Commit: 530fa82
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

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