Skip to content

Commit cde2bbd

Browse files
author
francois branciard
committed
remove attachWorkerPoolsAuthorizedListContract function thanks to gas available
1 parent cb5890f commit cde2bbd

9 files changed

+41
-98
lines changed

contracts/WorkerPool.sol

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor // Owned by a S(w)
3535
/**
3636
* Address of slave/related contracts
3737
*/
38-
address public m_workersAuthorizedListAddress;
38+
address public m_workersAuthorizedListAddress;
3939
address private m_workerPoolHubAddress;
4040

4141
modifier onlyWorkerPoolHub()
@@ -72,25 +72,22 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor // Owned by a S(w)
7272
m_workerPoolStatus = WorkerPoolStatusEnum.OPEN;
7373
m_workerPoolHubAddress = msg.sender;
7474

75-
/* cannot do the following AuthorizedList contracts creation because of :
75+
/*
76+
cannot do the following AuthorizedList contracts creation because of :
7677
VM Exception while processing transaction: out of gas at deploy.
7778
use attach....AuthorizedListContract instead function
7879
*/
79-
/*
80-
workersAuthorizedListAddress = new AuthorizedList();
81-
AuthorizedList(workersAuthorizedListAddress).transferOwnership(tx.origin); // owner → tx.origin
80+
81+
m_workersAuthorizedListAddress = new AuthorizedList(AuthorizedList.ListPolicyEnum.WHITELIST);
82+
AuthorizedList(m_workersAuthorizedListAddress).transferOwnership(tx.origin); // owner → tx.origin
83+
/*
8284
dappsAuthorizedListAddress = new AuthorizedList();
8385
AuthorizedList(dappsAuthorizedListAddress).transferOwnership(tx.origin); // owner → tx.origin
8486
requesterAuthorizedListAddress = new AuthorizedList();
8587
AuthorizedList(requesterAuthorizedListAddress).transferOwnership(tx.origin); // owner → tx.origin
8688
*/
8789
}
8890

89-
function attachWorkerPoolsAuthorizedListContract(address _workerPoolsAuthorizedListAddress) public onlyOwner
90-
{
91-
m_workersAuthorizedListAddress = _workerPoolsAuthorizedListAddress;
92-
}
93-
9491
function changeWorkerPoolPolicy(
9592
uint256 _newStakeRatioPolicy,
9693
uint256 _newSchedulerRewardRatioPolicy,
@@ -168,6 +165,8 @@ contract WorkerPool is OwnableOZ, IexecHubAccessor // Owned by a S(w)
168165
}
169166
*/
170167

