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

Update to solc 0.4.24 #383

Merged
merged 33 commits into from
Aug 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7cd1f45
Bump to solc 0.4.24
izqui Aug 16, 2018
ba41180
Update to new constructor syntax and fix tests
izqui Aug 16, 2018
04c3dde
Use 'block.timestamp' instead of deprecated 'now'
izqui Aug 17, 2018
e22a882
Fix StandardToken tests
izqui Aug 17, 2018
8a3e40b
Fix lint
izqui Aug 17, 2018
7471d08
Fix compiler warnings except for lib contracts
izqui Aug 17, 2018
eb0f4ba
Update solc pragma for recently new contracts and mocks
izqui Aug 23, 2018
2993bc9
Use solc abi.encodeWithSelector instead of custom encoding
izqui Aug 17, 2018
2056fe0
Cleanup
izqui Aug 17, 2018
97b835b
Remove unused memcpy from ScriptHelpers
izqui Aug 17, 2018
cae3501
Update to solidity-coverage 0.5.7, moves mocks to contract dir
izqui Aug 23, 2018
bf647a8
Fix KernelConstants test
izqui Aug 23, 2018
04c3f66
Fix compiler warnings in contracts and mocks
izqui Aug 23, 2018
1a5d332
Update solidity-coverage settings
izqui Aug 23, 2018
5153348
Fix coverage for app_base_lifecycle.js
izqui Aug 23, 2018
3c1d91a
Mocks: fix paths to be relative to contracts/
sohkai Aug 23, 2018
4b0d6aa
Remove unnecessary migration
sohkai Aug 23, 2018
083e038
Merge branch 'dev' into solc-0.4.24
sohkai Aug 23, 2018
f3a07ec
Make ACL oracle check a staticcall
izqui Aug 23, 2018
2e67157
Mocks: fix compile warnings
sohkai Aug 23, 2018
e480100
Pin truffle and solidity-coverage versions
izqui Aug 23, 2018
c59e01b
Merge branch 'dev' into solc-0.4.24
sohkai Aug 23, 2018
95c6e21
Skip ACLSyntaxSugar from coverage
izqui Aug 24, 2018
d58d7e1
test: wrap solidity tests in JS runner
sohkai Aug 24, 2018
277290e
test: remove unnecessay .call()s
sohkai Aug 24, 2018
430358b
test: stop emitting events from APMNamehash mock
sohkai Aug 24, 2018
78d5ce4
Manually link library in runSolidityTest removing the migration
izqui Aug 25, 2018
f3db3ca
Linter ignore test dir
izqui Aug 25, 2018
ccacd79
Manually link library in runSolidityTest removing the migration (#396)
sohkai Aug 26, 2018
6b94631
test: fix APMNamehashWrapper
sohkai Aug 26, 2018
cba432e
test: fix compile warnings
sohkai Aug 26, 2018
bb32ba1
Make interface functions external
sohkai Aug 26, 2018
291c1a6
Merge pull request #395 from aragon/wrap-solidity-tests
sohkai Aug 26, 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
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contracts/test
16 changes: 2 additions & 14 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
// NOTE: Upgrading to solidity-coverage 0.4.x breaks our tests

const libFiles = require('glob').sync('contracts/lib/**/*.sol').map(n => n.replace('contracts/', ''))
const interfaces = [
'acl/IACL.sol',
'acl/IACLOracle.sol',
'acl/ACLSyntaxSugar.sol',
'common/IForwarder.sol',
'common/IVaultRecoverable.sol',
'evmscript/IEVMScriptExecutor.sol',
'kernel/IKernel.sol',
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh this is much needed; they can detect interfaces now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like it! Was testing to see the cause of requirement for .call() was the fact that interfaces weren't being instrumented, which was not the case, but it was a nice surprise.

const skipFiles = ['lib', 'test', 'acl/ACLSyntaxSugar.sol']

module.exports = {
norpc: true,
compileCommand: '../node_modules/.bin/truffle compile',
testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage',
skipFiles: interfaces.concat(libFiles),
copyNodeModules: true,
skipFiles,
}
1 change: 1 addition & 0 deletions .soliumignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
contracts/lib
contracts/test
57 changes: 34 additions & 23 deletions contracts/acl/ACL.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.18;
pragma solidity 0.4.24;

import "../apps/AragonApp.sol";
import "./ACLSyntaxSugar.sol";
Expand Down Expand Up @@ -43,6 +43,7 @@ contract ACL is IACL, AragonApp, ACLHelpers {
bytes32 constant public EMPTY_PARAM_HASH = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563;
bytes32 constant public NO_PERMISSION = bytes32(0);
address constant public ANY_ENTITY = address(-1);
uint256 constant ORACLE_CHECK_GAS = 30000;

modifier onlyPermissionManager(address _app, bytes32 _role) {
require(msg.sender == getPermissionManager(_app, _role));
Expand Down Expand Up @@ -170,12 +171,10 @@ contract ACL is IACL, AragonApp, ACLHelpers {
function getPermissionParam(address _entity, address _app, bytes32 _role, uint _index)
external
view
returns (uint8 id, uint8 op, uint240 value)
returns (uint8, uint8, uint240)
{
Param storage param = permissionParams[permissions[permissionHash(_entity, _app, _role)]][_index];
id = param.id;
op = param.op;
value = param.value;
return (param.id, param.op, param.value);
}

/**
Expand Down Expand Up @@ -257,17 +256,17 @@ contract ACL is IACL, AragonApp, ACLHelpers {
*/
function _setPermission(address _entity, address _app, bytes32 _role, bytes32 _paramsHash) internal {
permissions[permissionHash(_entity, _app, _role)] = _paramsHash;
bool hasPermission = _paramsHash != NO_PERMISSION;
bool hasParams = hasPermission && _paramsHash != EMPTY_PARAM_HASH;
bool entityHasPermission = _paramsHash != NO_PERMISSION;
bool permissionHasParams = entityHasPermission && _paramsHash != EMPTY_PARAM_HASH;

SetPermission(_entity, _app, _role, hasPermission);
if (hasParams) {
SetPermissionParams(_entity, _app, _role, _paramsHash);
emit SetPermission(_entity, _app, _role, entityHasPermission);
if (permissionHasParams) {
emit SetPermissionParams(_entity, _app, _role, _paramsHash);
}
}

function _saveParams(uint256[] _encodedParams) internal returns (bytes32) {
bytes32 paramHash = keccak256(_encodedParams);
bytes32 paramHash = keccak256(abi.encodePacked(_encodedParams));
Param[] storage params = permissionParams[paramHash];

if (params.length == 0) { // params not saved before
Expand Down Expand Up @@ -333,14 +332,21 @@ contract ACL is IACL, AragonApp, ACLHelpers {
returns (bool)
{
if (Op(_param.op) == Op.IF_ELSE) {
var (condition, success, failure) = decodeParamsList(uint256(_param.value));
bool result = _evalParam(_paramsHash, condition, _who, _where, _what, _how);
uint32 conditionParam;
uint32 successParam;
uint32 failureParam;

return _evalParam(_paramsHash, result ? success : failure, _who, _where, _what, _how);
(conditionParam, successParam, failureParam) = decodeParamsList(uint256(_param.value));
bool result = _evalParam(_paramsHash, conditionParam, _who, _where, _what, _how);

return _evalParam(_paramsHash, result ? successParam : failureParam, _who, _where, _what, _how);
}

var (v1, v2,) = decodeParamsList(uint256(_param.value));
bool r1 = _evalParam(_paramsHash, v1, _who, _where, _what, _how);
uint32 param1;
uint32 param2;

(param1, param2,) = decodeParamsList(uint256(_param.value));
bool r1 = _evalParam(_paramsHash, param1, _who, _where, _what, _how);

if (Op(_param.op) == Op.NOT) {
return !r1;
Expand All @@ -354,7 +360,7 @@ contract ACL is IACL, AragonApp, ACLHelpers {
return false;
}

bool r2 = _evalParam(_paramsHash, v2, _who, _where, _what, _how);
bool r2 = _evalParam(_paramsHash, param2, _who, _where, _what, _how);

if (Op(_param.op) == Op.XOR) {
return r1 != r2;
Expand All @@ -377,8 +383,13 @@ contract ACL is IACL, AragonApp, ACLHelpers {
bytes4 sig = _oracleAddr.canPerform.selector;

// a raw call is required so we can return false if the call reverts, rather than reverting
bool ok = address(_oracleAddr).call(sig, _who, _where, _what, 0x80, _how.length, _how);
// 0x80 is the position where the array that goes there starts
bytes memory checkCalldata = abi.encodeWithSelector(sig, _who, _where, _what, _how);
uint256 oracleCheckGas = ORACLE_CHECK_GAS;

bool ok;
assembly {
ok := staticcall(oracleCheckGas, _oracleAddr, add(checkCalldata, 0x20), mload(checkCalldata), 0, 0)
}

if (!ok) {
return false;
Expand All @@ -393,7 +404,7 @@ contract ACL is IACL, AragonApp, ACLHelpers {
bool result;
assembly {
let ptr := mload(0x40) // get next free memory ptr
returndatacopy(ptr, 0, size) // copy return from above `call`
returndatacopy(ptr, 0, size) // copy return from above `staticcall`
result := mload(ptr) // read data at ptr and set it to result
mstore(ptr, 0) // set pointer memory to 0 so it still is the next free ptr
}
Expand All @@ -406,15 +417,15 @@ contract ACL is IACL, AragonApp, ACLHelpers {
*/
function _setPermissionManager(address _newManager, address _app, bytes32 _role) internal {
permissionManager[roleHash(_app, _role)] = _newManager;
ChangePermissionManager(_app, _role, _newManager);
emit ChangePermissionManager(_app, _role, _newManager);
}

function roleHash(address _where, bytes32 _what) internal pure returns (bytes32) {
return keccak256("ROLE", _where, _what);
return keccak256(abi.encodePacked("ROLE", _where, _what));
}

function permissionHash(address _who, address _where, bytes32 _what) internal pure returns (bytes32) {
return keccak256("PERMISSION", _who, _where, _what);
return keccak256(abi.encodePacked("PERMISSION", _who, _where, _what));
}

function time() internal view returns (uint64) { return uint64(block.timestamp); } // solium-disable-line security/no-block-members
Expand Down
4 changes: 2 additions & 2 deletions contracts/acl/ACLSyntaxSugar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;


contract ACLSyntaxSugar {
function arr() internal pure returns (uint256[] r) {}
function arr() internal pure returns (uint256[]) {}

function arr(bytes32 _a) internal pure returns (uint256[] r) {
return arr(uint256(_a));
Expand Down
7 changes: 5 additions & 2 deletions contracts/acl/IACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;


interface IACL {
function initialize(address permissionsCreator) public;
function initialize(address permissionsCreator) external;

// TODO: this should be external
// See https://github.com/ethereum/solidity/issues/4832
function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
}
4 changes: 2 additions & 2 deletions contracts/acl/IACLOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;


interface IACLOracle {
function canPerform(address who, address where, bytes32 what, uint256[] how) public view returns (bool);
function canPerform(address who, address where, bytes32 what, uint256[] how) external view returns (bool);
}
6 changes: 3 additions & 3 deletions contracts/apm/APMNamehash.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;

import "../ens/ENSConstants.sol";


contract APMNamehash is ENSConstants {
bytes32 constant public APM_NODE = keccak256(ETH_TLD_NODE, keccak256("aragonpm"));
bytes32 constant public APM_NODE = keccak256(abi.encodePacked(ETH_TLD_NODE, keccak256("aragonpm")));

function apmNamehash(string name) internal pure returns (bytes32) {
return keccak256(APM_NODE, keccak256(name));
return keccak256(abi.encodePacked(APM_NODE, keccak256(bytes(name))));
}
}
8 changes: 4 additions & 4 deletions contracts/apm/APMRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.18;
pragma solidity 0.4.24;

import "../lib/ens/AbstractENS.sol";
import "../ens/ENSSubdomainRegistrar.sol";
Expand Down Expand Up @@ -89,9 +89,9 @@ contract APMRegistry is AragonApp, AppProxyFactory, APMRegistryConstants {

// Creates [name] subdomain in the rootNode and sets registry as resolver
// This will fail if repo name already exists
bytes32 node = registrar.createNameAndPoint(keccak256(_name), repo);
bytes32 node = registrar.createNameAndPoint(keccak256(abi.encodePacked(_name)), repo);

NewRepo(node, _name, repo);
emit NewRepo(node, _name, repo);

return repo;
}
Expand All @@ -102,6 +102,6 @@ contract APMRegistry is AragonApp, AppProxyFactory, APMRegistryConstants {
}

function repoAppId() internal view returns (bytes32) {
return keccak256(registrar.rootNode(), keccak256(REPO_APP_NAME));
return keccak256(abi.encodePacked(registrar.rootNode(), keccak256(abi.encodePacked(REPO_APP_NAME))));
}
}
6 changes: 3 additions & 3 deletions contracts/apm/Repo.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.18;
pragma solidity 0.4.24;

import "../apps/AragonApp.sol";

Expand Down Expand Up @@ -60,7 +60,7 @@ contract Repo is AragonApp {
versionIdForSemantic[semanticVersionHash(_newSemanticVersion)] = versionId;
latestVersionIdForContract[contractAddress] = versionId;

NewVersion(versionId, _newSemanticVersion);
emit NewVersion(versionId, _newSemanticVersion);
}

function getLatest() public view returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) {
Expand Down Expand Up @@ -114,6 +114,6 @@ contract Repo is AragonApp {
}

function semanticVersionHash(uint16[3] version) internal pure returns (bytes32) {
return keccak256(version[0], version[1], version[2]);
return keccak256(abi.encodePacked(version[0], version[1], version[2]));
}
}
6 changes: 3 additions & 3 deletions contracts/apps/AppProxyBase.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.18;
pragma solidity 0.4.24;

import "./AppStorage.sol";
import "../common/DepositableDelegateProxy.sol";
Expand All @@ -13,7 +13,7 @@ contract AppProxyBase is AppStorage, DepositableDelegateProxy, KernelConstants {
* @param _appId Identifier for app
* @param _initializePayload Payload for call to be made after setup to initialize
*/
function AppProxyBase(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
setKernel(_kernel);
setAppId(_appId);

Expand All @@ -33,6 +33,6 @@ contract AppProxyBase is AppStorage, DepositableDelegateProxy, KernelConstants {
}

function getAppBase(bytes32 _appId) internal view returns (address) {
return kernel().getApp(keccak256(APP_BASES_NAMESPACE, _appId));
return kernel().getApp(keccak256(abi.encodePacked(APP_BASES_NAMESPACE, _appId)));
}
}
4 changes: 2 additions & 2 deletions contracts/apps/AppProxyPinned.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.18;
pragma solidity 0.4.24;

import "../common/UnstructuredStorage.sol";
import "../common/IsContract.sol";
Expand All @@ -17,7 +17,7 @@ contract AppProxyPinned is IsContract, AppProxyBase {
* @param _appId Identifier for app
* @param _initializePayload Payload for call to be made after setup to initialize
*/
function AppProxyPinned(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
AppProxyBase(_kernel, _appId, _initializePayload)
public // solium-disable-line visibility-first
{
Expand Down
4 changes: 2 additions & 2 deletions contracts/apps/AppProxyUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.18;
pragma solidity 0.4.24;

import "./AppProxyBase.sol";

Expand All @@ -10,7 +10,7 @@ contract AppProxyUpgradeable is AppProxyBase {
* @param _appId Identifier for app
* @param _initializePayload Payload for call to be made after setup to initialize
*/
function AppProxyUpgradeable(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
AppProxyBase(_kernel, _appId, _initializePayload)
public // solium-disable-line visibility-first
{
Expand Down
2 changes: 1 addition & 1 deletion contracts/apps/AppStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;

import "../common/UnstructuredStorage.sol";
import "../kernel/IKernel.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/apps/AragonApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;

import "./AppStorage.sol";
import "../common/Autopetrified.sol";
Expand Down
4 changes: 2 additions & 2 deletions contracts/apps/UnsafeAragonApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;

import "../common/UnstructuredStorage.sol";
import "./AragonApp.sol";
Expand All @@ -17,7 +17,7 @@ import "./AragonApp.sol";
contract UnsafeAragonApp is AragonApp {
using UnstructuredStorage for bytes32;

function UnsafeAragonApp() public {
constructor() public {
// Removes auto petrifying; simulates a delete at INITIALIZATION_BLOCK_POSITION
INITIALIZATION_BLOCK_POSITION.setStorageUint256(0);
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/common/Autopetrified.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;
pragma solidity ^0.4.24;

import "./Petrifiable.sol";


contract Autopetrified is Petrifiable {
function Autopetrified() public {
constructor() public {
// Immediately petrify base (non-proxy) instances of inherited contracts on deploy.
// This renders them uninitializable (and unusable without a proxy).
petrify();
Expand Down
2 changes: 1 addition & 1 deletion contracts/common/DelegateProxy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.18;
pragma solidity 0.4.24;

import "../common/IsContract.sol";
import "../lib/misc/ERCProxy.sol";
Expand Down
Loading