module greed.sim_manager

Global Variables

  • TYPE_CHECKING

class SimulationManager

This class is the main class for running the symbolic execution. The simulation manager is responsible for keeping track of the states, and for moving them between the different stashes according to the employed exploration techniques.

method __init__

__init__(entry_state: SymbolicEVMState, project)

Args:

  • entry_state: The entry state of the simulation manager
  • project: The greed project

property active

Returns: All the active states


property deadended

Returns: All the deadended states (halted states)


property found

Returns: All the found states (states that met the find condition)


property one_active

Returns: First element of the active stash, or None if the stash is empty


property one_deadended

Returns: First element of the deadended stash, or None if the stash is empty


property one_found

Returns: First element of the found stash, or None if the stash is empty


property states

Returns: All the states in the simulation manager


method findall

findall(
    find: Callable[[SymbolicEVMState], bool] = <function SimulationManager.<lambda> at 0x7f79526d6980>,
    prune: Callable[[SymbolicEVMState], bool] = <function SimulationManager.<lambda> at 0x7f79526d6a20>
)

Run the simulation manager, until the find condition of all the ET is met.

Args:

  • find: Function that will be called after each step. The matching states will be moved to the found stash
  • prune: Function that will be called after each step. The matching states will be moved to the pruned stash Yield: The found states

Raises:

  • Exception: If something goes wrong while stepping the simulation manager

method move

move(
    from_stash: str,
    to_stash: str,
    filter_func: Callable[[SymbolicEVMState], bool] = <function SimulationManager.<lambda> at 0x7f79526d63e0>
)

Move all the states that meet the filter_func condition from from_stash to to_stash

Args:

  • from_stash: Source stash
  • to_stash: Destination Stash
  • filter_func: A function that discriminates what states should be moved

method run

run(
    find: Callable[[SymbolicEVMState], bool] = <function SimulationManager.<lambda> at 0x7f79526d67a0>,
    prune: Callable[[SymbolicEVMState], bool] = <function SimulationManager.<lambda> at 0x7f79526d6840>,
    find_all=False
)

Run the simulation manager, until the find condition is met. The analysis will stop when there are no more active states, some states met the find condition (these will be moved to the found stash), or the exploration techniques are done. If no ET are plugged, the default searching strategy is BFS. When techniques are plugged, their methods are executed following the same order they were plugged.

e.g., assuming we have T1 and T2. T1(check_stashes) -> T2(check_stashes) -> T1(check_state) -> T2(check_state)
-> T1(check_successors) -> T2(check_successors)

Args:

  • find: Function that will be called after each step. The matching states will be moved to the found stash
  • prune: Function that will be called after each step. The matching states will be moved to the pruned stash
  • find_all: If True, the analysis will continue until all the ET meet the find condition

Raises:

  • Exception: If something goes wrong while stepping the simulation manager

method set_error

set_error(s: str)

Set an error to the simulation manager


method single_step_state

single_step_state(state: SymbolicEVMState)  List[SymbolicEVMState]

Step a single state (calculate its successors)

Args:

  • state: The state to step

Returns: The successors of the state

Raises:

  • Exception: If something goes wrong while generating the successors

method step

step(
    find: Callable[[SymbolicEVMState], bool] = <function SimulationManager.<lambda> at 0x7f79526d6520>,
    prune: Callable[[SymbolicEVMState], bool] = <function SimulationManager.<lambda> at 0x7f79526d65c0>
)

Step the simulation manager, i.e., step all the active states.

Args:

  • find: A function that discriminates what states should be moved to the found stash
  • prune: A function that discriminates what states should be moved to the pruned stash

method use_technique

use_technique(technique: 'ExplorationTechnique')

Install an exploration technique in the simulation manager.


This file was automatically generated via lazydocs.