Fix builtin name shadowing

pull/555/head
Dominik Muhs 6 years ago
parent 2e56cef99a
commit 0142e6e41b
  1. 4
      mythril/interfaces/cli.py
  2. 6
      mythril/leveldb/accountindexing.py
  3. 38
      mythril/leveldb/client.py

@ -17,8 +17,8 @@ from mythril.mythril import Mythril
from mythril.version import VERSION
def exit_with_error(format, message):
if format == 'text' or format == 'markdown':
def exit_with_error(fmt, message):
if fmt == 'text' or fmt == 'markdown':
print(message)
else:
result = {'success': False, 'error': str(message), 'issues': []}

@ -80,9 +80,9 @@ class AccountIndexer(object):
addresses = []
for blockNum in range(startblock, startblock + BATCH_SIZE):
hash = self.db.reader._get_block_hash(blockNum)
if hash is not None:
receipts = self.db.reader._get_block_receipts(hash, blockNum)
block_hash = self.db.reader._get_block_hash(blockNum)
if block_hash is not None:
receipts = self.db.reader._get_block_receipts(block_hash, blockNum)
for receipt in receipts:
if receipt.contractAddress is not None and not all(b == 0 for b in receipt.contractAddress):

@ -79,38 +79,38 @@ class LevelDBReader(object):
gets head block header
'''
if not self.head_block_header:
hash = self.db.get(head_header_key)
num = self._get_block_number(hash)
self.head_block_header = self._get_block_header(hash, num)
block_hash = self.db.get(head_header_key)
num = self._get_block_number(block_hash)
self.head_block_header = self._get_block_header(block_hash, num)
# find header with valid state
while not self.db.get(self.head_block_header.state_root) and self.head_block_header.prevhash is not None:
hash = self.head_block_header.prevhash
num = self._get_block_number(hash)
self.head_block_header = self._get_block_header(hash, num)
block_hash = self.head_block_header.prevhash
num = self._get_block_number(block_hash)
self.head_block_header = self._get_block_header(block_hash, num)
return self.head_block_header
def _get_block_number(self, hash):
def _get_block_number(self, block_hash):
'''
gets block number by hash
gets block number by its hash
'''
number_key = block_hash_prefix + hash
number_key = block_hash_prefix + block_hash
return self.db.get(number_key)
def _get_block_header(self, hash, num):
def _get_block_header(self, block_hash, num):
'''
get block header by block header hash & number
'''
header_key = header_prefix + num + hash
header_key = header_prefix + num + block_hash
block_header_data = self.db.get(header_key)
header = rlp.decode(block_header_data, sedes=BlockHeader)
return header
def _get_address_by_hash(self, hash):
def _get_address_by_hash(self, block_hash):
'''
get mapped address by its hash
'''
address_key = address_prefix + hash
address_key = address_prefix + block_hash
return self.db.get(address_key)
def _get_last_indexed_number(self):
@ -119,12 +119,12 @@ class LevelDBReader(object):
'''
return self.db.get(address_mapping_head_key)
def _get_block_receipts(self, hash, num):
def _get_block_receipts(self, block_hash, num):
'''
get block transaction receipts by block header hash & number
'''
number = _format_block_number(num)
receipts_key = block_receipts_prefix + number + hash
receipts_key = block_receipts_prefix + number + block_hash
receipts_data = self.db.get(receipts_key)
receipts = rlp.decode(receipts_data, sedes=CountableList(ReceiptForStorage))
return receipts
@ -216,12 +216,12 @@ class EthLevelDB(object):
if not cnt % 1000:
logging.info("Searched %d contracts" % cnt)
def contract_hash_to_address(self, hash):
def contract_hash_to_address(self, contract_hash):
'''
tries to find corresponding account address
'''
address_hash = binascii.a2b_hex(utils.remove_0x_head(hash))
address_hash = binascii.a2b_hex(utils.remove_0x_head(contract_hash))
indexer = AccountIndexer(self)
return _encode_hex(indexer.get_contract_by_hash(address_hash))
@ -230,9 +230,9 @@ class EthLevelDB(object):
'''
gets block header by block number
'''
hash = self.reader._get_block_hash(number)
block_hash = self.reader._get_block_hash(number)
block_number = _format_block_number(number)
return self.reader._get_block_header(hash, block_number)
return self.reader._get_block_header(block_hash, block_number)
def eth_getBlockByNumber(self, number):
'''

Loading…
Cancel
Save