Skip to content
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

feat(x/gov): add max cancel voting period param #18856

Merged
merged 9 commits into from
Dec 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
param renaming
julienrbrt committed Dec 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 18fc56ef6ba2e3bc1ec6a102f53f1e4970583678
227 changes: 113 additions & 114 deletions api/cosmos/gov/v1/gov.pulsar.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions proto/cosmos/gov/v1/gov.proto
Original file line number Diff line number Diff line change
@@ -310,17 +310,17 @@
// Since: cosmos-sdk 0.50
string min_deposit_ratio = 16 [(cosmos_proto.scalar) = "cosmos.Dec"];

// proposal_cancel_max_cancel_period defines how far in the voting period a proposer can cancel a proposal.
// proposal_cancel_max_period defines how far in the voting period a proposer can cancel a proposal.
// If the proposal is cancelled before the max cancel period, the deposit will be returned/burn to the
// depositors, according to the proposal_cancel_ratio and proposal_cancel_dest parameters.
// After the max cancel period, the proposal cannot be cancelled anymore.
string proposal_cancel_max_cancel_period = 17 [(cosmos_proto.scalar) = "cosmos.Dec"];
string proposal_cancel_max_period = 17 [(cosmos_proto.scalar) = "cosmos.Dec"];

Check failure on line 317 in proto/cosmos/gov/v1/gov.proto

GitHub Actions / break-check

Field "17" with name "proposal_cancel_max_period" on message "Params" changed option "json_name" from "optimisticAuthorizedAddresses" to "proposalCancelMaxPeriod".

Check failure on line 317 in proto/cosmos/gov/v1/gov.proto

GitHub Actions / break-check

Field "17" on message "Params" changed label from "repeated" to "optional".

Check failure on line 317 in proto/cosmos/gov/v1/gov.proto

GitHub Actions / break-check

Field "17" on message "Params" changed name from "optimistic_authorized_addresses" to "proposal_cancel_max_period".
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved

// optimistic_authorized_addresses is an optional governance parameter that limits the authorized accounts than can
// submit optimistic proposals
//
// Since: x/gov v1.0.0
repeated string optimistic_authorized_addresses = 18 [(cosmos_proto.scalar) = "cosmos.AddressString"];

Check failure on line 323 in proto/cosmos/gov/v1/gov.proto

GitHub Actions / break-check

Field "18" with name "optimistic_authorized_addresses" on message "Params" changed option "json_name" from "optimisticRejectedThreshold" to "optimisticAuthorizedAddresses".

Check failure on line 323 in proto/cosmos/gov/v1/gov.proto

GitHub Actions / break-check

Field "18" on message "Params" changed label from "optional" to "repeated".

Check failure on line 323 in proto/cosmos/gov/v1/gov.proto

GitHub Actions / break-check

Field "18" on message "Params" changed name from "optimistic_rejected_threshold" to "optimistic_authorized_addresses".

