From 0d120b92c173ca876ef2d54c65ad30c4a09e0ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 8 Apr 2021 14:50:55 +0200 Subject: [PATCH 1/2] Modify all message constructors to take in a string for address All NewMsg() functions take in the signer as a string. This prevents bugs from happening at the level of the caller since String relies on external context --- modules/apps/transfer/client/cli/tx.go | 2 +- modules/apps/transfer/handler_test.go | 6 +-- modules/apps/transfer/keeper/relay_test.go | 8 +-- modules/apps/transfer/types/msgs.go | 8 +-- modules/apps/transfer/types/msgs_test.go | 10 ++-- modules/apps/transfer/types/packet_test.go | 10 ++-- modules/core/02-client/client/cli/tx.go | 8 +-- modules/core/02-client/keeper/client_test.go | 4 +- modules/core/02-client/types/msgs.go | 16 +++--- modules/core/02-client/types/msgs_test.go | 52 +++++++++---------- modules/core/03-connection/client/cli/tx.go | 8 +-- modules/core/03-connection/types/msgs.go | 16 +++--- modules/core/03-connection/types/msgs_test.go | 24 ++++----- modules/core/04-channel/client/cli/tx.go | 12 ++--- modules/core/04-channel/types/msgs.go | 40 +++++++------- modules/core/04-channel/types/msgs_test.go | 10 ++-- modules/core/keeper/msg_server_test.go | 14 ++--- testing/chain.go | 22 ++++---- testing/coordinator.go | 4 +- 19 files changed, 136 insertions(+), 138 deletions(-) diff --git a/modules/apps/transfer/client/cli/tx.go b/modules/apps/transfer/client/cli/tx.go index 0efba3b4499..c1cbc9f9ca8 100644 --- a/modules/apps/transfer/client/cli/tx.go +++ b/modules/apps/transfer/client/cli/tx.go @@ -40,7 +40,7 @@ to the counterparty channel. Any timeout set to 0 is disabled.`), if err != nil { return err } - sender := clientCtx.GetFromAddress() + sender := clientCtx.GetFromAddress().String() srcPort := args[0] srcChannel := args[1] receiver := args[2] diff --git a/modules/apps/transfer/handler_test.go b/modules/apps/transfer/handler_test.go index 5d4d95d7aa8..03129ba91c0 100644 --- a/modules/apps/transfer/handler_test.go +++ b/modules/apps/transfer/handler_test.go @@ -43,7 +43,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) // send from chainA to chainB - msg := types.NewMsgTransfer(channelA.PortID, channelA.ID, coinToSendToB, suite.chainA.SenderAccount.GetAddress(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0) + msg := types.NewMsgTransfer(channelA.PortID, channelA.ID, coinToSendToB, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0) err := suite.coordinator.SendMsg(suite.chainA, suite.chainB, clientB, msg) suite.Require().NoError(err) // message committed @@ -67,7 +67,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { channelOnBForC, channelOnCForB := suite.coordinator.CreateTransferChannels(suite.chainB, suite.chainC, connOnBForC, connOnCForB, channeltypes.UNORDERED) // send from chainB to chainC - msg = types.NewMsgTransfer(channelOnBForC.PortID, channelOnBForC.ID, coinSentFromAToB, suite.chainB.SenderAccount.GetAddress(), suite.chainC.SenderAccount.GetAddress().String(), timeoutHeight, 0) + msg = types.NewMsgTransfer(channelOnBForC.PortID, channelOnBForC.ID, coinSentFromAToB, suite.chainB.SenderAccount.GetAddress().String(), suite.chainC.SenderAccount.GetAddress().String(), timeoutHeight, 0) err = suite.coordinator.SendMsg(suite.chainB, suite.chainC, clientOnCForB, msg) suite.Require().NoError(err) // message committed @@ -91,7 +91,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { suite.Require().Zero(balance.Amount.Int64()) // send from chainC back to chainB - msg = types.NewMsgTransfer(channelOnCForB.PortID, channelOnCForB.ID, coinSentFromBToC, suite.chainC.SenderAccount.GetAddress(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0) + msg = types.NewMsgTransfer(channelOnCForB.PortID, channelOnCForB.ID, coinSentFromBToC, suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0) err = suite.coordinator.SendMsg(suite.chainC, suite.chainB, clientOnBForC, msg) suite.Require().NoError(err) // message committed diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 2f754e60597..e67d2f8af88 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -103,7 +103,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { if !tc.sendFromSource { // send coin from chainB to chainA coinFromBToA := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - transferMsg := types.NewMsgTransfer(channelB.PortID, channelB.ID, coinFromBToA, suite.chainB.SenderAccount.GetAddress(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(0, 110), 0) + transferMsg := types.NewMsgTransfer(channelB.PortID, channelB.ID, coinFromBToA, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(0, 110), 0) err = suite.coordinator.SendMsg(suite.chainB, suite.chainA, channelA.ClientID, transferMsg) suite.Require().NoError(err) // message committed @@ -115,7 +115,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetKey) - recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainA.SenderAccount.GetAddress()) + recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) err = suite.coordinator.SendMsg(suite.chainA, suite.chainB, channelB.ClientID, recvMsg) suite.Require().NoError(err) // message committed } @@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { if tc.recvIsSource { // send coin from chainB to chainA, receive them, acknowledge them, and send back to chainB coinFromBToA := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - transferMsg := types.NewMsgTransfer(channelB.PortID, channelB.ID, coinFromBToA, suite.chainB.SenderAccount.GetAddress(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(0, 110), 0) + transferMsg := types.NewMsgTransfer(channelB.PortID, channelB.ID, coinFromBToA, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(0, 110), 0) err := suite.coordinator.SendMsg(suite.chainB, suite.chainA, channelA.ClientID, transferMsg) suite.Require().NoError(err) // message committed @@ -210,7 +210,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { } // send coin from chainA to chainB - transferMsg := types.NewMsgTransfer(channelA.PortID, channelA.ID, sdk.NewCoin(trace.IBCDenom(), amount), suite.chainA.SenderAccount.GetAddress(), receiver, clienttypes.NewHeight(0, 110), 0) + transferMsg := types.NewMsgTransfer(channelA.PortID, channelA.ID, sdk.NewCoin(trace.IBCDenom(), amount), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(0, 110), 0) err := suite.coordinator.SendMsg(suite.chainA, suite.chainB, channelB.ClientID, transferMsg) suite.Require().NoError(err) // message committed diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 6985e3b9dfc..b45dca98afb 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -18,14 +18,14 @@ const ( //nolint:interfacer func NewMsgTransfer( sourcePort, sourceChannel string, - token sdk.Coin, sender sdk.AccAddress, receiver string, + token sdk.Coin, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, ) *MsgTransfer { return &MsgTransfer{ SourcePort: sourcePort, SourceChannel: sourceChannel, Token: token, - Sender: sender.String(), + Sender: sender, Receiver: receiver, TimeoutHeight: timeoutHeight, TimeoutTimestamp: timeoutTimestamp, @@ -77,9 +77,9 @@ func (msg MsgTransfer) GetSignBytes() []byte { // GetSigners implements sdk.Msg func (msg MsgTransfer) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.AccAddressFromBech32(msg.Sender) + signer, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { panic(err) } - return []sdk.AccAddress{valAddr} + return []sdk.AccAddress{signer} } diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 2d24438f603..6e63b5ed30f 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -25,9 +25,9 @@ const ( ) var ( - addr1 = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + addr1 = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() addr2 = sdk.AccAddress("testaddr2").String() - emptyAddr sdk.AccAddress + emptyAddr string coin = sdk.NewCoin("atom", sdk.NewInt(100)) ibcCoin = sdk.NewCoin("ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.NewInt(100)) @@ -96,8 +96,10 @@ func TestMsgTransferValidation(t *testing.T) { // TestMsgTransferGetSigners tests GetSigners for MsgTransfer func TestMsgTransferGetSigners(t *testing.T) { - msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, timeoutHeight, 0) + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + msg := NewMsgTransfer(validPort, validChannel, coin, addr.String(), addr2, timeoutHeight, 0) res := msg.GetSigners() - require.Equal(t, []sdk.AccAddress{addr1}, res) + require.Equal(t, []sdk.AccAddress{addr}, res) } diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index 1edcb093d3c..6b16095b0b5 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -18,11 +18,11 @@ func TestFungibleTokenPacketDataValidateBasic(t *testing.T) { packetData FungibleTokenPacketData expPass bool }{ - {"valid packet", NewFungibleTokenPacketData(denom, amount, addr1.String(), addr2), true}, - {"invalid denom", NewFungibleTokenPacketData("", amount, addr1.String(), addr2), false}, - {"invalid amount", NewFungibleTokenPacketData(denom, 0, addr1.String(), addr2), false}, - {"missing sender address", NewFungibleTokenPacketData(denom, amount, emptyAddr.String(), addr2), false}, - {"missing recipient address", NewFungibleTokenPacketData(denom, amount, addr1.String(), emptyAddr.String()), false}, + {"valid packet", NewFungibleTokenPacketData(denom, amount, addr1, addr2), true}, + {"invalid denom", NewFungibleTokenPacketData("", amount, addr1, addr2), false}, + {"invalid amount", NewFungibleTokenPacketData(denom, 0, addr1, addr2), false}, + {"missing sender address", NewFungibleTokenPacketData(denom, amount, emptyAddr, addr2), false}, + {"missing recipient address", NewFungibleTokenPacketData(denom, amount, addr1, emptyAddr), false}, } for i, tc := range testCases { diff --git a/modules/core/02-client/client/cli/tx.go b/modules/core/02-client/client/cli/tx.go index 78a660127fc..64d7b97f836 100644 --- a/modules/core/02-client/client/cli/tx.go +++ b/modules/core/02-client/client/cli/tx.go @@ -71,7 +71,7 @@ func NewCreateClientCmd() *cobra.Command { } } - msg, err := types.NewMsgCreateClient(clientState, consensusState, clientCtx.GetFromAddress()) + msg, err := types.NewMsgCreateClient(clientState, consensusState, clientCtx.GetFromAddress().String()) if err != nil { return err } @@ -124,7 +124,7 @@ func NewUpdateClientCmd() *cobra.Command { } } - msg, err := types.NewMsgUpdateClient(clientID, header, clientCtx.GetFromAddress()) + msg, err := types.NewMsgUpdateClient(clientID, header, clientCtx.GetFromAddress().String()) if err != nil { return err } @@ -172,7 +172,7 @@ func NewSubmitMisbehaviourCmd() *cobra.Command { } } - msg, err := types.NewMsgSubmitMisbehaviour(misbehaviour.GetClientID(), misbehaviour, clientCtx.GetFromAddress()) + msg, err := types.NewMsgSubmitMisbehaviour(misbehaviour.GetClientID(), misbehaviour, clientCtx.GetFromAddress().String()) if err != nil { return err } @@ -242,7 +242,7 @@ func NewUpgradeClientCmd() *cobra.Command { proofUpgradeClient := []byte(args[3]) proofUpgradeConsensus := []byte(args[4]) - msg, err := types.NewMsgUpgradeClient(clientID, clientState, consensusState, proofUpgradeClient, proofUpgradeConsensus, clientCtx.GetFromAddress()) + msg, err := types.NewMsgUpgradeClient(clientID, clientState, consensusState, proofUpgradeClient, proofUpgradeConsensus, clientCtx.GetFromAddress().String()) if err != nil { return err } diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index 21002d175b0..69e0953be74 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -7,6 +7,7 @@ import ( tmtypes "github.com/tendermint/tendermint/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/cosmos/ibc-go/modules/core/02-client/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types" @@ -15,7 +16,6 @@ import ( localhosttypes "github.com/cosmos/ibc-go/modules/light-clients/09-localhost/types" ibctesting "github.com/cosmos/ibc-go/testing" ibctestingmock "github.com/cosmos/ibc-go/testing/mock" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) func (suite *KeeperTestSuite) TestCreateClient() { @@ -598,7 +598,7 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() { msg, err := clienttypes.NewMsgUpdateClient( clientID, header, - suite.chainA.SenderAccount.GetAddress(), + suite.chainA.SenderAccount.GetAddress().String(), ) result, err := suite.chainA.SendMsgs(msg) diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index bc17c6751e1..46538c95580 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -31,7 +31,7 @@ var ( // NewMsgCreateClient creates a new MsgCreateClient instance //nolint:interfacer func NewMsgCreateClient( - clientState exported.ClientState, consensusState exported.ConsensusState, signer sdk.AccAddress, + clientState exported.ClientState, consensusState exported.ConsensusState, signer string, ) (*MsgCreateClient, error) { anyClientState, err := PackClientState(clientState) @@ -47,7 +47,7 @@ func NewMsgCreateClient( return &MsgCreateClient{ ClientState: anyClientState, ConsensusState: anyConsensusState, - Signer: signer.String(), + Signer: signer, }, nil } @@ -119,7 +119,7 @@ func (msg MsgCreateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err // NewMsgUpdateClient creates a new MsgUpdateClient instance //nolint:interfacer -func NewMsgUpdateClient(id string, header exported.Header, signer sdk.AccAddress) (*MsgUpdateClient, error) { +func NewMsgUpdateClient(id string, header exported.Header, signer string) (*MsgUpdateClient, error) { anyHeader, err := PackHeader(header) if err != nil { return nil, err @@ -128,7 +128,7 @@ func NewMsgUpdateClient(id string, header exported.Header, signer sdk.AccAddress return &MsgUpdateClient{ ClientId: id, Header: anyHeader, - Signer: signer.String(), + Signer: signer, }, nil } @@ -185,7 +185,7 @@ func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err // NewMsgUpgradeClient creates a new MsgUpgradeClient instance // nolint: interfacer func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, consState exported.ConsensusState, - proofUpgradeClient, proofUpgradeConsState []byte, signer sdk.AccAddress) (*MsgUpgradeClient, error) { + proofUpgradeClient, proofUpgradeConsState []byte, signer string) (*MsgUpgradeClient, error) { anyClient, err := PackClientState(clientState) if err != nil { return nil, err @@ -201,7 +201,7 @@ func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, cons ConsensusState: anyConsState, ProofUpgradeClient: proofUpgradeClient, ProofUpgradeConsensusState: proofUpgradeConsState, - Signer: signer.String(), + Signer: signer, }, nil } @@ -276,7 +276,7 @@ func (msg MsgUpgradeClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) er // NewMsgSubmitMisbehaviour creates a new MsgSubmitMisbehaviour instance. //nolint:interfacer -func NewMsgSubmitMisbehaviour(clientID string, misbehaviour exported.Misbehaviour, signer sdk.AccAddress) (*MsgSubmitMisbehaviour, error) { +func NewMsgSubmitMisbehaviour(clientID string, misbehaviour exported.Misbehaviour, signer string) (*MsgSubmitMisbehaviour, error) { anyMisbehaviour, err := PackMisbehaviour(misbehaviour) if err != nil { return nil, err @@ -285,7 +285,7 @@ func NewMsgSubmitMisbehaviour(clientID string, misbehaviour exported.Misbehaviou return &MsgSubmitMisbehaviour{ ClientId: clientID, Misbehaviour: anyMisbehaviour, - Signer: signer.String(), + Signer: signer, }, nil } diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 9019f13395d..7efc07b42d1 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -49,14 +49,14 @@ func (suite *TypesTestSuite) TestMarshalMsgCreateClient() { { "solo machine client", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgCreateClient(soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, }, { "tendermint client", func() { tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) - msg, err = types.NewMsgCreateClient(tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, }, @@ -101,7 +101,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { "valid - tendermint client", func() { tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) - msg, err = types.NewMsgCreateClient(tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, true, @@ -109,7 +109,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { { "invalid tendermint client", func() { - msg, err = types.NewMsgCreateClient(&ibctmtypes.ClientState{}, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(&ibctmtypes.ClientState{}, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -125,7 +125,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { "failed to unpack consensus state", func() { tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) - msg, err = types.NewMsgCreateClient(tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) msg.ConsensusState = nil }, @@ -142,7 +142,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { "valid - solomachine client", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgCreateClient(soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, true, @@ -151,7 +151,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { "invalid solomachine client", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgCreateClient(&solomachinetypes.ClientState{}, soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(&solomachinetypes.ClientState{}, soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -160,7 +160,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { "invalid solomachine consensus state", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgCreateClient(soloMachine.ClientState(), &solomachinetypes.ConsensusState{}, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(soloMachine.ClientState(), &solomachinetypes.ConsensusState{}, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -170,7 +170,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { func() { tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgCreateClient(tendermintClient, soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgCreateClient(tendermintClient, soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -203,13 +203,13 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() { { "solo machine client", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, }, { "tendermint client", func() { - msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, @@ -261,7 +261,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() { { "valid - tendermint header", func() { - msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, true, @@ -269,7 +269,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() { { "invalid tendermint header", func() { - msg, err = types.NewMsgUpdateClient("tendermint", &ibctmtypes.Header{}, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpdateClient("tendermint", &ibctmtypes.Header{}, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -292,7 +292,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() { "valid - solomachine header", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, true, @@ -300,7 +300,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() { { "invalid solomachine header", func() { - msg, err = types.NewMsgUpdateClient("solomachine", &solomachinetypes.Header{}, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpdateClient("solomachine", &solomachinetypes.Header{}, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -308,7 +308,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() { { "unsupported - localhost", func() { - msg, err = types.NewMsgUpdateClient(exported.Localhost, suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpdateClient(exported.Localhost, suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -341,7 +341,7 @@ func (suite *TypesTestSuite) TestMarshalMsgUpgradeClient() { func() { tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) tendermintConsState := &ibctmtypes.ConsensusState{NextValidatorsHash: []byte("nextValsHash")} - msg, err = types.NewMsgUpgradeClient("clientid", tendermintClient, tendermintConsState, []byte("proofUpgradeClient"), []byte("proofUpgradeConsState"), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpgradeClient("clientid", tendermintClient, tendermintConsState, []byte("proofUpgradeClient"), []byte("proofUpgradeConsState"), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, }, @@ -349,7 +349,7 @@ func (suite *TypesTestSuite) TestMarshalMsgUpgradeClient() { "client upgrades to new solomachine client", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 1) - msg, err = types.NewMsgUpgradeClient("clientid", soloMachine.ClientState(), soloMachine.ConsensusState(), []byte("proofUpgradeClient"), []byte("proofUpgradeConsState"), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgUpgradeClient("clientid", soloMachine.ClientState(), soloMachine.ConsensusState(), []byte("proofUpgradeClient"), []byte("proofUpgradeConsState"), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, }, @@ -454,7 +454,7 @@ func (suite *TypesTestSuite) TestMsgUpgradeClient_ValidateBasic() { clientState := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) consState := &ibctmtypes.ConsensusState{NextValidatorsHash: []byte("nextValsHash")} - msg, err := types.NewMsgUpgradeClient("testclientid", clientState, consState, []byte("proofUpgradeClient"), []byte("proofUpgradeConsState"), suite.chainA.SenderAccount.GetAddress()) + msg, err := types.NewMsgUpgradeClient("testclientid", clientState, consState, []byte("proofUpgradeClient"), []byte("proofUpgradeConsState"), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) tc.malleate(msg) @@ -482,7 +482,7 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() { { "solo machine client", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, }, @@ -494,7 +494,7 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() { header2 := suite.chainA.CreateTMClientHeader(suite.chainA.ChainID, int64(height.RevisionHeight), heightMinus1, suite.chainA.CurrentHeader.Time.Add(time.Minute), suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers) misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", header1, header2) - msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, @@ -552,7 +552,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { header2 := suite.chainA.CreateTMClientHeader(suite.chainA.ChainID, int64(height.RevisionHeight), heightMinus1, suite.chainA.CurrentHeader.Time.Add(time.Minute), suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers) misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", header1, header2) - msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, true, @@ -560,7 +560,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { { "invalid tendermint misbehaviour", func() { - msg, err = types.NewMsgSubmitMisbehaviour("tendermint", &ibctmtypes.Misbehaviour{}, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgSubmitMisbehaviour("tendermint", &ibctmtypes.Misbehaviour{}, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -583,7 +583,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { "valid - solomachine misbehaviour", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, true, @@ -591,7 +591,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { { "invalid solomachine misbehaviour", func() { - msg, err = types.NewMsgSubmitMisbehaviour("solomachine", &solomachinetypes.Misbehaviour{}, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgSubmitMisbehaviour("solomachine", &solomachinetypes.Misbehaviour{}, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, @@ -600,7 +600,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { "client-id mismatch", func() { soloMachineMisbehaviour := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2).CreateMisbehaviour() - msg, err = types.NewMsgSubmitMisbehaviour("external", soloMachineMisbehaviour, suite.chainA.SenderAccount.GetAddress()) + msg, err = types.NewMsgSubmitMisbehaviour("external", soloMachineMisbehaviour, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, false, diff --git a/modules/core/03-connection/client/cli/tx.go b/modules/core/03-connection/client/cli/tx.go index 87c8de75b09..df396c8b578 100644 --- a/modules/core/03-connection/client/cli/tx.go +++ b/modules/core/03-connection/client/cli/tx.go @@ -74,7 +74,7 @@ func NewConnectionOpenInitCmd() *cobra.Command { msg := types.NewMsgConnectionOpenInit( clientID, counterpartyClientID, - counterpartyPrefix, version, delayPeriod, clientCtx.GetFromAddress(), + counterpartyPrefix, version, delayPeriod, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} @@ -190,7 +190,7 @@ func NewConnectionOpenTryCmd() *cobra.Command { connectionID, clientID, counterpartyConnectionID, counterpartyClientID, counterpartyClient, counterpartyPrefix, counterpartyVersions, delayPeriod, proofInit, proofClient, proofConsensus, proofHeight, - consensusHeight, clientCtx.GetFromAddress(), + consensusHeight, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} @@ -280,7 +280,7 @@ func NewConnectionOpenAckCmd() *cobra.Command { msg := types.NewMsgConnectionOpenAck( connectionID, counterpartyConnectionID, counterpartyClient, proofTry, proofClient, proofConsensus, proofHeight, - consensusHeight, version, clientCtx.GetFromAddress(), + consensusHeight, version, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} @@ -328,7 +328,7 @@ func NewConnectionOpenConfirmCmd() *cobra.Command { } msg := types.NewMsgConnectionOpenConfirm( - connectionID, proofAck, proofHeight, clientCtx.GetFromAddress(), + connectionID, proofAck, proofHeight, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} diff --git a/modules/core/03-connection/types/msgs.go b/modules/core/03-connection/types/msgs.go index fcae27b6821..0ef6f06bbec 100644 --- a/modules/core/03-connection/types/msgs.go +++ b/modules/core/03-connection/types/msgs.go @@ -26,7 +26,7 @@ var ( func NewMsgConnectionOpenInit( clientID, counterpartyClientID string, counterpartyPrefix commitmenttypes.MerklePrefix, - version *Version, delayPeriod uint64, signer sdk.AccAddress, + version *Version, delayPeriod uint64, signer string, ) *MsgConnectionOpenInit { // counterparty must have the same delay period counterparty := NewCounterparty(counterpartyClientID, "", counterpartyPrefix) @@ -35,7 +35,7 @@ func NewMsgConnectionOpenInit( Counterparty: counterparty, Version: version, DelayPeriod: delayPeriod, - Signer: signer.String(), + Signer: signer, } } @@ -94,7 +94,7 @@ func NewMsgConnectionOpenTry( counterpartyPrefix commitmenttypes.MerklePrefix, counterpartyVersions []*Version, delayPeriod uint64, proofInit, proofClient, proofConsensus []byte, - proofHeight, consensusHeight clienttypes.Height, signer sdk.AccAddress, + proofHeight, consensusHeight clienttypes.Height, signer string, ) *MsgConnectionOpenTry { counterparty := NewCounterparty(counterpartyClientID, counterpartyConnectionID, counterpartyPrefix) csAny, _ := clienttypes.PackClientState(counterpartyClient) @@ -110,7 +110,7 @@ func NewMsgConnectionOpenTry( ProofConsensus: proofConsensus, ProofHeight: proofHeight, ConsensusHeight: consensusHeight, - Signer: signer.String(), + Signer: signer, } } @@ -206,7 +206,7 @@ func NewMsgConnectionOpenAck( proofTry, proofClient, proofConsensus []byte, proofHeight, consensusHeight clienttypes.Height, version *Version, - signer sdk.AccAddress, + signer string, ) *MsgConnectionOpenAck { csAny, _ := clienttypes.PackClientState(counterpartyClient) return &MsgConnectionOpenAck{ @@ -219,7 +219,7 @@ func NewMsgConnectionOpenAck( ProofHeight: proofHeight, ConsensusHeight: consensusHeight, Version: version, - Signer: signer.String(), + Signer: signer, } } @@ -300,13 +300,13 @@ func (msg MsgConnectionOpenAck) GetSigners() []sdk.AccAddress { //nolint:interfacer func NewMsgConnectionOpenConfirm( connectionID string, proofAck []byte, proofHeight clienttypes.Height, - signer sdk.AccAddress, + signer string, ) *MsgConnectionOpenConfirm { return &MsgConnectionOpenConfirm{ ConnectionId: connectionID, ProofAck: proofAck, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index a929ff72431..1875804d807 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -10,19 +10,20 @@ import ( abci "github.com/tendermint/tendermint/abci/types" dbm "github.com/tendermint/tm-db" - "github.com/cosmos/ibc-go/testing/simapp" "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/rootmulti" storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" "github.com/cosmos/ibc-go/modules/core/03-connection/types" commitmenttypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types" ibctmtypes "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/ibc-go/testing" + "github.com/cosmos/ibc-go/testing/simapp" ) var ( + signer = "cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht" + emptyPrefix = commitmenttypes.MerklePrefix{} emptyProof = []byte{} ) @@ -77,7 +78,6 @@ func TestMsgTestSuite(t *testing.T) { func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey")) - signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") // empty versions are considered valid, the default compatible versions // will be used in protocol. var version *types.Version @@ -89,10 +89,10 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { }{ {"invalid client ID", types.NewMsgConnectionOpenInit("test/iris", "clienttotest", prefix, version, 500, signer), false}, {"invalid counterparty client ID", types.NewMsgConnectionOpenInit("clienttotest", "(clienttotest)", prefix, version, 500, signer), false}, - {"invalid counterparty connection ID", &types.MsgConnectionOpenInit{connectionID, types.NewCounterparty("clienttotest", "connectiontotest", prefix), version, 500, signer.String()}, false}, + {"invalid counterparty connection ID", &types.MsgConnectionOpenInit{connectionID, types.NewCounterparty("clienttotest", "connectiontotest", prefix), version, 500, signer}, false}, {"empty counterparty prefix", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", emptyPrefix, version, 500, signer), false}, {"supplied version fails basic validation", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, &types.Version{}, 500, signer), false}, - {"empty singer", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, version, 500, nil), false}, + {"empty singer", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, version, 500, ""), false}, {"success", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, version, 500, signer), true}, } @@ -108,7 +108,6 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey")) - signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") clientState := ibctmtypes.NewClientState( chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, @@ -137,7 +136,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { {"invalid counterparty connection ID", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "ibc/test", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, {"invalid counterparty client ID", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "test/conn1", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, {"invalid nil counterparty client", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", nil, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, - {"invalid client unpacking", &types.MsgConnectionOpenTry{connectionID, "clienttotesta", invalidAny, counterparty, 500, []*types.Version{ibctesting.ConnectionVersion}, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer.String()}, false}, + {"invalid client unpacking", &types.MsgConnectionOpenTry{connectionID, "clienttotesta", invalidAny, counterparty, 500, []*types.Version{ibctesting.ConnectionVersion}, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer}, false}, {"counterparty failed validate", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", invalidClient, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, {"empty counterparty prefix", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, emptyPrefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, {"empty counterpartyVersions", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, @@ -146,7 +145,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { {"empty proofConsensus", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, emptyProof, clientHeight, clientHeight, signer), false}, {"invalid proofHeight", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clienttypes.ZeroHeight(), clientHeight, signer), false}, {"invalid consensusHeight", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.ZeroHeight(), signer), false}, - {"empty singer", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, nil), false}, + {"empty singer", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ""), false}, {"success", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), true}, {"invalid version", types.NewMsgConnectionOpenTry(connectionID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{{}}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, } @@ -162,7 +161,6 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { } func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { - signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") clientState := ibctmtypes.NewClientState( chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, ) @@ -187,7 +185,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { {"invalid connection ID", types.NewMsgConnectionOpenAck("test/conn1", connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), false}, {"invalid counterparty connection ID", types.NewMsgConnectionOpenAck(connectionID, "test/conn1", clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), false}, {"invalid nil counterparty client", types.NewMsgConnectionOpenAck(connectionID, connectionID, nil, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), false}, - {"invalid unpacking counterparty client", &types.MsgConnectionOpenAck{connectionID, connectionID, ibctesting.ConnectionVersion, invalidAny, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer.String()}, false}, + {"invalid unpacking counterparty client", &types.MsgConnectionOpenAck{connectionID, connectionID, ibctesting.ConnectionVersion, invalidAny, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer}, false}, {"counterparty client failed validate", types.NewMsgConnectionOpenAck(connectionID, connectionID, invalidClient, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), false}, {"empty proofTry", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, emptyProof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), false}, {"empty proofClient", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, emptyProof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), false}, @@ -195,7 +193,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { {"invalid proofHeight", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clienttypes.ZeroHeight(), clientHeight, ibctesting.ConnectionVersion, signer), false}, {"invalid consensusHeight", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.ZeroHeight(), ibctesting.ConnectionVersion, signer), false}, {"invalid version", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, &types.Version{}, signer), false}, - {"empty signer", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, nil), false}, + {"empty signer", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, ""), false}, {"success", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), true}, } @@ -210,13 +208,11 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { } func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { - signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") - testMsgs := []*types.MsgConnectionOpenConfirm{ types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, clientHeight, signer), types.NewMsgConnectionOpenConfirm(connectionID, emptyProof, clientHeight, signer), types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clienttypes.ZeroHeight(), signer), - types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, nil), + types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, ""), types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, signer), } diff --git a/modules/core/04-channel/client/cli/tx.go b/modules/core/04-channel/client/cli/tx.go index fb6adedecfd..c76c02f32a3 100644 --- a/modules/core/04-channel/client/cli/tx.go +++ b/modules/core/04-channel/client/cli/tx.go @@ -41,7 +41,7 @@ func NewChannelOpenInitCmd() *cobra.Command { msg := types.NewMsgChannelOpenInit( portID, version, order, hops, - counterpartyPortID, clientCtx.GetFromAddress(), + counterpartyPortID, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} msgClient := types.NewMsgClient(svcMsgClientConn) @@ -95,7 +95,7 @@ func NewChannelOpenTryCmd() *cobra.Command { msg := types.NewMsgChannelOpenTry( portID, channelID, version, order, hops, counterpartyPortID, counterpartyChannelID, version, - proofInit, proofHeight, clientCtx.GetFromAddress(), + proofInit, proofHeight, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} msgClient := types.NewMsgClient(svcMsgClientConn) @@ -144,7 +144,7 @@ func NewChannelOpenAckCmd() *cobra.Command { } msg := types.NewMsgChannelOpenAck( - portID, channelID, counterpartyChannelID, version, proofTry, proofHeight, clientCtx.GetFromAddress(), + portID, channelID, counterpartyChannelID, version, proofTry, proofHeight, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} msgClient := types.NewMsgClient(svcMsgClientConn) @@ -187,7 +187,7 @@ func NewChannelOpenConfirmCmd() *cobra.Command { } msg := types.NewMsgChannelOpenConfirm( - portID, channelID, proofAck, proofHeight, clientCtx.GetFromAddress(), + portID, channelID, proofAck, proofHeight, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} msgClient := types.NewMsgClient(svcMsgClientConn) @@ -219,7 +219,7 @@ func NewChannelCloseInitCmd() *cobra.Command { portID := args[0] channelID := args[1] - msg := types.NewMsgChannelCloseInit(portID, channelID, clientCtx.GetFromAddress()) + msg := types.NewMsgChannelCloseInit(portID, channelID, clientCtx.GetFromAddress().String()) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} msgClient := types.NewMsgClient(svcMsgClientConn) _, err = msgClient.ChannelCloseInit(cmd.Context(), msg) @@ -261,7 +261,7 @@ func NewChannelCloseConfirmCmd() *cobra.Command { } msg := types.NewMsgChannelCloseConfirm( - portID, channelID, proofInit, proofHeight, clientCtx.GetFromAddress(), + portID, channelID, proofInit, proofHeight, clientCtx.GetFromAddress().String(), ) svcMsgClientConn := &msgservice.ServiceMsgClientConn{} msgClient := types.NewMsgClient(svcMsgClientConn) diff --git a/modules/core/04-channel/types/msgs.go b/modules/core/04-channel/types/msgs.go index d35c983f8ca..151b5582c74 100644 --- a/modules/core/04-channel/types/msgs.go +++ b/modules/core/04-channel/types/msgs.go @@ -17,14 +17,14 @@ var _ sdk.Msg = &MsgChannelOpenInit{} // nolint:interfacer func NewMsgChannelOpenInit( portID, version string, channelOrder Order, connectionHops []string, - counterpartyPortID string, signer sdk.AccAddress, + counterpartyPortID string, signer string, ) *MsgChannelOpenInit { counterparty := NewCounterparty(counterpartyPortID, "") channel := NewChannel(INIT, channelOrder, counterparty, connectionHops, version) return &MsgChannelOpenInit{ PortId: portID, Channel: channel, - Signer: signer.String(), + Signer: signer, } } @@ -81,7 +81,7 @@ var _ sdk.Msg = &MsgChannelOpenTry{} func NewMsgChannelOpenTry( portID, previousChannelID, version string, channelOrder Order, connectionHops []string, counterpartyPortID, counterpartyChannelID, counterpartyVersion string, - proofInit []byte, proofHeight clienttypes.Height, signer sdk.AccAddress, + proofInit []byte, proofHeight clienttypes.Height, signer string, ) *MsgChannelOpenTry { counterparty := NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := NewChannel(TRYOPEN, channelOrder, counterparty, connectionHops, version) @@ -92,7 +92,7 @@ func NewMsgChannelOpenTry( CounterpartyVersion: counterpartyVersion, ProofInit: proofInit, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } @@ -161,7 +161,7 @@ var _ sdk.Msg = &MsgChannelOpenAck{} // nolint:interfacer func NewMsgChannelOpenAck( portID, channelID, counterpartyChannelID string, cpv string, proofTry []byte, proofHeight clienttypes.Height, - signer sdk.AccAddress, + signer string, ) *MsgChannelOpenAck { return &MsgChannelOpenAck{ PortId: portID, @@ -170,7 +170,7 @@ func NewMsgChannelOpenAck( CounterpartyVersion: cpv, ProofTry: proofTry, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } @@ -229,14 +229,14 @@ var _ sdk.Msg = &MsgChannelOpenConfirm{} // nolint:interfacer func NewMsgChannelOpenConfirm( portID, channelID string, proofAck []byte, proofHeight clienttypes.Height, - signer sdk.AccAddress, + signer string, ) *MsgChannelOpenConfirm { return &MsgChannelOpenConfirm{ PortId: portID, ChannelId: channelID, ProofAck: proofAck, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } @@ -291,12 +291,12 @@ var _ sdk.Msg = &MsgChannelCloseInit{} // NewMsgChannelCloseInit creates a new MsgChannelCloseInit instance // nolint:interfacer func NewMsgChannelCloseInit( - portID string, channelID string, signer sdk.AccAddress, + portID string, channelID string, signer string, ) *MsgChannelCloseInit { return &MsgChannelCloseInit{ PortId: portID, ChannelId: channelID, - Signer: signer.String(), + Signer: signer, } } @@ -346,14 +346,14 @@ var _ sdk.Msg = &MsgChannelCloseConfirm{} // nolint:interfacer func NewMsgChannelCloseConfirm( portID, channelID string, proofInit []byte, proofHeight clienttypes.Height, - signer sdk.AccAddress, + signer string, ) *MsgChannelCloseConfirm { return &MsgChannelCloseConfirm{ PortId: portID, ChannelId: channelID, ProofInit: proofInit, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } @@ -409,13 +409,13 @@ var _ sdk.Msg = &MsgRecvPacket{} // nolint:interfacer func NewMsgRecvPacket( packet Packet, proofCommitment []byte, proofHeight clienttypes.Height, - signer sdk.AccAddress, + signer string, ) *MsgRecvPacket { return &MsgRecvPacket{ Packet: packet, ProofCommitment: proofCommitment, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } @@ -472,14 +472,14 @@ var _ sdk.Msg = &MsgTimeout{} // nolint:interfacer func NewMsgTimeout( packet Packet, nextSequenceRecv uint64, proofUnreceived []byte, - proofHeight clienttypes.Height, signer sdk.AccAddress, + proofHeight clienttypes.Height, signer string, ) *MsgTimeout { return &MsgTimeout{ Packet: packet, NextSequenceRecv: nextSequenceRecv, ProofUnreceived: proofUnreceived, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } @@ -531,7 +531,7 @@ func (msg MsgTimeout) Type() string { func NewMsgTimeoutOnClose( packet Packet, nextSequenceRecv uint64, proofUnreceived, proofClose []byte, - proofHeight clienttypes.Height, signer sdk.AccAddress, + proofHeight clienttypes.Height, signer string, ) *MsgTimeoutOnClose { return &MsgTimeoutOnClose{ Packet: packet, @@ -539,7 +539,7 @@ func NewMsgTimeoutOnClose( ProofUnreceived: proofUnreceived, ProofClose: proofClose, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } @@ -597,14 +597,14 @@ func NewMsgAcknowledgement( packet Packet, ack, proofAcked []byte, proofHeight clienttypes.Height, - signer sdk.AccAddress, + signer string, ) *MsgAcknowledgement { return &MsgAcknowledgement{ Packet: packet, Acknowledgement: ack, ProofAcked: proofAcked, ProofHeight: proofHeight, - Signer: signer.String(), + Signer: signer, } } diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index fd8d2328729..daa2195b7ec 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -9,7 +9,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" dbm "github.com/tendermint/tm-db" - "github.com/cosmos/ibc-go/testing/simapp" "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/rootmulti" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -18,6 +17,7 @@ import ( "github.com/cosmos/ibc-go/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/modules/core/exported" + "github.com/cosmos/ibc-go/testing/simapp" ) const ( @@ -59,8 +59,8 @@ var ( invalidProofs1 = exported.Proof(nil) invalidProofs2 = emptyProof - addr = sdk.AccAddress("testaddr111111111111") - emptyAddr sdk.AccAddress + addr = sdk.AccAddress("testaddr111111111111").String() + emptyAddr string connHops = []string{"testconnection"} invalidConnHops = []string{"testconnection", "testconnection"} @@ -125,7 +125,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenInitValidateBasic() { {"connection id contains non-alpha", types.NewMsgChannelOpenInit(portid, version, types.UNORDERED, []string{invalidConnection}, cpportid, addr), false}, {"", types.NewMsgChannelOpenInit(portid, "", types.UNORDERED, connHops, cpportid, addr), true}, {"invalid counterparty port id", types.NewMsgChannelOpenInit(portid, version, types.UNORDERED, connHops, invalidPort, addr), false}, - {"channel not in INIT state", &types.MsgChannelOpenInit{portid, tryOpenChannel, addr.String()}, false}, + {"channel not in INIT state", &types.MsgChannelOpenInit{portid, tryOpenChannel, addr}, false}, } for _, tc := range testCases { @@ -169,7 +169,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenTryValidateBasic() { {"invalid counterparty port id", types.NewMsgChannelOpenTry(portid, chanid, version, types.UNORDERED, connHops, invalidPort, cpchanid, version, suite.proof, height, addr), false}, {"invalid counterparty channel id", types.NewMsgChannelOpenTry(portid, chanid, version, types.UNORDERED, connHops, cpportid, invalidChannel, version, suite.proof, height, addr), false}, {"empty proof", types.NewMsgChannelOpenTry(portid, chanid, version, types.UNORDERED, connHops, cpportid, cpchanid, version, emptyProof, height, addr), false}, - {"channel not in TRYOPEN state", &types.MsgChannelOpenTry{portid, chanid, initChannel, version, suite.proof, height, addr.String()}, false}, + {"channel not in TRYOPEN state", &types.MsgChannelOpenTry{portid, chanid, initChannel, version, suite.proof, height, addr}, false}, } for _, tc := range testCases { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 18830d79f94..4ec1a0d2f53 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types" @@ -15,7 +16,6 @@ import ( ibctmtypes "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/ibc-go/testing" ibcmock "github.com/cosmos/ibc-go/testing/mock" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) const height = 10 @@ -144,7 +144,7 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := suite.chainA.QueryProof(packetKey) - msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress()) + msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) // ante-handle RecvPacket _, err := keeper.Keeper.RecvPacket(*suite.chainB.App.IBCKeeper, sdk.WrapSDKContext(suite.chainB.GetContext()), msg) @@ -283,7 +283,7 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetKey) - msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement, proof, proofHeight, suite.chainA.SenderAccount.GetAddress()) + msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) _, err := keeper.Keeper.Acknowledgement(*suite.chainA.App.IBCKeeper, sdk.WrapSDKContext(suite.chainA.GetContext()), msg) @@ -404,7 +404,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { proof, proofHeight := suite.chainB.QueryProof(packetKey) - msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress()) + msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) _, err := keeper.Keeper.Timeout(*suite.chainA.App.IBCKeeper, sdk.WrapSDKContext(suite.chainA.GetContext()), msg) @@ -586,7 +586,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { channelKey := host.ChannelKey(counterpartyChannel.PortID, counterpartyChannel.ID) proofClosed, _ := suite.chainB.QueryProof(channelKey) - msg := channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, proofClosed, proofHeight, suite.chainA.SenderAccount.GetAddress()) + msg := channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, proofClosed, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) _, err := keeper.Keeper.TimeoutOnClose(*suite.chainA.App.IBCKeeper, sdk.WrapSDKContext(suite.chainA.GetContext()), msg) @@ -660,7 +660,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { proofUpgradedConsState, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight()) msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradedConsState, - proofUpgradeClient, proofUpgradedConsState, suite.chainA.SenderAccount.GetAddress()) + proofUpgradeClient, proofUpgradedConsState, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, expPass: true, @@ -694,7 +694,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) - msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradedConsState, nil, nil, suite.chainA.SenderAccount.GetAddress()) + msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradedConsState, nil, nil, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, expPass: false, diff --git a/testing/chain.go b/testing/chain.go index 6f1f4e781aa..3578bd0ec94 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -461,7 +461,7 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client } msg, err := clienttypes.NewMsgCreateClient( - clientState, consensusState, chain.SenderAccount.GetAddress(), + clientState, consensusState, chain.SenderAccount.GetAddress().String(), ) require.NoError(chain.t, err) return msg @@ -484,7 +484,7 @@ func (chain *TestChain) UpdateTMClient(counterparty *TestChain, clientID string) msg, err := clienttypes.NewMsgUpdateClient( clientID, header, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) require.NoError(chain.t, err) @@ -645,7 +645,7 @@ func (chain *TestChain) ConnectionOpenInit( connection.ClientID, connection.CounterpartyClientID, counterparty.GetPrefix(), DefaultOpenInitVersion, DefaultDelayPeriod, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -668,7 +668,7 @@ func (chain *TestChain) ConnectionOpenTry( counterpartyClient, counterparty.GetPrefix(), []*connectiontypes.Version{ConnectionVersion}, DefaultDelayPeriod, proofInit, proofClient, proofConsensus, proofHeight, consensusHeight, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -690,7 +690,7 @@ func (chain *TestChain) ConnectionOpenAck( proofTry, proofClient, proofConsensus, proofHeight, consensusHeight, ConnectionVersion, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -706,7 +706,7 @@ func (chain *TestChain) ConnectionOpenConfirm( msg := connectiontypes.NewMsgConnectionOpenConfirm( connection.ID, proof, height, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -788,7 +788,7 @@ func (chain *TestChain) ChanOpenInit( ch.PortID, ch.Version, order, []string{connectionID}, counterparty.PortID, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -807,7 +807,7 @@ func (chain *TestChain) ChanOpenTry( ch.Version, order, []string{connectionID}, counterpartyCh.PortID, counterpartyCh.ID, counterpartyCh.Version, proof, height, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -823,7 +823,7 @@ func (chain *TestChain) ChanOpenAck( ch.PortID, ch.ID, counterpartyCh.ID, counterpartyCh.Version, // testing doesn't use flexible selection proof, height, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -838,7 +838,7 @@ func (chain *TestChain) ChanOpenConfirm( msg := channeltypes.NewMsgChannelOpenConfirm( ch.PortID, ch.ID, proof, height, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } @@ -852,7 +852,7 @@ func (chain *TestChain) ChanCloseInit( ) error { msg := channeltypes.NewMsgChannelCloseInit( channel.PortID, channel.ID, - chain.SenderAccount.GetAddress(), + chain.SenderAccount.GetAddress().String(), ) return chain.sendMsgs(msg) } diff --git a/testing/coordinator.go b/testing/coordinator.go index 80f45157005..9bf6f040dc8 100644 --- a/testing/coordinator.go +++ b/testing/coordinator.go @@ -245,7 +245,7 @@ func (coord *Coordinator) RecvPacket( coord.IncrementTime() coord.CommitBlock(source, counterparty) - recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, counterparty.SenderAccount.GetAddress()) + recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, counterparty.SenderAccount.GetAddress().String()) // receive on counterparty and update source client return coord.SendMsgs(counterparty, source, sourceClient, []sdk.Msg{recvMsg}) @@ -288,7 +288,7 @@ func (coord *Coordinator) AcknowledgePacket( coord.IncrementTime() coord.CommitBlock(source, counterparty) - ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, source.SenderAccount.GetAddress()) + ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, source.SenderAccount.GetAddress().String()) return coord.SendMsgs(source, counterparty, counterpartyClient, []sdk.Msg{ackMsg}) } From fd17db6692bb1f2f62ff1e8bce9e9d0c0e49a897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 8 Apr 2021 14:52:57 +0200 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 234a38be084..f05c56b8494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## API Breaking + +* (modules) [\#108](https://github.com/cosmos/ibc-go/pull/108) All message constructors take the signer as a string to prevent upstream bugs. The `String()` function for an SDK Acc Address relies on external context. + ### State Machine Breaking * (modules/light-clients/07-tendermint) [\#99](https://github.com/cosmos/ibc-go/pull/99) Enforce maximum chain-id length for tendermint client.