def __init__(self, accounts, dynamic_loader=None, max_depth=float('inf'), execution_timeout=60, create_timeout=10, strategy=DepthFirstSearchStrategy): world_state = WorldState() world_state.accounts = accounts # this sets the initial world state self.world_state = world_state self.open_states = [world_state] self.nodes = {} self.edges = [] self.coverage = {} self.total_states = 0 self.dynamic_loader = dynamic_loader self.work_list = [] self.strategy = strategy(self.work_list, max_depth) self.max_depth = max_depth self.execution_timeout = execution_timeout self.create_timeout = create_timeout self.time = None self.pre_hooks = {} self.post_hooks = {} logging.info("LASER EVM initialized with dynamic loader: " + str(dynamic_loader))
def exec(self): for global_state in self.strategy: if self.execution_timeout: if self.time + timedelta( seconds=self.execution_timeout) <= datetime.now(): return try: new_states, op_code = self.execute_state(global_state) except NotImplementedError: logging.info( "Encountered unimplemented instruction: {}".format( op_code)) continue if len(new_states) == 0: # TODO: let global state use worldstate open_world_state = WorldState() open_world_state.accounts = global_state.accounts open_world_state.node = global_state.node self.open_states.append(open_world_state) self.manage_cfg(op_code, new_states) self.work_list += new_states self.total_states += len(new_states)