Skip to content

Commit 5629de0

Browse files
committed
Appease lint
1 parent f9f1374 commit 5629de0

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

eth/db/trie_iteration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def __str__(self) -> str:
5555
f"hash={self.keccak.hex()}"
5656
f" path={self.path_rest}"
5757
f" child={self.obj[1].hex()}"
58-
")"
58+
f")"
5959
)
6060
if self.kind == NodeKind.LEAF:
6161
return (
6262
"TrieNode<Leaf>("
6363
f"hash={self.keccak.hex()}"
6464
f" path={self.path_rest[:10]}..."
65-
")"
65+
f")"
6666
)
6767
return f"TrieNode(kind={self.kind.name} hash={self.keccak.hex()})"
6868

@@ -104,7 +104,7 @@ def _get_children_with_nibbles(node: TrieNode, prefix: Nibbles) -> Iterable[Tupl
104104

105105
def _get_node(db: ChainDB, node_hash: Hash32) -> TrieNode:
106106
if len(node_hash) < 32:
107-
node_rlp = node_hash
107+
node_rlp = cast(bytes, node_hash)
108108
else:
109109
node_rlp = db.get(node_hash)
110110

scripts/gethimport.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import os
1010
import os.path
1111
from pathlib import Path
12-
import shutil
1312
import snappy
1413
import struct
1514
import time
@@ -130,7 +129,7 @@ def get(self, number: int) -> bytes:
130129

131130
# What happens if we're trying to read the last item? Won't this fail?
132131
# Is there always one extra entry in the index file?
133-
self.index_file.seek((number+1) * 6)
132+
self.index_file.seek((number + 1) * 6)
134133
entry_bytes = self.index_file.read(6)
135134
end_entry = GethFreezerIndexEntry.from_bytes(entry_bytes)
136135

@@ -165,7 +164,6 @@ def first_index(self):
165164
return GethFreezerIndexEntry.from_bytes(first_index_bytes)
166165

167166

168-
169167
class BlockBody(rlp.Serializable):
170168
"This is how geth stores block bodies"
171169
fields = [
@@ -276,7 +274,9 @@ def open_gethdb(location):
276274

277275
last_block = gethdb.last_block_hash
278276
last_block_num = gethdb.block_num_for_hash(last_block)
279-
logger.info(f'found geth chain tip: header_hash={humanize_hash(last_block)} block_number={last_block_num}')
277+
278+
context = f'header_hash={humanize_hash(last_block)} block_number={last_block_num}'
279+
logger.info(f'found geth chain tip: {context}')
280280

281281
genesis_hash = gethdb.header_hash_for_block_number(0)
282282
genesis_header = gethdb.block_header(0, genesis_hash)
@@ -352,8 +352,8 @@ def sweep_state(gethdb: GethDatabase, trinitydb: LevelDB):
352352
logger.debug('sweep_state: bulk-importing state entries')
353353

354354
iterator = gethdb.db.iterator(
355-
start=b'\x00'*32,
356-
stop=b'\xff'*32,
355+
start=b'\x00' * 32,
356+
stop=b'\xff' * 32,
357357
include_start=True,
358358
include_stop=True,
359359
)
@@ -385,14 +385,16 @@ def import_state(gethdb: GethDatabase, chain):
385385
f'state_root={humanize_hash(state_root)}'
386386
)
387387

388+
leveldb = headerdb.db
388389
imported_leaf_count = 0
389390
importdb = ImportDatabase(gethdb=gethdb.db, trinitydb=leveldb.db)
390391
for path, leaf_data in iterate_leaves(importdb, state_root):
391392
account = rlp.decode(leaf_data, sedes=Account)
392393
addr_hash = nibbles_to_bytes(path)
393394

394395
if account.code_hash != EMPTY_SHA3:
395-
bytecode = importdb.get(account.code_hash)
396+
# by fetching it, we're copying it into the trinity database
397+
importdb.get(account.code_hash)
396398

397399
if account.storage_root == BLANK_ROOT_HASH:
398400
imported_leaf_count += 1
@@ -401,14 +403,14 @@ def import_state(gethdb: GethDatabase, chain):
401403
logger.debug(f'progress sha(addr)={addr_hash.hex()}')
402404
continue
403405

404-
for path, leaf_data in iterate_leaves(importdb, account.storage_root):
406+
for path, _leaf_data in iterate_leaves(importdb, account.storage_root):
405407
item_addr = nibbles_to_bytes(path)
406408
imported_leaf_count += 1
407409

408410
if imported_leaf_count % 1000 == 0:
409411
logger.debug(f'progress sha(addr)={addr_hash.hex()} sha(item)={item_addr.hex()}')
410412

411-
loger.info('successfully imported state trie and all storage tries')
413+
logger.info('successfully imported state trie and all storage tries')
412414

413415

414416
def import_block_body(gethdb, chain, block_number: int):
@@ -461,7 +463,7 @@ def process_blocks(gethdb, chain, end_block):
461463
transaction_class.from_base_transaction(txn) for txn in body.transactions
462464
]
463465
block = block_class(header, transactions, body.uncles)
464-
imported_block, _, _ = chain.import_block(block, perform_validation = True)
466+
imported_block, _, _ = chain.import_block(block, perform_validation=True)
465467
logger.debug(f'imported block: {imported_block}')
466468

467469

@@ -478,7 +480,12 @@ def read_receipts(gethdb, block_number):
478480
if len(raw_gas_used) < 8:
479481
padded = (b'\x00' * (8 - len(raw_gas_used))) + raw_gas_used
480482
gas_used = struct.unpack('>Q', padded)[0]
481-
logger.info(f'- post_state_or_status={post_state} gas_used={gas_used} len(logs)={len(logs)}')
483+
context = ' '.join([
484+
f'post_state_or_status={post_state}',
485+
f'gas_used={gas_used}',
486+
f'len(logs)={len(logs)}'
487+
])
488+
logger.info(f'- {context}')
482489

483490

484491
def read_geth(gethdb):

0 commit comments

Comments
 (0)