Skip to content

Commit d9bcafa

Browse files
docs: refresh READMEs (#585)
* add readme * fix * fix readmes * udpate lookup.md * add wip note * rm print as syscall on readme * fix: add missing clang/lld dependency, surface --blowup default in CLI - Add clang + lld (with RISC-V target) to README dependencies section so users don't fail at `make compile-programs-asm` - Add `default_value = "2"` to --blowup in both prove and verify subcommands so `--help` shows the default - Fix verify --time help text ("Print verification time" not "timing breakdown") - Match [default: 2] style in bin/cli/README.md tables --------- Co-authored-by: MauroFab <maurotoscano2@gmail.com>
1 parent c4711f8 commit d9bcafa

11 files changed

Lines changed: 458 additions & 138 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Right now, this is a project under development and experimentation and must not
1111
### Dependencies
1212

1313
- Rust nightly with `rust-src` component
14+
- Clang with RISC-V target support and LLD linker (used by `make compile-programs-asm`)
15+
- **macOS**: `brew install llvm` (the Homebrew LLVM includes `clang` and `lld` with RISC-V support)
16+
- **Linux**: `apt install clang lld` (or equivalent for your distribution)
1417

1518
### Dev dependencies
1619

@@ -26,11 +29,10 @@ Install Rust using [rustup](https://rustup.rs/):
2629
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2730
```
2831

29-
Then install the nightly toolchain with the `rust-src` component (required for building `std` for the custom RISC-V target):
32+
Add the `rust-src` component to the pinned nightly toolchain used to build guest programs (required for building `std` for the custom RISC-V target`make compile-programs-rust` will auto-fetch the toolchain itself):
3033

3134
```sh
32-
rustup toolchain install nightly
33-
rustup component add rust-src --toolchain nightly
35+
rustup component add rust-src --toolchain nightly-2026-02-01
3436
```
3537

3638
#### Compile sysroot
@@ -44,7 +46,7 @@ wget https://lambda.alignedlayer.com/lambda-vm-sysroot-rv64im.tar.gz
4446
sudo mkdir -p /opt && sudo tar -xzf lambda-vm-sysroot-rv64im.tar.gz -C /opt
4547
```
4648

47-
##### Compile it directly
49+
##### Compile them directly
4850

4951
```sh
5052
sudo apt-get install -y autoconf automake autotools-dev curl python3 \
@@ -65,20 +67,62 @@ sudo mkdir -p /opt && sudo tar -xzf lambda-vm-sysroot-rv64im.tar.gz -C /opt
6567
cp -r /opt/riscv64-newlib/riscv64-unknown-elf/lib /opt/lambda-vm-sysroot/
6668
```
6769

68-
#### Install the dependencies
70+
Then, you can check that the executor works by running:
6971

7072
```sh
71-
make deps
73+
make test-executor
7274
```
7375

74-
**Note:** At the moment, `make deps` only works on macOS.
76+
### Using the CLI
7577

76-
Then, you can check that the executor works by running:
78+
The `cli` binary lets you execute, prove, and verify RISC-V ELF programs. Build it once with:
7779

7880
```sh
79-
make test-executor
81+
cargo build --release -p cli
8082
```
8183

84+
The binary will be available at `target/release/cli`.
85+
86+
To get a sample program to work with, compile the bundled assembly tests:
87+
88+
```sh
89+
make compile-programs-asm
90+
```
91+
92+
This emits ELF files under `executor/program_artifacts/asm/`. With those in place, you can run the three core commands:
93+
94+
#### Execute
95+
96+
Run a program without generating a proof. Useful for sanity checks and debugging:
97+
98+
```sh
99+
cargo run -p cli --release -- execute executor/program_artifacts/asm/add.elf
100+
```
101+
102+
#### Prove
103+
104+
Generate a STARK proof of the execution:
105+
106+
```sh
107+
cargo run -p cli --release -- prove executor/program_artifacts/asm/add.elf -o /tmp/proof.bin
108+
```
109+
110+
#### Verify
111+
112+
Verify a proof against the ELF it was generated from. The command exits `0` on success and `1` on failure:
113+
114+
```sh
115+
cargo run -p cli --release -- verify /tmp/proof.bin executor/program_artifacts/asm/add.elf
116+
```
117+
118+
For the full CLI reference — including private inputs, blowup factor tuning, timing, and flamegraph profiling — see [`bin/cli/README.md`](./bin/cli/README.md).
119+
120+
### Writing a guest program
121+
122+
Guest programs are written in Rust (or RISC-V assembly) and cross-compiled to the custom RV64IM target. The guest SDK [`lambda-vm-syscalls`](./syscalls/README.md) provides the syscalls a program uses to read private input, commit public output, halt, and call precompiles like Keccak. The [`executor`](./executor/README.md) crate is what loads your compiled ELF and emits the per-instruction logs the prover consumes.
123+
124+
To add a new Rust guest, drop a project under `executor/programs/rust/<name>/` and run `make compile-programs-rust`. See [`executor/programs/rust/`](./executor/programs/rust/) for examples (`fibonacci`, `keccak`, `hashmap`, …).
125+
82126
## Design choices
83127

84128
- The Instruction Set Architecture is RISCV64IM
@@ -98,7 +142,18 @@ Following [ethrex](https://github.com/lambdaclass/ethrex):
98142

99143
## Documentation
100144

101-
Full documentation can be found in [docs](./docs/). It is currently a work in progress, we expect that as more features and components become ready, they will be included in the docs.
145+
High-level documentation lives in [`docs/`](./docs/):
146+
147+
- [Overview of VM flow](./docs/general_flow.md) — the pipeline from source code to proof
148+
- [Proof system overview](./docs/cryptography/proof_system.md) — design goals and primitives
149+
- [Lookup arguments](./docs/cryptography/lookup.md) — how tables are linked via LogUp
150+
- [Recommended reading](./docs/other_resources.md) — papers and tutorials
151+
152+
### Specification
153+
154+
A formal specification of the VM is written in [Typst](https://typst.app/) under [`spec/`](./spec/) and rendered as a browsable wiki (HTML) or PDF using [`shiroa`](https://myriad-dreamin.github.io/shiroa/). With both tools installed, run `shiroa serve` from `spec/` to host the wiki locally.
155+
156+
See [`spec/README.md`](./spec/README.md) for full setup instructions.
102157

103158
## Testing
104159

@@ -114,6 +169,7 @@ Full documentation can be found in [docs](./docs/). It is currently a work in pr
114169
| `make test-asm` | Compile and run ASM tests |
115170
| `make test-rust` | Compile and run Rust tests |
116171
| `make test-executor` | Compile all programs and run executor tests |
172+
| `make test-math-cuda` | math-cuda parity tests (requires NVIDIA GPU + nvcc) |
117173
| `make build` | Build all workspace crates |
118174
| `make check` | Check all crates (faster than build, no codegen) |
119175
| `make clippy` | Run clippy on all crates |
@@ -128,8 +184,8 @@ To run all tests across the project use
128184

129185
### ASM Tests
130186

131-
In order to add a new asm test you should add the `.s` file under `programs/asm`
132-
Then add the corresponding test under `tests/asm.rs`
187+
In order to add a new asm test you should add the `.s` file under `executor/programs/asm`
188+
Then add the corresponding test under `executor/tests/asm.rs`
133189

134190
To run them you can use
135191

@@ -139,9 +195,9 @@ This will compile them and run the tests
139195

140196
### Rust Tests
141197

142-
In order to add a new rust test you should add the cargo project under `programs/rust` as a new directory.
198+
In order to add a new rust test you should add the cargo project under `executor/programs/rust` as a new directory.
143199
The folder should have the same name as the `Cargo.toml` program name.
144-
Then add the corresponding test under `tests/rust.rs`
200+
Then add the corresponding test under `executor/tests/rust.rs`
145201

146202
You can run it with
147203

@@ -151,8 +207,20 @@ You can run it with
151207

152208
You can create a flamegraph for proof generation using the following target:
153209

210+
```sh
211+
make flamegraph-prover
212+
```
213+
214+
This profiles the synthetic `fibonacci_multi_column` STARK example in `crypto/stark` (i.e. the STARK engine itself, not a real guest ELF). To profile the VM prover end-to-end on a real ELF, use the dedicated bench in the `prover` crate:
215+
216+
```sh
217+
samply record cargo bench --bench profile_vm_prover --features parallel
154218
```
155-
make flamegraph-prover
219+
220+
For a quick GPU microbench (requires an NVIDIA GPU + `nvcc`):
221+
222+
```sh
223+
make bench-math-cuda
156224
```
157225

158226
## Debug Checks

bin/cli/README.md

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,88 @@ A command-line interface for executing, proving, and verifying RISC-V ELF progra
44

55
## Installation
66

7-
```bash
8-
cargo build -p cli --release
7+
```sh
8+
cargo build --release -p cli
99
```
1010

1111
The binary will be available at `target/release/cli`.
1212

13+
## Producing an ELF
14+
15+
The CLI consumes RISC-V ELF binaries. The repo ships ready-to-use guest programs that you can compile with:
16+
17+
```sh
18+
# RISC-V assembly tests → executor/program_artifacts/asm/*.elf
19+
make compile-programs-asm
20+
21+
# Rust guest programs → executor/program_artifacts/rust/*.elf (needs the sysroot + nightly toolchain)
22+
make compile-programs-rust
23+
24+
# Benchmark programs → executor/program_artifacts/bench/*.elf (needs the sysroot + nightly toolchain)
25+
make compile-bench
26+
```
27+
28+
See the root [`README.md`](../../README.md) for the toolchain setup.
29+
1330
## Commands
1431

1532
### Execute
1633

1734
Run a RISC-V ELF program without generating a proof. Useful for testing and debugging.
1835

19-
```bash
20-
cargo run -p cli --release -- execute <PROGRAM.elf>
36+
```sh
37+
cargo run -p cli --release -- execute <PROGRAM.elf> [--private-input <FILE>] [--flamegraph <FILE>]
2138
```
2239

23-
See [Guest Program Flamegraphs](#guest-program-flamegraphs) for profiling execution.
40+
| Flag | Description |
41+
|---|---|
42+
| `--private-input <FILE>` | Pass private input bytes to the guest (read via `get_private_input()`). |
43+
| `--flamegraph <FILE>` | Generate folded-stack flamegraph output. See [Guest Program Flamegraphs](#guest-program-flamegraphs). |
2444

2545
### Prove
2646

2747
Generate a STARK proof for a RISC-V ELF program execution.
2848

29-
```bash
30-
cargo run -p cli --release -- prove <PROGRAM.elf> -o proof.bin
49+
```sh
50+
cargo run -p cli --release -- prove <PROGRAM.elf> -o proof.bin [flags]
3151
```
3252

53+
| Flag | Description |
54+
|---|---|
55+
| `-o, --output <FILE>` | Output path for the serialized proof bundle. Required. |
56+
| `--private-input <FILE>` | Pass private input bytes to the guest. |
57+
| `--blowup <N>` | FRI blowup factor (power of 2). Higher = fewer queries, smaller proof, slower proving. [default: 2] |
58+
| `--time` | Print total proving time. |
59+
| `--cycles` | Run one extra pre-pass outside the timer and print the dynamic instruction count. |
60+
| `--elements` | Build traces and print main-trace and aux-trace field element counts. |
61+
3362
### Verify
3463

35-
Verify a proof generated by the `prove` command.
64+
Verify a proof generated by `prove`.
3665

37-
```bash
38-
cargo run -p cli --release -- verify proof.bin <PROGRAM.elf>
66+
```sh
67+
cargo run -p cli --release -- verify <PROOF> <PROGRAM.elf> [flags]
3968
```
4069

41-
Returns exit code 0 on successful verification, 1 on failure.
70+
| Flag | Description |
71+
|---|---|
72+
| `--blowup <N>` | FRI blowup factor used during proving. Must match. [default: 2] |
73+
| `--time` | Print verification time. |
74+
75+
Returns exit code `0` on successful verification, `1` on failure.
76+
77+
### Count Elements
78+
79+
Build traces and print main-trace and aux-trace field element counts **without** running the proof step. Useful for sizing.
80+
81+
```sh
82+
cargo run -p cli --release -- count-elements <PROGRAM.elf> [--private-input <FILE>]
83+
```
4284

4385
## Examples
4486

45-
```bash
46-
# Compile test programs (if not already done)
87+
```sh
88+
# Compile the bundled assembly tests
4789
make compile-programs-asm
4890

4991
# Execute a simple program
@@ -52,6 +94,9 @@ cargo run -p cli --release -- execute executor/program_artifacts/asm/add.elf
5294
# Generate and verify a proof
5395
cargo run -p cli --release -- prove executor/program_artifacts/asm/add.elf -o /tmp/proof.bin
5496
cargo run -p cli --release -- verify /tmp/proof.bin executor/program_artifacts/asm/add.elf
97+
98+
# Prove with private input and print metrics
99+
cargo run -p cli --release -- prove program.elf -o /tmp/proof.bin --private-input input.bin --time --cycles
55100
```
56101

57102
## Guest Program Flamegraphs
@@ -60,15 +105,15 @@ Generate flamegraphs showing where the guest RISC-V program spends its execution
60105

61106
### Generate Folded Stacks
62107

63-
```bash
108+
```sh
64109
cargo run -p cli --release -- execute <PROGRAM.elf> --flamegraph folded.txt
65110
```
66111

67112
### Convert to SVG
68113

69114
Requires [inferno](https://github.com/jonhoo/inferno) or [flamegraph.pl](https://github.com/brendangregg/FlameGraph):
70115

71-
```bash
116+
```sh
72117
# Install inferno (one-time)
73118
cargo install inferno
74119

@@ -78,7 +123,7 @@ cat folded.txt | inferno-flamegraph > flamegraph.svg
78123

79124
### Example
80125

81-
```bash
126+
```sh
82127
# Generate flamegraph for quicksort benchmark
83128
cargo run -p cli --release -- execute executor/program_artifacts/bench/quicksort.elf --flamegraph /tmp/quicksort.txt
84129
cat /tmp/quicksort.txt | inferno-flamegraph --title "quicksort" > quicksort_flamegraph.svg

bin/cli/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ enum Commands {
125125
private_input: Option<PathBuf>,
126126

127127
/// Blowup factor (power of 2). Higher = fewer queries, smaller proof, slower proving.
128-
#[arg(long)]
128+
#[arg(long, default_value = "2")]
129129
blowup: Option<u8>,
130130

131131
/// Print proving time
@@ -153,10 +153,10 @@ enum Commands {
153153
elf: PathBuf,
154154

155155
/// Blowup factor used during proving (must match)
156-
#[arg(long)]
156+
#[arg(long, default_value = "2")]
157157
blowup: Option<u8>,
158158

159-
/// Print timing breakdown
159+
/// Print verification time
160160
#[arg(long)]
161161
time: bool,
162162
},

0 commit comments

Comments
 (0)