From 552a70f4532730e02c8ad1c95edfecf32328201e Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 24 Apr 2023 11:07:04 +0300 Subject: [PATCH 01/13] feat(client): migrate client params --- modules/core/02-client/exported/exported.go | 18 + modules/core/02-client/genesis.go | 3 + modules/core/02-client/keeper/keeper.go | 34 +- modules/core/02-client/keeper/migrations.go | 15 + .../core/02-client/keeper/migrations_test.go | 43 ++ modules/core/02-client/keeper/params.go | 21 +- modules/core/02-client/keeper/params_test.go | 52 +- modules/core/02-client/types/codec.go | 1 + modules/core/02-client/types/keys.go | 3 + modules/core/02-client/types/msgs.go | 26 + modules/core/02-client/types/msgs_test.go | 40 ++ modules/core/02-client/types/params.go | 31 +- modules/core/02-client/types/params_legacy.go | 31 ++ modules/core/02-client/types/params_test.go | 18 + modules/core/02-client/types/tx.pb.go | 469 ++++++++++++++++-- modules/core/keeper/keeper.go | 6 +- modules/core/keeper/msg_server.go | 14 + modules/core/module.go | 6 +- proto/ibc/core/client/v1/tx.proto | 22 + 19 files changed, 763 insertions(+), 90 deletions(-) create mode 100644 modules/core/02-client/exported/exported.go create mode 100644 modules/core/02-client/keeper/migrations_test.go create mode 100644 modules/core/02-client/types/params_legacy.go diff --git a/modules/core/02-client/exported/exported.go b/modules/core/02-client/exported/exported.go new file mode 100644 index 00000000000..000114e6194 --- /dev/null +++ b/modules/core/02-client/exported/exported.go @@ -0,0 +1,18 @@ +package exported + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +type ( + ParamSet = paramtypes.ParamSet + + // Subspace defines an interface that implements the legacy x/params Subspace + // type. + // + // NOTE: This is used solely for migration of x/params managed parameters. + Subspace interface { + GetParamSet(ctx sdk.Context, ps ParamSet) + } +) 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..da503220382 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -27,26 +27,29 @@ 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 + + authority string } // 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, authority string) 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, + authority: authority, } } @@ -413,3 +416,8 @@ func (k Keeper) GetClientStatus(ctx sdk.Context, clientState exported.ClientStat } return clientState.Status(ctx, k.ClientStore(ctx, clientID), k.cdc) } + +// GetAuthority returns the client module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} 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 index 5ed3181472f..c519813da13 100644 --- a/modules/core/02-client/keeper/params.go +++ b/modules/core/02-client/keeper/params.go @@ -6,19 +6,28 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ) -// GetAllowedClients retrieves the allowed clients from the paramstore +// GetAllowedClients retrieves the allowed clients from the params stored. func (k Keeper) GetAllowedClients(ctx sdk.Context) []string { - var res []string - k.paramSpace.Get(ctx, types.KeyAllowedClients, &res) - return res + p := k.GetParams(ctx) + return p.AllowedClients } // GetParams returns the total set of ibc-client parameters. func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams(k.GetAllowedClients(ctx)...) + store := ctx.KVStore(k.storeKey) + bz := store.Get([]byte(types.ParamsKey)) + if bz == nil { + panic("ibc client params are not set in store") + } + + var p types.Params + k.cdc.MustUnmarshal(bz, &p) + return p } // SetParams sets the total set of ibc-client parameters. func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramSpace.SetParamSet(ctx, ¶ms) + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.ParamsKey), bz) } diff --git a/modules/core/02-client/keeper/params_test.go b/modules/core/02-client/keeper/params_test.go index 49484ad4c85..976eb9bcc83 100644 --- a/modules/core/02-client/keeper/params_test.go +++ b/modules/core/02-client/keeper/params_test.go @@ -2,16 +2,58 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ) -func (suite *KeeperTestSuite) TestParams() { +// TestDefaultSetParams tests the default params set are what is expected +func (suite *KeeperTestSuite) TestDefaultSetParams() { expParams := types.DefaultParams() params := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) suite.Require().Equal(expParams, params) +} + +// 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(ibcexported.Tendermint, ibcexported.Localhost), true}, + {"failure: contains a single empty string value as allowedClient", types.NewParams(ibcexported.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 panics. +func (suite *KeeperTestSuite) TestUnsetParams() { + suite.SetupTest() + ctx := suite.chainA.GetContext() + store := ctx.KVStore(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)) + store.Delete([]byte(types.ParamsKey)) - 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) + suite.Require().Panics(func() { + suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.GetParams(ctx) + }) } 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..f01d724a858 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().ClientKeeper.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..7525730913f --- /dev/null +++ b/modules/core/02-client/types/params_legacy.go @@ -0,0 +1,31 @@ +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..e7f98a40811 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 + }{ + {"valid client", exported.Tendermint, DefaultParams(), true}, + {"valid client with custom params", exported.Tendermint, NewParams(exported.Tendermint), true}, + {"invalid blank client", " ", DefaultParams(), false}, + {"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..f4f3947836b 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -6,7 +6,9 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" 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 +364,100 @@ func (m *MsgSubmitMisbehaviourResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitMisbehaviourResponse proto.InternalMessageInfo +// MsgUpdateParams 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{} +} + +// MsgUpdateParamsResponse 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 +467,57 @@ 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, 0x54, 0x4d, 0x6f, 0x12, 0x41, - 0x18, 0x66, 0x40, 0x49, 0x99, 0xd2, 0xd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f, 0x86, 0x65, 0x6f, 0x89, 0xb0, 0xa9, 0xcb, 0x8a, 0x19, 0x43, 0x23, 0x23, 0xbe, - 0x12, 0x0a, 0xb1, 0x6a, 0xbd, 0x06, 0x0f, 0xd7, 0xba, 0x9b, 0xfb, 0x6f, 0x7f, 0x2b, 0xc0, 0x42, - 0x47, 0x32, 0xf4, 0x01, 0x96, 0x63, 0x47, 0xf9, 0x08, 0xaf, 0x9e, 0x3b, 0x4e, 0x1c, 0x83, 0xf1, - 0x34, 0x03, 0x68, 0xae, 0x34, 0x55, 0x88, 0x5d, 0x4b, 0x9a, 0xc2, 0x32, 0x28, 0x55, 0x61, 0xdd, - 0xa2, 0x23, 0x17, 0xee, 0xc4, 0xb7, 0xe3, 0x71, 0x2a, 0x7b, 0x09, 0x65, 0x3c, 0xcb, 0x82, 0x5a, - 0x88, 0x04, 0x10, 0xad, 0x19, 0xf6, 0x93, 0x94, 0x1c, 0xab, 0x50, 0xa3, 0x95, 0x19, 0x3a, 0xd7, - 0x3c, 0xb3, 0x7e, 0x8e, 0x4d, 0x70, 0x33, 0x36, 0xc1, 0xef, 0xb1, 0x09, 0xbe, 0x4c, 0xcc, 0xdc, - 0xcd, 0xc4, 0xcc, 0xfd, 0x9a, 0x98, 0xb9, 0xf7, 0x2f, 0x18, 0x0f, 0xaf, 0x22, 0x07, 0xbb, 0xc2, - 0x23, 0xae, 0x90, 0x9e, 0x90, 0x84, 0x3b, 0xee, 0x11, 0x13, 0x64, 0x78, 0x42, 0x3c, 0xd1, 0x8b, - 0xfa, 0x54, 0xea, 0x17, 0xfd, 0xb8, 0x7d, 0x34, 0x7b, 0xd4, 0xc3, 0xd1, 0x80, 0x4a, 0xa7, 0xa8, - 0xf6, 0xeb, 0xf9, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x54, 0x95, 0x90, 0xf4, 0x05, 0x00, - 0x00, + // 684 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00,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 0x7a, 0x9e, 0x42, 0x1c, 0x94, 0xab, 0x90, 0x75, + 0x4a, 0xa1, 0x0b, 0x66, 0x92, 0xa3, 0x7d, 0x37, 0x37, 0x3b, 0x86, 0xd2, 0x1f, 0x14, 0x41, 0x0d, + 0x45, 0x18, 0x80, 0x19, 0x93, 0xba, 0x96, 0xc3, 0x31, 0x0a, 0xd5, 0x37, 0x0b, 0x43, 0xe3, 0x9a, + 0x19, 0xd3, 0xb5, 0x56, 0xa0, 0x37, 0x12, 0x9a, 0xab, 0x99, 0x3f, 0x18, 0xfb, 0xd6, 0xd9, 0x45, + 0x53, 0x3b, 0xbf, 0x68, 0x6a, 0xbf, 0x2e, 0x9a, 0xda, 0xfb, 0xcb, 0x66, 0xe9, 0xfc, 0xb2, 0x59, + 0xfa, 0x71, 0xd9, 0x2c, 0xbd, 0xdc, 0xc1, 0x44, 0x1c, 0x87, 0x8e, 0xe1, 0x52, 0x5f, 0x3d, 0x82, + 0x26, 0x71, 0xdc, 0x75, 0x4c, 0xcd, 0xde, 0xb6, 0xe9, 0x53, 0x2f, 0x3c, 0x41, 0x5c, 0x3e, 0x79, + 0x1b, 0x5b, 0xeb, 0xea, 0xd5, 0x13, 0xfd, 0x2e, 0xe2, 0x4e, 0x25, 0x3a, 0x90, 0x0f, 0xff, 0x06, + 0x00, 0x00, 0xff, 0xff, 0x3e, 0x31, 0xdd, 0xb8, 0x7a, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -435,6 +540,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 +588,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 +607,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 +627,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 +707,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 +745,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 +1073,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 +1279,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 +2217,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..afc76b56a49 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -6,6 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" @@ -61,7 +63,9 @@ func NewKeeper( panic(fmt.Errorf("cannot initialize IBC keeper: empty scoped keeper")) } - clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper, upgradeKeeper) + authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() + + clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper, upgradeKeeper, authority) connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index e43aff4fdca..1bb29720530 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,16 @@ 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) { + ck := k.ClientKeeper + if ck.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", ck.GetAuthority(), msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + ck.SetParams(ctx, msg.Params) + + return &clienttypes.MsgUpdateClientParamsResponse{}, nil +} 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..7a76ae77ca8 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -4,6 +4,9 @@ package ibc.core.client.v1; option go_package = "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; +import "ibc/core/client/v1/client.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; @@ -20,6 +23,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 +104,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 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // 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 From 25e786c73208ea7153e55c5072901fc4cac44a87 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 24 May 2023 19:36:50 +0300 Subject: [PATCH 02/13] Address initial feedback. --- modules/core/02-client/exported/exported.go | 18 ---- modules/core/02-client/keeper/keeper.go | 2 + modules/core/02-client/keeper/params.go | 4 +- modules/core/02-client/keeper/params_test.go | 6 +- modules/core/02-client/types/params_legacy.go | 6 ++ modules/core/02-client/types/params_test.go | 8 +- modules/core/02-client/types/tx.pb.go | 92 +++++++++---------- proto/ibc/core/client/v1/tx.proto | 5 +- 8 files changed, 62 insertions(+), 79 deletions(-) delete mode 100644 modules/core/02-client/exported/exported.go diff --git a/modules/core/02-client/exported/exported.go b/modules/core/02-client/exported/exported.go deleted file mode 100644 index 000114e6194..00000000000 --- a/modules/core/02-client/exported/exported.go +++ /dev/null @@ -1,18 +0,0 @@ -package exported - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -type ( - ParamSet = paramtypes.ParamSet - - // Subspace defines an interface that implements the legacy x/params Subspace - // type. - // - // NOTE: This is used solely for migration of x/params managed parameters. - Subspace interface { - GetParamSet(ctx sdk.Context, ps ParamSet) - } -) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index da503220382..d1c070f6d89 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -33,6 +33,8 @@ type Keeper struct { stakingKeeper types.StakingKeeper upgradeKeeper types.UpgradeKeeper + // the address capable of executing a MsgUpdateClientParams message. Typically, this + // should be the x/gov module account. authority string } diff --git a/modules/core/02-client/keeper/params.go b/modules/core/02-client/keeper/params.go index c519813da13..a15f3ef22f5 100644 --- a/modules/core/02-client/keeper/params.go +++ b/modules/core/02-client/keeper/params.go @@ -14,13 +14,13 @@ func (k Keeper) GetAllowedClients(ctx sdk.Context) []string { // GetParams returns the total set of ibc-client parameters. func (k Keeper) GetParams(ctx sdk.Context) types.Params { + var p types.Params store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.ParamsKey)) if bz == nil { - panic("ibc client params are not set in store") + return p } - var p types.Params k.cdc.MustUnmarshal(bz, &p) return p } diff --git a/modules/core/02-client/keeper/params_test.go b/modules/core/02-client/keeper/params_test.go index 976eb9bcc83..8146f87f11f 100644 --- a/modules/core/02-client/keeper/params_test.go +++ b/modules/core/02-client/keeper/params_test.go @@ -46,14 +46,12 @@ func (suite *KeeperTestSuite) TestParams() { } } -// TestUnsetParams tests that trying to get params that are not set panics. +// 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(ibcexported.StoreKey)) store.Delete([]byte(types.ParamsKey)) - suite.Require().Panics(func() { - suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.GetParams(ctx) - }) + suite.Require().Equal(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.GetParams(ctx), types.Params{}) } diff --git a/modules/core/02-client/types/params_legacy.go b/modules/core/02-client/types/params_legacy.go index 7525730913f..c903b49f330 100644 --- a/modules/core/02-client/types/params_legacy.go +++ b/modules/core/02-client/types/params_legacy.go @@ -1,3 +1,9 @@ +/* +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 ( diff --git a/modules/core/02-client/types/params_test.go b/modules/core/02-client/types/params_test.go index e7f98a40811..d88400eee40 100644 --- a/modules/core/02-client/types/params_test.go +++ b/modules/core/02-client/types/params_test.go @@ -15,10 +15,10 @@ func TestIsAllowedClient(t *testing.T) { params Params expPass bool }{ - {"valid client", exported.Tendermint, DefaultParams(), true}, - {"valid client with custom params", exported.Tendermint, NewParams(exported.Tendermint), true}, - {"invalid blank client", " ", DefaultParams(), false}, - {"invalid client with custom params", exported.Localhost, NewParams(exported.Tendermint), false}, + {"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 { diff --git a/modules/core/02-client/types/tx.pb.go b/modules/core/02-client/types/tx.pb.go index f4f3947836b..82249a19039 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" 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" @@ -364,7 +363,7 @@ func (m *MsgSubmitMisbehaviourResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitMisbehaviourResponse proto.InternalMessageInfo -// MsgUpdateParams defines the sdk.Msg type to update the client parameters. +// 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"` @@ -421,7 +420,7 @@ func (m *MsgUpdateClientParams) GetParams() Params { return Params{} } -// MsgUpdateParamsResponse defines the MsgUpdateClientParams response type. +// MsgUpdateClientParamsResponse defines the MsgUpdateClientParams response type. type MsgUpdateClientParamsResponse struct { } @@ -474,50 +473,49 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ - // 684 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xbf, 0x4f, 0x14, 0x41, - 0x14, 0xbe, 0x3d, 0xf0, 0xc2, 0x0d, 0x07, 0x98, 0xc9, 0x29, 0xc7, 0x12, 0xee, 0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- 0x45, 0x18, 0x80, 0x19, 0x93, 0xba, 0x96, 0xc3, 0x31, 0x0a, 0xd5, 0x37, 0x0b, 0x43, 0xe3, 0x9a, - 0x19, 0xd3, 0xb5, 0x56, 0xa0, 0x37, 0x12, 0x9a, 0xab, 0x99, 0x3f, 0x18, 0xfb, 0xd6, 0xd9, 0x45, - 0x53, 0x3b, 0xbf, 0x68, 0x6a, 0xbf, 0x2e, 0x9a, 0xda, 0xfb, 0xcb, 0x66, 0xe9, 0xfc, 0xb2, 0x59, - 0xfa, 0x71, 0xd9, 0x2c, 0xbd, 0xdc, 0xc1, 0x44, 0x1c, 0x87, 0x8e, 0xe1, 0x52, 0x5f, 0x3d, 0x82, - 0x26, 0x71, 0xdc, 0x75, 0x4c, 0xcd, 0xde, 0xb6, 0xe9, 0x53, 0x2f, 0x3c, 0x41, 0x5c, 0x3e, 0x79, - 0x1b, 0x5b, 0xeb, 0xea, 0xd5, 0x13, 0xfd, 0x2e, 0xe2, 0x4e, 0x25, 0x3a, 0x90, 0x0f, 0xff, 0x06, - 0x00, 0x00, 0xff, 0xff, 0x3e, 0x31, 0xdd, 0xb8, 0x7a, 0x07, 0x00, 0x00, + // 662 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0xe3, 0xb4, 0x44, 0xcd, 0x35, 0x6d, 0xd1, 0x29, 0x40, 0xea, 0xaa, 0x49, 0x55, 0x18, + 0x5a, 0x41, 0xed, 0xb6, 0x48, 0xb4, 0xe2, 0xc7, 0xd0, 0x76, 0x62, 0x88, 0x84, 0x5c, 0xb1, 0xb0, + 0x04, 0xff, 0xb8, 0x5e, 0x4f, 0xaa, 0x7d, 0xd1, 0xdd, 0x39, 0x22, 0xff, 0x01, 0x0c, 0x48, 0x4c, + 0x4c, 0x0c, 0xdd, 0x59, 0x99, 0x99, 0x3b,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 0xfa, 0x6e, 0xb3, 0x89, 0xe7, 0x6f, 0x60, 0x6a, + 0x0f, 0x76, 0xec, 0x90, 0x06, 0xf1, 0x09, 0xe2, 0xea, 0xc6, 0xda, 0xdc, 0xde, 0xd0, 0x97, 0x96, + 0x18, 0xf6, 0x11, 0xf7, 0x6a, 0x72, 0x03, 0x3e, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x3a, + 0x40, 0xc8, 0x51, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto index 7a76ae77ca8..42f2f517045 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -5,10 +5,9 @@ package ibc.core.client.v1; option go_package = "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"; import "cosmos_proto/cosmos.proto"; -import "cosmos/msg/v1/msg.proto"; -import "ibc/core/client/v1/client.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 { @@ -107,8 +106,6 @@ 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 [(cosmos_proto.scalar) = "cosmos.AddressString"]; From 1d8afc248d84dc0c3d7480fe38a2f0394d5de124 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 25 May 2023 12:02:01 +0300 Subject: [PATCH 03/13] Use anonymous function as handler. --- modules/core/module.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/core/module.go b/modules/core/module.go index 1abee13facd..1e85990611e 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -138,7 +138,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { panic(err) } - if err := cfg.RegisterMigration(exported.ModuleName, 4, clientMigrator.MigrateParams); err != nil { + if err := cfg.RegisterMigration(exported.ModuleName, 4, func(ctx sdk.Context) error { + return clientMigrator.MigrateParams(ctx) + }); err != nil { panic(err) } } From e014f5e6c2a0a26ec41a2af8a1a08e46876c5616 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 25 May 2023 12:23:13 +0300 Subject: [PATCH 04/13] Add tests for msg_server. whoops. --- modules/core/keeper/msg_server_test.go | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index b46dbcff4c8..933401dc282 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -774,3 +774,52 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { } } } + +// TestUpdateClientParams tests the UpdateClientParams rpc handler +func (suite *KeeperTestSuite) TestUpdateClientParams() { + validAuthority := suite.chainA.App.GetIBCKeeper().ClientKeeper.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) + } else { + suite.Require().Error(err) + } + }) + } +} From b30ead1a05fa24d01d91a2e2503596103599c6be Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 25 May 2023 13:14:35 +0300 Subject: [PATCH 05/13] Revert anon function as handler. --- modules/core/module.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/core/module.go b/modules/core/module.go index 1e85990611e..1abee13facd 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -138,9 +138,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { panic(err) } - if err := cfg.RegisterMigration(exported.ModuleName, 4, func(ctx sdk.Context) error { - return clientMigrator.MigrateParams(ctx) - }); err != nil { + if err := cfg.RegisterMigration(exported.ModuleName, 4, clientMigrator.MigrateParams); err != nil { panic(err) } } From 530795073f42ed2d452f73947d2b23d998bb53c7 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Thu, 25 May 2023 13:32:22 +0300 Subject: [PATCH 06/13] Implicitly test GetAllowedClients in TestDefaultSetParams. --- modules/core/02-client/keeper/params_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/core/02-client/keeper/params_test.go b/modules/core/02-client/keeper/params_test.go index 8146f87f11f..0f25a015dff 100644 --- a/modules/core/02-client/keeper/params_test.go +++ b/modules/core/02-client/keeper/params_test.go @@ -9,8 +9,11 @@ import ( func (suite *KeeperTestSuite) TestDefaultSetParams() { expParams := types.DefaultParams() - params := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) + clientKeeper := suite.chainA.App.GetIBCKeeper().ClientKeeper + params := clientKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) + suite.Require().Equal(expParams.AllowedClients, clientKeeper.GetAllowedClients(suite.chainA.GetContext())) } // TestParams tests that Param setting and retrieval works properly From 5d91eaad6155beace17318ad5104a49b412c9d7b Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Fri, 26 May 2023 11:52:51 +0300 Subject: [PATCH 07/13] Consistency is more important than perfection. --- modules/core/02-client/keeper/keeper.go | 28 ++++++--- modules/core/02-client/keeper/keeper_test.go | 54 ++++++++++++++++++ modules/core/02-client/keeper/params.go | 33 ----------- modules/core/02-client/keeper/params_test.go | 60 -------------------- modules/core/02-client/types/msgs_test.go | 2 +- modules/core/keeper/keeper.go | 18 ++++-- modules/core/keeper/keeper_test.go | 1 + modules/core/keeper/msg_server.go | 7 +-- modules/core/keeper/msg_server_test.go | 2 +- testing/simapp/app.go | 2 +- 10 files changed, 92 insertions(+), 115 deletions(-) delete mode 100644 modules/core/02-client/keeper/params.go delete mode 100644 modules/core/02-client/keeper/params_test.go diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index d1c070f6d89..ef38306333e 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -32,14 +32,10 @@ type Keeper struct { legacySubspace paramtypes.Subspace stakingKeeper types.StakingKeeper upgradeKeeper types.UpgradeKeeper - - // the address capable of executing a MsgUpdateClientParams message. Typically, this - // should be the x/gov module account. - authority string } // NewKeeper creates a new NewKeeper instance -func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, sk types.StakingKeeper, uk types.UpgradeKeeper, authority string) 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 !legacySubspace.HasKeyTable() { legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable()) @@ -51,7 +47,6 @@ func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace pa legacySubspace: legacySubspace, stakingKeeper: sk, upgradeKeeper: uk, - authority: authority, } } @@ -419,7 +414,22 @@ func (k Keeper) GetClientStatus(ctx sdk.Context, clientState exported.ClientStat return clientState.Status(ctx, k.ClientStore(ctx, clientID), k.cdc) } -// GetAuthority returns the client module's authority. -func (k Keeper) GetAuthority() string { - return k.authority +// GetParams returns the total set of ibc-client parameters. +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + var p types.Params + store := ctx.KVStore(k.storeKey) + bz := store.Get([]byte(types.ParamsKey)) + if bz == nil { + return types.Params{} + } + + k.cdc.MustUnmarshal(bz, &p) + return p +} + +// 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/params.go b/modules/core/02-client/keeper/params.go deleted file mode 100644 index a15f3ef22f5..00000000000 --- a/modules/core/02-client/keeper/params.go +++ /dev/null @@ -1,33 +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 params stored. -func (k Keeper) GetAllowedClients(ctx sdk.Context) []string { - p := k.GetParams(ctx) - return p.AllowedClients -} - -// GetParams returns the total set of ibc-client parameters. -func (k Keeper) GetParams(ctx sdk.Context) types.Params { - var p types.Params - store := ctx.KVStore(k.storeKey) - bz := store.Get([]byte(types.ParamsKey)) - if bz == nil { - return p - } - - k.cdc.MustUnmarshal(bz, &p) - return p -} - -// 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/params_test.go b/modules/core/02-client/keeper/params_test.go deleted file mode 100644 index 0f25a015dff..00000000000 --- a/modules/core/02-client/keeper/params_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package keeper_test - -import ( - "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" -) - -// 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.GetAllowedClients(suite.chainA.GetContext())) -} - -// 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(ibcexported.Tendermint, ibcexported.Localhost), true}, - {"failure: contains a single empty string value as allowedClient", types.NewParams(ibcexported.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(ibcexported.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/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index f01d724a858..2f92c4a4ffc 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -612,7 +612,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { // TestMsgUpdateClientParams_ValidateBasic tests ValidateBasic for MsgUpdateClientParams func (suite *TypesTestSuite) TestMsgUpdateClientParams_ValidateBasic() { - authority := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetAuthority() + authority := suite.chainA.App.GetIBCKeeper().GetAuthority() testCases := []struct { name string msg *types.MsgUpdateClientParams diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index afc76b56a49..454cfc71a81 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -6,8 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" @@ -35,13 +33,17 @@ type Keeper struct { ChannelKeeper channelkeeper.Keeper PortKeeper portkeeper.Keeper Router *porttypes.Router + + // the address capable of executing a MsgUpdateClientParams message. Typically, this + // should be the x/gov module account. + 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 @@ -63,9 +65,7 @@ func NewKeeper( panic(fmt.Errorf("cannot initialize IBC keeper: empty scoped keeper")) } - authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() - - clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper, upgradeKeeper, authority) + clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper, upgradeKeeper) connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) @@ -76,6 +76,7 @@ func NewKeeper( ConnectionKeeper: connectionKeeper, ChannelKeeper: channelKeeper, PortKeeper: portKeeper, + authority: authority, } } @@ -96,6 +97,11 @@ func (k *Keeper) SetRouter(rtr *porttypes.Router) { k.Router.Seal() } +// GetAuthority returns the client module'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 1bb29720530..b205462d70a 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -697,13 +697,12 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn // UpdateClientParams defines a rpc handler method for MsgUpdateClientParams. func (k Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUpdateClientParams) (*clienttypes.MsgUpdateClientParamsResponse, error) { - ck := k.ClientKeeper - if ck.GetAuthority() != msg.Authority { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", ck.GetAuthority(), msg.Authority) + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) - ck.SetParams(ctx, msg.Params) + 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 933401dc282..ac6ba876e75 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -777,7 +777,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { // TestUpdateClientParams tests the UpdateClientParams rpc handler func (suite *KeeperTestSuite) TestUpdateClientParams() { - validAuthority := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetAuthority() + validAuthority := suite.chainA.App.GetIBCKeeper().GetAuthority() testCases := []struct { name string msg *clienttypes.MsgUpdateClientParams 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 From e483b3b53822f154b7bdc7c09a7c965294a08408 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 30 May 2023 13:24:39 +0300 Subject: [PATCH 08/13] Add msg.signer option back, remove cosmos.scalar for the time being. --- modules/core/02-client/types/tx.pb.go | 87 +++++++++++++-------------- proto/ibc/core/client/v1/tx.proto | 6 +- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/modules/core/02-client/types/tx.pb.go b/modules/core/02-client/types/tx.pb.go index 82249a19039..12f0d629f63 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -6,8 +6,8 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" 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" @@ -473,49 +473,48 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ - // 662 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0xe3, 0xb4, 0x44, 0xcd, 0x35, 0x6d, 0xd1, 0x29, 0x40, 0xea, 0xaa, 0x49, 0x55, 0x18, - 0x5a, 0x41, 0xed, 0xb6, 0x48, 0xb4, 0xe2, 0xc7, 0xd0, 0x76, 0x62, 0x88, 0x84, 0x5c, 0xb1, 0xb0, - 0x04, 0xff, 0xb8, 0x5e, 0x4f, 0xaa, 0x7d, 0xd1, 0xdd, 0x39, 0x22, 0xff, 0x01, 0x0c, 0x48, 0x4c, - 0x4c, 0x0c, 0xdd, 0x59, 0x99, 0x99, 0x3b, 0x56, 0x4c, 0x4c, 0x08, 0xb5, 0x0b, 0x7f, 0x06, 0xca, - 0xdd, 0x35, 0xb5, 0x1d, 0xbb, 0x32, 0x62, 0xb3, 0xfd, 0x3e, 0xef, 0xbe, 0xdf, 0xf7, 0xfc, 0xee, - 0x0e, 0x2c, 0x11, 0xcf, 0xb7, 0x7d, 0xca, 0x90, 0xed, 0x9f, 0x10, 0x14, 0x09, 0x7b, 0xb0, 0x65, - 0x8b, 0x77, 0x56, 0x9f, 0x51, 0x41, 0x21, 0x24, 0x9e, 0x6f, 0x8d, 0x82, 0x96, 0x0a, 0x5a, 0x83, - 0x2d, 0x73, 0xd1, 0xa7, 0x3c, 0xa4, 0xbc, 0x27, 0x09, 0x5b, 0xbd, 0x28, 0xdc, 0x6c, 0x62, 0x8a, - 0xa9, 0xfa, 0x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0xf0, 0x2d, - 0x68, 0xa4, 0x4e, 0x90, 0xfb, 0x79, 0x12, 0x99, 0x9d, 0x6b, 0x3e, 0x2c, 0x01, 0x5d, 0x29, 0x8d, - 0x14, 0x52, 0x5b, 0xbb, 0x48, 0x21, 0x09, 0x15, 0x2a, 0xe4, 0xed, 0x4a, 0xe8, 0x83, 0xb9, 0xf4, - 0x28, 0x3f, 0x28, 0xcc, 0x4e, 0x50, 0xe6, 0xa3, 0x32, 0xd4, 0x58, 0x84, 0x01, 0x98, 0x33, 0x99, - 0xeb, 0x05, 0x6b, 0x4c, 0xa2, 0xe6, 0x56, 0x69, 0x34, 0xa9, 0x99, 0x33, 0x4d, 0xeb, 0x25, 0x7a, - 0xa3, 0xd0, 0x42, 0xcd, 0xe2, 0xc1, 0xd8, 0x77, 0xce, 0x2e, 0xda, 0xc6, 0xf9, 0x45, 0xdb, 0xf8, - 0x7d, 0xd1, 0x36, 0x3e, 0x5d, 0xb6, 0x2b, 0xe7, 0x97, 0xed, 0xca, 0xcf, 0xcb, 0x76, 0xe5, 0xcd, - 0x2e, 0x26, 0xe2, 0x38, 0xf6, 0x2c, 0x9f, 0x86, 0xfa, 0x6e, 0xb3, 0x89, 0xe7, 0x6f, 0x60, 0x6a, - 0x0f, 0x76, 0xec, 0x90, 0x06, 0xf1, 0x09, 0xe2, 0xea, 0xc6, 0xda, 0xdc, 0xde, 0xd0, 0x97, 0x96, - 0x18, 0xf6, 0x11, 0xf7, 0x6a, 0x72, 0x03, 0x3e, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x3a, - 0x40, 0xc8, 0x51, 0x07, 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, 0x1f, 0x87, 0xc8, 0x8a, 0xd0, 0x31, 0x8b, 0xc0, 0x3d, 0xd0, 0xe4, 0xcc, + 0x29, 0x8d, 0xac, 0x08, 0xb5, 0xe4, 0x35, 0x79, 0x63, 0x76, 0x77, 0x51, 0xe7, 0x32, 0xfa, 0x40, + 0x46, 0x3f, 0xf4, 0x7b, 0xe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, 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. diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto index 42f2f517045..b52eda0cf6d 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -4,7 +4,7 @@ package ibc.core.client.v1; option go_package = "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"; -import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "ibc/core/client/v1/client.proto"; @@ -106,8 +106,10 @@ 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 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1; // params defines the client parameters to update. // From c9f7b98c02048c9162b8c4b959943222f5d186af Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 30 May 2023 13:38:33 +0300 Subject: [PATCH 09/13] Remove authority comment, update GetParams as per suggestion. --- modules/core/02-client/keeper/keeper.go | 6 +++--- modules/core/keeper/keeper.go | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index ef38306333e..693d9499c6e 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -416,15 +416,15 @@ func (k Keeper) GetClientStatus(ctx sdk.Context, clientState exported.ClientStat // GetParams returns the total set of ibc-client parameters. func (k Keeper) GetParams(ctx sdk.Context) types.Params { - var p types.Params store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.ParamsKey)) if bz == nil { return types.Params{} } - k.cdc.MustUnmarshal(bz, &p) - return p + var params types.Params + k.cdc.MustUnmarshal(bz, ¶ms) + return params } // SetParams sets the total set of ibc-client parameters. diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 454cfc71a81..b6495ec5389 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -34,8 +34,6 @@ type Keeper struct { PortKeeper portkeeper.Keeper Router *porttypes.Router - // the address capable of executing a MsgUpdateClientParams message. Typically, this - // should be the x/gov module account. authority string } From 48f6260bb60e99e5c2f45f8d7cfc8238d2a7bc89 Mon Sep 17 00:00:00 2001 From: Jim Fasarakis-Hilliard Date: Tue, 30 May 2023 14:02:02 +0300 Subject: [PATCH 10/13] Update modules/core/02-client/keeper/keeper.go Co-authored-by: Damian Nolan --- modules/core/02-client/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 693d9499c6e..cfbcbc57676 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -418,7 +418,7 @@ func (k Keeper) GetClientStatus(ctx sdk.Context, clientState exported.ClientStat func (k Keeper) GetParams(ctx sdk.Context) types.Params { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.ParamsKey)) - if bz == nil { + if len(bz) == 0 { return types.Params{} } From cf65afdc50453f8605bad375f6b8a31f81f062d4 Mon Sep 17 00:00:00 2001 From: Jim Fasarakis-Hilliard Date: Tue, 30 May 2023 14:02:15 +0300 Subject: [PATCH 11/13] Update modules/core/keeper/keeper.go Co-authored-by: Damian Nolan --- modules/core/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index b6495ec5389..1eefcdc2b3d 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -95,7 +95,7 @@ func (k *Keeper) SetRouter(rtr *porttypes.Router) { k.Router.Seal() } -// GetAuthority returns the client module's authority. +// GetAuthority returns the client submodule's authority. func (k Keeper) GetAuthority() string { return k.authority } From a6119e674c8079108e98a60d0fe742f40f475979 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 30 May 2023 14:15:48 +0300 Subject: [PATCH 12/13] Check that new parameters updated match what is expected. --- modules/core/keeper/msg_server_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index ac6ba876e75..ab10dee7d80 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -817,6 +817,8 @@ func (suite *KeeperTestSuite) TestUpdateClientParams() { _, 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) } From 9070b498ce9f3de97cfb1f58c90d36a9a2a1cfe8 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 30 May 2023 14:21:54 +0300 Subject: [PATCH 13/13] Add note to migration docs. --- docs/migrations/v7-to-v8.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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