import React from 'react' /** * Shared SVG wrapper for crisp, responsive, theme-aware diagrams. * Uses Vocs CSS variables so diagrams adapt cleanly between light and dark modes. */ function DiagramFrame({ title, caption, viewBox, children }) { return (
{title &&
{title}
}
{children}
{caption &&
{caption}
}
) } /** * 1. Full TEVM + ZEVM + Voltaire + Guillotine Mini layered architecture diagram. */ export function ArchitectureDiagram() { return ( {/* Layer 1: Consumers */} HOST CONSUMERS Viem / App / Vitest Ethers (TevmProvider) Browser (HTTP / WS) AI Agents (@tevm/mcp) {/* Arrows down to Layer 2 */} {/* Layer 2: JS Host Surfaces */} MemoryClient (@tevm/memory-client) viem public · wallet · test (Anvil) · tevm* actions createMemoryClient() · createTevmTransport() RPC Servers (@tevm/server) HTTP · WebSocket subscriptions · Unix IPC · Express · Next.js createServer() · createIpcServer() · createHttpClient() {/* Arrows to ZevmEngine */} {/* Layer 3: ZevmEngine / Node-API boundary */} ZevmEngine (@tevm/node) — Node-API / C ABI Boundary request() · rpc(json) · events (request, response, block, close) · ready() · close() Serialized Queue {/* Divider line JS vs Native */} NATIVE ZIG ENGINE {/* Layer 4: Native Zig Components */} ZEVM NodeRuntime & RPC dispatcher Chain, mempool, mining, filters Snapshots & fork backend Voltaire Account & storage state Ethereum primitives & RLP Cryptography & precompiles Guillotine Mini Native EVM bytecode interpreter Gas accounting & hardforks debug_traceCall opcode tracer {/* Bidirectional connectors between Zig modules */} ) } /** * 2. Simulation vs Pending Mempool vs Mined Canonical Block. */ export function ExecutionFlowDiagram() { return ( {/* Row 1: Simulate */} tevmCall(params) default: read-only eth_call optional stateOverride Discard state chain untouched {'{ rawData }'} no txHash {/* Row 2: Queue to mempool */} addToMempool: true manual mining mode eth_sendTransaction queued in txpool Pending (unmined) receipt is null until mine {'{ txHash }'} call tevmMine() {/* Row 3: Add to blockchain */} addToBlockchain: true or auto mining (default) Send + evm_mine mines if unmined Canonical block state committed {'{ txHash,'} {' receipt }'} ) } /** * 3. Mining Modes timeline diagram. */ export function MiningModesDiagram() { return ( {/* Auto */} 1. Auto (default) mining: {'{ auto: true }'} tx1 → Block #1 tx2 → Block #2 tx3 → Block #3 {/* Manual */} 2. Manual mining: {'{ auto: false }'} tx1 queued tx2 queued tevmMine() → Block #1 [tx1, tx2] {/* Interval */} 3. Interval (Zig thread) mining: {'{ auto: false, interval: 2 }'} t = 2s · Block #1 t = 4s · Block #2 t = 6s · Block #3 Always call client.tevmClose() (or engine.close()) to stop interval timers and release native handles. ) } /** * 4. ZEVM Fork Overlay & Lazy Read-Through Cache diagram. */ export function ForkOverlayDiagram() { return ( {/* Local Process Box */} LOCAL NODE.JS PROCESS (HEIGHT STARTS AT 0) {/* Read / Write caller */} Your Client reads & writes tevmSetAccount tevmCall / mine {/* Local Overlay */} 1. Local Write Overlay Accounts, code, storage, mined blocks Checked first on every read · Never sent upstream {/* Cache */} 2. Lazy Read-Through Cache Miss? Fetch once at pinned blockNumber Hit? Served locally at native speed {/* Arrows inside local */} write read {/* Remote Upstream Box */} SEPARATE PROCESS / RPC Upstream JSON-RPC Mainnet, Optimism, Base, or a separate local server eth_getBalance / Code eth_getStorageAt Sync HTTP in native code: do not fork a server on the same JS event loop. {/* Arrow across process boundary */} cache miss ) } /** * 5. Snapshots vs Dump/Load State diagram. */ export function StateRollbackDiagram() { return ( {/* Left: Snapshot/Revert */} In-Process Rewind (snapshot / revert) Same engine · Instant · Reverts blocks, time, and accounts Baseline id = 0x1 Mutate txs / edits Assert read state {/* Curved arrow back */} revert({'{ id }'}) Note: reverting consumes snapshot id; take a fresh snapshot for the next test. {/* Right: Dump/Load */} Portable State Blob (dumpState / loadState) Across engines or disk · ZEVM opaque hex blob Engine A tevmDumpState() 0x... hex blob Engine B tevmLoadState() Format is ZEVM v2 binary-in-hex — not a JSON account map. Save to disk or pass between worker processes. ) } /** * 6. Server Transports diagram (HTTP, WS, IPC, Express, Next.js). */ export function ServerTransportsDiagram() { return ( {/* Clients on left */} Browser dApp (viem) http() / webSocket() Remote Node / CLI createHttpClient() Local Process / Foundry /tmp/tevm.sock Express / Next.js Route middleware / handler {/* Transport adapters middle */} createServer(client) HTTP POST · batches · notifications WebSocket · eth_subscribe newHeads · logs · pendingTxs createIpcServer(client) newline-delimited JSON stream createHttpHandler(client) Express & Next.js adapters {/* Arrows left -> middle */} {/* Single Engine right */} Shared Client ZevmEngine One chain state Native filters Serialized queue {/* Arrows middle -> right */} ) } /** * 7. Bundler Pipeline diagram. */ export function BundlerPipelineDiagram() { return ( Counter.sol Local files node_modules/ Foundry remappings Tevm Bundler Vite · Rollup · esbuild Webpack · Rspack · Bun solc + module cache @tevm/ts-plugin (IDE) Contract Module Counter.abi Counter.bytecode Counter.read.* Counter.write.* Counter.deploy() Your Code tevmDeploy() readContract() ) } /** * 8. Native Tracing Pipeline diagram (debug_traceCall). */ export function TracePipelineDiagram() { return ( debug_traceCall call object + blockTag enableMemory: true enableReturnData: true disableStack / Storage Guillotine Mini Tracer Snapshots before each opcode: pc · op · gas · gasCost · depth stack[] · memory[] · returnData Cap: 100,000 steps Trace Payload gas: 21018 failed: false returnValue: "0x...2a" truncated: false structLogs: [...] ) } /** * 9. MCP Server Session Architecture diagram. */ export function McpLoopDiagram() { return ( AI Coding Agent Claude, Cursor, Codex, Antigravity MCP over stdio @tevm/mcp Server 14 Zod-validated EVM tools evm_create_session / fork evm_compile / deploy / call evm_mine / trace_call SessionManager (TTL cleanup) Session A (local · 31337) isolated ZevmEngine Session B (fork · mainnet) isolated ZevmEngine solc Compiler evm_compile_solidity ) }