Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a staged, workspace-wide Rust/Clippy lint baseline for LEZ programs (including separate linting for the excluded zkVM guest crates) and updates several call sites to comply with the new rules.
Changes:
- Add
[workspace.lints]policy at the root and opt workspace member crates into inheriting it; add matching lint configs to the excluded guest crates. - Add
clippy.tomlto pin MSRV and configure test-specific lint behavior; extend CI to run workspace + guest Clippy and reject placeholder lint-suppression reasons. - Replace/adjust a number of
unwrap()calls and some arithmetic/indexing patterns to satisfy the baseline (tests + AMM logic + PDA seed assembly).
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Cargo.toml | Adds workspace-level Rust/Clippy lint baseline. |
| clippy.toml | Pins MSRV and configures Clippy behavior (incl. test allowances). |
| .github/workflows/ci.yml | Adds CI checks for placeholder lint-suppression reasons and runs guest Clippy. |
| tools/idl-gen/Cargo.toml | Opts the idl-gen tool into workspace lints. |
| tools/idl-gen/src/main.rs | Replaces unwrap() with expect() for JSON serialization. |
| token/Cargo.toml | Opts token program crate into workspace lints. |
| token/core/Cargo.toml | Opts token core crate into workspace lints. |
| token/methods/Cargo.toml | Opts token methods crate into workspace lints. |
| token/src/print_nft.rs | Switches decrement to checked arithmetic to satisfy arithmetic linting. |
| token/src/tests.rs | Adds test-level lint expectations and replaces unwrap() with expect(). |
| token/methods/guest/Cargo.toml | Adds standalone lint baseline for excluded token guest crate. |
| token/methods/guest/src/bin/token.rs | Adjusts entry/no_main for tests and adds reasoned lint expectations. |
| ata/Cargo.toml | Opts ATA program crate into workspace lints. |
| ata/core/Cargo.toml | Opts ATA core crate into workspace lints. |
| ata/methods/Cargo.toml | Opts ATA methods crate into workspace lints. |
| ata/core/src/lib.rs | Removes direct slicing when assembling PDA seed bytes. |
| ata/methods/guest/Cargo.toml | Adds standalone lint baseline for excluded ATA guest crate. |
| ata/methods/guest/src/bin/ata.rs | Adjusts entry/no_main for tests and adds reasoned lint expectations. |
| amm/Cargo.toml | Opts AMM program crate into workspace lints. |
| amm/core/Cargo.toml | Opts AMM core crate into workspace lints. |
| amm/methods/Cargo.toml | Opts AMM methods crate into workspace lints. |
| amm/core/src/lib.rs | Removes direct slicing when assembling PDA seed bytes. |
| amm/src/add.rs | Replaces integer division with checked division where needed. |
| amm/src/remove.rs | Uses checked subtraction/division for liquidity math. |
| amm/src/new_definition.rs | Uses checked subtraction for initial LP accounting. |
| amm/src/swap.rs | Improves lint expectation reasons and uses checked arithmetic/division in swap math. |
| amm/src/tests.rs | Adds test-level lint expectations and replaces unwrap() with expect(). |
| amm/methods/guest/Cargo.toml | Adds standalone lint baseline for excluded AMM guest crate. |
| amm/methods/guest/src/bin/amm.rs | Adjusts entry/no_main for tests and adds reasoned lint expectations. |
| integration_tests/Cargo.toml | Opts integration tests crate into workspace lints. |
| integration_tests/tests/token.rs | Replaces unwrap() with expect() in test setup paths. |
| integration_tests/tests/ata.rs | Replaces unwrap() with expect() in test setup paths. |
| integration_tests/tests/amm.rs | Adds test-level lint expectations and replaces unwrap() with expect(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Ok(idl) => println!( | ||
| "{}", | ||
| serde_json::to_string_pretty(&idl) | ||
| .expect("serializing generated IDL to JSON should not fail") | ||
| ), |
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Done in b194f42. The expect(...) on serde_json::to_string_pretty is now replaced with an explicit match that prints the error to stderr and calls process::exit(1), consistent with the other error branches in the CLI.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…d of panicking Agent-Logs-Url: https://github.com/logos-blockchain/lez-programs/sessions/c96af723-7390-4496-9838-2cdd2083ab3d Co-authored-by: 3esmit <224810+3esmit@users.noreply.github.com>
| *print_balance -= 1; | ||
| *print_balance = print_balance | ||
| .checked_sub(1) | ||
| .expect("print balance must be greater than one after validation"); |
| if rg -n -U --multiline '#\[(allow|expect)\([\s\S]*?reason\s*=\s*"(TODO|FIXME|fix later|later|temporary|hack)' token amm ata integration_tests tools -g '*.rs'; then | ||
| echo "Found non-actionable lint suppression reason" | ||
| exit 1 | ||
| fi |
Fixes #87
Summary
Adds a staged lint baseline for the LEZ workspace and the excluded guest crates.
What Changed
clippy.tomlwith the pinned Rust MSRV and test-specific lint behavior.unwrap()call inidl-gen, made AMM arithmetic use checked division where needed, removed unchecked PDA seed slicing, and gave existing lint expectations concrete reasons.Justification
The repository contains deterministic program logic and zkVM guest wrappers. A shared lint baseline makes risky patterns visible earlier and prevents excluded guest crates from drifting outside the normal quality gate.
Benefits
Risks
riscv32im-risc0-zkvm-elfClippy gate likely needs separate stable build-std/toolchain wiring.Validation
cargo +nightly fmt --all -- --check taplo fmt --check . RISC0_SKIP_BUILD=1 cargo +1.94.0 clippy --workspace --all-targets -- -D warnings cargo +1.94.0 clippy --manifest-path token/methods/guest/Cargo.toml --all-targets -- -D warnings cargo +1.94.0 clippy --manifest-path amm/methods/guest/Cargo.toml --all-targets -- -D warnings cargo +1.94.0 clippy --manifest-path ata/methods/guest/Cargo.toml --all-targets -- -D warnings