Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GovernorTimelockControlUpgradeable

Inherits: Initializable, GovernorUpgradeable

Extension of {Governor} that binds the execution process to an instance of {TimelockController}. This adds a delay, enforced by the {TimelockController} to all successful proposal (in addition to the voting duration). The {Governor} needs the proposer (and ideally the executor and canceller) roles for the {Governor} to work properly. Using this model means the proposal will be operated by the {TimelockController} and not by the {Governor}. Thus, the assets and permissions must be attached to the {TimelockController}. Any asset sent to the {Governor} will be inaccessible from a proposal, unless executed via {Governor-relay}. WARNING: Setting up the TimelockController to have additional proposers or cancelers besides the governor is very risky, as it grants them the ability to: 1) execute operations as the timelock, and thus possibly performing operations or accessing funds that are expected to only be accessible through a vote, and 2) block governance proposals that have been approved by the voters, effectively executing a Denial of Service attack.

State Variables

GovernorTimelockControlStorageLocation

bytes32 private constant GovernorTimelockControlStorageLocation =
    0x0d5829787b8befdbc6044ef7457d8a95c2a04bc99235349f1a212c063e59d400;

Functions

_getGovernorTimelockControlStorage

function _getGovernorTimelockControlStorage() private pure returns (GovernorTimelockControlStorage storage $);

__GovernorTimelockControl_init

Set the timelock.

function __GovernorTimelockControl_init(TimelockControllerUpgradeable timelockAddress) internal onlyInitializing;

__GovernorTimelockControl_init_unchained

function __GovernorTimelockControl_init_unchained(TimelockControllerUpgradeable timelockAddress)
    internal
    onlyInitializing;

state

Overridden version of the Governor-state function that considers the status reported by the timelock.

function state(uint256 proposalId) public view virtual override returns (ProposalState);

timelock

Public accessor to check the address of the timelock

function timelock() public view virtual returns (address);

proposalNeedsQueuing

module:core

Whether a proposal needs to be queued before execution.

function proposalNeedsQueuing(uint256) public view virtual override returns (bool);

_queueOperations

Function to queue a proposal to the timelock.

function _queueOperations(
    uint256 proposalId,
    address[] memory targets,
    uint256[] memory values,
    bytes[] memory calldatas,
    bytes32 descriptionHash
) internal virtual override returns (uint48);

_executeOperations

Overridden version of the Governor-_executeOperations function that runs the already queued proposal through the timelock.

function _executeOperations(
    uint256 proposalId,
    address[] memory targets,
    uint256[] memory values,
    bytes[] memory calldatas,
    bytes32 descriptionHash
) internal virtual override;

_cancel

Overridden version of the Governor-_cancel function to cancel the timelocked proposal if it has already been queued.

function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
    internal
    virtual
    override
    returns (uint256);

_executor

Address through which the governor executes action. In this case, the timelock.

function _executor() internal view virtual override returns (address);

updateTimelock

Public endpoint to update the underlying timelock instance. Restricted to the timelock itself, so updates must be proposed, scheduled, and executed through governance proposals. CAUTION: It is not recommended to change the timelock while there are other queued governance proposals.

function updateTimelock(TimelockControllerUpgradeable newTimelock) external virtual onlyGovernance;

_updateTimelock

function _updateTimelock(TimelockControllerUpgradeable newTimelock) private;

_timelockSalt

Computes the {TimelockController} operation salt. It is computed with the governor address itself to avoid collisions across governor instances using the same timelock.

function _timelockSalt(bytes32 descriptionHash) private view returns (bytes32);

Events

TimelockChange

Emitted when the timelock controller used for proposal execution is modified.

event TimelockChange(address oldTimelock, address newTimelock);

Structs

GovernorTimelockControlStorage

Note: storage-location: erc7201:openzeppelin.storage.GovernorTimelockControl

struct GovernorTimelockControlStorage {
    TimelockControllerUpgradeable _timelock;
    mapping(uint256 proposalId => bytes32) _timelockIds;
}