-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fix(protocol): remove L1/gov/ in favor of Aragon's (#16933)"
This reverts commit 1573735.
- Loading branch information
1 parent
5175fbe
commit 3352b29
Showing
19 changed files
with
583 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import | ||
"@openzeppelin/contracts-upgradeable/governance/compatibility/GovernorCompatibilityBravoUpgradeable.sol"; | ||
import | ||
"@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol"; | ||
import | ||
"@openzeppelin/contracts-upgradeable/governance/extensions/GovernorTimelockControlUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorSettingsUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; | ||
|
||
/// @title TaikoGovernor | ||
/// @custom:security-contact [email protected] | ||
contract TaikoGovernor is | ||
Ownable2StepUpgradeable, | ||
GovernorCompatibilityBravoUpgradeable, | ||
GovernorSettingsUpgradeable, | ||
GovernorVotesQuorumFractionUpgradeable, | ||
GovernorTimelockControlUpgradeable | ||
{ | ||
uint256[50] private __gap; | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
/// @param _token The Taiko token. | ||
/// @param _timelock The timelock contract address. | ||
function init( | ||
address _owner, | ||
IVotesUpgradeable _token, | ||
TimelockControllerUpgradeable _timelock | ||
) | ||
external | ||
initializer | ||
{ | ||
_transferOwnership(_owner == address(0) ? msg.sender : _owner); | ||
__Governor_init("TaikoGovernor"); | ||
__GovernorVotes_init(_token); | ||
__GovernorSettings_init(7200, 50_400, 100_000 ether); // Values respectively: 1day, 1week, | ||
// 0.01% of Taiko Token; | ||
__GovernorVotesQuorumFraction_init(4); | ||
__GovernorTimelockControl_init(_timelock); | ||
} | ||
|
||
/// @dev See {IGovernor-propose} | ||
function propose( | ||
address[] memory _targets, | ||
uint256[] memory _values, | ||
bytes[] memory _calldatas, | ||
string memory _description | ||
) | ||
public | ||
override(IGovernorUpgradeable, GovernorUpgradeable, GovernorCompatibilityBravoUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.propose(_targets, _values, _calldatas, _description); | ||
} | ||
|
||
/// @dev See {GovernorUpgradeable-supportsInterface} | ||
function supportsInterface(bytes4 _interfaceId) | ||
public | ||
view | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable, IERC165Upgradeable) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(_interfaceId); | ||
} | ||
|
||
/// @dev See {GovernorUpgradeable-state} | ||
function state(uint256 _proposalId) | ||
public | ||
view | ||
override(IGovernorUpgradeable, GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (ProposalState) | ||
{ | ||
return super.state(_proposalId); | ||
} | ||
|
||
/// @notice How long after a proposal is created should voting power be fixed. A | ||
/// large voting delay gives users time to unstake tokens if necessary. | ||
/// @return The duration of the voting delay. | ||
function votingDelay() | ||
public | ||
view | ||
override(IGovernorUpgradeable, GovernorSettingsUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.votingDelay(); | ||
} | ||
|
||
/// @notice How long does a proposal remain open to votes. | ||
/// @return The duration of the voting period. | ||
function votingPeriod() | ||
public | ||
view | ||
override(IGovernorUpgradeable, GovernorSettingsUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.votingPeriod(); | ||
} | ||
|
||
/// @notice The number of votes required in order for a voter to become a proposer. | ||
/// @return The number of votes required. | ||
function proposalThreshold() | ||
public | ||
view | ||
override(GovernorUpgradeable, GovernorSettingsUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.proposalThreshold(); | ||
} | ||
|
||
/// @dev Cancel a proposal with GovernorBravo logic. | ||
function cancel( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) | ||
public | ||
virtual | ||
override(IGovernorUpgradeable, GovernorUpgradeable, GovernorCompatibilityBravoUpgradeable) | ||
returns (uint256) | ||
{ | ||
return GovernorCompatibilityBravoUpgradeable.cancel( | ||
targets, values, calldatas, descriptionHash | ||
); | ||
} | ||
|
||
function _execute( | ||
uint256 _proposalId, | ||
address[] memory _targets, | ||
uint256[] memory _values, | ||
bytes[] memory _calldatas, | ||
bytes32 _descriptionHash | ||
) | ||
internal | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
{ | ||
return super._execute(_proposalId, _targets, _values, _calldatas, _descriptionHash); | ||
} | ||
|
||
function _cancel( | ||
address[] memory _targets, | ||
uint256[] memory _values, | ||
bytes[] memory _calldatas, | ||
bytes32 _descriptionHash | ||
) | ||
internal | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super._cancel(_targets, _values, _calldatas, _descriptionHash); | ||
} | ||
|
||
function _executor() | ||
internal | ||
view | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (address) | ||
{ | ||
return super._executor(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/protocol/contracts/L1/gov/TaikoTimelockController.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; | ||
import "../../common/EssentialContract.sol"; | ||
|
||
/// @title TaikoTimelockController | ||
/// @custom:security-contact [email protected] | ||
contract TaikoTimelockController is EssentialContract, TimelockControllerUpgradeable { | ||
uint256[50] private __gap; | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
/// @param _minDelay The minimal delay. | ||
function init(address _owner, uint256 _minDelay) external initializer { | ||
__Essential_init(_owner); | ||
address[] memory nil = new address[](0); | ||
__TimelockController_init(_minDelay, nil, nil, owner()); | ||
} | ||
|
||
/// @dev Gets the minimum delay for an operation to become valid, allows the admin to get around | ||
/// of the min delay. | ||
/// @return The minimum delay. | ||
function getMinDelay() public view override returns (uint256) { | ||
return hasRole(TIMELOCK_ADMIN_ROLE, msg.sender) ? 0 : super.getMinDelay(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.