diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7b84b99c26..14f39a45b9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,6 +39,7 @@ jobs: - run: yarn install --immutable - run: yarn lint - run: pip3 install solc-select slither-analyzer + - run: pip3 install slitherin - run: solc-select install 0.8.19 - run: solc-select use 0.8.19 - run: yarn slither diff --git a/docs/dev-env.md b/docs/dev-env.md index 40ca0d3368..edd3e822e0 100644 --- a/docs/dev-env.md +++ b/docs/dev-env.md @@ -3,13 +3,14 @@ We're using: - [Hardhat](hardhat.org) to compile, test, and deploy our smart contracts. -- [Slither][] and [Echidna][], from the [Trail of Bits contract security toolkit][tob-suite] for static analysis, fuzz checking, and differential testing. +- [Slither][], [Slitherin][], and [Echidna][], from the [Trail of Bits contract security toolkit][tob-suite] for static analysis, fuzz checking, and differential testing. - [Prettier][] to auto-format both Solidity and Typescript (test) code - [Solhint][] for Solidity linting - [ESlint][] for Typescript linting [echidna]: https://github.com/crytic/echidna [slither]: https://github.com/crytic/slither +[slitherin]: https://github.com/pessimistic-io/slitherin [tob-suite]: https://blog.trailofbits.com/2018/03/23/use-our-suite-of-ethereum-security-tools/ [prettier]: https://prettier.io/ [solhint]: https://protofire.github.io/solhint/ @@ -56,18 +57,24 @@ tenderly login --authentication-method access-key --access-key {your_access_key} ### Slither -You should also setup `slither`. The [Trail of Bits tools][tob-suite] require solc-select. Check [the installation instructions](https://github.com/crytic/solc-select) to ensure you have all prerequisites. Then: +You should also setup `slither` and `slitherin`. The [Trail of Bits tools][tob-suite] require solc-select. Check [the installation instructions](https://github.com/crytic/solc-select) to ensure you have all prerequisites. Then: ```bash # Install solc-select and slither pip3 install solc-select slither-analyzer +# Include slitherin detectors within slither +pip3 install slitherin + # Install and use solc version 0.8.19 solc-select install 0.8.19 solc-select use 0.8.19 # Double-check that your slither version is at least 0.8.3! hash -r && slither --version + +# Slitherin version should be at least 0.7.0 +slitherin --version ``` ## Usage @@ -83,7 +90,7 @@ hash -r && slither --version - Run integration tests: `yarn test:integration` - Run tests and report test coverage: `yarn test:coverage` - Lint Solidity + Typescript code: `yarn lint` -- Run the Slither static checker: `yarn slither` +- Run the Slither static checker: `yarn slither` (will include Slitherin detectors) - Run a local mainnet fork devchain: `yarn devchain` - Deploy to devchain: `yarn deploy:run --network localhost` @@ -107,7 +114,6 @@ We _have_ some tooling for testing with Echidna, but it is specifically in `fuzz See our [deployment documentation](deployment.md). -## Slither Analysis - -The ToB Sliter tool is run on any pull request, and is expected to be checked by devs for any unexpected high or medium issues raised. +## Slither/Slitherin Analysis +The ToB Sliter tool is run on any pull request, and is expected to be checked by devs for any unexpected high or medium issues raised. It also includes the additional Slitherin detectors developed by Pessimistic. diff --git a/docs/solidity-style.md b/docs/solidity-style.md index 1ff39574db..4bec58a300 100644 --- a/docs/solidity-style.md +++ b/docs/solidity-style.md @@ -48,7 +48,7 @@ We're using 192 bits instead of the full 256 bits because it makes typical multi Initial versions of this code were written using the custom type `Fix` everywhere, and `Fixed` contained the line `type Fix is int192`. We found later that: - We had essentially no need for negative `Fix` values, so spending a storage bit on sign, and juggling the possibility of negative values, cost extra gas and harmed the clarity of our code. -- While `solc 0.8.19` allows custom types without any issue, practically all of the other tools we want to use on our Solidity source -- `slither`, `prettier`, `solhint` -- would fail when encountering substantial code using a custom type. +- While `solc 0.8.19` allows custom types without any issue, practically all of the other tools we want to use on our Solidity source -- `slither`, `slitherin`, `prettier`, `solhint` -- would fail when encountering substantial code using a custom type. Reintroducing this custom type should be mostly mechanicanizable, but now that P1 contains a handful of hotspot optimizations that do raw arithmetic internally to eliminate Fixlib calls, it won't be trivial to do so. Still, if and when those tools achieve adequate support for custom types, we will probably do this conversion ourselves, if only to ensure that conversions between the Fix and integer interpretations of uints are carefully type-checked. diff --git a/tools/slither.py b/tools/slither.py index e3e38153a2..d6a26918b8 100644 --- a/tools/slither.py +++ b/tools/slither.py @@ -23,7 +23,7 @@ def proj_root(): if file_orig.exists(): rename(file_orig, file_temp) - # run slither from inside the tools directory + # run slither from inside the tools directory (includes slitherin detectors) args = argv[1:] run(["slither", "../", *args], cwd=project / "tools")