fixes 'collectTouchedAccounts' for Istanbul

This commit is contained in:
andri lim 2019-11-19 16:14:36 +07:00
parent 6b053d8a89
commit 0d743dc468
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 16 additions and 14 deletions

View File

@ -1685,11 +1685,11 @@ OK: 38/38 Fail: 0/38 Skip: 0/38
+ RevertOpcodeMultipleSubCalls.json OK
+ RevertOpcodeReturn.json OK
+ RevertOpcodeWithBigOutputInInit.json OK
RevertPrecompiledTouch.json Skip
RevertPrecompiledTouchExactOOG.json Skip
+ RevertPrecompiledTouch.json OK
+ RevertPrecompiledTouchExactOOG.json OK
+ RevertPrecompiledTouch_nonce.json OK
+ RevertPrecompiledTouch_noncestorage.json OK
RevertPrecompiledTouch_storage.json Skip
+ RevertPrecompiledTouch_storage.json OK
+ RevertPrefound.json OK
+ RevertPrefoundCall.json OK
+ RevertPrefoundCallOOG.json OK
@ -1706,7 +1706,7 @@ OK: 38/38 Fail: 0/38 Skip: 0/38
+ TouchToEmptyAccountRevert2.json OK
+ TouchToEmptyAccountRevert3.json OK
```
OK: 36/45 Fail: 0/45 Skip: 9/45
OK: 39/45 Fail: 0/45 Skip: 6/45
## stSLoadTest
```diff
+ sloadGasCost.json OK
@ -2625,4 +2625,4 @@ OK: 133/133 Fail: 0/133 Skip: 0/133
OK: 130/130 Fail: 0/130 Skip: 0/130
---TOTAL---
OK: 2300/2411 Fail: 0/2411 Skip: 111/2411
OK: 2303/2411 Fail: 0/2411 Skip: 108/2411

View File

@ -282,18 +282,23 @@ proc getGasRemaining*(c: BaseComputation): GasInt =
else:
result = c.gasMeter.gasRemaining
proc collectTouchedAccounts*(c: BaseComputation, output: var HashSet[EthAddress]) =
proc collectTouchedAccounts*(c: BaseComputation, output: var HashSet[EthAddress], ancestorHadError: bool = false) =
## Collect all of the accounts that *may* need to be deleted based on EIP161:
## https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md
## also see: https://github.com/ethereum/EIPs/issues/716
proc cmpThree(address: EthAddress): bool =
# looking for RIPEMD160
for i in 0..18:
if address[i] != 0: return
result = address[19] == byte(3)
let isIstanbul = c.getFork >= FkIstanbul
let condition = if isIstanbul: c.isError or ancestorHadError
else: c.isError and c.isOriginComputation
for _, beneficiary in c.accountsToDelete:
if c.isError and c.isOriginComputation:
if condition:
# Special case to account for geth+parity bug
# https://github.com/ethereum/EIPs/issues/716
if beneficiary.cmpThree:
@ -303,7 +308,7 @@ proc collectTouchedAccounts*(c: BaseComputation, output: var HashSet[EthAddress]
output.incl beneficiary
if not c.msg.isCreate:
if c.isError and c.isOriginComputation:
if condition:
# Special case to account for geth+parity bug
# https://github.com/ethereum/EIPs/issues/716
if cmpThree(c.msg.storageAddress):
@ -311,9 +316,10 @@ proc collectTouchedAccounts*(c: BaseComputation, output: var HashSet[EthAddress]
else:
output.incl c.msg.storageAddress
if not c.isError:
if c.isSuccess or isIstanbul:
# recurse into nested computations (even errored ones, since looking for RIPEMD160)
for child in c.children:
child.collectTouchedAccounts(output)
child.collectTouchedAccounts(output, c.isError or ancestorHadError)
proc tracingEnabled*(c: BaseComputation): bool =
c.vmState.tracingEnabled

View File

@ -28,9 +28,5 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"RevertInCreateInInit.json",
"RevertInCreateInInitCreate2.json",
"InitCollision.json",
"RevertPrecompiledTouch.json",
"RevertPrecompiledTouchExactOOG.json",
"RevertPrecompiledTouch_storage.json",
]
result = name in allowedFailingGeneralStateTests