diff --git a/docs/migrations/v7-to-v8.md b/docs/migrations/v7-to-v8.md index 572c2cc9e6d..f6b15ff4eed 100644 --- a/docs/migrations/v7-to-v8.md +++ b/docs/migrations/v7-to-v8.md @@ -47,6 +47,19 @@ TODO: https://github.com/cosmos/ibc-go/pull/3505 (extra parameter added to trans ) ``` +- You should pass the `authority` to the IBC keeper. ([#3640](https://github.com/cosmos/ibc-go/pull/3640)) See [diff](https://github.com/cosmos/ibc-go/pull/3640/files#diff-d18972debee5e64f16e40807b2ae112ddbe609504a93ea5e1c80a5d489c3a08a). + +```diff +// app.go + + // IBC Keepers + + app.IBCKeeper = ibckeeper.NewKeeper( +- appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, ++ appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) +``` + ## IBC Apps TODO: https://github.com/cosmos/ibc-go/pull/3303 diff --git a/modules/core/02-client/genesis.go b/modules/core/02-client/genesis.go index 7a38683ea03..1e391d9daea 100644 --- a/modules/core/02-client/genesis.go +++ b/modules/core/02-client/genesis.go @@ -13,6 +13,9 @@ import ( // InitGenesis initializes the ibc client submodule's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { + if err := gs.Params.Validate(); err != nil { + panic(fmt.Sprintf("invalid ibc client genesis state parameters: %v", err)) + } k.SetParams(ctx, gs.Params) // Set all client metadata first. This will allow client keeper to overwrite client and consensus state keys diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 7d0b707ecaa..cfbcbc57676 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -27,26 +27,26 @@ import ( // Keeper represents a type that grants read and write permissions to any client // state information type Keeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec - paramSpace paramtypes.Subspace - stakingKeeper types.StakingKeeper - upgradeKeeper types.UpgradeKeeper + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + legacySubspace paramtypes.Subspace + stakingKeeper types.StakingKeeper + upgradeKeeper types.UpgradeKeeper } // NewKeeper creates a new NewKeeper instance -func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper { // set KeyTable if it has not already been set - if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + if !legacySubspace.HasKeyTable() { + legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable()) } return Keeper{ - storeKey: key, - cdc: cdc, - paramSpace: paramSpace, - stakingKeeper: sk, - upgradeKeeper: uk, + storeKey: key, + cdc: cdc, + legacySubspace: legacySubspace, + stakingKeeper: sk, + upgradeKeeper: uk, } } @@ -413,3 +413,23 @@ func (k Keeper) GetClientStatus(ctx sdk.Context, clientState exported.ClientStat } return clientState.Status(ctx, k.ClientStore(ctx, clientID), k.cdc) } + +// GetParams returns the total set of ibc-client parameters. +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + store := ctx.KVStore(k.storeKey) + bz := store.Get([]byte(types.ParamsKey)) + if len(bz) == 0 { + return types.Params{} + } + + var params types.Params + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +// SetParams sets the total set of ibc-client parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.ParamsKey), bz) +} diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index c81e9d0fcff..5275ddd3a48 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -450,3 +450,57 @@ func (suite KeeperTestSuite) TestIterateClientStates() { //nolint:govet // this }) } } + +// TestDefaultSetParams tests the default params set are what is expected +func (suite *KeeperTestSuite) TestDefaultSetParams() { + expParams := types.DefaultParams() + + clientKeeper := suite.chainA.App.GetIBCKeeper().ClientKeeper + params := clientKeeper.GetParams(suite.chainA.GetContext()) + + suite.Require().Equal(expParams, params) + suite.Require().Equal(expParams.AllowedClients, clientKeeper.GetParams(suite.chainA.GetContext()).AllowedClients) +} + +// TestParams tests that Param setting and retrieval works properly +func (suite *KeeperTestSuite) TestParams() { + testCases := []struct { + name string + input types.Params + expPass bool + }{ + {"success: set default params", types.DefaultParams(), true}, + {"success: empty allowedClients", types.NewParams(), true}, + {"success: subset of allowedClients", types.NewParams(exported.Tendermint, exported.Localhost), true}, + {"failure: contains a single empty string value as allowedClient", types.NewParams(exported.Localhost, ""), false}, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + ctx := suite.chainA.GetContext() + err := tc.input.Validate() + suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.SetParams(ctx, tc.input) + if tc.expPass { + suite.Require().NoError(err) + expected := tc.input + p := suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.GetParams(ctx) + suite.Require().Equal(expected, p) + } else { + suite.Require().Error(err) + } + }) + } +} + +// TestUnsetParams tests that trying to get params that are not set returns empty params. +func (suite *KeeperTestSuite) TestUnsetParams() { + suite.SetupTest() + ctx := suite.chainA.GetContext() + store := ctx.KVStore(suite.chainA.GetSimApp().GetKey(exported.StoreKey)) + store.Delete([]byte(types.ParamsKey)) + + suite.Require().Equal(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.GetParams(ctx), types.Params{}) +} diff --git a/modules/core/02-client/keeper/migrations.go b/modules/core/02-client/keeper/migrations.go index b8290133042..0270aa1da85 100644 --- a/modules/core/02-client/keeper/migrations.go +++ b/modules/core/02-client/keeper/migrations.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" v7 "github.com/cosmos/ibc-go/v7/modules/core/02-client/migrations/v7" + "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ) // Migrator is a struct for handling in-place store migrations. @@ -31,3 +32,17 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { func (m Migrator) Migrate3to4(ctx sdk.Context) error { return v7.MigrateLocalhostClient(ctx, m.keeper) } + +// MigrateParams migrates from consensus version 4 to 5. +// This migration takes the parameters that are currently stored and managed by x/params +// and stores them directly in the ibc module's state. +func (m Migrator) MigrateParams(ctx sdk.Context) error { + var params types.Params + m.keeper.legacySubspace.GetParamSet(ctx, ¶ms) + + if err := params.Validate(); err != nil { + return err + } + m.keeper.SetParams(ctx, params) + return nil +} diff --git a/modules/core/02-client/keeper/migrations_test.go b/modules/core/02-client/keeper/migrations_test.go new file mode 100644 index 00000000000..0967478017f --- /dev/null +++ b/modules/core/02-client/keeper/migrations_test.go @@ -0,0 +1,43 @@ +package keeper_test + +import ( + "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" + "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" +) + +// TestMigrateParams tests the migration for the client params +func (suite *KeeperTestSuite) TestMigrateParams() { + testCases := []struct { + name string + malleate func() + expectedParams types.Params + }{ + { + "success: default params", + func() { + params := types.DefaultParams() + subspace := suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName) + subspace.SetParamSet(suite.chainA.GetContext(), ¶ms) + }, + types.DefaultParams(), + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + tc.malleate() + + ctx := suite.chainA.GetContext() + migrator := keeper.NewMigrator(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) + err := migrator.MigrateParams(ctx) + suite.Require().NoError(err) + + params := suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.GetParams(ctx) + suite.Require().Equal(tc.expectedParams, params) + }) + } +} diff --git a/modules/core/02-client/keeper/params.go b/modules/core/02-client/keeper/params.go deleted file mode 100644 index 5ed3181472f..00000000000 --- a/modules/core/02-client/keeper/params.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" -) - -// GetAllowedClients retrieves the allowed clients from the paramstore -func (k Keeper) GetAllowedClients(ctx sdk.Context) []string { - var res []string - k.paramSpace.Get(ctx, types.KeyAllowedClients, &res) - return res -} - -// GetParams returns the total set of ibc-client parameters. -func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams(k.GetAllowedClients(ctx)...) -} - -// SetParams sets the total set of ibc-client parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramSpace.SetParamSet(ctx, ¶ms) -} diff --git a/modules/core/02-client/keeper/params_test.go b/modules/core/02-client/keeper/params_test.go deleted file mode 100644 index 49484ad4c85..00000000000 --- a/modules/core/02-client/keeper/params_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package keeper_test - -import ( - "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" -) - -func (suite *KeeperTestSuite) TestParams() { - expParams := types.DefaultParams() - - params := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) - suite.Require().Equal(expParams, params) - - expParams.AllowedClients = []string{} - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetParams(suite.chainA.GetContext(), expParams) - _ = suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) - suite.Require().Empty(expParams.AllowedClients) -} diff --git a/modules/core/02-client/types/codec.go b/modules/core/02-client/types/codec.go index 28dd6eb9688..c3845497802 100644 --- a/modules/core/02-client/types/codec.go +++ b/modules/core/02-client/types/codec.go @@ -46,6 +46,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgUpdateClient{}, &MsgUpgradeClient{}, &MsgSubmitMisbehaviour{}, + &MsgUpdateClientParams{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/02-client/types/keys.go b/modules/core/02-client/types/keys.go index 892268e2368..b30832c5e74 100644 --- a/modules/core/02-client/types/keys.go +++ b/modules/core/02-client/types/keys.go @@ -25,6 +25,9 @@ const ( // KeyNextClientSequence is the key used to store the next client sequence in // the keeper. KeyNextClientSequence = "nextClientSequence" + + // ParamsKey is the store key for the IBC client parameters + ParamsKey = "clientParams" ) // FormatClientIdentifier returns the client identifier with the sequence appended. diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index 48d7c054f86..3db934f30e1 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -15,6 +15,7 @@ var ( _ sdk.Msg = (*MsgUpdateClient)(nil) _ sdk.Msg = (*MsgSubmitMisbehaviour)(nil) _ sdk.Msg = (*MsgUpgradeClient)(nil) + _ sdk.Msg = (*MsgUpdateClientParams)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgCreateClient)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgUpdateClient)(nil) @@ -264,3 +265,28 @@ func (msg MsgSubmitMisbehaviour) UnpackInterfaces(unpacker codectypes.AnyUnpacke var misbehaviour exported.ClientMessage return unpacker.UnpackAny(msg.Misbehaviour, &misbehaviour) } + +// NewMsgUpdateClientParams creates a new instance of MsgUpdateClientParams. +func NewMsgUpdateClientParams(authority string, params Params) *MsgUpdateClientParams { + return &MsgUpdateClientParams{ + Authority: authority, + Params: params, + } +} + +// GetSigners returns the expected signers for a MsgUpdateClientParams message. +func (msg *MsgUpdateClientParams) GetSigners() []sdk.AccAddress { + accAddr, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +// ValidateBasic performs basic checks on a MsgUpdateClientParams. +func (msg *MsgUpdateClientParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + return msg.Params.Validate() +} diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 9eeac2e3908..2f92c4a4ffc 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -609,3 +609,43 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { } } } + +// TestMsgUpdateClientParams_ValidateBasic tests ValidateBasic for MsgUpdateClientParams +func (suite *TypesTestSuite) TestMsgUpdateClientParams_ValidateBasic() { + authority := suite.chainA.App.GetIBCKeeper().GetAuthority() + testCases := []struct { + name string + msg *types.MsgUpdateClientParams + expPass bool + }{ + { + "success: valid authority and params", + types.NewMsgUpdateClientParams(authority, types.DefaultParams()), + true, + }, + { + "success: valid authority empty params", + types.NewMsgUpdateClientParams(authority, types.Params{}), + true, + }, + { + "failure: invalid authority address", + types.NewMsgUpdateClientParams("invalid", types.DefaultParams()), + false, + }, + { + "failure: invalid allowed client", + types.NewMsgUpdateClientParams(authority, types.NewParams("")), + false, + }, + } + + for _, tc := range testCases { + err := tc.msg.ValidateBasic() + if tc.expPass { + suite.Require().NoError(err, "valid case %s failed", tc.name) + } else { + suite.Require().Error(err, "invalid case %s passed", tc.name) + } + } +} diff --git a/modules/core/02-client/types/params.go b/modules/core/02-client/types/params.go index b0c43b156ef..0f2f6b93229 100644 --- a/modules/core/02-client/types/params.go +++ b/modules/core/02-client/types/params.go @@ -4,23 +4,11 @@ import ( "fmt" "strings" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/ibc-go/v7/modules/core/exported" ) -var ( - // DefaultAllowedClients are the default clients for the AllowedClients parameter. - DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, exported.Localhost} - - // KeyAllowedClients is store's key for AllowedClients Params - KeyAllowedClients = []byte("AllowedClients") -) - -// ParamKeyTable type declaration for parameters -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} +// DefaultAllowedClients are the default clients for the AllowedClients parameter. +var DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, exported.Localhost} // NewParams creates a new parameter configuration for the ibc client module func NewParams(allowedClients ...string) Params { @@ -39,13 +27,6 @@ func (p Params) Validate() error { return validateClients(p.AllowedClients) } -// ParamSetPairs implements params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyAllowedClients, p.AllowedClients, validateClients), - } -} - // IsAllowedClient checks if the given client type is registered on the allowlist. func (p Params) IsAllowedClient(clientType string) bool { for _, allowedClient := range p.AllowedClients { @@ -56,12 +37,8 @@ func (p Params) IsAllowedClient(clientType string) bool { return false } -func validateClients(i interface{}) error { - clients, ok := i.([]string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - +// validateClients checks that the given clients are not blank. +func validateClients(clients []string) error { for i, clientType := range clients { if strings.TrimSpace(clientType) == "" { return fmt.Errorf("client type %d cannot be blank", i) diff --git a/modules/core/02-client/types/params_legacy.go b/modules/core/02-client/types/params_legacy.go new file mode 100644 index 00000000000..c903b49f330 --- /dev/null +++ b/modules/core/02-client/types/params_legacy.go @@ -0,0 +1,37 @@ +/* +NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov +controlled execution of MsgUpdateParams messages. These types remains solely +for migration purposes and will be removed in a future release. +[#3621](https://github.com/cosmos/ibc-go/issues/3621) +*/ +package types + +import ( + "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// KeyAllowedClients is store's key for AllowedClients Params +var KeyAllowedClients = []byte("AllowedClients") + +// ParamKeyTable type declaration for parameters +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// ParamSetPairs implements params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyAllowedClients, &p.AllowedClients, validateClientsLegacy), + } +} + +func validateClientsLegacy(i interface{}) error { + clients, ok := i.([]string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return validateClients(clients) +} diff --git a/modules/core/02-client/types/params_test.go b/modules/core/02-client/types/params_test.go index 447b0ffa5c7..d88400eee40 100644 --- a/modules/core/02-client/types/params_test.go +++ b/modules/core/02-client/types/params_test.go @@ -8,6 +8,24 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" ) +func TestIsAllowedClient(t *testing.T) { + testCases := []struct { + name string + clientType string + params Params + expPass bool + }{ + {"success: valid client", exported.Tendermint, DefaultParams(), true}, + {"success: valid client with custom params", exported.Tendermint, NewParams(exported.Tendermint), true}, + {"success: invalid blank client", " ", DefaultParams(), false}, + {"success: invalid client with custom params", exported.Localhost, NewParams(exported.Tendermint), false}, + } + + for _, tc := range testCases { + require.Equal(t, tc.expPass, tc.params.IsAllowedClient(tc.clientType), tc.name) + } +} + func TestValidateParams(t *testing.T) { testCases := []struct { name string diff --git a/modules/core/02-client/types/tx.pb.go b/modules/core/02-client/types/tx.pb.go index 8ac4ff760c0..12f0d629f63 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -362,6 +363,100 @@ func (m *MsgSubmitMisbehaviourResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitMisbehaviourResponse proto.InternalMessageInfo +// MsgUpdateClientParams defines the sdk.Msg type to update the client parameters. +type MsgUpdateClientParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the client parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateClientParams) Reset() { *m = MsgUpdateClientParams{} } +func (m *MsgUpdateClientParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateClientParams) ProtoMessage() {} +func (*MsgUpdateClientParams) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{8} +} +func (m *MsgUpdateClientParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateClientParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateClientParams.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 *MsgUpdateClientParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateClientParams.Merge(m, src) +} +func (m *MsgUpdateClientParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateClientParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateClientParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateClientParams proto.InternalMessageInfo + +func (m *MsgUpdateClientParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateClientParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateClientParamsResponse defines the MsgUpdateClientParams response type. +type MsgUpdateClientParamsResponse struct { +} + +func (m *MsgUpdateClientParamsResponse) Reset() { *m = MsgUpdateClientParamsResponse{} } +func (m *MsgUpdateClientParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateClientParamsResponse) ProtoMessage() {} +func (*MsgUpdateClientParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{9} +} +func (m *MsgUpdateClientParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateClientParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateClientParamsResponse.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 *MsgUpdateClientParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateClientParamsResponse.Merge(m, src) +} +func (m *MsgUpdateClientParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateClientParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateClientParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateClientParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateClient)(nil), "ibc.core.client.v1.MsgCreateClient") proto.RegisterType((*MsgCreateClientResponse)(nil), "ibc.core.client.v1.MsgCreateClientResponse") @@ -371,48 +466,55 @@ func init() { proto.RegisterType((*MsgUpgradeClientResponse)(nil), "ibc.core.client.v1.MsgUpgradeClientResponse") proto.RegisterType((*MsgSubmitMisbehaviour)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviour") proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") + proto.RegisterType((*MsgUpdateClientParams)(nil), "ibc.core.client.v1.MsgUpdateClientParams") + proto.RegisterType((*MsgUpdateClientParamsResponse)(nil), "ibc.core.client.v1.MsgUpdateClientParamsResponse") } func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ - // 561 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0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0x00, - 0x00, + // 656 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0xed, 0xb4, 0x44, 0xcd, 0x35, 0x6d, 0xd1, 0xa9, 0xd0, 0xd4, 0xa5, 0x76, 0x55, 0x18, + 0x5a, 0xa0, 0x76, 0x5b, 0x86, 0x56, 0x05, 0x86, 0xb6, 0x13, 0x43, 0x24, 0xe4, 0x8a, 0x85, 0xa5, + 0xd8, 0xce, 0xf5, 0x6a, 0xa9, 0xf6, 0x59, 0x3e, 0x3b, 0x22, 0x13, 0x12, 0x13, 0x0b, 0x12, 0x13, + 0x13, 0x43, 0x77, 0x16, 0x3e, 0x01, 0x73, 0xc7, 0x8e, 0x4c, 0x08, 0x35, 0x03, 0x7c, 0x0c, 0xe4, + 0xbb, 0x4b, 0x62, 0x3b, 0x76, 0x64, 0xc4, 0x66, 0xfb, 0xfd, 0xde, 0xfd, 0xff, 0xef, 0xdd, 0x3b, + 0x1f, 0x58, 0x71, 0x6d, 0xc7, 0x70, 0x48, 0x88, 0x0c, 0xe7, 0xc2, 0x45, 0x7e, 0x64, 0x74, 0x77, + 0x8c, 0xe8, 0xad, 0x1e, 0x84, 0x24, 0x22, 0x10, 0xba, 0xb6, 0xa3, 0x27, 0x41, 0x9d, 0x07, 0xf5, + 0xee, 0x8e, 0xb2, 0xe4, 0x10, 0xea, 0x11, 0x6a, 0x78, 0x14, 0x27, 0xac, 0x47, 0x31, 0x87, 0x95, + 0x45, 0x4c, 0x30, 0x61, 0x8f, 0x46, 0xf2, 0x24, 0xbe, 0x2e, 0x63, 0x42, 0xf0, 0x05, 0x32, 0xd8, + 0x9b, 0x1d, 0x9f, 0x19, 0x96, 0xdf, 0x13, 0x21, 0xad, 0x40, 0x5a, 0xe8, 0x30, 0x60, 0xfd, 0xab, + 0x0c, 0x16, 0xda, 0x14, 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28, 0xe5, 0x71, 0x15, 0x6a, 0x28, 0x12, 0x02, 0x58, 0x30, 0x8e, 0x9b, 0x25, 0x6b, 0x8c, 0xa3, + 0xca, 0x4e, 0x65, 0x34, 0xad, 0x59, 0x30, 0x43, 0x9b, 0x15, 0x7a, 0xc3, 0xd1, 0x52, 0xcd, 0xf2, + 0xc1, 0x38, 0x32, 0xaf, 0x6e, 0x54, 0xf9, 0xfa, 0x46, 0x95, 0x7f, 0xdd, 0xa8, 0xf2, 0xa7, 0xbe, + 0x2a, 0x5d, 0xf7, 0x55, 0xe9, 0x47, 0x5f, 0x95, 0x5e, 0xef, 0x63, 0x37, 0x3a, 0x8f, 0x6d, 0xdd, + 0x21, 0x9e, 0x21, 0xee, 0x36, 0xd7, 0x76, 0xb6, 0x30, 0x31, 0xba, 0x7b, 0x86, 0x47, 0x3a, 0xf1, + 0x05, 0xa2, 0xfc, 0x9a, 0xda, 0xde, 0xdd, 0x12, 0x37, 0x55, 0xd4, 0x0b, 0x10, 0xb5, 0xeb, 0xec, + 0xd4, 0x3d, 0xf9, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xd8, 0xf7, 0x9b, 0xad, 0x44, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -435,6 +537,8 @@ type MsgClient interface { UpgradeClient(ctx context.Context, in *MsgUpgradeClient, opts ...grpc.CallOption) (*MsgUpgradeClientResponse, error) // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) + // UpdateClientParams defines a rpc handler method for MsgUpdateClientParams. + UpdateClientParams(ctx context.Context, in *MsgUpdateClientParams, opts ...grpc.CallOption) (*MsgUpdateClientParamsResponse, error) } type msgClient struct { @@ -481,6 +585,15 @@ func (c *msgClient) SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbeha return out, nil } +func (c *msgClient) UpdateClientParams(ctx context.Context, in *MsgUpdateClientParams, opts ...grpc.CallOption) (*MsgUpdateClientParamsResponse, error) { + out := new(MsgUpdateClientParamsResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/UpdateClientParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // CreateClient defines a rpc handler method for MsgCreateClient. @@ -491,6 +604,8 @@ type MsgServer interface { UpgradeClient(context.Context, *MsgUpgradeClient) (*MsgUpgradeClientResponse, error) // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. SubmitMisbehaviour(context.Context, *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) + // UpdateClientParams defines a rpc handler method for MsgUpdateClientParams. + UpdateClientParams(context.Context, *MsgUpdateClientParams) (*MsgUpdateClientParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -509,6 +624,9 @@ func (*UnimplementedMsgServer) UpgradeClient(ctx context.Context, req *MsgUpgrad func (*UnimplementedMsgServer) SubmitMisbehaviour(ctx context.Context, req *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SubmitMisbehaviour not implemented") } +func (*UnimplementedMsgServer) UpdateClientParams(ctx context.Context, req *MsgUpdateClientParams) (*MsgUpdateClientParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateClientParams not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -586,6 +704,24 @@ func _Msg_SubmitMisbehaviour_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_UpdateClientParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateClientParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateClientParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Msg/UpdateClientParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateClientParams(ctx, req.(*MsgUpdateClientParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.client.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -606,6 +742,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "SubmitMisbehaviour", Handler: _Msg_SubmitMisbehaviour_Handler, }, + { + MethodName: "UpdateClientParams", + Handler: _Msg_UpdateClientParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/client/v1/tx.proto", @@ -930,6 +1070,69 @@ func (m *MsgSubmitMisbehaviourResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgUpdateClientParams) 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 *MsgUpdateClientParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateClientParams) 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateClientParamsResponse) 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 *MsgUpdateClientParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateClientParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1073,6 +1276,30 @@ func (m *MsgSubmitMisbehaviourResponse) Size() (n int) { return n } +func (m *MsgUpdateClientParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateClientParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1987,6 +2214,171 @@ func (m *MsgSubmitMisbehaviourResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateClientParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateClientParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateClientParams: 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateClientParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateClientParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateClientParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 6a2c40ab1af..1eefcdc2b3d 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -33,13 +33,15 @@ type Keeper struct { ChannelKeeper channelkeeper.Keeper PortKeeper portkeeper.Keeper Router *porttypes.Router + + authority string } // NewKeeper creates a new ibc Keeper func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, stakingKeeper clienttypes.StakingKeeper, upgradeKeeper clienttypes.UpgradeKeeper, - scopedKeeper capabilitykeeper.ScopedKeeper, + scopedKeeper capabilitykeeper.ScopedKeeper, authority string, ) *Keeper { // register paramSpace at top level keeper // set KeyTable if it has not already been set @@ -72,6 +74,7 @@ func NewKeeper( ConnectionKeeper: connectionKeeper, ChannelKeeper: channelKeeper, PortKeeper: portKeeper, + authority: authority, } } @@ -92,6 +95,11 @@ func (k *Keeper) SetRouter(rtr *porttypes.Router) { k.Router.Seal() } +// GetAuthority returns the client submodule's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + // isEmpty checks if the interface is an empty struct or a pointer pointing // to an empty struct func isEmpty(keeper interface{}) bool { diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index dfe676fe37d..8f927fb1815 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -70,6 +70,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { stakingKeeper, upgradeKeeper, scopedKeeper, + suite.chainA.App.GetIBCKeeper().GetAuthority(), ) } ) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index e43aff4fdca..b205462d70a 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -12,6 +12,7 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" coretypes "github.com/cosmos/ibc-go/v7/modules/core/types" ) @@ -693,3 +694,15 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn return &channeltypes.MsgAcknowledgementResponse{Result: channeltypes.SUCCESS}, nil } + +// UpdateClientParams defines a rpc handler method for MsgUpdateClientParams. +func (k Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUpdateClientParams) (*clienttypes.MsgUpdateClientParamsResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + k.ClientKeeper.SetParams(ctx, msg.Params) + + return &clienttypes.MsgUpdateClientParamsResponse{}, nil +} diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index b46dbcff4c8..ab10dee7d80 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -774,3 +774,54 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { } } } + +// TestUpdateClientParams tests the UpdateClientParams rpc handler +func (suite *KeeperTestSuite) TestUpdateClientParams() { + validAuthority := suite.chainA.App.GetIBCKeeper().GetAuthority() + testCases := []struct { + name string + msg *clienttypes.MsgUpdateClientParams + expPass bool + }{ + { + "success: valid authority and default params", + clienttypes.NewMsgUpdateClientParams(validAuthority, clienttypes.DefaultParams()), + true, + }, + { + "failure: malformed authority address", + clienttypes.NewMsgUpdateClientParams(ibctesting.InvalidID, clienttypes.DefaultParams()), + false, + }, + { + "failure: empty authority address", + clienttypes.NewMsgUpdateClientParams("", clienttypes.DefaultParams()), + false, + }, + { + "failure: whitespace authority address", + clienttypes.NewMsgUpdateClientParams(" ", clienttypes.DefaultParams()), + false, + }, + { + "failure: unauthorized authority address", + clienttypes.NewMsgUpdateClientParams(ibctesting.TestAccAddress, clienttypes.DefaultParams()), + false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + _, err := keeper.Keeper.UpdateClientParams(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), tc.msg) + if tc.expPass { + suite.Require().NoError(err) + p := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(tc.msg.Params, p) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/modules/core/module.go b/modules/core/module.go index 4eeb48e1a25..1abee13facd 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -137,6 +137,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { }); err != nil { panic(err) } + + if err := cfg.RegisterMigration(exported.ModuleName, 4, clientMigrator.MigrateParams); err != nil { + panic(err) + } } // InitGenesis performs genesis initialization for the ibc module. It returns @@ -158,7 +162,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 4 } +func (AppModule) ConsensusVersion() uint64 { return 5 } // BeginBlock returns the begin blocker for the ibc module. func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto index 9388dbc9dd5..b52eda0cf6d 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -4,8 +4,10 @@ package ibc.core.client.v1; option go_package = "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"; +import "cosmos/msg/v1/msg.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; +import "ibc/core/client/v1/client.proto"; // Msg defines the ibc/client Msg service. service Msg { @@ -20,6 +22,9 @@ service Msg { // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. rpc SubmitMisbehaviour(MsgSubmitMisbehaviour) returns (MsgSubmitMisbehaviourResponse); + + // UpdateClientParams defines a rpc handler method for MsgUpdateClientParams. + rpc UpdateClientParams(MsgUpdateClientParams) returns (MsgUpdateClientParamsResponse); } // MsgCreateClient defines a message to create an IBC client @@ -98,3 +103,19 @@ message MsgSubmitMisbehaviour { // MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response // type. message MsgSubmitMisbehaviourResponse {} + +// MsgUpdateClientParams defines the sdk.Msg type to update the client parameters. +message MsgUpdateClientParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + string authority = 1; + + // params defines the client parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false]; +} + +// MsgUpdateClientParamsResponse defines the MsgUpdateClientParams response type. +message MsgUpdateClientParamsResponse {} \ No newline at end of file diff --git a/testing/simapp/app.go b/testing/simapp/app.go index e0fe1ebda7c..468c0a12115 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -373,7 +373,7 @@ func NewSimApp( // IBC Keepers app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // register the proposal types