fix(sdk): use as_chunks in capsule counterparty decode — unbreaks CI on clippy 1.98 - #730
Merged
Merged
Conversation
…on clippy 1.98
CI's Rust job failed with:
error: using `chunks_exact` with a constant chunk size
--> dsm_sdk/src/storage/client_db/recovery.rs:1092
= note: `#[deny(clippy::chunks_exact_to_as_chunks)]` implied by `#[deny(warnings)]`
NOT a regression from any recent PR
-----------------------------------
The flagged line dates from the initial commit (1f60266, 2026-03-19) and is
absent from the diff of the PR whose CI reported it. What changed is CI's
toolchain: `chunks_exact_to_as_chunks` is new in clippy 1.98, and dsm_sdk
denies warnings crate-wide (lib.rs:90). Main was going red on the next push
regardless of what merged.
The fix replaces the pattern rather than suppressing it. `as_chunks` yields
`&[u8; 32]` directly, so the scratch array and its copy_from_slice disappear:
- let mut ids = Vec::with_capacity(blob.len() / 32);
- for chunk in blob.chunks_exact(32) {
- let mut arr = [0u8; 32];
- arr.copy_from_slice(chunk);
- ids.push(arr);
- }
- Ok(ids)
+ Ok(blob.as_chunks::<32>().0.to_vec())
The existing `blob.len() % 32 != 0` guard already rejects a remainder, so the
discarded `.1` is provably empty and behaviour is identical.
Why this was invisible locally
------------------------------
Local clippy is 0.1.96; CI's is 1.98.0. A lint that does not exist locally
cannot fire locally, so `make lint` green was SILENT about it rather than
clean. Compounding it, Homebrew's cargo shadows rustup's, so
`cargo clippy --version` reported 0.1.96 even under `rustup run stable`
(1.97.1).
Verified by reproducing the failure, not by assuming
----------------------------------------------------
Installed a pinned 1.98 toolchain (additive; the default stays 1.97.1) and
POSITIVE-CONTROLLED it against the pre-fix code — it reproduces the CI error
exactly. Local 1.97 emitted NOTHING on that line and would have "confirmed"
the fix while proving nothing.
CI aborts at the first error, so a single reported failure does not bound the
work: swept `cargo clippy --all-targets -- -D warnings` under 1.98 across the
whole workspace. Clean, exit 0 — recovery.rs was the only occurrence, and grep
confirms no constant-size `chunks_exact` remains.
Verification (three gates, each run separately with its own exit code)
board 68 suites, 3811 passed, 0 failed, 19 ignored, exit 0
make lint (1.96) exit 0, 0 errors
clippy 1.98 --all-targets, exit 0, 0 errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unbreaks the
RustCI job. One line of production code; the rest of this description is why it was invisible locally.Not a regression from any recent PR
The flagged line dates from the initial commit (
1f60266c, 2026-03-19) and is absent from the diff of the PR whose CI reported it. What changed is CI's toolchain:chunks_exact_to_as_chunksis new in clippy 1.98, anddsm_sdkdenies warnings crate-wide (lib.rs:90). Main was going red on the next push regardless of what merged.The fix replaces the pattern rather than suppressing it
No
#[allow].as_chunksyields&[u8; 32]directly, so the scratch array and itscopy_from_slicedisappear — the lint was pointing at real redundancy. The existingblob.len() % 32 != 0guard already rejects a remainder, so the discarded.1is provably empty and behaviour is identical.Why
make lintwas green while CI was redLocal clippy
0.1.96; CI's1.98.0. A lint that does not exist locally cannot fire locally — so a local pass is silent about it, not clean. I have been reportingLINT_EXIT=0in PR bodies as if it were equivalent to CI's lint; it is not, when the versions differ.Compounding it: Homebrew's cargo shadows rustup's, so
cargo clippy --versionreported0.1.96even underrustup run stable(which is 1.97.1). Asking the shadowed binary gives the wrong answer about which toolchain would actually run.Verified by reproducing the failure, not by assuming
Installed a pinned
1.98.0toolchain (additive — the default stays 1.97.1) and positive-controlled it against the pre-fix code. It reproduces the CI error exactly.This mattered: local 1.97 emitted nothing on that line. Verifying with it would have "confirmed" the fix while proving nothing.
CI aborts at the first error (
due to 1 previous error), so one reported failure does not bound the work. Sweptcargo clippy --all-targets -- -D warningsunder 1.98 across the whole workspace — clean, exit 0.recovery.rswas the only occurrence, and grep confirms no constant-sizechunks_exactremains anywhere.Verification — three gates, each run separately with its own exit code
Follow-up worth taking separately
The tracked
.github/instructions/verification.instructions.mdsays to runmake lint, with no version-parity rule. A candidate is filed to add one: comparecargo clippy --versionagainst the version in the CI log, invoke the rustup toolchain binary directly rather than the shadowed one, positive-control a newly installed toolchain against known-bad code, and check whether a CI-flagged file is even in your diff before treating the failure as your own.