-
Notifications
You must be signed in to change notification settings - Fork 11
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
Penalty for reward as alternative to slashing #254
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.
Great work here 🙌
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.
🎸 - nice work!
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.
Nice one! Tried to outline the simplest way for penaltyPercent
to scale with violation count.
* @notice Resets future reward back to 100% | ||
* @param _stakingProvider Staking provider address | ||
*/ | ||
function resetReward(address _stakingProvider) external { |
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.
Can you clarify what happens in resetReward
is not called for a penalized staking provider whose penalty ended?
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.
resetReward
also included in updareReward
, so if it none such methods will be called then reward calculation will be looking like staker still has penalty. I know it's not great but with our model - we need active input to update values
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.
In that case, this needs to be stated in the @notice
.
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.
✔️
return effectiveAuthorized(_authorized, _info.penaltyPercent); | ||
} | ||
|
||
/// @dev This view should be called after updateReward modifier |
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 mean with these @dev comments?
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.
updateReward
modifier has resetReward
inside, so this view will give proper value after that check. Otherwise it will show penalty in cases when they may be reseted
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.
Right, this is related to my previous comment. What about something like:
/// @dev In case that a penalty period already ended, this view method may produce
/// outdated results if the penalty hasn't been reset, either by calling
/// `resetReward` explicitly or any function with the `updateReward` modifier.
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.
✔️
if (_info.endPenalty == 0) { | ||
return _from - _to; | ||
} | ||
uint96 effectiveFrom = effectiveAuthorized(_from, _info.penaltyPercent); | ||
uint96 effectiveTo = effectiveAuthorized(_to, _info.penaltyPercent); | ||
return effectiveFrom - effectiveTo; |
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.
Can you just say return effectiveAuthorized(_from, _to)
? When endPenalty == 0
, L492 will make sure the result is _from - _to
.
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.
not sure that I follow you, second value in effectiveAuthorized
is penalty percent, can you elaborate?
in general I made this thing to decrease read operations (still costly)
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.
Sorry, this is what I meant:
if (_info.endPenalty == 0) { | |
return _from - _to; | |
} | |
uint96 effectiveFrom = effectiveAuthorized(_from, _info.penaltyPercent); | |
uint96 effectiveTo = effectiveAuthorized(_to, _info.penaltyPercent); | |
return effectiveFrom - effectiveTo; | |
return effectiveAuthorized(_from - _to); |
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 I see your question, but I didn't do that on purpose, reason is it could produce different result because of rounding errors, for all other places it's division first and then addition/subtraction.
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.
Opened #260
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.
Added some comments, but in general looks good. Just waiting for the small RFCs to merge, IMO.
Co-authored-by: Manuel Montenegro <[email protected]> Co-authored-by: Derek Pierre <[email protected]> Co-authored-by: David Núñez <[email protected]>
Type of PR:
Required reviews:
What this does:
Penalize reward as an option when slashing is too much. Penalty decreases reward by
penaltyDefault
forpenaltyDuration
. Eachpenalize
restarts time, penalty itself is the same value until end of duration. Initially this event starts on Polygon in child app, wherepenalize
can be called by special role (adjudicator
for now)Issues fixed/closed:
Why it's needed:
Notes for reviewers: