Merge pull request #469 from JoranHonig/bugfix/contract_name

Initialize account with contract name
pull/477/head
JoranHonig 6 years ago committed by GitHub
commit f56df80826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mythril/analysis/symbolic.py
  2. 4
      mythril/laser/ethereum/svm.py
  3. 4
      mythril/laser/ethereum/transaction/symbolic.py

@ -33,7 +33,7 @@ class SymExecWrapper:
create_timeout=create_timeout) create_timeout=create_timeout)
if isinstance(contract, SolidityContract): if isinstance(contract, SolidityContract):
self.laser.sym_exec(creation_code=contract.creation_code) self.laser.sym_exec(creation_code=contract.creation_code, contract_name=contract.name)
else: else:
self.laser.sym_exec(address) self.laser.sym_exec(address)

@ -61,7 +61,7 @@ class LaserEVM:
def accounts(self): def accounts(self):
return self.world_state.accounts return self.world_state.accounts
def sym_exec(self, main_address=None, creation_code=None): def sym_exec(self, main_address=None, creation_code=None, contract_name=None):
logging.debug("Starting LASER execution") logging.debug("Starting LASER execution")
self.time = datetime.now() self.time = datetime.now()
@ -70,7 +70,7 @@ class LaserEVM:
execute_message_call(self, main_address) execute_message_call(self, main_address)
elif creation_code: elif creation_code:
logging.info("Starting contract creation transaction") logging.info("Starting contract creation transaction")
created_account = execute_contract_creation(self, creation_code) created_account = execute_contract_creation(self, creation_code, contract_name)
logging.info("Finished contract creation, found {} open states".format(len(self.open_states))) logging.info("Finished contract creation, found {} open states".format(len(self.open_states)))
if len(self.open_states) == 0: if len(self.open_states) == 0:
print("No contract was created during the execution of contract creation " print("No contract was created during the execution of contract creation "

@ -26,12 +26,14 @@ def execute_message_call(laser_evm, callee_address):
laser_evm.exec() laser_evm.exec()
def execute_contract_creation(laser_evm, contract_initialization_code): def execute_contract_creation(laser_evm, contract_initialization_code, contract_name=None):
""" Executes a contract creation transaction from all open states""" """ Executes a contract creation transaction from all open states"""
open_states = laser_evm.open_states[:] open_states = laser_evm.open_states[:]
del laser_evm.open_states[:] del laser_evm.open_states[:]
new_account = laser_evm.world_state.create_account(0, concrete_storage=True, dynamic_loader=None) new_account = laser_evm.world_state.create_account(0, concrete_storage=True, dynamic_loader=None)
if contract_name:
new_account.contract_name = contract_name
for open_world_state in open_states: for open_world_state in open_states:
transaction = ContractCreationTransaction( transaction = ContractCreationTransaction(

Loading…
Cancel
Save