Skip to content
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

refactor: apply new gov/params structure #4

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 2 additions & 36 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/gogoproto/proto"

// ibc imports
Expand Down Expand Up @@ -251,7 +249,6 @@ type MilkyWayApp struct {
BankKeeper *bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
UpgradeKeeper *upgradekeeper.Keeper
ParamsKeeper *paramskeeper.Keeper
GroupKeeper *groupkeeper.Keeper
ConsensusParamsKeeper *consensusparamkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
Expand Down Expand Up @@ -337,11 +334,10 @@ func NewMilkyWayApp(
auctiontypes.StoreKey, packetforwardtypes.StoreKey, oracletypes.StoreKey,
tokenfactorytypes.StoreKey, ibchookstypes.StoreKey, forwardingtypes.StoreKey,
marketmaptypes.StoreKey,
paramstypes.StoreKey,
ratelimittypes.StoreKey, epochstypes.StoreKey, icqtypes.StoreKey,
icacallbackstypes.StoreKey, recordstypes.StoreKey, stakeibctypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(forwardingtypes.TransientStoreKey, paramstypes.TStoreKey)
tkeys := storetypes.NewTransientStoreKeys(forwardingtypes.TransientStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)

// register streaming services
Expand Down Expand Up @@ -370,14 +366,6 @@ func NewMilkyWayApp(
panic(err)
}

paramsKeeper := initParamsKeeper(
appCodec,
legacyAmino,
keys[paramstypes.StoreKey],
tkeys[paramstypes.TStoreKey],
)
app.ParamsKeeper = &paramsKeeper

// set the BaseApp's parameter store
consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authorityAddr, runtime.EventService{})
app.ConsensusParamsKeeper = &consensusParamsKeeper
Expand Down Expand Up @@ -544,7 +532,6 @@ func NewMilkyWayApp(
app.RateLimitKeeper = *ratelimitkeeper.NewKeeper(
appCodec,
keys[ratelimittypes.StoreKey],
app.GetSubspace(ratelimittypes.ModuleName),
authorityAddr,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
Expand All @@ -562,7 +549,6 @@ func NewMilkyWayApp(
appCodec,
keys[icacallbackstypes.StoreKey],
keys[icacallbackstypes.MemStoreKey],
app.GetSubspace(icacallbackstypes.ModuleName),
*app.IBCKeeper,
)

Expand Down Expand Up @@ -637,7 +623,6 @@ func NewMilkyWayApp(
appCodec,
keys[recordstypes.StoreKey],
keys[recordstypes.MemStoreKey],
app.GetSubspace(recordstypes.ModuleName),
app.AccountKeeper,
*app.TransferKeeper,
*app.IBCKeeper,
Expand Down Expand Up @@ -708,7 +693,7 @@ func NewMilkyWayApp(
appCodec,
keys[stakeibctypes.StoreKey],
keys[stakeibctypes.MemStoreKey],
app.GetSubspace(stakeibctypes.ModuleName),
runtime.NewKVStoreService(keys[stakeibctypes.StoreKey]),
authorityAddr,
app.AccountKeeper,
app.BankKeeper,
Expand Down Expand Up @@ -1312,14 +1297,6 @@ func (app *MilkyWayApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
return app.memKeys[storeKey]
}

// GetSubspace returns a param subspace for a given module name.
//
// NOTE: This is solely to be used for testing purposes.
func (app *MilkyWayApp) GetSubspace(moduleName string) paramstypes.Subspace {
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
return subspace
}

// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *MilkyWayApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
Expand Down Expand Up @@ -1520,14 +1497,3 @@ func (app *MilkyWayApp) Close() error {

return nil
}

// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(ratelimittypes.ModuleName)
paramsKeeper.Subspace(recordstypes.ModuleName)
paramsKeeper.Subspace(stakeibctypes.ModuleName)

return paramsKeeper
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,6 @@ replace (

// MilkyWay custom
replace (
github.com/Stride-Labs/ibc-rate-limiting => github.com/milkyway-labs/ibc-rate-limiting v0.0.0-20240509215339-45e398477ad5
github.com/Stride-Labs/ibc-rate-limiting => github.com/milkyway-labs/ibc-rate-limiting v0.0.0-20240529144041-70ebeac5863b
github.com/cosmos/relayer/v2 => github.com/milkyway-labs/relayer/v2 v2.0.0-20240510185220-0492766a512d
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/mgechev/revive v1.3.7 h1:502QY0vQGe9KtYJ9FpxMz9rL+Fc/P13CI5POL4uHCcE=
github.com/mgechev/revive v1.3.7/go.mod h1:RJ16jUbF0OWC3co/+XTxmFNgEpUPwnnA0BRllX2aDNA=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/milkyway-labs/ibc-rate-limiting v0.0.0-20240509215339-45e398477ad5 h1:1QBEsR4IX53rUHE3EB4VzWiGfEyB+owTivjJU4+zYAM=
github.com/milkyway-labs/ibc-rate-limiting v0.0.0-20240509215339-45e398477ad5/go.mod h1:YAf80eEQ4bdg5qXP4EI8eCxzhhWfqwiy9DoP8JXXg60=
github.com/milkyway-labs/ibc-rate-limiting v0.0.0-20240529144041-70ebeac5863b h1:5OjDS9hKDyXPPd9XJwFcxrpFDUcaEZf9L14zj0fzbwo=
github.com/milkyway-labs/ibc-rate-limiting v0.0.0-20240529144041-70ebeac5863b/go.mod h1:YAf80eEQ4bdg5qXP4EI8eCxzhhWfqwiy9DoP8JXXg60=
github.com/milkyway-labs/relayer/v2 v2.0.0-20240510185220-0492766a512d h1:2nNoD9y1Ucp9swVydBI4JrW/pyGp5cbo5IXAlFzlmyc=
github.com/milkyway-labs/relayer/v2 v2.0.0-20240510185220-0492766a512d/go.mod h1:h4Ng2QsVpxExIq5S+WvLr8slDb9MSBh82gQS4DeMwDo=
github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g=
Expand Down
29 changes: 0 additions & 29 deletions proto/stride/stakeibc/gov.proto

This file was deleted.

22 changes: 21 additions & 1 deletion proto/stride/stakeibc/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "amino/amino.proto";
import "stride/stakeibc/params.proto";

// Msg defines the Msg service.
service Msg {
Expand Down Expand Up @@ -429,4 +430,23 @@ message MsgUpdateHostZoneParams {
// Max messages that can be sent in a single ICA message
uint64 max_messages_per_ica_tx = 3;
}
message MsgUpdateHostZoneParamsResponse {}
message MsgUpdateHostZoneParamsResponse {}

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "stride/x/stakeibc/MsgUpdateParams";

// authority is the address that controls the module (defaults to x/gov unless
// overwritten).
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// params defines the x/staking parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}
20 changes: 3 additions & 17 deletions x/icacallbacks/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,22 @@ package keeper
import (
"fmt"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"

storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

errorsmod "cosmossdk.io/errors"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

"github.com/milkyway-labs/milkyway/x/icacallbacks/types"

channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"

storetypes "cosmossdk.io/store/types"
)

type (
Keeper struct {
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey
paramstore paramtypes.Subspace
icacallbacks map[string]types.ICACallback
IBCKeeper ibckeeper.Keeper
}
Expand All @@ -35,19 +28,12 @@ func NewKeeper(
cdc codec.BinaryCodec,
storeKey,
memKey storetypes.StoreKey,
ps paramtypes.Subspace,
ibcKeeper ibckeeper.Keeper,
) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}

return &Keeper{
cdc: cdc,
storeKey: storeKey,
memKey: memKey,
paramstore: ps,
icacallbacks: make(map[string]types.ICACallback),
IBCKeeper: ibcKeeper,
}
Expand Down
1 change: 0 additions & 1 deletion x/icacallbacks/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {

// SetParams set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, &params)
}
10 changes: 0 additions & 10 deletions x/records/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

icacallbackskeeper "github.com/milkyway-labs/milkyway/x/icacallbacks/keeper"

"github.com/milkyway-labs/milkyway/x/records/types"
)

Expand All @@ -22,7 +20,6 @@ type (
Cdc codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey
paramstore paramtypes.Subspace
AccountKeeper types.AccountKeeper
TransferKeeper ibctransferkeeper.Keeper
IBCKeeper ibckeeper.Keeper
Expand All @@ -34,22 +31,15 @@ func NewKeeper(
Cdc codec.BinaryCodec,
storeKey,
memKey storetypes.StoreKey,
ps paramtypes.Subspace,
AccountKeeper types.AccountKeeper,
TransferKeeper ibctransferkeeper.Keeper,
ibcKeeper ibckeeper.Keeper,
ICACallbacksKeeper icacallbackskeeper.Keeper,
) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}

return &Keeper{
Cdc: Cdc,
storeKey: storeKey,
memKey: memKey,
paramstore: ps,
AccountKeeper: AccountKeeper,
TransferKeeper: TransferKeeper,
IBCKeeper: ibcKeeper,
Expand Down
1 change: 0 additions & 1 deletion x/records/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {

// SetParams set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, &params)
}
Loading
Loading