diff --git a/eth/vm/logic/flow.py b/eth/vm/logic/flow.py index 47fc7a15ad..d041c109ef 100644 --- a/eth/vm/logic/flow.py +++ b/eth/vm/logic/flow.py @@ -7,6 +7,7 @@ from eth.vm.computation import BaseComputation from eth.vm.opcode_values import ( JUMPDEST, + BEGINSUB, ) @@ -57,3 +58,40 @@ def gas(computation: BaseComputation) -> None: gas_remaining = computation.get_gas_remaining() computation.stack_push_int(gas_remaining) + + +def beginsub(computation: BaseComputation) -> None: + #TODO: raise OOG exception + pass + + +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.rstack.length >= 1023: + #TODO: abort execution + pass + + computation.rstack_push_int(temp + 1) + + +def returnsub(computation: BaseComputation) -> None: + + if computation.rstack.length == 0: + #TODO: abort execution + pass + + computation.code.program_counter = computation.rstack_pop1_int() +