From 0cfa0e970446766510ab7167375fe15b9aedd8b3 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 2 Jul 2024 13:44:10 +0300 Subject: [PATCH] chore: move back to nullable forwarding. (#6733) * chore: move back to nullable forwarding. * chore: use proto generated getters. --- e2e/tests/transfer/authz_test.go | 8 +- e2e/tests/transfer/incentivized_test.go | 5 +- e2e/tests/transfer/upgradesv1_test.go | 2 +- e2e/tests/transfer/upgradesv2_test.go | 2 +- e2e/tests/upgrades/upgrade_test.go | 3 +- e2e/testsuite/testsuite.go | 2 +- e2e/testsuite/tx.go | 3 +- .../host/keeper/relay_test.go | 4 +- modules/apps/29-fee/keeper/events_test.go | 2 +- modules/apps/29-fee/transfer_test.go | 4 +- modules/apps/callbacks/ibc_middleware_test.go | 2 +- modules/apps/callbacks/replay_test.go | 2 +- modules/apps/callbacks/transfer_test.go | 4 +- modules/apps/transfer/client/cli/tx.go | 10 +- modules/apps/transfer/ibc_module_test.go | 2 +- modules/apps/transfer/keeper/forwarding.go | 2 +- .../apps/transfer/keeper/invariants_test.go | 2 +- .../apps/transfer/keeper/mbt_relay_test.go | 2 +- modules/apps/transfer/keeper/msg_server.go | 4 +- .../apps/transfer/keeper/msg_server_test.go | 4 +- .../transfer/keeper/relay_forwarding_test.go | 6 +- modules/apps/transfer/keeper/relay_test.go | 4 +- modules/apps/transfer/transfer_test.go | 6 +- modules/apps/transfer/types/forwarding.go | 6 +- .../apps/transfer/types/forwarding_test.go | 2 +- modules/apps/transfer/types/msgs.go | 54 ++++++--- modules/apps/transfer/types/msgs_test.go | 10 +- .../transfer/types/transfer_authorization.go | 6 +- .../types/transfer_authorization_test.go | 2 +- modules/apps/transfer/types/tx.pb.go | 111 ++++++++++-------- proto/ibc/applications/transfer/v1/tx.proto | 2 +- testing/solomachine.go | 2 +- 32 files changed, 152 insertions(+), 128 deletions(-) diff --git a/e2e/tests/transfer/authz_test.go b/e2e/tests/transfer/authz_test.go index 2a1d9b7c1fc..24ea055d6bd 100644 --- a/e2e/tests/transfer/authz_test.go +++ b/e2e/tests/transfer/authz_test.go @@ -131,7 +131,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) @@ -192,7 +192,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) @@ -276,7 +276,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) @@ -337,7 +337,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) diff --git a/e2e/tests/transfer/incentivized_test.go b/e2e/tests/transfer/incentivized_test.go index 350d0ccaa37..7b42a6b509d 100644 --- a/e2e/tests/transfer/incentivized_test.go +++ b/e2e/tests/transfer/incentivized_test.go @@ -20,7 +20,6 @@ import ( "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) @@ -217,7 +216,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou s.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgTransfer) // this message should be successful, as receiver account is not validated on the sending chain. @@ -356,7 +355,7 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender s.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer) s.AssertTxSuccess(resp) diff --git a/e2e/tests/transfer/upgradesv1_test.go b/e2e/tests/transfer/upgradesv1_test.go index 31bcaf7faa2..0227031d62f 100644 --- a/e2e/tests/transfer/upgradesv1_test.go +++ b/e2e/tests/transfer/upgradesv1_test.go @@ -306,7 +306,7 @@ func (s *TransferChannelUpgradesV1TestSuite) TestChannelUpgrade_WithFeeMiddlewar s.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer) s.AssertTxSuccess(resp) diff --git a/e2e/tests/transfer/upgradesv2_test.go b/e2e/tests/transfer/upgradesv2_test.go index 96033742f64..88854f7deac 100644 --- a/e2e/tests/transfer/upgradesv2_test.go +++ b/e2e/tests/transfer/upgradesv2_test.go @@ -213,7 +213,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer) s.AssertTxSuccess(resp) diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index bbfa2567915..6e194a138cd 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -29,7 +29,6 @@ import ( "github.com/cosmos/ibc-go/e2e/testsuite/query" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" v7migrations "github.com/cosmos/ibc-go/v8/modules/core/02-client/migrations/v7" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" @@ -979,7 +978,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.GetTimeoutHeight(ctx, chainB), 0, "", - transfertypes.Forwarding{}, + nil, ) resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer) s.AssertTxSuccess(resp) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index d877e3c8084..7b1d5ff4c7b 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -706,7 +706,7 @@ func getValidatorsAndFullNodes(chainIdx int) (int, int) { } // GetMsgTransfer returns a MsgTransfer that is constructed based on the channel version -func GetMsgTransfer(portID, channelID, version string, tokens sdk.Coins, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string, forwarding transfertypes.Forwarding) *transfertypes.MsgTransfer { +func GetMsgTransfer(portID, channelID, version string, tokens sdk.Coins, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string, forwarding *transfertypes.Forwarding) *transfertypes.MsgTransfer { if len(tokens) == 0 { panic(errors.New("tokens cannot be empty")) } diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index 535870b3c85..825867b8195 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -30,7 +30,6 @@ import ( "github.com/cosmos/ibc-go/e2e/testsuite/sanitize" "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) @@ -300,7 +299,7 @@ func (s *E2ETestSuite) Transfer(ctx context.Context, chain ibc.Chain, user ibc.W transferVersion = version.AppVersion } - msg := GetMsgTransfer(portID, channelID, transferVersion, tokens, sender, receiver, timeoutHeight, timeoutTimestamp, memo, transfertypes.Forwarding{}) + msg := GetMsgTransfer(portID, channelID, transferVersion, tokens, sender, receiver, timeoutHeight, timeoutTimestamp, memo, nil) return s.BroadcastMessages(ctx, chain, user, msg) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 719ae8047f5..a99b7e957c0 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -353,7 +353,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { suite.chainB.GetTimeoutHeight(), 0, "", - transfertypes.Forwarding{}, + nil, ) data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}, encoding) @@ -389,7 +389,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { suite.chainB.GetTimeoutHeight(), 0, "", - transfertypes.Forwarding{}, + nil, ) data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}, encoding) diff --git a/modules/apps/29-fee/keeper/events_test.go b/modules/apps/29-fee/keeper/events_test.go index e480cebcf28..b7f2142157a 100644 --- a/modules/apps/29-fee/keeper/events_test.go +++ b/modules/apps/29-fee/keeper/events_test.go @@ -113,7 +113,7 @@ func (suite *KeeperTestSuite) TestDistributeFeeEvent() { path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(ibctesting.TestCoin), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, "", - transfertypes.Forwarding{}, + nil, ) res, err := suite.chainA.SendMsgs(msgPayPacketFee, msgTransfer) diff --git a/modules/apps/29-fee/transfer_test.go b/modules/apps/29-fee/transfer_test.go index 23e6e1e80b0..f935262e4af 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() { msgs := []sdk.Msg{ types.NewMsgPayPacketFee(fee, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, suite.chainA.SenderAccount.GetAddress().String(), nil), - transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, tc.coinsToTransfer, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, "", transfertypes.Forwarding{}), + transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, tc.coinsToTransfer, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, "", nil), } res, err := suite.chainA.SendMsgs(msgs...) @@ -156,7 +156,7 @@ func (suite *FeeTestSuite) TestTransferFeeUpgrade() { fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) msgs := []sdk.Msg{ types.NewMsgPayPacketFee(fee, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, suite.chainA.SenderAccount.GetAddress().String(), nil), - transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(ibctesting.TestCoin), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, "", transfertypes.Forwarding{}), + transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(ibctesting.TestCoin), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, "", nil), } res, err := suite.chainA.SendMsgs(msgs...) diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index d0d7505d514..889e852938f 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -496,7 +496,7 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { sdk.NewCoins(ibctesting.TestCoin), s.chainA.SenderAccount.GetAddress().String(), s.chainB.SenderAccount.GetAddress().String(), clienttypes.ZeroHeight(), timeoutTimestamp, fmt.Sprintf(`{"src_callback": {"address":"%s", "gas_limit":"%d"}}`, ibctesting.TestAccAddress, userGasLimit), // set user gas limit above panic level in mock contract keeper - transfertypes.Forwarding{}, + nil, ) res, err := s.chainA.SendMsgs(msg) diff --git a/modules/apps/callbacks/replay_test.go b/modules/apps/callbacks/replay_test.go index 3a31b1a0af5..ee62bdca182 100644 --- a/modules/apps/callbacks/replay_test.go +++ b/modules/apps/callbacks/replay_test.go @@ -330,7 +330,7 @@ func (s *CallbacksTestSuite) ExecuteFailedTransfer(memo string) { s.chainA.SenderAccount.GetAddress().String(), s.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, memo, - transfertypes.Forwarding{}, + nil, ) res, err := s.chainA.SendMsgs(msg) diff --git a/modules/apps/callbacks/transfer_test.go b/modules/apps/callbacks/transfer_test.go index dead34dbd71..5556ca2a3a2 100644 --- a/modules/apps/callbacks/transfer_test.go +++ b/modules/apps/callbacks/transfer_test.go @@ -193,7 +193,7 @@ func (s *CallbacksTestSuite) ExecuteTransfer(memo string) { s.chainA.SenderAccount.GetAddress().String(), s.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, memo, - transfertypes.Forwarding{}, + nil, ) res, err := s.chainA.SendMsgs(msg) @@ -228,7 +228,7 @@ func (s *CallbacksTestSuite) ExecuteTransferTimeout(memo string) { s.chainA.SenderAccount.GetAddress().String(), s.chainB.SenderAccount.GetAddress().String(), timeoutHeight, timeoutTimestamp, memo, - transfertypes.Forwarding{}, + nil, ) res, err := s.chainA.SendMsgs(msg) diff --git a/modules/apps/transfer/client/cli/tx.go b/modules/apps/transfer/client/cli/tx.go index 2a42012a082..64da770cf7e 100644 --- a/modules/apps/transfer/client/cli/tx.go +++ b/modules/apps/transfer/client/cli/tx.go @@ -143,22 +143,22 @@ to first unwind IBC tokens to their native chain and then forward them to the fi // parseForwarding parses the forwarding flag into a Forwarding object or nil if the flag is not specified. If the flag cannot // be parsed or the hops aren't in the portID/channelID format an error is returned. -func parseForwarding(cmd *cobra.Command) (types.Forwarding, error) { +func parseForwarding(cmd *cobra.Command) (*types.Forwarding, error) { var hops []types.Hop forwardingString, err := cmd.Flags().GetString(flagForwarding) if err != nil { - return types.Forwarding{}, err + return nil, err } if strings.TrimSpace(forwardingString) == "" { - return types.Forwarding{}, nil + return nil, nil } pairs := strings.Split(forwardingString, ",") for _, pair := range pairs { pairSplit := strings.Split(pair, "/") if len(pairSplit) != 2 { - return types.Forwarding{}, fmt.Errorf("expected a portID/channelID pair, found %s", pair) + return nil, fmt.Errorf("expected a portID/channelID pair, found %s", pair) } hop := types.NewHop(pairSplit[0], pairSplit[1]) @@ -167,7 +167,7 @@ func parseForwarding(cmd *cobra.Command) (types.Forwarding, error) { unwind, err := cmd.Flags().GetBool(flagUnwind) if err != nil { - return types.Forwarding{}, err + return nil, err } return types.NewForwarding(unwind, hops...), nil diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 20b3c3866e9..b3f4dfd08e2 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -490,7 +490,7 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { timeoutHeight, 0, "", - types.Forwarding{}, + nil, ) res, err := suite.chainA.SendMsgs(msg) suite.Require().NoError(err) // message committed diff --git a/modules/apps/transfer/keeper/forwarding.go b/modules/apps/transfer/keeper/forwarding.go index 346f3b56423..29f00714f3e 100644 --- a/modules/apps/transfer/keeper/forwarding.go +++ b/modules/apps/transfer/keeper/forwarding.go @@ -14,7 +14,7 @@ import ( // forwardPacket forwards a fungible FungibleTokenPacketDataV2 to the next hop in the forwarding path. func (k Keeper) forwardPacket(ctx sdk.Context, data types.FungibleTokenPacketDataV2, packet channeltypes.Packet, receivedCoins sdk.Coins) error { - var nextForwardingPath types.Forwarding + var nextForwardingPath *types.Forwarding if len(data.Forwarding.Hops) > 1 { // remove the first hop since we are going to send to the first hop now and we want to propagate the rest of the hops to the receiver nextForwardingPath = types.NewForwarding(false, data.Forwarding.Hops[1:]...) diff --git a/modules/apps/transfer/keeper/invariants_test.go b/modules/apps/transfer/keeper/invariants_test.go index 61474cfafbc..28b6a33d867 100644 --- a/modules/apps/transfer/keeper/invariants_test.go +++ b/modules/apps/transfer/keeper/invariants_test.go @@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) TestTotalEscrowPerDenomInvariant() { suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.GetTimeoutHeight(), 0, "", - types.Forwarding{}, + nil, ) res, err := suite.chainA.SendMsgs(msg) diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index 33eeab9bee7..82a339c3237 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -358,7 +358,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { tc.packet.Data.Receiver, suite.chainA.GetTimeoutHeight(), 0, // only use timeout height "", - types.Forwarding{}, + nil, ) _, err = suite.chainB.GetSimApp().TransferKeeper.Transfer(suite.chainB.GetContext(), msg) diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index 46e97ba1901..246e67ed936 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -36,7 +36,7 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", sender) } - if msg.Forwarding.Unwind { + if msg.Forwarding.GetUnwind() { msg, err = k.unwindHops(ctx, msg) if err != nil { return nil, err @@ -45,7 +45,7 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. sequence, err := k.sendTransfer( ctx, msg.SourcePort, msg.SourceChannel, coins, sender, msg.Receiver, msg.TimeoutHeight, msg.TimeoutTimestamp, - msg.Memo, msg.Forwarding.Hops) + msg.Memo, msg.Forwarding.GetHops()) if err != nil { return nil, err } diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index 9e6c5732274..ef902c9b596 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -136,7 +136,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { suite.chainB.SenderAccount.GetAddress().String(), suite.chainB.GetTimeoutHeight(), 0, // only use timeout height "memo", - types.Forwarding{}, + nil, ) // send some coins of the second denom from bank module to the sender account as well @@ -159,7 +159,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { tokensBz, err := json.Marshal(types.Tokens(tokens)) suite.Require().NoError(err) - forwardingHopsBz, err := json.Marshal(msg.Forwarding.Hops) + forwardingHopsBz, err := json.Marshal(msg.Forwarding.GetHops()) suite.Require().NoError(err) res, err := suite.chainA.GetSimApp().TransferKeeper.Transfer(ctx, msg) diff --git a/modules/apps/transfer/keeper/relay_forwarding_test.go b/modules/apps/transfer/keeper/relay_forwarding_test.go index e70d390b554..4829e140402 100644 --- a/modules/apps/transfer/keeper/relay_forwarding_test.go +++ b/modules/apps/transfer/keeper/relay_forwarding_test.go @@ -614,7 +614,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureWithMiddleChainAsNativeT setupReceiver.GetAddress().String(), suite.chainB.GetTimeoutHeight(), 0, "", - types.Forwarding{}, + nil, ) result, err := suite.chainB.SendMsgs(setupTransferMsg) @@ -899,9 +899,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacketForwarding() { originalABalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), sender.GetAddress(), coin.Denom) - forwarding := types.Forwarding{ - Hops: []types.Hop{types.NewHop(pathBtoC.EndpointA.ChannelConfig.PortID, pathBtoC.EndpointA.ChannelID)}, - } + forwarding := types.NewForwarding(false, types.NewHop(pathBtoC.EndpointA.ChannelConfig.PortID, pathBtoC.EndpointA.ChannelID)) transferMsg := types.NewMsgTransfer( pathAtoB.EndpointA.ChannelConfig.PortID, diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 6366454f967..fd1d7f69320 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -23,7 +23,7 @@ import ( ) var ( - emptyForwarding = types.Forwarding{} + emptyForwarding *types.Forwarding emptyForwardingPacketData = types.ForwardingPacketData{} ) @@ -36,7 +36,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { sender sdk.AccAddress timeoutHeight clienttypes.Height memo string - forwarding types.Forwarding + forwarding *types.Forwarding expEscrowAmount sdkmath.Int // total amount in escrow for denom on receiving chain ) diff --git a/modules/apps/transfer/transfer_test.go b/modules/apps/transfer/transfer_test.go index b334d39ba7b..82fab84020b 100644 --- a/modules/apps/transfer/transfer_test.go +++ b/modules/apps/transfer/transfer_test.go @@ -80,7 +80,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { } // send from chainA to chainB - msg := types.NewMsgTransfer(pathAToB.EndpointA.ChannelConfig.PortID, pathAToB.EndpointA.ChannelID, originalCoins, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", types.Forwarding{}) + msg := types.NewMsgTransfer(pathAToB.EndpointA.ChannelConfig.PortID, pathAToB.EndpointA.ChannelID, originalCoins, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", nil) res, err := suite.chainA.SendMsgs(msg) suite.Require().NoError(err) // message committed @@ -120,7 +120,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { traceBToC := types.NewHop(pathBToC.EndpointB.ChannelConfig.PortID, pathBToC.EndpointB.ChannelID) // send from chainB to chainC - msg = types.NewMsgTransfer(pathBToC.EndpointA.ChannelConfig.PortID, pathBToC.EndpointA.ChannelID, coinsSentFromAToB, suite.chainB.SenderAccount.GetAddress().String(), suite.chainC.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", types.Forwarding{}) + msg = types.NewMsgTransfer(pathBToC.EndpointA.ChannelConfig.PortID, pathBToC.EndpointA.ChannelID, coinsSentFromAToB, suite.chainB.SenderAccount.GetAddress().String(), suite.chainC.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", nil) res, err = suite.chainB.SendMsgs(msg) suite.Require().NoError(err) // message committed @@ -149,7 +149,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { } // send from chainC back to chainB - msg = types.NewMsgTransfer(pathBToC.EndpointB.ChannelConfig.PortID, pathBToC.EndpointB.ChannelID, coinsSentFromBToC, suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", types.Forwarding{}) + msg = types.NewMsgTransfer(pathBToC.EndpointB.ChannelConfig.PortID, pathBToC.EndpointB.ChannelID, coinsSentFromBToC, suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", nil) res, err = suite.chainC.SendMsgs(msg) suite.Require().NoError(err) // message committed diff --git a/modules/apps/transfer/types/forwarding.go b/modules/apps/transfer/types/forwarding.go index 2e21c35a4e1..b244b7b840b 100644 --- a/modules/apps/transfer/types/forwarding.go +++ b/modules/apps/transfer/types/forwarding.go @@ -11,8 +11,8 @@ import ( const MaximumNumberOfForwardingHops = 8 // denotes the maximum number of forwarding hops allowed // NewForwarding creates a new Forwarding instance given an unwind value and a variable number of hops. -func NewForwarding(unwind bool, hops ...Hop) Forwarding { - return Forwarding{ +func NewForwarding(unwind bool, hops ...Hop) *Forwarding { + return &Forwarding{ Unwind: unwind, Hops: hops, } @@ -20,7 +20,7 @@ func NewForwarding(unwind bool, hops ...Hop) Forwarding { // Validate performs a basic validation of the Forwarding fields. func (f Forwarding) Validate() error { - if err := validateHops(f.Hops); err != nil { + if err := validateHops(f.GetHops()); err != nil { return errorsmod.Wrapf(ErrInvalidForwarding, "invalid hops in forwarding") } diff --git a/modules/apps/transfer/types/forwarding_test.go b/modules/apps/transfer/types/forwarding_test.go index 07deaa62527..c67a8a4fe1e 100644 --- a/modules/apps/transfer/types/forwarding_test.go +++ b/modules/apps/transfer/types/forwarding_test.go @@ -15,7 +15,7 @@ var validHop = types.NewHop(types.PortID, ibctesting.FirstChannelID) func TestForwarding_Validate(t *testing.T) { tests := []struct { name string - forwarding types.Forwarding + forwarding *types.Forwarding expError error }{ { diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 6b036e491c3..eb717b6e5ca 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -49,7 +49,7 @@ func NewMsgTransfer( tokens sdk.Coins, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string, - forwarding Forwarding, + forwarding *Forwarding, ) *MsgTransfer { return &MsgTransfer{ SourcePort: sourcePort, @@ -72,19 +72,11 @@ func (msg MsgTransfer) ValidateBasic() error { if err := msg.validateForwarding(); err != nil { return err } - if !msg.Forwarding.Unwind { - // We verify that portID and channelID are valid IDs only if - // we are not setting unwind to true. - // In that case, validation that they are empty is performed in - // validateForwarding(). - if err := host.PortIdentifierValidator(msg.SourcePort); err != nil { - return errorsmod.Wrap(err, "invalid source port ID") - } - if err := host.ChannelIdentifierValidator(msg.SourceChannel); err != nil { - return errorsmod.Wrap(err, "invalid source channel ID") - } + if err := msg.validateIdentifiers(); err != nil { + return err } + if len(msg.Tokens) == 0 && !isValidIBCCoin(msg.Token) { return errorsmod.Wrap(ibcerrors.ErrInvalidCoins, "either token or token array must be filled") } @@ -125,6 +117,7 @@ func (msg MsgTransfer) validateForwarding() error { if !msg.HasForwarding() { return nil } + if err := msg.Forwarding.Validate(); err != nil { return err } @@ -135,12 +128,6 @@ func (msg MsgTransfer) validateForwarding() error { } if msg.Forwarding.Unwind { - if msg.SourcePort != "" { - return errorsmod.Wrapf(ErrInvalidForwarding, "source port must be empty when unwind is set, got %s instead", msg.SourcePort) - } - if msg.SourceChannel != "" { - return errorsmod.Wrapf(ErrInvalidForwarding, "source channel must be empty when unwind is set, got %s instead", msg.SourceChannel) - } if len(msg.GetCoins()) > 1 { // When unwinding, we must have at most one token. return errorsmod.Wrap(ibcerrors.ErrInvalidCoins, "cannot unwind more than one token") @@ -163,9 +150,40 @@ func (msg MsgTransfer) GetCoins() sdk.Coins { // HasForwarding determines if the transfer should be forwarded to the next hop. func (msg MsgTransfer) HasForwarding() bool { + if msg.Forwarding == nil { + return false + } + return len(msg.Forwarding.Hops) > 0 || msg.Forwarding.Unwind } +// validateIdentifiers validates the source port and channel identifiers based on the +// forwarding information present in the message. If forwarding information is missing +// or unwinding isn't performed, we do normal validation, else, we assert that both +// fields must be empty. +func (msg MsgTransfer) validateIdentifiers() error { + if msg.Forwarding != nil && msg.Forwarding.Unwind { + if msg.SourcePort != "" { + return errorsmod.Wrapf(ErrInvalidForwarding, "source port must be empty when unwind is set, got %s instead", msg.SourcePort) + } + if msg.SourceChannel != "" { + return errorsmod.Wrapf(ErrInvalidForwarding, "source channel must be empty when unwind is set, got %s instead", msg.SourceChannel) + } + + return nil + } + + // If forwarding is nil or if no unwinding occurs, validate port, channel. + if err := host.PortIdentifierValidator(msg.SourcePort); err != nil { + return errorsmod.Wrapf(err, "invalid source port ID %s", msg.SourcePort) + } + if err := host.ChannelIdentifierValidator(msg.SourceChannel); err != nil { + return errorsmod.Wrapf(err, "invalid source channel ID %s", msg.SourceChannel) + } + + return nil +} + // isValidIBCCoin returns true if the token provided is valid, // and should be used to transfer tokens. func isValidIBCCoin(coin sdk.Coin) bool { diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 233218286f8..135472bd2f2 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -48,7 +48,7 @@ var ( zeroCoins = []sdk.Coin{{Denom: "atoms", Amount: sdkmath.NewInt(0)}} timeoutHeight = clienttypes.NewHeight(0, 10) - emptyForwarding = types.Forwarding{} + emptyForwarding *types.Forwarding ) // TestMsgTransferValidation tests ValidateBasic for MsgTransfer @@ -59,11 +59,11 @@ func TestMsgTransferValidation(t *testing.T) { expError error }{ {"valid msg with base denom", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", emptyForwarding), nil}, - {"valid msg with unwind", types.NewMsgTransfer("", "", sdk.NewCoins(ibctesting.TestCoin), sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(true)), nil}, + {"valid msg with unwind", types.NewMsgTransfer("", "", sdk.NewCoins(coin), sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(true)), nil}, {"valid msg with trace hash", types.NewMsgTransfer(validPort, validChannel, ibcCoins, sender, receiver, clienttypes.ZeroHeight(), 100, "", emptyForwarding), nil}, {"multidenom", types.NewMsgTransfer(validPort, validChannel, coins.Add(ibcCoins...), sender, receiver, clienttypes.ZeroHeight(), 100, "", emptyForwarding), nil}, {"memo with forwarding path hops not empty", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, clienttypes.ZeroHeight(), 100, "memo", types.NewForwarding(false, validHop)), nil}, - {"memo with forwarding unwind set to true", types.NewMsgTransfer("", "", sdk.NewCoins(ibctesting.TestCoin), sender, receiver, clienttypes.ZeroHeight(), 100, "memo", types.NewForwarding(true)), nil}, + {"memo with forwarding unwind set to true", types.NewMsgTransfer("", "", sdk.NewCoins(coin), sender, receiver, clienttypes.ZeroHeight(), 100, "memo", types.NewForwarding(true)), nil}, {"invalid ibc denom", types.NewMsgTransfer(validPort, validChannel, invalidIBCCoins, sender, receiver, clienttypes.ZeroHeight(), 100, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, {"too short port id", types.NewMsgTransfer(invalidShortPort, validChannel, coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", emptyForwarding), host.ErrInvalidID}, {"too long port id", types.NewMsgTransfer(invalidLongPort, validChannel, coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", emptyForwarding), host.ErrInvalidID}, @@ -89,8 +89,8 @@ func TestMsgTransferValidation(t *testing.T) { {"invalid forwarding info too many hops", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(false, generateHops(types.MaximumNumberOfForwardingHops+1)...)), types.ErrInvalidForwarding}, {"invalid portID when forwarding is set but unwind is not", types.NewMsgTransfer("", validChannel, coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(false, validHop)), host.ErrInvalidID}, {"invalid channelID when forwarding is set but unwind is not", types.NewMsgTransfer(validPort, "", coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(false, validHop)), host.ErrInvalidID}, - {"unwind specified but source port is not empty", types.NewMsgTransfer(validPort, "", coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(true)), types.ErrInvalidForwarding}, - {"unwind specified but source channel is not empty", types.NewMsgTransfer("", validChannel, coins, sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(true)), types.ErrInvalidForwarding}, + {"unwind specified but source port is not empty", types.NewMsgTransfer(validPort, "", sdk.NewCoins(coin), sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(true)), types.ErrInvalidForwarding}, + {"unwind specified but source channel is not empty", types.NewMsgTransfer("", validChannel, sdk.NewCoins(coin), sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(true)), types.ErrInvalidForwarding}, {"unwind specified but more than one coin in the message", types.NewMsgTransfer("", "", coins.Add(sdk.NewCoin("atom", ibctesting.TestCoin.Amount)), sender, receiver, clienttypes.ZeroHeight(), 100, "", types.NewForwarding(true)), ibcerrors.ErrInvalidCoins}, } diff --git a/modules/apps/transfer/types/transfer_authorization.go b/modules/apps/transfer/types/transfer_authorization.go index 7b73d064a1b..0735ef860d3 100644 --- a/modules/apps/transfer/types/transfer_authorization.go +++ b/modules/apps/transfer/types/transfer_authorization.go @@ -178,7 +178,11 @@ func isAllowedAddress(ctx sdk.Context, receiver string, allowedAddrs []string) b } // validateForwarding performs the validation of forwarding info. -func validateForwarding(forwarding Forwarding, allowedForwarding []AllowedForwarding) error { +func validateForwarding(forwarding *Forwarding, allowedForwarding []AllowedForwarding) error { + if forwarding == nil { + return nil + } + if forwarding.Unwind { return errorsmod.Wrap(ErrInvalidForwarding, "not allowed automatic unwind") } diff --git a/modules/apps/transfer/types/transfer_authorization_test.go b/modules/apps/transfer/types/transfer_authorization_test.go index e7ab3cdc43c..fa97b7a28f6 100644 --- a/modules/apps/transfer/types/transfer_authorization_test.go +++ b/modules/apps/transfer/types/transfer_authorization_test.go @@ -470,7 +470,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { { "failure: unwind is not allowed", func() { - msgTransfer.Forwarding.Unwind = true + msgTransfer.Forwarding = types.NewForwarding(true) }, func(res authz.AcceptResponse, err error) { suite.Require().Error(err) diff --git a/modules/apps/transfer/types/tx.pb.go b/modules/apps/transfer/types/tx.pb.go index 518107142a6..66acd8c1238 100644 --- a/modules/apps/transfer/types/tx.pb.go +++ b/modules/apps/transfer/types/tx.pb.go @@ -57,7 +57,7 @@ type MsgTransfer struct { // tokens to be transferred Tokens []types.Coin `protobuf:"bytes,9,rep,name=tokens,proto3" json:"tokens"` // optional forwarding information - Forwarding Forwarding `protobuf:"bytes,10,opt,name=forwarding,proto3" json:"forwarding"` + Forwarding *Forwarding `protobuf:"bytes,10,opt,name=forwarding,proto3" json:"forwarding,omitempty"` } func (m *MsgTransfer) Reset() { *m = MsgTransfer{} } @@ -226,47 +226,47 @@ func init() { var fileDescriptor_7401ed9bed2f8e09 = []byte{ // 659 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x31, 0x6f, 0x13, 0x31, - 0x14, 0xce, 0xd1, 0x34, 0xb4, 0x0e, 0x6d, 0xa9, 0x41, 0xed, 0xf5, 0x84, 0x2e, 0x51, 0x44, 0xa5, - 0x90, 0xaa, 0xb6, 0x52, 0x84, 0x8a, 0x2a, 0xa6, 0x54, 0x42, 0x0c, 0x14, 0x95, 0x53, 0x59, 0x58, - 0xaa, 0xbb, 0x8b, 0x7b, 0xb1, 0x9a, 0xb3, 0x0f, 0xdb, 0x09, 0xb0, 0x20, 0xc4, 0x84, 0x60, 0xe1, - 0x27, 0x30, 0x32, 0xf6, 0x67, 0x74, 0xec, 0xc8, 0x84, 0x50, 0x3b, 0x74, 0xe1, 0x47, 0x20, 0xfb, - 0x7c, 0xe1, 0x60, 0x08, 0xb0, 0xdc, 0xf9, 0xbd, 0xf7, 0xbd, 0xef, 0xbd, 0xf7, 0xf9, 0xc9, 0x60, - 0x9d, 0x46, 0x31, 0x0e, 0xb3, 0x6c, 0x48, 0xe3, 0x50, 0x51, 0xce, 0x24, 0x56, 0x22, 0x64, 0xf2, - 0x88, 0x08, 0x3c, 0xee, 0x62, 0xf5, 0x0a, 0x65, 0x82, 0x2b, 0x0e, 0x6f, 0xd1, 0x28, 0x46, 0x65, - 0x18, 0x2a, 0x60, 0x68, 0xdc, 0xf5, 0x96, 0xc3, 0x94, 0x32, 0x8e, 0xcd, 0x37, 0x4f, 0xf0, 0x6e, - 0x26, 0x3c, 0xe1, 0xe6, 0x88, 0xf5, 0xc9, 0x7a, 0x57, 0x63, 0x2e, 0x53, 0x2e, 0x71, 0x2a, 0x13, - 0x4d, 0x9f, 0xca, 0xc4, 0x06, 0x7c, 0x1b, 0x88, 0x42, 0x49, 0xf0, 0xb8, 0x1b, 0x11, 0x15, 0x76, - 0x71, 0xcc, 0x29, 0xb3, 0xf1, 0x86, 0x6e, 0x33, 0xe6, 0x82, 0xe0, 0x78, 0x48, 0x09, 0x53, 0x3a, - 0x3b, 0x3f, 0x59, 0xc0, 0xc6, 0xf4, 0x39, 0x8a, 0x66, 0x0d, 0xb8, 0xf5, 0xb1, 0x0a, 0xea, 0x7b, - 0x32, 0x39, 0xb0, 0x5e, 0xd8, 0x00, 0x75, 0xc9, 0x47, 0x22, 0x26, 0x87, 0x19, 0x17, 0xca, 0x75, - 0x9a, 0x4e, 0x7b, 0x3e, 0x00, 0xb9, 0x6b, 0x9f, 0x0b, 0x05, 0xd7, 0xc1, 0xa2, 0x05, 0xc4, 0x83, - 0x90, 0x31, 0x32, 0x74, 0xaf, 0x18, 0xcc, 0x42, 0xee, 0xdd, 0xcd, 0x9d, 0xf0, 0x01, 0x98, 0x55, - 0xfc, 0x98, 0x30, 0x77, 0xa6, 0xe9, 0xb4, 0xeb, 0x5b, 0x6b, 0x28, 0x9f, 0x0a, 0xe9, 0xa9, 0x90, - 0x9d, 0x0a, 0xed, 0x72, 0xca, 0x7a, 0xf5, 0xd3, 0x6f, 0x8d, 0xca, 0x97, 0xcb, 0x93, 0x8e, 0xe3, - 0x3a, 0x41, 0x9e, 0x04, 0x57, 0x40, 0x4d, 0x12, 0xd6, 0x27, 0xc2, 0xad, 0x1a, 0x72, 0x6b, 0x41, - 0x0f, 0xcc, 0x09, 0x12, 0x13, 0x3a, 0x26, 0xc2, 0x9d, 0x35, 0x91, 0x89, 0x0d, 0x1f, 0x83, 0x45, - 0x45, 0x53, 0xc2, 0x47, 0xea, 0x70, 0x40, 0x68, 0x32, 0x50, 0x6e, 0xcd, 0x94, 0xf6, 0x90, 0xbe, - 0x30, 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, 0xb8, + 0x4c, 0x49, 0xea, 0xa5, 0xd6, 0x1a, 0x3b, 0xd8, 0x6e, 0x81, 0x0b, 0x42, 0x48, 0x48, 0x88, 0x13, + 0x1f, 0x81, 0x23, 0xc7, 0x7d, 0x8c, 0x1d, 0x77, 0xe4, 0x84, 0xd0, 0x76, 0xd8, 0x85, 0x0f, 0x81, + 0xec, 0x38, 0x25, 0x70, 0x28, 0x70, 0x49, 0xfc, 0xde, 0xfb, 0xbd, 0x3f, 0xbf, 0x9f, 0x9f, 0x0c, + 0xd6, 0x69, 0x14, 0xe3, 0x30, 0xcb, 0x86, 0x34, 0x0e, 0x15, 0xe5, 0x4c, 0x62, 0x25, 0x42, 0x26, + 0x8f, 0x89, 0xc0, 0xe3, 0x2e, 0x56, 0xaf, 0x50, 0x26, 0xb8, 0xe2, 0xf0, 0x0e, 0x8d, 0x62, 0x54, + 0x86, 0xa1, 0x02, 0x86, 0xc6, 0x5d, 0x6f, 0x39, 0x4c, 0x29, 0xe3, 0xd8, 0x7c, 0xf3, 0x04, 0xef, + 0x76, 0xc2, 0x13, 0x6e, 0x8e, 0x58, 0x9f, 0xac, 0x77, 0x35, 0xe6, 0x32, 0xe5, 0x12, 0xa7, 0x32, + 0xd1, 0xe5, 0x53, 0x99, 0xd8, 0x80, 0x6f, 0x03, 0x51, 0x28, 0x09, 0x1e, 0x77, 0x23, 0xa2, 0xc2, + 0x2e, 0x8e, 0x39, 0x65, 0x36, 0xde, 0xd0, 0x63, 0xc6, 0x5c, 0x10, 0x1c, 0x0f, 0x29, 0x61, 0x4a, + 0x67, 0xe7, 0x27, 0x0b, 0xd8, 0x98, 0xce, 0xa3, 0x18, 0xd6, 0x80, 0x5b, 0xef, 0xab, 0xa0, 0xbe, + 0x2f, 0x93, 0x43, 0xeb, 0x85, 0x0d, 0x50, 0x97, 0x7c, 0x24, 0x62, 0x72, 0x94, 0x71, 0xa1, 0x5c, + 0xa7, 0xe9, 0xb4, 0xe7, 0x03, 0x90, 0xbb, 0x0e, 0xb8, 0x50, 0x70, 0x1d, 0x2c, 0x5a, 0x40, 0x3c, + 0x08, 0x19, 0x23, 0x43, 0xf7, 0x9a, 0xc1, 0x2c, 0xe4, 0xde, 0xdd, 0xdc, 0x09, 0x1f, 0x81, 0x59, + 0xc5, 0x4f, 0x08, 0x73, 0x67, 0x9a, 0x4e, 0xbb, 0xbe, 0xb5, 0x86, 0x72, 0x56, 0x48, 0xb3, 0x42, + 0x96, 0x15, 0xda, 0xe5, 0x94, 0xf5, 0xea, 0x67, 0xdf, 0x1a, 0x95, 0x2f, 0x57, 0xa7, 0x1d, 0xc7, + 0x75, 0x82, 0x3c, 0x09, 0xae, 0x80, 0x9a, 0x24, 0xac, 0x4f, 0x84, 0x5b, 0x35, 0xc5, 0xad, 0x05, + 0x3d, 0x30, 0x27, 0x48, 0x4c, 0xe8, 0x98, 0x08, 0x77, 0xd6, 0x44, 0x26, 0x36, 0x7c, 0x02, 0x16, + 0x15, 0x4d, 0x09, 0x1f, 0xa9, 0xa3, 0x01, 0xa1, 0xc9, 0x40, 0xb9, 0x35, 0xd3, 0xda, 0x43, 0xfa, + 0xc2, 0xb4, 0x60, 0xc8, 0xca, 0x34, 0xee, 0xa2, 0x3d, 0x83, 0xe8, 0xcd, 0x4f, 0x7a, 0x07, 0x0b, + 0x36, 0x39, 0x8f, 0xc0, 0x0d, 0xb0, 0x5c, 0x54, 0xd3, 0x7f, 0xa9, 0xc2, 0x34, 0x73, 0xaf, 0x37, + 0x9d, 0x76, 0x35, 0xb8, 0x69, 0x03, 0x87, 0x85, 0x1f, 0x42, 0x50, 0x4d, 0x49, 0xca, 0xdd, 0x39, + 0x33, 0x92, 0x39, 0xc3, 0x6d, 0x50, 0x33, 0x5c, 0xa4, 0x3b, 0xdf, 0x9c, 0x99, 0xae, 0x40, 0x55, + 0x4f, 0x11, 0x58, 0x38, 0xdc, 0x03, 0xe0, 0x98, 0x8b, 0x97, 0xa1, 0xe8, 0x53, 0x96, 0xb8, 0xc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2b, 0xe7, 0x97, 0x7e, 0xe5, 0xeb, 0xa5, 0x5f, 0x79, 0xbe, 0x9d, + 0x50, 0x35, 0x18, 0x45, 0x28, 0xe6, 0x29, 0xb6, 0xaf, 0x0b, 0x8d, 0xe2, 0xcd, 0x84, 0xe3, 0xf1, + 0x43, 0x9c, 0xf2, 0xfe, 0x68, 0x48, 0xa4, 0x7e, 0x31, 0x4a, 0x2f, 0x85, 0x7a, 0x9d, 0x11, 0x19, + 0xd5, 0xcc, 0x23, 0x71, 0xff, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x2c, 0x89, 0xb7, 0x1b, 0x05, 0x00, 0x00, } @@ -410,16 +410,18 @@ func (m *MsgTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Forwarding.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Forwarding != nil { + { + size, err := m.Forwarding.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x52 } - i-- - dAtA[i] = 0x52 if len(m.Tokens) > 0 { for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { { @@ -638,8 +640,10 @@ func (m *MsgTransfer) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } } - l = m.Forwarding.Size() - n += 1 + l + sovTx(uint64(l)) + if m.Forwarding != nil { + l = m.Forwarding.Size() + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -1022,6 +1026,9 @@ func (m *MsgTransfer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + if m.Forwarding == nil { + m.Forwarding = &Forwarding{} + } if err := m.Forwarding.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/proto/ibc/applications/transfer/v1/tx.proto b/proto/ibc/applications/transfer/v1/tx.proto index 6a422d0c74d..0a1c8d49d8c 100644 --- a/proto/ibc/applications/transfer/v1/tx.proto +++ b/proto/ibc/applications/transfer/v1/tx.proto @@ -52,7 +52,7 @@ message MsgTransfer { // tokens to be transferred repeated cosmos.base.v1beta1.Coin tokens = 9 [(gogoproto.nullable) = false]; // optional forwarding information - Forwarding forwarding = 10 [(gogoproto.nullable) = false]; + Forwarding forwarding = 10; } // MsgTransferResponse defines the Msg/Transfer response type. diff --git a/testing/solomachine.go b/testing/solomachine.go index b6b3d986a22..9d431313457 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -376,7 +376,7 @@ func (solo *Solomachine) SendTransfer(chain *TestChain, portID, channelID string clienttypes.ZeroHeight(), uint64(chain.GetContext().BlockTime().Add(time.Hour).UnixNano()), "", - transfertypes.Forwarding{}, + nil, ) for _, fn := range fns {