Skip to content

Custom RPC transaction request body #17051

Open
@RomanHodulak

Description

@RomanHodulak

Describe the feature

Currently, the transaction request is set using an associated type on RpcTypes.

type TransactionRequest: RpcObject;

There is one limitation. Most of the generic EthApi implementations require RpcTypes::TransactionRequest to implement From<alloy_rpc_types_eth::TransactionRequest>.

NetworkTypes: RpcTypes<TransactionRequest: From<TransactionRequest>>,

The reason for that is that the alloy_rpc_types_eth::TransactionRequest is the only accepted JSON encoded RPC method argument.

async fn send_transaction(&self, request: TransactionRequest) -> RpcResult<B256>;

To summarize:

  • Transaction request is generic and can be set to a custom type using an associated type provided in a custom RpcTypes implementation.
  • Transaction request is always created using From<alloy_rpc_types_eth::TransactionRequest> conversion.

The goal of this task is to get rid of this limitation. The consequece of that will be that custom nodes can have their RPC accept custom transaction request bodies without a custom EthApi implementation.

There is already a generic in place for the transaction request called TxReq ready on EthApi

pub trait EthApi<TxReq: RpcObject, T: RpcObject, B: RpcObject, R: RpcObject, H: RpcObject> {

So the way to go about this task is to replace alloy_rpc_types_eth::TransactionRequest with TxReq generic type and make it work. This will most likely require replacing all the From<alloy_rpc_types_eth::TransactionRequest> bounds with a trait bound that every transaction request should implement. Using alloy_network::TransactionBuilder trait should make the most sense.

Additional context

Follow-up on #15117

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rpcRelated to the RPC implementationA-sdkRelated to reth's use as a library

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions