8000 GitHub - evmts/zevm: Embeddable Zig Ethereum execution and light-client node (Voltaire + Guillotine Mini) with C ABI, Node-API, WASM, and Lean 4 formal spec · GitHub
[go: up one dir, main page]

Skip to content
evmtsPublic

About

Embeddable Zig Ethereum execution and light-client node (Voltaire + Guillotine Mini) with C ABI, Node-API, WASM, and Lean 4 formal spec

Topics

Resources

Code of conduct

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

ZEVM

ZEVM is an Ethereum execution client written in Zig. One native core runs as a CLI node, a Node.js addon, a browser WebAssembly module, a C library, and a Zig library.

                         zevm core (Zig)
   ┌─────────────┬──────────────┬──────────────┬─────────────┐
   │  zevm CLI   │ @evmts/zevm  │ @evmts/zevm  │ libzevm     │
   │  (binary)   │ Node addon   │ browser wasm │ C ABI / Zig │
   └─────────────┴──────────────┴──────────────┴─────────────┘

It has two runtime modes:

Mode What it is Chain data comes from
trusted (default) A writable execution node: local dev chain, fork of an upstream RPC, or a full node driven by the Engine API and devp2p Its own execution of every block
light A consensus-anchored client that verifies execution reads with Merkle proofs A beacon API and an execution RPC that it does not trust

Forking is trusted-mode configuration, not a third mode.

Status

ZEVM is version 0.1.0 and under active development. Read this table before you depend on it.

Area What is validated today What is not
EVM and state transition Full Guillotine is the default 64-bit native EVM backend (guillotine-mini stays default for 32-bit/WASM and opcode-level inspector tracing). 37,724 / 37,724 (100.00%) Ethereum GeneralStateTests pass across Cancun (19,732/19,732) and Prague (17,992/17,992); see tools/latest_fork_state_baseline.json and Latest Fork State Tests. Blockchain, transaction, difficulty, EOF, trie, RLP, and ABI fixture suites run under zig build verify Osaka state fixtures are not in the gate yet
Dev node and JSON-RPC Unit, integration, and fuzz suites; Hive ethereum/rpc-compat smoke; WebSocket eth_subscribe in both trusted and light modes; past-block eth_call/eth_estimateGas/eth_createAccessList
Engine API Unit, fuzz, and cross-client sealed-payload consensus tests against Reth, Geth, and Nethermind; P2P ancestor backfill on unknown parents The Hive engine and consensus simulators are not wired into CI
devp2p (discv4, RLPx, eth/68, snap/1) Protocol test vectors, multi-peer coordinated header/body/receipt downloader, snap/1 serving + client + trie healing, --snap and --fork-policy, and multi-peer loopback sync + transaction-gossip tests Not validated against public-network peers; live snap/1 state adoption into StateManager awaits address-keyed import
--network mainnet|sepolia|hoodi presets Embedded hash-verified genesis blocks, fork IDs, blob schedules, and bootnode lists checked against well-known values in tests Syncing a public network end to end is not validated
--datadir persistence Pure-Zig crash-safe ordered LSM KV store (<datadir>/kv/) with WAL+SSTable crash-injection tests, reverse changesets, history index (--history-retention, default 10,064 blocks), automatic v1→v2 migration, and O(diff) Engine FCU persistence (0 blocks lost across cold restart) Live world state is still hydrated into Voltaire's in-memory StateManager; larger-than-RAM on-disk trie paging is not yet implemented
Light mode Proof and consensus verification unit and fuzz tests, eth_subscribe (newHeads, logs), eth_feeHistory, multi-endpoint fallback (up to 8 URLs), exponential-backoff auto-recovery, checkpoint persistence, and Node + headless Chromium WASM smoke

Install

Node.js and browsers: npm

npm install @evmts/zevm
import { NativeNode } from '@evmts/zevm'

const node = new NativeNode({ chain_id: 31337 })
try {
  console.log(node.rpc('{"jsonrpc":"2.0","id":1,"method":"eth_chainId"}'))
} finally {
  node.close()
}

The package loads a prebuilt Node-API addon for 11 platforms (macOS, Linux glibc and musl, FreeBSD, Windows) and needs Node 22.12.0 or newer. It does not install the zevm CLI. In a browser, the same runtime loads as WebAssembly:

import { createWasmBackend } from '@evmts/zevm/browser'

const backend = await createWasmBackend()
const response = backend.rpc(JSON.stringify({
  jsonrpc: '2.0', id: 1, method: 'eth_call',
  params: [{ data: '0x602a60005260206000f3' }, 'latest'],
}))
backend.close()

createWasmLightClient runs the light client in the browser. The API is in npm/zevm/README.md.

Browser WASM artifact Raw Gzip -9 Brotli -11 WebAssembly.compile
zevm-light.wasm (light-only reactor) 1,085,203 B (1.03 MiB) 451,905 B (441.3 KiB) 361,646 B (353.2 KiB) 1.35 ms
zevm.wasm (trusted + light reactor) 1,874,353 B (1.79 MiB) 762,872 B (745.0 KiB) 596,047 B (582.1 KiB) 2.08 ms

Measured with tools/measure_artifacts.mjs and npm/zevm/scripts/browser-bench.mjs (Binaryen v123 -Oz, verify-only KZG setup, 32 KiB secp256k1 table).

CLI: build from source

There are no prebuilt CLI binaries, Docker images, or installers yet. Building takes one command and needs Zig 0.15.2, Rust/Cargo, and jj (Jujutsu):

jj git clone https://github.com/evmts/zevm.git
cd zevm
bash tools/build.sh
./zig-out/bin/zevm --version

tools/build.sh clones the three pinned native dependencies (voltaire, guillotine, and guillotine-mini) with jj into the untracked .deps/ directory at the commits pinned in native-dependencies.json, then runs zig build (64-bit native builds default to full Guillotine; pass -Devm-backend=guillotine-mini to select the mini interpreter). No sibling checkout is needed, and none is read or modified. Arguments go to zig build:

bash tools/build.sh -Doptimize=ReleaseFast

The steps, the maintainer override for building against your own dependency checkout, and release artifacts are in Installation and CONTRIBUTING.md.

Run

Local dev node

./zig-out/bin/zevm

This serves JSON-RPC on 127.0.0.1:8545 with chain id 31337, 10 funded dev accounts, and a block mined for each transaction.

curl -s -X POST -H 'content-type: application/json' \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' \
  http://127.0.0.1:8545
Goal Flags
Mine on a timer --mining interval --block-time 12
Mine only on request --mining manual
Keep the chain across restarts --datadir ./data
Start from a Geth-style genesis file --genesis genesis.json
Read every flag --help

anvil_*, hardhat_*, evm_*, and zevm_* dev methods are served only while the RPC host is loopback and the Engine API listener is off.

Fork an upstream chain

./zig-out/bin/zevm --fork-url "$RPC_URL" --fork-block-number 21000000

Missing state is read from the upstream RPC; writes and mining stay local. Add --fork-follow to move the fork base to each new upstream head and replay local transactions on top. --datadir cannot be combined with forking.

Full node

./zig-out/bin/zevm --network sepolia --datadir ./sepolia \
  --engine-port 8551 --authrpc.jwtsecret ./jwt.hex \
  --p2p-port 30303
Flag Effect
--network mainnet|sepolia|hoodi Sets the chain id, the hash-verified genesis block, the hardfork and blob schedule, the fork ID, and the default bootnodes
--engine-port, --engine-host, --authrpc.jwtsecret Opens the Engine API listener for a consensus client. JWT (HS256) is required; without a secret file ZEVM creates one at .zevm/jwtsecret
--p2p-port, --bootnodes, --max-peers, --snap, --fork-policy Turns on devp2p: discv4 discovery, RLPx, eth/68 multi-peer block sync + tx gossip, snap/1 state sync/serving, and Engine ancestor backfill. P2P is off unless one of these is set
--datadir, --history-retention Persists state, canonical blocks, receipts, and reverse changesets in a crash-safe pure-Zig LSM KV store (<datadir>/kv/) and serves past-block reads without genesis replay

Public-network sync is not validated yet; see Status. Custom networks use --chain-id with --genesis and explicit --bootnodes.

Light client

./zig-out/bin/zevm --mode light --network mainnet \
  --consensus-rpc-url "$BEACON_API_URL" \
  --execution-rpc-url "$EXECUTION_RPC_URL"

Light mode follows the beacon chain's sync committee from a checkpoint, then answers eth_getBalance, eth_getCode, eth_getStorageAt, eth_call, eth_getLogs, and the other supported reads only after verifying proofs against a consensus-verified state root. It relays eth_sendRawTransaction and serves no dev methods. Networks: mainnet, sepolia, holesky, hoodi. See Run Light Mode.

What It Serves

Surface Details
HTTP JSON-RPC POST /, batches up to 256 requests. No TLS and no authentication on this port: keep --host on loopback or put a proxy in front
WebSocket Same port as HTTP. eth_subscribe supports newHeads, logs, and newPendingTransactions in trusted mode, and newHeads + logs in light mode
eth_* Reads, filters, eth_getProof, eth_feeHistory, eth_simulateV1, eth_createAccessList, raw and managed-wallet transaction submission
Tracing debug_traceTransaction, debug_traceBlockByNumber, and debug_traceBlockByHash with the struct logger or callTracer; debug_traceCall with the struct logger; debug_getRaw*. No prestateTracer, JavaScript tracers, or trace_*
Dev controls anvil_*, hardhat_*, evm_*, and zevm_*: impersonation, snapshots, state overrides, time travel, mining control, runtime fork reset
txpool_*, net_*, web3_*, admin_nodeInfo Pool inspection, peer count, client version, node identity
Engine API engine_newPayloadV1-V5, engine_forkchoiceUpdatedV1-V4, engine_getPayloadV1-V6, payload bodies, blobs, and capability exchange, on a separate JWT-authenticated port
Hardforks Frontier through Osaka, including the EIP-7892 blob-parameter schedule

The exact method list, parameters, and error codes are in docs/specs/json-rpc-contract.md. Method Support By Mode shows which mode serves what. There is no IPC transport.

Performance

3-round consensus-verified cross-client Engine API + JSON-RPC benchmarks (2026-12-03/04, Apple Silicon arm64, 16 CPUs, load average 7.0–11.5, Linux Docker vs Docker) are published with full raw samples, min-max spreads, and methodology in bench/cross-client/results/2026-12-03-ship/report.md and bench/cross-client/README.md.

On-Disk Engine API & Cold Restart (20k accounts / 20k ERC-20 holders, Docker-to-Docker medians)

Workload / Metric ZEVM (docker, on-disk) ZEVM (native ReleaseFast) Reth (docker) Reth-durable (docker) Geth (docker) Nethermind (docker)
erc20_500tx_warm (newPayload / NP+FCU) 1,944 / 1,122 MGas/s 2,418 / 1,091 MGas/s 1,118 / 1,005 MGas/s 860 / 768 MGas/s 921 / 681 MGas/s 340 / 333 MGas/s
prestate_accounts_1000tx (newPayload / NP+FCU) 1,796 / 859 MGas/s 2,096 / 874 MGas/s 763 / 705 MGas/s 622 / 598 MGas/s 516 / 474 MGas/s 333 / 327 MGas/s
prestate_erc20_500tx (newPayload / NP+FCU) 1,715 / 857 MGas/s 2,196 / 876 MGas/s 1,173 / 1,041 MGas/s 630 / 551 MGas/s 524 / 471 MGas/s 347 / 339 MGas/s
cold_erc20_500tx post-restart (newPayload / NP+FCU) 1,602 / 784 MGas/s 2,049 / 847 MGas/s 1,143 / 1,022 MGas/s 690 / 628 MGas/s 587 / 518 MGas/s 302 / 289 MGas/s
storage_cold_1200slots (newPayload) 6,896 MGas/s 8,195 MGas/s 4,209 MGas/s 3,735 MGas/s 1,781 MGas/s 1,384 MGas/s
Cold restart ready / graceful stop / blocks lost 334 ms / 258 ms / 0 128 ms / 98 ms / 0 455 ms / 2,442 ms / 0 646 ms / 3,585 ms / 0 468 ms / 1,533 ms / 0 4,857 ms / 473 ms / 0
On-disk data size at stop 8.4 MiB 8.4 MiB 8.9 MiB 9.0 MiB 290.1 MiB 11.4 MiB

On-Disk Concurrent JSON-RPC (8 keep-alive connections, Docker-to-Docker medians)

Method ZEVM (docker, on-disk) ZEVM (native ReleaseFast) Reth (docker) Nethermind (docker) Geth (docker)
eth_chainId 36,652 RPS (204 µs) 113,207 RPS (65 µs) 22,380 RPS 18,755 RPS 22,921 RPS
eth_getBalance 36,335 RPS (208 µs) 110,653 RPS (67 µs) 17,818 RPS 19,454 RPS 22,018 RPS
eth_call_erc20_balanceOf 31,606 RPS (238 µs) 55,239 RPS (82 µs) 17,416 RPS 12,371 RPS 18,528 RPS
eth_getBlockByNumber (500-tx block) 28,172 RPS (270 µs) 55,589 RPS (111 µs) 12,613 RPS 17,924 RPS 8,520 RPS
eth_getLogs_erc20 (1,500 logs) 598 RPS (11.7 ms) 595 RPS (11.8 ms) 273 RPS 424 RPS 122 RPS

