-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: NodeTypesWithDB
#10683
feat: NodeTypesWithDB
#10683
Conversation
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.
why not use syntax?
trait FullNodeTypes: NodeTypes<Engine: EngineTypes, DB: FullDatabase> { .. }
this would leave us with something like trait FullNodeTypes: NodeTypes<Engine: EngineTypes, DB: FullDatabase> {
type Provider = FullProvider<Self>;
} and such structure would make it harder to deal with generics on providers, eg expressing this bound becomes not trivial if reth/crates/node/builder/src/launch/mod.rs Line 106 in 25997b4
|
ok I see, then why have these traits got associated types? and not just super traits? instead of trait FullDB: DatabaseMetrics + Database + NodeTypes {} |
hmm, what's the benefit of such trait? doesn't feel right that we'd impl |
doesn't feel right to have a trait with one associated type. what are the reasons for this? it's a shame that we loose the nice aggregation of stateless components that we used to have in trait NodeTypes: PrimitiveTypes {
type Engine: EngineTypes;
type ChainSpec: ChainsSpec;
} nonetheless, we can see where this ends up, and if we need to deal with debt later. it is beneficial that we are agiley moving forward. |
we've added reth/crates/node/builder/src/builder/mod.rs Lines 209 to 212 in 2c28438
agreed that we might end up with too many layers. helper traits aggregating types should help, we could also consider restructuring |
fully supportive of this |
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.
cool,
this will be slightly messy for a bit and some parts will change often but we need incremental progress here
/// node. | ||
/// | ||
/// Its types are configured by node internally and are not intended to be user configurable. | ||
pub trait NodeTypesWithDB: NodeTypesWithEngine { |
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.
for nodebuilder I think we should perhaps try to stack trait types, like T: NodeTypesWithDB + EngineTypes
and consider getting rid of
enginetypes: NodeTypes
but for now this seems appropriate
This PR extracts
DB
AT fromFullNodeTypes
into separate traitNodeTypesWithDB
. This trait is moved to new cratereth-node-types
along withNodePrimitives
,NodeTypes
andNodeTypesWithEngine
This is needed to allowreth-provider
depend onNodeTypesWithDB
FullProvider
is now generic overNodeTypesWithDB
andFullNodeTypes
is changed to the following form:reth/crates/node/api/src/node.rs
Lines 95 to 100 in 416fc6b
As it no more depends on
NodeTypes
I had to change the way we access some of the ATs (Node::Engine
-><Node::Types as NodeTypesWithEngine>::Engine
)This should allow usage of
NodeTypesWithDB
in provider traits