diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index b5557d2d923..8deda5b71e8 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -8,7 +8,9 @@ - [InterchainAccount](#ibc.applications.interchain_accounts.v1.InterchainAccount) - [ibc/applications/interchain_accounts/v1/genesis.proto](#ibc/applications/interchain_accounts/v1/genesis.proto) + - [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) - [GenesisState](#ibc.applications.interchain_accounts.v1.GenesisState) + - [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) - [ibc/applications/interchain_accounts/v1/query.proto](#ibc/applications/interchain_accounts/v1/query.proto) - [QueryInterchainAccountAddressRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest) @@ -311,15 +313,49 @@ An InterchainAccount is defined as a BaseAccount & the address of the account ow + + +### ActiveChannel +ActiveChannel contains a pairing of port ID and channel ID for an active interchain accounts channel + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | + + + + + + ### GenesisState -GenesisState defines the interchain_account genesis state +GenesisState defines the interchain accounts genesis state + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | +| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | +| `ports` | [string](#string) | repeated | | + + + + + + + + +### RegisteredInterchainAccount +RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `port_id` | [string](#string) | | | +| `account_address` | [string](#string) | | | diff --git a/modules/apps/27-interchain-accounts/genesis.go b/modules/apps/27-interchain-accounts/genesis.go index e052834b8a5..dae97a236b7 100644 --- a/modules/apps/27-interchain-accounts/genesis.go +++ b/modules/apps/27-interchain-accounts/genesis.go @@ -12,20 +12,29 @@ import ( // InitGenesis initializes the interchain accounts application state from a provided genesis state func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, state types.GenesisState) { - if !keeper.IsBound(ctx, state.PortId) { - cap := keeper.BindPort(ctx, state.PortId) - if err := keeper.ClaimCapability(ctx, cap, host.PortPath(state.PortId)); err != nil { - panic(fmt.Sprintf("could not claim port capability: %v", err)) + for _, portID := range state.Ports { + if !keeper.IsBound(ctx, portID) { + cap := keeper.BindPort(ctx, portID) + if err := keeper.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { + panic(fmt.Sprintf("could not claim port capability: %v", err)) + } } } -} -// ExportGenesis exports transfer module's portID into its geneis state -func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { - // TODO: Using a range query with KVStorePrefixIterator export all port IDs - // See https://github.com/cosmos/ibc-go/issues/448 + for _, ch := range state.ActiveChannels { + keeper.SetActiveChannelID(ctx, ch.PortId, ch.ChannelId) + } - return &types.GenesisState{ - PortId: types.PortID, + for _, acc := range state.InterchainAccounts { + keeper.SetInterchainAccountAddress(ctx, acc.PortId, acc.AccountAddress) } } + +// ExportGenesis returns the interchain accounts exported genesis +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { + return types.NewGenesisState( + keeper.GetAllPorts(ctx), + keeper.GetAllActiveChannels(ctx), + keeper.GetAllInterchainAccounts(ctx), + ) +} diff --git a/modules/apps/27-interchain-accounts/genesis_test.go b/modules/apps/27-interchain-accounts/genesis_test.go new file mode 100644 index 00000000000..e403bdcadd4 --- /dev/null +++ b/modules/apps/27-interchain-accounts/genesis_test.go @@ -0,0 +1,59 @@ +package interchain_accounts_test + +import ( + ica "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts" + "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" +) + +func (suite *InterchainAccountsTestSuite) TestInitGenesis() { + var ( + expectedChannelID string = "channel-0" + ) + + suite.SetupTest() + + genesisState := types.GenesisState{ + Ports: []string{types.PortID, TestPortID}, + ActiveChannels: []*types.ActiveChannel{ + { + PortId: TestPortID, + ChannelId: expectedChannelID, + }, + }, + InterchainAccounts: []*types.RegisteredInterchainAccount{ + { + PortId: TestPortID, + AccountAddress: TestAccAddress.String(), + }, + }, + } + + ica.InitGenesis(suite.chainA.GetContext(), suite.chainA.GetSimApp().ICAKeeper, genesisState) + + channelID, found := suite.chainA.GetSimApp().ICAKeeper.GetActiveChannelID(suite.chainA.GetContext(), TestPortID) + suite.Require().True(found) + suite.Require().Equal(expectedChannelID, channelID) + + accountAdrr, found := suite.chainA.GetSimApp().ICAKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), TestPortID) + suite.Require().True(found) + suite.Require().Equal(TestAccAddress.String(), accountAdrr) +} + +func (suite *InterchainAccountsTestSuite) TestExportGenesis() { + suite.SetupTest() + path := NewICAPath(suite.chainA, suite.chainB) + suite.coordinator.SetupConnections(path) + + err := SetupICAPath(path, TestOwnerAddress) + suite.Require().NoError(err) + + genesisState := ica.ExportGenesis(suite.chainA.GetContext(), suite.chainA.GetSimApp().ICAKeeper) + + suite.Require().Equal([]string{types.PortID, TestPortID}, genesisState.GetPorts()) + + suite.Require().Equal(path.EndpointA.ChannelID, genesisState.ActiveChannels[0].ChannelId) + suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.ActiveChannels[0].PortId) + + suite.Require().Equal(TestAccAddress.String(), genesisState.InterchainAccounts[0].AccountAddress) + suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.InterchainAccounts[0].PortId) +} diff --git a/modules/apps/27-interchain-accounts/keeper/keeper.go b/modules/apps/27-interchain-accounts/keeper/keeper.go index c730882207d..2886698b26d 100644 --- a/modules/apps/27-interchain-accounts/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/keeper/keeper.go @@ -113,6 +113,27 @@ func (k Keeper) GetActiveChannelID(ctx sdk.Context, portID string) (string, bool return string(store.Get(key)), true } +// GetAllActiveChannels returns a list of all active interchain accounts channels and their associated port identifiers +func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []*types.ActiveChannel { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.ActiveChannelKeyPrefix)) + defer iterator.Close() + + var activeChannels []*types.ActiveChannel + for ; iterator.Valid(); iterator.Next() { + keySplit := strings.Split(string(iterator.Key()), "/") + + ch := &types.ActiveChannel{ + PortId: keySplit[1], + ChannelId: string(iterator.Value()), + } + + activeChannels = append(activeChannels, ch) + } + + return activeChannels +} + // SetActiveChannelID stores the active channelID, keyed by the provided portID func (k Keeper) SetActiveChannelID(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) @@ -143,6 +164,26 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, portID string) (str return string(store.Get(key)), true } +// GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated controller port identifiers +func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []*types.RegisteredInterchainAccount { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.OwnerKeyPrefix)) + + var interchainAccounts []*types.RegisteredInterchainAccount + for ; iterator.Valid(); iterator.Next() { + keySplit := strings.Split(string(iterator.Key()), "/") + + acc := &types.RegisteredInterchainAccount{ + PortId: keySplit[1], + AccountAddress: string(iterator.Value()), + } + + interchainAccounts = append(interchainAccounts, acc) + } + + return interchainAccounts +} + // SetInterchainAccountAddress stores the InterchainAccount address, keyed by the associated portID func (k Keeper) SetInterchainAccountAddress(ctx sdk.Context, portID string, address string) { store := ctx.KVStore(k.storeKey) diff --git a/modules/apps/27-interchain-accounts/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/keeper/keeper_test.go index 307451fd14b..92a57e74eec 100644 --- a/modules/apps/27-interchain-accounts/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/keeper/keeper_test.go @@ -116,9 +116,11 @@ func (suite *KeeperTestSuite) TestGetAllPorts() { err := SetupICAPath(path, TestOwnerAddress) suite.Require().NoError(err) + expectedPorts := []string{types.PortID, TestPortID} + ports := suite.chainA.GetSimApp().ICAKeeper.GetAllPorts(suite.chainA.GetContext()) - suite.Require().Contains(ports, types.PortID) - suite.Require().Contains(ports, TestPortID) + suite.Require().Len(ports, len(expectedPorts)) + suite.Require().Equal(expectedPorts, ports) } func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { @@ -141,6 +143,68 @@ func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { suite.Require().Empty(retrievedAddr) } +func (suite *KeeperTestSuite) TestGetAllActiveChannels() { + var ( + expectedChannelID string = "test-channel" + expectedPortID string = "test-port" + ) + + suite.SetupTest() + path := NewICAPath(suite.chainA, suite.chainB) + suite.coordinator.SetupConnections(path) + + err := SetupICAPath(path, TestOwnerAddress) + suite.Require().NoError(err) + + suite.chainA.GetSimApp().ICAKeeper.SetActiveChannelID(suite.chainA.GetContext(), expectedPortID, expectedChannelID) + + expectedChannels := []*types.ActiveChannel{ + { + PortId: TestPortID, + ChannelId: path.EndpointA.ChannelID, + }, + { + PortId: expectedPortID, + ChannelId: expectedChannelID, + }, + } + + activeChannels := suite.chainA.GetSimApp().ICAKeeper.GetAllActiveChannels(suite.chainA.GetContext()) + suite.Require().Len(activeChannels, len(expectedChannels)) + suite.Require().Equal(expectedChannels, activeChannels) +} + +func (suite *KeeperTestSuite) TestGetAllInterchainAccounts() { + var ( + expectedAccAddr string = "test-acc-addr" + expectedPortID string = "test-port" + ) + + suite.SetupTest() + path := NewICAPath(suite.chainA, suite.chainB) + suite.coordinator.SetupConnections(path) + + err := SetupICAPath(path, TestOwnerAddress) + suite.Require().NoError(err) + + suite.chainA.GetSimApp().ICAKeeper.SetInterchainAccountAddress(suite.chainA.GetContext(), expectedPortID, expectedAccAddr) + + expectedAccounts := []*types.RegisteredInterchainAccount{ + { + PortId: TestPortID, + AccountAddress: TestAccAddress.String(), + }, + { + PortId: expectedPortID, + AccountAddress: expectedAccAddr, + }, + } + + interchainAccounts := suite.chainA.GetSimApp().ICAKeeper.GetAllInterchainAccounts(suite.chainA.GetContext()) + suite.Require().Len(interchainAccounts, len(expectedAccounts)) + suite.Require().Equal(expectedAccounts, interchainAccounts) +} + func (suite *KeeperTestSuite) TestIsActiveChannel() { suite.SetupTest() // reset path := NewICAPath(suite.chainA, suite.chainB) @@ -156,12 +220,16 @@ func (suite *KeeperTestSuite) TestIsActiveChannel() { } func (suite *KeeperTestSuite) TestSetInterchainAccountAddress() { - expectedAddr, portID := "address", "port" - suite.chainA.GetSimApp().ICAKeeper.SetInterchainAccountAddress(suite.chainA.GetContext(), portID, expectedAddr) + var ( + expectedAccAddr string = "test-acc-addr" + expectedPortID string = "test-port" + ) + + suite.chainA.GetSimApp().ICAKeeper.SetInterchainAccountAddress(suite.chainA.GetContext(), expectedPortID, expectedAccAddr) - retrievedAddr, found := suite.chainA.GetSimApp().ICAKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), portID) + retrievedAddr, found := suite.chainA.GetSimApp().ICAKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), expectedPortID) suite.Require().True(found) - suite.Require().Equal(expectedAddr, retrievedAddr) + suite.Require().Equal(expectedAccAddr, retrievedAddr) } func (suite *KeeperTestSuite) SetupICAPath(path *ibctesting.Path, owner string) error { diff --git a/modules/apps/27-interchain-accounts/types/genesis.go b/modules/apps/27-interchain-accounts/types/genesis.go index e3a9bab7949..f98ce12caa6 100644 --- a/modules/apps/27-interchain-accounts/types/genesis.go +++ b/modules/apps/27-interchain-accounts/types/genesis.go @@ -1,7 +1,18 @@ package types +// DefaultGenesis creates and returns the default interchain accounts GenesisState +// The default GenesisState includes the standard port identifier to which all host chains must bind func DefaultGenesis() *GenesisState { return &GenesisState{ - PortId: PortID, + Ports: []string{PortID}, + } +} + +// NewGenesisState creates a returns a new GenesisState instance +func NewGenesisState(ports []string, channels []*ActiveChannel, accounts []*RegisteredInterchainAccount) *GenesisState { + return &GenesisState{ + ActiveChannels: channels, + InterchainAccounts: accounts, + Ports: ports, } } diff --git a/modules/apps/27-interchain-accounts/types/genesis.pb.go b/modules/apps/27-interchain-accounts/types/genesis.pb.go index 44661c274c4..32d38337ac1 100644 --- a/modules/apps/27-interchain-accounts/types/genesis.pb.go +++ b/modules/apps/27-interchain-accounts/types/genesis.pb.go @@ -23,9 +23,11 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the interchain_account genesis state +// GenesisState defines the interchain accounts genesis state type GenesisState struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + ActiveChannels []*ActiveChannel `protobuf:"bytes,1,rep,name=active_channels,json=activeChannels,proto3" json:"active_channels,omitempty" yaml:"active_channels"` + InterchainAccounts []*RegisteredInterchainAccount `protobuf:"bytes,2,rep,name=interchain_accounts,json=interchainAccounts,proto3" json:"interchain_accounts,omitempty" yaml:"interchain_accounts"` + Ports []string `protobuf:"bytes,3,rep,name=ports,proto3" json:"ports,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -61,15 +63,137 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetPortId() string { +func (m *GenesisState) GetActiveChannels() []*ActiveChannel { + if m != nil { + return m.ActiveChannels + } + return nil +} + +func (m *GenesisState) GetInterchainAccounts() []*RegisteredInterchainAccount { + if m != nil { + return m.InterchainAccounts + } + return nil +} + +func (m *GenesisState) GetPorts() []string { + if m != nil { + return m.Ports + } + return nil +} + +// 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"` + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` +} + +func (m *ActiveChannel) Reset() { *m = ActiveChannel{} } +func (m *ActiveChannel) String() string { return proto.CompactTextString(m) } +func (*ActiveChannel) ProtoMessage() {} +func (*ActiveChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_629b3ced0911516b, []int{1} +} +func (m *ActiveChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ActiveChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ActiveChannel.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 *ActiveChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActiveChannel.Merge(m, src) +} +func (m *ActiveChannel) XXX_Size() int { + return m.Size() +} +func (m *ActiveChannel) XXX_DiscardUnknown() { + xxx_messageInfo_ActiveChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_ActiveChannel proto.InternalMessageInfo + +func (m *ActiveChannel) GetPortId() string { if m != nil { return m.PortId } return "" } +func (m *ActiveChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +// RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address +type RegisteredInterchainAccount struct { + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + AccountAddress string `protobuf:"bytes,2,opt,name=account_address,json=accountAddress,proto3" json:"account_address,omitempty" yaml:"account_address"` +} + +func (m *RegisteredInterchainAccount) Reset() { *m = RegisteredInterchainAccount{} } +func (m *RegisteredInterchainAccount) String() string { return proto.CompactTextString(m) } +func (*RegisteredInterchainAccount) ProtoMessage() {} +func (*RegisteredInterchainAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_629b3ced0911516b, []int{2} +} +func (m *RegisteredInterchainAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisteredInterchainAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisteredInterchainAccount.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 *RegisteredInterchainAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisteredInterchainAccount.Merge(m, src) +} +func (m *RegisteredInterchainAccount) XXX_Size() int { + return m.Size() +} +func (m *RegisteredInterchainAccount) XXX_DiscardUnknown() { + xxx_messageInfo_RegisteredInterchainAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisteredInterchainAccount proto.InternalMessageInfo + +func (m *RegisteredInterchainAccount) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +func (m *RegisteredInterchainAccount) GetAccountAddress() string { + if m != nil { + return m.AccountAddress + } + return "" +} + func init() { proto.RegisterType((*GenesisState)(nil), "ibc.applications.interchain_accounts.v1.GenesisState") + proto.RegisterType((*ActiveChannel)(nil), "ibc.applications.interchain_accounts.v1.ActiveChannel") + proto.RegisterType((*RegisteredInterchainAccount)(nil), "ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount") } func init() { @@ -77,23 +201,34 @@ func init() { } var fileDescriptor_629b3ced0911516b = []byte{ - // 244 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xcd, 0x4c, 0x4a, 0xd6, - 0x4f, 0x2c, 0x28, 0xc8, 0xc9, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0xcf, 0xcc, 0x2b, - 0x49, 0x2d, 0x4a, 0xce, 0x48, 0xcc, 0xcc, 0x8b, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, - 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 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 0x01, 0x00, 0x00, + // 426 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x4f, 0x8b, 0x13, 0x31, + 0x18, 0xc6, 0x9b, 0x16, 0x57, 0x1a, 0x75, 0xc5, 0xb8, 0x4a, 0xa9, 0x30, 0x2d, 0xb9, 0x58, 0x90, + 0x4e, 0xd8, 0xfa, 0x0f, 0xbc, 0xb5, 0xab, 0x48, 0xaf, 0xe3, 0xcd, 0xcb, 0x90, 0xc9, 0x84, 0x69, + 0xa0, 0x33, 0x19, 0xe6, 0x4d, 0x07, 0x16, 0x3f, 0x84, 0x5e, 0xfc, 0x30, 0x7e, 0x03, 0x8f, 0x7b, + 0xf4, 0x34, 0x48, 0xfb, 0x0d, 0xe6, 0x13, 0xc8, 0x24, 0xc3, 0xee, 0x76, 0x29, 0xb2, 0x7b, 0x4b, + 0xf2, 0x3c, 0xbf, 0x37, 0x4f, 0xf2, 0xbe, 0xf8, 0xad, 0x8a, 0x04, 0xe3, 0x79, 0xbe, 0x56, 0x82, + 0x1b, 0xa5, 0x33, 0x60, 0x2a, 0x33, 0xb2, 0x10, 0x2b, 0xae, 0xb2, 0x90, 0x0b, 0xa1, 0x37, 0x99, + 0x01, 0x56, 0x9e, 0xb2, 0x44, 0x66, 0x12, 0x14, 0xf8, 0x79, 0xa1, 0x8d, 0x26, 0x2f, 0x55, 0x24, + 0xfc, 0xeb, 0x98, 0x7f, 0x00, 0xf3, 0xcb, 0xd3, 0xe1, 0x49, 0xa2, 0x13, 0x6d, 0x19, 0xd6, 0xac, + 0x1c, 0x4e, 0x7f, 0x75, 0xf1, 0xc3, 0xcf, 0xae, 0xe0, 0x17, 0xc3, 0x8d, 0x24, 0xdf, 0xf0, 0x63, + 0x2e, 0x8c, 0x2a, 0x65, 0x28, 0x56, 0x3c, 0xcb, 0xe4, 0x1a, 0x06, 0x68, 0xdc, 0x9b, 0x3c, 0x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 0xd7, 0xb9, 0xd8, 0x79, 0x9d, 0x3f, 0x3b, 0xaf, 0xf3, 0xf5, 0x53, 0xa2, + 0xcc, 0x6a, 0x13, 0xf9, 0x42, 0xa7, 0x4c, 0x68, 0x48, 0x35, 0x30, 0x15, 0x89, 0x69, 0xa2, 0x59, + 0x39, 0x63, 0xa9, 0x8e, 0x37, 0x6b, 0x09, 0xcd, 0xc4, 0x03, 0x9b, 0xbd, 0x9f, 0x5e, 0xfd, 0xfa, + 0xf4, 0x72, 0xd8, 0xcd, 0x79, 0x2e, 0x21, 0x3a, 0xb2, 0x93, 0xfa, 0xfa, 0x5f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xc5, 0x32, 0x06, 0x92, 0x21, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -116,6 +251,110 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Ports) > 0 { + for iNdEx := len(m.Ports) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Ports[iNdEx]) + copy(dAtA[i:], m.Ports[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Ports[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.InterchainAccounts) > 0 { + for iNdEx := len(m.InterchainAccounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.InterchainAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.ActiveChannels) > 0 { + for iNdEx := len(m.ActiveChannels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ActiveChannels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ActiveChannel) 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 *ActiveChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ActiveChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RegisteredInterchainAccount) 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 *RegisteredInterchainAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisteredInterchainAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AccountAddress) > 0 { + i -= len(m.AccountAddress) + copy(dAtA[i:], m.AccountAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AccountAddress))) + i-- + dAtA[i] = 0x12 + } if len(m.PortId) > 0 { i -= len(m.PortId) copy(dAtA[i:], m.PortId) @@ -138,6 +377,33 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { return base } func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ActiveChannels) > 0 { + for _, e := range m.ActiveChannels { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.InterchainAccounts) > 0 { + for _, e := range m.InterchainAccounts { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Ports) > 0 { + for _, s := range m.Ports { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *ActiveChannel) Size() (n int) { if m == nil { return 0 } @@ -147,6 +413,27 @@ func (m *GenesisState) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *RegisteredInterchainAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.AccountAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -185,6 +472,270 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ActiveChannels", 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 + } + m.ActiveChannels = append(m.ActiveChannels, &ActiveChannel{}) + if err := m.ActiveChannels[len(m.ActiveChannels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InterchainAccounts", 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 + } + m.InterchainAccounts = append(m.InterchainAccounts, &RegisteredInterchainAccount{}) + if err := m.InterchainAccounts[len(m.InterchainAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ports", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ports = append(m.Ports, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ActiveChannel) 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 ErrIntOverflowGenesis + } + 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: ActiveChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ActiveChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RegisteredInterchainAccount) 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 ErrIntOverflowGenesis + } + 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: RegisteredInterchainAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisteredInterchainAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) @@ -217,6 +768,38 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.PortId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccountAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/proto/ibc/applications/interchain_accounts/v1/account.proto b/proto/ibc/applications/interchain_accounts/v1/account.proto index a94519cd6ac..b7af89b502b 100644 --- a/proto/ibc/applications/interchain_accounts/v1/account.proto +++ b/proto/ibc/applications/interchain_accounts/v1/account.proto @@ -1,12 +1,13 @@ syntax = "proto3"; + package ibc.applications.interchain_accounts.v1; +option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"; + import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "cosmos/auth/v1beta1/auth.proto"; -option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"; - // An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain message InterchainAccount { option (gogoproto.goproto_getters) = false; diff --git a/proto/ibc/applications/interchain_accounts/v1/genesis.proto b/proto/ibc/applications/interchain_accounts/v1/genesis.proto index 001eeb00a6c..5645e726a3d 100644 --- a/proto/ibc/applications/interchain_accounts/v1/genesis.proto +++ b/proto/ibc/applications/interchain_accounts/v1/genesis.proto @@ -1,11 +1,26 @@ syntax = "proto3"; + 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"; -// GenesisState defines the interchain_account genesis state +// GenesisState defines the interchain accounts genesis state message GenesisState { - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + repeated ActiveChannel active_channels = 1 [(gogoproto.moretags) = "yaml:\"active_channels\""]; + repeated RegisteredInterchainAccount interchain_accounts = 2 [(gogoproto.moretags) = "yaml:\"interchain_accounts\""]; + repeated string ports = 3; +} + +// ActiveChannel contains a pairing of port ID and channel ID for an active interchain accounts channel +message ActiveChannel { + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; +} + +// RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address +message RegisteredInterchainAccount { + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string account_address = 2 [(gogoproto.moretags) = "yaml:\"account_address\""]; } diff --git a/proto/ibc/applications/interchain_accounts/v1/query.proto b/proto/ibc/applications/interchain_accounts/v1/query.proto index 160912b0610..a3b77506794 100644 --- a/proto/ibc/applications/interchain_accounts/v1/query.proto +++ b/proto/ibc/applications/interchain_accounts/v1/query.proto @@ -1,12 +1,13 @@ syntax = "proto3"; + 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 "google/api/annotations.proto"; import "ibc/applications/interchain_accounts/v1/account.proto"; -option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"; - // Query defines the gRPC querier service. service Query { // Query to get the address of an interchain account diff --git a/proto/ibc/applications/interchain_accounts/v1/types.proto b/proto/ibc/applications/interchain_accounts/v1/types.proto index fe19488d986..c6d9d0a3e96 100644 --- a/proto/ibc/applications/interchain_accounts/v1/types.proto +++ b/proto/ibc/applications/interchain_accounts/v1/types.proto @@ -1,9 +1,11 @@ syntax = "proto3"; + package ibc.applications.interchain_accounts.v1; +option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"; + import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"; // Type defines a classification of message issued from a controller chain to its associated interchain accounts // host