refactor: add network-primitives#1101
Merged
Merged
Conversation
mattsse
approved these changes
Jul 25, 2024
mattsse
reviewed
Jul 25, 2024
| #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub struct Block<T = Transaction> { | ||
| pub struct Block { |
Member
There was a problem hiding this comment.
hmm, can we keep this generic? otherwise we can't reuse that block type?
Member
Author
There was a problem hiding this comment.
right, this could be useful in some cases, though I think for most of the rollups entire Block would be different as there'll be no withdrawals for example, so we'd likely want to just add more reusable generic components for custom blocks (like BlockTransactions<T>)
added generic back as it doesn't hurt anyway
Member
There was a problem hiding this comment.
yep I also think this will be the case but this can be useful for rollups that only have 1 additional tx type for example
mattsse
approved these changes
Jul 25, 2024
3 tasks
ben186
pushed a commit
to ben186/alloy
that referenced
this pull request
Jul 27, 2024
* refactor: add network-primitives * fix tests * fix docs * add re-exports * Block<T>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
alloy-rpc-types-ethare supposed to be concrete, thus having generics on types defined in it is not helpful and makes it hard to define implementations based on traits from other crates.Solution
ReceiptResponseandTransactionResponsefromalloy-networkto new cratealloy-network-primitives, allowing their usage without depending onalloy-networkBlockTransactions<T>intonetwork-primitivesand provide implementations forT: TransactionResponseinstead of concreterpc_types_eth::TransactionThis sets us up for block response abstraction, making it possible to add getters for
BlockTransactionsgeneric overN::TransactionResponseref #267Note: This changed
Iterator::ItemforBlockTransactionHashesfrom&B256toB256as this is whatTransactionResponse::tx_hashreturns. Is it fine or should I update the trait instead? It seems that it's OK to expectTransactionResponseto own a hash.This also removes
BlockTransactionHashesMutPR Checklist