11
11
validate_stack_int ,
12
12
)
13
13
14
- from eth . utils import (
14
+ from eth_utils import (
15
15
big_endian_to_int ,
16
16
ValidationError ,
17
17
)
18
18
19
- import collections .UserList as rstack
20
19
"""
21
20
This module simply implements for the return stack the exact same design used for the data stack.
22
21
As 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():
28
27
VM Return Stack
29
28
"""
30
29
31
- __slots__ = ['values' , '_append' , '_pop_int ' , '__len__' ]
30
+ __slots__ = ['values' , '_append' , '_pop_typed ' , '__len__' ]
32
31
33
32
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__
39
38
40
39
def push_int (self ) -> int :
41
40
if len (self .values ) > 1023 :
@@ -49,18 +48,3 @@ def push_int(self) -> int:
49
48
def pop1_int (self ) -> int :
50
49
#
51
50
# 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