Fix EVM out of gas handling (#133)

This commit is contained in:
Austin Abell 2019-10-30 14:39:46 -04:00 committed by GitHub
parent 69e0873dd9
commit c130105b86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -74,7 +74,9 @@ func handleETHTxMsg(ctx sdk.Context, keeper Keeper, msg types.EthereumTxMsg) sdk
keeper.txCount.increment()
bloom, res := st.TransitionCSDB(ctx)
if res.IsOK() {
keeper.bloom.Or(keeper.bloom, bloom)
}
return res
}

View File

@ -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
}