refactor(group): Distinguish Voting period and Execution period for group policies (#11198)
## Description Closes: #11092 ## TODOs I'm thinking to do the 2 todos in a separate PR, or else this PR is too big. WDYT? - [ ] #11246 This involves adding a new index ProposalsByVotingPeriodEnd, so might be better to do in another PR - [ ] #11245 Also should be done in a separate PR (as it needs the above index) ### Main change 1: Group policy proto defs have `voting_period` and `min_execution_period` For group policies: ```diff - // Within this times votes and exec messages can be submitted. - // timeout is the duration from submission of a proposal to the end of voting period - google.protobuf.Duration timeout = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + // voting_period is the duration from submission of a proposal to the end of voting period + // Within this times votes can be submitted with MsgVote. + google.protobuf.Duration voting_period = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + // min_execution_period is the minimum duration after the proposal submission + // where members can start sending MsgExec. This means that the window for + // sending a MsgExec transaction is: + // `[ submission + min_execution_period ; submission + voting_period + max_execution_period]` + // where max_execution_period is a app-specific config, defined in the keeper. + // If not set, min_execution_period will default to 0. + google.protobuf.Duration min_execution_period = 3 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; ``` ### Main Change 2: We don't update proposal's FinalTallyResult result on MsgVote/MsgSubmitProposal Unless the msg has TryExec set to true, in which case the FinalTallyResult is updated ONLY if the tally is final. ### Main Change 3: Add a keeper-level `MaxExecutionPeriod` MsgExecs will be rejected if they are sent after `voting_period_end + MaxExecutionPeriod` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
@@ -41,9 +41,8 @@ message ThresholdDecisionPolicy {
|
||||
// threshold is the minimum weighted sum of yes votes that must be met or exceeded for a proposal to succeed.
|
||||
string threshold = 1;
|
||||
|
||||
// timeout is the duration from submission of a proposal to the end of voting period
|
||||
// Within this times votes and exec messages can be submitted.
|
||||
google.protobuf.Duration timeout = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
// windows defines the different windows for voting and execution.
|
||||
DecisionPolicyWindows windows = 2;
|
||||
}
|
||||
|
||||
// PercentageDecisionPolicy implements the DecisionPolicy interface
|
||||
@@ -53,9 +52,28 @@ message PercentageDecisionPolicy {
|
||||
// percentage is the minimum percentage the weighted sum of yes votes must meet for a proposal to succeed.
|
||||
string percentage = 1;
|
||||
|
||||
// timeout is the duration from submission of a proposal to the end of voting period
|
||||
// Within these times votes and exec messages can be submitted.
|
||||
google.protobuf.Duration timeout = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
// windows defines the different windows for voting and execution.
|
||||
DecisionPolicyWindows windows = 2;
|
||||
}
|
||||
|
||||
// DecisionPolicyWindows defines the different windows for voting and execution.
|
||||
message DecisionPolicyWindows {
|
||||
// voting_period is the duration from submission of a proposal to the end of voting period
|
||||
// Within this times votes can be submitted with MsgVote.
|
||||
google.protobuf.Duration voting_period = 1 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
|
||||
// min_execution_period is the minimum duration after the proposal submission
|
||||
// where members can start sending MsgExec. This means that the window for
|
||||
// sending a MsgExec transaction is:
|
||||
// `[ submission + min_execution_period ; submission + voting_period + max_execution_period]`
|
||||
// where max_execution_period is a app-specific config, defined in the keeper.
|
||||
// If not set, min_execution_period will default to 0.
|
||||
//
|
||||
// Please make sure to set a `min_execution_period` that is smaller than
|
||||
// `voting_period + max_execution_period`, or else the above execution window
|
||||
// is empty, meaning that all proposals created with this decision policy
|
||||
// won't be able to be executed.
|
||||
google.protobuf.Duration min_execution_period = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// VoteOption enumerates the valid vote options for a given proposal.
|
||||
@@ -184,11 +202,12 @@ message Proposal {
|
||||
// has ended.
|
||||
TallyResult final_tally_result = 10 [(gogoproto.nullable) = false];
|
||||
|
||||
// timeout is the timestamp before which both voting and execution must be
|
||||
// done. If this timestamp is passed, then the proposal cannot be executed
|
||||
// anymore and should be considered pending delete. This timestamp is checked
|
||||
// against the block header's timestamp.
|
||||
google.protobuf.Timestamp timeout = 11 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
// voting_period_end is the timestamp before which voting must be done.
|
||||
// Unless a successfull MsgExec is called before (to execute a proposal whose
|
||||
// tally is successful before the voting period ends), tallying will be done
|
||||
// at this point, and the `final_tally_result`, as well
|
||||
// as `status` and `result` fields will be accordingly updated.
|
||||
google.protobuf.Timestamp voting_period_end = 11 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
|
||||
// executor_result is the final result based on the votes and election rule. Initial value is NotRun.
|
||||
ProposalExecutorResult executor_result = 12;
|
||||
|
||||
Reference in New Issue
Block a user