Update the state merge plugin

state_merge
Nikhil Parasaram 5 years ago
parent 405891f086
commit 40a9bef6a2
  1. 4
      mythril/analysis/symbolic.py
  2. 1
      mythril/laser/plugin/builder.py
  3. 2
      mythril/laser/plugin/plugins/__init__.py
  4. 17
      mythril/laser/plugin/plugins/state_merge/__init__.py

@ -23,7 +23,7 @@ from mythril.laser.plugin.plugins import (
MutationPrunerBuilder, MutationPrunerBuilder,
DependencyPrunerBuilder, DependencyPrunerBuilder,
CoveragePluginBuilder, CoveragePluginBuilder,
StateMerge, StateMergePluginBuilder,
) )
from mythril.laser.ethereum.strategy.extensions.bounded_loops import ( from mythril.laser.ethereum.strategy.extensions.bounded_loops import (
BoundedLoopsStrategy, BoundedLoopsStrategy,
@ -132,7 +132,7 @@ class SymExecWrapper:
plugin_loader.load(CoveragePluginBuilder()) plugin_loader.load(CoveragePluginBuilder())
plugin_loader.load(MutationPrunerBuilder()) plugin_loader.load(MutationPrunerBuilder())
if enable_state_merging: if enable_state_merging:
plugin_loader.load(StateMerge()) plugin_loader.load(StateMergePluginBuilder())
if not disable_dependency_pruning: if not disable_dependency_pruning:
plugin_loader.load(DependencyPrunerBuilder()) plugin_loader.load(DependencyPrunerBuilder())

@ -1,7 +1,6 @@
from mythril.laser.plugin.interface import LaserPlugin from mythril.laser.plugin.interface import LaserPlugin
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Optional
class PluginBuilder(ABC): class PluginBuilder(ABC):

@ -9,4 +9,4 @@ from mythril.laser.plugin.plugins.benchmark import BenchmarkPluginBuilder
from mythril.laser.plugin.plugins.coverage.coverage_plugin import CoveragePluginBuilder from mythril.laser.plugin.plugins.coverage.coverage_plugin import CoveragePluginBuilder
from mythril.laser.plugin.plugins.dependency_pruner import DependencyPrunerBuilder from mythril.laser.plugin.plugins.dependency_pruner import DependencyPrunerBuilder
from mythril.laser.plugin.plugins.mutation_pruner import MutationPrunerBuilder from mythril.laser.plugin.plugins.mutation_pruner import MutationPrunerBuilder
from mythril.laser.plugin.plugins.state_merge import StateMerge from mythril.laser.plugin.plugins.state_merge import StateMergePluginBuilder

@ -1,11 +1,10 @@
from copy import copy from copy import copy
from typing import Set, List from typing import Set, List
from mythril.laser.ethereum.svm import LaserEVM from mythril.laser.ethereum.svm import LaserEVM
from mythril.laser.ethereum.plugins.plugin import LaserPlugin from mythril.laser.plugin.interface import LaserPlugin
from mythril.laser.ethereum.plugins.implementations.state_merge.merge_states import ( from mythril.laser.plugin.plugins.state_merge.merge_states import merge_states
merge_states, from mythril.laser.plugin.builder import PluginBuilder
) from mythril.laser.plugin.plugins.state_merge.check_mergeability import (
from mythril.laser.ethereum.plugins.implementations.state_merge.check_mergeability import (
check_ws_merge_condition, check_ws_merge_condition,
) )
from mythril.laser.ethereum.state.world_state import WorldState from mythril.laser.ethereum.state.world_state import WorldState
@ -19,6 +18,13 @@ class MergeAnnotation(StateAnnotation):
pass pass
class StateMergePluginBuilder(PluginBuilder):
plugin_name = "state merge"
def __call__(self, *args, **kwargs):
return StateMerge()
class StateMerge(LaserPlugin): class StateMerge(LaserPlugin):
""" """
Tries to merge states based on their similarity. Tries to merge states based on their similarity.
@ -38,7 +44,6 @@ class StateMerge(LaserPlugin):
@symbolic_vm.laser_hook("stop_sym_trans") @symbolic_vm.laser_hook("stop_sym_trans")
def execute_stop_sym_trans_hook(svm: LaserEVM): def execute_stop_sym_trans_hook(svm: LaserEVM):
open_states = svm.open_states open_states = svm.open_states
if len(open_states) <= 1: if len(open_states) <= 1:
return return

Loading…
Cancel
Save