Guidance for AI agents working with Rust code in the Optimism monorepo. See dev-workflow.md for tool versions, PR workflow, and other cross-language guidance.
All Rust code lives under rust/. This is a unified Cargo workspace — always run Rust commands from this directory. The workspace contains three main component groups:
- Kona — Proof system and rollup node (
rust/kona/) - Op-Reth — OP Stack execution client built on reth (
rust/op-reth/) - Op-Alloy / Alloy extensions — OP Stack types and providers
Check rust/Cargo.toml for the full workspace member list, dependency versions, and lint configuration. The Rust toolchain version is pinned in rust/rust-toolchain.toml.
Run just --list in rust/ to see all available targets. The key ones:
cd rust
# Build the workspace
just build
# Build in release mode
just build-release
# Build specific binaries
just build-node # kona-node
just build-op-reth # op-rethTests use cargo-nextest (not cargo test) for unit tests:
cd rust
# Run all tests (unit + doc tests)
just test
# Unit tests only (excludes online tests)
just test-unit
# Doc tests only
just test-docsKona prestates are built via Docker:
cd rust
just build-kona-prestatescd rust
# Run all lints (format check + clippy + doc lints)
just lint
# Individual lint steps
just fmt-check # formatting (requires nightly)
just lint-clippy # clippy with all features, -D warnings
just lint-docs # rustdoc warningsLint configuration lives in rust/Cargo.toml (workspace lints section), rust/clippy.toml, and rust/rustfmt.toml.
Formatting uses a pinned nightly toolchain (defined as NIGHTLY in rust/justfile). If the nightly isn't installed:
cd rust
just install-nightlyThen use just fmt-fix to auto-format, or just fmt-check to verify.
Many kona and alloy crates must compile without the standard library (for the fault proof VM). If you modify these crates, verify no_std builds:
cd rust
just check-no-stdThis builds affected crates for the riscv32imac-unknown-none-elf target.
The workspace uses cargo-deny for license, advisory, and dependency checks. Configuration is in rust/deny.toml.
cd rust
just denyRun these checks from rust/. Fix all issues — CI enforces zero warnings.
-
Lint — this checks formatting, clippy, and doc lints:
just lint
-
Test — run tests for changed packages:
just test-unit
-
no_std — if you changed any proof, protocol, or alloy crate:
just check-no-std
Op-reth requires clang / libclang-dev for reth-mdbx-sys bindgen. CI installs this automatically — if you see bindgen errors locally, install clang.
- Fix Rust Formatting (
.claude/skills/fix-rust-fmt/SKILL.md): Fixesrust-fmtCI failures by installing the pinned nightly toolchain and runningjust fmt-fix. Invoke with/fix-rust-fmt.