Merge pull request #1490 from filecoin-project/fix/charge-gas
Fix charge gas in case of overcharge
This commit is contained in:
commit
7ef08bfbdf
@ -426,10 +426,11 @@ func (rt *Runtime) ChargeGas(toUse int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) chargeGasSafe(toUse int64) aerrors.ActorError {
|
func (rt *Runtime) chargeGasSafe(toUse int64) aerrors.ActorError {
|
||||||
rt.gasUsed += toUse
|
if rt.gasUsed+toUse > rt.gasAvailable {
|
||||||
if rt.gasUsed > rt.gasAvailable {
|
rt.gasUsed = rt.gasAvailable
|
||||||
return aerrors.Newf(uint8(exitcode.SysErrOutOfGas), "not enough gas: used=%d, available=%d", 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user