diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 969aefebe..b582cba0f 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -39,7 +39,7 @@ import ( var DefaultConsensusParams = &tmproto.ConsensusParams{ Block: &tmproto.BlockParams{ MaxBytes: 200000, - MaxGas: 2000000, + MaxGas: 100000000, }, Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: 302400, diff --git a/x/auth/ante/setup.go b/x/auth/ante/setup.go index 6ef8f0c68..deaa6da61 100644 --- a/x/auth/ante/setup.go +++ b/x/auth/ante/setup.go @@ -51,6 +51,13 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate newCtx = sud.gasMeterSetter(simulate, ctx, gasTx.GetGas(), tx) + if cp := ctx.ConsensusParams(); cp != nil && cp.Block != nil { + // If there exists a maximum block gas limit, we must ensure that the tx + // does not exceed it. + if cp.Block.MaxGas > 0 && gasTx.GetGas() > uint64(cp.Block.MaxGas) { + return newCtx, sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "tx gas wanted %d exceeds block max gas limit %d", gasTx.GetGas(), cp.Block.MaxGas) + } + } // Decorator will catch an OutOfGasPanic caused in the next antehandler // AnteHandlers must have their own defer/recover in order for the BaseApp // to know how much gas was used! This is because the GasMeter is created in