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

consensus: add BlockHeader getter trait #1302

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

tcoratger
Copy link
Contributor

Should close #1301

mattsse
mattsse previously approved these changes Sep 17, 2024
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.

ah now I get it @emhane

pending @klkvr and @emhane

@@ -638,6 +638,158 @@ impl<'a> arbitrary::Arbitrary<'a> for Header {
}
}

/// Trait for extracting specific Ethereum block data from a header
pub trait BlockHeader {
Copy link
Member

Choose a reason for hiding this comment

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

from reth pov there's an argument for limiting these functions to the absolute necessary fields, or introduce sub traits, for example for evm you only need certain fields.
but since this doesn't clash with rpc, I think all of those are fine, and we could still do sub traits

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if you think we should split in subtraits now or if we should do that in a follow up if needed

Copy link
Member

Choose a reason for hiding this comment

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

I think we can do in a followup if needed, realistically we only need this trait for one type really, the chain's header type and for op we can even reuse the L1 type

@mattsse mattsse dismissed their stale review September 18, 2024 13:12

after thinking about this, this might be redundant since we already have HeaderResponse if we unify rpc with consensus, so I'd like to hold off here

@tcoratger
Copy link
Contributor Author

@emhane @mattsse Now that paradigmxyz/reth#10691 is merged, in order to completely remove BlockHeader trait from reth and have it in alloy, do we want to merge this? Or reduce the implementation strictly to what has be done in reth (less getter)?

@emhane
Copy link
Member

emhane commented Sep 23, 2024

@emhane @mattsse Now that paradigmxyz/reth#10691 is merged, in order to completely remove BlockHeader trait from reth and have it in alloy, do we want to merge this? Or reduce the implementation strictly to what has be done in reth (less getter)?

I think we merge as is, because I'm getting blocked on several prs over and over again because some getters are missing. in the end it seems to result in that we are using all the fields on the primitive types we abstract away with these traits, i.e. reth primitives are minimal types.

@emhane
Copy link
Member

emhane commented Sep 23, 2024

also for rpc header we want HeaderResponse: BlockHeader, as for rpc transaction
#1328 (comment)

@emhane emhane merged commit b021936 into alloy-rs:main Sep 23, 2024
26 checks passed
@tcoratger
Copy link
Contributor Author

@emhane FYI just opened a follow up issue here on reth paradigmxyz/reth#11127

lwedge99 pushed a commit to sentioxyz/alloy that referenced this pull request Oct 8, 2024
consensus: add BlockHeader getter trait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add getters of alloy_consensus::Header to a new trait BlockHeader
3 participants