computation.nim cleanup

This commit is contained in:
andri lim 2019-02-28 10:30:16 +07:00 committed by zah
parent 4cc318d948
commit fc613b33df
2 changed files with 1 additions and 21 deletions

View File

@ -11,7 +11,6 @@ const
ZERO_ADDRESS* = default(EthAddress)
CREATE_CONTRACT_ADDRESS* = ZERO_ADDRESS
ZERO_HASH32* = Hash256()
STACK_DEPTH_LIMIT* = 1024
GAS_LIMIT_EMA_DENOMINATOR* = 1_024
GAS_LIMIT_ADJUSTMENT_FACTOR* = 1_024

View File

@ -110,7 +110,7 @@ proc dispose*(snapshot: var ComputationSnapshot) {.inline.} =
snapshot.snapshot.dispose()
proc applyMessageAux(computation: var BaseComputation, opCode: static[Op]) =
if computation.msg.depth > STACK_DEPTH_LIMIT:
if computation.msg.depth >= MaxCallDepth:
raise newException(StackDepthError, "Stack depth limit reached")
if computation.msg.value != 0:
@ -124,25 +124,6 @@ proc applyMessageAux(computation: var BaseComputation, opCode: static[Op]) =
&"Insufficient funds: {senderBalance} < {computation.msg.value}"
)
let
insufficientFunds = senderBalance < computation.msg.value
stackTooDeep = computation.msg.depth >= MaxCallDepth
if insufficientFunds or stackTooDeep:
computation.returnData = @[]
var errMessage: string
if insufficientFunds:
errMessage = &"Insufficient Funds: have: {$senderBalance} need: {$computation.msg.value}"
elif stackTooDeep:
errMessage = "Stack Limit Reached"
else:
raise newException(VMError, "Invariant: Unreachable code path")
debug "Computation failure", msg = errMessage
computation.gasMeter.returnGas(computation.msg.gas)
push: 0
return
newBalance = senderBalance - computation.msg.value
computation.vmState.mutateStateDb:
db.setBalance(computation.msg.sender, newBalance)