Skip to content

fix: execute-tipset-traces-parallelize#7107

Merged
hanabi1224 merged 2 commits into
mainfrom
execute-tipset-traces-parallelize
May 27, 2026
Merged

fix: execute-tipset-traces-parallelize#7107
hanabi1224 merged 2 commits into
mainfrom
execute-tipset-traces-parallelize

Conversation

@LesnyRumcajs

@LesnyRumcajs LesnyRumcajs commented May 26, 2026

Copy link
Copy Markdown
Member

Summary of changes

Changes introduced in this pull request:

  • parallelizes trace execution logic which was running in sequence. Most inefficient!

Reference issue to close (if applicable)

Closes

Other information and links

Numbers from #7110

# command
oha -n 1000 -c 1 -m POST http://localhost:2345/rpc/v1 -H 'Content-Type: application/json' -D trace_block_call.json

# payload
{
	"method": "trace_block",
	"params": [
		"0x5c4ce8"
	],
	"id": 328,
	"jsonrpc": "2.0"
}

# main
  Success rate:m100.00%   4m    5m    6m    7m    8m       ││0.0314  0.0701  0.1087  0.1474  0.1861  0.2248  0.2635    │
  Total:────────61728.4416 ms──────────────────────────────┘└──────────────────────────────────────────────────────────┘
  Slowest:      263.5058 ms
  Fastest:      31.3651 ms
  Average:      61.7077 ms
  Requests/sec: 16.2000

  Total data:   659.85 MiB
  Size/request: 675.69 KiB
  Size/sec:     10.69 MiB

Response time histogram:
   31.365 ms [1]   |
   54.579 ms [445] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
   77.793 ms [177] |■■■■■■■■■■■■
  101.007 ms [349] |■■■■■■■■■■■■■■■■■■■■■■■■■
  124.221 ms [5]   |
  147.435 ms [8]   |
  170.650 ms [13]  |
  193.864 ms [1]   |
  217.078 ms [0]   |
  240.292 ms [0]   |
  263.506 ms [1]   |

Response time distribution:
  10.00% in 33.7217 ms
  25.00% in 35.3091 ms
  50.00% in 68.3582 ms
  75.00% in 81.4580 ms
  90.00% in 84.6755 ms
  95.00% in 86.3642 ms
  99.00% in 158.7673 ms
  99.90% in 263.5058 ms
  99.99% in 263.5058 ms
  
# PR  
  Success rate: 100.00%30s    40s    50s    60s    70s     ││0.0299  0.0436  0.0573  0.0710  0.0846  0.0983  0.1120    │
  Total:────────41611.7485 ms──────────────────────────────┘└──────────────────────────────────────────────────────────┘
  Slowest:      119.1231 ms
  Fastest:      29.3240 ms
  Average:      41.5943 ms
  Requests/sec: 24.0317

  Total data:   659.85 MiB
  Size/request: 675.69 KiB
  Size/sec:     15.86 MiB

Response time histogram:
   29.324 ms [1]   |
   38.304 ms [502] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
   47.284 ms [303] |■■■■■■■■■■■■■■■■■■■
   56.264 ms [138] |■■■■■■■■
   65.244 ms [11]  |
   74.224 ms [6]   |
   83.203 ms [6]   |
   92.183 ms [14]  |
  101.163 ms [12]  |
  110.143 ms [5]   |
  119.123 ms [2]   |

Response time distribution:
  10.00% in 31.5868 ms
  25.00% in 33.3507 ms
  50.00% in 38.1203 ms
  75.00% in 46.4174 ms
  90.00% in 48.7285 ms
  95.00% in 61.7432 ms
  99.00% in 96.8557 ms
  99.90% in 119.1231 ms
  99.99% in 119.1231 ms

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

  • Refactor
    • Improved internal handling of Ethereum transaction operations for better code organization and maintainability. No changes to external APIs or user-facing functionality.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR refactors Ethereum trace execution in the RPC layer by extracting transaction hash resolution logic into a reusable helper, redesigning execute_tipset_traces to resolve hashes concurrently using tokio task spawning, and propagating the signature changes through all dependent trace helpers and RPC methods.

