From e55e074e01a56fb1bdb875023feee0549d33b683 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 3 May 2024 18:53:07 -0500 Subject: [PATCH] remove staking keeper & use "stake" for default 0 fee --- app/ante.go | 2 +- x/globalfee/ante/fee.go | 23 ++--------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/app/ante.go b/app/ante.go index 0441d66..b515f61 100644 --- a/app/ante.go +++ b/app/ante.go @@ -56,7 +56,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), // ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), - globalfeeante.NewFeeDecorator(options.BypassMinFeeMsgTypes, options.GlobalFeeKeeper, options.StakingKeeper, maxBypassMinFeeMsgGasUsage), + globalfeeante.NewFeeDecorator(options.BypassMinFeeMsgTypes, options.GlobalFeeKeeper, maxBypassMinFeeMsgGasUsage), ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(options.AccountKeeper), ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), diff --git a/x/globalfee/ante/fee.go b/x/globalfee/ante/fee.go index df21f09..7533ba2 100644 --- a/x/globalfee/ante/fee.go +++ b/x/globalfee/ante/fee.go @@ -1,8 +1,6 @@ package ante import ( - "errors" - tmstrings "github.com/cometbft/cometbft/libs/strings" errorsmod "cosmossdk.io/errors" @@ -10,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" globalfeekeeper "github.com/strangelove-ventures/globalfee/x/globalfee/keeper" ) @@ -31,15 +28,13 @@ var _ sdk.AnteDecorator = FeeDecorator{} type FeeDecorator struct { BypassMinFeeMsgTypes []string GlobalFeeKeeper globalfeekeeper.Keeper - StakingKeeper *stakingkeeper.Keeper MaxTotalBypassMinFeeMsgGasUsage uint64 } -func NewFeeDecorator(bypassMsgTypes []string, gfk globalfeekeeper.Keeper, sk *stakingkeeper.Keeper, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator { +func NewFeeDecorator(bypassMsgTypes []string, gfk globalfeekeeper.Keeper, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator { return FeeDecorator{ BypassMinFeeMsgTypes: bypassMsgTypes, GlobalFeeKeeper: gfk, - StakingKeeper: sk, MaxTotalBypassMinFeeMsgGasUsage: maxTotalBypassMinFeeMsgGasUsage, } } @@ -169,21 +164,7 @@ func (mfd FeeDecorator) GetGlobalFee(ctx sdk.Context, feeTx sdk.FeeTx) (sdk.Coin } func (mfd FeeDecorator) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, error) { - bondDenom := mfd.getBondDenom(ctx) - if bondDenom == "" { - return nil, errors.New("empty staking bond denomination") - } - - return []sdk.DecCoin{sdk.NewDecCoinFromDec(bondDenom, sdkmath.LegacyNewDec(0))}, nil -} - -func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string { - bd, err := mfd.StakingKeeper.BondDenom(ctx) - if err != nil { - return "" - } - - return bd + return []sdk.DecCoin{sdk.NewDecCoinFromDec("stake", sdkmath.LegacyNewDec(0))}, nil } // ContainsOnlyBypassMinFeeMsgs returns true if all the given msgs type are listed