diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index bd0e93d1a7f..ddeba3e5cb6 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -343,6 +343,7 @@ It contains the raw acknowledgement bytes, as well as the forward relayer addres | ----- | ---- | ----- | ----------- | | `result` | [bytes](#bytes) | | | | `forward_relayer_address` | [string](#string) | | | +| `underlying_app_success` | [bool](#bool) | | | @@ -743,7 +744,7 @@ and an optional list of relayers that are permitted to receive the fee. ### IdentifiedPacketFees -IdentifiedPacketFees contains a PacketFree and associated PacketId +IdentifiedPacketFees contains a list of type PacketFee and associated PacketId | Field | Type | Label | Description | @@ -865,6 +866,7 @@ RegisteredRelayerAddress contains the address and counterparty address for a spe | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | | | `counterparty_address` | [string](#string) | | | +| `channel_id` | [string](#string) | | | @@ -1076,6 +1078,7 @@ MsgRegisterCounterpartyAddress is the request type for registering the counterpa | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | | | `counterparty_address` | [string](#string) | | | +| `channel_id` | [string](#string) | | | diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index e5ff524dee7..9e18b088dc4 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -25,14 +25,14 @@ func GetQueryCmd() *cobra.Command { func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ Use: "ibc-fee", - Short: "", // TODO + Short: "Transaction subcommand for IBC relayer incentivization", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } txCmd.AddCommand( - // TODO + NewPayPacketFeeAsyncTxCmd(), ) return txCmd diff --git a/modules/apps/29-fee/client/cli/tx.go b/modules/apps/29-fee/client/cli/tx.go index e8878f3e042..a9f66a71007 100644 --- a/modules/apps/29-fee/client/cli/tx.go +++ b/modules/apps/29-fee/client/cli/tx.go @@ -1,3 +1,99 @@ package cli -// TODO +import ( + "fmt" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" +) + +const ( + flagRecvFee = "recv-fee" + flagAckFee = "ack-fee" + flagTimeoutFee = "timeout-fee" +) + +// NewPayPacketFeeAsyncTxCmd returns the command to create a MsgPayPacketFeeAsync +func NewPayPacketFeeAsyncTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "pay-packet-fee [src-port] [src-channel] [sequence]", + Short: "Pay a fee to incentivize an existing IBC packet", + Long: strings.TrimSpace(`Pay a fee to incentivize an existing IBC packet.`), + Example: fmt.Sprintf("%s tx pay-packet-fee transfer channel-0 1 --recv-fee 10stake --ack-fee 10stake --timeout-fee 10stake", version.AppName), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // NOTE: specifying non-nil relayers is currently unsupported + var relayers []string + + sender := clientCtx.GetFromAddress().String() + seq, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + packetID := channeltypes.NewPacketId(args[1], args[0], seq) + + recvFeeStr, err := cmd.Flags().GetString(flagRecvFee) + if err != nil { + return err + } + + recvFee, err := sdk.ParseCoinsNormalized(recvFeeStr) + if err != nil { + return err + } + + ackFeeStr, err := cmd.Flags().GetString(flagAckFee) + if err != nil { + return err + } + + ackFee, err := sdk.ParseCoinsNormalized(ackFeeStr) + if err != nil { + return err + } + + timeoutFeeStr, err := cmd.Flags().GetString(flagTimeoutFee) + if err != nil { + return err + } + + timeoutFee, err := sdk.ParseCoinsNormalized(timeoutFeeStr) + if err != nil { + return err + } + + fee := types.Fee{ + RecvFee: recvFee, + AckFee: ackFee, + TimeoutFee: timeoutFee, + } + + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, sender, relayers) + + msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(flagRecvFee, "", "Fee paid to a relayer for relaying a packet receive.") + cmd.Flags().String(flagAckFee, "", "Fee paid to a relayer for relaying a packet acknowledgement.") + cmd.Flags().String(flagTimeoutFee, "", "Fee paid to a relayer for relaying a packet timeout.") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 88037046a69..12d7e70a147 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -3,11 +3,9 @@ package fee_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" @@ -25,27 +23,11 @@ type FeeTestSuite struct { path *ibctesting.Path } -// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *FeeTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) - 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 - path.EndpointB.ChannelConfig.PortID = transfertypes.PortID - suite.path = path -} - -// TODO: rename to 'SetupTest' when the above function is removed -func (suite *FeeTestSuite) SetupMockTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) path.EndpointA.ChannelConfig.Version = mockFeeVersion @@ -59,28 +41,6 @@ func TestIBCFeeTestSuite(t *testing.T) { suite.Run(t, new(FeeTestSuite)) } -// TODO: remove -func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet { - - fungibleTokenPacket := transfertypes.NewFungibleTokenPacketData( - coin.Denom, - sdk.NewInt(100).String(), - suite.chainA.SenderAccount.GetAddress().String(), - suite.chainB.SenderAccount.GetAddress().String(), - ) - - return channeltypes.NewPacket( - fungibleTokenPacket.GetBytes(), - suite.chainA.SenderAccount.GetSequence(), - suite.path.EndpointA.ChannelConfig.PortID, - suite.path.EndpointA.ChannelID, - suite.path.EndpointB.ChannelConfig.PortID, - suite.path.EndpointB.ChannelID, - clienttypes.NewHeight(0, 100), - 0, - ) -} - func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet { return channeltypes.NewPacket( ibcmock.MockPacketData, diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 421900807a6..c7a73d56e74 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -116,7 +116,7 @@ func (im IBCModule) OnChanOpenAck( } if versionMetadata.FeeVersion != types.Version { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty version: %s, got: %s", types.Version, versionMetadata.FeeVersion) + return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty fee version: %s, got: %s", types.Version, versionMetadata.FeeVersion) } // call underlying app's OnChanOpenAck callback with the counterparty app version. @@ -196,15 +196,16 @@ func (im IBCModule) OnRecvPacket( ack := im.app.OnRecvPacket(ctx, packet, relayer) - forwardRelayer, found := im.keeper.GetCounterpartyAddress(ctx, relayer.String()) - - // incase of async aknowledgement (ack == nil) store the ForwardRelayer address for use later - if ack == nil && found { - im.keeper.SetForwardRelayerAddress(ctx, channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()), forwardRelayer) + // incase of async aknowledgement (ack == nil) store the relayer address for use later during async WriteAcknowledgement + if ack == nil { + im.keeper.SetRelayerAddressForAsyncAck(ctx, channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()), relayer.String()) return nil } - return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement()) + // if forwardRelayer is not found we refund recv_fee + forwardRelayer, _ := im.keeper.GetCounterpartyAddress(ctx, relayer.String(), packet.GetSourceChannel()) + + return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement(), ack.Success()) } // OnAcknowledgementPacket 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 8ffbdd5466b..214c171d72a 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -10,6 +10,7 @@ import ( transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" + "github.com/cosmos/ibc-go/v3/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) @@ -59,7 +60,7 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { suite.Run(tc.name, func() { // reset suite - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) // setup mock callback @@ -150,7 +151,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { suite.Run(tc.name, func() { // reset suite - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) suite.path.EndpointB.ChanOpenInit() @@ -255,7 +256,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) // setup mock callback @@ -337,7 +338,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) @@ -415,7 +416,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) @@ -461,11 +462,18 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { true, }, { - "source relayer is empty string", + "async write acknowledgement: ack is nil", func() { - suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "") + // setup mock callback + suite.chainB.GetSimApp().FeeMockModule.IBCApp.OnRecvPacket = func( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, + ) exported.Acknowledgement { + return nil + } }, - false, + true, true, }, { @@ -476,12 +484,20 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { true, false, }, + { + "forward address is not found", + func() { + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "", suite.path.EndpointB.ChannelID) + }, + false, + true, + }, } for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled @@ -498,7 +514,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String()) + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID) // malleate test case tc.malleate() @@ -509,19 +525,16 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { case !tc.feeEnabled: suite.Require().Equal(ibcmock.MockAcknowledgement, result) - case tc.forwardRelayer: - ack := types.IncentivizedAcknowledgement{ - Result: ibcmock.MockAcknowledgement.Acknowledgement(), - ForwardRelayerAddress: suite.chainB.SenderAccount.GetAddress().String(), - } - suite.Require().Equal(ack, result) + case tc.forwardRelayer && result == nil: + suite.Require().Equal(nil, result) case !tc.forwardRelayer: - ack := types.IncentivizedAcknowledgement{ + expectedAck := types.IncentivizedAcknowledgement{ Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: "", + UnderlyingAppSuccess: true, } - suite.Require().Equal(ack, result) + suite.Require().Equal(expectedAck, result) } }) } @@ -723,7 +736,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) packet := suite.CreateMockPacket() diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index cf750c07f31..70b6a5012a2 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -12,12 +12,12 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { k.SetFeesInEscrow(ctx, identifiedFees.PacketId, types.NewPacketFees(identifiedFees.PacketFees)) } - for _, addr := range state.RegisteredRelayers { - k.SetCounterpartyAddress(ctx, addr.Address, addr.CounterpartyAddress) + for _, relayer := range state.RegisteredRelayers { + k.SetCounterpartyAddress(ctx, relayer.Address, relayer.CounterpartyAddress, relayer.ChannelId) } for _, forwardAddr := range state.ForwardRelayers { - k.SetForwardRelayerAddress(ctx, forwardAddr.PacketId, forwardAddr.Address) + k.SetRelayerAddressForAsyncAck(ctx, forwardAddr.PacketId, forwardAddr.Address) } for _, enabledChan := range state.FeeEnabledChannels { diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 264261939e5..f2824120a82 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -43,6 +43,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { { Address: sender, CounterpartyAddress: counterparty, + ChannelId: ibctesting.FirstChannelID, }, }, } @@ -59,7 +60,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().True(isEnabled) // check relayers - addr, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainA.GetContext(), sender) + addr, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainA.GetContext(), sender, ibctesting.FirstChannelID) suite.Require().True(found) suite.Require().Equal(genesisState.RegisteredRelayers[0].CounterpartyAddress, addr) } @@ -84,10 +85,10 @@ func (suite *KeeperTestSuite) TestExportGenesis() { sender := suite.chainA.SenderAccount.GetAddress().String() counterparty := suite.chainB.SenderAccount.GetAddress().String() // set counterparty address - suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) + suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID) // set forward relayer address - suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetID, sender) + suite.chainA.GetSimApp().IBCFeeKeeper.SetRelayerAddressForAsyncAck(suite.chainA.GetContext(), packetID, sender) // export genesis genesisState := suite.chainA.GetSimApp().IBCFeeKeeper.ExportGenesis(suite.chainA.GetContext()) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index df55aa16cc4..48ff7c935b0 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -135,15 +135,15 @@ func (k Keeper) DisableAllChannels(ctx sdk.Context) { // SetCounterpartyAddress maps the destination chain relayer address to the source relayer address // The receiving chain must store the mapping from: address -> counterpartyAddress for the given channel -func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address, counterpartyAddress string) { +func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address, counterpartyAddress, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyRelayerAddress(address), []byte(counterpartyAddress)) + store.Set(types.KeyCounterpartyRelayer(address, channelID), []byte(counterpartyAddress)) } // GetCounterpartyAddress gets the relayer counterparty address given a destination relayer address -func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, bool) { +func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address, channelID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyRelayerAddress(address) + key := types.KeyCounterpartyRelayer(address, channelID) if !store.Has(key) { return "", false @@ -156,7 +156,7 @@ func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, // GetAllRelayerAddresses returns all registered relayer addresses func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelayerAddress { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.RelayerAddressKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.CounterpartyRelayerAddressKeyPrefix)) defer iterator.Close() var registeredAddrArr []types.RegisteredRelayerAddress @@ -166,6 +166,7 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelaye addr := types.RegisteredRelayerAddress{ Address: keySplit[1], CounterpartyAddress: string(iterator.Value()), + ChannelId: keySplit[2], } registeredAddrArr = append(registeredAddrArr, addr) @@ -174,14 +175,14 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelaye return registeredAddrArr } -// SetForwardRelayerAddress sets the forward relayer address during OnRecvPacket in case of async acknowledgement -func (k Keeper) SetForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId, address string) { +// SetRelayerAddressForAsyncAck sets the forward relayer address during OnRecvPacket in case of async acknowledgement +func (k Keeper) SetRelayerAddressForAsyncAck(ctx sdk.Context, packetId channeltypes.PacketId, address string) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyForwardRelayerAddress(packetId), []byte(address)) } -// GetForwardRelayerAddress gets forward relayer address for a particular packet -func (k Keeper) GetForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId) (string, bool) { +// GetRelayerAddressForAsyncAck gets forward relayer address for a particular packet +func (k Keeper) GetRelayerAddressForAsyncAck(ctx sdk.Context, packetId channeltypes.PacketId) (string, bool) { store := ctx.KVStore(k.storeKey) key := types.KeyForwardRelayerAddress(packetId) if !store.Has(key) { diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 74f7bc7b811..65132c243e1 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" @@ -34,31 +33,11 @@ type KeeperTestSuite struct { queryClient types.QueryClient } -// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *KeeperTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) - 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 - path.EndpointB.ChannelConfig.PortID = transfertypes.PortID - suite.path = path - - queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) -} - -// TODO: rename to 'SetupTest' when the above function is removed -func (suite *KeeperTestSuite) SetupMockTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) path.EndpointA.ChannelConfig.Version = mockFeeVersion @@ -77,7 +56,6 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestFeeInEscrow() { - suite.SetupMockTest() suite.coordinator.Setup(suite.path) fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} @@ -119,7 +97,6 @@ func (suite *KeeperTestSuite) TestDisableAllChannels() { } func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { - suite.SetupMockTest() suite.coordinator.Setup(suite.path) // escrow a fee @@ -179,12 +156,13 @@ func (suite *KeeperTestSuite) TestGetAllRelayerAddresses() { sender := suite.chainA.SenderAccount.GetAddress().String() counterparty := suite.chainB.SenderAccount.GetAddress().String() - suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) + suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID) expectedAddr := []types.RegisteredRelayerAddress{ { Address: sender, CounterpartyAddress: counterparty, + ChannelId: ibctesting.FirstChannelID, }, } diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 678a8b6c08c..2f0004be150 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -18,7 +18,7 @@ func (k Keeper) RegisterCounterpartyAddress(goCtx context.Context, msg *types.Ms ctx := sdk.UnwrapSDKContext(goCtx) k.SetCounterpartyAddress( - ctx, msg.Address, msg.CounterpartyAddress, + ctx, msg.Address, msg.CounterpartyAddress, msg.ChannelId, ) k.Logger(ctx).Info("Registering counterparty address for relayer.", "Address:", msg.Address, "Counterparty Address:", msg.CounterpartyAddress) diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index f541dd3fd36..0a8ad4b7d06 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { @@ -35,14 +36,14 @@ func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { sender = suite.chainA.SenderAccount.GetAddress().String() counterparty = suite.chainB.SenderAccount.GetAddress().String() tc.malleate() - msg := types.NewMsgRegisterCounterpartyAddress(sender, counterparty) + msg := types.NewMsgRegisterCounterpartyAddress(sender, counterparty, ibctesting.FirstChannelID) _, err := suite.chainA.SendMsgs(msg) if tc.expPass { suite.Require().NoError(err) // message committed - counterpartyAddress, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(ctx, suite.chainA.SenderAccount.GetAddress().String()) + counterpartyAddress, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(ctx, suite.chainA.SenderAccount.GetAddress().String(), ibctesting.FirstChannelID) suite.Require().Equal(counterparty, counterpartyAddress) } else { suite.Require().Error(err) diff --git a/modules/apps/29-fee/keeper/relay.go b/modules/apps/29-fee/keeper/relay.go index 628ad40a61f..76b410bb09e 100644 --- a/modules/apps/29-fee/keeper/relay.go +++ b/modules/apps/29-fee/keeper/relay.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" @@ -16,14 +17,27 @@ func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, // WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function // ICS29 WriteAcknowledgement is used for asynchronous acknowledgements -func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement []byte) error { +func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error { + if !k.IsFeeEnabled(ctx, packet.GetDestPort(), packet.GetDestChannel()) { + // ics4Wrapper may be core IBC or higher-level middleware + return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, acknowledgement) + } + // retrieve the forward relayer that was stored in `onRecvPacket` packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) - relayer, _ := k.GetForwardRelayerAddress(ctx, packetId) - k.DeleteForwardRelayerAddress(ctx, packetId) + relayer, found := k.GetRelayerAddressForAsyncAck(ctx, packetId) + if !found { + return sdkerrors.Wrapf(types.ErrRelayerNotFoundForAsyncAck, "no relayer address stored for async acknowledgement for packet with portID: %s, channelID: %s, sequence: %d", packetId.PortId, packetId.ChannelId, packetId.Sequence) + } + + // it is possible that a relayer has not registered a counterparty address. + // if there is no registered counterparty address then write acknowledgement with empty relayer address and refund recv_fee. + forwardRelayer, _ := k.GetCounterpartyAddress(ctx, relayer, packet.GetSourceChannel()) - ack := types.NewIncentivizedAcknowledgement(relayer, acknowledgement) + ack := types.NewIncentivizedAcknowledgement(forwardRelayer, acknowledgement.Acknowledgement(), acknowledgement.Success()) + + k.DeleteForwardRelayerAddress(ctx, packetId) // ics4Wrapper may be core IBC or higher-level middleware return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, ack) diff --git a/modules/apps/29-fee/keeper/relay_test.go b/modules/apps/29-fee/keeper/relay_test.go index 79410552b05..4f366b8682a 100644 --- a/modules/apps/29-fee/keeper/relay_test.go +++ b/modules/apps/29-fee/keeper/relay_test.go @@ -13,16 +13,17 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { }{ { "success", - func() {}, - true, - }, - { - "forward relayer address is successfully deleted", func() { - suite.chainB.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1), suite.chainA.SenderAccount.GetAddress().String()) + suite.chainB.GetSimApp().IBCFeeKeeper.SetRelayerAddressForAsyncAck(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1), suite.chainA.SenderAccount.GetAddress().String()) + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointA.ChannelID) }, true, }, + { + "relayer address not set for async WriteAcknowledgement", + func() {}, + false, + }, } for _, tc := range testCases { @@ -46,7 +47,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { timeoutTimestamp, ) - ack := []byte("ack") + ack := channeltypes.NewResultAcknowledgement([]byte("success")) chanCap := suite.chainB.GetChannelCapability(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) // malleate test case @@ -56,7 +57,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { if tc.expPass { suite.Require().NoError(err) - _, found := suite.chainB.GetSimApp().IBCFeeKeeper.GetForwardRelayerAddress(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1)) + _, found := suite.chainB.GetSimApp().IBCFeeKeeper.GetRelayerAddressForAsyncAck(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1)) suite.Require().False(found) } else { suite.Require().Error(err) @@ -64,3 +65,31 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { }) } } + +func (suite *KeeperTestSuite) TestWriteAcknowledgementAsyncFeeDisabled() { + // open incentivized channel + suite.coordinator.Setup(suite.path) + suite.chainB.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, "channel-0") + + // build packet + timeoutTimestamp := ^uint64(0) + packet := channeltypes.NewPacket( + []byte("packetData"), + 1, + suite.path.EndpointA.ChannelConfig.PortID, + suite.path.EndpointA.ChannelID, + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID, + clienttypes.ZeroHeight(), + timeoutTimestamp, + ) + + ack := channeltypes.NewResultAcknowledgement([]byte("success")) + chanCap := suite.chainB.GetChannelCapability(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) + + err := suite.chainB.GetSimApp().IBCFeeKeeper.WriteAcknowledgement(suite.chainB.GetContext(), chanCap, packet, ack) + suite.Require().NoError(err) + + packetAck, _ := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, 1) + suite.Require().Equal(packetAck, channeltypes.CommitAcknowledgement(ack.Acknowledgement())) +} diff --git a/modules/apps/29-fee/transfer_test.go b/modules/apps/29-fee/transfer_test.go index 863b728d45f..a07d841d07c 100644 --- a/modules/apps/29-fee/transfer_test.go +++ b/modules/apps/29-fee/transfer_test.go @@ -46,7 +46,7 @@ func (suite *FeeTestSuite) TestFeeTransfer() { // to differentiate from the chainA.SenderAccount for checking successful relay payouts relayerAddress := suite.chainB.SenderAccount.GetAddress() - msgRegister := types.NewMsgRegisterCounterpartyAddress(suite.chainB.SenderAccount.GetAddress().String(), relayerAddress.String()) + msgRegister := types.NewMsgRegisterCounterpartyAddress(suite.chainB.SenderAccount.GetAddress().String(), relayerAddress.String(), ibctesting.FirstChannelID) _, err = suite.chainB.SendMsgs(msgRegister) suite.Require().NoError(err) // message committed diff --git a/modules/apps/29-fee/types/ack.go b/modules/apps/29-fee/types/ack.go index f54214d8432..229d8e4cc3f 100644 --- a/modules/apps/29-fee/types/ack.go +++ b/modules/apps/29-fee/types/ack.go @@ -5,10 +5,11 @@ import ( ) // NewIncentivizedAcknowledgement creates a new instance of IncentivizedAcknowledgement -func NewIncentivizedAcknowledgement(relayer string, ack []byte) IncentivizedAcknowledgement { +func NewIncentivizedAcknowledgement(relayer string, ack []byte, success bool) IncentivizedAcknowledgement { return IncentivizedAcknowledgement{ Result: ack, ForwardRelayerAddress: relayer, + UnderlyingAppSuccess: success, } } @@ -16,7 +17,7 @@ func NewIncentivizedAcknowledgement(relayer string, ack []byte) IncentivizedAckn // considered successful if the forward relayer address is empty. Otherwise it is // considered a failed acknowledgement. func (ack IncentivizedAcknowledgement) Success() bool { - return ack.ForwardRelayerAddress != "" + return ack.UnderlyingAppSuccess } // Acknowledgement implements the Acknowledgement interface. It returns the diff --git a/modules/apps/29-fee/types/ack.pb.go b/modules/apps/29-fee/types/ack.pb.go index 796fa3cd139..dfcc0e1041c 100644 --- a/modules/apps/29-fee/types/ack.pb.go +++ b/modules/apps/29-fee/types/ack.pb.go @@ -28,6 +28,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type IncentivizedAcknowledgement struct { Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` ForwardRelayerAddress string `protobuf:"bytes,2,opt,name=forward_relayer_address,json=forwardRelayerAddress,proto3" json:"forward_relayer_address,omitempty" yaml:"forward_relayer_address"` + UnderlyingAppSuccess bool `protobuf:"varint,3,opt,name=underlying_app_success,json=underlyingAppSuccess,proto3" json:"underlying_app_success,omitempty" yaml:"underlying_app_successl"` } func (m *IncentivizedAcknowledgement) Reset() { *m = IncentivizedAcknowledgement{} } @@ -77,6 +78,13 @@ func (m *IncentivizedAcknowledgement) GetForwardRelayerAddress() string { return "" } +func (m *IncentivizedAcknowledgement) GetUnderlyingAppSuccess() bool { + if m != nil { + return m.UnderlyingAppSuccess + } + return false +} + func init() { proto.RegisterType((*IncentivizedAcknowledgement)(nil), "ibc.applications.fee.v1.IncentivizedAcknowledgement") } @@ -84,25 +92,27 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/ack.proto", fileDescriptor_ab2834946fb65ea4) } var fileDescriptor_ab2834946fb65ea4 = []byte{ - // 274 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd0, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0x06, 0xe0, 0x9a, 0xa1, 0x12, 0x11, 0x53, 0x04, 0xb4, 0x02, 0xc9, 0x94, 0x4c, 0x5d, 0x1a, - 0xab, 0x54, 0x0c, 0xb0, 0xb5, 0x1b, 0x13, 0x52, 0xc6, 0x2e, 0x95, 0x63, 0x5f, 0x82, 0x55, 0x27, - 0x17, 0xd9, 0x4e, 0xaa, 0xf0, 0x14, 0xf0, 0x56, 0x8c, 0x1d, 0x99, 0x10, 0x4a, 0xde, 0x80, 0x27, - 0x40, 0x69, 0x3a, 0xb0, 0xb0, 0xdd, 0xdd, 0xff, 0x2d, 0xf7, 0x7b, 0xb7, 0x2a, 0x16, 0x8c, 0x17, - 0x85, 0x56, 0x82, 0x3b, 0x85, 0xb9, 0x65, 0x09, 0x00, 0xab, 0xe6, 0x8c, 0x8b, 0x6d, 0x58, 0x18, - 0x74, 0xe8, 0x8f, 0x54, 0x2c, 0xc2, 0xbf, 0x24, 0x4c, 0x00, 0xc2, 0x6a, 0x7e, 0x75, 0x9e, 0x62, - 0x8a, 0x07, 0xc3, 0xba, 0xa9, 0xe7, 0xc1, 0x3b, 0xf1, 0xae, 0x9f, 0x72, 0x01, 0xb9, 0x53, 0x95, - 0x7a, 0x05, 0xb9, 0x14, 0xdb, 0x1c, 0x77, 0x1a, 0x64, 0x0a, 0x19, 0xe4, 0xce, 0xbf, 0xf4, 0x86, - 0x06, 0x6c, 0xa9, 0xdd, 0x98, 0x4c, 0xc8, 0xf4, 0x2c, 0x3a, 0x6e, 0xfe, 0xda, 0x1b, 0x25, 0x68, - 0x76, 0xdc, 0xc8, 0x8d, 0x01, 0xcd, 0x6b, 0x30, 0x1b, 0x2e, 0xa5, 0x01, 0x6b, 0xc7, 0x27, 0x13, - 0x32, 0x3d, 0x5d, 0x05, 0x3f, 0x5f, 0x37, 0xb4, 0xe6, 0x99, 0x7e, 0x0c, 0xfe, 0x81, 0x41, 0x74, - 0x71, 0x4c, 0xa2, 0x3e, 0x58, 0xf6, 0xf7, 0xd5, 0xf3, 0x47, 0x43, 0xc9, 0xbe, 0xa1, 0xe4, 0xbb, - 0xa1, 0xe4, 0xad, 0xa5, 0x83, 0x7d, 0x4b, 0x07, 0x9f, 0x2d, 0x1d, 0xac, 0xef, 0x53, 0xe5, 0x5e, - 0xca, 0x38, 0x14, 0x98, 0x31, 0x81, 0x36, 0x43, 0xcb, 0x54, 0x2c, 0x66, 0x29, 0xb2, 0x6a, 0xc1, - 0x32, 0x94, 0xa5, 0x06, 0xdb, 0xf5, 0x63, 0xd9, 0xdd, 0xc3, 0xac, 0xab, 0xc6, 0xd5, 0x05, 0xd8, - 0x78, 0x78, 0xf8, 0x75, 0xf1, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x50, 0xc6, 0xd5, 0xaa, 0x3f, 0x01, - 0x00, 0x00, + // 315 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0xeb, 0xff, 0x97, 0x2a, 0x88, 0x98, 0xa2, 0xd2, 0x56, 0x20, 0x85, 0x92, 0xa9, 0x4b, + 0x63, 0x95, 0x8a, 0x01, 0xb6, 0x76, 0x63, 0x42, 0x0a, 0x0b, 0xea, 0x12, 0x39, 0xf6, 0x6d, 0xb0, + 0xea, 0xd8, 0x96, 0xed, 0xa4, 0x0a, 0x4f, 0xc1, 0x63, 0x31, 0x76, 0x64, 0x42, 0xa8, 0x1d, 0xd9, + 0x78, 0x02, 0x94, 0xa6, 0x12, 0x1d, 0x60, 0xbb, 0xf7, 0x9c, 0x4f, 0x67, 0xf8, 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x5f, 0x67, 0xdc, 0x3d, 0x15, 0x69, 0x44, 0x55, 0x8e, 0xa9, 0xb2, 0xb9, + 0xb2, 0x98, 0xa7, 0x74, 0x94, 0x29, 0x5c, 0x4e, 0x70, 0xae, 0x58, 0x21, 0xc0, 0xd6, 0xe6, 0x2d, + 0xbe, 0xba, 0x19, 0xd5, 0xd2, 0x5d, 0xa5, 0xc1, 0xa6, 0xed, 0x9d, 0xc5, 0xc9, 0x77, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x2e, 0x38, 0x5f, 0x80, 0x99, 0x01, 0x00, 0x00, } func (m *IncentivizedAcknowledgement) Marshal() (dAtA []byte, err error) { @@ -125,6 +135,16 @@ func (m *IncentivizedAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l + if m.UnderlyingAppSuccess { + i-- + if m.UnderlyingAppSuccess { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } if len(m.ForwardRelayerAddress) > 0 { i -= len(m.ForwardRelayerAddress) copy(dAtA[i:], m.ForwardRelayerAddress) @@ -167,6 +187,9 @@ func (m *IncentivizedAcknowledgement) Size() (n int) { if l > 0 { n += 1 + l + sovAck(uint64(l)) } + if m.UnderlyingAppSuccess { + n += 2 + } return n } @@ -271,6 +294,26 @@ func (m *IncentivizedAcknowledgement) Unmarshal(dAtA []byte) error { } m.ForwardRelayerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UnderlyingAppSuccess", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAck + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UnderlyingAppSuccess = bool(v != 0) default: iNdEx = preIndex skippy, err := skipAck(dAtA[iNdEx:]) diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go index 55ce843e92c..75fdd436c91 100644 --- a/modules/apps/29-fee/types/errors.go +++ b/modules/apps/29-fee/types/errors.go @@ -14,4 +14,5 @@ var ( ErrCounterpartyAddressEmpty = sdkerrors.Register(ModuleName, 7, "counterparty address must not be empty") ErrForwardRelayerAddressNotFound = sdkerrors.Register(ModuleName, 8, "forward relayer address not found") ErrFeeNotEnabled = sdkerrors.Register(ModuleName, 9, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled") + ErrRelayerNotFoundForAsyncAck = sdkerrors.Register(ModuleName, 10, "relayer address must be stored for async WriteAcknowledgement") ) diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index e3e41810f96..ad74e0b2d86 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -268,7 +268,7 @@ func (m *PacketFees) GetPacketFees() []PacketFee { return nil } -// IdentifiedPacketFees contains a PacketFree and associated PacketId +// IdentifiedPacketFees contains a list of type PacketFee and associated PacketId type IdentifiedPacketFees struct { PacketId types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` PacketFees []PacketFee `protobuf:"bytes,2,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index bdd5c23a967..be9299fcd94 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -1,6 +1,8 @@ package types import ( + "strings" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -8,11 +10,12 @@ import ( ) // NewGenesisState creates a 29-fee GenesisState instance. -func NewGenesisState(identifiedFees []IdentifiedPacketFees, feeEnabledChannels []FeeEnabledChannel, registeredRelayers []RegisteredRelayerAddress) *GenesisState { +func NewGenesisState(identifiedFees []IdentifiedPacketFees, feeEnabledChannels []FeeEnabledChannel, registeredRelayers []RegisteredRelayerAddress, forwardRelayers []ForwardRelayerAddress) *GenesisState { return &GenesisState{ IdentifiedFees: identifiedFees, FeeEnabledChannels: feeEnabledChannels, RegisteredRelayers: registeredRelayers, + ForwardRelayers: forwardRelayers, } } @@ -20,6 +23,7 @@ func NewGenesisState(identifiedFees []IdentifiedPacketFees, feeEnabledChannels [ func DefaultGenesisState() *GenesisState { return &GenesisState{ IdentifiedFees: []IdentifiedPacketFees{}, + ForwardRelayers: []ForwardRelayerAddress{}, FeeEnabledChannels: []FeeEnabledChannel{}, RegisteredRelayers: []RegisteredRelayerAddress{}, } @@ -53,15 +57,25 @@ func (gs GenesisState) Validate() error { // Validate RegisteredRelayers for _, rel := range gs.RegisteredRelayers { - _, err := sdk.AccAddressFromBech32(rel.Address) - if err != nil { + if _, err := sdk.AccAddressFromBech32(rel.Address); err != nil { return sdkerrors.Wrap(err, "failed to convert source relayer address into sdk.AccAddress") } - if rel.CounterpartyAddress == "" { + if strings.TrimSpace(rel.CounterpartyAddress) == "" { return ErrCounterpartyAddressEmpty } } + // Validate ForwardRelayers + for _, rel := range gs.ForwardRelayers { + if _, err := sdk.AccAddressFromBech32(rel.Address); err != nil { + return sdkerrors.Wrap(err, "failed to convert forward relayer address into sdk.AccAddress") + } + + if err := rel.PacketId.Validate(); err != nil { + return err + } + } + return nil } diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index bf5a49edf4d..84a946a6d43 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -150,6 +150,7 @@ func (m *FeeEnabledChannel) GetChannelId() string { type RegisteredRelayerAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } func (m *RegisteredRelayerAddress) Reset() { *m = RegisteredRelayerAddress{} } @@ -199,6 +200,13 @@ func (m *RegisteredRelayerAddress) GetCounterpartyAddress() string { return "" } +func (m *RegisteredRelayerAddress) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements type ForwardRelayerAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` @@ -264,43 +272,44 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 571 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x4d, 0x6f, 0xd4, 0x30, - 0x14, 0xdc, 0xb4, 0x55, 0x4b, 0x5d, 0xd4, 0x0f, 0xb7, 0xa5, 0x51, 0x11, 0xd9, 0x62, 0x84, 0x54, - 0x81, 0x9a, 0x68, 0x5b, 0x38, 0xc0, 0x8d, 0x45, 0x14, 0xed, 0x09, 0x64, 0x38, 0x71, 0x89, 0xf2, - 0xf1, 0x92, 0x5a, 0x64, 0xe3, 0xc8, 0x76, 0x83, 0x96, 0x1b, 0x17, 0xe0, 0x06, 0x3f, 0xab, 0xc7, - 0x1e, 0x39, 0xad, 0x50, 0xfb, 0x0f, 0xfa, 0x0b, 0x50, 0x62, 0xa7, 0x5d, 0x96, 0x0d, 0xb7, 0x17, - 0x7b, 0xe6, 0xcd, 0x64, 0xec, 0x67, 0xf4, 0x90, 0x85, 0x91, 0x17, 0x14, 0x45, 0xc6, 0xa2, 0x40, - 0x31, 0x9e, 0x4b, 0x2f, 0x01, 0xf0, 0xca, 0x9e, 0x97, 0x42, 0x0e, 0x92, 0x49, 0xb7, 0x10, 0x5c, - 0x71, 0xbc, 0xc3, 0xc2, 0xc8, 0x9d, 0x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6f, 0x15, 0x0d, 0xe6, 0xcd, 0xd9, 0x85, 0x63, 0x9d, 0x5f, 0x38, 0xd6, - 0xef, 0x0b, 0xc7, 0xfa, 0x79, 0xe9, 0x74, 0xce, 0x2f, 0x9d, 0xce, 0xaf, 0x4b, 0xa7, 0xf3, 0xe1, - 0x69, 0xca, 0xd4, 0xc9, 0x69, 0xe8, 0x46, 0x7c, 0xe8, 0x45, 0x5c, 0x0e, 0xb9, 0xf4, 0x58, 0x18, - 0x1d, 0xa4, 0xdc, 0x2b, 0x8f, 0xbc, 0x21, 0x8f, 0x4f, 0x33, 0x90, 0xd5, 0xf3, 0x20, 0xbd, 0xc3, - 0x67, 0x07, 0xd5, 0xcb, 0xa0, 0x46, 0x05, 0xc8, 0x70, 0xb1, 0x1e, 0xfb, 0xa3, 0x3f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xf7, 0xbe, 0x68, 0x08, 0x94, 0x04, 0x00, 0x00, + // 579 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6f, 0xd4, 0x30, + 0x14, 0xdc, 0xb4, 0x55, 0x4b, 0x5d, 0xd4, 0x0f, 0xb7, 0xa5, 0x51, 0x11, 0x49, 0x31, 0x42, 0xaa, + 0x40, 0x4d, 0xb4, 0x2d, 0x1c, 0xe0, 0xc6, 0x22, 0x8a, 0xf6, 0x04, 0x32, 0x9c, 0xb8, 0x44, 0xf9, + 0x78, 0x49, 0x2d, 0xb2, 0x71, 0x64, 0xbb, 0x41, 0xcb, 0x8d, 0x0b, 0x1c, 0xe1, 0x17, 0x71, 0xee, + 0xb1, 0x47, 0x4e, 0x2b, 0xd4, 0xfe, 0x83, 0xfe, 0x02, 0x94, 0x38, 0xe9, 0x6e, 0x97, 0x0d, 0xe2, + 0xf6, 0x62, 0xcf, 0xbc, 0x19, 0x8f, 0xf3, 0x8c, 0x1e, 0xb2, 0x20,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, 0xff, 0x1e, 0x2d, 0xe7, 0xd5, 0xcc, 0x34, + 0x49, 0xad, 0x1c, 0xde, 0xab, 0x6e, 0xb8, 0x9c, 0x5a, 0xa7, 0x19, 0xd5, 0xa2, 0xeb, 0xe8, 0xc9, + 0xea, 0x47, 0x3d, 0xb3, 0xbe, 0xd0, 0xf5, 0x3a, 0xfc, 0x86, 0x4d, 0xe8, 0xad, 0xbc, 0xc1, 0xbc, + 0x39, 0xbb, 0xb0, 0x8c, 0xf3, 0x0b, 0xcb, 0xf8, 0x7d, 0x61, 0x19, 0x3f, 0x2e, 0xad, 0xce, 0xf9, + 0xa5, 0xd5, 0xf9, 0x75, 0x69, 0x75, 0x3e, 0x3c, 0x4d, 0x98, 0x3a, 0x39, 0x0d, 0x9c, 0x90, 0x0f, + 0xdc, 0x90, 0xcb, 0x01, 0x97, 0x2e, 0x0b, 0xc2, 0x83, 0x84, 0xbb, 0xc5, 0x91, 0x3b, 0xe0, 0xd1, + 0x69, 0x0a, 0xb2, 0x7c, 0x54, 0xa4, 0x7b, 0xf8, 0xec, 0xa0, 0x7c, 0x4f, 0xd4, 0x30, 0x07, 0x19, + 0x2c, 0x56, 0x8f, 0xc5, 0xd1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x33, 0x0f, 0x78, 0xca, + 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -439,6 +448,13 @@ func (m *RegisteredRelayerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x1a + } if len(m.CounterpartyAddress) > 0 { i -= len(m.CounterpartyAddress) copy(dAtA[i:], m.CounterpartyAddress) @@ -571,6 +587,10 @@ func (m *RegisteredRelayerAddress) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -988,6 +1008,38 @@ func (m *RegisteredRelayerAddress) Unmarshal(dAtA []byte) error { } m.CounterpartyAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index e4cad279bbd..75c754cc7c9 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -23,14 +23,16 @@ var ( func TestValidateGenesis(t *testing.T) { var ( - packetId channeltypes.PacketId - fee types.Fee - refundAcc string - sender string - counterparty string - portID string - channelID string - seq uint64 + packetId channeltypes.PacketId + fee types.Fee + refundAcc string + sender string + forwardAddr string + counterparty string + portID string + channelID string + packetChannelID string + seq uint64 ) testCases := []struct { @@ -118,7 +120,21 @@ func TestValidateGenesis(t *testing.T) { { "invalid RegisteredRelayers: invalid counterparty", func() { - counterparty = "" + counterparty = " " + }, + false, + }, + { + "invalid ForwardRelayerAddress: invalid forwardAddr", + func() { + forwardAddr = "" + }, + false, + }, + { + "invalid ForwardRelayerAddress: invalid packet", + func() { + packetChannelID = "1" }, false, }, @@ -127,6 +143,7 @@ func TestValidateGenesis(t *testing.T) { for _, tc := range testCases { portID = transfertypes.PortID channelID = ibctesting.FirstChannelID + packetChannelID = ibctesting.FirstChannelID seq = uint64(1) // build PacketId & Fee @@ -146,6 +163,7 @@ func TestValidateGenesis(t *testing.T) { // relayer addresses sender = addr1 counterparty = addr2 + forwardAddr = addr2 tc.malleate() @@ -174,6 +192,12 @@ func TestValidateGenesis(t *testing.T) { CounterpartyAddress: counterparty, }, }, + ForwardRelayers: []types.ForwardRelayerAddress{ + { + Address: forwardAddr, + PacketId: channeltypes.NewPacketId(packetChannelID, portID, 1), + }, + }, } err := genState.Validate() diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index ec5132fab1a..d65d8efcbef 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -24,8 +24,8 @@ const ( // FeeEnabledPrefix is the key prefix for storing fee enabled flag FeeEnabledKeyPrefix = "feeEnabled" - // RelayerAddressKeyPrefix is the key prefix for relayer address mapping - RelayerAddressKeyPrefix = "relayerAddress" + // CounterpartyRelayerAddressKeyPrefix is the key prefix for relayer address mapping + CounterpartyRelayerAddressKeyPrefix = "relayerAddress" // FeeInEscrowPrefix is the key prefix for fee in escrow mapping FeeInEscrowPrefix = "feeInEscrow" @@ -47,9 +47,9 @@ func FeeEnabledKey(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", FeeEnabledKeyPrefix, portID, channelID)) } -// KeyRelayerAddress returns the key for relayer address -> counteryparty address mapping -func KeyRelayerAddress(address string) []byte { - return []byte(fmt.Sprintf("%s/%s", RelayerAddressKeyPrefix, address)) +// KeyCounterpartyRelayer returns the key for relayer address -> counteryparty address mapping +func KeyCounterpartyRelayer(address, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", CounterpartyRelayerAddressKeyPrefix, address, channelID)) } // KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index fbe2c2bbdde..a49532b753b 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -9,11 +9,12 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" ) -func TestKeyRelayerAddress(t *testing.T) { +func TestKeyCounterpartyRelayer(t *testing.T) { var ( relayerAddress = "relayer_address" + channelID = "channel-0" ) - key := types.KeyRelayerAddress(relayerAddress) - require.Equal(t, string(key), fmt.Sprintf("%s/relayer_address", types.RelayerAddressKeyPrefix)) + key := types.KeyCounterpartyRelayer(relayerAddress, channelID) + require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s", types.CounterpartyRelayerAddressKeyPrefix, relayerAddress, channelID)) } diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index f3abe737472..50e6584e26b 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -17,10 +17,11 @@ const ( ) // NewMsgRegisterCounterpartyAddress creates a new instance of MsgRegisterCounterpartyAddress -func NewMsgRegisterCounterpartyAddress(address, counterpartyAddress string) *MsgRegisterCounterpartyAddress { +func NewMsgRegisterCounterpartyAddress(address, counterpartyAddress, channelID string) *MsgRegisterCounterpartyAddress { return &MsgRegisterCounterpartyAddress{ Address: address, CounterpartyAddress: counterpartyAddress, + ChannelId: channelID, } } @@ -35,6 +36,11 @@ func (msg MsgRegisterCounterpartyAddress) ValidateBasic() error { return ErrCounterpartyAddressEmpty } + // validate channelId + if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + return err + } + return nil } diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 57b38a07086..c4ee1a477f1 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -5,18 +5,20 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/secp256k1" ) var ( - validChannelID = "channel-1" - validPortID = "validPortId" - invalidID = "this identifier is too long to be used as a valid identifier" - validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} - validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - invalidAddr = "invalid_address" + validChannelID = "channel-1" + invalidChannelID = "ch-1" + validPortID = "validPortId" + invalidID = "this identifier is too long to be used as a valid identifier" + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} + validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() + invalidAddr = "invalid_address" ) // TestMsgTransferValidation tests ValidateBasic for MsgTransfer @@ -26,10 +28,11 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { msg *MsgRegisterCounterpartyAddress expPass bool }{ - {"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr), true}, - {"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr), false}, - {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, ""), false}, - {"invalid counterparty address: whitespaced empty string", NewMsgRegisterCounterpartyAddress(validAddr, " "), false}, + {"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr, validChannelID), true}, + {"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr, validChannelID), false}, + {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, "", validChannelID), false}, + {"invalid counterparty address: whitespaced empty string", NewMsgRegisterCounterpartyAddress(validAddr, " ", validChannelID), false}, + {"invalid channelID", NewMsgRegisterCounterpartyAddress(validAddr, validAddr, invalidChannelID), false}, } for i, tc := range testCases { @@ -46,7 +49,7 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { func TestRegisterCountepartyAddressGetSigners(t *testing.T) { addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) // build message - msg := NewMsgRegisterCounterpartyAddress(addr.String(), "counterparty") + msg := NewMsgRegisterCounterpartyAddress(addr.String(), "counterparty", validChannelID) // GetSigners res := msg.GetSigners() diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 624c6d8279a..a7f8e1d3bee 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -32,6 +32,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgRegisterCounterpartyAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } func (m *MsgRegisterCounterpartyAddress) Reset() { *m = MsgRegisterCounterpartyAddress{} } @@ -280,44 +281,45 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 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, 0x09, 0x25, 0x98, 0xc8, 0x4e, 0xad, 0xaa, - 0xca, 0xa1, 0xb1, 0x4b, 0x28, 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0x7c, 0xb5, 0xd0, 0xc5, 0xf2, 0x38, 0x6a, 0x2c, 0x59, 0x7a, 0x11, 0xb9, 0x3a, 0xe8, - 0xea, 0xd9, 0xa4, 0xe5, 0xb9, 0xc2, 0x86, 0xbd, 0x43, 0x66, 0x43, 0x27, 0xda, 0xd0, 0x50, 0x76, - 0x5e, 0xa9, 0xa3, 0x5e, 0x8a, 0x57, 0x29, 0x94, 0xaa, 0x70, 0x4f, 0xf9, 0x26, 0xa3, 0x83, 0x65, - 0x33, 0xfc, 0x76, 0x61, 0xe9, 0xcb, 0x47, 0x4c, 0x3d, 0xfd, 0xc7, 0xc0, 0x51, 0x85, 0xca, 0x27, - 0xb4, 0x39, 0x35, 0x97, 0xf9, 0x65, 0x82, 0x93, 0xa4, 0xfa, 0xfa, 0xb1, 0xe4, 0x38, 0x57, 0x88, - 0xb6, 0x67, 0xff, 0x6a, 0xe1, 0xb1, 0x32, 0x31, 0xae, 0x1e, 0xff, 0x15, 0x3e, 0x4a, 0x5d, 0xfa, - 0x70, 0xdb, 0xd3, 0xe4, 0xbb, 0x9e, 0x26, 0xff, 0xea, 0x69, 0xf2, 0x75, 0x5f, 0x93, 0xee, 0xfa, - 0x9a, 0xf4, 0xb3, 0xaf, 0x49, 0x1f, 0x8f, 0x3d, 0x22, 0x2e, 0xdb, 0x75, 0x13, 0xd3, 0x96, 0x85, - 0x29, 0x6f, 0x51, 0x6e, 0x91, 0x3a, 0x2e, 0x78, 0xd4, 0xea, 0x1c, 0x59, 0x2d, 0xea, 0xb6, 0x9b, - 0xc0, 0xa3, 0x25, 0xc5, 0xad, 0xe2, 0xbb, 0x42, 0xb4, 0x9f, 0x44, 0x18, 0x00, 0xaf, 0xaf, 0xc5, - 0xfb, 0xe9, 0xe8, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x81, 0xea, 0x8a, 0x9a, 0x15, 0x05, 0x00, - 0x00, + // 594 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00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97, 0x9a, 0xdd, 0x03, 0xb3, 0x4d, 0x9d, 0x4e, + 0x0b, 0x58, 0xfc, 0xb5, 0x31, 0x73, 0xff, 0xed, 0x6e, 0xfc, 0xab, 0xf1, 0xd0, 0x07, 0xd6, 0x58, + 0x48, 0x7e, 0xb5, 0x83, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x27, 0xb3, 0x4f, 0x4b, 0x05, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -514,6 +516,13 @@ func (m *MsgRegisterCounterpartyAddress) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x1a + } if len(m.CounterpartyAddress) > 0 { i -= len(m.CounterpartyAddress) copy(dAtA[i:], m.CounterpartyAddress) @@ -721,6 +730,10 @@ func (m *MsgRegisterCounterpartyAddress) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -890,6 +903,38 @@ func (m *MsgRegisterCounterpartyAddress) Unmarshal(dAtA []byte) error { } m.CounterpartyAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto index b978454892d..6a77e4fce45 100644 --- a/proto/ibc/applications/fee/v1/ack.proto +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -11,4 +11,5 @@ import "gogoproto/gogo.proto"; message IncentivizedAcknowledgement { bytes result = 1; string forward_relayer_address = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""]; + bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; } diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index 09fdd6d1a7d..4d39ad3786c 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -54,7 +54,7 @@ message PacketFees { repeated PacketFee packet_fees = 1 [(gogoproto.moretags) = "yaml:\"packet_fees\"", (gogoproto.nullable) = false]; } -// IdentifiedPacketFees contains a PacketFree and associated PacketId +// IdentifiedPacketFees contains a list of type PacketFee and associated PacketId message IdentifiedPacketFees { ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 72887c3588e..0e76fa3a168 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -30,6 +30,7 @@ message FeeEnabledChannel { message RegisteredRelayerAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 900764f9343..8209e14d531 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -32,6 +32,7 @@ message MsgRegisterCounterpartyAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type