Rename time handler and the execution timeout variable

fix/timeout
Nikhil Parasaram 6 years ago
parent 376a6604f5
commit 15864aad6e
  1. 2
      mythril/analysis/solver.py
  2. 10
      mythril/laser/ethereum/time_handler.py

@ -25,7 +25,7 @@ def get_model(constraints, minimize=(), maximize=(), enforce_execution_time=True
s = Optimize()
timeout = 100000
if enforce_execution_time:
timeout = min(timeout, time_handler.time_remaining() - 500)
timeout = min(timeout, time_handler.transaction_time_remaining() - 500)
if timeout <= 0:
raise UnsatError
s.set_timeout(timeout)

@ -5,14 +5,16 @@ from mythril.support.support_utils import Singleton
class TimeHandler(object, metaclass=Singleton):
def __init__(self):
self._start_time = None
self._execution_time = None
self._transaction_execution_timeout = None
def start_execution(self, execution_time: int, transaction_count: int):
self._start_time = int(time.time() * 1000)
self._execution_time = execution_time * 1000 // transaction_count
self._transaction_execution_timeout = execution_time * 1000 // transaction_count
def time_remaining(self):
return self._execution_time - (int(time.time() * 1000) - self._start_time)
def transaction_time_remaining(self):
return self._transaction_execution_timeout - (
int(time.time() * 1000) - self._start_time
)
time_handler = TimeHandler()

Loading…
Cancel
Save