From a759409c9da2780663244308b430a7847b95139b Mon Sep 17 00:00:00 2001 From: dongsam Date: Tue, 18 Jul 2023 19:02:10 +0900 Subject: [PATCH] Merge pull request from GHSA-354m-4qv6-x846 --- ante/gov_ante.go | 2 +- ante/gov_ante_test.go | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ante/gov_ante.go b/ante/gov_ante.go index 88dbddea157..5c08e669f85 100644 --- a/ante/gov_ante.go +++ b/ante/gov_ante.go @@ -50,7 +50,7 @@ func (g GovPreventSpamDecorator) ValidateGovMsgs(ctx sdk.Context, msgs []sdk.Msg // prevent messages with insufficient initial deposit amount depositParams := g.govKeeper.GetDepositParams(ctx) minInitialDeposit := g.calcMinInitialDeposit(depositParams.MinDeposit) - if msg.InitialDeposit.IsAllLT(minInitialDeposit) { + if !msg.InitialDeposit.IsAllGTE(minInitialDeposit) { return errorsmod.Wrapf(gaiaerrors.ErrInsufficientFunds, "insufficient initial deposit amount - required: %v", minInitialDeposit) } } diff --git a/ante/gov_ante_test.go b/ante/gov_ante_test.go index b4194bdc9bf..d2509dbe181 100644 --- a/ante/gov_ante_test.go +++ b/ante/gov_ante_test.go @@ -20,10 +20,16 @@ import ( ) var ( - insufficientCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100)) - minCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000)) - moreThanMinCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 2500000)) - testAddr = sdk.AccAddress("test1") + insufficientCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100)) + insufficientMultiDenomCoins = sdk.NewCoins( + sdk.NewInt64Coin(sdk.DefaultBondDenom, 100), + sdk.NewInt64Coin("ibc/example", 100)) + minCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000)) + moreThanMinCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 2500000)) + moreThanMinMultiDenomCoins = sdk.NewCoins( + sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000), + sdk.NewInt64Coin("ibc/example", 100)) + testAddr = sdk.AccAddress("test1") ) type GovAnteHandlerTestSuite struct { @@ -66,7 +72,9 @@ func (s *GovAnteHandlerTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { }{ {"Passing proposal 1", "the purpose of this proposal is to pass", govtypes.ProposalTypeText, testAddr, minCoins, true}, {"Passing proposal 2", "the purpose of this proposal is to pass with more coins than minimum", govtypes.ProposalTypeText, testAddr, moreThanMinCoins, true}, - {"Failing proposal", "the purpose of this proposal is to fail", govtypes.ProposalTypeText, testAddr, insufficientCoins, false}, + {"Passing proposal 3", "the purpose of this proposal is to pass with multi denom coins", govtypes.ProposalTypeText, testAddr, moreThanMinMultiDenomCoins, true}, + {"Failing proposal 1", "the purpose of this proposal is to fail", govtypes.ProposalTypeText, testAddr, insufficientCoins, false}, + {"Failing proposal 2", "the purpose of this proposal is to fail with multi denom coins", govtypes.ProposalTypeText, testAddr, insufficientMultiDenomCoins, false}, } decorator := ante.NewGovPreventSpamDecorator(s.app.AppCodec(), &s.app.GovKeeper)