From 2f33154dae69e663fcad9ff78394f99da1c8a882 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 15:49:59 +0700 Subject: [PATCH 01/43] remove host connection ID in default metadata --- .../27-interchain-accounts/controller/keeper/handshake.go | 7 +------ modules/apps/27-interchain-accounts/types/metadata.go | 5 ++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index 17234cc62a9..03ce13ede90 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -48,12 +48,7 @@ func (k Keeper) OnChanOpenInit( metadata icatypes.Metadata ) if strings.TrimSpace(version) == "" { - connection, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) - if err != nil { - return "", err - } - - metadata = icatypes.NewDefaultMetadata(connectionHops[0], connection.GetCounterparty().GetConnectionID()) + metadata = icatypes.NewDefaultMetadata(connectionHops[0]) } else { metadata, err = icatypes.MetadataFromVersion(version) if err != nil { diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 61c077a46f0..4885b1de65f 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -34,10 +34,9 @@ func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, // NewDefaultMetadata creates and returns a new ICS27 Metadata instance containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadata { +func NewDefaultMetadata(controllerConnectionID string) Metadata { metadata := Metadata{ ControllerConnectionId: controllerConnectionID, - HostConnectionId: hostConnectionID, Encoding: EncodingProtobuf, TxType: TxTypeSDKMultiMsg, Version: Version, @@ -49,7 +48,7 @@ func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadat // NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values // with the provided controller and host connection identifiers func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { - metadata := NewDefaultMetadata(controllerConnectionID, hostConnectionID) + metadata := NewDefaultMetadata(controllerConnectionID) return string(ModuleCdc.MustMarshalJSON(&metadata)) } From e535ddbcf125b97c23b26120a4b2122a68d02bfb Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 15:52:45 +0700 Subject: [PATCH 02/43] allow empty host connection id in validateConnectionParams --- modules/apps/27-interchain-accounts/types/metadata.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 4885b1de65f..66a02f88e00 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -37,6 +37,7 @@ func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, func NewDefaultMetadata(controllerConnectionID string) Metadata { metadata := Metadata{ ControllerConnectionId: controllerConnectionID, + HostConnectionId: "", Encoding: EncodingProtobuf, TxType: TxTypeSDKMultiMsg, Version: Version, @@ -168,6 +169,9 @@ func validateConnectionParams(metadata Metadata, controllerConnectionID, hostCon } if metadata.HostConnectionId != hostConnectionID { + if metadata.HostConnectionId == "" { + return nil + } return errorsmod.Wrapf(connectiontypes.ErrInvalidConnection, "expected %s, got %s", hostConnectionID, metadata.HostConnectionId) } From 670ff0d5e4cc4a73c89aeea7ad51551883cf7aa0 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 15:54:34 +0700 Subject: [PATCH 03/43] add host connection id to the metadata on host open try --- modules/apps/27-interchain-accounts/host/keeper/handshake.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index 819abd89426..c369e0c68e4 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -47,6 +47,10 @@ func (k Keeper) OnChanOpenTry( return "", err } + if metadata.HostConnectionId == "" { + metadata.HostConnectionId = connectionHops[0] + } + activeChannelID, found := k.GetActiveChannelID(ctx, connectionHops[0], counterparty.PortId) if found { channel, found := k.channelKeeper.GetChannel(ctx, portID, activeChannelID) From bc119a7f5f43e9faa230efb93692efd9faceb61c Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 16:31:36 +0700 Subject: [PATCH 04/43] nit --- .../controller/keeper/handshake.go | 7 ++++++- .../controller/keeper/handshake_test.go | 15 ++++++++++++--- .../apps/27-interchain-accounts/types/metadata.go | 6 +++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index 03ce13ede90..17234cc62a9 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -48,7 +48,12 @@ func (k Keeper) OnChanOpenInit( metadata icatypes.Metadata ) if strings.TrimSpace(version) == "" { - metadata = icatypes.NewDefaultMetadata(connectionHops[0]) + connection, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) + if err != nil { + return "", err + } + + metadata = icatypes.NewDefaultMetadata(connectionHops[0], connection.GetCounterparty().GetConnectionID()) } else { metadata, err = icatypes.MetadataFromVersion(version) if err != nil { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index b2fd351cc06..21909f8f3ba 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "fmt" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" @@ -16,9 +18,10 @@ const ( func (suite *KeeperTestSuite) TestOnChanOpenInit() { var ( - channel *channeltypes.Channel - path *ibctesting.Path - chanCap *capabilitytypes.Capability + channel *channeltypes.Channel + path *ibctesting.Path + chanCap *capabilitytypes.Capability + // hostConnectionId string metadata icatypes.Metadata ) @@ -35,6 +38,8 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { { "success: previous active channel closed", func() { + fmt.Println("") + fmt.Println("success: previous active channel closed") suite.chainA.GetSimApp().ICAControllerKeeper.SetActiveChannelID(suite.chainA.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -47,6 +52,8 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { } path.EndpointA.SetChannel(channel) + + // hostConnectionId = path.EndpointB.ChannelID }, true, }, @@ -60,6 +67,8 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { { "success: channel reopening", func() { + fmt.Println("") + fmt.Println("success: channel reopening") err := SetupICAPath(path, TestOwnerAddress) suite.Require().NoError(err) diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 66a02f88e00..373bbe5030b 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -34,10 +34,10 @@ func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, // NewDefaultMetadata creates and returns a new ICS27 Metadata instance containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadata(controllerConnectionID string) Metadata { +func NewDefaultMetadata(controllerConnectionID string, hostConnectionID string) Metadata { metadata := Metadata{ ControllerConnectionId: controllerConnectionID, - HostConnectionId: "", + HostConnectionId: hostConnectionID, Encoding: EncodingProtobuf, TxType: TxTypeSDKMultiMsg, Version: Version, @@ -49,7 +49,7 @@ func NewDefaultMetadata(controllerConnectionID string) Metadata { // NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values // with the provided controller and host connection identifiers func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { - metadata := NewDefaultMetadata(controllerConnectionID) + metadata := NewDefaultMetadata(controllerConnectionID, hostConnectionID) return string(ModuleCdc.MustMarshalJSON(&metadata)) } From d0f083133a4664774dd089ed26ee1598601be152 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 16:34:22 +0700 Subject: [PATCH 05/43] add test init with empty host connection ID --- .../controller/keeper/handshake_test.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 21909f8f3ba..c27791b1923 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -1,8 +1,6 @@ package keeper_test import ( - "fmt" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" @@ -18,10 +16,9 @@ const ( func (suite *KeeperTestSuite) TestOnChanOpenInit() { var ( - channel *channeltypes.Channel - path *ibctesting.Path - chanCap *capabilitytypes.Capability - // hostConnectionId string + channel *channeltypes.Channel + path *ibctesting.Path + chanCap *capabilitytypes.Capability metadata icatypes.Metadata ) @@ -35,11 +32,16 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { func() {}, true, }, + { + "success: empty host connection ID", + func() { + path.EndpointB.ConnectionID = "" + }, + true, + }, { "success: previous active channel closed", func() { - fmt.Println("") - fmt.Println("success: previous active channel closed") suite.chainA.GetSimApp().ICAControllerKeeper.SetActiveChannelID(suite.chainA.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -67,8 +69,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { { "success: channel reopening", func() { - fmt.Println("") - fmt.Println("success: channel reopening") err := SetupICAPath(path, TestOwnerAddress) suite.Require().NoError(err) From a37e7f1653a75b69283b51dd00412d24cb56d76a Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 16:41:47 +0700 Subject: [PATCH 06/43] add test host --- .../host/keeper/handshake_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index c14ac85a576..dd14e17eb3d 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -91,6 +91,18 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { suite.Require().False(found) }, true, }, + { + "success - metadata empty host connection id", + func() { + metadata.HostConnectionId = "" + + versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) + suite.Require().NoError(err) + + path.EndpointA.ChannelConfig.Version = string(versionBytes) + }, + true, + }, { "reopening account fails - no existing account", func() { From 0e377ef21d4f88990dec24a5eff8d6fd570e1c0b Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 16:56:05 +0700 Subject: [PATCH 07/43] correct test --- .../host/keeper/handshake_test.go | 49 ++++++++++++++++--- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index dd14e17eb3d..713ceea6f47 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -2,7 +2,6 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" @@ -47,16 +46,19 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path *ibctesting.Path chanCap *capabilitytypes.Capability metadata icatypes.Metadata + version string ) testCases := []struct { name string malleate func() + assert func() expPass bool }{ { "success", func() {}, + func() {}, true, }, { @@ -69,7 +71,9 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { suite.Require().NoError(err) suite.openAndCloseChannel(path) - }, true, + }, + func() {}, + true, }, { "success - reopening account with new address", @@ -89,7 +93,9 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // assert interchain account address mapping was deleted _, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID) suite.Require().False(found) - }, true, + }, + func() {}, + true, }, { "success - metadata empty host connection id", @@ -101,6 +107,13 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, + func() { + var metadataResponse icatypes.Metadata + err := icatypes.ModuleCdc.UnmarshalJSON([]byte(version), &metadataResponse) + suite.Require().NoError(err) + + suite.Require().Equal(ibctesting.FirstConnectionID, metadataResponse.HostConnectionId) + }, true, }, { @@ -120,7 +133,9 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { acc := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), sdk.MustAccAddressFromBech32(addr)) suite.chainB.GetSimApp().AccountKeeper.RemoveAccount(suite.chainB.GetContext(), acc) - }, false, + }, + func() {}, + false, }, { "reopening account fails - existing account is not interchain account type", @@ -144,7 +159,9 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // overwrite existing account with only base account type, not intercahin account type suite.chainB.GetSimApp().AccountKeeper.SetAccount(suite.chainB.GetContext(), icaAcc.BaseAccount) - }, false, + }, + func() {}, + false, }, { "account already exists", @@ -154,6 +171,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { suite.Require().NoError(err) suite.Require().True(suite.chainB.GetSimApp().AccountKeeper.HasAccount(suite.chainB.GetContext(), interchainAccAddr)) }, + func() {}, false, }, { @@ -175,13 +193,16 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { channel.Version = string(versionBytes) path.EndpointB.SetChannel(*channel) - }, false, + }, + func() {}, + false, }, { "invalid order - UNORDERED", func() { channel.Ordering = channeltypes.UNORDERED }, + func() {}, false, }, { @@ -189,6 +210,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { func() { path.EndpointB.ChannelConfig.PortID = "invalid-port-id" //nolint:goconst }, + func() {}, false, }, { @@ -197,6 +219,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { channel.ConnectionHops = []string{"invalid-connnection-id"} path.EndpointB.SetChannel(*channel) }, + func() {}, false, }, { @@ -204,6 +227,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { func() { path.EndpointA.ChannelConfig.Version = "invalid-metadata-bytestring" }, + func() {}, false, }, { @@ -216,6 +240,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, + func() {}, false, }, { @@ -228,6 +253,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, + func() {}, false, }, { @@ -240,6 +266,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, + func() {}, false, }, { @@ -252,6 +279,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, + func() {}, false, }, { @@ -264,6 +292,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, + func() {}, false, }, { @@ -273,6 +302,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { err := suite.chainB.GetSimApp().ScopedICAHostKeeper.ClaimCapability(suite.chainB.GetContext(), chanCap, host.ChannelCapabilityPath(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)) suite.Require().NoError(err) }, + func() {}, false, }, { @@ -284,7 +314,9 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // set the active channelID in state suite.chainB.GetSimApp().ICAHostKeeper.SetActiveChannelID(suite.chainB.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, path.EndpointB.ChannelID) - }, false, + }, + func() {}, + false, }, } @@ -323,7 +355,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { tc.malleate() // malleate mutates test data - version, err := suite.chainB.GetSimApp().ICAHostKeeper.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.GetConnectionHops(), + version, err = suite.chainB.GetSimApp().ICAHostKeeper.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.GetConnectionHops(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, chanCap, channel.Counterparty, path.EndpointA.ChannelConfig.Version, ) @@ -339,6 +371,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // Check if account is created interchainAccount := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), interchainAccAddr) suite.Require().Equal(interchainAccount.GetAddress().String(), storedAddr) + tc.assert() } else { suite.Require().Error(err) suite.Require().Equal("", version) From b9f280b7a714c8717f3b60d31bee864d3b64c736 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Sun, 7 Jan 2024 16:59:03 +0700 Subject: [PATCH 08/43] nit --- .../27-interchain-accounts/controller/keeper/handshake_test.go | 2 -- modules/apps/27-interchain-accounts/types/metadata.go | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index c27791b1923..e8da823df74 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -54,8 +54,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { } path.EndpointA.SetChannel(channel) - - // hostConnectionId = path.EndpointB.ChannelID }, true, }, diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 373bbe5030b..70b7bede623 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -34,7 +34,7 @@ func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, // NewDefaultMetadata creates and returns a new ICS27 Metadata instance containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadata(controllerConnectionID string, hostConnectionID string) Metadata { +func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadata { metadata := Metadata{ ControllerConnectionId: controllerConnectionID, HostConnectionId: hostConnectionID, From c92c59b7369b33fb3f3aa0b6f778e85423444ec0 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 8 Jan 2024 10:32:05 +0100 Subject: [PATCH 09/43] lint --- .../apps/27-interchain-accounts/host/keeper/handshake_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 713ceea6f47..c109d057280 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -2,6 +2,7 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" From fc05c68131908f8fdd85b33b62eff250d605446c Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 8 Jan 2024 23:39:37 +0700 Subject: [PATCH 10/43] remove assert --- .../host/keeper/handshake_test.go | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 713ceea6f47..058b3f0b5ff 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -46,19 +46,16 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path *ibctesting.Path chanCap *capabilitytypes.Capability metadata icatypes.Metadata - version string ) testCases := []struct { name string malleate func() - assert func() expPass bool }{ { "success", func() {}, - func() {}, true, }, { @@ -72,7 +69,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { suite.openAndCloseChannel(path) }, - func() {}, true, }, { @@ -94,7 +90,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { _, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID) suite.Require().False(found) }, - func() {}, true, }, { @@ -107,13 +102,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, - func() { - var metadataResponse icatypes.Metadata - err := icatypes.ModuleCdc.UnmarshalJSON([]byte(version), &metadataResponse) - suite.Require().NoError(err) - - suite.Require().Equal(ibctesting.FirstConnectionID, metadataResponse.HostConnectionId) - }, true, }, { @@ -134,7 +122,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { acc := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), sdk.MustAccAddressFromBech32(addr)) suite.chainB.GetSimApp().AccountKeeper.RemoveAccount(suite.chainB.GetContext(), acc) }, - func() {}, false, }, { @@ -160,7 +147,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // overwrite existing account with only base account type, not intercahin account type suite.chainB.GetSimApp().AccountKeeper.SetAccount(suite.chainB.GetContext(), icaAcc.BaseAccount) }, - func() {}, false, }, { @@ -171,7 +157,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { suite.Require().NoError(err) suite.Require().True(suite.chainB.GetSimApp().AccountKeeper.HasAccount(suite.chainB.GetContext(), interchainAccAddr)) }, - func() {}, false, }, { @@ -194,7 +179,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointB.SetChannel(*channel) }, - func() {}, false, }, { @@ -202,7 +186,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { func() { channel.Ordering = channeltypes.UNORDERED }, - func() {}, false, }, { @@ -210,7 +193,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { func() { path.EndpointB.ChannelConfig.PortID = "invalid-port-id" //nolint:goconst }, - func() {}, false, }, { @@ -219,7 +201,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { channel.ConnectionHops = []string{"invalid-connnection-id"} path.EndpointB.SetChannel(*channel) }, - func() {}, false, }, { @@ -227,7 +208,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { func() { path.EndpointA.ChannelConfig.Version = "invalid-metadata-bytestring" }, - func() {}, false, }, { @@ -240,7 +220,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, - func() {}, false, }, { @@ -253,7 +232,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, - func() {}, false, }, { @@ -266,7 +244,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, - func() {}, false, }, { @@ -279,7 +256,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, - func() {}, false, }, { @@ -292,7 +268,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { path.EndpointA.ChannelConfig.Version = string(versionBytes) }, - func() {}, false, }, { @@ -302,7 +277,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { err := suite.chainB.GetSimApp().ScopedICAHostKeeper.ClaimCapability(suite.chainB.GetContext(), chanCap, host.ChannelCapabilityPath(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)) suite.Require().NoError(err) }, - func() {}, false, }, { @@ -315,7 +289,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // set the active channelID in state suite.chainB.GetSimApp().ICAHostKeeper.SetActiveChannelID(suite.chainB.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, path.EndpointB.ChannelID) }, - func() {}, false, }, } @@ -355,7 +328,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { tc.malleate() // malleate mutates test data - version, err = suite.chainB.GetSimApp().ICAHostKeeper.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.GetConnectionHops(), + version, err := suite.chainB.GetSimApp().ICAHostKeeper.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.GetConnectionHops(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, chanCap, channel.Counterparty, path.EndpointA.ChannelConfig.Version, ) @@ -371,7 +344,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // Check if account is created interchainAccount := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), interchainAccAddr) suite.Require().Equal(interchainAccount.GetAddress().String(), storedAddr) - tc.assert() } else { suite.Require().Error(err) suite.Require().Equal("", version) From 116201937ce25fd1c8e6fb2955ab43db7ff792a9 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Tue, 9 Jan 2024 23:49:12 +0700 Subject: [PATCH 11/43] TestOnChanOpenInit --- .../controller/keeper/handshake.go | 10 +++++----- .../controller/keeper/handshake_test.go | 18 +++++++++++------- .../27-interchain-accounts/types/metadata.go | 8 ++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index 17234cc62a9..bb584da2258 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -48,21 +48,21 @@ func (k Keeper) OnChanOpenInit( metadata icatypes.Metadata ) if strings.TrimSpace(version) == "" { - connection, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) + _, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) if err != nil { return "", err } - metadata = icatypes.NewDefaultMetadata(connectionHops[0], connection.GetCounterparty().GetConnectionID()) + metadata = icatypes.NewDefaultMetadata(connectionHops[0]) } else { metadata, err = icatypes.MetadataFromVersion(version) if err != nil { return "", err } - } - if err := icatypes.ValidateControllerMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { - return "", err + if err := icatypes.ValidateControllerMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { + return "", err + } } activeChannelID, found := k.GetActiveChannelID(ctx, connectionHops[0], portID) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index e8da823df74..1cf80a93971 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -16,10 +16,11 @@ const ( func (suite *KeeperTestSuite) TestOnChanOpenInit() { var ( - channel *channeltypes.Channel - path *ibctesting.Path - chanCap *capabilitytypes.Capability - metadata icatypes.Metadata + channel *channeltypes.Channel + path *ibctesting.Path + chanCap *capabilitytypes.Capability + metadata icatypes.Metadata + expectedVersionReturn string ) testCases := []struct { @@ -61,6 +62,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { "success: empty channel version returns default metadata JSON string", func() { channel.Version = "" + expectedVersionReturn = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID) }, true, }, @@ -257,6 +259,8 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) suite.Require().NoError(err) + expectedVersionReturn = string(versionBytes) + counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) channel = &channeltypes.Channel{ State: channeltypes.INIT, @@ -277,7 +281,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(string(versionBytes), version) + suite.Require().Equal(expectedVersionReturn, version) } else { suite.Require().Error(err) } @@ -634,7 +638,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeInit() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) // use the same address as the previous metadata. metadata.Address = currentMetadata.Address @@ -801,7 +805,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeAck() { currentMetadata, err := suite.chainA.GetSimApp().ICAControllerKeeper.GetAppMetadata(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) suite.Require().NoError(err) - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) // use the same address as the previous metadata. metadata.Address = currentMetadata.Address diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 70b7bede623..f8adbf6e5ef 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -34,10 +34,10 @@ func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, // NewDefaultMetadata creates and returns a new ICS27 Metadata instance containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadata { +func NewDefaultMetadata(controllerConnectionID string) Metadata { metadata := Metadata{ ControllerConnectionId: controllerConnectionID, - HostConnectionId: hostConnectionID, + HostConnectionId: "", Encoding: EncodingProtobuf, TxType: TxTypeSDKMultiMsg, Version: Version, @@ -48,8 +48,8 @@ func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadat // NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { - metadata := NewDefaultMetadata(controllerConnectionID, hostConnectionID) +func NewDefaultMetadataString(controllerConnectionID string) string { + metadata := NewDefaultMetadata(controllerConnectionID) return string(ModuleCdc.MustMarshalJSON(&metadata)) } From 237ade9490bbf2b0e43cedf23846c9b23b04d6e4 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Tue, 9 Jan 2024 23:53:24 +0700 Subject: [PATCH 12/43] OnChanOpenTry --- .../controller/migrations/v6/migrations_test.go | 4 ++-- .../controller/types/msgs_test.go | 4 ++-- .../host/keeper/handshake.go | 7 +++---- .../host/keeper/handshake_test.go | 14 +------------- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index 4aec10eb05a..fd5f47e71c4 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -38,8 +38,8 @@ func (suite *MigrationsTestSuite) SetupTest() { suite.path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID suite.path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED suite.path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - suite.path.EndpointA.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) - suite.path.EndpointB.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + suite.path.EndpointA.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + suite.path.EndpointB.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) } func (suite *MigrationsTestSuite) SetupPath() error { diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 17bf0d98e0c..673770948ac 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -42,7 +42,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { func() { feeMetadata := feetypes.Metadata{ FeeVersion: feetypes.Version, - AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), + AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), } bz := feetypes.ModuleCdc.MustMarshalJSON(&feeMetadata) @@ -79,7 +79,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { msg = types.NewMsgRegisterInterchainAccount( ibctesting.FirstConnectionID, ibctesting.TestAccAddress, - icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), + icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), ) tc.malleate() diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index c369e0c68e4..e4b3921ae8c 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -43,14 +43,13 @@ func (k Keeper) OnChanOpenTry( return "", err } + // override the HostConnectionId metadata + metadata.HostConnectionId = connectionHops[0] + if err = icatypes.ValidateHostMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { return "", err } - if metadata.HostConnectionId == "" { - metadata.HostConnectionId = connectionHops[0] - } - activeChannelID, found := k.GetActiveChannelID(ctx, connectionHops[0], counterparty.PortId) if found { channel, found := k.channelKeeper.GetChannel(ctx, portID, activeChannelID) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 4d033bf9e65..2f42032349b 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -247,18 +247,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { }, false, }, - { - "invalid host connection ID", - func() { - metadata.HostConnectionId = "invalid-connnection-id" - - versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) - suite.Require().NoError(err) - - path.EndpointA.ChannelConfig.Version = string(versionBytes) - }, - false, - }, { "invalid counterparty version", func() { @@ -544,7 +532,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) // use the same address as the previous metadata. metadata.Address = currentMetadata.Address From b53a2ff56b94f2a06dad5f19804e6f94522d8346 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Tue, 9 Jan 2024 23:56:14 +0700 Subject: [PATCH 13/43] TestOnChanUpgradeInit --- .../27-interchain-accounts/controller/keeper/handshake_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 1cf80a93971..0d57d904527 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -638,7 +638,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeInit() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) + metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) // use the same address as the previous metadata. metadata.Address = currentMetadata.Address From 0324206201ad761c418e2158758e45f5187d01c6 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Tue, 9 Jan 2024 23:57:05 +0700 Subject: [PATCH 14/43] TestOnChanUpgradeTry --- .../apps/27-interchain-accounts/host/keeper/handshake_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 2f42032349b..1f2456c186f 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -532,7 +532,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) + metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) // use the same address as the previous metadata. metadata.Address = currentMetadata.Address From b8e8fe247209796cf5f0751da80cb534304aa46d Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 00:07:56 +0700 Subject: [PATCH 15/43] TestOnChanUpgradeTry --- .../27-interchain-accounts/controller/ibc_middleware_test.go | 4 ++-- modules/apps/27-interchain-accounts/host/ibc_module_test.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 568edb2b031..0081df11c62 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -249,7 +249,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { ) if tc.expPass { - suite.Require().Equal(icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID), version) + suite.Require().Equal(TestVersion, version) suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -827,7 +827,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress) suite.Require().NoError(err) - metadata := icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + metadata := icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) tc.malleate() // malleate mutates test data diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index f5fdde6c5c1..7a48f9962cf 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -635,7 +635,8 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { interchainAccountAddr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID) suite.Require().True(found) - metadata := icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + metadata := icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) + metadata.HostConnectionId = path.EndpointB.ConnectionID metadata.Address = interchainAccountAddr metadata.Encoding = icatypes.EncodingProto3JSON // this is the actual change to the version path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) From a1a5e0f8c191e22b7848f84f0d274753f510289a Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 00:25:33 +0700 Subject: [PATCH 16/43] remove check --- .../apps/27-interchain-accounts/controller/keeper/handshake.go | 1 + .../27-interchain-accounts/controller/keeper/handshake_test.go | 2 ++ modules/apps/27-interchain-accounts/types/metadata.go | 3 --- modules/apps/29-fee/ica_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index bb584da2258..41c2225bcd8 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -47,6 +47,7 @@ func (k Keeper) OnChanOpenInit( err error metadata icatypes.Metadata ) + if strings.TrimSpace(version) == "" { _, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) if err != nil { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 0d57d904527..6f16e9b112f 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -806,6 +806,8 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeAck() { suite.Require().NoError(err) metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) + // add host connection id to metadata + metadata.HostConnectionId = path.EndpointB.ConnectionID // use the same address as the previous metadata. metadata.Address = currentMetadata.Address diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index f8adbf6e5ef..6ec6cd5b368 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -169,9 +169,6 @@ func validateConnectionParams(metadata Metadata, controllerConnectionID, hostCon } if metadata.HostConnectionId != hostConnectionID { - if metadata.HostConnectionId == "" { - return nil - } return errorsmod.Wrapf(connectiontypes.ErrInvalidConnection, "expected %s, got %s", hostConnectionID, metadata.HostConnectionId) } diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index 530ffa2f631..cda67c4f50e 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -25,7 +25,7 @@ var ( defaultPortID, _ = icatypes.NewControllerPortID(defaultOwnerAddress) // defaultICAVersion defines a reusable interchainaccounts version string for testing purposes - defaultICAVersion = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + defaultICAVersion = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) ) // NewIncentivizedICAPath creates and returns a new ibctesting path configured for a fee enabled interchain accounts channel From e1d2f77361410ff8eaa1ad6abd0db3c2d94c4c76 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 00:37:44 +0700 Subject: [PATCH 17/43] test --- .../controller/keeper/handshake_test.go | 2 +- .../controller/migrations/v6/migrations_test.go | 4 ++-- .../apps/27-interchain-accounts/controller/types/msgs_test.go | 4 ++-- modules/apps/27-interchain-accounts/types/metadata.go | 3 ++- modules/apps/29-fee/ica_test.go | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 6f16e9b112f..48c0551fb2d 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { "success: empty channel version returns default metadata JSON string", func() { channel.Version = "" - expectedVersionReturn = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID) + expectedVersionReturn = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, "") }, true, }, diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index fd5f47e71c4..4aec10eb05a 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -38,8 +38,8 @@ func (suite *MigrationsTestSuite) SetupTest() { suite.path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID suite.path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED suite.path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - suite.path.EndpointA.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) - suite.path.EndpointB.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + suite.path.EndpointA.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + suite.path.EndpointB.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) } func (suite *MigrationsTestSuite) SetupPath() error { diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 673770948ac..17bf0d98e0c 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -42,7 +42,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { func() { feeMetadata := feetypes.Metadata{ FeeVersion: feetypes.Version, - AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), + AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), } bz := feetypes.ModuleCdc.MustMarshalJSON(&feeMetadata) @@ -79,7 +79,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { msg = types.NewMsgRegisterInterchainAccount( ibctesting.FirstConnectionID, ibctesting.TestAccAddress, - icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), + icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), ) tc.malleate() diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 6ec6cd5b368..4990e679bf2 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -48,8 +48,9 @@ func NewDefaultMetadata(controllerConnectionID string) Metadata { // NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadataString(controllerConnectionID string) string { +func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { metadata := NewDefaultMetadata(controllerConnectionID) + metadata.HostConnectionId = hostConnectionID return string(ModuleCdc.MustMarshalJSON(&metadata)) } diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index cda67c4f50e..530ffa2f631 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -25,7 +25,7 @@ var ( defaultPortID, _ = icatypes.NewControllerPortID(defaultOwnerAddress) // defaultICAVersion defines a reusable interchainaccounts version string for testing purposes - defaultICAVersion = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + defaultICAVersion = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) ) // NewIncentivizedICAPath creates and returns a new ibctesting path configured for a fee enabled interchain accounts channel From cbb39da14da38fa2827acbddd5d2615e881df7a5 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 00:41:24 +0700 Subject: [PATCH 18/43] test --- .../host/keeper/handshake_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 1f2456c186f..2c7a781e4e0 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -105,6 +105,18 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { }, true, }, + { + "success - empty host connection ID", + func() { + metadata.HostConnectionId = "" + + versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) + suite.Require().NoError(err) + + path.EndpointA.ChannelConfig.Version = string(versionBytes) + }, + true, + }, { "reopening account fails - no existing account", func() { From 6d86f85dde55d9b805985f45fc05096e897690a8 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 00:46:25 +0700 Subject: [PATCH 19/43] nit --- .../27-interchain-accounts/controller/ibc_middleware_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 0081df11c62..d2aba7d2cca 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -249,7 +249,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { ) if tc.expPass { - suite.Require().Equal(TestVersion, version) + suite.Require().Equal(icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID), version) suite.Require().NoError(err) } else { suite.Require().Error(err) From 61f3fb53360973a6a718e037a474a127b52aa896 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 11:40:04 +0700 Subject: [PATCH 20/43] nit --- .../host/keeper/handshake_test.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 2c7a781e4e0..80b58dc5c56 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -93,18 +93,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { }, true, }, - { - "success - metadata empty host connection id", - func() { - metadata.HostConnectionId = "" - - versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) - suite.Require().NoError(err) - - path.EndpointA.ChannelConfig.Version = string(versionBytes) - }, - true, - }, { "success - empty host connection ID", func() { From e222c4b2cb2041a28e0a0b142c5ebfb6acf7aeb1 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 17:31:54 +0700 Subject: [PATCH 21/43] add check version --- .../27-interchain-accounts/host/keeper/handshake_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 80b58dc5c56..0d5df208461 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -303,6 +303,8 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) suite.Require().NoError(err) + expectedMetadataReturn := metadata + counterparty := channeltypes.NewCounterparty(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) channel = &channeltypes.Channel{ State: channeltypes.TRYOPEN, @@ -333,6 +335,12 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { // Check if account is created interchainAccount := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), interchainAccAddr) suite.Require().Equal(interchainAccount.GetAddress().String(), storedAddr) + + expectedMetadataReturn.Address = storedAddr + expectedVersionBytes, err := icatypes.ModuleCdc.MarshalJSON(&expectedMetadataReturn) + suite.Require().NoError(err) + + suite.Require().Equal(string(expectedVersionBytes), version) } else { suite.Require().Error(err) suite.Require().Equal("", version) From 0b0b7d068f859d4482c7e2d1e0e4f254d66de97e Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 19:09:37 +0700 Subject: [PATCH 22/43] NewDefaultMetadataString --- .../controller/ibc_middleware_test.go | 2 +- .../controller/keeper/handshake_test.go | 2 +- .../controller/migrations/v6/migrations_test.go | 10 ++++++++-- .../controller/types/msgs_test.go | 4 ++-- modules/apps/27-interchain-accounts/types/metadata.go | 3 +-- modules/apps/29-fee/ica_test.go | 4 +++- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index d2aba7d2cca..0081df11c62 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -249,7 +249,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { ) if tc.expPass { - suite.Require().Equal(icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID), version) + suite.Require().Equal(TestVersion, version) suite.Require().NoError(err) } else { suite.Require().Error(err) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 48c0551fb2d..6f16e9b112f 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { "success: empty channel version returns default metadata JSON string", func() { channel.Version = "" - expectedVersionReturn = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, "") + expectedVersionReturn = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID) }, true, }, diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index 4aec10eb05a..03ee1aedac8 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -17,6 +17,12 @@ import ( ibcmock "github.com/cosmos/ibc-go/v8/testing/mock" ) +var ( + metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + versionBytes, _ = icatypes.ModuleCdc.MarshalJSON(&metadata) + version = string(versionBytes) +) + type MigrationsTestSuite struct { testifysuite.Suite @@ -38,8 +44,8 @@ func (suite *MigrationsTestSuite) SetupTest() { suite.path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID suite.path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED suite.path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - suite.path.EndpointA.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) - suite.path.EndpointB.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + suite.path.EndpointA.ChannelConfig.Version = version + suite.path.EndpointB.ChannelConfig.Version = version } func (suite *MigrationsTestSuite) SetupPath() error { diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 17bf0d98e0c..673770948ac 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -42,7 +42,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { func() { feeMetadata := feetypes.Metadata{ FeeVersion: feetypes.Version, - AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), + AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), } bz := feetypes.ModuleCdc.MustMarshalJSON(&feeMetadata) @@ -79,7 +79,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { msg = types.NewMsgRegisterInterchainAccount( ibctesting.FirstConnectionID, ibctesting.TestAccAddress, - icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), + icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), ) tc.malleate() diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 4990e679bf2..6ec6cd5b368 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -48,9 +48,8 @@ func NewDefaultMetadata(controllerConnectionID string) Metadata { // NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { +func NewDefaultMetadataString(controllerConnectionID string) string { metadata := NewDefaultMetadata(controllerConnectionID) - metadata.HostConnectionId = hostConnectionID return string(ModuleCdc.MustMarshalJSON(&metadata)) } diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index 530ffa2f631..7c773143e3f 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -25,7 +25,9 @@ var ( defaultPortID, _ = icatypes.NewControllerPortID(defaultOwnerAddress) // defaultICAVersion defines a reusable interchainaccounts version string for testing purposes - defaultICAVersion = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + versionBytes, _ = icatypes.ModuleCdc.MarshalJSON(&metadata) + defaultICAVersion = string(versionBytes) ) // NewIncentivizedICAPath creates and returns a new ibctesting path configured for a fee enabled interchain accounts channel From 858954be5d766da4912e69e6758ed80dc528489f Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 10 Jan 2024 19:35:16 +0700 Subject: [PATCH 23/43] e2e --- e2e/tests/interchain_accounts/base_test.go | 8 ++++---- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- e2e/tests/interchain_accounts/localhost_test.go | 4 ++-- e2e/tests/interchain_accounts/params_test.go | 3 +-- e2e/tests/interchain_accounts/utils.go | 12 ++++++++++++ e2e/tests/upgrades/genesis_test.go | 3 ++- 7 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 e2e/tests/interchain_accounts/utils.go diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 1425e512787..06890262b66 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -58,7 +58,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() { t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -154,7 +154,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -252,7 +252,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) portID, err = icatypes.NewControllerPortID(controllerAddress) @@ -350,7 +350,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 3505fcd559d..29d97f34e4b 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -52,7 +52,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) }) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index 6fe99fe533b..a59b8394e54 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -114,7 +114,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 99dbc591eb1..393f710cdc4 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 5e8e0e10102..b47a0887bb4 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -16,7 +16,6 @@ import ( "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) @@ -94,7 +93,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/utils.go b/e2e/tests/interchain_accounts/utils.go new file mode 100644 index 00000000000..8a8ecee8375 --- /dev/null +++ b/e2e/tests/interchain_accounts/utils.go @@ -0,0 +1,12 @@ +package interchainaccounts + +import ( + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" +) + +func DefaultTestMetadataVersionString(controllerConnectionID, hostConnectionID string) string { + metadata := icatypes.NewMetadata(icatypes.Version, controllerConnectionID, hostConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) + + return string(versionBytes) +} diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 95cba42dcf9..5196f6b0fc9 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -20,6 +20,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + interchainaccounts "github.com/cosmos/ibc-go/e2e/tests/interchain_accounts" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" @@ -88,7 +89,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := interchainaccounts.DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) From 3b092a6aaf3300a46a0e0290e9ad1d1647fc78be Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 17 Jan 2024 17:29:22 +0700 Subject: [PATCH 24/43] change func name and var place --- e2e/tests/interchain_accounts/base_test.go | 8 ++++---- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- e2e/tests/interchain_accounts/localhost_test.go | 4 ++-- e2e/tests/interchain_accounts/params_test.go | 2 +- e2e/tests/interchain_accounts/utils.go | 2 +- e2e/tests/upgrades/genesis_test.go | 2 +- .../controller/migrations/v6/migrations_test.go | 10 ++++------ 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 06890262b66..1cf68d904f1 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -58,7 +58,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() { t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -154,7 +154,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -252,7 +252,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) portID, err = icatypes.NewControllerPortID(controllerAddress) @@ -350,7 +350,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 29d97f34e4b..fcb68f102e8 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -52,7 +52,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) }) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index a59b8394e54..f032204ec6d 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -114,7 +114,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 393f710cdc4..34b54465e3e 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index b47a0887bb4..48931ae15b4 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -93,7 +93,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/utils.go b/e2e/tests/interchain_accounts/utils.go index 8a8ecee8375..415f853df9d 100644 --- a/e2e/tests/interchain_accounts/utils.go +++ b/e2e/tests/interchain_accounts/utils.go @@ -4,7 +4,7 @@ import ( icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ) -func DefaultTestMetadataVersionString(controllerConnectionID, hostConnectionID string) string { +func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { metadata := icatypes.NewMetadata(icatypes.Version, controllerConnectionID, hostConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 5196f6b0fc9..bdf81507337 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -89,7 +89,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := interchainaccounts.DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := interchainaccounts.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index 03ee1aedac8..907998d158a 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -17,12 +17,6 @@ import ( ibcmock "github.com/cosmos/ibc-go/v8/testing/mock" ) -var ( - metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) - versionBytes, _ = icatypes.ModuleCdc.MarshalJSON(&metadata) - version = string(versionBytes) -) - type MigrationsTestSuite struct { testifysuite.Suite @@ -34,6 +28,10 @@ type MigrationsTestSuite struct { } func (suite *MigrationsTestSuite) SetupTest() { + metadata := icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) + version := string(versionBytes) + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) From ad3e34427557fc08f97caa01b727dc34a0d9317d Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 17 Jan 2024 17:37:31 +0700 Subject: [PATCH 25/43] callbacks --- modules/apps/callbacks/callbacks_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/apps/callbacks/callbacks_test.go b/modules/apps/callbacks/callbacks_test.go index 9796913cef6..ee0a9697945 100644 --- a/modules/apps/callbacks/callbacks_test.go +++ b/modules/apps/callbacks/callbacks_test.go @@ -115,15 +115,15 @@ func (s *CallbacksTestSuite) SetupICATest() string { icaOwner := s.chainA.SenderAccount.GetAddress().String() // ICAVersion defines a interchain accounts version string - icaVersion := icatypes.NewDefaultMetadataString(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID) + icaVersion := icatypes.NewMetadata(icatypes.Version, s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) icaControllerPortID, err := icatypes.NewControllerPortID(icaOwner) s.Require().NoError(err) s.path.SetChannelOrdered() s.path.EndpointA.ChannelConfig.PortID = icaControllerPortID s.path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID - s.path.EndpointA.ChannelConfig.Version = icaVersion - s.path.EndpointB.ChannelConfig.Version = icaVersion + s.path.EndpointA.ChannelConfig.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&icaVersion)) + s.path.EndpointB.ChannelConfig.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&icaVersion)) s.RegisterInterchainAccount(icaOwner) // open chan init must be skipped. So we cannot use .CreateChannels() From 27d488fea1b15f3231b5f74467e4573af658d8de Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 17 Jan 2024 19:12:35 +0700 Subject: [PATCH 26/43] revert icatypes.NewDefaultMetadataString --- e2e/tests/interchain_accounts/base_test.go | 8 ++++---- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- e2e/tests/interchain_accounts/localhost_test.go | 4 ++-- e2e/tests/interchain_accounts/params_test.go | 3 ++- e2e/tests/interchain_accounts/utils.go | 12 ------------ e2e/tests/upgrades/genesis_test.go | 3 +-- 7 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 e2e/tests/interchain_accounts/utils.go diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 1cf68d904f1..2e3f09eda18 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -58,7 +58,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() { t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -154,7 +154,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -252,7 +252,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) portID, err = icatypes.NewControllerPortID(controllerAddress) @@ -350,7 +350,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index fcb68f102e8..682d19dbccb 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -52,7 +52,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) }) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index f032204ec6d..41a872bd34f 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -114,7 +114,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID)) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 34b54465e3e..f2a7d019075 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 48931ae15b4..da14c316386 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) @@ -93,7 +94,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/utils.go b/e2e/tests/interchain_accounts/utils.go deleted file mode 100644 index 415f853df9d..00000000000 --- a/e2e/tests/interchain_accounts/utils.go +++ /dev/null @@ -1,12 +0,0 @@ -package interchainaccounts - -import ( - icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" -) - -func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { - metadata := icatypes.NewMetadata(icatypes.Version, controllerConnectionID, hostConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) - versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) - - return string(versionBytes) -} diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index bdf81507337..28de499dc75 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -20,7 +20,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - interchainaccounts "github.com/cosmos/ibc-go/e2e/tests/interchain_accounts" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" @@ -89,7 +88,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := interchainaccounts.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) From fd23ea256c9b5bcc92333a104c97e39483e15b08 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 17 Jan 2024 21:31:02 +0700 Subject: [PATCH 27/43] add back NewDefaultMetadataString with hostConnectionID --- e2e/tests/interchain_accounts/base_test.go | 8 ++++---- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- e2e/tests/interchain_accounts/localhost_test.go | 4 ++-- e2e/tests/interchain_accounts/params_test.go | 3 +-- e2e/tests/interchain_accounts/utils.go | 12 ++++++++++++ e2e/tests/upgrades/genesis_test.go | 3 ++- 7 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 e2e/tests/interchain_accounts/utils.go diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 2e3f09eda18..1cf68d904f1 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -58,7 +58,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() { t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -154,7 +154,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -252,7 +252,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) portID, err = icatypes.NewControllerPortID(controllerAddress) @@ -350,7 +350,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 682d19dbccb..fcb68f102e8 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -52,7 +52,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) }) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index 41a872bd34f..f032204ec6d 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -114,7 +114,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID)) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index f2a7d019075..eaad839c8dc 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index da14c316386..48931ae15b4 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -16,7 +16,6 @@ import ( "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) @@ -94,7 +93,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/utils.go b/e2e/tests/interchain_accounts/utils.go new file mode 100644 index 00000000000..415f853df9d --- /dev/null +++ b/e2e/tests/interchain_accounts/utils.go @@ -0,0 +1,12 @@ +package interchainaccounts + +import ( + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" +) + +func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { + metadata := icatypes.NewMetadata(icatypes.Version, controllerConnectionID, hostConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) + + return string(versionBytes) +} diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 28de499dc75..bdf81507337 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -20,6 +20,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + interchainaccounts "github.com/cosmos/ibc-go/e2e/tests/interchain_accounts" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" @@ -88,7 +89,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID) + version := interchainaccounts.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) From ef00a21013df3a5635e005a1f6a17b5ed603e7ce Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 17 Jan 2024 22:11:07 +0700 Subject: [PATCH 28/43] nit --- e2e/tests/interchain_accounts/localhost_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index eaad839c8dc..34b54465e3e 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) From 9abb30916c31f3e86ab51365d3513ec9d3a8ff92 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Wed, 17 Jan 2024 22:13:52 +0700 Subject: [PATCH 29/43] nit --- e2e/tests/interchain_accounts/base_test.go | 8 ++++---- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- e2e/tests/interchain_accounts/localhost_test.go | 4 ++-- e2e/tests/interchain_accounts/params_test.go | 2 +- e2e/tests/interchain_accounts/utils.go | 2 +- e2e/tests/upgrades/genesis_test.go | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 1cf68d904f1..06890262b66 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -58,7 +58,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() { t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -154,7 +154,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -252,7 +252,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) portID, err = icatypes.NewControllerPortID(controllerAddress) @@ -350,7 +350,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index fcb68f102e8..29d97f34e4b 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -52,7 +52,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) }) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index f032204ec6d..a59b8394e54 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -114,7 +114,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 34b54465e3e..393f710cdc4 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 48931ae15b4..b47a0887bb4 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -93,7 +93,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/utils.go b/e2e/tests/interchain_accounts/utils.go index 415f853df9d..8a8ecee8375 100644 --- a/e2e/tests/interchain_accounts/utils.go +++ b/e2e/tests/interchain_accounts/utils.go @@ -4,7 +4,7 @@ import ( icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ) -func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { +func DefaultTestMetadataVersionString(controllerConnectionID, hostConnectionID string) string { metadata := icatypes.NewMetadata(icatypes.Version, controllerConnectionID, hostConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index bdf81507337..5196f6b0fc9 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -89,7 +89,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := interchainaccounts.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := interchainaccounts.DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) From 5a6a68affa310ee3b576507abe61335c693ed1c1 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Thu, 18 Jan 2024 11:34:26 +0700 Subject: [PATCH 30/43] nit --- .../27-interchain-accounts/controller/keeper/handshake_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 8de5f5aacdc..14109f1ae3d 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { func() { path.EndpointB.ConnectionID = "" }, - true, + nil, }, { "success: previous active channel closed", From cebec2bc121868c83e3b35dc3f09051bab0c8b1b Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Thu, 18 Jan 2024 16:33:33 +0700 Subject: [PATCH 31/43] remove unused code --- .../27-interchain-accounts/controller/keeper/handshake.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index 552a0425c56..ff7e40780fa 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -44,11 +44,6 @@ func (k Keeper) OnChanOpenInit( ) if strings.TrimSpace(version) == "" { - _, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) - if err != nil { - return "", err - } - metadata = icatypes.NewDefaultMetadata(connectionHops[0]) } else { metadata, err = icatypes.MetadataFromVersion(version) From 530ecd9f9643fb6807bab48fab2f3c8114b084b9 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Fri, 19 Jan 2024 11:16:22 +0700 Subject: [PATCH 32/43] revert --- .../27-interchain-accounts/controller/keeper/handshake.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index ff7e40780fa..552a0425c56 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -44,6 +44,11 @@ func (k Keeper) OnChanOpenInit( ) if strings.TrimSpace(version) == "" { + _, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) + if err != nil { + return "", err + } + metadata = icatypes.NewDefaultMetadata(connectionHops[0]) } else { metadata, err = icatypes.MetadataFromVersion(version) From de2ef57cdccd8b808e13c3de77e06d1d89a4dfc4 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 1 Feb 2024 23:53:07 +0100 Subject: [PATCH 33/43] address self-review comments --- docs/docs/05-migrations/13-v8-to-v9.md | 16 +++++++++++ e2e/tests/interchain_accounts/base_test.go | 8 +++--- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- .../interchain_accounts/localhost_test.go | 4 +-- e2e/tests/interchain_accounts/params_test.go | 2 +- e2e/tests/interchain_accounts/utils.go | 12 --------- e2e/tests/upgrades/genesis_test.go | 3 +-- .../controller/ibc_middleware_test.go | 3 +-- .../controller/keeper/handshake.go | 5 ---- .../controller/keeper/handshake_test.go | 27 +++++++------------ .../host/keeper/handshake.go | 2 +- .../host/keeper/handshake_test.go | 9 ++++--- .../27-interchain-accounts/types/metadata.go | 12 +++++++-- modules/apps/callbacks/callbacks_test.go | 6 ++--- 15 files changed, 56 insertions(+), 57 deletions(-) delete mode 100644 e2e/tests/interchain_accounts/utils.go diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index 1cc0983f31e..6729992804b 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -24,6 +24,22 @@ There are four sections based on the four potential user groups of this document ## IBC Apps +### ICS27 - Interchain Accounts + +- The signature of function `NewDefaultMetadata` has changed: + +```diff +- func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadata ++ func NewDefaultMetadata(controllerConnectionID string) Metadata +``` + +- The signature of function `NewDefaultMetadataString` has changed: + +```diff +- func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) ++ func NewDefaultMetadataString(controllerConnectionID string) string +``` + ### API removals The `exported.ChannelI` interface has been removed. Please use the concrete type. diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index b21545512a8..282f710287a 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -73,7 +73,7 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, order) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -171,7 +171,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -269,7 +269,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) @@ -368,7 +368,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 07658d1cadd..160c8447536 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -53,7 +53,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version, channeltypes.ORDERED) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index c1923edba94..a17d5fbd400 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -115,7 +115,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), channeltypes.ORDERED) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), channeltypes.ORDERED) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 3c4251360a6..662b57d05e9 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := DefaultTestMetadataVersionString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 00c85447930..0d368b54bf8 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -95,7 +95,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/utils.go b/e2e/tests/interchain_accounts/utils.go deleted file mode 100644 index 8a8ecee8375..00000000000 --- a/e2e/tests/interchain_accounts/utils.go +++ /dev/null @@ -1,12 +0,0 @@ -package interchainaccounts - -import ( - icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" -) - -func DefaultTestMetadataVersionString(controllerConnectionID, hostConnectionID string) string { - metadata := icatypes.NewMetadata(icatypes.Version, controllerConnectionID, hostConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) - versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) - - return string(versionBytes) -} diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 9fc42f73acb..4b3adf5acf8 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -20,7 +20,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - interchainaccounts "github.com/cosmos/ibc-go/e2e/tests/interchain_accounts" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" @@ -90,7 +89,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := interchainaccounts.DefaultTestMetadataVersionString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 8b84b0d63c3..f4442f5657f 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -828,8 +828,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress) suite.Require().NoError(err) - metadata := icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) - version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) + version = icatypes.NewDefaultMetadataStringWithHostConnectionId(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) tc.malleate() // malleate mutates test data diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index 552a0425c56..ff7e40780fa 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -44,11 +44,6 @@ func (k Keeper) OnChanOpenInit( ) if strings.TrimSpace(version) == "" { - _, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) - if err != nil { - return "", err - } - metadata = icatypes.NewDefaultMetadata(connectionHops[0]) } else { metadata, err = icatypes.MetadataFromVersion(version) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index f8d62366fc3..7db6c2b5015 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -16,11 +16,11 @@ const ( func (suite *KeeperTestSuite) TestOnChanOpenInit() { var ( - channel *channeltypes.Channel - path *ibctesting.Path - chanCap *capabilitytypes.Capability - metadata icatypes.Metadata - expectedVersionReturn string + channel *channeltypes.Channel + path *ibctesting.Path + chanCap *capabilitytypes.Capability + metadata icatypes.Metadata + expectedVersion string ) testCases := []struct { @@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { "success: empty channel version returns default metadata JSON string", func() { channel.Version = "" - expectedVersionReturn = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID) + expectedVersion = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID) }, nil, }, @@ -182,14 +182,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { }, connectiontypes.ErrConnectionNotFound, }, - { - "connection not found with default empty channel version", - func() { - channel.ConnectionHops = []string{"connection-10"} - channel.Version = "" - }, - connectiontypes.ErrConnectionNotFound, - }, { "invalid controller connection ID", func() { @@ -287,7 +279,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) suite.Require().NoError(err) - expectedVersionReturn = string(versionBytes) + expectedVersion = string(versionBytes) counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) channel = &channeltypes.Channel{ @@ -310,7 +302,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { expPass := tc.expError == nil if expPass { suite.Require().NoError(err) - suite.Require().Equal(expectedVersionReturn, version) + suite.Require().Equal(expectedVersion, version) } else { suite.Require().Error(err) suite.Require().ErrorIs(err, tc.expError) @@ -668,7 +660,8 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeInit() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) + metadata.HostConnectionId = path.EndpointB.ConnectionID // use the same address as the previous metadata. metadata.Address = currentMetadata.Address diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index 318ce76aee2..853f663ae0d 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -39,7 +39,7 @@ func (k Keeper) OnChanOpenTry( return "", err } - // override the HostConnectionId metadata + // set here the HostConnectionId because the controller did not set it metadata.HostConnectionId = connectionHops[0] if err = icatypes.ValidateHostMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index e01191dfa2f..0db3695359b 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -314,7 +314,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { versionBytes, err := icatypes.ModuleCdc.MarshalJSON(&metadata) suite.Require().NoError(err) - expectedMetadataReturn := metadata + expectedMetadata := metadata counterparty := channeltypes.NewCounterparty(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) channel = &channeltypes.Channel{ @@ -347,8 +347,8 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { interchainAccount := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), interchainAccAddr) suite.Require().Equal(interchainAccount.GetAddress().String(), storedAddr) - expectedMetadataReturn.Address = storedAddr - expectedVersionBytes, err := icatypes.ModuleCdc.MarshalJSON(&expectedMetadataReturn) + expectedMetadata.Address = storedAddr + expectedVersionBytes, err := icatypes.ModuleCdc.MarshalJSON(&expectedMetadata) suite.Require().NoError(err) suite.Require().Equal(string(expectedVersionBytes), version) @@ -592,7 +592,8 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) + metadata.HostConnectionId = path.EndpointB.ConnectionID // use the same address as the previous metadata. metadata.Address = currentMetadata.Address diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index b6dec958389..d0d53f08d6b 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -33,7 +33,7 @@ func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, } // NewDefaultMetadata creates and returns a new ICS27 Metadata instance containing the default ICS27 Metadata values -// with the provided controller and host connection identifiers +// with the provided controller connection identifier func NewDefaultMetadata(controllerConnectionID string) Metadata { metadata := Metadata{ ControllerConnectionId: controllerConnectionID, @@ -47,13 +47,21 @@ func NewDefaultMetadata(controllerConnectionID string) Metadata { } // NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values -// with the provided controller and host connection identifiers +// with the provided controller connection identifier and an empty host connection identifier func NewDefaultMetadataString(controllerConnectionID string) string { metadata := NewDefaultMetadata(controllerConnectionID) return string(ModuleCdc.MustMarshalJSON(&metadata)) } +// NewDefaultMetadataStringWithHostConnectionId creates and returns a new JSON encoded version string containing the default ICS27 Metadata values +// with the provided controller and host connection identifiers +func NewDefaultMetadataStringWithHostConnectionId(controllerConnectionID, hostConnectionID string) string { + metadata := NewMetadata(Version, controllerConnectionID, hostConnectionID, "", EncodingProtobuf, TxTypeSDKMultiMsg) + + return string(ModuleCdc.MustMarshalJSON(&metadata)) +} + // MetadataFromVersion parses Metadata from a json encoded version string. func MetadataFromVersion(versionString string) (Metadata, error) { var metadata Metadata diff --git a/modules/apps/callbacks/callbacks_test.go b/modules/apps/callbacks/callbacks_test.go index f9947c642c5..bec84cbffcb 100644 --- a/modules/apps/callbacks/callbacks_test.go +++ b/modules/apps/callbacks/callbacks_test.go @@ -116,15 +116,15 @@ func (s *CallbacksTestSuite) SetupICATest() string { icaOwner := s.chainA.SenderAccount.GetAddress().String() // ICAVersion defines a interchain accounts version string - icaVersion := icatypes.NewMetadata(icatypes.Version, s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) + icaVersion := icatypes.NewDefaultMetadataStringWithHostConnectionId(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID) icaControllerPortID, err := icatypes.NewControllerPortID(icaOwner) s.Require().NoError(err) s.path.SetChannelOrdered() s.path.EndpointA.ChannelConfig.PortID = icaControllerPortID s.path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID - s.path.EndpointA.ChannelConfig.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&icaVersion)) - s.path.EndpointB.ChannelConfig.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&icaVersion)) + s.path.EndpointA.ChannelConfig.Version = icaVersion + s.path.EndpointB.ChannelConfig.Version = icaVersion s.RegisterInterchainAccount(icaOwner) // open chan init must be skipped. So we cannot use .CreateChannels() From 6af728f2c13285459da590fecc0456343d7a3468 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 1 Feb 2024 23:58:37 +0100 Subject: [PATCH 34/43] add import back --- e2e/tests/interchain_accounts/params_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 0d368b54bf8..83d3ba68aaa 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -16,7 +16,7 @@ import ( "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) From cfd440a8bde5c65b29353a092c8d8caa70372b00 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 2 Feb 2024 00:03:46 +0100 Subject: [PATCH 35/43] some more refactoring --- .../controller/migrations/v6/migrations_test.go | 4 +--- modules/apps/29-fee/ica_test.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index e907f45304c..52381593e8f 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -28,9 +28,7 @@ type MigrationsTestSuite struct { } func (suite *MigrationsTestSuite) SetupTest() { - metadata := icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) - versionBytes, _ := icatypes.ModuleCdc.MarshalJSON(&metadata) - version := string(versionBytes) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index 339ce295e53..d00836486d0 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -25,9 +25,7 @@ var ( defaultPortID, _ = icatypes.NewControllerPortID(defaultOwnerAddress) // defaultICAVersion defines a reusable interchainaccounts version string for testing purposes - metadata = icatypes.NewMetadata(icatypes.Version, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID, "", icatypes.EncodingProtobuf, icatypes.TxTypeSDKMultiMsg) - versionBytes, _ = icatypes.ModuleCdc.MarshalJSON(&metadata) - defaultICAVersion = string(versionBytes) + defaultICAVersion = icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) ) // NewIncentivizedICAPath creates and returns a new ibctesting path configured for a fee enabled interchain accounts channel From 61b35056f210905352520b2c3f44da384a2c5860 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 2 Feb 2024 00:06:33 +0100 Subject: [PATCH 36/43] more cleanup --- .../controller/ibc_middleware_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index f4442f5657f..bee7fea7daf 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -31,13 +31,7 @@ var ( TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress) // TestVersion defines a reusable interchainaccounts version string for testing purposes - TestVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{ - Version: icatypes.Version, - ControllerConnectionId: ibctesting.FirstConnectionID, - HostConnectionId: ibctesting.FirstConnectionID, - Encoding: icatypes.EncodingProtobuf, - TxType: icatypes.TxTypeSDKMultiMsg, - })) + TestVersion = icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) ) type InterchainAccountsTestSuite struct { From 8f381a5eee95a24fb23dbdd7d630af9a7813e4aa Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Fri, 2 Feb 2024 11:20:15 +0700 Subject: [PATCH 37/43] remove unused test --- .../controller/keeper/handshake_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 302d21ba718..2f0e43696b2 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -33,13 +33,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { func() {}, nil, }, - { - "success: empty host connection ID", - func() { - path.EndpointB.ConnectionID = "" - }, - nil, - }, { "success: previous active channel closed", func() { From f9a8e4c8e980a7d3cac4605f9f76d7893911fdde Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Fri, 2 Feb 2024 11:27:18 +0700 Subject: [PATCH 38/43] change set version func --- e2e/tests/interchain_accounts/upgrades_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index ddfe321f2ef..5d487458559 100644 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ b/e2e/tests/interchain_accounts/upgrades_test.go @@ -63,7 +63,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) @@ -249,7 +249,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) s.AssertTxSuccess(txResp) From 22871330aeb52f3e5ea91d8c57568a7098f9ccfd Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Fri, 2 Feb 2024 11:33:28 +0700 Subject: [PATCH 39/43] lint --- e2e/tests/interchain_accounts/base_test.go | 8 ++++---- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- e2e/tests/interchain_accounts/localhost_test.go | 4 ++-- e2e/tests/interchain_accounts/params_test.go | 2 +- e2e/tests/interchain_accounts/upgrades_test.go | 4 ++-- e2e/tests/upgrades/genesis_test.go | 2 +- .../controller/ibc_middleware_test.go | 4 ++-- .../controller/migrations/v6/migrations_test.go | 2 +- modules/apps/27-interchain-accounts/types/metadata.go | 4 ++-- modules/apps/29-fee/ica_test.go | 2 +- modules/apps/callbacks/callbacks_test.go | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 0881ae6da06..1d0bbde6092 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -73,7 +73,7 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, order) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -172,7 +172,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -270,7 +270,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) @@ -369,7 +369,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 160c8447536..a7614289a11 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -53,7 +53,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version, channeltypes.ORDERED) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index a17d5fbd400..2d04f4818e6 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -115,7 +115,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), channeltypes.ORDERED) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), channeltypes.ORDERED) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index a8494d5da2a..5e01d7910d1 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 83d3ba68aaa..9b851b94d82 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -95,7 +95,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index 5d487458559..51e6afea42a 100644 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ b/e2e/tests/interchain_accounts/upgrades_test.go @@ -63,7 +63,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) @@ -249,7 +249,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) s.AssertTxSuccess(txResp) diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index 4b3adf5acf8..a1b41763d1e 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -89,7 +89,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 6f9ba8a27a7..ee3cdb35b7d 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -31,7 +31,7 @@ var ( TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress) // TestVersion defines a reusable interchainaccounts version string for testing purposes - TestVersion = icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + TestVersion = icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) ) type InterchainAccountsTestSuite struct { @@ -822,7 +822,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress) suite.Require().NoError(err) - version = icatypes.NewDefaultMetadataStringWithHostConnectionId(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + version = icatypes.NewDefaultMetadataStringWithHostConnectionID(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) tc.malleate() // malleate mutates test data diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index 52381593e8f..e83a21a73e7 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -28,7 +28,7 @@ type MigrationsTestSuite struct { } func (suite *MigrationsTestSuite) SetupTest() { - version := icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 3c064569119..562838b48a1 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -54,9 +54,9 @@ func NewDefaultMetadataString(controllerConnectionID string) string { return string(ModuleCdc.MustMarshalJSON(&metadata)) } -// NewDefaultMetadataStringWithHostConnectionId creates and returns a new JSON encoded version string containing the default ICS27 Metadata values +// NewDefaultMetadataStringWithHostConnectionID creates and returns a new JSON encoded version string containing the default ICS27 Metadata values // with the provided controller and host connection identifiers -func NewDefaultMetadataStringWithHostConnectionId(controllerConnectionID, hostConnectionID string) string { +func NewDefaultMetadataStringWithHostConnectionID(controllerConnectionID, hostConnectionID string) string { metadata := NewMetadata(Version, controllerConnectionID, hostConnectionID, "", EncodingProtobuf, TxTypeSDKMultiMsg) return string(ModuleCdc.MustMarshalJSON(&metadata)) diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index d00836486d0..bf295086eb9 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -25,7 +25,7 @@ var ( defaultPortID, _ = icatypes.NewControllerPortID(defaultOwnerAddress) // defaultICAVersion defines a reusable interchainaccounts version string for testing purposes - defaultICAVersion = icatypes.NewDefaultMetadataStringWithHostConnectionId(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + defaultICAVersion = icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) ) // NewIncentivizedICAPath creates and returns a new ibctesting path configured for a fee enabled interchain accounts channel diff --git a/modules/apps/callbacks/callbacks_test.go b/modules/apps/callbacks/callbacks_test.go index bec84cbffcb..983262c140d 100644 --- a/modules/apps/callbacks/callbacks_test.go +++ b/modules/apps/callbacks/callbacks_test.go @@ -116,7 +116,7 @@ func (s *CallbacksTestSuite) SetupICATest() string { icaOwner := s.chainA.SenderAccount.GetAddress().String() // ICAVersion defines a interchain accounts version string - icaVersion := icatypes.NewDefaultMetadataStringWithHostConnectionId(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID) + icaVersion := icatypes.NewDefaultMetadataStringWithHostConnectionID(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID) icaControllerPortID, err := icatypes.NewControllerPortID(icaOwner) s.Require().NoError(err) From e23cf8514e96a03c5897b58af324d755274eee1c Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 7 Mar 2024 23:12:55 +0100 Subject: [PATCH 40/43] still set host connection ID in our controller implementation --- docs/docs/05-migrations/13-v8-to-v9.md | 16 --------------- e2e/tests/interchain_accounts/base_test.go | 8 ++++---- e2e/tests/interchain_accounts/gov_test.go | 2 +- e2e/tests/interchain_accounts/groups_test.go | 2 +- .../interchain_accounts/localhost_test.go | 4 ++-- e2e/tests/interchain_accounts/params_test.go | 2 +- .../interchain_accounts/upgrades_test.go | 4 ++-- e2e/tests/upgrades/genesis_test.go | 2 +- .../controller/ibc_middleware_test.go | 4 ++-- .../controller/keeper/handshake.go | 13 ++++++++---- .../controller/keeper/handshake_test.go | 17 ++++++++++------ .../migrations/v6/migrations_test.go | 2 +- .../controller/types/msgs_test.go | 4 ++-- .../host/ibc_module_test.go | 3 +-- .../host/keeper/handshake.go | 2 +- .../host/keeper/handshake_test.go | 2 +- .../27-interchain-accounts/types/metadata.go | 20 ++++++------------- modules/apps/29-fee/ica_test.go | 2 +- modules/apps/callbacks/callbacks_test.go | 2 +- 19 files changed, 48 insertions(+), 63 deletions(-) diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index 866972f302d..ba6bd719a45 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -24,22 +24,6 @@ There are four sections based on the four potential user groups of this document ## IBC Apps -### ICS27 - Interchain Accounts - -- The signature of function `NewDefaultMetadata` has changed: - -```diff -- func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadata -+ func NewDefaultMetadata(controllerConnectionID string) Metadata -``` - -- The signature of function `NewDefaultMetadataString` has changed: - -```diff -- func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) -+ func NewDefaultMetadataString(controllerConnectionID string) string -``` - ### API removals The `exported.ChannelI` and `exported.CounterpartyChannelI` interfaces have been removed. Please use the concrete types. diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 1d0bbde6092..ef87037649f 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -73,7 +73,7 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, order) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -172,7 +172,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) @@ -270,7 +270,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) @@ -369,7 +369,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // on an ordered channel t.Run("register interchain account", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index a7614289a11..9060c413565 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -53,7 +53,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() s.Require().NotNil(govModuleAddress) t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version, channeltypes.ORDERED) s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index 2d04f4818e6..43faca17a3f 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -115,7 +115,7 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) { groupPolicyAddr = s.QueryGroupPolicyAddress(ctx, chainA) - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), channeltypes.ORDERED) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, groupPolicyAddr, icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), channeltypes.ORDERED) msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount") s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 5e01d7910d1..fdd875686e4 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -59,7 +59,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost( s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) @@ -214,7 +214,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(exported.LocalhostConnectionID, exported.LocalhostConnectionID) + version := icatypes.NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 9b851b94d82..4cdc64fa371 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -95,7 +95,7 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go index 51e6afea42a..ddfe321f2ef 100644 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ b/e2e/tests/interchain_accounts/upgrades_test.go @@ -63,7 +63,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTra t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) @@ -249,7 +249,7 @@ func (s *InterchainAccountsChannelUpgradesTestSuite) TestChannelUpgrade_ICAChann t.Run("register interchain account", func(t *testing.T) { var err error // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) s.AssertTxSuccess(txResp) diff --git a/e2e/tests/upgrades/genesis_test.go b/e2e/tests/upgrades/genesis_test.go index a1b41763d1e..4b387bb128b 100644 --- a/e2e/tests/upgrades/genesis_test.go +++ b/e2e/tests/upgrades/genesis_test.go @@ -89,7 +89,7 @@ func (s *GenesisTestSuite) TestIBCGenesis() { t.Run("ics27: broadcast MsgRegisterInterchainAccount", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index f9cd3ed2aed..c8ef37eecdf 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -31,7 +31,7 @@ var ( TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress) // TestVersion defines a reusable interchainaccounts version string for testing purposes - TestVersion = icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + TestVersion = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) ) type InterchainAccountsTestSuite struct { @@ -836,7 +836,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress) suite.Require().NoError(err) - version = icatypes.NewDefaultMetadataStringWithHostConnectionID(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + version = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) tc.malleate() // malleate mutates test data diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index ff7e40780fa..ac05f43aa18 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -44,18 +44,23 @@ func (k Keeper) OnChanOpenInit( ) if strings.TrimSpace(version) == "" { - metadata = icatypes.NewDefaultMetadata(connectionHops[0]) - } else { - metadata, err = icatypes.MetadataFromVersion(version) + connection, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) if err != nil { return "", err } - if err := icatypes.ValidateControllerMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { + metadata = icatypes.NewDefaultMetadata(connectionHops[0], connection.Counterparty.ConnectionId) + } else { + metadata, err = icatypes.MetadataFromVersion(version) + if err != nil { return "", err } } + if err := icatypes.ValidateControllerMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { + return "", err + } + activeChannelID, found := k.GetActiveChannelID(ctx, connectionHops[0], portID) if found { channel, found := k.channelKeeper.GetChannel(ctx, portID, activeChannelID) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index bd00677a928..ec8a671b307 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -55,7 +55,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { "success: empty channel version returns default metadata JSON string", func() { channel.Version = "" - expectedVersion = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID) + expectedVersion = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) }, nil, }, @@ -172,6 +172,14 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { }, connectiontypes.ErrConnectionNotFound, }, + { + "connection not found with default empty channel version", + func() { + channel.ConnectionHops = []string{"connection-10"} + channel.Version = "" + }, + connectiontypes.ErrConnectionNotFound, + }, { "invalid controller connection ID", func() { @@ -648,8 +656,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeInit() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) - metadata.HostConnectionId = path.EndpointB.ConnectionID + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) // use the same address as the previous metadata. metadata.Address = currentMetadata.Address @@ -814,9 +821,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeAck() { currentMetadata, err := suite.chainA.GetSimApp().ICAControllerKeeper.GetAppMetadata(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) suite.Require().NoError(err) - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) - // add host connection id to metadata - metadata.HostConnectionId = path.EndpointB.ConnectionID + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) // use the same address as the previous metadata. metadata.Address = currentMetadata.Address diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index e83a21a73e7..dcbe067ceaf 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -28,7 +28,7 @@ type MigrationsTestSuite struct { } func (suite *MigrationsTestSuite) SetupTest() { - version := icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index df156cf4aa3..8f15b2ba9d9 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -43,7 +43,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { func() { feeMetadata := feetypes.Metadata{ FeeVersion: feetypes.Version, - AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), + AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), } bz := feetypes.ModuleCdc.MustMarshalJSON(&feeMetadata) @@ -87,7 +87,7 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { msg = types.NewMsgRegisterInterchainAccount( ibctesting.FirstConnectionID, ibctesting.TestAccAddress, - icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID), + icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID), channeltypes.ORDERED, ) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index be97ebca071..e8f2d859b2f 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -696,8 +696,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { interchainAccountAddr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID) suite.Require().True(found) - metadata := icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) - metadata.HostConnectionId = path.EndpointB.ConnectionID + metadata := icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) metadata.Address = interchainAccountAddr metadata.Encoding = icatypes.EncodingProto3JSON // this is the actual change to the version path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index 853f663ae0d..a9a62c55e75 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -39,7 +39,7 @@ func (k Keeper) OnChanOpenTry( return "", err } - // set here the HostConnectionId because the controller did not set it + // set here the HostConnectionId in case the controller did not set it metadata.HostConnectionId = connectionHops[0] if err = icatypes.ValidateHostMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index cf8c9f86e0b..2e6452680d9 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -587,7 +587,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { suite.Require().NoError(err) order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID) + metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) metadata.HostConnectionId = path.EndpointB.ConnectionID // use the same address as the previous metadata. metadata.Address = currentMetadata.Address diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 562838b48a1..0508466aad5 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -33,11 +33,11 @@ func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, } // NewDefaultMetadata creates and returns a new ICS27 Metadata instance containing the default ICS27 Metadata values -// with the provided controller connection identifier -func NewDefaultMetadata(controllerConnectionID string) Metadata { +// with the provided controller and host connection identifiers. The host connection identifier may be an empty string. +func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadata { metadata := Metadata{ ControllerConnectionId: controllerConnectionID, - HostConnectionId: "", + HostConnectionId: hostConnectionID, Encoding: EncodingProtobuf, TxType: TxTypeSDKMultiMsg, Version: Version, @@ -47,17 +47,9 @@ func NewDefaultMetadata(controllerConnectionID string) Metadata { } // NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values -// with the provided controller connection identifier and an empty host connection identifier -func NewDefaultMetadataString(controllerConnectionID string) string { - metadata := NewDefaultMetadata(controllerConnectionID) - - return string(ModuleCdc.MustMarshalJSON(&metadata)) -} - -// NewDefaultMetadataStringWithHostConnectionID creates and returns a new JSON encoded version string containing the default ICS27 Metadata values -// with the provided controller and host connection identifiers -func NewDefaultMetadataStringWithHostConnectionID(controllerConnectionID, hostConnectionID string) string { - metadata := NewMetadata(Version, controllerConnectionID, hostConnectionID, "", EncodingProtobuf, TxTypeSDKMultiMsg) +// with the provided controller and host connection identifiers. The host connection identifier may be an empty string. +func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string { + metadata := NewDefaultMetadata(controllerConnectionID, hostConnectionID) return string(ModuleCdc.MustMarshalJSON(&metadata)) } diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index bf295086eb9..a7f45fb4af6 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -25,7 +25,7 @@ var ( defaultPortID, _ = icatypes.NewControllerPortID(defaultOwnerAddress) // defaultICAVersion defines a reusable interchainaccounts version string for testing purposes - defaultICAVersion = icatypes.NewDefaultMetadataStringWithHostConnectionID(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + defaultICAVersion = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) ) // NewIncentivizedICAPath creates and returns a new ibctesting path configured for a fee enabled interchain accounts channel diff --git a/modules/apps/callbacks/callbacks_test.go b/modules/apps/callbacks/callbacks_test.go index 983262c140d..65eb1764658 100644 --- a/modules/apps/callbacks/callbacks_test.go +++ b/modules/apps/callbacks/callbacks_test.go @@ -116,7 +116,7 @@ func (s *CallbacksTestSuite) SetupICATest() string { icaOwner := s.chainA.SenderAccount.GetAddress().String() // ICAVersion defines a interchain accounts version string - icaVersion := icatypes.NewDefaultMetadataStringWithHostConnectionID(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID) + icaVersion := icatypes.NewDefaultMetadataString(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID) icaControllerPortID, err := icatypes.NewControllerPortID(icaOwner) s.Require().NoError(err) From abcff645c795dd7a725cc723884c8ddfe4d1401b Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 7 Mar 2024 23:16:54 +0100 Subject: [PATCH 41/43] remove empty lines --- e2e/tests/interchain_accounts/base_test.go | 2 -- e2e/tests/interchain_accounts/gov_test.go | 1 - .../apps/27-interchain-accounts/controller/keeper/handshake.go | 1 - 3 files changed, 4 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index ef87037649f..1477f4b511a 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -272,7 +272,6 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // explicitly set the version string because we don't want to use incentivized channels. version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) - s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) portID, err = icatypes.NewControllerPortID(controllerAddress) s.Require().NoError(err) @@ -371,7 +370,6 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop // explicitly set the version string because we don't want to use incentivized channels. version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) - s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB)) diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 9060c413565..212b5d173f4 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -55,7 +55,6 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version, channeltypes.ORDERED) - s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount) }) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index ac05f43aa18..aa54053221a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -42,7 +42,6 @@ func (k Keeper) OnChanOpenInit( err error metadata icatypes.Metadata ) - if strings.TrimSpace(version) == "" { connection, err := k.channelKeeper.GetConnection(ctx, connectionHops[0]) if err != nil { From 5b5b609b16d17399b90209431ba90f5fffe2dc12 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 09:31:30 +0100 Subject: [PATCH 42/43] remove unnecessary line --- .../apps/27-interchain-accounts/host/keeper/handshake_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 2e6452680d9..90a5cb74874 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -588,10 +588,8 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { order = channeltypes.ORDERED metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) - metadata.HostConnectionId = path.EndpointB.ConnectionID // use the same address as the previous metadata. metadata.Address = currentMetadata.Address - // this is the actual change to the version. metadata.Encoding = icatypes.EncodingProto3JSON From 883d795fe057d53bf3850958c0c853bdc185123a Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 09:36:53 +0100 Subject: [PATCH 43/43] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7803cb99797..a3d37512f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (apps/27-interchain-accounts) [\#5533](https://github.com/cosmos/ibc-go/pull/5533) ICA host sets the host connection ID on `OnChanOpenTry`, so that ICA controller implementations are not obliged to set the value on `OnChanOpenInit` if they are not able. + ### Features ### Bug Fixes