-
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.
Merge branch 'main' into xiaodino/fix-decode-message-1
- Loading branch information
Showing
24 changed files
with
197 additions
and
192 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "@openzeppelin/contracts-upgradeable/governance/GovernorUpgradeable.sol"; | ||
import | ||
"@openzeppelin/contracts-upgradeable/governance/compatibility/GovernorCompatibilityBravoUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesUpgradeable.sol"; | ||
import | ||
"@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol"; | ||
import | ||
"@openzeppelin/contracts-upgradeable/governance/extensions/GovernorTimelockControlUpgradeable.sol"; | ||
import "../../common/EssentialContract.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; | ||
|
||
/// @title TaikoGovernor | ||
/// @custom:security-contact [email protected] | ||
contract TaikoGovernor is | ||
EssentialContract, | ||
Ownable2StepUpgradeable, | ||
GovernorCompatibilityBravoUpgradeable, | ||
GovernorVotesUpgradeable, | ||
GovernorVotesQuorumFractionUpgradeable, | ||
GovernorTimelockControlUpgradeable | ||
{ | ||
|
@@ -36,9 +33,8 @@ contract TaikoGovernor is | |
external | ||
initializer | ||
{ | ||
__Essential_init(_owner); | ||
_transferOwnership(_owner == address(0) ? msg.sender : _owner); | ||
__Governor_init("TaikoGovernor"); | ||
__GovernorCompatibilityBravo_init(); | ||
__GovernorVotes_init(_token); | ||
__GovernorVotesQuorumFraction_init(4); | ||
__GovernorTimelockControl_init(_timelock); | ||
|
@@ -58,33 +54,6 @@ contract TaikoGovernor is | |
return super.propose(_targets, _values, _calldatas, _description); | ||
} | ||
|
||
/// @notice An overwrite of GovernorCompatibilityBravoUpgradeable's propose() as that one does | ||
/// not check that the length of signatures equal the calldata. | ||
/// @dev See vulnerability description here: | ||
/// https://github.com/taikoxyz/taiko-mono/security/dependabot/114 | ||
/// See fix in OZ 4.8.3 here (URL broken down for readability): | ||
/// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/ | ||
/// 0a25c1940ca220686588c4af3ec526f725fe2582/contracts/governance/compatibility/GovernorCompatibilityBravo.sol#L72 | ||
/// See {GovernorCompatibilityBravoUpgradeable-propose} | ||
function propose( | ||
address[] memory _targets, | ||
uint256[] memory _values, | ||
string[] memory _signatures, | ||
bytes[] memory _calldatas, | ||
string memory _description | ||
) | ||
public | ||
virtual | ||
override(GovernorCompatibilityBravoUpgradeable) | ||
returns (uint256) | ||
{ | ||
if (_signatures.length != _calldatas.length) revert TG_INVALID_SIGNATURES_LENGTH(); | ||
|
||
return GovernorCompatibilityBravoUpgradeable.propose( | ||
_targets, _values, _signatures, _calldatas, _description | ||
); | ||
} | ||
|
||
/// @dev See {GovernorUpgradeable-supportsInterface} | ||
function supportsInterface(bytes4 _interfaceId) | ||
public | ||
|
@@ -124,6 +93,23 @@ contract TaikoGovernor is | |
return 1_000_000_000 ether / 10_000; // 0.01% of Taiko Token | ||
} | ||
|
||
/// @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, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,6 @@ import "../../common/EssentialContract.sol"; | |
/// @notice A contract that manages a set of guardians and their approvals. | ||
/// @custom:security-contact [email protected] | ||
abstract contract Guardians is EssentialContract { | ||
/// @notice The minimum number of guardians | ||
uint256 public constant MIN_NUM_GUARDIANS = 5; | ||
|
||
/// @notice Contains the index of the guardian in `guardians` plus one (zero means not a | ||
/// guardian) | ||
/// @dev Slot 1 | ||
|
@@ -58,15 +55,13 @@ abstract contract Guardians is EssentialContract { | |
onlyOwner | ||
nonReentrant | ||
{ | ||
// We need at least MIN_NUM_GUARDIANS and at most 255 guardians (so the approval bits fit in | ||
// a uint256) | ||
if (_newGuardians.length < MIN_NUM_GUARDIANS || _newGuardians.length > type(uint8).max) { | ||
// We need at most 255 guardians (so the approval bits fit in a uint256) | ||
if (_newGuardians.length == 0 || _newGuardians.length > type(uint8).max) { | ||
revert INVALID_GUARDIAN_SET(); | ||
} | ||
// Minimum number of guardians to approve is at least equal or greater than half the | ||
// guardians (rounded up) and less or equal than the total number of guardians | ||
if (_minGuardians < (_newGuardians.length + 1) >> 1 || _minGuardians > _newGuardians.length) | ||
{ | ||
if (_minGuardians == 0 || _minGuardians > _newGuardians.length) { | ||
revert INVALID_MIN_GUARDIANS(); | ||
} | ||
|
||
|
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.