Fix EVM out of gas handling (#133)
This commit is contained in:
parent
69e0873dd9
commit
c130105b86
@ -74,7 +74,9 @@ func handleETHTxMsg(ctx sdk.Context, keeper Keeper, msg types.EthereumTxMsg) sdk
|
|||||||
keeper.txCount.increment()
|
keeper.txCount.increment()
|
||||||
|
|
||||||
bloom, res := st.TransitionCSDB(ctx)
|
bloom, res := st.TransitionCSDB(ctx)
|
||||||
keeper.bloom.Or(keeper.bloom, bloom)
|
if res.IsOK() {
|
||||||
|
keeper.bloom.Or(keeper.bloom, bloom)
|
||||||
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result)
|
|||||||
return nil, res
|
return nil, res
|
||||||
}
|
}
|
||||||
|
|
||||||
cost, err := core.IntrinsicGas(st.Payload, st.Recipient == nil, true)
|
cost, err := core.IntrinsicGas(st.Payload, contractCreation, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, sdk.ErrOutOfGas("invalid intrinsic gas for transaction").Result()
|
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
|
// handle errors
|
||||||
if vmerr != nil {
|
if vmerr != nil {
|
||||||
res := emint.ErrVMExecution(vmerr.Error()).Result()
|
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
|
res.Data = returnData
|
||||||
|
// Consume gas before returning
|
||||||
|
ctx.GasMeter().ConsumeGas(gasLimit-leftOverGas, "EVM execution consumption")
|
||||||
return nil, res
|
return nil, res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user