-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Revert "Change enum values to be powers of two (fix #3417)" #4604
Conversation
Yes, reverting the commit will fix the problem. But I feel we also need to add additional unit tests, so that such blindspots are covered for the future. |
This is ready to merge because it just reverts PR #4239, and the original author of that PR has approved. |
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.
This revertible code isn't readable because it checks like a bit-mask even though it is not a bit-mask.
If the power-of-2 fix doesn't have the right behavior, it should be fixed with code that is more readable than this revert results in. E.g. change the checks to use ==
instead of &
.
That being said, @ximinez has an analysis that says the behavior between these two versions is the same, in which case I strongly prefer the power-of-2 version.
Veto. Copying my comment from #4601 (comment):
I don't think there's a behavior change at all. I commented on the original PR to that effect: #4239 (comment) Here's more detail. In the old code,
Consider the condition on line 110:
which is equivalent to
Basically, for any value except The new values are 0, 1, 2, and 4, respectively, but the result is the same. It should be clear that the results are the same for the other values. |
Closing because @ckeshava and @ximinez agree that this should not be reverted; see #4601 (comment) |
Consider the function
conditionMet
, specifically lines 121 and 122 and 146-147 of Handler.h:1c2ae10#diff-41d8d23b15cb894b075204dcd88d7bf9ca223fa77f43e28bb22cf38b805cabfcL121-L122
1c2ae10#diff-41d8d23b15cb894b075204dcd88d7bf9ca223fa77f43e28bb22cf38b805cabfcL146-L147
The change is broken: where it previously, it checked for a specific condition (e.g.
NEEDS_CLOSED_LEDGER
) and only entered theif
block if it was met, it now executes that code if any condition is set.A prime example of a RPC request that fails is the
tx
command, which hasNEEDS_NETWORK_CONNECTION
and will now not work unless the server has both a current and a closed ledger.The problem isn't the powers of two change. It's how the checks where restructured.
Originally posted by @nbougalis in #4601 (comment)
Reverts #4239