- Notifications
You must be signed in to change notification settings - Fork2
Implement reth StateProviderFactory to forward requests to an RPC using Alloy
License
Apache-2.0, MIT licenses found
Licenses found
cakevm/alloy-reth-provider
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repository illustrates how theStateProviderFactory
fromreth can be implemented withalloy-rs to fetch all state using RPC. This can be useful to not be dependent on a real database when testing reth ExEx.
There is nodebug_codeByHash
implemented currently (seefeat(rpc): debug_codeByHash #14479). But since revm will first callbasic_account
, we can cache it and return it whenbytecode_by_hash
is called.
Currently, this repos purpose as copy/paste reference and not as library. Not all functions are implemented.
See tests insrc/alloy_reth_provider.rs
for an example.
// Init the providerlet provider =ProviderBuilder::new().on_http("https://eth.merkle.io".parse().unwrap());// Init the db providerlet db_provider =AlloyRethProvider::new(provider);// Use the StateProviderFactorylet state = db_provider.state_by_block_id(BlockId::number(16148323)).unwrap();
Many, many thanks to the team ofreth andalloy-rs for the awesome work they do. Some parts of the trait implementation are taken from reth. Also, many thanks torevm. Thealloy_db
part is a copy/paste from revm because this part is not included in the latest revm version, and it makes it easier to be in sync with the latest Alloy version.
This project is licensed under theApache 2.0 orMIT. The part inalloy_db
is licensed asrevm only underMIT.
About
Implement reth StateProviderFactory to forward requests to an RPC using Alloy