-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat: migrate x/staking to app wiring #12102
feat: migrate x/staking to app wiring #12102
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.
is this R4R?
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
I still have this test regarding the distribution module for delegation I'm getting the error |
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
- hack: Fixes post construction SetHooks mutation
@@ -63,14 +63,12 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { | |||
} | |||
|
|||
// Set the validator hooks | |||
func (k *Keeper) SetHooks(sh types.StakingHooks) *Keeper { |
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 pattern makes little sense to me given the name SetHooks
.
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 we should add an API-breaking changelog entry, iirc Osmosis is using SetHooks pretty heavily
@@ -47,7 +47,7 @@ func NewKeeper( | |||
panic(fmt.Sprintf("%s module account has not been set", types.NotBondedPoolName)) | |||
} | |||
|
|||
return Keeper{ |
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.
Fundamentally this change is required so that when InitGenesis iterates over the ModuleManager
the StakingKeeper
which is retrieved (by reference) is the same area of memory which the post construction SetHooks mutation modifies.
This is the reason for now passing the Keeper around everywhere by reference.
Not a huge fan of this, but it seems it will be up for refactor when we get to x/distribution
and x/slashing
, or possibly sooner. Those modules can provide their StakingHooks
for this module to order as BaseAppOptions
.
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.
Same here
@aaronc, @kocubinski found a memory bug regarding the staking keeper. Given that the new mechanism was initialized before the hooks are added to it, it will initialize with hooks on nil. @kocubinski solution is in the comment above. I was wondering if you could give it a look and give us your opinion about it. |
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.
LGTM
…_use_app_wiring' into JeancarloBarrios/migrate_staking_use_app_wiring
Codecov Report
@@ Coverage Diff @@
## main #12102 +/- ##
=======================================
Coverage 66.00% 66.00%
=======================================
Files 671 671
Lines 71006 71011 +5
=======================================
+ Hits 46866 46872 +6
+ Misses 21478 21477 -1
Partials 2662 2662
|
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.
🎉
@JeancarloBarrios could you create a quick follow-up to add changelog entries?
@@ -63,14 +63,12 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { | |||
} | |||
|
|||
// Set the validator hooks | |||
func (k *Keeper) SetHooks(sh types.StakingHooks) *Keeper { |
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 we should add an API-breaking changelog entry, iirc Osmosis is using SetHooks pretty heavily
@@ -47,7 +47,7 @@ func NewKeeper( | |||
panic(fmt.Sprintf("%s module account has not been set", types.NotBondedPoolName)) | |||
} | |||
|
|||
return Keeper{ |
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.
Same here
## Description Migrate x/staking to the new app wiring (dependency injection). Tracking progress at cosmos#12036 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [x] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
Description
Migrate x/staking to the new app wiring (dependency injection).
Tracking progress at #12036
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change