-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Make Node Types: Clone #14351
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
Make Node Types: Clone #14351
Conversation
still some failing tests |
Yes i noticed. I was able to finally get make pr to work and i got some errors in files where the clone has to be also implemented, so i made few modifications to it be deriving clone. especially in the |
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.
a few more nits
crates/node/types/src/lib.rs
Outdated
@@ -79,7 +79,7 @@ impl<Types, DB> Clone for NodeTypesWithDBAdapter<Types, DB> { | |||
|
|||
impl<Types, DB> NodeTypes for NodeTypesWithDBAdapter<Types, DB> | |||
where | |||
Types: NodeTypes, | |||
Types: NodeTypes + 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 think these are now redundant NodeTypes + Clone
because NodeTypes
already implies 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.
oh okay
crates/node/types/src/lib.rs
Outdated
P: NodePrimitives + Send + Sync + Unpin + 'static + Clone, | ||
E: EngineTypes + Send + Sync + Unpin + Clone, | ||
C: EthChainSpec<Header = P::BlockHeader> + 'static + Clone, | ||
SC: StateCommitment + Clone, | ||
S: Default + Send + Sync + Unpin + Debug + 'static + 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.
most of those are already clone so we likely don't need all of these changes
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.
oh okay. I'm on it right away
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.
most of those are already clone so we likely don't need all of these changes
Hey @mattsse i checked they aren't really redundant. If i remove the clone it throws an error like this the trait bound `C: Clone` is not satisfied
. That was why i added them there initially.
Example
line 149 to 160 throws an error. The AnyNodeTypes<P, C, SC, S>
Throws an error
impl<P, C, SC, S> NodeTypes for AnyNodeTypes<P, C, SC, S>
where
P: NodePrimitives + Send + Sync + Unpin + 'static,
C: EthChainSpec<Header = P::BlockHeader> + 'static,
SC: StateCommitment,
S: Default + Send + Sync + Unpin + Debug + 'static,
{
type Primitives = P;
type ChainSpec = C;
type StateCommitment = SC;
type Storage = S;
}
Error
the trait bound `C: Clone` is not satisfied
the trait `Clone` is not implemented for `C`, which is required by `AnyNodeTypes<P, C, SC, S>: Clone`rustc[Click for full compiler diagnostic](rust-analyzer-diagnostics-view:/diagnostic%20message%20[0]?0#file:///home/reentrancy/reth/crates/node/types/src/lib.rs)
lib.rs(108, 10): required for `AnyNodeTypes<P, C, SC, S>` to implement `Clone`
lib.rs(28, 22): required by a bound in `NodeTypes`
lib.rs(152, 55): consider further restricting this bound: ` + std::clone::Clone`
the trait bound `SC: Clone` is not satisfied
the trait `Clone` is not implemented for `SC`, which is required by `AnyNodeTypes<P, C, SC, S>: Clone`rustc[Click for full compiler diagnostic](rust-analyzer-diagnostics-view:/diagnostic%20message%20[4]?4#file:///home/reentrancy/reth/crates/node/types/src/lib.rs)
lib.rs(108, 10): required for `AnyNodeTypes<P, C, SC, S>` to implement `Clone`
Hey @mattsse i made a new commit, was able to remove some though, if i removed the rest it will throw errors. Check it out. |
Hey @Cyber-Mitch, I believe the |
okay. This is good @kustrun But, did you run test to see if all test cases pass though? |
Yes, the tests are passing (was having some troubles running them locally): #14997 |
Make NodeTypes: Clone
Description
The
NodeTypes
trait and its implementations are used extensively in the codebase, particularly when restricting trait bounds or using associated types. SinceNodeTypes
is intended to be stateless and only defines types, it should implement theClone
trait to make it easier to deriveClone
for types that useNodeTypes
.Issue
The
NodeTypes
trait and its implementations did not implement theClone
trait.Solutions Snippet
Add
Clone
to theNodeTypes
trait definition:@mattsse closes #14345