Skip to content

Commit c0a13b5

Browse files
committed
[WIP] Implement subroutine opcodes
1 parent 48d115f commit c0a13b5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

eth/vm/computation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def rstack_push_int(self) -> Callable[[int], None]:
333333
return self._rstack.push_int
334334

335335
@cached_property
336-
def rstack_pop1_int(self) -> Callable[[int]], None]:
336+
def rstack_pop1_int(self) -> Callable[[int], None]:
337337
return self._rstack.pop1_int
338338

339339
#

eth/vm/rstack.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ def push_int(self) -> int:
4848
def pop1_int(self) -> int:
4949
#
5050
# Note: This function is optimized for speed over readability.
51+
#
52+
if not self.values:
53+
raise InsufficientStack("Wanted 1 stack item as int, had none")
54+
else:
55+
item_type, popped = self._pop_typed()
56+
if item_type is int:
57+
return popped # type: ignore
58+
elif item_type is bytes:
59+
return big_endian_to_int(popped) # type: ignore
60+
else:
61+
raise ValidationError(
62+
"Stack must always be bytes or int, "
63+
f"got {item_type!r} type, val {value!r}"
64+
)

0 commit comments

Comments
 (0)