A DeFi project.
Prefer working inside the provided devcontainer instead of installing toolchains and running commands directly on your host machine.
This is important for security: a devcontainer is not bulletproof, and Docker is not a true sandbox, but isolating dependencies and execution from your main OS environment can still reduce the attack surface and lower the impact of a compromised dependency, script, or tool.
Available configurations:
.devcontainer/mounted/devcontainer.json: mounts the local repository into the container workspace.devcontainer/unmounted/devcontainer.json: copies the workspace into a Docker volume instead of mounting it from the host
The unmounted option is generally the safer default because it reduces direct host filesystem exposure. The mounted option is more convenient when you explicitly want a live bind mount from the host.
In VS Code:
- Install the
Dev Containersextension if it is not already installed. - Run
Dev Containers: Open Folder in Container.... - Choose either
.devcontainer/unmounted/devcontainer.jsonor.devcontainer/mounted/devcontainer.json. - After the container starts, run dependency installation and project commands inside the container terminal.
If you only need one recommendation, prefer .devcontainer/unmounted/devcontainer.json over local installation and local execution.
yarn install && forge installEach time a new dependency is added in lib/ run forge install.
Follow's Solidstate architecture (diamond pattern based).
| folder | layer | description | example |
|---|---|---|---|
| - | internal - interface |
contains custom error, enum, struct& event |
IRandomnessWritableInternal.sol, IRandomnessReadableInternal.sol |
| - | external - interface |
common interfaces which define external and public function's prototypes | IRandomnessFallback.sol, IRandomnessReadble.sol, IRandomnessWritable.sol |
| readable | external | set of functions which only read the storage | RandomnessReadable.sol |
| writable | external & internal | set of functions which update storage; internal function always declares in xyzWritableInternal.sol & contains modifier |
RandomnessInternalWritable.sol, RandomnessWritable.sol |
| ./ | storage | library for to map, access and modify storage | RandomnessStorage.sol |
- Run without fuzz testing, use
forge test -vvv
If lcov is not installed, run brew install lcov.
Then run: forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage
TBD
- Install act
- Load env var
source .env - Run a job:
act -j foundry -s SEED(hit ENTER when askedProvide value for 'SEED':)
slither .
Note: Slither has been added to GitHub actions, so it will run automatically on every push and pull requests.
myth a src/Vault.sol --solc-json mythril.config.json (you can use both myth a and mythril analyze)
- Run Docker container:
docker run --rm -it --platform linux/amd64 \
-v $(pwd):/home/vault \
baolean/manticore:latest
-
Go to mounted volume location:
cd /home/vault -
Select Solidity version
solc-select install 0.8.17 && solc-select use 0.8.17
- Run manticore:
manticore src/Vault.sol --contract Vault --solc-remaps="openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/"
After install yarn dependencies, run yarn sumo test to run mutation testing.
Note: there are issues when forge needs to compile with --ffi
-
Install it locally, see GitHub
-
Run:
gambit mutate --json gambit-conf.json
Note: gambit does not take into account specified remappings
- Code formatter & linter: prettier, solhint, husky, lint-staged & husky
- Foundry
- Solidity Patterns
- Solcurity Codes
- Secureum posts (101 & 101: Security Pitfalls & Best Practice)
- Smart Contract Security Verification Standard
- SWC
Must Do Checklist:
- Unit (TDD) & integration (BDD) tests (green)
- Well refactored & commented code
- Internal Audit - Tool Suite
- Secureum articles
- Built in Foundry:
- fuzz testing: generate (semi-)random inputs
- There is also echidna which can be used
- differential testing
- invariant testing
- fuzz testing: generate (semi-)random inputs
- Static analysers: mythril, slither (GitHub actions), securify, smartcheck, oyente
- Note: solidity smt checker can be used on top for formal verification testing
- Symbolic execution: manticore
- Mutation testing: SuMo, Gambit, universalmutator
- Audit report generator: MythX
Note: For more complex contract Paper code review should be considered to check for conception & logic errors.
Other tools for a deeper analysis:
- static binary EVM analysis: rattle
- control flow graph: surya (integrated into VSCode extension), evm_cfg_builder
- disassemble EVM code: ethersplay, pyevmasm
- runtime verification: scribble (also done by: mythril, harvey, mythx)
- JSON RPC multiplexer, analysis tool wrapper & test integration tool: etheno (Ethereum testing Swiss Army knife)
- eliminates the complexity of tools like Echidna on large, multi-contract projects
TBD
beta-* is forked off dev and merged into rc-* (once integratoin issues fixed). rc-* is merged into main (once audit fixes are done).
beta-*branches contain fixes found during frontend/backend integrations, updated ABIs & new testnet addressesrc-*branches contain audit fixes, audit report and mainnet addressesmainbranch freeze latestrc-*