-
Notifications
You must be signed in to change notification settings - Fork 996
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
slither-check-upgradeability: support complex datatypes #1535
slither-check-upgradeability: support complex datatypes #1535
Conversation
using structure types
with new test cases using structures
@montyly @0xalpharush got any advice re: how to fix these failing checks? It seems like the pip-audit may be unrelated to the content of this PR, since I'm suddenly getting the same issue on #1506 (this check was passing before). As for the Features and Printers tests, it's not immediately clear to me why these are failing, though they seem to be possibly related to recursively nested structures. I just don't understand how the |
to avoid infinite loops from recursive structs
Alright, my last commit resolved the infinite loop issue with recursively nested structures, but I still don't get why the printers test is failing. I tried commenting out my
|
@0xalpharush @montyly my latest commit resolved the printer test issue (which was related to the |
…gradeability-complex-datatype
return False | ||
for idx, elem in enumerate(self.elems_ordered): | ||
other_elem = other.elems_ordered[idx] | ||
if str(other_elem.type) != str(elem.type) or other_elem.name != elem.name: |
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 think this might create issue where two types share the same name
For example in
struct St{
uint a;
}
contract A{
St s;
}
import {A} from "test.sol";
struct St{
uint b;
}
contract B is A{
St s2;
}
Maybe we should create a canonical_name
for type that would include the source mapping definition? (cc @smonicas @0xalpharush)
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.
Seems like canonical_name
would be a good idea. But in the example you gave, wouldn't it be correct to say that the two St
structs are not equal? In the highlighted code, while enumerating the elements of the two structs, the other_elem.name != elem.name
would cause my __eq__()
implementation to return False
, which seems correct at a glance. Granted, comparing canonical names would probably be better still.
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 suppose if you renamed St.b
in the second code block to uint a
, then the resulting equality might be considered a false positive, since it would see that both structs have the same name, and their elements have the same types and names, therefore returning true. But that seems quite picky, since the two structs would be identical except for where they are defined in Solidity.
Addresses #185, an old one, but still an issue!
Resolves false positives when comparing storage layouts that use structure types (test contracts and updated CI test included).
Currently only addresses structures, but I can add more here to resolve comparisons between other complex types, i.e., contract types and enums. (edit: Contract types also supported, at least on a superficial level, i.e., using the current
Contract.__eq__()
method which only works when comparing a contract object to another contract's name)