diff --git a/modules/core/04-channel/v2/genesis.go b/modules/core/04-channel/v2/genesis.go new file mode 100644 index 00000000000..29515d46bf0 --- /dev/null +++ b/modules/core/04-channel/v2/genesis.go @@ -0,0 +1,57 @@ +package channelv2 + +import ( + "context" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" +) + +func InitGenesis(ctx context.Context, k *keeper.Keeper, gs types.GenesisState) { + // set acks + for _, ack := range gs.Acknowledgements { + k.SetPacketAcknowledgement(ctx, ack.ClientId, ack.Sequence, ack.Data) + } + + // set commits + for _, commitment := range gs.Commitments { + k.SetPacketCommitment(ctx, commitment.ClientId, commitment.Sequence, commitment.Data) + } + + // set receipts + for _, receipt := range gs.Receipts { + k.SetPacketReceipt(ctx, receipt.ClientId, receipt.Sequence) + } + + // set send sequences + for _, seq := range gs.SendSequences { + k.SetNextSequenceSend(ctx, seq.ClientId, seq.Sequence) + } +} + +func ExportGenesis(ctx context.Context, k *keeper.Keeper) types.GenesisState { + clientStates := k.ClientKeeper.GetAllGenesisClients(ctx) + gs := types.GenesisState{ + Acknowledgements: make([]types.PacketState, 0), + Commitments: make([]types.PacketState, 0), + Receipts: make([]types.PacketState, 0), + SendSequences: make([]types.PacketSequence, 0), + } + for _, clientState := range clientStates { + acks := k.GetAllPacketAcknowledgementsForClient(ctx, clientState.ClientId) + gs.Acknowledgements = append(gs.Acknowledgements, acks...) + + comms := k.GetAllPacketCommitmentsForClient(ctx, clientState.ClientId) + gs.Commitments = append(gs.Commitments, comms...) + + receipts := k.GetAllPacketReceiptsForClient(ctx, clientState.ClientId) + gs.Receipts = append(gs.Receipts, receipts...) + + seq, ok := k.GetNextSequenceSend(ctx, clientState.ClientId) + if ok { + gs.SendSequences = append(gs.SendSequences, types.NewPacketSequence(clientState.ClientId, seq)) + } + } + + return gs +} diff --git a/modules/core/04-channel/v2/genesis_test.go b/modules/core/04-channel/v2/genesis_test.go new file mode 100644 index 00000000000..e56be7b23a2 --- /dev/null +++ b/modules/core/04-channel/v2/genesis_test.go @@ -0,0 +1,61 @@ +package channelv2_test + +import ( + channelv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +// TestInitExportGenesis tests the import and export flow for the channel v2 keeper. +func (suite *ModuleTestSuite) TestInitExportGenesis() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + path2 := ibctesting.NewPath(suite.chainA, suite.chainC) + path2.SetupV2() + + app := suite.chainA.App + + emptyGenesis := types.DefaultGenesisState() + + // create a valid genesis state that uses the client keepers existing client IDs + clientStates := app.GetIBCKeeper().ClientKeeper.GetAllGenesisClients(suite.chainA.GetContext()) + validGs := types.DefaultGenesisState() + for i, clientState := range clientStates { + ack := types.NewPacketState(clientState.ClientId, uint64(i+1), []byte("ack")) + receipt := types.NewPacketState(clientState.ClientId, uint64(i+1), []byte{byte(0x2)}) + commitment := types.NewPacketState(clientState.ClientId, uint64(i+1), []byte("commit_hash")) + seq := types.NewPacketSequence(clientState.ClientId, uint64(i+1)) + + validGs.Acknowledgements = append(validGs.Acknowledgements, ack) + validGs.Receipts = append(validGs.Receipts, receipt) + validGs.Commitments = append(validGs.Commitments, commitment) + validGs.SendSequences = append(validGs.SendSequences, seq) + emptyGenesis.SendSequences = append(emptyGenesis.SendSequences, seq) + } + + tests := []struct { + name string + genState types.GenesisState + }{ + { + name: "no modifications genesis", + genState: emptyGenesis, + }, + { + name: "valid", + genState: validGs, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + channelV2Keeper := app.GetIBCKeeper().ChannelKeeperV2 + + channelv2.InitGenesis(suite.chainA.GetContext(), channelV2Keeper, tt.genState) + + exported := channelv2.ExportGenesis(suite.chainA.GetContext(), channelV2Keeper) + suite.Require().Equal(tt.genState, exported) + }) + } +} diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 1d9027c39a8..59bea345638 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -1,12 +1,15 @@ package keeper import ( + "bytes" "context" corestore "cosmossdk.io/core/store" "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" connectionkeeper "github.com/cosmos/ibc-go/v9/modules/core/03-connection/keeper" @@ -193,3 +196,58 @@ func (k *Keeper) DeleteAsyncPacket(ctx context.Context, clientID string, sequenc panic(err) } } + +// extractSequenceFromKey takes the full store key as well as a packet store prefix and extracts +// the encoded sequence number from the key. +// +// This function panics of the provided key once trimmed is larger than 8 bytes as the expected +// sequence byte length is always 8. +func extractSequenceFromKey(key, storePrefix []byte) uint64 { + sequenceBz := bytes.TrimPrefix(key, storePrefix) + if len(sequenceBz) > 8 { + panic("sequence is too long - expected 8 bytes") + } + return sdk.BigEndianToUint64(sequenceBz) +} + +// GetAllPacketCommitmentsForClient returns all stored PacketCommitments objects for a specified +// client ID. +func (k *Keeper) GetAllPacketCommitmentsForClient(ctx context.Context, clientID string) []types.PacketState { + return k.getAllPacketsForClientStore(ctx, clientID, hostv2.PacketCommitmentPrefixKey) +} + +// GetAllPacketAcknowledgementsForClient returns all stored PacketAcknowledgements objects for a specified +// client ID. +func (k *Keeper) GetAllPacketAcknowledgementsForClient(ctx context.Context, clientID string) []types.PacketState { + return k.getAllPacketsForClientStore(ctx, clientID, hostv2.PacketAcknowledgementPrefixKey) +} + +// GetAllPacketReceiptsForClient returns all stored PacketReceipts objects for a specified +// client ID. +func (k *Keeper) GetAllPacketReceiptsForClient(ctx context.Context, clientID string) []types.PacketState { + return k.getAllPacketsForClientStore(ctx, clientID, hostv2.PacketReceiptPrefixKey) +} + +// prefixKeyConstructor is a function that constructs a store key for a specific packet store using the provided +// clientID. +type prefixKeyConstructor func(clientID string) []byte + +// getAllPacketsForClientStore gets all PacketState objects for the specified clientID using a provided +// function for constructing the key prefix for the store. +// +// For example, to get all PacketReceipts for a clientID the hostv2.PacketReceiptPrefixKey function can be +// passed to get the PacketReceipt store key prefix. +func (k *Keeper) getAllPacketsForClientStore(ctx context.Context, clientID string, prefixFn prefixKeyConstructor) []types.PacketState { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + storePrefix := prefixFn(clientID) + iterator := storetypes.KVStorePrefixIterator(store, storePrefix) + + var packets []types.PacketState + for ; iterator.Valid(); iterator.Next() { + sequence := extractSequenceFromKey(iterator.Key(), storePrefix) + state := types.NewPacketState(clientID, sequence, iterator.Value()) + + packets = append(packets, state) + } + return packets +} diff --git a/modules/core/04-channel/v2/module.go b/modules/core/04-channel/v2/module.go index 9f6fbf8f7d6..aa899ec2291 100644 --- a/modules/core/04-channel/v2/module.go +++ b/modules/core/04-channel/v2/module.go @@ -1,4 +1,4 @@ -package client +package channelv2 import ( "github.com/spf13/cobra" @@ -7,7 +7,6 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) -// Name returns the IBC channel/v2 name func Name() string { return types.SubModuleName } diff --git a/modules/core/04-channel/v2/module_test.go b/modules/core/04-channel/v2/module_test.go new file mode 100644 index 00000000000..dcac04a2614 --- /dev/null +++ b/modules/core/04-channel/v2/module_test.go @@ -0,0 +1,31 @@ +package channelv2_test + +import ( + "testing" + + testifysuite "github.com/stretchr/testify/suite" + + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +func TestModuleTestSuite(t *testing.T) { + testifysuite.Run(t, new(ModuleTestSuite)) +} + +type ModuleTestSuite struct { + testifysuite.Suite + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain + chainC *ibctesting.TestChain +} + +func (suite *ModuleTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) +} diff --git a/modules/core/04-channel/v2/types/expected_keepers.go b/modules/core/04-channel/v2/types/expected_keepers.go index 41db0741876..2078b5ac0f6 100644 --- a/modules/core/04-channel/v2/types/expected_keepers.go +++ b/modules/core/04-channel/v2/types/expected_keepers.go @@ -25,4 +25,6 @@ type ClientKeeper interface { GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) // GetClientCounterparty returns the counterpartyInfo given a clientID GetClientCounterparty(ctx context.Context, clientID string) (clienttypes.CounterpartyInfo, bool) + // GetAllGenesisClients returns all the clients in state with their client ids returned as IdentifiedClientState + GetAllGenesisClients(ctx context.Context) clienttypes.IdentifiedClientStates } diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index 03f15a858d5..1a0e5d796da 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -6,22 +6,28 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +const ( + PacketCommitmentBasePrefix = byte(1) + PacketReceiptBasePrefix = byte(2) + PacketAcknowledgementBasePrefix = byte(3) +) + // PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. // channelID must be a generated identifier, not provided externally so key collisions are not possible. func PacketCommitmentPrefixKey(channelID string) []byte { - return append([]byte(channelID), byte(1)) + return append([]byte(channelID), PacketCommitmentBasePrefix) } // PacketCommitmentKey returns the store key of under which a packet commitment is stored. // channelID must be a generated identifier, not provided externally so key collisions are not possible. func PacketCommitmentKey(channelID string, sequence uint64) []byte { - return append(PacketCommitmentPrefixKey((channelID)), sdk.Uint64ToBigEndian(sequence)...) + return append(PacketCommitmentPrefixKey(channelID), sdk.Uint64ToBigEndian(sequence)...) } // PacketReceiptPrefixKey returns the store key prefix under which packet receipts for a particular channel are stored. // channelID must be a generated identifier, not provided externally so key collisions are not possible. func PacketReceiptPrefixKey(channelID string) []byte { - return append([]byte(channelID), byte(2)) + return append([]byte(channelID), PacketReceiptBasePrefix) } // PacketReceiptKey returns the store key of under which a packet receipt is stored. @@ -33,7 +39,7 @@ func PacketReceiptKey(channelID string, sequence uint64) []byte { // PacketAcknowledgementPrefixKey returns the store key prefix under which packet acknowledgements for a particular channel are stored. // channelID must be a generated identifier, not provided externally so key collisions are not possible. func PacketAcknowledgementPrefixKey(channelID string) []byte { - return append([]byte(channelID), byte(3)) + return append([]byte(channelID), PacketAcknowledgementBasePrefix) } // PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. diff --git a/modules/core/genesis.go b/modules/core/genesis.go index 972e1d3e723..437be3cd7bd 100644 --- a/modules/core/genesis.go +++ b/modules/core/genesis.go @@ -6,6 +6,7 @@ import ( client "github.com/cosmos/ibc-go/v9/modules/core/02-client" connection "github.com/cosmos/ibc-go/v9/modules/core/03-connection" channel "github.com/cosmos/ibc-go/v9/modules/core/04-channel" + channelv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2" "github.com/cosmos/ibc-go/v9/modules/core/keeper" "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -16,6 +17,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs *types.GenesisState) { client.InitGenesis(ctx, k.ClientKeeper, gs.ClientGenesis) connection.InitGenesis(ctx, k.ConnectionKeeper, gs.ConnectionGenesis) channel.InitGenesis(ctx, k.ChannelKeeper, gs.ChannelGenesis) + channelv2.InitGenesis(ctx, k.ChannelKeeperV2, gs.ChannelV2Genesis) } // ExportGenesis returns the ibc exported genesis. @@ -24,5 +26,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { ClientGenesis: client.ExportGenesis(ctx, k.ClientKeeper), ConnectionGenesis: connection.ExportGenesis(ctx, k.ConnectionKeeper), ChannelGenesis: channel.ExportGenesis(ctx, k.ChannelKeeper), + ChannelV2Genesis: channelv2.ExportGenesis(ctx, k.ChannelKeeperV2), } } diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index ea378605fd1..8d07cb5acd4 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -13,6 +13,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channelv2types "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/types" @@ -145,6 +146,20 @@ func (suite *IBCTestSuite) TestValidateGenesis() { 0, channeltypes.Params{UpgradeTimeout: channeltypes.DefaultTimeout}, ), + ChannelV2Genesis: channelv2types.NewGenesisState( + []channelv2types.PacketState{ + channelv2types.NewPacketState(channel2, 1, []byte("ack")), + }, + []channelv2types.PacketState{ + channelv2types.NewPacketState(channel2, 1, []byte("")), + }, + []channelv2types.PacketState{ + channelv2types.NewPacketState(channel1, 1, []byte("commit_hash")), + }, + []channelv2types.PacketSequence{ + channelv2types.NewPacketSequence(channel1, 1), + }, + ), }, expError: nil, }, @@ -172,6 +187,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { 2, ), ConnectionGenesis: connectiontypes.DefaultGenesisState(), + ChannelV2Genesis: channelv2types.DefaultGenesisState(), }, expError: errors.New("genesis metadata key cannot be empty"), }, @@ -189,6 +205,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { 0, connectiontypes.Params{}, ), + ChannelV2Genesis: channelv2types.DefaultGenesisState(), }, expError: errors.New("invalid connection"), }, @@ -202,6 +219,21 @@ func (suite *IBCTestSuite) TestValidateGenesis() { channeltypes.NewPacketState("(portID)", channel1, 1, []byte("ack")), }, }, + ChannelV2Genesis: channelv2types.DefaultGenesisState(), + }, + expError: errors.New("invalid acknowledgement"), + }, + { + name: "invalid channel v2 genesis", + genState: &types.GenesisState{ + ClientGenesis: clienttypes.DefaultGenesisState(), + ConnectionGenesis: connectiontypes.DefaultGenesisState(), + ChannelGenesis: channeltypes.DefaultGenesisState(), + ChannelV2Genesis: channelv2types.GenesisState{ + Acknowledgements: []channelv2types.PacketState{ + channelv2types.NewPacketState(channel1, 1, nil), + }, + }, }, expError: errors.New("invalid acknowledgement"), }, @@ -305,6 +337,20 @@ func (suite *IBCTestSuite) TestInitGenesis() { 0, channeltypes.Params{UpgradeTimeout: channeltypes.DefaultTimeout}, ), + ChannelV2Genesis: channelv2types.NewGenesisState( + []channelv2types.PacketState{ + channelv2types.NewPacketState(channel2, 1, []byte("ack")), + }, + []channelv2types.PacketState{ + channelv2types.NewPacketState(channel2, 1, []byte("")), + }, + []channelv2types.PacketState{ + channelv2types.NewPacketState(channel1, 1, []byte("commit_hash")), + }, + []channelv2types.PacketSequence{ + channelv2types.NewPacketSequence(channel1, 1), + }, + ), }, }, } diff --git a/modules/core/types/genesis.go b/modules/core/types/genesis.go index 7b43fd9c71a..9adab5d0d40 100644 --- a/modules/core/types/genesis.go +++ b/modules/core/types/genesis.go @@ -6,6 +6,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + channelv2types "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) var _ codectypes.UnpackInterfacesMessage = (*GenesisState)(nil) @@ -16,6 +17,7 @@ func DefaultGenesisState() *GenesisState { ClientGenesis: clienttypes.DefaultGenesisState(), ConnectionGenesis: connectiontypes.DefaultGenesisState(), ChannelGenesis: channeltypes.DefaultGenesisState(), + ChannelV2Genesis: channelv2types.DefaultGenesisState(), } } @@ -35,5 +37,9 @@ func (gs *GenesisState) Validate() error { return err } - return gs.ChannelGenesis.Validate() + if err := gs.ChannelGenesis.Validate(); err != nil { + return err + } + + return gs.ChannelV2Genesis.Validate() } diff --git a/modules/core/types/genesis.pb.go b/modules/core/types/genesis.pb.go index 752101a366d..c216f00f74c 100644 --- a/modules/core/types/genesis.pb.go +++ b/modules/core/types/genesis.pb.go @@ -10,6 +10,7 @@ import ( types "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" types1 "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" types2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + types3 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" io "io" math "math" math_bits "math/bits" @@ -34,6 +35,8 @@ type GenesisState struct { ConnectionGenesis types1.GenesisState `protobuf:"bytes,2,opt,name=connection_genesis,json=connectionGenesis,proto3" json:"connection_genesis"` // ICS004 - Channel genesis state ChannelGenesis types2.GenesisState `protobuf:"bytes,3,opt,name=channel_genesis,json=channelGenesis,proto3" json:"channel_genesis"` + // ICS004 - Channel/v2 genesis state + ChannelV2Genesis types3.GenesisState `protobuf:"bytes,4,opt,name=channel_v2_genesis,json=channelV2Genesis,proto3" json:"channel_v2_genesis"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -90,6 +93,13 @@ func (m *GenesisState) GetChannelGenesis() types2.GenesisState { return types2.GenesisState{} } +func (m *GenesisState) GetChannelV2Genesis() types3.GenesisState { + if m != nil { + return m.ChannelV2Genesis + } + return types3.GenesisState{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "ibc.core.types.v1.GenesisState") } @@ -97,26 +107,27 @@ func init() { func init() { proto.RegisterFile("ibc/core/types/v1/genesis.proto", fileDescriptor_b9a49c5663e6fc59) } var fileDescriptor_b9a49c5663e6fc59 = []byte{ - // 293 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xb1, 0x4e, 0xeb, 0x30, - 0x14, 0x40, 0x93, 0xbe, 0x27, 0x86, 0x00, 0x45, 0x8d, 0x18, 0x50, 0x06, 0x37, 0x45, 0x1d, 0x58, - 0xb0, 0x15, 0x98, 0x58, 0xbb, 0xc0, 0x82, 0x84, 0x60, 0x82, 0x05, 0x35, 0xc6, 0x72, 0x2d, 0x25, - 0xbe, 0x55, 0xed, 0x46, 0xe2, 0x17, 0x98, 0xf8, 0xac, 0x8e, 0x1d, 0x99, 0x10, 0x4a, 0x7e, 0x04, - 0xd5, 0x36, 0x4e, 0xa4, 0xa8, 0x5b, 0x94, 0x73, 0x7c, 0x7c, 0x6d, 0x47, 0x63, 0x91, 0x53, 0x42, - 0x61, 0xc5, 0x88, 0x7e, 0x5f, 0x32, 0x45, 0xaa, 0x8c, 0x70, 0x26, 0x99, 0x12, 0x0a, 0x2f, 0x57, - 0xa0, 0x21, 0x1e, 0x89, 0x9c, 0xe2, 0x9d, 0x80, 0x8d, 0x80, 0xab, 0x2c, 0x39, 0xe5, 0xc0, 0xc1, - 0x50, 0xb2, 0xfb, 0xb2, 0x62, 0x92, 0xfa, 0x12, 0x2d, 0x04, 0x93, 0xba, 0x97, 0x4a, 0xa6, 0xad, - 0x01, 0x52, 0x32, 0xaa, 0x05, 0xc8, 0xbe, 0x35, 0x69, 0xad, 0xc5, 0x5c, 0x4a, 0x56, 0xf4, 0x94, - 0xf3, 0x8f, 0x41, 0x74, 0x74, 0x6b, 0xff, 0x3c, 0xe9, 0xb9, 0x66, 0xf1, 0x7d, 0x34, 0xb4, 0x9b, - 0xbe, 0x3a, 0xf1, 0x2c, 0x4c, 0xc3, 0x8b, 0xc3, 0xab, 0x14, 0xfb, 0xe9, 0x2d, 0xc7, 0x55, 0x86, - 0xbb, 0x2b, 0x67, 0xff, 0x37, 0xdf, 0xe3, 0xe0, 0xf1, 0xd8, 0x52, 0x47, 0xe2, 0xe7, 0x28, 0x6e, - 0x27, 0xf4, 0xc9, 0x81, 0x49, 0x4e, 0x3b, 0x49, 0xef, 0xec, 0xc9, 0x8e, 0x5a, 0xe3, 0x2f, 0xfd, - 0x10, 0x9d, 0xb8, 0x63, 0xf9, 0xee, 0x3f, 0xd3, 0x9d, 0x74, 0xba, 0x56, 0xd8, 0x13, 0x1d, 0x3a, - 0xec, 0xd0, 0xec, 0x6e, 0x53, 0xa3, 0x70, 0x5b, 0xa3, 0xf0, 0xa7, 0x46, 0xe1, 0x67, 0x83, 0x82, - 0x6d, 0x83, 0x82, 0xaf, 0x06, 0x05, 0x2f, 0x98, 0x0b, 0xbd, 0x58, 0xe7, 0x98, 0x42, 0x49, 0x28, - 0xa8, 0x12, 0x14, 0x11, 0x39, 0xbd, 0xe4, 0x40, 0xaa, 0x1b, 0x52, 0xc2, 0xdb, 0xba, 0x60, 0xaa, - 0xf3, 0xf6, 0xf9, 0x81, 0xb9, 0xdd, 0xeb, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x65, 0x21, 0x36, - 0x53, 0x14, 0x02, 0x00, 0x00, + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, + 0x1c, 0xc7, 0xf1, 0xa4, 0x16, 0x87, 0x53, 0xab, 0x0d, 0x0e, 0xd2, 0xe1, 0xda, 0x4a, 0x07, 0x17, + 0xef, 0x68, 0x9c, 0x5c, 0xbb, 0xe8, 0x22, 0x88, 0xa2, 0xa0, 0x8b, 0x34, 0xe7, 0x91, 0x1e, 0xb4, + 0xf7, 0x2f, 0xbd, 0x6b, 0xc0, 0xb7, 0xf0, 0xb1, 0x3a, 0x76, 0x74, 0x12, 0x4d, 0x5e, 0x44, 0x9a, + 0xbb, 0x5c, 0x22, 0x35, 0xe0, 0x16, 0xf2, 0xfb, 0xe6, 0x43, 0x8e, 0x04, 0x75, 0x45, 0xc4, 0x28, + 0x83, 0x05, 0xa7, 0xfa, 0x6d, 0xce, 0x15, 0x4d, 0x86, 0x34, 0xe6, 0x92, 0x2b, 0xa1, 0xc8, 0x7c, + 0x01, 0x1a, 0x82, 0xb6, 0x88, 0x18, 0xd9, 0x04, 0x24, 0x0f, 0x48, 0x32, 0xec, 0x1c, 0xc7, 0x10, + 0x43, 0xbe, 0xd2, 0xcd, 0x95, 0x09, 0x3b, 0x3d, 0x27, 0xb1, 0xa9, 0xe0, 0x52, 0x6f, 0x51, 0x9d, + 0x41, 0x59, 0x80, 0x94, 0x9c, 0x69, 0x01, 0x72, 0xbb, 0xea, 0x97, 0xd5, 0x64, 0x2c, 0x25, 0x9f, + 0xfe, 0x2b, 0x09, 0x7f, 0x27, 0xa7, 0xdf, 0x0d, 0xb4, 0x7f, 0x65, 0xee, 0xdc, 0xeb, 0xb1, 0xe6, + 0xc1, 0x0d, 0x6a, 0x99, 0xf7, 0x7a, 0xb1, 0xe1, 0x89, 0xdf, 0xf3, 0xcf, 0xf6, 0xc2, 0x1e, 0x71, + 0x07, 0x34, 0x3b, 0x49, 0x86, 0xa4, 0xfa, 0xe4, 0xa8, 0xb9, 0xfa, 0xec, 0x7a, 0x77, 0x07, 0x66, + 0xb5, 0x4b, 0xf0, 0x84, 0x82, 0xf2, 0x10, 0x8e, 0x6c, 0xe4, 0xe4, 0xa0, 0x42, 0xba, 0xa6, 0x86, + 0x6d, 0x97, 0x45, 0x41, 0xdf, 0xa2, 0x43, 0x7b, 0x2c, 0xe7, 0xee, 0xe4, 0x6e, 0xbf, 0xe2, 0x9a, + 0xa0, 0x06, 0x6d, 0xd9, 0xb9, 0x10, 0x1f, 0x50, 0x50, 0x88, 0x49, 0xe8, 0xd0, 0x66, 0x2d, 0x1a, + 0xfe, 0x85, 0x1e, 0xd9, 0xf9, 0x31, 0xb4, 0xe3, 0xe8, 0x7a, 0x95, 0x62, 0x7f, 0x9d, 0x62, 0xff, + 0x2b, 0xc5, 0xfe, 0x7b, 0x86, 0xbd, 0x75, 0x86, 0xbd, 0x8f, 0x0c, 0x7b, 0xcf, 0x24, 0x16, 0x7a, + 0xb2, 0x8c, 0x08, 0x83, 0x19, 0x65, 0xa0, 0x66, 0xa0, 0xa8, 0x88, 0xd8, 0x79, 0x0c, 0x34, 0xb9, + 0xa4, 0x33, 0x78, 0x5d, 0x4e, 0xb9, 0xaa, 0xfc, 0x75, 0xd1, 0x6e, 0xfe, 0xd1, 0x2e, 0x7e, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x30, 0xba, 0x18, 0x2c, 0x8e, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -139,6 +150,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.ChannelV2Genesis.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 { size, err := m.ChannelGenesis.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -195,6 +216,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) l = m.ChannelGenesis.Size() n += 1 + l + sovGenesis(uint64(l)) + l = m.ChannelV2Genesis.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -332,6 +355,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelV2Genesis", 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.ChannelV2Genesis.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/proto/ibc/core/types/v1/genesis.proto b/proto/ibc/core/types/v1/genesis.proto index 4c6571da60a..6e087c6d547 100644 --- a/proto/ibc/core/types/v1/genesis.proto +++ b/proto/ibc/core/types/v1/genesis.proto @@ -8,6 +8,7 @@ import "gogoproto/gogo.proto"; import "ibc/core/client/v1/genesis.proto"; import "ibc/core/connection/v1/genesis.proto"; import "ibc/core/channel/v1/genesis.proto"; +import "ibc/core/channel/v2/genesis.proto"; // GenesisState defines the ibc module's genesis state. message GenesisState { @@ -17,4 +18,6 @@ message GenesisState { ibc.core.connection.v1.GenesisState connection_genesis = 2 [(gogoproto.nullable) = false]; // ICS004 - Channel genesis state ibc.core.channel.v1.GenesisState channel_genesis = 3 [(gogoproto.nullable) = false]; + // ICS004 - Channel/v2 genesis state + ibc.core.channel.v2.GenesisState channel_v2_genesis = 4 [(gogoproto.nullable) = false]; }