Skip to content

Commit 0806c70

Browse files
authored
chore: Update deal tag comments (#280)
1 parent f07d661 commit 0806c70

14 files changed

+126
-140
lines changed

contracts/facets/IexecPoco1Facet.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ contract IexecPoco1Facet is IexecPoco1, IexecPoco1Errors, FacetBase, IexecEscrow
118118
if (!_isAccountAuthorizedByRestriction(datasetOrder.requesterrestrict, deal.requester)) {
119119
revert IncompatibleDatasetOrder("Requester restriction not satisfied");
120120
}
121-
// TODO check inclusion not strict equality.
122-
// The deal's tag should fulfill all the tag bits of the dataset order.
121+
// The deal's tag should include all tag bits of the dataset order.
122+
// Deal: 0b0101, Dataset: 0b0101 => ok
123+
// Deal: 0b0101, Dataset: 0b0001 => ok
124+
// Deal: 0b0101, Dataset: 0b0010 => !ok
123125
if ((deal.tag & datasetOrder.tag) != datasetOrder.tag) {
124126
revert IncompatibleDatasetOrder("Tag compatibility not satisfied");
125127
}
@@ -211,7 +213,6 @@ contract IexecPoco1Facet is IexecPoco1, IexecPoco1Errors, FacetBase, IexecEscrow
211213
*/
212214

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

test/000_fullchain-boost.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
WorkerpoolInterface__factory,
1818
} from '../typechain';
1919
import * as constants from '../utils/constants';
20+
import { TAG_TEE } from '../utils/constants';
2021
import {
2122
OrdersActors,
2223
OrdersAssets,
@@ -39,7 +40,6 @@ import { IexecWrapper } from './utils/IexecWrapper';
3940
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
4041
import { randomAddress } from './utils/utils';
4142

42-
const teeDealTag = '0x0000000000000000000000000000000000000000000000000000000000000001';
4343
const taskIndex = 0n;
4444
const volume = taskIndex + 1n;
4545
const { results, resultDigest } = buildUtf8ResultAndDigest('result');
@@ -135,7 +135,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
135135
assets: ordersAssets,
136136
requester: requester.address,
137137
beneficiary: beneficiary.address,
138-
tag: teeDealTag,
138+
tag: TAG_TEE,
139139
prices: ordersPrices,
140140
callback: callbackAddress,
141141
});
@@ -175,7 +175,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
175175
appAddress,
176176
datasetAddress,
177177
requestOrder.category,
178-
teeDealTag,
178+
TAG_TEE,
179179
requestOrder.params,
180180
beneficiary.address,
181181
)
@@ -234,7 +234,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
234234
assets: ordersAssets,
235235
requester: requester.address,
236236
beneficiary: beneficiary.address,
237-
tag: teeDealTag,
237+
tag: TAG_TEE,
238238
}).toObject();
239239
await iexecOrderManagementInstance.connect(appProvider).manageAppOrder({
240240
order: appOrder,
@@ -273,7 +273,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
273273
appAddress,
274274
datasetAddress,
275275
requestOrder.category,
276-
teeDealTag,
276+
TAG_TEE,
277277
requestOrder.params,
278278
beneficiary.address,
279279
)
@@ -294,7 +294,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
294294
assets: ordersAssets,
295295
requester: requester.address,
296296
beneficiary: beneficiary.address,
297-
tag: teeDealTag,
297+
tag: TAG_TEE,
298298
prices: ordersPrices,
299299
callback: callbackAddress,
300300
});
@@ -337,7 +337,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
337337
appAddress,
338338
datasetAddress,
339339
requestOrder.category,
340-
teeDealTag,
340+
TAG_TEE,
341341
requestOrder.params,
342342
beneficiary.address,
343343
)
@@ -398,7 +398,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
398398
const orders = buildOrders({
399399
assets: ordersAssets,
400400
requester: requester.address,
401-
tag: teeDealTag,
401+
tag: TAG_TEE,
402402
});
403403
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
404404
const oracleConsumerInstance = await new TestClient__factory()
@@ -455,7 +455,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
455455
const orders = buildOrders({
456456
assets: ordersAssets,
457457
requester: requester.address,
458-
tag: teeDealTag,
458+
tag: TAG_TEE,
459459
prices: ordersPrices,
460460
volume: volume,
461461
});
@@ -615,7 +615,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
615615
const orders = buildOrders({
616616
assets: ordersAssets,
617617
requester: requester.address,
618-
tag: teeDealTag,
618+
tag: TAG_TEE,
619619
prices: ordersPrices,
620620
volume: expectedVolume,
621621
});
@@ -697,7 +697,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
697697
const orders = buildOrders({
698698
assets: ordersAssets,
699699
requester: requester.address,
700-
tag: teeDealTag,
700+
tag: TAG_TEE,
701701
prices: ordersPrices,
702702
volume: expectedVolume,
703703
});

