0x-r4bbit / dapptools-rs

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 / --from-utf8
    • --to-hex
    • --to-checksum-address
    • --to-ascii
    • --to-bytes32
    • --to-dec
    • --to-fix
    • --to-uint256
    • --to-wei
    • block
    • block-number
    • chain-id
    • age
    • basefee
    • gas-price
    • call (partial)
    • send (partial)
    • balance
    • ens
    • abi encoding
    • 4byte resolution
  • 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.54.0 (a178d0322 2021-07-26).

Building & testing

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

Formatting

cargo +nightly fmt
cargo clippy

Getting Help

First, see if the answer to your question can be found in the API documentation. If the answer is not there, try opening an issue with the question.

Join the turbodapptools telegram to chat with the community!

About

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

License:Apache License 2.0


Languages

Language:Rust 97.7%Language:Solidity 2.3%