-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into DanielVF/propose-with-sigs
- Loading branch information
Showing
14 changed files
with
81 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ import {Addresses} from "contracts/utils/Addresses.sol"; | |
import "forge-std/console.sol"; | ||
|
||
import {TimelockController} from "OpenZeppelin/[email protected]/contracts/governance/TimelockController.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/utils/Strings.sol"; | ||
|
||
library GovFive { | ||
struct GovFiveAction { | ||
|
@@ -50,26 +49,27 @@ library GovFive { | |
GovFiveAction memory propAction = prop.actions[i]; | ||
|
||
targets[i] = propAction.receiver; | ||
payloads[i] = | ||
abi.encodePacked(abi.encodePacked(bytes4(keccak256(bytes(propAction.fullsig)))), propAction.data); | ||
payloads[i] = abi.encodePacked(bytes4(keccak256(bytes(propAction.fullsig))), propAction.data); | ||
} | ||
|
||
bytes32 salt = keccak256(bytes(prop.description)); | ||
|
||
TimelockController timelock = TimelockController(payable(Addresses.TIMELOCK)); | ||
receiver = Addresses.TIMELOCK; | ||
|
||
opHash = timelock.hashOperationBatch(targets, values, payloads, hex"", salt); | ||
opHash = timelock.hashOperationBatch(targets, values, payloads, bytes32(0), salt); | ||
|
||
if (timelock.isOperation(opHash)) { | ||
bytes4 executeSig = bytes4(keccak256(bytes("executeBatch(address[],uint256[],bytes[],bytes32,bytes32)"))); | ||
|
||
payload = abi.encodePacked(executeSig, abi.encode(targets, values, payloads, hex"", salt)); | ||
console.log("Yet to be exeucted."); | ||
payload = abi.encodePacked(executeSig, abi.encode(targets, values, payloads, bytes32(0), salt)); | ||
} else { | ||
bytes4 scheduleSig = | ||
bytes4(keccak256(bytes("scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,delay)"))); | ||
bytes4(keccak256(bytes("scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,uint256)"))); | ||
|
||
payload = abi.encodePacked(scheduleSig, abi.encode(targets, values, payloads, hex"", salt, 2 days)); | ||
console.log("Yet to be scheduled."); | ||
payload = abi.encodePacked(scheduleSig, abi.encode(targets, values, payloads, bytes32(0), salt, 2 days)); | ||
} | ||
} | ||
|
||
|
@@ -113,6 +113,10 @@ library GovFive { | |
console.log("Scheduling..."); | ||
(bool success, bytes memory data) = receiver.call(payload); | ||
|
||
if (!success || !timelock.isOperation(opHash)) { | ||
revert("Failed to schedule"); | ||
} | ||
|
||
(receiver, payload, opHash) = getSafeTxData(prop); | ||
} | ||
|
||
|
@@ -125,6 +129,12 @@ library GovFive { | |
|
||
(bool success, bytes memory data) = receiver.call(payload); | ||
|
||
if (!success || !timelock.isOperationDone(opHash)) { | ||
revert("Failed to execute"); | ||
} | ||
|
||
console.log("Executed"); | ||
|
||
vm.stopPrank(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,10 @@ pragma solidity 0.8.10; | |
import {Addresses} from "contracts/utils/Addresses.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
import "OpenZeppelin/[email protected]/contracts/utils/Strings.sol"; | ||
import {IGovernor} from "OpenZeppelin/[email protected]/contracts/governance/IGovernor.sol"; | ||
import {Governance} from "../Governance.sol"; | ||
|
||
import "contracts/utils/VmHelper.sol"; | ||
import {Vm} from "forge-std/Vm.sol"; | ||
|
||
struct GovAction { | ||
address target; | ||
|
@@ -24,8 +23,6 @@ struct GovProposal { | |
} | ||
|
||
library GovProposalHelper { | ||
using VmHelper for Vm; | ||
|
||
function id(GovProposal memory prop) internal view returns (uint256 proposalId) { | ||
bytes32 descriptionHash = keccak256(bytes(prop.description)); | ||
(address[] memory targets, uint256[] memory values,,, bytes[] memory calldatas) = getParams(prop); | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,20 +12,18 @@ import {Governance} from "contracts/Governance.sol"; | |
|
||
import {GovFive} from "contracts/utils/GovFive.sol"; | ||
|
||
import {VmHelper} from "utils/VmHelper.sol"; | ||
|
||
import {MigrationZapper} from "contracts/MigrationZapper.sol"; | ||
|
||
import "OpenZeppelin/[email protected]/contracts/token/ERC20/extensions/ERC20Votes.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/governance/TimelockController.sol"; | ||
|
||
contract MigrationZapperScript is BaseMainnetScript { | ||
using GovFive for GovFive.GovFiveProposal; | ||
using VmHelper for Vm; | ||
|
||
GovFive.GovFiveProposal public govProposal; | ||
|
||
string public constant override DEPLOY_NAME = "012_MigrationZapper"; | ||
bool public constant override proposalExecuted = true; | ||
|
||
constructor() {} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,30 +3,21 @@ | |
pragma solidity 0.8.10; | ||
|
||
import "./BaseMainnetScript.sol"; | ||
import {Vm} from "forge-std/Vm.sol"; | ||
|
||
import {Addresses} from "contracts/utils/Addresses.sol"; | ||
|
||
import {Timelock} from "contracts/Timelock.sol"; | ||
import {Governance} from "contracts/Governance.sol"; | ||
|
||
import {GovFive} from "contracts/utils/GovFive.sol"; | ||
|
||
import {VmHelper} from "utils/VmHelper.sol"; | ||
|
||
import {Migrator} from "contracts/Migrator.sol"; | ||
import {OgvStaking} from "contracts/OgvStaking.sol"; | ||
|
||
import "OpenZeppelin/[email protected]/contracts/token/ERC20/extensions/ERC20Votes.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/governance/TimelockController.sol"; | ||
|
||
contract UpgradeMigratorScript is BaseMainnetScript { | ||
using GovFive for GovFive.GovFiveProposal; | ||
using VmHelper for Vm; | ||
|
||
GovFive.GovFiveProposal public govProposal; | ||
|
||
string public constant override DEPLOY_NAME = "013_UpgradeMigrator"; | ||
bool public constant override proposalExecuted = false; | ||
|
||
constructor() {} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,16 @@ import {Governance} from "contracts/Governance.sol"; | |
|
||
import {GovFive} from "contracts/utils/GovFive.sol"; | ||
|
||
import {VmHelper} from "utils/VmHelper.sol"; | ||
|
||
import "OpenZeppelin/[email protected]/contracts/token/ERC20/extensions/ERC20Votes.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/governance/TimelockController.sol"; | ||
import {ERC20Votes} from "OpenZeppelin/[email protected]/contracts/token/ERC20/extensions/ERC20Votes.sol"; | ||
import {TimelockController} from "OpenZeppelin/[email protected]/contracts/governance/TimelockController.sol"; | ||
|
||
contract XOGNGovernanceScript is BaseMainnetScript { | ||
using GovFive for GovFive.GovFiveProposal; | ||
using VmHelper for Vm; | ||
|
||
GovFive.GovFiveProposal public govProposal; | ||
|
||
string public constant override DEPLOY_NAME = "014_xOGNGovernance"; | ||
bool public constant override proposalExecuted = false; | ||
|
||
uint256 public constant OGN_EPOCH = 1717041600; // May 30, 2024 GMT | ||
|
||
|
@@ -45,9 +43,6 @@ contract XOGNGovernanceScript is BaseMainnetScript { | |
|
||
address xognGov = deployedContracts["XOGN_GOV"]; | ||
|
||
address ognRewardsSourceProxy = deployedContracts["OGN_REWARDS_SOURCE"]; | ||
address veOgvImpl = deployedContracts["VEOGV_IMPL"]; | ||
|
||
govProposal.setName("Grant access to OGN Governance"); | ||
|
||
govProposal.setDescription("Grant access to OGN Governance"); | ||
|
@@ -88,6 +83,6 @@ contract XOGNGovernanceScript is BaseMainnetScript { | |
|
||
function skip() external view override returns (bool) { | ||
// Don't deploy on Mainnet for now | ||
return !vm.isForkEnv(); | ||
return !this.isForked(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,18 @@ | |
|
||
pragma solidity 0.8.10; | ||
|
||
import "forge-std/Script.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/utils/Strings.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {Vm, VmSafe} from "forge-std/Vm.sol"; | ||
|
||
import {Addresses} from "contracts/utils/Addresses.sol"; | ||
import {GovProposal, GovProposalHelper} from "contracts/utils/GovProposalHelper.sol"; | ||
|
||
import "utils/VmHelper.sol"; | ||
|
||
abstract contract BaseMainnetScript is Script { | ||
using VmHelper for Vm; | ||
using GovProposalHelper for GovProposal; | ||
|
||
uint256 public deployBlockNum = type(uint256).max; | ||
bool isForked = false; | ||
|
||
// DeployerRecord stuff to be extracted as well | ||
struct DeployRecord { | ||
|
@@ -42,6 +40,10 @@ abstract contract BaseMainnetScript is Script { | |
deployedContracts[name] = addr; | ||
} | ||
|
||
function isForked() public view returns (bool) { | ||
return vm.isContext(VmSafe.ForgeContext.ScriptDryRun) || vm.isContext(VmSafe.ForgeContext.TestGroup); | ||
} | ||
|
||
function setUp() external {} | ||
|
||
function run() external { | ||
|
@@ -54,9 +56,7 @@ abstract contract BaseMainnetScript is Script { | |
return; | ||
} | ||
|
||
isForked = vm.isForkEnv(); | ||
|
||
if (isForked) { | ||
if (this.isForked()) { | ||
address impersonator = Addresses.INITIAL_DEPLOYER; | ||
console.log("Running script on mainnet fork impersonating: %s", impersonator); | ||
vm.startPrank(impersonator); | ||
|
@@ -69,7 +69,7 @@ abstract contract BaseMainnetScript is Script { | |
|
||
_execute(); | ||
|
||
if (isForked) { | ||
if (this.isForked()) { | ||
vm.stopPrank(); | ||
_buildGovernanceProposal(); | ||
_fork(); | ||
|
@@ -80,6 +80,8 @@ abstract contract BaseMainnetScript is Script { | |
|
||
function DEPLOY_NAME() external view virtual returns (string memory); | ||
|
||
function proposalExecuted() external view virtual returns (bool); | ||
|
||
function skip() external view virtual returns (bool) { | ||
return false; | ||
} | ||
|
@@ -91,6 +93,10 @@ abstract contract BaseMainnetScript is Script { | |
function _buildGovernanceProposal() internal virtual {} | ||
|
||
function handleGovernanceProposal() external virtual { | ||
if (this.proposalExecuted()) { | ||
return; | ||
} | ||
|
||
_buildGovernanceProposal(); | ||
_fork(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.