verified builds · Solana programs in Lean

Verified, for programs written in Lean.

Solscan and the Solana Explorer mark a program verified when its public source rebuilds into exactly the bytes on chain. On its own, the verifier only builds Rust. Lean Verify rebuilds Lean programs with the official toolchain, checks their proofs on the way, and earns them the same mark.

Lean AMM · mainnetOtterSec's verifier, live
Checking…
Program
AMXwyCL9aEBrbEWdMEi1ro89VCwPhNrQPdeRkGCf9n8E
Source
–
Hash
–
Checked
–
01 · how

Three steps to the mark.

From your program's repository, with Docker. The image's tag is the Lean version in your lean-toolchain; it holds that release of Lean, downloaded from its GitHub release and checked against its SHA-256.

alias lean-verify='docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/build" ghcr.io/midtermdev/lean-verify:4.36.0'
1 · init

Say how it builds

Writes verify/: your build command, which puts the program in $OUT, and the two Cargo files the verifier looks for, with no Rust in them. Start it with lake build and every proof is checked first.

lean-verify init my_program 'lake build && lake exe lean-svm build My.Program My.entrypoint -o "$OUT"'
2 · check

Compare with the chain

Builds in the image and compares the result with the program on chain, the way the verifier will. When they match, commit verify/ and push; it prints the two commands for the last step.

lean-verify check <PROGRAM>
3 · publish

Let the verifier see

As the program's upgrade authority, with the solana-verify CLI: record the build on chain (a few thousandths of a SOL of rent), then ask OtterSec's verifier to repeat it. A minute or two later, it's verified.

solana-verify verify-from-repo … --base-image ghcr.io/midtermdev/lean-verify@…
solana-verify remote submit-job …
02 · check

Is it verified?

Any program's address. This asks OtterSec's verifier, which Solscan and the Solana Explorer read, and shows what it compared.

Try .

03 · what it means

One claim, made exactly.

The verifier, solana-verify, rebuilds a program in a Docker image and only knows how to run cargo build-sbf. In the Lean Verify image, that command is your build.sh, run with Lean's own toolchain. The image is built in public, by GitHub Actions, from verify/.

exactly this code

The bytes on chain are the repository

Built from the commit the record names, in an image pinned by its digest, the program is byte for byte the one on chain. Anyone can run the same build and see.

proofs, tied down

A proof that fails, a build that doesn't

When the build starts with lake build, Lean checks every theorem before it compiles anything. A failing proof leaves no program to match, so the program on chain is the code the proofs are about. Lean AMM is verified this way.

not an audit

What it does not say

The mark says nothing about whether the code is right. Proofs say what their statements say; read which ones a program has, and what they leave out.