Caveats: ZEVM's --datadir LSM KV store fsyncs every commit and loses 0 blocks on cold restart, but hydrates live state into Voltaire's in-memory StateManager rather than paging an on-disk trie (so larger-than-RAM prestates are not yet tested). On heavy precompile stress blocks (ecrecover, modexp, bn254mul), multi-core Reth prewarming (reth) runs faster than single-threaded ZEVM, while ZEVM matches or beats single-threaded reth-serial (141 vs 141 MGas/s on ecrecover_4k; 231 vs 152 on modexp256_5k; 229 vs 149 on bn254mul_2k). On pure EVM execution (zig build bench-evm-guillotine-vs-mini -Doptimize=ReleaseFast), default full Guillotine runs snailtracer in 22.83 ms (10.34 GGas/s) vs guillotine-mini's 31.40 ms, sload_sstore_64 in 8.76 µs (6.29 GGas/s) (6.1× faster than mini), and CLI cold start takes 2.45 ms (1.87 MB RSS; 6.40 ms boot-to-RPC, 4.26 MB idle RSS).

Embed It

Target Entry point
Node.js NativeNode and LightClient from @evmts/zevm
Browser createWasmBackend and createWasmLightClient from @evmts/zevm/browser
C include/zevm.h; zig build c-ffi writes libzevm.a, a shared library, and the header under zig-out/
Zig src/root.zig: Node, DefaultNode, and in-process execution extensions (src/exex.zig)

Documentation

The docs are authored under docs/ and published at https://zevm.sh/docs. Start with:

If implementation, tests, or public docs diverge from the two specs, treat the mismatch as release-blocking unless the behavior is explicitly moved to deferred or out-of-contract docs.

After editing docs/, run node tools/docs_mirror.mjs --write and node tools/generate_llms_txt.mjs --write. To build the site locally, use Node.js 22.23.4 or later and run npm ci followed by npm run build from docs/.

Contributing

bash tools/build.sh test
npm --prefix npm/zevm install --ignore-scripts
zig build verify-fast
zig build fuzz -Doptimize=ReleaseSafe
zig build c-smoke
zig build npm-smoke

ZEVM has 50 native std.testing.fuzz targets across consensus, EVM execution, state and MPT proofs, KZG blobs, JSON-RPC, the Engine API, the light client, and config, CLI, and genesis parsing, plus C ABI fuzz targets under zig build fuzz-c-abi:

zig build fuzz -Dfuzz-filter="rpc"
./tools/fuzz_ubuntu.sh --list
./tools/fuzz_ubuntu.sh --optimize ReleaseSafe --seconds 30 --jobs 8

Coverage-guided --fuzz runs on Linux; tools/fuzz_ubuntu.sh syncs the checkout to a Linux host from macOS.

Behavior changes are docs-first: update docs/specs/prd.md and docs/specs/json-rpc-contract.md before landing code that changes startup, runtime modes, JSON-RPC behavior, release metadata, the C ABI, or npm distribution. The process is in docs/specs/docs-first-process.md.

See CONTRIBUTING.md for the local workflow, native dependency handling, release gates, C ABI, and npm package notes, and the submodule update policy for the fixture inputs zig build verify needs.

npm release

Run gh workflow run release.yml --ref main to build all 11 platform addons and the browser WASM, validate their tarballs, and test installation. The workflow retains the 12 tarballs as the npm-tarballs artifact. To publish, dispatch with -f publish=true or push the matching version tag (for this release, v0.1.0) at the tip of main. Publication requires successful CI on that commit and uploads the platform packages first.

Configure the npm trusted publisher on each package for evmts/zevm, workflow release.yml, environment npm. For bootstrap, the environment can supply an npm granular publish token as NPM_TOKEN. The publisher checks registry integrity before resuming a partial publication.

License

MIT

About

Embeddable Zig Ethereum execution and light-client node (Voltaire + Guillotine Mini) with C ABI, Node-API, WASM, and Lean 4 formal spec

Topics

Resources

Code of conduct

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0