diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 284a8718f00..fb67b288640 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -38,6 +38,9 @@ - [GenesisState](#ibc.applications.fee.v1.GenesisState) - [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) +- [ibc/applications/fee/v1/metadata.proto](#ibc/applications/fee/v1/metadata.proto) + - [Metadata](#ibc.applications.fee.v1.Metadata) + - [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto) - [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) @@ -812,6 +815,39 @@ RegisteredRelayerAddress contains the address and counterparty address for a spe + + + + + + + + + + + +

Top

+ +## ibc/applications/fee/v1/metadata.proto + + + + + +### Metadata +Metadata defines the ICS29 channel specific metadata encoded into the channel version bytestring +See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee_version` | [string](#string) | | fee_version defines the ICS29 fee version | +| `app_version` | [string](#string) | | app_version defines the underlying application version, which may or may not be a JSON encoded bytestring | + + + + + diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 147bd0b01a4..e7fe0c371af 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -30,7 +30,7 @@ func (suite *FeeTestSuite) SetupTest() { suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := channeltypes.MergeChannelVersions(types.Version, transfertypes.Version) + feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) path.EndpointA.ChannelConfig.Version = feeTransferVersion path.EndpointB.ChannelConfig.Version = feeTransferVersion path.EndpointA.ChannelConfig.PortID = transfertypes.PortID diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index ac4ea21ca52..cb5eb71b6d3 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -37,22 +37,24 @@ func (im IBCModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) error { - mwVersion, appVersion := channeltypes.SplitChannelVersion(version) - // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware - // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying - // application. - // If an invalid fee version was passed, we expect the underlying application to fail on its version negotiation. - if mwVersion == types.Version { - im.keeper.SetFeeEnabled(ctx, portID, channelID) - } else { - // middleware version is not the expected version for this midddleware. Pass the full version string along, - // if it not valid version for any other lower middleware, an error will be returned by base application. - appVersion = version + var versionMetadata types.Metadata + if err := types.ModuleCdc.UnmarshalJSON([]byte(version), &versionMetadata); err != nil { + // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware + // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying + // application. + return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, + chanCap, counterparty, version) } + if versionMetadata.FeeVersion != types.Version { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, versionMetadata.FeeVersion) + } + + im.keeper.SetFeeEnabled(ctx, portID, channelID) + // call underlying app's OnChanOpenInit callback with the appVersion return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, - chanCap, counterparty, appVersion) + chanCap, counterparty, versionMetadata.AppVersion) } // OnChanOpenTry implements the IBCModule interface @@ -68,31 +70,34 @@ func (im IBCModule) OnChanOpenTry( counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { - cpMwVersion, cpAppVersion := channeltypes.SplitChannelVersion(counterpartyVersion) + var versionMetadata types.Metadata + if err := types.ModuleCdc.UnmarshalJSON([]byte(counterpartyVersion), &versionMetadata); err != nil { + // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware + // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying + // application. + return im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, counterpartyVersion) + } - // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware - // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying - // application. - // If an invalid fee version was passed, we expect the underlying application to fail on its version negotiation. - if cpMwVersion == types.Version { - im.keeper.SetFeeEnabled(ctx, portID, channelID) - } else { - // middleware versions are not the expected version for this midddleware. Pass the full version strings along, - // if it not valid version for any other lower middleware, an error will be returned by base application. - cpAppVersion = counterpartyVersion + if versionMetadata.FeeVersion != types.Version { + return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, versionMetadata.FeeVersion) } + im.keeper.SetFeeEnabled(ctx, portID, channelID) + // call underlying app's OnChanOpenTry callback with the app versions - appVersion, err := im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, cpAppVersion) + appVersion, err := im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, versionMetadata.AppVersion) if err != nil { return "", err } - if !im.keeper.IsFeeEnabled(ctx, portID, channelID) { - return appVersion, nil + versionMetadata.AppVersion = appVersion + + versionBytes, err := types.ModuleCdc.MarshalJSON(&versionMetadata) + if err != nil { + return "", err } - return channeltypes.MergeChannelVersions(types.Version, appVersion), nil + return string(versionBytes), nil } // OnChanOpenAck implements the IBCModule interface @@ -104,17 +109,22 @@ func (im IBCModule) OnChanOpenAck( ) error { // If handshake was initialized with fee enabled it must complete with fee enabled. // If handshake was initialized with fee disabled it must complete with fee disabled. - cpAppVersion := counterpartyVersion if im.keeper.IsFeeEnabled(ctx, portID, channelID) { - var cpFeeVersion string - cpFeeVersion, cpAppVersion = channeltypes.SplitChannelVersion(counterpartyVersion) + var versionMetadata types.Metadata + if err := types.ModuleCdc.UnmarshalJSON([]byte(counterpartyVersion), &versionMetadata); err != nil { + return sdkerrors.Wrap(types.ErrInvalidVersion, "failed to unmarshal ICS29 counterparty version metadata") + } - if cpFeeVersion != types.Version { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty version: %s, got: %s", types.Version, cpFeeVersion) + if versionMetadata.FeeVersion != types.Version { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty version: %s, got: %s", types.Version, versionMetadata.FeeVersion) } + + // call underlying app's OnChanOpenAck callback with the counterparty app version. + return im.app.OnChanOpenAck(ctx, portID, channelID, versionMetadata.AppVersion) } + // call underlying app's OnChanOpenAck callback with the counterparty app version. - return im.app.OnChanOpenAck(ctx, portID, channelID, cpAppVersion) + return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion) } // OnChanOpenConfirm implements the IBCModule interface diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 715a2509344..5c4b198efb3 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -1,8 +1,6 @@ package fee_test import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -28,28 +26,23 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { expPass bool }{ { - "valid fee middleware and transfer version", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "success - valid fee middleware and transfer version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), true, }, { - "fee version not included, only perform transfer logic", + "success - fee version not included, only perform transfer logic", transfertypes.Version, true, }, { "invalid fee middleware version", - channeltypes.MergeChannelVersions("otherfee28-1", transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), false, }, { "invalid transfer version", - channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), - false, - }, - { - "incorrect wrapping delimiter", - fmt.Sprintf("%s//%s", types.Version, transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), false, }, { @@ -57,11 +50,6 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { types.Version, false, }, - { - "hanging delimiter", - fmt.Sprintf("%s:%s:", types.Version, transfertypes.Version), - false, - }, } for _, tc := range testCases { @@ -112,32 +100,32 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { expPass bool }{ { - "valid fee middleware version", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "success - valid fee middleware version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), false, true, }, { - "valid transfer version", + "success - valid transfer version", transfertypes.Version, false, true, }, { - "crossing hellos: valid fee middleware", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "success - crossing hellos: valid fee middleware", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), true, true, }, { "invalid fee middleware version", - channeltypes.MergeChannelVersions("wrongfee29-1", transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), false, false, }, { "invalid transfer version", - channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), false, false, }, @@ -205,25 +193,31 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { }{ { "success", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), func(suite *FeeTestSuite) {}, true, }, { "invalid fee version", - channeltypes.MergeChannelVersions("fee29-A", transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), func(suite *FeeTestSuite) {}, false, }, { "invalid transfer version", - channeltypes.MergeChannelVersions(types.Version, "ics20-4"), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), + func(suite *FeeTestSuite) {}, + false, + }, + { + "invalid version fails to unmarshal metadata", + "invalid-version", func(suite *FeeTestSuite) {}, false, }, { "previous INIT set without fee, however counterparty set fee version", // note this can only happen with incompetent or malicious counterparty chain - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), func(suite *FeeTestSuite) { // do the first steps without fee version, then pass the fee version as counterparty version in ChanOpenACK suite.path.EndpointA.ChannelConfig.Version = transfertypes.Version diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index bfea0dabcd9..577d0e8b5f4 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -40,7 +40,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := channeltypes.MergeChannelVersions(types.Version, transfertypes.Version) + feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) path.EndpointA.ChannelConfig.Version = feeTransferVersion path.EndpointB.ChannelConfig.Version = feeTransferVersion path.EndpointA.ChannelConfig.PortID = transfertypes.PortID diff --git a/modules/apps/29-fee/types/metadata.pb.go b/modules/apps/29-fee/types/metadata.pb.go new file mode 100644 index 00000000000..95bb9244946 --- /dev/null +++ b/modules/apps/29-fee/types/metadata.pb.go @@ -0,0 +1,378 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/fee/v1/metadata.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Metadata defines the ICS29 channel specific metadata encoded into the channel version bytestring +// See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning +type Metadata struct { + // fee_version defines the ICS29 fee version + FeeVersion string `protobuf:"bytes,1,opt,name=fee_version,json=feeVersion,proto3" json:"fee_version,omitempty" yaml:"fee_version"` + // app_version defines the underlying application version, which may or may not be a JSON encoded bytestring + AppVersion string `protobuf:"bytes,2,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty" yaml:"app_version"` +} + +func (m *Metadata) Reset() { *m = Metadata{} } +func (m *Metadata) String() string { return proto.CompactTextString(m) } +func (*Metadata) ProtoMessage() {} +func (*Metadata) Descriptor() ([]byte, []int) { + return fileDescriptor_03d0f000eda681ce, []int{0} +} +func (m *Metadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Metadata.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 *Metadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata.Merge(m, src) +} +func (m *Metadata) XXX_Size() int { + return m.Size() +} +func (m *Metadata) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata.DiscardUnknown(m) +} + +var xxx_messageInfo_Metadata proto.InternalMessageInfo + +func (m *Metadata) GetFeeVersion() string { + if m != nil { + return m.FeeVersion + } + return "" +} + +func (m *Metadata) GetAppVersion() string { + if m != nil { + return m.AppVersion + } + return "" +} + +func init() { + proto.RegisterType((*Metadata)(nil), "ibc.applications.fee.v1.Metadata") +} + +func init() { + proto.RegisterFile("ibc/applications/fee/v1/metadata.proto", fileDescriptor_03d0f000eda681ce) +} + +var fileDescriptor_03d0f000eda681ce = []byte{ + // 248 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0x4c, 0x4a, 0xd6, + 0x4f, 0x2c, 0x28, 0xc8, 0xc9, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0x4f, 0x4b, 0x4d, + 0xd5, 0x2f, 0x33, 0xd4, 0xcf, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0xd4, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x12, 0xcf, 0x4c, 0x4a, 0xd6, 0x43, 0x56, 0xa7, 0x97, 0x96, 0x9a, 0xaa, 0x57, + 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa3, 0x0f, 0x62, 0x41, 0x94, 0x2b, 0xd5, + 0x70, 0x71, 0xf8, 0x42, 0x0d, 0x10, 0x32, 0xe7, 0xe2, 0x4e, 0x4b, 0x4d, 0x8d, 0x2f, 0x4b, 0x2d, + 0x2a, 0xce, 0xcc, 0xcf, 0x93, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x12, 0xfb, 0x74, 0x4f, 0x5e, + 0xa8, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0x49, 0x52, 0x29, 0x88, 0x2b, 0x2d, 0x35, 0x35, 0x0c, + 0xc2, 0x01, 0x69, 0x4c, 0x2c, 0x28, 0x80, 0x6b, 0x64, 0x42, 0xd7, 0x88, 0x24, 0xa9, 0x14, 0xc4, + 0x95, 0x58, 0x50, 0x00, 0xd5, 0xe8, 0xe4, 0x7f, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, + 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, + 0x0c, 0x51, 0xa6, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc9, 0xf9, + 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x99, 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0xc6, 0xfa, 0xb9, + 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xc5, 0xa0, 0xe0, 0x28, 0xd6, 0x37, 0xb2, 0xd4, 0x05, 0x85, 0x44, + 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x57, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x04, 0x84, 0x58, 0xe0, 0x2e, 0x01, 0x00, 0x00, +} + +func (m *Metadata) 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 *Metadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AppVersion) > 0 { + i -= len(m.AppVersion) + copy(dAtA[i:], m.AppVersion) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.AppVersion))) + i-- + dAtA[i] = 0x12 + } + if len(m.FeeVersion) > 0 { + i -= len(m.FeeVersion) + copy(dAtA[i:], m.FeeVersion) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.FeeVersion))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Metadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FeeVersion) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.AppVersion) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func sovMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMetadata(x uint64) (n int) { + return sovMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Metadata) 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 ErrIntOverflowMetadata + } + 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: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMetadata(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index b57cc2cc03c..bbbd82663e1 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -34,8 +34,9 @@ message Fee { // the refund address to which any unused funds are refunded, // and an optional list of relayers that are permitted to receive the fee. message IdentifiedPacketFee { - ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; - Fee fee = 2 [(gogoproto.nullable) = false]; - string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; - repeated string relayers = 4; + ibc.core.channel.v1.PacketId packet_id = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; + Fee fee = 2 [(gogoproto.nullable) = false]; + string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; + repeated string relayers = 4; } diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index cf88fc6602a..2396cf6d272 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -10,7 +10,8 @@ import "ibc/core/channel/v1/channel.proto"; // GenesisState defines the fee middleware genesis state message GenesisState { - repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; + repeated IdentifiedPacketFee identified_fees = 1 + [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\""]; repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\""]; repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\""]; @@ -31,5 +32,6 @@ message RegisteredRelayerAddress { // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements message ForwardRelayerAddress { string address = 1; - ibc.core.channel.v1.PacketId packet_id = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; + ibc.core.channel.v1.PacketId packet_id = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; } diff --git a/proto/ibc/applications/fee/v1/metadata.proto b/proto/ibc/applications/fee/v1/metadata.proto new file mode 100644 index 00000000000..0afb3e09b2e --- /dev/null +++ b/proto/ibc/applications/fee/v1/metadata.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package ibc.applications.fee.v1; + +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; + +import "gogoproto/gogo.proto"; + +// Metadata defines the ICS29 channel specific metadata encoded into the channel version bytestring +// See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning +message Metadata { + // fee_version defines the ICS29 fee version + string fee_version = 1 [(gogoproto.moretags) = "yaml:\"fee_version\""]; + // app_version defines the underlying application version, which may or may not be a JSON encoded bytestring + string app_version = 2 [(gogoproto.moretags) = "yaml:\"app_version\""]; +} diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 1a41c3091c4..47db939a512 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -43,7 +43,7 @@ message QueryIncentivizedPacketsResponse { // QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets message QueryIncentivizedPacketRequest { // PacketID - ibc.core.channel.v1.PacketId packet_id = 1[(gogoproto.nullable) = false]; + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false]; // Height to query at uint64 query_height = 2; }