Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions contracts/facets/IexecPoco1Facet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ contract IexecPoco1Facet is IexecPoco1, IexecPoco1Errors, FacetBase, IexecEscrow
if (!_isAccountAuthorizedByRestriction(datasetOrder.requesterrestrict, deal.requester)) {
revert IncompatibleDatasetOrder("Requester restriction not satisfied");
}
// TODO check inclusion not strict equality.
// The deal's tag should fulfill all the tag bits of the dataset order.
// The deal's tag should include all tag bits of the dataset order.
// Deal: 0b0101, Dataset: 0b0101 => ok
// Deal: 0b0101, Dataset: 0b0001 => ok
// Deal: 0b0101, Dataset: 0b0010 => !ok
if ((deal.tag & datasetOrder.tag) != datasetOrder.tag) {
revert IncompatibleDatasetOrder("Tag compatibility not satisfied");
}
Expand Down Expand Up @@ -211,7 +213,6 @@ contract IexecPoco1Facet is IexecPoco1, IexecPoco1Errors, FacetBase, IexecEscrow
*/

// computation environment & allowed enough funds
bytes32 tag = _apporder.tag | _datasetorder.tag | _requestorder.tag;
require(_requestorder.category == _workerpoolorder.category, "iExecV5-matchOrders-0x00");
require(_requestorder.category < $.m_categories.length, "iExecV5-matchOrders-0x01");
require(_requestorder.trust <= _workerpoolorder.trust, "iExecV5-matchOrders-0x02");
Expand All @@ -224,6 +225,8 @@ contract IexecPoco1Facet is IexecPoco1, IexecPoco1Errors, FacetBase, IexecEscrow
_requestorder.workerpoolmaxprice >= _workerpoolorder.workerpoolprice,
"iExecV5-matchOrders-0x05"
);
// The workerpool tag should include all tag bits of dataset, app, and requester orders.
bytes32 tag = _apporder.tag | _datasetorder.tag | _requestorder.tag;
require(tag & ~_workerpoolorder.tag == 0x0, "iExecV5-matchOrders-0x06");
require((tag ^ _apporder.tag)[31] & 0x01 == 0x0, "iExecV5-matchOrders-0x07");

Expand Down
22 changes: 11 additions & 11 deletions test/000_fullchain-boost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
WorkerpoolInterface__factory,
} from '../typechain';
import * as constants from '../utils/constants';
import { TAG_TEE } from '../utils/constants';
import {
OrdersActors,
OrdersAssets,
Expand All @@ -39,7 +40,6 @@ import { IexecWrapper } from './utils/IexecWrapper';
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
import { randomAddress } from './utils/utils';

const teeDealTag = '0x0000000000000000000000000000000000000000000000000000000000000001';
const taskIndex = 0n;
const volume = taskIndex + 1n;
const { results, resultDigest } = buildUtf8ResultAndDigest('result');
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
assets: ordersAssets,
requester: requester.address,
beneficiary: beneficiary.address,
tag: teeDealTag,
tag: TAG_TEE,
prices: ordersPrices,
callback: callbackAddress,
});
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
appAddress,
datasetAddress,
requestOrder.category,
teeDealTag,
TAG_TEE,
requestOrder.params,
beneficiary.address,
)
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
assets: ordersAssets,
requester: requester.address,
beneficiary: beneficiary.address,
tag: teeDealTag,
tag: TAG_TEE,
}).toObject();
await iexecOrderManagementInstance.connect(appProvider).manageAppOrder({
order: appOrder,
Expand Down Expand Up @@ -273,7 +273,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
appAddress,
datasetAddress,
requestOrder.category,
teeDealTag,
TAG_TEE,
requestOrder.params,
beneficiary.address,
)
Expand All @@ -294,7 +294,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
assets: ordersAssets,
requester: requester.address,
beneficiary: beneficiary.address,
tag: teeDealTag,
tag: TAG_TEE,
prices: ordersPrices,
callback: callbackAddress,
});
Expand Down Expand Up @@ -337,7 +337,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
appAddress,
datasetAddress,
requestOrder.category,
teeDealTag,
TAG_TEE,
requestOrder.params,
beneficiary.address,
)
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
});
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
const oracleConsumerInstance = await new TestClient__factory()
Expand Down Expand Up @@ -455,7 +455,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
prices: ordersPrices,
volume: volume,
});
Expand Down Expand Up @@ -615,7 +615,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
prices: ordersPrices,
volume: expectedVolume,
});
Expand Down Expand Up @@ -697,7 +697,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
prices: ordersPrices,
volume: expectedVolume,
});
Expand Down
17 changes: 8 additions & 9 deletions test/000_fullchain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { IexecWrapper } from './utils/IexecWrapper';
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
import { randomAddress } from './utils/utils';
import { TAG_STANDARD, TAG_TEE } from '../utils/constants';

