Skip to content

Commit 7aaf4b6

Browse files
committed
Make LightDispatchChain inherit from Chain
1 parent 7d5f041 commit 7aaf4b6

File tree

1 file changed

+2
-121
lines changed

1 file changed

+2
-121
lines changed

trinity/chains/light.py

Lines changed: 2 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import inspect
32
from typing import ( # noqa: F401
43
Any,
54
Optional,
@@ -22,12 +21,7 @@
2221
)
2322

2423
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,
3125
)
3226
from evm.db.header import (
3327
BaseHeaderDB,
@@ -37,17 +31,6 @@
3731
)
3832
from evm.rlp.headers import (
3933
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
5134
)
5235

5336
from p2p.lightchain import (
@@ -58,7 +41,7 @@
5841
from evm.vm.base import BaseVM # noqa: F401
5942

6043

61-
class LightDispatchChain(BaseChain):
44+
class LightDispatchChain(Chain):
6245
"""
6346
Provide the :class:`BaseChain` API, even though only a
6447
:class:`LightPeerChain` is syncing. Store results locally so that not
@@ -73,46 +56,6 @@ def __init__(self, headerdb: BaseHeaderDB, peer_chain: LightPeerChain) -> None:
7356
self._peer_chain = peer_chain
7457
self._peer_chain_loop = asyncio.get_event_loop()
7558

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-
11659
def get_block_header_by_hash(self, block_hash: Hash32) -> BlockHeader:
11760
return self._headerdb.get_block_header_by_hash(block_hash)
11861

@@ -122,15 +65,6 @@ def get_canonical_head(self) -> BlockHeader:
12265
def get_score(self, block_hash: Hash32) -> int:
12366
return self._headerdb.get_score(block_hash)
12467

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-
13468
def get_block_by_hash(self, block_hash: Hash32) -> BaseBlock:
13569
header = self._headerdb.get_block_header_by_hash(block_hash)
13670
return self.get_block_by_header(header)
@@ -163,59 +97,6 @@ def get_canonical_block_by_number(self, block_number: BlockNumber) -> BaseBlock:
16397
def get_canonical_block_hash(self, block_number: int) -> Hash32:
16498
return self._headerdb.get_canonical_block_hash(block_number)
16599

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-
219100
#
220101
# Async utils
221102
#

0 commit comments

Comments
 (0)