-
Notifications
You must be signed in to change notification settings - Fork 985
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
Move is_post_xxx
functions to new module
#3072
Conversation
Moving the `is_post_xxx` functions to a separate module allows `genesis` to also use them (cyclic import from `context` prevented this before). This allows removing `FORKS_BEFORE_ALTAIR` and `FORKS_BEFORE_BELLATRIX` constants and adding a more general `is_post_fork` function that needs less maintenance. This then allows definition of `with_all_phases_from` to streamline the implementation of the `with_xxx_and_later` decorators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactoring!
Raised some naming nitpicking around phases v.s. forks. protocols here.
@@ -0,0 +1,33 @@ | |||
from .constants import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although we had Phase0, now I wish we could retire "phases" someday since developments are in-parallel.
What do you think about protocols.py
or forks.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will go with forks.py
then. It is consistent with the fork=...
naming when running make citest
.
I will not touch the decorators such as @with_all_phases
for now, as it is out of scope of this PR.
return b in [PHASE0, ALTAIR] | ||
if a == PHASE0: | ||
return b in [PHASE0] | ||
assert False # Fork is missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert False # Fork is missing | |
raise ValueError("Wrong fork name %s" % a) |
Co-authored-by: Hsiao-Wei Wang <hsiaowei.eth@gmail.com>
Moving the
is_post_xxx
functions to a separate module allowsgenesis
to also use them (cyclic import fromcontext
prevented this before). This allows removingFORKS_BEFORE_ALTAIR
andFORKS_BEFORE_BELLATRIX
constants and adding a more generalis_post_fork
function that needs less maintenance. This then allows definition ofwith_all_phases_from
to streamline the implementation of thewith_xxx_and_later
decorators.