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: couple convenience methods #1955

Merged
merged 2 commits into from
Jan 27, 2025
Merged

feat: couple convenience methods #1955

merged 2 commits into from
Jan 27, 2025

Conversation

prestwich
Copy link
Member

Adds a couple convenience methods to check if hard forks are active in a given header

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Comment on lines 338 to 346
/// True if the Cancun hardfork is active.
pub const fn cancun_active(&self) -> bool {
self.blob_gas_used.is_some()
}

/// True if the Prague hardfork is active.
///
/// This function checks that the withdrawals root is present.
pub const fn prague_active(&self) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

since this is the ethereum header type, I think this makes sense because these fields were introduced with the corresponding hardforks. although this assumes that the header is valid, but I think we can do this.
the alternative would be has_withdrawals_root and then the caller is expected to know that this means hardfork active

Copy link
Member Author

Choose a reason for hiding this comment

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

these will also need to be updated if any field is removed in future hard forks, but that seems unlikely (and also fine)

crates/consensus/src/block/header.rs Outdated Show resolved Hide resolved
@mattsse mattsse merged commit b107143 into main Jan 27, 2025
27 checks passed
@mattsse mattsse deleted the prestwich/convenience branch January 27, 2025 21:27
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.

2 participants