fix callcode regression

This commit is contained in:
andri lim 2019-02-20 18:02:14 +07:00 committed by zah
parent 85d8155177
commit dcf7699358
4 changed files with 47 additions and 47 deletions

View File

@ -1099,7 +1099,7 @@ OK: 0/16 Fail: 0/16 Skip: 16/16
+ randomStatetest245.json OK
+ randomStatetest246.json OK
+ randomStatetest247.json OK
+ randomStatetest248.json OK
randomStatetest248.json Skip
+ randomStatetest249.json OK
+ randomStatetest25.json OK
+ randomStatetest250.json OK
@ -1284,7 +1284,7 @@ OK: 0/16 Fail: 0/16 Skip: 16/16
+ randomStatetest97.json OK
+ randomStatetest98.json OK
```
OK: 314/327 Fail: 0/327 Skip: 13/327
OK: 313/327 Fail: 0/327 Skip: 14/327
## stRandom2
```diff
+ 201503110226PYTHON_DUP6.json OK
@ -1458,7 +1458,7 @@ OK: 314/327 Fail: 0/327 Skip: 13/327
+ randomStatetest576.json OK
+ randomStatetest577.json OK
+ randomStatetest578.json OK
randomStatetest579.json Skip
+ randomStatetest579.json OK
+ randomStatetest580.json OK
+ randomStatetest581.json OK
+ randomStatetest582.json OK
@ -1515,7 +1515,7 @@ OK: 314/327 Fail: 0/327 Skip: 13/327
randomStatetest646.json Skip
randomStatetest647.json Skip
```
OK: 218/227 Fail: 0/227 Skip: 9/227
OK: 219/227 Fail: 0/227 Skip: 8/227
## stRecursiveCreate
```diff
recursiveCreate.json Skip

View File

@ -123,40 +123,39 @@ proc applyMessageAux(computation: var BaseComputation, opCode: static[Op]) =
raise newException(InsufficientFunds,
&"Insufficient funds: {senderBalance} < {computation.msg.value}"
)
when opCode in {Call, CallCode}:
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")
let
insufficientFunds = senderBalance < computation.msg.value
stackTooDeep = computation.msg.depth >= MaxCallDepth
debug "Computation failure", msg = errMessage
computation.gasMeter.returnGas(computation.msg.gas)
push: 0
return
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")
when opCode == Call:
newBalance = senderBalance - computation.msg.value
computation.vmState.mutateStateDb:
db.setBalance(computation.msg.sender, newBalance)
db.addBalance(computation.msg.storageAddress, computation.msg.value)
debug "Computation failure", msg = errMessage
computation.gasMeter.returnGas(computation.msg.gas)
push: 0
return
trace "Value transferred",
source = computation.msg.sender,
dest = computation.msg.storageAddress,
value = computation.msg.value,
oldSenderBalance = senderBalance,
newSenderBalance = newBalance,
gasPrice = computation.msg.gasPrice,
gas = computation.msg.gas
newBalance = senderBalance - computation.msg.value
computation.vmState.mutateStateDb:
db.setBalance(computation.msg.sender, newBalance)
db.addBalance(computation.msg.storageAddress, computation.msg.value)
trace "Value transferred",
source = computation.msg.sender,
dest = computation.msg.storageAddress,
value = computation.msg.value,
oldSenderBalance = senderBalance,
newSenderBalance = newBalance,
gasPrice = computation.msg.gasPrice,
gas = computation.msg.gas
trace "Apply message",
value = computation.msg.value,
@ -168,20 +167,20 @@ proc applyMessageAux(computation: var BaseComputation, opCode: static[Op]) =
else:
# even though the value is zero, the account
# should be exist.
when opCode == Call:
computation.vmState.mutateStateDb:
db.addBalance(computation.msg.storageAddress, computation.msg.value)
computation.vmState.mutateStateDb:
db.addBalance(computation.msg.storageAddress, computation.msg.value)
proc applyMessage(computation: var BaseComputation, opCode: static[Op]) =
var snapshot = computation.snapshot()
defer: snapshot.dispose()
try:
computation.applyMessageAux(opCode)
except VMError:
snapshot.revert()
debug "applyMessageAux failed", msg = computation.error.info
return
when opCode == Call:
try:
computation.applyMessageAux(opCode)
except VMError:
snapshot.revert()
debug "applyMessageAux failed", msg = computation.error.info
return
if computation.gasMeter.gasRemaining <= 0:
snapshot.commit()

View File

@ -626,7 +626,7 @@ proc callCodeParams(computation: var BaseComputation): (UInt256, UInt256, EthAdd
value,
to,
ZERO_ADDRESS, # sender
ZERO_ADDRESS, # code_address
to, # code_address
memoryInputStartPosition,
memoryInputSize,
memoryOutputStartPosition,
@ -738,7 +738,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
if opCode == CallCode:
childMsg.storageAddress = computation.msg.storageAddress
var childComputation = applyChildComputation(computation, childMsg, opCode)
if childComputation.isError:
@ -755,7 +755,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
computation.gasMeter.returnGas(childComputation.gasMeter.gasRemaining)
if computation.gasMeter.gasRemaining <= 0:
raise newException(OutOfGas, "computation out of gas after contract call")
raise newException(OutOfGas, "computation out of gas after contract call (" & callName.astToStr & ")")
genCall(call, Call)
genCall(callCode, CallCode)

View File

@ -131,11 +131,12 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"randomStatetest307.json",
"randomStatetest368.json",
"randomStatetest85.json",
"randomStatetest579.json",
#"randomStatetest579.json",
"randomStatetest643.json",
"randomStatetest644.json",
"randomStatetest645.json",
"randomStatetest646.json",
"randomStatetest248.json",
"refundSuicide50procentCap.json",
"refund_CallToSuicideNoStorage.json",
"refund_CallToSuicideStorage.json",