Skip to content

fix(backend): resolve clippy lints#101

Merged
Camillebzd merged 3 commits into
ci/unified-frontend-workflowfrom
fix/backend-clippy-autofix
Jun 11, 2026
Merged

fix(backend): resolve clippy lints#101
Camillebzd merged 3 commits into
ci/unified-frontend-workflowfrom
fix/backend-clippy-autofix

Conversation

@kyscott18

@kyscott18 kyscott18 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Resolves all 8 clippy findings surfaced by the new rust CI job (#100) so cargo clippy -D warnings passes.

Mechanical fixes (equivalents of cargo clippy --fix)

File Lint Fix
server.rs needless_return drop return
server.rs match_like_matches_macro use matches!
event_filter.rs ptr_arg &Vec<T>&[T]
event_filter.rs needless_borrow drop &
event_listener.rs manual_is_multiple_of .is_multiple_of(100)
serializable_event.rs clone_on_copy drop .clone() on u64

Manual fixes (not auto-fixable)

File Lint Fix
server.rs large_enum_variant box the 640-byte variant: EventDataOrMetrics::Event(Box<EventData>); the from(&event_data) call site deref-coerces, construction now uses Box::new(..)
event_listener.rs should_implement_trait rename inherent EventName::from_strfrom_name (+ its single caller) so it no longer shadows std::str::FromStr::from_str

No behavioral change. With these, the rust job (fmt + clippy -D warnings + build) should be fully green.

Stacked on #100 (the unified CI workflow) so the containerized rust job validates these fixes. Rebase base back to main once #100 merges.

Addresses 6 of the 8 clippy findings surfaced by the new rust CI job:
- needless_return (server.rs)
- match_like_matches_macro (server.rs)
- ptr_arg: &Vec<T> -> &[T] (event_filter.rs)
- needless_borrow (event_filter.rs)
- manual_is_multiple_of (event_listener.rs)
- clone_on_copy (serializable_event.rs)

Remaining (require manual judgment, deferred): large_enum_variant
(server.rs), should_implement_trait for from_str (event_listener.rs).
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monode Ready Ready Preview, Comment Jun 9, 2026 7:37pm

Request Review

@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR resolves all 8 Clippy warnings surfaced by the new rust CI job, making cargo clippy -D warnings pass. All changes are mechanical — no behavioral difference.

  • Mechanical fixes: drops redundant return, clone(), and & borrows; upgrades &Vec<T> to &[T]; replaces an if-let chain with matches!; and uses is_multiple_of(100) in the event loop.
  • EventDataOrMetrics::Event is now Box<EventData> to address the large_enum_variant lint, with the single construction site updated to Box::new(event_data) and the match arm updated to &*event_data for deref-coercion.
  • EventName::from_strfrom_name avoids shadowing std::str::FromStr::from_str; the single internal call site in event_to_data is updated accordingly. A small undocumented client.rs change also removes redundant as u64 casts that the PR description doesn't mention.

Confidence Score: 5/5

All changes are mechanical Clippy lint fixes with no behavioral change; safe to merge once the stacking dependency on #100 lands.

Every fix is a direct, correct application of what Clippy prescribes — boxing the large enum variant, removing redundant borrows/casts/clones, using idiomatic matches!. The one unrelated undocumented client.rs change is also provably a no-op (removing an identity as u64 cast). No logic paths are altered.

No files require special attention; the client.rs change is safe but is worth a brief mention since it was omitted from the PR description.

Important Files Changed

Filename Overview
backend/src/lib/server.rs Boxes the large EventData variant, removes redundant return, and replaces if-let chain with matches! — all correct and no behavioral change.
backend/src/lib/event_listener.rs Renames from_strfrom_name (single call site updated) and replaces % 100 == 0 with .is_multiple_of(100); both are correct mechanical changes.
backend/src/lib/event_filter.rs Replaces &Vec<T> with &[T] in ArrayPrefixFilter::matches and removes the redundant borrow in the is_native_transfer call; both are idiomatic improvements with no semantic change.
backend/src/lib/serializable_event.rs Drops .clone() on the u64 field timestamp_ns — trivially correct since u64 is Copy.
backend/src/bin/client.rs Removes redundant as u64 casts from u64 - u64 subtractions; safe since both operands and Duration::from_nanos already operate on u64, but this change is not described in the PR.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ExecEventRing / Snapshot] -->|event descriptor| B[event_to_data]
    B -->|EventName::from_name| C{known event?}
    C -->|None| D[skip event]
    C -->|Some EventData| E[run_event_forwarder_task]
    E -->|Box::new event_data| F[broadcast::Sender EventDataOrMetrics]
    F -->|EventDataOrMetrics::Event Box EventData| G[process_event]
    G -->|&*event_data| H[SerializableEventData::from]
    H --> I{filter.matches_event?}
    I -->|yes| J[events_buf push]
    I -->|no| K[discard]
    J --> L[client_write_task send over WebSocket]
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
backend/src/bin/client.rs:113-123
**Undocumented change not listed in PR description**

