Fix incorrect number of transaction in certain states (#724)

* privatize Executor.put, use in evm

* better typeerror

* Simplify execute(), directly raise exception in _process...
This commit is contained in:
Mark Mossberg 2018-02-02 13:23:04 -05:00 committed by GitHub
parent 9f7b87d0b8
commit 97307906c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 13 deletions

View File

@ -253,7 +253,7 @@ class Executor(Eventful):
''' '''
#save the state to secondary storage #save the state to secondary storage
state_id = self._workspace.save_state(state) state_id = self._workspace.save_state(state)
self.put(state_id) self._put(state_id)
self._publish('did_enqueue_state', state_id, state) self._publish('did_enqueue_state', state_id, state)
return state_id return state_id
@ -304,7 +304,7 @@ class Executor(Eventful):
############################################### ###############################################
# Priority queue # Priority queue
@sync @sync
def put(self, state_id): def _put(self, state_id):
''' Enqueue it for processing ''' ''' Enqueue it for processing '''
self._states.append(state_id) self._states.append(state_id)
self._lock.notify_all() self._lock.notify_all()

View File

@ -919,7 +919,7 @@ class ManticoreEVM(Manticore):
assert len(self._executor.list()) == 0 assert len(self._executor.list()) == 0
for state_id in context['_saved_states']: for state_id in context['_saved_states']:
self._executor.put(state_id) self._executor.enqueue(state_id)
context['_saved_states'] = [] context['_saved_states'] = []
#A callback will use _pending_transaction and issue the transaction #A callback will use _pending_transaction and issue the transaction
@ -997,7 +997,7 @@ class ManticoreEVM(Manticore):
state.context['last_exception'] = e state.context['last_exception'] = e
# TODO(mark): This will break if we ever change the message text. Use a less # TODO(mark): This will break if we ever change the message text. Use a less
# brittle check. # brittle check.
if e.message not in {'REVERT', 'THROW', 'Not Enough Funds for transaction'}: if e.message not in {'REVERT', 'THROW', 'TXERROR'}:
# if not a revert we save the state for further transactioning # if not a revert we save the state for further transactioning
state.context['processed'] = False state.context['processed'] = False
if e.message == 'RETURN': if e.message == 'RETURN':

View File

@ -2117,8 +2117,6 @@ class EVMWorld(Platform):
def execute(self): def execute(self):
self._process_pending_transaction() self._process_pending_transaction()
try: try:
if self.current is None:
raise TerminateState("Trying to execute an empty transaction", testcase=False)
self.current.execute() self.current.execute()
except Create as ex: except Create as ex:
self.CREATE(ex.value, ex.data) self.CREATE(ex.value, ex.data)
@ -2260,11 +2258,6 @@ class EVMWorld(Platform):
pass pass
def _process_pending_transaction(self): def _process_pending_transaction(self):
def err():
if self.depth == 0:
raise TerminateState("Not Enough Funds for transaction", testcase=True)
if self._pending_transaction is None: if self._pending_transaction is None:
return return
assert self.current is None or self.current.last_exception is not None assert self.current is None or self.current.last_exception is not None
@ -2312,6 +2305,7 @@ class EVMWorld(Platform):
if is_human_tx: #human transaction if is_human_tx: #human transaction
tx = Transaction(ty, address, origin, price, data, caller, value, 'TXERROR', None) tx = Transaction(ty, address, origin, price, data, caller, value, 'TXERROR', None)
self._transactions.append(tx) self._transactions.append(tx)
raise TerminateState('TXERROR')
else: else:
self.current._push(0) self.current._push(0)
return return

View File

@ -142,7 +142,7 @@ class Eventful(object):
def forward_events_from(self, source, include_source=False): def forward_events_from(self, source, include_source=False):
if not isinstance(source, Eventful): if not isinstance(source, Eventful):
raise TypeError raise TypeError('{} is not Eventful'.format(source.__class__.__name__))
source.forward_events_to(self, include_source=include_source) source.forward_events_to(self, include_source=include_source)
def forward_events_to(self, sink, include_source=False): def forward_events_to(self, sink, include_source=False):