|
|
@ -73,7 +73,7 @@ class WorldState: |
|
|
|
new_world_state.constraints = copy(self.constraints) |
|
|
|
new_world_state.constraints = copy(self.constraints) |
|
|
|
return new_world_state |
|
|
|
return new_world_state |
|
|
|
|
|
|
|
|
|
|
|
def accounts_exist_or_load(self, addr: str, dynamic_loader: DynLoader) -> str: |
|
|
|
def accounts_exist_or_load(self, addr: str, dynamic_loader: DynLoader) -> Account: |
|
|
|
""" |
|
|
|
""" |
|
|
|
returns account if it exists, else it loads from the dynamic loader |
|
|
|
returns account if it exists, else it loads from the dynamic loader |
|
|
|
:param addr: address |
|
|
|
:param addr: address |
|
|
@ -81,18 +81,17 @@ class WorldState: |
|
|
|
:return: The code |
|
|
|
:return: The code |
|
|
|
""" |
|
|
|
""" |
|
|
|
addr_bitvec = symbol_factory.BitVecVal(int(addr, 16), 256) |
|
|
|
addr_bitvec = symbol_factory.BitVecVal(int(addr, 16), 256) |
|
|
|
|
|
|
|
|
|
|
|
if addr_bitvec.value in self.accounts: |
|
|
|
if addr_bitvec.value in self.accounts: |
|
|
|
code = self.accounts[addr_bitvec.value].code |
|
|
|
return self.accounts[addr_bitvec.value] |
|
|
|
else: |
|
|
|
if dynamic_loader is None: |
|
|
|
code = dynamic_loader.dynld(addr) |
|
|
|
raise ValueError("dynamic_loader is None") |
|
|
|
self.create_account( |
|
|
|
return self.create_account( |
|
|
|
balance=0, address=addr_bitvec.value, dynamic_loader=dynamic_loader |
|
|
|
balance=0, |
|
|
|
) |
|
|
|
address=addr_bitvec.value, |
|
|
|
if code is None: |
|
|
|
dynamic_loader=dynamic_loader, |
|
|
|
code = "" |
|
|
|
code=dynamic_loader.dynld(addr), |
|
|
|
else: |
|
|
|
) |
|
|
|
code = code.bytecode |
|
|
|
|
|
|
|
return code |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_account( |
|
|
|
def create_account( |
|
|
|
self, |
|
|
|
self, |
|
|
@ -101,6 +100,7 @@ class WorldState: |
|
|
|
concrete_storage=False, |
|
|
|
concrete_storage=False, |
|
|
|
dynamic_loader=None, |
|
|
|
dynamic_loader=None, |
|
|
|
creator=None, |
|
|
|
creator=None, |
|
|
|
|
|
|
|
code=None, |
|
|
|
) -> Account: |
|
|
|
) -> Account: |
|
|
|
"""Create non-contract account. |
|
|
|
"""Create non-contract account. |
|
|
|
|
|
|
|
|
|
|
@ -108,6 +108,8 @@ class WorldState: |
|
|
|
:param balance: Initial balance for the account |
|
|
|
:param balance: Initial balance for the account |
|
|
|
:param concrete_storage: Interpret account storage as concrete |
|
|
|
:param concrete_storage: Interpret account storage as concrete |
|
|
|
:param dynamic_loader: used for dynamically loading storage from the block chain |
|
|
|
:param dynamic_loader: used for dynamically loading storage from the block chain |
|
|
|
|
|
|
|
:param creator: The address of the creator of the contract if it's a contract |
|
|
|
|
|
|
|
:param code: The code of the contract, if it's a contract |
|
|
|
:return: The new account |
|
|
|
:return: The new account |
|
|
|
""" |
|
|
|
""" |
|
|
|
address = ( |
|
|
|
address = ( |
|
|
@ -122,6 +124,8 @@ class WorldState: |
|
|
|
dynamic_loader=dynamic_loader, |
|
|
|
dynamic_loader=dynamic_loader, |
|
|
|
concrete_storage=concrete_storage, |
|
|
|
concrete_storage=concrete_storage, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
if code: |
|
|
|
|
|
|
|
new_account.code = code |
|
|
|
if balance: |
|
|
|
if balance: |
|
|
|
new_account.add_balance(symbol_factory.BitVecVal(balance, 256)) |
|
|
|
new_account.add_balance(symbol_factory.BitVecVal(balance, 256)) |
|
|
|
|
|
|
|
|
|
|
|