revm

revm is a high-performance Ethereum Virtual Machine (EVM) written in Rust. Designed with an emphasis on speed and simplicity, revm provides a fast and flexible EVM implementation, featuring a simple interface and an embedded Host. It successfully passes all the ethereum/tests test suites, ensuring compatibility and reliability.

Guiding Principles

revm adheres to several core principles:

  • EVM Compatibility and Stability: Ensuring stability is paramount in the blockchain industry.
  • Speed: Optimization for high performance, with most decisions aimed at enhancing speed.
  • Simplicity: Simplified internals for easier understanding and extension, and an interface that integrates seamlessly into other projects.
  • Interfacing: [no_std] compliance, enabling use as a WebAssembly (wasm) library and integration with JavaScript and C++ bindings if needed.

Project Structure

The revm project is organized into several crates and binaries:

  • Crates:
    • revm: The main EVM library.
    • revm-primitives: Contains primitive data types.
    • revm-interpreter: Houses the execution loop and instructions.
    • revm-precompile: Manages EVM precompiles.
  • Binaries:
    • revme: A CLI binary used for running state test JSONs.

Building from Source

To build revm from source, follow these steps:

  1. Clone the repository:

    git clone https://github.com/bluealloy/revm.git
    cd revm
  2. Build the project:

    cargo build --release

Note: clang is required for building revm with c-kzg or secp256k1 feature flags due to dependencies on C libraries. Install it via apt install clang if not already installed.

Running Ethereum Tests

  1. Navigate to the revme directory:

    cd bins/revme/
  2. Download Ethereum tests:

    git clone https://github.com/ethereum/tests
  3. Run the tests:

    cargo run --release -- statetest tests/GeneralStateTests/ tests/LegacyTests/Constantinople/GeneralStateTests

Running Benchmarks

Benchmarks for revm can be found in crates/revm/benches. To run the snailtracer benchmark:

cargo bench --package revm --profile release -- snailtracer

To generate a flame graph for visualizing the runtime of various sections:

cargo flamegraph --root --freq 4000 --min-width 0.001 --package revm --bench bench -- snailtracer

Note: Install flamegraph via cargo install flamegraph if not already installed.

Running Examples

To run an example, such as fork_ref_transact:

cargo run -p revm --features ethersdb --example fork_ref_transact

To generate block traces and write them to JSON files:

cargo run -p revm --features std,serde-json,ethersdb --example generate_block_traces

Used By

revm is utilized by several prominent projects, including:

  • Foundry: A toolkit for Ethereum application development.
  • Helios: An efficient Ethereum light client.
  • Reth: A fast implementation of the Ethereum protocol.
  • Arbiter: A framework for stateful Ethereum smart-contract simulation.
  • Zeth: An open-source ZK block prover for Ethereum.
  • VERBS: An Ethereum agent-based modeling and simulation library.
  • Hardhat: A development environment for Ethereum software.
  • Trin: A Portal Network client providing execution archival access.
  • Simular: A Python smart-contract API with an embedded EVM.

Documentation

The revm documentation is available online at revm docs. To serve the documentation locally:

mdbook serve documentation

Similar Projects

Rustfinity.com

Links

  1. Home
  2. Learn Rust
  3. Get Started
  4. Practice Rust
  5. Challenges
  6. Tutorials
  7. Blog
  8. Open source
  9. Learn Gleam

Socials

  1. GitHub
  2. X

Legal

  1. Privacy Policy
  2. Terms of Service