From 828b54f1b602830555f1b018dfa7fe50a94f29b0 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Thu, 1 Feb 2024 23:26:27 +0000 Subject: [PATCH] Refactor code (#1831) * Refactor code * Edit tox * Modify tox * Modify tests * Reduce processes --- mythril/laser/ethereum/svm.py | 5 ----- mythril/support/opcodes.py | 2 +- tests/integration_tests/parallel_test.py | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/mythril/laser/ethereum/svm.py b/mythril/laser/ethereum/svm.py index 0b3e3891..3defd402 100644 --- a/mythril/laser/ethereum/svm.py +++ b/mythril/laser/ethereum/svm.py @@ -592,11 +592,6 @@ class LaserEVM: self._new_node_state( state, JumpType.CONDITIONAL, state.world_state.constraints[-1] ) - elif opcode in ("SLOAD", "SSTORE") and len(new_states) > 1: - for state in new_states: - self._new_node_state( - state, JumpType.CONDITIONAL, state.world_state.constraints[-1] - ) elif opcode == "RETURN": for state in new_states: self._new_node_state(state, JumpType.RETURN) diff --git a/mythril/support/opcodes.py b/mythril/support/opcodes.py index c927b582..2723e781 100644 --- a/mythril/support/opcodes.py +++ b/mythril/support/opcodes.py @@ -96,7 +96,7 @@ OPCODES: Dict = { "MSTORE8": {GAS: (3, 98), STACK: (2, 0), ADDRESS: 0x53}, # assume 64 byte r/w cost as upper bound "SLOAD": {GAS: (800, 800), STACK: UN_OPERATOR_TUPLE, ADDRESS: 0x54}, - "SSTORE": {GAS: (5000, 25000), STACK: (1, 0), ADDRESS: 0x55}, + "SSTORE": {GAS: (5000, 25000), STACK: (2, 0), ADDRESS: 0x55}, "JUMP": {GAS: (8, 8), STACK: (1, 0), ADDRESS: 0x56}, "JUMPI": {GAS: (10, 10), STACK: (2, 0), ADDRESS: 0x57}, "PC": {GAS: (2, 2), STACK: Z_OPERATOR_TUPLE, ADDRESS: 0x58}, diff --git a/tests/integration_tests/parallel_test.py b/tests/integration_tests/parallel_test.py index 898d1dd7..af2e9a50 100644 --- a/tests/integration_tests/parallel_test.py +++ b/tests/integration_tests/parallel_test.py @@ -9,7 +9,7 @@ def test_parallel(): test_file = str(TESTDATA / "input_contracts" / "origin.sol") program = f"python3 {MYTH} a {test_file} --solv 0.5.0 -o json" - processes = [Popen(program, stdout=PIPE, shell=True) for i in range(30)] + processes = [Popen(program, stdout=PIPE, shell=True) for i in range(8)] for p in processes: out, err = p.communicate() json_output = json.loads(out.decode("utf-8"))