168+
169+
171170
function switchOnOff(bool onoff) public onlyIexecHub /*for staking management*/ returns (bool)
172171
{
173172
if(onoff){

test/10_finalizedTask.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,15 @@ contract('IexecHub', function(accounts) {
293293
})
294294
.then(result => {
295295
workerPoolAddress = result;
296-
return AuthorizedList.new(0, {
297-
from: scheduleProvider
298-
});
299-
})
300-
.then(instance => {
301-
aWorkersAuthorizedListInstance = instance;
302296
return WorkerPool.at(workerPoolAddress);
303297
})
304298
.then(instance => {
305299
aWorkerPoolInstance = instance;
306-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
307-
from: scheduleProvider
308-
});
300+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
309301
})
310-
.then(txMined => {
311-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
302+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
303+
.then(instance => {
304+
aWorkersAuthorizedListInstance = instance;
312305
return aWorkersAuthorizedListInstance.updateWhitelist(resourceProvider, true, {
313306
from: scheduleProvider,
314307
gas: amountGazProvided

test/2_workerPoolSubscription.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,22 +225,15 @@ contract('IexecHub', function(accounts) {
225225
})
226226
.then(result => {
227227
workerPoolAddress = result;
228-
return AuthorizedList.new(0, { //0 = whiteListPolicy
229-
from: scheduleProvider
230-
});
231-
})
232-
.then(instance => {
233-
aWorkersAuthorizedListInstance = instance;
234228
return WorkerPool.at(workerPoolAddress);
235229
})
236230
.then(instance => {
237231
aWorkerPoolInstance = instance;
238-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
239-
from: scheduleProvider
240-
});
232+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
241233
})
242-
.then(txMined => {
243-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
234+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
235+
.then(instance => {
236+
aWorkersAuthorizedListInstance = instance;
244237
return Promise.all([
245238
aRLCInstance.approve(aIexecHubInstance.address, 100, {
246239
from: scheduleProvider,

test/4_taskRequestCreation.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,22 +241,15 @@ contract('IexecHub', function(accounts) {
241241
})
242242
.then(result => {
243243
workerPoolAddress = result;
244-
return AuthorizedList.new(0, {
245-
from: scheduleProvider
246-
});
247-
})
248-
.then(instance => {
249-
aWorkersAuthorizedListInstance = instance;
250244
return WorkerPool.at(workerPoolAddress);
251245
})
252246
.then(instance => {
253247
aWorkerPoolInstance = instance;
254-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
255-
from: scheduleProvider
256-
});
248+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
257249
})
258-
.then(txMined => {
259-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
250+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
251+
.then(instance => {
252+
aWorkersAuthorizedListInstance = instance;
260253
return aWorkersAuthorizedListInstance.updateWhitelist(resourceProvider, true, {
261254
from: scheduleProvider,
262255
gas: amountGazProvided

test/5_taskRequestAccepted.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,15 @@ contract('IexecHub', function(accounts) {
293293
})
294294
.then(result => {
295295
workerPoolAddress = result;
296-
return AuthorizedList.new(0, {
297-
from: scheduleProvider
298-
});
299-
})
300-
.then(instance => {
301-
aWorkersAuthorizedListInstance = instance;
302296
return WorkerPool.at(workerPoolAddress);
303297
})
304298
.then(instance => {
305299
aWorkerPoolInstance = instance;
306-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
307-
from: scheduleProvider
308-
});
300+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
309301
})
310-
.then(txMined => {
311-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
302+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
303+
.then(instance => {
304+
aWorkersAuthorizedListInstance = instance;
312305
return aWorkersAuthorizedListInstance.updateWhitelist(resourceProvider, true, {
313306
from: scheduleProvider,
314307
gas: amountGazProvided

test/6_callForContributions.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,22 +294,15 @@ contract('IexecHub', function(accounts) {
294294
})
295295
.then(result => {
296296
workerPoolAddress = result;
297-
return AuthorizedList.new(0, {
298-
from: scheduleProvider
299-
});
300-
})
301-
.then(instance => {
302-
aWorkersAuthorizedListInstance = instance;
303297
return WorkerPool.at(workerPoolAddress);
304298
})
305299
.then(instance => {
306300
aWorkerPoolInstance = instance;
307-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
308-
from: scheduleProvider
309-
});
301+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
310302
})
311-
.then(txMined => {
312-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
303+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
304+
.then(instance => {
305+
aWorkersAuthorizedListInstance = instance;
313306
return aWorkersAuthorizedListInstance.updateWhitelist(resourceProvider, true, {
314307
from: scheduleProvider,
315308
gas: amountGazProvided

test/7_workerContribute.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,15 @@ contract('IexecHub', function(accounts) {
295295
})
296296
.then(result => {
297297
workerPoolAddress = result;
298-
return AuthorizedList.new(0, {
299-
from: scheduleProvider
300-
});
301-
})
302-
.then(instance => {
303-
aWorkersAuthorizedListInstance = instance;
304298
return WorkerPool.at(workerPoolAddress);
305299
})
306300
.then(instance => {
307301
aWorkerPoolInstance = instance;
308-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
309-
from: scheduleProvider
310-
});
302+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
311303
})
312-
.then(txMined => {
313-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
304+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
305+
.then(instance => {
306+
aWorkersAuthorizedListInstance = instance;
314307
return aWorkersAuthorizedListInstance.updateWhitelist(resourceProvider, true, {
315308
from: scheduleProvider,
316309
gas: amountGazProvided

test/8_revealConsensus.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,22 +294,15 @@ contract('IexecHub', function(accounts) {
294294
})
295295
.then(result => {
296296
workerPoolAddress = result;
297-
return AuthorizedList.new(0, {
298-
from: scheduleProvider
299-
});
300-
})
301-
.then(instance => {
302-
aWorkersAuthorizedListInstance = instance;
303297
return WorkerPool.at(workerPoolAddress);
304298
})
305299
.then(instance => {
306300
aWorkerPoolInstance = instance;
307-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
308-
from: scheduleProvider
309-
});
301+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
310302
})
311-
.then(txMined => {
312-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
303+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
304+
.then(instance => {
305+
aWorkersAuthorizedListInstance = instance;
313306
return aWorkersAuthorizedListInstance.updateWhitelist(resourceProvider, true, {
314307
from: scheduleProvider,
315308
gas: amountGazProvided

test/9_revealContribution.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,22 +302,15 @@ contract('IexecHub', function(accounts) {
302302
})
303303
.then(result => {
304304
workerPoolAddress = result;
305-
return AuthorizedList.new(0, {
306-
from: scheduleProvider
307-
});
308-
})
309-
.then(instance => {
310-
aWorkersAuthorizedListInstance = instance;
311305
return WorkerPool.at(workerPoolAddress);
312306
})
313307
.then(instance => {
314308
aWorkerPoolInstance = instance;
315-
return aWorkerPoolInstance.attachWorkerPoolsAuthorizedListContract(aWorkersAuthorizedListInstance.address, {
316-
from: scheduleProvider
317-
});
309+
return aWorkerPoolInstance.m_workersAuthorizedListAddress.call();
318310
})
319-
.then(txMined => {
320-
assert.isBelow(txMined.receipt.gasUsed, amountGazProvided, "should not use all gas");
311+
.then( workersAuthorizedListAddress => AuthorizedList.at(workersAuthorizedListAddress))
312+
.then(instance => {
313+
aWorkersAuthorizedListInstance = instance;
321314
return aWorkersAuthorizedListInstance.updateWhitelist(resourceProvider, true, {
322315
from: scheduleProvider,
323316
gas: amountGazProvided

0 commit comments

Comments
 (0)