Skip to content

feat(rpc): Use pool-based pending block for pending state over latest#17924

Merged
mattsse merged 1 commit intomainfrom
pool-pending-block
Aug 21, 2025
Merged

feat(rpc): Use pool-based pending block for pending state over latest#17924
mattsse merged 1 commit intomainfrom
pool-pending-block

Conversation

@RomanHodulak
Copy link
Contributor

Closes #17876

For LoadState trait based RPC features, use pool-based pending block before using latest block if no pending block from consensus layer is available.

A feature useful for MEV / flashblocks use-cases.

@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Aug 18, 2025
@github-actions github-actions bot added A-rpc Related to the RPC implementation A-sdk Related to reth's use as a library C-enhancement New feature or request labels Aug 18, 2025
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.

imo this goes in the right direction,

because this is a bit tricky, I'd like to start smaller and first focussing on making the state_at fn async

for the state I think we should introduce a placeholder pending_state fn first then we don't need to touch the local_pending block fn for now

@RomanHodulak RomanHodulak marked this pull request as ready for review August 21, 2025 11:10
@RomanHodulak RomanHodulak requested a review from mattsse August 21, 2025 11:10
Comment on lines +224 to +230
if at.is_pending() {
if let Ok(Some(state)) = self.local_pending_state().await {
return Ok(state)
}
}

self.provider().state_by_block_id(at).map_err(Self::Error::from_eth_err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this will no ignore the real pending state right?

hmm, this is a bit tricky because we don't have a nice way to obtain just the optional pending state from the provider, only if the real pending block exists, but imo we could ignore this case for now and then add this functionality separately as an additional optional fn to:

/// Storage provider for pending state.
///
/// Represents the state at the block that extends the canonical chain by one.
/// If there's no `pending` block, then this is equal to [`StateProviderFactory::latest`]
fn pending(&self) -> ProviderResult<StateProviderBox>;

as fn maybe_pending?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, this won't ignore the real pending state.

However, the local_pending_state only returns the pool-based pending state, not the real pending state.

@mattsse mattsse added this pull request to the merge queue Aug 21, 2025
Merged via the queue into main with commit aabeb06 Aug 21, 2025
41 checks passed
@mattsse mattsse deleted the pool-pending-block branch August 21, 2025 11:56
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Aug 21, 2025
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 22, 2026
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Feb 11, 2026
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 C-enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Actually respect pending state for pending tag

2 participants