Changes

Ethereum trace execution refactoring

Layer / File(s) Summary
EthGetTransactionHashByCid extraction
src/rpc/methods/eth.rs
Added EthGetTransactionHashByCid::run(db, eth_chain_id, cid) helper that resolves transaction hashes via messages_from_cids with fallback to get_chain_message, updating the RpcMethod<1> implementation to delegate to this helper.
Parallel transaction hash resolution in execute_tipset_traces
src/rpc/methods/eth.rs
Refactored execute_tipset_traces to remove the ext parameter and resolve per-message transaction hashes concurrently using tokio::task::JoinSet with spawn_blocking, gathering results and sorting by message position.
Trace helper and RPC method callsites
src/rpc/methods/eth.rs
Updated eth_trace_block, eth_trace_replay_block_transactions, EthDebugTraceTransaction, debug_trace_transaction, EthTraceTransaction, and EthTraceReplayBlockTransactions to use the new execute_tipset_traces signature without ext and to pass precomputed api_path where applicable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ChainSafe/forest#7001: Both PRs modify src/rpc/methods/eth.rs trace execution (execute_tipset_traces and related eth_trace* paths) to compute and order transaction positioning in trace results.

Suggested labels

RPC

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 33.33% 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 'fix: execute-tipset-traces-parallelize' directly reflects the main change: parallelizing trace execution logic in the execute_tipset_traces function, which is the primary focus of the PR.
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 execute-tipset-traces-parallelize
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch execute-tipset-traces-parallelize

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

@LesnyRumcajs

Copy link
Copy Markdown
Member Author

@hanabi1224

@LesnyRumcajs LesnyRumcajs force-pushed the execute-tipset-traces-parallelize branch from 999b3ad to 7a7f15a Compare May 27, 2026 08:49
Co-authored-by: Hubert Bugaj <lesny.rumcajs+github@gmail.com>
@LesnyRumcajs LesnyRumcajs marked this pull request as ready for review May 27, 2026 08:56
@LesnyRumcajs LesnyRumcajs requested a review from a team as a code owner May 27, 2026 08:56
@LesnyRumcajs LesnyRumcajs requested review from akaladarshi and hanabi1224 and removed request for a team May 27, 2026 08:56
@LesnyRumcajs LesnyRumcajs added the RPC requires calibnet RPC checks to run on CI label May 27, 2026

@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

🤖 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/rpc/methods/eth.rs`:
- Around line 3497-3524: The execute_tipset_traces loop spawns unbounded
blocking tasks for each non-system message (spawn_blocking calling
EthGetTransactionHashByCid::run) which can saturate Tokio and leaves in-flight
tasks running if an early error causes an immediate return; wrap the spawn logic
with a bounded in-flight semaphore (e.g., tokio::sync::Semaphore.acquire_owned)
to limit concurrent blocking tasks, make each spawn_blocking release the permit
when its closure finishes, and on encountering an error from a joined task call
join_set.abort_all() then drain remaining joins (await join_set.join_next()
until None) before returning the error so no background work is leaked or the
blocking pool is saturated.
🪄 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: b31ebb4e-77c3-4685-957f-c75fac54233f

📥 Commits

Reviewing files that changed from the base of the PR and between ee2a7e6 and 0e00a75.

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

Comment thread src/rpc/methods/eth.rs
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.41%. Comparing base (ee2a7e6) to head (0e00a75).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 70.00% 5 Missing and 7 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/methods/eth.rs 65.22% <70.00%> (-0.06%) ⬇️

... and 6 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 ee2a7e6...0e00a75. 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 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@hanabi1224 hanabi1224 added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit 0d71649 May 27, 2026
62 of 85 checks passed
@hanabi1224 hanabi1224 deleted the execute-tipset-traces-parallelize branch May 27, 2026 16:51
@coderabbitai coderabbitai Bot mentioned this pull request Jun 9, 2026
6 tasks
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