Skip to content

Conversation

@itamar-starkware
Copy link
Contributor

@itamar-starkware itamar-starkware commented Nov 10, 2025

TL;DR

Made get_block_info in MempoolStateReader trait async to avoid blocking operations.

What changed?

  • Modified the MempoolStateReader trait to make get_block_info an async function
  • Updated implementations in RpcStateReader, SyncStateReader, and TestStateReader to be async
  • Added #[async_trait] attribute to the trait and its implementations
  • In RpcStateReader, moved the RPC request to a spawn_blocking task to prevent blocking the async runtime
  • Removed the use of block_on in SyncStateReader in favor of proper async/await
  • Updated all callers to use .await when calling get_block_info

How to test?

Run the existing tests which have been updated to use the async version of get_block_info:

  • test_get_block_info in rpc_state_reader_test.rs
  • test_get_block_info in sync_state_reader_test.rs

Why make this change?

This change improves the asynchronous behavior of the codebase by ensuring that potentially blocking operations like RPC requests don't block the async runtime. By making get_block_info async, we can properly handle I/O operations without blocking threads, which leads to better resource utilization and scalability.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

itamar-starkware commented Nov 10, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants