-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Remove all Solidity warnings #1346
Comments
Some warnings include Can help contribute if open to a pull request. |
Hey there @ChrisCates! Sure, a contribution here would be of great help :) For reference, these are the warnings of the latest CI run (https://travis-ci.org/OpenZeppelin/openzeppelin-solidity/jobs/430787621#L2884):
|
Having troubles running Can't run |
What truffle version are you running? The setup process is literally to run |
|
@ChrisCates can you show us the output you get when trying to install? |
Using:
Resolved the issue. Using node I will test with v8.9.1 to see if I can reproduce the issue. |
Interestingly enough, Here is a logcat of the install: https://gist.github.com/ChrisCates/ff9f91ceefd0c616d90ef4a5334c67eb |
@ChrisCates you working on it? |
@ChrisCates it looks like you had trouble installing @Aniket-Engg I'd say you're free to work on this, since Chris has been having issues setting up the project. |
@nventuro, very bizarre issue I agree, however, it's only problematic with the node version specified in the root folder. Using the I've provided some comments that both you and @Aniket-Engg can give feedback and/or discuss problems. Here are some concerns I have: First, /**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param beneficiary Address performing the token purchase
* @param weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(
address beneficiary,
uint256 weiAmount
)
internal
{
// optional override
require(beneficiary != address(0));
require(weiAmount > 0);
} Second, /**
* @dev Returns whether refundees can withdraw their deposits (be refunded).
*/
function withdrawalAllowed() public view returns (bool) {
return _state == State.Refunding;
} The conflict with function withdrawalAllowed(address payee) public view returns (bool); To summarize, because the Solidity language does not allow for function overloading, and, all functions that are extended via an implementation must use the same name and the same modifiers and arguments... We still end up with these side effects stated as warnings in the compiler even with /Users/chriscates/Projects/openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol:151:3: Warning: Function state mutability can be restricted to pure
function _preValidatePurchase(
^ (Relevant source part starts here and spans across multiple lines).
,/Users/chriscates/Projects/openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol:166:3: Warning: Function state mutability can be restricted to pure
function _postValidatePurchase(
^ (Relevant source part starts here and spans across multiple lines).
,/Users/chriscates/Projects/openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol:210:3: Warning: Function state mutability can be restricted to pure
function _updatePurchasingState(
^ (Relevant source part starts here and spans across multiple lines).
,/Users/chriscates/Projects/openzeppelin-solidity/contracts/crowdsale/distribution/FinalizableCrowdsale.sol:45:3: Warning: Function state mutability can be restricted to pure
function _finalization() internal {
^ (Relevant source part starts here and spans across multiple lines).
,/Users/chriscates/Projects/openzeppelin-solidity/contracts/payment/ConditionalEscrow.sol:16:3: Warning: Function state mutability can be restricted to pure
function withdrawalAllowed(address payee) public view returns (bool) {
^ (Relevant source part starts here and spans across multiple lines). Also, when running tests, there are side effects such as the revert functionality failing in the context of using I have also written an EIP in regards to this issue that directly discusses some existing issues: ethereum/EIPs#1465 |
@ChrisCates Regarding function overloading, as per the solidity documentation,
For more: https://solidity.readthedocs.io/en/v0.4.25/contracts.html#overload-function |
@Aniket-Engg, my bad in regards to function overloading... /Users/chriscates/Projects/openzeppelin-solidity/contracts/crowdsale/distribution/RefundableCrowdsale.sol:29:15: TypeError: Trying to create an instance of an abstract contract.
_escrow = new RefundEscrow(wallet());
^--------------^
/Users/chriscates/Projects/openzeppelin-solidity/contracts/payment/ConditionalEscrow.sol:16:3: Missing implementation:
function withdrawalAllowed(address payee) public view returns (bool);
^-------------------------------------------------------------------^ I was really tired when looking through the error logs last night... Didn't realize I made such a big logical error (in regards to debugging and the core standard library itself)... The question then becomes... If an implementation/abstract function is not used when created... How do we treat the unused functions in the contract? Should there be a new contract in place? Or do we completely remove dependency to the |
True, but we need them for the docstring :/
Not sure what you mean with 'causes revert to fail', do the function calls not revert when you add those
The argument needs to be there to override the correct function, but you're right in that it is unsed in that override (because that escrow doesn't allow or disallow based on the payee).
This is because the implementations are empty, but the overrides will not, and they will not be
Could you expand a bit on this point, and provide an example if possible?
What do you mean by 'not used'? Not implemented? In that case, the contract will be abstract, and won't be able to be deployed (as you saw in that error message when you changed the override). |
No Problem @ChrisCates , I agree with @nventuro . I think we have very less scope of improvement in some of the warnings. |
I'm going to provide a pull request later tonight for you guys to review while also doing some revisions as per the comments from @nventuro. I believe that the issue with reverting transactions will still occur. And will get back to you with a pull request once I get everything sorted. Also, @nventuro When a function implementation is not used for example: function withdrawalAllowed(address payee) public view returns (bool); //This is not used
function withdrawalAllowed() public view returns (bool); //This is used There will be a compilation /Users/chriscates/Projects/openzeppelin-solidity/contracts/crowdsale/distribution/RefundableCrowdsale.sol:29:15: TypeError: Trying to create an instance of an abstract contract.
_escrow = new RefundEscrow(wallet());
^--------------^
/Users/chriscates/Projects/openzeppelin-solidity/contracts/payment/ConditionalEscrow.sol:16:3: Missing implementation:
function withdrawalAllowed(address payee) public view returns (bool);
^-------------------------------------------------------------------^ Anyway, will get back to you guys soon with some updates! |
A couple users have reported concerns upon finding that compiling OpenZeppelin contracts emits warnings. This is the only warning the latest compier (v0.5.8) emits:
That warning is actually valid, and there's currently no way to express what we intend to do (call |
We found a workaround to all edge cases, and now have no more warnings! |
@nventuro, sweet good to hear man! Keep up the good work man! |
Some of our contracts compile with warnings, mostly due to unused function names of functions that will be overridden, and require the argument to be there for the docstring to not error out.
OZ should compile with no warnings, so we should either make inline exceptions for this, or find a way to work around it.
The text was updated successfully, but these errors were encountered: