Skip to content

Commit

Permalink
feat(x/gov): implement a minimum amount per deposit (cosmos#18146)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored and mattverse committed Feb 2, 2024
1 parent 2b41ee8 commit 395ba98
Show file tree
Hide file tree
Showing 21 changed files with 573 additions and 184 deletions.
151 changes: 117 additions & 34 deletions api/cosmos/gov/v1/gov.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions proto/cosmos/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,12 @@ message Params {

// burn deposits if quorum with vote type no_veto is met
bool burn_vote_veto = 15;

// The ratio representing the proportion of the deposit value minimum that must be met when making a deposit.
// Default value: 0.01. Meaning that for a chain with a min_deposit of 100stake, a deposit of 1stake would be
// required.
//
// Since: cosmos-sdk 0.50
// NOTE: backported from v50 (https://github.com/cosmos/cosmos-sdk/pull/18146)
string min_deposit_ratio = 16 [(cosmos_proto.scalar) = "cosmos.Dec"];
}
29 changes: 1 addition & 28 deletions tests/e2e/gov/deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,6 @@ func (s *DepositTestSuite) TearDownSuite() {
s.network.Cleanup()
}

func (s *DepositTestSuite) TestQueryDepositsWithoutInitialDeposit() {
val := s.network.Validators[0]
clientCtx := val.ClientCtx

// submit proposal without initial deposit
id := s.submitProposal(val, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0)), "TestQueryDepositsWithoutInitialDeposit")
proposalID := strconv.FormatUint(id, 10)

// deposit amount
depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Add(sdk.NewInt(50))).String()
_, err := govclitestutil.MsgDeposit(clientCtx, val.Address.String(), proposalID, depositAmount)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())

// query deposit
deposit := s.queryDeposit(val, proposalID, false, "")
s.Require().NotNil(deposit)
s.Require().Equal(sdk.Coins(deposit.Amount).String(), depositAmount)

// query deposits
deposits := s.queryDeposits(val, proposalID, false, "")
s.Require().NotNil(deposits)
s.Require().Len(deposits.Deposits, 1)
// verify initial deposit
s.Require().Equal(sdk.Coins(deposits.Deposits[0].Amount).String(), depositAmount)
}

func (s *DepositTestSuite) TestQueryDepositsWithInitialDeposit() {
val := s.network.Validators[0]
depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens)
Expand Down Expand Up @@ -149,7 +122,7 @@ func (s *DepositTestSuite) TestQueryProposalAfterVotingPeriod() {
s.Require().Contains(err.Error(), fmt.Sprintf("proposal %s doesn't exist", proposalID))

// query deposits
deposits := s.queryDeposits(val, proposalID, true, "proposal 3 doesn't exist")
deposits := s.queryDeposits(val, proposalID, true, fmt.Sprintf("proposal %s doesn't exist", proposalID))
s.Require().Nil(deposits)
}

Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/gov/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ func (s *E2ETestSuite) TestCmdParams() {
{
"json output",
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
<<<<<<< HEAD
`{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000","expedited_voting_period":"86400s","expedited_threshold":"0.667000000000000000","expedited_min_deposit":[{"denom":"stake","amount":"50000000"}],"burn_vote_quorum":false,"burn_proposal_deposit_prevote":false,"burn_vote_veto":true}}`,
=======
`{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000","burn_vote_quorum":false,"burn_proposal_deposit_prevote":false,"burn_vote_veto":true,"min_deposit_ratio":"0.010000000000000000"}}`,
>>>>>>> eefb34369c (fix(x/gov)!: backport of PR #18146: min amount per deposit (#19312))
},
{
"text output",
Expand All @@ -47,6 +51,7 @@ params:
min_deposit:
- amount: "10000000"
denom: stake
min_deposit_ratio: "0.010000000000000000"
min_initial_deposit_ratio: "0.000000000000000000"
quorum: "0.334000000000000000"
threshold: "0.500000000000000000"
Expand Down
Loading

0 comments on commit 395ba98

Please sign in to comment.