-
Notifications
You must be signed in to change notification settings - Fork 281
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: introduce dedicated types for Any type aliases #2046
base: main
Are you sure you want to change the base?
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.
cool, good start
crates/network/src/any/mod.rs
Outdated
|
||
/// A wrapper for [`AnyRpcBlock`] that allows for handling unknown block types. | ||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct AnyRpcBlockWrapper(pub AnyRpcBlock); |
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.
in order to make this non breaking we need to rename this struct to AnyRpcBlock
we also need to expose all the functions that WithOtherFields has so that becomes non breaking
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.
how can I avoid errors when there is already a type defined with that name above?
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.
remove the alias and place it where pub AnyRpcBlock
is
crates/network/src/any/mod.rs
Outdated
impl<'de> Deserialize<'de> for AnyRpcTransaction { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
{ | ||
let inner = WithOtherFields::<Transaction<AnyTxEnvelope>>::deserialize(deserializer)?; | ||
Ok(Self(inner)) | ||
} | ||
} |
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.
all of this can be derived
crates/network/src/any/mod.rs
Outdated
type BlockResponse = | ||
WithOtherFields<Block<WithOtherFields<Transaction<AnyTxEnvelope>>, AnyRpcHeader>>; |
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.
this must now use the wrapper type
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.
last nit
this change could be breaking, so it would be helpful if you could open a reth pr with the alloy deps patched to this branch:
and patch to your fork and branch
/// A wrapper for [`AnyRpcBlock`] that allows for handling unknown block types. | ||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct AnyRpcBlock( | ||
WithOtherFields<Block<WithOtherFields<Transaction<AnyTxEnvelope>>, AnyRpcHeader>>, |
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.
we also need from impls for these, you can use derive_more::From for all of these
in line 643 ?
|
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.
this looks good,
since this is technically breaking, I'm putting this on hold until next release
Motivation
closes #2020
Solution
PR Checklist