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. It also runs on-chain programs: its sBPF virtual machine executes what toly's lean-svm compiles, lets those programs call the real SPL token programs, and applies whole signed transactions.
- nodes in gossip
- —
- chain tip
- —
- signatures verified
- —
- bad signatures
- —
A mainnet validator, running a client written in Lean
This node has a vote account and stake on Solana mainnet. Its BLS key is the one the client derives from its identity, its votes are signed by Lean code, and every block it runs is executed by a virtual machine written in Lean before it is final.
Status
- epoch
- —
- stake
- —
- vote account
- —
Accounts
- vote account
- Ht7wK9ba…ko1Z48t
- identity
- DBzsY3TC…ZNJJeRi
- stake account
- 3oMBbp8S…cvmj2zT
- BLS key
- 7T3E5hCc…D8m5iqM
- commission
- —
- client
- leansol 0.19, gossip client id 19534 ("LN")
Its executor
- latest
- —
- behind the tip
- —
- before final
- —
Its votes
In 1,134 live slots at the tip it voted, in shadow, for the very block mainnet made final 983 times, voted to skip 151 whose block reached it too late, and never chose a wrong block.
All hardware for this validator is funded by $LEAN.
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
- —
Blocks verified
Each block, received as shreds and checked down to every signature.
- verified
- —
- latest
- —
- its leader
- —
- its blockhash
- —
- it held
- —
- in all
- —
- chained
- —
- shreds
- —
- failed a check
- —
- executed
- not on this node yet
Node explorer
Every node this one holds a verified contact record for.
| Identity | Client | Version | Gossip address | Latest snapshot slot |
|---|
A compiler, an IPC layer, a node and a virtual machine
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
sBPF virtual machine
Loads on-chain programs and applies signed transactions to accounts: signatures, fees, compute budgets, programs calling programs, rent, every sysvar. Lean, Pinocchio and Anchor programs run against the unmodified SPL token programs, with results identical to Agave's runtime.
$ leansol run amm.so --data 01… \
--program Token=p_token.so \
--program Token-2022=spl_token_2022.so …
result success
units 4,690 of 200,000
log Instruction: TransferChecked
account vaultA data 412d497f… (changed)
account vaultB data 5a60e8a6… (changed)
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.
Runs on-chain programs
An sBPF virtual machine executes programs compiled by toly's lean-svm, locally, and meters them exactly as Agave does.
Lets programs call programs
Cross-program invocation with derived-address signing. The SPL Token and Token-2022 programs run unmodified; the system program is built in.
Runs Anchor programs
Both calling conventions, C and Rust. An Anchor vault that runs five programs in one instruction prints exactly what Agave's own runtime prints.
Applies whole transactions
Verifies the signatures, charges the fee, honours the compute budget, runs every instruction, enforces rent, and keeps all of it or only the fee.
Provides every sysvar
Clock, rent, epoch schedule, slot hashes and the rest, by system call, by address and as accounts, including a transaction's view of its own instructions.
Runs every sBPF version
v0 through v3: one program compiled four ways gives the same answers at four different costs, each matching Agave.
Deploys and upgrades programs
The program loader, the system program with nonce accounts, and the stake, config and lookup-table programs, as transactions.
Follows the chain
Receives every block over turbine, rebuilds the shreds that do not arrive from the coding shreds, and checks each block and its link to the one before.
Holds mainnet's state
Streams a snapshot from a validator, files all 1.2 billion accounts in a store, and checks them against the lattice hash the snapshot is named after and the supply it records.
Knows whose slot it is
Computes the leader schedule from the stakes in the snapshot, as every validator does, and accepts a block only from the validator scheduled to produce it.
Replays mainnet blocks
Executes a block's transactions against the state, applies its footer, and arrives at the bank hash the leader signed: the hash of every account on the chain.
Executes the chain
From a snapshot, block after block: tens of thousands in a row to the leaders' bank hashes, fetching what it lacks, saving its state as it goes, stopping at the first hash that differs.
Turns an epoch
Stakes warm up and cool down, 1.3 million stake accounts are paid over 522 blocks, validators are admitted, and the next epoch's budget is computed in floating point done in integers. Mainnet's epoch 1099 matched.
Runs programs as machine code
A program that runs often is translated from sBPF into x86-64 by a translator written in Lean. The interpreter stays the definition: 1,500 random programs must come out the same both ways.
Uses vector instructions
The compiler emits AVX-512 and the SHA instructions for operations that are defined in Lean and checked against it; the lattice hash runs BLAKE3 sixteen blocks at a time.
Enforces the account rules
Only an owner changes an account's data or spends its lamports, read-only stays read-only, and lamports are conserved.
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.
What it is not
Not a voting validator
It verifies gossip and every block, holds the state, and executes the chain to the leaders' bank hashes. It checks the validators' BLS signatures but does not make them: it does not vote or produce blocks, which needs the consensus messages and stake.
Listen-only
It answers pings but does not yet serve or push records to other nodes.
It stops when it does not know
Mainnet uses things no test set holds: a dozen of them stopped the executor in its first 47,000 blocks, five more in the next 250,000. It stops at the first bank hash that differs, with its state as last saved, rather than carry on wrong. Feature activations are not followed yet.
The executor is a second process
The node saves the blocks it verifies and the executor reads them. At 0.1 seconds a block it has twice the chain's pace, no more.
Nothing is sent on-chain
Programs execute locally. The client does not build, sign or submit transactions.
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.
From observing the network to executing the chain
Each step moves the client closer to checking the ledger itself instead of listening to what other nodes say about it. On-chain programs are written in Lean with toly's lean-svm, which compiles Lean 4 to sBPF. This project is the other side: the node, and the machine that runs those programs.
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.
- sBPF virtual machineRuns lean-svm programs with Agave's compute-unit counts.
- Programs calling programsLean programs moving tokens through the real SPL token programs.
- Anchor programsThe Rust calling convention, checked line for line against Agave's runtime.
- Whole transactionsSignatures, fees, compute budgets, rent, every sysvar. Twenty transactions, identical to Agave.
- sBPF v0 to v3Every version of the instruction set, compared with Agave 4.
- Built-in programsSystem with nonces, the program loader, stake, config, lookup tables.
- Block verificationReal blocks fetched as shreds: Merkle paths, leader signature, proof of history, every transaction signature.
- Every blockThe turbine feed, Reed–Solomon recovery of missing shreds, and each block linked to its parent.
- SnapshotsZstandard, tar, BLAKE3 and the lattice hash: a snapshot's accounts loaded into a store and verified against its name.
- Mainnet's state1,245,863,525 accounts from a validator's snapshot, every one hashed: the lattice hash and the supply match.
- Leader scheduleComputed from the stakes in the snapshot; every block must be signed by the validator whose slot it is.
- Replay600 mainnet blocks executed against the state: 204,532 transactions, and 600 bank hashes out of 600 equal to the leaders'.
- At the chain's paceThose 600 blocks in 123 seconds (the chain: 120), every signature checked; AVX-512 from the compiler.
- Faster than the chainThe same 600 blocks in 73 seconds: programs translated from sBPF into machine code, by Lean, with the interpreter as the definition.
- Executing the chainFrom a fresh snapshot, block after block: 23,700 in a row between two stops, state saved as it goes, missing blocks fetched from validators.
- The turn of an epochMainnet's epoch 1099: stakes, rewards to a million accounts over 522 blocks, and a budget computed in doubles made of integers. Every hash matched.
- Certificates checkedBLS12-381 in 600 lines of Lean: a block is executed only when a certificate signed by enough of the stake says it is final. 19 ms a check, and the same answers as the validators' own library.
- Speaking to validatorsTLS 1.3 and QUIC in 1,100 lines of Lean: the connection validators vote over, opened with mainnet's own and each side's identity proven. The first piece of voting.
- Vote accounts and the new memory modelThe vote program as mainnet runs it, BLS proofs of possession included, and accounts mapped into a program's memory the way validators now do. 116 transactions, line for line the same as Agave's.
- Confidential transfersThe proof program behind encrypted token balances, all twelve kinds of proof up to Bulletproofs, in 360 lines. Line for line the same as Agave's on 65 transactions.
- Every index proven by Lean's kernelEach of the client's 1,921 array accesses carries a proof that the official Lean toolchain checks with its kernel, and the compiler emits no check for any of them; overflows and missing cases are proven too, and the build refuses code that is not.
- Votes, and when to cast themThe validators' votes and certificates byte for byte as Agave makes them, and Alpenglow's rules for voting as a value of 350 lines: events in, votes out, with a record that survives a restart.
Next
- At the tip, and staying thereThe executor inside the node, feature activations, a log of changes that is trimmed.
- VotingExecute blocks before they are final, send the votes the rules give, and stake behind a vote account.
- Full gossip participantServe pull requests and push records, not only listen.
- Record ageingExpire old records one by one instead of flushing the store.
- Self-hostingleanc rewritten in Lean, compiling itself.
- A second architectureAn aarch64 backend.
Later
- Producing blocksLead a slot: take transactions, build the block, send its shreds.
- Machine-checked proofsProve the wire parsers never read out of bounds.
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
A token funds the work
This token on Solana is used to raise funds for development and for creating full validators on this client.
B2HU7PEkoKmhkMhfZa5tFN3YJdwLeLq6Fg85saoo111