Skip to content

Commit c8a3d3f

Browse files
committed
Merge branch 'v1.0.13' of github.com:iExecBlockchainComputing/PoCo into v1.0.13
2 parents 4326c9a + 8cce7ba commit c8a3d3f

19 files changed

+149
-161
lines changed

ChangeLog.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ Features:
1717
* [#21](https://github.com/iExecBlockchainComputing/PoCo/issues/21): remove change ownership in OwnableOZ.sol
1818

1919
Bugfixes:
20-
* [#24](https://github.com/iExecBlockchainComputing/PoCo/issues/24) possibly useless RLC address getter
21-
* [#15](https://github.com/iExecBlockchainComputing/PoCo/issues/15): Malicious IexecAPI contract without callback
22-
* [#15](https://github.com/iExecBlockchainComputing/PoCo/issues/15): [SC AUDIT] Result without Payment. Malicious IexecAPI contract without callback
23-
* [#25](https://github.com/iExecBlockchainComputing/PoCo/issues/25) :[SC AUDIT] Scheduler can manipulate its reward percentage
24-
* [#26](https://github.com/iExecBlockchainComputing/PoCo/issues/26) :[SC AUDIT] Arbitrary Contract are trusted
20+
* [#24](https://github.com/iExecBlockchainComputing/PoCo/issues/24) : possibly useless RLC address getter
21+
* [#15](https://github.com/iExecBlockchainComputing/PoCo/issues/15) :[CS AUDIT] Result without Payment. Malicious IexecAPI contract without callback
22+
* [#25](https://github.com/iExecBlockchainComputing/PoCo/issues/25) :[CS AUDIT] Scheduler can manipulate its reward percentage
23+
* [#26](https://github.com/iExecBlockchainComputing/PoCo/issues/26) :[CS AUDIT] Arbitrary Contract are trusted
24+
* [#27](https://github.com/iExecBlockchainComputing/PoCo/issues/27) :[CS AUDIT] fix consensusTimout, failled typo to consensusTimeout, failed
25+
* [#28](https://github.com/iExecBlockchainComputing/PoCo/issues/28) : Attacker can race to attach invalid hubs.
26+
* [#29](https://github.com/iExecBlockchainComputing/PoCo/issues/29) : [CS AUDIT] Addresses are are duplicates
27+
* [#30](https://github.com/iExecBlockchainComputing/PoCo/issues/30) : IexecHubInterface is not up to date
28+
* [#31](https://github.com/iExecBlockchainComputing/PoCo/issues/31) : OwnableOZ event not correct
29+
* [#32](https://github.com/iExecBlockchainComputing/PoCo/issues/32) : Need more gas
30+
* [#33](https://github.com/iExecBlockchainComputing/PoCo/issues/33) : [CS AUDIT] Both a contract and an event are called WorkOrder.
31+
* [#34](https://github.com/iExecBlockchainComputing/PoCo/issues/34) : [CS AUDIT] the variable names workerReward and workersReward are confusingly similar
2532

2633

2734
### [v1.0.12](https://github.com/iExecBlockchainComputing/PoCo/releases/tag/v1.0.12)

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,15 @@ or
492492

493493

494494
```
495-
coverage : 12/04/2018
495+
coverage : 20/05/2018
496496
497-
180 passing (12m)
497+
184 passing (10m)
498498
1 pending
499499
500500
-----------------------------|----------|----------|----------|----------|----------------|
501501
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
502502
-----------------------------|----------|----------|----------|----------|----------------|
503-
contracts/ | 100 | 75.16 | 100 | 100 | |
503+
contracts/ | 100 | 74.7 | 100 | 100 | |
504504
App.sol | 100 | 50 | 100 | 100 | |
505505
AppHub.sol | 100 | 100 | 100 | 100 | |
506506
Dataset.sol | 100 | 50 | 100 | 100 | |
@@ -511,17 +511,17 @@ IexecHub.sol | 100 | 70.54 | 100 | 100 |
511511
IexecHubAccessor.sol | 100 | 75 | 100 | 100 | |
512512
IexecHubInterface.sol | 100 | 100 | 100 | 100 | |
513513
IexecLib.sol | 100 | 100 | 100 | 100 | |
514-
Marketplace.sol | 100 | 88.89 | 100 | 100 | |
514+
Marketplace.sol | 100 | 83.33 | 100 | 100 | |
515515
MarketplaceAccessor.sol | 100 | 50 | 100 | 100 | |
516516
MarketplaceInterface.sol | 100 | 100 | 100 | 100 | |
517-
OwnableOZ.sol | 100 | 75 | 100 | 100 | |
517+
OwnableOZ.sol | 100 | 66.67 | 100 | 100 | |
518518
SafeMathOZ.sol | 100 | 75 | 100 | 100 | |
519519
TestSha.sol | 100 | 100 | 100 | 100 | |
520-
WorkOrder.sol | 100 | 60 | 100 | 100 | |
521-
WorkerPool.sol | 100 | 82.69 | 100 | 100 | |
520+
WorkOrder.sol | 100 | 56.25 | 100 | 100 | |
521+
WorkerPool.sol | 100 | 81.9 | 100 | 100 | |
522522
WorkerPoolHub.sol | 100 | 75 | 100 | 100 | |
523523
-----------------------------|----------|----------|----------|----------|----------------|
524-
All files | 100 | 75.16 | 100 | 100 | |
524+
All files | 100 | 74.7 | 100 | 100 | |
525525
-----------------------------|----------|----------|----------|----------|----------------|
526526
```
527527
## Oyente analyse see [here](./oyente)

contracts/IexecAPI.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "rlc-token/contracts/RLC.sol";
77

88
contract IexecAPI is OwnableOZ, IexecHubAccessor, IexecCallbackInterface
99
{
10-
event WorkOrder (address woid);
10+
event WorkOrderActivated (address woid);
1111
event WithdrawRLCFromIexecAPI(address to, uint256 amount);
1212
event ApproveIexecHub (address iexecHub, uint256 amount);
1313
event DepositRLCOnIexecHub (address iexecHub, uint256 amount);
@@ -34,7 +34,7 @@ contract IexecAPI is OwnableOZ, IexecHubAccessor, IexecCallbackInterface
3434
public
3535
{
3636
address woid = iexecHubInterface.buyForWorkOrder(_marketorderIdx, _workerpool, _app, _dataset, _params, _callback, _beneficiary);
37-
emit WorkOrder(woid);
37+
emit WorkOrderActivated(woid);
3838
}
3939

4040
function workOrderCallback(

contracts/IexecHub.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ contract IexecHub
3838
/**
3939
* Market place
4040
*/
41-
Marketplace marketplace;
41+
Marketplace public marketplace;
4242
modifier onlyMarketplace()
4343
{
4444
require(msg.sender == address(marketplace));
@@ -504,7 +504,7 @@ contract IexecHub
504504
require(seize(_worker, _amount));
505505
if (_reputation)
506506
{
507-
m_contributionHistory.failled = m_contributionHistory.failled.add(1);
507+
m_contributionHistory.failed = m_contributionHistory.failed.add(1);
508508
m_scores[_worker] = m_scores[_worker].sub(m_scores[_worker].min(SCORE_UNITARY_SLASH));
509509
emit FaultyContribution(_woid, _worker);
510510
}

contracts/IexecLib.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ library IexecLib
3232
UNSET, // Work order not yet initialized (invalid address)
3333
ACTIVE, // Marketed → constributions are open
3434
REVEALING, // Starting consensus reveal
35-
CLAIMED, // Failled consensus
35+
CLAIMED, // failed consensus
3636
COMPLETED // Concensus achieved
3737
}
3838

@@ -48,7 +48,7 @@ library IexecLib
4848
bytes32 consensus;
4949
uint256 revealDate;
5050
uint256 revealCounter;
51-
uint256 consensusTimout;
51+
uint256 consensusTimeout;
5252
uint256 winnerCount;
5353
address[] contributors;
5454
address workerpoolOwner;
@@ -90,10 +90,10 @@ library IexecLib
9090
uint256 locked;
9191
}
9292

93-
struct ContributionHistory // for credibility computation, f = failled/total
93+
struct ContributionHistory // for credibility computation, f = failed/total
9494
{
9595
uint256 success;
96-
uint256 failled;
96+
uint256 failed;
9797
}
9898

9999
struct Category

contracts/WorkerPool.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
176176
bytes32 c_consensus,
177177
uint256 c_revealDate,
178178
uint256 c_revealCounter,
179-
uint256 c_consensusTimout,
179+
uint256 c_consensusTimeout,
180180
uint256 c_winnerCount,
181181
address c_workerpoolOwner)
182182
{
@@ -187,7 +187,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
187187
consensus.consensus,
188188
consensus.revealDate,
189189
consensus.revealCounter,
190-
consensus.consensusTimout,
190+
consensus.consensusTimeout,
191191
consensus.winnerCount,
192192
consensus.workerpoolOwner
193193
);
@@ -240,7 +240,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
240240
consensus.poolReward = marketplaceInterface.getMarketOrderValue(_marketorderIdx);
241241
consensus.workerpoolOwner = marketplaceInterface.getMarketOrderWorkerpoolOwner(_marketorderIdx);
242242
consensus.stakeAmount = consensus.poolReward.percentage(m_stakeRatioPolicy);
243-
consensus.consensusTimout = timeout;
243+
consensus.consensusTimeout = timeout;
244244
consensus.schedulerRewardRatioPolicy = m_schedulerRewardRatioPolicy;
245245

246246
emit WorkOrderActive(_woid);
@@ -251,7 +251,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
251251
function claimFailedConsensus(address _woid) public onlyIexecHub returns (bool)
252252
{
253253
IexecLib.Consensus storage consensus = m_consensus[_woid];
254-
require(now > consensus.consensusTimout);
254+
require(now > consensus.consensusTimeout);
255255
uint256 i;
256256
address w;
257257
for (i = 0; i < consensus.contributors.length; ++i)
@@ -281,7 +281,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
281281
require(WorkOrder(_woid).m_status() == IexecLib.WorkOrderStatusEnum.ACTIVE);
282282
IexecLib.Contribution storage contribution = m_contributions[_woid][_worker];
283283
IexecLib.Consensus storage consensus = m_consensus[_woid];
284-
require(now <= consensus.consensusTimout);
284+
require(now <= consensus.consensusTimeout);
285285

286286
address workerPool;
287287
uint256 workerScore;
@@ -300,7 +300,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
300300
{
301301
require(iexecHubInterface.isWoidRegistred(_woid));
302302
IexecLib.Consensus storage consensus = m_consensus[_woid];
303-
require(now <= consensus.consensusTimout);
303+
require(now <= consensus.consensusTimeout);
304304
require(WorkOrder(_woid).m_status() == IexecLib.WorkOrderStatusEnum.ACTIVE); // can't contribute on a claimed or completed workorder
305305
IexecLib.Contribution storage contribution = m_contributions[_woid][msg.sender];
306306

@@ -328,7 +328,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
328328
{
329329
require(iexecHubInterface.isWoidRegistred(_woid));
330330
IexecLib.Consensus storage consensus = m_consensus[_woid];
331-
require(now <= consensus.consensusTimout);
331+
require(now <= consensus.consensusTimeout);
332332
require(WorkOrder(_woid).startRevealingPhase());
333333

334334
consensus.winnerCount = 0;
@@ -356,7 +356,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
356356
{
357357
require(iexecHubInterface.isWoidRegistred(_woid));
358358
IexecLib.Consensus storage consensus = m_consensus[_woid];
359-
require(now <= consensus.consensusTimout);
359+
require(now <= consensus.consensusTimeout);
360360
IexecLib.Contribution storage contribution = m_contributions[_woid][msg.sender];
361361

362362
require(WorkOrder(_woid).m_status() == IexecLib.WorkOrderStatusEnum.REVEALING );
@@ -377,7 +377,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
377377
{
378378
require(iexecHubInterface.isWoidRegistred(_woid));
379379
IexecLib.Consensus storage consensus = m_consensus[_woid];
380-
require(now <= consensus.consensusTimout);
380+
require(now <= consensus.consensusTimeout);
381381
require(consensus.revealDate <= now && consensus.revealCounter == 0);
382382
require(WorkOrder(_woid).reActivate());
383383

@@ -402,7 +402,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
402402
{
403403
require(iexecHubInterface.isWoidRegistred(_woid));
404404
IexecLib.Consensus storage consensus = m_consensus[_woid];
405-
require(now <= consensus.consensusTimout);
405+
require(now <= consensus.consensusTimeout);
406406
require((consensus.revealDate <= now && consensus.revealCounter > 0) || (consensus.revealCounter == consensus.winnerCount)); // consensus.winnerCount never 0 at this step
407407

408408
// add penalized to the call worker to contribution and they never contribute ?
@@ -420,7 +420,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
420420
uint256 workerBonus;
421421
uint256 workerWeight;
422422
uint256 totalWeight;
423-
uint256 workerReward;
423+
uint256 individualWorkerReward;
424424
uint256 totalReward = _consensus.poolReward;
425425
address[] memory contributors = _consensus.contributors;
426426
for (i = 0; i<contributors.length; ++i)
@@ -442,17 +442,17 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor, MarketplaceAccessor
442442
require(totalWeight > 0);
443443

444444
// compute how much is going to the workers
445-
uint256 workersReward = totalReward.percentage(uint256(100).sub(_consensus.schedulerRewardRatioPolicy));
445+
uint256 totalWorkersReward = totalReward.percentage(uint256(100).sub(_consensus.schedulerRewardRatioPolicy));
446446

447447
for (i = 0; i<contributors.length; ++i)
448448
{
449449
w = contributors[i];
450450
if (m_contributions[_woid][w].status == IexecLib.ContributionStatusEnum.PROVED)
451451
{
452-
workerReward = workersReward.mulByFraction(m_contributions[_woid][w].weight, totalWeight);
453-
totalReward = totalReward.sub(workerReward);
452+
individualWorkerReward = totalWorkersReward.mulByFraction(m_contributions[_woid][w].weight, totalWeight);
453+
totalReward = totalReward.sub(individualWorkerReward);
454454
require(iexecHubInterface.unlockForWork(_woid, w, _consensus.stakeAmount));
455-
require(iexecHubInterface.rewardForWork(_woid, w, workerReward, true));
455+
require(iexecHubInterface.rewardForWork(_woid, w, individualWorkerReward, true));
456456
}
457457
else // WorkStatusEnum.POCO_REJECT or ContributionStatusEnum.CONTRIBUTED (not revealed)
458458
{

test/byFunctions/IexecAPI/buyForWorkOrder.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ contract('IexecHub', function(accounts) {
259259
it("buyForWorkOrder_01: test buyForWorkOrder from a smart contract", async function() {
260260

261261

262-
aIexecAPIInstance = await IexecAPI.new(aIexecHubInstance.address, aMarketplaceInstance.address, aRLCInstance.address,{
262+
aIexecAPIInstance = await IexecAPI.new(aIexecHubInstance.address, aMarketplaceInstance.address, {
263263
from: iExecCloudUser
264264
});
265265
console.log("aIexecAPIInstance created "+aIexecAPIInstance.address);
@@ -348,6 +348,9 @@ contract('IexecHub', function(accounts) {
348348
woid = events[0].args.woid;
349349
assert.strictEqual(events[0].args.workerPool, aWorkerPoolInstance.address, "check workerPool");
350350

351+
events = await Extensions.getEventsPromise(aIexecAPIInstance.WorkOrderActivated({}),1,constants.EVENT_WAIT_TIMEOUT);
352+
assert.strictEqual(events[0].args.woid, woid, "check woid");
353+
351354
checkBalance = await aIexecHubInstance.checkBalance.call(aIexecAPIInstance.address);
352355
assert.strictEqual(checkBalance[0].toNumber(), 0, "check stake of the aIexecAPIInstance.address");
353356
assert.strictEqual(checkBalance[1].toNumber(), 100, "check stake locked of the aIexecAPIInstance.address");

test/byFunctions/IexecAPI/workOrderCallback.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ contract('IexecHub', function(accounts) {
304304
it("workOrderCallback_01: test workOrderCallback from a smart contract", async function() {
305305

306306

307-
aIexecAPIInstance = await IexecAPI.new(aIexecHubInstance.address, aMarketplaceInstance.address,aRLCInstance.address, {
307+
aIexecAPIInstance = await IexecAPI.new(aIexecHubInstance.address, aMarketplaceInstance.address, {
308308
from: iExecCloudUser
309309
});
310310
console.log("aIexecAPIInstance created " + aIexecAPIInstance.address);
@@ -417,7 +417,7 @@ contract('IexecHub', function(accounts) {
417417
assert.strictEqual(events[0].args.result, '0x5def3ac0554e7a443f84985aa9629864e81d71d59e0649ddad3d618f85a1bf4b', "check revealed result by resourceProvider");
418418
assert.strictEqual(events[0].args.result, web3.sha3("iExec the wanderer"), "check revealed result by resourceProvider");
419419

420-
[poolReward, stakeAmount, consensus, revealDate, revealCounter, consensusTimout, winnerCount] = await aWorkerPoolInstance.getConsensusDetails.call(woid, {
420+
[poolReward, stakeAmount, consensus, revealDate, revealCounter, consensusTimeout, winnerCount] = await aWorkerPoolInstance.getConsensusDetails.call(woid, {
421421
from: iExecCloudUser,
422422
gas: constants.AMOUNT_GAS_PROVIDED
423423
});
@@ -436,7 +436,7 @@ contract('IexecHub', function(accounts) {
436436
assert.strictEqual(consensus, '0x2fa3c6dc29e10dfc01cea7e9443ffe431e6564e74f5dcf4de4b04f2e5d343d70', "check consensus");
437437
assert.isTrue(revealDate.toNumber() > 0, "check revealDate > 0");
438438
assert.strictEqual(revealCounter.toNumber(), 1, "check revealCounter 1 now");
439-
assert.isTrue(consensusTimout.toNumber() > 0, "check consensusTimout > 0");
439+
assert.isTrue(consensusTimeout.toNumber() > 0, "check consensusTimeout > 0");
440440
assert.strictEqual(winnerCount.toNumber(), 1, "check 1 winnerCount");
441441

442442

test/byFunctions/IexecHub/attachMarketplace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ contract('IexecHub', function(accounts) {
166166
gas : constants.AMOUNT_GAS_PROVIDED
167167
});
168168
assert.isBelow(txMined.receipt.gasUsed, constants.AMOUNT_GAS_PROVIDED, "should not use all gas");
169-
let marketplaceAddressCall = await aIexecHubInstance.marketplaceAddress.call();
169+
let marketplaceAddressCall = await aIexecHubInstance.marketplace.call();
170170
assert.strictEqual(marketplaceAddressCall, aMarketplaceInstance.address, "check marketplaceAddress in aIexecHubInstance");
171171
});
172172

test/byFunctions/IexecHub/setCategoriesCreator.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -219,28 +219,6 @@ contract('IexecHub', function(accounts) {
219219

220220
});
221221

222-
it("setCategoriesCreator_03 : it should be possible for any user to setCategoriesCreator to himself", async function() {
223-
224-
txMined = await aIexecHubInstance.setCategoriesCreator(iExecCloudUser, {
225-
from: iExecCloudUser,
226-
gas: constants.AMOUNT_GAS_PROVIDED
227-
});
228-
assert.isBelow(txMined.receipt.gasUsed, constants.AMOUNT_GAS_PROVIDED, "should not use all gas");
229-
230-
let categoriesCreatorCall = await aIexecHubInstance.m_categoriesCreator.call();
231-
assert.strictEqual(categoriesCreatorCall, iExecCloudUser, "check m_categoriesCreator in aIexecHubInstance");
232-
233-
});
234-
235-
it("setCategoriesCreator_04 : it should be possible for any user to setCategoriesCreator to others users", async function() {
236-
txMined = await aIexecHubInstance.setCategoriesCreator(resourceProvider, {
237-
from: iExecCloudUser,
238-
gas: constants.AMOUNT_GAS_PROVIDED
239-
});
240-
assert.isBelow(txMined.receipt.gasUsed, constants.AMOUNT_GAS_PROVIDED, "should not use all gas");
241-
let categoriesCreatorCall = await aIexecHubInstance.m_categoriesCreator.call();
242-
assert.strictEqual(categoriesCreatorCall, resourceProvider, "check m_categoriesCreator in aIexecHubInstance");
243-
});
244222

245223
it("setCategoriesCreator_05 : when m_categoriesCreator is valorized. it must not be possible to others users to call setCategoriesCreator", async function() {
246224
txMined = await aIexecHubInstance.setCategoriesCreator(marketplaceCreator, {

0 commit comments

Comments
 (0)