-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: Removal of Mandatory Self-Delegation Reward #2984
Changes from 6 commits
66d83fb
b91e6a8
841dec2
f72b7b5
16866e2
9753d4f
b54fbc6
8ee8d0a
e16c203
a6c3a33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package keeper | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
@@ -77,6 +78,14 @@ func (k Keeper) onDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, | |
func (k Keeper) onDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, | ||
valAddr sdk.ValAddress) { | ||
|
||
if bytes.Equal(delAddr.Bytes(), valAddr.Bytes()) { | ||
// On updates to a self bond/unbond, we must update the validator's dist | ||
// info without withdrawing any rewards. | ||
k.UpdateValidatorDistInfoFromPool(ctx, valAddr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also if you look at what's happening within onValidatorModified you'll see we skip running this at height of 0 - don't see why we wouldn't replicate this for the new function too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto: I don't think there is a need now as I just moved the new call into |
||
} else { | ||
k.onValidatorModified(ctx, valAddr) | ||
} | ||
|
||
if err := k.WithdrawDelegationReward(ctx, delAddr, valAddr); err != nil { | ||
panic(err) | ||
} | ||
|
@@ -116,7 +125,6 @@ func (h Hooks) OnDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valA | |
h.k.onDelegationCreated(ctx, delAddr, valAddr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new hook route should also be called within the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there is a need now as I just moved the new call into |
||
} | ||
func (h Hooks) OnDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { | ||
h.k.onValidatorModified(ctx, valAddr) | ||
h.k.onDelegationSharesModified(ctx, delAddr, valAddr) | ||
} | ||
func (h Hooks) OnDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { | ||
|
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.
this doesn't need to be exposed (should keep consistency)
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! Updated.
But consistency with what exactly? Everything in
x/distribution/keeper/validator.go
is exposed (which is where this lives). I wasn't able to find a consistent pattern for these methods. I think a large bulk of them should be unexposed.