Skip to content

feat(rpc): Convert state_at_block_id into async function#17954

Merged
mattsse merged 1 commit intomainfrom
async-state-at
Aug 20, 2025
Merged

feat(rpc): Convert state_at_block_id into async function#17954
mattsse merged 1 commit intomainfrom
async-state-at

Conversation

@RomanHodulak
Copy link
Contributor

@RomanHodulak RomanHodulak commented Aug 20, 2025

Follow-up on #17924

This makes the existing state_at_block_id async, despite them not having any async call at the moment. This is a preparation for introducing async pending_state function and calling it inside this function.

There are two places that previously used spawn_tracing that were replaced with spawn_blocking_io_fut.

  1. https://github.com/paradigmxyz/reth/blob/main/crates/rpc/rpc-eth-api/src/helpers/call.rs#L541
  2. https://github.com/paradigmxyz/reth/blob/main/crates/rpc/rpc-eth-api/src/helpers/trace.rs#L305

I haven't found a simple way to make spawn_tracing accept futures, nor am I sure that such thing makes sense. However, the call place is not really benefiting from using the rayon pool, which is what spawn_tracing is used for. And the second place, the trace API, might benefit from it, but trace API is not affecting production path, hence it is not as speed critical.

If we really wanted to keep spawn_tracing, one idea is to also put the async call to state_at_block_id outside of the callback. This, however, causes a mysterious higher-ranked lifetime error - I tried a few simple fixes unsuccessfully like:

  • Introducing use<>
  • Making a use of StateProviderTraitObjWrapper

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

makes sense

most existing trace calls that were previously spawned on rayon pool do a lot of IO and should really be spawned on blocking

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Aug 20, 2025
@mattsse mattsse added this pull request to the merge queue Aug 20, 2025
@mattsse mattsse added A-rpc Related to the RPC implementation A-sdk Related to reth's use as a library labels Aug 20, 2025
Merged via the queue into main with commit 441bad8 Aug 20, 2025
43 checks passed
@mattsse mattsse deleted the async-state-at branch August 20, 2025 14:24
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Aug 20, 2025
lwedge99 pushed a commit to sentioxyz/reth that referenced this pull request Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rpc Related to the RPC implementation A-sdk Related to reth's use as a library

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants