-
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
feat: migrate x/staking to app wiring #12102
Changes from all commits
f272fc8
0530a1c
15446da
12d1ec4
ebeb7c5
fbbbd46
b467dcd
6046ac5
39eb9a9
c0eaec6
834fd1a
ed83c41
7bb92f1
722a05e
16a6a40
6e8a954
7b8c22f
194538c
2005d75
1dc2759
215b63f
cd880e4
9ec5a3c
b241d51
35440b7
d8903e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
|
||
package cosmos.staking.module.v1; | ||
|
||
import "cosmos/app/v1alpha1/module.proto"; | ||
|
||
// Module is the config object of the staking module. | ||
message Module { | ||
option (cosmos.app.v1alpha1.module) = { | ||
go_import: "github.com/cosmos/cosmos-sdk/x/staking" | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ type Keeper struct { | |
func NewKeeper( | ||
cdc codec.BinaryCodec, key storetypes.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, | ||
ps paramtypes.Subspace, | ||
) Keeper { | ||
) *Keeper { | ||
// set KeyTable if it has not already been set | ||
if !ps.HasKeyTable() { | ||
ps = ps.WithKeyTable(types.ParamKeyTable()) | ||
|
@@ -47,7 +47,7 @@ func NewKeeper( | |
panic(fmt.Sprintf("%s module account has not been set", types.NotBondedPoolName)) | ||
} | ||
|
||
return Keeper{ | ||
return &Keeper{ | ||
storeKey: key, | ||
cdc: cdc, | ||
authKeeper: ak, | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This pattern makes little sense to me given the name 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 think we should add an API-breaking changelog entry, iirc Osmosis is using SetHooks pretty heavily |
||
func (k *Keeper) SetHooks(sh types.StakingHooks) { | ||
if k.hooks != nil { | ||
panic("cannot set validator hooks twice") | ||
} | ||
|
||
k.hooks = sh | ||
|
||
return k | ||
} | ||
|
||
// Load the last total validator power. | ||
|
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
theStakingKeeper
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
andx/slashing
, or possibly sooner. Those modules can provide theirStakingHooks
for this module to order asBaseAppOptions
.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