Skip to content

Commit

Permalink
Dev single gas calc (#1353)
Browse files Browse the repository at this point in the history
* Try fix concolic

* Let gas calc be done in a single place

* Fix refactoring
  • Loading branch information
feliam authored and disconnect3d committed Jan 17, 2019
1 parent 1da68dc commit 26dc0d2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions manticore/platforms/evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 26dc0d2

Please sign in to comment.