diff --git a/app/antedecorators/gasless.go b/app/antedecorators/gasless.go index e506fe4e5..ee76cbb26 100644 --- a/app/antedecorators/gasless.go +++ b/app/antedecorators/gasless.go @@ -28,19 +28,15 @@ func (gd GaslessDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // eagerly set infinite gas meter so that queries performed by isTxGasless will not incur gas cost ctx = ctx.WithGasMeter(storetypes.NewNoConsumptionInfiniteGasMeter()) - feeTx, ok := tx.(sdk.FeeTx) - if !ok { - return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") - } - gas := feeTx.GetGas() - // If non-zero gas limit is provided by the TX, we then consider it exempt from the gasless TX, and then prioritize it accordingly isGasless, err := isTxGasless(tx, ctx, gd.oracleKeeper) if err != nil { return ctx, err } + if !isGasless { + ctx = ctx.WithGasMeter(originalGasMeter) + } isDeliverTx := !ctx.IsCheckTx() && !ctx.IsReCheckTx() && !simulate - shouldCheckTxSkipFeeDeduct := gas == 0 && isGasless // whether the tx should be subject to min fee check AND priority assignment. Applicable to CheckTx only. - if isDeliverTx || !shouldCheckTxSkipFeeDeduct { + if isDeliverTx || !isGasless { // In the case of deliverTx, we want to deduct fees regardless of whether the tx is considered gasless or not, since // gasless txs will be subject to application-specific fee requirements in later stage of ante, for which the payment // of those app-specific fees happens here. Note that the minimum fee check in the wrapped deduct fee handler is only @@ -49,13 +45,9 @@ func (gd GaslessDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // Otherwise (i.e. in the case of checkTx), we only want to perform fee checks and fee deduction if the tx is not considered // gasless, or if it specifies a non-zero gas limit even if it is considered gasless, so that the wrapped deduct fee // handler will assign an appropriate priority to it. - if !isGasless { - ctx = ctx.WithGasMeter(originalGasMeter) - } return gd.handleWrapped(ctx, tx, simulate, next) } - // must be gasless if this part is reached, so no need to overwrite gas meter back return next(ctx, tx, simulate) } diff --git a/app/antedecorators/gasless_test.go b/app/antedecorators/gasless_test.go index 2415a9fa4..5e77d907b 100644 --- a/app/antedecorators/gasless_test.go +++ b/app/antedecorators/gasless_test.go @@ -146,20 +146,7 @@ func TestGaslessDecorator(t *testing.T) { require.NoError(t, err) require.Equal(t, "onetwothree", outputDeps) - // gasless tx (checkTx w/ gas limit) -> wrapped should still be run - output = "" - outputDeps = "" - _, err = chainedHandler(ctx.WithIsCheckTx(true), FakeTx{ - FakeMsgs: []sdk.Msg{&types.MsgPlaceOrders{}}, - Gas: 100, - }, false) - require.NoError(t, err) - require.Equal(t, "onetwothree", output) - _, err = depGen([]accesscontrol.AccessOperation{}, FakeTx{}, 1) - require.NoError(t, err) - require.Equal(t, "onetwothree", outputDeps) - - // gasless tx (checkTx w/o gas limit) -> wrapped should not be run + // gasless tx (checkTx) -> wrapped should not be run output = "" outputDeps = "" _, err = chainedHandler(ctx.WithIsCheckTx(true), FakeTx{