diff --git a/libs/cosmos-sdk/baseapp/baseapp.go b/libs/cosmos-sdk/baseapp/baseapp.go index dcd3952151..4f03beec32 100644 --- a/libs/cosmos-sdk/baseapp/baseapp.go +++ b/libs/cosmos-sdk/baseapp/baseapp.go @@ -48,6 +48,9 @@ const ( // LatestSimulateTxHeight is the height to simulate tx based on the state of latest block height // only for runTxModeSimulate LatestSimulateTxHeight = 0 + + // SimulationGasLimit gas limit of Simulation, limit only stdTx, especially wasm stdTx + SimulationGasLimit = 50000000 ) var ( diff --git a/libs/cosmos-sdk/x/auth/ante/setup.go b/libs/cosmos-sdk/x/auth/ante/setup.go index 92c79d3c0a..6b9c266dda 100644 --- a/libs/cosmos-sdk/x/auth/ante/setup.go +++ b/libs/cosmos-sdk/x/auth/ante/setup.go @@ -2,6 +2,7 @@ package ante import ( "fmt" + "github.com/okex/exchain/libs/cosmos-sdk/baseapp" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors" @@ -22,7 +23,12 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate // all transactions must implement GasTx gasTx := tx - SetGasMeter(simulate, &ctx, gasTx.GetGas()) + if simulate { + ctx.SetGasMeter(sdk.NewGasMeter(baseapp.SimulationGasLimit)) + } else { + SetGasMeter(simulate, &ctx, gasTx.GetGas()) + } + newCtx = ctx // Decorator will catch an OutOfGasPanic caused in the next antehandler diff --git a/x/wasm/proxy/context.go b/x/wasm/proxy/context.go index c83ee941b3..5c740a9c17 100644 --- a/x/wasm/proxy/context.go +++ b/x/wasm/proxy/context.go @@ -1,6 +1,7 @@ package proxy import ( + "github.com/okex/exchain/libs/cosmos-sdk/baseapp" "github.com/okex/exchain/libs/cosmos-sdk/store/types" "sync" "time" @@ -17,10 +18,6 @@ import ( evmwatcher "github.com/okex/exchain/x/evm/watcher" ) -const ( - simulationGasLimit = 3000000 -) - var clientCtx clientcontext.CLIContext func SetCliContext(ctx clientcontext.CLIContext) { @@ -33,7 +30,7 @@ func MakeContext(storeKey sdk.StoreKey) sdk.Context { cms := getCommitMultiStore() ctx := sdk.NewContext(cms, header, true, tmlog.NewNopLogger()) - ctx.SetGasMeter(sdk.NewGasMeter(simulationGasLimit)) + ctx.SetGasMeter(sdk.NewGasMeter(baseapp.SimulationGasLimit)) return ctx }