-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New proposal type
SetGovernanceParameterProposal
(#299)
* shift gov params storage to * add new proposal * settable vote duration * test: add tests (#300) * set multiply governance parameters at a time * execute multiple test * move out of * modify codecov * add back an assertion --------- Co-authored-by: Brian Le <[email protected]>
- Loading branch information
Showing
9 changed files
with
257 additions
and
43 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 |
---|---|---|
@@ -1,10 +1,3 @@ | ||
ignore: | ||
- "test" | ||
- "deploy" | ||
|
||
coverage: | ||
status: | ||
patch: | ||
default: | ||
target: 90% | ||
if_ci_failed: error |
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
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.20; | ||
|
||
import { ProposalStorage } from "./ProposalStorage.sol"; | ||
import { IProposalExecutionEngine } from "./IProposalExecutionEngine.sol"; | ||
|
||
contract SetGovernanceParameterProposal is ProposalStorage { | ||
/// @notice Reverted with when the new governance parameter value is invalid | ||
error InvalidGovernanceParameter(uint256 value); | ||
/// @notice Emitted when the vote duration is set | ||
event VoteDurationSet(uint256 oldValue, uint256 newValue); | ||
/// @notice Emitted when the execution delay is set | ||
event ExecutionDelaySet(uint256 oldValue, uint256 newValue); | ||
/// @notice Emitted when the pass threshold bps is set | ||
event PassThresholdBpsSet(uint256 oldValue, uint256 newValue); | ||
|
||
/// @notice Struct containing data required for this proposal type | ||
struct SetGovernanceParameterProposalData { | ||
uint40 voteDuration; | ||
uint40 executionDelay; | ||
uint16 passThresholdBps; | ||
} | ||
|
||
/// @notice Execute a `SetGovernanceParameterProposal` which sets the given governance parameter. | ||
function _executeSetGovernanceParameter( | ||
IProposalExecutionEngine.ExecuteProposalParams memory params | ||
) internal returns (bytes memory) { | ||
SetGovernanceParameterProposalData memory proposalData = abi.decode( | ||
params.proposalData, | ||
(SetGovernanceParameterProposalData) | ||
); | ||
if (proposalData.voteDuration != 0) { | ||
if (proposalData.voteDuration < 1 hours) { | ||
revert InvalidGovernanceParameter(proposalData.voteDuration); | ||
} | ||
emit VoteDurationSet( | ||
_getSharedProposalStorage().governanceValues.voteDuration, | ||
proposalData.voteDuration | ||
); | ||
_getSharedProposalStorage().governanceValues.voteDuration = proposalData.voteDuration; | ||
} | ||
if (proposalData.executionDelay != 0) { | ||
if (proposalData.executionDelay > 30 days) { | ||
revert InvalidGovernanceParameter(proposalData.executionDelay); | ||
} | ||
emit ExecutionDelaySet( | ||
_getSharedProposalStorage().governanceValues.executionDelay, | ||
proposalData.executionDelay | ||
); | ||
_getSharedProposalStorage().governanceValues.executionDelay = proposalData | ||
.executionDelay; | ||
} | ||
if (proposalData.passThresholdBps != 0) { | ||
if (proposalData.passThresholdBps > 10000) { | ||
revert InvalidGovernanceParameter(proposalData.passThresholdBps); | ||
} | ||
emit PassThresholdBpsSet( | ||
_getSharedProposalStorage().governanceValues.passThresholdBps, | ||
proposalData.passThresholdBps | ||
); | ||
_getSharedProposalStorage().governanceValues.passThresholdBps = proposalData | ||
.passThresholdBps; | ||
} | ||
|
||
return ""; | ||
} | ||
} |
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
Oops, something went wrong.