Skip to content

Bypass transport in reth ExEx context when using Alloy

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

cakevm/alloy-reth-rpc-layer

Repository files navigation

Alloy Reth RPC Layer

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.

Benefits

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.

Example

// 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?;

Acknowledgements

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.

License

This project is licensed under the Apache 2.0 or MIT. The part in alloy_db is licensed as revm only under MIT.

About

Bypass transport in reth ExEx context when using Alloy

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks