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

Commit 9275309

Browse files
committed
Fixes to static call and trie
1 parent 1872a28 commit 9275309

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ethereum/trie.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _encode_node(self, node):
220220
def _decode_to_node(self, encoded):
221221
if encoded == BLANK_NODE:
222222
return BLANK_NODE
223-
# if isinstance(encoded, list):
223+
if isinstance(encoded, list):
224224
return encoded
225225
o = rlp.decode(self.db.get(encoded))
226226
return o

ethereum/vm.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ def vm_execute(ext, msg, code):
533533
mstart, msz = stk.pop(), stk.pop()
534534
topics = [stk.pop() for x in range(depth)]
535535
compustate.gas -= msz * opcodes.GLOGBYTE
536+
if msg.static:
537+
return vm_exception('Cannot LOG inside a static context')
536538
if not mem_extend(mem, compustate, op, mstart, msz):
537539
return vm_exception('OOG EXTENDING MEMORY')
538540
data = bytearray_to_bytestr(mem[mstart: mstart + msz])
@@ -570,8 +572,8 @@ def vm_execute(ext, msg, code):
570572
stk.pop(), stk.pop(), stk.pop(), stk.pop(), stk.pop(), stk.pop()
571573
value = 0
572574
# Static context prohibition
573-
if msg.static and op != 'STATICCALL':
574-
return vm_exception('Cannot %s inside a static context' % op)
575+
if msg.static and value > 0:
576+
return vm_exception('Cannot make a non-zero-value call inside a static context')
575577
# Expand memory
576578
if not mem_extend(mem, compustate, op, meminstart, meminsz) or \
577579
not mem_extend(mem, compustate, op, memoutstart, memoutsz):
@@ -602,15 +604,15 @@ def vm_execute(ext, msg, code):
602604
# Generate the message
603605
if op == 'CALL':
604606
call_msg = Message(msg.to, to, value, submsg_gas, cd,
605-
msg.depth + 1, code_address=to)
607+
msg.depth + 1, code_address=to, static=msg.static)
606608
elif ext.post_homestead_hardfork() and op == 'DELEGATECALL':
607609
call_msg = Message(msg.sender, msg.to, msg.value, submsg_gas, cd,
608-
msg.depth + 1, code_address=to, transfers_value=False)
610+
msg.depth + 1, code_address=to, transfers_value=False, static=msg.static)
609611
elif op == 'DELEGATECALL':
610612
return vm_exception('OPCODE INACTIVE')
611613
elif op == 'CALLCODE':
612614
call_msg = Message(msg.to, msg.to, value, submsg_gas, cd,
613-
msg.depth + 1, code_address=to)
615+
msg.depth + 1, code_address=to, static=msg.static)
614616
elif op == 'STATICCALL':
615617
call_msg = Message(msg.to, to, value, submsg_gas, cd,
616618
msg.depth + 1, code_address=to, static=True)

0 commit comments

Comments
 (0)