|
1 | 1 | from evmjit import EVMJIT
|
2 |
| -from ethereum.utils import sha3_256 |
| 2 | +from ethereum.utils import sha3_256, decode_int |
3 | 3 | from ethereum.vm import CallData, Message
|
4 | 4 |
|
5 | 5 | from pprint import pprint
|
@@ -75,8 +75,16 @@ def update(self, key, arg1, arg2):
|
75 | 75 | self.ext.set_balance(addr, self.ext.get_balance(addr) + xfer)
|
76 | 76 | self.ext.set_balance(self.msg.to, 0)
|
77 | 77 | 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) |
78 | 86 | else:
|
79 |
| - assert False, "Implement ME!" |
| 87 | + assert False, "Unknown EVM-C update key" |
80 | 88 |
|
81 | 89 | def call(self, kind, gas, address, value, input):
|
82 | 90 | if self.msg.depth >= 1024:
|
@@ -130,11 +138,12 @@ def call(self, kind, gas, address, value, input):
|
130 | 138 |
|
131 | 139 |
|
132 | 140 | 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__) |
133 | 144 | # EVMJIT requires secure hash of the code to be used as the code
|
134 | 145 | # identifier.
|
135 | 146 | # TODO: Can we avoid recalculating it?
|
136 |
| - pprint(ext.__dict__) |
137 |
| - pprint(msg.__dict__) |
138 | 147 | code_hash = sha3_256(code)
|
139 | 148 | mode = (EVMJIT.HOMESTEAD if ext.post_homestead_hardfork()
|
140 | 149 | else EVMJIT.FRONTIER)
|
|
0 commit comments