Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions VMTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions nimbus/logic/call.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 12 additions & 1 deletion nimbus/opcode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ 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
opcode.runLogic(computation)

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 =
logging.getLogger(&"vm.opcode.{opcode.kind}")
Expand Down