Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(advanced): Provider trait over reth-db #144

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

yash-atreya
Copy link
Member

@yash-atreya yash-atreya commented Sep 25, 2024

Motivation

In the latest release of alloy-0.3.6, ProviderCall was introduced as a return type in the Provider trait.

ProviderCall enables to fetch the result of an RPC call from any data source such as the node's db, cache etc.

More on this can be found here alloy-rs/alloy#788

Solution

Example showing how to wrap the Provider trait over reth-db and use ProviderCall to fetch responses from the db directly.

PR Checklist

  • Added Documentation
  • Breaking changes

@yash-atreya yash-atreya changed the title feat(advanced): Provider trait over reth-db feat(advanced): Provider trait over reth-db Sep 25, 2024
@yash-atreya yash-atreya marked this pull request as ready for review September 26, 2024 06:36
examples/advanced/Cargo.toml Outdated Show resolved Hide resolved
examples/advanced/examples/reth_db_provider.rs Outdated Show resolved Hide resolved
examples/advanced/examples/reth_db_provider.rs Outdated Show resolved Hide resolved
examples/advanced/examples/reth_db_provider.rs Outdated Show resolved Hide resolved
Comment on lines +208 to +210
struct WrapProviderFactory {
inner: Arc<ProviderFactory<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>>,
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer if we could operate entirely on traits here

ptal @klkvr

Copy link
Member

Choose a reason for hiding this comment

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

it's a bit tricky rn because ProviderFactory implements getters for state providers directly and not through trait: https://github.com/paradigmxyz/reth/blob/ba4e41110b87cccda21d588e0a59bc94ee910e80/crates/storage/provider/src/providers/database/mod.rs#L164

however, we could use TryIntoHistoricalStateProvider trait directly on db provider

so the resulting bound would look like DatabaseProviderFactory<Provider: TryIntoHistoricalStateProvider> + BlockNumReader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants