You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+83-15Lines changed: 83 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,9 @@ Right now, this is a project under development and experimentation and must not
11
11
### Dependencies
12
12
13
13
- 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)
14
17
15
18
### Dev dependencies
16
19
@@ -26,11 +29,10 @@ Install Rust using [rustup](https://rustup.rs/):
26
29
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
27
30
```
28
31
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):
Then, you can check that the executor works by running:
69
71
70
72
```sh
71
-
make deps
73
+
make test-executor
72
74
```
73
75
74
-
**Note:** At the moment, `make deps` only works on macOS.
76
+
### Using the CLI
75
77
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:
77
79
78
80
```sh
79
-
make test-executor
81
+
cargo build --release -p cli
80
82
```
81
83
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
+
82
126
## Design choices
83
127
84
128
- The Instruction Set Architecture is RISCV64IM
@@ -98,7 +142,18 @@ Following [ethrex](https://github.com/lambdaclass/ethrex):
98
142
99
143
## Documentation
100
144
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.
102
157
103
158
## Testing
104
159
@@ -114,6 +169,7 @@ Full documentation can be found in [docs](./docs/). It is currently a work in pr
114
169
|`make test-asm`| Compile and run ASM tests |
115
170
|`make test-rust`| Compile and run Rust tests |
116
171
|`make test-executor`| Compile all programs and run executor tests |
|`make check`| Check all crates (faster than build, no codegen) |
119
175
|`make clippy`| Run clippy on all crates |
@@ -128,8 +184,8 @@ To run all tests across the project use
128
184
129
185
### ASM Tests
130
186
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`
133
189
134
190
To run them you can use
135
191
@@ -139,9 +195,9 @@ This will compile them and run the tests
139
195
140
196
### Rust Tests
141
197
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.
143
199
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`
145
201
146
202
You can run it with
147
203
@@ -151,8 +207,20 @@ You can run it with
151
207
152
208
You can create a flamegraph for proof generation using the following target:
153
209
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
154
218
```
155
-
make flamegraph-prover
219
+
220
+
For a quick GPU microbench (requires an NVIDIA GPU + `nvcc`):
0 commit comments