Skip to content

paradigmxyz/revmc

Repository files navigation

revmc

Experimental JIT and AOT compiler for the Ethereum Virtual Machine.

The compiler implementation is abstracted over an intermediate representation backend. It performs very well, as demonstrated below from our criterion benchmarks, and exposes an intuitive API via Revm.

image

This repository hosts two backend implementations:

  • LLVM (revmc-llvm): main backend with full test coverage;
  • Cranelift (revmc-cranelift); currently not functional due to missing i256 support in Cranelift. This will likely require a custom fork of Cranelift.

Requirements

  • Latest stable Rust version

LLVM backend

  • Linux or macOS, Windows is not supported
  • LLVM 21
    • On Debian-based Linux distros: see apt.llvm.org
    • On Arch-based Linux distros: pacman -S llvm
    • On macOS: brew install llvm@21
    • The following environment variables may be required:
      prefix=$(llvm-config --prefix)
      # or
      #prefix=$(llvm-config-21 --prefix)
      # on macOS:
      #prefix=$(brew --prefix llvm@21)
      export LLVM_SYS_211_PREFIX=$prefix

Usage

The compiler is implemented as a library and can be used as such through the revmc crate.

A minimal runtime is required to run AOT-compiled bytecodes. A default runtime implementation is provided through symbols exported in the revmc-builtins crate and must be exported in the final binary. This can be achieved with the following build script:

fn main() {
    revmc_build::emit();
}

You can check out the examples directory for example usage.

Testing

The Ethereum state tests are included as a git submodule. The submodule is configured with update = none so it won't be cloned automatically.

To check it out:

git submodule update --init --checkout --depth 1 tests/ethereum-tests

Then run the state tests:

# All three modes (interpreter baseline, JIT, AOT):
cargo nextest run -p revmc -E 'test(statetest::)'

# A specific mode:
cargo nextest run -p revmc -E 'test(statetest::jit)'

# A specific test subdirectory:
SUBDIR=stSelfBalance cargo nextest run -p revmc -E 'test(statetest::jit)'

Credits

The initial compiler implementation was inspired by paradigmxyz/jitevm.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

JIT and AOT compiler for the Ethereum Virtual Machine, built on Revm.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages