Skip to content

Commit

Permalink
Merge branch 'rp3.0-updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
kanewallmann committed Jul 20, 2021
2 parents e614c96 + ad6861e commit 07b212e
Show file tree
Hide file tree
Showing 220 changed files with 15,175 additions and 3,955 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ coverage.json
coverage/
coverageEnv/
.vscode
1.0
@openzeppelin
1.0
.idea
25 changes: 3 additions & 22 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
testrpcOptions: '--accounts 35 --port 8555 --defaultBalanceEther 1000',
providerOptions: {
default_balance_ether: 100000,
},
testCommand: 'truffle test test/rocketPool-tests.js --network coverage',
skipFiles: [
'lib',
Expand All @@ -10,26 +12,5 @@ module.exports = {
'contract/utils/Maths.sol',
'contract/utils/Ownable.sol',
'contract/utils/Signatures.sol',
'contract/utils/lists/AddressListStorage.sol',
//'contract/utils/lists/AddressQueueStorage.sol',
//'contract/utils/lists/AddressSetStorage.sol',
'contract/utils/lists/BoolListStorage.sol',
'contract/utils/lists/BoolQueueStorage.sol',
'contract/utils/lists/BoolSetStorage.sol',
'contract/utils/lists/Bytes32ListStorage.sol',
//'contract/utils/lists/Bytes32QueueStorage.sol',
//'contract/utils/lists/Bytes32SetStorage.sol',
'contract/utils/lists/BytesListStorage.sol',
'contract/utils/lists/BytesQueueStorage.sol',
'contract/utils/lists/BytesSetStorage.sol',
'contract/utils/lists/IntListStorage.sol',
'contract/utils/lists/IntQueueStorage.sol',
'contract/utils/lists/IntSetStorage.sol',
'contract/utils/lists/StringListStorage.sol',
'contract/utils/lists/StringQueueStorage.sol',
//'contract/utils/lists/StringSetStorage.sol',
'contract/utils/lists/UintListStorage.sol',
'contract/utils/lists/UintQueueStorage.sol',
'contract/utils/lists/UintSetStorage.sol',
],
};
7 changes: 6 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ pool:
vmImage: ubuntu-latest

steps:
- task: NodeTool@0
inputs:
versionSpec: '16.4.2'
- script: npm install
- script: npm run compile
- task: DownloadSecureFile@1
name: githubPEM
displayName: 'Download Github PEM'
Expand All @@ -28,4 +33,4 @@ steps:
env:
GITHUB_PEM_PATH: $(githubPEM.secureFilePath)
GITHUB_APP_ID: $(GITHUB_APP_ID)
GITHUB_APP_INSTALLATION_ID: $(GITHUB_APP_INSTALLATION_ID)
GITHUB_APP_INSTALLATION_ID: $(GITHUB_APP_INSTALLATION_ID)
8 changes: 4 additions & 4 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

// SPDX-License-Identifier: GPL-3.0-only

Expand All @@ -13,15 +13,15 @@ contract Migrations {
_;
}

constructor() public {
constructor() {
owner = msg.sender;
}

function setCompleted(uint completed) public restricted {
function setCompleted(uint completed) external restricted {
last_completed_migration = completed;
}

function upgrade(address newAddress) public restricted {
function upgrade(address newAddress) external restricted {
Migrations upgraded = Migrations(newAddress);
upgraded.setCompleted(last_completed_migration);
}
Expand Down
109 changes: 42 additions & 67 deletions contracts/contract/RocketBase.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

// SPDX-License-Identifier: GPL-3.0-only

Expand All @@ -9,6 +9,8 @@ import "../interface/RocketStorageInterface.sol";

abstract contract RocketBase {

// Calculate using this as the base
uint256 constant calcBase = 1 ether;

// Version of the contract
uint8 public version;
Expand All @@ -17,6 +19,8 @@ abstract contract RocketBase {
RocketStorageInterface rocketStorage = RocketStorageInterface(0);


/*** Modifiers **********************************************************/

/**
* @dev Throws if called by any sender that doesn't match a Rocket Pool network contract
*/
Expand All @@ -25,7 +29,6 @@ abstract contract RocketBase {
_;
}


/**
* @dev Throws if called by any sender that doesn't match one of the supplied contract or is the latest version of that contract
*/
Expand All @@ -34,7 +37,6 @@ abstract contract RocketBase {
_;
}


/**
* @dev Throws if called by any sender that isn't a registered node
*/
Expand All @@ -43,63 +45,38 @@ abstract contract RocketBase {
_;
}


/**
* @dev Throws if called by any sender that isn't a trusted node
* @dev Throws if called by any sender that isn't a trusted node DAO member
*/
modifier onlyTrustedNode(address _nodeAddress) {
require(getBool(keccak256(abi.encodePacked("node.trusted", _nodeAddress))), "Invalid trusted node");
require(getBool(keccak256(abi.encodePacked("dao.trustednodes.", "member", _nodeAddress))), "Invalid trusted node");
_;
}


/**
* @dev Throws if called by any sender that isn't a registered minipool
*/
modifier onlyRegisteredMinipool(address _minipoolAddress) {
require(getBool(keccak256(abi.encodePacked("minipool.exists", _minipoolAddress))), "Invalid minipool");
_;
}


/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(roleHas("owner", msg.sender), "Account is not the owner");
_;
}



/**
* @dev Modifier to scope access to admins
* @dev Throws if called by any account other than a guardian account (temporary account allowed access to settings before DAO is fully enabled)
*/
modifier onlyAdmin() {
require(roleHas("admin", msg.sender), "Account is not an admin");
modifier onlyGuardian() {
require(msg.sender == rocketStorage.getGuardian(), "Account is not a temporary guardian");
_;
}


/**
* @dev Modifier to scope access to admins
*/
modifier onlySuperUser() {
require(roleHas("owner", msg.sender) || roleHas("admin", msg.sender), "Account is not a super user");
_;
}


/**
* @dev Reverts if the address doesn't have this role
*/
modifier onlyRole(string memory _role) {
require(roleHas(_role, msg.sender), "Account does not match the specified role");
_;
}

/*** Methods **********************************************************/

/// @dev Set the main Rocket Storage address
constructor(address _rocketStorageAddress) public {
constructor(RocketStorageInterface _rocketStorageAddress) {
// Update the contract address
rocketStorage = RocketStorageInterface(_rocketStorageAddress);
}
Expand All @@ -116,16 +93,41 @@ abstract contract RocketBase {
}


/// @dev Get the address of a network contract by name (returns address(0x0) instead of reverting if contract does not exist)
function getContractAddressUnsafe(string memory _contractName) internal view returns (address) {
// Get the current contract address
address contractAddress = getAddress(keccak256(abi.encodePacked("contract.address", _contractName)));
// Return
return contractAddress;
}


/// @dev Get the name of a network contract by address
function getContractName(address _contractAddress) internal view returns (string memory) {
// Get the contract name
string memory contractName = getString(keccak256(abi.encodePacked("contract.name", _contractAddress)));
// Check it
require(keccak256(abi.encodePacked(contractName)) != keccak256(abi.encodePacked("")), "Contract not found");
require(bytes(contractName).length > 0, "Contract not found");
// Return
return contractName;
}

/// @dev Get revert error message from a .call method
function getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return "Transaction reverted silently";
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}



/*** Rocket Storage Methods ****************************************/

// Note: Unused helpers have been removed to keep contract sizes down

/// @dev Storage get methods
function getAddress(bytes32 _key) internal view returns (address) { return rocketStorage.getAddress(_key); }
Expand All @@ -135,13 +137,6 @@ abstract contract RocketBase {
function getBool(bytes32 _key) internal view returns (bool) { return rocketStorage.getBool(_key); }
function getInt(bytes32 _key) internal view returns (int) { return rocketStorage.getInt(_key); }
function getBytes32(bytes32 _key) internal view returns (bytes32) { return rocketStorage.getBytes32(_key); }
function getAddressS(string memory _key) internal view returns (address) { return rocketStorage.getAddress(keccak256(abi.encodePacked(_key))); }
function getUintS(string memory _key) internal view returns (uint) { return rocketStorage.getUint(keccak256(abi.encodePacked(_key))); }
function getStringS(string memory _key) internal view returns (string memory) { return rocketStorage.getString(keccak256(abi.encodePacked(_key))); }
function getBytesS(string memory _key) internal view returns (bytes memory) { return rocketStorage.getBytes(keccak256(abi.encodePacked(_key))); }
function getBoolS(string memory _key) internal view returns (bool) { return rocketStorage.getBool(keccak256(abi.encodePacked(_key))); }
function getIntS(string memory _key) internal view returns (int) { return rocketStorage.getInt(keccak256(abi.encodePacked(_key))); }
function getBytes32S(string memory _key) internal view returns (bytes32) { return rocketStorage.getBytes32(keccak256(abi.encodePacked(_key))); }

/// @dev Storage set methods
function setAddress(bytes32 _key, address _value) internal { rocketStorage.setAddress(_key, _value); }
Expand All @@ -151,13 +146,6 @@ abstract contract RocketBase {
function setBool(bytes32 _key, bool _value) internal { rocketStorage.setBool(_key, _value); }
function setInt(bytes32 _key, int _value) internal { rocketStorage.setInt(_key, _value); }
function setBytes32(bytes32 _key, bytes32 _value) internal { rocketStorage.setBytes32(_key, _value); }
function setAddressS(string memory _key, address _value) internal { rocketStorage.setAddress(keccak256(abi.encodePacked(_key)), _value); }
function setUintS(string memory _key, uint _value) internal { rocketStorage.setUint(keccak256(abi.encodePacked(_key)), _value); }
function setStringS(string memory _key, string memory _value) internal { rocketStorage.setString(keccak256(abi.encodePacked(_key)), _value); }
function setBytesS(string memory _key, bytes memory _value) internal { rocketStorage.setBytes(keccak256(abi.encodePacked(_key)), _value); }
function setBoolS(string memory _key, bool _value) internal { rocketStorage.setBool(keccak256(abi.encodePacked(_key)), _value); }
function setIntS(string memory _key, int _value) internal { rocketStorage.setInt(keccak256(abi.encodePacked(_key)), _value); }
function setBytes32S(string memory _key, bytes32 _value) internal { rocketStorage.setBytes32(keccak256(abi.encodePacked(_key)), _value); }

/// @dev Storage delete methods
function deleteAddress(bytes32 _key) internal { rocketStorage.deleteAddress(_key); }
Expand All @@ -167,21 +155,8 @@ abstract contract RocketBase {
function deleteBool(bytes32 _key) internal { rocketStorage.deleteBool(_key); }
function deleteInt(bytes32 _key) internal { rocketStorage.deleteInt(_key); }
function deleteBytes32(bytes32 _key) internal { rocketStorage.deleteBytes32(_key); }
function deleteAddressS(string memory _key) internal { rocketStorage.deleteAddress(keccak256(abi.encodePacked(_key))); }
function deleteUintS(string memory _key) internal { rocketStorage.deleteUint(keccak256(abi.encodePacked(_key))); }
function deleteStringS(string memory _key) internal { rocketStorage.deleteString(keccak256(abi.encodePacked(_key))); }
function deleteBytesS(string memory _key) internal { rocketStorage.deleteBytes(keccak256(abi.encodePacked(_key))); }
function deleteBoolS(string memory _key) internal { rocketStorage.deleteBool(keccak256(abi.encodePacked(_key))); }
function deleteIntS(string memory _key) internal { rocketStorage.deleteInt(keccak256(abi.encodePacked(_key))); }
function deleteBytes32S(string memory _key) internal { rocketStorage.deleteBytes32(keccak256(abi.encodePacked(_key))); }


/**
* @dev Check if an address has this role
*/
function roleHas(string memory _role, address _address) internal view returns (bool) {
return getBool(keccak256(abi.encodePacked("access.role", _role, _address)));
}


/// @dev Storage arithmetic methods
function addUint(bytes32 _key, uint256 _amount) internal { rocketStorage.addUint(_key, _amount); }
function subUint(bytes32 _key, uint256 _amount) internal { rocketStorage.subUint(_key, _amount); }
}
75 changes: 0 additions & 75 deletions contracts/contract/RocketRole.sol

This file was deleted.

Loading

0 comments on commit 07b212e

Please sign in to comment.