fix MaxCallDepth comparison

This commit is contained in:
andri lim 2019-03-21 23:08:41 +07:00
parent 90924eef47
commit da88d498e3
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 5 additions and 2 deletions

View File

@ -144,7 +144,7 @@ proc writeContract*(computation: var BaseComputation, fork: Fork): bool =
result = false
proc transferBalance(computation: var BaseComputation, opCode: static[Op]): bool =
if computation.msg.depth >= MaxCallDepth:
if computation.msg.depth > MaxCallDepth:
debug "Stack depth limit reached", depth=computation.msg.depth
return false

View File

@ -528,7 +528,10 @@ proc canTransfer(computation: BaseComputation, memPos, memLen: int, value: Uint2
debug "Computation Failure", reason = "Insufficient funds available to transfer", required = computation.msg.value, balance = senderBalance
return false
if computation.msg.depth >= MaxCallDepth:
# unlike the other MaxCallDepth comparison,
# this one has not been entered child computation
# thats why it has `+ 1`
if computation.msg.depth + 1 > MaxCallDepth:
debug "Computation Failure", reason = "Stack too deep", maximumDepth = MaxCallDepth, depth = computation.msg.depth
return false