mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-24 01:38:33 +00:00
Call now gets and checks balance against funds, also now fetches code
This commit is contained in:
parent
7ba90fda54
commit
b4fd38e062
@ -695,20 +695,20 @@ template genCall(callName: untyped): untyped =
|
|||||||
computation.memory.extend(memInPos, memInLen)
|
computation.memory.extend(memInPos, memInLen)
|
||||||
computation.memory.extend(memOutPos, memOutLen)
|
computation.memory.extend(memOutPos, memOutLen)
|
||||||
|
|
||||||
let callData = computation.memory.read(memInPos, memInLen)
|
let
|
||||||
|
callData = computation.memory.read(memInPos, memInLen)
|
||||||
##### getBalance type error: expression 'db' is of type: proc (vmState: untyped, readOnly: untyped, handler: untyped): untyped{.noSideEffect, gcsafe, locks: <unknown>.}
|
senderBalance = computation.vmState.readOnlyStateDb.getBalance(computation.msg.storageAddress)
|
||||||
# computation.vmState.db(readOnly = true):
|
# TODO check gas balance rollover
|
||||||
# let senderBalance = db.getBalance(computation.msg.storageAddress) # TODO check gas balance rollover
|
# TODO: shouldTransferValue is not set up, should be:
|
||||||
|
# call, callCode: True
|
||||||
let insufficientFunds = false # shouldTransferValue and senderBalance < value
|
# callDelegate, callStatic: False
|
||||||
let stackTooDeep = computation.msg.depth >= MaxCallDepth
|
insufficientFunds = senderBalance < value # TODO: and shouldTransferValue
|
||||||
|
stackTooDeep = computation.msg.depth >= MaxCallDepth
|
||||||
|
|
||||||
if insufficientFunds or stackTooDeep:
|
if insufficientFunds or stackTooDeep:
|
||||||
computation.returnData = @[]
|
computation.returnData = @[]
|
||||||
var errMessage: string
|
var errMessage: string
|
||||||
if insufficientFunds:
|
if insufficientFunds:
|
||||||
let senderBalance = -1 # TODO workaround
|
|
||||||
# Note: for some reason we can't use strformat here, we get undeclared identifiers
|
# Note: for some reason we can't use strformat here, we get undeclared identifiers
|
||||||
errMessage = &"Insufficient Funds: have: " & $senderBalance & "need: " & $value
|
errMessage = &"Insufficient Funds: have: " & $senderBalance & "need: " & $value
|
||||||
elif stackTooDeep:
|
elif stackTooDeep:
|
||||||
@ -721,11 +721,11 @@ template genCall(callName: untyped): untyped =
|
|||||||
push: 0
|
push: 0
|
||||||
return
|
return
|
||||||
|
|
||||||
##### getCode type error: expression 'db' is of type: proc (vmState: untyped, readOnly: untyped, handler: untyped): untyped{.noSideEffect, gcsafe, locks: <unknown>.}
|
let code =
|
||||||
# computation.vmState.db(readOnly = true):
|
if codeAddress != ZERO_ADDRESS:
|
||||||
# let code = if codeAddress != ZERO_ADDRESS: db.getCode(codeAddress)
|
computation.vmState.readOnlyStateDb.getCode(codeAddress)
|
||||||
# else: db.getCode(to)
|
else:
|
||||||
let code: seq[byte] = @[]
|
computation.vmState.readOnlyStateDb.getCode(to)
|
||||||
|
|
||||||
var childMsg = prepareChildMessage(
|
var childMsg = prepareChildMessage(
|
||||||
computation,
|
computation,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user