From 26dc0d22e1ef51f3741c7a7a59568a8f5b74412b Mon Sep 17 00:00:00 2001 From: feliam Date: Wed, 16 Jan 2019 22:32:40 -0300 Subject: [PATCH] Dev single gas calc (#1353) * Try fix concolic * Let gas calc be done in a single place * Fix refactoring --- manticore/platforms/evm.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manticore/platforms/evm.py b/manticore/platforms/evm.py index 2cff34da2..8f7efa2f3 100644 --- a/manticore/platforms/evm.py +++ b/manticore/platforms/evm.py @@ -902,12 +902,12 @@ def _push_results(self, instruction, result): assert instruction.pushes == 0 assert result is None - def _calculate_extra_gas(self, *arguments): + def _calculate_gas(self, *arguments): current = self.instruction implementation = getattr(self, f"{current.semantics}_gas", None) if implementation is None: - return 0 - return implementation(*arguments) + return current.fee + return current.fee + implementation(*arguments) def _handler(self, *arguments): current = self.instruction @@ -933,7 +933,7 @@ def _checkpoint(self): #FIXME Not clear which exception should trigger first. OOG or insuficient stack # this could raise an insuficient stack exception arguments = self._pop_arguments() - fee = instruction.fee + self._calculate_extra_gas(*arguments) + fee = self._calculate_gas(*arguments) self._checkpoint_data = (pc, old_gas, instruction, arguments, fee, allocated) return self._checkpoint_data @@ -2026,6 +2026,7 @@ def _close_transaction(self, result, data=None, rollback=False): else: self._deleted_accounts = deleted_accounts + #FIXME: BUG: a CREATE can be succesfull and still return an empty contract :shrug: if not issymbolic(tx.caller) and (tx.sort == 'CREATE' or not self._world_state[tx.caller]['code']): # Increment the nonce if this transaction created a contract, or if it was called by a non-contract account self.increase_nonce(tx.caller)