computation.nim cleanup
This commit is contained in:
parent
4cc318d948
commit
fc613b33df
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue