-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
We should make it easier to work with and customize the EthApi
. Right now it takes 4 generics all of which are available on FullNodeComponents
trait:
reth/crates/rpc/rpc/src/eth/core.rs
Line 63 in 73ffe36
pub struct EthApi<Provider: BlockReader, Pool, Network, EvmConfig> { |
Ideally we want it to simply take a single N: FullNodeComponents
generic so that all of the node configuration and, more importantly, bounds on components are available directly on it, allowing to remove e.g those bounds:
reth/crates/optimism/rpc/src/eth/mod.rs
Lines 251 to 259 in 73ffe36
+ LoadState< | |
Evm: ConfigureEvm< | |
Primitives: NodePrimitives< | |
BlockHeader = ProviderHeader<Self::Provider>, | |
SignedTx = ProviderTx<Self::Provider>, | |
>, | |
>, | |
Error: FromEvmError<Self::Evm>, | |
>, |
This would break APIs around RpcModuleBuilder
:
reth/crates/rpc/rpc-builder/src/lib.rs
Lines 299 to 320 in 73ffe36
/// | |
/// This is the main entrypoint and the easiest way to configure an RPC server. | |
#[derive(Debug, Clone)] | |
pub struct RpcModuleBuilder<N, Provider, Pool, Network, Tasks, EvmConfig, BlockExecutor, Consensus> | |
{ | |
/// The Provider type to when creating all rpc handlers | |
provider: Provider, | |
/// The Pool type to when creating all rpc handlers | |
pool: Pool, | |
/// The Network type to when creating all rpc handlers | |
network: Network, | |
/// How additional tasks are spawned, for example in the eth pubsub namespace | |
executor: Tasks, | |
/// Defines how the EVM should be configured before execution. | |
evm_config: EvmConfig, | |
/// The provider for getting a block executor that executes blocks | |
block_executor: BlockExecutor, | |
/// The consensus implementation. | |
consensus: Consensus, | |
/// Node data primitives. | |
_primitives: PhantomData<N>, | |
} |
It's primary usecase is to allow setting up EthApi
without a full launched node in the same process by configuring mocks for components that are not available/needed:
reth/examples/rpc-db/src/main.rs
Lines 68 to 72 in 73ffe36
let rpc_builder = RpcModuleBuilder::default() | |
.with_provider(provider.clone()) | |
// Rest is just noops that do nothing | |
.with_noop_pool() | |
.with_noop_network() |
We can fix those by introducing a helper FullNodeComponentsBuilder
which would be a similar helper constructing FullNodeComponents
instead which might be useful even outisde of RPC
Sub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
Status