From c92c55cb69f75d3e36f2074916da0d5197b97dc6 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Wed, 22 Sep 2021 11:47:42 +0200 Subject: [PATCH] simplify parent genesis --- docs/ibc/proto-docs.md | 18 - modules/apps/ccv/parent/keeper/genesis.go | 20 +- .../apps/ccv/parent/keeper/genesis_test.go | 28 -- modules/apps/ccv/parent/keeper/keeper.go | 56 --- modules/apps/ccv/parent/keeper/relay.go | 2 - modules/apps/ccv/types/genesis.pb.go | 382 +++--------------- modules/apps/ccv/types/genesis_test.go | 32 +- proto/ibc/applications/ccv/v1/genesis.proto | 15 +- 8 files changed, 63 insertions(+), 490 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 0456478b5a1..e13a0e6c92e 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -46,7 +46,6 @@ - [ChildGenesisState](#ibc.applications.ccv.v1.ChildGenesisState) - [ChildState](#ibc.applications.ccv.v1.ChildState) - [ParentGenesisState](#ibc.applications.ccv.v1.ParentGenesisState) - - [UnbondingGenesis](#ibc.applications.ccv.v1.UnbondingGenesis) - [UnbondingSequence](#ibc.applications.ccv.v1.UnbondingSequence) - [ibc/applications/transfer/v1/transfer.proto](#ibc/applications/transfer/v1/transfer.proto) @@ -849,7 +848,6 @@ ChildState defines the state that the parent chain stores for each child chain | `chain_id` | [string](#string) | | | | `channel_id` | [string](#string) | | | | `status` | [Status](#ibc.applications.ccv.v1.Status) | | | -| `unbonding_packets` | [UnbondingGenesis](#ibc.applications.ccv.v1.UnbondingGenesis) | repeated | | @@ -871,22 +869,6 @@ ParentGenesisState defines the CCV parent chain genesis state - - -### UnbondingGenesis -UnbondingGenesis defines the genesis state for an unbonding packet - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `sequence` | [uint64](#uint64) | | | -| `unbonding_changes` | [tendermint.abci.ValidatorUpdate](#tendermint.abci.ValidatorUpdate) | repeated | | - - - - - - ### UnbondingSequence diff --git a/modules/apps/ccv/parent/keeper/genesis.go b/modules/apps/ccv/parent/keeper/genesis.go index 99e27d1b8ce..646c7defadd 100644 --- a/modules/apps/ccv/parent/keeper/genesis.go +++ b/modules/apps/ccv/parent/keeper/genesis.go @@ -27,10 +27,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.ParentGenesisState) k.SetChainToChannel(ctx, cc.ChainId, cc.ChannelId) k.SetChannelToChain(ctx, cc.ChannelId, cc.ChainId) k.SetChannelStatus(ctx, cc.ChannelId, cc.Status) - for _, up := range cc.UnbondingPackets { - packetData := types.NewValidatorSetChangePacketData(up.UnbondingChanges) - k.SetUnbondingPacketData(ctx, cc.ChainId, up.Sequence, packetData) - } } } @@ -48,22 +44,12 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) types.ParentGenesisState { for ; iterator.Valid(); iterator.Next() { channelID := string(iterator.Key()) chainID := string(iterator.Value()) - var unbondingPackets []types.UnbondingGenesis - - k.IterateUnbondingPacketData(ctx, chainID, func(_ string, seq uint64, packetData types.ValidatorSetChangePacketData) (stop bool) { - unbondingPackets = append(unbondingPackets, types.UnbondingGenesis{ - Sequence: seq, - UnbondingChanges: packetData.ValidatorUpdates, - }) - return false - }) status := k.GetChannelStatus(ctx, channelID) cc := types.ChildState{ - ChainId: chainID, - ChannelId: channelID, - Status: status, - UnbondingPackets: unbondingPackets, + ChainId: chainID, + ChannelId: channelID, + Status: status, } childStates = append(childStates, cc) } diff --git a/modules/apps/ccv/parent/keeper/genesis_test.go b/modules/apps/ccv/parent/keeper/genesis_test.go index 95736204b84..85180381218 100644 --- a/modules/apps/ccv/parent/keeper/genesis_test.go +++ b/modules/apps/ccv/parent/keeper/genesis_test.go @@ -3,40 +3,16 @@ package keeper_test import ( "fmt" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/ibc-go/modules/apps/ccv/types" - abci "github.com/tendermint/tendermint/abci/types" ) func (suite *KeeperTestSuite) TestGenesis() { - pk1, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) - suite.Require().NoError(err) - pk2, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) - suite.Require().NoError(err) - - pd := types.NewValidatorSetChangePacketData( - []abci.ValidatorUpdate{ - { - PubKey: pk1, - Power: 30, - }, - { - PubKey: pk2, - Power: 20, - }, - }, - ) - // set some chain-channel pairs before exporting ctx := suite.parentChain.GetContext() for i := 0; i < 4; i++ { suite.parentChain.GetSimApp().ParentKeeper.SetChainToChannel(ctx, fmt.Sprintf("chainid-%d", i), fmt.Sprintf("channel-%d", i)) suite.parentChain.GetSimApp().ParentKeeper.SetChannelToChain(ctx, fmt.Sprintf("channel-%d", i), fmt.Sprintf("chainid-%d", i)) suite.parentChain.GetSimApp().ParentKeeper.SetChannelStatus(ctx, fmt.Sprintf("channel-%d", i), types.Status(i)) - for i := 3; i < 6; i++ { - suite.parentChain.GetSimApp().ParentKeeper.SetUnbondingPacketData(ctx, fmt.Sprintf("chainid-%d", i), uint64(i), pd) - } } genState := suite.parentChain.GetSimApp().ParentKeeper.ExportGenesis(suite.parentChain.GetContext()) @@ -56,9 +32,5 @@ func (suite *KeeperTestSuite) TestGenesis() { status := suite.childChain.GetSimApp().ParentKeeper.GetChannelStatus(ctx, channelID) suite.Require().Equal(int32(i), status, "status is unexpected for given channel id: %s", channelID) - - for j := 3; j < 6; j++ { - suite.childChain.GetSimApp().ParentKeeper.GetUnbondingPacketData(ctx, chainID, uint64(j)) - } } } diff --git a/modules/apps/ccv/parent/keeper/keeper.go b/modules/apps/ccv/parent/keeper/keeper.go index 6b627b1a93f..d8576cfa4be 100644 --- a/modules/apps/ccv/parent/keeper/keeper.go +++ b/modules/apps/ccv/parent/keeper/keeper.go @@ -1,9 +1,6 @@ package keeper import ( - "fmt" - "strconv" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -17,7 +14,6 @@ import ( host "github.com/cosmos/ibc-go/modules/core/24-host" ibcexported "github.com/cosmos/ibc-go/modules/core/exported" ibctmtypes "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" ) @@ -168,58 +164,6 @@ func (k Keeper) IterateChannelToChain(ctx sdk.Context, cb func(ctx sdk.Context, } } -// SetUnbondingPacketData sets the unbonding packet data for a given baby chain and sequence -func (k Keeper) SetUnbondingPacketData(ctx sdk.Context, chainID string, seq uint64, packetData ccv.ValidatorSetChangePacketData) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&packetData) - store.Set(types.UnbondingPacketData(chainID, seq), bz) -} - -// GetUnbondingPacketData gets the unbonding packet for a given baby chain and sequence -func (k Keeper) GetUnbondingPacketData(ctx sdk.Context, chainID string, seq uint64) []abci.ValidatorUpdate { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.UnbondingPacketData(chainID, seq)) - if bz != nil { - return nil - } - var packetData ccv.ValidatorSetChangePacketData - k.cdc.MustUnmarshal(bz, &packetData) - return packetData.ValidatorUpdates -} - -// DeleteUnbondingPacketData deletes the unbonding packet for a given baby chain and sequence -func (k Keeper) DeleteUnbondingPacketData(ctx sdk.Context, chainID string, seq uint64) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.UnbondingPacketData(chainID, seq)) -} - -// IterateUnbondingPacketData iterates over the unbonding packet data for a given chainID -// and calls the callback provided until the stop boolean returns true. -func (k Keeper) IterateUnbondingPacketData(ctx sdk.Context, chainID string, cb func(chainID string, seq uint64, packetData ccv.ValidatorSetChangePacketData) (stop bool)) { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(fmt.Sprintf("%s/%s/", types.UnbondingPacketDataPrefix, chainID))) - defer iterator.Close() - - if !iterator.Valid() { - return - } - - for ; iterator.Valid(); iterator.Next() { - seq, err := strconv.Atoi(string(iterator.Key())) - if err != nil { - panic("sequence is not a number") - } - - bz := iterator.Value() - var packetData ccv.ValidatorSetChangePacketData - k.cdc.MustUnmarshal(bz, &packetData) - - if cb(chainID, uint64(seq), packetData) { - break - } - } -} - // SetChannelStatus sets the status of a CCV channel with the given status func (k Keeper) SetChannelStatus(ctx sdk.Context, channelID string, status ccv.Status) { store := ctx.KVStore(k.storeKey) diff --git a/modules/apps/ccv/parent/keeper/relay.go b/modules/apps/ccv/parent/keeper/relay.go index 5db5a7cdbff..ea0f47d1c83 100644 --- a/modules/apps/ccv/parent/keeper/relay.go +++ b/modules/apps/ccv/parent/keeper/relay.go @@ -48,7 +48,6 @@ func (k Keeper) SendPacket(ctx sdk.Context, chainID string, valUpdates []abci.Va return err } - k.SetUnbondingPacketData(ctx, chainID, sequence, packetData) return nil } @@ -61,7 +60,6 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Pac return err } k.registryKeeper.UnbondValidators(ctx, chainID, data.ValidatorUpdates) - k.DeleteUnbondingPacketData(ctx, chainID, packet.Sequence) return nil } diff --git a/modules/apps/ccv/types/genesis.pb.go b/modules/apps/ccv/types/genesis.pb.go index 866b0729d56..3953a16e365 100644 --- a/modules/apps/ccv/types/genesis.pb.go +++ b/modules/apps/ccv/types/genesis.pb.go @@ -9,7 +9,7 @@ import ( types "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - types2 "github.com/tendermint/tendermint/abci/types" + _ "github.com/tendermint/tendermint/abci/types" io "io" math "math" math_bits "math/bits" @@ -221,10 +221,9 @@ func (m *ParentGenesisState) GetChildStates() []ChildState { // ChildState defines the state that the parent chain stores for each child chain type ChildState struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" yaml:"chain_id"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` - Status Status `protobuf:"varint,3,opt,name=status,proto3,enum=ibc.applications.ccv.v1.Status" json:"status,omitempty"` - UnbondingPackets []UnbondingGenesis `protobuf:"bytes,4,rep,name=unbonding_packets,json=unbondingPackets,proto3" json:"unbonding_packets" yaml:"unbonding_packets"` + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" yaml:"chain_id"` + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + Status Status `protobuf:"varint,3,opt,name=status,proto3,enum=ibc.applications.ccv.v1.Status" json:"status,omitempty"` } func (m *ChildState) Reset() { *m = ChildState{} } @@ -281,72 +280,11 @@ func (m *ChildState) GetStatus() Status { return UNINITIALIZED } -func (m *ChildState) GetUnbondingPackets() []UnbondingGenesis { - if m != nil { - return m.UnbondingPackets - } - return nil -} - -// UnbondingGenesis defines the genesis state for an unbonding packet -type UnbondingGenesis struct { - Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` - UnbondingChanges []types2.ValidatorUpdate `protobuf:"bytes,2,rep,name=unbonding_changes,json=unbondingChanges,proto3" json:"unbonding_changes" yaml:"pending_changes"` -} - -func (m *UnbondingGenesis) Reset() { *m = UnbondingGenesis{} } -func (m *UnbondingGenesis) String() string { return proto.CompactTextString(m) } -func (*UnbondingGenesis) ProtoMessage() {} -func (*UnbondingGenesis) Descriptor() ([]byte, []int) { - return fileDescriptor_56dc4e19cc3510f7, []int{4} -} -func (m *UnbondingGenesis) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UnbondingGenesis) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UnbondingGenesis.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 *UnbondingGenesis) XXX_Merge(src proto.Message) { - xxx_messageInfo_UnbondingGenesis.Merge(m, src) -} -func (m *UnbondingGenesis) XXX_Size() int { - return m.Size() -} -func (m *UnbondingGenesis) XXX_DiscardUnknown() { - xxx_messageInfo_UnbondingGenesis.DiscardUnknown(m) -} - -var xxx_messageInfo_UnbondingGenesis proto.InternalMessageInfo - -func (m *UnbondingGenesis) GetSequence() uint64 { - if m != nil { - return m.Sequence - } - return 0 -} - -func (m *UnbondingGenesis) GetUnbondingChanges() []types2.ValidatorUpdate { - if m != nil { - return m.UnbondingChanges - } - return nil -} - func init() { proto.RegisterType((*ChildGenesisState)(nil), "ibc.applications.ccv.v1.ChildGenesisState") proto.RegisterType((*UnbondingSequence)(nil), "ibc.applications.ccv.v1.UnbondingSequence") proto.RegisterType((*ParentGenesisState)(nil), "ibc.applications.ccv.v1.ParentGenesisState") proto.RegisterType((*ChildState)(nil), "ibc.applications.ccv.v1.ChildState") - proto.RegisterType((*UnbondingGenesis)(nil), "ibc.applications.ccv.v1.UnbondingGenesis") } func init() { @@ -354,56 +292,51 @@ func init() { } var fileDescriptor_56dc4e19cc3510f7 = []byte{ - // 775 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0x8e, 0xdb, 0xdc, 0xde, 0x74, 0x72, 0x6f, 0x9b, 0x38, 0xfd, 0x31, 0x29, 0xc4, 0xe9, 0x20, - 0xa4, 0x00, 0x62, 0xac, 0x04, 0x24, 0x24, 0x56, 0xc8, 0x59, 0x40, 0x77, 0x95, 0x4b, 0x59, 0xb0, - 0x89, 0x9c, 0xf1, 0xc8, 0x19, 0x61, 0x8f, 0x43, 0xc6, 0x49, 0xa9, 0x58, 0xb0, 0x64, 0xcb, 0x0b, - 0xb0, 0xe4, 0x0d, 0x78, 0x88, 0x2e, 0xbb, 0x44, 0x2c, 0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a7, - 0x89, 0x69, 0x9c, 0xba, 0x61, 0xf0, 0x02, 0x5e, 0x49, 0x81, 0xce, 0x66, 0x1a, 0xeb, 0xa6, 0xa1, - 0x03, 0x4f, 0x6f, 0x83, 0x75, 0x46, 0x4e, 0x44, 0x0e, 0x65, 0xc6, 0xaa, 0xf8, 0x8c, 0xbd, 0x35, - 0x4d, 0xcc, 0x4a, 0x8a, 0x90, 0xbd, 0x82, 0x4e, 0x89, 0x91, 0x93, 0xae, 0x38, 0xea, 0x9f, 0x40, - 0x6d, 0x86, 0x2c, 0x85, 0xed, 0x71, 0xc1, 0xd7, 0x28, 0x36, 0xb5, 0x56, 0xb9, 0xf3, 0x18, 0x89, - 0xfb, 0xc8, 0xcb, 0x8e, 0x72, 0x42, 0x4f, 0xda, 0xa8, 0x2b, 0xa3, 0xb2, 0x45, 0xbb, 0x31, 0x4d, - 0xcc, 0xfa, 0x22, 0xd7, 0x1c, 0x22, 0x74, 0x54, 0x93, 0xb9, 0x12, 0xfd, 0x8b, 0x06, 0x76, 0x66, - 0xb9, 0x11, 0xe3, 0x84, 0xf1, 0x31, 0x57, 0x04, 0xfe, 0x91, 0x04, 0xd0, 0xad, 0x04, 0x66, 0x65, - 0x29, 0x87, 0xfd, 0x69, 0x62, 0xde, 0x5b, 0xe4, 0xb0, 0x88, 0x0b, 0x9d, 0x2d, 0x45, 0x63, 0xa1, - 0x50, 0xff, 0x0c, 0x6a, 0x63, 0xd6, 0x8f, 0x98, 0x47, 0x99, 0xdf, 0xe3, 0xe4, 0xc3, 0x98, 0x30, - 0x4c, 0xb8, 0xb1, 0xd6, 0x5c, 0x6d, 0x95, 0x3b, 0x8f, 0xd0, 0x0d, 0x63, 0x89, 0x8e, 0x67, 0x35, - 0x47, 0xaa, 0xc4, 0x86, 0x67, 0x89, 0x59, 0x98, 0x2b, 0x71, 0x0d, 0x28, 0x74, 0xf4, 0xf1, 0x72, - 0x19, 0x87, 0xbf, 0x34, 0x50, 0xbd, 0x82, 0x26, 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 0xd7, 0x3f, - 0x82, 0xea, 0xb2, 0x9c, 0xdc, 0x28, 0x4a, 0x5d, 0x1e, 0xde, 0x3e, 0x84, 0x4a, 0x5d, 0xbb, 0xa9, - 0xd4, 0x31, 0xae, 0xbf, 0x20, 0x0e, 0x9d, 0xca, 0xd2, 0x0d, 0x71, 0xf8, 0x4d, 0x03, 0x95, 0x65, - 0xa0, 0xbf, 0x8e, 0x5f, 0x98, 0xa7, 0x2a, 0x5a, 0xf7, 0x09, 0x37, 0x56, 0x24, 0xd5, 0x66, 0xde, - 0xa4, 0x62, 0x87, 0xa2, 0xb7, 0x6e, 0x40, 0x3d, 0x37, 0x8e, 0x46, 0xc7, 0x43, 0x4f, 0xee, 0x0a, - 0xc5, 0x70, 0x47, 0x79, 0x95, 0x2c, 0xc0, 0xe4, 0xf9, 0x75, 0xd3, 0x90, 0x7d, 0x70, 0x76, 0xd1, - 0xd0, 0xce, 0x2f, 0x1a, 0xda, 0xef, 0x8b, 0x86, 0xf6, 0xf5, 0xb2, 0x51, 0x38, 0xbf, 0x6c, 0x14, - 0x7e, 0x5e, 0x36, 0x0a, 0xef, 0x2c, 0x9f, 0xc6, 0x83, 0x71, 0x1f, 0xe1, 0x28, 0xb4, 0x70, 0xc4, - 0xc3, 0x88, 0x8b, 0x9f, 0xc5, 0x13, 0x3f, 0xb2, 0xc2, 0xc8, 0x1b, 0x07, 0x84, 0x8b, 0x85, 0x9d, - 0x2e, 0x6a, 0xb9, 0xca, 0xfb, 0x6b, 0x72, 0x51, 0x3f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x46, - 0x72, 0xe4, 0xfa, 0x94, 0x06, 0x00, 0x00, + // 690 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x8d, 0xbf, 0xe6, 0x2b, 0xe9, 0x04, 0xda, 0xc6, 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0x27, 0x84, 0x61, 0xc2, 0xb5, 0xf5, 0xfe, 0xda, + 0xa0, 0x3d, 0x7a, 0x8a, 0x6e, 0xb9, 0x96, 0xe8, 0x43, 0xc9, 0x39, 0x2e, 0x28, 0x16, 0x3c, 0x4b, + 0x8d, 0xc6, 0x72, 0x12, 0x37, 0x88, 0x42, 0x5b, 0x4d, 0xae, 0xd2, 0x38, 0xfc, 0xad, 0x80, 0xce, + 0x35, 0x35, 0x71, 0x6d, 0x4a, 0x9e, 0xbc, 0x36, 0x4d, 0xbb, 0xfa, 0x56, 0xdf, 0x80, 0xcd, 0xa5, + 0x7a, 0x4c, 0x43, 0x22, 0xef, 0x4c, 0xd3, 0x7a, 0x90, 0xa5, 0xc6, 0xee, 0xd5, 0xdd, 0xc5, 0x7f, + 0x68, 0xdf, 0xab, 0x0a, 0xef, 0x69, 0x48, 0x54, 0x1f, 0x6c, 0x2f, 0x11, 0x33, 0x07, 0x7f, 0x22, + 0xb1, 0xbc, 0x35, 0xed, 0xd1, 0xbe, 0xec, 0x58, 0xc4, 0x07, 0x95, 0x99, 0x59, 0x0c, 0xd1, 0x91, + 0x84, 0x58, 0x46, 0xd1, 0xe2, 0xde, 0xd5, 0x4d, 0x72, 0x09, 0x68, 0x6f, 0x55, 0xa5, 0x9c, 0x01, + 0x4f, 0x81, 0x7a, 0x24, 0xa7, 0xbe, 0x92, 0x09, 0x0c, 0xee, 0x62, 0x11, 0x94, 0xfc, 0x64, 0xb8, + 0xa6, 0xc8, 0x61, 0x3f, 0xbe, 0x75, 0xd8, 0x32, 0x55, 0xf9, 0x39, 0xef, 0x17, 0x16, 0xba, 0xb9, + 0x85, 0xba, 0x0c, 0xb4, 0xdb, 0xb8, 0x02, 0x72, 0xf8, 0x43, 0x01, 0x60, 0x49, 0x54, 0x11, 0x68, + 0xc9, 0x08, 0x88, 0x88, 0x29, 0x32, 0x62, 0xdd, 0x2c, 0x35, 0xb6, 0x4a, 0x99, 0xfc, 0x0f, 0xb4, + 0xef, 0xc8, 0xe5, 0xa1, 0xa7, 0xbe, 0x04, 0xe0, 0x5a, 0x28, 0x77, 0xb3, 0xd4, 0xe8, 0x54, 0x8c, + 0x2a, 0x8d, 0x1b, 0xb8, 0xca, 0xe1, 0x2b, 0xb0, 0x2e, 0xcc, 0x24, 0x5c, 0x8e, 0x73, 0x73, 0x64, + 0xdc, 0xda, 0xd3, 0xb1, 0x84, 0xd9, 0x05, 0xdc, 0x3a, 0x3c, 0xbb, 0xd0, 0x95, 0xf3, 0x0b, 0x5d, + 0xf9, 0x73, 0xa1, 0x2b, 0xdf, 0x2f, 0xf5, 0xc6, 0xf9, 0xa5, 0xde, 0xf8, 0x75, 0xa9, 0x37, 0x3e, + 0x9a, 0x3e, 0x8d, 0xa7, 0x89, 0x8b, 0x70, 0x14, 0x9a, 0x38, 0xe2, 0x61, 0xc4, 0xc5, 0x93, 0xf8, + 0xdc, 0x8f, 0xcc, 0x30, 0xf2, 0x92, 0x80, 0x70, 0xf1, 0x2c, 0xe5, 0xcf, 0x91, 0x7c, 0xb0, 0xdc, + 0x75, 0xf9, 0x1c, 0xbd, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x85, 0x2e, 0x7b, 0x7a, 0x05, + 0x00, 0x00, } func (m *ChildGenesisState) Marshal() (dAtA []byte, err error) { @@ -594,20 +527,6 @@ func (m *ChildState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.UnbondingPackets) > 0 { - for iNdEx := len(m.UnbondingPackets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.UnbondingPackets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } if m.Status != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.Status)) i-- @@ -630,48 +549,6 @@ func (m *ChildState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *UnbondingGenesis) 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 *UnbondingGenesis) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UnbondingGenesis) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.UnbondingChanges) > 0 { - for iNdEx := len(m.UnbondingChanges) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.UnbondingChanges[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.Sequence != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.Sequence)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -765,30 +642,6 @@ func (m *ChildState) Size() (n int) { if m.Status != 0 { n += 1 + sovGenesis(uint64(m.Status)) } - if len(m.UnbondingPackets) > 0 { - for _, e := range m.UnbondingPackets { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - return n -} - -func (m *UnbondingGenesis) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sequence != 0 { - n += 1 + sovGenesis(uint64(m.Sequence)) - } - if len(m.UnbondingChanges) > 0 { - for _, e := range m.UnbondingChanges { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -1343,143 +1196,6 @@ func (m *ChildState) Unmarshal(dAtA []byte) error { break } } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPackets", 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.UnbondingPackets = append(m.UnbondingPackets, UnbondingGenesis{}) - if err := m.UnbondingPackets[len(m.UnbondingPackets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 *UnbondingGenesis) 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: UnbondingGenesis: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnbondingGenesis: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) - } - m.Sequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Sequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingChanges", 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.UnbondingChanges = append(m.UnbondingChanges, types2.ValidatorUpdate{}) - if err := m.UnbondingChanges[len(m.UnbondingChanges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/apps/ccv/types/genesis_test.go b/modules/apps/ccv/types/genesis_test.go index 755fdf1fba9..9eb29b6b603 100644 --- a/modules/apps/ccv/types/genesis_test.go +++ b/modules/apps/ccv/types/genesis_test.go @@ -275,22 +275,6 @@ func TestValidateRestartGenesisState(t *testing.T) { } func TestValidateParentGenesisState(t *testing.T) { - pk1, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) - require.NoError(t, err) - pk2, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) - require.NoError(t, err) - - updates := []abci.ValidatorUpdate{ - { - PubKey: pk1, - Power: 30, - }, - { - PubKey: pk2, - Power: 20, - }, - } - testCases := []struct { name string genState types.ParentGenesisState @@ -299,14 +283,14 @@ func TestValidateParentGenesisState(t *testing.T) { { "valid initializing parent genesis with nil updates", types.NewParentGenesisState( - []types.ChildState{{"chainid-1", "channelid", 1, nil}}, + []types.ChildState{{"chainid-1", "channelid", 1}}, ), true, }, { "valid validating parent genesis with nil updates", types.NewParentGenesisState( - []types.ChildState{{"chainid-1", "channelid", 2, nil}}, + []types.ChildState{{"chainid-1", "channelid", 2}}, ), true, }, @@ -314,10 +298,10 @@ func TestValidateParentGenesisState(t *testing.T) { "valid multiple parent genesis with multiple child chains", types.NewParentGenesisState( []types.ChildState{ - {"chainid-1", "channelid", 2, []types.UnbondingGenesis{{2, updates}, {4, updates}}}, - {"chainid-2", "channelid2", 1, nil}, - {"chainid-3", "channelid3", 0, nil}, - {"chainid-4", "channelid4", 3, nil}, + {"chainid-1", "channelid", 2}, + {"chainid-2", "channelid2", 1}, + {"chainid-3", "channelid3", 0}, + {"chainid-4", "channelid4", 3}, }, ), true, @@ -325,14 +309,14 @@ func TestValidateParentGenesisState(t *testing.T) { { "invalid chain id", types.NewParentGenesisState( - []types.ChildState{{"invalidid{}", "channelid", 2, []types.UnbondingGenesis{{2, updates}, {4, updates}}}}, + []types.ChildState{{"invalidid{}", "channelid", 2}}, ), false, }, { "invalid channel id", types.NewParentGenesisState( - []types.ChildState{{"chainid", "invalidchannel{}", 2, []types.UnbondingGenesis{{2, updates}, {4, updates}}}}, + []types.ChildState{{"chainid", "invalidchannel{}", 2}}, ), false, }, diff --git a/proto/ibc/applications/ccv/v1/genesis.proto b/proto/ibc/applications/ccv/v1/genesis.proto index a26e1024a1e..1e383ae6b99 100644 --- a/proto/ibc/applications/ccv/v1/genesis.proto +++ b/proto/ibc/applications/ccv/v1/genesis.proto @@ -42,16 +42,7 @@ message ParentGenesisState { // ChildState defines the state that the parent chain stores for each child chain message ChildState { - string chain_id = 1 [(gogoproto.moretags) = "yaml:\"chain_id\""]; - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; - Status status = 3; - repeated UnbondingGenesis unbonding_packets = 4 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"unbonding_packets\""]; + string chain_id = 1 [(gogoproto.moretags) = "yaml:\"chain_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + Status status = 3; } - -// UnbondingGenesis defines the genesis state for an unbonding packet -message UnbondingGenesis { - uint64 sequence = 1; - repeated .tendermint.abci.ValidatorUpdate unbonding_changes = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"pending_changes\""]; -} \ No newline at end of file