From 1f61c0f41b25cfc15b24e5e14c754f6bacefc69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 16 Feb 2024 14:48:42 +0530 Subject: [PATCH 1/7] Fix OZ bump side effects --- .../contracts/L1/gov/TaikoGovernor.sol | 20 +++++++++++++++++- .../test/common/EssentialContract.t.sol | 21 ++++++++----------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol index c146bb42c6f..05e9574c440 100644 --- a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol +++ b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol @@ -68,7 +68,8 @@ contract TaikoGovernor is override(GovernorUpgradeable, GovernorTimelockControlUpgradeable, IERC165Upgradeable) returns (bool) { - return super.supportsInterface(interfaceId); + return interfaceId == type(IGovernorUpgradeable).interfaceId + || super.supportsInterface(interfaceId); } function state(uint256 proposalId) @@ -96,6 +97,23 @@ 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/test/common/EssentialContract.t.sol b/packages/protocol/test/common/EssentialContract.t.sol index db68fe03815..4a707fb4e87 100644 --- a/packages/protocol/test/common/EssentialContract.t.sol +++ b/packages/protocol/test/common/EssentialContract.t.sol @@ -27,6 +27,11 @@ 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); @@ -80,18 +85,10 @@ contract TestOwnerUUPSUpgradable is TaikoTest { vm.prank(Carol); assertEq(target.owner(), Alice); - // 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(); + // 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); // Alice can adjust(); vm.prank(Alice); From b73818382b074bbba34c7ae84d60ae3523101a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 16 Feb 2024 15:00:12 +0530 Subject: [PATCH 2/7] remove unnecessary inheritance --- packages/protocol/contracts/L1/gov/TaikoGovernor.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol index 05e9574c440..faa5b86d12a 100644 --- a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol +++ b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol @@ -14,7 +14,6 @@ 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"; @@ -26,7 +25,6 @@ import "../../common/OwnerUUPSUpgradable.sol"; contract TaikoGovernor is OwnerUUPSUpgradable, - GovernorUpgradeable, GovernorCompatibilityBravoUpgradeable, GovernorVotesUpgradeable, GovernorVotesQuorumFractionUpgradeable, From 2ef751f718bf79cd54772a4c08891ac339a49245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 16 Feb 2024 15:22:27 +0530 Subject: [PATCH 3/7] remove unnecessary inheritance --- packages/protocol/contracts/L1/gov/TaikoGovernor.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol index faa5b86d12a..63b027c5f82 100644 --- a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol +++ b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol @@ -16,7 +16,6 @@ pragma solidity 0.8.24; 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 @@ -26,7 +25,6 @@ import "../../common/OwnerUUPSUpgradable.sol"; contract TaikoGovernor is OwnerUUPSUpgradable, GovernorCompatibilityBravoUpgradeable, - GovernorVotesUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorTimelockControlUpgradeable { From ef95aff36f2d6f72918bf659f7b3c419ff2357ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 16 Feb 2024 15:39:55 +0530 Subject: [PATCH 4/7] shortening name --- .../L1/gov/{TaikoGovernor.sol => TkoGv.sol} | 5 +- packages/protocol/script/DeployOnL1.s.sol | 6 +- .../script/upgrade/UpgradeTaikoGovernor.s.sol | 12 +-- ...{TaikoGovernor.t.sol => TkoGovernor.t.sol} | 90 +++++++++---------- 4 files changed, 54 insertions(+), 59 deletions(-) rename packages/protocol/contracts/L1/gov/{TaikoGovernor.sol => TkoGv.sol} (97%) rename packages/protocol/test/L1/gov/{TaikoGovernor.t.sol => TkoGovernor.t.sol} (62%) diff --git a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol b/packages/protocol/contracts/L1/gov/TkoGv.sol similarity index 97% rename from packages/protocol/contracts/L1/gov/TaikoGovernor.sol rename to packages/protocol/contracts/L1/gov/TkoGv.sol index 63b027c5f82..eec92e257d1 100644 --- a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol +++ b/packages/protocol/contracts/L1/gov/TkoGv.sol @@ -22,7 +22,7 @@ import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorTimelockControlUpgradeable.sol"; import "../../common/OwnerUUPSUpgradable.sol"; -contract TaikoGovernor is +contract TkoGv is OwnerUUPSUpgradable, GovernorCompatibilityBravoUpgradeable, GovernorVotesQuorumFractionUpgradeable, @@ -38,8 +38,7 @@ contract TaikoGovernor is initializer { __OwnerUUPSUpgradable_init(); - __Governor_init("TaikoGovernor"); - __GovernorCompatibilityBravo_init(); + __Governor_init("TkoGv"); __GovernorVotes_init(_token); __GovernorVotesQuorumFraction_init(4); __GovernorTimelockControl_init(_timelock); diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index ab9dd077508..70c906a8c0f 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -23,7 +23,7 @@ import "../contracts/L1/tiers/TaikoA6TierProvider.sol"; import "../contracts/L1/tiers/OptimisticTierProvider.sol"; import "../contracts/L1/hooks/AssignmentHook.sol"; import "../contracts/L1/gov/TaikoTimelockController.sol"; -import "../contracts/L1/gov/TaikoGovernor.sol"; +import "../contracts/L1/gov/TkoGv.sol"; import "../contracts/bridge/Bridge.sol"; import "../contracts/tokenvault/ERC20Vault.sol"; import "../contracts/tokenvault/ERC1155Vault.sol"; @@ -190,9 +190,9 @@ contract DeployOnL1 is DeployCapability { address governor = deployProxy({ name: "taiko_governor", - impl: address(new TaikoGovernor()), + impl: address(new TkoGv()), data: abi.encodeCall( - TaikoGovernor.init, + TkoGv.init, (IVotesUpgradeable(taikoToken), TimelockControllerUpgradeable(payable(timelock))) ), registerTo: address(0), diff --git a/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol index 87bb815ddb4..484386e7c7f 100644 --- a/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol +++ b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol @@ -16,15 +16,15 @@ pragma solidity ^0.8.24; import "forge-std/src/Script.sol"; import "forge-std/src/console2.sol"; -import "../../contracts/L1/gov/TaikoGovernor.sol"; +import "../../contracts/L1/gov/TkoGv.sol"; import "./UpgradeScript.s.sol"; -contract UpgradeTaikoGovernor is UpgradeScript { +contract UpgradeTkoGovernor is UpgradeScript { function run() external setUp { - console2.log("upgrading TaikoGovernor"); - TaikoGovernor newTaikoGovernor = new TaikoGovernor(); - upgrade(address(newTaikoGovernor)); + console2.log("upgrading TkoGv"); + TkoGv newTkoGovernor = new TkoGv(); + upgrade(address(newTkoGovernor)); - console2.log("upgraded TaikoGovernor to", address(newTaikoGovernor)); + console2.log("upgraded TkoGv to", address(newTkoGovernor)); } } diff --git a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol b/packages/protocol/test/L1/gov/TkoGovernor.t.sol similarity index 62% rename from packages/protocol/test/L1/gov/TaikoGovernor.t.sol rename to packages/protocol/test/L1/gov/TkoGovernor.t.sol index 1839017ad4a..8de8029952a 100644 --- a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol +++ b/packages/protocol/test/L1/gov/TkoGovernor.t.sol @@ -2,14 +2,14 @@ pragma solidity 0.8.24; import "../TaikoL1TestBase.sol"; -import "../../../contracts/L1/gov/TaikoGovernor.sol"; +import "../../../contracts/L1/gov/TkoGv.sol"; import "../../../contracts/L1/gov/TaikoTimelockController.sol"; import "@openzeppelin/contracts/governance/IGovernor.sol"; import "@openzeppelin/contracts/governance/TimelockController.sol"; /// @author Kirk Baird -contract TestTaikoGovernor is TaikoL1TestBase { - TaikoGovernor public taikoGovernor; +contract TestTkoGovernor is TaikoL1TestBase { + TkoGv public tkoGovernor; TaikoTimelockController public taikoTimelockController; function deployTaikoL1() internal override returns (TaikoL1) { @@ -36,19 +36,19 @@ contract TestTaikoGovernor is TaikoL1TestBase { uint256 minDelay = 0.5 days; taikoTimelockController.init(minDelay); - // deploy TaikoGovernor - taikoGovernor = TaikoGovernor( + // deploy TkoGv + tkoGovernor = TkoGv( payable( LibDeploy.deployERC1967Proxy({ - impl: address(new TaikoGovernor()), + impl: address(new TkoGv()), owner: address(0), data: "" }) ) ); - // init TaikoGovernor - taikoGovernor.init(tko, taikoTimelockController); + // init TkoGv + tkoGovernor.init(tko, taikoTimelockController); // Alice delegate voting power to self vm.startPrank(Alice); tko.delegate(Alice); @@ -58,20 +58,20 @@ contract TestTaikoGovernor is TaikoL1TestBase { vm.startPrank(owner); // Owner set access controls for timelock controller taikoTimelockController.grantRole( - taikoTimelockController.PROPOSER_ROLE(), address(taikoGovernor) + taikoTimelockController.PROPOSER_ROLE(), address(tkoGovernor) ); taikoTimelockController.grantRole( - taikoTimelockController.EXECUTOR_ROLE(), address(taikoGovernor) + taikoTimelockController.EXECUTOR_ROLE(), address(tkoGovernor) ); taikoTimelockController.grantRole( - taikoTimelockController.CANCELLER_ROLE(), address(taikoGovernor) + taikoTimelockController.CANCELLER_ROLE(), address(tkoGovernor) ); // Owner delegate voting power to self tko.delegate(owner); // Transfer Alice double the proposal threshold worth of tokens - uint256 proposalThreshold = taikoGovernor.proposalThreshold(); + uint256 proposalThreshold = tkoGovernor.proposalThreshold(); tko.transfer(Alice, proposalThreshold * 2); tko.transfer(Bob, proposalThreshold * 5); vm.roll(block.number + 1); // increase block number to help facilitate snapshots in @@ -82,55 +82,53 @@ contract TestTaikoGovernor is TaikoL1TestBase { function test_init() public { // GovernorVotesQuorumFractionUpgradeable - assertEq(taikoGovernor.quorumNumerator(), 4, "Incorrect initial quorum numerator"); + assertEq(tkoGovernor.quorumNumerator(), 4, "Incorrect initial quorum numerator"); assertEq( - taikoGovernor.quorumNumerator(block.number), - 4, - "Incorrect initial block quorum numerator" + tkoGovernor.quorumNumerator(block.number), 4, "Incorrect initial block quorum numerator" ); - assertEq(taikoGovernor.quorumDenominator(), 100, "Incorrect quorum denominator"); + assertEq(tkoGovernor.quorumDenominator(), 100, "Incorrect quorum denominator"); // GovernorUpgradeable - assertEq(taikoGovernor.name(), "TaikoGovernor", "Incorrect name"); - assertEq(taikoGovernor.version(), "1", "Incorrect version"); + assertEq(tkoGovernor.name(), "TkoGv", "Incorrect name"); + assertEq(tkoGovernor.version(), "1", "Incorrect version"); // GovernorVotesUpgradeable - assertEq(address(taikoGovernor.token()), address(tko), "Incorrect token"); + assertEq(address(tkoGovernor.token()), address(tko), "Incorrect token"); // GovernorCompatibilityBravoUpgradeable assertEq( - taikoGovernor.COUNTING_MODE(), "support=bravo&quorum=bravo", "Incorrect counting mode" + tkoGovernor.COUNTING_MODE(), "support=bravo&quorum=bravo", "Incorrect counting mode" ); // GovernorTimelockControlUpgradeable - assertEq(taikoGovernor.timelock(), address(taikoTimelockController), "Incorrect timelock"); + assertEq(tkoGovernor.timelock(), address(taikoTimelockController), "Incorrect timelock"); // Interfaces assertEq( - taikoGovernor.supportsInterface(type(IGovernorTimelockUpgradeable).interfaceId), + tkoGovernor.supportsInterface(type(IGovernorTimelockUpgradeable).interfaceId), true, "Incorrect supports interface" ); assertEq( - taikoGovernor.supportsInterface(type(IGovernorUpgradeable).interfaceId), + tkoGovernor.supportsInterface(type(IGovernorUpgradeable).interfaceId), true, "Incorrect supports interface" ); assertEq( - taikoGovernor.supportsInterface(type(IERC1155ReceiverUpgradeable).interfaceId), + tkoGovernor.supportsInterface(type(IERC1155ReceiverUpgradeable).interfaceId), true, "Incorrect supports interface" ); - // TaikoGovernor - assertEq(taikoGovernor.votingDelay(), 7200, "Incorrect voting delay"); - assertEq(taikoGovernor.votingPeriod(), 50_400, "Incorrect voting period"); - assertEq(taikoGovernor.proposalThreshold(), 100_000 ether, "Incorrect proposal threshold"); + // TkoGv + assertEq(tkoGovernor.votingDelay(), 7200, "Incorrect voting delay"); + assertEq(tkoGovernor.votingPeriod(), 50_400, "Incorrect voting period"); + assertEq(tkoGovernor.proposalThreshold(), 100_000 ether, "Incorrect proposal threshold"); } // Tests `propose()` function test_propose() public { - // Parameters for `TaikoGovernor.propose()` + // Parameters for `tkoGovernor.propose()` address[] memory targets = new address[](1); targets[0] = Alice; @@ -145,10 +143,10 @@ contract TestTaikoGovernor is TaikoL1TestBase { vm.startPrank(proposer); // Prepare for event emission - uint256 startBlock = block.number + taikoGovernor.votingDelay(); - uint256 endBlock = startBlock + taikoGovernor.votingPeriod(); + uint256 startBlock = block.number + tkoGovernor.votingDelay(); + uint256 endBlock = startBlock + tkoGovernor.votingPeriod(); uint256 calculatedProposalId = - taikoGovernor.hashProposal(targets, values, calldatas, keccak256(bytes(description))); + tkoGovernor.hashProposal(targets, values, calldatas, keccak256(bytes(description))); vm.expectEmit(true, true, true, true); emit IGovernor.ProposalCreated( @@ -164,22 +162,20 @@ contract TestTaikoGovernor is TaikoL1TestBase { ); // `propose()` - uint256 proposalId = taikoGovernor.propose(targets, values, calldatas, description); + uint256 proposalId = tkoGovernor.propose(targets, values, calldatas, description); vm.stopPrank(); // Validate proposal assertEq(proposalId, calculatedProposalId, "Proposal does not have the correct ID"); assertEq( - taikoGovernor.state(proposalId) == IGovernorUpgradeable.ProposalState.Pending, + tkoGovernor.state(proposalId) == IGovernorUpgradeable.ProposalState.Pending, true, "Incorrect proposal state" ); assertEq( - taikoGovernor.proposalSnapshot(proposalId), startBlock, "Incorrect proposal snapshot" - ); - assertEq( - taikoGovernor.proposalDeadline(proposalId), endBlock, "Incorrect proposal deadline" + tkoGovernor.proposalSnapshot(proposalId), startBlock, "Incorrect proposal snapshot" ); + assertEq(tkoGovernor.proposalDeadline(proposalId), endBlock, "Incorrect proposal deadline"); } // Tests `castVote()`, `queue()` and `execute()` @@ -201,26 +197,26 @@ contract TestTaikoGovernor is TaikoL1TestBase { // `propose()` vm.startPrank(proposer); - uint256 proposalId = taikoGovernor.propose(targets, values, calldatas, description); + uint256 proposalId = tkoGovernor.propose(targets, values, calldatas, description); vm.stopPrank(); // Skip to voting start - uint256 startBlock = taikoGovernor.proposalSnapshot(proposalId); + uint256 startBlock = tkoGovernor.proposalSnapshot(proposalId); vm.roll(startBlock + 1); // `castVote()` vm.startPrank(tko.owner()); - taikoGovernor.castVote(proposalId, 1); // 1 = for + tkoGovernor.castVote(proposalId, 1); // 1 = for // Skip to voting end - uint256 endBlock = taikoGovernor.proposalDeadline(proposalId); + uint256 endBlock = tkoGovernor.proposalDeadline(proposalId); vm.roll(endBlock + 1); // `queue()` successful proposal - taikoGovernor.queue(proposalId); + tkoGovernor.queue(proposalId); // Skip delay amount of time - uint256 eta = taikoGovernor.proposalEta(proposalId); + uint256 eta = tkoGovernor.proposalEta(proposalId); vm.warp(eta + 1); // Prepare execute event @@ -231,8 +227,8 @@ contract TestTaikoGovernor is TaikoL1TestBase { emit TimelockController.CallExecuted(timelockId, 0, targets[0], values[0], calldatas[0]); // `execute()` - // taikoGovernor.execute(targets, values, calldatas, descriptionHash); - taikoGovernor.execute(proposalId); + // tkoGovernor.execute(targets, values, calldatas, descriptionHash); + tkoGovernor.execute(proposalId); vm.stopPrank(); } From 689d0993980af719b5070935622c032f66dc5ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 16 Feb 2024 21:30:12 +0530 Subject: [PATCH 5/7] rename back --- .../L1/gov/{TkoGv.sol => TaikoGovernor.sol} | 4 ++-- packages/protocol/script/DeployOnL1.s.sol | 6 +++--- .../script/upgrade/UpgradeTaikoGovernor.s.sol | 8 ++++---- packages/protocol/test/L1/gov/TkoGovernor.t.sol | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) rename packages/protocol/contracts/L1/gov/{TkoGv.sol => TaikoGovernor.sol} (98%) diff --git a/packages/protocol/contracts/L1/gov/TkoGv.sol b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol similarity index 98% rename from packages/protocol/contracts/L1/gov/TkoGv.sol rename to packages/protocol/contracts/L1/gov/TaikoGovernor.sol index eec92e257d1..ad2e3d0bc3e 100644 --- a/packages/protocol/contracts/L1/gov/TkoGv.sol +++ b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol @@ -22,7 +22,7 @@ import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorTimelockControlUpgradeable.sol"; import "../../common/OwnerUUPSUpgradable.sol"; -contract TkoGv is +contract TaikoGovernor is OwnerUUPSUpgradable, GovernorCompatibilityBravoUpgradeable, GovernorVotesQuorumFractionUpgradeable, @@ -38,7 +38,7 @@ contract TkoGv is initializer { __OwnerUUPSUpgradable_init(); - __Governor_init("TkoGv"); + __Governor_init("Taiko"); __GovernorVotes_init(_token); __GovernorVotesQuorumFraction_init(4); __GovernorTimelockControl_init(_timelock); diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index 70c906a8c0f..ab9dd077508 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -23,7 +23,7 @@ import "../contracts/L1/tiers/TaikoA6TierProvider.sol"; import "../contracts/L1/tiers/OptimisticTierProvider.sol"; import "../contracts/L1/hooks/AssignmentHook.sol"; import "../contracts/L1/gov/TaikoTimelockController.sol"; -import "../contracts/L1/gov/TkoGv.sol"; +import "../contracts/L1/gov/TaikoGovernor.sol"; import "../contracts/bridge/Bridge.sol"; import "../contracts/tokenvault/ERC20Vault.sol"; import "../contracts/tokenvault/ERC1155Vault.sol"; @@ -190,9 +190,9 @@ contract DeployOnL1 is DeployCapability { address governor = deployProxy({ name: "taiko_governor", - impl: address(new TkoGv()), + impl: address(new TaikoGovernor()), data: abi.encodeCall( - TkoGv.init, + TaikoGovernor.init, (IVotesUpgradeable(taikoToken), TimelockControllerUpgradeable(payable(timelock))) ), registerTo: address(0), diff --git a/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol index 484386e7c7f..3ad05afcfdb 100644 --- a/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol +++ b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol @@ -16,15 +16,15 @@ pragma solidity ^0.8.24; import "forge-std/src/Script.sol"; import "forge-std/src/console2.sol"; -import "../../contracts/L1/gov/TkoGv.sol"; +import "../../contracts/L1/gov/TaikoGovernor.sol"; import "./UpgradeScript.s.sol"; contract UpgradeTkoGovernor is UpgradeScript { function run() external setUp { - console2.log("upgrading TkoGv"); - TkoGv newTkoGovernor = new TkoGv(); + console2.log("upgrading TaikoGovernor"); + TaikoGovernor newTkoGovernor = new TaikoGovernor(); upgrade(address(newTkoGovernor)); - console2.log("upgraded TkoGv to", address(newTkoGovernor)); + console2.log("upgraded TaikoGovernor to", address(newTkoGovernor)); } } diff --git a/packages/protocol/test/L1/gov/TkoGovernor.t.sol b/packages/protocol/test/L1/gov/TkoGovernor.t.sol index 8de8029952a..75236add904 100644 --- a/packages/protocol/test/L1/gov/TkoGovernor.t.sol +++ b/packages/protocol/test/L1/gov/TkoGovernor.t.sol @@ -2,14 +2,14 @@ pragma solidity 0.8.24; import "../TaikoL1TestBase.sol"; -import "../../../contracts/L1/gov/TkoGv.sol"; +import "../../../contracts/L1/gov/TaikoGovernor.sol"; import "../../../contracts/L1/gov/TaikoTimelockController.sol"; import "@openzeppelin/contracts/governance/IGovernor.sol"; import "@openzeppelin/contracts/governance/TimelockController.sol"; /// @author Kirk Baird contract TestTkoGovernor is TaikoL1TestBase { - TkoGv public tkoGovernor; + TaikoGovernor public tkoGovernor; TaikoTimelockController public taikoTimelockController; function deployTaikoL1() internal override returns (TaikoL1) { @@ -36,18 +36,18 @@ contract TestTkoGovernor is TaikoL1TestBase { uint256 minDelay = 0.5 days; taikoTimelockController.init(minDelay); - // deploy TkoGv - tkoGovernor = TkoGv( + // deploy TaikoGovernor + tkoGovernor = TaikoGovernor( payable( LibDeploy.deployERC1967Proxy({ - impl: address(new TkoGv()), + impl: address(new TaikoGovernor()), owner: address(0), data: "" }) ) ); - // init TkoGv + // init TaikoGovernor tkoGovernor.init(tko, taikoTimelockController); // Alice delegate voting power to self vm.startPrank(Alice); @@ -89,7 +89,7 @@ contract TestTkoGovernor is TaikoL1TestBase { assertEq(tkoGovernor.quorumDenominator(), 100, "Incorrect quorum denominator"); // GovernorUpgradeable - assertEq(tkoGovernor.name(), "TkoGv", "Incorrect name"); + assertEq(tkoGovernor.name(), "Taiko", "Incorrect name"); assertEq(tkoGovernor.version(), "1", "Incorrect version"); // GovernorVotesUpgradeable @@ -120,7 +120,7 @@ contract TestTkoGovernor is TaikoL1TestBase { "Incorrect supports interface" ); - // TkoGv + // TaikoGovernor assertEq(tkoGovernor.votingDelay(), 7200, "Incorrect voting delay"); assertEq(tkoGovernor.votingPeriod(), 50_400, "Incorrect voting period"); assertEq(tkoGovernor.proposalThreshold(), 100_000 ether, "Incorrect proposal threshold"); From 7b1674fc23814213866e19076f2cf2a33d89a8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 16 Feb 2024 21:52:38 +0530 Subject: [PATCH 6/7] rename tests and sciprts back too --- .../script/upgrade/UpgradeTaikoGovernor.s.sol | 8 +- ...{TkoGovernor.t.sol => TaikoGovernor.t.sol} | 80 ++++++++++--------- 2 files changed, 46 insertions(+), 42 deletions(-) rename packages/protocol/test/L1/gov/{TkoGovernor.t.sol => TaikoGovernor.t.sol} (65%) diff --git a/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol index 3ad05afcfdb..87bb815ddb4 100644 --- a/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol +++ b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.s.sol @@ -19,12 +19,12 @@ import "forge-std/src/console2.sol"; import "../../contracts/L1/gov/TaikoGovernor.sol"; import "./UpgradeScript.s.sol"; -contract UpgradeTkoGovernor is UpgradeScript { +contract UpgradeTaikoGovernor is UpgradeScript { function run() external setUp { console2.log("upgrading TaikoGovernor"); - TaikoGovernor newTkoGovernor = new TaikoGovernor(); - upgrade(address(newTkoGovernor)); + TaikoGovernor newTaikoGovernor = new TaikoGovernor(); + upgrade(address(newTaikoGovernor)); - console2.log("upgraded TaikoGovernor to", address(newTkoGovernor)); + console2.log("upgraded TaikoGovernor to", address(newTaikoGovernor)); } } diff --git a/packages/protocol/test/L1/gov/TkoGovernor.t.sol b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol similarity index 65% rename from packages/protocol/test/L1/gov/TkoGovernor.t.sol rename to packages/protocol/test/L1/gov/TaikoGovernor.t.sol index 75236add904..c69ca961080 100644 --- a/packages/protocol/test/L1/gov/TkoGovernor.t.sol +++ b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol @@ -8,8 +8,8 @@ import "@openzeppelin/contracts/governance/IGovernor.sol"; import "@openzeppelin/contracts/governance/TimelockController.sol"; /// @author Kirk Baird -contract TestTkoGovernor is TaikoL1TestBase { - TaikoGovernor public tkoGovernor; +contract TestTaikoGovernor is TaikoL1TestBase { + TaikoGovernor public taikoGovernor; TaikoTimelockController public taikoTimelockController; function deployTaikoL1() internal override returns (TaikoL1) { @@ -37,7 +37,7 @@ contract TestTkoGovernor is TaikoL1TestBase { taikoTimelockController.init(minDelay); // deploy TaikoGovernor - tkoGovernor = TaikoGovernor( + taikoGovernor = TaikoGovernor( payable( LibDeploy.deployERC1967Proxy({ impl: address(new TaikoGovernor()), @@ -48,7 +48,7 @@ contract TestTkoGovernor is TaikoL1TestBase { ); // init TaikoGovernor - tkoGovernor.init(tko, taikoTimelockController); + taikoGovernor.init(tko, taikoTimelockController); // Alice delegate voting power to self vm.startPrank(Alice); tko.delegate(Alice); @@ -58,20 +58,20 @@ contract TestTkoGovernor is TaikoL1TestBase { vm.startPrank(owner); // Owner set access controls for timelock controller taikoTimelockController.grantRole( - taikoTimelockController.PROPOSER_ROLE(), address(tkoGovernor) + taikoTimelockController.PROPOSER_ROLE(), address(taikoGovernor) ); taikoTimelockController.grantRole( - taikoTimelockController.EXECUTOR_ROLE(), address(tkoGovernor) + taikoTimelockController.EXECUTOR_ROLE(), address(taikoGovernor) ); taikoTimelockController.grantRole( - taikoTimelockController.CANCELLER_ROLE(), address(tkoGovernor) + taikoTimelockController.CANCELLER_ROLE(), address(taikoGovernor) ); // Owner delegate voting power to self tko.delegate(owner); // Transfer Alice double the proposal threshold worth of tokens - uint256 proposalThreshold = tkoGovernor.proposalThreshold(); + uint256 proposalThreshold = taikoGovernor.proposalThreshold(); tko.transfer(Alice, proposalThreshold * 2); tko.transfer(Bob, proposalThreshold * 5); vm.roll(block.number + 1); // increase block number to help facilitate snapshots in @@ -82,53 +82,55 @@ contract TestTkoGovernor is TaikoL1TestBase { function test_init() public { // GovernorVotesQuorumFractionUpgradeable - assertEq(tkoGovernor.quorumNumerator(), 4, "Incorrect initial quorum numerator"); + assertEq(taikoGovernor.quorumNumerator(), 4, "Incorrect initial quorum numerator"); assertEq( - tkoGovernor.quorumNumerator(block.number), 4, "Incorrect initial block quorum numerator" + taikoGovernor.quorumNumerator(block.number), + 4, + "Incorrect initial block quorum numerator" ); - assertEq(tkoGovernor.quorumDenominator(), 100, "Incorrect quorum denominator"); + assertEq(taikoGovernor.quorumDenominator(), 100, "Incorrect quorum denominator"); // GovernorUpgradeable - assertEq(tkoGovernor.name(), "Taiko", "Incorrect name"); - assertEq(tkoGovernor.version(), "1", "Incorrect version"); + assertEq(taikoGovernor.name(), "Taiko", "Incorrect name"); + assertEq(taikoGovernor.version(), "1", "Incorrect version"); // GovernorVotesUpgradeable - assertEq(address(tkoGovernor.token()), address(tko), "Incorrect token"); + assertEq(address(taikoGovernor.token()), address(tko), "Incorrect token"); // GovernorCompatibilityBravoUpgradeable assertEq( - tkoGovernor.COUNTING_MODE(), "support=bravo&quorum=bravo", "Incorrect counting mode" + taikoGovernor.COUNTING_MODE(), "support=bravo&quorum=bravo", "Incorrect counting mode" ); // GovernorTimelockControlUpgradeable - assertEq(tkoGovernor.timelock(), address(taikoTimelockController), "Incorrect timelock"); + assertEq(taikoGovernor.timelock(), address(taikoTimelockController), "Incorrect timelock"); // Interfaces assertEq( - tkoGovernor.supportsInterface(type(IGovernorTimelockUpgradeable).interfaceId), + taikoGovernor.supportsInterface(type(IGovernorTimelockUpgradeable).interfaceId), true, "Incorrect supports interface" ); assertEq( - tkoGovernor.supportsInterface(type(IGovernorUpgradeable).interfaceId), + taikoGovernor.supportsInterface(type(IGovernorUpgradeable).interfaceId), true, "Incorrect supports interface" ); assertEq( - tkoGovernor.supportsInterface(type(IERC1155ReceiverUpgradeable).interfaceId), + taikoGovernor.supportsInterface(type(IERC1155ReceiverUpgradeable).interfaceId), true, "Incorrect supports interface" ); // TaikoGovernor - assertEq(tkoGovernor.votingDelay(), 7200, "Incorrect voting delay"); - assertEq(tkoGovernor.votingPeriod(), 50_400, "Incorrect voting period"); - assertEq(tkoGovernor.proposalThreshold(), 100_000 ether, "Incorrect proposal threshold"); + assertEq(taikoGovernor.votingDelay(), 7200, "Incorrect voting delay"); + assertEq(taikoGovernor.votingPeriod(), 50_400, "Incorrect voting period"); + assertEq(taikoGovernor.proposalThreshold(), 100_000 ether, "Incorrect proposal threshold"); } // Tests `propose()` function test_propose() public { - // Parameters for `tkoGovernor.propose()` + // Parameters for `taikoGovernor.propose()` address[] memory targets = new address[](1); targets[0] = Alice; @@ -143,10 +145,10 @@ contract TestTkoGovernor is TaikoL1TestBase { vm.startPrank(proposer); // Prepare for event emission - uint256 startBlock = block.number + tkoGovernor.votingDelay(); - uint256 endBlock = startBlock + tkoGovernor.votingPeriod(); + uint256 startBlock = block.number + taikoGovernor.votingDelay(); + uint256 endBlock = startBlock + taikoGovernor.votingPeriod(); uint256 calculatedProposalId = - tkoGovernor.hashProposal(targets, values, calldatas, keccak256(bytes(description))); + taikoGovernor.hashProposal(targets, values, calldatas, keccak256(bytes(description))); vm.expectEmit(true, true, true, true); emit IGovernor.ProposalCreated( @@ -162,20 +164,22 @@ contract TestTkoGovernor is TaikoL1TestBase { ); // `propose()` - uint256 proposalId = tkoGovernor.propose(targets, values, calldatas, description); + uint256 proposalId = taikoGovernor.propose(targets, values, calldatas, description); vm.stopPrank(); // Validate proposal assertEq(proposalId, calculatedProposalId, "Proposal does not have the correct ID"); assertEq( - tkoGovernor.state(proposalId) == IGovernorUpgradeable.ProposalState.Pending, + taikoGovernor.state(proposalId) == IGovernorUpgradeable.ProposalState.Pending, true, "Incorrect proposal state" ); assertEq( - tkoGovernor.proposalSnapshot(proposalId), startBlock, "Incorrect proposal snapshot" + taikoGovernor.proposalSnapshot(proposalId), startBlock, "Incorrect proposal snapshot" + ); + assertEq( + taikoGovernor.proposalDeadline(proposalId), endBlock, "Incorrect proposal deadline" ); - assertEq(tkoGovernor.proposalDeadline(proposalId), endBlock, "Incorrect proposal deadline"); } // Tests `castVote()`, `queue()` and `execute()` @@ -197,26 +201,26 @@ contract TestTkoGovernor is TaikoL1TestBase { // `propose()` vm.startPrank(proposer); - uint256 proposalId = tkoGovernor.propose(targets, values, calldatas, description); + uint256 proposalId = taikoGovernor.propose(targets, values, calldatas, description); vm.stopPrank(); // Skip to voting start - uint256 startBlock = tkoGovernor.proposalSnapshot(proposalId); + uint256 startBlock = taikoGovernor.proposalSnapshot(proposalId); vm.roll(startBlock + 1); // `castVote()` vm.startPrank(tko.owner()); - tkoGovernor.castVote(proposalId, 1); // 1 = for + taikoGovernor.castVote(proposalId, 1); // 1 = for // Skip to voting end - uint256 endBlock = tkoGovernor.proposalDeadline(proposalId); + uint256 endBlock = taikoGovernor.proposalDeadline(proposalId); vm.roll(endBlock + 1); // `queue()` successful proposal - tkoGovernor.queue(proposalId); + taikoGovernor.queue(proposalId); // Skip delay amount of time - uint256 eta = tkoGovernor.proposalEta(proposalId); + uint256 eta = taikoGovernor.proposalEta(proposalId); vm.warp(eta + 1); // Prepare execute event @@ -227,8 +231,8 @@ contract TestTkoGovernor is TaikoL1TestBase { emit TimelockController.CallExecuted(timelockId, 0, targets[0], values[0], calldatas[0]); // `execute()` - // tkoGovernor.execute(targets, values, calldatas, descriptionHash); - tkoGovernor.execute(proposalId); + // taikoGovernor.execute(targets, values, calldatas, descriptionHash); + taikoGovernor.execute(proposalId); vm.stopPrank(); } From 51082026d122521ac55802996914126f112545d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 16 Feb 2024 21:59:57 +0530 Subject: [PATCH 7/7] typo --- packages/protocol/test/L1/gov/TaikoGovernor.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol index c69ca961080..b52a1eb50d5 100644 --- a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol +++ b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol @@ -130,7 +130,7 @@ contract TestTaikoGovernor is TaikoL1TestBase { // Tests `propose()` function test_propose() public { - // Parameters for `taikoGovernor.propose()` + // Parameters for `TaikoGovernor.propose()` address[] memory targets = new address[](1); targets[0] = Alice;