// +---------+-------------+-------------+-------------+----------+-----+---------------------------------------------+
// | | Sponsorship | Replication | Beneficiary | Callback | BoT | Type |
Expand All @@ -29,8 +30,6 @@ import { randomAddress } from './utils/utils';
// | [7] | x | ✔ | x | x | x | Standard, 4 good workers 1 bad worker |
// +---------+-------------+-------------+-------------+----------+-----+---------------------------------------------+

const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
const teeDealTag = '0x0000000000000000000000000000000000000000000000000000000000000001';
const appPrice = 1000n;
const datasetPrice = 1_000_000n;
const workerpoolPrice = 1_000_000_000n;
Expand Down Expand Up @@ -113,7 +112,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
beneficiary: beneficiary.address,
callback: callbackAddress,
volume,
Expand Down Expand Up @@ -204,7 +203,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
beneficiary: beneficiary.address,
callback: callbackAddress,
volume,
Expand Down Expand Up @@ -292,7 +291,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
beneficiary: beneficiary.address,
callback: callbackAddress,
volume,
Expand Down Expand Up @@ -370,7 +369,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
beneficiary: beneficiary.address,
callback: callbackAddress,
volume,
Expand Down Expand Up @@ -448,7 +447,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
volume,
trust: 1n,
});
Expand Down Expand Up @@ -520,7 +519,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
volume,
trust: BigInt(workerNumber ** 2 - 1),
});
Expand Down Expand Up @@ -622,7 +621,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
volume,
trust: BigInt(winningWorkers.length),
});
Expand Down
4 changes: 2 additions & 2 deletions test/200_fullchain-bot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { OrdersActors, OrdersAssets, OrdersPrices, buildOrders } from '../utils/
import { TaskStatusEnum, buildUtf8ResultAndDigest, getIexecAccounts } from '../utils/poco-tools';
import { IexecWrapper } from './utils/IexecWrapper';
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
import { TAG_STANDARD } from '../utils/constants';

const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
const appPrice = 1000n;
const datasetPrice = 1_000_000n;
const workerpoolPrice = 1_000_000_000n;
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
volume,
trust: 4n,
});
Expand Down
4 changes: 2 additions & 2 deletions test/201_fullchain-multi-orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
import { maxBigInt, minBigInt } from '../utils/tools';
import { IexecWrapper } from './utils/IexecWrapper';
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
import { TAG_STANDARD } from '../utils/constants';

const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
const appPrice = 1000n;
const datasetPrice = 1_000_000n;
const workerpoolPrice1 = 1_000_000_015n;
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
volume,
}).toObject();
// Create 2 different orders for the same workerpool.
Expand Down
4 changes: 2 additions & 2 deletions test/300_fullchain-reopen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
getIexecAccounts,
} from '../utils/poco-tools';
import { IexecWrapper } from './utils/IexecWrapper';
import { TAG_STANDARD } from '../utils/constants';

const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
const appPrice = 1000n;
const datasetPrice = 1_000_000n;
const workerpoolPrice = 1_000_000_000n;
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('Integration tests', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
volume,
trust: 4n,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
} from '../../../utils/poco-tools';
import { IexecWrapper } from '../../utils/IexecWrapper';
import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deployer';
import { TAG_STANDARD } from '../../../utils/constants';

const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
const volume = 1n;
const trust = 1n;
const categoryId = 1;
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('IexecAccessorsABILegacy', function () {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: standardDealTag,
tag: TAG_STANDARD,
beneficiary: beneficiary.address,
callback: callbackAddress,
volume,
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('IexecAccessorsABILegacy', function () {
const dealPart2 = await iexecPocoABILegacy.viewDealABILegacy_pt2(dealId);
expect(dealPart2.length).to.equal(6);
expect(dealPart2[0]).to.equal(trust);
expect(dealPart2[1]).to.equal(standardDealTag);
expect(dealPart2[1]).to.equal(TAG_STANDARD);
expect(dealPart2[2]).to.equal(requester.address);
expect(dealPart2[3]).to.equal(beneficiary.address);
expect(dealPart2[4]).to.equal(callbackAddress);
Expand Down
21 changes: 10 additions & 11 deletions test/byContract/IexecPoco/IexecPoco1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import { compactSignature } from '../../../utils/tools';
import { IexecWrapper } from '../../utils/IexecWrapper';
import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deployer';
import { TAG_STANDARD, TAG_TEE } from '../../../utils/constants';

/*
* TODO add Standard tests.
Expand All @@ -44,8 +45,6 @@ import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deploy
const appPrice = 1000n;
const datasetPrice = 1_000_000n;
const workerpoolPrice = 1_000_000_000n;
const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
const teeDealTag = '0x0000000000000000000000000000000000000000000000000000000000000001';
const volume = 1n;
const botVolume = 321n;
const someMessage = 'some-message';
Expand Down Expand Up @@ -129,7 +128,7 @@ describe('IexecPoco1', () => {
assets: ordersAssets,
prices: ordersPrices,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
volume: volume,
});
const randomWallet = ethers.Wallet.createRandom();
Expand Down Expand Up @@ -354,7 +353,7 @@ describe('IexecPoco1', () => {
prices: ordersPrices,
requester: requester.address,
beneficiary: beneficiary.address,
tag: teeDealTag,
tag: TAG_TEE,
volume: botVolume,
callback: randomAddress,
trust: trust,
Expand Down Expand Up @@ -435,7 +434,7 @@ describe('IexecPoco1', () => {
expect(deal.workerpool.price).to.equal(workerpoolPrice);
expect(deal.trust).to.equal(trust);
expect(deal.category).to.equal(category);
expect(deal.tag).to.equal(teeDealTag);
expect(deal.tag).to.equal(TAG_TEE);
expect(deal.requester).to.equal(requester.address);
expect(deal.beneficiary).to.equal(beneficiary.address);
expect(deal.callback).to.equal(randomAddress);
Expand All @@ -458,7 +457,7 @@ describe('IexecPoco1', () => {
prices: ordersPrices,
requester: requester.address,
beneficiary: beneficiary.address,
tag: standardDealTag,
tag: TAG_STANDARD,
volume: botVolume,
callback: randomAddress,
trust: trust,
Expand Down Expand Up @@ -487,7 +486,7 @@ describe('IexecPoco1', () => {
expect(deal.workerpool.price).to.equal(workerpoolPrice);
expect(deal.trust).to.equal(trust);
expect(deal.category).to.equal(category);
expect(deal.tag).to.equal(standardDealTag);
expect(deal.tag).to.equal(TAG_STANDARD);
expect(deal.requester).to.equal(requester.address);
expect(deal.beneficiary).to.equal(beneficiary.address);
expect(deal.callback).to.equal(randomAddress);
Expand Down Expand Up @@ -1081,7 +1080,7 @@ describe('IexecPoco1', () => {
assets: { ...ordersAssets, dataset: ZeroAddress },
prices: ordersPrices,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
volume: volume,
});
await depositForRequesterAndSchedulerWithDefaultPrices(volume);
Expand All @@ -1097,7 +1096,7 @@ describe('IexecPoco1', () => {
dataset: datasetAddress,
datasetprice: datasetPrice,
volume: volume,
tag: teeDealTag,
tag: TAG_TEE,
apprestrict: ordersWithoutDataset.app.app,
workerpoolrestrict: ordersWithoutDataset.workerpool.workerpool,
requesterrestrict: ordersWithoutDataset.requester.requester,
Expand Down Expand Up @@ -1170,7 +1169,7 @@ describe('IexecPoco1', () => {
assets: ordersAssets, // This includes the dataset
prices: ordersPrices,
requester: requester.address,
tag: teeDealTag,
tag: TAG_TEE,
volume: volume,
});

Expand Down Expand Up @@ -1258,7 +1257,7 @@ describe('IexecPoco1', () => {
// Create dataset order with incompatible tag
const incompatibleTagDatasetOrder = {
...compatibleDatasetOrder,
tag: '0x0000000000000000000000000000000000000000000000000000000000000002', // Different tag
tag: '0x0000000000000000000000000000000000000000000000000000000000000010', // Different tag
};
await signOrder(iexecWrapper.getDomain(), incompatibleTagDatasetOrder, datasetProvider);
await expect(
Expand Down
Loading