Add balance loading to accounts_exist_or_load

pull/1347/head
Bernhard Mueller 5 years ago
parent 8df98f7ecd
commit caf01453db
  1. 12
      mythril/laser/ethereum/state/account.py
  2. 16
      mythril/laser/ethereum/state/world_state.py

@ -127,18 +127,6 @@ class Account:
self._balances = balances
self.balance = lambda: self._balances[self.address]
"""
if not self.address.symbolic and dynamic_loader is not None:
try:
_balance = dynamic_loader.read_balance(
"{0:#0{1}x}".format(self.address.value, 42)
)
self.set_balance(_balance)
except:
# Initial balance will be a symbolic variable
pass
"""
def __str__(self) -> str:
return str(self.as_dict)

@ -90,6 +90,22 @@ class WorldState:
return self.accounts[addr_bitvec.value]
if dynamic_loader is None:
raise ValueError("dynamic_loader is None")
if isinstance(addr, int):
try:
_balance = dynamic_loader.read_balance("{0:#0{1}x}".format(addr, 42))
self.set_balance(_balance)
except:
# Initial balance will be a symbolic variable
pass
elif isinstance(addr, str):
try:
_balance = dynamic_loader.read_balance(addr)
self.set_balance(_balance)
except:
# Initial balance will be a symbolic variable
pass
return self.create_account(
balance=0,
address=addr_bitvec.value,

Loading…
Cancel
Save