Merge branch 'jangko-fix_tangerine_whistle_bugs'

This commit is contained in:
Ștefan Talpalaru 2019-04-15 14:03:46 +02:00
commit 94f933dddb
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
8 changed files with 1062 additions and 30 deletions

View File

@ -406,7 +406,7 @@ OK: 23/30 Fail: 0/30 Skip: 7/30
+ CallLoseGasOOG.json OK
+ CallRecursiveBombPreCall.json OK
+ CallcodeLoseGasOOG.json OK
Delegatecall1024.json Skip
+ Delegatecall1024.json OK
+ Delegatecall1024OOG.json OK
+ callOutput1.json OK
+ callOutput2.json OK
@ -435,7 +435,7 @@ OK: 23/30 Fail: 0/30 Skip: 7/30
+ delegatecodeDynamicCode.json OK
+ delegatecodeDynamicCode2SelfCall.json OK
```
OK: 33/34 Fail: 0/34 Skip: 1/34
OK: 34/34 Fail: 0/34 Skip: 0/34
## stEIP150Specific
```diff
+ CallAndCallcodeConsumeMoreGasThenTransactionHas.json OK
@ -2017,8 +2017,8 @@ OK: 1/284 Fail: 0/284 Skip: 283/284
```diff
+ ABAcalls0.json OK
+ ABAcalls1.json OK
ABAcalls2.json Skip
ABAcalls3.json Skip
+ ABAcalls2.json OK
+ ABAcalls3.json OK
+ ABAcallsSuicide0.json OK
+ ABAcallsSuicide1.json OK
+ Call10.json OK
@ -2083,7 +2083,7 @@ OK: 1/284 Fail: 0/284 Skip: 283/284
+ suicideSendEtherToMe.json OK
+ testRandomTest.json OK
```
OK: 61/67 Fail: 0/67 Skip: 6/67
OK: 63/67 Fail: 0/67 Skip: 4/67
## stTransactionTest
```diff
+ ContractStoreClearsOOG.json OK
@ -2520,4 +2520,4 @@ OK: 5/133 Fail: 0/133 Skip: 128/133
OK: 0/130 Fail: 0/130 Skip: 130/130
---TOTAL---
OK: 1497/2334 Fail: 0/2334 Skip: 837/2334
OK: 1500/2334 Fail: 0/2334 Skip: 834/2334

View File

@ -19,6 +19,7 @@ PersistBlockTests
+ block226522.json OK
+ block231501.json OK
+ block243826.json OK
+ block2463413.json OK
+ block248032.json OK
+ block299804.json OK
+ block420301.json OK
@ -43,7 +44,7 @@ PersistBlockTests
+ block97.json OK
+ block98.json OK
```
OK: 40/40 Fail: 0/40 Skip: 0/40
OK: 41/41 Fail: 0/41 Skip: 0/41
---TOTAL---
OK: 40/40 Fail: 0/40 Skip: 0/40
OK: 41/41 Fail: 0/41 Skip: 0/41

View File

@ -154,10 +154,6 @@ proc writeContract*(computation: BaseComputation, fork: Fork): bool =
result = false
proc transferBalance(computation: BaseComputation, opCode: static[Op]) =
if computation.msg.depth > MaxCallDepth:
computation.setError(&"Stack depth limit reached depth={computation.msg.depth}")
return
let senderBalance = computation.vmState.readOnlyStateDb().
getBalance(computation.msg.sender)
@ -193,6 +189,11 @@ proc postExecuteVM(computation: BaseComputation) =
proc executeOpcodes*(computation: BaseComputation) {.gcsafe.}
proc applyMessage*(computation: BaseComputation, opCode: static[Op]) =
if computation.msg.depth > MaxCallDepth:
computation.setError(&"Stack depth limit reached depth={computation.msg.depth}")
computation.nextProc()
return
computation.snapshot()
defer:
computation.dispose()

View File

@ -8,7 +8,7 @@
import
math, eth/common/eth_types,
./utils/[macros_gen_opcodes, utils_numeric],
./opcode_values, ./vm_forks
./opcode_values, ./vm_forks, ../../errors
# Gas Fee Schedule
# Yellow Paper Appendix G - https://ethereum.github.io/yellowpaper/paper.pdf
@ -67,7 +67,7 @@ type
of Call, CallCode, DelegateCall, StaticCall:
c_isNewAccount*: bool
c_gasBalance*: GasInt
c_contractGas*: Gasint
c_contractGas*: Uint256
c_currentMemSize*: Natural
c_memOffset*: Natural
c_memLength*: Natural
@ -325,16 +325,16 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
# Cgascap
when fork >= FkTangerine:
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md
result.gasRefund =
if gasParams.c_gasBalance >= result.gasCost:
min(
`prefix all_but_one_64th`(gasParams.c_gasBalance - result.gasCost),
gasParams.c_contractGas
)
else:
gasParams.c_contractGas
let gas = `prefix all_but_one_64th`(gasParams.c_gasBalance - result.gasCost)
if gasParams.c_contractGas > high(GasInt).u256 or
gas < gasParams.c_contractGas.truncate(GasInt):
result.gasRefund = gas
else:
result.gasRefund = gasParams.c_contractGas.truncate(GasInt)
else:
result.gasRefund += gasParams.c_contractGas
if gasParams.c_contractGas > high(GasInt).u256:
raise newException(TypeError, "GasInt Overflow (" & $gasParams.kind & ") " & $gasParams.c_contractGas)
result.gasRefund = gasParams.c_contractGas.truncate(GasInt)
result.gasCost += result.gasRefund

View File

@ -710,15 +710,12 @@ template genCall(callName: untyped, opCode: Op): untyped =
else:
(memOutPos, memOutLen)
if gas > high(GasInt).u256:
raise newException(TypeError, "GasInt Overflow (" & callNameStr & ")")
let (childGasFee, childGasLimit) = computation.gasCosts[opCode].c_handler(
value,
GasParams(kind: opCode,
c_isNewAccount: isNewAccount,
c_gasBalance: computation.gasMeter.gasRemaining,
c_contractGas: gas.truncate(GasInt),
c_contractGas: gas,
c_currentMemSize: computation.memory.len,
c_memOffset: memOffset,
c_memLength: memLength

File diff suppressed because it is too large Load Diff

View File

@ -94,6 +94,11 @@ proc main() =
chainDB.dumpTest(1_920_000) # the DAO fork
chainDB.dumpTest(1_927_662) # fork comparison bug in postExecuteVM
# too big and too slow, we can skip it
# because it already covered by GST
#chainDB.dumpTest(2_283_416) # first DDOS spam attack block
chainDB.dumpTest(2_463_413) # tangerine call* gas cost bug
when isMainModule:
var message: string

View File

@ -17,9 +17,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"randomStatetest85.json", # CALL* memoffset
# Tangerine failed GST
"Delegatecall1024.json",
"ABAcalls2.json",
"ABAcalls3.json",
"doubleSelfdestructTest.json",
"doubleSelfdestructTest2.json",