-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: Rename hooks from Before -> Pre and On -> Post #3076
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.
As it's a breaking SDK API change, I think this warrants a pending log update, otherwise, LGTM.
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.
These names aren't right, I think we want Pre/Post to reflect whether or not the store has been updated.
Also needs a PENDING.md
update.
x/stake/handler.go
Outdated
@@ -163,7 +163,7 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe | |||
return err.Result() | |||
} | |||
validator.Commission = commission | |||
k.OnValidatorModified(ctx, msg.ValidatorAddr) | |||
k.PostValidatorModified(ctx, msg.ValidatorAddr) |
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 isn't post-modification? Changes haven't been written to the store yet (line 169).
x/stake/keeper/delegation.go
Outdated
@@ -398,9 +398,9 @@ func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Co | |||
|
|||
// call the appropriate hook if present | |||
if found { | |||
k.OnDelegationSharesModified(ctx, delAddr, validator.OperatorAddr) | |||
k.PostDelegationSharesModified(ctx, delAddr, validator.OperatorAddr) |
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 isn't post-modification.
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.
All of the hooks were On
something. I'll have to read through the code in a bit more detail to figure out which ones are Pre
.
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, the previous names were (are) wrong / misleading
x/stake/keeper/delegation.go
Outdated
} else { | ||
k.OnDelegationCreated(ctx, delAddr, validator.OperatorAddr) | ||
k.PostDelegationCreated(ctx, delAddr, validator.OperatorAddr) |
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 isn't post-modification either.
I only see |
x/stake/handler.go
Outdated
@@ -122,7 +122,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k | |||
k.SetValidatorByConsAddr(ctx, validator) | |||
k.SetNewValidatorByPowerIndex(ctx, validator) | |||
|
|||
k.OnValidatorCreated(ctx, validator.OperatorAddr) | |||
k.PostValidatorCreated(ctx, validator.OperatorAddr) |
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 is post-modification, 👍 )
x/stake/keeper/delegation.go
Outdated
@@ -81,7 +81,7 @@ func (k Keeper) SetDelegation(ctx sdk.Context, delegation types.Delegation) { | |||
|
|||
// remove a delegation from store | |||
func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation) { | |||
k.OnDelegationRemoved(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr) | |||
k.PostDelegationRemoved(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr) |
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 isn't post-modification (as you can see by the store.Delete
call two lines below)
x/stake/keeper/delegation.go
Outdated
@@ -431,7 +431,7 @@ func (k Keeper) unbond(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValA | |||
return | |||
} | |||
|
|||
k.OnDelegationSharesModified(ctx, delAddr, valAddr) | |||
k.PostDelegationSharesModified(ctx, delAddr, valAddr) |
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 isn't post-modification (we set the delegation later in this function)
x/stake/keeper/val_state_change.go
Outdated
@@ -81,7 +81,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab | |||
// Assert that the validator had updated its ValidatorDistInfo.FeePoolWithdrawalHeight. | |||
// This hook is extremely useful, otherwise lazy accum bugs will be difficult to solve. | |||
if k.hooks != nil { | |||
k.hooks.OnValidatorPowerDidChange(ctx, validator.ConsAddress(), valAddr) | |||
k.hooks.PostValidatorPowerDidChange(ctx, validator.ConsAddress(), valAddr) |
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 is post-modification, 👍
x/stake/keeper/val_state_change.go
Outdated
@@ -197,7 +197,7 @@ func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types. | |||
|
|||
// call the bond hook if present | |||
if k.hooks != nil { | |||
k.hooks.OnValidatorBonded(ctx, validator.ConsAddress(), validator.OperatorAddr) | |||
k.hooks.PostValidatorBonded(ctx, validator.ConsAddress(), validator.OperatorAddr) |
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 is post-modification, 👍 )
x/stake/keeper/val_state_change.go
Outdated
@@ -232,7 +232,7 @@ func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validat | |||
|
|||
// call the unbond hook if present | |||
if k.hooks != nil { | |||
k.hooks.OnValidatorBeginUnbonding(ctx, validator.ConsAddress(), validator.OperatorAddr) | |||
k.hooks.PostValidatorBeginUnbonding(ctx, validator.ConsAddress(), validator.OperatorAddr) |
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 is post-modification, 👍 )
x/stake/keeper/validator.go
Outdated
@@ -204,7 +204,7 @@ func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.ValAddress) { | |||
|
|||
// call hook if present | |||
if k.hooks != nil { | |||
k.hooks.OnValidatorRemoved(ctx, validator.ConsAddress(), validator.OperatorAddr) | |||
k.hooks.PostValidatorRemoved(ctx, validator.ConsAddress(), validator.OperatorAddr) |
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 is post-modification, 👍 )
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.
@jackzampolin I've done a thorough review and labeled which hooks should be which, I think (always good to oonfirm - just look at where the store.Set
calls are in relation to the hook invocation).
Codecov Report
@@ Coverage Diff @@
## develop #3076 +/- ##
===========================================
+ Coverage 54.85% 54.86% +<.01%
===========================================
Files 133 133
Lines 9544 9546 +2
===========================================
+ Hits 5235 5237 +2
Misses 3988 3988
Partials 321 321 |
I've addressed the comments here and properly named the functions (according to @cwgoes). Would be good to get 👀 from @rigelrozanski here |
Merge develop; that should fix the sim. |
ad19b42
to
a8664c9
Compare
Can we do "Before"/"After"? or "Will"/"Did". "Pre"/"Post" seems like they would be overloaded terms in general. |
ebf2929
to
fd1647f
Compare
@jaekwon Done. I think this is ready to go in after that. |
cbdb264
to
ffad6ae
Compare
LGTM, this needs another review still. |
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.
Generally looks good - still a few comments which I'd like addressed
Co-Authored-By: jackzampolin <[email protected]>
Is this PR waiting on anything @cwgoes @rigelrozanski ? Looks like I've addressed the comments? |
LGTM except linter fails. |
Turned off the linter on the affected file. This is ready to go and can be merged whenever. |
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.
@jackzampolin just for reference my comments where not fully addressed (I added leftover comments to another issue as well as made one commit) - Generally speaking, somebodies PR comments should only be considered "addressed" once all the the PR comments have been marked as resolved, which was not this case here (nbd obv. - just mentioning)
Fixes #2538
This PR renames the hooks in the SDK to match the agreed upon format in the linked issue.
cc @rigelrozanski @cwgoes