Skip to content

Commit

Permalink
fix: allow executing during voting period when qualified
Browse files Browse the repository at this point in the history
- allow execution of proposal if result is final, i.e. >2/3 of all active stake has voted in favor
- added "Qualified" proposal state
- modified _castVote method to update proposal endBlockOrTime when result is final if before voting ends
- added qualified consensus check in strategy
  • Loading branch information
gabririgo committed Feb 8, 2023
1 parent 9b3a834 commit 296cda7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface IGovernanceState {
Pending,
Active,
Canceled,
Qualified,
Defeated,
Succeeded,
Queued,
Expand Down
5 changes: 5 additions & 0 deletions contracts/governance/mixins/MixinVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ abstract contract MixinVoting is MixinStorage, MixinAbstract {
voteType: voteType
});

// if vote reaches qualified majority we prepare execution at next block
if(_getProposalState(proposalId) == ProposalState.Qualified) {
proposal.endBlockOrTime = _paramsWrapper().governanceParameters.timeType == TimeType.Timestamp ? block.timestamp : block.number;
}

emit VoteCast(voter, proposalId, voteType, votingPower);
}
}
13 changes: 13 additions & 0 deletions contracts/governance/strategies/RigoblockGovernanceStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ contract RigoblockGovernanceStrategy is IGovernanceStrategy {
// using timestamps instead of epoch is a safeguard for upgrades, should the staking system get stuck by being unable to finalize.
if (block.timestamp <= proposal.startBlockOrTime) {
return IGovernanceState.ProposalState.Pending;
} else if (block.timestamp <= proposal.endBlockOrTime && _qualifiedConsensus(proposal, minimumQuorum)) {
return IGovernanceState.ProposalState.Qualified;
} else if (block.timestamp <= proposal.endBlockOrTime) {
return IGovernanceState.ProposalState.Active;
} else if (proposal.votesFor <= 2 * proposal.votesAgainst || proposal.votesFor < minimumQuorum) {
Expand All @@ -67,6 +69,17 @@ contract RigoblockGovernanceStrategy is IGovernanceStrategy {
}
}

function _qualifiedConsensus(IRigoblockGovernance.Proposal memory proposal, uint256 minimumQuorum) private view returns (bool) {
return (
3 * proposal.votesFor >
2 *
IStaking(_getStakingProxy())
.getGlobalStakeByStatus(IStructs.StakeStatus.DELEGATED)
.currentEpochBalance
&& proposal.votesFor >= minimumQuorum
);
}

/// @inheritdoc IGovernanceStrategy
function getVotingPower(address account) public view override returns (uint256) {
return
Expand Down

0 comments on commit 296cda7

Please sign in to comment.