mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-11 00:08:13 -05:00
feat: add alloy-provider crate for RPC-based state access (#16809)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Federico Gimenez <federico.gimenez@gmail.com>
This commit is contained in:
1
.github/assets/check_wasm.sh
vendored
1
.github/assets/check_wasm.sh
vendored
@@ -58,6 +58,7 @@ exclude_crates=(
|
||||
reth-ress-provider
|
||||
# The following are not supposed to be working
|
||||
reth # all of the crates below
|
||||
reth-alloy-provider
|
||||
reth-invalid-block-hooks # reth-provider
|
||||
reth-libmdbx # mdbx
|
||||
reth-mdbx-sys # mdbx
|
||||
|
||||
28
Cargo.lock
generated
28
Cargo.lock
generated
@@ -7142,6 +7142,34 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reth-alloy-provider"
|
||||
version = "1.4.8"
|
||||
dependencies = [
|
||||
"alloy-consensus",
|
||||
"alloy-eips",
|
||||
"alloy-network",
|
||||
"alloy-primitives",
|
||||
"alloy-provider",
|
||||
"alloy-rpc-types",
|
||||
"alloy-rpc-types-engine",
|
||||
"reth-chainspec",
|
||||
"reth-db-api",
|
||||
"reth-errors",
|
||||
"reth-execution-types",
|
||||
"reth-node-types",
|
||||
"reth-primitives",
|
||||
"reth-provider",
|
||||
"reth-prune-types",
|
||||
"reth-stages-types",
|
||||
"reth-storage-api",
|
||||
"reth-trie",
|
||||
"revm",
|
||||
"revm-primitives",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reth-basic-payload-builder"
|
||||
version = "1.4.8"
|
||||
|
||||
@@ -11,6 +11,7 @@ exclude = [".github/"]
|
||||
members = [
|
||||
"bin/reth-bench/",
|
||||
"bin/reth/",
|
||||
"crates/alloy-provider/",
|
||||
"crates/chain-state/",
|
||||
"crates/chainspec/",
|
||||
"crates/cli/cli/",
|
||||
@@ -319,6 +320,7 @@ codegen-units = 1
|
||||
# reth
|
||||
op-reth = { path = "crates/optimism/bin" }
|
||||
reth = { path = "bin/reth" }
|
||||
reth-alloy-provider = { path = "crates/alloy-provider" }
|
||||
reth-basic-payload-builder = { path = "crates/payload/basic" }
|
||||
reth-bench = { path = "bin/reth-bench" }
|
||||
reth-chain-state = { path = "crates/chain-state" }
|
||||
|
||||
48
crates/alloy-provider/Cargo.toml
Normal file
48
crates/alloy-provider/Cargo.toml
Normal file
@@ -0,0 +1,48 @@
|
||||
[package]
|
||||
name = "reth-alloy-provider"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Alloy provider implementation for reth that fetches state via RPC"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-storage-api.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-provider.workspace = true
|
||||
reth-errors.workspace = true
|
||||
reth-execution-types.workspace = true
|
||||
reth-prune-types.workspace = true
|
||||
reth-node-types.workspace = true
|
||||
reth-trie.workspace = true
|
||||
reth-stages-types.workspace = true
|
||||
reth-db-api.workspace = true
|
||||
|
||||
# alloy
|
||||
alloy-provider.workspace = true
|
||||
alloy-network.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
alloy-rpc-types.workspace = true
|
||||
alloy-rpc-types-engine.workspace = true
|
||||
alloy-eips.workspace = true
|
||||
|
||||
# async
|
||||
tokio = { workspace = true, features = ["sync", "macros", "rt-multi-thread"] }
|
||||
|
||||
# other
|
||||
tracing.workspace = true
|
||||
|
||||
# revm
|
||||
revm.workspace = true
|
||||
revm-primitives.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { workspace = true, features = ["rt", "macros"] }
|
||||
60
crates/alloy-provider/README.md
Normal file
60
crates/alloy-provider/README.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Alloy Provider for Reth
|
||||
|
||||
This crate provides an implementation of reth's `StateProviderFactory` and related traits that fetches state data via RPC instead of from a local database.
|
||||
|
||||
Originally created by [cakevm](https://github.com/cakevm/alloy-reth-provider).
|
||||
|
||||
## Features
|
||||
|
||||
- Implements `StateProviderFactory` for remote RPC state access
|
||||
- Supports Ethereum networks
|
||||
- Useful for testing without requiring a full database
|
||||
- Can be used with reth ExEx (Execution Extensions) for testing
|
||||
|
||||
## Usage
|
||||
|
||||
```rust
|
||||
use alloy_provider::ProviderBuilder;
|
||||
use reth_alloy_provider::AlloyRethProvider;
|
||||
use reth_ethereum_node::EthereumNode;
|
||||
|
||||
// Initialize provider
|
||||
let provider = ProviderBuilder::new()
|
||||
.builtin("https://eth.merkle.io")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create database provider with NodeTypes
|
||||
let db_provider = AlloyRethProvider::new(provider, EthereumNode);
|
||||
|
||||
// Get state at specific block
|
||||
let state = db_provider.state_by_block_id(BlockId::number(16148323)).unwrap();
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The provider can be configured with custom settings:
|
||||
|
||||
```rust
|
||||
use reth_alloy_provider::{AlloyRethProvider, AlloyRethProviderConfig};
|
||||
use reth_ethereum_node::EthereumNode;
|
||||
|
||||
let config = AlloyRethProviderConfig {
|
||||
compute_state_root: true, // Enable state root computation
|
||||
};
|
||||
|
||||
let db_provider = AlloyRethProvider::new_with_config(provider, EthereumNode, config);
|
||||
```
|
||||
|
||||
## Technical Details
|
||||
|
||||
The provider uses `alloy_network::AnyNetwork` for network operations, providing compatibility with various Ethereum-based networks while maintaining the expected block structure with headers.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of:
|
||||
|
||||
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||
|
||||
at your option.
|
||||
1460
crates/alloy-provider/src/lib.rs
Normal file
1460
crates/alloy-provider/src/lib.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user