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

The solution for the slither exercise 1 is not general enough #10

Closed
ggrieco-tob opened this issue Feb 4, 2020 · 0 comments · Fixed by #187
Closed

The solution for the slither exercise 1 is not general enough #10

ggrieco-tob opened this issue Feb 4, 2020 · 0 comments · Fixed by #187
Labels
question Further information is requested Slither

Comments

@ggrieco-tob
Copy link
Member

The proposed solution fails to work when the exercise is made a little harder, using the following contract:

contract Coin{

    address owner = msg.sender;

    mapping(address => uint) balances;


    // _mint must not be overriden
    function _mint(address dst, uint val) internal{
        require(msg.sender == owner);
        balances[dst] += val;
    }

    function mint(address dst, uint val) public{
        _mint(dst, val);
    }

}

contract MyCoin is Coin{

    event Mint(address, uint);

    function _mint(address dst, uint val) internal{
        balances[dst] += val;
        emit Mint(dst, val);
    }

}

contract MyCoin2 is MyCoin{

    function set(address dst, uint val) internal{
        balances[dst] = val;
    }
    
}

contract MyCoin3 is Coin{

    function set(address dst, uint val) internal{
        balances[dst] = val;
    }
}

contract MyCoin4 {
   
    function _mint(address dst, int val) public{}

}

contract NotCoin {
    address notowner;
    function _mint(address dst, uint val) internal{}


}

Running the solution results in this output:

$ python3 solution.py 
Error, MyCoin overrides _mint
Error, MyCoin2 overrides _mint
Error, MyCoin3 overrides _mint

However, MyCoin3 should not be detected as overriding the _mint function.

@ggrieco-tob ggrieco-tob added question Further information is requested Slither labels Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Slither
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant