1111 validate_stack_int ,
1212)
1313
14- from eth . utils import (
14+ from eth_utils import (
1515 big_endian_to_int ,
1616 ValidationError ,
1717)
1818
19- import collections .UserList as rstack
2019"""
2120This module simply implements for the return stack the exact same design used for the data stack.
2221As this stack must simply push_int or pop1_int any time a subroutine is accessed or left, only those two functions are provided.
@@ -28,14 +27,14 @@ class RStack():
2827 VM Return Stack
2928 """
3029
31- __slots__ = ['values' , '_append' , '_pop_int ' , '__len__' ]
30+ __slots__ = ['values' , '_append' , '_pop_typed ' , '__len__' ]
3231
3332 def __init__ (self ) -> None :
34- values : List [int ]
35- self .values = rstack . data
36- self ._append = rstack . data .append
37- self ._pop_typed = rstack . data .pop
38- self .__len__ = rstack . data .__len__
33+ values : List [int ] = []
34+ self .values = values
35+ self ._append = values .append
36+ self ._pop_typed = values .pop
37+ self .__len__ = values .__len__
3938
4039 def push_int (self ) -> int :
4140 if len (self .values ) > 1023 :
@@ -49,18 +48,3 @@ def push_int(self) -> int:
4948 def pop1_int (self ) -> int :
5049 #
5150 # Note: This function is optimized for speed over readability.
52- #
53- if not self .values :
54- raise InsufficientStack ("Wanted 1 stack item as int, had none" )
55- else :
56- item_type , popped = self ._pop_typed ()
57- if item_type is int :
58- return popped # type: ignore
59- elif item_type is bytes :
60- return big_endian_to_int (popped ) # type: ignore
61- else :
62- raise ValidationError (
63- "Stack must always be bytes or int, "
64- f"got { item_type !r} type, val { value !r} "
65- )
66-
0 commit comments