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

Commit b56c0f3

Browse files
committed
rm: no safe_ord in vm
1 parent b3006b2 commit b56c0f3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ethereum/vm.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import time
1111
from ethereum.slogging import get_logger
1212
from rlp.utils import encode_hex, ascii_chr
13-
from ethereum.utils import to_string, safe_ord
13+
from ethereum.utils import to_string
1414

1515
log_log = get_logger('eth.vm.log')
1616
log_vm_exit = get_logger('eth.vm.exit')
@@ -83,16 +83,16 @@ def __init__(self, **kwargs):
8383
# Preprocesses code, and determines which locations are in the middle
8484
# of pushdata and thus invalid
8585
def preprocess_code(code):
86+
assert isinstance(code, str)
8687
i = 0
8788
ops = []
8889
while i < len(code):
89-
o = copy.copy(opcodes.opcodes.get(safe_ord(code[i]), ['INVALID', 0, 0, 0]) +
90-
[safe_ord(code[i]), 0])
90+
o = copy.copy(opcodes.opcodes.get(ord(code[i]), ['INVALID', 0, 0, 0]) + [ord(code[i]), 0])
9191
ops.append(o)
9292
if o[0][:4] == 'PUSH':
9393
for j in range(int(o[0][4:])):
9494
i += 1
95-
byte = safe_ord(code[i]) if i < len(code) else 0
95+
byte = ord(code[i]) if i < len(code) else 0
9696
o[-1] = (o[-1] << 8) + byte
9797
if i < len(code):
9898
ops.append(['INVALID', 0, 0, 0, byte, 0])
@@ -350,13 +350,14 @@ def vm_execute(ext, msg, code):
350350
addr = utils.coerce_addr_to_hex(stk.pop() % 2**160)
351351
start, s2, size = stk.pop(), stk.pop(), stk.pop()
352352
extcode = ext.get_code(addr) or b''
353+
assert isinstance(extcode, str)
353354
if not mem_extend(mem, compustate, op, start, size):
354355
return vm_exception('OOG EXTENDING MEMORY')
355356
if not data_copy(compustate, size):
356357
return vm_exception('OOG COPY DATA')
357358
for i in range(size):
358359
if s2 + i < len(extcode):
359-
mem[start + i] = safe_ord(extcode[s2 + i])
360+
mem[start + i] = ord(extcode[s2 + i])
360361
else:
361362
mem[start + i] = 0
362363
elif opcode < 0x50:
@@ -463,8 +464,8 @@ def vm_execute(ext, msg, code):
463464
return vm_exception('OOG EXTENDING MEMORY')
464465
data = b''.join(map(ascii_chr, mem[mstart: mstart + msz]))
465466
ext.log(msg.to, topics, data)
466-
log_log.trace('LOG', to=msg.to, topics=topics, data=list(map(safe_ord, data)))
467-
# print('LOG', msg.to, topics, list(map(safe_ord, data)))
467+
log_log.trace('LOG', to=msg.to, topics=topics, data=list(map(ord, data)))
468+
# print('LOG', msg.to, topics, list(map(ord, data)))
468469

469470
elif op == 'CREATE':
470471
value, mstart, msz = stk.pop(), stk.pop(), stk.pop()

0 commit comments

Comments
 (0)