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

primitives: make block header gas limit field compatible with u128 #11130

Closed
wants to merge 4 commits into from

Conversation

tcoratger
Copy link
Contributor

Follow up on #10691 cc @mattsse

Copy link
Collaborator

@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.

pedantic lock nit, otherwise this is reasonable.

Cargo.lock Outdated Show resolved Hide resolved
@mattsse mattsse added the C-debt Refactor of code section that is hard to understand or maintain label Sep 23, 2024
@@ -23,7 +23,7 @@ struct Header {
logs_bloom: Bloom,
difficulty: U256,
number: BlockNumber,
gas_limit: u64,
Copy link
Collaborator

Choose a reason for hiding this comment

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

not possible

Copy link
Collaborator

@joshieDo joshieDo Sep 23, 2024

Choose a reason for hiding this comment

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

this would break.

additionally we should add an existing recent header to tests to ensure backwards compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just undo this change. I suggest that for now we leave the codec as it is without touching it so we don't risk breaking anything. There are other fields to change first. When everything is done we can come back to it and fix things properly, wdyt?

Copy link
Collaborator

@joshieDo joshieDo Sep 23, 2024

Choose a reason for hiding this comment

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

we should still add the test.

this kind of change, changing an existing field type like this, is not possible unfortunately. Added some additional docs here https://github.com/paradigmxyz/reth/pull/11131/files#diff-e5f90be56b8337d7431ad21b53260ca57f13efed8310e8c48f2a0bfeca43e82f

in a short summary ser/deser of certain types are done by using an helper struct that has fixed sizes (bitflag struct). changing u64 to u128 would increase how many bits are required for that field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since everything is converging towards using u64 for these fields, I wonder if it would not be better to do what is described here alloy-rs/alloy#1241, that is to say to convert everything to u64 in alloy. This will reduce a lot of modifications to be made in reth and it would naturally eliminate all the conversions when applying the clippy...

I do not really see any specific cases where the use of a u128 is justified except perhaps very specific devnets or local developments but as a general rule, I would say that switching everything to u64 seems more justified to me. What do you think @joshieDo @mattsse @klkvr ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

if it would not be better to do what is described here alloy-rs/alloy#1241,

yeah I know think that'd be better, especially because eth consensus has these fields as u64 and u64::MAX should be plenty for all things gas

@joshieDo joshieDo added the S-breaking This PR includes a breaking change label Sep 23, 2024
@joshieDo joshieDo removed the S-breaking This PR includes a breaking change label Sep 23, 2024
@mattsse
Copy link
Collaborator

mattsse commented Sep 23, 2024

closing since we should change the header fields instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants