diff --git a/x/evm/handler.go b/x/evm/handler.go index 4b121203..f521324c 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -74,7 +74,9 @@ func handleETHTxMsg(ctx sdk.Context, keeper Keeper, msg types.EthereumTxMsg) sdk keeper.txCount.increment() bloom, res := st.TransitionCSDB(ctx) - keeper.bloom.Or(keeper.bloom, bloom) + if res.IsOK() { + keeper.bloom.Or(keeper.bloom, bloom) + } return res } diff --git a/x/evm/types/state_transition.go b/x/evm/types/state_transition.go index 700677b3..0a4b22ea 100644 --- a/x/evm/types/state_transition.go +++ b/x/evm/types/state_transition.go @@ -36,7 +36,7 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result) return nil, res } - cost, err := core.IntrinsicGas(st.Payload, st.Recipient == nil, true) + cost, err := core.IntrinsicGas(st.Payload, contractCreation, true) if err != nil { return nil, sdk.ErrOutOfGas("invalid intrinsic gas for transaction").Result() } @@ -105,7 +105,12 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result) // handle errors if vmerr != nil { res := emint.ErrVMExecution(vmerr.Error()).Result() + if vmerr == vm.ErrOutOfGas || vmerr == vm.ErrCodeStoreOutOfGas { + res = sdk.ErrOutOfGas("EVM execution went out of gas").Result() + } res.Data = returnData + // Consume gas before returning + ctx.GasMeter().ConsumeGas(gasLimit-leftOverGas, "EVM execution consumption") return nil, res }