1
1
# ` hevm symbolic `
2
2
3
- ``` shell
3
+ ``` plain
4
4
Usage: hevm symbolic [--code TEXT] [--calldata TEXT] [--address ADDR]
5
5
[--caller ADDR] [--origin ADDR] [--coinbase ADDR]
6
6
[--value W256] [--nonce WORD64] [--gas WORD64]
7
- [--number W256] [--timestamp W256] [--basefee W256]
8
- [--priority-fee W256] [--gaslimit WORD64] [--gasprice W256]
9
- [--create] [--maxcodesize W256] [--prev-randao W256]
10
- [--chainid W256] [--rpc TEXT] [--block W256]
11
- [--root STRING] [--project-type PROJECTTYPE]
12
- [--initial-storage INITIALSTORAGE] [--sig TEXT]
13
- [--arg STRING]... [--get-models] [--show-tree]
14
- [--show-reachable-tree] [--smttimeout NATURAL]
15
- [--max-iterations INTEGER] [--solver TEXT] [--smtdebug]
16
- [--assertions [WORD256]] [--ask-smt-iterations INTEGER]
17
- [--num-solvers NATURAL]
18
- [--loop-detection-heuristic LOOPHEURISTIC]
19
-
20
- Available options:
21
- -h ,--help Show this help text
22
- --code TEXT Program bytecode
23
- --calldata TEXT Tx: calldata
24
- --address ADDR Tx: address
25
- --caller ADDR Tx: caller
26
- --origin ADDR Tx: origin
27
- --coinbase ADDR Block: coinbase
28
- --value W256 Tx: Eth amount
29
- --nonce WORD64 Nonce of origin
30
- --gas WORD64 Tx: gas amount
31
- --number W256 Block: number
32
- --timestamp W256 Block: timestamp
33
- --basefee W256 Block: base fee
34
- --priority-fee W256 Tx: priority fee
35
- --gaslimit WORD64 Tx: gas limit
36
- --gasprice W256 Tx: gas price
37
- --create Tx: creation
38
- --maxcodesize W256 Block: max code size
39
- --prev-randao W256 Block: prevRandao
40
- --chainid W256 Env: chainId
41
- --rpc TEXT Fetch state from a remote node
42
- --block W256 Block state is be fetched from
43
- --root STRING Path to project root directory (default: . )
44
- --project-type PROJECTTYPE Foundry or CombinedJSON project
45
- --initial-storage INITIALSTORAGE
46
- Starting state for storage: Empty, Abstract (default
47
- Abstract)
48
- --sig TEXT Signature of types to decode / encode
49
- --arg STRING Values to encode
50
- --get-models Print example testcase for each execution path
51
- --show-tree Print branches explored in tree view
52
- --show-reachable-tree Print only reachable branches explored in tree view
53
- --smttimeout NATURAL Timeout given to SMT solver in seconds (default: 300)
54
- --max-iterations INTEGER Number of times we may revisit a particular branching
55
- point. Default is 5. Setting to -1 allows infinite looping
56
- --solver TEXT Used SMT solver: z3 (default), cvc5, or bitwuzla
57
- --smtdebug Print smt queries sent to the solver
58
- --assertions [WORD256] Comma separated list of solc panic codes to check for
59
- (default: user defined assertion violations only)
60
- --ask-smt-iterations INTEGER
61
- Number of times we may revisit a particular branching
62
- point before we consult the smt solver to check
63
- reachability (default: 1) (default: 1)
64
- --num-solvers NATURAL Number of solver instances to use (default: number of
65
- cpu cores)
66
- --loop-detection-heuristic LOOPHEURISTIC
67
- Which heuristic should be used to determine if we are
68
- in a loop: StackBased (default) or Naive
69
- (default: StackBased)
7
+ [--number W256] [--timestamp W256] [--basefee W256] ..
70
8
```
71
9
72
- Run a symbolic execution against the given parameters, searching for assertion violations.
10
+ Run a symbolic execution against the given parameters, searching for assertion
11
+ violations. For a full listing of options, see ` hevm symbolic --help ` .
73
12
74
- Counterexamples will be returned for any reachable assertion violations. Where
13
+ Counterexamples are returned for any reachable assertion violations. Where
75
14
an assertion violation is defined as either an execution of the invalid opcode
76
15
(` 0xfe ` ), or a revert with a message of the form
77
16
` abi.encodeWithSelector('Panic(uint256)', errCode) ` with ` errCode ` being one of
78
17
the predefined solc assertion codes defined
79
18
[ here] ( https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require ) .
80
19
20
+ ## Arithmetic overflow
21
+
81
22
By default hevm ignores assertion violations that result from arithmetic
82
23
overflow (` Panic(0x11) ` ), although this behaviour can be customised via the
83
24
` --assertions ` flag. For example, the following will return counterexamples for
@@ -87,7 +28,10 @@ arithmetic overflow (`0x11`) and user defined assertions (`0x01`):
87
28
hevm symbolic --code $CODE --assertions '[0x01, 0x11]'
88
29
```
89
30
90
- The default value for ` calldata` and ` caller` are symbolic values, but can be specialized to concrete functions with their corresponding flags.
31
+ The default value for ` calldata ` and ` caller ` are symbolic values, but can be
32
+ specialized to concrete functions with their corresponding flags.
33
+
34
+ ## Specializing calldata
91
35
92
36
One can also specialize specific arguments to a function signature, while
93
37
leaving others abstract. If ` --sig ` is given, calldata is assumed to be of the
@@ -126,11 +70,15 @@ The default timeout for SMT queries is no timeout. If your program is taking
126
70
longer than a couple of minutes to run, you can experiment with configuring the
127
71
timeout to somewhere around 10s by doing ` --smttimeout 10000 `
128
72
73
+ ## Storage
74
+
129
75
Storage can be initialized in two ways:
130
76
131
77
- ` Empty ` : all storage slots for all contracts are initialized to zero
132
78
- ` Abstract ` : all storage slots are initialized as unconstrained abstract values
133
79
80
+ ## Exploration strategy
81
+
134
82
` hevm ` uses an eager approach for symbolic execution, meaning that it will
135
83
first attempt to explore all branches in the program (without querying the smt
136
84
solver to check if they are reachable or not). Once the full execution tree has
@@ -143,3 +91,10 @@ iterations (controlled by the `--ask-smt-iterations` flag), the solver will be
143
91
invoked to check whether a given loop branch is reachable. In cases where the
144
92
number of loop iterations is known in advance, you may be able to speed up
145
93
execution by setting this flag to an appropriate value.
94
+
95
+ ## Further reading
96
+
97
+ For a tutorial on symbolic execution with ` hevm ` , see the [ the page
98
+ here] ( symbolic-execution-tutorial.html ) .
99
+ An older blog post on symbolic execution with ` hevm ` can be found
100
+ [ here] ( https://fv.ethereum.org/2020/07/28/symbolic-hevm-release ) .
0 commit comments