crytic / building-secure-contracts

Guidelines and training material to write secure smart contracts
https://secure-contracts.com/
GNU Affero General Public License v3.0
2.22k stars 345 forks source link

Manticore: show how to use the quick-mode in script #22

Open montyly opened 4 years ago

montyly commented 4 years ago

This would speed-up many analyses that do not require the detectors/gas consumption.

We could add a section "tips to optimize scripts", or something like that, that will explain how to just disable the gas, etc

montyly commented 3 years ago
# Disable gas computation
from manticore.utils import config
consts_evm = config.get_group("evm")
consts_evm.oog = "ignore"
from manticore.ethereum.plugins import SkipRevertBasicBlocks, FilterFunctions
m = Manticore(...)

# Do not explore path that will revert
m.register_plugin(SkipRevertBasicBlocks())

# Do not explore constant/view/pure functions
filter_nohuman_constants = FilterFunctions(regexp=r".*", depth="human", mutability="constant", include=False)
m.register_plugin(filter_nohuman_constants)
m = Manticore(...)
# When calling finalize, only generate testcases that did not revert
m.finalize(only_alive_states=True)