leansol

A Solana client written in Lean, compiled by its own compiler.

leansol joins Solana's gossip network and checks the signature on every record it hears. It is written in Lean 4 and turned into machine code by leanc, a compiler in the same repository that needs no libc, no LLVM and no linker. Its processes talk through shared memory and a single futex.

leansol · mainnet CONNECTING
nodes in gossip
—
chain tip
—
signatures verified
— 
bad signatures
—
7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00  · the ELF header leanc writes, byte by byte
188 KBthe whole client, one static binary
40 msto build it from source
0dependencies to build or run
—this node's uptime
Liverefreshed every 2 seconds from a node running around the clock

Mainnet, as this node sees it

Every figure here comes from gossip records whose Ed25519 signature the node verified itself, with code written in Lean. Nothing is read from an RPC provider.

Validator clients

The software each node says it runs.

Versions

The ten most common releases.

Records accepted

Signed gossip records, by type.

The node

Separate processes, shared memory, one futex each.

identity
—
cluster
—
verifying
—
receiving
—
sending
—
records held
—
pings answered
—

Node explorer

Every node this one holds a verified contact record for.

IdentityClientVersionGossip addressLatest snapshot slot
How it worksthree pieces, all in one repository

A compiler, an IPC layer, and a client built on both

leanc: Lean in, ELF out

Reads Lean 4 source and writes the bytes of a static x86-64 executable itself: instruction encodings, jump fix-ups, ELF headers. No C is generated and no toolchain runs. Reference counting gives immutable Lean values in-place updates.

-- Lean
(x >>> n) ||| (x <<< (32 - n))
-- what leanc emits for rotr e 6
mov rax, [rbp-80]
ror eax, 6

IPC on a raw futex

Processes pass messages through lock-free rings in shared memory. Sending is a memory copy and one atomic add. The kernel is involved only when the receiver is asleep, and then through a single futex wake.

producer
lock xadd  head += 1
if sleeping: futex_wake
consumer
xchg  sleeping := 1
if empty:   futex_wait

Tiles: one job per process

Receiving, verifying, protocol logic and sending each run as their own process. Only records that passed verification ever reach the process holding the node's key.

socket ─▶ net-rx ─▶ verify × N
                        │
socket ◀─ net-tx ◀─── gossip
every arrow between processes is a ring
Capabilitieswhat works today

What it does

Joins gossip on mainnet, testnet and devnet

Resolves an entrypoint with its own DNS resolver, learns the cluster's shred version, and starts pulling records.

Verifies every signature

Strict Ed25519, the rules validators apply, written in Lean. About 2,900 checks per second per core.

Reads every record type

Knows the wire layout of all 14 gossip record types, so it can find where each record ends and who signed it.

Proves it owns its address

Answers the ping challenges peers send with signed pongs, as the protocol requires before anyone replies.

Exports what it learns

A JSON snapshot of every node, a JSON file that stays fresh, and Prometheus metrics over HTTP.

Keeps a stable identity

An optional key file makes a long-running node the same node after a restart.

Compiles other programs

leanc is a general compiler for its subset of Lean. Hello world is four system calls, start to finish.

Agrees with official Lean

The official toolchain type-checks every file, and must match leanc on every test program's output.

Builds reproducibly

The published binary and a build on your machine have the same SHA-256.

Survives hostile input

The parsers are bounds-checked and fuzzed with 16,000 random and corrupted records on every commit.

Limitswhere the line is

What it is not

Not a validator

It does not download blocks, replay transactions or vote. It observes and verifies the gossip plane.

Listen-only

It answers pings but does not yet serve or push records to other nodes.

x86-64 Linux

The code generator and the system-call numbers are specific to it.

A subset of Lean

No type classes, lambdas or polymorphism. The compiler does not check proofs; official Lean does that.

Roadmapintentions, not dates

From observing the network to following the chain

Each step moves the client closer to checking the ledger itself instead of listening to what other nodes say about it. For writing on-chain programs in Lean, see toly's lean-svm, which compiles Lean 4 to sBPF. This project is the other side: the node.

Shipped

  • Lean → x86-64 compilerStatic executables with no toolchain behind them.
  • Futex-backed IPCLock-free rings between processes.
  • Gossip clientFull signature verification on mainnet.
  • JSON and Prometheus exportThe cluster as data.
  • A public nodeRunning around the clock, feeding this page.

Later

  • Repair and TurbineReceive shreds and rebuild blocks.
  • Ledger verificationCheck proof of history and block signatures.
  • Run on-chain programsAn sBPF virtual machine in the client, to replay transactions.
  • Machine-checked proofsProve the wire parsers never read out of bounds.
Get itLinux on x86-64

Run it in three commands

Download

curl -LO https://github.com/MidTermDev/lean-Solana-client/releases/latest/download/leansol-x86_64-linux
chmod +x leansol-x86_64-linux
./leansol-x86_64-linux

Or build from source

git clone https://github.com/MidTermDev/lean-Solana-client
cd lean-Solana-client
make && ./build/leansol   # no compiler needed