Two `as u64` casts are removed here (`event.timestamp_ns - txn_start_ns` and `event.timestamp_ns - client_state.block_start_ns`). Both operands are already `u64`, so the cast was a no-op and the removal is correct, but neither change appears in the PR's list of 8 lint fixes. Looks like a `clippy::unnecessary_cast` fix that slipped in — worth noting for completeness.

Reviews (4): Last reviewed commit: "fix(backend): remove redundant u64 casts..." | Re-trigger Greptile

event_count += 1;

if event_count % 100 == 0 {
if event_count.is_multiple_of(100) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 is_multiple_of requires Rust ≥ 1.87.0

<uN>::is_multiple_of was stabilized in Rust 1.87.0 (May 2025). The CI container pins rust:1.91-slim so the build will pass, but Cargo.toml has no rust-version field. Any contributor running cargo build or cargo clippy locally with a stable toolchain older than 1.87 will hit a compile error with no obvious hint about the minimum required version. Adding rust-version = "1.87" to Cargo.toml lets cargo surface a clear diagnostic instead of a confusing "method not found" error.

Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/src/lib/event_listener.rs
Line: 287

Comment:
**`is_multiple_of` requires Rust ≥ 1.87.0**

`<uN>::is_multiple_of` was stabilized in Rust 1.87.0 (May 2025). The CI container pins `rust:1.91-slim` so the build will pass, but `Cargo.toml` has no `rust-version` field. Any contributor running `cargo build` or `cargo clippy` locally with a stable toolchain older than 1.87 will hit a compile error with no obvious hint about the minimum required version. Adding `rust-version = "1.87"` to `Cargo.toml` lets `cargo` surface a clear diagnostic instead of a confusing "method not found" error.

How can I resolve this? If you propose a fix, please make it concise.

@kyscott18 kyscott18 changed the title fix(backend): resolve auto-fixable clippy lints fix(backend): resolve clippy lints Jun 9, 2026
kyscott18 added 2 commits June 9, 2026 19:36
- large_enum_variant: box the 640-byte Event variant of EventDataOrMetrics
  (Event(Box<EventData>)). Since From::from infers its parameter type from
  the argument (deref coercion does not apply), the match-site call passes
  &*event_data to select From<&EventData>; construction uses Box::new(..).
- should_implement_trait: rename inherent EventName::from_str -> from_name
  (and its single caller) so it no longer shadows std::str::FromStr::from_str.
Surfaced once the lib compiled clean: timestamp_ns is u64, so the
(u64 - u64) as u64 casts are redundant; drop the cast and parens.
@kyscott18 kyscott18 force-pushed the fix/backend-clippy-autofix branch from 9e056d8 to de4daf8 Compare June 9, 2026 19:36
@Camillebzd Camillebzd merged commit 8668e15 into ci/unified-frontend-workflow Jun 11, 2026
10 checks passed
@Camillebzd Camillebzd deleted the fix/backend-clippy-autofix branch June 11, 2026 09:04
Camillebzd added a commit that referenced this pull request Jun 11, 2026
* fix(tps-chart): smooth Transaction volume line

Switch the TPS Area interpolation from `linear` to `monotone` so the
Transaction volume chart renders as a smooth curve instead of connected
straight segments between data points.

* fix(tps-chart): animate new data points instead of curving the line

Revert line interpolation to linear and enable Recharts' built-in
animation so newly arriving data points ease into the chart instead
of snapping in. This is the smoothing that was actually requested:
the visible motion of new points appearing, not the line shape.

* feat(tps-chart): smooth streaming via sliding time-window X axis

Switch the X axis to a continuous time scale with a [now - 5min, now]
domain advanced each animation frame, so new points slide in smoothly
from the right edge instead of popping into discrete category slots.
Keeps isAnimationActive disabled to avoid Recharts re-animation loops on
each TPS event. Clamp the domain's left edge to the oldest point so the
chart fills immediately instead of showing an empty 5-minute lead-in.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: update pnpm lockfile and allow sharp/unrs-resolver builds

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: minimize lockfile diff vs main

Replaces frontend/pnpm-lock.yaml with main's lockfile minus the duplicate
keys introduced by PR #97 (so pnpm 10 can parse it). No package versions
change vs main; pnpm install --frozen-lockfile passes.

The previous commit on this branch ran a non-frozen pnpm install, which
silently re-resolved every floating semver in package.json and produced
~2000 lines of incidental lockfile churn. This commit reverses that.

* ci: unified frontend workflow (lint + typecheck + build)

* ci: add rust job (fmt + clippy + build)

* ci: run rust job in rust:1.91-slim container for libclang/bindgen parity

* perf(frontend): reduce GC pressure and re-renders in the live event pipeline (#98)

**Motivation:**

After ~1h on node.monad.xyz the renderer process is killed for OOM. There is
no single growing array — every component bounds its state — but at ~200 TPS
the per-event fan-out from EventsContext drives enough short-lived allocations
to fragment the heap. Backgrounded tabs are worse because the browser does not
throttle WebSocket onmessage.

**Modifications:**

1. Memoize EventsContext value so consumers don't re-render every time
   TopAccesses updates.
2. Drop WebSocket messages while document.visibilityState === 'hidden' to
   avoid running the dispatch + decode pipeline for an invisible tab.
3. Move the in-flight block's transactions out of React state into a
   ref-backed Map<txnIndex, Transaction>. Per-event updates are now O(1)
   instead of O(N), and the block is materialized into React state once at
   BlockFinalized/BlockVerified.
4. Allow subscribers to register an eventTypes filter on subscribe, and
   apply it at dispatch time so swap/transfer/totals hooks no longer run
   on BlockStart/TxnHeaderStart/etc.

**Result:**

Live event dispatch does far less work per WebSocket message, in-flight
blocks no longer reallocate their transactions array on every txn event,
and a backgrounded tab is effectively idle until it becomes visible again.

Co-authored-by: dak-agent[bot] <284037069+dak-agent[bot]@users.noreply.github.com>

* Smooth transaction volume chart clean (#105)

* feat(tps-chart): smoothly extend the line to each new point

Switch the X axis to a continuous time scale whose right edge eases
toward the newest point's timestamp each animation frame. A freshly
appended point sits just past the edge (clipped by allowDataOverflow)
and is revealed sliding in from the right instead of snapping into a
discrete category slot; the animation halts once the edge catches up, so
the chart is still between points. isAnimationActive stays disabled to
avoid Recharts re-animation loops on every TPS event.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: update pnpm lockfile and allow sharp/unrs-resolver builds

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* drawing lines smoothly between the points creation

* fix the x absis to have only 1 now

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(backend): resolve clippy lints (#101)

* fix(backend): resolve auto-fixable clippy lints

Addresses 6 of the 8 clippy findings surfaced by the new rust CI job:
- needless_return (server.rs)
- match_like_matches_macro (server.rs)
- ptr_arg: &Vec<T> -> &[T] (event_filter.rs)
- needless_borrow (event_filter.rs)
- manual_is_multiple_of (event_listener.rs)
- clone_on_copy (serializable_event.rs)

Remaining (require manual judgment, deferred): large_enum_variant
(server.rs), should_implement_trait for from_str (event_listener.rs).

* fix(backend): resolve non-auto-fixable clippy lints

- large_enum_variant: box the 640-byte Event variant of EventDataOrMetrics
  (Event(Box<EventData>)). Since From::from infers its parameter type from
  the argument (deref coercion does not apply), the match-site call passes
  &*event_data to select From<&EventData>; construction uses Box::new(..).
- should_implement_trait: rename inherent EventName::from_str -> from_name
  (and its single caller) so it no longer shadows std::str::FromStr::from_str.

* fix(backend): remove redundant u64 casts in client (unnecessary_cast)

Surfaced once the lib compiled clean: timestamp_ns is u64, so the
(u64 - u64) as u64 casts are redundant; drop the cast and parens.

---------

Co-authored-by: dak-agent[bot] <284037069+dak-agent[bot]@users.noreply.github.com>
Co-authored-by: Camillebzd <bcamille99@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Camillebzd <48495021+Camillebzd@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants