Skip to content

fix(eth): scope receipt logs by message, cap event filter, max rpc size#7025

Merged
sudo-shashank merged 1 commit into
mainfrom
worktree-fix+eth-receipt-logs-scope-event-filter-cap
May 12, 2026
Merged

fix(eth): scope receipt logs by message, cap event filter, max rpc size#7025
sudo-shashank merged 1 commit into
mainfrom
worktree-fix+eth-receipt-logs-scope-event-filter-cap

Conversation

@LesnyRumcajs
Copy link
Copy Markdown
Member

@LesnyRumcajs LesnyRumcajs commented May 8, 2026

Summary of changes

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes

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

  • New Features

    • Added FOREST_RPC_MAX_RESPONSE_BODY_SIZE env var to configure RPC response body size limits.
    • Event filtering supports scoping by message CID for more precise log queries.
  • Bug Fixes

    • Fixed eth_getTransactionReceipt failing when a tipset contains transactions that emit many events.
    • RPC returns a clear "events not yet available" error for queries against unavailable tipsets.
  • Documentation

    • Updated CHANGELOG and config docs with the new env var and event-filter behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Walkthrough

This PR configures the JSON-RPC response body size limit via environment variable and refactors event filtering to support per-message CID scoping. Transaction receipts now scope logs to specific messages, and deferred execution for future chain events is explicitly rejected with a new error variant.

Changes

RPC Response Size Configuration

Layer / File(s) Summary
Environment-based Configuration
src/rpc/mod.rs
Response body size limit is moved from fixed constant to LazyLock reading FOREST_RPC_MAX_RESPONSE_BODY_SIZE environment variable, defaulting to 64 MiB.
Client HTTP/WS Configuration
src/rpc/client.rs
HTTP and WebSocket client builders dereference the LazyLock constant when setting max_response_size.
Documentation
CHANGELOG.md
Changelog entry documents the new FOREST_RPC_MAX_RESPONSE_BODY_SIZE environment variable.

Event Filtering with Message CID Support

Layer / File(s) Summary
Filter Data Model
src/rpc/methods/eth/filter/mod.rs
ParsedFilter gains msg_cid: Option<Cid> field; Matcher trait gains msg_cid_filter() hook; new constructor new_with_tipset_and_msg() added.
Filter Construction
src/rpc/methods/eth/filter/mod.rs, src/rpc/methods/eth/filter/event.rs
All filter construction paths initialize msg_cid (parsing, actor conversion, EventFilter→ParsedFilter conversion, tests/fixtures).
Event Collection Logic
src/rpc/methods/eth/filter/mod.rs
collect_events_for_tipsets now tracks contributing tipsets and applies ensure_filter_cap (disables cap for single tipset, enforces for multiple); collect_events filters events by message CID while preserving monotonic event_idx.
Deferred Execution Error
src/rpc/methods/eth/errors.rs, src/rpc/methods/eth/filter/mod.rs
New EthErrors::EventsNotYetAvailable returned for ranges at/after head; mapped in RpcErrorData with unit test.
Transaction Receipt Integration
src/rpc/methods/eth.rs
new_eth_tx_receipt accepts msg_cid; eth_logs_for_block_and_transaction signature changed to take msg_cid and build a filter scoped to block+message; call sites pass message CID.
Log Refactoring
src/rpc/methods/eth.rs, src/rpc/methods/chain.rs
eth_logs_with_filter no longer post-filters by tx_hash; eth_filter_logs_from_events rewritten to directly build EthLog entries with cached lookups (msg_cid→tx_hash, tipset_key→block_hash, address conversion); transform_events removed; chain.rs call simplified.
Configuration Documentation
src/cli_shared/cli/config.rs
EventsConfig fields documented: max_filter_results behavior across tipsets and max_filter_height_range description.
Tests / Fixtures
src/rpc/methods/eth/filter/mod.rs, src/rpc/methods/eth/filter/event.rs
Tests added for msg_cid_filter behavior and ensure_filter_cap semantics; test fixtures updated to initialize msg_cid: None.
Changelog
CHANGELOG.md
Documents fix: eth_getTransactionReceipt no longer fails with large event counts in the same tipset and clarifies max_filter_results scope.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • hanabi1224
  • akaladarshi
  • sudo-shashank
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.50% 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 accurately summarizes the three main objectives: scoping receipt logs by message, capping the event filter, and making RPC response size configurable.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 worktree-fix+eth-receipt-logs-scope-event-filter-cap
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch worktree-fix+eth-receipt-logs-scope-event-filter-cap

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@LesnyRumcajs LesnyRumcajs added the RPC requires calibnet RPC checks to run on CI label May 8, 2026
@LesnyRumcajs LesnyRumcajs force-pushed the worktree-fix+eth-receipt-logs-scope-event-filter-cap branch 2 times, most recently from 69878eb to 63d715e Compare May 11, 2026 11:46
@LesnyRumcajs LesnyRumcajs marked this pull request as ready for review May 11, 2026 11:47
@LesnyRumcajs LesnyRumcajs requested a review from a team as a code owner May 11, 2026 11:47
@LesnyRumcajs LesnyRumcajs requested review from hanabi1224 and sudo-shashank and removed request for a team May 11, 2026 11:47
Copy link
Copy Markdown
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: 2

🤖 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 `@CHANGELOG.md`:
- Line 32: Update the changelog entries that currently reference PR `#7024` to the
correct PR number `#7025`: replace the markdown link targets and displayed numbers
(e.g., the link text "[`#7024`](...)" and any other occurrences) with
"[`#7025`](...)" for both instances mentioned (the entry describing
FOREST_RPC_MAX_RESPONSE_BODY_SIZE around the earlier block and the duplicate at
the later block), ensuring the links point to the PR rather than an issue and
that the displayed PR number matches the URL.

In `@src/rpc/methods/eth/filter/mod.rs`:
- Around line 93-109: The cap exemption currently uses tipsets_contributing <= 1
which allows wide-range queries to bypass max_filter_results if all matches
happen to fall in one tipset; instead, change the logic to gate the exemption on
the *requested filter shape* (e.g., whether the RPC requested a single-height
range or a block-hash/Key filter) not on post-hoc match distribution.
Concretely, modify ensure_filter_cap (and the analogous logic at the other
occurrence) to accept a boolean like is_single_block_query /
requested_single_height_or_hash and replace the tipsets_contributing <= 1 check
with that flag (keep max_filter_results == 0 to disable cap entirely); update
call sites to pass true only when the caller explicitly asked for a
single-block/hash/single-height range.
🪄 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: 61c62217-58a9-4bc6-90e6-896beeebb5ca

📥 Commits

Reviewing files that changed from the base of the PR and between 7bef5d7 and 63d715e.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • src/cli_shared/cli/config.rs
  • src/rpc/client.rs
  • src/rpc/methods/chain.rs
  • src/rpc/methods/eth.rs
  • src/rpc/methods/eth/errors.rs
  • src/rpc/methods/eth/filter/event.rs
  • src/rpc/methods/eth/filter/mod.rs
  • src/rpc/mod.rs

Comment thread CHANGELOG.md Outdated
Comment thread src/rpc/methods/eth/filter/mod.rs
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 88.81988% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.16%. Comparing base (17e1991) to head (d0a9a49).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 76.78% 6 Missing and 7 partials ⚠️
src/rpc/methods/eth/filter/mod.rs 96.59% 2 Missing and 1 partial ⚠️
src/rpc/methods/chain.rs 0.00% 1 Missing ⚠️
src/rpc/methods/eth/filter/event.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/cli_shared/cli/config.rs 100.00% <ø> (ø)
src/rpc/client.rs 46.37% <100.00%> (ø)
src/rpc/methods/eth/errors.rs 74.13% <100.00%> (+4.75%) ⬆️
src/rpc/mod.rs 89.36% <100.00%> (+0.03%) ⬆️
src/rpc/methods/chain.rs 56.07% <0.00%> (ø)
src/rpc/methods/eth/filter/event.rs 84.48% <50.00%> (-1.24%) ⬇️
src/rpc/methods/eth/filter/mod.rs 90.09% <96.59%> (+1.13%) ⬆️
src/rpc/methods/eth.rs 65.22% <76.78%> (-0.34%) ⬇️

... and 14 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17e1991...d0a9a49. 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.

@LesnyRumcajs LesnyRumcajs force-pushed the worktree-fix+eth-receipt-logs-scope-event-filter-cap branch from 63d715e to 802ba2c Compare May 11, 2026 12:10
Copy link
Copy Markdown
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.

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

115-125: ⚡ Quick win

Assert the fallback RPC code, not only the message.

Line 120 states fallback-to-default behavior, but the test currently validates only the message. Add a code assertion so this contract doesn’t regress silently.

Proposed test hardening
 #[test]
 fn test_events_not_yet_available_converts_to_server_error() {
     let err = EthErrors::EventsNotYetAvailable;
     let server_err: ServerError = err.into();
+    let default_server_err: ServerError = anyhow::anyhow!("baseline").into();

     // No specific RPC error code is assigned; falls back to default.
+    assert_eq!(
+        server_err.inner().code(),
+        default_server_err.inner().code()
+    );
     assert_eq!(
         server_err.message(),
         "events for the requested block are not yet available"
     );
 }
🤖 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/errors.rs` around lines 115 - 125, The test
test_events_not_yet_available_converts_to_server_error currently only checks the
error message; add an assertion that the RPC error code falls back to the
default as promised. After creating server_err from
EthErrors::EventsNotYetAvailable, assert that server_err.code() (or the
appropriate accessor on ServerError) equals the ServerError default RPC code
(e.g. ServerError::default_rpc_code() or the module's DEFAULT RPC code constant)
so the fallback-to-default behavior is enforced.
🤖 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.

Nitpick comments:
In `@src/rpc/methods/eth/errors.rs`:
- Around line 115-125: The test
test_events_not_yet_available_converts_to_server_error currently only checks the
error message; add an assertion that the RPC error code falls back to the
default as promised. After creating server_err from
EthErrors::EventsNotYetAvailable, assert that server_err.code() (or the
appropriate accessor on ServerError) equals the ServerError default RPC code
(e.g. ServerError::default_rpc_code() or the module's DEFAULT RPC code constant)
so the fallback-to-default behavior is enforced.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: df620788-9cb3-4998-8e26-6e50bfccebc8

📥 Commits

Reviewing files that changed from the base of the PR and between 63d715e and 802ba2c.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • src/cli_shared/cli/config.rs
  • src/rpc/client.rs
  • src/rpc/methods/chain.rs
  • src/rpc/methods/eth.rs
  • src/rpc/methods/eth/errors.rs
  • src/rpc/methods/eth/filter/event.rs
  • src/rpc/methods/eth/filter/mod.rs
  • src/rpc/mod.rs
✅ Files skipped from review due to trivial changes (3)
  • src/rpc/methods/eth/filter/event.rs
  • src/cli_shared/cli/config.rs
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/rpc/mod.rs
  • src/rpc/client.rs
  • src/rpc/methods/eth/filter/mod.rs
  • src/rpc/methods/eth.rs

sudo-shashank
sudo-shashank previously approved these changes May 12, 2026
Copy link
Copy Markdown
Contributor

@sudo-shashank sudo-shashank left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread src/rpc/methods/eth/errors.rs
@LesnyRumcajs LesnyRumcajs force-pushed the worktree-fix+eth-receipt-logs-scope-event-filter-cap branch from 802ba2c to d0a9a49 Compare May 12, 2026 08:11
Copy link
Copy Markdown
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.

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

3124-3148: ⚡ Quick win

Add context to the new fallible log-conversion paths.

These ? sites now sit on the critical path for every returned log. If one fails, the RPC error will be hard to tie back to the offending event/message without extra context.

♻️ Suggested improvement
-            match eth_tx_hash_from_message_cid(ctx.store(), &event.msg_cid, chain_id)? {
+            match eth_tx_hash_from_message_cid(ctx.store(), &event.msg_cid, chain_id)
+                .with_context(|| {
+                    format!("failed to derive transaction hash for event message {}", event.msg_cid)
+                })? {
                 Some(h) => {
                     tx_hash_by_msg.insert(event.msg_cid, h);
                     h
@@
-            let h: EthHash = event.tipset_key.cid()?.into();
+            let h: EthHash = event
+                .tipset_key
+                .cid()
+                .context("failed to derive block hash from event tipset key")?
+                .into();
@@
-            let a = EthAddress::from_filecoin_address(&event.emitter_addr)?;
+            let a = EthAddress::from_filecoin_address(&event.emitter_addr)
+                .with_context(|| {
+                    format!("failed to convert event emitter {} to an Ethereum address", event.emitter_addr)
+                })?;

As per coding guidelines "Use anyhow::Result for most operations and add context with .context() when errors occur".

🤖 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 3124 - 3148, The fallible conversions on
the critical path (eth_tx_hash_from_message_cid(ctx.store(), &event.msg_cid,
chain_id)?, event.tipset_key.cid()?, and
EthAddress::from_filecoin_address(&event.emitter_addr)?) must attach context so
RPC errors can be traced to the offending event; wrap each `?`-returning call
with anyhow context (e.g. `.context(...)`) that includes identifying info such
as the event.msg_cid, event.tipset_key, and event.emitter_addr, and update the
error messages in the branches using those symbols
(eth_tx_hash_from_message_cid, tipset_key.cid,
EthAddress::from_filecoin_address) to provide clear, concise context for
debugging.
🤖 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.

Nitpick comments:
In `@src/rpc/methods/eth.rs`:
- Around line 3124-3148: The fallible conversions on the critical path
(eth_tx_hash_from_message_cid(ctx.store(), &event.msg_cid, chain_id)?,
event.tipset_key.cid()?, and
EthAddress::from_filecoin_address(&event.emitter_addr)?) must attach context so
RPC errors can be traced to the offending event; wrap each `?`-returning call
with anyhow context (e.g. `.context(...)`) that includes identifying info such
as the event.msg_cid, event.tipset_key, and event.emitter_addr, and update the
error messages in the branches using those symbols
(eth_tx_hash_from_message_cid, tipset_key.cid,
EthAddress::from_filecoin_address) to provide clear, concise context for
debugging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a66722fe-c3a8-4ab9-81e2-5cf46d5929bf

📥 Commits

Reviewing files that changed from the base of the PR and between 802ba2c and d0a9a49.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • src/cli_shared/cli/config.rs
  • src/rpc/client.rs
  • src/rpc/methods/chain.rs
  • src/rpc/methods/eth.rs
  • src/rpc/methods/eth/errors.rs
  • src/rpc/methods/eth/filter/event.rs
  • src/rpc/methods/eth/filter/mod.rs
  • src/rpc/mod.rs
✅ Files skipped from review due to trivial changes (3)
  • src/rpc/methods/eth/filter/event.rs
  • CHANGELOG.md
  • src/cli_shared/cli/config.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/rpc/methods/chain.rs
  • src/rpc/client.rs
  • src/rpc/methods/eth/errors.rs
  • src/rpc/mod.rs
  • src/rpc/methods/eth/filter/mod.rs

@LesnyRumcajs LesnyRumcajs enabled auto-merge May 12, 2026 13:16
@LesnyRumcajs LesnyRumcajs added this pull request to the merge queue May 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 12, 2026
@sudo-shashank sudo-shashank added this pull request to the merge queue May 12, 2026
Merged via the queue into main with commit 64bc264 May 12, 2026
43 checks passed
@sudo-shashank sudo-shashank deleted the worktree-fix+eth-receipt-logs-scope-event-filter-cap branch May 12, 2026 14:25
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.

3 participants