Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move states that selfdestruct to the ready queue #1699

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions manticore/ethereum/manticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1425,16 +1425,13 @@ def _terminate_state_callback(self, state, e):
# generate a testcase. FIXME This should be configurable as REVERT and
# THROW; it actually changes the balance and nonce? of some accounts

if tx.result in {"SELFDESTRUCT", "REVERT", "THROW", "TXERROR"}:
if tx.return_value == 0:
pass
elif tx.result in {"RETURN", "STOP"}:
else:
# if not a revert, we save the state for further transactions
with self.locked_context("ethereum.saved_states", list) as saved_states:
saved_states.append(state.id)

else:
logger.debug("Exception in state. Discarding it")

# Callbacks
def _did_evm_execute_instruction_callback(self, state, instruction, arguments, result):
""" INTERNAL USE """
Expand Down
17 changes: 17 additions & 0 deletions tests/ethereum/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,23 @@ def test_gas_check(self):
result = str(e)
self.assertEqual(result, "SELFDESTRUCT")

def test_selfdestruct(self):
with disposable_mevm() as m:
asm_acc = """ PUSH1 0x0
SELFDESTRUCT
"""
m.create_account(
address=0x111111111111111111111111111111111111111, code=EVMAsm.assemble(asm_acc)
)
m.create_account(address=0x222222222222222222222222222222222222222)
symbolic_data = m.make_symbolic_buffer(320)
m.transaction(
caller=0x222222222222222222222222222222222222222,
address=0x111111111111111111111111111111111111111,
data=symbolic_data,
value=0,
)
self.assertEqual(m.count_ready_states(), 1)

class EthPluginTests(unittest.TestCase):
def test_FilterFunctions_fallback_function_matching(self):
Expand Down