11import asyncio
2+ import inspect
23from typing import ( # noqa: F401
34 Any ,
45 Optional ,
2122)
2223
2324from evm .chains .base import (
24- Chain ,
25+ AccountState ,
26+ BaseChain ,
27+ )
28+ from evm .db .backends .base import BaseDB
29+ from evm .db .chain import (
30+ BaseChainDB ,
2531)
2632from evm .db .header import (
2733 BaseHeaderDB ,
3137)
3238from evm .rlp .headers import (
3339 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
3451)
3552
3653from p2p .lightchain import (
4158 from evm .vm .base import BaseVM # noqa: F401
4259
4360
44- class LightDispatchChain (Chain ):
61+ class LightDispatchChain (BaseChain ):
4562 """
4663 Provide the :class:`BaseChain` API, even though only a
4764 :class:`LightPeerChain` is syncing. Store results locally so that not
@@ -56,6 +73,46 @@ def __init__(self, headerdb: BaseHeaderDB, peer_chain: LightPeerChain) -> None:
5673 self ._peer_chain = peer_chain
5774 self ._peer_chain_loop = asyncio .get_event_loop ()
5875
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+
59116 def get_block_header_by_hash (self , block_hash : Hash32 ) -> BlockHeader :
60117 return self ._headerdb .get_block_header_by_hash (block_hash )
61118
@@ -65,6 +122,15 @@ def get_canonical_head(self) -> BlockHeader:
65122 def get_score (self , block_hash : Hash32 ) -> int :
66123 return self ._headerdb .get_score (block_hash )
67124
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+
68134 def get_block_by_hash (self , block_hash : Hash32 ) -> BaseBlock :
69135 header = self ._headerdb .get_block_header_by_hash (block_hash )
70136 return self .get_block_by_header (header )
@@ -97,6 +163,59 @@ def get_canonical_block_by_number(self, block_number: BlockNumber) -> BaseBlock:
97163 def get_canonical_block_hash (self , block_number : int ) -> Hash32 :
98164 return self ._headerdb .get_canonical_block_hash (block_number )
99165
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+
100219 #
101220 # Async utils
102221 #
0 commit comments