diff --git a/eth/vm/logic/flow.py b/eth/vm/logic/flow.py index 5fcd633e35..fcf7527b26 100644 --- a/eth/vm/logic/flow.py +++ b/eth/vm/logic/flow.py @@ -1,6 +1,7 @@ from eth.exceptions import ( InvalidJumpDestination, InvalidInstruction, + OutOfGas, Halt, ) @@ -61,33 +62,29 @@ def gas(computation: BaseComputation) -> None: def beginsub(computation: BaseComputation) -> None: - #TODO: raise OOG exception - pass + raise OutOfGas def jumpsub(computation: BaseComputation) -> None: sub_loc = computation.stack_pop1_int() - temp = computation.code.program_counter - computation.code.program_counter = sub_loc - - next_opcode = computation.code.peek() - - if next_opcode != BEGINSUB: - #TODO: abort execution - pass - - else: - computation.code.program_counter += 1 + if computation.code.is_valid_opcode(sub_loc): - computation.rstack_push_int(temp + 1) + sub_op = computation.code(sub_loc) + + if sub_op == BEGINSUB: + temp = computation.code.program_counter + computation.code.program_counter = sub_loc + 1 + computation.rstack_push_int(temp + 1) def returnsub(computation: BaseComputation) -> None: - if computation.rstack.length == 0: - #TODO: abort execution + try: + ret_loc = computation.rstack_pop1_int() + except InsufficientStack: pass + - computation.code.program_counter = computation.rstack_pop1_int() + computation.code.program_counter = ret_loc