From bef00ef2c40347b7bc6087f6e72eaebdc9b0f8ff Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 21 Sep 2023 12:59:05 +0200 Subject: [PATCH] chore: re-adding legacy proposal type for ibc client upgrades (#4732) Co-authored-by: Charly --- modules/core/02-client/types/client.pb.go | 435 ++++++++++++++++-- .../core/02-client/types/legacy_proposal.go | 91 +++- proto/ibc/core/client/v1/client.proto | 26 ++ 3 files changed, 512 insertions(+), 40 deletions(-) diff --git a/modules/core/02-client/types/client.pb.go b/modules/core/02-client/types/client.pb.go index 7a9fdae2289..0405c0e792a 100644 --- a/modules/core/02-client/types/client.pb.go +++ b/modules/core/02-client/types/client.pb.go @@ -4,6 +4,7 @@ package types import ( + types1 "cosmossdk.io/x/upgrade/types" fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" @@ -343,6 +344,57 @@ func (m *ClientUpdateProposal) XXX_DiscardUnknown() { var xxx_messageInfo_ClientUpdateProposal proto.InternalMessageInfo +// UpgradeProposal is a gov Content type for initiating an IBC breaking +// upgrade. +// +// Deprecated: Please use MsgIBCSoftwareUpgrade in favour of this message type. +// +// Deprecated: Do not use. +type UpgradeProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Plan types1.Plan `protobuf:"bytes,3,opt,name=plan,proto3" json:"plan"` + // An UpgradedClientState must be provided to perform an IBC breaking upgrade. + // This will make the chain commit to the correct upgraded (self) client state + // before the upgrade occurs, so that connecting chains can verify that the + // new upgraded client is valid by verifying a proof on the previous version + // of the chain. This will allow IBC connections to persist smoothly across + // planned chain upgrades + UpgradedClientState *types.Any `protobuf:"bytes,4,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"` +} + +func (m *UpgradeProposal) Reset() { *m = UpgradeProposal{} } +func (*UpgradeProposal) ProtoMessage() {} +func (*UpgradeProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_b6bc4c8185546947, []int{6} +} +func (m *UpgradeProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpgradeProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpgradeProposal.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 *UpgradeProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpgradeProposal.Merge(m, src) +} +func (m *UpgradeProposal) XXX_Size() int { + return m.Size() +} +func (m *UpgradeProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpgradeProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpgradeProposal proto.InternalMessageInfo + func init() { proto.RegisterType((*IdentifiedClientState)(nil), "ibc.core.client.v1.IdentifiedClientState") proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.core.client.v1.ConsensusStateWithHeight") @@ -350,51 +402,91 @@ func init() { proto.RegisterType((*Height)(nil), "ibc.core.client.v1.Height") proto.RegisterType((*Params)(nil), "ibc.core.client.v1.Params") proto.RegisterType((*ClientUpdateProposal)(nil), "ibc.core.client.v1.ClientUpdateProposal") + proto.RegisterType((*UpgradeProposal)(nil), "ibc.core.client.v1.UpgradeProposal") } func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) } var fileDescriptor_b6bc4c8185546947 = []byte{ - // 582 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xc1, 0x8a, 0xd3, 0x40, - 0x18, 0x4e, 0xda, 0x5a, 0xb6, 0x53, 0x69, 0x35, 0x74, 0x21, 0xdb, 0x95, 0xa4, 0x04, 0xc1, 0x1e, - 0x6c, 0x62, 0xeb, 0xc1, 0x52, 0xf0, 0x60, 0x7b, 0xd9, 0xbd, 0xc8, 0x1a, 0x11, 0x41, 0x90, 0x92, - 0x4c, 0x66, 0xd3, 0x91, 0x24, 0x53, 0x32, 0x93, 0x48, 0xdf, 0xc0, 0xa3, 0xe2, 0xc5, 0xe3, 0x3e, - 0x84, 0x0f, 0xb1, 0x78, 0xda, 0xa3, 0xa7, 0x22, 0xed, 0x1b, 0xec, 0x13, 0x48, 0x66, 0xa6, 0x76, - 0x6b, 0x55, 0xbc, 0xfd, 0xf3, 0xcd, 0x97, 0xef, 0xff, 0xfe, 0x6f, 0x32, 0x03, 0x4c, 0xec, 0x43, - 0x07, 0x92, 0x14, 0x39, 0x30, 0xc2, 0x28, 0x61, 0x4e, 0xde, 0x97, 0x95, 0x3d, 0x4f, 0x09, 0x23, - 0x9a, 0x86, 0x7d, 0x68, 0x17, 0x04, 0x5b, 0xc2, 0x79, 0xbf, 0x7d, 0x04, 0x09, 0x8d, 0x09, 0x9d, - 0x72, 0x86, 0x23, 0x16, 0x82, 0xde, 0x6e, 0x85, 0x24, 0x24, 0x02, 0x2f, 0x2a, 0x89, 0x1e, 0x85, - 0x84, 0x84, 0x11, 0x72, 0xf8, 0xca, 0xcf, 0xce, 0x1d, 0x2f, 0x59, 0x88, 0x2d, 0x2b, 0x06, 0x87, - 0xa7, 0x01, 0x4a, 0x18, 0x3e, 0xc7, 0x28, 0x98, 0xf0, 0x16, 0x2f, 0x99, 0xc7, 0x90, 0x76, 0x0c, - 0x6a, 0xa2, 0xe3, 0x14, 0x07, 0xba, 0xda, 0x51, 0xbb, 0x35, 0xf7, 0x40, 0x00, 0xa7, 0x81, 0xf6, - 0x04, 0xdc, 0x96, 0x9b, 0xb4, 0x20, 0xeb, 0xa5, 0x8e, 0xda, 0xad, 0x0f, 0x5a, 0xb6, 0xe8, 0x63, - 0x6f, 0xfa, 0xd8, 0xcf, 0x92, 0x85, 0x5b, 0x87, 0x5b, 0x55, 0xeb, 0xb3, 0x0a, 0x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0xa1, 0x75, 0x40, 0x3d, 0x40, 0x14, 0xa6, 0x78, 0xce, 0x30, 0x49, 0xb8, - 0xa1, 0x9a, 0x7b, 0x13, 0xd2, 0x4e, 0xc0, 0x5d, 0x9a, 0xf9, 0xef, 0x10, 0x64, 0xd3, 0x6d, 0xda, - 0xe5, 0x82, 0x37, 0xbe, 0x77, 0xbd, 0x34, 0xf5, 0x85, 0x17, 0x47, 0x23, 0x6b, 0x8f, 0x62, 0xb9, - 0x4d, 0x89, 0x4d, 0x36, 0x47, 0xf2, 0x02, 0xb4, 0x68, 0xe6, 0x53, 0x86, 0x59, 0xc6, 0xd0, 0x0d, - 0xb1, 0x0a, 0x17, 0x33, 0xaf, 0x97, 0xe6, 0xf1, 0x2f, 0xb1, 0x3d, 0x96, 0xe5, 0x6a, 0x5b, 0x78, - 0x23, 0x39, 0xba, 0x5f, 0x44, 0xf5, 0xed, 0x6b, 0xaf, 0x2d, 0x2f, 0x5a, 0x48, 0x72, 0x3b, 0xef, - 0xfb, 0x88, 0x79, 0xfc, 0x48, 0x19, 0x4a, 0x98, 0xae, 0x8e, 0xdd, 0xcb, 0x95, 0xa1, 0x5e, 0xad, - 0x0c, 0xf5, 0xc7, 0xca, 0x50, 0x3f, 0xae, 0x0d, 0xe5, 0x6a, 0x6d, 0x28, 0xdf, 0xd7, 0x86, 0xf2, - 0x66, 0x18, 0x62, 0x36, 0xcb, 0x7c, 0x1b, 0x92, 0x58, 0xde, 0x55, 0x07, 0xfb, 0xb0, 0x17, 0x12, - 0x27, 0x1f, 0x3a, 0x31, 0x09, 0xb2, 0x08, 0x51, 0xf1, 0x04, 0x3c, 0x1a, 0xf4, 0xe4, 0x2b, 0xc0, - 0x16, 0x73, 0x44, 0xfd, 0x2a, 0xff, 0x69, 0x1f, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x59, 0x14, - 0xcb, 0xe1, 0x25, 0x04, 0x00, 0x00, + // 677 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xce, 0xa6, 0x31, 0x34, 0x13, 0x69, 0x74, 0x4d, 0x61, 0x4d, 0x4b, 0x36, 0x2c, 0x05, 0x73, + 0x68, 0x77, 0x4d, 0x04, 0x2d, 0x01, 0x0f, 0xa6, 0x97, 0xf6, 0x22, 0x75, 0xa5, 0x08, 0x82, 0x84, + 0xfd, 0x98, 0x6e, 0xa6, 0xec, 0xce, 0x2c, 0x3b, 0xb3, 0x91, 0xfc, 0x03, 0x8f, 0x8a, 0x17, 0xc1, + 0x4b, 0x7f, 0x84, 0x3f, 0xa2, 0x78, 0xea, 0xd1, 0x53, 0x90, 0xf6, 0xe2, 0xb9, 0xbf, 0x40, 0x76, + 0x3e, 0x6c, 0x63, 0x5a, 0x15, 0xbc, 0xcd, 0xfb, 0xcc, 0x33, 0xef, 0xfb, 0xcc, 0x33, 0xf3, 0xbe, + 0xc0, 0x44, 0x7e, 0xe0, 0x04, 0x24, 0x83, 0x4e, 0x10, 0x23, 0x88, 0x99, 0x33, 0xe9, 0xc9, 0x95, + 0x9d, 0x66, 0x84, 0x11, 0x5d, 0x47, 0x7e, 0x60, 0x17, 0x04, 0x5b, 0xc2, 0x93, 0x5e, 0x6b, 0x23, + 0x20, 0x34, 0x21, 0xd4, 0xc9, 0xd3, 0x28, 0xf3, 0x42, 0xe8, 0x4c, 0x7a, 0x3e, 0x64, 0x5e, 0x4f, + 0xc5, 0xe2, 0x64, 0xeb, 0xbe, 0x60, 0x8d, 0x78, 0xe4, 0x88, 0x40, 0x6e, 0x35, 0x23, 0x12, 0x11, + 0x81, 0x17, 0x2b, 0x75, 0x20, 0x22, 0x24, 0x8a, 0xa1, 0xc3, 0x23, 0x3f, 0x3f, 0x74, 0x3c, 0x3c, + 0x15, 0x5b, 0x56, 0x02, 0x56, 0xf7, 0x42, 0x88, 0x19, 0x3a, 0x44, 0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f6, 0xb0, 0xfc, 0x3b, 0x9c, 0xaf, 0x1f, + 0x81, 0x55, 0xc9, 0x51, 0x2f, 0x28, 0x7b, 0xa1, 0x72, 0x73, 0x2f, 0x0c, 0x3b, 0x17, 0x33, 0x73, + 0x5d, 0x78, 0x72, 0xed, 0x61, 0xcb, 0xbd, 0xa7, 0xf0, 0x2b, 0xe3, 0x61, 0xb0, 0xa9, 0x3e, 0xd0, + 0x8f, 0x63, 0x53, 0xfb, 0x9b, 0x3b, 0x43, 0xf7, 0xe4, 0xac, 0xad, 0x9d, 0x9e, 0xb5, 0xb5, 0xef, + 0x67, 0x6d, 0xed, 0xfd, 0x79, 0xbb, 0x74, 0x7a, 0xde, 0x2e, 0x7d, 0x3b, 0x6f, 0x97, 0x5e, 0x6f, + 0x47, 0x88, 0x8d, 0x73, 0xdf, 0x0e, 0x48, 0x22, 0x27, 0x99, 0x83, 0xfc, 0x60, 0x2b, 0x22, 0xce, + 0x64, 0xdb, 0x49, 0x48, 0x98, 0xc7, 0x90, 0x8a, 0x31, 0xfa, 0xb0, 0xbf, 0x25, 0x27, 0x29, 0x9b, + 0xa6, 0x90, 0xfa, 0x55, 0x7e, 0x8d, 0x47, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x80, 0x51, + 0x2a, 0x69, 0x05, 0x00, 0x00, +} + +func (this *UpgradeProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UpgradeProposal) + if !ok { + that2, ok := that.(UpgradeProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if !this.Plan.Equal(&that1.Plan) { + return false + } + if !this.UpgradedClientState.Equal(that1.UpgradedClientState) { + return false + } + return true } - func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -642,6 +734,65 @@ func (m *ClientUpdateProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *UpgradeProposal) 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 *UpgradeProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpgradeProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.UpgradedClientState != nil { + { + size, err := m.UpgradedClientState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintClient(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Plan.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintClient(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintClient(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintClient(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintClient(dAtA []byte, offset int, v uint64) int { offset -= sovClient(v) base := offset @@ -759,6 +910,29 @@ func (m *ClientUpdateProposal) Size() (n int) { return n } +func (m *UpgradeProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + l = m.Plan.Size() + n += 1 + l + sovClient(uint64(l)) + if m.UpgradedClientState != nil { + l = m.UpgradedClientState.Size() + n += 1 + l + sovClient(uint64(l)) + } + return n +} + func sovClient(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1466,6 +1640,189 @@ func (m *ClientUpdateProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *UpgradeProposal) 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 ErrIntOverflowClient + } + 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: UpgradeProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpgradeProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + 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 ErrInvalidLengthClient + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + 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 ErrInvalidLengthClient + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Plan", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Plan.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpgradedClientState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpgradedClientState == nil { + m.UpgradedClientState = &types.Any{} + } + if err := m.UpgradedClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipClient(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipClient(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/02-client/types/legacy_proposal.go b/modules/core/02-client/types/legacy_proposal.go index f86724e55ca..86629994d25 100644 --- a/modules/core/02-client/types/legacy_proposal.go +++ b/modules/core/02-client/types/legacy_proposal.go @@ -3,20 +3,34 @@ package types import ( + "fmt" + "reflect" + errorsmod "cosmossdk.io/errors" + upgradetypes "cosmossdk.io/x/upgrade/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + + "github.com/cosmos/ibc-go/v8/modules/core/exported" ) const ( // ProposalTypeClientUpdate defines the type for a ClientUpdateProposal ProposalTypeClientUpdate = "ClientUpdate" + // ProposalTypeUpgrade defines the type for an UpgradeProposal + ProposalTypeUpgrade = "IBCUpgrade" ) -var _ govtypes.Content = &ClientUpdateProposal{} +var ( + _ govtypes.Content = &ClientUpdateProposal{} + _ govtypes.Content = &UpgradeProposal{} + _ codectypes.UnpackInterfacesMessage = &UpgradeProposal{} +) func init() { govtypes.RegisterProposalType(ProposalTypeClientUpdate) + govtypes.RegisterProposalType(ProposalTypeUpgrade) } // NewClientUpdateProposal creates a new client update proposal. @@ -60,3 +74,78 @@ func (cup *ClientUpdateProposal) ValidateBasic() error { return nil } + +// NewUpgradeProposal creates a new IBC breaking upgrade proposal. +func NewUpgradeProposal(title, description string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (govtypes.Content, error) { + clientAny, err := PackClientState(upgradedClientState) + if err != nil { + return nil, err + } + + return &UpgradeProposal{ + Title: title, + Description: description, + Plan: plan, + UpgradedClientState: clientAny, + }, nil +} + +// GetTitle returns the title of a upgrade proposal. +func (up *UpgradeProposal) GetTitle() string { return up.Title } + +// GetDescription returns the description of a upgrade proposal. +func (up *UpgradeProposal) GetDescription() string { return up.Description } + +// ProposalRoute returns the routing key of a upgrade proposal. +func (*UpgradeProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the upgrade proposal type. +func (*UpgradeProposal) ProposalType() string { return ProposalTypeUpgrade } + +// ValidateBasic runs basic stateless validity checks +func (up *UpgradeProposal) ValidateBasic() error { + if err := govtypes.ValidateAbstract(up); err != nil { + return err + } + + if err := up.Plan.ValidateBasic(); err != nil { + return err + } + + if up.UpgradedClientState == nil { + return errorsmod.Wrap(ErrInvalidUpgradeProposal, "upgraded client state cannot be nil") + } + + clientState, err := UnpackClientState(up.UpgradedClientState) + if err != nil { + return errorsmod.Wrap(err, "failed to unpack upgraded client state") + } + + if !reflect.DeepEqual(clientState, clientState.ZeroCustomFields()) { + return errorsmod.Wrap(ErrInvalidUpgradeProposal, "upgraded client state is not zeroed out") + } + + return nil +} + +// String returns the string representation of the UpgradeProposal. +func (up UpgradeProposal) String() string { + var upgradedClientStr string + upgradedClient, err := UnpackClientState(up.UpgradedClientState) + if err != nil { + upgradedClientStr = "invalid IBC Client State" + } else { + upgradedClientStr = upgradedClient.String() + } + + return fmt.Sprintf(`IBC Upgrade Proposal + Title: %s + Description: %s + %s + Upgraded IBC Client: %s`, up.Title, up.Description, up.Plan.String(), upgradedClientStr) +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (up UpgradeProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + return unpacker.UnpackAny(up.UpgradedClientState, new(exported.ClientState)) +} diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto index 27ab04c43bf..7a09e360ace 100644 --- a/proto/ibc/core/client/v1/client.proto +++ b/proto/ibc/core/client/v1/client.proto @@ -4,6 +4,7 @@ package ibc.core.client.v1; option go_package = "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"; +import "cosmos/upgrade/v1beta1/upgrade.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; @@ -85,3 +86,28 @@ message ClientUpdateProposal { // client string substitute_client_id = 4 [(gogoproto.moretags) = "yaml:\"substitute_client_id\""]; } + +// UpgradeProposal is a gov Content type for initiating an IBC breaking +// upgrade. +// +// Deprecated: Please use MsgIBCSoftwareUpgrade in favour of this message type. +message UpgradeProposal { + option deprecated = true; + + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = true; + + string title = 1; + string description = 2; + cosmos.upgrade.v1beta1.Plan plan = 3 [(gogoproto.nullable) = false]; + + // An UpgradedClientState must be provided to perform an IBC breaking upgrade. + // This will make the chain commit to the correct upgraded (self) client state + // before the upgrade occurs, so that connecting chains can verify that the + // new upgraded client is valid by verifying a proof on the previous version + // of the chain. This will allow IBC connections to persist smoothly across + // planned chain upgrades + google.protobuf.Any upgraded_client_state = 4 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; +}