Skip to content

refactor(filters): reduce the clones while updating the filters#7360

Merged
akaladarshi merged 2 commits into
mainfrom
akaladarshi/refactor-filters
Jul 17, 2026
Merged

refactor(filters): reduce the clones while updating the filters#7360
akaladarshi merged 2 commits into
mainfrom
akaladarshi/refactor-filters

Conversation

@akaladarshi

@akaladarshi akaladarshi commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary of changes

Changes introduced in this pull request:

  • The Eth filter were calling the update on the filter, just to store the last seen_positions of the events or epochs.
  • Now we just use the update the seen_position directly by holding a lock on it.

Reference issue to close (if applicable)

Closes Part of #7265

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Bug Fixes
    • Improved event filter polling to return only previously unseen events and prevent duplicate results.
    • Improved tipset filter tracking so collected progress is maintained reliably across successive requests.
    • Enhanced filter behavior during concurrent polling for more consistent results.
  • Tests
    • Expanded coverage for event and tipset filter creation, polling, state tracking, and removal.

@akaladarshi
akaladarshi requested a review from a team as a code owner July 15, 2026 09:11
@akaladarshi
akaladarshi requested review from hanabi1224 and sudo-shashank and removed request for a team July 15, 2026 09:11
@akaladarshi akaladarshi changed the title refactor(fillters): reduce the clones while updating the filters refactor(filters): reduce the clones while updating the filters Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Ethereum event and tipset filters now keep cursor state behind mutexes. Polling updates that state directly, filter managers no longer receive result-limit configuration, and FilterStore no longer supports updates.

Changes

Ethereum filter state

Layer / File(s) Summary
Event cursor management
src/rpc/methods/eth/filter/event.rs
EventFilter protects unseen-event positions with a mutex, while manager construction and tests use the revised state model.
Tipset cursor management
src/rpc/methods/eth/filter/tipset.rs
TipSetFilter protects its collected epoch with a mutex, and manager constructors no longer accept result limits.
RPC and store integration
src/rpc/methods/eth.rs, src/rpc/methods/eth/filter/mod.rs, src/rpc/methods/eth/filter/store.rs
RPC polling mutates filter cursors directly, handler setup uses zero-argument managers, and filter storage removes update.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: RPC

Suggested reviewers: hanabi1224, sudo-shashank, lesnyrumcajs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the refactor focus and the goal of reducing cloning in filter update paths.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch akaladarshi/refactor-filters
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch akaladarshi/refactor-filters

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/rpc/methods/eth.rs (1)

3513-3528: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Serialize the tipset filter cursor update. Two concurrent eth_getFilterChanges calls can read the same collected() value before either reaches set_collected(), so both scan and return the same range. Guard the read/scan/advance sequence per filter, or make the cursor advance atomic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/rpc/methods/eth.rs` around lines 3513 - 3528, Serialize the tipset filter
cursor lifecycle in the eth_getFilterChanges flow surrounding
tipset_filter.collected(), event scanning, and
tipset_filter.set_collected(height). Ensure concurrent calls for the same filter
cannot read the same cursor or scan the same range; use per-filter locking or an
atomic cursor advance while preserving the existing range and update behavior.

Source: Coding guidelines

🧹 Nitpick comments (1)
src/rpc/methods/eth/filter/tipset.rs (1)

21-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use anyhow::Result here too. TipSetFilter::new still exposes uuid::Error; wrapping FilterID::new() with .context(...) keeps this constructor aligned with the rest of the error handling.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/rpc/methods/eth/filter/tipset.rs` around lines 21 - 26, Update
TipSetFilter::new to return anyhow::Result, wrap FilterID::new() with contextual
error information using the existing anyhow error-handling conventions, and
preserve the current Arc<Self> construction on success.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/rpc/methods/eth.rs`:
- Around line 3513-3528: Serialize the tipset filter cursor lifecycle in the
eth_getFilterChanges flow surrounding tipset_filter.collected(), event scanning,
and tipset_filter.set_collected(height). Ensure concurrent calls for the same
filter cannot read the same cursor or scan the same range; use per-filter
locking or an atomic cursor advance while preserving the existing range and
update behavior.

---

Nitpick comments:
In `@src/rpc/methods/eth/filter/tipset.rs`:
- Around line 21-26: Update TipSetFilter::new to return anyhow::Result, wrap
FilterID::new() with contextual error information using the existing anyhow
error-handling conventions, and preserve the current Arc<Self> construction on
success.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9b52443c-983a-41b3-94ed-0149f593c86e

📥 Commits

Reviewing files that changed from the base of the PR and between b436194 and 477a744.

📒 Files selected for processing (5)
  • src/rpc/methods/eth.rs
  • src/rpc/methods/eth/filter/event.rs
  • src/rpc/methods/eth/filter/mod.rs
  • src/rpc/methods/eth/filter/store.rs
  • src/rpc/methods/eth/filter/tipset.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)
💤 Files with no reviewable changes (1)
  • src/rpc/methods/eth/filter/store.rs

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.76404% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.83%. Comparing base (b123cab) to head (8d920f6).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/eth/filter/tipset.rs 36.36% 6 Missing and 1 partial ⚠️
src/rpc/methods/eth.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/methods/eth/filter/event.rs 92.80% <100.00%> (+8.31%) ⬆️
src/rpc/methods/eth/filter/mod.rs 88.64% <100.00%> (ø)
src/rpc/methods/eth/filter/store.rs 94.11% <ø> (+6.84%) ⬆️
src/rpc/methods/eth.rs 68.50% <0.00%> (+0.79%) ⬆️
src/rpc/methods/eth/filter/tipset.rs 83.67% <36.36%> (-12.25%) ⬇️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b123cab...8d920f6. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@akaladarshi
akaladarshi marked this pull request as draft July 15, 2026 09:37
@akaladarshi
akaladarshi marked this pull request as ready for review July 15, 2026 15:04
@akaladarshi
akaladarshi added this pull request to the merge queue Jul 17, 2026
Merged via the queue into main with commit cab14c4 Jul 17, 2026
57 of 58 checks passed
@akaladarshi
akaladarshi deleted the akaladarshi/refactor-filters branch July 17, 2026 10:28
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