Skip to content

feat: improve eth_getBlockReceipts perf - #7498

Merged
LesnyRumcajs merged 3 commits into
mainfrom
fix-log-collect
Aug 18, 2026
Merged

feat: improve eth_getBlockReceipts perf#7498
LesnyRumcajs merged 3 commits into
mainfrom
fix-log-collect

Conversation

@LesnyRumcajs

@LesnyRumcajs LesnyRumcajs commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary of changes

Changes introduced in this pull request:

  • improves event collection from quadratic to linear
  • less message re-hashing
  • checked correctness against riba dataset manually (mainnet 6277900–6279799 (~1900 epochs, 2026-08-14))
┌──────────┬─────────────────┬────────┬────────┬───────────┬────────────────┬─────────┬─────────┬──────────┐
│   net    │      range      │ blocks │ max rx │ NEW total │ BASELINE total │ speedup │ new/blk │ base/blk │
├──────────┼─────────────────┼────────┼────────┼───────────┼────────────────┼─────────┼─────────┼──────────┤
│ calibnet │ 3986400–3986637 │ 235    │ 73     │ 773 ms    │ 1303 ms        │ 1.69×   │ 3.29 ms │ 5.54 ms  │
├──────────┼─────────────────┼────────┼────────┼───────────┼────────────────┼─────────┼─────────┼──────────┤
│ mainnet  │ 6279600–6279838 │ 237    │ 27     │ 15 898 ms │ 30 611 ms      │ 1.93×   │ 67.1 ms │ 129.2 ms │
└──────────┴─────────────────┴────────┴────────┴───────────┴────────────────┴─────────┴─────────┴──────────┘

Per-large-block hot path (calibnet, 65–73 rx, warm 50 iters): new 2.7 ms vs baseline ~11 ms ≈ 4×.

so on average almost 2x improvement, bad case 4x (and in case of bigger blocks it only gets better).

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

  • 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

  • Bug Fixes
    • Improved Ethereum transaction receipts to include event logs more reliably.
    • Corrected event-log handling for reverted transactions.
    • Improved consistency of logs across block receipts and individual transaction lookups.
    • Improved receipt accuracy when multiple transactions emit logs within the same block.
    • Added clearer handling when event data is unavailable for the current chain head.
    • Improved event ordering and transaction association across messages, including messages without events.

@LesnyRumcajs LesnyRumcajs added the RPC requires calibnet RPC checks to run on CI label Aug 17, 2026
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 8 minutes

Limit details: You’ve used all 5 included reviews currently available under your plan. You completed 29 included PR reviews in the past 7 days; at that activity level, included reviews refill at 5 reviews per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c56c10d4-0d02-4ed5-bb9d-bc5d54a45b75

📥 Commits

Reviewing files that changed from the base of the PR and between e40e145 and 1db1535.

📒 Files selected for processing (1)
  • src/rpc/methods/eth/filter/mod.rs

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: 152ee50b-4b28-4a23-8598-e91bfa5895c8

📥 Commits

Reviewing files that changed from the base of the PR and between 2d915cb and e40e145.

📒 Files selected for processing (4)
  • src/rpc/methods/eth.rs
  • src/rpc/methods/eth/filter/mod.rs
  • src/shim/executor.rs
  • src/state_manager/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/rpc/methods/eth.rs

Included review availability: 1 review is currently available. Based on recent review activity, included reviews refill at 5 per hour.


Walkthrough

Ethereum receipt construction now accepts pre-collected logs. A shared helper collects logs for executed tipset messages. Block receipts collect logs once and distribute them by transaction index. Tests cover event indexing, emitter association, and revert status.

Changes

Ethereum receipt log handling

Layer / File(s) Summary
Receipt log collection contract
src/rpc/methods/eth.rs
new_eth_tx_receipt accepts supplied logs. collect_block_logs converts logs for executed messages and preserves applied or reverted status. Head-change collection uses the shared helper.
Block receipt log distribution
src/rpc/methods/eth.rs
Block receipt generation rejects event-bearing current or future head tipsets, collects logs once, distributes them by transaction index, and passes each bucket to receipt construction.
Individual receipt log loading
src/rpc/methods/eth.rs
Individual receipt lookup loads logs when events exist and passes them to the synchronous receipt constructor.
Event collection test coverage
src/rpc/methods/eth/filter/mod.rs, src/shim/executor.rs, src/state_manager/tests.rs
Shared fixtures and test-only event and receipt constructors support tests for revert status, message indices, event indices, and emitter associations.

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

Merge Risk: ⚪ Minimal · up to e40e1

This PR changes the receipt-collection implementation to improve performance, with no actionable merge-blocking risk identified at the current head.

Sequence Diagram(s)

sequenceDiagram
  participant RPC
  participant LogCollector
  participant ReceiptBuilder
  participant StateManager
  RPC->>StateManager: load tipset messages and receipts
  StateManager->>LogCollector: provide executed messages and events
  LogCollector->>ReceiptBuilder: provide logs grouped by transaction
  ReceiptBuilder->>RPC: return Ethereum transaction receipts
Loading

Suggested reviewers: eclesiomelojunior, hanabi1224, akaladarshi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: improving the performance of eth_getBlockReceipts.
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.
✨ 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 fix-log-collect
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix-log-collect

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

@LesnyRumcajs
LesnyRumcajs force-pushed the fix-log-collect branch 2 times, most recently from 5c5a855 to 6af045a Compare August 17, 2026 22:29
@LesnyRumcajs
LesnyRumcajs marked this pull request as ready for review August 17, 2026 22:31
@LesnyRumcajs
LesnyRumcajs requested a review from a team as a code owner August 17, 2026 22:31
@LesnyRumcajs
LesnyRumcajs requested review from EclesioMeloJunior and akaladarshi and removed request for a team August 17, 2026 22:31
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.22556% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.75%. Comparing base (1e9b885) to head (1db1535).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 71.11% 6 Missing and 7 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/methods/eth/filter/mod.rs 89.84% <100.00%> (+0.28%) ⬆️
src/shim/executor.rs 88.92% <100.00%> (+1.68%) ⬆️
src/rpc/methods/eth.rs 69.05% <71.11%> (+0.21%) ⬆️

... and 11 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 1e9b885...1db1535. 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/rpc/methods/eth.rs
Comment thread src/rpc/methods/eth.rs Outdated
@akaladarshi

Copy link
Copy Markdown
Contributor

@LesnyRumcajs Also if possible can we also include some tests to make sure the indexing of transaction is correct in collect_events_from_messages (transaction_index == msg_idx == executed_message) because we rely on it a lot.

I mean it is correct we already know that but just adding a test if possible might make it regression free.

@LesnyRumcajs

Copy link
Copy Markdown
Member Author

@LesnyRumcajs Also if possible can we also include some tests to make sure the indexing of transaction is correct in collect_events_from_messages (transaction_index == msg_idx == executed_message) because we rely on it a lot.

I mean it is correct we already know that but just adding a test if possible might make it regression free.

Yeah, it's a good invariant to lock.

@LesnyRumcajs
LesnyRumcajs enabled auto-merge August 18, 2026 09:40
@LesnyRumcajs
LesnyRumcajs added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit fe438e5 Aug 18, 2026
34 checks passed
@LesnyRumcajs
LesnyRumcajs deleted the fix-log-collect branch August 18, 2026 10:04
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.

2 participants