{"file_path":"./contracts/genesis/implementation/GovernanceSettings.sol","creation_status":"success","source_code":"// (c) 2021, Flare Networks Limited. All rights reserved.\n// Please see the file LICENSE for licensing terms.\n\n// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\nimport \"../../userInterfaces/IGovernanceSettings.sol\";\n\n\n/**\n * A special contract that holds Flare governance address.\n * This contract enables updating governance address and timelock only by hard forking the network,\n * meaning only by updating validator code.\n */\ncontract GovernanceSettings is IGovernanceSettings {\n\n    address public constant SIGNAL_COINBASE = address(0x00000000000000000000000000000000000dEAD0);\n\n    uint256 internal constant MAX_TIMELOCK = 365 days;\n    \n    address internal constant GENESIS_GOVERNANCE = 0xfffEc6C83c8BF5c3F4AE0cCF8c45CE20E4560BD7;\n    \n    // governance address set by the validator (set in initialise call, can be changed by fork)\n    address private governanceAddress;\n    \n    // global timelock setting (in seconds), also set by validator (set in initialise call, can be changed by fork)\n    uint64 private timelock;\n    \n    // prevent double initialisation\n    bool private initialised;\n    \n    // executor addresses, changeable anytime by the governance\n    address[] private executors;\n    mapping (address => bool) private executorMap;\n\n    event GovernanceAddressUpdated(\n        uint256 timestamp,\n        address oldGovernanceAddress,\n        address newGovernanceAddress\n    );\n\n    event GovernanceTimelockUpdated(\n        uint256 timestamp,\n        uint256 oldTimelock,\n        uint256 newTimelock\n    );\n\n    event GovernanceExecutorsUpdated(\n        uint256 timestamp,\n        address[] oldExecutors,\n        address[] newExecutors\n    );\n\n    /**\n     * Perform initialisation, which cannot be done in constructor, since this is a genesis contract.\n     * Can only be called once.\n     */\n    function initialise(address _governanceAddress, uint256 _timelock, address[] memory _executors) external {\n        require(msg.sender == GENESIS_GOVERNANCE, \"only genesis governance\");\n        require(!initialised, \"already initialised\");\n        require(_timelock < MAX_TIMELOCK, \"timelock too large\");\n        // set the field values\n        initialised = true;\n        governanceAddress = _governanceAddress;\n        timelock = uint64(_timelock);\n        _setExecutors(_executors);\n    }\n\n    /**\n     * Change the governance address.\n     * Can only be called by validators via fork.\n     */\n    function setGovernanceAddress(address _newGovernance) external {\n        require(governanceAddress != _newGovernance, \"governanceAddress == _newGovernance\");\n        if (msg.sender == block.coinbase && block.coinbase == SIGNAL_COINBASE) {\n            emit GovernanceAddressUpdated(block.timestamp, governanceAddress, _newGovernance);\n            governanceAddress = _newGovernance;\n        }\n    }\n\n    /**\n     * Change the timelock.\n     * Can only be called by validators via fork.\n     */\n    function setTimelock(uint256 _newTimelock) external {\n        require(timelock != _newTimelock, \"timelock == _newTimelock\");\n        require(_newTimelock < MAX_TIMELOCK, \"timelock too large\");\n        if (msg.sender == block.coinbase && block.coinbase == SIGNAL_COINBASE) {\n            emit GovernanceTimelockUpdated(block.timestamp, timelock, _newTimelock);\n            timelock = uint64(_newTimelock);\n        }\n    }\n    \n    /**\n     * Set the addresses of the accounts that are allowed to execute the timelocked governance calls\n     * once the timelock period expires.\n     * It isn't very dangerous to allow for anyone to execute timelocked calls, but we reserve the right to\n     * make sure the timing of the execution is under control.\n     * Can only be called by the governance.\n     */\n    function setExecutors(address[] memory _newExecutors) external {\n        require(msg.sender == governanceAddress, \"only governance\");\n        _setExecutors(_newExecutors);\n    }\n    \n    /**\n     * Get the governance account address.\n     */\n    function getGovernanceAddress() external view override returns (address) {\n        return governanceAddress;\n    }\n    \n    /**\n     * Get the time that must pass between a governance call and execution.\n     */\n    function getTimelock() external view override returns (uint256) {\n        return timelock;\n    }\n    \n    /**\n     * Get the addresses of the accounts that are allowed to execute the timelocked governance calls\n     * once the timelock period expires.\n     */\n    function getExecutors() external view override returns (address[] memory) {\n        return executors;\n    }\n    \n    /**\n     * Check whether an address is allowed to execute an governance call after timelock expires.\n     */\n    function isExecutor(address _address) external view override returns (bool) {\n        return executorMap[_address];\n    }\n\n    function _setExecutors(address[] memory _newExecutors) private {\n        emit GovernanceExecutorsUpdated(block.timestamp, executors, _newExecutors);\n        // clear old\n        while (executors.length > 0) {\n            executorMap[executors[executors.length - 1]] = false;\n            executors.pop();\n        }\n        // set new\n        for (uint256 i = 0; i < _newExecutors.length; i++) {\n            executors.push(_newExecutors[i]);\n            executorMap[_newExecutors[i]] = true;\n        }\n    }\n}\n","deployed_bytecode":"0x608060405234801561001057600080fd5b50600436106100935760003560e01c80637ff6faa6116100665780637ff6faa614610198578063cf0ea268146101a0578063cfc1625414610258578063debfda301461027e578063ef09e78f146102b857610093565b80631d452e46146100985780631e891c0a1461013d5780636221a54b1461015a5780637325249414610174575b600080fd5b61013b600480360360208110156100ae57600080fd5b8101906020810181356401000000008111156100c957600080fd5b8201836020820111156100db57600080fd5b803590602001918460208302840111640100000000831117156100fd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610310945050505050565b005b61013b6004803603602081101561015357600080fd5b503561036d565b6101626104b6565b60408051918252519081900360200190f35b61017c6104cd565b604080516001600160a01b039092168252519081900360200190f35b61017c6104dc565b61013b600480360360608110156101b657600080fd5b6001600160a01b03823516916020810135918101906060810160408201356401000000008111156101e657600080fd5b8201836020820111156101f857600080fd5b8035906020019184602083028401116401000000008311171561021a57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506104e3945050505050565b61013b6004803603602081101561026e57600080fd5b50356001600160a01b0316610645565b6102a46004803603602081101561029457600080fd5b50356001600160a01b0316610714565b604080519115158252519081900360200190f35b6102c0610732565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102fc5781810151838201526020016102e4565b505050509050019250505060405180910390f35b6000546001600160a01b03163314610361576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b61036a81610794565b50565b600054600160a01b900467ffffffffffffffff168114156103d5576040805162461bcd60e51b815260206004820152601860248201527f74696d656c6f636b203d3d205f6e657754696d656c6f636b0000000000000000604482015290519081900360640190fd5b6301e133808110610422576040805162461bcd60e51b815260206004820152601260248201527174696d656c6f636b20746f6f206c6172676560701b604482015290519081900360640190fd5b3341148015610433575041620dead0145b1561036a5760005460408051428152600160a01b90920467ffffffffffffffff166020830152818101839052517feb86fa0729fdcf66bda3d834e93bf513d3740be7f7a4a6cab0dd318f1df8514f916060908290030190a16000805467ffffffffffffffff8316600160a01b0267ffffffffffffffff60a01b1990911617905550565b600054600160a01b900467ffffffffffffffff1690565b6000546001600160a01b031690565b620dead081565b3373fffec6c83c8bf5c3f4ae0ccf8c45ce20e4560bd71461054b576040805162461bcd60e51b815260206004820152601760248201527f6f6e6c792067656e6573697320676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b600054600160e01b900460ff16156105a0576040805162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5cd959606a1b604482015290519081900360640190fd5b6301e1338082106105ed576040805162461bcd60e51b815260206004820152601260248201527174696d656c6f636b20746f6f206c6172676560701b604482015290519081900360640190fd5b60008054600160e01b60ff60e01b19909116176001600160a01b0319166001600160a01b0385161767ffffffffffffffff60a01b1916600160a01b67ffffffffffffffff85160217905561064081610794565b505050565b6000546001600160a01b03828116911614156106925760405162461bcd60e51b815260040180806020018281038252602381526020018061098d6023913960400191505060405180910390fd5b33411480156106a3575041620dead0145b1561036a57600054604080514281526001600160a01b03928316602082015291831682820152517f7e1a30031de5a45b59b70d6a9f61956645cf3cf9468588f31f4217f7c770d7cc9181900360600190a1600080546001600160a01b0383166001600160a01b031990911617905550565b6001600160a01b031660009081526002602052604090205460ff1690565b6060600180548060200260200160405190810160405280929190818152602001828054801561078a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161076c575b5050505050905090565b7fa2c44af5dca41c60e42e3fc93e9fc4dd6e5d2c14ededf08259d3372874ac085442600183604051808481526020018060200180602001838103835285818154815260200191508054801561081257602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116107f4575b50508381038252845181528451602091820191808701910280838360005b83811015610848578181015183820152602001610830565b505050509050019550505050505060405180910390a15b600154156108e6576000600260006001808080549050038154811061088057fe5b6000918252602080832091909101546001600160a01b031683528201929092526040019020805460ff191691151591909117905560018054806108bf57fe5b600082815260209020810160001990810180546001600160a01b031916905501905561085f565b60005b815181101561098857600182828151811061090057fe5b60209081029190910181015182546001808201855560009485529284200180546001600160a01b0319166001600160a01b039092169190911790558351909160029185908590811061094e57fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016108e9565b505056fe676f7665726e616e636541646472657373203d3d205f6e6577476f7665726e616e6365a2646970667358221220dc35724b5a2e5b003d9e6cf36ed995b5398fa1e1ef57af93db7adb9451b6d5c664736f6c63430007060033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":null,"optimization_runs":200,"sourcify_repo_url":null,"decoded_constructor_args":null,"compiler_version":"v0.7.6+commit.7338295f","is_verified_via_verifier_alliance":null,"verified_at":"2022-07-13T21:04:41.106790Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":null,"name":"GovernanceSettings","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":null,"language":"solidity","evm_version":null,"can_be_visualized_via_sol2uml":false,"is_verified_via_sourcify":null,"additional_sources":[{"file_path":"./contracts/userInterfaces/IGovernanceSettings.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\n\n/**\n * A special contract that holds Flare governance address.\n * This contract enables updating governance address and timelock only by hard forking the network,\n * meaning only by updating validator code.\n */\ninterface IGovernanceSettings {\n    /**\n     * Get the governance account address.\n     * The governance address can only be changed by a hardfork.\n     */\n    function getGovernanceAddress() external view returns (address);\n    \n    /**\n     * Get the time in seconds that must pass between a governance call and execution.\n     * The timelock value can only be changed by a hardfork.\n     */\n    function getTimelock() external view returns (uint256);\n    \n    /**\n     * Get the addresses of the accounts that are allowed to execute the timelocked governance calls\n     * once the timelock period expires.\n     * Executors can be changed without a hardfork, via a normal governance call.\n     */\n    function getExecutors() external view returns (address[] memory);\n    \n    /**\n     * Check whether an address is one of the executors.\n     */\n    function isExecutor(address _address) external view returns (bool);\n}\n"}],"certified":true,"conflicting_implementations":null,"abi":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldGovernanceAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newGovernanceAddress","type":"address"}],"name":"GovernanceAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"oldExecutors","type":"address[]"},{"indexed":false,"internalType":"address[]","name":"newExecutors","type":"address[]"}],"name":"GovernanceExecutorsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldTimelock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimelock","type":"uint256"}],"name":"GovernanceTimelockUpdated","type":"event"},{"inputs":[],"name":"SIGNAL_COINBASE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutors","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGovernanceAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_governanceAddress","type":"address"},{"internalType":"uint256","name":"_timelock","type":"uint256"},{"internalType":"address[]","name":"_executors","type":"address[]"}],"name":"initialise","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"isExecutor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_newExecutors","type":"address[]"}],"name":"setExecutors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newGovernance","type":"address"}],"name":"setGovernanceAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newTimelock","type":"uint256"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":null,"constructor_args":null}