|
1 | 1 | # Exercise 7 |
2 | 2 |
|
3 | | -**Table of contents:** |
| 3 | +**Table of Contents:** |
4 | 4 |
|
5 | 5 | - [Exercise 7](#exercise-7) |
6 | 6 | - [Setup](#setup) |
| 7 | + - [Context](#context) |
7 | 8 | - [Goals](#goals) |
| 9 | + - [Hints](#hints) |
8 | 10 | - [Solution](#solution) |
9 | 11 |
|
10 | 12 | Join the team on Slack at: https://slack.empirehacking.nyc/ #ethereum |
11 | 13 |
|
12 | 14 | ## Setup |
13 | 15 |
|
14 | 16 | 1. Clone the repository: `git clone https://github.com/crytic/damn-vulnerable-defi-echidna` |
15 | | -2. Install dependencies using `yarn install`. |
16 | | -3. Analyze the `before` function in `test/side-entrance/side-entrance.challenge.js` to determine the initial setup requirements. |
17 | | -4. Create a contract to be used for property testing with Echidna. |
| 17 | +2. Install the dependencies via `yarn install`. |
18 | 18 |
|
19 | | -No skeleton will be provided for this exercise. |
| 19 | +## Context |
| 20 | + |
| 21 | +The challenge is described here: https://www.damnvulnerabledefi.xyz/challenges/4.html. We assume that the reader is familiar with it. |
20 | 22 |
|
21 | 23 | ## Goals |
22 | 24 |
|
23 | 25 | - Set up the testing environment with appropriate contracts and necessary balances. |
| 26 | +- Analyze the `before` function in `test/side-entrance/side-entrance.challenge.js` to determine the initial setup requirements. |
24 | 27 | - Add a property to check if the balance of the `SideEntranceLenderPool` contract has changed. |
25 | 28 | - Create a `config.yaml` with the required configuration option(s). |
26 | 29 | - After Echidna discovers the bug, fix the issue and test your property with Echidna again. |
27 | 30 |
|
28 | | -Hint: To become familiar with the workings of the target contract, try manually executing a flash loan. |
| 31 | +Only the following contracts are relevant: |
| 32 | + |
| 33 | +- `contracts/side-entrance/SideEntranceLenderPool.sol` |
| 34 | + |
| 35 | +## Hints |
| 36 | + |
| 37 | +We recommend trying without reading the following hints first. The hints are in the [`hints` branch](https://github.com/crytic/damn-vulnerable-defi-echidna/tree/hints). |
| 38 | + |
| 39 | +- The invariant you are looking for is "the balance of the pool contract cannot change." |
| 40 | +- To become familiar with the workings of the target contract, try manually executing a flash loan. |
| 41 | +- Read about the [allContracts option](../basic/common-testing-approaches.md#external-testing). |
| 42 | +- A template is provided in [contracts/side-entrance/SideEntranceEchidna.sol](https://github.com/crytic/damn-vulnerable-defi-echidna/blob/hints/contracts/side-entrance/SideEntranceEchidna.sol). |
| 43 | +- A config file is provided in [side-entrance.yaml](https://github.com/crytic/damn-vulnerable-defi-echidna/blob/hints/side-entrance.yaml). |
29 | 44 |
|
30 | 45 | ## Solution |
31 | 46 |
|
32 | | -The solution can be found in [solution.sol](https://github.com/crytic/building-secure-contracts/tree/master/program-analysis/echidna/exercises/exercise7/solution.sol). |
| 47 | +This solution can be found in the [`solutions` branch](https://github.com/crytic/damn-vulnerable-defi-echidna/blob/solutions/contracts/side-entrance/SideEntranceEchidna.sol). |
33 | 48 |
|
34 | 49 | [ctf]: https://www.damnvulnerabledefi.xyz/ |
35 | 50 |
|
|
0 commit comments