-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate external Staking app #1151
Integrate external Staking app #1151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I left a couple of questions.
I think we can implement the receiveLockManager
method in the Agreement app to allow users to sign it in a single tx, what do you think?
await this.approveAndCall({ amount: stake, from: submitter }) | ||
} else { | ||
stake = this.actionCollateral | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the else case being caught right above? Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, sometimes stake
is false
, and I thought this was intended, like if it is false
we explicitly don’t want to stake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure but I mean, I don't see we are using the stake
variable below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, now we are (it was used before). Fixing it.
const unlocked = await staking.unlockedBalanceOf(user) | ||
const tokenBalance = await token.balanceOf(user) | ||
|
||
return unlocked.add(tokenBalance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a bit confusing mixing balances from different contracts. Based on the usages of this function, I think we are using it only to the challenger's balance.
I think this is because the challenger now is forced to use the staking pool. I'm not sure about this to be honest, what was the rationale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's important we fix this, we are mixing different balances here
@@ -294,15 +294,15 @@ contract('Agreement', ([_, someone, user]) => { | |||
const amount = bigExp(200, 18) | |||
|
|||
it('reverts', async () => { | |||
await assertRevert(agreement.unstake({ token, user, amount }), STAKING_ERRORS.ERROR_NOT_ENOUGH_AVAILABLE_STAKE) | |||
await assertRevert(agreement.unstake({ token, user, amount }), SAFE_MATH_ERRORS.ERROR_SUB_UNDERFLOW) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably handle this scenario in the Staking contract, what do you think?
@@ -137,7 +137,7 @@ contract('Agreement', ([_, someone, user]) => { | |||
|
|||
context('when the user has not approved the requested amount', () => { | |||
it('reverts', async () => { | |||
await assertRevert(agreement.stake({ token, user, amount, from, approve }), STAKING_ERRORS.ERROR_TOKEN_DEPOSIT_FAILED) | |||
await assertRevert(agreement.stake({ token, user, amount, from, approve }), STAKING_ERRORS.ERROR_TOKEN_TRANSFER_FAILED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about distinguishing between token deposits and transfers for the error messages in the staking contract?
assertBn(currentChallengerBalance, previousChallengerBalance.add(actionCollateral).add(challengeCollateral), 'challenger balance does not match') | ||
|
||
const currentAgreementBalance = await collateralToken.balanceOf(agreement.address) | ||
assertBn(currentAgreementBalance, previousAgreementBalance.sub(challengeCollateral), 'agreement balance does not match') | ||
|
||
const currentStakingBalance = await collateralToken.balanceOf(stakingAddress) | ||
assertBn(currentStakingBalance, previousStakingBalance.sub(actionCollateral), 'staking balance does not match') | ||
assertBn(currentStakingBalance, previousStakingBalance, 'staking balance does not match') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To understand this a bit, are we changing the way this was working before right? I mean, the challenger must use the staking pool now if I understand correctly.
What do you think about transferring the rewards to the challenger directly?
b332423
to
df48d5b
Compare
6a5e751
to
1254aed
Compare
Also, fix token deposit errors
- action end date - cannot challenge error
1254aed
to
c6c039c
Compare
await this.approveAndCall({ amount: stake, from: submitter }) | ||
} else { | ||
stake = this.actionCollateral | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure but I mean, I don't see we are using the stake
variable below
@@ -924,7 +922,7 @@ contract Agreement is IAgreement, AragonApp { | |||
*/ | |||
function _unlockAndSlashBalance(Staking _staking, address _user, uint256 _unlockAmount, address _challenger, uint256 _slashAmount) internal { | |||
if (_unlockAmount != 0 && _slashAmount != 0) { | |||
_staking.unlockAndSlash(_user, _unlockAmount, _challenger, _slashAmount); | |||
_staking.slashAndUnlock(_user, _challenger, _unlockAmount, _slashAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we agreed on using slashAndUnstake
here for now.
The UI is not thought to have the challenger interacting with the staking for now, we will probably do it in the future tho.
const unlocked = await staking.unlockedBalanceOf(user) | ||
const tokenBalance = await token.balanceOf(user) | ||
|
||
return unlocked.add(tokenBalance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's important we fix this, we are mixing different balances here
Address PR #1151 comments.
Fix dependencies (https://github.com/cgewecke/web3-issue-3544)
* agreements: implement contracts * agreement: init project * agreement: implement happy path tests * agreement: do not allow changing collateral token * agreement: organize errors * agreement: small contract fixes * agreement: complete unit tests * agreement: submit evidence only if there is context on dispute * agreement: implement gas costs tests * agreement: fix authentication logic * agreement: allow challenger to claim settlements * agreements: add settings tests * agreement: model token-balance based permissions * agreements: simplify state assertion logic * agreements: use safe transfers always * agreements: simplify periods validation logic * agreements: use challenge collateral instead of multiplier * agreement: support forwarding interface * agreement: simplify token balance based permissions * agreement: do not allow changing the arbitrator * agreements: add information to emitted events * agreements: improve blacklist for evm scripts * agreements: improve arbitrator fees approval * agreements: implement intergration tests * agreements: add contract inline documentation * agreement: add authentication check when scheduling actions * agreement: update readme * agreement: allow having token balance challenge permissions * agreement: add arapp json file * agreement: add manifest json file * agreement: migrate tests to Truffle v5 * agreements: tell whether a signer must review the content or not * chore: use buidler to run tests * Agreements: Implement disputable app (#1140) * agreements: implement explicit signing process * agreements: implement agreement executors architecture * agreements: remove old executor * agreements: rename "executor" to "disputable" * agreements: migrate back from buidler to truffle * agreements: add test script * agreements: fix clock mocking * agreements: update delay app gas costs * agreements: optimize collateral requirements storage * agreements: use shared staking pool (#1138) * agreements: improve disputable interface naming * disputable: allow setting agreement after initialization * agreements: improve challenge callback * agreements: test disputable voting app * delay: remove embedded token balance permission * agreements: support ACL oracle interface * agreements: implement registration process * disputable: add sample registry app * chore: remove voting app dependency * disputable: add can proceed helper * disputable: supports ERC165 * agreement: multiple enhancements * disputable: allow working without agreement * agreement: optimize bytecode * agreement: remove unregistering state * agreements: support multiple challenges * agreement: add action lifetime config * agreement: allow changing the arbitrator address * agreement: improve architecture naming * agreement: improve dispute metadata * agreement: move disputable base app to aragonOS * agreement: update arapp json file * agreement: fix circular dependency * agreement: skip flaky test * agreement: poc moving responsibilities to disputable app * agreement: poc moving responsibilities to disputable app 2 * agreement: poc moving responsibilities to disputable app 3 * agreement: fix action getter * Agreement: update README and details * Agreement: typo fix in manifest.json * Agreement: cosmetic import re-ordering * Agreement: cosmetic comment rewording/clarification * Agreement: cosmetic code naming clarifications * Agreement: small state optimization in _canProceed() * Agreement: Integrate external Staking app (#1151) * Integrate external Staking app * Staking integration: adapt to new names * test: fix wrapper names Also, fix token deposit errors * Upgrade Staking dependency * Fixes after moving moving responsibilities to disputable app - action end date - cannot challenge error * Fixes after rebase on moving responsibilities to disputable app * Update Staking dependency * Fixes after rebase on moving responsibilities to disputable app Address PR #1151 comments. * Clean _unlockAndSlashBalance Fix dependencies (https://github.com/cgewecke/web3-issue-3544) * fixup! Clean _unlockAndSlashBalance Co-authored-by: Facu Spagnuolo <facuspagnuolo@users.noreply.github.com> * agreement: multiple enhancements * Fix CI (#1167) Broken due to web3 1.2.8 issue and decode events. * Agreement: update comments and docstrings * agreements: follow same ID pattern for all objects * agreements: use aragon os v5 beta * agreements: fix tests * agreements: small enhancements * agreements: optimize disputable activation * agreements: fix gas cost tests Co-authored-by: Brett Sun <qisheng.brett.sun@gmail.com> Co-authored-by: ßingen <bingen@aragon.one>
* agreements: implement contracts * agreement: init project * agreement: implement happy path tests * agreement: do not allow changing collateral token * agreement: organize errors * agreement: small contract fixes * agreement: complete unit tests * agreement: submit evidence only if there is context on dispute * agreement: implement gas costs tests * agreement: fix authentication logic * agreement: allow challenger to claim settlements * agreements: add settings tests * agreement: model token-balance based permissions * agreements: simplify state assertion logic * agreements: use safe transfers always * agreements: simplify periods validation logic * agreements: use challenge collateral instead of multiplier * agreement: support forwarding interface * agreement: simplify token balance based permissions * agreement: do not allow changing the arbitrator * agreements: add information to emitted events * agreements: improve blacklist for evm scripts * agreements: improve arbitrator fees approval * agreements: implement intergration tests * agreements: add contract inline documentation * agreement: add authentication check when scheduling actions * agreement: update readme * agreement: allow having token balance challenge permissions * agreement: add arapp json file * agreement: add manifest json file * agreement: migrate tests to Truffle v5 * agreements: tell whether a signer must review the content or not * chore: use buidler to run tests * Agreements: Implement disputable app (aragon#1140) * agreements: implement explicit signing process * agreements: implement agreement executors architecture * agreements: remove old executor * agreements: rename "executor" to "disputable" * agreements: migrate back from buidler to truffle * agreements: add test script * agreements: fix clock mocking * agreements: update delay app gas costs * agreements: optimize collateral requirements storage * agreements: use shared staking pool (aragon#1138) * agreements: improve disputable interface naming * disputable: allow setting agreement after initialization * agreements: improve challenge callback * agreements: test disputable voting app * delay: remove embedded token balance permission * agreements: support ACL oracle interface * agreements: implement registration process * disputable: add sample registry app * chore: remove voting app dependency * disputable: add can proceed helper * disputable: supports ERC165 * agreement: multiple enhancements * disputable: allow working without agreement * agreement: optimize bytecode * agreement: remove unregistering state * agreements: support multiple challenges * agreement: add action lifetime config * agreement: allow changing the arbitrator address * agreement: improve architecture naming * agreement: improve dispute metadata * agreement: move disputable base app to aragonOS * agreement: update arapp json file * agreement: fix circular dependency * agreement: skip flaky test * agreement: poc moving responsibilities to disputable app * agreement: poc moving responsibilities to disputable app 2 * agreement: poc moving responsibilities to disputable app 3 * agreement: fix action getter * Agreement: update README and details * Agreement: typo fix in manifest.json * Agreement: cosmetic import re-ordering * Agreement: cosmetic comment rewording/clarification * Agreement: cosmetic code naming clarifications * Agreement: small state optimization in _canProceed() * Agreement: Integrate external Staking app (aragon#1151) * Integrate external Staking app * Staking integration: adapt to new names * test: fix wrapper names Also, fix token deposit errors * Upgrade Staking dependency * Fixes after moving moving responsibilities to disputable app - action end date - cannot challenge error * Fixes after rebase on moving responsibilities to disputable app * Update Staking dependency * Fixes after rebase on moving responsibilities to disputable app Address PR aragon#1151 comments. * Clean _unlockAndSlashBalance Fix dependencies (https://github.com/cgewecke/web3-issue-3544) * fixup! Clean _unlockAndSlashBalance Co-authored-by: Facu Spagnuolo <facuspagnuolo@users.noreply.github.com> * agreement: multiple enhancements * Fix CI (aragon#1167) Broken due to web3 1.2.8 issue and decode events. * Agreement: update comments and docstrings * agreements: follow same ID pattern for all objects * agreements: use aragon os v5 beta * agreements: fix tests * agreements: small enhancements * agreements: optimize disputable activation * agreements: fix gas cost tests Co-authored-by: Brett Sun <qisheng.brett.sun@gmail.com> Co-authored-by: ßingen <bingen@aragon.one>
No description provided.