diff --git a/CHANGELOG.md b/CHANGELOG.md index 92efb7b45c..1b1db8858e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (server) [\#821](https://github.com/line/lbm-sdk/pull/821) Get validator pubkey considering KMS * (client) [\#890](https://github.com/line/lbm-sdk/pull/890) Map Ostracon:ErrTxInMap to lbm-sdk:ErrTxInMempoolCache * (x/collection) [\#894](https://github.com/line/lbm-sdk/pull/894) Change the default params of x/collection +* (ante) [\#895](https://github.com/line/lbm-sdk/pull/895) Remove max gas validation ### Bug Fixes * (client) [\#817](https://github.com/line/lbm-sdk/pull/817) remove support for composite (BLS) type diff --git a/baseapp/abci.go b/baseapp/abci.go index e023cdac5c..705ac293ce 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -175,8 +175,7 @@ func (app *BaseApp) BeginBlock(req ocabci.RequestBeginBlock) (res abci.ResponseB if app.checkState != nil { app.checkState.ctx = app.checkState.ctx. WithBlockGasMeter(gasMeter). - WithHeaderHash(req.Hash). - WithConsensusParams(app.GetConsensusParams(app.deliverState.ctx)) + WithHeaderHash(req.Hash) } if app.beginBlocker != nil { diff --git a/x/auth/ante/setup.go b/x/auth/ante/setup.go index b5f2905d04..279790185d 100644 --- a/x/auth/ante/setup.go +++ b/x/auth/ante/setup.go @@ -39,11 +39,6 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate newCtx = SetGasMeter(simulate, ctx, gasTx.GetGas()) - err = validateGasWanted(newCtx) - if err != nil { - return newCtx, sdkerrors.Wrap(sdkerrors.ErrOutOfGas, err.Error()) - } - // 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 @@ -77,28 +72,3 @@ func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64) sdk.Context { return ctx.WithGasMeter(sdk.NewGasMeter(gasLimit)) } - -func validateGasWanted(ctx sdk.Context) error { - if !ctx.IsCheckTx() { - return nil - } - - // TODO: Should revise type - // reference: https://github.com/line/cosmos-sdk/blob/fd6d941cc429fc2a58154dbace3bbaec4beef445/baseapp/abci.go#L189 - gasWanted := int64(ctx.GasMeter().Limit()) - if gasWanted < 0 { - return fmt.Errorf("gas wanted %d is negative", gasWanted) - } - - consParams := ctx.ConsensusParams() - if consParams == nil || consParams.Block == nil || consParams.Block.MaxGas == -1 { - return nil - } - - maxGas := consParams.Block.MaxGas - if gasWanted > maxGas { - return fmt.Errorf("gas wanted %d is greater than max gas %d", gasWanted, maxGas) - } - - return nil -} diff --git a/x/auth/ante/setup_test.go b/x/auth/ante/setup_test.go index 0cb47694cb..20335965ad 100644 --- a/x/auth/ante/setup_test.go +++ b/x/auth/ante/setup_test.go @@ -1,8 +1,6 @@ package ante_test import ( - abci "github.com/tendermint/tendermint/abci/types" - cryptotypes "github.com/line/lbm-sdk/crypto/types" "github.com/line/lbm-sdk/testutil/testdata" sdk "github.com/line/lbm-sdk/types" @@ -43,21 +41,6 @@ func (suite *AnteTestSuite) TestSetup() { // Context GasMeter Limit should be set after SetUpContextDecorator runs suite.Require().Equal(gasLimit, newCtx.GasMeter().Limit(), "GasMeter not set correctly") - - // Set MaxGas lower than the tx's gasWanted - consensusParams := &abci.ConsensusParams{ - Block: &abci.BlockParams{ - MaxGas: int64(gasLimit) - 1, - }, - } - suite.ctx = suite.ctx.WithConsensusParams(consensusParams) - - // for both of CheckTx and ReCheckTx - for _, isRecheck := range []bool{false, true} { - suite.ctx = suite.ctx.WithIsReCheckTx(isRecheck) - _, err = antehandler(suite.ctx, tx, false) - suite.Require().Error(err) - } } func (suite *AnteTestSuite) TestRecoverPanic() {