Skip to content

Commit 6e9d38e

Browse files
committed
update
1 parent 2525de2 commit 6e9d38e

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

app/antedecorators/gasless.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,15 @@ func (gd GaslessDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool,
2828
// eagerly set infinite gas meter so that queries performed by isTxGasless will not incur gas cost
2929
ctx = ctx.WithGasMeter(storetypes.NewNoConsumptionInfiniteGasMeter())
3030

31-
feeTx, ok := tx.(sdk.FeeTx)
32-
if !ok {
33-
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
34-
}
35-
gas := feeTx.GetGas()
36-
// If non-zero gas limit is provided by the TX, we then consider it exempt from the gasless TX, and then prioritize it accordingly
3731
isGasless, err := isTxGasless(tx, ctx, gd.oracleKeeper)
3832
if err != nil {
3933
return ctx, err
4034
}
35+
if !isGasless {
36+
ctx = ctx.WithGasMeter(originalGasMeter)
37+
}
4138
isDeliverTx := !ctx.IsCheckTx() && !ctx.IsReCheckTx() && !simulate
42-
shouldCheckTxSkipFeeDeduct := gas == 0 && isGasless // whether the tx should be subject to min fee check AND priority assignment. Applicable to CheckTx only.
43-
if isDeliverTx || !shouldCheckTxSkipFeeDeduct {
39+
if isDeliverTx || !isGasless {
4440
// In the case of deliverTx, we want to deduct fees regardless of whether the tx is considered gasless or not, since
4541
// gasless txs will be subject to application-specific fee requirements in later stage of ante, for which the payment
4642
// 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,
4945
// Otherwise (i.e. in the case of checkTx), we only want to perform fee checks and fee deduction if the tx is not considered
5046
// gasless, or if it specifies a non-zero gas limit even if it is considered gasless, so that the wrapped deduct fee
5147
// handler will assign an appropriate priority to it.
52-
if !isGasless {
53-
ctx = ctx.WithGasMeter(originalGasMeter)
54-
}
5548
return gd.handleWrapped(ctx, tx, simulate, next)
5649
}
5750

58-
// must be gasless if this part is reached, so no need to overwrite gas meter back
5951
return next(ctx, tx, simulate)
6052
}
6153

app/antedecorators/gasless_test.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,7 @@ func TestGaslessDecorator(t *testing.T) {
146146
require.NoError(t, err)
147147
require.Equal(t, "onetwothree", outputDeps)
148148

149-
// gasless tx (checkTx w/ gas limit) -> wrapped should still be run
150-
output = ""
151-
outputDeps = ""
152-
_, err = chainedHandler(ctx.WithIsCheckTx(true), FakeTx{
153-
FakeMsgs: []sdk.Msg{&types.MsgPlaceOrders{}},
154-
Gas: 100,
155-
}, false)
156-
require.NoError(t, err)
157-
require.Equal(t, "onetwothree", output)
158-
_, err = depGen([]accesscontrol.AccessOperation{}, FakeTx{}, 1)
159-
require.NoError(t, err)
160-
require.Equal(t, "onetwothree", outputDeps)
161-
162-
// gasless tx (checkTx w/o gas limit) -> wrapped should not be run
149+
// gasless tx (checkTx) -> wrapped should not be run
163150
output = ""
164151
outputDeps = ""
165152
_, err = chainedHandler(ctx.WithIsCheckTx(true), FakeTx{

0 commit comments

Comments
 (0)