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

Modify merge is_transition_block for readability #2337

Closed
wants to merge 2 commits into from

Conversation

paulhauner
Copy link
Contributor

This is subjective, but I found the existing code to be a little hard to read. I don't think it's immediately clear to the non-Python-guru how the order of operations should work here.

Consider this example:

>>> not True and False
False
>>> not (True and False)
True

I'm not particularly concerned about this PR getting merged, it just feels less like a trap this way IMO.

@paulhauner
Copy link
Contributor Author

Closing this since there's more of this not ordering going on in process_execution_payload and it seems like it's going to be required knowledge.

@paulhauner paulhauner closed this Apr 19, 2021
@mkalinin
Copy link
Collaborator

Wdyt about anything like that:

def is_transition_block(state: BeaconState, block_body: BeaconBlockBody) -> bool:
    transition_is_not_completed = not is_transition_completed(state)
    block_has_payload = block_body.execution_payload != ExecutionPayload()
    return transition_is_not_completed and block_has_payload

@paulhauner
Copy link
Contributor Author

Wdyt about anything like that:

It does read very nicely!

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.

None yet

2 participants