-
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
General improvements for utils/upgradeability/compare_variables_order.py #275
Conversation
EricR
commented
Jun 11, 2019
- Fixed slither-check-upgradeability raises "IndexError: list index out of range" #274
- Refactored code
- Made logging more explicit and (hopefully) clearer
Nice work! So the loop now in Typically, we would have:
Now we have
I think the previous order was a bit better, as we reduce the size of the output. The main issue though that the info was not clear enough. Maybe we should keep the original logic, but refactor the output to be more clear? |
I reworked the logic a little bit in an attempt to fix some confusing checks. For example, if there are more variables in version 1 of a contract than version 2, the check will currently report that variables are missing when they may just be out of order: slither/utils/upgradeability/compare_variables_order.py Lines 32 to 36 in 1128b4c
Similarly, if version 2 of a contract has more variables than version 1, the check will currently report that variables are new when they may just be out of order: slither/utils/upgradeability/compare_variables_order.py Lines 46 to 49 in 1128b4c
I agree that the repeated variables in output isn't great. What if instead we did the following? for idx in range(len(vars_v1)):
(v1_type, v1_name) = vars_v1[idx]
if idx > len(vars_v2):
logger.info(red('Expected variable in {}: {} {}'.format(
new_name, v1_type, v1_name
)))
issues_found = True
continue
(v2_name, v2_type) = vars_v2[idx]
if (v1_name != v2_name) or (v1_type != v2_type):
logger.info(red('Expected variable in {}: {} {}. Found {} {} instead.'.format(
new_name, v1_type, v1_name, v2_type, v2_name
)))
issues_found = True
elif warn:
logger.info(yellow('Variable in {}: {} {}'.format(new_name, v2_type, v2_name))) This way we're simply detecting when each variable in v1 isn't where it was expected to be in v2. More like a diff. Then we can just display a list of truly new variables (in v2 but not v1) after the ordering warnings. |
I am closing this PR. It is out of date, and will be replaced by #354 |