Skip to content

Commit

Permalink
feat: Remove NewValidatorCommissionDecorator and set min_commission_r…
Browse files Browse the repository at this point in the history
…ate to upgrade handler
  • Loading branch information
dudong2 committed May 13, 2024
1 parent 36053ab commit 38a6092
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 88 deletions.
85 changes: 0 additions & 85 deletions app/ante/comission.go

This file was deleted.

3 changes: 0 additions & 3 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, nil),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand All @@ -114,7 +113,6 @@ func newCosmosSimulationAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
// NewParamChangeLimitDecorator(options.SlashingKeeper, options.Cdc),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, nil),
// NewValidatorCommissionDecorator(options.Cdc),
//ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
//ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
Expand All @@ -138,7 +136,6 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, nil),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ func (app *Canto) setupUpgradeHandlers() {
app.ConsensusParamsKeeper.ParamsStore,
app.configurator,
app.IBCKeeper.ClientKeeper,
app.StakingKeeper,
),
)

Expand Down
13 changes: 13 additions & 0 deletions app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"context"

"cosmossdk.io/collections"
sdkmath "cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
)
Expand All @@ -21,6 +23,7 @@ func CreateUpgradeHandler(
consensusParamsStore collections.Item[types.ConsensusParams],
configurator module.Configurator,
clientKeeper clientkeeper.Keeper,
stakingKeeper *stakingkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
Expand All @@ -47,6 +50,16 @@ func CreateUpgradeHandler(
return vm, err
}

// canto v8 custom
{
params, err := stakingKeeper.GetParams(ctx)
if err != nil {
return vm, err
}
params.MinCommissionRate = sdkmath.LegacyNewDecWithPrec(5, 2) // 5%
stakingKeeper.SetParams(ctx, params)
}

// Leave modules are as-is to avoid running InitGenesis.
logger.Debug("running module migrations ...")
return mm.RunMigrations(ctx, configurator, vm)
Expand Down

0 comments on commit 38a6092

Please sign in to comment.