Skip to content

Commit

Permalink
Update examples in README.md (#14) and always use ./bin/echidna for…
Browse files Browse the repository at this point in the history
… fork mode (#15) (#19)

* Update prog name and desc for argparse

* Update examples in README.md (#14)

* Minor linting, testing tweaks (#1)

* Black

* Pylint

* Fix typo

* Update when linters are run

* Fix failing super linter run on push
`DEFAULT_BRANCH` set to  `${{ github.base_ref || github.ref_name }} `
so it uses the base branch name for PRs and the branch itself (main/dev) for the rest

* Only run `test_diffusc_path_run_mode` for 10 minutes

* Update block number in `test_few_token_holders`

* Update examples in README.md

---------

Co-authored-by: William E Bodell III <[email protected]>

* Always use `./bin/echidna` in run mode

* Remove line re: copying `./bin/echidna` to `/usr/local/bin`

---------

Co-authored-by: Rappie <[email protected]>
  • Loading branch information
webthethird and rappie authored Jul 31, 2023
1 parent 40376a7 commit f2f9f4b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ git clone https://github.com/crytic/diffusc.git
cd diffusc
pip3 install .
```
You will also need copy the Echidna binary from `./bin/echidna` to `/usr/local/bin` (or wherever Windows expects to find the binary) in order to fuzz with the auto-generated test contracts.

## Running Diffusc
The minimum required arguments for running Diffusc are two contracts, provided as either file paths or addresses:
Expand All @@ -82,11 +81,11 @@ echidna DiffFuzzUpgrades.sol --contract DiffFuzzUpgrades --config CryticConfig.y
```
Or you can provide additional arguments for more effective testing:
```bash
diffusc ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV1.sol ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV2.sol -d ./contracts/test/compound/ -t ./contracts/implementation/compound/compound-0.8.10/CErc20.sol,./contracts/implementation/compound/compound-0.8.10/CompHarness.sol -p ./contracts/implementation/compound/compound-0.8.10/Unitroller.sol -u -v 0.8.10 --run-custom ./contracts/test/compound/DiffFuzzCustomInit.sol DiffFuzzCustomInit
diffusc ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV1.sol ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV2.sol -d ./contracts/test/compound/ -t ./contracts/implementation/compound/compound-0.8.10/CErc20.sol,./contracts/implementation/compound/compound-0.8.10/CompHarness.sol -p ./contracts/implementation/compound/compound-0.8.10/Unitroller.sol -u -V 0.8.10 --run-custom ./contracts/test/compound/DiffFuzzCustomInit.sol DiffFuzzCustomInit
```
Similarly, to test fuzzing Compound in fork mode, try:
```bash
diffusc 0x75442Ac771a7243433e033F3F8EaB2631e22938f 0x374ABb8cE19A73f2c4EFAd642bda76c797f19233 -t 0x12392F67bdf24faE0AF363c24aC620a2f67DAd86:0xa035b9e130f2b1aedc733eefb1c67ba4c503491f,0xc00e94Cb662C3520282E6f5717214004A7f26888 -p 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B -u -v 0.8.10 -T --token-holder 0x309d413391e975B553B7B8D19bC11F8a6c2eB889 -r
diffusc 0x75442Ac771a7243433e033F3F8EaB2631e22938f 0x374ABb8cE19A73f2c4EFAd642bda76c797f19233 -t 0x12392F67bdf24faE0AF363c24aC620a2f67DAd86:0xa035b9e130f2b1aedc733eefb1c67ba4c503491f,0xc00e94Cb662C3520282E6f5717214004A7f26888 -p 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B -u -V 0.8.10 -T --token-holder 0x309d413391e975B553B7B8D19bC11F8a6c2eB889 -r
```

### Command Line Arguments
Expand Down
7 changes: 6 additions & 1 deletion diffusc/core/echidna.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
import json
import shutil
from pathlib import Path
from io import UnsupportedOperation
from os import mkdir
from subprocess import Popen, PIPE
Expand All @@ -10,6 +11,9 @@
from diffusc.utils.crytic_print import CryticPrint


ECHIDNA_BIN_PATH = Path(__file__).resolve().parent.parent.parent / "bin" / "echidna"


def create_echidna_process(
prefix: str, filename: str, contract: str, config: str, extra_args: List[str]
) -> Popen:
Expand All @@ -18,7 +22,8 @@ def create_echidna_process(
except OSError:
pass

call = ["echidna"]
path_to_echidna_from_prefix = os.path.relpath(ECHIDNA_BIN_PATH, prefix)
call = [path_to_echidna_from_prefix]
call.extend([filename])
call.extend(["--config", config])
call.extend(["--contract", contract])
Expand Down
4 changes: 2 additions & 2 deletions diffusc/diffusc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def main(_args: Optional[Sequence[str]] = None) -> int:
# Read command line arguments

parser = argparse.ArgumentParser(
prog="diff-fuzz-upgrades",
description="Generate differential fuzz testing contract for comparing two upgradeable contract versions.",
prog="diffusc",
description="Differential fuzzing w/ static taint analysis for comparing two upgradeable contract versions.",
)

parser.add_argument("v1", help="The original version of the contract.")
Expand Down

0 comments on commit f2f9f4b

Please sign in to comment.