Merge pull request #1490 from filecoin-project/fix/charge-gas

Fix charge gas in case of overcharge
This commit is contained in:
Łukasz Magiera 2020-04-01 23:00:28 +02:00 committed by GitHub
commit 7ef08bfbdf

View File

@ -426,10 +426,11 @@ func (rt *Runtime) ChargeGas(toUse int64) {
}
func (rt *Runtime) chargeGasSafe(toUse int64) aerrors.ActorError {
rt.gasUsed += toUse
if rt.gasUsed > rt.gasAvailable {
if rt.gasUsed+toUse > rt.gasAvailable {
rt.gasUsed = rt.gasAvailable
return aerrors.Newf(uint8(exitcode.SysErrOutOfGas), "not enough gas: used=%d, available=%d", rt.gasUsed, rt.gasAvailable)
}
rt.gasUsed += toUse
return nil
}