Skip to content

Commit

Permalink
Skip max gas fees if tx contains MsgSubmitProposal msg (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Adams committed Mar 4, 2022
1 parent 55c93a6 commit 497e4b9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/antewrapper/tx_gas_limit_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package antewrapper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

// TxGasLimitDecorator will check if the transaction's gas amount is higher than
Expand Down Expand Up @@ -31,8 +32,18 @@ func (mfd TxGasLimitDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b
gasTxLimit = ctx.BlockGasMeter().Limit() / MinTxPerBlock
}

// Skip gas limit check for txs with MsgSubmitProposal
hasSubmitPropMsg := false
for _, msg := range tx.GetMsgs() {
_, isSubmitPropMsg := msg.(*govtypes.MsgSubmitProposal)
if isSubmitPropMsg {
hasSubmitPropMsg = true
break
}
}

// TODO - remove "gasTxLimit > 0" with SDK 0.46 which fixes the infinite gas meter to use max int vs zero for the limit.
if gasTxLimit > 0 && gas > gasTxLimit {
if gasTxLimit > 0 && gas > gasTxLimit && !hasSubmitPropMsg {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrTxTooLarge, "transaction gas exceeds maximum allowed; got: %d max allowed: %d", gas, gasTxLimit)
}
return next(ctx, tx, simulate)
Expand Down

0 comments on commit 497e4b9

Please sign in to comment.