Skip to content
LogoLogo
guillotine · mini

A readable EVM,
written in Zig

One Evm type, one call() entry point, hardforks from Frontier through Osaka, EIP-3155 tracing, a flat C ABI, and a WASI Preview 1 WebAssembly reactor with linked crypto precompiles.

$

zig build test-trace && zig build wasm && zig build test-wasm

const std = @import("std");
const guillotine = @import("guillotine_mini");
const voltaire = @import("voltaire");
 
pub fn main() !void {
    const Evm = guillotine.Evm(.{});
    var vm: Evm = undefined;
    try vm.init(std.heap.page_allocator, null, .CANCUN, null, voltaire.ZERO_ADDRESS, 0, null);
    defer vm.deinit();
 
    // PUSH1 0x2a  PUSH1 0x00  MSTORE  PUSH1 0x20  PUSH1 0x00  RETURN
    const target = voltaire.Address.fromU256(0x42);
    try vm.code.put(target, &.{ 0x60, 0x2a, 0x60, 0x00, 0x52, 0x60, 0x20, 0x60, 0x00, 0xF3 });
 
    const result = vm.call(.{ .call = .{
        .caller = voltaire.ZERO_ADDRESS,
        .to = target,
        .value = 0,
        .input = &.{},
        .gas = 100_000,
    } });
    // result.success == true, result.gas_left == 99_982 (18 gas used), output == 32-byte word 0x2a
}

Why Guillotine Mini exists

Production EVMs optimize for block throughput: bytecode is fused into superinstructions, gas is hoisted across basic blocks, and the correspondence to the specification disappears. That is the right trade for a mainnet node and the wrong trade when you need to verify what the Ethereum specification actually requires.

Guillotine Mini takes the opposite side:

  • Spec-first. The Python execution-specs are the authority. Gas is charged in the same order, in the same place.
  • Small enough to read in an afternoon. State orchestration lives in src/evm.zig; the bytecode loop lives in src/frame.zig; external state crosses an 11-pointer vtable in src/host.zig.
  • Three delivery surfaces. Use it as a Zig module, link libguillotine_mini.a over C FFI, or instantiate guillotine_mini.wasm (a WASI Preview 1 reactor with BN254, BLS12-381, SHA256, and KZG compiled in).
  • Zero hidden ownership. Transaction-scoped allocations live in an arena owned by Evm and are released together in deinit().
Guillotine Mini — Three-Layer Execution Architecturesrc/*.zig
vm.call(CallParams) / root_c.zigEvm(config) · src/evm.zig — Transaction OrchestratorArenaAllocator (freed on deinit)Storagepersistent · originaltransient (EIP-1153)AccessListManagerwarm/cold addresseswarm/cold slots (2929)Snapshot Stacksbalances · nonces · codecopy-on-write rollbackNested Calls & Logsinner_call · inner_creategas_refund · Tracerframes stack (depth ≤ 1024)optional vtable (host != null)Frame(config) · src/frame.zig — Bytecode InterpreterStack1024 × u256Memorybyte-addressed · 32BBytecodeJUMPDEST bitmapHostInterface · src/host.zigget/setBalance · get/setCodeget/setStorage · get/setNonceaccountExists? · deleteAccount?Voltaire (@import("voltaire") · "crypto" · "precompiles")Address · Hardfork · GasConstants · RLP · Log · Keccak256 · secp256k1 · BN254 · BLS12-381 · KZG · P256VERIFY
Evm owns transaction-scoped state and nested call orchestration. Frame is a pure bytecode interpreter operating on stack, memory, and PC. HostInterface is an optional vtable for external state.

Choose your path

Getting Started

Wire up Zig 0.15.2 + Voltaire, execute your first bytecode, and account for every unit of gas.

Hands-On Tutorials

Visual walkthroughs for contract calls, snapshots, custom hosts, and WebAssembly — complete with puzzles and traces.

WebAssembly (WASI)

Run the EVM and linked crypto precompiles from Node 22+ with zero npm dependencies.

C ABI & Async FFI

Embed libguillotine_mini.a from C, Rust, Go, or Python — including yield/resume external state injection.

EIP-3155 Tracing

Capture bounded opcode traces, export JSON, and diff step-by-step against Python execution-specs.

API Reference

Exact signatures, defaults, error sets, and build targets transcribed directly from src/*.zig.

What it is not

Guillotine Mini is an execution engine, not a full node. Block headers, transaction signatures, the mempool, JSON-RPC, and devp2p live one layer up in Guillotine. Public APIs are pre-1.0 and may shift between revisions.

Current status

  • Native Zig (0.15.2): zig build, zig build native, and zig build test-trace pass cleanly. Core EVM unit tests pass; the 5 TrieTests fixture tests (client/trie/fixtures.zig) in zig build unit require the optional ethereum-tests submodule.
  • WebAssembly (wasm32-wasi): zig build wasm builds zig-out/bin/guillotine_mini.wasm (WASI Preview 1 reactor with linked Rust crypto), and zig build test-wasm verifies execution, reverts, logs, SHA256, BN254 pairing, and BLS12-381 precompiles on Node 22+.
  • Hardforks: Frontier through Osaka, including EIP-1153 transient storage, EIP-4844 blobs, EIP-6780 SELFDESTRUCT, EIP-7702 set-code delegation, BLS12-381 (0x0B–0x11), Osaka CLZ (0x1E), and P256VERIFY (0x0100).

Part of the Tevm family