-
Notifications
You must be signed in to change notification settings - Fork 979
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
Add upgradeability utils #1757
Add upgradeability utils #1757
Conversation
…grades # Conflicts: # README.md
in `slither.utils.upgradeability`
…ame state variable(s) as a new/modified function
when finding functions tainted by `new_modified_function_vars`
when finding functions tainted by `new_modified_functions`
when finding modified functions
when finding modified functions
like `get_proxy_implementation_slot(proxy: Contract)`
out of `get_proxy_implementation_slot` since either one could be more useful.
…lity-utils # Conflicts: # README.md
I'm not sure why
Seems unrelated to me, though I was hoping the problem would go away when I merged dev into this PR. |
I think that is being tracked in #1710 |
Due to the non-deterministic order of `Function.all_nodes()`
i.e., `delegatecall(gas(), sload(0x3608...), 0, calldatasize(), 0, 0)` where the slot is not defined as a bytes32 constant but rather is hardcoded in the fallback.
Outside of the conflict with |
…lity-utils # Conflicts: # slither/tools/upgradeability/checks/variables_order.py
I believe so |
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 looks good. Only minor comment to address, and we can merge it
@montyly I believe I've addressed the minor changes |
slither/utils/upgradeability.py
Outdated
|
||
|
||
# pylint: disable=too-many-branches | ||
def encode_ir_for_compare(ir: Union[Operation, Variable]) -> str: |
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.
It's great that we have added the types, because this does not sound right :)
Should we split this function in two?
encore_ir_for_compare
encore_variable_for_compare
Note that we probably have the same issue in the slither-similar code, but that should be fixed in another PR
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.
Should we split this function in two?
Done!
@0xalpharush : should I merge this, or do you want to take a stab at the tests architecture first? |
@@ -663,6 +666,24 @@ def functions_and_modifiers_declared(self) -> List["Function"]: | |||
""" | |||
return self.functions_declared + self.modifiers_declared # type: ignore | |||
|
|||
@property |
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.
Can we add a test case under slither/tests/unit/core
to ensure that it works for examples like #1331 (comment)
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.
Done!
tests/test_upgradeability_util.py
Outdated
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.
Can you move this test to slither/tests/unit/utils/
and put the tests folder and its files under slither/tests/unit/testdata/
?
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.
Done
@montyly I think we should merge |
and `Contract.receive_function`
Done, done and done! |
Extends #1699, adding more utilities to
slither.utils.upgradeability
, specifically related to finding a proxy's implementation address storage slot.