From 9606c16c311a8818f382b03358ccef933d8611bd Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 26 Jan 2022 19:36:24 +0100 Subject: [PATCH] feat: remove burning of deposits in gov (#11011) ## Description Closes: #11010 only burn deposits on veto'd proposals/ --- ### 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) --- CHANGELOG.md | 1 + x/gov/abci.go | 4 ++-- x/gov/keeper/tally.go | 2 +- x/gov/keeper/tally_test.go | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e17643146d1..c36c6b714b46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -192,6 +192,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#10763](https://github.com/cosmos/cosmos-sdk/pull/10763) modify the fields in `TallyParams` to use `string` instead of `bytes` * [#10770](https://github.com/cosmos/cosmos-sdk/pull/10770) revert tx when block gas limit exceeded * [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1beta2. Both v1beta1 and v1beta2 queries and Msgs are accepted. +* [\#11011](https://github.com/cosmos/cosmos-sdk/pull/11011) Remove burning of deposits when qourum is not reached on a governance proposal and when the deposit is not fully met. ### Deprecated diff --git a/x/gov/abci.go b/x/gov/abci.go index 36fea6f2c0e9..5876358ef493 100644 --- a/x/gov/abci.go +++ b/x/gov/abci.go @@ -17,10 +17,10 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { logger := keeper.Logger(ctx) - // delete dead proposals from store and burn theirs deposits. A proposal is dead when it's inactive and didn't get enough deposit on time to get into voting phase. + // delete dead proposals from store and returns theirs deposits. A proposal is dead when it's inactive and didn't get enough deposit on time to get into voting phase. keeper.IterateInactiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal v1beta2.Proposal) bool { keeper.DeleteProposal(ctx, proposal.ProposalId) - keeper.DeleteAndBurnDeposits(ctx, proposal.ProposalId) + keeper.RefundAndDeleteDeposits(ctx, proposal.ProposalId) // refund deposit if proposal got removed without getting 100% of the proposal // called when proposal become inactive keeper.AfterProposalFailedMinDeposit(ctx, proposal.ProposalId) diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index 2cabec0cf5bc..470af87088ba 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -105,7 +105,7 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal v1beta2.Proposal) (passes b percentVoting := totalVotingPower.Quo(keeper.sk.TotalBondedTokens(ctx).ToDec()) quorum, _ := sdk.NewDecFromStr(tallyParams.Quorum) if percentVoting.LT(quorum) { - return false, true, tallyResults + return false, false, tallyResults } // If no one votes (everyone abstains), proposal fails diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index 2f9d48618f88..a7e3176e18ea 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -31,7 +31,7 @@ func TestTallyNoOneVotes(t *testing.T) { passes, burnDeposits, tallyResults := app.GovKeeper.Tally(ctx, proposal) require.False(t, passes) - require.True(t, burnDeposits) + require.False(t, burnDeposits) require.True(t, tallyResults.Equals(v1beta2.EmptyTallyResult())) } @@ -57,7 +57,7 @@ func TestTallyNoQuorum(t *testing.T) { require.True(t, ok) passes, burnDeposits, _ := app.GovKeeper.Tally(ctx, proposal) require.False(t, passes) - require.True(t, burnDeposits) + require.False(t, burnDeposits) } func TestTallyOnlyValidatorsAllYes(t *testing.T) {