This repository is a Proof of Concept (PoC) demonstrating how to implement a layer for alloy-rs that bypasses transport in a reth ExEx context. The idea is to pass the reth RpcRegistry
to this layer, which then directly dispatches calls to RpcRegistry
, with a fallback to the standard implementation. This example is inspired by the reth_db_provider example from the Alloy examples.
This approach reduces overhead by eliminating the need for transport handling, such as IPC connections, while maintaining the Alloy interface. It allows you to pass the Alloy provider around without needing to interact directly with RpcRegistry
(e.g. traits, ...). This provides an optimized execution flow for reth ExEx while still allowing fallback to the standard JSON-RPC transport.
// Init here your reth node
let NodeHandle { node, _ } = ...;
let rpc_registry = node.rpc_registry.clone(); // Get the RpcRegistry from reth
let reth_provider = ProviderBuilder::default()
.layer(RethRpcLayer::new(rpc_registry)) // pass the RpcRegistry to the layer
.on_builtin(node.config.rpc.ipcpath.as_str()) // use the ipc path from reth as fallback client
.await?;
Many, many thanks to the team of reth and alloy-rs for the awesome work they do. Some parts of the trait implementation are taken from reth and the reth_provider example. Also, many thanks to revm.
This project is licensed under the Apache 2.0 or MIT. The part in alloy_db
is licensed as revm only under MIT.