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

fix!: remove GovPreventSpamDecorator #2913

Merged
merged 6 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
3 changes: 3 additions & 0 deletions .changelog/unreleased/state-breaking/2913-gov-spam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Remove `GovPreventSpamDecorator` and initialize the `MinInitialDepositRatio` gov
param to `10%`.
([\#2913](https://github.com/cosmos/gaia/pull/2913))
6 changes: 0 additions & 6 deletions ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

Expand All @@ -22,7 +21,6 @@ import (
type HandlerOptions struct {
ante.HandlerOptions
Codec codec.BinaryCodec
GovKeeper *govkeeper.Keeper
IBCkeeper *ibckeeper.Keeper
GlobalFeeSubspace paramtypes.Subspace
StakingKeeper *stakingkeeper.Keeper
Expand Down Expand Up @@ -50,9 +48,6 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
if opts.StakingKeeper == nil {
return nil, errorsmod.Wrap(gaiaerrors.ErrNotFound, "staking param store is required for AnteHandler")
}
if opts.GovKeeper == nil {
return nil, errorsmod.Wrap(gaiaerrors.ErrLogic, "gov keeper is required for AnteHandler")
}

sigGasConsumer := opts.SigGasConsumer
if sigGasConsumer == nil {
Expand All @@ -66,7 +61,6 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(opts.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
NewGovPreventSpamDecorator(opts.Codec, opts.GovKeeper),
gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingKeeper),
ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper, opts.TxFeeChecker),
ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
Expand Down
98 changes: 0 additions & 98 deletions ante/gov_ante.go

This file was deleted.

101 changes: 0 additions & 101 deletions ante/gov_ante_test.go

This file was deleted.

1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ func NewGaiaApp(
},
Codec: appCodec,
IBCkeeper: app.IBCKeeper,
GovKeeper: app.GovKeeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
StakingKeeper: app.StakingKeeper,
// If TxFeeChecker is nil the default ante TxFeeChecker is used
Expand Down
22 changes: 22 additions & 0 deletions app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
Expand Down Expand Up @@ -57,6 +58,9 @@ func CreateUpgradeHandler(
keepers); err != nil {
return nil, fmt.Errorf("failed migrating vesting funds: %s", err)
}
if err := SetMinInitialDepositRatio(ctx, *keepers.GovKeeper); err != nil {
return nil, fmt.Errorf("failed initializing the min initial deposit ratio: %s", err)
}

ctx.Logger().Info("Upgrade v15 complete")
return vm, err
Expand Down Expand Up @@ -323,3 +327,21 @@ func setBalance(

return nil
}

// SetMinInitialDepositRatio sets the MinInitialDepositRatio param of the gov
// module to 10% - this is the proportion of the deposit value that must be paid
// at proposal submission.
func SetMinInitialDepositRatio(ctx sdk.Context, gk govkeeper.Keeper) error {
ctx.Logger().Info("Initializing MinInitialDepositRatio...")

params := gk.GetParams(ctx)
params.MinInitialDepositRatio = sdk.NewDecWithPrec(1, 1).String() // 0.1 (10%)
err := gk.SetParams(ctx, params)
if err != nil {
return err
}

ctx.Logger().Info("Finished initializing MinInitialDepositRatio...")

return nil
}
12 changes: 12 additions & 0 deletions app/upgrades/v15/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,15 @@
)
require.NoError(t, err)
}

func TestSetMinInitialDepositRatio(t *testing.T) {
gaiaApp := helpers.Setup(t)
ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{})

v15.SetMinInitialDepositRatio(ctx, *gaiaApp.GovKeeper)

Check failure on line 278 in app/upgrades/v15/upgrades_test.go

View workflow job for this annotation

GitHub Actions / Analyze

Error return value of `v15.SetMinInitialDepositRatio` is not checked (errcheck)

Check failure on line 278 in app/upgrades/v15/upgrades_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `v15.SetMinInitialDepositRatio` is not checked (errcheck)
mpoke marked this conversation as resolved.
Show resolved Hide resolved

minInitialDepositRatioStr := gaiaApp.GovKeeper.GetParams(ctx).MinInitialDepositRatio
minInitialDepositRatio, err := math.LegacyNewDecFromStr(minInitialDepositRatioStr)
require.NoError(t, err)
require.True(t, minInitialDepositRatio.Equal(sdk.NewDecWithPrec(1, 1)))
}
Loading