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(cli): cancel gov proposal by proposer before voting period ends #13010

Merged
merged 203 commits into from
Jan 20, 2023
Merged

feat(cli): cancel gov proposal by proposer before voting period ends #13010

merged 203 commits into from
Jan 20, 2023

Conversation

gsk967
Copy link
Contributor

@gsk967 gsk967 commented Aug 24, 2022

Description

This pull request contains the new cli tx to cancel the gov proposal by the proposer

Closes: #11554

  1. Proposer can cancel the proposal before the voting period ends.
  2. Added proposal_cancel_ratio and proposal_cancel_dest params to gov.
  3. When the proposal is cancel by proposer
    i. (totalDeposits * proposal_cancel_ratio) amount will be burned if proposal_cancel_dest is not empty otherwise it will burned.
    ii. totalDeposits * (1 - proposal_cancel_ratio) amount will be sent back to the depositors.

Proposal migrations with proposer

package simapp

import (
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/cosmos/cosmos-sdk/types/module"
	v4 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v4"
	upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// UpgradeName defines the on-chain upgrade name for the sample simapp upgrade from v045 to v046.
//
// NOTE: This upgrade defines a reference implementation of what an upgrade could look like
const UpgradeName = "v047-to-v048"

func (app SimApp) RegisterUpgradeHandlers() {
	app.UpgradeKeeper.SetUpgradeHandler(UpgradeName,
		func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
			// add proposal ids with proposers
			proposals := make(map[uint64]string)
			// proposals[1] = "cosmos1luyncewxk4lm24k6gqy8y5dxkj0klr4tu0lmnj" ...
			v4.AddProposerAddressToProposal(ctx, sdk.NewKVStoreKey(v4.ModuleName), app.appCodec, proposals)
			return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
		})
}

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 in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • 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 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)

x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/migrations/v4/store.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Sep 1, 2022

Codecov Report

Merging #13010 (479e71c) into main (2739f83) will decrease coverage by 2.08%.
The diff coverage is 36.59%.

❗ Current head 479e71c differs from pull request most recent head 127caff. Consider uploading reports for the commit 127caff to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13010      +/-   ##
==========================================
- Coverage   56.25%   54.18%   -2.08%     
==========================================
  Files         667      654      -13     
  Lines       56576    55910     -666     
==========================================
- Hits        31829    30294    -1535     
- Misses      22165    23205    +1040     
+ Partials     2582     2411     -171     
Impacted Files Coverage Δ
x/gov/client/cli/tx.go 12.82% <0.00%> (-57.70%) ⬇️
x/gov/keeper/deposit.go 71.76% <0.00%> (-17.95%) ⬇️
x/gov/migrations/v4/store.go 50.98% <0.00%> (-30.66%) ⬇️
x/gov/types/expected_keepers.go 0.00% <ø> (ø)
x/gov/types/keys.go 88.88% <0.00%> (ø)
x/gov/types/v1/msgs.go 53.44% <0.00%> (-5.05%) ⬇️
x/gov/types/v1/proposal.go 16.94% <0.00%> (-0.30%) ⬇️
x/gov/keeper/msg_server.go 76.67% <7.14%> (-6.40%) ⬇️
x/gov/keeper/proposal.go 77.31% <53.84%> (-4.50%) ⬇️
x/gov/keeper/keeper.go 68.18% <54.54%> (-5.23%) ⬇️
... and 309 more

@gsk967 gsk967 marked this pull request as ready for review September 1, 2022 14:08
@gsk967 gsk967 requested a review from a team as a code owner September 1, 2022 14:08
CHANGELOG.md Outdated Show resolved Hide resolved
x/gov/abci.go Outdated Show resolved Hide resolved
x/gov/abci.go Outdated Show resolved Hide resolved
x/gov/abci.go Outdated Show resolved Hide resolved
x/gov/client/cli/tx.go Outdated Show resolved Hide resolved
x/gov/client/testutil/tx.go Outdated Show resolved Hide resolved
x/gov/keeper/deposit.go Outdated Show resolved Hide resolved
x/gov/keeper/deposit.go Outdated Show resolved Hide resolved
x/gov/keeper/deposit.go Outdated Show resolved Hide resolved
x/gov/keeper/deposit.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

utACK

@tac0turtle tac0turtle enabled auto-merge (squash) January 20, 2023 12:30
@tac0turtle
Copy link
Member

enabled auto merge, don't see any followups left

@tac0turtle tac0turtle added the A:automerge Automatically merge PR once all prerequisites pass. label Jan 20, 2023
@gsk967
Copy link
Contributor Author

gsk967 commented Jan 20, 2023

Thanks all whoever support this feature, specially @anilcse @robert-zaremba 🙏🏻🙏🏻🙏🏻

@tac0turtle tac0turtle merged commit a4cf8e8 into cosmos:main Jan 20, 2023
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
…osmos#13010)

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Marko <marbar3778@yahoo.com>
Closes cosmos#11554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI C:Simulations C:x/bank C:x/gov T: State Machine Breaking State machine breaking changes (impacts consensus).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cancel governance proposal by proposer