test/000_fullchain.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { IexecWrapper } from './utils/IexecWrapper';
1717
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
1818
import { randomAddress } from './utils/utils';
19+
import { TAG_STANDARD, TAG_TEE } from '../utils/constants';
1920

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

32-
const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
33-
const teeDealTag = '0x0000000000000000000000000000000000000000000000000000000000000001';
3433
const appPrice = 1000n;
3534
const datasetPrice = 1_000_000n;
3635
const workerpoolPrice = 1_000_000_000n;
@@ -113,7 +112,7 @@ describe('Integration tests', function () {
113112
assets: ordersAssets,
114113
prices: ordersPrices,
115114
requester: requester.address,
116-
tag: standardDealTag,
115+
tag: TAG_STANDARD,
117116
beneficiary: beneficiary.address,
118117
callback: callbackAddress,
119118
volume,
@@ -204,7 +203,7 @@ describe('Integration tests', function () {
204203
assets: ordersAssets,
205204
prices: ordersPrices,
206205
requester: requester.address,
207-
tag: standardDealTag,
206+
tag: TAG_STANDARD,
208207
beneficiary: beneficiary.address,
209208
callback: callbackAddress,
210209
volume,
@@ -292,7 +291,7 @@ describe('Integration tests', function () {
292291
assets: ordersAssets,
293292
prices: ordersPrices,
294293
requester: requester.address,
295-
tag: teeDealTag,
294+
tag: TAG_TEE,
296295
beneficiary: beneficiary.address,
297296
callback: callbackAddress,
298297
volume,
@@ -370,7 +369,7 @@ describe('Integration tests', function () {
370369
assets: ordersAssets,
371370
prices: ordersPrices,
372371
requester: requester.address,
373-
tag: teeDealTag,
372+
tag: TAG_TEE,
374373
beneficiary: beneficiary.address,
375374
callback: callbackAddress,
376375
volume,
@@ -448,7 +447,7 @@ describe('Integration tests', function () {
448447
assets: ordersAssets,
449448
prices: ordersPrices,
450449
requester: requester.address,
451-
tag: teeDealTag,
450+
tag: TAG_TEE,
452451
volume,
453452
trust: 1n,
454453
});
@@ -520,7 +519,7 @@ describe('Integration tests', function () {
520519
assets: ordersAssets,
521520
prices: ordersPrices,
522521
requester: requester.address,
523-
tag: standardDealTag,
522+
tag: TAG_STANDARD,
524523
volume,
525524
trust: BigInt(workerNumber ** 2 - 1),
526525
});
@@ -622,7 +621,7 @@ describe('Integration tests', function () {
622621
assets: ordersAssets,
623622
prices: ordersPrices,
624623
requester: requester.address,
625-
tag: standardDealTag,
624+
tag: TAG_STANDARD,
626625
volume,
627626
trust: BigInt(winningWorkers.length),
628627
});

test/200_fullchain-bot.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { OrdersActors, OrdersAssets, OrdersPrices, buildOrders } from '../utils/
99
import { TaskStatusEnum, buildUtf8ResultAndDigest, getIexecAccounts } from '../utils/poco-tools';
1010
import { IexecWrapper } from './utils/IexecWrapper';
1111
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
12+
import { TAG_STANDARD } from '../utils/constants';
1213

13-
const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
1414
const appPrice = 1000n;
1515
const datasetPrice = 1_000_000n;
1616
const workerpoolPrice = 1_000_000_000n;
@@ -109,7 +109,7 @@ describe('Integration tests', function () {
109109
assets: ordersAssets,
110110
prices: ordersPrices,
111111
requester: requester.address,
112-
tag: standardDealTag,
112+
tag: TAG_STANDARD,
113113
volume,
114114
trust: 4n,
115115
});

test/201_fullchain-multi-orders.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import {
2222
import { maxBigInt, minBigInt } from '../utils/tools';
2323
import { IexecWrapper } from './utils/IexecWrapper';
2424
import { loadHardhatFixtureDeployment } from './utils/hardhat-fixture-deployer';
25+
import { TAG_STANDARD } from '../utils/constants';
2526

26-
const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
2727
const appPrice = 1000n;
2828
const datasetPrice = 1_000_000n;
2929
const workerpoolPrice1 = 1_000_000_015n;
@@ -93,7 +93,7 @@ describe('Integration tests', function () {
9393
assets: ordersAssets,
9494
prices: ordersPrices,
9595
requester: requester.address,
96-
tag: standardDealTag,
96+
tag: TAG_STANDARD,
9797
volume,
9898
}).toObject();
9999
// Create 2 different orders for the same workerpool.

test/300_fullchain-reopen.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {
1818
getIexecAccounts,
1919
} from '../utils/poco-tools';
2020
import { IexecWrapper } from './utils/IexecWrapper';
21+
import { TAG_STANDARD } from '../utils/constants';
2122

22-
const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
2323
const appPrice = 1000n;
2424
const datasetPrice = 1_000_000n;
2525
const workerpoolPrice = 1_000_000_000n;
@@ -112,7 +112,7 @@ describe('Integration tests', function () {
112112
assets: ordersAssets,
113113
prices: ordersPrices,
114114
requester: requester.address,
115-
tag: standardDealTag,
115+
tag: TAG_STANDARD,
116116
volume,
117117
trust: 4n,
118118
});

test/byContract/IexecAccessors/IexecAccessorsABILegacy.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import {
1616
} from '../../../utils/poco-tools';
1717
import { IexecWrapper } from '../../utils/IexecWrapper';
1818
import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deployer';
19+
import { TAG_STANDARD } from '../../../utils/constants';
1920

20-
const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
2121
const volume = 1n;
2222
const trust = 1n;
2323
const categoryId = 1;
@@ -76,7 +76,7 @@ describe('IexecAccessorsABILegacy', function () {
7676
assets: ordersAssets,
7777
prices: ordersPrices,
7878
requester: requester.address,
79-
tag: standardDealTag,
79+
tag: TAG_STANDARD,
8080
beneficiary: beneficiary.address,
8181
callback: callbackAddress,
8282
volume,
@@ -108,7 +108,7 @@ describe('IexecAccessorsABILegacy', function () {
108108
const dealPart2 = await iexecPocoABILegacy.viewDealABILegacy_pt2(dealId);
109109
expect(dealPart2.length).to.equal(6);
110110
expect(dealPart2[0]).to.equal(trust);
111-
expect(dealPart2[1]).to.equal(standardDealTag);
111+
expect(dealPart2[1]).to.equal(TAG_STANDARD);
112112
expect(dealPart2[2]).to.equal(requester.address);
113113
expect(dealPart2[3]).to.equal(beneficiary.address);
114114
expect(dealPart2[4]).to.equal(callbackAddress);

test/byContract/IexecPoco/IexecPoco1.test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
import { compactSignature } from '../../../utils/tools';
3737
import { IexecWrapper } from '../../utils/IexecWrapper';
3838
import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deployer';
39+
import { TAG_STANDARD, TAG_TEE } from '../../../utils/constants';
3940

4041
/*
4142
* TODO add Standard tests.
@@ -44,8 +45,6 @@ import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deploy
4445
const appPrice = 1000n;
4546
const datasetPrice = 1_000_000n;
4647
const workerpoolPrice = 1_000_000_000n;
47-
const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
48-
const teeDealTag = '0x0000000000000000000000000000000000000000000000000000000000000001';
4948
const volume = 1n;
5049
const botVolume = 321n;
5150
const someMessage = 'some-message';
@@ -129,7 +128,7 @@ describe('IexecPoco1', () => {
129128
assets: ordersAssets,
130129
prices: ordersPrices,
131130
requester: requester.address,
132-
tag: teeDealTag,
131+
tag: TAG_TEE,
133132
volume: volume,
134133
});
135134
const randomWallet = ethers.Wallet.createRandom();
@@ -354,7 +353,7 @@ describe('IexecPoco1', () => {
354353
prices: ordersPrices,
355354
requester: requester.address,
356355
beneficiary: beneficiary.address,
357-
tag: teeDealTag,
356+
tag: TAG_TEE,
358357
volume: botVolume,
359358
callback: randomAddress,
360359
trust: trust,
@@ -435,7 +434,7 @@ describe('IexecPoco1', () => {
435434
expect(deal.workerpool.price).to.equal(workerpoolPrice);
436435
expect(deal.trust).to.equal(trust);
437436
expect(deal.category).to.equal(category);
438-
expect(deal.tag).to.equal(teeDealTag);
437+
expect(deal.tag).to.equal(TAG_TEE);
439438
expect(deal.requester).to.equal(requester.address);
440439
expect(deal.beneficiary).to.equal(beneficiary.address);
441440
expect(deal.callback).to.equal(randomAddress);
@@ -458,7 +457,7 @@ describe('IexecPoco1', () => {
458457
prices: ordersPrices,
459458
requester: requester.address,
460459
beneficiary: beneficiary.address,
461-
tag: standardDealTag,
460+
tag: TAG_STANDARD,
462461
volume: botVolume,
463462
callback: randomAddress,
464463
trust: trust,
@@ -487,7 +486,7 @@ describe('IexecPoco1', () => {
487486
expect(deal.workerpool.price).to.equal(workerpoolPrice);
488487
expect(deal.trust).to.equal(trust);
489488
expect(deal.category).to.equal(category);
490-
expect(deal.tag).to.equal(standardDealTag);
489+
expect(deal.tag).to.equal(TAG_STANDARD);
491490
expect(deal.requester).to.equal(requester.address);
492491
expect(deal.beneficiary).to.equal(beneficiary.address);
493492
expect(deal.callback).to.equal(randomAddress);
@@ -1081,7 +1080,7 @@ describe('IexecPoco1', () => {
10811080
assets: { ...ordersAssets, dataset: ZeroAddress },
10821081
prices: ordersPrices,
10831082
requester: requester.address,
1084-
tag: teeDealTag,
1083+
tag: TAG_TEE,
10851084
volume: volume,
10861085
});
10871086
await depositForRequesterAndSchedulerWithDefaultPrices(volume);
@@ -1097,7 +1096,7 @@ describe('IexecPoco1', () => {
10971096
dataset: datasetAddress,
10981097
datasetprice: datasetPrice,
10991098
volume: volume,
1100-
tag: teeDealTag,
1099+
tag: TAG_TEE,
11011100
apprestrict: ordersWithoutDataset.app.app,
11021101
workerpoolrestrict: ordersWithoutDataset.workerpool.workerpool,
11031102
requesterrestrict: ordersWithoutDataset.requester.requester,
@@ -1170,7 +1169,7 @@ describe('IexecPoco1', () => {
11701169
assets: ordersAssets, // This includes the dataset
11711170
prices: ordersPrices,
11721171
requester: requester.address,
1173-
tag: teeDealTag,
1172+
tag: TAG_TEE,
11741173
volume: volume,
11751174
});
11761175

@@ -1258,7 +1257,7 @@ describe('IexecPoco1', () => {
12581257
// Create dataset order with incompatible tag
12591258
const incompatibleTagDatasetOrder = {
12601259
...compatibleDatasetOrder,
1261-
tag: '0x0000000000000000000000000000000000000000000000000000000000000002', // Different tag
1260+
tag: '0x0000000000000000000000000000000000000000000000000000000000000010', // Different tag
12621261
};
12631262
await signOrder(iexecWrapper.getDomain(), incompatibleTagDatasetOrder, datasetProvider);
12641263
await expect(

0 commit comments

Comments
 (0)