Skip to content

Commit f951880

Browse files
Remove unnecessary back and forth transfers in IexecPoco2Delegate
1 parent d443cc4 commit f951880

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

33
## vNEXT
4+
5+
### Updated contracts
6+
- [x] `IexecPoco2Delegate.sol`
7+
8+
### Features
9+
- Remove unnecessary back and forth transfers in `IexecPoco2Delegate` happening during `claim(..)`. (#167)
410
- Remove references to blockscout v5. (#161)
511
- Migrate integration test files to Typescript & Hardhat:
612
- 000_fullchain.js (#156, #157)

contracts/modules/delegates/IexecPoco2Delegate.sol

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,15 @@ contract IexecPoco2Delegate is IexecPoco2, DelegateBase, IexecEscrow, SignatureV
6161

6262
unlock(deal.sponsor, taskPrice); // Refund the payer of the task
6363
seize(deal.workerpool.owner, poolstake, _taskid);
64-
reward(KITTY_ADDRESS, poolstake, _taskid); // → Kitty / Burn
65-
lock(KITTY_ADDRESS, poolstake); // → Kitty / Burn
64+
/**
65+
* Reward kitty and lock value on it.
66+
* Next lines optimize simple `reward(kitty, ..)` and `lock(kitty, ..)` calls
67+
* where functions would together uselessly transfer value from main PoCo
68+
* proxy to kitty, then would transfer value back from kitty to main PoCo proxy.
69+
*/
70+
m_frozens[KITTY_ADDRESS] += poolstake; // → Kitty / Burn
71+
emit Reward(KITTY_ADDRESS, poolstake, _taskid);
72+
emit Lock(KITTY_ADDRESS, poolstake);
6673
}
6774

6875
/***************************************************************************

test/byContract/IexecPoco/06_claim.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,8 @@ describe('IexecPoco2#claim', async () => {
144144
.withArgs(sponsor.address, taskPrice)
145145
.to.emit(iexecPoco, 'Seize')
146146
.withArgs(scheduler.address, schedulerTaskStake, taskId)
147-
.to.emit(iexecPoco, 'Transfer')
148-
.withArgs(iexecPoco.address, kittyAddress, schedulerTaskStake)
149147
.to.emit(iexecPoco, 'Reward')
150148
.withArgs(kittyAddress, schedulerTaskStake, taskId)
151-
.to.emit(iexecPoco, 'Transfer')
152-
.withArgs(kittyAddress, iexecPoco.address, schedulerTaskStake)
153149
.to.emit(iexecPoco, 'Lock')
154150
.withArgs(kittyAddress, schedulerTaskStake);
155151
for (const worker of workers) {

0 commit comments

Comments
 (0)