-
Notifications
You must be signed in to change notification settings - Fork 370
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
[Slashing] Slash locked gold #2317
Conversation
* has the most votes of any validator group. | ||
* @param indices The indices of the i'th group in `account`'s voting list. | ||
*/ | ||
function slash( |
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.
Emit an event
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.
should I emit one event AccountSlashed(account, penalty, reporter, reward)
or two events to split account/penalty and reporter/reward. Or is the reporter/reward not as important
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.
one event is ok imo
312bdd4
to
1aac117
Compare
I'll try to add a test into |
// If not enough nonvoting, revoke the difference | ||
if (nonvotingBalance < penalty) { | ||
difference = penalty.sub(nonvotingBalance); | ||
require( |
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 should we do if there's not enough to slash anymore?
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 believe we would want to just slash all of the account
's gold, I'm assuming this is handled on the caller side (Slasher
contract) by passing in for penalty
max(normalSlashPenalty, totalGoldOwnedByAccount)
where normalSlashPenalty
is the default penalty and totalGoldOwnedByAccount
is the total balance + voting balance for the account.
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.
Now that the other PRs are in, we can update e.g. https://github.com/celo-org/celo-monorepo/blob/master/packages/protocol/contracts/governance/SlasherUtil.sol#L81 to do the max(normalSlashPenalty, totalGoldOwnedByAccount)
.
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.
Perhaps it's easier to handle in LockedGold, because the needed balances are stored there.
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.
Based on this I am changing LockedGold.slash
to only slash min(totalLockedGold, penalty)
. A problematic implication is that if totalLockedGold
is somehow less than the reward
passed in to slash, the call will revert. However, without doing a bunch of wasteful calculations (adjusting reward
based on its original proportion or something similar) slash
doesn't have the right info to change reward
properly. Just something to keep in mind
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 this is OK for now, but i would follow the discussion on this.
My concern is that Given the min()
i will be considered "slashed" and thus can't be slashed again for the same thing, but i wouldn't be really paying the penalty that i'm due... i wonder if i can use that to shield me from penalties somehow.
But to analyze this we need to see the bigger picture...
Did you solve the issue with sending to governance? I guess you just need to make MockGovernance able to receive gold like Governance (fallback function). |
ec84451
to
e923f34
Compare
Codecov Report
@@ Coverage Diff @@
## master #2317 +/- ##
========================================
Coverage 74.55% 74.55%
========================================
Files 278 278
Lines 7777 7777
Branches 707 991 +284
========================================
Hits 5798 5798
Misses 1868 1868
Partials 111 111
Continue to review full report at Codecov.
|
b0d3ee3
to
24c0a9e
Compare
Looks like the integration test broke here. Should be fixed by using the migration from https://github.com/mrsmkl/celo-monorepo/blob/test-slashing2/packages/protocol/migrations/19_governance_slasher.ts |
Looks like there was some flakiness in the validators test, perhaps because the epoch number was calculated differently. |
4df3962
to
29919e6
Compare
b744f78
to
65b6d2b
Compare
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.
left a comment, but approved!
* master: (26 commits) Added new lint rule (#2349) [Slashing] Slash locked gold (#2317) [Slashing] Allow voting gold to be slashable (#2302) 1666 precompiles assembly rewrite (#2324) Small fixes to deploy web (#2343) Governance, downtime and double signing slasher contracts (#2267) Added daily limit for reserve spending (#2303) Fixing multisig tests (#2342) [Wallet] Implement new send & import flow (#2332) Limechain/16xx (#1982) Add infinite pagination to Leaderboard (#2339) cli: Add rewards:show (#2160) Correct broken link formatting Celotool command for deploying hotfixes (#2142) Governance ContractKit + CLI changes (#2139) Complete codependent slashing precompile PRs (#2333) Add new and modified precompiles to UsingPrecompiles.sol (#2318) Adding error messages to contracts (#1182) Upgrade i18next and react-i18next to latest across monorepo (#2311) [Wallet] Fix exchange input on iOS and feed item display (#2319) ... # Conflicts: # yarn.lock
* master: (35 commits) Remove rep sentence from brand kit page (#2350) Added new lint rule (#2349) [Slashing] Slash locked gold (#2317) [Slashing] Allow voting gold to be slashable (#2302) 1666 precompiles assembly rewrite (#2324) Small fixes to deploy web (#2343) Governance, downtime and double signing slasher contracts (#2267) Added daily limit for reserve spending (#2303) Fixing multisig tests (#2342) [Wallet] Implement new send & import flow (#2332) Limechain/16xx (#1982) Add infinite pagination to Leaderboard (#2339) cli: Add rewards:show (#2160) Correct broken link formatting Celotool command for deploying hotfixes (#2142) Governance ContractKit + CLI changes (#2139) Complete codependent slashing precompile PRs (#2333) Add new and modified precompiles to UsingPrecompiles.sol (#2318) Adding error messages to contracts (#1182) Upgrade i18next and react-i18next to latest across monorepo (#2311) ...
Description
Adds
slash
function to LockedGold to allow slashing contracts to slash an account's gold.Adds
isSlasher
mapping to allow addition of registered slashing addresses for permissioned use of functions.Tested
Added unit tests.
Related issues
Driveby changes
Changed
MockGovernance
to be payable to allow testing of sending to community fund.Changed Election interface and mock to allow
LockedGold
to test slashing voting gold.Adds governance slasher as registered slasher in migrations (this will be expanded upon in PR #2347