Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
depth = 16 # The number of times to run the invariant tests
13 changes: 6 additions & 7 deletions script/RedeployTimelock.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions script/SetCancellers.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions script/TimelockRoleManager.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions src/OptimismGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/VotableSupplyOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
14 changes: 8 additions & 6 deletions src/alligator/AlligatorOP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// =============================================================
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/interfaces/IAlligatorOP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
// =============================================================
Expand Down
4 changes: 1 addition & 3 deletions src/interfaces/IOptimismGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions src/interfaces/IRule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
22 changes: 15 additions & 7 deletions src/lib/openzeppelin/v2/GovernorUpgradeableV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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]);
Expand All @@ -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)) {
Expand All @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion src/lib/openzeppelin/v2/GovernorVotesUpgradeableV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/modules/ApprovalVotingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/modules/VotingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading