File tree 1 file changed +14
-17
lines changed
1 file changed +14
-17
lines changed Original file line number Diff line number Diff line change 1
1
from eth .exceptions import (
2
2
InvalidJumpDestination ,
3
3
InvalidInstruction ,
4
+ OutOfGas ,
4
5
Halt ,
5
6
)
6
7
@@ -61,33 +62,29 @@ def gas(computation: BaseComputation) -> None:
61
62
62
63
63
64
def beginsub (computation : BaseComputation ) -> None :
64
- #TODO: raise OOG exception
65
- pass
65
+ raise OutOfGas
66
66
67
67
68
68
def jumpsub (computation : BaseComputation ) -> None :
69
69
sub_loc = computation .stack_pop1_int ()
70
70
71
- temp = computation .code .program_counter
72
- computation .code .program_counter = sub_loc
73
-
74
- next_opcode = computation .code .peek ()
75
-
76
- if next_opcode != BEGINSUB :
77
- #TODO: abort execution
78
- pass
79
-
80
- else :
81
- computation .code .program_counter += 1
71
+ if computation .code .is_valid_opcode (sub_loc ):
82
72
83
- computation .rstack_push_int (temp + 1 )
73
+ sub_op = computation .code (sub_loc )
74
+
75
+ if sub_op == BEGINSUB :
76
+ temp = computation .code .program_counter
77
+ computation .code .program_counter = sub_loc + 1
78
+ computation .rstack_push_int (temp + 1 )
84
79
85
80
86
81
def returnsub (computation : BaseComputation ) -> None :
87
82
88
- if computation .rstack .length == 0 :
89
- #TODO: abort execution
83
+ try :
84
+ ret_loc = computation .rstack_pop1_int ()
85
+ except InsufficientStack :
90
86
pass
87
+
91
88
92
- computation .code .program_counter = computation . rstack_pop1_int ()
89
+ computation .code .program_counter = ret_loc
93
90
You can’t perform that action at this time.
0 commit comments