diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index da269933b46..c1eaa081667 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -336,6 +336,7 @@ ControllerGenesisState defines the interchain accounts controller genesis state | `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | | `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | | `ports` | [string](#string) | repeated | | +| `params` | [ibc.applications.interchain_accounts.controller.v1.Params](#ibc.applications.interchain_accounts.controller.v1.Params) | | | @@ -369,6 +370,7 @@ HostGenesisState defines the interchain accounts host genesis state | `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | | `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | | `port` | [string](#string) | | | +| `params` | [ibc.applications.interchain_accounts.host.v1.Params](#ibc.applications.interchain_accounts.host.v1.Params) | | | diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go index d38a4ed6e77..19bcb1de6cc 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go @@ -27,6 +27,8 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state icatypes.ControllerGenesi for _, acc := range state.InterchainAccounts { keeper.SetInterchainAccountAddress(ctx, acc.PortId, acc.AccountAddress) } + + keeper.SetParams(ctx, state.Params) } // ExportGenesis returns the interchain accounts controller exported genesis @@ -35,5 +37,6 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) icatypes.ControllerGenesisSta keeper.GetAllActiveChannels(ctx), keeper.GetAllInterchainAccounts(ctx), keeper.GetAllPorts(ctx), + keeper.GetParams(ctx), ) } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go index 398100458ac..488d39d982b 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper" + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) @@ -34,6 +35,11 @@ func (suite *KeeperTestSuite) TestInitGenesis() { accountAdrr, found := suite.chainA.GetSimApp().ICAControllerKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), TestPortID) suite.Require().True(found) suite.Require().Equal(TestAccAddress.String(), accountAdrr) + + expParams := types.NewParams(false) + params := suite.chainA.GetSimApp().ICAControllerKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) + } func (suite *KeeperTestSuite) TestExportGenesis() { @@ -54,4 +60,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.InterchainAccounts[0].PortId) suite.Require().Equal([]string{TestPortID}, genesisState.GetPorts()) + + expParams := types.DefaultParams() + suite.Require().Equal(expParams, genesisState.GetParams()) } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index 4f021c1eb16..91705ae89e1 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -9,16 +9,19 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ) // Keeper defines the IBC interchain accounts controller keeper type Keeper struct { - storeKey sdk.StoreKey - cdc codec.BinaryCodec + storeKey sdk.StoreKey + cdc codec.BinaryCodec + paramSpace paramtypes.Subspace ics4Wrapper icatypes.ICS4Wrapper channelKeeper icatypes.ChannelKeeper @@ -32,13 +35,20 @@ type Keeper struct { // NewKeeper creates a new interchain accounts controller Keeper instance func NewKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, + cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, ics4Wrapper icatypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, accountKeeper icatypes.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, ) Keeper { + + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + return Keeper{ storeKey: key, cdc: cdc, + paramSpace: paramSpace, ics4Wrapper: ics4Wrapper, channelKeeper: channelKeeper, portKeeper: portKeeper, diff --git a/modules/apps/27-interchain-accounts/controller/keeper/params.go b/modules/apps/27-interchain-accounts/controller/keeper/params.go new file mode 100644 index 00000000000..5169d51e6a9 --- /dev/null +++ b/modules/apps/27-interchain-accounts/controller/keeper/params.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" +) + +// GetControllerEnabled retrieves the host enabled boolean from the paramstore +func (k Keeper) GetControllerEnabled(ctx sdk.Context) bool { + var res bool + k.paramSpace.Get(ctx, types.KeyControllerEnabled, &res) + return res +} + +// GetParams returns the total set of the host submodule parameters. +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams(k.GetControllerEnabled(ctx)) +} + +// SetParams sets the total set of the host submodule parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} diff --git a/modules/apps/27-interchain-accounts/controller/keeper/params_test.go b/modules/apps/27-interchain-accounts/controller/keeper/params_test.go new file mode 100644 index 00000000000..27138d42de5 --- /dev/null +++ b/modules/apps/27-interchain-accounts/controller/keeper/params_test.go @@ -0,0 +1,15 @@ +package keeper_test + +import "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" + +func (suite *KeeperTestSuite) TestParams() { + expParams := types.DefaultParams() + + params := suite.chainA.GetSimApp().ICAControllerKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) + + expParams.ControllerEnabled = false + suite.chainA.GetSimApp().ICAControllerKeeper.SetParams(suite.chainA.GetContext(), expParams) + params = suite.chainA.GetSimApp().ICAControllerKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) +} diff --git a/modules/apps/27-interchain-accounts/controller/types/controller.pb.go b/modules/apps/27-interchain-accounts/controller/types/controller.pb.go new file mode 100644 index 00000000000..3a292e9a77b --- /dev/null +++ b/modules/apps/27-interchain-accounts/controller/types/controller.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/interchain_accounts/controller/v1/controller.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the set of on-chain interchain accounts parameters. +// The following parameters may be used to disable the controller submodule. +type Params struct { + // controller_enabled enables or disables the controller submodule. + ControllerEnabled bool `protobuf:"varint,1,opt,name=controller_enabled,json=controllerEnabled,proto3" json:"controller_enabled,omitempty" yaml:"controller_enabled"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_177fd0fec5eb3400, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetControllerEnabled() bool { + if m != nil { + return m.ControllerEnabled + } + return false +} + +func init() { + proto.RegisterType((*Params)(nil), "ibc.applications.interchain_accounts.controller.v1.Params") +} + +func init() { + proto.RegisterFile("ibc/applications/interchain_accounts/controller/v1/controller.proto", fileDescriptor_177fd0fec5eb3400) +} + +var fileDescriptor_177fd0fec5eb3400 = []byte{ + // 268 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0x4e, 0xc3, 0x30, + 0x14, 0x45, 0x93, 0xa5, 0x42, 0xd9, 0x88, 0x18, 0x68, 0x25, 0x0c, 0xca, 0xc4, 0x92, 0x3c, 0x35, + 0x0c, 0x48, 0x8c, 0x45, 0x6c, 0x0c, 0x15, 0x03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x57, 0xa0, + 0x03, 0xc5, 0x78, 0x2a, 0x11, 0xea, 0x1c, 0x0a, 0xdc, 0x56, 0x5a, 0xb8, 0xc3, 0x76, 0x0e, 0xf2, + 0xfb, 0x74, 0x6c, 0x9c, 0x9e, 0x9a, 0xcd, 0x37, 0xa5, 0x70, 0x6c, 0xd6, 0x57, 0xb9, 0xfb, 0x0f, + 0x00, 0x00, 0xff, 0xff, 0x0f, 0xf9, 0x46, 0xeb, 0x76, 0x01, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ControllerEnabled { + i-- + if m.ControllerEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintController(dAtA []byte, offset int, v uint64) int { + offset -= sovController(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ControllerEnabled { + n += 2 + } + return n +} + +func sovController(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozController(x uint64) (n int) { + return sovController(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowController + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ControllerEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowController + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ControllerEnabled = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipController(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthController + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipController(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowController + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowController + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowController + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthController + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupController + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthController + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthController = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowController = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupController = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/apps/27-interchain-accounts/controller/types/params.go b/modules/apps/27-interchain-accounts/controller/types/params.go new file mode 100644 index 00000000000..eb9c413bec0 --- /dev/null +++ b/modules/apps/27-interchain-accounts/controller/types/params.go @@ -0,0 +1,59 @@ +package types + +import ( + "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +const ( + // DefaultControllerEnabled is the default value for the controller param (set to true) + DefaultControllerEnabled = true +) + +var ( + // KeyControllerEnabled is the store key for ControllerEnabled Params + KeyControllerEnabled = []byte("ControllerEnabled") +) + +// ParamKeyTable type declaration for parameters +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new parameter configuration for the controller submodule +func NewParams(enableController bool) Params { + return Params{ + ControllerEnabled: enableController, + } +} + +// DefaultParams is the default parameter configuration for the controller submodule +func DefaultParams() Params { + return NewParams(DefaultControllerEnabled) +} + +// Validate validates all controller submodule parameters +func (p Params) Validate() error { + if err := validateEnabled(p.ControllerEnabled); err != nil { + return err + } + + return nil +} + +// ParamSetPairs implements params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyControllerEnabled, p.ControllerEnabled, validateEnabled), + } +} + +func validateEnabled(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} diff --git a/modules/apps/27-interchain-accounts/controller/types/params_test.go b/modules/apps/27-interchain-accounts/controller/types/params_test.go new file mode 100644 index 00000000000..0a25fd213a0 --- /dev/null +++ b/modules/apps/27-interchain-accounts/controller/types/params_test.go @@ -0,0 +1,14 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" +) + +func TestValidateParams(t *testing.T) { + require.NoError(t, types.DefaultParams().Validate()) + require.NoError(t, types.NewParams(false).Validate()) +} diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis.go b/modules/apps/27-interchain-accounts/host/keeper/genesis.go index 3fd5c02f8da..12174ca3f26 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis.go @@ -25,6 +25,8 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state icatypes.HostGenesisState for _, acc := range state.InterchainAccounts { keeper.SetInterchainAccountAddress(ctx, acc.PortId, acc.AccountAddress) } + + keeper.SetParams(ctx, state.Params) } // ExportGenesis returns the interchain accounts host exported genesis @@ -33,5 +35,6 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) icatypes.HostGenesisState { keeper.GetAllActiveChannels(ctx), keeper.GetAllInterchainAccounts(ctx), icatypes.PortID, + keeper.GetParams(ctx), ) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go index 272109b5412..7dba9ea121a 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/keeper" + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) @@ -34,6 +35,10 @@ func (suite *KeeperTestSuite) TestInitGenesis() { accountAdrr, found := suite.chainA.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), TestPortID) suite.Require().True(found) suite.Require().Equal(TestAccAddress.String(), accountAdrr) + + expParams := types.NewParams(false) + params := suite.chainA.GetSimApp().ICAHostKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) } func (suite *KeeperTestSuite) TestExportGenesis() { @@ -54,4 +59,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.InterchainAccounts[0].PortId) suite.Require().Equal(icatypes.PortID, genesisState.GetPort()) + + expParams := types.DefaultParams() + suite.Require().Equal(expParams, genesisState.GetParams()) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 23fcd168c5a..c4d9261651b 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -10,8 +10,10 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" @@ -19,8 +21,9 @@ import ( // Keeper defines the IBC interchain accounts host keeper type Keeper struct { - storeKey sdk.StoreKey - cdc codec.BinaryCodec + storeKey sdk.StoreKey + cdc codec.BinaryCodec + paramSpace paramtypes.Subspace channelKeeper icatypes.ChannelKeeper portKeeper icatypes.PortKeeper @@ -33,7 +36,8 @@ type Keeper struct { // NewKeeper creates a new interchain accounts host Keeper instance func NewKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, + cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, + channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, accountKeeper icatypes.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, ) Keeper { @@ -42,9 +46,15 @@ func NewKeeper( panic("the Interchain Accounts module account has not been set") } + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + return Keeper{ storeKey: key, cdc: cdc, + paramSpace: paramSpace, channelKeeper: channelKeeper, portKeeper: portKeeper, accountKeeper: accountKeeper, diff --git a/modules/apps/27-interchain-accounts/host/keeper/params.go b/modules/apps/27-interchain-accounts/host/keeper/params.go new file mode 100644 index 00000000000..c5198283b53 --- /dev/null +++ b/modules/apps/27-interchain-accounts/host/keeper/params.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" +) + +// GetHostEnabled retrieves the host enabled boolean from the paramstore +func (k Keeper) GetHostEnabled(ctx sdk.Context) bool { + var res bool + k.paramSpace.Get(ctx, types.KeyHostEnabled, &res) + return res +} + +// GetParams returns the total set of the host submodule parameters. +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams(k.GetHostEnabled(ctx)) +} + +// SetParams sets the total set of the host submodule parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} diff --git a/modules/apps/27-interchain-accounts/host/keeper/params_test.go b/modules/apps/27-interchain-accounts/host/keeper/params_test.go new file mode 100644 index 00000000000..9f8e53068ae --- /dev/null +++ b/modules/apps/27-interchain-accounts/host/keeper/params_test.go @@ -0,0 +1,15 @@ +package keeper_test + +import "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" + +func (suite *KeeperTestSuite) TestParams() { + expParams := types.DefaultParams() + + params := suite.chainA.GetSimApp().ICAHostKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) + + expParams.HostEnabled = false + suite.chainA.GetSimApp().ICAHostKeeper.SetParams(suite.chainA.GetContext(), expParams) + params = suite.chainA.GetSimApp().ICAHostKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) +} diff --git a/modules/apps/27-interchain-accounts/host/types/host.pb.go b/modules/apps/27-interchain-accounts/host/types/host.pb.go new file mode 100644 index 00000000000..f926909215b --- /dev/null +++ b/modules/apps/27-interchain-accounts/host/types/host.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/interchain_accounts/host/v1/host.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the set of on-chain interchain accounts parameters. +// The following parameters may be used to disable the host submodule. +type Params struct { + // host_enabled enables or disables the host submodule. + HostEnabled bool `protobuf:"varint,1,opt,name=host_enabled,json=hostEnabled,proto3" json:"host_enabled,omitempty" yaml:"host_enabled"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_48e202774f13d08e, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetHostEnabled() bool { + if m != nil { + return m.HostEnabled + } + return false +} + +func init() { + proto.RegisterType((*Params)(nil), "ibc.applications.interchain_accounts.host.v1.Params") +} + +func init() { + proto.RegisterFile("ibc/applications/interchain_accounts/host/v1/host.proto", fileDescriptor_48e202774f13d08e) +} + +var fileDescriptor_48e202774f13d08e = []byte{ + // 264 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0x4e, 0xc3, 0x30, + 0x10, 0x86, 0x93, 0xa5, 0x42, 0x81, 0xa9, 0x20, 0x01, 0x1d, 0x0c, 0xca, 0xc4, 0x40, 0x72, 0x6a, + 0x19, 0x2a, 0x75, 0xac, 0x60, 0x61, 0x42, 0x8c, 0x2c, 0x95, 0xed, 0x18, 0xc7, 0x92, 0xed, 0x8b, + 0x62, 0x27, 0x52, 0xde, 0x82, 0xc7, 0x62, 0xec, 0xc8, 0x84, 0x50, 0xf2, 0x06, 0x3c, 0x01, 0x8a, + 0x33, 0x50, 0x24, 0x26, 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0x7e, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x78, 0x3c, 0xa0, 0x19, 0x4c, 0x01, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.HostEnabled { + i-- + if m.HostEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintHost(dAtA []byte, offset int, v uint64) int { + offset -= sovHost(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.HostEnabled { + n += 2 + } + return n +} + +func sovHost(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozHost(x uint64) (n int) { + return sovHost(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHost + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HostEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHost + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.HostEnabled = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipHost(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthHost + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipHost(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHost + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHost + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHost + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthHost + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupHost + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthHost + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthHost = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowHost = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupHost = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/apps/27-interchain-accounts/host/types/params.go b/modules/apps/27-interchain-accounts/host/types/params.go new file mode 100644 index 00000000000..589de75fc23 --- /dev/null +++ b/modules/apps/27-interchain-accounts/host/types/params.go @@ -0,0 +1,59 @@ +package types + +import ( + "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +const ( + // DefaultHostEnabled is the default value for the host param (set to true) + DefaultHostEnabled = true +) + +var ( + // KeyHostEnabled is the store key for HostEnabled Params + KeyHostEnabled = []byte("HostEnabled") +) + +// ParamKeyTable type declaration for parameters +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new parameter configuration for the host submodule +func NewParams(enableHost bool) Params { + return Params{ + HostEnabled: enableHost, + } +} + +// DefaultParams is the default parameter configuration for the host submodule +func DefaultParams() Params { + return NewParams(DefaultHostEnabled) +} + +// Validate validates all host submodule parameters +func (p Params) Validate() error { + if err := validateEnabled(p.HostEnabled); err != nil { + return err + } + + return nil +} + +// ParamSetPairs implements params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyHostEnabled, p.HostEnabled, validateEnabled), + } +} + +func validateEnabled(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} diff --git a/modules/apps/27-interchain-accounts/host/types/params_test.go b/modules/apps/27-interchain-accounts/host/types/params_test.go new file mode 100644 index 00000000000..b8a0d418bc2 --- /dev/null +++ b/modules/apps/27-interchain-accounts/host/types/params_test.go @@ -0,0 +1,14 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" +) + +func TestValidateParams(t *testing.T) { + require.NoError(t, types.DefaultParams().Validate()) + require.NoError(t, types.NewParams(false).Validate()) +} diff --git a/modules/apps/27-interchain-accounts/types/genesis.go b/modules/apps/27-interchain-accounts/types/genesis.go index 84e489a4df6..97a906cf5f5 100644 --- a/modules/apps/27-interchain-accounts/types/genesis.go +++ b/modules/apps/27-interchain-accounts/types/genesis.go @@ -1,6 +1,8 @@ package types import ( + controllertypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" + hosttypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ) @@ -35,15 +37,18 @@ func (gs GenesisState) Validate() error { // DefaultControllerGenesis creates and returns the default interchain accounts ControllerGenesisState func DefaultControllerGenesis() ControllerGenesisState { - return ControllerGenesisState{} + return ControllerGenesisState{ + Params: controllertypes.DefaultParams(), + } } // NewControllerGenesisState creates a returns a new ControllerGenesisState instance -func NewControllerGenesisState(channels []ActiveChannel, accounts []RegisteredInterchainAccount, ports []string) ControllerGenesisState { +func NewControllerGenesisState(channels []ActiveChannel, accounts []RegisteredInterchainAccount, ports []string, controllerParams controllertypes.Params) ControllerGenesisState { return ControllerGenesisState{ ActiveChannels: channels, InterchainAccounts: accounts, Ports: ports, + Params: controllerParams, } } @@ -75,22 +80,28 @@ func (gs ControllerGenesisState) Validate() error { } } + if err := gs.Params.Validate(); err != nil { + return err + } + return nil } // DefaultHostGenesis creates and returns the default interchain accounts HostGenesisState func DefaultHostGenesis() HostGenesisState { return HostGenesisState{ - Port: PortID, + Port: PortID, + Params: hosttypes.DefaultParams(), } } // NewHostGenesisState creates a returns a new HostGenesisState instance -func NewHostGenesisState(channels []ActiveChannel, accounts []RegisteredInterchainAccount, port string) HostGenesisState { +func NewHostGenesisState(channels []ActiveChannel, accounts []RegisteredInterchainAccount, port string, hostParams hosttypes.Params) HostGenesisState { return HostGenesisState{ ActiveChannels: channels, InterchainAccounts: accounts, Port: port, + Params: hostParams, } } @@ -120,5 +131,9 @@ func (gs HostGenesisState) Validate() error { return err } + if err := gs.Params.Validate(); err != nil { + return err + } + return nil } diff --git a/modules/apps/27-interchain-accounts/types/genesis.pb.go b/modules/apps/27-interchain-accounts/types/genesis.pb.go index 261826239bf..5a226263fb8 100644 --- a/modules/apps/27-interchain-accounts/types/genesis.pb.go +++ b/modules/apps/27-interchain-accounts/types/genesis.pb.go @@ -5,6 +5,8 @@ package types import ( fmt "fmt" + types "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" + types1 "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -81,6 +83,7 @@ type ControllerGenesisState struct { ActiveChannels []ActiveChannel `protobuf:"bytes,1,rep,name=active_channels,json=activeChannels,proto3" json:"active_channels" yaml:"active_channels"` InterchainAccounts []RegisteredInterchainAccount `protobuf:"bytes,2,rep,name=interchain_accounts,json=interchainAccounts,proto3" json:"interchain_accounts" yaml:"interchain_accounts"` Ports []string `protobuf:"bytes,3,rep,name=ports,proto3" json:"ports,omitempty"` + Params types.Params `protobuf:"bytes,4,opt,name=params,proto3" json:"params"` } func (m *ControllerGenesisState) Reset() { *m = ControllerGenesisState{} } @@ -137,11 +140,19 @@ func (m *ControllerGenesisState) GetPorts() []string { return nil } +func (m *ControllerGenesisState) GetParams() types.Params { + if m != nil { + return m.Params + } + return types.Params{} +} + // HostGenesisState defines the interchain accounts host genesis state type HostGenesisState struct { ActiveChannels []ActiveChannel `protobuf:"bytes,1,rep,name=active_channels,json=activeChannels,proto3" json:"active_channels" yaml:"active_channels"` InterchainAccounts []RegisteredInterchainAccount `protobuf:"bytes,2,rep,name=interchain_accounts,json=interchainAccounts,proto3" json:"interchain_accounts" yaml:"interchain_accounts"` Port string `protobuf:"bytes,3,opt,name=port,proto3" json:"port,omitempty"` + Params types1.Params `protobuf:"bytes,4,opt,name=params,proto3" json:"params"` } func (m *HostGenesisState) Reset() { *m = HostGenesisState{} } @@ -198,6 +209,13 @@ func (m *HostGenesisState) GetPort() string { return "" } +func (m *HostGenesisState) GetParams() types1.Params { + if m != nil { + return m.Params + } + return types1.Params{} +} + // ActiveChannel contains a pairing of port ID and channel ID for an active interchain accounts channel type ActiveChannel struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` @@ -317,41 +335,46 @@ func init() { } var fileDescriptor_629b3ced0911516b = []byte{ - // 543 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0xcf, 0x8f, 0x12, 0x31, - 0x14, 0xc7, 0xe9, 0xa0, 0x6b, 0xe8, 0xea, 0xba, 0xd6, 0x75, 0x33, 0x62, 0x32, 0x60, 0x2f, 0x4b, - 0x62, 0x98, 0x66, 0xf1, 0x57, 0xf4, 0x62, 0x00, 0x8d, 0x72, 0x1d, 0x6f, 0x5e, 0x26, 0xa5, 0xd3, - 0x0c, 0x4d, 0x86, 0x29, 0x99, 0x16, 0x92, 0x3d, 0x79, 0xf7, 0xa2, 0x57, 0xaf, 0xfe, 0x25, 0x26, - 0x5e, 0x36, 0xf1, 0xb2, 0x47, 0x4f, 0xc4, 0xc0, 0x7f, 0xc0, 0x5f, 0x60, 0xa6, 0x9d, 0x20, 0x20, - 0x6e, 0xf0, 0xee, 0xad, 0xed, 0x7b, 0xdf, 0xf7, 0xfd, 0xf4, 0xbd, 0xb4, 0xf0, 0xb1, 0xe8, 0x33, - 0x42, 0x47, 0xa3, 0x44, 0x30, 0xaa, 0x85, 0x4c, 0x15, 0x11, 0xa9, 0xe6, 0x19, 0x1b, 0x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dc, 0x2b, 0xfd, 0x98, 0x7b, 0xa5, - 0x77, 0xaf, 0x62, 0xa1, 0x07, 0xe3, 0xbe, 0xcf, 0xe4, 0x90, 0x30, 0xa9, 0x86, 0x52, 0x11, 0xd1, - 0x67, 0xcd, 0x58, 0x92, 0x49, 0x8b, 0x0c, 0x65, 0x34, 0x4e, 0xb8, 0xca, 0x3f, 0x63, 0x45, 0x5a, - 0x4f, 0x9b, 0xbf, 0x7b, 0xde, 0x5c, 0xfe, 0xc3, 0xfa, 0x6c, 0xc4, 0x55, 0x7f, 0xcf, 0x7c, 0xa2, - 0x0f, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x47, 0x25, 0xf6, 0xbc, 0x05, 0x00, 0x00, + // 609 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0xcf, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x9b, 0x66, 0x0c, 0xd5, 0x83, 0x31, 0xcc, 0x98, 0x42, 0x91, 0xd2, 0xe2, 0xcb, 0x2a, + 0xa1, 0x25, 0x5a, 0x19, 0x4c, 0xec, 0x82, 0x96, 0x82, 0x60, 0x37, 0x14, 0x2e, 0x88, 0x4b, 0xe4, + 0x3a, 0x56, 0x6a, 0x29, 0x8d, 0xa3, 0xd8, 0xab, 0xb4, 0x13, 0x77, 0x2e, 0x70, 0x43, 0x5c, 0x91, + 0xf8, 0x3f, 0x38, 0xee, 0xb8, 0x23, 0xa7, 0x0a, 0xad, 0xff, 0x41, 0xff, 0x02, 0x64, 0x27, 0xea, + 0x8f, 0xd0, 0x4d, 0xe1, 0xce, 0xa9, 0x76, 0xfc, 0xbe, 0xdf, 0xf7, 0x79, 0x7e, 0xee, 0x03, 0x4f, + 0x59, 0x9f, 0xb8, 0x38, 0x4d, 0x63, 0x46, 0xb0, 0x64, 0x3c, 0x11, 0x2e, 0x4b, 0x24, 0xcd, 0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, 0x6e, 0xdd, 0x2d, + 0xa6, 0xcb, 0xec, 0x0c, 0xf9, 0x8d, 0x62, 0x73, 0x12, 0xa2, 0xcf, 0x06, 0x78, 0x78, 0xcd, 0x9d, + 0xfd, 0x1b, 0x42, 0x4f, 0xbd, 0x22, 0xad, 0x0b, 0x70, 0x18, 0x66, 0x54, 0x88, 0x82, 0xa3, 0xb9, + 0xf8, 0x12, 0x96, 0x02, 0xf4, 0x4b, 0xd0, 0x5f, 0x8e, 0xf3, 0x0f, 0x5e, 0x70, 0x7e, 0x69, 0x1b, + 0x17, 0x97, 0xb6, 0xf1, 0xfb, 0xd2, 0x36, 0xbe, 0x4c, 0xec, 0xda, 0xc5, 0xc4, 0xae, 0xfd, 0x9a, + 0xd8, 0xb5, 0x0f, 0xaf, 0x22, 0x26, 0x07, 0xa7, 0x7d, 0x87, 0xf0, 0xa1, 0x4b, 0xb8, 0x18, 0x72, + 0xe1, 0xb2, 0x3e, 0xd9, 0x8b, 0xb8, 0x3b, 0xea, 0xba, 0x43, 0x1e, 0x9e, 0xc6, 0x54, 0xa8, 0xe9, + 0x2f, 0xdc, 0xee, 0xe1, 0xde, 0xfc, 0xf6, 0xf7, 0x66, 0x83, 0x5f, 0x9e, 0xa5, 0x54, 0xf4, 0xd7, + 0xf5, 0xc8, 0x7f, 0xf2, 0x27, 0x00, 0x00, 0xff, 0xff, 0x61, 0x4a, 0xb3, 0xe7, 0xe8, 0x06, 0x00, + 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -417,6 +440,16 @@ func (m *ControllerGenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 if len(m.Ports) > 0 { for iNdEx := len(m.Ports) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Ports[iNdEx]) @@ -477,6 +510,16 @@ func (m *HostGenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 if len(m.Port) > 0 { i -= len(m.Port) copy(dAtA[i:], m.Port) @@ -637,6 +680,8 @@ func (m *ControllerGenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -662,6 +707,8 @@ func (m *HostGenesisState) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -950,6 +997,39 @@ func (m *ControllerGenesisState) Unmarshal(dAtA []byte) error { } m.Ports = append(m.Ports, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -1100,6 +1180,39 @@ func (m *HostGenesisState) Unmarshal(dAtA []byte) error { } m.Port = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/apps/27-interchain-accounts/types/genesis_test.go b/modules/apps/27-interchain-accounts/types/genesis_test.go index 939339f5fb3..2ac017c63ad 100644 --- a/modules/apps/27-interchain-accounts/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/types/genesis_test.go @@ -1,6 +1,8 @@ package types_test import ( + controllertypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types" + hosttypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types" "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) @@ -85,7 +87,7 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { }, } - genesisState = types.NewControllerGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, []string{}) + genesisState = types.NewControllerGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, false, }, @@ -99,7 +101,7 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { }, } - genesisState = types.NewControllerGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, []string{}) + genesisState = types.NewControllerGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, false, }, @@ -120,7 +122,7 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { }, } - genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}) + genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, false, }, @@ -141,7 +143,7 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { }, } - genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}) + genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, false, }, @@ -162,7 +164,7 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { }, } - genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{"invalid|port"}) + genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{"invalid|port"}, controllertypes.DefaultParams()) }, false, }, @@ -210,7 +212,7 @@ func (suite *TypesTestSuite) TestValidateHostGenesisState() { }, } - genesisState = types.NewHostGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, types.PortID) + genesisState = types.NewHostGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, types.PortID, hosttypes.DefaultParams()) }, false, }, @@ -224,7 +226,7 @@ func (suite *TypesTestSuite) TestValidateHostGenesisState() { }, } - genesisState = types.NewHostGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, types.PortID) + genesisState = types.NewHostGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, types.PortID, hosttypes.DefaultParams()) }, false, }, @@ -245,7 +247,7 @@ func (suite *TypesTestSuite) TestValidateHostGenesisState() { }, } - genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, types.PortID) + genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, types.PortID, hosttypes.DefaultParams()) }, false, }, @@ -266,7 +268,7 @@ func (suite *TypesTestSuite) TestValidateHostGenesisState() { }, } - genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, types.PortID) + genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, types.PortID, hosttypes.DefaultParams()) }, false, }, @@ -287,7 +289,7 @@ func (suite *TypesTestSuite) TestValidateHostGenesisState() { }, } - genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, "invalid|port") + genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, "invalid|port", hosttypes.DefaultParams()) }, false, }, diff --git a/proto/ibc/applications/interchain_accounts/controller/v1/controller.proto b/proto/ibc/applications/interchain_accounts/controller/v1/controller.proto new file mode 100644 index 00000000000..79430e89e7e --- /dev/null +++ b/proto/ibc/applications/interchain_accounts/controller/v1/controller.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package ibc.applications.interchain_accounts.controller.v1; + +option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types"; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; + +// Params defines the set of on-chain interchain accounts parameters. +// The following parameters may be used to disable the controller submodule. +message Params { + // controller_enabled enables or disables the controller submodule. + bool controller_enabled = 1 [(gogoproto.moretags) = "yaml:\"controller_enabled\""]; +} diff --git a/proto/ibc/applications/interchain_accounts/host/v1/host.proto b/proto/ibc/applications/interchain_accounts/host/v1/host.proto new file mode 100644 index 00000000000..a5301199286 --- /dev/null +++ b/proto/ibc/applications/interchain_accounts/host/v1/host.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package ibc.applications.interchain_accounts.host.v1; + +option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types"; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; + +// Params defines the set of on-chain interchain accounts parameters. +// The following parameters may be used to disable the host submodule. +message Params { + // host_enabled enables or disables the host submodule. + bool host_enabled = 1 [(gogoproto.moretags) = "yaml:\"host_enabled\""]; +} diff --git a/proto/ibc/applications/interchain_accounts/v1/genesis.proto b/proto/ibc/applications/interchain_accounts/v1/genesis.proto index 69527bd867a..7fc5cd846bd 100644 --- a/proto/ibc/applications/interchain_accounts/v1/genesis.proto +++ b/proto/ibc/applications/interchain_accounts/v1/genesis.proto @@ -5,6 +5,8 @@ package ibc.applications.interchain_accounts.v1; option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"; import "gogoproto/gogo.proto"; +import "ibc/applications/interchain_accounts/controller/v1/controller.proto"; +import "ibc/applications/interchain_accounts/host/v1/host.proto"; // GenesisState defines the interchain accounts genesis state message GenesisState { @@ -21,6 +23,7 @@ message ControllerGenesisState { repeated RegisteredInterchainAccount interchain_accounts = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"interchain_accounts\""]; repeated string ports = 3; + ibc.applications.interchain_accounts.controller.v1.Params params = 4 [(gogoproto.nullable) = false]; } // HostGenesisState defines the interchain accounts host genesis state @@ -30,6 +33,7 @@ message HostGenesisState { repeated RegisteredInterchainAccount interchain_accounts = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"interchain_accounts\""]; string port = 3; + ibc.applications.interchain_accounts.host.v1.Params params = 4 [(gogoproto.nullable) = false]; } // ActiveChannel contains a pairing of port ID and channel ID for an active interchain accounts channel diff --git a/proto/ibc/applications/interchain_accounts/v1/types.proto b/proto/ibc/applications/interchain_accounts/v1/types.proto index c6d9d0a3e96..43350212934 100644 --- a/proto/ibc/applications/interchain_accounts/v1/types.proto +++ b/proto/ibc/applications/interchain_accounts/v1/types.proto @@ -29,3 +29,4 @@ message InterchainAccountPacketData { message CosmosTx { repeated google.protobuf.Any messages = 1; } + diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 1955558be31..18aba3e1ec6 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -353,14 +353,14 @@ func NewSimApp( mockIBCModule := ibcmock.NewIBCModule(&ibcmock.MockIBCApp{}, scopedIBCMockKeeper) app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( - appCodec, keys[icacontrollertypes.StoreKey], + appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.ModuleName), app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, scopedICAControllerKeeper, app.MsgServiceRouter(), ) app.ICAHostKeeper = icahostkeeper.NewKeeper( - appCodec, keys[icahosttypes.StoreKey], + appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.ModuleName), app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), ) @@ -708,6 +708,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(icacontrollertypes.ModuleName) + paramsKeeper.Subspace(icahosttypes.ModuleName) return paramsKeeper }