1
1
import asyncio
2
- import inspect
3
2
from typing import ( # noqa: F401
4
3
Any ,
5
4
Optional ,
22
21
)
23
22
24
23
from evm .chains .base import (
25
- AccountState ,
26
- BaseChain ,
27
- )
28
- from evm .db .backends .base import BaseDB
29
- from evm .db .chain import (
30
- BaseChainDB ,
24
+ Chain ,
31
25
)
32
26
from evm .db .header import (
33
27
BaseHeaderDB ,
37
31
)
38
32
from evm .rlp .headers import (
39
33
BlockHeader ,
40
- HeaderParams ,
41
- )
42
- from evm .rlp .receipts import (
43
- Receipt
44
- )
45
- from evm .rlp .transactions import (
46
- BaseTransaction ,
47
- BaseUnsignedTransaction ,
48
- )
49
- from evm .vm .computation import (
50
- BaseComputation
51
34
)
52
35
53
36
from p2p .lightchain import (
58
41
from evm .vm .base import BaseVM # noqa: F401
59
42
60
43
61
- class LightDispatchChain (BaseChain ):
44
+ class LightDispatchChain (Chain ):
62
45
"""
63
46
Provide the :class:`BaseChain` API, even though only a
64
47
:class:`LightPeerChain` is syncing. Store results locally so that not
@@ -73,46 +56,6 @@ def __init__(self, headerdb: BaseHeaderDB, peer_chain: LightPeerChain) -> None:
73
56
self ._peer_chain = peer_chain
74
57
self ._peer_chain_loop = asyncio .get_event_loop ()
75
58
76
- #
77
- # Helpers
78
- #
79
- @classmethod
80
- def get_chaindb_class (cls ) -> Type [BaseChainDB ]:
81
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
82
-
83
- #
84
- # Chain API
85
- #
86
- @classmethod
87
- def from_genesis (cls ,
88
- base_db : BaseDB ,
89
- genesis_params : Dict [str , HeaderParams ],
90
- genesis_state : AccountState = None ) -> 'BaseChain' :
91
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
92
-
93
- @classmethod
94
- def from_genesis_header (cls ,
95
- base_db : BaseDB ,
96
- genesis_header : BlockHeader ) -> 'BaseChain' :
97
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
98
-
99
- def get_chain_at_block_parent (self , block : BaseBlock ) -> 'BaseChain' :
100
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
101
-
102
- #
103
- # VM API
104
- #
105
- def get_vm (self , header : BlockHeader = None ) -> 'BaseVM' :
106
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
107
-
108
- #
109
- # Header API
110
- #
111
- def create_header_from_parent (self ,
112
- parent_header : BlockHeader ,
113
- ** header_params : HeaderParams ) -> BlockHeader :
114
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
115
-
116
59
def get_block_header_by_hash (self , block_hash : Hash32 ) -> BlockHeader :
117
60
return self ._headerdb .get_block_header_by_hash (block_hash )
118
61
@@ -122,15 +65,6 @@ def get_canonical_head(self) -> BlockHeader:
122
65
def get_score (self , block_hash : Hash32 ) -> int :
123
66
return self ._headerdb .get_score (block_hash )
124
67
125
- #
126
- # Block API
127
- #
128
- def get_ancestors (self , limit : int , header : BlockHeader = None ) -> Iterator [BaseBlock ]:
129
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
130
-
131
- def get_block (self ) -> BaseBlock :
132
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
133
-
134
68
def get_block_by_hash (self , block_hash : Hash32 ) -> BaseBlock :
135
69
header = self ._headerdb .get_block_header_by_hash (block_hash )
136
70
return self .get_block_by_header (header )
@@ -163,59 +97,6 @@ def get_canonical_block_by_number(self, block_number: BlockNumber) -> BaseBlock:
163
97
def get_canonical_block_hash (self , block_number : int ) -> Hash32 :
164
98
return self ._headerdb .get_canonical_block_hash (block_number )
165
99
166
- def build_block_with_transactions (
167
- self , transactions : Tuple [BaseTransaction , ...], parent_header : BlockHeader ) -> None :
168
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
169
-
170
- #
171
- # Transaction API
172
- #
173
- def create_transaction (self , * args : Any , ** kwargs : Any ) -> BaseTransaction :
174
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
175
-
176
- def create_unsigned_transaction (self ,
177
- * args : Any ,
178
- ** kwargs : Any ) -> BaseUnsignedTransaction :
179
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
180
-
181
- def get_canonical_transaction (self , transaction_hash : Hash32 ) -> BaseTransaction :
182
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
183
-
184
- #
185
- # Execution API
186
- #
187
- def apply_transaction (
188
- self ,
189
- transaction : BaseTransaction ) -> Tuple [BaseBlock , Receipt , BaseComputation ]:
190
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
191
-
192
- def estimate_gas (self , transaction : BaseTransaction , at_header : BlockHeader = None ) -> int :
193
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
194
-
195
- def import_block (self , block : BaseBlock , perform_validation : bool = True ) -> BaseBlock :
196
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
197
-
198
- def mine_block (self , * args : Any , ** kwargs : Any ) -> BaseBlock :
199
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
200
-
201
- #
202
- # Validation API
203
- #
204
- def validate_block (self , block : BaseBlock ) -> None :
205
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
206
-
207
- def validate_gaslimit (self , header : BlockHeader ) -> None :
208
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
209
-
210
- def validate_seal (self , header : BlockHeader ) -> None :
211
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
212
-
213
- def validate_uncles (self , block : BaseBlock ) -> None :
214
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
215
-
216
- def validate_chain (self , chain : Tuple [BlockHeader , ...]) -> None :
217
- raise NotImplementedError ("Chain classes must implement " + inspect .stack ()[0 ][3 ])
218
-
219
100
#
220
101
# Async utils
221
102
#
0 commit comments