Skip to content

domsteil/dapptools-rs

 
 

Repository files navigation

dapptools.rs

Rust port of DappTools

Github Actions

Why?! DappTools is great!

Developer experience is the #1 thing we should be optimizing for in development. Tests MUST be fast, non-trivial tests (e.g. proptests) MUST be easy to write, compilation MUST be fast.

Before getting into technical reasons, my simple answer is: rewriting software in Rust is fun. I enjoy it, and that could be the end of the "why" section.

DappTools is REALLY great. You should try it, especially the symbolic execution and step debugger features.

But it has some shortcomings:

It's written in a mix of Bash, Javascript and Haskell. In my opinion, this makes it hard to contribute, you don't have a "standard" way to test things, and it happens to be that there are not that many Haskell developers in the Ethereum community.

It is also hard to distribute. It requires installing Nix, and that's a barrier to entry to many already because (for whatever reason) Nix doesn't always install properly the first time.

The more technical reasons I decided to use it are:

  1. It is easier to write regression tests in Rust vs in Bash
  2. Rust binaries are cross-platform and easy to distribute
  3. Compilation speed: We can use native bindings to the Solidity compiler (instead of calling out to solcjs or even to the compiled binary) for extra compilation speed
  4. Testing speed: HEVM tests are really fast, but I believe we can go faster by leveraging Rust's high performance multithreading and resource allocation system.
  5. There seems to be an emerging community of Rust-Ethereum developers

Benchmarks TBD in the future, but:

  1. Using a Rust EVM w/ forked RPC mode was claimed to be as high as 10x faster than HEVM's forking mode.
  2. Native bindings to the Solidity compiler have shown to be 10x faster than the JS bindings or even just calling out to the native binary
  3. seth and dapp are less than 7mb when built with cargo build --release

Features

  • seth
    • --from-ascii
    • --to-hex
    • --to-checksum-address
    • --to-bytes32
    • block
    • call (partial)
    • send (partial)
    • balance
    • ens
  • dapp
    • test
      • simple unit tests
        • Gas costs
        • DappTools style test output
        • JSON test output
        • matching on regex
        • DSTest-style assertions support
      • fuzzing
      • symbolic execution
      • coverage
      • HEVM-style Solidity cheatcodes
      • structured tracing with abi decoding
      • per-line gas profiling
      • forking mode
      • automatic solc selection
    • build
      • can read DappTools-style .sol.json artifacts
      • manual remappings
      • automatic remappings
      • multiple compiler versions
      • incremental compilation
      • can read Hardhat-style artifacts
      • can read Truffle-style artifacts
    • debug
    • CLI Tracing with RUST_LOG=dapp=trace

Tested Against

This repository has been tested against the following DappTools repos: *

Development

Rust Toolchain

We use the stable Rust toolchain. Install by running: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Minimum Supported Rust Version

The current minimum supported Rust version is rustc 1.51.0 (2fd73fabe 2021-03-23).

Building & testing

cargo check cargo test cargo doc --open cargo build [--release] 

Formatting

cargo +nightly fmt cargo clippy 

About

A drop-in replacement for `dapp` and `seth` in Rust

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 97.7%
  • Solidity 2.3%