-
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
feat: make Consensus trait generic over block parts #12451
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
prefer this, and adding header and block body as ATs parallel to block in
NodePrimitives
. it's nice to grow the generics list by only a single element everywhere via this task of generalising the data primitives.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.
imo ideally this has a single block AT bounded by
reth/crates/primitives-traits/src/block/mod.rs
Line 22 in 9773635
Consensus
responsibility is to validate blocks so don't think it should know about entire node storage model. this would also be consistent with pool traits which only know the transaction ATI've done this as 2 generics right now so that we can still keep
dyn Consensus
everywheredoes it make sense?
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 can't you keep the trait object if you add the generic?
NetworkPrimitives
has header and body as ATs, and the block, so I'm not sure you're intentions are really clear?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 mean that we can't keep it as is if we'd add AT because we'd need to specify
Block = Block
everywhere, so went with generics for nowsorry, not sure I follow, how are
NetworkPrimitives
related to consensus trait?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.
yeah a single AT would be ideal, but for now we can introduce both AT just to move forward
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
I see, seems to be a misunderstanding, I didn't mean adding an AT to the consensus trait
if you remove the rlp encoding trait bounds from ATs on
NetworkPrimitives
, and just have auto trait bounds, then the associated types can easily just be the unit struct()
.by passing one type, that aggregates the data primitives as associated types, we make a framework that is extensible without breaking the public api.
in the future, and even towards the end of this sdk integration task, it may well be, that somewhere in consensus, another data primitive type is needed. then we have to change the type definition again to put another generic to the list if we do it the way you impl it now.
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.
hmm, in scope of sdk the
Consensus
trait API only needs block and its components right now. If we were to add additional methods requiring something else this would anyway be a breaking change to API I think? and internally trait implementations are free to use any componentsThere 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.
just recently op impl of transaction rpc, needed a receipt type, who would have known.
#11164
#11732
keep the code usable for use cases you could not have had time to think of yourself at the time of impl.