Skip to content

Commit

Permalink
Merge 291c1a6 into 2b14e55
Browse files Browse the repository at this point in the history
  • Loading branch information
izqui committed Aug 26, 2018
2 parents 2b14e55 + 291c1a6 commit b4efaee
Show file tree
Hide file tree
Showing 101 changed files with 1,963 additions and 624 deletions.
1 change: 1 addition & 0 deletions .npmignore
@@ -0,0 +1 @@
contracts/test
16 changes: 2 additions & 14 deletions .solcover.js
@@ -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',
]
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
@@ -1,2 +1,3 @@
node_modules
contracts/lib
contracts/test
57 changes: 34 additions & 23 deletions contracts/acl/ACL.sol
@@ -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
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
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
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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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
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
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
@@ -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

0 comments on commit b4efaee

Please sign in to comment.