Skip to content

Refactor EthApi generics #15606

Open
Open
@emhane

Description

@emhane

Describe the feature

Replace the list of generics for EthApi and EthApiInner with N: RpcNodeCore.

/// `Eth` API implementation.
///
/// This type provides the functionality for handling `eth_` related requests.
/// These are implemented two-fold: Core functionality is implemented as
/// [`EthApiSpec`](reth_rpc_eth_api::helpers::EthApiSpec) trait. Additionally, the required server
/// implementations (e.g. [`EthApiServer`](reth_rpc_eth_api::EthApiServer)) are implemented
/// separately in submodules. The rpc handler implementation can then delegate to the main impls.
/// This way [`EthApi`] is not limited to [`jsonrpsee`] and can be used standalone or in other
/// network handlers (for example ipc).
///
/// ## Trait requirements
///
/// While this type requires various unrestricted generic components, trait bounds are enforced when
/// additional traits are implemented for this type.
#[derive(Deref)]
pub struct EthApi<Provider: BlockReader, Pool, Network, EvmConfig> {
/// All nested fields bundled together.
#[deref]
pub(super) inner: Arc<EthApiInner<Provider, Pool, Network, EvmConfig>>,
/// Transaction RPC response builder.
pub tx_resp_builder: EthTxBuilder,
}

See how it is done for OpEthApi.

Additional context

Changing EthApiInner this way appears to be the only way to workaround rustdoc bug rust-lang/rust#91380 encountered in #15508. Refactoring EthApiInner requires EthApi to be refactored too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-op-rethRelated to Optimism and op-rethA-sdkRelated to reth's use as a libraryS-blockedThis cannot more forward until something else changesS-needs-designThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions