Skip to content

make OpAddOnsBuilder generic over middleware #17273

@thaodt

Description

@thaodt

Describe the feature

It looks like I still got the type constraint when injecting middleware, for e.g.:

110 |             addons.with_rpc_middleware(
    |                    ------------------- arguments to this method are incorrect
111 |                 SlowRequestLogMiddleware::new(self.slow_request_log_config.clone())
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Identity`, found `SlowRequestLogMiddleware`
    |
help: the return type of this call is `SlowRequestLogMiddleware` due to the type of the argument passed

impl<N, NetworkT> Default
for OpAddOns<
N,
OpEthApiBuilder<NetworkT>,
OpEngineValidatorBuilder,
OpEngineApiBuilder<OpEngineValidatorBuilder>,
>

I think we need to add Identity here and update the builder() method to be generic over RpcMiddleware

impl<N, NetworkT>
OpAddOns<
N,
OpEthApiBuilder<NetworkT>,
OpEngineValidatorBuilder,
OpEngineApiBuilder<OpEngineValidatorBuilder>,
>
where

Also, update the OpAddOnsBuilder to support custom middleware.

I have a working solution already, I'd like to take this if you're open to it! @mattsse 🙏

Additional context

relating to #17076

Metadata

Metadata

Assignees

Labels

A-op-rethRelated to Optimism and op-rethC-enhancementNew feature or request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions