Skip to content

Tracking: RPC Simplifications #14964

Open
4 of 7 issues completed
Open
4 of 7 issues completed
@jenpaff

Description

@jenpaff

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:

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:

+ LoadState<
Evm: ConfigureEvm<
Primitives: NodePrimitives<
BlockHeader = ProviderHeader<Self::Provider>,
SignedTx = ProviderTx<Self::Provider>,
>,
>,
Error: FromEvmError<Self::Evm>,
>,

This would break APIs around RpcModuleBuilder:

///
/// 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:

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

A-sdkRelated to reth's use as a libraryC-tracking-issueAn issue that collects information about a broad development initiative

Type

No type

Projects

Status

Tracking

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions