Skip to content
Verified contractExactMIT

GovernanceTimelock

Address0x9b0c3b40c34eee4bb0e2eb48ea7322a32841a0a5
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.24

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,463,916
Creation transaction
0x1c9ed6a8ed…fc140b00cd

src/governance/GovernanceTimelock.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

/// @notice Dual-control timelock governance (module 09).
/// @dev Sandbox: recording an upgrade target does not activate production or settle value.
contract GovernanceTimelock {
    uint256 public immutable minDelay;

    address public admin;
    address public proposer;
    address public executor;
    address public canceller;
    address public emergencyGuardian;
    address public immutable signerA;
    address public immutable signerB;

    bool public paused;
    address public implementation;

    struct Proposal {
        address nextImplementation;
        uint256 eta;
        bool executed;
        bool cancelled;
    }

    mapping(bytes32 => Proposal) public proposals;

    error ZeroAddress();
    error Unauthorized();
    error AlreadyExists();
    error UnknownProposal();
    error TimelockActive();
    error Cancelled();
    error AlreadyExecuted();
    error SingleParty();
    error Paused();
    error RolesNotSeparated();

    event RoleUpdated(bytes32 indexed role, address indexed account);
    event Proposed(bytes32 indexed proposalId, address nextImplementation, uint256 eta);
    event CancelledProposal(bytes32 indexed proposalId);
    event Executed(bytes32 indexed proposalId, address nextImplementation);
    event EmergencyPaused(address indexed actor);
    event EmergencyUnpaused(address indexed actor);

    modifier onlyAdmin() {
        if (msg.sender != admin) revert Unauthorized();
        _;
    }

    constructor(
        address admin_,
        address proposer_,
        address executor_,
        address canceller_,
        address emergencyGuardian_,
        address signerA_,
        address signerB_,
        uint256 minDelay_
    ) {
        if (
            admin_ == address(0) || proposer_ == address(0) || executor_ == address(0) || canceller_ == address(0)
                || emergencyGuardian_ == address(0) || signerA_ == address(0) || signerB_ == address(0)
        ) revert ZeroAddress();
        if (signerA_ == signerB_) revert RolesNotSeparated();
        if (minDelay_ == 0) revert TimelockActive();

        admin = admin_;
        proposer = proposer_;
        executor = executor_;
        canceller = canceller_;
        emergencyGuardian = emergencyGuardian_;
        signerA = signerA_;
        signerB = signerB_;
        minDelay = minDelay_;
    }

    function setProposer(address account) external onlyAdmin {
        if (account == address(0)) revert ZeroAddress();
        proposer = account;
        emit RoleUpdated("PROPOSER", account);
    }

    function setExecutor(address account) external onlyAdmin {
        if (account == address(0)) revert ZeroAddress();
        executor = account;
        emit RoleUpdated("EXECUTOR", account);
    }

    function setCanceller(address account) external onlyAdmin {
        if (account == address(0)) revert ZeroAddress();
        canceller = account;
        emit RoleUpdated("CANCELLER", account);
    }

    function setEmergencyGuardian(address account) external onlyAdmin {
        if (account == address(0)) revert ZeroAddress();
        emergencyGuardian = account;
        emit RoleUpdated("EMERGENCY", account);
    }

    function pause() external {
        if (msg.sender != emergencyGuardian) revert Unauthorized();
        paused = true;
        emit EmergencyPaused(msg.sender);
    }

    function unpause() external {
        if (msg.sender != emergencyGuardian && msg.sender != admin) revert Unauthorized();
        paused = false;
        emit EmergencyUnpaused(msg.sender);
    }

    function propose(bytes32 proposalId, address nextImplementation) external returns (uint256 eta) {
        if (paused) revert Paused();
        if (msg.sender != proposer && msg.sender != admin) revert Unauthorized();
        if (nextImplementation == address(0)) revert ZeroAddress();
        if (proposals[proposalId].eta != 0 || proposals[proposalId].executed) revert AlreadyExists();
        eta = block.timestamp + minDelay;
        proposals[proposalId] = Proposal(nextImplementation, eta, false, false);
        emit Proposed(proposalId, nextImplementation, eta);
    }

    function cancel(bytes32 proposalId) external {
        if (msg.sender != canceller && msg.sender != admin) revert Unauthorized();
        Proposal storage p = proposals[proposalId];
        if (p.eta == 0) revert UnknownProposal();
        if (p.executed) revert AlreadyExecuted();
        p.cancelled = true;
        emit CancelledProposal(proposalId);
    }

    /// @notice Dual-signer execute after delay. Admin alone cannot bypass signers or delay.
    function execute(bytes32 proposalId, address signerOne, address signerTwo) external {
        if (paused) revert Paused();
        if (msg.sender != executor && msg.sender != admin) revert Unauthorized();
        Proposal storage p = proposals[proposalId];
        if (p.eta == 0) revert UnknownProposal();
        if (p.cancelled) revert Cancelled();
        if (p.executed) revert AlreadyExecuted();
        if (block.timestamp < p.eta) revert TimelockActive();
        if (
            signerOne == signerTwo || (signerOne != signerA && signerOne != signerB)
                || (signerTwo != signerA && signerTwo != signerB)
        ) revert SingleParty();

        p.executed = true;
        implementation = p.nextImplementation;
        emit Executed(proposalId, p.nextImplementation);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.