Dirty fix #46 (test_vm_json segfaults from #45), incidentally fix #32 (#47)

This commit is contained in:
Mamy Ratsimbazafy 2018-06-06 20:40:44 +02:00 committed by GitHub
parent 040c09d5a9
commit 8528f1b704
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 10 deletions

View File

@ -144,7 +144,7 @@ VMTests
+ mulmod2_1.json OK
+ mulmod3.json OK
+ mulmod3_0.json OK
- mulmod4.json Fail
+ mulmod4.json OK
+ mulmoddivByZero.json OK
+ mulmoddivByZero1.json OK
+ mulmoddivByZero2.json OK
@ -198,7 +198,7 @@ VMTests
+ sub3.json OK
+ sub4.json OK
```
OK: 189/195 Fail: 5/195 Skip: 1/195
OK: 190/195 Fail: 4/195 Skip: 1/195
## vmBitwiseLogicOperation
```diff
+ and0.json OK
@ -720,8 +720,8 @@ OK: 0/36 Fail: 0/36 Skip: 36/36
## vmTests
```diff
arith.json Skip
- boolean.json Fail
- mktx.json Fail
- suicide.json Fail
+ boolean.json OK
+ mktx.json OK
+ suicide.json OK
```
OK: 0/4 Fail: 3/4 Skip: 1/4
OK: 3/4 Fail: 0/4 Skip: 1/4

View File

@ -7,7 +7,7 @@
import
strformat, eth_common,
../constants, ../vm_types, ../errors, ../computation, ../opcode, ../opcode_values, ../logging,
../constants, ../vm_types, ../errors, ../computation, ../opcode_values, ../logging,
.. / vm / [stack, memory, gas_meter, message],
.. / utils / [address, bytes],
stint
@ -52,7 +52,7 @@ method callParams*(call: BaseCall, computation): (UInt256, UInt256, EthAddress,
raise newException(NotImplementedError, "Must be implemented subclasses")
method runLogic*(call: BaseCall, computation) =
computation.gasMeter.consumeGas(computation.gasCosts[call.gasCost(computation)], reason = $call.kind) # TODO: Refactoring call gas costs
computation.gasMeter.consumeGas(computation.gasCosts[call.gasCostKind], reason = $call.kind) # TODO: Refactoring call gas costs
let (gas, value, to, sender,
codeAddress,
memoryInputStartPosition, memoryInputSize,
@ -87,7 +87,7 @@ method runLogic*(call: BaseCall, computation) =
else:
raise newException(VMError, "Invariant: Unreachable code path")
call.logger.debug(&"{call.kind} failure: {errMessage}")
computation.logger.debug(&"{call.kind} failure: {errMessage}")
computation.gasMeter.returnGas(childMsgGas)
computation.stack.push(0.u256)
else:

View File

@ -10,10 +10,21 @@ import
constants, logging, errors, opcode_values, computation, vm/stack, stint,
./vm_types
# Super dirty fix for https://github.com/status-im/nimbus/issues/46
# Pending https://github.com/status-im/nimbus/issues/36
# Disentangle opcode logic
from logic.call import runLogic, BaseCall
template run*(opcode: Opcode, computation: var BaseComputation) =
# Hook for performing the actual VM execution
# opcode.consumeGas(computation)
computation.gasMeter.consumeGas(computation.gasCosts[opcode.gasCost(computation)], reason = $opcode.kind) # TODO: further refactoring of gas costs
if opcode.kind == Op.Call: # Super dirty fix for https://github.com/status-im/nimbus/issues/46
runLogic(BaseCall(opcode), computation)
else:
opcode.runLogic(computation)
method logger*(opcode: Opcode): Logger =