Skip to content

fix: eth new block filter stateful test#7392

Merged
akaladarshi merged 3 commits into
mainfrom
akaladarshi/fix-stateful-test-failure
Jul 21, 2026
Merged

fix: eth new block filter stateful test#7392
akaladarshi merged 3 commits into
mainfrom
akaladarshi/fix-stateful-test-failure

Conversation

@akaladarshi

@akaladarshi akaladarshi commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary of changes

Changes introduced in this pull request:

  • Earlier the EthNewBlockFilter relied on the ChainNotify and was failing if the tipset reverted was returned in the Chain Notify response
  • Now it simply waits for the ChainHead to report a new head

Reference issue to close (if applicable)

Closes #7385

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

  • This pull request is based on an issue that a maintainer has accepted (see Before Opening a Pull Request).
  • 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

Summary

  • Bug Fixes
    • Improved reliability of Ethereum block filter testing by adding bounded polling to wait for chain head progress (with a defined timeout) before re-verifying results.
    • Reduced flaky outcomes by re-polling and re-checking returned block hashes across multiple epoch advances, and by simplifying cleanup to avoid obscuring the original test failure.

@akaladarshi
akaladarshi requested a review from a team as a code owner July 21, 2026 08:41
@akaladarshi
akaladarshi requested review from LesnyRumcajs and hanabi1224 and removed request for a team July 21, 2026 08:41
@akaladarshi akaladarshi added the RPC requires calibnet RPC checks to run on CI label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9f943ae7-6145-4bd2-a42b-4d509eb1b49a

📥 Commits

Reviewing files that changed from the base of the PR and between 54d6ed2 and a34486f.

📒 Files selected for processing (1)
  • src/tool/subcommands/api_cmd/stateful_tests.rs
🔗 Linked repositories identified

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

  • filecoin-project/lotus (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tool/subcommands/api_cmd/stateful_tests.rs

Walkthrough

The stateful API test replaces WebSocket tipset waiting with bounded chain-head epoch polling. Block filter verification now uses one controlled flow across several epochs, accepts empty or changed hash sets, and removes the outer retry loop.

Changes

Block filter verification

Layer / File(s) Summary
Bounded epoch waiting
src/tool/subcommands/api_cmd/stateful_tests.rs
Adds wait_next_epoch, which polls ChainHead until the chain epoch advances or a 180-second timeout is reached.
Single-pass filter polling
src/tool/subcommands/api_cmd/stateful_tests.rs
Refactors eth_new_block_filter to poll and verify changes across up to three epoch advances, then uninstall the filter once without the previous outer retry loop.

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

Possibly related PRs

Suggested reviewers: hanabi1224, lesnyrumcajs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly describes the primary change to the eth new block filter stateful test.
Linked Issues check ✅ Passed The PR addresses #7385 by replacing the ChainNotify-based wait with ChainHead polling so the test no longer depends on reverted tipsets.
Out of Scope Changes check ✅ Passed The changes stay focused on the eth_new_block_filter stateful test and its waiting/verification flow.
✨ 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/fix-stateful-test-failure
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch akaladarshi/fix-stateful-test-failure

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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/tool/subcommands/api_cmd/stateful_tests.rs (2)

882-896: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Comment mischaracterizes why a block filter poll could be unchanged; ensure! lacks a diagnostic message.

eth_newBlockFilter/eth_getFilterChanges reports new block hashes, not filtered event/log hashes — the "epoch without events" framing on lines 882-884 seems copied from log-filter reasoning. The actual reason a poll can be unchanged is a null round (no block produced that epoch), not "executed events." Consider rewording so future readers don't misapply this reasoning to event/log filter tests.

Separately, the ensure! on line 894 has no message, so a failure here will only surface the raw boolean expression rather than something like "block filter hashes did not change across 3 epochs," making CI failures harder to diagnose quickly.

✏️ Suggested comment/message tweak
-            // The filter derives its hashes from executed events, so an epoch
-            // without events legitimately leaves the poll unchanged, allow a
-            // few more epochs before declaring the filter stuck.
+            // A given epoch can be a "null round" with no block produced,
+            // legitimately leaving the poll unchanged; allow a few more
+            // epochs before declaring the filter stuck.
             let mut hashes = Vec::new();
             for _ in 0..3 {
                 wait_next_epoch(client).await?;
                 hashes = poll().await?;
                 verify_hashes(&hashes).await?;
                 if hashes != prev_hashes {
                     break;
                 }
             }
-            anyhow::ensure!((prev_hashes.is_empty() && hashes.is_empty()) || prev_hashes != hashes);
+            anyhow::ensure!(
+                (prev_hashes.is_empty() && hashes.is_empty()) || prev_hashes != hashes,
+                "block filter hashes did not change across 3 epochs: prev={prev_hashes:?}, current={hashes:?}"
+            );
🤖 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/tool/subcommands/api_cmd/stateful_tests.rs` around lines 882 - 896,
Update the explanatory comment in the block-filter polling loop around
wait_next_epoch and poll to describe unchanged hashes as resulting from null
rounds with no block produced, not epochs without events. Add a diagnostic
message to the anyhow::ensure! assertion identifying that block filter hashes
did not change across the polling attempts, while preserving its existing
condition.

198-210: 🩺 Stability & Availability | 🔵 Trivial

Cumulative worst-case wait can reach ~9 minutes.

wait_next_epoch is bounded at 180s, but process_filter (lines 886-893) can call it up to 3 times, so a stuck-but-not-erroring chain could keep the test running for up to ~9 minutes before failing. Worth confirming this fits the CI test-timeout budget for stateful tests.

🤖 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/tool/subcommands/api_cmd/stateful_tests.rs` around lines 198 - 210,
Review the cumulative timeout between wait_next_epoch and process_filter, where
up to three 180-second waits can extend a stalled stateful test to roughly nine
minutes. Adjust the timeout or retry behavior in these symbols so the total
worst-case duration fits the CI stateful-test budget, while preserving
successful epoch advancement handling.
🤖 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.

Inline comments:
In `@src/tool/subcommands/api_cmd/stateful_tests.rs`:
- Around line 899-911: Update the cleanup flow around process_filter so an
uninstall failure cannot replace an earlier process_filter error. Preserve and
return the original result when it is already an error, while still propagating
uninstall failures when processing succeeded; retain the existing filter removal
validation.

---

Nitpick comments:
In `@src/tool/subcommands/api_cmd/stateful_tests.rs`:
- Around line 882-896: Update the explanatory comment in the block-filter
polling loop around wait_next_epoch and poll to describe unchanged hashes as
resulting from null rounds with no block produced, not epochs without events.
Add a diagnostic message to the anyhow::ensure! assertion identifying that block
filter hashes did not change across the polling attempts, while preserving its
existing condition.
- Around line 198-210: Review the cumulative timeout between wait_next_epoch and
process_filter, where up to three 180-second waits can extend a stalled stateful
test to roughly nine minutes. Adjust the timeout or retry behavior in these
symbols so the total worst-case duration fits the CI stateful-test budget, while
preserving successful epoch advancement handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8355bc2e-2c62-43c7-b9e9-6920f547e60a

📥 Commits

Reviewing files that changed from the base of the PR and between b707582 and 3c5a683.

📒 Files selected for processing (1)
  • src/tool/subcommands/api_cmd/stateful_tests.rs
🔗 Linked repositories identified

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

  • filecoin-project/lotus (manual)

Comment thread src/tool/subcommands/api_cmd/stateful_tests.rs
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.89%. Comparing base (b707582) to head (a34486f).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

see 21 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 b707582...a34486f. 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.

Comment thread src/tool/subcommands/api_cmd/stateful_tests.rs Outdated
LesnyRumcajs
LesnyRumcajs previously approved these changes Jul 21, 2026
@akaladarshi
akaladarshi added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 5385cf6 Jul 21, 2026
34 checks passed
@akaladarshi
akaladarshi deleted the akaladarshi/fix-stateful-test-failure branch July 21, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stateful tests for eth_newBlockFilter failing in CI

2 participants