-
Notifications
You must be signed in to change notification settings - Fork 1.5k
POC: simplify SDK #15593
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
base: main
Are you sure you want to change the base?
POC: simplify SDK #15593
Conversation
impl<C, N> CanonStateSubscriptions for NoopProvider<C, N> | ||
where | ||
C: Send + Sync, | ||
N: NodePrimitives + Unpin + Default + Clone + 'static, |
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.
places that require trait bounds like these can be collapsed into some helper trait eventually HalfFullNodePrimitives
or smthg. NodePrimitives
can't be static for example in order to be supertrait of traits of T
that should be implemented on &T
also. @mattsse
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.
alt, we can upgrade the trait bound everywhere where it needs to be static/Clone/etc. to FullNodePrimitives
. it works quite nicely with the MaybeCompact
and other Maybe
- traits in reth-primitives-traits
to just include the trait bound everywhere, even where Compact
isn't needed, without any overhead.
Ref #13951
BlockReader
is trait aggregating a lot of stateful behaviour, however it's used as trait bound in type definitions just in order to access the associated data primitive types. A more intentional way to do this, is to make use of the stateless base traitNodePrimitives
in the type definition.reth/crates/rpc/rpc/src/eth/core.rs
Lines 249 to 288 in 6ae48f8
Since
NodePrimitives
is stateless, it can effortlessly become supertrait of any provider trait and removes the need for adding the same associated types again explicitly to the provider traits.All provider traits read to and from the same database so there is no need to separately configure and therefore to define new associated types
TransactionProvider::Transaction
,HeaderProvider::Header
, etc. creating overhead as we need to link them to the rest of the node, e.g.TransactionProvider::Transaction == <N as NodePrimitives>::SignedTx
. It also saves the need for the traitNodePrimitivesProvider
, hereby removing an extra complexity layer.reth/crates/storage/storage-api/src/header.rs
Lines 11 to 15 in 6ae48f8
Alt approaches: creating a new trait
NodePrimitivesBase
, identical associated types asNodePrimitives
but without trait bounds on the associated types and using this as super trait instead and in type defs, similar asRpcNodeCore
. This approach was out-ruled because it adds more code, whereas the PR aims to remove redundancy and create stronger cohesion in the SDK abstraction to its origin inNodePrimitives
.