From 90f890bb90f97d8b035bd9533603bf92f392a36d Mon Sep 17 00:00:00 2001 From: Lane Rettig Date: Sun, 17 Jun 2018 20:00:22 -0400 Subject: [PATCH] Begin juno implementation Tie together the software packages (py-evm, juno, pywasm) and test detecting WASM code and passing data and receiving data. One stEWASMtests test (`useGas`) is passing so data is flowing in both directions. --- .gitignore | 1 + evm/vm/computation.py | 32 +++++++++++++++++++------------- setup.py | 1 + 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 5114dae242..545b053f54 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,4 @@ monkeytype.sqlite3 # pyenv .python-version +.idea diff --git a/evm/vm/computation.py b/evm/vm/computation.py index 608a234391..e26534bc5e 100644 --- a/evm/vm/computation.py +++ b/evm/vm/computation.py @@ -3,6 +3,7 @@ abstractmethod ) import itertools +from juno import juno_execute import logging from typing import ( # noqa: F401 Any, @@ -537,20 +538,25 @@ def apply_computation(cls, computation.precompiles[message.code_address](computation) return computation - for opcode in computation.code: - opcode_fn = computation.get_opcode_fn(opcode) + # Hand off execution of WASM code + if computation.code[0:8] == b'\x00asm\x01\x00\x00\x00': + juno_execute(state, message, transaction_context, computation) - computation.logger.trace( - "OPCODE: 0x%x (%s) | pc: %s", - opcode, - opcode_fn.mnemonic, - max(0, computation.code.pc - 1), - ) - - try: - opcode_fn(computation=computation) - except Halt: - break + else: + for opcode in computation.code: + opcode_fn = computation.get_opcode_fn(opcode) + + computation.logger.trace( + "OPCODE: 0x%x (%s) | pc: %s", + opcode, + opcode_fn.mnemonic, + max(0, computation.code.pc - 1), + ) + + try: + opcode_fn(computation=computation) + except Halt: + break return computation # diff --git a/setup.py b/setup.py index 27168a2c66..a491d0d66f 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ "eth-bloom>=1.0.0,<2.0.0", "eth-utils>=1.0.1,<2.0.0", "eth-typing>=1.0.0,<2.0.0", + "juno>=0.1.0", "pyethash>=0.1.27,<1.0.0", "py-ecc>=1.4.2,<2.0.0", "rlp>=1.0.1,<2.0.0",