Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

stevencartavia
Copy link
Contributor

Motivation

closes #2020

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, good start


/// A wrapper for [`AnyRpcBlock`] that allows for handling unknown block types.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct AnyRpcBlockWrapper(pub AnyRpcBlock);
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

Comment on lines 156 to 164
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))
}
}
Copy link
Member

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

Comment on lines 70 to 71
type BlockResponse =
WithOtherFields<Block<WithOtherFields<Transaction<AnyTxEnvelope>>, AnyRpcHeader>>;
Copy link
Member

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

Copy link
Member

@mattsse mattsse left a 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:

https://github.com/paradigmxyz/reth/blob/16c3c5b733702f31daa4bf4e2c688ce37ccd5b58/Cargo.toml#L614-L642

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>>,
Copy link
Member

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

@stevencartavia
Copy link
Contributor Author

stevencartavia commented Feb 15, 2025

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:

https://github.com/paradigmxyz/reth/blob/16c3c5b733702f31daa4bf4e2c688ce37ccd5b58/Cargo.toml#L614-L642

and patch to your fork and branch

in line 643 ?

# alloy_rpc_types_any = { git = "https://github.com/my_user_name/alloy.git", branch = "my_user_name:this_branch" }
# alloy_rpc_types_eth = { git = "https://github.com/my_user_name/alloy.git", branch = "my_user_name:this_branch" }
# alloy_serde = { git = "https://github.com/my_user_name/alloy.git", branch = "my_user_name:this_branch" }

@zerosnacks zerosnacks requested a review from mattsse February 20, 2025 08:24
@mattsse mattsse added the blocked This cannot move forward until something else changes label Feb 20, 2025
Copy link
Member

@mattsse mattsse left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked This cannot move forward until something else changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Introduce dedicated types for Any type aliases
2 participants