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

Remove deprecated functions #1193

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"storage": []
}
74 changes: 30 additions & 44 deletions contracts/colony/ColonyArbitraryTransaction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,9 @@ contract ColonyArbitraryTransaction is ColonyStorage {

function makeArbitraryTransaction(
address _to,
bytes memory _action
) public stoppable auth returns (bool) {
return this.makeSingleArbitraryTransaction(_to, _action);
}

function makeArbitraryTransactions(
address[] memory _targets,
bytes[] memory _actions,
bytes memory _action,
bool _strict
) public stoppable auth returns (bool) {
require(_targets.length == _actions.length, "colony-targets-and-actions-length-mismatch");
for (uint256 i; i < _targets.length; i += 1) {
bool success = true;
// slither-disable-next-line unused-return
try this.makeSingleArbitraryTransaction(_targets[i], _actions[i]) returns (bool ret) {
if (_strict) {
success = ret;
}
} catch {
// We failed in a require, which is only okay if we're not in strict mode
if (_strict) {
success = false;
}
}
require(success, "colony-arbitrary-transaction-failed");
}
return true;
}

function makeSingleArbitraryTransaction(
address _to,
bytes memory _action
) external stoppable self returns (bool) {
// Prevent transactions to network contracts
require(_to != address(this), "colony-cannot-target-self");
require(_to != colonyNetworkAddress, "colony-cannot-target-network");
Expand Down Expand Up @@ -102,30 +72,50 @@ contract ColonyArbitraryTransaction is ColonyStorage {
} catch {}

bool res = executeCall(_to, 0, _action);

assert(res);
if (sig == APPROVE_SIG) {
approveTransactionCleanup(_to, _action);
approveTransactionCheck(_to, _action);
}

emit ArbitraryTransaction(_to, _action, res);

require(res || !_strict, "colony-arbitrary-transaction-failed");

return res;
}

function approveTransactionPreparation(address _to, bytes memory _action) internal {
function approveTransactionPreparation(address _token, bytes memory _action) internal {
address spender;
uint256 amount;
assembly {
spender := mload(add(_action, 0x24))
amount := mload(add(_action, 0x44))
}
updateApprovalAmountInternal(_to, spender, false);
updateApprovalAmountInternal(_token, spender);

// Calculate and set the approval we expect to have after the approve is made
tokenApprovalTotals[_token] =
(tokenApprovalTotals[_token] - tokenApprovals[_token][spender]) +
amount;
require(
fundingPots[1].balance[_token] >= tokenApprovalTotals[_token],
"colony-approval-exceeds-balance"
);

tokenApprovals[_token][spender] = amount;
}

function approveTransactionCleanup(address _to, bytes memory _action) internal {
function approveTransactionCheck(address _token, bytes memory _action) internal view {
address spender;
uint256 amount;
assembly {
spender := mload(add(_action, 0x24))
amount := mload(add(_action, 0x44))
}
updateApprovalAmountInternal(_to, spender, true);

uint256 recordedApproval = tokenApprovals[_token][spender];
uint256 actualApproval = ERC20Extended(_token).allowance(address(this), spender);
require(recordedApproval == actualApproval, "colony-approval-amount-mismatch");
}

function burnTransactionPreparation(address _to, bytes memory _action) internal {
Expand Down Expand Up @@ -155,21 +145,17 @@ contract ColonyArbitraryTransaction is ColonyStorage {
}

function updateApprovalAmount(address _token, address _spender) public stoppable {
updateApprovalAmountInternal(_token, _spender, false);
updateApprovalAmountInternal(_token, _spender);
}

function updateApprovalAmountInternal(
address _token,
address _spender,
bool _postApproval
) internal {
function updateApprovalAmountInternal(address _token, address _spender) internal {
uint256 recordedApproval = tokenApprovals[_token][_spender];
uint256 actualApproval = ERC20Extended(_token).allowance(address(this), _spender);
if (recordedApproval == actualApproval) {
return;
}

if (recordedApproval > actualApproval && !_postApproval) {
if (recordedApproval > actualApproval) {
// They've spend some tokens out of root. Adjust balances accordingly
// If we are post approval, then they have not spent tokens
fundingPots[1].balance[_token] =
Expand Down
15 changes: 9 additions & 6 deletions contracts/colony/ColonyAuthority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ contract ColonyAuthority is CommonAuthority {
addRoleCapability(ADMINISTRATION_ROLE, "finalizePayment(uint256,uint256,uint256)"); // Only for versions < 14

// Add permissions for the Funding role
addRoleCapability(FUNDING_ROLE, "moveFundsBetweenPots(uint256,uint256,uint256,uint256,uint256,uint256,address)");
addRoleCapability(FUNDING_ROLE, "moveFundsBetweenPots(uint256,uint256,uint256,uint256,uint256,uint256,address)"); // Deprecated

// Add permissions for the Architecture role
addRoleCapability(ARCHITECTURE_ROLE, "addDomain(uint256,uint256,uint256)");
Expand Down Expand Up @@ -84,9 +84,9 @@ contract ColonyAuthority is CommonAuthority {

// Added in colony v4 (burgundy-glider)
addRoleCapability(ADMINISTRATION_ROLE, "makeExpenditure(uint256,uint256,uint256)");
addRoleCapability(ARBITRATION_ROLE, "transferExpenditureViaArbitration(uint256,uint256,uint256,address)");
addRoleCapability(ARBITRATION_ROLE, "setExpenditurePayoutModifier(uint256,uint256,uint256,uint256,int256)");
addRoleCapability(ARBITRATION_ROLE, "setExpenditureClaimDelay(uint256,uint256,uint256,uint256,uint256)");
addRoleCapability(ARBITRATION_ROLE, "transferExpenditureViaArbitration(uint256,uint256,uint256,address)"); // Deprecated
addRoleCapability(ARBITRATION_ROLE, "setExpenditurePayoutModifier(uint256,uint256,uint256,uint256,int256)"); // Deprecated
addRoleCapability(ARBITRATION_ROLE, "setExpenditureClaimDelay(uint256,uint256,uint256,uint256,uint256)"); // Deprecated

// Added in colony v5 (cerulean-lwss)
addRoleCapability(ROOT_ROLE, "setPayoutWhitelist(address,bool)");
Expand All @@ -98,7 +98,7 @@ contract ColonyAuthority is CommonAuthority {
addRoleCapability(ROOT_ROLE, "upgradeExtension(bytes32,uint256)");
addRoleCapability(ROOT_ROLE, "deprecateExtension(bytes32,bool)");
addRoleCapability(ROOT_ROLE, "uninstallExtension(bytes32)");
addRoleCapability(ROOT_ROLE, "makeArbitraryTransaction(address,bytes)");
addRoleCapability(ROOT_ROLE, "makeArbitraryTransaction(address,bytes)"); // Deprecated
addRoleCapability(ROOT_ROLE, "emitDomainReputationReward(uint256,address,int256)");
addRoleCapability(ROOT_ROLE, "emitSkillReputationReward(uint256,address,int256)");
addRoleCapability(ARBITRATION_ROLE, "transferStake(uint256,uint256,address,address,uint256,uint256,address)");
Expand All @@ -116,7 +116,7 @@ contract ColonyAuthority is CommonAuthority {
addRoleCapability(FUNDING_ROLE, "moveFundsBetweenPots(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,address)");

// Added in colony v8 (ebony-lwss)
addRoleCapability(ROOT_ROLE, "makeArbitraryTransactions(address[],bytes[],bool)");
addRoleCapability(ROOT_ROLE, "makeArbitraryTransactions(address[],bytes[],bool)"); // Deprecated
addRoleCapability(ROOT_ROLE, "setDefaultGlobalClaimDelay(uint256)");
addRoleCapability(ARBITRATION_ROLE, "setExpenditureMetadata(uint256,uint256,uint256,string)");

Expand All @@ -134,6 +134,9 @@ contract ColonyAuthority is CommonAuthority {
addRoleCapability(ARBITRATION_ROLE, "finalizeExpenditureViaArbitration(uint256,uint256,uint256)");
addRoleCapability(ROOT_ROLE, "setColonyBridgeAddress(address)");
addRoleCapability(ROOT_ROLE, "initialiseReputationMining(uint256,bytes32,uint256)");

// Added in colony v17 (jade-lwss)
addRoleCapability(ROOT_ROLE, "makeArbitraryTransaction(address,bytes,bool)");
}

function addRoleCapability(uint8 role, bytes memory sig) private {
Expand Down
52 changes: 0 additions & 52 deletions contracts/colony/ColonyExpenditure.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,6 @@ contract ColonyExpenditure is ColonyStorage {
emit ExpenditureTransferred(msgSender(), _id, _newOwner);
}

// Deprecated
function transferExpenditureViaArbitration(
uint256 _permissionDomainId,
uint256 _childSkillIndex,
uint256 _id,
address _newOwner
)
public
stoppable
expenditureDraftOrLocked(_id)
authDomain(_permissionDomainId, _childSkillIndex, expenditures[_id].domainId)
{
expenditures[_id].owner = _newOwner;

emit ExpenditureTransferred(msgSender(), _id, _newOwner);
}

function cancelExpenditureViaArbitration(
uint256 _permissionDomainId,
uint256 _childSkillIndex,
Expand Down Expand Up @@ -236,41 +219,6 @@ contract ColonyExpenditure is ColonyStorage {
}
}

// Deprecated
function setExpenditureRecipient(
uint256 _id,
uint256 _slot,
address payable _recipient
) public stoppable {
uint256[] memory slots = new uint256[](1);
slots[0] = _slot;
address payable[] memory recipients = new address payable[](1);
recipients[0] = _recipient;
setExpenditureRecipients(_id, slots, recipients);
}

// Deprecated
function setExpenditureSkill(uint256 _id, uint256 _slot, uint256 _skillId) public stoppable {
uint256[] memory slots = new uint256[](1);
slots[0] = _slot;
uint256[] memory skillIds = new uint256[](1);
skillIds[0] = _skillId;
setExpenditureSkills(_id, slots, skillIds);
}

// Deprecated
function setExpenditureClaimDelay(
uint256 _id,
uint256 _slot,
uint256 _claimDelay
) public stoppable {
uint256[] memory slots = new uint256[](1);
slots[0] = _slot;
uint256[] memory claimDelays = new uint256[](1);
claimDelays[0] = _claimDelay;
setExpenditureClaimDelays(_id, slots, claimDelays);
}

uint256 constant EXPENDITURES_SLOT = 25;
uint256 constant EXPENDITURESLOTS_SLOT = 26;

Expand Down
33 changes: 0 additions & 33 deletions contracts/colony/ColonyFunding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,6 @@ contract ColonyFunding is
moveFundsBetweenPotsFunctionality(_fromPot, _toPot, _amount, _token);
}

function moveFundsBetweenPots(
uint256 _permissionDomainId,
uint256 _fromChildSkillIndex,
uint256 _toChildSkillIndex,
uint256 _fromPot,
uint256 _toPot,
uint256 _amount,
address _token
)
public
stoppable
domainNotDeprecated(getDomainFromFundingPot(_toPot))
authDomain(_permissionDomainId, _fromChildSkillIndex, getDomainFromFundingPot(_fromPot))
authDomain(_permissionDomainId, _toChildSkillIndex, getDomainFromFundingPot(_toPot))
validFundingTransfer(_fromPot, _toPot)
{
moveFundsBetweenPotsFunctionality(_fromPot, _toPot, _amount, _token);
}

function claimColonyFunds(address _token) public stoppable {
uint256 toClaim;
uint256 feeToPay;
Expand Down Expand Up @@ -141,20 +122,6 @@ contract ColonyFunding is
setExpenditurePayoutsInternal(_id, slots, _token, amounts);
}

/// @notice For owners to update payouts with one token and one slot
function setExpenditurePayout(
uint256 _id,
uint256 _slot,
address _token,
uint256 _amount
) public stoppable expenditureDraft(_id) expenditureOnlyOwner(_id) {
uint256[] memory slots = new uint256[](1);
slots[0] = _slot;
uint256[] memory amounts = new uint256[](1);
amounts[0] = _amount;
setExpenditurePayoutsInternal(_id, slots, _token, amounts);
}

int256 constant MAX_PAYOUT_MODIFIER = int256(WAD);
int256 constant MIN_PAYOUT_MODIFIER = -int256(WAD);

Expand Down
21 changes: 14 additions & 7 deletions contracts/colony/ColonyStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,20 @@ contract ColonyStorage is ColonyDataTypes, ColonyNetworkDataTypes, DSMath, Commo
uint256 value,
bytes memory data
) internal returns (bool success) {
assembly {
// call contract at address a with input mem[in…(in+insize))
// providing g gas and v wei and output area mem[out…(out+outsize))
// returning 0 on error (eg. out of gas) and 1 on success

// call(g, a, v, in, insize, out, outsize)
success := call(gas(), to, value, add(data, 0x20), mload(data), 0, 0)
bytes memory res;
(success, res) = to.call{ value: value }(data);
if (!success) {
// Stolen shamelessly from
// https://ethereum.stackexchange.com/questions/83528/how-can-i-get-the-revert-reason-of-a-call-in-solidity-so-that-i-can-use-it-in-th
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (res.length >= 68) {
assembly {
// Slice the sighash.
res := add(res, 0x04)
}
require(false, abi.decode(res, (string))); // All that remains is the revert string
}
require(false, "require-execute-call-reverted-with-no-error");
}
}
}
Loading