Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

EVMJIT support #406

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Fix output and add more logs
  • Loading branch information
chfast committed Sep 8, 2016
commit ab90a4b91e2efbd852b4a881ba4cfb9064468ec9
9 changes: 7 additions & 2 deletions ethereum/jitvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def get_balance(self, addr):
def query(self, key, arg):
print("query(key: {}, arg: {})".format(key, arg))
if key == EVMJIT.SLOAD:
return self.ext.get_storage_data(self.msg.to, arg)
v = self.ext.get_storage_data(self.msg.to, arg)
print("SLOAD({}): {}".format(arg, v))
return v
if key == EVMJIT.ADDRESS:
return self.msg.to
if key == EVMJIT.CALLER:
Expand Down Expand Up @@ -87,6 +89,7 @@ def update(self, key, arg1, arg2):
assert False, "Unknown EVM-C update key"

def call(self, kind, gas, address, value, input):
print("call")
if self.msg.depth >= 1024:
return EVMJIT.FAILURE, b'', 0

Expand Down Expand Up @@ -135,19 +138,21 @@ def call(self, kind, gas, address, value, input):

if value and self.ext.get_balance(self.msg.to) < value:
cost -= msg.gas
print("{}: no gas".format(name))
return EVMJIT.FAILURE, b'', cost

print("{}({}, gas: {}, value: {})".format(name, hexlify(address), gas, value))
result, gas_left, out = self.ext.msg(msg)
cost -= gas_left
assert cost >= 0
res_code = EVMJIT.SUCCESS if result else EVMJIT.FAILURE
out = bytes(out) # The output must be bytes, not list of ints. WTF?
return res_code, out, cost


def vm_execute(ext, msg, code):
# FIXME: This is needed for ext.get_code() to work. WTF??????????
ext._block.commit_state()
# ext._block.commit_state()
# pprint(msg.__dict__)
# EVMJIT requires secure hash of the code to be used as the code
# identifier.
Expand Down