-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(sdk): add helper trait to node API to simplify type definition #10616
Conversation
it's not possible to move the helper traits |
removed re-export from not sure what's the root of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
nice work, combined with #12050 this will become a lot easier.
crates/rpc/rpc-eth-api/src/node.rs
Outdated
/// Helper trait to relax trait bounds on [`FullNodeComponents`], when defining types. | ||
pub trait RpcNodeCore: Clone { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this a lot as a non-restricted version of our components.
This is specifically tailored towards rpc, which is great because then we can extend this with additional things that we need for rpc, for example a trace executor type #10616
crates/rpc/rpc-eth-api/src/node.rs
Outdated
/// Helper trait to relax trait bounds on [`FullNodeComponents`], when defining types. | ||
pub trait RpcNodeCore: Clone { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this contains all components used by the rpc impl.
I think naming makes sense
ah I think the alloy-rpc-types-engine dep in node-core just lacks the "std" feature, imo this is actually an alloy issue |
35c4130
to
d550a27
Compare
Ref #9555
Building unit tests for any type that inherits from
FullNodeComponents
is too costly. Replacing the trait boundN: FullNodeComponents
withN: NodeCore
in type definitions, enables testing without importing a massive framework of unused mock node components. This, without sacrificing DevX of aggregate genericN
for a long list of generics.reth_node_api::NodeCore
, with blanket implementation for all types that implreth_node_api::FullNodeComponents
reth_optimism_rpc::OpEthApi<N: FullNodeComponents>
withOpEthApi<N: NodeCore>