Skip to content

Commit

Permalink
revert(protocol): revert update open-zeppelin contracts (#15896)
Browse files Browse the repository at this point in the history
  • Loading branch information
d1onys1us committed Feb 18, 2024
1 parent 4b5a95a commit 994e29e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 40 deletions.
27 changes: 7 additions & 20 deletions packages/protocol/contracts/L1/gov/TaikoGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

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
Expand All @@ -24,7 +26,9 @@ import "../../common/OwnerUUPSUpgradable.sol";

contract TaikoGovernor is
OwnerUUPSUpgradable,
GovernorUpgradeable,
GovernorCompatibilityBravoUpgradeable,
GovernorVotesUpgradeable,
GovernorVotesQuorumFractionUpgradeable,
GovernorTimelockControlUpgradeable
{
Expand All @@ -38,7 +42,8 @@ contract TaikoGovernor is
initializer
{
__OwnerUUPSUpgradable_init();
__Governor_init("Taiko");
__Governor_init("TaikoGovernor");
__GovernorCompatibilityBravo_init();
__GovernorVotes_init(_token);
__GovernorVotesQuorumFraction_init(4);
__GovernorTimelockControl_init(_timelock);
Expand All @@ -63,8 +68,7 @@ contract TaikoGovernor is
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable, IERC165Upgradeable)
returns (bool)
{
return interfaceId == type(IGovernorUpgradeable).interfaceId
|| super.supportsInterface(interfaceId);
return super.supportsInterface(interfaceId);
}

function state(uint256 proposalId)
Expand Down Expand Up @@ -92,23 +96,6 @@ contract TaikoGovernor is
return 1_000_000_000 ether / 10_000; // 0.01% of Taiko Token
}

/**
* @dev See {IGovernor-cancel}.
*/
function cancel(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
)
public
virtual
override(IGovernorUpgradeable, GovernorUpgradeable, GovernorCompatibilityBravoUpgradeable)
returns (uint256)
{
return super.cancel(targets, values, calldatas, descriptionHash);
}

function _execute(
uint256 proposalId,
address[] memory targets,
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@openzeppelin/contracts-upgradeable": "4.9.5",
"@openzeppelin/contracts": "4.9.5",
"@openzeppelin/contracts-upgradeable": "4.8.2",
"@openzeppelin/contracts": "4.8.2",
"forge-std": "github:foundry-rs/forge-std#v1.7.5",
"ds-test": "github:dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"solady": "github:Vectorized/solady#v0.0.167",
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/L1/gov/TaikoGovernor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract TestTaikoGovernor is TaikoL1TestBase {
assertEq(taikoGovernor.quorumDenominator(), 100, "Incorrect quorum denominator");

// GovernorUpgradeable
assertEq(taikoGovernor.name(), "Taiko", "Incorrect name");
assertEq(taikoGovernor.name(), "TaikoGovernor", "Incorrect name");
assertEq(taikoGovernor.version(), "1", "Incorrect version");

// GovernorVotesUpgradeable
Expand Down
21 changes: 12 additions & 9 deletions packages/protocol/test/common/EssentialContract.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ contract Target2 is Target1 {
}

contract TestOwnerUUPSUpgradable is TaikoTest {
/// @dev This is how we can query the admin - because from v.4.9.5 external admin() function
/// does not exist anymore.
bytes32 internal constant _ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

function test_essential_behind_1967_proxy() external {
bytes memory data = abi.encodeCall(Target1.init, ());
vm.startPrank(Alice);
Expand Down Expand Up @@ -85,10 +80,18 @@ contract TestOwnerUUPSUpgradable is TaikoTest {
vm.prank(Carol);
assertEq(target.owner(), Alice);

// Admin can be queried via storage slot only - no other way.
bytes32 adminSlotValue = vm.load(address(proxy), _ADMIN_SLOT);
address admin = address(uint160(uint256(adminSlotValue)));
assertEq(admin, Bob);
// Only Bob can call admin()
vm.prank(Bob);
assertEq(proxy.admin(), Bob);

// Other people, including Alice, cannot call admin()
vm.prank(Alice);
vm.expectRevert();
proxy.admin();

vm.prank(Carol);
vm.expectRevert();
proxy.admin();

// Alice can adjust();
vm.prank(Alice);
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 994e29e

Please sign in to comment.