Skip to content

Commit 31034fb

Browse files
Echidna 2.0 (#716)
1 parent 253e159 commit 31034fb

File tree

185 files changed

+1332
-5550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+1332
-5550
lines changed

.github/workflows/nix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
- uses: cachix/install-nix-action@v16
2323
with:
2424
nix_path: nixpkgs=channel:nixos-unstable
25-
- run: nix-build
25+
- run: true #nix-build

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
## TODO
22

3+
## 2.0.0
4+
5+
* Refactored test internal data structures and code
6+
* Refactored unit test code and moved the related files to the `tests` directory
7+
* Added support to show events and custom errors when a property/assertion fails
8+
* Added support for catching assertion failure in Solidity 0.8.x
9+
* Added two new testing mode: optimization and overflow (only in Solidity 0.8.x)
10+
* Added optional checks for contract destruction
11+
* Added `testMode` option and removed related flags
12+
* Simplified contract deployer and property sender addresses to be easier to read
13+
* Updated hevm to 0.49.0
14+
315
## 1.7.3
416

517
* Removed old compilation artifacts before starting a new fuzzing campaign (#697)

README.md

+22-40
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ More seriously, Echidna is a Haskell program designed for fuzzing/property-based
2020

2121
.. and [a beautiful high-resolution handcrafted logo](https://raw.githubusercontent.com/crytic/echidna/master/echidna.png).
2222

23-
<a href="https://trailofbits.files.wordpress.com/2020/03/image5.png"><img src="https://trailofbits.files.wordpress.com/2020/03/image5.png" width="650"/></a>
23+
<a href="https://i.imgur.com/saFWti4.png"><img src="https://i.imgur.com/saFWti4.png" width="650"/></a>
2424

2525
## Usage
2626

@@ -44,9 +44,9 @@ To check these invariants, run:
4444
$ echidna-test myContract.sol
4545
```
4646

47-
An example contract with tests can be found [examples/solidity/basic/flags.sol](examples/solidity/basic/flags.sol). To run it, you should execute:
47+
An example contract with tests can be found [tests/solidity/basic/flags.sol](examples/solidity/basic/flags.sol). To run it, you should execute:
4848
```
49-
$ echidna-test examples/solidity/basic/flags.sol
49+
$ echidna-test tests/solidity/basic/flags.sol
5050
```
5151

5252
Echidna should find a a call sequence that falsifies `echidna_sometimesfalse` and should be unable to find a falsifying input for `echidna_alwaystrue`.
@@ -55,7 +55,7 @@ Echidna should find a a call sequence that falsifies `echidna_sometimesfalse` an
5555

5656
After finishing a campaign, Echidna can save a coverage maximizing **corpus** in a special directory specified with the `corpusDir` config option. This directory will contain two entries: (1) a directory named `coverage` with JSON files that can be replayed by Echidna and (2) a plain-text file named `covered.txt`, a copy of the source code with coverage annotations.
5757

58-
If you run `examples/solidity/basic/flags.sol` example, Echidna will save a few files serialized transactions in the `coverage` directory and a `covered.$(date +%s).txt` file with the following lines:
58+
If you run `tests/solidity/basic/flags.sol` example, Echidna will save a few files serialized transactions in the `coverage` directory and a `covered.$(date +%s).txt` file with the following lines:
5959

6060
```
6161
*r | function set0(int val) public returns (bool){
@@ -77,20 +77,20 @@ Our tool signals each execution trace in the corpus with the following "line mar
7777

7878
### Support for smart contract build systems
7979

80-
Echidna can test contracts compiled with different smart contract build systems, including [Truffle](https://truffleframework.com/), [Embark](https://framework.embarklabs.io/) and even [Vyper](https://vyper.readthedocs.io), using [crytic-compile](https://github.com/crytic/crytic-compile). For instance,
81-
we can uncover an integer overflow in the [Metacoin Truffle box](https://github.com/truffle-box/metacoin-box) using a
82-
[contract with Echidna properties to test](examples/solidity/truffle/metacoin/contracts/MetaCoinEchidna.sol):
80+
Echidna can test contracts compiled with different smart contract build systems, including [Truffle](https://truffleframework.com/) or [hardhat](https://hardhat.org/) using [crytic-compile](https://github.com/crytic/crytic-compile). To invoke echidna with the current compilation framework, use `echidna-test .`.
8381

84-
```
85-
$ cd examples/solidity/truffle/metacoin
86-
$ echidna-test . --contract TEST
87-
...
88-
echidna_convert: failed!💥
89-
Call sequence:
90-
mint(57896044618658097711785492504343953926634992332820282019728792003956564819968)
91-
```
82+
On top of that, Echidna supports two modes of testing complex contracts. Firstly, one can [describe an initialization procedure with Truffle and Etheno](https://github.com/crytic/building-secure-contracts/blob/master/program-analysis/echidna/end-to-end-testing.md) and use that as the base state for Echidna. Secondly, echidna can call into any contract with a known ABI by passing in the corresponding solidity source in the CLI. Use `multi-abi: true` in your config to turn this on.
83+
84+
### Crash course on Echidna
85+
86+
Our [Building Secure Smart Contracts](https://github.com/crytic/building-secure-contracts/tree/master/program-analysis/echidna#echidna-tutorial) repository contains a crash course on Echidna, including examples, lessons and exercises.
9287

93-
Echidna supports two modes of testing complex contracts. Firstly, one can [describe an initialization procedure with Truffle and Etheno](https://github.com/crytic/building-secure-contracts/blob/master/program-analysis/echidna/end-to-end-testing.md) and use that as the base state for Echidna. Secondly, echidna can call into any contract with a known ABI by passing in the corresponding solidity source in the CLI. Use `multi-abi: true` in your config to turn this on.
88+
### Using Echidna in a GitHub Actions workflow
89+
90+
There is an Echidna action which can be used to run `echidna-test` as part of a
91+
GitHub Actions workflow. Please refer to the
92+
[crytic/echidna-action](https://github.com/crytic/echidna-action) repository for
93+
usage instructions and examples.
9494

9595
### Configuration options
9696

@@ -104,7 +104,7 @@ $ echidna-test contract.sol --contract TEST --config config.yaml
104104
The configuration file allows users to choose EVM and test generation
105105
parameters. An example of a complete and annotated config file with the default
106106
options can be found at
107-
[examples/solidity/basic/default.yaml](examples/solidity/basic/default.yaml).
107+
[tests/solidity/basic/default.yaml](examples/solidity/basic/default.yaml).
108108
More detailed documentation on the configuration options is available in our
109109
[wiki](https://github.com/trailofbits/echidna/wiki/Config).
110110

@@ -145,13 +145,6 @@ subject to change to be slightly more user friendly at a later date. `testType`
145145
will either be `property` or `assertion`, and `status` always takes on either
146146
`fuzzing`, `shrinking`, `solved`, `passed`, or `error`.
147147

148-
### Using Echidna in a GitHub Actions workflow
149-
150-
There is an Echidna action which can be used to run `echidna-test` as part of a
151-
GitHub Actions workflow. Please refer to the
152-
[crytic/echidna-action](https://github.com/crytic/echidna-action) repository for
153-
usage instructions and examples.
154-
155148
### Debugging Performance Problems
156149

157150
The best way to deal with an Echidna performance issue is to run `echidna-test` with profiling on.
@@ -167,23 +160,14 @@ Performance issues in the past have been because of functions getting called rep
167160
and memory leaks related to Haskell's lazy evaluation;
168161
checking for these would be a good place to start.
169162

170-
### Crash course on Echidna
171-
172-
Our [Building Secure Smart Contracts](https://github.com/crytic/building-secure-contracts/tree/master/program-analysis/echidna#echidna-tutorial) repository contains a crash course on Echidna, including examples, lessons and exercises.
173-
174163
## Limitations and known issues
175164

176165
EVM emulation and testing is hard. Echidna has a number of limitations in the latest release. Some of these are inherited from [hevm](https://github.com/dapphub/dapptools/tree/master/src/hevm) while some are results from design/performance decisions or simply bugs in our code. We list them here including their corresponding issue and the status ("wont fix", "in review", "fixed"). Issues that are "fixed" are expected to be included in the next Echidna release.
177166

178167
| Description | Issue | Status |
179168
| :--- | :---: | :---: |
180-
| Debug information can be insufficient | [#656](https://github.com/crytic/echidna/issues/656) | *[in review for 2.0](https://github.com/crytic/echidna/pull/674)* |
181169
| Vyper support is limited | [#652](https://github.com/crytic/echidna/issues/652) | *wont fix* |
182170
| Limited library support for testing | [#651](https://github.com/crytic/echidna/issues/651) | *wont fix* |
183-
| If the contract is not properly linked, Echidna will crash | [#514](https://github.com/crytic/echidna/issues/514) | *in review* |
184-
| Assertions are not detected in internal transactions | [#601](https://github.com/crytic/echidna/issues/601) | *[in review for 2.0](https://github.com/crytic/echidna/pull/674)* |
185-
| Assertions are not detected in solc 0.8.x | [#669](https://github.com/crytic/echidna/issues/669) | *[in review for 2.0](https://github.com/crytic/echidna/pull/674)* |
186-
| Value generation can fail in multi-abi mode, since the function hash is not precise enough | [#579](https://github.com/crytic/echidna/issues/579) | *[in review for 2.0](https://github.com/crytic/echidna/pull/674)*|
187171

188172
## Installation
189173

@@ -291,10 +275,10 @@ We can also use Echidna to reproduce research examples from smart contract fuzzi
291275

292276
| Source | Code
293277
|--|--
294-
[Using automatic analysis tools with MakerDAO contracts](https://forum.openzeppelin.com/t/using-automatic-analysis-tools-with-makerdao-contracts/1021) | [SimpleDSChief](https://github.com/crytic/echidna/blob/master/examples/solidity/research/vera_dschief.sol)
295-
[Integer precision bug in Sigma Prime](https://github.com/b-mueller/sabre#example-2-integer-precision-bug) | [VerifyFunWithNumbers](https://github.com/crytic/echidna/blob/master/examples/solidity/research/solcfuzz_funwithnumbers.sol)
296-
[Learning to Fuzz from Symbolic Execution with Application to Smart Contracts](https://files.sri.inf.ethz.ch/website/papers/ccs19-ilf.pdf) | [Crowdsale](https://github.com/crytic/echidna/blob/master/examples/solidity/research/ilf_crowdsale.sol)
297-
[Harvey: A Greybox Fuzzer for Smart Contracts](https://arxiv.org/abs/1905.06944) | [Foo](https://github.com/crytic/echidna/blob/master/examples/solidity/research/harvey_foo.sol), [Baz](https://github.com/crytic/echidna/blob/master/examples/solidity/research/harvey_baz.sol)
278+
[Using automatic analysis tools with MakerDAO contracts](https://forum.openzeppelin.com/t/using-automatic-analysis-tools-with-makerdao-contracts/1021) | [SimpleDSChief](https://github.com/crytic/echidna/blob/master/tests/solidity/research/vera_dschief.sol)
279+
[Integer precision bug in Sigma Prime](https://github.com/b-mueller/sabre#example-2-integer-precision-bug) | [VerifyFunWithNumbers](https://github.com/crytic/echidna/blob/master/tests/solidity/research/solcfuzz_funwithnumbers.sol)
280+
[Learning to Fuzz from Symbolic Execution with Application to Smart Contracts](https://files.sri.inf.ethz.ch/website/papers/ccs19-ilf.pdf) | [Crowdsale](https://github.com/crytic/echidna/blob/master/tests/solidity/research/ilf_crowdsale.sol)
281+
[Harvey: A Greybox Fuzzer for Smart Contracts](https://arxiv.org/abs/1905.06944) | [Foo](https://github.com/crytic/echidna/blob/master/test/solidity/research/harvey_foo.sol), [Baz](https://github.com/crytic/echidna/blob/master/tests/solidity/research/harvey_baz.sol)
298282

299283
### Academic Publications
300284

@@ -310,9 +294,7 @@ If you are using Echidna for academic work, consider applying to the [Crytic $10
310294

311295
Feel free to stop by our #ethereum slack channel in [Empire Hacking](https://empireslacking.herokuapp.com/) for help using or extending Echidna.
312296

313-
* Get started by reviewing these simple [Echidna invariants](examples/solidity/basic/flags.sol)
314-
315-
* Review the [Solidity examples](examples/solidity) directory for more extensive Echidna use cases
297+
* Get started by reviewing these simple [Echidna invariants](tests/solidity/basic/flags.sol)
316298

317299
* Considering [emailing](mailto:[email protected]) the Echidna development team directly for more detailed questions
318300

examples/api/revert/Revert.hs

-17
This file was deleted.

examples/api/state-machine/StateMachine.hs

-84
This file was deleted.

examples/api/state-machine/turnstile.sol

-18
This file was deleted.

examples/api/state-machine/turnstile_badinit.sol

-18
This file was deleted.

examples/api/state-machine/turnstile_nolock.sol

-17
This file was deleted.

examples/api/state-machine/turnstile_nounlock.sol

-18
This file was deleted.

examples/solidity/basic/assert.yaml

-1
This file was deleted.

examples/solidity/basic/benchmark.yaml

-2
This file was deleted.

examples/solidity/basic/push_long.yaml

-1
This file was deleted.

examples/solidity/basic/whitelist_asserts.yaml

-3
This file was deleted.

examples/solidity/basic_multicontract/LICENSE

-22
This file was deleted.

0 commit comments

Comments
 (0)