Repository navigation
Implement deploy script for new Gitcoin Governor #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-only | ||
| pragma solidity ^0.8.35; | ||
|
|
||
| import {Script} from "forge-std/Script.sol"; | ||
| import {console2} from "forge-std/console2.sol"; | ||
| import {ICompoundTimelock} from "@openzeppelin/contracts/vendor/compound/ICompoundTimelock.sol"; | ||
| import {GitcoinGovernorWithGuardian} from "src/GitcoinGovernorWithGuardian.sol"; | ||
| import {IComp} from "src/interfaces/IComp.sol"; | ||
|
|
||
| /// @notice Abstract base that holds the mechanics of deploying a `GitcoinGovernorWithGuardian`. | ||
| /// A concrete contract supplies the configuration for a specific deployment by implementing | ||
| /// `_getDeploymentParams`. | ||
| abstract contract DeployGitcoinGovernorWithGuardian is Script { | ||
| struct DeploymentParams { | ||
| string name; | ||
| uint256 initialQuorum; | ||
| uint48 initialVoteExtension; | ||
| uint48 initialVotingDelay; | ||
| uint32 initialVotingPeriod; | ||
| uint256 initialProposalThreshold; | ||
| IComp token; | ||
| ICompoundTimelock timelock; | ||
| } | ||
|
|
||
| GitcoinGovernorWithGuardian public governor; | ||
| bool internal isLogging = true; | ||
|
|
||
| function run() public virtual { | ||
| DeploymentParams memory _params = _getDeploymentParams(); | ||
| _revertIfDeploymentParamsAreInvalid(_params); | ||
|
|
||
| _log("Deploying GitcoinGovernorWithGuardian with:"); | ||
| _log(string.concat(" name: ", _params.name)); | ||
| _log(string.concat(" initialQuorum: ", vm.toString(_params.initialQuorum))); | ||
| _log(string.concat(" initialVoteExtension: ", vm.toString(_params.initialVoteExtension))); | ||
| _log(string.concat(" initialVotingDelay: ", vm.toString(_params.initialVotingDelay))); | ||
| _log(string.concat(" initialVotingPeriod: ", vm.toString(_params.initialVotingPeriod))); | ||
| _log( | ||
| string.concat(" initialProposalThreshold: ", vm.toString(_params.initialProposalThreshold)) | ||
| ); | ||
| _log(string.concat(" token: ", vm.toString(address(_params.token)))); | ||
| _log(string.concat(" timelock: ", vm.toString(address(_params.timelock)))); | ||
|
|
||
| vm.startBroadcast(); | ||
| // BROADCAST: deploy the GitcoinGovernorWithGuardian | ||
| _log("[1/1] Deploying GitcoinGovernorWithGuardian"); | ||
| governor = new GitcoinGovernorWithGuardian( | ||
| _params.name, | ||
| _params.initialQuorum, | ||
| _params.initialVoteExtension, | ||
| _params.initialVotingDelay, | ||
| _params.initialVotingPeriod, | ||
| _params.initialProposalThreshold, | ||
| address(_params.token), | ||
| _params.timelock | ||
| ); | ||
| vm.stopBroadcast(); | ||
|
|
||
| _log(string.concat("GitcoinGovernorWithGuardian deployed at ", vm.toString(address(governor)))); | ||
|
|
||
| _revertIfDeploymentIsInvalid(_params); | ||
| } | ||
|
|
||
| function disableLogging() public { | ||
| isLogging = false; | ||
| } | ||
|
|
||
| function _getDeploymentParams() internal view virtual returns (DeploymentParams memory); | ||
|
|
||
| function _log(string memory _msg) internal view { | ||
| if (isLogging) { | ||
| console2.log(_msg); | ||
| } | ||
| } | ||
|
|
||
| function _revertIfDeploymentParamsAreInvalid(DeploymentParams memory _params) internal pure { | ||
| if (address(_params.token) == address(0)) { | ||
| revert( | ||
| "DeployGitcoinGovernorWithGuardian: token is the zero address; " | ||
| "set it to the address of the COMP-style GTC token" | ||
| ); | ||
| } | ||
| if (address(_params.timelock) == address(0)) { | ||
| revert( | ||
| "DeployGitcoinGovernorWithGuardian: timelock is the zero address; " | ||
| "set it to the address of Gitcoin's Compound Timelock" | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function _revertIfDeploymentIsInvalid(DeploymentParams memory _params) internal view { | ||
| if (address(governor.token()) != address(_params.token)) { | ||
| revert( | ||
| string.concat( | ||
| "DeployGitcoinGovernorWithGuardian: deployed governor token is ", | ||
| vm.toString(address(governor.token())), | ||
| " but expected ", | ||
| vm.toString(address(_params.token)) | ||
| ) | ||
| ); | ||
| } | ||
| if (governor.timelock() != address(_params.timelock)) { | ||
| revert( | ||
| string.concat( | ||
| "DeployGitcoinGovernorWithGuardian: deployed governor timelock is ", | ||
| vm.toString(governor.timelock()), | ||
| " but expected ", | ||
| vm.toString(address(_params.timelock)) | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-only | ||
| pragma solidity ^0.8.35; | ||
|
|
||
| // `run()` is inherited from the abstract base; scopelint's per-file `script` rule does not resolve | ||
| // the inherited entrypoint, so this concrete config opts out of that check. | ||
| // scopelint: ignore-script-file | ||
|
|
||
| import {ICompoundTimelock} from "@openzeppelin/contracts/vendor/compound/ICompoundTimelock.sol"; | ||
| import {DeployGitcoinGovernorWithGuardian} from "script/DeployGitcoinGovernorWithGuardian.s.sol"; | ||
| import {IComp} from "src/interfaces/IComp.sol"; | ||
|
|
||
| /// @notice Mainnet deployment configuration for the upgraded Gitcoin Governor. | ||
| /// @dev The governance parameters mirror the active "GTC Governor Bravo" | ||
| /// (0x9D4C63565D5618310271bF3F3c01b2954C1D1639) so the upgrade preserves current behavior. The | ||
| /// late-quorum vote extension is new to this Governor and has no precedent to carry over. | ||
| contract DeployGitcoinGovernorWithGuardianMainnet is DeployGitcoinGovernorWithGuardian { | ||
| // TODO: Confirm the Governor name with Gitcoin stakeholders before deploying. It sets the EIP-712 | ||
| // domain separator used when signing votes; defaulted here to the active Governor's name for | ||
| // continuity. | ||
| string constant GOVERNOR_NAME = "GTC Governor Bravo"; | ||
|
|
||
| // Fixed values that can't change | ||
| IComp constant GTC_TOKEN = IComp(0xDe30da39c46104798bB5aA3fe8B9e0e1F348163F); | ||
| ICompoundTimelock constant TIMELOCK = | ||
| ICompoundTimelock(payable(0x57a8865cfB1eCEf7253c27da6B4BC3dAEE5Be518)); | ||
|
|
||
| // Match the values from the existing Governor | ||
| uint256 constant INITIAL_QUORUM = 2_500_000e18; | ||
| uint48 constant INITIAL_VOTING_DELAY = 13_140; | ||
| uint32 constant INITIAL_VOTING_PERIOD = 40_320; | ||
| uint256 constant INITIAL_PROPOSAL_THRESHOLD = 150_000e18; | ||
|
|
||
| // TODO: Validate the late-quorum vote extension with Gitcoin stakeholders before deploying. This | ||
| // is a new parameter with no precedent in the active Governor; defaulted here to ~2 days (14,400 | ||
| // blocks at ~12s/block), the minimum window guaranteed between a proposal reaching quorum and its | ||
| // voting period ending. | ||
| uint48 constant INITIAL_VOTE_EXTENSION = 14_400; | ||
|
|
||
| function _getDeploymentParams() internal pure override returns (DeploymentParams memory) { | ||
| return DeploymentParams({ | ||
| name: GOVERNOR_NAME, | ||
| initialQuorum: INITIAL_QUORUM, | ||
| initialVoteExtension: INITIAL_VOTE_EXTENSION, | ||
| initialVotingDelay: INITIAL_VOTING_DELAY, | ||
| initialVotingPeriod: INITIAL_VOTING_PERIOD, | ||
| initialProposalThreshold: INITIAL_PROPOSAL_THRESHOLD, | ||
| token: GTC_TOKEN, | ||
| timelock: TIMELOCK | ||
| }); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.