diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c967de1..178ca7f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: id: build - name: Run tests - run: forge test -v + run: forge test --no-match-contract UpgradeToLive -v id: test - name: Check format diff --git a/foundry.toml b/foundry.toml index d6bdc27..b06044b 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,7 +5,6 @@ libs = ['lib'] # A list of library dire optimizer = true # Enable or disable the solc optimizer optimizer_runs = 200 # The number of optimizer runs fs_permissions = [{ access = "read", path = "./"}] # Gives permission to read files for enviroment files. -fail_on_revert = false # Not fail the test if the contract reverts [fuzz] runs = 2000 # The number of times to run the fuzzing tests @@ -29,4 +28,4 @@ runs = 10000 # The number of times to run the fuzzing tests [profile.super_deep.invariant] runs = 16 # The number of calls to make in the invariant tests -depth = 16 # The number of times to run the invariant tests \ No newline at end of file +depth = 16 # The number of times to run the invariant tests diff --git a/script/RedeployTimelock.s.sol b/script/RedeployTimelock.s.sol index e53015f..3b43eee 100644 --- a/script/RedeployTimelock.s.sol +++ b/script/RedeployTimelock.s.sol @@ -4,8 +4,9 @@ pragma solidity ^0.8.19; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; import {OptimismGovernor} from "../src/OptimismGovernor.sol"; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; import {Timelock, TimelockControllerUpgradeable} from "test/mocks/TimelockMock.sol"; import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; @@ -76,13 +77,11 @@ contract RedeployTimelock is Script { console.log("========== DEPLOYING NEW TIMELOCK =========="); timelock = Timelock( - payable( - new TransparentUpgradeableProxy( + payable(new TransparentUpgradeableProxy( address(new Timelock()), address(PROXY_ADMIN), abi.encodeWithSelector(Timelock.initialize.selector, MIN_DELAY, EXISTING_GOVERNOR, deployer) - ) - ) + )) ); console.log("New Timelock deployed:", address(timelock)); @@ -95,7 +94,7 @@ contract RedeployTimelock is Script { console.log("========== SETTING UP ROLES =========="); // Grant canceller roles - + timelock.grantRole(CANCELLER_ROLE, EXISTING_GOVERNOR); timelock.grantRole(CANCELLER_ROLE, L2_SAFE_1); timelock.grantRole(CANCELLER_ROLE, L2_SAFE_2); diff --git a/script/SetCancellers.s.sol b/script/SetCancellers.s.sol index 2b7cdaa..ec6eaba 100644 --- a/script/SetCancellers.s.sol +++ b/script/SetCancellers.s.sol @@ -4,11 +4,13 @@ pragma solidity ^0.8.19; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; import {OptimismGovernor} from "../src/OptimismGovernor.sol"; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import {AccessControlEnumerableUpgradeable} from - "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; +import { + AccessControlEnumerableUpgradeable +} from "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; /** * @title SetCancellers diff --git a/script/TimelockRoleManager.s.sol b/script/TimelockRoleManager.s.sol index 8956896..bb830e7 100644 --- a/script/TimelockRoleManager.s.sol +++ b/script/TimelockRoleManager.s.sol @@ -4,10 +4,12 @@ pragma solidity ^0.8.19; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; import {OptimismGovernor} from "../src/OptimismGovernor.sol"; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; -import {AccessControlEnumerableUpgradeable} from - "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + AccessControlEnumerableUpgradeable +} from "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; /** * @title TimelockRoleManager diff --git a/src/OptimismGovernor.sol b/src/OptimismGovernor.sol index d48671d..80835f6 100644 --- a/src/OptimismGovernor.sol +++ b/src/OptimismGovernor.sol @@ -3,8 +3,9 @@ pragma solidity ^0.8.19; import {GovernorUpgradeableV2} from "./lib/openzeppelin/v2/GovernorUpgradeableV2.sol"; import {GovernorCountingSimpleUpgradeableV2} from "./lib/openzeppelin/v2/GovernorCountingSimpleUpgradeableV2.sol"; -import {GovernorVotesQuorumFractionUpgradeableV2} from - "./lib/openzeppelin/v2/GovernorVotesQuorumFractionUpgradeableV2.sol"; +import { + GovernorVotesQuorumFractionUpgradeableV2 +} from "./lib/openzeppelin/v2/GovernorVotesQuorumFractionUpgradeableV2.sol"; import {GovernorVotesUpgradeableV2} from "./lib/openzeppelin/v2/GovernorVotesUpgradeableV2.sol"; import {GovernorSettingsUpgradeableV2} from "./lib/openzeppelin/v2/GovernorSettingsUpgradeableV2.sol"; import {GovernorTimelockControlUpgradeableV2} from "./lib/openzeppelin/v2/GovernorTimelockControlUpgradeableV2.sol"; @@ -17,10 +18,12 @@ import {VotingModule} from "./modules/VotingModule.sol"; import {IVotableSupplyOracle} from "./interfaces/IVotableSupplyOracle.sol"; import {IProposalTypesConfigurator} from "./interfaces/IProposalTypesConfigurator.sol"; import {IVotingToken} from "./interfaces/IVotingToken.sol"; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; -import {IGovernorTimelockUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/extensions/IGovernorTimelockUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + IGovernorTimelockUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/extensions/IGovernorTimelockUpgradeable.sol"; contract OptimismGovernor is Initializable, diff --git a/src/VotableSupplyOracle.sol b/src/VotableSupplyOracle.sol index 7e604fe..aa9abd0 100644 --- a/src/VotableSupplyOracle.sol +++ b/src/VotableSupplyOracle.sol @@ -32,9 +32,10 @@ contract VotableSupplyOracle is IVotableSupplyOracle, Ownable { _transferOwnership(initOwner); // Initialize votable supply - _votableSupplyHistory._checkpoints.push( - Checkpoints.Checkpoint({_blockNumber: block.number.toUint32(), _value: initVotableSupply.toUint224()}) - ); + _votableSupplyHistory._checkpoints + .push( + Checkpoints.Checkpoint({_blockNumber: block.number.toUint32(), _value: initVotableSupply.toUint224()}) + ); emit VotableSupplyUpdated(0, initVotableSupply); } diff --git a/src/alligator/AlligatorOP.sol b/src/alligator/AlligatorOP.sol index f7de05b..b749dc0 100644 --- a/src/alligator/AlligatorOP.sol +++ b/src/alligator/AlligatorOP.sol @@ -93,8 +93,8 @@ contract AlligatorOP is IAlligatorOP, UUPSUpgradeable, OwnableUpgradeable, Pausa mapping( address proxy => mapping( - uint256 proposalId => mapping(bytes32 authorityChainHash => mapping(address delegate => uint256)) - ) + uint256 proposalId => mapping(bytes32 authorityChainHash => mapping(address delegate => uint256)) + ) ) public votesCastByAuthorityChain; // ============================================================= @@ -427,8 +427,9 @@ contract AlligatorOP is IAlligatorOP, UUPSUpgradeable, OwnableUpgradeable, Pausa for (uint256 i = 1; i < authorityLength;) { // We save votesCast twice to always have the correct values for absolute and relative allowances - votesCastByAuthorityChain[proxy][proposalId][keccak256(abi.encode(authority[0:i]))][authority[i]] += - votesToCast; + votesCastByAuthorityChain[ + proxy + ][proposalId][keccak256(abi.encode(authority[0:i]))][authority[i]] += votesToCast; votesCast[proxy][proposalId][delegator][delegator = authority[i]] += votesToCast; ++i; @@ -769,8 +770,9 @@ contract AlligatorOP is IAlligatorOP, UUPSUpgradeable, OwnableUpgradeable, Pausa uint256 delegatorAllowance ) private pure returns (uint256) { if (allowanceType == IAlligatorOP.AllowanceType.Relative) { - return - subdelegationAllowance >= 1e5 ? delegatorAllowance : delegatorAllowance * subdelegationAllowance / 1e5; + return subdelegationAllowance >= 1e5 + ? delegatorAllowance + : delegatorAllowance * subdelegationAllowance / 1e5; } // else if (allowanceType == IAlligatorOP.AllowanceType.Absolute) diff --git a/src/interfaces/IAlligatorOP.sol b/src/interfaces/IAlligatorOP.sol index 836196b..22de75c 100644 --- a/src/interfaces/IAlligatorOP.sol +++ b/src/interfaces/IAlligatorOP.sol @@ -106,8 +106,7 @@ interface IAlligatorOP { function subdelegateBatched(address[] calldata targets, SubdelegationRules calldata subdelegateRules) external; - function subdelegateBatched(address[] calldata targets, SubdelegationRules[] calldata subdelegationRules) - external; + function subdelegateBatched(address[] calldata targets, SubdelegationRules[] calldata subdelegationRules) external; // ============================================================= // RESTRICTED // ============================================================= diff --git a/src/interfaces/IOptimismGovernor.sol b/src/interfaces/IOptimismGovernor.sol index bb36146..3cc8ae7 100644 --- a/src/interfaces/IOptimismGovernor.sol +++ b/src/interfaces/IOptimismGovernor.sol @@ -12,9 +12,7 @@ abstract contract IOptimismGovernor is IGovernor { function token() external view virtual returns (IVotesUpgradeable); - function increaseWeightCast(uint256 proposalId, address account, uint256 votes, uint256 proxyVotes) - external - virtual; + function increaseWeightCast(uint256 proposalId, address account, uint256 votes, uint256 proxyVotes) external virtual; function castVoteFromAlligator( uint256 proposalId, diff --git a/src/interfaces/IRule.sol b/src/interfaces/IRule.sol index 0410e5e..4165373 100644 --- a/src/interfaces/IRule.sol +++ b/src/interfaces/IRule.sol @@ -10,8 +10,5 @@ interface IRule { * @param support The support value for the vote. 0=against, 1=for, 2=abstain, 0xff=propose * @return IRule.validate.selector */ - function validate(address governor, address voter, uint256 proposalId, uint8 support) - external - view - returns (bytes4); + function validate(address governor, address voter, uint256 proposalId, uint8 support) external view returns (bytes4); } diff --git a/src/lib/openzeppelin/v2/GovernorCountingSimpleUpgradeableV2.sol b/src/lib/openzeppelin/v2/GovernorCountingSimpleUpgradeableV2.sol index 53ec9b0..02cd1e9 100644 --- a/src/lib/openzeppelin/v2/GovernorCountingSimpleUpgradeableV2.sol +++ b/src/lib/openzeppelin/v2/GovernorCountingSimpleUpgradeableV2.sol @@ -89,7 +89,11 @@ abstract contract GovernorCountingSimpleUpgradeableV2 is Initializable, Governor uint8 support, uint256 weight, bytes memory // params - ) internal virtual override { + ) + internal + virtual + override + { ProposalVote storage proposalVote = _proposalVotes[proposalId]; require(!proposalVote.hasVoted[account], "GovernorVotingSimple: vote already cast"); diff --git a/src/lib/openzeppelin/v2/GovernorTimelockControlUpgradeableV2.sol b/src/lib/openzeppelin/v2/GovernorTimelockControlUpgradeableV2.sol index 85bfd95..c84ed17 100644 --- a/src/lib/openzeppelin/v2/GovernorTimelockControlUpgradeableV2.sol +++ b/src/lib/openzeppelin/v2/GovernorTimelockControlUpgradeableV2.sol @@ -3,8 +3,9 @@ pragma solidity ^0.8.0; -import {IGovernorTimelockUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/extensions/IGovernorTimelockUpgradeable.sol"; +import { + IGovernorTimelockUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/extensions/IGovernorTimelockUpgradeable.sol"; import "./GovernorUpgradeableV2.sol"; import "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; diff --git a/src/lib/openzeppelin/v2/GovernorUpgradeableV2.sol b/src/lib/openzeppelin/v2/GovernorUpgradeableV2.sol index acba6b4..afe47c2 100644 --- a/src/lib/openzeppelin/v2/GovernorUpgradeableV2.sol +++ b/src/lib/openzeppelin/v2/GovernorUpgradeableV2.sol @@ -110,10 +110,9 @@ abstract contract GovernorUpgradeableV2 is // In addition to the current interfaceId, also support previous version of the interfaceId that did not // include the castVoteWithReasonAndParams() function as standard return interfaceId - == ( - type(IGovernorUpgradeable).interfaceId ^ this.castVoteWithReasonAndParams.selector - ^ this.castVoteWithReasonAndParamsBySig.selector ^ this.getVotesWithParams.selector - ) || interfaceId == type(IGovernorUpgradeable).interfaceId + == (type(IGovernorUpgradeable).interfaceId ^ this.castVoteWithReasonAndParams.selector + ^ this.castVoteWithReasonAndParamsBySig.selector ^ this.getVotesWithParams.selector) + || interfaceId == type(IGovernorUpgradeable).interfaceId || interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId || super.supportsInterface(interfaceId); } @@ -328,7 +327,10 @@ abstract contract GovernorUpgradeableV2 is uint256[] memory values, bytes[] memory calldatas, bytes32 /*descriptionHash*/ - ) internal virtual { + ) + internal + virtual + { string memory errorMessage = "Governor: call reverted without message"; for (uint256 i = 0; i < targets.length; ++i) { (bool success, bytes memory returndata) = targets[i].call{value: values[i]}(calldatas[i]); @@ -345,7 +347,10 @@ abstract contract GovernorUpgradeableV2 is uint256[] memory, /* values */ bytes[] memory calldatas, bytes32 /*descriptionHash*/ - ) internal virtual { + ) + internal + virtual + { if (_executor() != address(this)) { for (uint256 i = 0; i < targets.length; ++i) { if (targets[i] == address(this)) { @@ -364,7 +369,10 @@ abstract contract GovernorUpgradeableV2 is uint256[] memory, /* values */ bytes[] memory, /* calldatas */ bytes32 /*descriptionHash*/ - ) internal virtual { + ) + internal + virtual + { if (_executor() != address(this)) { if (!_governanceCall.empty()) { _governanceCall.clear(); diff --git a/src/lib/openzeppelin/v2/GovernorVotesUpgradeableV2.sol b/src/lib/openzeppelin/v2/GovernorVotesUpgradeableV2.sol index 0702e9b..2556b7c 100644 --- a/src/lib/openzeppelin/v2/GovernorVotesUpgradeableV2.sol +++ b/src/lib/openzeppelin/v2/GovernorVotesUpgradeableV2.sol @@ -26,7 +26,11 @@ abstract contract GovernorVotesUpgradeableV2 is Initializable, GovernorUpgradeab /** * Read the voting weight from the token's built in snapshot mechanism (see {Governor-_getVotes}). */ - function _getVotes(address account, uint256 blockNumber, bytes memory /*params*/ ) + function _getVotes( + address account, + uint256 blockNumber, + bytes memory /*params*/ + ) internal view virtual diff --git a/src/modules/ApprovalVotingModule.sol b/src/modules/ApprovalVotingModule.sol index 45c0e54..5866720 100644 --- a/src/modules/ApprovalVotingModule.sol +++ b/src/modules/ApprovalVotingModule.sol @@ -354,8 +354,7 @@ contract ApprovalVotingModule is VotingModule { * on expected types. */ function PROPOSAL_DATA_ENCODING() external pure virtual override returns (string memory) { - return - "((uint256 budgetTokensSpent,address[] targets,uint256[] values,bytes[] calldatas,string description)[] proposalOptions,(uint8 maxApprovals,uint8 criteria,address budgetToken,uint128 criteriaValue,uint128 budgetAmount) proposalSettings)"; + return "((uint256 budgetTokensSpent,address[] targets,uint256[] values,bytes[] calldatas,string description)[] proposalOptions,(uint8 maxApprovals,uint8 criteria,address budgetToken,uint128 criteriaValue,uint128 budgetAmount) proposalSettings)"; } /** diff --git a/src/modules/VotingModule.sol b/src/modules/VotingModule.sol index 4f714b9..ce67123 100644 --- a/src/modules/VotingModule.sol +++ b/src/modules/VotingModule.sol @@ -52,7 +52,14 @@ abstract contract VotingModule { virtual returns (address[] memory targets, uint256[] memory values, bytes[] memory calldatas); - function _voteSucceeded(uint256 /* proposalId */ ) external view virtual returns (bool) { + function _voteSucceeded( + uint256 /* proposalId */ + ) + external + view + virtual + returns (bool) + { return true; } diff --git a/test/AlligatorOP.t.sol b/test/AlligatorOP.t.sol index 4154a25..3452052 100644 --- a/test/AlligatorOP.t.sol +++ b/test/AlligatorOP.t.sol @@ -452,18 +452,19 @@ contract AlligatorOPTest is SetupAlligatorOP { address node = initAuthority[i]; vm.prank(node); - AlligatorOPMock(alligator).subdelegate( - initAuthority[i + 1], - IAlligatorOP.SubdelegationRules( - subdelegationRules.maxRedelegations, - subdelegationRules.blocksBeforeVoteCloses, - subdelegationRules.notValidBefore, - subdelegationRules.notValidAfter, - subdelegationRules.customRule, - rules.allowanceType, - rules.allowance - ) - ); + AlligatorOPMock(alligator) + .subdelegate( + initAuthority[i + 1], + IAlligatorOP.SubdelegationRules( + subdelegationRules.maxRedelegations, + subdelegationRules.blocksBeforeVoteCloses, + subdelegationRules.notValidBefore, + subdelegationRules.notValidAfter, + subdelegationRules.customRule, + rules.allowanceType, + rules.allowance + ) + ); } authority[initAuthority.length - 1] = initAuthority[initAuthority.length - 1]; @@ -499,18 +500,19 @@ contract AlligatorOPTest is SetupAlligatorOP { address node = initAuthority[i]; vm.prank(node); - AlligatorOPMock(alligator).subdelegate( - initAuthority[i + 1], - IAlligatorOP.SubdelegationRules( - subdelegationRules.maxRedelegations, - subdelegationRules.blocksBeforeVoteCloses, - subdelegationRules.notValidBefore, - subdelegationRules.notValidAfter, - subdelegationRules.customRule, - rules.allowanceType, - rules.allowance - ) - ); + AlligatorOPMock(alligator) + .subdelegate( + initAuthority[i + 1], + IAlligatorOP.SubdelegationRules( + subdelegationRules.maxRedelegations, + subdelegationRules.blocksBeforeVoteCloses, + subdelegationRules.notValidBefore, + subdelegationRules.notValidAfter, + subdelegationRules.customRule, + rules.allowanceType, + rules.allowance + ) + ); } authority[initAuthority.length - 1] = initAuthority[initAuthority.length - 1]; @@ -546,18 +548,19 @@ contract AlligatorOPTest is SetupAlligatorOP { address node = initAuthority[i]; vm.prank(node); - AlligatorOPMock(alligator).subdelegate( - initAuthority[i + 1], - IAlligatorOP.SubdelegationRules( - subdelegationRules.maxRedelegations, - subdelegationRules.blocksBeforeVoteCloses, - subdelegationRules.notValidBefore, - subdelegationRules.notValidAfter, - subdelegationRules.customRule, - rules.allowanceType, - rules.allowance - ) - ); + AlligatorOPMock(alligator) + .subdelegate( + initAuthority[i + 1], + IAlligatorOP.SubdelegationRules( + subdelegationRules.maxRedelegations, + subdelegationRules.blocksBeforeVoteCloses, + subdelegationRules.notValidBefore, + subdelegationRules.notValidAfter, + subdelegationRules.customRule, + rules.allowanceType, + rules.allowance + ) + ); } authority[initAuthority.length - 1] = initAuthority[initAuthority.length - 1]; @@ -593,18 +596,19 @@ contract AlligatorOPTest is SetupAlligatorOP { address node = initAuthority[i]; vm.prank(node); - AlligatorOPMock(alligator).subdelegate( - initAuthority[i + 1], - IAlligatorOP.SubdelegationRules( - subdelegationRules.maxRedelegations, - subdelegationRules.blocksBeforeVoteCloses, - subdelegationRules.notValidBefore, - subdelegationRules.notValidAfter, - subdelegationRules.customRule, - rules.allowanceType, - rules.allowance - ) - ); + AlligatorOPMock(alligator) + .subdelegate( + initAuthority[i + 1], + IAlligatorOP.SubdelegationRules( + subdelegationRules.maxRedelegations, + subdelegationRules.blocksBeforeVoteCloses, + subdelegationRules.notValidBefore, + subdelegationRules.notValidAfter, + subdelegationRules.customRule, + rules.allowanceType, + rules.allowance + ) + ); } authority[initAuthority.length - 1] = initAuthority[initAuthority.length - 1]; @@ -640,18 +644,19 @@ contract AlligatorOPTest is SetupAlligatorOP { address node = initAuthority[i]; vm.prank(node); - AlligatorOPMock(alligator).subdelegate( - initAuthority[i + 1], - IAlligatorOP.SubdelegationRules( - subdelegationRules.maxRedelegations, - subdelegationRules.blocksBeforeVoteCloses, - subdelegationRules.notValidBefore, - subdelegationRules.notValidAfter, - subdelegationRules.customRule, - rules.allowanceType, - rules.allowance - ) - ); + AlligatorOPMock(alligator) + .subdelegate( + initAuthority[i + 1], + IAlligatorOP.SubdelegationRules( + subdelegationRules.maxRedelegations, + subdelegationRules.blocksBeforeVoteCloses, + subdelegationRules.notValidBefore, + subdelegationRules.notValidAfter, + subdelegationRules.customRule, + rules.allowanceType, + rules.allowance + ) + ); } authority[initAuthority.length - 1] = initAuthority[initAuthority.length - 1]; @@ -671,7 +676,11 @@ contract AlligatorOPTest is SetupAlligatorOP { assertEq(forVotes, 50e18 + op.getVotes(address(this))); createAuthorityChain( - [alice, address(this)], [ReducedSubdelegationRules(IAlligatorOP.AllowanceType.Relative, 75e3 /* 75% */ )] + [alice, address(this)], + [ReducedSubdelegationRules( + IAlligatorOP.AllowanceType.Relative, + 75e3 /* 75% */ + )] ); standardCastVote(authority); @@ -1034,9 +1043,8 @@ contract AlligatorOPTest is SetupAlligatorOP { address proxy = _proxyAddress(authority[0]); uint256 proxyTotalVotes = op.getPastVotes(proxy, governor.proposalSnapshot(proposalId)); - (uint256 votesToCast) = AlligatorOPMock(alligator)._validate( - proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes - ); + (uint256 votesToCast) = AlligatorOPMock(alligator) + ._validate(proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes); assertEq(votesToCast, proxyTotalVotes); @@ -1048,9 +1056,8 @@ contract AlligatorOPTest is SetupAlligatorOP { vm.prank(alice); AlligatorOPMock(alligator).subdelegate(address(this), subRules); - (votesToCast) = AlligatorOPMock(alligator)._validate( - proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes - ); + (votesToCast) = AlligatorOPMock(alligator) + ._validate(proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes); assertEq(votesToCast, proxyTotalVotes * subRules.allowance / 1e5); @@ -1058,9 +1065,8 @@ contract AlligatorOPTest is SetupAlligatorOP { vm.prank(alice); AlligatorOPMock(alligator).subdelegate(address(this), subRules); - (votesToCast) = AlligatorOPMock(alligator)._validate( - proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes - ); + (votesToCast) = AlligatorOPMock(alligator) + ._validate(proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes); assertEq(votesToCast, proxyTotalVotes * subRules.allowance / 1e5); @@ -1068,9 +1074,8 @@ contract AlligatorOPTest is SetupAlligatorOP { vm.prank(alice); AlligatorOPMock(alligator).subdelegate(address(this), subRules); - (votesToCast) = AlligatorOPMock(alligator)._validate( - proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes - ); + (votesToCast) = AlligatorOPMock(alligator) + ._validate(proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes); assertEq(votesToCast, subRules.allowance); } @@ -1090,9 +1095,8 @@ contract AlligatorOPTest is SetupAlligatorOP { vm.expectRevert(ZeroVotesToCast.selector); vm.prank(carol); - AlligatorOPMock(alligator).limitedCastVoteWithReasonAndParamsBatched( - 200, authorities, proposalId, 1, "reason", "params" - ); + AlligatorOPMock(alligator) + .limitedCastVoteWithReasonAndParamsBatched(200, authorities, proposalId, 1, "reason", "params"); } /*////////////////////////////////////////////////////////////// @@ -1239,9 +1243,8 @@ contract AlligatorOPTest is SetupAlligatorOP { emit VotesCast(proxies, carol, authorities, proposalId, 1); vm.prank(carol); - AlligatorOPMock(alligator).limitedCastVoteWithReasonAndParamsBatched( - maxVotingPower, authorities, proposalId, 1, reason, params - ); + AlligatorOPMock(alligator) + .limitedCastVoteWithReasonAndParamsBatched(maxVotingPower, authorities, proposalId, 1, reason, params); _castVoteBatchedAssertions( authorities, proxies, votesToCast, totalVotesToCast, initWeightCast, initForVotes, initWeights @@ -1273,9 +1276,8 @@ contract AlligatorOPTest is SetupAlligatorOP { vm.expectEmit(); emit VoteCast(_proxyAddress(authority[0]), signer, authority, proposalId, 1); - AlligatorOPMock(alligator).castVoteWithReasonAndParamsBySig( - authority, proposalId, 1, "reason", "params", v, r, s - ); + AlligatorOPMock(alligator) + .castVoteWithReasonAndParamsBySig(authority, proposalId, 1, "reason", "params", v, r, s); } function standardLimitedCastVoteWithReasonAndParamsBatchedBySig( @@ -1323,9 +1325,8 @@ contract AlligatorOPTest is SetupAlligatorOP { { proxy = _proxyAddress(authority[0]); uint256 proxyTotalVotes = op.getPastVotes(proxy, governor.proposalSnapshot(proposalId)); - (votesToCast) = AlligatorOPMock(alligator)._validate( - proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes - ); + (votesToCast) = AlligatorOPMock(alligator) + ._validate(proxy, authority[authority.length - 1], authority, proposalId, 1, proxyTotalVotes); votesToCast_[proxy] += votesToCast; initWeightCast = governor.weightCast(proposalId, proxy); initWeights = new uint256[](authority.length); @@ -1353,9 +1354,8 @@ contract AlligatorOPTest is SetupAlligatorOP { ); if (authority.length > 1) { - uint256 recordedVotes = AlligatorOPMock(alligator).votesCast( - proxy, proposalId, authority[authority.length - 2], authority[authority.length - 1] - ); + uint256 recordedVotes = AlligatorOPMock(alligator) + .votesCast(proxy, proposalId, authority[authority.length - 2], authority[authority.length - 1]); assertEq(recordedVotes, initWeights[authority.length - 1] + votesToCast); } } @@ -1382,9 +1382,8 @@ contract AlligatorOPTest is SetupAlligatorOP { assertEq(governor.weightCast(proposalId, proxy), initWeightCast[i] + votesToCast_[proxy]); if (authority.length > 1) { - uint256 recordedVotes = AlligatorOPMock(alligator).votesCast( - proxy, proposalId, authority[authority.length - 2], authority[authority.length - 1] - ); + uint256 recordedVotes = AlligatorOPMock(alligator) + .votesCast(proxy, proposalId, authority[authority.length - 2], authority[authority.length - 1]); assertEq(recordedVotes, initWeights[i][authority.length - 1] + votesToCast[i]); } } @@ -1432,9 +1431,10 @@ contract AlligatorOPTest is SetupAlligatorOP { ) ); - AlligatorOPMock(alligator).limitedCastVoteWithReasonAndParamsBatchedBySig( - maxVotingPower, authorities, propId, support, reason, params, v, r, s - ); + AlligatorOPMock(alligator) + .limitedCastVoteWithReasonAndParamsBatchedBySig( + maxVotingPower, authorities, propId, support, reason, params, v, r, s + ); } function createBasicAuthorities(address[][1] memory initAuthorities) diff --git a/test/OptimismGovernor.t.sol b/test/OptimismGovernor.t.sol index 60832ee..141ba41 100644 --- a/test/OptimismGovernor.t.sol +++ b/test/OptimismGovernor.t.sol @@ -291,8 +291,7 @@ contract Initialize is OptimismGovernorTest { _proposalTypes[3] = IProposalTypesConfigurator.ProposalType(0, 0, "Optimistic", "Lorem Ipsum", address(optimisticModule)); OptimismGovernor _governor = OptimismGovernor( - payable( - new TransparentUpgradeableProxy( + payable(new TransparentUpgradeableProxy( implementation, proxyAdmin, abi.encodeCall( @@ -307,8 +306,7 @@ contract Initialize is OptimismGovernorTest { _proposalTypes ) ) - ) - ) + )) ); assertEq(address(_governor.token()), _token); assertEq(_governor.manager(), _manager); @@ -345,6 +343,7 @@ contract Propose is OptimismGovernorTest { function testFuzz_CreatesProposalAsAuthorizedProposer(address _authorizedProposer) public virtual { // Set the authorized proposer to a random address + vm.assume(_authorizedProposer != governor.authorizedProposer()); vm.prank(manager); governor.setAuthorizedProposer(_authorizedProposer); @@ -440,6 +439,7 @@ contract ProposeWithModule is OptimismGovernorTest { function testFuzz_CreatesProposalAsAuthorizedProposer(address _authorizedProposer) public virtual { // Set the authorized proposer to a random address + vm.assume(_authorizedProposer != governor.authorizedProposer()); vm.prank(manager); governor.setAuthorizedProposer(_authorizedProposer); @@ -2328,6 +2328,7 @@ contract SetManager is OptimismGovernorTest { contract SetAuthorizedProposer is OptimismGovernorTest { function testFuzz_SetsNewAuthorizedProposer(address _newAuthorizedProposer, uint256 _actorSeed) public { + vm.assume(_newAuthorizedProposer != authorizedProposer); vm.prank(_managerOrTimelock(_actorSeed)); vm.expectEmit(); emit AuthorizedProposerSet(authorizedProposer, _newAuthorizedProposer); @@ -2389,11 +2390,7 @@ contract UpgradeToLive is OptimismGovernorTest { IProposalTypesConfigurator.ProposalType[] memory proposalTypes = new IProposalTypesConfigurator.ProposalType[](1); proposalTypes[0] = IProposalTypesConfigurator.ProposalType({ - quorum: 3000, - approvalThreshold: 5100, - name: "Default", - description: "Default", - module: address(0) + quorum: 3000, approvalThreshold: 5100, name: "Default", description: "Default", module: address(0) }); address _newImplementation = address(new OptimismGovernor()); @@ -2404,17 +2401,18 @@ contract UpgradeToLive is OptimismGovernorTest { address _manager = governorProxyOP.manager(); vm.startPrank(proxyAdminOP); - TransparentUpgradeableProxy(payable(address(governorProxyOP))).upgradeToAndCall( - _newImplementation, - abi.encodeWithSelector( - OptimismGovernor.reinitialize.selector, - 0x7f08F3095530B67CdF8466B7a923607944136Df0, - 0x1b7CA7437748375302bAA8954A2447fC3FBE44CC, - _newProposalTypesConfigurator, - TimelockControllerUpgradeable(payable(address(timelock))), - _manager - ) - ); + TransparentUpgradeableProxy(payable(address(governorProxyOP))) + .upgradeToAndCall( + _newImplementation, + abi.encodeWithSelector( + OptimismGovernor.reinitialize.selector, + 0x7f08F3095530B67CdF8466B7a923607944136Df0, + 0x1b7CA7437748375302bAA8954A2447fC3FBE44CC, + _newProposalTypesConfigurator, + TimelockControllerUpgradeable(payable(address(timelock))), + _manager + ) + ); assertEq(TransparentUpgradeableProxy(payable(address(governorProxyOP))).implementation(), _newImplementation); vm.stopPrank(); assertEq(governorProxyOP.authorizedProposer(), governorProxyOP.manager()); @@ -2445,7 +2443,9 @@ contract UpgradeToLive is OptimismGovernorTest { assertEq(abstainVotes, 3487066530234316527174422); assertEq( - uint8(governorProxyOP.state(105090569675606228680479820654354019470447822380910214626164858605991232311940)), + uint8( + governorProxyOP.state(105090569675606228680479820654354019470447822380910214626164858605991232311940) + ), uint8(ProposalState.Defeated) ); } @@ -2473,17 +2473,18 @@ contract UpgradeToLive is OptimismGovernorTest { address _manager = governorProxyOP.manager(); vm.prank(proxyAdminOP); - TransparentUpgradeableProxy(payable(address(governorProxyOP))).upgradeToAndCall( - _newImplementation, - abi.encodeWithSelector( - OptimismGovernor.reinitialize.selector, - 0x7f08F3095530B67CdF8466B7a923607944136Df0, - 0x1b7CA7437748375302bAA8954A2447fC3FBE44CC, - _newProposalTypesConfigurator, - TimelockControllerUpgradeable(payable(address(timelock))), - _manager - ) - ); + TransparentUpgradeableProxy(payable(address(governorProxyOP))) + .upgradeToAndCall( + _newImplementation, + abi.encodeWithSelector( + OptimismGovernor.reinitialize.selector, + 0x7f08F3095530B67CdF8466B7a923607944136Df0, + 0x1b7CA7437748375302bAA8954A2447fC3FBE44CC, + _newProposalTypesConfigurator, + TimelockControllerUpgradeable(payable(address(timelock))), + _manager + ) + ); assertEq(governorProxyOP.authorizedProposer(), governorProxyOP.manager()); assertEq(governorProxyOP.VERSION(), 5); diff --git a/test/RedeployTimelock.t.sol b/test/RedeployTimelock.t.sol index 97337ee..7d5bf10 100644 --- a/test/RedeployTimelock.t.sol +++ b/test/RedeployTimelock.t.sol @@ -3,8 +3,9 @@ pragma solidity ^0.8.19; import {Test} from "forge-std/Test.sol"; import {console} from "forge-std/console.sol"; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; /** diff --git a/test/mocks/TimelockMock.sol b/test/mocks/TimelockMock.sol index d7e1626..b990118 100644 --- a/test/mocks/TimelockMock.sol +++ b/test/mocks/TimelockMock.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; contract Timelock is TimelockControllerUpgradeable { function initialize(uint256 minDelay, address governor, address admin) public initializer { diff --git a/test/setup/SetupAlligatorOP.sol b/test/setup/SetupAlligatorOP.sol index 043fa94..694c8af 100644 --- a/test/setup/SetupAlligatorOP.sol +++ b/test/setup/SetupAlligatorOP.sol @@ -11,11 +11,13 @@ import {OptimismGovernorMock} from "../mocks/OptimismGovernorMock.sol"; import {IVotableSupplyOracle} from "src/interfaces/IVotableSupplyOracle.sol"; import {TokenMock} from "test/mocks/TokenMock.sol"; import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; import {IVotesUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol"; -import {TimelockControllerUpgradeable} from - "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; import {IVotingToken} from "src/interfaces/IVotingToken.sol"; import {IAlligatorOP} from "src/interfaces/IAlligatorOP.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";