Skip to content

Commit

Permalink
Remove unnecessary back and forth transfers in IexecPoco2Delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjams committed Dec 16, 2024
1 parent d443cc4 commit f951880
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## vNEXT

### Updated contracts
- [x] `IexecPoco2Delegate.sol`

### Features
- Remove unnecessary back and forth transfers in `IexecPoco2Delegate` happening during `claim(..)`. (#167)
- Remove references to blockscout v5. (#161)
- Migrate integration test files to Typescript & Hardhat:
- 000_fullchain.js (#156, #157)
Expand Down
11 changes: 9 additions & 2 deletions contracts/modules/delegates/IexecPoco2Delegate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ contract IexecPoco2Delegate is IexecPoco2, DelegateBase, IexecEscrow, SignatureV

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

/***************************************************************************
Expand Down
4 changes: 0 additions & 4 deletions test/byContract/IexecPoco/06_claim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,8 @@ describe('IexecPoco2#claim', async () => {
.withArgs(sponsor.address, taskPrice)
.to.emit(iexecPoco, 'Seize')
.withArgs(scheduler.address, schedulerTaskStake, taskId)
.to.emit(iexecPoco, 'Transfer')
.withArgs(iexecPoco.address, kittyAddress, schedulerTaskStake)
.to.emit(iexecPoco, 'Reward')
.withArgs(kittyAddress, schedulerTaskStake, taskId)
.to.emit(iexecPoco, 'Transfer')
.withArgs(kittyAddress, iexecPoco.address, schedulerTaskStake)
.to.emit(iexecPoco, 'Lock')
.withArgs(kittyAddress, schedulerTaskStake);
for (const worker of workers) {
Expand Down

0 comments on commit f951880

Please sign in to comment.