diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index e51f12b9d56..84127283e32 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -31,6 +31,7 @@ - [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) - [ibc/applications/fee/v1/genesis.proto](#ibc/applications/fee/v1/genesis.proto) - [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) @@ -736,6 +737,21 @@ and an optional list of relayers that are permitted to receive the fee. + + + +### IdentifiedPacketFees +IdentifiedPacketFees contains a list of packet fees + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | | + + + + + diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 66319d6be58..66e40d5d8d8 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -224,15 +224,17 @@ func (im IBCModule) OnAcknowledgementPacket( return sdkerrors.Wrapf(err, "cannot unmarshal ICS-29 incentivized packet acknowledgement: %v", ack) } - packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) - - identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) + packetID := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) + identifiedPacketFees, found := im.keeper.GetFeesInEscrow(ctx, packetID) if !found { // return underlying callback if no fee found for given packetID return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) } - im.keeper.DistributePacketFees(ctx, identifiedPacketFee.RefundAddress, ack.ForwardRelayerAddress, relayer, identifiedPacketFee) + im.keeper.DistributePacketFees(ctx, ack.ForwardRelayerAddress, relayer, identifiedPacketFees.PacketFees) + + // removes the fees from the store as fees are now paid + im.keeper.DeleteFeesInEscrow(ctx, packetID) // call underlying callback return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) @@ -249,15 +251,17 @@ func (im IBCModule) OnTimeoutPacket( return im.app.OnTimeoutPacket(ctx, packet, relayer) } - packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) - - identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) + packetID := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) + identifiedPacketFees, found := im.keeper.GetFeesInEscrow(ctx, packetID) if !found { // return underlying callback if fee not found for given packetID return im.app.OnTimeoutPacket(ctx, packet, relayer) } - im.keeper.DistributePacketFeesOnTimeout(ctx, identifiedPacketFee.RefundAddress, relayer, identifiedPacketFee) + im.keeper.DistributePacketFeesOnTimeout(ctx, relayer, identifiedPacketFees.PacketFees) + + // removes the fee from the store as fee is now paid + im.keeper.DeleteFeesInEscrow(ctx, packetID) // call underlying callback return im.app.OnTimeoutPacket(ctx, packet, relayer) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 8f1e4ad1f28..858a6ce9dcd 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -542,7 +542,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { "no op success without a packet fee", func() { packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) ack = types.IncentivizedAcknowledgement{ Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), @@ -636,8 +636,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { originalBalance = sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) // default to success case - expectedBalance = originalBalance. - Add(identifiedFee.Fee.TimeoutFee[0]) + expectedBalance = originalBalance.Add(identifiedFee.Fee.TimeoutFee[0]) // malleate test case tc.malleate() @@ -696,7 +695,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { func() { // delete packet fee packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer }, @@ -781,10 +780,11 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { relayerBalance := sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), relayerAddr, ibctesting.TestCoin.Denom)) if tc.expFeeDistributed { - suite.Require().Equal( - identifiedFee.Fee.TimeoutFee, - relayerBalance, - ) + // there should no longer be a fee in escrow for this packet + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetId) + suite.Require().False(found) + + suite.Require().Equal(identifiedFee.Fee.TimeoutFee, relayerBalance) } else { suite.Require().Empty(relayerBalance) } diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 088362567be..e97096271b7 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -26,63 +26,67 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedP return sdkerrors.Wrapf(types.ErrRefundAccNotFound, "account with address: %s not found", refundAcc) } - coins := identifiedFee.Fee.RecvFee - coins = coins.Add(identifiedFee.Fee.AckFee...) - coins = coins.Add(identifiedFee.Fee.TimeoutFee...) - - if err := k.bankKeeper.SendCoinsFromAccountToModule( - ctx, refundAcc, types.ModuleName, coins, - ); err != nil { + coins := identifiedFee.Fee.Total() + if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, refundAcc, types.ModuleName, coins); err != nil { return err } - // Store fee in state for reference later - k.SetFeeInEscrow(ctx, identifiedFee) + packetFees := []types.IdentifiedPacketFee{identifiedFee} + if feesInEscrow, found := k.GetFeesInEscrow(ctx, identifiedFee.PacketId); found { + packetFees = append(packetFees, feesInEscrow.PacketFees...) + } + + identifiedFees := types.NewIdentifiedPacketFees(packetFees) + k.SetFeesInEscrow(ctx, identifiedFee.PacketId, identifiedFees) + return nil } // DistributePacketFees pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee. -func (k Keeper) DistributePacketFees(ctx sdk.Context, refundAcc, forwardRelayer string, reverseRelayer sdk.AccAddress, feeInEscrow types.IdentifiedPacketFee) { - // distribute fee for forward relaying - forward, err := sdk.AccAddressFromBech32(forwardRelayer) - if err == nil { - k.distributeFee(ctx, forward, feeInEscrow.Fee.RecvFee) - } +func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, reverseRelayer sdk.AccAddress, feesInEscrow []types.IdentifiedPacketFee) { + forwardAddr, _ := sdk.AccAddressFromBech32(forwardRelayer) - // distribute fee for reverse relaying - k.distributeFee(ctx, reverseRelayer, feeInEscrow.Fee.AckFee) + for _, packetFee := range feesInEscrow { + refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress) + if err != nil { + panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", packetFee.RefundAddress)) + } - // refund timeout fee refund, - refundAddr, err := sdk.AccAddressFromBech32(refundAcc) - if err != nil { - panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", refundAcc)) - } + // distribute fee to valid forward relayer address otherwise refund the fee + if !forwardAddr.Empty() { + // distribute fee for forward relaying + k.distributeFee(ctx, forwardAddr, packetFee.Fee.RecvFee) + } else { + // refund onRecv fee as forward relayer is not valid address + k.distributeFee(ctx, refundAddr, packetFee.Fee.RecvFee) + } - // refund timeout fee for unused timeout - k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.TimeoutFee) + // distribute fee for reverse relaying + k.distributeFee(ctx, reverseRelayer, packetFee.Fee.AckFee) - // removes the fee from the store as fee is now paid - k.DeleteFeeInEscrow(ctx, feeInEscrow.PacketId) + // refund timeout fee for unused timeout + k.distributeFee(ctx, refundAddr, packetFee.Fee.TimeoutFee) + } } // DistributePacketsFeesTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee -func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, refundAcc string, timeoutRelayer sdk.AccAddress, feeInEscrow types.IdentifiedPacketFee) { - refundAddr, err := sdk.AccAddressFromBech32(refundAcc) - if err != nil { - panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", refundAcc)) - } - - // refund receive fee for unused forward relaying - k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.RecvFee) +func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, timeoutRelayer sdk.AccAddress, feesInEscrow []types.IdentifiedPacketFee) { + for _, feeInEscrow := range feesInEscrow { + // check if refundAcc address works + refundAddr, err := sdk.AccAddressFromBech32(feeInEscrow.RefundAddress) + if err != nil { + panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", feeInEscrow.RefundAddress)) + } - // refund ack fee for unused reverse relaying - k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.AckFee) + // refund receive fee for unused forward relaying + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.RecvFee) - // distribute fee for timeout relaying - k.distributeFee(ctx, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) + // refund ack fee for unused reverse relaying + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.AckFee) - // removes the fee from the store as fee is now paid - k.DeleteFeeInEscrow(ctx, feeInEscrow.PacketId) + // distribute fee for timeout relaying + k.distributeFee(ctx, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) + } } // distributeFee will attempt to distribute the escrowed fee to the receiver address. @@ -106,28 +110,31 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e var refundErr error - k.IterateChannelFeesInEscrow(ctx, portID, channelID, func(identifiedFee types.IdentifiedPacketFee) (stop bool) { - refundAccAddr, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) - if err != nil { - refundErr = err - return true + k.IterateIdentifiedChannelFeesInEscrow(ctx, portID, channelID, func(identifiedFees types.IdentifiedPacketFees) (stop bool) { + for _, identifiedFee := range identifiedFees.PacketFees { + refundAccAddr, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) + if err != nil { + refundErr = err + return true + } + + // refund all fees to refund address + // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. + // if any `SendCoins` call returns an error, we return error and stop iteration + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee); err != nil { + refundErr = err + return true + } + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee); err != nil { + refundErr = err + return true + } + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee); err != nil { + refundErr = err + return true + } } - // refund all fees to refund address - // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. - // if any `SendCoins` call returns an error, we return error and stop iteration - if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee); err != nil { - refundErr = err - return true - } - if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee); err != nil { - refundErr = err - return true - } - if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee); err != nil { - refundErr = err - return true - } return false }) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 8642cca14d9..0be30c8c22f 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -27,6 +27,23 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { { "success", func() {}, true, }, + { + "success with existing packet fee", func() { + fee := types.Fee{ + RecvFee: receiveFee, + AckFee: ackFee, + TimeoutFee: timeoutFee, + } + + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + + feesInEscrow := types.IdentifiedPacketFees{ + PacketFees: []types.IdentifiedPacketFee{identifiedPacketFee}, + } + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetId, feesInEscrow) + }, true, + }, { "fee not enabled on this channel", func() { packetId.ChannelId = "disabled_channel" @@ -84,11 +101,12 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) if tc.expPass { - feeInEscrow, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) + feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetId) + suite.Require().True(found) // check if the escrowed fee is set in state - suite.Require().True(feeInEscrow.Fee.AckFee.IsEqual(fee.AckFee)) - suite.Require().True(feeInEscrow.Fee.RecvFee.IsEqual(fee.RecvFee)) - suite.Require().True(feeInEscrow.Fee.TimeoutFee.IsEqual(fee.TimeoutFee)) + suite.Require().True(feesInEscrow.PacketFees[0].Fee.AckFee.IsEqual(fee.AckFee)) + suite.Require().True(feesInEscrow.PacketFees[0].Fee.RecvFee.IsEqual(fee.RecvFee)) + suite.Require().True(feesInEscrow.PacketFees[0].Fee.TimeoutFee.IsEqual(fee.TimeoutFee)) // check if the fee is escrowed correctly hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(600)}) suite.Require().True(hasBalance) @@ -152,13 +170,16 @@ func (suite *KeeperTestSuite) TestDistributeFee() { err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) + // escrow a second packet fee to test with multiple fees distributed + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + suite.Require().NoError(err) tc.malleate() // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), refundAcc.String(), forwardRelayer, reverseRelayer, identifiedPacketFee) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), forwardRelayer, reverseRelayer, []types.IdentifiedPacketFee{identifiedPacketFee, identifiedPacketFee}) if tc.expPass { // there should no longer be a fee in escrow for this packet @@ -166,17 +187,17 @@ func (suite *KeeperTestSuite) TestDistributeFee() { suite.Require().False(found) // check if the reverse relayer is paid - hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, fee.AckFee[0]) + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, fee.AckFee[0].Add(fee.AckFee[0])) suite.Require().True(hasBalance) // check if the forward relayer is paid forward, err := sdk.AccAddressFromBech32(forwardRelayer) suite.Require().NoError(err) - hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.RecvFee[0]) + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.RecvFee[0].Add(fee.RecvFee[0])) suite.Require().True(hasBalance) // check if the refund acc has been refunded the timeoutFee - expectedRefundAccBal := refundAccBal.Add(fee.TimeoutFee[0]) + expectedRefundAccBal := refundAccBal.Add(fee.TimeoutFee[0].Add(fee.TimeoutFee[0])) hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) @@ -184,8 +205,9 @@ func (suite *KeeperTestSuite) TestDistributeFee() { hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)}) suite.Require().True(hasBalance) } else { - // check the module acc wallet still has forward relaying balance - hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), fee.RecvFee[0]) + // check if the refund acc has been refunded the timeoutFee & onRecvFee + expectedRefundAccBal := refundAccBal.Add(fee.TimeoutFee[0]).Add(fee.RecvFee[0]).Add(fee.TimeoutFee[0]).Add(fee.RecvFee[0]) + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) } }) @@ -221,23 +243,22 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) + // escrow a second packet fee to test with multiple fees distributed + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + suite.Require().NoError(err) // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), refundAcc.String(), timeoutRelayer, identifiedPacketFee) - - // 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) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), timeoutRelayer, []types.IdentifiedPacketFee{identifiedPacketFee, identifiedPacketFee}) // check if the timeoutRelayer has been paid hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), timeoutRelayer, fee.TimeoutFee[0]) suite.Require().True(hasBalance) // check if the refund acc has been refunded the recv & ack fees - expectedRefundAccBal := refundAccBal.Add(fee.AckFee[0]) - expectedRefundAccBal = refundAccBal.Add(fee.RecvFee[0]) + expectedRefundAccBal := refundAccBal.Add(fee.AckFee[0]).Add(fee.AckFee[0]) + expectedRefundAccBal = refundAccBal.Add(fee.RecvFee[0]).Add(fee.RecvFee[0]) hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 568335daed1..3d4f42a3c28 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -18,9 +18,9 @@ func (suite *KeeperTestSuite) TestInitGenesis() { uint64(1), ) fee := types.Fee{ - defaultReceiveFee, - defaultAckFee, - defaultTimeoutFee, + RecvFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, } // relayer addresses @@ -74,19 +74,15 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // setup & escrow the packet fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := channeltypes.NewPacketId( - ibctesting.FirstChannelID, - transfertypes.PortID, - uint64(1), - ) + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1) fee := types.Fee{ - defaultReceiveFee, - defaultAckFee, - defaultTimeoutFee, + RecvFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) - suite.Require().NoError(err) + + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) // relayer addresses sender := suite.chainA.SenderAccount.GetAddress().String() @@ -95,7 +91,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) // set forward relayer address - suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetId, sender) + suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetID, sender) // export genesis genesisState := suite.chainA.GetSimApp().IBCFeeKeeper.ExportGenesis(suite.chainA.GetContext()) @@ -105,7 +101,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.Require().Equal(transfertypes.PortID, genesisState.FeeEnabledChannels[0].PortId) // check fee - suite.Require().Equal(packetId, genesisState.IdentifiedFees[0].PacketId) + suite.Require().Equal(packetID, genesisState.IdentifiedFees[0].PacketId) suite.Require().Equal(fee, genesisState.IdentifiedFees[0].Fee) suite.Require().Equal(refundAcc.String(), genesisState.IdentifiedFees[0].RefundAddress) suite.Require().Equal([]string(nil), genesisState.IdentifiedFees[0].Relayers) @@ -116,5 +112,5 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // check registered relayer addresses suite.Require().Equal(sender, genesisState.ForwardRelayers[0].Address) - suite.Require().Equal(packetId, genesisState.ForwardRelayers[0].PacketId) + suite.Require().Equal(packetID, genesisState.ForwardRelayers[0].PacketId) } diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 2c41da93d1e..9074002473a 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -70,8 +70,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { tc.malleate() suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) - suite.Require().NoError(err) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) res, err := suite.queryClient.IncentivizedPacket(ctx, req) @@ -123,8 +123,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { expPackets = append(expPackets, &fee1, &fee2, &fee3) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) - for _, p := range expPackets { - suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), *p) + for _, packetFee := range expPackets { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), *packetFee) } req = &types.QueryIncentivizedPacketsRequest{ diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 441aaf57a2c..d82e17b69a4 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -247,6 +247,40 @@ func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) return fee, true } +// GetFeesInEscrow returns all escrowed packet fees for a given packetID +func (k Keeper) GetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.IdentifiedPacketFees, bool) { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeesInEscrow(packetID) + bz := store.Get(key) + if bz == nil { + return types.IdentifiedPacketFees{}, false + } + + return k.MustUnmarshalFees(bz), true +} + +// HasFeesInEscrow returns true if packet fees exist for the provided packetID +func (k Keeper) HasFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) bool { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeesInEscrow(packetID) + + return store.Has(key) +} + +// SetFeesInEscrow sets the given packet fees in escrow keyed by the packet identifier +func (k Keeper) SetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId, fees types.IdentifiedPacketFees) { + store := ctx.KVStore(k.storeKey) + bz := k.MustMarshalFees(fees) + store.Set(types.KeyFeesInEscrow(packetID), bz) +} + +// DeleteFeesInEscrow deletes the fee associated with the given packetID +func (k Keeper) DeleteFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeesInEscrow(packetID) + store.Delete(key) +} + // 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)) { @@ -262,6 +296,21 @@ func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID st } } +// IterateIdentifiedChannelFeesInEscrow 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) IterateIdentifiedChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFees types.IdentifiedPacketFees) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyFeesInEscrowChannelPrefix(portID, channelID)) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + identifiedFees := k.MustUnmarshalFees(iterator.Value()) + if cb(identifiedFees) { + break + } + } +} + // Deletes the fee associated with the given packetId func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) @@ -305,3 +354,17 @@ func (k Keeper) MustUnmarshalFee(bz []byte) 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.IdentifiedPacketFees) []byte { + return k.cdc.MustMarshal(&fees) +} + +// MustUnmarshalFees attempts to decode and return a Fee object from +// raw encoded bytes. It panics on error. +func (k Keeper) MustUnmarshalFees(bz []byte) types.IdentifiedPacketFees { + var fees types.IdentifiedPacketFees + k.cdc.MustUnmarshal(bz, &fees) + return fees +} diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 3e21e268597..b510aa7b7c9 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -101,17 +101,20 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { // escrow a fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, uint64(1)) - fee := types.Fee{defaultAckFee, defaultReceiveFee, defaultTimeoutFee} - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, 1) + fee := types.Fee{ + AckFee: defaultAckFee, + RecvFee: defaultReceiveFee, + TimeoutFee: defaultTimeoutFee, + } // escrow the packet fee - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) - suite.Require().NoError(err) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) expectedFees := []types.IdentifiedPacketFee{ { - PacketId: packetId, + PacketId: packetID, Fee: fee, RefundAddress: refundAcc.String(), Relayers: nil, diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 841a1a3a0c1..7453c88e50e 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -3,9 +3,22 @@ package types import ( "strings" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +// NewIdentifiedPacketFees creates and returns a new IdentifiedPacketFees struct +func NewIdentifiedPacketFees(packetFees []IdentifiedPacketFee) IdentifiedPacketFees { + return IdentifiedPacketFees{ + PacketFees: packetFees, + } +} + +// Total returns the total amount for a given Fee +func (f Fee) Total() sdk.Coins { + return f.RecvFee.Add(f.AckFee...).Add(f.TimeoutFee...) +} + // Validate asserts that each Fee is valid and all three Fees are not empty or zero func (fee Fee) Validate() error { var errFees []string diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 4fa6f240abb..8be56939659 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -161,46 +161,94 @@ func (m *IdentifiedPacketFee) GetRelayers() []string { return nil } +// IdentifiedPacketFees contains a list of packet fees +type IdentifiedPacketFees struct { + PacketFees []IdentifiedPacketFee `protobuf:"bytes,1,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` +} + +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{2} +} +func (m *IdentifiedPacketFees) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IdentifiedPacketFees) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IdentifiedPacketFees.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 *IdentifiedPacketFees) XXX_Merge(src proto.Message) { + xxx_messageInfo_IdentifiedPacketFees.Merge(m, src) +} +func (m *IdentifiedPacketFees) XXX_Size() int { + return m.Size() +} +func (m *IdentifiedPacketFees) XXX_DiscardUnknown() { + xxx_messageInfo_IdentifiedPacketFees.DiscardUnknown(m) +} + +var xxx_messageInfo_IdentifiedPacketFees proto.InternalMessageInfo + +func (m *IdentifiedPacketFees) GetPacketFees() []IdentifiedPacketFee { + if m != nil { + return m.PacketFees + } + return nil +} + func init() { proto.RegisterType((*Fee)(nil), "ibc.applications.fee.v1.Fee") proto.RegisterType((*IdentifiedPacketFee)(nil), "ibc.applications.fee.v1.IdentifiedPacketFee") + proto.RegisterType((*IdentifiedPacketFees)(nil), "ibc.applications.fee.v1.IdentifiedPacketFees") } func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 488 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xbd, 0x8e, 0xd3, 0x40, - 0x10, 0xc7, 0x63, 0x7c, 0xba, 0x8f, 0x8d, 0x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, 0xeb, 0xfe, 0xe3, 0xdb, 0x2d, 0xd8, 0x3d, 0xf7, 0xa3, 0xfb, 0x26, - 0xf0, 0xd6, 0xf8, 0x4e, 0x0f, 0x17, 0x2c, 0xe5, 0x2b, 0x28, 0xb5, 0x7b, 0x30, 0xb0, 0x83, 0x93, - 0xe8, 0xce, 0x0f, 0xdf, 0x5f, 0x6d, 0x3c, 0xeb, 0x7a, 0xe3, 0x59, 0xbf, 0x36, 0x9e, 0xf5, 0x6d, - 0xeb, 0x75, 0xae, 0xb7, 0x5e, 0xe7, 0xc7, 0xd6, 0xeb, 0x7c, 0x7a, 0xf9, 0xf7, 0x44, 0x65, 0x2c, - 0x86, 0x73, 0xc5, 0xea, 0x73, 0x96, 0xa9, 0x64, 0x99, 0x82, 0xc6, 0x37, 0xa5, 0xd9, 0xf8, 0xd5, - 0x10, 0x9f, 0x53, 0x33, 0xe4, 0xf8, 0xb0, 0x59, 0xee, 0xf3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x4e, 0x82, 0x74, 0x21, 0x73, 0x03, 0x00, 0x00, + // 523 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x6b, 0x32, 0x6d, 0xab, 0x2b, 0x26, 0x14, 0x86, 0xe8, 0x2a, 0x48, 0x4b, 0x4e, 0x3d, + 0x50, 0x5b, 0xed, 0xe0, 0x00, 0x27, 0x08, 0x52, 0xa5, 0x9d, 0x40, 0x11, 0x27, 0x2e, 0x95, 0xe3, + 0xbc, 0x76, 0x56, 0x9b, 0x38, 0x8a, 0xd3, 0x48, 0x95, 0x38, 0x00, 0x9f, 0x80, 0xcf, 0xc1, 0x27, + 0xd9, 0x71, 0x47, 0x4e, 0x05, 0xb5, 0xdf, 0x60, 0x5f, 0x00, 0xe4, 0xd8, 0xab, 0x8a, 0xd8, 0x34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, 0xdf, 0x8a, 0x6d, + 0x85, 0xf3, 0x43, 0x9c, 0x6d, 0x50, 0xc1, 0xfb, 0x8b, 0x95, 0x87, 0x2e, 0x57, 0x1e, 0xfa, 0xbd, + 0xf2, 0xd0, 0xf7, 0xb5, 0x57, 0xbb, 0x5c, 0x7b, 0xb5, 0x9f, 0x6b, 0xaf, 0xf6, 0xe9, 0xe5, 0xff, + 0x55, 0x15, 0x11, 0xef, 0x4d, 0x24, 0x2d, 0x4f, 0x69, 0x22, 0xe3, 0xf9, 0x0c, 0x94, 0x9e, 0x6b, + 0x45, 0x07, 0xaf, 0x7a, 0x7a, 0xa4, 0xab, 0x42, 0x47, 0xfb, 0xd5, 0x80, 0x9d, 0xfe, 0x0d, 0x00, + 0x00, 0xff, 0xff, 0x0e, 0xeb, 0xd3, 0x29, 0xf7, 0x03, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -327,6 +375,43 @@ func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IdentifiedPacketFees) 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 *IdentifiedPacketFees) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IdentifiedPacketFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketFees) > 0 { + for iNdEx := len(m.PacketFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketFees[iNdEx].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 encodeVarintFee(dAtA []byte, offset int, v uint64) int { offset -= sovFee(v) base := offset @@ -388,6 +473,21 @@ func (m *IdentifiedPacketFee) Size() (n int) { return n } +func (m *IdentifiedPacketFees) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PacketFees) > 0 { + for _, e := range m.PacketFees { + l = e.Size() + n += 1 + l + sovFee(uint64(l)) + } + } + return n +} + func sovFee(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -726,6 +826,90 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { } return nil } +func (m *IdentifiedPacketFees) 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: IdentifiedPacketFees: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IdentifiedPacketFees: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketFees", 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 + } + m.PacketFees = append(m.PacketFees, IdentifiedPacketFee{}) + if err := m.PacketFees[len(m.PacketFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 skipFee(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/fee_test.go b/modules/apps/29-fee/types/fee_test.go index 0dbd9f29c4e..349fe8dcf07 100644 --- a/modules/apps/29-fee/types/fee_test.go +++ b/modules/apps/29-fee/types/fee_test.go @@ -7,6 +7,17 @@ import ( "github.com/stretchr/testify/require" ) +func TestFeeTotal(t *testing.T) { + fee := Fee{ + AckFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), + RecvFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), + TimeoutFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), + } + + total := fee.Total() + require.Equal(t, sdk.NewInt(300), total.AmountOf(sdk.DefaultBondDenom)) +} + // TestFeeValidation tests Validate func TestFeeValidation(t *testing.T) { var ( diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 2f26b859afc..b13aa2ba4b8 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -30,6 +30,9 @@ const ( // 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" ) @@ -55,7 +58,17 @@ 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)) +} + // 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/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 46f20f29783..624c6d8279a 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -281,44 +280,44 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 587 bytes of a gzipped FileDescriptorProto + // 577 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x4f, 0xdb, 0x4c, - 0x10, 0xc6, 0x6d, 0xc2, 0xcb, 0x0b, 0x5b, 0x54, 0x84, 0x81, 0x12, 0x4c, 0x64, 0x53, 0xab, 0xaa, - 0x72, 0x68, 0xec, 0x12, 0x8a, 0xaa, 0x72, 0x41, 0x04, 0x09, 0x35, 0x87, 0xa8, 0x91, 0x8f, 0xbd, - 0x44, 0xce, 0x7a, 0x62, 0xb6, 0x4d, 0xbc, 0xd6, 0xee, 0x26, 0xaa, 0xbf, 0x00, 0xea, 0x91, 0x5b, - 0x7b, 0xe4, 0xda, 0x6f, 0xc2, 0x91, 0x63, 0x4f, 0x51, 0x95, 0x5c, 0x7a, 0xce, 0x27, 0xa8, 0x6c, - 0x27, 0xc1, 0x21, 0x7f, 0x44, 0x7b, 0xdb, 0xdd, 0xf9, 0xcd, 0xb3, 0x33, 0xcf, 0xae, 0x06, 0x1d, - 0x90, 0x3a, 0xb6, 0x9c, 0x20, 0x68, 0x12, 0xec, 0x08, 0x42, 0x7d, 0x6e, 0x35, 0x00, 0xac, 0xce, - 0xa1, 0x25, 0xbe, 0x98, 0x01, 0xa3, 0x82, 0x2a, 0xbb, 0xa4, 0x8e, 0xcd, 0x34, 0x61, 0x36, 0x00, - 0xcc, 0xce, 0xa1, 0xba, 0xed, 0x51, 0x8f, 0xc6, 0x8c, 0x15, 0xad, 0x12, 0x5c, 0x7d, 0x3e, 0x4f, - 0x30, 0xca, 0x4a, 0x21, 0x98, 0x32, 0xb0, 0xf0, 0xa5, 0xe3, 0xfb, 0xd0, 0x8c, 0xc2, 0xc3, 0x65, - 0x82, 0x18, 0xdf, 0x65, 0xa4, 0x55, 0xb8, 0x67, 0x83, 0x47, 0xb8, 0x00, 0x76, 0x4e, 0xdb, 0xbe, - 0x00, 0x16, 0x38, 0x4c, 0x84, 0x67, 0xae, 0xcb, 0x80, 0x73, 0x25, 0x8b, 0xfe, 0x77, 0x92, 0x65, - 0x56, 0x3e, 0x90, 0xf3, 0x6b, 0xf6, 0x68, 0xab, 0xd8, 0x68, 0x1b, 0xa7, 0x12, 0x6a, 0x23, 0x6c, - 0x29, 0xc2, 0x4a, 0xfa, 0xa0, 0xab, 0xef, 0x87, 0x4e, 0xab, 0x79, 0x62, 0xcc, 0xa2, 0x0c, 0x7b, - 0x0b, 0x4f, 0xdf, 0x76, 0xb2, 0xfa, 0xf5, 0x46, 0x97, 0x7e, 0xdf, 0xe8, 0x92, 0x91, 0x47, 0x2f, - 0x17, 0x57, 0x66, 0x03, 0x0f, 0xa8, 0xcf, 0xc1, 0xb8, 0x5e, 0x42, 0x1b, 0x15, 0xee, 0x55, 0x9d, - 0xb0, 0xea, 0xe0, 0xcf, 0x20, 0x2e, 0x00, 0x94, 0x37, 0x28, 0xd3, 0x00, 0x88, 0x2b, 0x7e, 0x52, - 0xcc, 0x99, 0x73, 0xbc, 0x35, 0x2f, 0x00, 0x4a, 0xcb, 0xb7, 0x5d, 0x5d, 0xb2, 0x23, 0x5c, 0x39, - 0x45, 0x4f, 0x39, 0x6d, 0x33, 0x0c, 0xb5, 0x80, 0x32, 0x51, 0x23, 0xee, 0xb0, 0x97, 0xbd, 0x41, - 0x57, 0xdf, 0x49, 0x7a, 0x99, 0x8c, 0x1b, 0xf6, 0x7a, 0x72, 0x50, 0xa5, 0x4c, 0x94, 0x5d, 0xe5, - 0x3d, 0xda, 0x1c, 0x02, 0x43, 0x9f, 0x23, 0x8d, 0x4c, 0xac, 0x91, 0x1b, 0x74, 0xf5, 0xec, 0x84, - 0xc6, 0x3d, 0x62, 0xd8, 0x1b, 0xc9, 0xd9, 0x79, 0x72, 0x54, 0x76, 0x95, 0x67, 0x68, 0x85, 0x13, - 0xcf, 0x07, 0x96, 0x5d, 0x8e, 0x5d, 0x1f, 0xee, 0x14, 0x15, 0xad, 0x32, 0x68, 0x3a, 0x21, 0x30, - 0x9e, 0xfd, 0xef, 0x20, 0x93, 0x5f, 0xb3, 0xc7, 0xfb, 0x94, 0x79, 0x7b, 0x68, 0xf7, 0x81, 0x23, - 0x63, 0xb7, 0x7e, 0xc8, 0x68, 0xfb, 0x41, 0xec, 0x8c, 0x87, 0x3e, 0x56, 0xae, 0x64, 0xb4, 0x43, - 0x5c, 0xf0, 0x05, 0x69, 0x10, 0x70, 0x6b, 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x00, 0x00, 0x00, 0xff, 0xff, 0x81, 0xea, 0x8a, 0x9a, 0x15, 0x05, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index bbbd82663e1..3a58f093e06 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -40,3 +40,9 @@ message IdentifiedPacketFee { string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; repeated string relayers = 4; } + +// IdentifiedPacketFees contains a list of packet fees +message IdentifiedPacketFees { + repeated IdentifiedPacketFee packet_fees = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_fees\""]; +} \ No newline at end of file diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 4540c28967e..900764f9343 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -6,7 +6,6 @@ option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; -import "ibc/core/channel/v1/channel.proto"; // Msg defines the ibc/fee Msg service. service Msg {