// optimistic rejected threshold defines at which percentage of NO votes, the optimistic proposal should fail and be
// converted to a standard proposal. The threshold is expressed as a percentage of the total bonded tokens.
2 changes: 1 addition & 1 deletion x/gov/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [#18856](https://github.com/cosmos/cosmos-sdk/pull/18856) Add `ProposalCancelMaxCancelPeriod` for modifying how long a proposal can be cancelled after it has been submitted.
* [#18856](https://github.com/cosmos/cosmos-sdk/pull/18856) Add `ProposalCancelMaxPeriod` for modifying how long a proposal can be cancelled after it has been submitted.
* [#18445](https://github.com/cosmos/cosmos-sdk/pull/18445) Extend gov config.
* [#18532](https://github.com/cosmos/cosmos-sdk/pull/18532) Repurpose `govcliutils.NormalizeProposalType` to work for gov v1 proposal types.

94 changes: 47 additions & 47 deletions x/gov/README.md
Original file line number Diff line number Diff line change
@@ -35,32 +35,32 @@ can be adapted to any Proof-Of-Stake blockchain by replacing *ATOM* with the nat
staking token of the chain.

* [Concepts](#concepts)
* [Proposal submission](#proposal-submission)
* [Deposit](#deposit)
* [Vote](#vote)
* [Proposal submission](#proposal-submission)
* [Deposit](#deposit)
* [Vote](#vote)
* [State](#state)
* [Proposals](#proposals)
* [Parameters and base types](#parameters-and-base-types)
* [Deposit](#deposit-1)
* [ValidatorGovInfo](#validatorgovinfo)
* [Stores](#stores)
* [Proposal Processing Queue](#proposal-processing-queue)
* [Legacy Proposal](#legacy-proposal)
* [Proposals](#proposals)
* [Parameters and base types](#parameters-and-base-types)
* [Deposit](#deposit-1)
* [ValidatorGovInfo](#validatorgovinfo)
* [Stores](#stores)
* [Proposal Processing Queue](#proposal-processing-queue)
* [Legacy Proposal](#legacy-proposal)
* [Messages](#messages)
* [Proposal Submission](#proposal-submission-1)
* [Deposit](#deposit-2)
* [Vote](#vote-1)
* [Proposal Submission](#proposal-submission-1)
* [Deposit](#deposit-2)
* [Vote](#vote-1)
* [Events](#events)
* [EndBlocker](#endblocker)
* [Handlers](#handlers)
* [EndBlocker](#endblocker)
* [Handlers](#handlers)
* [Parameters](#parameters)
* [Client](#client)
* [CLI](#cli)
* [gRPC](#grpc)
* [REST](#rest)
* [CLI](#cli)
* [gRPC](#grpc)
* [REST](#rest)
* [Metadata](#metadata)
* [Proposal](#proposal-3)
* [Vote](#vote-5)
* [Proposal](#proposal-3)
* [Vote](#vote-5)
* [Future Improvements](#future-improvements)

## Concepts
@@ -273,12 +273,12 @@ There are three parameters that define if the deposit of a proposal should be bu
Since this is more of a social feature than a technical feature, we'll now get into some items that may have been useful to have in a genesis constitution:

* What limitations on governance exist, if any?
* is it okay for the community to slash the wallet of a whale that they no longer feel that they want around? (viz: Juno Proposal 4 and 16)
* can governance "socially slash" a validator who is using unapproved MEV? (viz: commonwealth.im/osmosis)
* In the event of an economic emergency, what should validators do?
* Terra crash of May, 2022, saw validators choose to run a new binary with code that had not been approved by governance, because the governance token had been inflated to nothing.
* is it okay for the community to slash the wallet of a whale that they no longer feel that they want around? (viz: Juno Proposal 4 and 16)
* can governance "socially slash" a validator who is using unapproved MEV? (viz: commonwealth.im/osmosis)
* In the event of an economic emergency, what should validators do?
* Terra crash of May, 2022, saw validators choose to run a new binary with code that had not been approved by governance, because the governance token had been inflated to nothing.
* What is the purpose of the chain, specifically?
* best example of this is the Cosmos hub, where different founding groups, have different interpretations of the purpose of the network.
* best example of this is the Cosmos hub, where different founding groups, have different interpretations of the purpose of the network.

This genesis entry, "constitution" hasn't been designed for existing chains, who should likely just ratify a constitution using their governance system. Instead, this is for new chains. It will allow for validators to have a much clearer idea of purpose and the expecations placed on them while operating their nodes. Likewise, for community members, the constitution will give them some idea of what to expect from both the "chain team" and the validators, respectively.

@@ -480,7 +480,7 @@ The `initialDeposit` must be strictly positive and conform to the accepted denom
* Initialise `Proposal`'s attributes
* Decrease balance of sender by `InitialDeposit`
* If `MinDeposit` is reached:
* Push `proposalID` in `ProposalProcessingQueue`
* Push `proposalID` in `ProposalProcessingQueue`
* Transfer `InitialDeposit` from the `Proposer` to the governance `ModuleAccount`

### Deposit
@@ -504,7 +504,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/gov/v1/tx.pro
* Add `deposit` of sender in `proposal.Deposits`
* Increase `proposal.TotalDeposit` by sender's `deposit`
* If `MinDeposit` is reached:
* Push `proposalID` in `ProposalProcessingQueueEnd`
* Push `proposalID` in `ProposalProcessingQueueEnd`
* Transfer `Deposit` from the `proposer` to the governance `ModuleAccount`

### Vote
@@ -591,26 +591,26 @@ The governance module emits the following events:

The governance module contains the following parameters:

| Key | Type | Example |
| --------------------------------- | ----------------- | --------------------------------------- |
| min_deposit | array (coins) | [{"denom":"uatom","amount":"10000000"}] |
| max_deposit_period | string (time ns) | "172800000000000" (17280s) |
| voting_period | string (time ns) | "172800000000000" (17280s) |
| quorum | string (dec) | "0.334000000000000000" |
| threshold | string (dec) | "0.500000000000000000" |
| veto | string (dec) | "0.334000000000000000" |
| expedited_threshold | string (time ns) | "0.667000000000000000" |
| expedited_voting_period | string (time ns) | "86400000000000" (8600s) |
| expedited_min_deposit | array (coins) | [{"denom":"uatom","amount":"50000000"}] |
| burn_proposal_deposit_prevote | bool | false |
| burn_vote_quorum | bool | false |
| burn_vote_veto | bool | true |
| min_initial_deposit_ratio | string | "0.1" |
| proposal_cancel_ratio | string (dec) | "0.5" |
| proposal_cancel_dest | string (address) | "cosmos1.." or empty for burn |
| proposal_cancel_max_cancel_period | string (dec) | "0.5" |
| optimistic_rejected_threshold | string (dec) | "0.1" |
| optimistic_authorized_addresses | array (addresses) | [] |
| Key | Type | Example |
| ------------------------------- | ----------------- | --------------------------------------- |
| min_deposit | array (coins) | [{"denom":"uatom","amount":"10000000"}] |
| max_deposit_period | string (time ns) | "172800000000000" (17280s) |
| voting_period | string (time ns) | "172800000000000" (17280s) |
| quorum | string (dec) | "0.334000000000000000" |
| threshold | string (dec) | "0.500000000000000000" |
| veto | string (dec) | "0.334000000000000000" |
| expedited_threshold | string (time ns) | "0.667000000000000000" |
| expedited_voting_period | string (time ns) | "86400000000000" (8600s) |
| expedited_min_deposit | array (coins) | [{"denom":"uatom","amount":"50000000"}] |
| burn_proposal_deposit_prevote | bool | false |
| burn_vote_quorum | bool | false |
| burn_vote_veto | bool | true |
| min_initial_deposit_ratio | string | "0.1" |
| proposal_cancel_ratio | string (dec) | "0.5" |
| proposal_cancel_dest | string (address) | "cosmos1.." or empty for burn |
| proposal_cancel_max_period | string (dec) | "0.5" |
| optimistic_rejected_threshold | string (dec) | "0.1" |
| optimistic_authorized_addresses | array (addresses) | [] |

**NOTE**: The governance module contains parameters that are objects unlike other
modules. If only a subset of parameters are desired to be changed, only they need
2 changes: 1 addition & 1 deletion x/gov/keeper/proposal.go
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ func (keeper Keeper) CancelProposal(ctx context.Context, proposalID uint64, prop
if proposal.VotingEndTime != nil {
currentTime := sdkCtx.HeaderInfo().Time

maxCancelPeriodRate := sdkmath.LegacyMustNewDecFromStr(params.ProposalCancelMaxCancelPeriod)
maxCancelPeriodRate := sdkmath.LegacyMustNewDecFromStr(params.ProposalCancelMaxPeriod)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what does rate mean in maxCancelPeriodRate? Maybe maxCancelPeriod or maxCancelPeriodDuration and rename maxCancelPeriod to maxCancelTime?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, it's not a duration, my bad

maxCancelPeriod := time.Duration(float64(proposal.VotingEndTime.Sub(*proposal.VotingStartTime)) * maxCancelPeriodRate.MustFloat64()).Round(time.Second)

if proposal.VotingEndTime.Before(currentTime) {
2 changes: 1 addition & 1 deletion x/gov/migrations/v6/store.go
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ func MigrateStore(ctx sdk.Context, paramsCollection collections.Item[v1.Params],
defaultParams := v1.DefaultParams()
govParams.OptimisticAuthorizedAddresses = defaultParams.OptimisticAuthorizedAddresses
govParams.OptimisticRejectedThreshold = defaultParams.OptimisticRejectedThreshold
govParams.ProposalCancelMaxCancelPeriod = defaultParams.ProposalCancelMaxCancelPeriod
govParams.ProposalCancelMaxPeriod = defaultParams.ProposalCancelMaxPeriod

return paramsCollection.Set(ctx, govParams)
}
4 changes: 2 additions & 2 deletions x/gov/simulation/genesis_test.go
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ func TestRandomizedGenState(t *testing.T) {
tallyExpeditedThreshold = "0.537000000000000000"
tallyVetoThreshold = "0.276000000000000000"
minInitialDepositDec = "0.880000000000000000"
proposalMaxCancelPeriod = "0.110000000000000000"
proposalCancelMaxPeriod = "0.110000000000000000"
)

assert.Equal(t, "272stake", govGenesis.Params.MinDeposit[0].String())
@@ -63,7 +63,7 @@ func TestRandomizedGenState(t *testing.T) {
assert.Equal(t, tallyThreshold, govGenesis.Params.Threshold)
assert.Equal(t, tallyExpeditedThreshold, govGenesis.Params.ExpeditedThreshold)
assert.Equal(t, tallyVetoThreshold, govGenesis.Params.VetoThreshold)
assert.Equal(t, proposalMaxCancelPeriod, govGenesis.Params.ProposalCancelMaxCancelPeriod)
assert.Equal(t, proposalCancelMaxPeriod, govGenesis.Params.ProposalCancelMaxPeriod)
assert.Equal(t, uint64(0x28), govGenesis.StartingProposalId)
assert.DeepEqual(t, []*v1.Deposit{}, govGenesis.Deposits)
assert.DeepEqual(t, []*v1.Vote{}, govGenesis.Votes)
Loading