On this page:
evm-redex:   An Executable EVM Specification in PLT Redex
9.3

evm-redex: An Executable EVM Specification in PLT Redex🔗

rodrigo

This document describes the library and its public interface. For a quick-start and installation, see the repository "README.md". The tutorial, worked examples, test suites, and conformance corpora live under the package’s "tests/" directory and are documented in The evm-redex test suite: tutorial, tests, and examples.

evm-redex is an executable specification of the Ethereum Virtual Machine, written in PLT Redex and Racket. It models the EVM as a formal small-step semantics — a Redex reduction relation over an explicit machine / world / transaction grammar — and runs that semantics directly against the official Ethereum test vectors (ethereum/tests / EEST), from which it derives its structure alongside ethereum/execution-specs.

The default target hard fork is Prague, and the semantics is multi-fork (Frontier through Prague). The project is designed to be read and tested: every opcode, gas rule, and precompile is an inspectable rewrite rule or metafunction, and conformance is established by computing real post-state roots and log hashes and comparing them against the reference fixtures.

The library’s public interface is three modules: (require evm-redex) — the whole specification (grammar, interpreter, world and transaction machinery, fork gates, precompiles); (require evm-redex/pbt) — the property-based testing DSL, documented in full below; and (require evm-redex/crypto) — the curve and field primitives. Nothing else is public: "private/" is an implementation detail and should never be imported directly.

New here? Start with the step-by-step tutorial that writes, compiles, and tests a small Solidity contract: Tutorial: testing Solidity contracts with evm-redex (English) / Tutorial: testando contratos Solidity com evm-redex (português).

The worked examples and the test suites live under "tests/" and are documented in The evm-redex test suite: tutorial, tests, and examples.

The library also ships two languages: #lang evm-redex/asm, whose source is an EVM program in assembly (#lang evm-redex/asm — writing and running EVM assembly), and #lang evm-redex/sim, a transaction-scenario language that submits transactions against an evolving chain and reports receipts, traces, and a state diff (#lang evm-redex/sim — simulating transactions).

    1 #lang evm-redex/asm — writing and running EVM assembly

      1.1 A first program

      1.2 The assembly dialect

      1.3 Using the result from other modules

      1.4 The programmatic API

    2 #lang evm-redex/sim — simulating transactions

      2.1 A first scenario

      2.2 The scenario language

        2.2.1 Setup directives

        2.2.2 Actions

      2.3 The four observations

        2.3.1 Receipt (with decoded logs and revert reasons)

        2.3.2 Call trace

        2.3.3 Step trace

        2.3.4 State diff and root

      2.4 The engine API

    3 Library reference: the property-based testing DSL

      3.1 Defining properties

      3.2 Running properties

      3.3 Worlds, accounts, and transactions

      3.4 Deploying contracts

      3.5 Solidity artifacts and the ABI

      3.6 Calling into a world

      3.7 Lower-level execution

      3.8 Observation vocabulary

        3.8.1 Machine fields

        3.8.2 Stack

        3.8.3 Outcome

        3.8.4 Return data and memory

        3.8.5 World, accounts, and storage

        3.8.6 Constants

      3.9 Generators

      3.10 Running the DSL’s own tests

    4 Tracing hook

    5 Repository layout