From 067065928ab40569d7ac21fc9338e612574124f7 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 18 Jun 2024 18:08:54 +0300 Subject: [PATCH] chore(transfer): make Forwarding non-null (#6618) * chore(transfer): make Forwarding non-null * chore(transfer): always validate forwarding. --- e2e/tests/transfer/authz_test.go | 8 +- e2e/tests/transfer/incentivized_test.go | 5 +- e2e/tests/transfer/upgrades_test.go | 3 +- 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 | 14 ++- 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.go | 2 +- modules/apps/transfer/ibc_module_test.go | 4 +- .../apps/transfer/internal/convert/convert.go | 2 +- modules/apps/transfer/internal/packet_test.go | 18 +-- modules/apps/transfer/keeper/export_test.go | 2 +- modules/apps/transfer/keeper/forwarding.go | 3 +- .../apps/transfer/keeper/invariants_test.go | 2 +- .../apps/transfer/keeper/mbt_relay_test.go | 4 +- .../apps/transfer/keeper/msg_server_test.go | 2 +- modules/apps/transfer/keeper/relay.go | 4 +- .../transfer/keeper/relay_forwarding_test.go | 8 +- modules/apps/transfer/keeper/relay_test.go | 34 +++--- modules/apps/transfer/transfer_test.go | 6 +- modules/apps/transfer/types/forwarding.go | 4 +- .../apps/transfer/types/forwarding_test.go | 2 +- modules/apps/transfer/types/msgs.go | 16 ++- modules/apps/transfer/types/msgs_test.go | 49 ++++---- modules/apps/transfer/types/packet.go | 18 ++- modules/apps/transfer/types/packet.pb.go | 79 ++++++------- modules/apps/transfer/types/packet_test.go | 44 +++---- .../transfer/types/transfer_authorization.go | 2 +- .../types/transfer_authorization_test.go | 8 +- modules/apps/transfer/types/tx.pb.go | 111 ++++++++---------- proto/ibc/applications/transfer/v1/tx.proto | 2 +- .../ibc/applications/transfer/v2/packet.proto | 2 +- testing/solomachine.go | 2 +- 39 files changed, 243 insertions(+), 251 deletions(-) diff --git a/e2e/tests/transfer/authz_test.go b/e2e/tests/transfer/authz_test.go index fc0d4586af0..495ffc3e880 100644 --- a/e2e/tests/transfer/authz_test.go +++ b/e2e/tests/transfer/authz_test.go @@ -127,7 +127,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) @@ -188,7 +188,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) @@ -271,7 +271,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) @@ -332,7 +332,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { suite.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) protoAny, err := codectypes.NewAnyWithValue(transferMsg) diff --git a/e2e/tests/transfer/incentivized_test.go b/e2e/tests/transfer/incentivized_test.go index 032a2c1a9e1..7d2cf8668a0 100644 --- a/e2e/tests/transfer/incentivized_test.go +++ b/e2e/tests/transfer/incentivized_test.go @@ -20,6 +20,7 @@ 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" ) @@ -211,7 +212,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou s.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgTransfer) // this message should be successful, as receiver account is not validated on the sending chain. @@ -350,7 +351,7 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender s.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer) s.AssertTxSuccess(resp) diff --git a/e2e/tests/transfer/upgrades_test.go b/e2e/tests/transfer/upgrades_test.go index 7eb9de1fb53..09e527f0e9e 100644 --- a/e2e/tests/transfer/upgrades_test.go +++ b/e2e/tests/transfer/upgrades_test.go @@ -19,6 +19,7 @@ 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" ) @@ -208,7 +209,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_ s.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) 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 277157878c8..68c65329e75 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -28,6 +28,7 @@ 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" @@ -966,7 +967,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() { s.GetTimeoutHeight(ctx, chainB), 0, "", - nil, + transfertypes.Forwarding{}, ) resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer) s.AssertTxSuccess(resp) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index d62e3d3c603..2fd9d9503e2 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -625,7 +625,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 7395f393741..ae8fc60f58d 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -30,6 +30,7 @@ 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" ) @@ -297,7 +298,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, nil) + msg := GetMsgTransfer(portID, channelID, transferVersion, tokens, sender, receiver, timeoutHeight, timeoutTimestamp, memo, transfertypes.Forwarding{}) 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 c9a115fd45b..fbd05e641cd 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, "", - nil, + transfertypes.Forwarding{}, ) data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}, encoding) @@ -389,7 +389,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { suite.chainB.GetTimeoutHeight(), 0, "", - nil, + transfertypes.Forwarding{}, ) 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 93b27ceef64..f9a14aa3a50 100644 --- a/modules/apps/29-fee/keeper/events_test.go +++ b/modules/apps/29-fee/keeper/events_test.go @@ -115,7 +115,7 @@ func (suite *KeeperTestSuite) TestDistributeFeeEvent() { path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, "", - nil, + transfertypes.Forwarding{}, ) 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 14fdfb42545..3d2beb18a49 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, "", 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{}), } res, err := suite.chainA.SendMsgs(msgs...) @@ -157,7 +157,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, "", 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{}), } 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 03e0e6cc0e1..923b4bb6c8e 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -24,6 +24,8 @@ import ( ibcmock "github.com/cosmos/ibc-go/v8/testing/mock" ) +var emptyForwarding = transfertypes.Forwarding{} + func (s *CallbacksTestSuite) TestNewIBCMiddleware() { testCases := []struct { name string @@ -186,7 +188,7 @@ func (s *CallbacksTestSuite) TestSendPacket() { ibctesting.TestAccAddress, ibctesting.TestAccAddress, fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, simapp.SuccessContract), - nil, + emptyForwarding, ) chanCap := s.path.EndpointA.Chain.GetChannelCapability(s.path.EndpointA.ChannelConfig.PortID, s.path.EndpointA.ChannelID) @@ -328,7 +330,7 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { ibctesting.TestAccAddress, ibctesting.TestAccAddress, fmt.Sprintf(`{"src_callback": {"address":"%s", "gas_limit":"%d"}}`, simapp.SuccessContract, userGasLimit), - nil, + emptyForwarding, ) packet = channeltypes.Packet{ @@ -494,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 - nil, + emptyForwarding, ) res, err := s.chainA.SendMsgs(msg) @@ -662,7 +664,7 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { ibctesting.TestAccAddress, s.chainB.SenderAccount.GetAddress().String(), fmt.Sprintf(`{"dest_callback": {"address":"%s", "gas_limit":"%d"}}`, ibctesting.TestAccAddress, userGasLimit), - nil, + emptyForwarding, ) packet = channeltypes.Packet{ @@ -794,7 +796,7 @@ func (s *CallbacksTestSuite) TestWriteAcknowledgement() { ibctesting.TestAccAddress, s.chainB.SenderAccount.GetAddress().String(), fmt.Sprintf(`{"dest_callback": {"address":"%s", "gas_limit":"600000"}}`, ibctesting.TestAccAddress), - nil, + emptyForwarding, ) packet = channeltypes.Packet{ @@ -1018,7 +1020,7 @@ func (s *CallbacksTestSuite) TestUnmarshalPacketDataV1() { Sender: ibctesting.TestAccAddress, Receiver: ibctesting.TestAccAddress, Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}, "dest_callback": {"address":"%s"}}`, ibctesting.TestAccAddress, ibctesting.TestAccAddress), - Forwarding: nil, + Forwarding: emptyForwarding, } portID := s.path.EndpointA.ChannelConfig.PortID diff --git a/modules/apps/callbacks/replay_test.go b/modules/apps/callbacks/replay_test.go index d04a614136d..4c619346597 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, - nil, + transfertypes.Forwarding{}, ) res, err := s.chainA.SendMsgs(msg) diff --git a/modules/apps/callbacks/transfer_test.go b/modules/apps/callbacks/transfer_test.go index 970fe36447e..c1e935e204d 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, - nil, + transfertypes.Forwarding{}, ) 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, - nil, + transfertypes.Forwarding{}, ) 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 096d72abc74..e4fd1a67511 100644 --- a/modules/apps/transfer/client/cli/tx.go +++ b/modules/apps/transfer/client/cli/tx.go @@ -97,7 +97,7 @@ using the {packet-timeout-timestamp} flag. If no timeout value is set then a def } // If parsed, set and replace memo. - if forwarding != nil { + if len(forwarding.Hops) > 0 { forwarding.Memo = memo memo = "" } @@ -142,22 +142,22 @@ using the {packet-timeout-timestamp} flag. If no timeout value is set then a def // 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 nil, err + return types.Forwarding{}, err } if strings.TrimSpace(forwardingString) == "" { - return nil, nil + return types.Forwarding{}, nil } pairs := strings.Split(forwardingString, ",") for _, pair := range pairs { pairSplit := strings.Split(pair, "/") if len(pairSplit) != 2 { - return nil, fmt.Errorf("expected a portID/channelID pair, found %s", pair) + return types.Forwarding{}, fmt.Errorf("expected a portID/channelID pair, found %s", pair) } hop := types.Hop{PortId: pairSplit[0], ChannelId: pairSplit[1]} diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index 266d100f9af..45a56ec6dc9 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -211,7 +211,7 @@ func (im IBCModule) OnRecvPacket( im.keeper.Logger(ctx).Info("successfully handled ICS-20 packet", "sequence", packet.Sequence) - if data.Forwarding != nil { + if data.ShouldBeForwarded() { // NOTE: acknowledgement will be written asynchronously return nil } diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index f4e02a8e06f..cbf937dd9a4 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -355,7 +355,7 @@ func (suite *TransferTestSuite) TestOnRecvPacket() { suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", - nil, + types.Forwarding{}, ) tokensBz, err := json.Marshal(packetData.Tokens) @@ -476,7 +476,7 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { timeoutHeight, 0, "", - nil, + types.Forwarding{}, ) res, err := suite.chainA.SendMsgs(msg) suite.Require().NoError(err) // message committed diff --git a/modules/apps/transfer/internal/convert/convert.go b/modules/apps/transfer/internal/convert/convert.go index 9bc43844e63..c266d42519a 100644 --- a/modules/apps/transfer/internal/convert/convert.go +++ b/modules/apps/transfer/internal/convert/convert.go @@ -24,6 +24,6 @@ func PacketDataV1ToV2(packetData types.FungibleTokenPacketData) (types.FungibleT Sender: packetData.Sender, Receiver: packetData.Receiver, Memo: packetData.Memo, - Forwarding: nil, + Forwarding: types.Forwarding{}, }, nil } diff --git a/modules/apps/transfer/internal/packet_test.go b/modules/apps/transfer/internal/packet_test.go index 604a8769a51..4cb975622fe 100644 --- a/modules/apps/transfer/internal/packet_test.go +++ b/modules/apps/transfer/internal/packet_test.go @@ -10,6 +10,8 @@ import ( "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ) +var emptyForwarding = types.Forwarding{} + func TestUnmarshalPacketData(t *testing.T) { var ( packetDataBz []byte @@ -35,7 +37,7 @@ func TestUnmarshalPacketData(t *testing.T) { Denom: types.NewDenom("atom", types.NewTrace("transfer", "channel-0")), Amount: "1000", }, - }, "sender", "receiver", "", nil) + }, "sender", "receiver", "", emptyForwarding) packetDataBz = packetData.GetBytes() version = types.V2 @@ -92,7 +94,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { Denom: types.NewDenom("atom", types.NewTrace("transfer", "channel-0")), Amount: "1000", }, - }, sender, receiver, "", nil), + }, sender, receiver, "", emptyForwarding), nil, }, { @@ -104,7 +106,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { Denom: types.NewDenom("atom"), Amount: "1000", }, - }, sender, receiver, "", nil), + }, sender, receiver, "", emptyForwarding), nil, }, { @@ -116,7 +118,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { Denom: types.NewDenom("atom/withslash", types.NewTrace("transfer", "channel-0")), Amount: "1000", }, - }, sender, receiver, "", nil), + }, sender, receiver, "", emptyForwarding), nil, }, { @@ -128,7 +130,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { Denom: types.NewDenom("atom/", types.NewTrace("transfer", "channel-0")), Amount: "1000", }, - }, sender, receiver, "", nil), + }, sender, receiver, "", emptyForwarding), nil, }, { @@ -140,7 +142,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { Denom: types.NewDenom("atom/pool", types.NewTrace("transfer", "channel-0"), types.NewTrace("transfer", "channel-1")), Amount: "1000", }, - }, sender, receiver, "", nil), + }, sender, receiver, "", emptyForwarding), nil, }, { @@ -152,7 +154,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { Denom: types.NewDenom("atom", types.NewTrace("transfer", "channel-0"), types.NewTrace("transfer", "channel-1"), types.NewTrace("transfer-custom", "channel-2")), Amount: "1000", }, - }, sender, receiver, "", nil), + }, sender, receiver, "", emptyForwarding), nil, }, { @@ -164,7 +166,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { Denom: types.NewDenom("atom/pool", types.NewTrace("transfer", "channel-0"), types.NewTrace("transfer", "channel-1"), types.NewTrace("transfer-custom", "channel-2")), Amount: "1000", }, - }, sender, receiver, "", nil), + }, sender, receiver, "", emptyForwarding), nil, }, { diff --git a/modules/apps/transfer/keeper/export_test.go b/modules/apps/transfer/keeper/export_test.go index ebf94032046..582ef3ea5bd 100644 --- a/modules/apps/transfer/keeper/export_test.go +++ b/modules/apps/transfer/keeper/export_test.go @@ -34,6 +34,6 @@ func (k Keeper) TokenFromCoin(ctx sdk.Context, coin sdk.Coin) (types.Token, erro } // CreatePacketDataBytesFromVersion is a wrapper around createPacketDataBytesFromVersion for testing purposes -func CreatePacketDataBytesFromVersion(appVersion, sender, receiver, memo string, tokens types.Tokens, forwarding *types.Forwarding) []byte { +func CreatePacketDataBytesFromVersion(appVersion, sender, receiver, memo string, tokens types.Tokens, forwarding types.Forwarding) []byte { return createPacketDataBytesFromVersion(appVersion, sender, receiver, memo, tokens, forwarding) } diff --git a/modules/apps/transfer/keeper/forwarding.go b/modules/apps/transfer/keeper/forwarding.go index a583f050128..69fdfdf5db9 100644 --- a/modules/apps/transfer/keeper/forwarding.go +++ b/modules/apps/transfer/keeper/forwarding.go @@ -99,10 +99,9 @@ func (k Keeper) revertForwardedPacket(ctx sdk.Context, prevPacket channeltypes.P func (k Keeper) forwardPacket(ctx sdk.Context, data types.FungibleTokenPacketDataV2, packet channeltypes.Packet, receivedCoins sdk.Coins) error { var memo string - var nextForwardingPath *types.Forwarding + var nextForwardingPath types.Forwarding if len(data.Forwarding.Hops) == 1 { memo = data.Forwarding.Memo - nextForwardingPath = nil } else { nextForwardingPath = types.NewForwarding(data.Forwarding.Memo, data.Forwarding.Hops[1:]...) } diff --git a/modules/apps/transfer/keeper/invariants_test.go b/modules/apps/transfer/keeper/invariants_test.go index 28b6a33d867..61474cfafbc 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, "", - nil, + types.Forwarding{}, ) 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 294c7ea7ac2..6d99322d105 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -159,7 +159,7 @@ func FungibleTokenPacketFromTla(packet TlaFungibleTokenPacket) FungibleTokenPack AddressFromString(packet.Data.Sender), AddressFromString(packet.Data.Receiver), "", - nil, + types.Forwarding{}, ), } } @@ -358,7 +358,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { tc.packet.Data.Receiver, suite.chainA.GetTimeoutHeight(), 0, // only use timeout height "", - nil, + types.Forwarding{}, ) _, err = suite.chainB.GetSimApp().TransferKeeper.Transfer(suite.chainB.GetContext(), msg) diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index d77ee61ca9d..1ce9458fdb1 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -129,7 +129,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { suite.chainB.SenderAccount.GetAddress().String(), suite.chainB.GetTimeoutHeight(), 0, // only use timeout height "memo", - nil, + types.Forwarding{}, ) // send some coins of the second denom from bank module to the sender account as well diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index e741f11ecfb..2bfedcc0493 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -64,7 +64,7 @@ func (k Keeper) sendTransfer( timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string, - forwarding *types.Forwarding, + forwarding types.Forwarding, ) (uint64, error) { channel, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) if !found { @@ -431,7 +431,7 @@ func (k Keeper) tokenFromCoin(ctx sdk.Context, coin sdk.Coin) (types.Token, erro } // createPacketDataBytesFromVersion creates the packet data bytes to be sent based on the application version. -func createPacketDataBytesFromVersion(appVersion, sender, receiver, memo string, tokens types.Tokens, forwarding *types.Forwarding) []byte { +func createPacketDataBytesFromVersion(appVersion, sender, receiver, memo string, tokens types.Tokens, forwarding types.Forwarding) []byte { var packetDataBytes []byte switch appVersion { case types.V1: diff --git a/modules/apps/transfer/keeper/relay_forwarding_test.go b/modules/apps/transfer/keeper/relay_forwarding_test.go index 4b2b79b605e..c350b6d2bf2 100644 --- a/modules/apps/transfer/keeper/relay_forwarding_test.go +++ b/modules/apps/transfer/keeper/relay_forwarding_test.go @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestHappyPathForwarding() { Denom: denom, Amount: amount.String(), }, - }, types.GetForwardAddress(path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID).String(), receiver.GetAddress().String(), "", nil) + }, types.GetForwardAddress(path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID).String(), receiver.GetAddress().String(), "", types.Forwarding{}) packetRecv = channeltypes.NewPacket(data.GetBytes(), 3, path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID, path2.EndpointA.ChannelConfig.PortID, path2.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0) // execute onRecvPacket, when chaninA receives the tokens the escrow amount on B should increase to amount @@ -396,7 +396,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() { receiver.GetAddress().String(), suite.chainA.GetTimeoutHeight(), 0, "", - nil, + types.Forwarding{}, ) result, err := suite.chainA.SendMsgs(transferMsg) @@ -440,7 +440,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() { receiver.GetAddress().String(), suite.chainA.GetTimeoutHeight(), 0, "", - nil, + types.Forwarding{}, ) result, err = suite.chainB.SendMsgs(transferMsg) @@ -574,7 +574,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() { Denom: denom, Amount: amount.String(), }, - }, suite.chainC.SenderAccounts[0].SenderAccount.GetAddress().String(), suite.chainA.SenderAccounts[0].SenderAccount.GetAddress().String(), "", nil) + }, suite.chainC.SenderAccounts[0].SenderAccount.GetAddress().String(), suite.chainA.SenderAccounts[0].SenderAccount.GetAddress().String(), "", types.Forwarding{}) // suite.chainC.SenderAccounts[0].SenderAccount.GetAddress().String() This should be forward account of B packet = channeltypes.NewPacket(data.GetBytes(), 3, path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID, path2.EndpointA.ChannelConfig.PortID, path2.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0) diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 71b53fa77be..7376823f6c5 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -21,6 +21,8 @@ import ( ibcmock "github.com/cosmos/ibc-go/v8/testing/mock" ) +var emptyForwarding = types.Forwarding{} + // TestSendTransfer tests sending from chainA to chainB using both coin // that originate on chainA and coin that originate on chainB. func (suite *KeeperTestSuite) TestSendTransfer() { @@ -159,7 +161,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { expEscrowAmount = sdkmath.ZeroInt() // create IBC token on chainA - transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sdk.NewCoins(coin), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainA.GetTimeoutHeight(), 0, "", nil) + transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sdk.NewCoins(coin), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainA.GetTimeoutHeight(), 0, "", emptyForwarding) result, err := suite.chainB.SendMsgs(transferMsg) suite.Require().NoError(err) // message committed @@ -179,7 +181,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, // only use timeout height memo, - nil, + emptyForwarding, ) res, err := suite.chainA.GetSimApp().TransferKeeper.Transfer(suite.chainA.GetContext(), msg) @@ -248,7 +250,7 @@ func (suite *KeeperTestSuite) TestSendTransferSetsTotalEscrowAmountForSourceIBCT suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.chainB.GetTimeoutHeight(), 0, "", - nil, + emptyForwarding, ) result, err := suite.chainA.SendMsgs(transferMsg) suite.Require().NoError(err) // message committed @@ -269,7 +271,7 @@ func (suite *KeeperTestSuite) TestSendTransferSetsTotalEscrowAmountForSourceIBCT suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainA.GetTimeoutHeight(), 0, "", - nil, + emptyForwarding, ) res, err := suite.chainB.GetSimApp().TransferKeeper.Transfer(suite.chainB.GetContext(), msg) @@ -368,7 +370,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsNotSource() { // send coin from chainA to chainB coin := sdk.NewCoin(sdk.DefaultBondDenom, amount) - transferMsg := types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(coin), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0, memo, nil) + transferMsg := types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(coin), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0, memo, emptyForwarding) _, err := suite.chainA.SendMsgs(transferMsg) suite.Require().NoError(err) // message committed @@ -381,7 +383,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsNotSource() { Denom: types.NewDenom(sdk.DefaultBondDenom, []types.Trace{}...), Amount: amount.String(), }, - }, suite.chainA.SenderAccount.GetAddress().String(), receiver, memo, nil) + }, suite.chainA.SenderAccount.GetAddress().String(), receiver, memo, emptyForwarding) packet := channeltypes.NewPacket(data.GetBytes(), seq, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0) err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, data) @@ -503,7 +505,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { // send coin from chainB to chainA, receive them, acknowledge them coin := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) - transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sdk.NewCoins(coin), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 110), 0, memo, nil) + transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sdk.NewCoins(coin), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 110), 0, memo, emptyForwarding) res, err := suite.chainB.SendMsgs(transferMsg) suite.Require().NoError(err) // message committed @@ -520,7 +522,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { // send coin back from chainA to chainB coin = sdk.NewCoin(denom.IBCDenom(), amount) - transferMsg = types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(coin), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0, memo, nil) + transferMsg = types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(coin), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0, memo, emptyForwarding) _, err = suite.chainA.SendMsgs(transferMsg) suite.Require().NoError(err) // message committed @@ -532,7 +534,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { Denom: denom, Amount: amount.String(), }, - }, suite.chainA.SenderAccount.GetAddress().String(), receiver, memo, nil) + }, suite.chainA.SenderAccount.GetAddress().String(), receiver, memo, emptyForwarding) packet = channeltypes.NewPacket(data.GetBytes(), seq, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0) err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, data) @@ -610,7 +612,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacketSetsTotalEscrowAmountForSourceIBCT Denom: denom, Amount: amount.String(), }, - }, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", nil) + }, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", emptyForwarding) packet := channeltypes.NewPacket( data.GetBytes(), seq, @@ -741,7 +743,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { Denom: denom, Amount: amount.String(), }, - }, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", nil) + }, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "", emptyForwarding) packet := channeltypes.NewPacket(data.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0) preAcknowledgementBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom.IBCDenom()) @@ -836,7 +838,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacketSetsTotalEscrowAmountFo suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "", - nil, + emptyForwarding, ) packet := channeltypes.NewPacket( data.GetBytes(), @@ -976,7 +978,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { Denom: denom, Amount: amount, }, - }, sender, suite.chainB.SenderAccount.GetAddress().String(), "", nil) + }, sender, suite.chainB.SenderAccount.GetAddress().String(), "", emptyForwarding) packet := channeltypes.NewPacket(data.GetBytes(), 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0) preTimeoutBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom.IBCDenom()) @@ -1062,7 +1064,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacketSetsTotalEscrowAmountForSourceI Denom: denom, Amount: amount.String(), }, - }, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "", nil) + }, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "", emptyForwarding) packet := channeltypes.NewPacket( data.GetBytes(), seq, @@ -1269,7 +1271,7 @@ func (suite *KeeperTestSuite) TestCreatePacketDataBytesFromVersion() { types.V2, func() {}, func(bz []byte) { - expPacketData := types.NewFungibleTokenPacketDataV2(types.Tokens{types.Token{}}, "", "", "", nil) + expPacketData := types.NewFungibleTokenPacketDataV2(types.Tokens{types.Token{}}, "", "", "", emptyForwarding) suite.Require().Equal(bz, expPacketData.GetBytes()) }, nil, @@ -1299,7 +1301,7 @@ func (suite *KeeperTestSuite) TestCreatePacketDataBytesFromVersion() { tc.malleate() createFunc := func() { - bz = transferkeeper.CreatePacketDataBytesFromVersion(tc.appVersion, "", "", "", tokens, nil) + bz = transferkeeper.CreatePacketDataBytesFromVersion(tc.appVersion, "", "", "", tokens, emptyForwarding) } expPanic := tc.expPanicErr != nil diff --git a/modules/apps/transfer/transfer_test.go b/modules/apps/transfer/transfer_test.go index 9fad7947408..b3198fc8cc1 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, "", nil) + 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{}) res, err := suite.chainA.SendMsgs(msg) suite.Require().NoError(err) // message committed @@ -120,7 +120,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { traceBToC := types.NewTrace(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, "", nil) + 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{}) 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, "", nil) + 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{}) 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 e8bf83f8dbf..a95efebff85 100644 --- a/modules/apps/transfer/types/forwarding.go +++ b/modules/apps/transfer/types/forwarding.go @@ -9,8 +9,8 @@ import ( const MaximumNumberOfForwardingHops = 16 // denotes the maximum number of forwarding hops allowed // NewForwarding creates a new Forwarding instance given a memo and a variable number of hops. -func NewForwarding(memo string, hops ...Hop) *Forwarding { - return &Forwarding{ +func NewForwarding(memo string, hops ...Hop) Forwarding { + return Forwarding{ Memo: memo, Hops: hops, } diff --git a/modules/apps/transfer/types/forwarding_test.go b/modules/apps/transfer/types/forwarding_test.go index d9283164cf7..236f78d65d6 100644 --- a/modules/apps/transfer/types/forwarding_test.go +++ b/modules/apps/transfer/types/forwarding_test.go @@ -18,7 +18,7 @@ var validHop = types.Hop{ 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 bd34f6cce49..9a3d4b821fc 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, @@ -102,15 +102,13 @@ func (msg MsgTransfer) ValidateBasic() error { return errorsmod.Wrapf(ErrInvalidMemo, "memo must not exceed %d bytes", MaximumMemoLength) } - if msg.Forwarding != nil { - if err := msg.Forwarding.Validate(); err != nil { - return err - } + if err := msg.Forwarding.Validate(); err != nil { + return err + } - // We cannot have non-empty memo and non-empty forwarding hops at the same time. - if len(msg.Forwarding.Hops) > 0 && msg.Memo != "" { - return errorsmod.Wrapf(ErrInvalidMemo, "memo must be empty if forwarding path hops is not empty: %s, %s", msg.Memo, msg.Forwarding.Hops) - } + // We cannot have non-empty memo and non-empty forwarding hops at the same time. + if len(msg.Forwarding.Hops) > 0 && msg.Memo != "" { + return errorsmod.Wrapf(ErrInvalidMemo, "memo must be empty if forwarding path hops is not empty: %s, %s", msg.Memo, msg.Forwarding.Hops) } for _, coin := range msg.GetCoins() { diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index bc043339dc3..49caeb04831 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -47,7 +47,8 @@ var ( invalidDenomCoins = []sdk.Coin{{Denom: "0atom", Amount: sdkmath.NewInt(100)}} zeroCoins = []sdk.Coin{{Denom: "atoms", Amount: sdkmath.NewInt(0)}} - timeoutHeight = clienttypes.NewHeight(0, 10) + timeoutHeight = clienttypes.NewHeight(0, 10) + emptyForwarding = types.Forwarding{} ) // TestMsgTransferValidation tests ValidateBasic for MsgTransfer @@ -57,28 +58,28 @@ func TestMsgTransferValidation(t *testing.T) { msg *types.MsgTransfer expError error }{ - {"valid msg with base denom", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", nil), nil}, - {"valid msg with trace hash", types.NewMsgTransfer(validPort, validChannel, ibcCoins, sender, receiver, timeoutHeight, 0, "", nil), nil}, - {"multidenom", types.NewMsgTransfer(validPort, validChannel, coins.Add(ibcCoins...), sender, receiver, timeoutHeight, 0, "", nil), nil}, - {"invalid ibc denom", types.NewMsgTransfer(validPort, validChannel, invalidIBCCoins, sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"too short port id", types.NewMsgTransfer(invalidShortPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", nil), host.ErrInvalidID}, - {"too long port id", types.NewMsgTransfer(invalidLongPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", nil), host.ErrInvalidID}, - {"port id contains non-alpha", types.NewMsgTransfer(invalidPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", nil), host.ErrInvalidID}, - {"too short channel id", types.NewMsgTransfer(validPort, invalidShortChannel, coins, sender, receiver, timeoutHeight, 0, "", nil), host.ErrInvalidID}, - {"too long channel id", types.NewMsgTransfer(validPort, invalidLongChannel, coins, sender, receiver, timeoutHeight, 0, "", nil), host.ErrInvalidID}, - {"too long memo", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, timeoutHeight, 0, ibctesting.GenerateString(types.MaximumMemoLength+1), nil), types.ErrInvalidMemo}, - {"channel id contains non-alpha", types.NewMsgTransfer(validPort, invalidChannel, coins, sender, receiver, timeoutHeight, 0, "", nil), host.ErrInvalidID}, - {"invalid denom", types.NewMsgTransfer(validPort, validChannel, invalidDenomCoins, sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"zero coins", types.NewMsgTransfer(validPort, validChannel, zeroCoins, sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"missing sender address", types.NewMsgTransfer(validPort, validChannel, coins, emptyAddr, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidAddress}, - {"missing recipient address", types.NewMsgTransfer(validPort, validChannel, coins, sender, "", timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidAddress}, - {"too long recipient address", types.NewMsgTransfer(validPort, validChannel, coins, sender, ibctesting.GenerateString(types.MaximumReceiverLength+1), timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidAddress}, - {"empty coins", types.NewMsgTransfer(validPort, validChannel, sdk.NewCoins(), sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"multidenom: invalid denom", types.NewMsgTransfer(validPort, validChannel, coins.Add(invalidDenomCoins...), sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"multidenom: invalid ibc denom", types.NewMsgTransfer(validPort, validChannel, coins.Add(invalidIBCCoins...), sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"multidenom: zero coins", types.NewMsgTransfer(validPort, validChannel, zeroCoins, sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"multidenom: too many coins", types.NewMsgTransfer(validPort, validChannel, make([]sdk.Coin, types.MaximumTokensLength+1), sender, receiver, timeoutHeight, 0, "", nil), ibcerrors.ErrInvalidCoins}, - {"multidenom: both token and tokens are set", &types.MsgTransfer{validPort, validChannel, coin, sender, receiver, timeoutHeight, 0, "", coins, nil}, ibcerrors.ErrInvalidCoins}, + {"valid msg with base denom", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), nil}, + {"valid msg with trace hash", types.NewMsgTransfer(validPort, validChannel, ibcCoins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), nil}, + {"multidenom", types.NewMsgTransfer(validPort, validChannel, coins.Add(ibcCoins...), sender, receiver, timeoutHeight, 0, "", emptyForwarding), nil}, + {"invalid ibc denom", types.NewMsgTransfer(validPort, validChannel, invalidIBCCoins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"too short port id", types.NewMsgTransfer(invalidShortPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), host.ErrInvalidID}, + {"too long port id", types.NewMsgTransfer(invalidLongPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), host.ErrInvalidID}, + {"port id contains non-alpha", types.NewMsgTransfer(invalidPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), host.ErrInvalidID}, + {"too short channel id", types.NewMsgTransfer(validPort, invalidShortChannel, coins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), host.ErrInvalidID}, + {"too long channel id", types.NewMsgTransfer(validPort, invalidLongChannel, coins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), host.ErrInvalidID}, + {"too long memo", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, timeoutHeight, 0, ibctesting.GenerateString(types.MaximumMemoLength+1), emptyForwarding), types.ErrInvalidMemo}, + {"channel id contains non-alpha", types.NewMsgTransfer(validPort, invalidChannel, coins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), host.ErrInvalidID}, + {"invalid denom", types.NewMsgTransfer(validPort, validChannel, invalidDenomCoins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"zero coins", types.NewMsgTransfer(validPort, validChannel, zeroCoins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"missing sender address", types.NewMsgTransfer(validPort, validChannel, coins, emptyAddr, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidAddress}, + {"missing recipient address", types.NewMsgTransfer(validPort, validChannel, coins, sender, "", timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidAddress}, + {"too long recipient address", types.NewMsgTransfer(validPort, validChannel, coins, sender, ibctesting.GenerateString(types.MaximumReceiverLength+1), timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidAddress}, + {"empty coins", types.NewMsgTransfer(validPort, validChannel, sdk.NewCoins(), sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"multidenom: invalid denom", types.NewMsgTransfer(validPort, validChannel, coins.Add(invalidDenomCoins...), sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"multidenom: invalid ibc denom", types.NewMsgTransfer(validPort, validChannel, coins.Add(invalidIBCCoins...), sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"multidenom: zero coins", types.NewMsgTransfer(validPort, validChannel, zeroCoins, sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"multidenom: too many coins", types.NewMsgTransfer(validPort, validChannel, make([]sdk.Coin, types.MaximumTokensLength+1), sender, receiver, timeoutHeight, 0, "", emptyForwarding), ibcerrors.ErrInvalidCoins}, + {"multidenom: both token and tokens are set", &types.MsgTransfer{validPort, validChannel, coin, sender, receiver, timeoutHeight, 0, "", coins, emptyForwarding}, ibcerrors.ErrInvalidCoins}, {"memo must be empty if forwarding path hops is not empty", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "memo", types.NewForwarding("", validHop)), types.ErrInvalidMemo}, {"invalid forwarding info port", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", types.NewForwarding("", types.Hop{PortId: invalidPort, ChannelId: validChannel})), host.ErrInvalidID}, {"invalid forwarding info channel", types.NewMsgTransfer(validPort, validChannel, coins, sender, receiver, timeoutHeight, 0, "", types.NewForwarding("", types.Hop{PortId: validPort, ChannelId: invalidChannel})), host.ErrInvalidID}, @@ -103,7 +104,7 @@ func TestMsgTransferValidation(t *testing.T) { // TestMsgTransferGetSigners tests GetSigners for MsgTransfer func TestMsgTransferGetSigners(t *testing.T) { addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - msg := types.NewMsgTransfer(validPort, validChannel, coins, addr.String(), receiver, timeoutHeight, 0, "", nil) + msg := types.NewMsgTransfer(validPort, validChannel, coins, addr.String(), receiver, timeoutHeight, 0, "", emptyForwarding) encodingCfg := moduletestutil.MakeTestEncodingConfig(transfer.AppModuleBasic{}) signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) diff --git a/modules/apps/transfer/types/packet.go b/modules/apps/transfer/types/packet.go index b00ccc6e957..6f74c1f4d54 100644 --- a/modules/apps/transfer/types/packet.go +++ b/modules/apps/transfer/types/packet.go @@ -103,7 +103,7 @@ func NewFungibleTokenPacketDataV2( tokens []Token, sender, receiver string, memo string, - forwarding *Forwarding, + forwarding Forwarding, ) FungibleTokenPacketDataV2 { return FungibleTokenPacketDataV2{ Tokens: tokens, @@ -140,15 +140,13 @@ func (ftpd FungibleTokenPacketDataV2) ValidateBasic() error { return errorsmod.Wrapf(ErrInvalidMemo, "memo must not exceed %d bytes", MaximumMemoLength) } - if ftpd.Forwarding != nil { - if err := ftpd.Forwarding.Validate(); err != nil { - return err - } + if err := ftpd.Forwarding.Validate(); err != nil { + return err + } - // We cannot have non-empty memo and non-empty forwarding path hops at the same time. - if len(ftpd.Forwarding.Hops) > 0 && ftpd.Memo != "" { - return errorsmod.Wrapf(ErrInvalidMemo, "memo must be empty if forwarding path hops is not empty: %s, %s", ftpd.Memo, ftpd.Forwarding.Hops) - } + // We cannot have non-empty memo and non-empty forwarding path hops at the same time. + if len(ftpd.Forwarding.Hops) > 0 && ftpd.Memo != "" { + return errorsmod.Wrapf(ErrInvalidMemo, "memo must be empty if forwarding path hops is not empty: %s, %s", ftpd.Memo, ftpd.Forwarding.Hops) } return nil @@ -199,5 +197,5 @@ func (ftpd FungibleTokenPacketDataV2) GetPacketSender(sourcePortID string) strin // ShouldBeForwarded determines if the packet should be forwarded to the next hop. func (ftpd FungibleTokenPacketDataV2) ShouldBeForwarded() bool { - return ftpd.Forwarding != nil && len(ftpd.Forwarding.Hops) > 0 + return len(ftpd.Forwarding.Hops) > 0 } diff --git a/modules/apps/transfer/types/packet.pb.go b/modules/apps/transfer/types/packet.pb.go index 4004072b664..fd02225dc97 100644 --- a/modules/apps/transfer/types/packet.pb.go +++ b/modules/apps/transfer/types/packet.pb.go @@ -120,7 +120,7 @@ type FungibleTokenPacketDataV2 struct { // optional memo Memo string `protobuf:"bytes,4,opt,name=memo,proto3" json:"memo,omitempty"` // optional forwarding information - Forwarding *Forwarding `protobuf:"bytes,5,opt,name=forwarding,proto3" json:"forwarding,omitempty"` + Forwarding Forwarding `protobuf:"bytes,5,opt,name=forwarding,proto3" json:"forwarding"` } func (m *FungibleTokenPacketDataV2) Reset() { *m = FungibleTokenPacketDataV2{} } @@ -184,11 +184,11 @@ func (m *FungibleTokenPacketDataV2) GetMemo() string { return "" } -func (m *FungibleTokenPacketDataV2) GetForwarding() *Forwarding { +func (m *FungibleTokenPacketDataV2) GetForwarding() Forwarding { if m != nil { return m.Forwarding } - return nil + return Forwarding{} } func init() { @@ -202,29 +202,29 @@ func init() { var fileDescriptor_653ca2ce9a5ca313 = []byte{ // 365 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0xc1, 0x8e, 0xd3, 0x30, - 0x14, 0x8c, 0xdb, 0xb4, 0x02, 0xf7, 0x66, 0x55, 0x10, 0x2a, 0x14, 0xaa, 0x72, 0x09, 0x42, 0xd8, - 0x6a, 0x38, 0xc0, 0x95, 0x0a, 0x55, 0x1c, 0xa1, 0x42, 0x1c, 0xb8, 0x39, 0x8e, 0x1b, 0xac, 0x36, - 0x76, 0x64, 0x3b, 0x41, 0xfb, 0x15, 0xbb, 0x9f, 0xd5, 0x63, 0x8f, 0x7b, 0x5a, 0xad, 0xda, 0x1f, - 0xd8, 0x4f, 0x58, 0xc5, 0xe9, 0x76, 0x73, 0x69, 0x6e, 0x33, 0xe3, 0x79, 0xa3, 0xf1, 0x7b, 0xf0, - 0x83, 0x48, 0x18, 0xa1, 0x45, 0xb1, 0x15, 0x8c, 0x5a, 0xa1, 0xa4, 0x21, 0x56, 0x53, 0x69, 0xd6, - 0x5c, 0x93, 0x2a, 0x26, 0x05, 0x65, 0x1b, 0x6e, 0x71, 0xa1, 0x95, 0x55, 0xe8, 0xad, 0x48, 0x18, - 0x6e, 0x5b, 0xf1, 0x93, 0x15, 0x57, 0xf1, 0x24, 0xea, 0x0c, 0xb2, 0x6a, 0xc3, 0x65, 0x93, 0x33, - 0x19, 0x67, 0x2a, 0x53, 0x0e, 0x92, 0x1a, 0x9d, 0xd4, 0x8f, 0x1d, 0xf3, 0xf3, 0x33, 0x6e, 0xcc, - 0xb3, 0x6b, 0x00, 0x5f, 0x2f, 0x4b, 0x99, 0x89, 0x64, 0xcb, 0x7f, 0xd7, 0xd1, 0x3f, 0x5d, 0xd1, - 0xef, 0xd4, 0x52, 0x34, 0x86, 0x83, 0x94,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 0xcf, 0x8f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x75, 0x75, 0x92, 0xad, 0x96, 0x02, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xb1, 0xae, 0xd3, 0x30, + 0x18, 0x85, 0xe3, 0x36, 0xad, 0xc0, 0xdd, 0xac, 0x0a, 0x42, 0x85, 0x42, 0x55, 0x96, 0x20, 0x84, + 0xad, 0x86, 0x01, 0x56, 0x2a, 0xd4, 0x11, 0x41, 0x85, 0x18, 0xd8, 0x1c, 0xc7, 0x0d, 0x56, 0x1b, + 0x3b, 0xb2, 0x9d, 0x20, 0x9e, 0x02, 0x1e, 0xab, 0x63, 0x47, 0xa6, 0xab, 0xab, 0xf6, 0x1d, 0xee, + 0x7c, 0x15, 0x27, 0xb7, 0x37, 0x4b, 0xb3, 0xfd, 0xe7, 0xe4, 0xf8, 0xe8, 0xcb, 0xff, 0xc3, 0x37, + 0x22, 0x61, 0x84, 0x16, 0xc5, 0x5e, 0x30, 0x6a, 0x85, 0x92, 0x86, 0x58, 0x4d, 0xa5, 0xd9, 0x72, + 0x4d, 0xaa, 0x98, 0x14, 0x94, 0xed, 0xb8, 0xc5, 0x85, 0x56, 0x56, 0xa1, 0x97, 0x22, 0x61, 0xb8, + 0x1b, 0xc5, 0x0f, 0x51, 0x5c, 0xc5, 0xb3, 0xa8, 0xb7, 0xc8, 0xaa, 0x1d, 0x97, 0x4d, 0xcf, 0x6c, + 0x9a, 0xa9, 0x4c, 0xb9, 0x91, 0xd4, 0x53, 0xeb, 0xbe, 0xed, 0x79, 0xbf, 0xbc, 0xcc, 0x4d, 0x78, + 0xf1, 0x17, 0xc0, 0xe7, 0xeb, 0x52, 0x66, 0x22, 0xd9, 0xf3, 0xef, 0x75, 0xf5, 0x57, 0x07, 0xfa, + 0x99, 0x5a, 0x8a, 0xa6, 0x70, 0x94, 0x72, 0xa9, 0xf2, 0x00,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 0x00, 0x00, 0xff, 0xff, 0xfe, 0xa2, 0xd3, 0x30, 0x9c, 0x02, 0x00, 0x00, } func (m *FungibleTokenPacketData) Marshal() (dAtA []byte, err error) { @@ -305,18 +305,16 @@ func (m *FungibleTokenPacketDataV2) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if m.Forwarding != nil { - { - size, err := m.Forwarding.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPacket(dAtA, i, uint64(size)) + { + size, err := m.Forwarding.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x2a + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x2a if len(m.Memo) > 0 { i -= len(m.Memo) copy(dAtA[i:], m.Memo) @@ -419,10 +417,8 @@ func (m *FungibleTokenPacketDataV2) Size() (n int) { if l > 0 { n += 1 + l + sovPacket(uint64(l)) } - if m.Forwarding != nil { - l = m.Forwarding.Size() - n += 1 + l + sovPacket(uint64(l)) - } + l = m.Forwarding.Size() + n += 1 + l + sovPacket(uint64(l)) return n } @@ -830,9 +826,6 @@ func (m *FungibleTokenPacketDataV2) 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/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index e2af7801931..69b7a30068b 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -183,7 +183,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), nil, }, @@ -199,7 +199,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "memo", - nil, + emptyForwarding, ), nil, }, @@ -215,7 +215,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "memo", - nil, + emptyForwarding, ), nil, }, @@ -263,7 +263,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), types.ErrInvalidDenomForTransfer, }, @@ -279,7 +279,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), types.ErrInvalidAmount, }, @@ -290,7 +290,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), types.ErrInvalidAmount, }, @@ -306,7 +306,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), types.ErrInvalidAmount, }, @@ -322,7 +322,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), types.ErrInvalidAmount, }, @@ -338,7 +338,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, "memo", - nil, + emptyForwarding, ), types.ErrInvalidAmount, }, @@ -354,7 +354,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { "", receiver, "memo", - nil, + emptyForwarding, ), ibcerrors.ErrInvalidAddress, }, @@ -370,7 +370,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, "", "", - nil, + emptyForwarding, ), ibcerrors.ErrInvalidAddress, }, @@ -386,7 +386,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { sender, receiver, ibctesting.GenerateString(types.MaximumMemoLength+1), - nil, + emptyForwarding, ), types.ErrInvalidMemo, }, @@ -516,7 +516,7 @@ func TestGetPacketSender(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), sender, }, @@ -532,7 +532,7 @@ func TestGetPacketSender(t *testing.T) { "", receiver, "abc", - nil, + emptyForwarding, ), "", }, @@ -563,7 +563,7 @@ func TestPacketDataProvider(t *testing.T) { sender, receiver, fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, receiver), - nil, + emptyForwarding, ), map[string]interface{}{ @@ -582,7 +582,7 @@ func TestPacketDataProvider(t *testing.T) { sender, receiver, fmt.Sprintf(`{"src_callback": {"address": "%s", "gas_limit": "200000"}}`, receiver), - nil, + emptyForwarding, ), map[string]interface{}{ "address": receiver, @@ -601,7 +601,7 @@ func TestPacketDataProvider(t *testing.T) { sender, receiver, `{"src_callback": "string"}`, - nil, + emptyForwarding, ), "string", }, @@ -617,7 +617,7 @@ func TestPacketDataProvider(t *testing.T) { sender, receiver, fmt.Sprintf(`{"dest_callback": {"address": "%s", "min_gas": "200000"}}`, receiver), - nil, + emptyForwarding, ), nil, }, @@ -633,7 +633,7 @@ func TestPacketDataProvider(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), nil, }, @@ -649,7 +649,7 @@ func TestPacketDataProvider(t *testing.T) { sender, receiver, "invalid", - nil, + emptyForwarding, ), nil, }, @@ -681,7 +681,7 @@ func TestFungibleTokenPacketDataOmitEmpty(t *testing.T) { sender, receiver, "", - nil, + emptyForwarding, ), false, }, @@ -697,7 +697,7 @@ func TestFungibleTokenPacketDataOmitEmpty(t *testing.T) { sender, receiver, "abc", - nil, + emptyForwarding, ), true, }, diff --git a/modules/apps/transfer/types/transfer_authorization.go b/modules/apps/transfer/types/transfer_authorization.go index 8d8ca7dbcaf..0d59e9bdc94 100644 --- a/modules/apps/transfer/types/transfer_authorization.go +++ b/modules/apps/transfer/types/transfer_authorization.go @@ -60,7 +60,7 @@ func (a TransferAuthorization) Accept(goCtx context.Context, msg proto.Message) memo := msgTransfer.Memo // in the case of forwarded transfers, the actual memo is stored in the forwarding path until the final destination - if msgTransfer.Forwarding != nil && len(msgTransfer.Forwarding.Hops) > 0 { + if len(msgTransfer.Forwarding.Hops) > 0 { memo = msgTransfer.Forwarding.Memo } diff --git a/modules/apps/transfer/types/transfer_authorization_test.go b/modules/apps/transfer/types/transfer_authorization_test.go index 718d299aac5..0b108525709 100644 --- a/modules/apps/transfer/types/transfer_authorization_test.go +++ b/modules/apps/transfer/types/transfer_authorization_test.go @@ -299,7 +299,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { suite.chainB.GetTimeoutHeight(), 0, "", - nil, + emptyForwarding, ) }, func(res authz.AcceptResponse, err error) { @@ -342,7 +342,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { suite.chainB.GetTimeoutHeight(), 0, "", - nil, + emptyForwarding, ) }, func(res authz.AcceptResponse, err error) { @@ -379,7 +379,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { suite.chainB.GetTimeoutHeight(), 0, "", - nil, + emptyForwarding, ) }, func(res authz.AcceptResponse, err error) { @@ -420,7 +420,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { suite.chainB.GetTimeoutHeight(), 0, "", - nil, + emptyForwarding, ) tc.malleate() diff --git a/modules/apps/transfer/types/tx.pb.go b/modules/apps/transfer/types/tx.pb.go index 66acd8c1238..518107142a6 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,omitempty"` + Forwarding Forwarding `protobuf:"bytes,10,opt,name=forwarding,proto3" json:"forwarding"` } 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, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0x6f, 0x58, 0x57, 0x36, 0x97, 0x6d, 0xcc, 0xa0, 0x2d, 0x8b, 0x50, 0x5a, 0x55, 0x4c, 0x2a, - 0x9d, 0x66, 0xab, 0x43, 0x68, 0x68, 0xe2, 0xd4, 0x49, 0x68, 0x07, 0x26, 0x8d, 0x68, 0x5c, 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,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x00, 0x00, 0xff, 0xff, 0xaf, 0x48, 0x04, 0x1e, 0x21, 0x05, 0x00, 0x00, } @@ -410,18 +410,16 @@ func (m *MsgTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - 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)) + { + size, err := m.Forwarding.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x52 + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x52 if len(m.Tokens) > 0 { for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { { @@ -640,10 +638,8 @@ func (m *MsgTransfer) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } } - if m.Forwarding != nil { - l = m.Forwarding.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = m.Forwarding.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -1026,9 +1022,6 @@ 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 0a1c8d49d8c..6a422d0c74d 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; + Forwarding forwarding = 10 [(gogoproto.nullable) = false]; } // MsgTransferResponse defines the Msg/Transfer response type. diff --git a/proto/ibc/applications/transfer/v2/packet.proto b/proto/ibc/applications/transfer/v2/packet.proto index a2948f5b996..9999e7ea87c 100644 --- a/proto/ibc/applications/transfer/v2/packet.proto +++ b/proto/ibc/applications/transfer/v2/packet.proto @@ -37,5 +37,5 @@ message FungibleTokenPacketDataV2 { // optional memo string memo = 4; // optional forwarding information - ibc.applications.transfer.v1.Forwarding forwarding = 5; + ibc.applications.transfer.v1.Forwarding forwarding = 5 [(gogoproto.nullable) = false]; } diff --git a/testing/solomachine.go b/testing/solomachine.go index c97ced04875..74a127686a6 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -378,7 +378,7 @@ func (solo *Solomachine) SendTransfer(chain *TestChain, portID, channelID string clienttypes.ZeroHeight(), uint64(chain.GetContext().BlockTime().Add(time.Hour).UnixNano()), "", - nil, + transfertypes.Forwarding{}, ) for _, fn := range fns {