Skip to content

Commit

Permalink
Replace X with UINT256_MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
kronosapiens committed Jun 2, 2020
1 parent 39ea08d commit 4569fb5
Show file tree
Hide file tree
Showing 25 changed files with 423 additions and 355 deletions.
8 changes: 4 additions & 4 deletions contracts/colonyNetwork/ColonyNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ contract ColonyNetwork is ColonyNetworkStorage {
IColony colony = IColony(_colonyAddress);
colony.setRecoveryRole(msg.sender);
colony.setRootRole(msg.sender, true);
colony.setArbitrationRole(1, 0, msg.sender, 1, true);
colony.setArchitectureRole(1, 0, msg.sender, 1, true);
colony.setFundingRole(1, 0, msg.sender, 1, true);
colony.setAdministrationRole(1, 0, msg.sender, 1, true);
colony.setArbitrationRole(1, UINT256_MAX, msg.sender, 1, true);
colony.setArchitectureRole(1, UINT256_MAX, msg.sender, 1, true);
colony.setFundingRole(1, UINT256_MAX, msg.sender, 1, true);
colony.setAdministrationRole(1, UINT256_MAX, msg.sender, 1, true);

// Colony will not have owner
DSAuth dsauth = DSAuth(_colonyAddress);
Expand Down
6 changes: 3 additions & 3 deletions contracts/extensions/FundingQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ contract FundingQueue is DSMath, PatriciaTreeProofs {
uint256 toSkillId = colony.getDomain(toDomain).skillId;

require(
domainSkillId == fromSkillId ||
(domainSkillId == fromSkillId && _fromChildSkillIndex == UINT256_MAX) ||
fromSkillId == colonyNetwork.getChildSkillId(domainSkillId, _fromChildSkillIndex),
"funding-queue-bad-inheritence-from"
);
require(
domainSkillId == toSkillId ||
(domainSkillId == toSkillId && _toChildSkillIndex == UINT256_MAX) ||
toSkillId == colonyNetwork.getChildSkillId(domainSkillId, _toChildSkillIndex),
"funding-queue-bad-inheritence-to"
);
Expand Down Expand Up @@ -269,8 +269,8 @@ contract FundingQueue is DSMath, PatriciaTreeProofs {

colony.moveFundsBetweenPots(
proposal.domainId,
proposal.toChildSkillIndex,
proposal.fromChildSkillIndex,
proposal.toChildSkillIndex,
proposal.fromPot,
proposal.toPot,
actualFundingToTransfer,
Expand Down
4 changes: 3 additions & 1 deletion contracts/extensions/OneTxPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import "./../colonyNetwork/IColonyNetwork.sol";


contract OneTxPayment {

uint256 constant UINT256_MAX = 2**256 - 1;
bytes4 constant ADD_PAYMENT_SIG = bytes4(keccak256("addPayment(uint256,uint256,address,address,uint256,uint256,uint256)"));
bytes4 constant MOVE_FUNDS_SIG = bytes4(keccak256("moveFundsBetweenPots(uint256,uint256,uint256,uint256,uint256,uint256,address)"));

Expand Down Expand Up @@ -113,7 +115,7 @@ contract OneTxPayment {
// Fund the payment
colony.moveFundsBetweenPots(
1, // Root domain always 1
0, // Not used, this extension must have funding permission in the root for this function to work
UINT256_MAX, // Not used, this extension must have funding permission in the root for this function to work
_childSkillIndex,
1, // Root domain funding pot is always 1
paymentData[2],
Expand Down
2 changes: 0 additions & 2 deletions helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { soliditySha3 } from "web3-utils";
import { BN } from "bn.js";
import shortid from "shortid";

const X = new BN(0).notn(256); // Shorthand for UINT256_MAX for domain proofs
const UINT256_MAX = new BN(0).notn(256);
const UINT128_MAX = new BN(0).notn(128);
const INT256_MAX = new BN(0).notn(255);
Expand Down Expand Up @@ -66,7 +65,6 @@ const DECAY_RATE = {
const GLOBAL_SKILL_ID = new BN("3"); // Not a root global skill ID or anything, just the first global skill's ID

module.exports = {
X,
UINT256_MAX,
INT256_MAX,
INT128_MAX,
Expand Down
6 changes: 3 additions & 3 deletions helpers/test-data-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BN from "bn.js";
import { ethers } from "ethers";

import {
X,
UINT256_MAX,
MANAGER_PAYOUT,
EVALUATOR_PAYOUT,
WORKER_PAYOUT,
Expand Down Expand Up @@ -153,8 +153,8 @@ export async function setupFundedTask({
const totalPayouts = managerPayoutBN.add(workerPayoutBN).add(evaluatorPayoutBN);

const childSkillIndex = await getChildSkillIndex(colonyNetwork, colony, 1, task.domainId);
await colony.setFundingRole(1, X, manager, 1, true);
await colony.moveFundsBetweenPots(1, X, childSkillIndex, 1, task.fundingPotId, totalPayouts, tokenAddress, { from: manager });
await colony.setFundingRole(1, UINT256_MAX, manager, 1, true);
await colony.moveFundsBetweenPots(1, UINT256_MAX, childSkillIndex, 1, task.fundingPotId, totalPayouts, tokenAddress, { from: manager });
await colony.setAllTaskPayouts(taskId, tokenAddress, managerPayout, evaluatorPayout, workerPayout, { from: manager });
await assignRoles({ colony, taskId, manager, evaluator, worker });

Expand Down
22 changes: 11 additions & 11 deletions test-gas-costs/gasCosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "path";
import { TruffleLoader } from "@colony/colony-js-contract-loader-fs";

import {
X,
UINT256_MAX,
WAD,
MANAGER_ROLE,
WORKER_ROLE,
Expand Down Expand Up @@ -108,7 +108,7 @@ contract("All", function (accounts) {
it("when working with a Colony", async function () {
await colony.mintTokens(200);
await colony.claimColonyFunds(token.address);
await colony.setAdministrationRole(1, X, EVALUATOR, 1, true);
await colony.setAdministrationRole(1, UINT256_MAX, EVALUATOR, 1, true);
});

it("when working with a Task", async function () {
Expand Down Expand Up @@ -148,7 +148,7 @@ contract("All", function (accounts) {
});

// moveFundsBetweenPots
await colony.moveFundsBetweenPots(1, X, X, 1, 2, 190, token.address);
await colony.moveFundsBetweenPots(1, UINT256_MAX, UINT256_MAX, 1, 2, 190, token.address);

// setTaskManagerPayout
await executeSignedTaskChange({
Expand Down Expand Up @@ -206,20 +206,20 @@ contract("All", function (accounts) {

it("when working with a Payment", async function () {
// 4 transactions payment
await colony.addPayment(1, X, WORKER, token.address, WAD, 1, 0);
await colony.addPayment(1, UINT256_MAX, WORKER, token.address, WAD, 1, 0);
const paymentId = await colony.getPaymentCount();
const payment = await colony.getPayment(paymentId);

await colony.moveFundsBetweenPots(1, X, X, 1, payment.fundingPotId, WAD.add(WAD.divn(10)), token.address);
await colony.finalizePayment(1, X, paymentId);
await colony.moveFundsBetweenPots(1, UINT256_MAX, UINT256_MAX, 1, payment.fundingPotId, WAD.add(WAD.divn(10)), token.address);
await colony.finalizePayment(1, UINT256_MAX, paymentId);
await colony.claimPayment(paymentId, token.address);

// 1 transaction payment
const oneTxExtension = await OneTxPayment.new(colony.address);
await colony.setAdministrationRole(1, X, oneTxExtension.address, 1, true);
await colony.setFundingRole(1, X, oneTxExtension.address, 1, true);
await colony.setAdministrationRole(1, UINT256_MAX, oneTxExtension.address, 1, true);
await colony.setFundingRole(1, UINT256_MAX, oneTxExtension.address, 1, true);

await oneTxExtension.makePayment(1, X, 1, X, [WORKER], [token.address], [10], 1, GLOBAL_SKILL_ID);
await oneTxExtension.makePayment(1, UINT256_MAX, 1, UINT256_MAX, [WORKER], [token.address], [10], 1, GLOBAL_SKILL_ID);
});

it("when working with staking", async function () {
Expand Down Expand Up @@ -314,7 +314,7 @@ contract("All", function (accounts) {

await fundColonyWithTokens(newColony, otherToken, 300);

await newColony.moveFundsBetweenPots(1, 0, 0, 1, 0, 100, otherToken.address);
await newColony.moveFundsBetweenPots(1, UINT256_MAX, UINT256_MAX, 1, 0, 100, otherToken.address);

const tx = await newColony.startNextRewardPayout(otherToken.address, ...colonyWideReputationProof);
const payoutId = tx.logs[0].args.rewardPayoutId;
Expand Down Expand Up @@ -348,7 +348,7 @@ contract("All", function (accounts) {
await forwardTime(5184001);
await newColony.finalizeRewardPayout(payoutId);

await newColony.moveFundsBetweenPots(1, 0, 0, 1, 0, 100, otherToken.address);
await newColony.moveFundsBetweenPots(1, UINT256_MAX, UINT256_MAX, 1, 0, 100, otherToken.address);

const tx2 = await newColony.startNextRewardPayout(otherToken.address, ...colonyWideReputationProof);
const payoutId2 = tx2.logs[0].args.rewardPayoutId;
Expand Down
Loading

0 comments on commit 4569fb5

Please sign in to comment.