From 8d5866fe397b0e06461f17faae316c81d23733f5 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 24 Nov 2022 09:07:33 +0000 Subject: [PATCH 1/2] Remove max gas validation --- baseapp/abci.go | 3 +-- x/auth/ante/setup.go | 30 ------------------------------ x/auth/ante/setup_test.go | 17 ----------------- 3 files changed, 1 insertion(+), 49 deletions(-) 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() { From 0c0f3151347300da1b19e9e061edebb0adc60605 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Mon, 13 Feb 2023 11:15:05 +0900 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e75380554f..884332b30e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (cosmovisor) [\#792](https://github.com/line/lbm-sdk/pull/792) Use upstream's cosmovisor * (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 +* (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