Skip to content

Commit a37f26c

Browse files
Merge pull request ethereum#616 from ChihChengLiang/clean-up-chain-db
Clean up chain db
2 parents 15958c3 + 34fd07a commit a37f26c

File tree

3 files changed

+6
-34
lines changed

3 files changed

+6
-34
lines changed

eth2/beacon/db/chain.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ def get_canonical_block_by_slot(self,
9292
block_class: Type[BaseBeaconBlock]) -> BaseBeaconBlock:
9393
pass
9494

95-
@abstractmethod
96-
def get_canonical_block_root_by_slot(self, slot: int) -> Hash32:
97-
pass
98-
9995
@abstractmethod
10096
def get_canonical_head(self, block_class: Type[BaseBeaconBlock]) -> BaseBeaconBlock:
10197
pass
@@ -263,26 +259,9 @@ def _get_canonical_block_by_slot(
263259
db: BaseDB,
264260
slot: int,
265261
block_class: Type[BaseBeaconBlock]) -> BaseBeaconBlock:
266-
canonical_block_root = cls._get_canonical_block_root_by_slot(db, slot)
262+
canonical_block_root = cls._get_canonical_block_root(db, slot)
267263
return cls._get_block_by_root(db, canonical_block_root, block_class)
268264

269-
def get_canonical_block_root_by_slot(self, slot: int) -> Hash32:
270-
"""
271-
Return the block root with the given slot in the canonical chain.
272-
273-
Raise BlockNotFound if there's no block with the given slot in the
274-
canonical chain.
275-
"""
276-
return self._get_canonical_block_root_by_slot(self.db, slot)
277-
278-
@classmethod
279-
def _get_canonical_block_root_by_slot(
280-
cls,
281-
db: BaseDB,
282-
slot: int) -> Hash32:
283-
validate_slot(slot)
284-
return cls._get_canonical_block_root(db, slot)
285-
286265
def get_canonical_head(self, block_class: Type[BaseBeaconBlock]) -> BaseBeaconBlock:
287266
"""
288267
Return the current block at the head of the chain.
@@ -323,8 +302,8 @@ def _get_finalized_head(cls,
323302
finalized_head_root = cls._get_finalized_head_root(db)
324303
return cls._get_block_by_root(db, Hash32(finalized_head_root), block_class)
325304

326-
@classmethod
327-
def _get_finalized_head_root(cls, db: BaseDB) -> Hash32:
305+
@staticmethod
306+
def _get_finalized_head_root(db: BaseDB) -> Hash32:
328307
try:
329308
finalized_head_root = db[SchemaV1.make_finalized_head_root_lookup_key()]
330309
except KeyError:
@@ -344,8 +323,8 @@ def _get_justified_head(cls,
344323
justified_head_root = cls._get_justified_head_root(db)
345324
return cls._get_block_by_root(db, Hash32(justified_head_root), block_class)
346325

347-
@classmethod
348-
def _get_justified_head_root(cls, db: BaseDB) -> Hash32:
326+
@staticmethod
327+
def _get_justified_head_root(db: BaseDB) -> Hash32:
349328
try:
350329
justified_head_root = db[SchemaV1.make_justified_head_root_lookup_key()]
351330
except KeyError:
@@ -426,9 +405,8 @@ def persist_block_chain(
426405
with self.db.atomic_batch() as db:
427406
return self._persist_block_chain(db, blocks, block_class)
428407

429-
@classmethod
408+
@staticmethod
430409
def _set_block_scores_to_db(
431-
cls,
432410
db: BaseDB,
433411
block: BaseBeaconBlock
434412
) -> int:

tests/core/p2p-proto/bcc/helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class FakeAsyncBeaconChainDB(BaseAsyncBeaconChainDB, BeaconChainDB):
4646
coro_persist_block = async_passthrough('persist_block')
4747
coro_get_canonical_block_root = async_passthrough('get_canonical_block_root')
4848
coro_get_canonical_block_by_slot = async_passthrough('get_canonical_block_by_slot')
49-
coro_get_canonical_block_root_by_slot = async_passthrough('get_canonical_block_root_by_slot')
5049
coro_get_canonical_head = async_passthrough('get_canonical_head')
5150
coro_get_canonical_head_root = async_passthrough('get_canonical_head_root')
5251
coro_get_finalized_head = async_passthrough('get_finalized_head')

trinity/db/beacon/chain.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ async def coro_get_canonical_block_by_slot(
5555
block_class: Type[BaseBeaconBlock]) -> BaseBeaconBlock:
5656
pass
5757

58-
@abstractmethod
59-
async def coro_get_canonical_block_root_by_slot(self, slot: int) -> Hash32:
60-
pass
61-
6258
@abstractmethod
6359
async def coro_get_canonical_head(self, block_class: Type[BaseBeaconBlock]) -> BaseBeaconBlock:
6460
pass
@@ -126,7 +122,6 @@ class AsyncBeaconChainDBPreProxy(BaseAsyncBeaconChainDB):
126122
coro_persist_block = async_method('persist_block')
127123
coro_get_canonical_block_root = async_method('get_canonical_block_root')
128124
coro_get_canonical_block_by_slot = async_method('get_canonical_block_by_slot')
129-
coro_get_canonical_block_root_by_slot = async_method('get_canonical_block_root_by_slot')
130125
coro_get_canonical_head = async_method('get_canonical_head')
131126
coro_get_canonical_head_root = async_method('get_canonical_head_root')
132127
coro_get_finalized_head = async_method('get_finalized_head')

0 commit comments

Comments
 (0)