From 15864aad6eb7695b03b3671b0f904dd710f4c8c6 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Mon, 18 Mar 2019 18:15:50 +0530 Subject: [PATCH] Rename time handler and the execution timeout variable --- mythril/analysis/solver.py | 2 +- mythril/laser/ethereum/time_handler.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mythril/analysis/solver.py b/mythril/analysis/solver.py index 98d3633a..72a67912 100644 --- a/mythril/analysis/solver.py +++ b/mythril/analysis/solver.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) diff --git a/mythril/laser/ethereum/time_handler.py b/mythril/laser/ethereum/time_handler.py index eb471d76..6ba1587c 100644 --- a/mythril/laser/ethereum/time_handler.py +++ b/mythril/laser/ethereum/time_handler.py @@ -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()