Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- GovernanceSettings
- Optimization enabled
- true
- Compiler version
- v0.7.6+commit.7338295f
- Optimization runs
- 200
- Verified at
- 2022-07-13T21:04:41.106790Z
./contracts/genesis/implementation/GovernanceSettings.sol
// (c) 2021, Flare Networks Limited. All rights reserved. // Please see the file LICENSE for licensing terms. // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "../../userInterfaces/IGovernanceSettings.sol"; /** * A special contract that holds Flare governance address. * This contract enables updating governance address and timelock only by hard forking the network, * meaning only by updating validator code. */ contract GovernanceSettings is IGovernanceSettings { address public constant SIGNAL_COINBASE = address(0x00000000000000000000000000000000000dEAD0); uint256 internal constant MAX_TIMELOCK = 365 days; address internal constant GENESIS_GOVERNANCE = 0xfffEc6C83c8BF5c3F4AE0cCF8c45CE20E4560BD7; // governance address set by the validator (set in initialise call, can be changed by fork) address private governanceAddress; // global timelock setting (in seconds), also set by validator (set in initialise call, can be changed by fork) uint64 private timelock; // prevent double initialisation bool private initialised; // executor addresses, changeable anytime by the governance address[] private executors; mapping (address => bool) private executorMap; event GovernanceAddressUpdated( uint256 timestamp, address oldGovernanceAddress, address newGovernanceAddress ); event GovernanceTimelockUpdated( uint256 timestamp, uint256 oldTimelock, uint256 newTimelock ); event GovernanceExecutorsUpdated( uint256 timestamp, address[] oldExecutors, address[] newExecutors ); /** * Perform initialisation, which cannot be done in constructor, since this is a genesis contract. * Can only be called once. */ function initialise(address _governanceAddress, uint256 _timelock, address[] memory _executors) external { require(msg.sender == GENESIS_GOVERNANCE, "only genesis governance"); require(!initialised, "already initialised"); require(_timelock < MAX_TIMELOCK, "timelock too large"); // set the field values initialised = true; governanceAddress = _governanceAddress; timelock = uint64(_timelock); _setExecutors(_executors); } /** * Change the governance address. * Can only be called by validators via fork. */ function setGovernanceAddress(address _newGovernance) external { require(governanceAddress != _newGovernance, "governanceAddress == _newGovernance"); if (msg.sender == block.coinbase && block.coinbase == SIGNAL_COINBASE) { emit GovernanceAddressUpdated(block.timestamp, governanceAddress, _newGovernance); governanceAddress = _newGovernance; } } /** * Change the timelock. * Can only be called by validators via fork. */ function setTimelock(uint256 _newTimelock) external { require(timelock != _newTimelock, "timelock == _newTimelock"); require(_newTimelock < MAX_TIMELOCK, "timelock too large"); if (msg.sender == block.coinbase && block.coinbase == SIGNAL_COINBASE) { emit GovernanceTimelockUpdated(block.timestamp, timelock, _newTimelock); timelock = uint64(_newTimelock); } } /** * Set the addresses of the accounts that are allowed to execute the timelocked governance calls * once the timelock period expires. * It isn't very dangerous to allow for anyone to execute timelocked calls, but we reserve the right to * make sure the timing of the execution is under control. * Can only be called by the governance. */ function setExecutors(address[] memory _newExecutors) external { require(msg.sender == governanceAddress, "only governance"); _setExecutors(_newExecutors); } /** * Get the governance account address. */ function getGovernanceAddress() external view override returns (address) { return governanceAddress; } /** * Get the time that must pass between a governance call and execution. */ function getTimelock() external view override returns (uint256) { return timelock; } /** * Get the addresses of the accounts that are allowed to execute the timelocked governance calls * once the timelock period expires. */ function getExecutors() external view override returns (address[] memory) { return executors; } /** * Check whether an address is allowed to execute an governance call after timelock expires. */ function isExecutor(address _address) external view override returns (bool) { return executorMap[_address]; } function _setExecutors(address[] memory _newExecutors) private { emit GovernanceExecutorsUpdated(block.timestamp, executors, _newExecutors); // clear old while (executors.length > 0) { executorMap[executors[executors.length - 1]] = false; executors.pop(); } // set new for (uint256 i = 0; i < _newExecutors.length; i++) { executors.push(_newExecutors[i]); executorMap[_newExecutors[i]] = true; } } }
./contracts/userInterfaces/IGovernanceSettings.sol
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; /** * A special contract that holds Flare governance address. * This contract enables updating governance address and timelock only by hard forking the network, * meaning only by updating validator code. */ interface IGovernanceSettings { /** * Get the governance account address. * The governance address can only be changed by a hardfork. */ function getGovernanceAddress() external view returns (address); /** * Get the time in seconds that must pass between a governance call and execution. * The timelock value can only be changed by a hardfork. */ function getTimelock() external view returns (uint256); /** * Get the addresses of the accounts that are allowed to execute the timelocked governance calls * once the timelock period expires. * Executors can be changed without a hardfork, via a normal governance call. */ function getExecutors() external view returns (address[] memory); /** * Check whether an address is one of the executors. */ function isExecutor(address _address) external view returns (bool); }
Contract ABI
[{"type":"event","name":"GovernanceAddressUpdated","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"address","name":"oldGovernanceAddress","internalType":"address","indexed":false},{"type":"address","name":"newGovernanceAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"GovernanceExecutorsUpdated","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"address[]","name":"oldExecutors","internalType":"address[]","indexed":false},{"type":"address[]","name":"newExecutors","internalType":"address[]","indexed":false}],"anonymous":false},{"type":"event","name":"GovernanceTimelockUpdated","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"uint256","name":"oldTimelock","internalType":"uint256","indexed":false},{"type":"uint256","name":"newTimelock","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"SIGNAL_COINBASE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getExecutors","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getGovernanceAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTimelock","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialise","inputs":[{"type":"address","name":"_governanceAddress","internalType":"address"},{"type":"uint256","name":"_timelock","internalType":"uint256"},{"type":"address[]","name":"_executors","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isExecutor","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setExecutors","inputs":[{"type":"address[]","name":"_newExecutors","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setGovernanceAddress","inputs":[{"type":"address","name":"_newGovernance","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTimelock","inputs":[{"type":"uint256","name":"_newTimelock","internalType":"uint256"}]}]
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80637ff6faa6116100665780637ff6faa614610198578063cf0ea268146101a0578063cfc1625414610258578063debfda301461027e578063ef09e78f146102b857610093565b80631d452e46146100985780631e891c0a1461013d5780636221a54b1461015a5780637325249414610174575b600080fd5b61013b600480360360208110156100ae57600080fd5b8101906020810181356401000000008111156100c957600080fd5b8201836020820111156100db57600080fd5b803590602001918460208302840111640100000000831117156100fd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610310945050505050565b005b61013b6004803603602081101561015357600080fd5b503561036d565b6101626104b6565b60408051918252519081900360200190f35b61017c6104cd565b604080516001600160a01b039092168252519081900360200190f35b61017c6104dc565b61013b600480360360608110156101b657600080fd5b6001600160a01b03823516916020810135918101906060810160408201356401000000008111156101e657600080fd5b8201836020820111156101f857600080fd5b8035906020019184602083028401116401000000008311171561021a57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506104e3945050505050565b61013b6004803603602081101561026e57600080fd5b50356001600160a01b0316610645565b6102a46004803603602081101561029457600080fd5b50356001600160a01b0316610714565b604080519115158252519081900360200190f35b6102c0610732565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102fc5781810151838201526020016102e4565b505050509050019250505060405180910390f35b6000546001600160a01b03163314610361576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b61036a81610794565b50565b600054600160a01b900467ffffffffffffffff168114156103d5576040805162461bcd60e51b815260206004820152601860248201527f74696d656c6f636b203d3d205f6e657754696d656c6f636b0000000000000000604482015290519081900360640190fd5b6301e133808110610422576040805162461bcd60e51b815260206004820152601260248201527174696d656c6f636b20746f6f206c6172676560701b604482015290519081900360640190fd5b3341148015610433575041620dead0145b1561036a5760005460408051428152600160a01b90920467ffffffffffffffff166020830152818101839052517feb86fa0729fdcf66bda3d834e93bf513d3740be7f7a4a6cab0dd318f1df8514f916060908290030190a16000805467ffffffffffffffff8316600160a01b0267ffffffffffffffff60a01b1990911617905550565b600054600160a01b900467ffffffffffffffff1690565b6000546001600160a01b031690565b620dead081565b3373fffec6c83c8bf5c3f4ae0ccf8c45ce20e4560bd71461054b576040805162461bcd60e51b815260206004820152601760248201527f6f6e6c792067656e6573697320676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b600054600160e01b900460ff16156105a0576040805162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5cd959606a1b604482015290519081900360640190fd5b6301e1338082106105ed576040805162461bcd60e51b815260206004820152601260248201527174696d656c6f636b20746f6f206c6172676560701b604482015290519081900360640190fd5b60008054600160e01b60ff60e01b19909116176001600160a01b0319166001600160a01b0385161767ffffffffffffffff60a01b1916600160a01b67ffffffffffffffff85160217905561064081610794565b505050565b6000546001600160a01b03828116911614156106925760405162461bcd60e51b815260040180806020018281038252602381526020018061098d6023913960400191505060405180910390fd5b33411480156106a3575041620dead0145b1561036a57600054604080514281526001600160a01b03928316602082015291831682820152517f7e1a30031de5a45b59b70d6a9f61956645cf3cf9468588f31f4217f7c770d7cc9181900360600190a1600080546001600160a01b0383166001600160a01b031990911617905550565b6001600160a01b031660009081526002602052604090205460ff1690565b6060600180548060200260200160405190810160405280929190818152602001828054801561078a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161076c575b5050505050905090565b7fa2c44af5dca41c60e42e3fc93e9fc4dd6e5d2c14ededf08259d3372874ac085442600183604051808481526020018060200180602001838103835285818154815260200191508054801561081257602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116107f4575b50508381038252845181528451602091820191808701910280838360005b83811015610848578181015183820152602001610830565b505050509050019550505050505060405180910390a15b600154156108e6576000600260006001808080549050038154811061088057fe5b6000918252602080832091909101546001600160a01b031683528201929092526040019020805460ff191691151591909117905560018054806108bf57fe5b600082815260209020810160001990810180546001600160a01b031916905501905561085f565b60005b815181101561098857600182828151811061090057fe5b60209081029190910181015182546001808201855560009485529284200180546001600160a01b0319166001600160a01b039092169190911790558351909160029185908590811061094e57fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016108e9565b505056fe676f7665726e616e636541646472657373203d3d205f6e6577476f7665726e616e6365a2646970667358221220dc35724b5a2e5b003d9e6cf36ed995b5398fa1e1ef57af93db7adb9451b6d5c664736f6c63430007060033