From 994e29e67f68b2478c2e79ce28c9542fd048dc3c Mon Sep 17 00:00:00 2001 From: d1onys1us <13951458+d1onys1us@users.noreply.github.com> Date: Sat, 17 Feb 2024 21:25:08 -0500 Subject: [PATCH] revert(protocol): revert update open-zeppelin contracts (#15896) --- .../contracts/L1/gov/TaikoGovernor.sol | 27 +++++-------------- packages/protocol/package.json | 4 +-- .../protocol/test/L1/gov/TaikoGovernor.t.sol | 2 +- .../test/common/EssentialContract.t.sol | 21 ++++++++------- pnpm-lock.yaml | 16 +++++------ 5 files changed, 30 insertions(+), 40 deletions(-) diff --git a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol index ad2e3d0bc3e..c146bb42c6f 100644 --- a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol +++ b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol @@ -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 @@ -24,7 +26,9 @@ import "../../common/OwnerUUPSUpgradable.sol"; contract TaikoGovernor is OwnerUUPSUpgradable, + GovernorUpgradeable, GovernorCompatibilityBravoUpgradeable, + GovernorVotesUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorTimelockControlUpgradeable { @@ -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); @@ -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) @@ -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, diff --git a/packages/protocol/package.json b/packages/protocol/package.json index a537bde6525..552d105e431 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -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", diff --git a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol index b52a1eb50d5..1839017ad4a 100644 --- a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol +++ b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol @@ -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 diff --git a/packages/protocol/test/common/EssentialContract.t.sol b/packages/protocol/test/common/EssentialContract.t.sol index 4a707fb4e87..db68fe03815 100644 --- a/packages/protocol/test/common/EssentialContract.t.sol +++ b/packages/protocol/test/common/EssentialContract.t.sol @@ -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); @@ -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); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d4af2c5f307..52ce5b68732 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -262,11 +262,11 @@ importers: packages/protocol: dependencies: '@openzeppelin/contracts': - specifier: 4.9.5 - version: 4.9.5 + specifier: 4.8.2 + version: 4.8.2 '@openzeppelin/contracts-upgradeable': - specifier: 4.9.5 - version: 4.9.5 + specifier: 4.8.2 + version: 4.8.2 ds-test: specifier: github:dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0 version: github.com/dapphub/ds-test/e282159d5170298eb2455a6c05280ab5a73a4ef0 @@ -4127,12 +4127,12 @@ packages: rimraf: 3.0.2 dev: true - /@openzeppelin/contracts-upgradeable@4.9.5: - resolution: {integrity: sha512-f7L1//4sLlflAN7fVzJLoRedrf5Na3Oal5PZfIq55NFcVZ90EpV1q5xOvL4lFvg3MNICSDr2hH0JUBxwlxcoPg==} + /@openzeppelin/contracts-upgradeable@4.8.2: + resolution: {integrity: sha512-zIggnBwemUmmt9IS73qxi+tumALxCY4QEs3zLCII78k0Gfse2hAOdAkuAeLUzvWUpneMUfFE5sGHzEUSTvn4Ag==} dev: false - /@openzeppelin/contracts@4.9.5: - resolution: {integrity: sha512-ZK+W5mVhRppff9BE6YdR8CC52C8zAvsVAiWhEtQ5+oNxFE6h1WdeWo+FJSF8KKvtxxVYZ7MTP/5KoVpAU3aSWg==} + /@openzeppelin/contracts@4.8.2: + resolution: {integrity: sha512-kEUOgPQszC0fSYWpbh2kT94ltOJwj1qfT2DWo+zVttmGmf97JZ99LspePNaeeaLhCImaHVeBbjaQFZQn7+Zc5g==} dev: false /@parcel/watcher-android-arm64@2.3.0: