Skip to content

Conversation

@sudo-shashank
Copy link
Contributor

@sudo-shashank sudo-shashank commented Sep 23, 2025

Summary of changes

Changes introduced in this pull request:

  • Fix test

Reference issue to close (if applicable)

Closes #6069

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.

Summary by CodeRabbit

  • Tests
    • Updated block filter tests to accept cases with empty or differing hash sets, reducing false negatives.
    • Re-enabled a previously ignored test, increasing coverage and CI validation.
    • No user-facing behavior or API changes; improves reliability of the test suite.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Walkthrough

Adjusts the eth_newBlockFilter stateful test to accept an additional valid outcome (both empty hash lists) and removes the ignore reason from its registration, enabling the test without an explicit ignore rationale.

Changes

Cohort / File(s) Summary of Changes
Test assertion update
src/tool/subcommands/api_cmd/stateful_tests.rs
Modified eth_new_block_filter test: assertion now allows prev_hashes and hashes to both be empty OR to differ; previously required inequality only.
Test registry cleanup
src/tool/subcommands/api_cmd/stateful_tests.rs
Removed ignore reason from EthNewBlockFilter test entry; now constructs eth_new_block_filter with name only.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • LesnyRumcajs
  • akaladarshi

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 "Fix eth_new_block_filter test" is concise, specific, and directly reflects the primary change in the diff, which updates the eth_new_block_filter test in stateful_tests.rs to avoid the previously failing assertion; it communicates the developer's intent without extraneous detail. The phrasing is short and clear for teammates scanning PR history. No edits to the title are necessary.
Linked Issues Check ✅ Passed The changes modify the eth_new_block_filter test to allow the case where prev_hashes and hashes are both empty and remove the ignore marker so the test runs, which directly addresses the failing assertion described in issue #6069. The diff is limited to test logic and test registration and does not alter production code, matching the linked issue's objective to restore the test to passing after the GoldenWeek upgrade. Based on the provided summaries, the PR satisfies the coding-related requirement to fix the failing test and claims to close #6069.
Out of Scope Changes Check ✅ Passed All modifications in the provided summary are confined to src/tool/subcommands/api_cmd/stateful_tests.rs and only adjust test assertions and test registration; the summary also indicates no exported or public signatures were changed, so there are no apparent out-of-scope code changes relative to the linked issue. The change set appears properly scoped to fixing the failing eth_new_block_filter test.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch shashank/fix-newblock-filter

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

@sudo-shashank sudo-shashank marked this pull request as ready for review September 24, 2025 03:28
@sudo-shashank sudo-shashank requested a review from a team as a code owner September 24, 2025 03:28
@sudo-shashank sudo-shashank requested review from LesnyRumcajs, akaladarshi and elmattic and removed request for a team September 24, 2025 03:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

407-411: Avoid false positives: re-poll once if both lists are empty before passing

Allowing both empty is reasonable post-GoldenWeek, but it weakens the assertion: the test can pass even if the filter never yields hashes after an apply. Do a single extra tipset wait and re-poll to reduce flakiness while still accommodating empty deltas.

Apply this diff:

                 if let EthFilterResult::Hashes(hashes) = filter_result {
                     verify_hashes(&hashes).await?;
-                    anyhow::ensure!(
-                        (prev_hashes.is_empty() && hashes.is_empty()) || prev_hashes != hashes,
-                    );
+                    if prev_hashes.is_empty() && hashes.is_empty() {
+                        // Second-chance: avoid passing on transient emptiness (ref. #6069)
+                        next_tipset(client).await?;
+                        let filter_result2 = client
+                            .call(EthGetFilterChanges::request((filter_id.clone(),))?)
+                            .await?;
+                        if let EthFilterResult::Hashes(hashes2) = filter_result2 {
+                            verify_hashes(&hashes2).await?;
+                            anyhow::ensure!(
+                                !(prev_hashes.is_empty() && hashes2.is_empty()),
+                                "eth_newBlockFilter produced no hashes after two consecutive tipsets"
+                            );
+                        } else {
+                            anyhow::bail!("expecting blocks");
+                        }
+                    } else {
+                        anyhow::ensure!(prev_hashes != hashes);
+                    }

637-641: Good to un-ignore; optionally include EthGetBlockByHash in used_methods for accurate filtering

This test uses EthGetBlockByHash in verify_hashes; adding it improves method-based filtering/discovery.

         with_methods!(
-            eth_new_block_filter().name("eth_newBlockFilter works"),
+            eth_new_block_filter().name("eth_newBlockFilter works"),
             EthNewBlockFilter,
             EthGetFilterChanges,
-            EthUninstallFilter
+            EthUninstallFilter,
+            EthGetBlockByHash
         ),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8524d3 and 072bcc0.

📒 Files selected for processing (1)
  • src/tool/subcommands/api_cmd/stateful_tests.rs (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/tool/subcommands/api_cmd/stateful_tests.rs (2)
src/rpc/methods/eth.rs (1)
  • is_empty (460-465)
src/rpc/methods/eth/types.rs (1)
  • is_empty (565-570)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests
  • GitHub Check: tests-release

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

Does this make sense @elmattic ?

@elmattic
Copy link
Contributor

elmattic commented Sep 24, 2025

Does this make sense @elmattic ?

Yes, only if one of the two blocks has no transactions, then we need to ensure that the hashes are different. This was a corner case that was overlooked.

@sudo-shashank sudo-shashank added this pull request to the merge queue Sep 24, 2025
Merged via the queue into main with commit a68b350 Sep 24, 2025
45 checks passed
@sudo-shashank sudo-shashank deleted the shashank/fix-newblock-filter branch September 24, 2025 12:31
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.

eth_newBlockFilter test is failing

4 participants