diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index e6bead7e83f..96963202d20 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -30,7 +30,6 @@ - [ibc/applications/fee/v1/fee.proto](#ibc/applications/fee/v1/fee.proto) - [Fee](#ibc.applications.fee.v1.Fee) - - [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) - [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) - [PacketFee](#ibc.applications.fee.v1.PacketFee) - [PacketFees](#ibc.applications.fee.v1.PacketFees) @@ -726,27 +725,6 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middl - - -### IdentifiedPacketFee -IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. -This includes the PacketId identifying the packet the fee is paying for, -the refund address to which any unused funds are refunded, -and an optional list of relayers that are permitted to receive the fee. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `refund_address` | [string](#string) | | | -| `relayers` | [string](#string) | repeated | | - - - - - - ### IdentifiedPacketFees diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 81103197aa5..647b968f56d 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -179,10 +179,6 @@ func (suite *KeeperTestSuite) TestDistributeFee() { suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), forwardRelayer, reverseRelayer, []types.PacketFee{packetFee, packetFee}) if tc.expPass { - // there should no longer be a fee in escrow for this packet - found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetID) - suite.Require().False(found) - // check if the reverse relayer is paid hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, fee.AckFee[0].Add(fee.AckFee[0])) suite.Require().True(hasBalance) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 4a3dfbdeb4a..4caa0579846 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -225,26 +225,6 @@ func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetID channeltyp store.Delete(key) } -// Stores a Fee for a given packet in state -func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee types.IdentifiedPacketFee) { - store := ctx.KVStore(k.storeKey) - bz := k.MustMarshalFee(&fee) - store.Set(types.KeyFeeInEscrow(fee.PacketId), bz) -} - -// Gets a Fee for a given packet -func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.IdentifiedPacketFee, bool) { - store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetID) - bz := store.Get(key) - if bz == nil { - return types.IdentifiedPacketFee{}, false - } - fee := k.MustUnmarshalFee(bz) - - return fee, true -} - // GetFeesInEscrow returns all escrowed packet fees for a given packetID func (k Keeper) GetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.PacketFees, bool) { store := ctx.KVStore(k.storeKey) @@ -265,7 +245,7 @@ func (k Keeper) HasFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) return store.Has(key) } -// SetFeesInEscrow sets the given packet fees in escrow keyed by the packetID +// SetFeesInEscrow sets the given packet fees in escrow keyed by the packetID func (k Keeper) SetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId, fees types.PacketFees) { store := ctx.KVStore(k.storeKey) bz := k.MustMarshalFees(fees) @@ -294,36 +274,6 @@ func (k Keeper) IteratePacketFeesInEscrow(ctx sdk.Context, portID, channelID str } } -// IterateChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback -// if the callback returns true, then iteration is stopped. -func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFee types.IdentifiedPacketFee) (stop bool)) { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyFeeInEscrowChannelPrefix(portID, channelID)) - - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - identifiedFee := k.MustUnmarshalFee(iterator.Value()) - if cb(identifiedFee) { - break - } - } -} - -// Deletes the fee associated with the given packetID -func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) { - store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetID) - store.Delete(key) -} - -// HasFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet -func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) bool { - store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetID) - - return store.Has(key) -} - // GetAllIdentifiedPacketFees returns a list of all IdentifiedPacketFees that are stored in state func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPacketFees { store := ctx.KVStore(k.storeKey) @@ -350,20 +300,6 @@ func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPa return identifiedFees } -// MustMarshalFee attempts to encode a Fee object and returns the -// raw encoded bytes. It panics on error. -func (k Keeper) MustMarshalFee(fee *types.IdentifiedPacketFee) []byte { - return k.cdc.MustMarshal(fee) -} - -// MustUnmarshalFee attempts to decode and return a Fee object from -// raw encoded bytes. It panics on error. -func (k Keeper) MustUnmarshalFee(bz []byte) types.IdentifiedPacketFee { - var fee types.IdentifiedPacketFee - k.cdc.MustUnmarshal(bz, &fee) - return fee -} - // MustMarshalFees attempts to encode a Fee object and returns the // raw encoded bytes. It panics on error. func (k Keeper) MustMarshalFees(fees types.PacketFees) []byte { diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index c9ad4a5f10b..92705c9c7cc 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "testing" "github.com/cosmos/cosmos-sdk/baseapp" @@ -66,30 +67,27 @@ func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } -func (suite *KeeperTestSuite) TestFeeInEscrow() { +func (suite *KeeperTestSuite) TestFeesInEscrow() { suite.coordinator.Setup(suite.path) - fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} + // escrow five fees for packet sequence 1 + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1) + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) - // set some fees for i := 1; i < 6; i++ { - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(i)) - fee := types.NewIdentifiedPacketFee(packetId, fee, suite.chainA.SenderAccount.GetAddress().String(), []string{}) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), fee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), nil) + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) } - // delete 1 fee - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 3) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) - - // iterate over remaining fees - arr := []int64{} - expectedArr := []int64{1, 2, 4, 5} - suite.chainA.GetSimApp().IBCFeeKeeper.IterateChannelFeesInEscrow(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, func(identifiedFee types.IdentifiedPacketFee) (stop bool) { - arr = append(arr, int64(identifiedFee.PacketId.Sequence)) - return false - }) - suite.Require().Equal(expectedArr, arr, "did not retrieve expected fees during iteration") + // retrieve the fees in escrow and assert the length of PacketFees + feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetID) + suite.Require().True(found) + suite.Require().Len(feesInEscrow.PacketFees, 5, fmt.Sprintf("expected length 5, but got %d", len(feesInEscrow.PacketFees))) + + // delete fees for packet sequence 1 + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetID) + hasFeesInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetID) + suite.Require().False(hasFeesInEscrow) } func (suite *KeeperTestSuite) TestDisableAllChannels() { diff --git a/modules/apps/29-fee/types/events.go b/modules/apps/29-fee/types/events.go index 2c63bc0dcc8..cac882d98d3 100644 --- a/modules/apps/29-fee/types/events.go +++ b/modules/apps/29-fee/types/events.go @@ -3,4 +3,8 @@ package types // 29-fee events const ( EventTypeIncentivizedPacket = "incentivized_ibc_packet" + + AttributeKeyRecvFee = "recv_fee" + AttributeKeyAckFee = "ack_fee" + AttributeKeyTimeoutFee = "timeout_fee" ) diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index ad74e0b2d86..8c95fd11176 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -89,78 +89,6 @@ func (m *Fee) GetTimeoutFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -// IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. -// This includes the PacketId identifying the packet the fee is paying for, -// the refund address to which any unused funds are refunded, -// and an optional list of relayers that are permitted to receive the fee. -type IdentifiedPacketFee struct { - PacketId types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` - Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"` - RefundAddress string `protobuf:"bytes,3,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` - Relayers []string `protobuf:"bytes,4,rep,name=relayers,proto3" json:"relayers,omitempty"` -} - -func (m *IdentifiedPacketFee) Reset() { *m = IdentifiedPacketFee{} } -func (m *IdentifiedPacketFee) String() string { return proto.CompactTextString(m) } -func (*IdentifiedPacketFee) ProtoMessage() {} -func (*IdentifiedPacketFee) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{1} -} -func (m *IdentifiedPacketFee) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *IdentifiedPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_IdentifiedPacketFee.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 *IdentifiedPacketFee) XXX_Merge(src proto.Message) { - xxx_messageInfo_IdentifiedPacketFee.Merge(m, src) -} -func (m *IdentifiedPacketFee) XXX_Size() int { - return m.Size() -} -func (m *IdentifiedPacketFee) XXX_DiscardUnknown() { - xxx_messageInfo_IdentifiedPacketFee.DiscardUnknown(m) -} - -var xxx_messageInfo_IdentifiedPacketFee proto.InternalMessageInfo - -func (m *IdentifiedPacketFee) GetPacketId() types1.PacketId { - if m != nil { - return m.PacketId - } - return types1.PacketId{} -} - -func (m *IdentifiedPacketFee) GetFee() Fee { - if m != nil { - return m.Fee - } - return Fee{} -} - -func (m *IdentifiedPacketFee) GetRefundAddress() string { - if m != nil { - return m.RefundAddress - } - return "" -} - -func (m *IdentifiedPacketFee) GetRelayers() []string { - if m != nil { - return m.Relayers - } - return nil -} - // PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the // fee type PacketFee struct { @@ -173,7 +101,7 @@ func (m *PacketFee) Reset() { *m = PacketFee{} } func (m *PacketFee) String() string { return proto.CompactTextString(m) } func (*PacketFee) ProtoMessage() {} func (*PacketFee) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{2} + return fileDescriptor_cb3319f1af2a53e5, []int{1} } func (m *PacketFee) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -232,7 +160,7 @@ func (m *PacketFees) Reset() { *m = PacketFees{} } func (m *PacketFees) String() string { return proto.CompactTextString(m) } func (*PacketFees) ProtoMessage() {} func (*PacketFees) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{3} + return fileDescriptor_cb3319f1af2a53e5, []int{2} } func (m *PacketFees) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -278,7 +206,7 @@ func (m *IdentifiedPacketFees) Reset() { *m = IdentifiedPacketFees{} } func (m *IdentifiedPacketFees) String() string { return proto.CompactTextString(m) } func (*IdentifiedPacketFees) ProtoMessage() {} func (*IdentifiedPacketFees) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{4} + return fileDescriptor_cb3319f1af2a53e5, []int{3} } func (m *IdentifiedPacketFees) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -323,7 +251,6 @@ func (m *IdentifiedPacketFees) GetPacketFees() []PacketFee { func init() { proto.RegisterType((*Fee)(nil), "ibc.applications.fee.v1.Fee") - proto.RegisterType((*IdentifiedPacketFee)(nil), "ibc.applications.fee.v1.IdentifiedPacketFee") proto.RegisterType((*PacketFee)(nil), "ibc.applications.fee.v1.PacketFee") proto.RegisterType((*PacketFees)(nil), "ibc.applications.fee.v1.PacketFees") proto.RegisterType((*IdentifiedPacketFees)(nil), "ibc.applications.fee.v1.IdentifiedPacketFees") @@ -332,42 +259,40 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 560 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xc1, 0x6e, 0xd3, 0x30, - 0x18, 0xc7, 0xeb, 0x66, 0xda, 0x56, 0x57, 0x4c, 0x28, 0x0c, 0xd1, 0x55, 0x90, 0x96, 0x9c, 0x7a, - 0xa9, 0xad, 0x76, 0x70, 0x80, 0x13, 0x04, 0xa9, 0xd2, 0x4e, 0xa0, 0x88, 0x13, 0x97, 0xca, 0x71, - 0xbe, 0x76, 0x56, 0x9b, 0x38, 0x8a, 0xd3, 0x48, 0x95, 0x38, 0x20, 0x9e, 0x80, 0x37, 0xe0, 0xce, - 0x93, 0xec, 0x82, 0xb4, 0x23, 0xa7, 0x82, 0xda, 0x37, 0xd8, 0x0b, 0x80, 0x9c, 0x78, 0xa5, 0x0c, - 0x26, 0x54, 0x0d, 0x4e, 0xb1, 0x9d, 0xef, 0xff, 0xfd, 0xfe, 0x9f, 0xfd, 0xd9, 0xf8, 0xa1, 0x08, - 0x38, 0x65, 0x49, 0x32, 0x15, 0x9c, 0x65, 0x42, 0xc6, 0x8a, 0x8e, 0x00, 0x68, 0xde, 0xd3, 0x1f, - 0x92, 0xa4, 0x32, 0x93, 0xf6, 0x3d, 0x11, 0x70, 0xb2, 0x19, 0x42, 0xf4, 0xbf, 0xbc, 0xd7, 0x74, - 0xb8, 0x54, 0x91, 0x54, 0x34, 0x60, 0x4a, 0x4b, 0x02, 0xc8, 0x58, 0x8f, 0x72, 0x29, 0xe2, 0x52, - 0xd8, 0x3c, 0x1c, 0xcb, 0xb1, 0x2c, 0x86, 0x54, 0x8f, 0xcc, 0x6a, 0x41, 0xe4, 0x32, 0x05, 0xca, - 0x4f, 0x59, 0x1c, 0xc3, 0x54, 0xd3, 0xcc, 0xb0, 0x0c, 0x71, 0xdf, 0x59, 0xd8, 0x1a, 0x00, 0xd8, - 0x6f, 0xf1, 0x7e, 0x0a, 0x3c, 0x1f, 0x8e, 0x00, 0x1a, 0xa8, 0x6d, 0x75, 0xea, 0xfd, 0x23, 0x52, - 0x32, 0x89, 0x66, 0x12, 0xc3, 0x24, 0x2f, 0xa4, 0x88, 0xbd, 0xc1, 0xd9, 0xa2, 0x55, 0xb9, 0x58, - 0xb4, 0xec, 0x39, 0x8b, 0xa6, 0x4f, 0xdd, 0x14, 0x38, 0x88, 0x1c, 0xb4, 0xd6, 0xfd, 0xf4, 0xb5, - 0xd5, 0x19, 0x8b, 0xec, 0x74, 0x16, 0x10, 0x2e, 0x23, 0x6a, 0x6c, 0x97, 0x9f, 0xae, 0x0a, 0x27, - 0x34, 0x9b, 0x27, 0xa0, 0x8a, 0x34, 0xca, 0xdf, 0xd3, 0x48, 0x4d, 0xcf, 0xf1, 0x1e, 0xe3, 0x93, - 0x02, 0x5e, 0xfd, 0x1b, 0xdc, 0x33, 0xf0, 0x83, 0x12, 0x6e, 0x74, 0xdb, 0x81, 0x77, 0x19, 0x9f, - 0x68, 0xee, 0x7b, 0x84, 0xeb, 0x99, 0x88, 0x40, 0xce, 0xb2, 0x02, 0x6e, 0x6d, 0x59, 0xf9, 0x86, - 0x76, 0x3b, 0x03, 0xd8, 0x28, 0x07, 0x00, 0xee, 0x77, 0x84, 0xef, 0x9c, 0x84, 0x10, 0x67, 0x62, - 0x24, 0x20, 0x7c, 0xc5, 0xf8, 0x04, 0xf4, 0xba, 0xfd, 0x1a, 0xd7, 0x92, 0x62, 0x32, 0x14, 0x61, - 0x03, 0xb5, 0x51, 0xa7, 0xde, 0x7f, 0x40, 0x74, 0x83, 0xe8, 0x13, 0x25, 0x97, 0xc7, 0x98, 0xf7, - 0x48, 0x29, 0x39, 0x09, 0xbd, 0x86, 0x71, 0x77, 0xbb, 0x74, 0xb7, 0x56, 0xbb, 0xfe, 0x7e, 0x62, - 0x62, 0xec, 0x47, 0xd8, 0x2a, 0xb7, 0x59, 0xe7, 0xbb, 0x4f, 0xae, 0x69, 0x38, 0x32, 0x00, 0xf0, - 0x76, 0x74,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 0xff, 0x6b, 0xd4, 0x49, 0x04, 0x54, 0x05, 0x00, 0x00, + // 526 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x8a, 0x13, 0x31, + 0x18, 0xc7, 0x3b, 0x5b, 0xd9, 0xdd, 0xa6, 0xb8, 0xc8, 0xb0, 0x62, 0xb7, 0xe8, 0x74, 0xcd, 0xa9, + 0x97, 0x26, 0xb4, 0xab, 0x07, 0x3d, 0xe9, 0x08, 0x85, 0x3d, 0x29, 0x83, 0x27, 0x2f, 0x25, 0x93, + 0x7c, 0xed, 0x86, 0x76, 0x26, 0xc3, 0x64, 0x3a, 0x50, 0xf0, 0x20, 0x3e, 0x81, 0x6f, 0xe0, 0xdd, + 0x27, 0xd9, 0x8b, 0xb0, 0x47, 0x4f, 0x55, 0xda, 0x37, 0xd8, 0x27, 0x90, 0x64, 0xb2, 0xa5, 0xab, + 0x2c, 0x52, 0xf0, 0x34, 0xf9, 0x92, 0xef, 0x9f, 0xdf, 0xf7, 0x25, 0xff, 0x09, 0x7a, 0x2a, 0x63, + 0x4e, 0x59, 0x96, 0xcd, 0x24, 0x67, 0x85, 0x54, 0xa9, 0xa6, 0x63, 0x00, 0x5a, 0xf6, 0xcd, 0x87, + 0x64, 0xb9, 0x2a, 0x94, 0xff, 0x48, 0xc6, 0x9c, 0x6c, 0xa7, 0x10, 0xb3, 0x56, 0xf6, 0xdb, 0x01, + 0x57, 0x3a, 0x51, 0x9a, 0xc6, 0x4c, 0x1b, 0x49, 0x0c, 0x05, 0xeb, 0x53, 0xae, 0x64, 0x5a, 0x09, + 0xdb, 0xc7, 0x13, 0x35, 0x51, 0x76, 0x48, 0xcd, 0xc8, 0xcd, 0x5a, 0x22, 0x57, 0x39, 0x50, 0x7e, + 0xc1, 0xd2, 0x14, 0x66, 0x86, 0xe6, 0x86, 0x55, 0x0a, 0xfe, 0x54, 0x47, 0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, 0x1d, 0x47, 0xf7, 0xab, 0x89, 0xd7, 0x55, 0xec, 0xb7, 0x8d, 0x01, 0x66, 0x6c, 0x01, + 0xb9, 0xb6, 0xc7, 0xd0, 0x88, 0x36, 0x31, 0x4e, 0x10, 0xda, 0x14, 0xa8, 0xfd, 0x11, 0x6a, 0x66, + 0x36, 0x32, 0x6d, 0x6b, 0xe7, 0x16, 0x7c, 0x67, 0xa5, 0x1b, 0x65, 0xd8, 0xbe, 0x7d, 0x78, 0x5b, + 0x9b, 0xe0, 0x08, 0x65, 0x1b, 0x00, 0xfe, 0xee, 0xa1, 0xe3, 0x73, 0x01, 0x69, 0x21, 0xc7, 0x12, + 0xc4, 0x16, 0xf9, 0x3d, 0x6a, 0x38, 0x91, 0x14, 0xee, 0x84, 0x9e, 0x58, 0xae, 0xf1, 0x38, 0xb9, + 0x31, 0xf6, 0x86, 0x79, 0x2e, 0xc2, 0x96, 0x43, 0x3e, 0xb8, 0x85, 0x94, 0x02, 0x47, 0x87, 0x99, + 0xcb, 0xf9, 0xb3, 0x9f, 0xbd, 0xff, 0xdd, 0x4f, 0xf8, 0xf6, 0x72, 0x15, 0x78, 0x57, 0xab, 0xc0, + 0xfb, 0xb5, 0x0a, 0xbc, 0x2f, 0xeb, 0xa0, 0x76, 0xb5, 0x0e, 0x6a, 0x3f, 0xd6, 0x41, 0xed, 0xc3, + 0xf3, 0xbf, 0x0d, 0x23, 0x63, 0xde, 0x9b, 0x28, 0x5a, 0x9e, 0xd1, 0x44, 0x89, 0xf9, 0x0c, 0xb4, + 0x79, 0x32, 0x34, 0x1d, 0xbc, 0xe8, 0x99, 0xd7, 0xc2, 0x7a, 0x28, 0xde, 0xb7, 0xff, 0xee, 0xd9, + 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x70, 0xf8, 0xe7, 0x52, 0x04, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -435,65 +360,6 @@ func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *IdentifiedPacketFee) 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 *IdentifiedPacketFee) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Relayers) > 0 { - for iNdEx := len(m.Relayers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Relayers[iNdEx]) - copy(dAtA[i:], m.Relayers[iNdEx]) - i = encodeVarintFee(dAtA, i, uint64(len(m.Relayers[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if len(m.RefundAddress) > 0 { - i -= len(m.RefundAddress) - copy(dAtA[i:], m.RefundAddress) - i = encodeVarintFee(dAtA, i, uint64(len(m.RefundAddress))) - i-- - dAtA[i] = 0x1a - } - { - size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *PacketFee) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -665,29 +531,6 @@ func (m *Fee) Size() (n int) { return n } -func (m *IdentifiedPacketFee) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.PacketId.Size() - n += 1 + l + sovFee(uint64(l)) - l = m.Fee.Size() - n += 1 + l + sovFee(uint64(l)) - l = len(m.RefundAddress) - if l > 0 { - n += 1 + l + sovFee(uint64(l)) - } - if len(m.Relayers) > 0 { - for _, s := range m.Relayers { - l = len(s) - n += 1 + l + sovFee(uint64(l)) - } - } - return n -} - func (m *PacketFee) Size() (n int) { if m == nil { return 0 @@ -899,186 +742,6 @@ func (m *Fee) Unmarshal(dAtA []byte) error { } return nil } -func (m *IdentifiedPacketFee) 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 ErrIntOverflowFee - } - 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: IdentifiedPacketFee: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IdentifiedPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthFee - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthFee - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RefundAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - 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 ErrInvalidLengthFee - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RefundAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - 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 ErrInvalidLengthFee - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Relayers = append(m.Relayers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipFee(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthFee - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *PacketFee) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index e619bde8806..c9fab858919 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -31,18 +31,11 @@ const ( // CounterpartyRelayerAddressKeyPrefix is the key prefix for relayer address mapping CounterpartyRelayerAddressKeyPrefix = "relayerAddress" - // FeeInEscrowPrefix is the key prefix for fee in escrow mapping - FeeInEscrowPrefix = "feeInEscrow" - // FeesInEscrowPrefix is the key prefix for fee in escrow mapping FeesInEscrowPrefix = "feesInEscrow" // ForwardRelayerPrefix is the key prefix for forward relayer addresses stored in state for async acknowledgements ForwardRelayerPrefix = "forwardRelayer" - - AttributeKeyRecvFee = "recv_fee" - AttributeKeyAckFee = "ack_fee" - AttributeKeyTimeoutFee = "timeout_fee" ) // KeyFeeEnabled returns the key that stores a flag to determine if fee logic should @@ -99,11 +92,6 @@ func ParseKeyForwardRelayerAddress(key string) (channeltypes.PacketId, error) { return packetID, nil } -// KeyFeeInEscrow returns the key for escrowed fees -func KeyFeeInEscrow(packetID channeltypes.PacketId) []byte { - return []byte(fmt.Sprintf("%s/%d", KeyFeeInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) -} - // KeyFeesInEscrow returns the key for escrowed fees func KeyFeesInEscrow(packetID channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%d", KeyFeesInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) @@ -127,11 +115,6 @@ func ParseKeyFeesInEscrow(key string) (channeltypes.PacketId, error) { return packetID, nil } -// KeyFeeInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel -func KeyFeeInEscrowChannelPrefix(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s/packet", FeeInEscrowPrefix, portID, channelID)) -} - // KeyFeesInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel func KeyFeesInEscrowChannelPrefix(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", FeesInEscrowPrefix, portID, channelID)) diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index 85c6b107f5f..e6ef922b757 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -25,6 +25,11 @@ func TestKeyCounterpartyRelayer(t *testing.T) { require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s", types.CounterpartyRelayerAddressKeyPrefix, relayerAddress, channelID)) } +func TestKeyFeesInEscrow(t *testing.T) { + key := types.KeyFeesInEscrow(validPacketID) + require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s/%d", types.FeesInEscrowPrefix, ibctesting.MockFeePort, ibctesting.FirstChannelID, 1)) +} + func TestParseKeyFeeEnabled(t *testing.T) { testCases := []struct { name string diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 2c0d8a52e32..d2fec3e542f 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -162,36 +162,3 @@ func (msg MsgPayPacketFeeAsync) Type() string { func (msg MsgPayPacketFeeAsync) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) } - -func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) IdentifiedPacketFee { - return IdentifiedPacketFee{ - PacketId: packetId, - Fee: fee, - RefundAddress: refundAddr, - Relayers: relayers, - } -} - -// Validate performs a stateless check of the IdentifiedPacketFee fields -func (fee IdentifiedPacketFee) Validate() error { - // validate PacketId - if err := fee.PacketId.Validate(); err != nil { - return sdkerrors.Wrap(err, "Invalid PacketId") - } - - _, err := sdk.AccAddressFromBech32(fee.RefundAddress) - if err != nil { - return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress") - } - - // enforce relayer is nil - if fee.Relayers != nil { - return ErrRelayersNotNil - } - - if err := fee.Fee.Validate(); err != nil { - return err - } - - return nil -} diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index 4d39ad3786c..b1ebd7008ad 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -29,18 +29,6 @@ message Fee { ]; } -// IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. -// This includes the PacketId identifying the packet the fee is paying for, -// 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; -} - // PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the // fee message PacketFee {