2 unstable releases

0.1.0 Jun 27, 2024
0.0.0-reserved Jun 19, 2024

#53 in #evm

Download history 15/week @ 2024-08-18 86/week @ 2024-08-25 265/week @ 2024-09-01 87/week @ 2024-09-08 212/week @ 2024-09-15 67/week @ 2024-09-22 42/week @ 2024-09-29 94/week @ 2024-10-06 37/week @ 2024-10-13 184/week @ 2024-10-20 25/week @ 2024-10-27 97/week @ 2024-11-03

354 downloads per month

MIT/Apache

255KB
5.5K SLoC

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 17
    • On Debian-based Linux distros: see apt.llvm.org
    • On Arch-based Linux distros: pacman -S llvm
    • On macOS: brew install llvm@17
    • The following environment variables may be required:
      prefix=$(llvm-config --prefix)
      # or
      #prefix=$(llvm-config-17 --prefix)
      # on macOS:
      #prefix=$(brew --prefix llvm@17)
      export LLVM_SYS_170_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.

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.

Dependencies

~15–26MB
~442K SLoC