Skip to content

Commit 91b5a64

Browse files
committed
[WIP] Implement subroutine opcodes
1 parent 62f6d23 commit 91b5a64

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

eth/vm/logic/flow.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def jumpsub(computation: BaseComputation) -> None:
7272

7373
if sub_loc >= code_range_length:
7474
raise InvalidJumpDestination(
75-
"Error: at pc={}, op=JUMPSUB: invalid jump destination".format(computation.code.program_counter))
75+
"Error: at pc={}, op=JUMPSUB: invalid jump destination".format(
76+
computation.code.program_counter)
77+
)
7678

7779
if computation.code.is_valid_opcode(sub_loc):
7880

@@ -89,6 +91,8 @@ def returnsub(computation: BaseComputation) -> None:
8991
ret_loc = computation.rstack_pop1_int()
9092
except InsufficientStack:
9193
raise InsufficientStack(
92-
"Error: at pc={}, op=RETURNSUB: invalid retsub".format(computation.code.program_counter))
94+
"Error: at pc={}, op=RETURNSUB: invalid retsub".format(
95+
computation.code.program_counter)
96+
)
9397

9498
computation.code.program_counter = ret_loc

eth/vm/rstack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
"""
2020
This module simply implements for the return stack the exact same design used for the data stack.
21-
As this stack must simply push_int or pop1_int any time a subroutine is accessed or left, only those two functions are
22-
provided.
23-
For the same reason, the class RStack doesn't inherit from the abc StackAPI, as it would require to implement all the
24-
abstract methods defined.
21+
As this stack must simply push_int or pop1_int any time a subroutine is accessed or left, only
22+
those two functions are provided.
23+
For the same reason, the class RStack doesn't inherit from the abc StackAPI, as it would require
24+
to implement all the abstract methods defined.
2525
"""
2626

2727

tests/core/opcodes/test_opcodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ def test_jumpsub(vm_class, code, expect_gas_used):
11591159
assert comp.get_gas_used() == expect_gas_used
11601160

11611161

1162-
@pytest.mark.xfail(reason="invalid subroutines")
1162+
@pytest.mark.xfail(reason="invalid subroutines") # noqa: F811
11631163
@pytest.mark.parametrize(
11641164
'vm_class, code',
11651165
(

tests/core/precompiles/test_bls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from py_ecc.optimized_bls12_381.optimized_curve import G1, G2, neg, FQ12
2-
from eth.precompiles.bls import _pairing, _serialize_g2, _serialize_g1
2+
from eth.precompiles.bls import _pairing, _serialize_g2, _serialize_g1 # noqa: F401
3+
34

45
def test_pairing_precompile():
56
# assert pairing(G1, G2) * pairing(neg(G1), G2) == FQ12.one()
@@ -8,3 +9,5 @@ def test_pairing_precompile():
89
serialized_neg_G1 = _serialize_g1(neg(G1))
910
input_data = serialized_G1 + serialized_G2 + serialized_neg_G1 + serialized_G2
1011
assert _pairing(input_data)
12+
13+
# remove "noqa" comment when import starts to be used

0 commit comments

Comments
 (0)