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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
789b8ae
Switch pragma to 0.5.0 and fix function parameter memory keyword miss…
elenadimitrova Dec 17, 2018
6da0616
Make 0x0 value explicitely an address where necessary
elenadimitrova Dec 17, 2018
bb30145
Explicitely convert contract references to address type
elenadimitrova Dec 17, 2018
4e07930
Final set of fixes to migrate to 0.5.0
elenadimitrova Dec 18, 2018
00bcef6
Skip solium run on contracts due to solium's incompatibility for solc…
elenadimitrova Dec 18, 2018
04e9891
Minor ammends
elenadimitrova Dec 18, 2018
1d408c5
Amend script to provision folder if nonexistent
elenadimitrova Dec 18, 2018
7750dc9
Remove named return parameters when they are payable address type
elenadimitrova Dec 18, 2018
566b394
Give proper name to circle step
elenadimitrova Dec 18, 2018
1c1b50a
Exclude fallback function from recovery mods check
elenadimitrova Dec 18, 2018
8c4684d
Fix a failing test with CLNY since that was compiled with dappsys lib…
elenadimitrova Dec 18, 2018
17e2efc
Remove the now deleted gnosis folder from solcover skip
elenadimitrova Dec 20, 2018
063ba42
Switch pragma back to supporting 0.4.23 and after solc version
elenadimitrova Dec 20, 2018
b3f8cfe
Remove payable modifier from address props and add solc <0.5.0 limita…
elenadimitrova Dec 20, 2018
4401163
Remove solium exceptions as not needed while we stay with no payable …
elenadimitrova Dec 20, 2018
8be273a
Fix a scope variable overlap
elenadimitrova Dec 20, 2018
4221da6
Pull the right solc docker image
elenadimitrova Dec 20, 2018
9572dcf
Bundle the truffle compile and token contracts provisioning for solcover
elenadimitrova Dec 21, 2018
b1d79ec
Remove setup upgradable token helper
elenadimitrova Dec 21, 2018
967daf8
Minor fixes
elenadimitrova Dec 21, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ step_setup_global_packages: &step_setup_global_packages
yarn run provision:token:contracts
step_pull_solc_docker: &step_pull_solc_docker
run:
name: "Pull solc 0.4.23 docker image"
name: "Pull solc docker image"
command: docker pull ethereum/solc:0.4.23
jobs:
lint-and-unit-test:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ node_modules
parity-genesis.json
contracts/Updated*
contracts/IUpdated*
contracts/Token.sol
contracts/TokenAuthority.sol
keys/*
test-results.xml
0
Expand Down
7 changes: 3 additions & 4 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ module.exports = {
skipFiles: [
'Migrations.sol',
'EtherRouter.sol',
'gnosis',
'ERC20ExtendedToken.sol',
'PatriciaTree'
'PatriciaTree',
'ERC20ExtendedToken.sol'
],
compileCommand: '../node_modules/.bin/truffle compile',
compileCommand: 'yarn run provision:token:contracts:compile',
testCommand: '../node_modules/.bin/truffle test --network coverage',
testrpcOptions: `--port 8555 -i 1999 --acctKeys="./coverageEnv/ganache-accounts.json" --noVMErrorsOnRPCResponse --accounts 12`
};
7 changes: 2 additions & 5 deletions .soliumignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ node_modules
helpers
migrations
test
contracts/Migrations.sol
contracts/Token.sol
contracts/TokenAuthority.sol
contracts/gnosis/MultiSigWallet.sol
lib
packages
packages
contracts/Migrations.sol
31 changes: 15 additions & 16 deletions contracts/Colony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
pragma experimental ABIEncoderV2;

import "./ColonyStorage.sol";
Expand All @@ -31,28 +30,28 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {

function setFounderRole(address _user) public stoppable auth {
// To allow only one address to have founder role at a time, we have to remove current founder from their role
ColonyAuthority colonyAuthority = ColonyAuthority(authority);
ColonyAuthority colonyAuthority = ColonyAuthority(address(authority));
colonyAuthority.setUserRole(msg.sender, FOUNDER_ROLE, false);
colonyAuthority.setUserRole(_user, FOUNDER_ROLE, true);

emit ColonyFounderRoleSet(msg.sender, _user);
}

function setAdminRole(address _user) public stoppable auth {
ColonyAuthority(authority).setUserRole(_user, ADMIN_ROLE, true);
ColonyAuthority(address(authority)).setUserRole(_user, ADMIN_ROLE, true);

emit ColonyAdminRoleSet(_user);
}

// Can only be called by the founder role.
function removeAdminRole(address _user) public stoppable auth {
ColonyAuthority(authority).setUserRole(_user, ADMIN_ROLE, false);
ColonyAuthority(address(authority)).setUserRole(_user, ADMIN_ROLE, false);

emit ColonyAdminRoleRemoved(_user);
}

function hasUserRole(address _user, uint8 _role) public view returns (bool) {
return ColonyAuthority(authority).hasUserRole(_user, _role);
return ColonyAuthority(address(authority)).hasUserRole(_user, _role);
}

function getColonyNetworkAddress() public view returns (address) {
Expand All @@ -69,7 +68,7 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
}

function getToken() public view returns (address) {
return token;
return address(token);
}

function initialiseColony(address _colonyNetworkAddress) public stoppable {
Expand Down Expand Up @@ -104,7 +103,7 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
emit ColonyInitialised(_colonyNetworkAddress);
}

function bootstrapColony(address[] _users, int[] _amounts) public
function bootstrapColony(address[] memory _users, int[] memory _amounts) public
stoppable
auth
isInBootstrapPhase
Expand Down Expand Up @@ -132,12 +131,12 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
// Only the colony Network can call this function
require(msg.sender == colonyNetworkAddress, "colony-access-denied-only-network-allowed");
// Function only valid on the Meta Colony
require(this == IColonyNetwork(colonyNetworkAddress).getMetaColony(), "colony-access-denied-only-meta-colony-allowed");
require(address(this) == IColonyNetwork(colonyNetworkAddress).getMetaColony(), "colony-access-denied-only-meta-colony-allowed");
token.mint(_wad);
token.transfer(colonyNetworkAddress, _wad);
}

function registerColonyLabel(string colonyName, string orbitdb) public stoppable auth {
function registerColonyLabel(string memory colonyName, string memory orbitdb) public stoppable auth {
IColonyNetwork(colonyNetworkAddress).registerColonyLabel(colonyName, orbitdb);
}

Expand Down Expand Up @@ -184,15 +183,15 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
initialiseDomain(newLocalSkill);
}

function getDomain(uint256 _id) public view returns (Domain domain) {
function getDomain(uint256 _id) public view returns (Domain memory domain) {
domain = domains[_id];
}

function getDomainCount() public view returns (uint256) {
return domainCount;
}

modifier verifyKey(bytes key) {
modifier verifyKey(bytes memory key) {
uint256 colonyAddress;
uint256 skillid;
uint256 userAddress;
Expand All @@ -209,7 +208,7 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
_;
}

function verifyReputationProof(bytes key, bytes value, uint branchMask, bytes32[] siblings) // solium-disable-line security/no-assign-params
function verifyReputationProof(bytes memory key, bytes memory value, uint branchMask, bytes32[] memory siblings)
public view
stoppable
verifyKey(key)
Expand All @@ -228,9 +227,9 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
require(_newVersion > currentVersion, "colony-version-must-be-newer");
// Requested version has to be registered
address newResolver = IColonyNetwork(colonyNetworkAddress).getColonyVersionResolver(_newVersion);
require(newResolver != 0x0, "colony-version-must-be-registered");
EtherRouter e = EtherRouter(address(this));
e.setResolver(newResolver);
require(newResolver != address(0x0), "colony-version-must-be-registered");
EtherRouter currentColony = EtherRouter(address(this));
currentColony.setResolver(newResolver);

emit ColonyUpgraded(currentVersion, _newVersion);
}
Expand Down
7 changes: 3 additions & 4 deletions contracts/ColonyAuthority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

import "./CommonAuthority.sol";

Expand Down Expand Up @@ -70,12 +69,12 @@ contract ColonyAuthority is CommonAuthority {
setFounderRoleCapability(colony, "setAdminRole(address)");
}

function setFounderRoleCapability(address colony, bytes sig) private {
function setFounderRoleCapability(address colony, bytes memory sig) private {
bytes4 functionSig = bytes4(keccak256(sig));
setRoleCapability(founderRole, colony, functionSig, true);
}

function setAdminRoleCapability(address colony, bytes sig) private {
function setAdminRoleCapability(address colony, bytes memory sig) private {
bytes4 functionSig = bytes4(keccak256(sig));
setRoleCapability(adminRole, colony, functionSig, true);
}
Expand Down
3 changes: 1 addition & 2 deletions contracts/ColonyDataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;


contract ColonyDataTypes {
Expand Down
47 changes: 27 additions & 20 deletions contracts/ColonyFunding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
pragma experimental "ABIEncoderV2";

import "./ColonyStorage.sol";
Expand Down Expand Up @@ -52,8 +51,15 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
{
Task storage task = tasks[_id];

require(task.roles[EVALUATOR].user == task.roles[MANAGER].user || task.roles[EVALUATOR].user == 0x0, "colony-funding-evaluator-already-set");
require(task.roles[WORKER].user == task.roles[MANAGER].user || task.roles[WORKER].user == 0x0, "colony-funding-worker-already-set");
require(
task.roles[EVALUATOR].user == task.roles[MANAGER].user ||
task.roles[EVALUATOR].user == address(0x0),
"colony-funding-evaluator-already-set");

require(
task.roles[WORKER].user == task.roles[MANAGER].user ||
task.roles[WORKER].user == address(0x0),
"colony-funding-worker-already-set");

this.setTaskManagerPayout(_id, _token, _managerAmount);
this.setTaskEvaluatorPayout(_id, _token, _evaluatorAmount);
Expand Down Expand Up @@ -95,10 +101,9 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
uint fee = calculateNetworkFeeForPayout(payout);
uint remainder = sub(payout, fee);

if (_token == 0x0) {
if (_token == address(0x0)) {
// Payout ether
address user = task.roles[_role].user;
user.transfer(remainder);
msg.sender.transfer(remainder);
// Fee goes directly to Meta Colony
IColonyNetwork colonyNetworkContract = IColonyNetwork(colonyNetworkAddress);
address metaColonyAddress = colonyNetworkContract.getMetaColony();
Expand Down Expand Up @@ -169,13 +174,13 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
uint toClaim;
uint feeToPay;
uint remainder;
if (_token == 0x0) {
if (_token == address(0x0)) {
// It's ether
toClaim = sub(sub(address(this).balance, nonRewardPotsTotal[_token]), pots[0].balance[_token]);
} else {
// Assume it's an ERC 20 token.
ERC20Extended targetToken = ERC20Extended(_token);
toClaim = sub(sub(targetToken.balanceOf(this), nonRewardPotsTotal[_token]), pots[0].balance[_token]);
toClaim = sub(sub(targetToken.balanceOf(address(this)), nonRewardPotsTotal[_token]), pots[0].balance[_token]);
}

feeToPay = toClaim / getRewardInverse();
Expand All @@ -191,7 +196,9 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
return nonRewardPotsTotal[_token];
}

function startNextRewardPayout(address _token, bytes key, bytes value, uint256 branchMask, bytes32[] siblings) public auth stoppable {
function startNextRewardPayout(address _token, bytes memory key, bytes memory value, uint256 branchMask, bytes32[] memory siblings)
public auth stoppable
{
ITokenLocking tokenLocking = ITokenLocking(IColonyNetwork(colonyNetworkAddress).getTokenLocking());
uint256 totalLockCount = tokenLocking.lockToken(address(token));

Expand All @@ -204,7 +211,7 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
uint256 colonyWideReputation = checkReputation(
rootHash,
domains[1].skillId,
0x0,
address(0x0),
key,
value,
branchMask,
Expand All @@ -228,11 +235,11 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {

function claimRewardPayout(
uint256 _payoutId,
uint256[7] _squareRoots,
bytes key,
bytes value,
uint256[7] memory _squareRoots,
bytes memory key,
bytes memory value,
uint256 branchMask,
bytes32[] siblings
bytes32[] memory siblings
) public stoppable
{
uint256 userReputation = checkReputation(
Expand Down Expand Up @@ -271,7 +278,7 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
emit RewardPayoutCycleEnded(_payoutId);
}

function getRewardPayoutInfo(uint256 _payoutId) public view returns (RewardPayoutCycle rewardPayoutCycle) {
function getRewardPayoutInfo(uint256 _payoutId) public view returns (RewardPayoutCycle memory rewardPayoutCycle) {
rewardPayoutCycle = rewardPayoutCycles[_payoutId];
}

Expand All @@ -293,10 +300,10 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
bytes32 rootHash,
uint256 skillId,
address userAddress,
bytes key,
bytes value,
bytes memory key,
bytes memory value,
uint256 branchMask,
bytes32[] siblings
bytes32[] memory siblings
) internal view returns (uint256)
{
bytes32 impliedRoot = getImpliedRootHashKey(key, value, branchMask, siblings);
Expand All @@ -321,7 +328,7 @@ contract ColonyFunding is ColonyStorage, PatriciaTreeProofs {
return reputationValue;
}

function calculateRewardForUser(uint256 payoutId, uint256[7] squareRoots, uint256 userReputation) internal returns (address, uint256) {
function calculateRewardForUser(uint256 payoutId, uint256[7] memory squareRoots, uint256 userReputation) internal returns (address, uint256) {
RewardPayoutCycle memory payout = rewardPayoutCycles[payoutId];
// Checking if payout is active
require(block.timestamp - payout.blockTimestamp <= 60 days, "colony-reward-payout-not-active");
Expand Down
Loading