mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-03-24 12:23:35 +00:00
82 lines
2.4 KiB
Markdown
82 lines
2.4 KiB
Markdown
# lez-programs
|
|
|
|
Essential programs for the **Logos Execution Zone (LEZ)** — a zkVM-based execution environment built on [RISC Zero](https://risczero.com/). Programs run inside the RISC Zero zkVM (`riscv32im-risc0-zkvm-elf` target) and interact with the LEZ runtime via the `nssa_core` library.
|
|
|
|
## Prerequisites
|
|
|
|
- **Rust** — install via [rustup](https://rustup.rs/). The pinned toolchain version is `1.91.1` (set in `rust-toolchain.toml`).
|
|
- **RISC Zero toolchain** — required to build guest ZK binaries:
|
|
|
|
```bash
|
|
cargo install cargo-risczero
|
|
cargo risczero install
|
|
```
|
|
- **SPEL toolchain** — provides `lez-cli` tools. Install from [logos-co/spel](https://github.com/logos-co/spel).
|
|
- **LEZ** — provides `wallet` CLI. Install from [logos-blockchain/logos-execution-zone](https://github.com/logos-blockchain/logos-execution-zone)
|
|
|
|
## Build & Test
|
|
|
|
```bash
|
|
# Lint the entire workspace (skips expensive guest ZK builds)
|
|
RISC0_SKIP_BUILD=1 cargo clippy --workspace --all-targets -- -D warnings
|
|
|
|
# Format check
|
|
cargo fmt --all
|
|
|
|
# Run all tests (dev mode skips ZK proof generation)
|
|
RISC0_DEV_MODE=1 cargo test --workspace
|
|
|
|
```
|
|
|
|
## Compile Guest Binaries
|
|
|
|
The guest binaries are compiled to the `riscv32im-risc0-zkvm-elf` target. This requires the RISC Zero toolchain.
|
|
|
|
```bash
|
|
cargo risczero build --manifest-path <PROGRAM>/methods/guest/Cargo.toml
|
|
```
|
|
|
|
Binaries are output to:
|
|
|
|
```
|
|
<PROGRAM>/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/<PROGRAM>.bin
|
|
```
|
|
|
|
## Deployment
|
|
|
|
```bash
|
|
# Deploy a program binary to the sequencer
|
|
wallet deploy-program <path-to-binary>
|
|
|
|
# Example
|
|
wallet deploy-program token/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/token.bin
|
|
wallet deploy-program amm/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/amm.bin
|
|
```
|
|
|
|
To inspect the `ProgramId` of a built binary:
|
|
|
|
```bash
|
|
lez-cli inspect <path-to-binary>
|
|
```
|
|
|
|
## Interacting with Programs via `lez-cli`
|
|
|
|
### Generate an IDL
|
|
|
|
The IDL describes the program's instructions and can be used to interact with a deployed program.
|
|
|
|
```bash
|
|
# Example
|
|
lez-cli generate-idl token/methods/guest/src/bin/token.rs > token/token-idl.json
|
|
lez-cli generate-idl amm/methods/guest/src/bin/amm.rs > amm/amm-idl.json
|
|
```
|
|
|
|
### Invoke Instructions
|
|
|
|
Use `lez-cli --idl <IDL> <INSTRUCTION> [ARGS...]` to call a deployed program instruction:
|
|
|
|
```bash
|
|
lez-cli --idl token/token-idl.json <instruction> [args...]
|
|
lez-cli --idl amm/amm-idl.json <instruction> [args...]
|
|
```
|