fixes callcode bug

This commit is contained in:
andri lim 2019-02-15 13:59:00 +07:00 committed by zah
parent d7bd55bd21
commit 8f9d1ae748
3 changed files with 10 additions and 7 deletions

View File

@ -127,10 +127,11 @@ proc applyMessage(computation: var BaseComputation, opCode: static[Op]) =
push: 0 push: 0
return return
newBalance = senderBalance - computation.msg.value when opCode == Call:
computation.vmState.mutateStateDb: newBalance = senderBalance - computation.msg.value
db.setBalance(computation.msg.sender, newBalance) computation.vmState.mutateStateDb:
db.addBalance(computation.msg.storageAddress, computation.msg.value) db.setBalance(computation.msg.sender, newBalance)
db.addBalance(computation.msg.storageAddress, computation.msg.value)
trace "Value transferred", trace "Value transferred",
source = computation.msg.sender, source = computation.msg.sender,
@ -151,7 +152,7 @@ proc applyMessage(computation: var BaseComputation, opCode: static[Op]) =
else: else:
# even though the value is zero, the account # even though the value is zero, the account
# should be exist. # should be exist.
when opCode in {Call, CallCode}: when opCode == Call:
computation.vmState.mutateStateDb: computation.vmState.mutateStateDb:
db.addBalance(computation.msg.storageAddress, computation.msg.value) db.addBalance(computation.msg.storageAddress, computation.msg.value)

View File

@ -71,6 +71,7 @@ type
c_currentMemSize*: Natural c_currentMemSize*: Natural
c_memOffset*: Natural c_memOffset*: Natural
c_memLength*: Natural c_memLength*: Natural
c_opCode*: Op
else: else:
discard discard
@ -293,7 +294,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
) )
# Cnew_account # Cnew_account
if gasParams.c_isNewAccount: if gasParams.c_isNewAccount and gasParams.c_opCode == Call:
if fork < FkSpurious: if fork < FkSpurious:
# Pre-EIP161 all account creation calls consumed 25000 gas. # Pre-EIP161 all account creation calls consumed 25000 gas.
result.gasCost += static(FeeSchedule[GasNewAccount]) result.gasCost += static(FeeSchedule[GasNewAccount])

View File

@ -708,7 +708,8 @@ template genCall(callName: untyped, opCode: Op): untyped =
c_contractGas: gas.truncate(GasInt), c_contractGas: gas.truncate(GasInt),
c_currentMemSize: computation.memory.len, c_currentMemSize: computation.memory.len,
c_memOffset: memOffset, c_memOffset: memOffset,
c_memLength: memLength c_memLength: memLength,
c_opCode: opCode
)) ))
trace "Call (" & callName.astToStr & ")", childGasLimit, childGasFee trace "Call (" & callName.astToStr & ")", childGasLimit, childGasFee