From 68fd35056fa525483273b5347d9c68650a8ef86f Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 26 Jan 2024 14:09:56 +0100 Subject: [PATCH 1/3] fix: re-enable ica unordered channel upgrade --- e2e/relayer/relayer.go | 2 +- e2e/tests/interchain_accounts/base_test.go | 164 ++++++++++++++------- e2e/testsuite/testconfig.go | 2 +- 3 files changed, 110 insertions(+), 58 deletions(-) diff --git a/e2e/relayer/relayer.go b/e2e/relayer/relayer.go index b63e1b86ba7..3ea06b3d3fe 100644 --- a/e2e/relayer/relayer.go +++ b/e2e/relayer/relayer.go @@ -16,7 +16,7 @@ const ( Hermes = "hermes" Hyperspace = "hyperspace" - HermesRelayerRepository = "ghcr.io/informalsystems/hermes" + HermesRelayerRepository = "crodveg/carlos-channel-upgrades" hermesRelayerUser = "1000:1000" RlyRelayerRepository = "ghcr.io/cosmos/relayer" rlyRelayerUser = "100:1000" diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 1199e0f35b8..92dc97de83a 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -17,6 +17,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" @@ -424,8 +425,6 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop }) } -/* -TODO: uncomment when hermes works with upgrades, https://github.com/cosmos/ibc-go/issues/5644 func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgradingOrdertoUnordered() { t := s.T() ctx := context.TODO() @@ -433,13 +432,13 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgr // setup relayers and connection-0 between two chains // channel-0 is a transfer channel but it will not be used in this test case relayer, _ := s.SetupChainsRelayerAndChannel(ctx, nil) - chainA, _ := s.GetChains() + chainA, chainB := s.GetChains() // setup 2 accounts: controller account on chain A, a second chain B account. // host account will be created when the ICA is registered controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) controllerAddress := controllerAccount.FormattedAddress() - // chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) + chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) var ( portID string @@ -472,57 +471,57 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgr s.Require().NoError(err) }) - // t.Run("fund interchain account wallet", func(t *testing.T) { - // // fund the host account account so it has some $$ to send - // err := chainB.SendFunds(ctx, interchaintest.FaucetAccountKeyName, ibc.WalletAmount{ - // Address: hostAccount, - // Amount: sdkmath.NewInt(testvalues.StartingTokenAmount), - // Denom: chainB.Config().Denom, - // }) - // s.Require().NoError(err) - // }) - - // t.Run("broadcast MsgSendTx", func(t *testing.T) { - // // assemble bank transfer message from host account to user account on host chain - // msgSend := &banktypes.MsgSend{ - // FromAddress: hostAccount, - // ToAddress: chainBAccount.FormattedAddress(), - // Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)), - // } - - // cdc := testsuite.Codec() - - // bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) - // s.Require().NoError(err) - - // packetData := icatypes.InterchainAccountPacketData{ - // Type: icatypes.EXECUTE_TX, - // Data: bz, - // Memo: "e2e", - // } - - // msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(5*time.Minute), packetData) - - // resp := s.BroadcastMessages( - // ctx, - // chainA, - // controllerAccount, - // msgSendTx, - // ) - - // s.AssertTxSuccess(resp) - - // // time for the packet to be relayed - // s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB)) - // }) - - // t.Run("verify tokens transferred", func(t *testing.T) { - // balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) - // s.Require().NoError(err) - - // expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount - // s.Require().Equal(expected, balance.Int64()) - // }) + t.Run("fund interchain account wallet", func(t *testing.T) { + // fund the host account account so it has some $$ to send + err := chainB.SendFunds(ctx, interchaintest.FaucetAccountKeyName, ibc.WalletAmount{ + Address: hostAccount, + Amount: sdkmath.NewInt(testvalues.StartingTokenAmount), + Denom: chainB.Config().Denom, + }) + s.Require().NoError(err) + }) + + t.Run("broadcast MsgSendTx", func(t *testing.T) { + // assemble bank transfer message from host account to user account on host chain + msgSend := &banktypes.MsgSend{ + FromAddress: hostAccount, + ToAddress: chainBAccount.FormattedAddress(), + Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)), + } + + cdc := testsuite.Codec() + + bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) + s.Require().NoError(err) + + packetData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: bz, + Memo: "e2e", + } + + msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(5*time.Minute), packetData) + + resp := s.BroadcastMessages( + ctx, + chainA, + controllerAccount, + msgSendTx, + ) + + s.AssertTxSuccess(resp) + + // time for the packet to be relayed + s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB)) + }) + + t.Run("verify tokens transferred", func(t *testing.T) { + balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + s.Require().NoError(err) + + expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount + s.Require().Equal(expected, balance.Int64()) + }) channel, err := s.QueryChannel(ctx, chainA, portID, initialChannelID) s.Require().NoError(err) @@ -550,5 +549,58 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgr }) s.Require().NoErrorf(waitErr, "channel was not upgraded: expected %s got %s", channeltypes.UNORDERED, channel.Ordering) }) + + t.Run("verify channel B upgraded and is now unordered", func(t *testing.T) { + var channel channeltypes.Channel + waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { + channel, err = s.QueryChannel(ctx, chainB, icatypes.HostPortID, initialChannelID) + if err != nil { + return false, err + } + return channel.Ordering == channeltypes.UNORDERED, nil + }) + s.Require().NoErrorf(waitErr, "channel was not upgraded: expected %s got %s", channeltypes.UNORDERED, channel.Ordering) + }) + + t.Run("broadcast MsgSendTx", func(t *testing.T) { + // assemble bank transfer message from host account to user account on host chain + msgSend := &banktypes.MsgSend{ + FromAddress: hostAccount, + ToAddress: chainBAccount.FormattedAddress(), + Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)), + } + + cdc := testsuite.Codec() + + bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) + s.Require().NoError(err) + + packetData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: bz, + Memo: "e2e", + } + + msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(5*time.Minute), packetData) + + resp := s.BroadcastMessages( + ctx, + chainA, + controllerAccount, + msgSendTx, + ) + + s.AssertTxSuccess(resp) + + // time for the packet to be relayed + s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB)) + }) + + t.Run("verify tokens transferred", func(t *testing.T) { + balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) + s.Require().NoError(err) + + expected := 2*testvalues.IBCTransferAmount + testvalues.StartingTokenAmount + s.Require().Equal(expected, balance.Int64()) + }) } -*/ diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index 3da52060b06..516499b3934 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -62,7 +62,7 @@ const ( // TODO: https://github.com/cosmos/ibc-go/issues/4965 defaultHyperspaceTag = "20231122v39" // defaultHermesTag is the tag that will be used if no relayer tag is specified for hermes. - defaultHermesTag = "luca_joss-channel-upgrade-authority" + defaultHermesTag = "latest" // defaultChainTag is the tag that will be used for the chains if none is specified. defaultChainTag = "main" // defaultConfigFileName is the default filename for the config file that can be used to configure From 012cc5b3afe2468bd4be93d01539d8429877b8c8 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 26 Jan 2024 23:13:35 +0100 Subject: [PATCH 2/3] put back hermes repository --- e2e/relayer/relayer.go | 2 +- e2e/testsuite/testconfig.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/relayer/relayer.go b/e2e/relayer/relayer.go index 3ea06b3d3fe..b63e1b86ba7 100644 --- a/e2e/relayer/relayer.go +++ b/e2e/relayer/relayer.go @@ -16,7 +16,7 @@ const ( Hermes = "hermes" Hyperspace = "hyperspace" - HermesRelayerRepository = "crodveg/carlos-channel-upgrades" + HermesRelayerRepository = "ghcr.io/informalsystems/hermes" hermesRelayerUser = "1000:1000" RlyRelayerRepository = "ghcr.io/cosmos/relayer" rlyRelayerUser = "100:1000" diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index 516499b3934..3da52060b06 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -62,7 +62,7 @@ const ( // TODO: https://github.com/cosmos/ibc-go/issues/4965 defaultHyperspaceTag = "20231122v39" // defaultHermesTag is the tag that will be used if no relayer tag is specified for hermes. - defaultHermesTag = "latest" + defaultHermesTag = "luca_joss-channel-upgrade-authority" // defaultChainTag is the tag that will be used for the chains if none is specified. defaultChainTag = "main" // defaultConfigFileName is the default filename for the config file that can be used to configure From 753d283b989a2d4f2d52372de71c0a23f8136720 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 29 Jan 2024 12:58:25 +0100 Subject: [PATCH 3/3] use assert packet relayed function --- e2e/tests/interchain_accounts/base_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index 92dc97de83a..eb82d9666a6 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -510,9 +510,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgr ) s.AssertTxSuccess(resp) - - // time for the packet to be relayed - s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB)) + s.AssertPacketRelayed(ctx, chainA, portID, initialChannelID, 1) }) t.Run("verify tokens transferred", func(t *testing.T) { @@ -591,9 +589,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgr ) s.AssertTxSuccess(resp) - - // time for the packet to be relayed - s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB)) + s.AssertPacketRelayed(ctx, chainA, portID, initialChannelID, 2) }) t.Run("verify tokens transferred", func(t *testing.T) {