Skip to content

chore(trie): Implement OverlayStateProviderFactory#18854

Merged
mediocregopher merged 11 commits into18460-trie-changesetsfrom
mediocregopher/18466-overlay-state-provider-factory
Oct 6, 2025
Merged

chore(trie): Implement OverlayStateProviderFactory#18854
mediocregopher merged 11 commits into18460-trie-changesetsfrom
mediocregopher/18466-overlay-state-provider-factory

Conversation

@mediocregopher
Copy link
Member

@mediocregopher mediocregopher commented Oct 3, 2025

This implements the OverlayStateProviderFactory, which intends on replacing the ConsistentDbView for use with proof fetching.

When creating a new OverlayStateProvider, the OverlayStateProviderFactory can be configured to first revert that provider's state to a particular block number (similar to the HistoricalStateProvider) and then also apply some other overlay state on top of it. This gives us full flexibility in computing proofs on top of re-org chains, even if they are based on block prior to the db tip.

It uses a new method trie_reverts to fetch trie changesets, alongside HashedPostState reverts using the existing method for that. With these two it is able to revert to any previous block for every provider it generates, ensuring a consistent view of the data. In the future if we switch to using tx children then the factory can fetch the reverts as part of its own constructor, rather than on every new provider.

This PR required adding the ability to extend the HashedPostStateSorted and TrieUpdatesSorted types. This is implemented fairly efficiently by updating the collection in-place with updates/removals, and then appending additions onto the back and sorting.

Closes #18466

@mediocregopher mediocregopher marked this pull request as ready for review October 6, 2025 11:50
Copy link
Member

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

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

LGTM, nits

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Oct 6, 2025
Copy link
Member

@yongkangc yongkangc left a comment

Choose a reason for hiding this comment

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

lgtm! p clear

@mediocregopher mediocregopher merged commit 3706961 into 18460-trie-changesets Oct 6, 2025
37 checks passed
@mediocregopher mediocregopher deleted the mediocregopher/18466-overlay-state-provider-factory branch October 6, 2025 15:02
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants