-
Notifications
You must be signed in to change notification settings - Fork 112
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
Upgrade contracts to solc 0.5.0 syntax #467
Conversation
6714ae9
to
b5a4d05
Compare
… _before_ error messages made it in
…modifier for addresses
b5a4d05
to
9572dcf
Compare
contracts/Colony.sol
Outdated
@@ -275,4 +276,6 @@ contract Colony is ColonyStorage, PatriciaTreeProofs { | |||
emit DomainAdded(domainCount); | |||
emit PotAdded(potCount); | |||
} | |||
|
|||
function() external payable {} |
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.
What is this for? A fallback for receiving Ether?
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.
You are on an outdated commit @kronosapiens . This was removed a day before I finished the PR. Not sure how you got it?
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 was trying out a commit-by-commit review this time, to better see how the PR evolved over time. But it does make commenting a bit trickier.
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.
Yeah I had to go back on part of the implementation. Normally I would just drop or amend commits but the change was tricker to extract this time. I'll try to keep a cleaner commit history going forward.
@@ -85,8 +85,9 @@ contract ColonyNetworkMining is ColonyNetworkStorage { | |||
address clnyToken = IMetaColony(metaColony).getToken(); | |||
require(clnyToken != address(0x0), "colony-reputation-mining-clny-token-invalid-address"); | |||
|
|||
inactiveReputationMiningCycle = new EtherRouter(); | |||
EtherRouter(inactiveReputationMiningCycle).setResolver(miningCycleResolver); | |||
EtherRouter e = new EtherRouter(); |
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.
Why this change?
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.
Because implicit conversion from a contract to address type is not supported in solc 0.5.0. Additionally the cast from non-payable address to a payable contract type (such as EtherRouter) is also not supported. Additionally the new single line replacement is much cleaner in its purpose.
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.
👍
@@ -72,7 +72,7 @@ contract ContractRecovery is CommonStorage { | |||
function exitRecoveryMode() public recovery auth { | |||
uint totalAuthorized = recoveryRolesCount; | |||
// Don't double count the owner (if set); | |||
if (owner != address(0x0) && !CommonAuthority(authority).hasUserRole(owner, RECOVERY_ROLE)) { | |||
if (owner != address(0x0) && !CommonAuthority(address(authority)).hasUserRole(owner, RECOVERY_ROLE)) { |
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.
How come owner
doesn't need to be cast to address
?
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.
If you check the actual declarations of these vars, they are:
DSAuthority public authority;
address public owner;
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.
👍
@@ -452,7 +452,7 @@ contract ColonyTask is ColonyStorage { | |||
role.rating = role.rateFail ? TaskRatings.Unsatisfactory : TaskRatings.Satisfactory; | |||
} | |||
|
|||
uint256 payout = task.payouts[roleId][token]; | |||
uint256 payout = task.payouts[roleId][address(token)]; |
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.
Interesting, elsewhere I saw that the address
cast was removed when accessing a mapping.
contracts/Colony.sol
Outdated
@@ -24,6 +24,8 @@ import "./EtherRouter.sol"; | |||
|
|||
contract Colony is ColonyStorage, PatriciaTreeProofs { | |||
|
|||
function() external payable {} |
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 comment explaining what this function is for?
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 is no longer there.
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.
👍
@@ -204,7 +204,7 @@ contract("ColonyNetworkMining", accounts => { | |||
await giveUserCLNYTokens(colonyNetwork, OTHER_ACCOUNT, 9000); | |||
await clny.approve(tokenLocking.address, 10000, { from: OTHER_ACCOUNT }); | |||
|
|||
await checkErrorRevert(tokenLocking.deposit(clny.address, 10000, { from: OTHER_ACCOUNT }), "ds-token-insufficient-balance"); | |||
await checkErrorRevert(tokenLocking.deposit(clny.address, 10000, { from: OTHER_ACCOUNT })); |
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.
Oh well :/
contracts/Colony.sol
Outdated
@@ -15,7 +15,7 @@ | |||
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
|
|||
pragma solidity >0.5.0; | |||
pragma solidity >=0.4.23; |
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.
Why, if we are committed to Sol 5 moving forward?
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.
In the PR description I explained that we cannot fully commit to 0.5.0 yet which is mainly because solidity-coverage
doesn't support it.
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.
👍
How come in the last few commits it looks like some of the changes around |
@@ -15,8 +15,7 @@ | |||
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
|
|||
pragma solidity ^0.4.23; | |||
pragma experimental "v0.5.0"; | |||
pragma solidity >=0.4.23 <0.5.0; |
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 this also omit the <0.5.0
?
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.
There are a handful of contracts which guaranteed will break if compiled under solc 0.5.0 so I've put a limit on those.
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 is because due to |
Closes #459
Implements fixes for the solc 0.5.0 breaking changes. The only exception not yet implemented is the
address payable
modifier and this is due tosolidity-coverage
and additionally [solium
] (duaraghav8/Ethlint#246) not yet supporting it.Since the CLNY token and MultiSig contracts were compiled and deployed with earlier version of
solc
here we start importing the already compiled contracts fromcolonyToken
repo, as opposed to recompiling them from source internally here.