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

Commit 1611fb9

Browse files
committed
Jit VM: preliminary support for LOG
1 parent cae4aa8 commit 1611fb9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

ethereum/jitvm.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from evmjit import EVMJIT
2-
from ethereum.utils import sha3_256
2+
from ethereum.utils import sha3_256, decode_int
33
from ethereum.vm import CallData, Message
44

55
from pprint import pprint
@@ -75,8 +75,16 @@ def update(self, key, arg1, arg2):
7575
self.ext.set_balance(addr, self.ext.get_balance(addr) + xfer)
7676
self.ext.set_balance(self.msg.to, 0)
7777
self.ext.add_suicide(self.msg.to)
78+
elif key == EVMJIT.LOG:
79+
print("LOG {}".format(map(hexlify, arg2)))
80+
# Make a copy of data because pyethereum expects bytes type
81+
# not buffer protocol.
82+
data = bytes(arg1)
83+
# Convert topics to ints.
84+
topics = [decode_int(t) for t in arg2]
85+
self.ext.log(self.msg.to, topics, data)
7886
else:
79-
assert False, "Implement ME!"
87+
assert False, "Unknown EVM-C update key"
8088

8189
def call(self, kind, gas, address, value, input):
8290
if self.msg.depth >= 1024:
@@ -130,11 +138,12 @@ def call(self, kind, gas, address, value, input):
130138

131139

132140
def vm_execute(ext, msg, code):
141+
# FIXME: This pprint is needed for ext.get_code() to work. WTF??????????
142+
pprint(ext.__dict__)
143+
# pprint(msg.__dict__)
133144
# EVMJIT requires secure hash of the code to be used as the code
134145
# identifier.
135146
# TODO: Can we avoid recalculating it?
136-
pprint(ext.__dict__)
137-
pprint(msg.__dict__)
138147
code_hash = sha3_256(code)
139148
mode = (EVMJIT.HOMESTEAD if ext.post_homestead_hardfork()
140149
else EVMJIT.FRONTIER)

ethereum/processblock.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
from ethereum.utils import safe_ord, normalize_address, mk_contract_address, \
1313
mk_metropolis_contract_address, big_endian_to_int
1414
from ethereum import transactions
15+
from ethereum import jitvm
1516
import ethereum.config as config
1617

1718
sys.setrecursionlimit(100000)
1819

20+
vm_execute = jitvm.vm_execute
21+
1922
from ethereum.slogging import get_logger
2023
log_tx = get_logger('eth.pb.tx')
2124
log_msg = get_logger('eth.pb.msg')
@@ -280,7 +283,7 @@ def _apply_msg(ext, msg, code):
280283
if msg.code_address in specials.specials:
281284
res, gas, dat = specials.specials[msg.code_address](ext, msg)
282285
else:
283-
res, gas, dat = vm.vm_execute(ext, msg, code)
286+
res, gas, dat = vm_execute(ext, msg, code)
284287
# gas = int(gas)
285288
# assert utils.is_numeric(gas)
286289
if trace_msg:

0 commit comments

Comments
 (0)