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

Upgrade contracts to solc 0.5.0 syntax #467

Merged
merged 20 commits into from
Dec 27, 2018

Conversation

elenadimitrova
Copy link
Contributor

@elenadimitrova elenadimitrova commented Dec 18, 2018

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 to solidity-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 from colonyToken repo, as opposed to recompiling them from source internally here.

@elenadimitrova elenadimitrova changed the title Upgrade contracts to solc 0.5.1 Upgrade contracts to solc 0.5.0 syntax Dec 21, 2018
@@ -275,4 +276,6 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
emit DomainAdded(domainCount);
emit PotAdded(potCount);
}

function() external payable {}
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

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.

Copy link
Member

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)) {
Copy link
Member

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?

Copy link
Contributor Author

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;

Copy link
Member

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)];
Copy link
Member

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.

@@ -24,6 +24,8 @@ import "./EtherRouter.sol";

contract Colony is ColonyStorage, PatriciaTreeProofs {

function() external payable {}
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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 }));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well :/

@@ -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;
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kronosapiens
Copy link
Member

How come in the last few commits it looks like some of the changes around address payable and the version pragma were rolled back?

@@ -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;
Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@elenadimitrova
Copy link
Contributor Author

How come in the last few commits it looks like some of the changes around address payable and the version pragma were rolled back?

This is because due to solidity-coverage not yet supporting solc 0.5.0 we had to stay on 0.4 compiler but still with an upgraded syntax to support the incoming solc 0.5.0. With the exception of address payable with is only supported from 0.5.0 onwards and so cannot be used yet here.

@kronosapiens kronosapiens merged commit 2d59360 into develop Dec 27, 2018
@kronosapiens kronosapiens deleted the maintenance/upgrade-solc-0.5.0 branch December 27, 2018 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade contracts to solc 0.5.0
2 participants