Skip to content
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

upgradeability: include inherited private variables, ignore immutables #1451

Merged

Conversation

0xalpharush
Copy link
Member

@0xalpharush 0xalpharush commented Nov 4, 2022

The upgradeability check doesn't consider inherited, private variable declarations nor does it consider immutability. This PR addresses that by using state_variables_ordered and checking that variables aren't immutable prior to flagging them.

// test.sol 
pragma solidity ^0.8.0;
contract A {
    uint private a = 1; // not currently detected 
}
contract B is A {
    uint a = 2;
    uint immutable b = 3; // fine to delegatecall (same as constant)
}

Command: slither-check-upgradeability test.sol B
Before:

B.a (test.sol#6) is a state variable with an initial value.
B.b (test.sol#7) is a state variable with an initial value.

After fix:

A.a (test.sol#3) is a state variable with an initial value.
B.a (test.sol#6) is a state variable with an initial value.

@0xalpharush 0xalpharush added the bug Something isn't working label Nov 28, 2022
@0xalpharush
Copy link
Member Author

Probably needs to be done here too

order1 = [variable for variable in contract1.state_variables if not variable.is_constant]

@montyly
Copy link
Member

montyly commented Jan 5, 2023

@0xalpharush: can you make the changes in the other places within this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants