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

specs: Make deneb function is_valid_light_client_header idiomatic #4118

Closed
wants to merge 1 commit into from

Conversation

bshastry
Copy link
Contributor

@bshastry bshastry commented Feb 4, 2025

refactor: improve light client header validation flow

Change validation logic in is_valid_light_client_header to use early return pattern for pre-Deneb blob gas checks. This improves code readability while maintaining identical validation behavior. It increases coverage by one SLoC and decreases partially covered branches by one, for deneb and beyond.

@bshastry bshastry force-pushed the deneb-spec-lc-header branch from 3c2529e to 40798de Compare February 4, 2025 12:15
Comment on lines -68 to +72
if epoch < DENEB_FORK_EPOCH:
if header.execution.blob_gas_used != uint64(0) or header.execution.excess_blob_gas != uint64(0):
return False
if epoch < config.DENEB_FORK_EPOCH:
return (
header.execution.blob_gas_used == uint64(0)
and header.execution.excess_blob_gas == uint64(0)
)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this change is correct. It doesn't behave the same. For pre-Deneb, with unset blob gas fields, it will no longer check if the execution branch is valid. It will simply return true now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the refactor is wrong, and CI also fails.

@jtraglia
Copy link
Member

jtraglia commented Feb 4, 2025

@etan-status, do you mind taking a look at this?

@etan-status
Copy link
Contributor

@etan-status, do you mind taking a look at this?

Thanks for the ping, agree with your observation that the change is incorrect.

@bshastry
Copy link
Contributor Author

bshastry commented Feb 4, 2025

Sorry, the change is wrong. My apologies. The original intention was to write a test to cover the line that would return False in the case the blob fields pre deneb are non zero.

I'm not sure it is possible to write such a test. Because the fields don't exist pre deneb let alone them being non zero.

@bshastry
Copy link
Contributor Author

bshastry commented Feb 4, 2025

Closing this PR.

@bshastry bshastry closed this Feb 4, 2025
@bshastry bshastry deleted the deneb-spec-lc-header branch February 5, 2025 08:24
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.

3 participants