From 2df01631ad82c3f25c62153a5c567991ae7e24d4 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Mon, 9 Sep 2024 17:15:30 -0500 Subject: [PATCH 01/11] feat: add v1.1.0 upgrade handler --- app/app.go | 23 ++++++++++++- app/upgrade.go | 15 ++------- app/upgrades/upgrade.go | 13 ++++++++ app/upgrades/v110/upgrade.go | 64 ++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 app/upgrades/upgrade.go create mode 100644 app/upgrades/v110/upgrade.go diff --git a/app/app.go b/app/app.go index de618020..cc8e34d4 100644 --- a/app/app.go +++ b/app/app.go @@ -148,6 +148,7 @@ import ( apphook "github.com/milkyway-labs/milkyway/app/hook" ibcwasmhooks "github.com/milkyway-labs/milkyway/app/ibc-hooks" appkeepers "github.com/milkyway-labs/milkyway/app/keepers" + "github.com/milkyway-labs/milkyway/app/upgrades" "github.com/milkyway-labs/milkyway/utils" "github.com/milkyway-labs/milkyway/x/assets" assetskeeper "github.com/milkyway-labs/milkyway/x/assets/keeper" @@ -1093,7 +1094,7 @@ func NewMilkyWayApp( app.indexerModule.RegisterServices(app.configurator) // register upgrade handler for later use - app.RegisterUpgradeHandlers(app.configurator) + app.RegisterUpgradeHandlers() autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules)) @@ -1482,6 +1483,26 @@ func (app *MilkyWayApp) RegisterNodeService(clientCtx client.Context, cfg config nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } +// Configurator returns the app's configurator. +func (a *MilkyWayApp) Configurator() module.Configurator { + return a.configurator +} + +// registerUpgrade registers the given upgrade to be supported by the app +func (app *MilkyWayApp) registerUpgrade(upgrade upgrades.Upgrade) { + app.UpgradeKeeper.SetUpgradeHandler(upgrade.Name(), upgrade.Handler()) + + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(err) + } + + if upgradeInfo.Name == upgrade.Name() && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + // Configure store loader that checks if version == upgradeHeight and applies store upgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, upgrade.StoreUpgrades())) + } +} + // RegisterSwaggerAPI registers swagger route with API Server func RegisterSwaggerAPI(rtr *mux.Router) { statikFS, err := fs.New() diff --git a/app/upgrade.go b/app/upgrade.go index 17385233..91182852 100644 --- a/app/upgrade.go +++ b/app/upgrade.go @@ -1,19 +1,10 @@ package app import ( - "context" - - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/types/module" + v110 "github.com/milkyway-labs/milkyway/app/upgrades/v110" ) -const upgradeName = "0.2.4" - // RegisterUpgradeHandlers returns upgrade handlers -func (app *MilkyWayApp) RegisterUpgradeHandlers(cfg module.Configurator) { - app.UpgradeKeeper.SetUpgradeHandler(upgradeName, - func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - return fromVM, nil - }, - ) +func (app *MilkyWayApp) RegisterUpgradeHandlers() { + app.registerUpgrade(v110.NewUpgrade(app.ModuleManager, app.Configurator())) } diff --git a/app/upgrades/upgrade.go b/app/upgrades/upgrade.go new file mode 100644 index 00000000..c8cee328 --- /dev/null +++ b/app/upgrades/upgrade.go @@ -0,0 +1,13 @@ +package upgrades + +import ( + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" +) + +// Upgrade represents a generic on-chain upgrade +type Upgrade interface { + Name() string + Handler() upgradetypes.UpgradeHandler + StoreUpgrades() *storetypes.StoreUpgrades +} diff --git a/app/upgrades/v110/upgrade.go b/app/upgrades/v110/upgrade.go new file mode 100644 index 00000000..359d6af7 --- /dev/null +++ b/app/upgrades/v110/upgrade.go @@ -0,0 +1,64 @@ +package v710 + +import ( + "context" + + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/milkyway-labs/milkyway/app/upgrades" + assetstypes "github.com/milkyway-labs/milkyway/x/assets/types" + operatorstypes "github.com/milkyway-labs/milkyway/x/operators/types" + poolstypes "github.com/milkyway-labs/milkyway/x/pools/types" + restakingtypes "github.com/milkyway-labs/milkyway/x/restaking/types" + rewardstypes "github.com/milkyway-labs/milkyway/x/rewards/types" + servicestypes "github.com/milkyway-labs/milkyway/x/services/types" +) + +var ( + _ upgrades.Upgrade = &Upgrade{} +) + +// Upgrade represents the v1.1.0 upgrade +type Upgrade struct { + mm *module.Manager + configurator module.Configurator +} + +// NewUpgrade returns a new Upgrade instance +func NewUpgrade(mm *module.Manager, configurator module.Configurator) *Upgrade { + return &Upgrade{ + mm: mm, + configurator: configurator, + } +} + +// Name implements upgrades.Upgrade +func (u *Upgrade) Name() string { + return "v1.1.0" +} + +// Handler implements upgrades.Upgrade +func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { + return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // This upgrade does not require any migration, so we can simply return the current version map + return u.mm.RunMigrations(ctx, u.configurator, fromVM) + } +} + +// StoreUpgrades implements upgrades.Upgrade +func (u *Upgrade) StoreUpgrades() *storetypes.StoreUpgrades { + return &storetypes.StoreUpgrades{ + Added: []string{ + assetstypes.ModuleName, + operatorstypes.ModuleName, + poolstypes.ModuleName, + restakingtypes.ModuleName, + rewardstypes.ModuleName, + servicestypes.ModuleName, + }, + Renamed: nil, + Deleted: nil, + } +} From a0752e1bb1700f4cba5492818ae6de5becb621d2 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 10:07:56 -0500 Subject: [PATCH 02/11] fix: add missing autocli data --- x/rewards/autocli.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/x/rewards/autocli.go b/x/rewards/autocli.go index 94670c6f..5385e493 100644 --- a/x/rewards/autocli.go +++ b/x/rewards/autocli.go @@ -93,7 +93,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, { - RpcMethod: "DelegationTotalRewards", + RpcMethod: "DelegatorTotalRewards", Use: "rewards [delegator-address]", Short: "Query all delegator rewards", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ @@ -114,6 +114,10 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Tx: &autocliv1.ServiceCommandDescriptor{ Service: rewardsv1.Msg_ServiceDesc.ServiceName, RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "CreateRewardsPlan", + Skip: true, + }, { RpcMethod: "SetWithdrawAddress", Use: "set-withdraw-addr [withdraw-address]", @@ -129,7 +133,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Example: fmt.Sprintf("%s tx rewards withdraw-rewards pool [pool-id] --from mykey", version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "delegation_type"}, - {ProtoField: "target_id"}, + {ProtoField: "delegation_target_id"}, }, }, { From 6f1fb6ff78b757ddab6e92b3e7499f6e79beeff3 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 11:18:29 -0500 Subject: [PATCH 03/11] feat: remove unused params from x/assets --- proto/milkyway/assets/v1/genesis.proto | 6 +- proto/milkyway/assets/v1/messages.proto | 30 +- proto/milkyway/assets/v1/params.proto | 7 - proto/milkyway/assets/v1/query.proto | 15 - x/assets/keeper/genesis.go | 16 +- x/assets/keeper/genesis_test.go | 12 - x/assets/keeper/grpc_query.go | 10 - x/assets/keeper/grpc_query_test.go | 45 --- x/assets/keeper/keeper.go | 2 - x/assets/keeper/msg_server.go | 22 -- x/assets/keeper/msg_server_test.go | 61 ---- x/assets/types/codec.go | 2 - x/assets/types/genesis.go | 17 +- x/assets/types/genesis.pb.go | 80 +---- x/assets/types/genesis_test.go | 1 - x/assets/types/messages.go | 22 -- x/assets/types/messages.pb.go | 453 ++---------------------- x/assets/types/params.go | 16 - x/assets/types/params.pb.go | 263 -------------- x/assets/types/query.go | 5 - x/assets/types/query.pb.go | 405 ++------------------- x/assets/types/query.pb.gw.go | 65 ---- 22 files changed, 81 insertions(+), 1474 deletions(-) delete mode 100644 proto/milkyway/assets/v1/params.proto delete mode 100644 x/assets/types/params.go delete mode 100644 x/assets/types/params.pb.go diff --git a/proto/milkyway/assets/v1/genesis.proto b/proto/milkyway/assets/v1/genesis.proto index f1ab95e1..02985b28 100644 --- a/proto/milkyway/assets/v1/genesis.proto +++ b/proto/milkyway/assets/v1/genesis.proto @@ -3,17 +3,13 @@ package milkyway.assets.v1; import "amino/amino.proto"; import "gogoproto/gogo.proto"; -import "milkyway/assets/v1/params.proto"; import "milkyway/assets/v1/models.proto"; option go_package = "github.com/milkyway-labs/milkyway/x/assets/types"; // GenesisState defines the module's genesis state. message GenesisState { - // Params defines the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; - // Assets defines the registered assets. - repeated Asset assets = 2 + repeated Asset assets = 1 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } \ No newline at end of file diff --git a/proto/milkyway/assets/v1/messages.proto b/proto/milkyway/assets/v1/messages.proto index 52a24fd4..a9c567a7 100644 --- a/proto/milkyway/assets/v1/messages.proto +++ b/proto/milkyway/assets/v1/messages.proto @@ -5,7 +5,6 @@ import "amino/amino.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; import "gogoproto/gogo.proto"; -import "milkyway/assets/v1/params.proto"; import "milkyway/assets/v1/models.proto"; option go_package = "github.com/milkyway-labs/milkyway/x/assets/types"; @@ -20,11 +19,6 @@ service Msg { // DeregisterAsset defines the operation for de-registering an asset with // its denomination. rpc DeregisterAsset(MsgDeregisterAsset) returns (MsgDeregisterAssetResponse); - - // UpdateParams defines a (governance) operation for updating the module - // parameters. - // The authority defaults to the x/gov module account. - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } // MsgRegisterAsset defines the message structure for the RegisterAsset @@ -60,26 +54,4 @@ message MsgDeregisterAsset { } // MsgRegisterAssetResponse is the return value of MsgDeregisterAsset. -message MsgDeregisterAssetResponse {} - -// MsgUpdateParams defines the message structure for the UpdateParams gRPC -// service method. It allows the authority to update the module parameters. -message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "milkyway/assets/MsgUpdateParams"; - - // Authority is the address that controls the module (defaults to x/gov unless - // overwritten). - string authority = 1 [ - (gogoproto.moretags) = "yaml:\"authority\"", - (cosmos_proto.scalar) = "cosmos.AddressString" - ]; - - // Params define the parameters to update. - // - // NOTE: All parameters must be supplied. - Params params = 2 [ (gogoproto.nullable) = false ]; -} - -// MsgUpdateParamsResponse is the return value of MsgUpdateParams. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgDeregisterAssetResponse {} \ No newline at end of file diff --git a/proto/milkyway/assets/v1/params.proto b/proto/milkyway/assets/v1/params.proto deleted file mode 100644 index 736354b6..00000000 --- a/proto/milkyway/assets/v1/params.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto3"; -package milkyway.assets.v1; - -option go_package = "github.com/milkyway-labs/milkyway/x/assets/types"; - -// Params defines the parameters for the module. -message Params {} \ No newline at end of file diff --git a/proto/milkyway/assets/v1/query.proto b/proto/milkyway/assets/v1/query.proto index 03c2f0e4..156029b3 100644 --- a/proto/milkyway/assets/v1/query.proto +++ b/proto/milkyway/assets/v1/query.proto @@ -5,19 +5,12 @@ import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -import "milkyway/assets/v1/params.proto"; import "milkyway/assets/v1/models.proto"; option go_package = "github.com/milkyway-labs/milkyway/x/assets/types"; // Query defines the gRPC querier service. service Query { - // Params defines a gRPC query method that returns the parameters of the - // module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/milkyway/assets/v1/params"; - } - // Assets defined a gRPC query method that returns all assets registered. rpc Assets(QueryAssetsRequest) returns (QueryAssetsResponse) { option (google.api.http).get = "/milkyway/assets/v1/assets"; @@ -30,14 +23,6 @@ service Query { } } -// QueryParamsRequest is the request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryParamsResponse { - Params params = 1 [ (gogoproto.nullable) = false ]; -} - // QueryAssetsRequest is the request type for the Query/Assets RPC method. message QueryAssetsRequest { // Ticker defines an optional filter parameter to query assets with the given diff --git a/x/assets/keeper/genesis.go b/x/assets/keeper/genesis.go index 6f95284a..e1d0a9b6 100644 --- a/x/assets/keeper/genesis.go +++ b/x/assets/keeper/genesis.go @@ -8,12 +8,6 @@ import ( // ExportGenesis returns the GenesisState associated with the given context func (k *Keeper) ExportGenesis(ctx sdk.Context) (*types.GenesisState, error) { - // Get the params - params, err := k.Params.Get(ctx) - if err != nil { - return nil, err - } - // Get all the assets var assets []types.Asset _ = k.Assets.Walk(ctx, nil, func(_ string, asset types.Asset) (stop bool, err error) { @@ -21,22 +15,16 @@ func (k *Keeper) ExportGenesis(ctx sdk.Context) (*types.GenesisState, error) { return false, nil }) - return types.NewGenesisState(params, assets), nil + return types.NewGenesisState(assets), nil } // -------------------------------------------------------------------------------------------------------------------- // InitGenesis initializes the state from a GenesisState func (k *Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) error { - // Store the params - err := k.Params.Set(ctx, state.Params) - if err != nil { - return err - } - // Store the assets for _, asset := range state.Assets { - err = k.SetAsset(ctx, asset) + err := k.SetAsset(ctx, asset) if err != nil { return err } diff --git a/x/assets/keeper/genesis_test.go b/x/assets/keeper/genesis_test.go index bb5157c9..ff92a3e9 100644 --- a/x/assets/keeper/genesis_test.go +++ b/x/assets/keeper/genesis_test.go @@ -13,17 +13,6 @@ func (suite *KeeperTestSuite) TestExportGenesis() { shouldErr bool expGenesis *types.GenesisState }{ - { - name: "params are exported correctly", - store: func(ctx sdk.Context) { - err := suite.keeper.Params.Set(ctx, types.DefaultParams()) - suite.Require().NoError(err) - }, - shouldErr: false, - expGenesis: &types.GenesisState{ - Params: types.DefaultParams(), - }, - }, { name: "assets are exported correctly", store: func(ctx sdk.Context) { @@ -77,7 +66,6 @@ func (suite *KeeperTestSuite) TestInitGenesis() { { name: "genesis is initialized properly", genesis: types.NewGenesisState( - types.DefaultParams(), []types.Asset{ types.NewAsset("umilk", "MILK", 6), types.NewAsset("umilk2", "MILK", 6), diff --git a/x/assets/keeper/grpc_query.go b/x/assets/keeper/grpc_query.go index 72ba4cd2..e363074b 100644 --- a/x/assets/keeper/grpc_query.go +++ b/x/assets/keeper/grpc_query.go @@ -86,13 +86,3 @@ func (q queryServer) Asset(ctx context.Context, req *types.QueryAssetRequest) (* return &types.QueryAssetResponse{Asset: asset}, nil } - -// Params queries the module params -func (q queryServer) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - params, err := q.k.Params.Get(ctx) - if err != nil { - return nil, err - } - - return &types.QueryParamsResponse{Params: params}, nil -} diff --git a/x/assets/keeper/grpc_query_test.go b/x/assets/keeper/grpc_query_test.go index c9ecd20a..486cc8ea 100644 --- a/x/assets/keeper/grpc_query_test.go +++ b/x/assets/keeper/grpc_query_test.go @@ -156,48 +156,3 @@ func (suite *KeeperTestSuite) TestQuerier_Asset() { }) } } - -func (suite *KeeperTestSuite) TestQuerier_Params() { - testCases := []struct { - name string - store func(ctx sdk.Context) - shouldErr bool - expParams types.Params - }{ - { - name: "non existing params returns empty params", - shouldErr: false, - expParams: types.Params{}, - }, - { - name: "existing params are returned properly", - store: func(ctx sdk.Context) { - err := suite.keeper.Params.Set(ctx, types.DefaultParams()) - suite.Require().NoError(err) - }, - shouldErr: false, - expParams: types.DefaultParams(), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - ctx, _ := suite.Ctx.CacheContext() - if tc.store != nil { - tc.store(ctx) - } - - queryServer := keeper.NewQueryServer(suite.keeper) - res, err := queryServer.Params(ctx, types.NewQueryParamsRequest()) - if tc.shouldErr { - suite.Require().Error(err) - } else { - suite.Require().NoError(err) - suite.Require().Equal(tc.expParams, res.Params) - } - }) - } -} diff --git a/x/assets/keeper/keeper.go b/x/assets/keeper/keeper.go index 4b8ff532..8bc26b0a 100644 --- a/x/assets/keeper/keeper.go +++ b/x/assets/keeper/keeper.go @@ -17,7 +17,6 @@ type Keeper struct { storeService corestoretypes.KVStoreService Schema collections.Schema - Params collections.Item[types.Params] Assets collections.Map[string, types.Asset] // denom => types.Asset TickerIndexes collections.KeySet[collections.Pair[string, string]] // ticker + denom => nil @@ -34,7 +33,6 @@ func NewKeeper( cdc: cdc, storeService: storeService, - Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), Assets: collections.NewMap( sb, types.AssetKeyPrefix, diff --git a/x/assets/keeper/msg_server.go b/x/assets/keeper/msg_server.go index db661da6..ff49c045 100644 --- a/x/assets/keeper/msg_server.go +++ b/x/assets/keeper/msg_server.go @@ -81,25 +81,3 @@ func (k msgServer) DeregisterAsset(ctx context.Context, msg *types.MsgDeregister return &types.MsgDeregisterAssetResponse{}, nil } - -// UpdateParams defines the rpc method for Msg/UpdateParams -func (k msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - // Validate the message - err := msg.Validate() - if err != nil { - return nil, err - } - - // Check if the authority is correct - if k.authority != msg.Authority { - return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) - } - - // Store the params - err = k.Params.Set(ctx, msg.Params) - if err != nil { - return nil, err - } - - return &types.MsgUpdateParamsResponse{}, nil -} diff --git a/x/assets/keeper/msg_server_test.go b/x/assets/keeper/msg_server_test.go index 0f85ff2a..5a796660 100644 --- a/x/assets/keeper/msg_server_test.go +++ b/x/assets/keeper/msg_server_test.go @@ -153,64 +153,3 @@ func (suite *KeeperTestSuite) TestMsgServer_DeregisterAsset() { }) } } - -func (suite *KeeperTestSuite) TestMsgServer_UpdateParams() { - testCases := []struct { - name string - setup func() - store func(ctx sdk.Context) - setupCtx func(ctx sdk.Context) sdk.Context - msg *types.MsgUpdateParams - shouldErr bool - expEvents sdk.Events - check func(ctx sdk.Context) - }{ - { - name: "invalid authority returns error", - msg: types.NewMsgUpdateParams("invalid", types.NewParams()), - shouldErr: true, - }, - { - name: "valid params are updated properly", - msg: types.NewMsgUpdateParams(suite.authority, types.NewParams()), - shouldErr: false, - check: func(ctx sdk.Context) { - // Make sure the params are stored - params, err := suite.keeper.Params.Get(ctx) - suite.Require().NoError(err) - suite.Require().Equal(types.DefaultParams(), params) - }, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - ctx, _ := suite.Ctx.CacheContext() - if tc.setup != nil { - tc.setup() - } - if tc.setupCtx != nil { - ctx = tc.setupCtx(ctx) - } - if tc.store != nil { - tc.store(ctx) - } - - msgServer := keeper.NewMsgServer(suite.keeper) - _, err := msgServer.UpdateParams(ctx, tc.msg) - if tc.shouldErr { - suite.Require().Error(err) - } else { - suite.Require().NoError(err) - for _, event := range tc.expEvents { - suite.Require().Contains(ctx.EventManager().Events(), event) - } - - if tc.check != nil { - tc.check(ctx) - } - } - }) - } -} diff --git a/x/assets/types/codec.go b/x/assets/types/codec.go index 001a0329..167ccd28 100644 --- a/x/assets/types/codec.go +++ b/x/assets/types/codec.go @@ -11,14 +11,12 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgRegisterAsset{}, "milkyway/MsgRegisterAsset") legacy.RegisterAminoMsg(cdc, &MsgDeregisterAsset{}, "milkyway/MsgDeregisterAsset") - legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "milkyway/assets/MsgUpdateParams") } func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterAsset{}, &MsgDeregisterAsset{}, - &MsgUpdateParams{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/assets/types/genesis.go b/x/assets/types/genesis.go index d6062798..82d3a235 100644 --- a/x/assets/types/genesis.go +++ b/x/assets/types/genesis.go @@ -1,35 +1,24 @@ package types -import ( - "fmt" -) - // NewGenesisState returns a new GenesisState instance -func NewGenesisState(params Params, assets []Asset) *GenesisState { +func NewGenesisState(assets []Asset) *GenesisState { return &GenesisState{ - Params: params, Assets: assets, } } // DefaultGenesis returns a default GenesisState func DefaultGenesis() *GenesisState { - return NewGenesisState(DefaultParams(), nil) + return NewGenesisState(nil) } // -------------------------------------------------------------------------------------------------------------------- // Validate validates the GenesisState and returns an error if it is invalid. func (data *GenesisState) Validate() error { - // Validate params - err := data.Params.Validate() - if err != nil { - return fmt.Errorf("invalid params: %s", err) - } - // Validate the assets for _, asset := range data.Assets { - err = asset.Validate() + err := asset.Validate() if err != nil { return err } diff --git a/x/assets/types/genesis.pb.go b/x/assets/types/genesis.pb.go index 373adb00..17c47e3e 100644 --- a/x/assets/types/genesis.pb.go +++ b/x/assets/types/genesis.pb.go @@ -26,10 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the module's genesis state. type GenesisState struct { - // Params defines the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` // Assets defines the registered assets. - Assets []Asset `protobuf:"bytes,2,rep,name=assets,proto3" json:"assets"` + Assets []Asset `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -65,13 +63,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - func (m *GenesisState) GetAssets() []Asset { if m != nil { return m.Assets @@ -86,23 +77,21 @@ func init() { func init() { proto.RegisterFile("milkyway/assets/v1/genesis.proto", fileDescriptor_f17ee47d995cb1cb) } var fileDescriptor_f17ee47d995cb1cb = []byte{ - // 250 bytes of a gzipped FileDescriptorProto + // 214 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0xcd, 0xcc, 0xc9, 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xa9, 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, 0xd7, 0x07, 0x93, 0x10, 0x65, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, 0x88, 0x05, 0x15, 0x95, 0xc7, - 0x62, 0x7c, 0x41, 0x62, 0x51, 0x62, 0x6e, 0x31, 0x1e, 0x05, 0xb9, 0xf9, 0x29, 0xa9, 0x39, 0x50, - 0x05, 0x4a, 0x6d, 0x8c, 0x5c, 0x3c, 0xee, 0x10, 0x07, 0x05, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x59, - 0x70, 0xb1, 0x41, 0x4c, 0x90, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd2, 0xc3, 0x74, 0xa0, - 0x5e, 0x00, 0x58, 0x85, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, 0x50, 0xf5, 0x42, 0x36, 0x5c, - 0x6c, 0x10, 0x15, 0x12, 0x4c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x92, 0xd8, 0x74, 0x3a, 0x82, 0x58, - 0x4e, 0x9c, 0x20, 0x8d, 0x2b, 0x9e, 0x6f, 0xd0, 0x62, 0x0c, 0x82, 0xea, 0x71, 0xf2, 0x3a, 0xf1, - 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, - 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x83, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, - 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x98, 0x89, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x70, 0x9e, 0x7e, 0x05, - 0xcc, 0x7b, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xbf, 0x19, 0x03, 0x02, 0x00, 0x00, - 0xff, 0xff, 0x0a, 0xd4, 0x32, 0xce, 0x7e, 0x01, 0x00, 0x00, + 0x62, 0x7c, 0x6e, 0x7e, 0x4a, 0x6a, 0x0e, 0xd4, 0x74, 0x25, 0x1f, 0x2e, 0x1e, 0x77, 0x88, 0x75, + 0xc1, 0x25, 0x89, 0x25, 0xa9, 0x42, 0x36, 0x5c, 0x6c, 0x10, 0x95, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, + 0xdc, 0x46, 0x92, 0x7a, 0x98, 0xd6, 0xeb, 0x39, 0x82, 0x58, 0x4e, 0x9c, 0x27, 0xee, 0xc9, 0x33, + 0xac, 0x78, 0xbe, 0x41, 0x8b, 0x31, 0x08, 0xaa, 0xc7, 0xc9, 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, + 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, + 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, + 0xf5, 0x61, 0x26, 0xea, 0xe6, 0x24, 0x26, 0x15, 0xc3, 0x79, 0xfa, 0x15, 0x30, 0x37, 0x96, 0x54, + 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x1d, 0x68, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x54, + 0xa6, 0x3b, 0x22, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -136,19 +125,9 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + dAtA[i] = 0xa } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -169,8 +148,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) if len(m.Assets) > 0 { for _, e := range m.Assets { l = e.Size() @@ -216,39 +193,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Assets", wireType) } diff --git a/x/assets/types/genesis_test.go b/x/assets/types/genesis_test.go index 2443863d..3250534e 100644 --- a/x/assets/types/genesis_test.go +++ b/x/assets/types/genesis_test.go @@ -22,7 +22,6 @@ func TestGenesis_Validate(t *testing.T) { { name: "invalid asset returns error", genesis: types.NewGenesisState( - types.DefaultParams(), []types.Asset{ types.NewAsset("@#$%", "bitcoin", 1), }, diff --git a/x/assets/types/messages.go b/x/assets/types/messages.go index 144e0f5a..61b1acef 100644 --- a/x/assets/types/messages.go +++ b/x/assets/types/messages.go @@ -9,7 +9,6 @@ import ( var ( _ sdk.Msg = &MsgRegisterAsset{} _ sdk.Msg = &MsgDeregisterAsset{} - _ sdk.Msg = &MsgUpdateParams{} ) // NewMsgRegisterAsset creates a new MsgRegisterAsset instance @@ -55,24 +54,3 @@ func (msg *MsgDeregisterAsset) Validate() error { } return nil } - -// NewMsgUpdateParams creates a new MsgUpdateParams instance -func NewMsgUpdateParams(authority string, params Params) *MsgUpdateParams { - return &MsgUpdateParams{ - Authority: authority, - Params: params, - } -} - -// Validate validates the MsgUpdateParams instance -func (msg *MsgUpdateParams) Validate() error { - _, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address") - } - err = msg.Params.Validate() - if err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid params: %s", err) - } - return nil -} diff --git a/x/assets/types/messages.pb.go b/x/assets/types/messages.pb.go index 115b8aaa..bef3bf00 100644 --- a/x/assets/types/messages.pb.go +++ b/x/assets/types/messages.pb.go @@ -220,147 +220,44 @@ func (m *MsgDeregisterAssetResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDeregisterAssetResponse proto.InternalMessageInfo -// MsgUpdateParams defines the message structure for the UpdateParams gRPC -// service method. It allows the authority to update the module parameters. -type MsgUpdateParams struct { - // Authority is the address that controls the module (defaults to x/gov unless - // overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` - // Params define the parameters to update. - // - // NOTE: All parameters must be supplied. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_fa7f7c938a129c02, []int{4} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateParams) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// MsgUpdateParamsResponse is the return value of MsgUpdateParams. -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fa7f7c938a129c02, []int{5} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - func init() { proto.RegisterType((*MsgRegisterAsset)(nil), "milkyway.assets.v1.MsgRegisterAsset") proto.RegisterType((*MsgRegisterAssetResponse)(nil), "milkyway.assets.v1.MsgRegisterAssetResponse") proto.RegisterType((*MsgDeregisterAsset)(nil), "milkyway.assets.v1.MsgDeregisterAsset") proto.RegisterType((*MsgDeregisterAssetResponse)(nil), "milkyway.assets.v1.MsgDeregisterAssetResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "milkyway.assets.v1.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "milkyway.assets.v1.MsgUpdateParamsResponse") } func init() { proto.RegisterFile("milkyway/assets/v1/messages.proto", fileDescriptor_fa7f7c938a129c02) } var fileDescriptor_fa7f7c938a129c02 = []byte{ - // 510 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x73, 0x85, 0x54, 0xca, 0x01, 0x6a, 0xb1, 0x22, 0x35, 0x39, 0x90, 0x53, 0x0c, 0x42, - 0x55, 0x48, 0x6d, 0x1a, 0x04, 0x42, 0xd9, 0x1a, 0x31, 0x55, 0x8a, 0x84, 0x8c, 0x58, 0x58, 0xe0, - 0x12, 0x9f, 0xae, 0x16, 0xb9, 0x9c, 0xe5, 0x77, 0x2d, 0x78, 0x43, 0x8c, 0x4c, 0x88, 0x2f, 0x42, - 0x06, 0x66, 0xe6, 0x4a, 0x2c, 0x15, 0x13, 0x53, 0x85, 0x92, 0x21, 0x3b, 0x9f, 0x00, 0xd5, 0x67, - 0xbb, 0xad, 0x9d, 0x22, 0x0f, 0x2c, 0x96, 0xdf, 0xbb, 0xdf, 0xbd, 0xf7, 0x7f, 0xfe, 0x3f, 0xe3, - 0x3b, 0xc2, 0x1f, 0xbf, 0x8d, 0xde, 0xd1, 0xc8, 0xa1, 0x00, 0x4c, 0x81, 0x73, 0xb8, 0xe3, 0x08, - 0x06, 0x40, 0x39, 0x03, 0x3b, 0x08, 0xa5, 0x92, 0x86, 0x91, 0x22, 0xb6, 0x46, 0xec, 0xc3, 0x1d, - 0x72, 0x93, 0x0a, 0x7f, 0x22, 0x9d, 0xf8, 0xa9, 0x31, 0xd2, 0x1c, 0x49, 0x10, 0x12, 0x5e, 0xc7, - 0x91, 0xa3, 0x83, 0xe4, 0x68, 0x43, 0x47, 0x8e, 0x00, 0x1e, 0xd7, 0x07, 0x9e, 0x1c, 0xd4, 0xb9, - 0xe4, 0x52, 0x5f, 0x38, 0x7d, 0x4b, 0xb2, 0xad, 0x25, 0x9a, 0x02, 0x1a, 0x52, 0x01, 0xff, 0x00, - 0x84, 0xf4, 0xd8, 0x38, 0x01, 0xac, 0xaf, 0x08, 0xaf, 0x0f, 0x80, 0xbb, 0x8c, 0xfb, 0xa0, 0x58, - 0xb8, 0x7b, 0x4a, 0x19, 0x4f, 0x70, 0x8d, 0x1e, 0xa8, 0x7d, 0x19, 0xfa, 0x2a, 0x6a, 0xa0, 0x4d, - 0xb4, 0x55, 0xeb, 0x37, 0x7e, 0x7e, 0xdb, 0xae, 0x27, 0x52, 0x77, 0x3d, 0x2f, 0x64, 0x00, 0x2f, - 0x54, 0xe8, 0x4f, 0xb8, 0x7b, 0x86, 0x1a, 0x8f, 0x71, 0x35, 0x6e, 0xd3, 0x58, 0xd9, 0x44, 0x5b, - 0xd7, 0xba, 0x4d, 0xbb, 0xf8, 0x3d, 0xec, 0xb8, 0x43, 0xff, 0xea, 0xd1, 0x49, 0xab, 0xe2, 0x6a, - 0xba, 0xd7, 0xf9, 0xb8, 0x98, 0xb6, 0xcf, 0xca, 0x7c, 0x5a, 0x4c, 0xdb, 0xcd, 0x4c, 0x77, 0x5e, - 0x9c, 0x45, 0x70, 0x23, 0x9f, 0x73, 0x19, 0x04, 0x72, 0x02, 0xcc, 0xfa, 0x82, 0xb0, 0x31, 0x00, - 0xfe, 0x8c, 0x85, 0xff, 0x65, 0x9e, 0x3a, 0xae, 0x7a, 0x6c, 0x22, 0x45, 0x3c, 0x4f, 0xcd, 0xd5, - 0x41, 0xcf, 0x2e, 0xca, 0xbd, 0x75, 0x5e, 0x6e, 0xae, 0xbb, 0x75, 0x1b, 0x93, 0x62, 0x36, 0x93, - 0xfc, 0x03, 0xe1, 0xb5, 0x01, 0xf0, 0x97, 0x81, 0x47, 0x15, 0x7b, 0x1e, 0x7b, 0x67, 0xec, 0x15, - 0xf5, 0x76, 0xfe, 0x9c, 0xb4, 0xd6, 0x23, 0x2a, 0xc6, 0x3d, 0x2b, 0x3b, 0xb2, 0xca, 0xcc, 0xf0, - 0x14, 0xaf, 0xea, 0x8d, 0x48, 0x4c, 0x21, 0xcb, 0x4c, 0xd1, 0x7d, 0x13, 0x57, 0x12, 0xbe, 0xd7, - 0x2d, 0xce, 0x59, 0x58, 0xa7, 0x9c, 0x72, 0xab, 0x89, 0x37, 0x72, 0xa9, 0x74, 0xd0, 0xee, 0xf7, - 0x15, 0x7c, 0x65, 0x00, 0xdc, 0x18, 0xe1, 0x1b, 0x17, 0xb7, 0xed, 0xde, 0x32, 0x45, 0x79, 0x8b, - 0x49, 0xa7, 0x0c, 0x95, 0x36, 0x33, 0x7c, 0xbc, 0x96, 0x5f, 0x82, 0xfb, 0x97, 0x14, 0xc8, 0x71, - 0xc4, 0x2e, 0xc7, 0x65, 0xad, 0xde, 0xe0, 0xeb, 0x17, 0xcc, 0xbb, 0x7b, 0xc9, 0xfd, 0xf3, 0x10, - 0x79, 0x50, 0x02, 0x4a, 0x3b, 0x90, 0xea, 0x87, 0xc5, 0xb4, 0x8d, 0xfa, 0x7b, 0x47, 0x33, 0x13, - 0x1d, 0xcf, 0x4c, 0xf4, 0x7b, 0x66, 0xa2, 0xcf, 0x73, 0xb3, 0x72, 0x3c, 0x37, 0x2b, 0xbf, 0xe6, - 0x66, 0xe5, 0xd5, 0x43, 0xee, 0xab, 0xfd, 0x83, 0xa1, 0x3d, 0x92, 0xc2, 0x49, 0xeb, 0x6e, 0x8f, - 0xe9, 0x10, 0xb2, 0xc8, 0x79, 0x9f, 0x3a, 0xa6, 0xa2, 0x80, 0xc1, 0x70, 0x35, 0xfe, 0xfb, 0x1f, - 0xfd, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xc1, 0xb6, 0xbd, 0xd5, 0x04, 0x00, 0x00, + // 417 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0xcd, 0xcc, 0xc9, + 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, + 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, + 0x29, 0xd1, 0x83, 0x28, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, 0xd7, 0x07, + 0x93, 0x10, 0x65, 0x52, 0x92, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0x60, 0x9e, 0x3e, 0x84, + 0x03, 0x95, 0x12, 0x87, 0xf0, 0xf4, 0x73, 0x8b, 0xd3, 0xc1, 0xe6, 0x17, 0xa7, 0x43, 0x25, 0x44, + 0xd2, 0xf3, 0xd3, 0xf3, 0x21, 0x1a, 0x40, 0x2c, 0xa8, 0xa8, 0x3c, 0x36, 0x37, 0xe5, 0xa7, 0xa4, + 0xe6, 0x40, 0xcd, 0x53, 0x5a, 0xcf, 0xc8, 0x25, 0xe0, 0x5b, 0x9c, 0x1e, 0x94, 0x9a, 0x9e, 0x59, + 0x5c, 0x92, 0x5a, 0xe4, 0x08, 0x52, 0x25, 0x64, 0xc6, 0xc5, 0x99, 0x58, 0x5a, 0x92, 0x91, 0x5f, + 0x94, 0x59, 0x52, 0x29, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0x71, 0x69, 0x8b, 0xae, 0x08, + 0xd4, 0x25, 0x8e, 0x29, 0x29, 0x45, 0xa9, 0xc5, 0xc5, 0xc1, 0x25, 0x45, 0x99, 0x79, 0xe9, 0x41, + 0x08, 0xa5, 0x42, 0xa6, 0x5c, 0xac, 0x60, 0x6b, 0x24, 0x98, 0x14, 0x18, 0x35, 0xb8, 0x8d, 0x24, + 0xf5, 0x30, 0xbd, 0xab, 0x07, 0xb6, 0xc1, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x88, 0x6a, + 0x2b, 0x9d, 0xa6, 0xe7, 0x1b, 0xb4, 0x10, 0xc6, 0x74, 0x3d, 0xdf, 0xa0, 0x25, 0x09, 0x77, 0x37, + 0xba, 0xe3, 0x94, 0xa4, 0xb8, 0x24, 0xd0, 0xc5, 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, + 0x95, 0x26, 0x31, 0x72, 0x09, 0xf9, 0x16, 0xa7, 0xbb, 0xa4, 0x16, 0x51, 0xc5, 0x3f, 0x22, 0x5c, + 0xac, 0x29, 0xa9, 0x79, 0xf9, 0xb9, 0x60, 0xff, 0x70, 0x06, 0x41, 0x38, 0x56, 0x7a, 0x98, 0xce, + 0x95, 0x46, 0x76, 0x2e, 0x9a, 0xed, 0x4a, 0x32, 0x5c, 0x52, 0x98, 0xa2, 0x30, 0x27, 0x1b, 0xdd, + 0x61, 0xe4, 0x62, 0xf6, 0x2d, 0x4e, 0x17, 0x4a, 0xe6, 0xe2, 0x45, 0x8d, 0x04, 0x15, 0x6c, 0xa1, + 0x87, 0xee, 0x73, 0x29, 0x1d, 0x62, 0x54, 0xc1, 0x2c, 0x13, 0xca, 0xe4, 0xe2, 0x47, 0x0f, 0x1b, + 0x35, 0x1c, 0x06, 0xa0, 0xa9, 0x93, 0xd2, 0x23, 0x4e, 0x1d, 0xcc, 0x2a, 0x29, 0xd6, 0x86, 0xe7, + 0x1b, 0xb4, 0x18, 0x9d, 0xbc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, + 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, + 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x66, 0xb4, 0x6e, 0x4e, + 0x62, 0x52, 0x31, 0x9c, 0xa7, 0x5f, 0x01, 0x4b, 0xb5, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, + 0xe0, 0x24, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x52, 0xce, 0xd2, 0xba, 0x69, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -380,10 +277,6 @@ type MsgClient interface { // DeregisterAsset defines the operation for de-registering an asset with // its denomination. DeregisterAsset(ctx context.Context, in *MsgDeregisterAsset, opts ...grpc.CallOption) (*MsgDeregisterAssetResponse, error) - // UpdateParams defines a (governance) operation for updating the module - // parameters. - // The authority defaults to the x/gov module account. - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -412,15 +305,6 @@ func (c *msgClient) DeregisterAsset(ctx context.Context, in *MsgDeregisterAsset, return out, nil } -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/milkyway.assets.v1.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. type MsgServer interface { // RegisterAsset defines the operation for registering an asset. @@ -428,10 +312,6 @@ type MsgServer interface { // DeregisterAsset defines the operation for de-registering an asset with // its denomination. DeregisterAsset(context.Context, *MsgDeregisterAsset) (*MsgDeregisterAssetResponse, error) - // UpdateParams defines a (governance) operation for updating the module - // parameters. - // The authority defaults to the x/gov module account. - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -444,9 +324,6 @@ func (*UnimplementedMsgServer) RegisterAsset(ctx context.Context, req *MsgRegist func (*UnimplementedMsgServer) DeregisterAsset(ctx context.Context, req *MsgDeregisterAsset) (*MsgDeregisterAssetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeregisterAsset not implemented") } -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -488,24 +365,6 @@ func _Msg_DeregisterAsset_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/milkyway.assets.v1.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "milkyway.assets.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -518,10 +377,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "DeregisterAsset", Handler: _Msg_DeregisterAsset_Handler, }, - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "milkyway/assets/v1/messages.proto", @@ -650,69 +505,6 @@ func (m *MsgDeregisterAssetResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMessages(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintMessages(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { offset -= sovMessages(v) base := offset @@ -774,30 +566,6 @@ func (m *MsgDeregisterAssetResponse) Size() (n int) { return n } -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovMessages(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func sovMessages(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1133,171 +901,6 @@ func (m *MsgDeregisterAssetResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMessages - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMessages - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMessages - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMessages(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessages - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessages - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipMessages(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessages - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipMessages(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/assets/types/params.go b/x/assets/types/params.go deleted file mode 100644 index 52fec7b8..00000000 --- a/x/assets/types/params.go +++ /dev/null @@ -1,16 +0,0 @@ -package types - -// NewParams creates a new Params object -func NewParams() Params { - return Params{} -} - -// DefaultParams returns a default set of parameters. -func DefaultParams() Params { - return NewParams() -} - -// Validate checks that the parameters have valid values. -func (p *Params) Validate() error { - return nil -} diff --git a/x/assets/types/params.pb.go b/x/assets/types/params.pb.go deleted file mode 100644 index 35cab0e2..00000000 --- a/x/assets/types/params.pb.go +++ /dev/null @@ -1,263 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: milkyway/assets/v1/params.proto - -package types - -import ( - fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params defines the parameters for the module. -type Params struct { -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_7ba69d80af27885a, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Params)(nil), "milkyway.assets.v1.Params") -} - -func init() { proto.RegisterFile("milkyway/assets/v1/params.proto", fileDescriptor_7ba69d80af27885a) } - -var fileDescriptor_7ba69d80af27885a = []byte{ - // 138 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0xcd, 0xcc, 0xc9, - 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, - 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x29, 0xd0, - 0x83, 0x28, 0xd0, 0x2b, 0x33, 0x54, 0xe2, 0xe0, 0x62, 0x0b, 0x00, 0xab, 0x71, 0xf2, 0x3a, 0xf1, - 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, - 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x83, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, - 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x98, 0x11, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x70, 0x9e, 0x7e, 0x05, - 0xcc, 0xce, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x85, 0xc6, 0x80, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x9c, 0x38, 0x96, 0x6c, 0x93, 0x00, 0x00, 0x00, -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/assets/types/query.go b/x/assets/types/query.go index 50a82214..217dd126 100644 --- a/x/assets/types/query.go +++ b/x/assets/types/query.go @@ -13,8 +13,3 @@ func NewQueryAssetsRequest(ticker string, pagination *query.PageRequest) *QueryA func NewQueryAssetRequest(denom string) *QueryAssetRequest { return &QueryAssetRequest{Denom: denom} } - -// NewQueryParamsRequest creates a new instance of QueryParamsRequest -func NewQueryParamsRequest() *QueryParamsRequest { - return &QueryParamsRequest{} -} diff --git a/x/assets/types/query.pb.go b/x/assets/types/query.pb.go index 8232c924..258afa15 100644 --- a/x/assets/types/query.pb.go +++ b/x/assets/types/query.pb.go @@ -31,88 +31,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryParamsRequest is the request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2d64a9f39441c4d1, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is the response type for the Query/Params RPC method. -type QueryParamsResponse struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2d64a9f39441c4d1, []int{1} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - // QueryAssetsRequest is the request type for the Query/Assets RPC method. type QueryAssetsRequest struct { // Ticker defines an optional filter parameter to query assets with the given @@ -126,7 +44,7 @@ func (m *QueryAssetsRequest) Reset() { *m = QueryAssetsRequest{} } func (m *QueryAssetsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAssetsRequest) ProtoMessage() {} func (*QueryAssetsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2d64a9f39441c4d1, []int{2} + return fileDescriptor_2d64a9f39441c4d1, []int{0} } func (m *QueryAssetsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -181,7 +99,7 @@ func (m *QueryAssetsResponse) Reset() { *m = QueryAssetsResponse{} } func (m *QueryAssetsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAssetsResponse) ProtoMessage() {} func (*QueryAssetsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2d64a9f39441c4d1, []int{3} + return fileDescriptor_2d64a9f39441c4d1, []int{1} } func (m *QueryAssetsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -234,7 +152,7 @@ func (m *QueryAssetRequest) Reset() { *m = QueryAssetRequest{} } func (m *QueryAssetRequest) String() string { return proto.CompactTextString(m) } func (*QueryAssetRequest) ProtoMessage() {} func (*QueryAssetRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2d64a9f39441c4d1, []int{4} + return fileDescriptor_2d64a9f39441c4d1, []int{2} } func (m *QueryAssetRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +198,7 @@ func (m *QueryAssetResponse) Reset() { *m = QueryAssetResponse{} } func (m *QueryAssetResponse) String() string { return proto.CompactTextString(m) } func (*QueryAssetResponse) ProtoMessage() {} func (*QueryAssetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2d64a9f39441c4d1, []int{5} + return fileDescriptor_2d64a9f39441c4d1, []int{3} } func (m *QueryAssetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -317,8 +235,6 @@ func (m *QueryAssetResponse) GetAsset() Asset { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "milkyway.assets.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "milkyway.assets.v1.QueryParamsResponse") proto.RegisterType((*QueryAssetsRequest)(nil), "milkyway.assets.v1.QueryAssetsRequest") proto.RegisterType((*QueryAssetsResponse)(nil), "milkyway.assets.v1.QueryAssetsResponse") proto.RegisterType((*QueryAssetRequest)(nil), "milkyway.assets.v1.QueryAssetRequest") @@ -328,40 +244,36 @@ func init() { func init() { proto.RegisterFile("milkyway/assets/v1/query.proto", fileDescriptor_2d64a9f39441c4d1) } var fileDescriptor_2d64a9f39441c4d1 = []byte{ - // 515 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xbf, 0x6f, 0xd3, 0x40, - 0x18, 0xcd, 0xb5, 0xc4, 0x52, 0xaf, 0x53, 0x8f, 0x08, 0x05, 0xab, 0x72, 0xab, 0x13, 0xa4, 0x25, - 0x12, 0x77, 0x24, 0x08, 0x89, 0x81, 0x85, 0x0c, 0x20, 0xc1, 0x40, 0xf1, 0xc8, 0x76, 0x4e, 0x4f, - 0xc6, 0x6a, 0xec, 0x73, 0x73, 0x97, 0x40, 0x84, 0xba, 0x74, 0x64, 0x42, 0x62, 0xe5, 0x0f, 0x60, - 0xe4, 0xcf, 0xe8, 0x58, 0x89, 0x85, 0x09, 0xa1, 0x04, 0x89, 0x7f, 0x03, 0xf9, 0xee, 0x73, 0xd3, - 0xa8, 0x89, 0xb3, 0x58, 0xf7, 0xe3, 0x7d, 0xef, 0xbd, 0xef, 0x7b, 0x67, 0x1c, 0xa4, 0xc9, 0xe0, - 0x64, 0xf2, 0x41, 0x4c, 0xb8, 0xd0, 0x5a, 0x1a, 0xcd, 0xc7, 0x1d, 0x7e, 0x3a, 0x92, 0xc3, 0x09, - 0xcb, 0x87, 0xca, 0x28, 0x42, 0xca, 0x7b, 0xe6, 0xee, 0xd9, 0xb8, 0xe3, 0xef, 0x88, 0x34, 0xc9, - 0x14, 0xb7, 0x5f, 0x07, 0xf3, 0x1b, 0xb1, 0x8a, 0x95, 0x5d, 0xf2, 0x62, 0x05, 0xa7, 0xbb, 0xb1, - 0x52, 0xf1, 0x40, 0x72, 0x91, 0x27, 0x5c, 0x64, 0x99, 0x32, 0xc2, 0x24, 0x2a, 0xd3, 0x70, 0xdb, - 0xee, 0x2b, 0x9d, 0x2a, 0xcd, 0x23, 0xa1, 0xa5, 0xd3, 0xe4, 0xe3, 0x4e, 0x24, 0x8d, 0xe8, 0xf0, - 0x5c, 0xc4, 0x49, 0x66, 0xc1, 0x80, 0xdd, 0x5b, 0x62, 0x33, 0x17, 0x43, 0x91, 0xea, 0x0a, 0x40, - 0xaa, 0x8e, 0xe5, 0x00, 0x00, 0xb4, 0x81, 0xc9, 0xdb, 0x42, 0xe3, 0xc8, 0x56, 0x85, 0xf2, 0x74, - 0x24, 0xb5, 0xa1, 0x6f, 0xf0, 0xed, 0x85, 0x53, 0x9d, 0xab, 0x4c, 0x4b, 0xf2, 0x14, 0x7b, 0x8e, - 0xbd, 0x89, 0xf6, 0xd1, 0xe1, 0x76, 0xd7, 0x67, 0x37, 0xc7, 0xc0, 0x5c, 0x4d, 0xef, 0xd6, 0xc5, - 0xef, 0xbd, 0x5a, 0x08, 0x78, 0x6a, 0x40, 0xe6, 0xb9, 0x85, 0x81, 0x0c, 0xb9, 0x83, 0x3d, 0x93, - 0xf4, 0x4f, 0xe4, 0xd0, 0xf2, 0x6d, 0x85, 0xb0, 0x23, 0x2f, 0x30, 0x9e, 0xb7, 0xda, 0xdc, 0xb0, - 0x5a, 0x2d, 0xe6, 0xe6, 0xc2, 0x8a, 0xb9, 0x30, 0x97, 0x05, 0xcc, 0x85, 0x1d, 0x89, 0x58, 0x02, - 0x67, 0x78, 0xad, 0x92, 0x7e, 0x43, 0xd0, 0x47, 0x29, 0x0b, 0x7d, 0x3c, 0xc3, 0x9e, 0xf3, 0xdb, - 0x44, 0xfb, 0x9b, 0x87, 0xdb, 0xdd, 0xbb, 0xcb, 0xfa, 0xb0, 0x35, 0xbd, 0xad, 0xa2, 0x8d, 0xef, - 0xff, 0x7e, 0xb4, 0x51, 0x08, 0x35, 0xe4, 0xe5, 0x12, 0x77, 0x07, 0x6b, 0xdd, 0x39, 0xe9, 0x05, - 0x7b, 0x0f, 0xf0, 0xce, 0xdc, 0x5d, 0x39, 0x93, 0x06, 0xae, 0x1f, 0xcb, 0x4c, 0xa5, 0x30, 0x12, - 0xb7, 0xa1, 0xaf, 0xaf, 0xcf, 0xef, 0xaa, 0x8f, 0x27, 0xb8, 0x6e, 0x3d, 0x41, 0x1c, 0x15, 0x6d, - 0xb8, 0x34, 0x1c, 0xba, 0xfb, 0x79, 0x13, 0xd7, 0x2d, 0x1b, 0x39, 0xc3, 0x9e, 0x8b, 0x8b, 0xb4, - 0x96, 0xd5, 0xde, 0x7c, 0x19, 0xfe, 0xc1, 0x5a, 0x9c, 0xf3, 0x46, 0xe9, 0xf9, 0xcf, 0xbf, 0x5f, - 0x37, 0x76, 0x89, 0xcf, 0x57, 0xbe, 0xd1, 0x42, 0xde, 0x25, 0x53, 0x21, 0xbf, 0xf0, 0x62, 0x2a, - 0xe4, 0x17, 0x23, 0xae, 0x96, 0x87, 0x20, 0xcf, 0x11, 0xae, 0xdb, 0x32, 0x72, 0xbf, 0x9a, 0xb6, - 0x54, 0x6f, 0xad, 0x83, 0x81, 0x78, 0xdb, 0x8a, 0xdf, 0x23, 0x74, 0xb5, 0x38, 0xff, 0x64, 0x83, - 0x3d, 0xeb, 0xbd, 0xba, 0x98, 0x06, 0xe8, 0x72, 0x1a, 0xa0, 0x3f, 0xd3, 0x00, 0x7d, 0x99, 0x05, - 0xb5, 0xcb, 0x59, 0x50, 0xfb, 0x35, 0x0b, 0x6a, 0xef, 0x1e, 0xc5, 0x89, 0x79, 0x3f, 0x8a, 0x58, - 0x5f, 0xa5, 0x57, 0x3c, 0x0f, 0x07, 0x22, 0xd2, 0x73, 0xd6, 0x8f, 0x25, 0x9b, 0x99, 0xe4, 0x52, - 0x47, 0x9e, 0xfd, 0xa7, 0x1f, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x1c, 0xb7, 0xe0, 0xbe, - 0x04, 0x00, 0x00, + // 458 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x3d, 0x8f, 0xd3, 0x30, + 0x18, 0x8e, 0x0b, 0x89, 0x74, 0xbe, 0xe9, 0xcc, 0x09, 0x95, 0xe8, 0x94, 0xab, 0x22, 0xe8, 0x95, + 0x4a, 0xd8, 0xa4, 0x88, 0x8d, 0x85, 0x1b, 0x40, 0x82, 0x05, 0x32, 0xb2, 0x39, 0x3d, 0x2b, 0x44, + 0x97, 0xc4, 0xb9, 0xda, 0x2d, 0x44, 0xe8, 0x96, 0x5b, 0x59, 0x90, 0x58, 0xf9, 0x01, 0x8c, 0xfc, + 0x8c, 0x1b, 0x2b, 0xb1, 0x30, 0x21, 0xd4, 0x22, 0xf1, 0x37, 0x50, 0x6c, 0xa7, 0x1f, 0x6a, 0xae, + 0x5d, 0x2a, 0xbb, 0xef, 0xf3, 0xf5, 0x3e, 0x31, 0xf4, 0xb2, 0x24, 0x3d, 0x2f, 0x3f, 0xd0, 0x92, + 0x50, 0x21, 0x98, 0x14, 0x64, 0x12, 0x90, 0x8b, 0x31, 0x1b, 0x95, 0xb8, 0x18, 0x71, 0xc9, 0x11, + 0xaa, 0xe7, 0x58, 0xcf, 0xf1, 0x24, 0x70, 0x0f, 0x68, 0x96, 0xe4, 0x9c, 0xa8, 0x5f, 0x0d, 0x73, + 0x0f, 0x63, 0x1e, 0x73, 0x75, 0x24, 0xd5, 0xc9, 0xfc, 0x7b, 0x14, 0x73, 0x1e, 0xa7, 0x8c, 0xd0, + 0x22, 0x21, 0x34, 0xcf, 0xb9, 0xa4, 0x32, 0xe1, 0xb9, 0x30, 0xd3, 0xfe, 0x90, 0x8b, 0x8c, 0x0b, + 0x12, 0x51, 0xc1, 0xb4, 0x27, 0x99, 0x04, 0x11, 0x93, 0x34, 0x20, 0x05, 0x8d, 0x93, 0x5c, 0x81, + 0x0d, 0xf6, 0xb8, 0x21, 0x66, 0xc6, 0xcf, 0x58, 0x6a, 0xc4, 0x7c, 0x09, 0xd1, 0xdb, 0x4a, 0xe2, + 0xb9, 0x1a, 0x87, 0xec, 0x62, 0xcc, 0x84, 0x44, 0x77, 0xa1, 0x23, 0x93, 0xe1, 0x39, 0x1b, 0xb5, + 0x41, 0x07, 0xf4, 0xf6, 0x42, 0x73, 0x43, 0x2f, 0x20, 0x5c, 0x5a, 0xb4, 0x5b, 0x1d, 0xd0, 0xdb, + 0x1f, 0x74, 0xb1, 0xce, 0x83, 0xab, 0x3c, 0x58, 0x77, 0x60, 0xf2, 0xe0, 0x37, 0x34, 0x66, 0x46, + 0x33, 0x5c, 0x61, 0xfa, 0xdf, 0x00, 0xbc, 0xb3, 0x66, 0x2b, 0x0a, 0x9e, 0x0b, 0x86, 0x9e, 0x41, + 0x47, 0xe7, 0x6c, 0x83, 0xce, 0xad, 0xde, 0xfe, 0xe0, 0x1e, 0xde, 0xac, 0x11, 0x2b, 0xce, 0xe9, + 0xde, 0xf5, 0xef, 0x63, 0xeb, 0xfb, 0xbf, 0x1f, 0x7d, 0x10, 0x1a, 0x0e, 0x7a, 0xd9, 0x90, 0xee, + 0x64, 0x67, 0x3a, 0x6d, 0xbd, 0x16, 0xef, 0x21, 0x3c, 0x58, 0xa6, 0xab, 0x3b, 0x39, 0x84, 0xf6, + 0x19, 0xcb, 0x79, 0x66, 0x2a, 0xd1, 0x17, 0xff, 0xf5, 0x6a, 0x7f, 0x8b, 0x3d, 0x9e, 0x42, 0x5b, + 0x65, 0x52, 0xd8, 0xad, 0x6b, 0xdc, 0xae, 0xd6, 0x08, 0x35, 0x7a, 0xf0, 0xb9, 0x05, 0x6d, 0xa5, + 0x86, 0x2e, 0xa1, 0xa3, 0xab, 0x41, 0xdd, 0x26, 0xee, 0xe6, 0x27, 0x73, 0x4f, 0x76, 0xe2, 0x74, + 0x36, 0xdf, 0xbf, 0xfa, 0xf9, 0xf7, 0x6b, 0xeb, 0x08, 0xb9, 0xa4, 0xe1, 0x6d, 0x98, 0x26, 0xaf, + 0x00, 0xb4, 0x15, 0x0d, 0x3d, 0xd8, 0x2e, 0x5b, 0xbb, 0x77, 0x77, 0xc1, 0x8c, 0x79, 0x5f, 0x99, + 0xdf, 0x47, 0xfe, 0xcd, 0xe6, 0xe4, 0x93, 0x6a, 0xf6, 0xf2, 0xf4, 0xd5, 0xf5, 0xcc, 0x03, 0xd3, + 0x99, 0x07, 0xfe, 0xcc, 0x3c, 0xf0, 0x65, 0xee, 0x59, 0xd3, 0xb9, 0x67, 0xfd, 0x9a, 0x7b, 0xd6, + 0xbb, 0xc7, 0x71, 0x22, 0xdf, 0x8f, 0x23, 0x3c, 0xe4, 0xd9, 0x42, 0xe7, 0x51, 0x4a, 0x23, 0xb1, + 0x54, 0xfd, 0x58, 0xab, 0xc9, 0xb2, 0x60, 0x22, 0x72, 0xd4, 0x6b, 0x7f, 0xf2, 0x3f, 0x00, 0x00, + 0xff, 0xff, 0xac, 0x59, 0x73, 0xbb, 0xb7, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -376,9 +288,6 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Params defines a gRPC query method that returns the parameters of the - // module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // Assets defined a gRPC query method that returns all assets registered. Assets(ctx context.Context, in *QueryAssetsRequest, opts ...grpc.CallOption) (*QueryAssetsResponse, error) // Asset defines a gRPC query method that returns the asset associated with @@ -394,15 +303,6 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/milkyway.assets.v1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) Assets(ctx context.Context, in *QueryAssetsRequest, opts ...grpc.CallOption) (*QueryAssetsResponse, error) { out := new(QueryAssetsResponse) err := c.cc.Invoke(ctx, "/milkyway.assets.v1.Query/Assets", in, out, opts...) @@ -423,9 +323,6 @@ func (c *queryClient) Asset(ctx context.Context, in *QueryAssetRequest, opts ... // QueryServer is the server API for Query service. type QueryServer interface { - // Params defines a gRPC query method that returns the parameters of the - // module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // Assets defined a gRPC query method that returns all assets registered. Assets(context.Context, *QueryAssetsRequest) (*QueryAssetsResponse, error) // Asset defines a gRPC query method that returns the asset associated with @@ -437,9 +334,6 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} func (*UnimplementedQueryServer) Assets(ctx context.Context, req *QueryAssetsRequest) (*QueryAssetsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Assets not implemented") } @@ -451,24 +345,6 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/milkyway.assets.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_Assets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryAssetsRequest) if err := dec(in); err != nil { @@ -509,10 +385,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "milkyway.assets.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, { MethodName: "Assets", Handler: _Query_Assets_Handler, @@ -526,62 +398,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "milkyway/assets/v1/query.proto", } -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *QueryAssetsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -747,26 +563,6 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - func (m *QueryAssetsRequest) Size() (n int) { if m == nil { return 0 @@ -833,139 +629,6 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryAssetsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/assets/types/query.pb.gw.go b/x/assets/types/query.pb.gw.go index b2615695..982286e5 100644 --- a/x/assets/types/query.pb.gw.go +++ b/x/assets/types/query.pb.gw.go @@ -33,24 +33,6 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_Assets_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -147,29 +129,6 @@ func local_request_Query_Asset_0(ctx context.Context, marshaler runtime.Marshale // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_Assets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -257,26 +216,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_Assets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -321,16 +260,12 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"milkyway", "assets", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Assets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"milkyway", "assets", "v1"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Asset_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 1, 0, 4, 1, 5, 3}, []string{"milkyway", "assets", "v1", "denom"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - forward_Query_Assets_0 = runtime.ForwardResponseMessage forward_Query_Asset_0 = runtime.ForwardResponseMessage From 2ee000fda8444e33f9bd73ce954ba2e5fde19fce Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 11:32:44 -0500 Subject: [PATCH 04/11] feat: add operators migration --- testutils/storetesting/context.go | 36 ++++++++++++++++ x/operators/keeper/migrations.go | 24 +++++++++++ x/operators/legacy/v2/store.go | 22 ++++++++++ x/operators/legacy/v2/store_test.go | 67 +++++++++++++++++++++++++++++ x/operators/module.go | 8 +++- 5 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 testutils/storetesting/context.go create mode 100644 x/operators/keeper/migrations.go create mode 100644 x/operators/legacy/v2/store.go create mode 100644 x/operators/legacy/v2/store_test.go diff --git a/testutils/storetesting/context.go b/testutils/storetesting/context.go new file mode 100644 index 00000000..2a18ed35 --- /dev/null +++ b/testutils/storetesting/context.go @@ -0,0 +1,36 @@ +package storetesting + +import ( + "cosmossdk.io/log" + "cosmossdk.io/store" + "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func BuildContext( + keys map[string]*storetypes.KVStoreKey, tKeys map[string]*storetypes.TransientStoreKey, memKeys map[string]*storetypes.MemoryStoreKey, +) sdk.Context { + logger := log.NewNopLogger() + db := dbm.NewMemDB() + cms := store.NewCommitMultiStore(db, logger, metrics.NewNoOpMetrics()) + for _, key := range keys { + cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) + } + for _, tKey := range tKeys { + cms.MountStoreWithDB(tKey, storetypes.StoreTypeTransient, db) + } + for _, memKey := range memKeys { + cms.MountStoreWithDB(memKey, storetypes.StoreTypeMemory, nil) + } + + err := cms.LoadLatestVersion() + if err != nil { + panic(err) + } + + return sdk.NewContext(cms, tmproto.Header{}, false, logger) +} diff --git a/x/operators/keeper/migrations.go b/x/operators/keeper/migrations.go new file mode 100644 index 00000000..4b488418 --- /dev/null +++ b/x/operators/keeper/migrations.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + v2 "github.com/milkyway-labs/milkyway/x/operators/legacy/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + k *Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper *Keeper) Migrator { + return Migrator{ + k: keeper, + } +} + +// Migrate1To2 migrates from version 1 to 2. +func (m Migrator) Migrate1To2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) +} diff --git a/x/operators/legacy/v2/store.go b/x/operators/legacy/v2/store.go new file mode 100644 index 00000000..3fb6d443 --- /dev/null +++ b/x/operators/legacy/v2/store.go @@ -0,0 +1,22 @@ +package v2 + +import ( + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/operators/types" +) + +// MigrateStore performs in-place store migrations from v1 to v2 +// The things done here are the following: +// 1. setting up the module params +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + + // Set the module params + params := types.DefaultParams() + store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) + + return nil +} diff --git a/x/operators/legacy/v2/store_test.go b/x/operators/legacy/v2/store_test.go new file mode 100644 index 00000000..ce77b46d --- /dev/null +++ b/x/operators/legacy/v2/store_test.go @@ -0,0 +1,67 @@ +package v2_test + +import ( + "testing" + + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/app" + "github.com/milkyway-labs/milkyway/testutils/storetesting" + v2 "github.com/milkyway-labs/milkyway/x/operators/legacy/v2" + "github.com/milkyway-labs/milkyway/x/operators/types" +) + +func TestMigrateStore(t *testing.T) { + cdc, _ := app.MakeCodecs() + + // Build all the necessary keys + keys := storetypes.NewKVStoreKeys(types.StoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + testCases := []struct { + name string + store func(ctx sdk.Context) + shouldErr bool + check func(ctx sdk.Context) + }{ + { + name: "module params are set properly", + shouldErr: false, + check: func(ctx sdk.Context) { + store := ctx.KVStore(keys[types.StoreKey]) + + // Check the module params + paramsBz := store.Get(types.ParamsKey) + require.NotNil(t, paramsBz) + + var params types.Params + err := cdc.Unmarshal(paramsBz, ¶ms) + require.NoError(t, err) + require.Equal(t, types.DefaultParams(), params) + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx := storetesting.BuildContext(keys, nil, memKeys) + if tc.store != nil { + tc.store(ctx) + } + + err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} diff --git a/x/operators/module.go b/x/operators/module.go index cf6c1274..be54ea74 100644 --- a/x/operators/module.go +++ b/x/operators/module.go @@ -24,7 +24,7 @@ import ( ) const ( - consensusVersion = 1 + consensusVersion = 2 ) var ( @@ -119,6 +119,12 @@ func (am AppModule) Name() string { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) + if err != nil { + panic(err) + } } // RegisterInvariants registers the operators module's invariants. From 6cf9eed82d7da5a0f8fa66f2470a7ce2e5a2172b Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 11:34:49 -0500 Subject: [PATCH 05/11] feat: add pools migration --- x/pools/keeper/migrations.go | 24 ++++++++++++ x/pools/legacy/v2/store.go | 22 +++++++++++ x/pools/legacy/v2/store_test.go | 67 +++++++++++++++++++++++++++++++++ x/pools/module.go | 8 +++- 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 x/pools/keeper/migrations.go create mode 100644 x/pools/legacy/v2/store.go create mode 100644 x/pools/legacy/v2/store_test.go diff --git a/x/pools/keeper/migrations.go b/x/pools/keeper/migrations.go new file mode 100644 index 00000000..8a0dbabc --- /dev/null +++ b/x/pools/keeper/migrations.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + v2 "github.com/milkyway-labs/milkyway/x/pools/legacy/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + k *Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper *Keeper) Migrator { + return Migrator{ + k: keeper, + } +} + +// Migrate1To2 migrates from version 1 to 2. +func (m Migrator) Migrate1To2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) +} diff --git a/x/pools/legacy/v2/store.go b/x/pools/legacy/v2/store.go new file mode 100644 index 00000000..c5a900ee --- /dev/null +++ b/x/pools/legacy/v2/store.go @@ -0,0 +1,22 @@ +package v2 + +import ( + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +// MigrateStore performs in-place store migrations from v1 to v2 +// The things done here are the following: +// 1. setting up the module params +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + + // Set the module params + params := types.DefaultParams() + store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) + + return nil +} diff --git a/x/pools/legacy/v2/store_test.go b/x/pools/legacy/v2/store_test.go new file mode 100644 index 00000000..d6fe448a --- /dev/null +++ b/x/pools/legacy/v2/store_test.go @@ -0,0 +1,67 @@ +package v2_test + +import ( + "testing" + + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/app" + "github.com/milkyway-labs/milkyway/testutils/storetesting" + v2 "github.com/milkyway-labs/milkyway/x/pools/legacy/v2" + "github.com/milkyway-labs/milkyway/x/pools/types" +) + +func TestMigrateStore(t *testing.T) { + cdc, _ := app.MakeCodecs() + + // Build all the necessary keys + keys := storetypes.NewKVStoreKeys(types.StoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + testCases := []struct { + name string + store func(ctx sdk.Context) + shouldErr bool + check func(ctx sdk.Context) + }{ + { + name: "module params are set properly", + shouldErr: false, + check: func(ctx sdk.Context) { + store := ctx.KVStore(keys[types.StoreKey]) + + // Check the module params + paramsBz := store.Get(types.ParamsKey) + require.NotNil(t, paramsBz) + + var params types.Params + err := cdc.Unmarshal(paramsBz, ¶ms) + require.NoError(t, err) + require.Equal(t, types.DefaultParams(), params) + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx := storetesting.BuildContext(keys, nil, memKeys) + if tc.store != nil { + tc.store(ctx) + } + + err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} diff --git a/x/pools/module.go b/x/pools/module.go index 3e1d9437..8da79715 100644 --- a/x/pools/module.go +++ b/x/pools/module.go @@ -24,7 +24,7 @@ import ( ) const ( - consensusVersion = 1 + consensusVersion = 2 ) var ( @@ -114,6 +114,12 @@ func (am AppModule) Name() string { // RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) + if err != nil { + panic(err) + } } // RegisterInvariants registers the pools module's invariants. From 9ec2f5e149a07cd92686f5343711a08ddd587a83 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 11:41:36 -0500 Subject: [PATCH 06/11] feat: add restaking migration --- x/restaking/keeper/migrations.go | 24 +++++++++++ x/restaking/legacy/v2/store.go | 22 ++++++++++ x/restaking/legacy/v2/store_test.go | 67 +++++++++++++++++++++++++++++ x/restaking/module.go | 9 +++- 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 x/restaking/keeper/migrations.go create mode 100644 x/restaking/legacy/v2/store.go create mode 100644 x/restaking/legacy/v2/store_test.go diff --git a/x/restaking/keeper/migrations.go b/x/restaking/keeper/migrations.go new file mode 100644 index 00000000..425327dc --- /dev/null +++ b/x/restaking/keeper/migrations.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + v2 "github.com/milkyway-labs/milkyway/x/restaking/legacy/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + k *Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper *Keeper) Migrator { + return Migrator{ + k: keeper, + } +} + +// Migrate1To2 migrates from version 1 to 2. +func (m Migrator) Migrate1To2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) +} diff --git a/x/restaking/legacy/v2/store.go b/x/restaking/legacy/v2/store.go new file mode 100644 index 00000000..c86a38ee --- /dev/null +++ b/x/restaking/legacy/v2/store.go @@ -0,0 +1,22 @@ +package v2 + +import ( + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/restaking/types" +) + +// MigrateStore performs in-place store migrations from v1 to v2 +// The things done here are the following: +// 1. setting up the module params +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + + // Set the module params + params := types.DefaultParams() + store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) + + return nil +} diff --git a/x/restaking/legacy/v2/store_test.go b/x/restaking/legacy/v2/store_test.go new file mode 100644 index 00000000..50874a61 --- /dev/null +++ b/x/restaking/legacy/v2/store_test.go @@ -0,0 +1,67 @@ +package v2_test + +import ( + "testing" + + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/app" + "github.com/milkyway-labs/milkyway/testutils/storetesting" + v2 "github.com/milkyway-labs/milkyway/x/restaking/legacy/v2" + "github.com/milkyway-labs/milkyway/x/restaking/types" +) + +func TestMigrateStore(t *testing.T) { + cdc, _ := app.MakeCodecs() + + // Build all the necessary keys + keys := storetypes.NewKVStoreKeys(types.StoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + testCases := []struct { + name string + store func(ctx sdk.Context) + shouldErr bool + check func(ctx sdk.Context) + }{ + { + name: "module params are set properly", + shouldErr: false, + check: func(ctx sdk.Context) { + store := ctx.KVStore(keys[types.StoreKey]) + + // Check the module params + paramsBz := store.Get(types.ParamsKey) + require.NotNil(t, paramsBz) + + var params types.Params + err := cdc.Unmarshal(paramsBz, ¶ms) + require.NoError(t, err) + require.Equal(t, types.DefaultParams(), params) + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx := storetesting.BuildContext(keys, nil, memKeys) + if tc.store != nil { + tc.store(ctx) + } + + err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} diff --git a/x/restaking/module.go b/x/restaking/module.go index 5be974f7..1f2385ef 100644 --- a/x/restaking/module.go +++ b/x/restaking/module.go @@ -23,7 +23,7 @@ import ( ) const ( - consensusVersion = 1 + consensusVersion = 2 ) var ( @@ -116,7 +116,14 @@ func (am AppModule) Name() string { // RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) + + m := keeper.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) + if err != nil { + panic(err) + } } // RegisterInvariants registers the restaking module's invariants. From 391f8849975ba7e859629ebbd9923fd94eadc1b5 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 11:46:40 -0500 Subject: [PATCH 07/11] feat: add rewards migration --- x/rewards/keeper/migrations.go | 24 +++++++++++ x/rewards/legacy/v2/store.go | 16 +++++++ x/rewards/legacy/v2/store_test.go | 71 +++++++++++++++++++++++++++++++ x/rewards/module.go | 8 +++- 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 x/rewards/keeper/migrations.go create mode 100644 x/rewards/legacy/v2/store.go create mode 100644 x/rewards/legacy/v2/store_test.go diff --git a/x/rewards/keeper/migrations.go b/x/rewards/keeper/migrations.go new file mode 100644 index 00000000..9eade767 --- /dev/null +++ b/x/rewards/keeper/migrations.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + v2 "github.com/milkyway-labs/milkyway/x/rewards/legacy/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + k *Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper *Keeper) Migrator { + return Migrator{ + k: keeper, + } +} + +// Migrate1To2 migrates from version 1 to 2. +func (m Migrator) Migrate1To2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.k.Params) +} diff --git a/x/rewards/legacy/v2/store.go b/x/rewards/legacy/v2/store.go new file mode 100644 index 00000000..ca696326 --- /dev/null +++ b/x/rewards/legacy/v2/store.go @@ -0,0 +1,16 @@ +package v2 + +import ( + "cosmossdk.io/collections" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/rewards/types" +) + +// MigrateStore performs in-place store migrations from v1 to v2 +// The things done here are the following: +// 1. setting up the module params +func MigrateStore(ctx sdk.Context, params collections.Item[types.Params]) error { + // Set the module params + return params.Set(ctx, types.DefaultParams()) +} diff --git a/x/rewards/legacy/v2/store_test.go b/x/rewards/legacy/v2/store_test.go new file mode 100644 index 00000000..bcd7aa21 --- /dev/null +++ b/x/rewards/legacy/v2/store_test.go @@ -0,0 +1,71 @@ +package v2_test + +import ( + "testing" + + "cosmossdk.io/collections" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/app" + "github.com/milkyway-labs/milkyway/testutils/storetesting" + v2 "github.com/milkyway-labs/milkyway/x/rewards/legacy/v2" + "github.com/milkyway-labs/milkyway/x/rewards/types" +) + +func TestMigrateStore(t *testing.T) { + cdc, _ := app.MakeCodecs() + + // Build all the necessary keys + keys := storetypes.NewKVStoreKeys(types.StoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + testCases := []struct { + name string + store func(ctx sdk.Context) + shouldErr bool + check func(ctx sdk.Context) + }{ + { + name: "module params are set properly", + shouldErr: false, + check: func(ctx sdk.Context) { + storeService := runtime.NewKVStoreService(keys[types.StoreKey]) + sb := collections.NewSchemaBuilder(storeService) + paramsCollection := collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)) + + params, err := paramsCollection.Get(ctx) + require.NoError(t, err) + require.Equal(t, types.DefaultParams(), params) + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx := storetesting.BuildContext(keys, nil, memKeys) + if tc.store != nil { + tc.store(ctx) + } + + storeService := runtime.NewKVStoreService(keys[types.StoreKey]) + sb := collections.NewSchemaBuilder(storeService) + paramsCollection := collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)) + + err := v2.MigrateStore(ctx, paramsCollection) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} diff --git a/x/rewards/module.go b/x/rewards/module.go index e95f7fca..33874e9d 100644 --- a/x/rewards/module.go +++ b/x/rewards/module.go @@ -19,7 +19,7 @@ import ( ) const ( - consensusVersion = 1 + consensusVersion = 2 ) var ( @@ -104,6 +104,12 @@ func (am AppModule) Name() string { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) + + m := keeper.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) + if err != nil { + panic(err) + } } // RegisterInvariants registers the module's invariants. From f4def17f40071eacccf49e4a51a5ee7cefb570d7 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 11:48:29 -0500 Subject: [PATCH 08/11] feat: add services migration --- x/services/keeper/migrations.go | 24 +++++++++++ x/services/legacy/v2/store.go | 22 ++++++++++ x/services/legacy/v2/store_test.go | 67 ++++++++++++++++++++++++++++++ x/services/module.go | 8 +++- 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 x/services/keeper/migrations.go create mode 100644 x/services/legacy/v2/store.go create mode 100644 x/services/legacy/v2/store_test.go diff --git a/x/services/keeper/migrations.go b/x/services/keeper/migrations.go new file mode 100644 index 00000000..df802f9e --- /dev/null +++ b/x/services/keeper/migrations.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + v2 "github.com/milkyway-labs/milkyway/x/services/legacy/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + k *Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper *Keeper) Migrator { + return Migrator{ + k: keeper, + } +} + +// Migrate1To2 migrates from version 1 to 2. +func (m Migrator) Migrate1To2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) +} diff --git a/x/services/legacy/v2/store.go b/x/services/legacy/v2/store.go new file mode 100644 index 00000000..11b2176b --- /dev/null +++ b/x/services/legacy/v2/store.go @@ -0,0 +1,22 @@ +package v2 + +import ( + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/milkyway-labs/milkyway/x/services/types" +) + +// MigrateStore performs in-place store migrations from v1 to v2 +// The things done here are the following: +// 1. setting up the module params +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + + // Set the module params + params := types.DefaultParams() + store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) + + return nil +} diff --git a/x/services/legacy/v2/store_test.go b/x/services/legacy/v2/store_test.go new file mode 100644 index 00000000..8717fdfc --- /dev/null +++ b/x/services/legacy/v2/store_test.go @@ -0,0 +1,67 @@ +package v2_test + +import ( + "testing" + + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/stretchr/testify/require" + + "github.com/milkyway-labs/milkyway/app" + "github.com/milkyway-labs/milkyway/testutils/storetesting" + v2 "github.com/milkyway-labs/milkyway/x/services/legacy/v2" + "github.com/milkyway-labs/milkyway/x/services/types" +) + +func TestMigrateStore(t *testing.T) { + cdc, _ := app.MakeCodecs() + + // Build all the necessary keys + keys := storetypes.NewKVStoreKeys(types.StoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + testCases := []struct { + name string + store func(ctx sdk.Context) + shouldErr bool + check func(ctx sdk.Context) + }{ + { + name: "module params are set properly", + shouldErr: false, + check: func(ctx sdk.Context) { + store := ctx.KVStore(keys[types.StoreKey]) + + // Check the module params + paramsBz := store.Get(types.ParamsKey) + require.NotNil(t, paramsBz) + + var params types.Params + err := cdc.Unmarshal(paramsBz, ¶ms) + require.NoError(t, err) + require.Equal(t, types.DefaultParams(), params) + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx := storetesting.BuildContext(keys, nil, memKeys) + if tc.store != nil { + tc.store(ctx) + } + + err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} diff --git a/x/services/module.go b/x/services/module.go index de434a10..4df9b5ca 100644 --- a/x/services/module.go +++ b/x/services/module.go @@ -24,7 +24,7 @@ import ( ) const ( - consensusVersion = 1 + consensusVersion = 2 ) var ( @@ -119,6 +119,12 @@ func (am AppModule) Name() string { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) + if err != nil { + panic(err) + } } // RegisterInvariants registers the capability module's invariants. From c0ad1f2da9e0814ecefdc7006639d73f94b7fcf5 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 10 Sep 2024 11:48:46 -0500 Subject: [PATCH 09/11] feat: add consensus version setting inside upgrade handler --- app/upgrades/v110/upgrade.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/upgrades/v110/upgrade.go b/app/upgrades/v110/upgrade.go index 359d6af7..3992d661 100644 --- a/app/upgrades/v110/upgrade.go +++ b/app/upgrades/v110/upgrade.go @@ -42,6 +42,13 @@ func (u *Upgrade) Name() string { // Handler implements upgrades.Upgrade func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Set the consensus version to 1 in order to run migrations from 1 to 2 for the following modules + fromVM[operatorstypes.ModuleName] = 1 + fromVM[poolstypes.ModuleName] = 1 + fromVM[restakingtypes.ModuleName] = 1 + fromVM[rewardstypes.ModuleName] = 1 + fromVM[servicestypes.ModuleName] = 1 + // This upgrade does not require any migration, so we can simply return the current version map return u.mm.RunMigrations(ctx, u.configurator, fromVM) } From 7e1517501392f867496d5d2da9bd654703e6e118 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Wed, 18 Sep 2024 13:06:57 -0500 Subject: [PATCH 10/11] refactor: use in-manager upgrade --- app/upgrade.go | 2 +- app/upgrades/v110/upgrade.go | 52 +++++++++++++++++++-- x/operators/keeper/migrations.go | 24 ---------- x/operators/legacy/v2/store.go | 22 --------- x/operators/legacy/v2/store_test.go | 67 --------------------------- x/operators/module.go | 8 +--- x/pools/keeper/migrations.go | 24 ---------- x/pools/legacy/v2/store.go | 22 --------- x/pools/legacy/v2/store_test.go | 67 --------------------------- x/pools/module.go | 8 +--- x/restaking/keeper/migrations.go | 24 ---------- x/restaking/legacy/v2/store.go | 22 --------- x/restaking/legacy/v2/store_test.go | 67 --------------------------- x/restaking/module.go | 8 +--- x/rewards/keeper/migrations.go | 24 ---------- x/rewards/legacy/v2/store.go | 16 ------- x/rewards/legacy/v2/store_test.go | 71 ----------------------------- x/rewards/module.go | 8 +--- x/services/keeper/migrations.go | 24 ---------- x/services/legacy/v2/store.go | 22 --------- x/services/legacy/v2/store_test.go | 67 --------------------------- x/services/module.go | 8 +--- 22 files changed, 54 insertions(+), 603 deletions(-) delete mode 100644 x/operators/keeper/migrations.go delete mode 100644 x/operators/legacy/v2/store.go delete mode 100644 x/operators/legacy/v2/store_test.go delete mode 100644 x/pools/keeper/migrations.go delete mode 100644 x/pools/legacy/v2/store.go delete mode 100644 x/pools/legacy/v2/store_test.go delete mode 100644 x/restaking/keeper/migrations.go delete mode 100644 x/restaking/legacy/v2/store.go delete mode 100644 x/restaking/legacy/v2/store_test.go delete mode 100644 x/rewards/keeper/migrations.go delete mode 100644 x/rewards/legacy/v2/store.go delete mode 100644 x/rewards/legacy/v2/store_test.go delete mode 100644 x/services/keeper/migrations.go delete mode 100644 x/services/legacy/v2/store.go delete mode 100644 x/services/legacy/v2/store_test.go diff --git a/app/upgrade.go b/app/upgrade.go index 91182852..5cdabcb1 100644 --- a/app/upgrade.go +++ b/app/upgrade.go @@ -6,5 +6,5 @@ import ( // RegisterUpgradeHandlers returns upgrade handlers func (app *MilkyWayApp) RegisterUpgradeHandlers() { - app.registerUpgrade(v110.NewUpgrade(app.ModuleManager, app.Configurator())) + app.registerUpgrade(v110.NewUpgrade(app.ModuleManager, app.Configurator(), app.appCodec, app.keys, app.RewardsKeeper)) } diff --git a/app/upgrades/v110/upgrade.go b/app/upgrades/v110/upgrade.go index 3992d661..6fc72277 100644 --- a/app/upgrades/v110/upgrade.go +++ b/app/upgrades/v110/upgrade.go @@ -5,6 +5,8 @@ import ( storetypes "cosmossdk.io/store/types" upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/milkyway-labs/milkyway/app/upgrades" @@ -12,6 +14,7 @@ import ( operatorstypes "github.com/milkyway-labs/milkyway/x/operators/types" poolstypes "github.com/milkyway-labs/milkyway/x/pools/types" restakingtypes "github.com/milkyway-labs/milkyway/x/restaking/types" + rewardskeeper "github.com/milkyway-labs/milkyway/x/rewards/keeper" rewardstypes "github.com/milkyway-labs/milkyway/x/rewards/types" servicestypes "github.com/milkyway-labs/milkyway/x/services/types" ) @@ -24,13 +27,26 @@ var ( type Upgrade struct { mm *module.Manager configurator module.Configurator + + cdc codec.BinaryCodec + keys map[string]*storetypes.KVStoreKey + rewardsKeeper *rewardskeeper.Keeper } // NewUpgrade returns a new Upgrade instance -func NewUpgrade(mm *module.Manager, configurator module.Configurator) *Upgrade { +func NewUpgrade( + mm *module.Manager, + configurator module.Configurator, + cdc codec.BinaryCodec, + keys map[string]*storetypes.KVStoreKey, + rewardsKeeper *rewardskeeper.Keeper, +) *Upgrade { return &Upgrade{ - mm: mm, - configurator: configurator, + mm: mm, + configurator: configurator, + cdc: cdc, + keys: keys, + rewardsKeeper: rewardsKeeper, } } @@ -42,7 +58,35 @@ func (u *Upgrade) Name() string { // Handler implements upgrades.Upgrade func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // Set the consensus version to 1 in order to run migrations from 1 to 2 for the following modules + sdkCtx := sdk.UnwrapSDKContext(ctx) + + // Set the operators module params + store := sdkCtx.KVStore(u.keys[operatorstypes.ModuleName]) + operatorsParams := operatorstypes.DefaultParams() + store.Set(operatorstypes.ParamsKey, u.cdc.MustMarshal(&operatorsParams)) + + // Set the pools params + store = sdkCtx.KVStore(u.keys[poolstypes.ModuleName]) + poolsParams := poolstypes.DefaultParams() + store.Set(poolstypes.ParamsKey, u.cdc.MustMarshal(&poolsParams)) + + // Set the restaking params + store = sdkCtx.KVStore(u.keys[restakingtypes.ModuleName]) + restakingParams := restakingtypes.DefaultParams() + store.Set(restakingtypes.ParamsKey, u.cdc.MustMarshal(&restakingParams)) + + // Set the rewards params + if err := u.rewardsKeeper.Params.Set(ctx, rewardstypes.DefaultParams()); err != nil { + return nil, err + } + + // Set the services params + store = sdkCtx.KVStore(u.keys[servicestypes.ModuleName]) + servicesParams := servicestypes.DefaultParams() + store.Set(servicestypes.ParamsKey, u.cdc.MustMarshal(&servicesParams)) + + // Set the module versions + fromVM[assetstypes.ModuleName] = 1 fromVM[operatorstypes.ModuleName] = 1 fromVM[poolstypes.ModuleName] = 1 fromVM[restakingtypes.ModuleName] = 1 diff --git a/x/operators/keeper/migrations.go b/x/operators/keeper/migrations.go deleted file mode 100644 index 4b488418..00000000 --- a/x/operators/keeper/migrations.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - v2 "github.com/milkyway-labs/milkyway/x/operators/legacy/v2" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - k *Keeper -} - -// NewMigrator returns a new Migrator. -func NewMigrator(keeper *Keeper) Migrator { - return Migrator{ - k: keeper, - } -} - -// Migrate1To2 migrates from version 1 to 2. -func (m Migrator) Migrate1To2(ctx sdk.Context) error { - return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) -} diff --git a/x/operators/legacy/v2/store.go b/x/operators/legacy/v2/store.go deleted file mode 100644 index 3fb6d443..00000000 --- a/x/operators/legacy/v2/store.go +++ /dev/null @@ -1,22 +0,0 @@ -package v2 - -import ( - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/operators/types" -) - -// MigrateStore performs in-place store migrations from v1 to v2 -// The things done here are the following: -// 1. setting up the module params -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) - - // Set the module params - params := types.DefaultParams() - store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) - - return nil -} diff --git a/x/operators/legacy/v2/store_test.go b/x/operators/legacy/v2/store_test.go deleted file mode 100644 index ce77b46d..00000000 --- a/x/operators/legacy/v2/store_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package v2_test - -import ( - "testing" - - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/app" - "github.com/milkyway-labs/milkyway/testutils/storetesting" - v2 "github.com/milkyway-labs/milkyway/x/operators/legacy/v2" - "github.com/milkyway-labs/milkyway/x/operators/types" -) - -func TestMigrateStore(t *testing.T) { - cdc, _ := app.MakeCodecs() - - // Build all the necessary keys - keys := storetypes.NewKVStoreKeys(types.StoreKey) - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - - testCases := []struct { - name string - store func(ctx sdk.Context) - shouldErr bool - check func(ctx sdk.Context) - }{ - { - name: "module params are set properly", - shouldErr: false, - check: func(ctx sdk.Context) { - store := ctx.KVStore(keys[types.StoreKey]) - - // Check the module params - paramsBz := store.Get(types.ParamsKey) - require.NotNil(t, paramsBz) - - var params types.Params - err := cdc.Unmarshal(paramsBz, ¶ms) - require.NoError(t, err) - require.Equal(t, types.DefaultParams(), params) - }, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - ctx := storetesting.BuildContext(keys, nil, memKeys) - if tc.store != nil { - tc.store(ctx) - } - - err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - if tc.check != nil { - tc.check(ctx) - } - } - }) - } -} diff --git a/x/operators/module.go b/x/operators/module.go index be54ea74..cf6c1274 100644 --- a/x/operators/module.go +++ b/x/operators/module.go @@ -24,7 +24,7 @@ import ( ) const ( - consensusVersion = 2 + consensusVersion = 1 ) var ( @@ -119,12 +119,6 @@ func (am AppModule) Name() string { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - - m := keeper.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) - if err != nil { - panic(err) - } } // RegisterInvariants registers the operators module's invariants. diff --git a/x/pools/keeper/migrations.go b/x/pools/keeper/migrations.go deleted file mode 100644 index 8a0dbabc..00000000 --- a/x/pools/keeper/migrations.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - v2 "github.com/milkyway-labs/milkyway/x/pools/legacy/v2" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - k *Keeper -} - -// NewMigrator returns a new Migrator. -func NewMigrator(keeper *Keeper) Migrator { - return Migrator{ - k: keeper, - } -} - -// Migrate1To2 migrates from version 1 to 2. -func (m Migrator) Migrate1To2(ctx sdk.Context) error { - return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) -} diff --git a/x/pools/legacy/v2/store.go b/x/pools/legacy/v2/store.go deleted file mode 100644 index c5a900ee..00000000 --- a/x/pools/legacy/v2/store.go +++ /dev/null @@ -1,22 +0,0 @@ -package v2 - -import ( - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/pools/types" -) - -// MigrateStore performs in-place store migrations from v1 to v2 -// The things done here are the following: -// 1. setting up the module params -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) - - // Set the module params - params := types.DefaultParams() - store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) - - return nil -} diff --git a/x/pools/legacy/v2/store_test.go b/x/pools/legacy/v2/store_test.go deleted file mode 100644 index d6fe448a..00000000 --- a/x/pools/legacy/v2/store_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package v2_test - -import ( - "testing" - - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/app" - "github.com/milkyway-labs/milkyway/testutils/storetesting" - v2 "github.com/milkyway-labs/milkyway/x/pools/legacy/v2" - "github.com/milkyway-labs/milkyway/x/pools/types" -) - -func TestMigrateStore(t *testing.T) { - cdc, _ := app.MakeCodecs() - - // Build all the necessary keys - keys := storetypes.NewKVStoreKeys(types.StoreKey) - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - - testCases := []struct { - name string - store func(ctx sdk.Context) - shouldErr bool - check func(ctx sdk.Context) - }{ - { - name: "module params are set properly", - shouldErr: false, - check: func(ctx sdk.Context) { - store := ctx.KVStore(keys[types.StoreKey]) - - // Check the module params - paramsBz := store.Get(types.ParamsKey) - require.NotNil(t, paramsBz) - - var params types.Params - err := cdc.Unmarshal(paramsBz, ¶ms) - require.NoError(t, err) - require.Equal(t, types.DefaultParams(), params) - }, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - ctx := storetesting.BuildContext(keys, nil, memKeys) - if tc.store != nil { - tc.store(ctx) - } - - err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - if tc.check != nil { - tc.check(ctx) - } - } - }) - } -} diff --git a/x/pools/module.go b/x/pools/module.go index 8da79715..3e1d9437 100644 --- a/x/pools/module.go +++ b/x/pools/module.go @@ -24,7 +24,7 @@ import ( ) const ( - consensusVersion = 2 + consensusVersion = 1 ) var ( @@ -114,12 +114,6 @@ func (am AppModule) Name() string { // RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - - m := keeper.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) - if err != nil { - panic(err) - } } // RegisterInvariants registers the pools module's invariants. diff --git a/x/restaking/keeper/migrations.go b/x/restaking/keeper/migrations.go deleted file mode 100644 index 425327dc..00000000 --- a/x/restaking/keeper/migrations.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - v2 "github.com/milkyway-labs/milkyway/x/restaking/legacy/v2" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - k *Keeper -} - -// NewMigrator returns a new Migrator. -func NewMigrator(keeper *Keeper) Migrator { - return Migrator{ - k: keeper, - } -} - -// Migrate1To2 migrates from version 1 to 2. -func (m Migrator) Migrate1To2(ctx sdk.Context) error { - return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) -} diff --git a/x/restaking/legacy/v2/store.go b/x/restaking/legacy/v2/store.go deleted file mode 100644 index c86a38ee..00000000 --- a/x/restaking/legacy/v2/store.go +++ /dev/null @@ -1,22 +0,0 @@ -package v2 - -import ( - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/restaking/types" -) - -// MigrateStore performs in-place store migrations from v1 to v2 -// The things done here are the following: -// 1. setting up the module params -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) - - // Set the module params - params := types.DefaultParams() - store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) - - return nil -} diff --git a/x/restaking/legacy/v2/store_test.go b/x/restaking/legacy/v2/store_test.go deleted file mode 100644 index 50874a61..00000000 --- a/x/restaking/legacy/v2/store_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package v2_test - -import ( - "testing" - - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/app" - "github.com/milkyway-labs/milkyway/testutils/storetesting" - v2 "github.com/milkyway-labs/milkyway/x/restaking/legacy/v2" - "github.com/milkyway-labs/milkyway/x/restaking/types" -) - -func TestMigrateStore(t *testing.T) { - cdc, _ := app.MakeCodecs() - - // Build all the necessary keys - keys := storetypes.NewKVStoreKeys(types.StoreKey) - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - - testCases := []struct { - name string - store func(ctx sdk.Context) - shouldErr bool - check func(ctx sdk.Context) - }{ - { - name: "module params are set properly", - shouldErr: false, - check: func(ctx sdk.Context) { - store := ctx.KVStore(keys[types.StoreKey]) - - // Check the module params - paramsBz := store.Get(types.ParamsKey) - require.NotNil(t, paramsBz) - - var params types.Params - err := cdc.Unmarshal(paramsBz, ¶ms) - require.NoError(t, err) - require.Equal(t, types.DefaultParams(), params) - }, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - ctx := storetesting.BuildContext(keys, nil, memKeys) - if tc.store != nil { - tc.store(ctx) - } - - err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - if tc.check != nil { - tc.check(ctx) - } - } - }) - } -} diff --git a/x/restaking/module.go b/x/restaking/module.go index 1f2385ef..fedb6e6f 100644 --- a/x/restaking/module.go +++ b/x/restaking/module.go @@ -23,7 +23,7 @@ import ( ) const ( - consensusVersion = 2 + consensusVersion = 1 ) var ( @@ -118,12 +118,6 @@ func (am AppModule) Name() string { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) - - m := keeper.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) - if err != nil { - panic(err) - } } // RegisterInvariants registers the restaking module's invariants. diff --git a/x/rewards/keeper/migrations.go b/x/rewards/keeper/migrations.go deleted file mode 100644 index 9eade767..00000000 --- a/x/rewards/keeper/migrations.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - v2 "github.com/milkyway-labs/milkyway/x/rewards/legacy/v2" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - k *Keeper -} - -// NewMigrator returns a new Migrator. -func NewMigrator(keeper *Keeper) Migrator { - return Migrator{ - k: keeper, - } -} - -// Migrate1To2 migrates from version 1 to 2. -func (m Migrator) Migrate1To2(ctx sdk.Context) error { - return v2.MigrateStore(ctx, m.k.Params) -} diff --git a/x/rewards/legacy/v2/store.go b/x/rewards/legacy/v2/store.go deleted file mode 100644 index ca696326..00000000 --- a/x/rewards/legacy/v2/store.go +++ /dev/null @@ -1,16 +0,0 @@ -package v2 - -import ( - "cosmossdk.io/collections" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/rewards/types" -) - -// MigrateStore performs in-place store migrations from v1 to v2 -// The things done here are the following: -// 1. setting up the module params -func MigrateStore(ctx sdk.Context, params collections.Item[types.Params]) error { - // Set the module params - return params.Set(ctx, types.DefaultParams()) -} diff --git a/x/rewards/legacy/v2/store_test.go b/x/rewards/legacy/v2/store_test.go deleted file mode 100644 index bcd7aa21..00000000 --- a/x/rewards/legacy/v2/store_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package v2_test - -import ( - "testing" - - "cosmossdk.io/collections" - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/app" - "github.com/milkyway-labs/milkyway/testutils/storetesting" - v2 "github.com/milkyway-labs/milkyway/x/rewards/legacy/v2" - "github.com/milkyway-labs/milkyway/x/rewards/types" -) - -func TestMigrateStore(t *testing.T) { - cdc, _ := app.MakeCodecs() - - // Build all the necessary keys - keys := storetypes.NewKVStoreKeys(types.StoreKey) - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - - testCases := []struct { - name string - store func(ctx sdk.Context) - shouldErr bool - check func(ctx sdk.Context) - }{ - { - name: "module params are set properly", - shouldErr: false, - check: func(ctx sdk.Context) { - storeService := runtime.NewKVStoreService(keys[types.StoreKey]) - sb := collections.NewSchemaBuilder(storeService) - paramsCollection := collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)) - - params, err := paramsCollection.Get(ctx) - require.NoError(t, err) - require.Equal(t, types.DefaultParams(), params) - }, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - ctx := storetesting.BuildContext(keys, nil, memKeys) - if tc.store != nil { - tc.store(ctx) - } - - storeService := runtime.NewKVStoreService(keys[types.StoreKey]) - sb := collections.NewSchemaBuilder(storeService) - paramsCollection := collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)) - - err := v2.MigrateStore(ctx, paramsCollection) - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - if tc.check != nil { - tc.check(ctx) - } - } - }) - } -} diff --git a/x/rewards/module.go b/x/rewards/module.go index 33874e9d..e95f7fca 100644 --- a/x/rewards/module.go +++ b/x/rewards/module.go @@ -19,7 +19,7 @@ import ( ) const ( - consensusVersion = 2 + consensusVersion = 1 ) var ( @@ -104,12 +104,6 @@ func (am AppModule) Name() string { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) - - m := keeper.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) - if err != nil { - panic(err) - } } // RegisterInvariants registers the module's invariants. diff --git a/x/services/keeper/migrations.go b/x/services/keeper/migrations.go deleted file mode 100644 index df802f9e..00000000 --- a/x/services/keeper/migrations.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - v2 "github.com/milkyway-labs/milkyway/x/services/legacy/v2" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - k *Keeper -} - -// NewMigrator returns a new Migrator. -func NewMigrator(keeper *Keeper) Migrator { - return Migrator{ - k: keeper, - } -} - -// Migrate1To2 migrates from version 1 to 2. -func (m Migrator) Migrate1To2(ctx sdk.Context) error { - return v2.MigrateStore(ctx, m.k.storeKey, m.k.cdc) -} diff --git a/x/services/legacy/v2/store.go b/x/services/legacy/v2/store.go deleted file mode 100644 index 11b2176b..00000000 --- a/x/services/legacy/v2/store.go +++ /dev/null @@ -1,22 +0,0 @@ -package v2 - -import ( - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/milkyway-labs/milkyway/x/services/types" -) - -// MigrateStore performs in-place store migrations from v1 to v2 -// The things done here are the following: -// 1. setting up the module params -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) - - // Set the module params - params := types.DefaultParams() - store.Set(types.ParamsKey, cdc.MustMarshal(¶ms)) - - return nil -} diff --git a/x/services/legacy/v2/store_test.go b/x/services/legacy/v2/store_test.go deleted file mode 100644 index 8717fdfc..00000000 --- a/x/services/legacy/v2/store_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package v2_test - -import ( - "testing" - - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/stretchr/testify/require" - - "github.com/milkyway-labs/milkyway/app" - "github.com/milkyway-labs/milkyway/testutils/storetesting" - v2 "github.com/milkyway-labs/milkyway/x/services/legacy/v2" - "github.com/milkyway-labs/milkyway/x/services/types" -) - -func TestMigrateStore(t *testing.T) { - cdc, _ := app.MakeCodecs() - - // Build all the necessary keys - keys := storetypes.NewKVStoreKeys(types.StoreKey) - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - - testCases := []struct { - name string - store func(ctx sdk.Context) - shouldErr bool - check func(ctx sdk.Context) - }{ - { - name: "module params are set properly", - shouldErr: false, - check: func(ctx sdk.Context) { - store := ctx.KVStore(keys[types.StoreKey]) - - // Check the module params - paramsBz := store.Get(types.ParamsKey) - require.NotNil(t, paramsBz) - - var params types.Params - err := cdc.Unmarshal(paramsBz, ¶ms) - require.NoError(t, err) - require.Equal(t, types.DefaultParams(), params) - }, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - ctx := storetesting.BuildContext(keys, nil, memKeys) - if tc.store != nil { - tc.store(ctx) - } - - err := v2.MigrateStore(ctx, keys[types.StoreKey], cdc) - if tc.shouldErr { - require.Error(t, err) - } else { - require.NoError(t, err) - if tc.check != nil { - tc.check(ctx) - } - } - }) - } -} diff --git a/x/services/module.go b/x/services/module.go index 4df9b5ca..de434a10 100644 --- a/x/services/module.go +++ b/x/services/module.go @@ -24,7 +24,7 @@ import ( ) const ( - consensusVersion = 2 + consensusVersion = 1 ) var ( @@ -119,12 +119,6 @@ func (am AppModule) Name() string { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - - m := keeper.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1To2) - if err != nil { - panic(err) - } } // RegisterInvariants registers the capability module's invariants. From 658bcb1d8db411b5ebdf426aa7976ae60eeb3132 Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Thu, 19 Sep 2024 22:33:26 +0900 Subject: [PATCH 11/11] chore: fix linter issue --- app/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index cc8e34d4..e1364eaa 100644 --- a/app/app.go +++ b/app/app.go @@ -1484,8 +1484,8 @@ func (app *MilkyWayApp) RegisterNodeService(clientCtx client.Context, cfg config } // Configurator returns the app's configurator. -func (a *MilkyWayApp) Configurator() module.Configurator { - return a.configurator +func (app *MilkyWayApp) Configurator() module.Configurator { + return app.configurator } // registerUpgrade registers the given upgrade to be supported by the app