From 5550dfa9a337acb4f499cb8120d0a0759d465bbc Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 5 Sep 2023 17:28:14 +0200 Subject: [PATCH 01/16] wip e2e test --- e2e/tests/core/02-client/client_test.go | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 9ddc57829e1..ca84849959e 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -24,6 +24,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/cosmos/ibc-go/e2e/dockerutil" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" @@ -150,6 +151,61 @@ func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() { }) } +// TestScheduleIBCUpgrade_Succeeds tests that a governance proposal to schedule an IBC software upgrade is successful. +func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { + t := s.T() + ctx := context.TODO() + + _, _ = s.SetupChainsRelayerAndChannel(ctx) + chainA, chainB := s.GetChains() + chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) + + s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB)) + + authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + s.Require().NoError(err) + s.Require().NotNil(authority) + + t.Run("send schedule IBC upgrade message", func(t *testing.T) { + authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + s.Require().NoError(err) + s.Require().NotNil(authority) + + clientState, err := s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + s.Require().NoError(err) + + originalTrustingPeriod := clientState.(*ibctm.ClientState).TrustingPeriod + newTrustingPeriod := originalTrustingPeriod + time.Duration(time.Hour*24) + + upgradedClientState := clientState.(*ibctm.ClientState) + upgradedClientState.TrustingPeriod = newTrustingPeriod + + latestHeight := clientState.GetLatestHeight().GetRevisionHeight() + + scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( + authority.String(), + types.Plan{ + Name: "upgrade-ibc", + Height: int64(latestHeight), + }, + upgradedClientState, + ) + s.Require().NoError(err) + s.ExecuteGovProposalV1(ctx, scheduleUpgradeMsg, chainA, chainAWallet, 1) + }) + + s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") + + t.Run("check that the upgrade has been scheduled", func(t *testing.T) { + + cs, err := s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + s.Require().NoError(err) + + fmt.Printf("CLIENTSTATE: %v", cs) + + }) +} + func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { t := s.T() ctx := context.TODO() From fd45b73378235c6e564b512b41be83b550d47875 Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 6 Sep 2023 09:34:17 +0200 Subject: [PATCH 02/16] query proposal --- e2e/tests/core/02-client/client_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 9b69821de65..204b8296a72 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + "cosmossdk.io/x/upgrade/types" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" @@ -187,7 +188,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( authority.String(), types.Plan{ - Name: "upgrade-ibc", + Name: "upgrade-client", Height: int64(latestHeight), }, upgradedClientState, @@ -198,14 +199,17 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") - t.Run("check that the upgrade has been scheduled", func(t *testing.T) { + // t.Run("check that the upgrade has been scheduled", func(t *testing.T) { - cs, err := s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) - s.Require().NoError(err) + // cs, err := s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + // s.Require().NoError(err) - fmt.Printf("CLIENTSTATE: %v", cs) + // fmt.Printf("CLIENTSTATE: %v", cs) - }) + // proposal, err := s.QueryProposalV1(ctx, chainA, 1) + // s.Require().NoError(err) + // s.Require().Equal(govtypesv1.StatusPassed, proposal.Status) + // }) } func (s *ClientTestSuite) TestClient_Update_Misbehaviour() { From 5d0419417c2705fb809cc32d70d95216e098f7b1 Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 6 Sep 2023 14:44:44 +0200 Subject: [PATCH 03/16] update upgrade height in plan --- e2e/tests/core/02-client/client_test.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 3a8028a3eb7..a80bda9efd8 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -169,6 +169,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) s.Require().NotNil(authority) + var ( + originalTrustingPeriod time.Duration + newTrustingPeriod time.Duration + ) + t.Run("send schedule IBC upgrade message", func(t *testing.T) { authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) @@ -177,8 +182,8 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { clientState, err := s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) s.Require().NoError(err) - originalTrustingPeriod := clientState.(*ibctm.ClientState).TrustingPeriod - newTrustingPeriod := originalTrustingPeriod + time.Duration(time.Hour*24) + originalTrustingPeriod = clientState.(*ibctm.ClientState).TrustingPeriod + newTrustingPeriod = originalTrustingPeriod + time.Duration(time.Hour*24) upgradedClientState := clientState.(*ibctm.ClientState) upgradedClientState.TrustingPeriod = newTrustingPeriod @@ -189,26 +194,13 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { authority.String(), types.Plan{ Name: "upgrade-client", - Height: int64(latestHeight), + Height: int64(latestHeight + 100), }, upgradedClientState, ) s.Require().NoError(err) s.ExecuteGovProposalV1(ctx, scheduleUpgradeMsg, chainA, chainAWallet, 1) }) - - // t.Run("check that the upgrade has been scheduled", func(t *testing.T) { - - // cs, err := s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) - // s.Require().NoError(err) - - // fmt.Printf("CLIENTSTATE: %v", cs) - - // proposal, err := s.QueryProposalV1(ctx, chainA, 1) - // s.Require().NoError(err) - // s.Require().Equal(govtypesv1.StatusPassed, proposal.Status) - // }) - } // TestRecoverClient_Succeeds tests that a governance proposal to recover a client using a MsgRecoverClient is successful. From ab2bd3dcf9f07fa7a8920a3076f7eb52eeb560e9 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Sep 2023 16:49:02 +0200 Subject: [PATCH 04/16] rm unnecessary wait/authority --- e2e/tests/core/02-client/client_test.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index a80bda9efd8..631728cc38b 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -163,12 +163,6 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { chainA, chainB := s.GetChains() chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB)) - - authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) - s.Require().NoError(err) - s.Require().NotNil(authority) - var ( originalTrustingPeriod time.Duration newTrustingPeriod time.Duration @@ -179,7 +173,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) s.Require().NotNil(authority) - clientState, err := s.QueryClientState(ctx, chainA, ibctesting.FirstClientID) + clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) originalTrustingPeriod = clientState.(*ibctm.ClientState).TrustingPeriod @@ -188,13 +182,14 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { upgradedClientState := clientState.(*ibctm.ClientState) upgradedClientState.TrustingPeriod = newTrustingPeriod - latestHeight := clientState.GetLatestHeight().GetRevisionHeight() + latestHeight, err := chainA.Height(ctx) + s.Require().NoError(err) scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( authority.String(), types.Plan{ Name: "upgrade-client", - Height: int64(latestHeight + 100), + Height: int64(latestHeight + 50), }, upgradedClientState, ) From c85f06d13a173c5b376dfbe90655c334d819e508 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Sep 2023 17:03:34 +0200 Subject: [PATCH 05/16] rm test artifact from merge --- e2e/tests/core/02-client/client_test.go | 82 ------------------------- 1 file changed, 82 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 631728cc38b..47371b9d22c 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -72,88 +72,6 @@ func (s *ClientTestSuite) QueryAllowedClients(ctx context.Context, chain ibc.Cha return res.Params.AllowedClients } -func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() { - t := s.T() - ctx := context.TODO() - - var ( - pathName string - relayer ibc.Relayer - subjectClientID string - substituteClientID string - // set the trusting period to a value which will still be valid upon client creation, but invalid before the first update - badTrustingPeriod = time.Second * 10 - ) - - t.Run("create substitute client with correct trusting period", func(t *testing.T) { - relayer, _ = s.SetupChainsRelayerAndChannel(ctx) - - // TODO: update when client identifier created is accessible - // currently assumes first client is 07-tendermint-0 - substituteClientID = clienttypes.FormatClientIdentifier(ibcexported.Tendermint, 0) - - // TODO: replace with better handling of path names - pathName = fmt.Sprintf("%s-path-%d", s.T().Name(), 0) - pathName = strings.ReplaceAll(pathName, "/", "-") - }) - - chainA, chainB := s.GetChains() - chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - - t.Run("create subject client with bad trusting period", func(t *testing.T) { - createClientOptions := ibc.CreateClientOptions{ - TrustingPeriod: badTrustingPeriod.String(), - } - - s.SetupClients(ctx, relayer, createClientOptions) - - // TODO: update when client identifier created is accessible - // currently assumes second client is 07-tendermint-1 - subjectClientID = clienttypes.FormatClientIdentifier(ibcexported.Tendermint, 1) - }) - - time.Sleep(badTrustingPeriod) - - t.Run("update substitute client", func(t *testing.T) { - s.UpdateClients(ctx, relayer, pathName) - }) - - s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") - - t.Run("check status of each client", func(t *testing.T) { - t.Run("substitute should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, substituteClientID) - s.Require().NoError(err) - s.Require().Equal(ibcexported.Active.String(), status) - }) - - t.Run("subject should be expired", func(t *testing.T) { - status, err := s.Status(ctx, chainA, subjectClientID) - s.Require().NoError(err) - s.Require().Equal(ibcexported.Expired.String(), status) - }) - }) - - t.Run("pass client update proposal", func(t *testing.T) { - proposal := clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subjectClientID, substituteClientID) - s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal) - }) - - t.Run("check status of each client", func(t *testing.T) { - t.Run("substitute should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, substituteClientID) - s.Require().NoError(err) - s.Require().Equal(ibcexported.Active.String(), status) - }) - - t.Run("subject should be active", func(t *testing.T) { - status, err := s.Status(ctx, chainA, subjectClientID) - s.Require().NoError(err) - s.Require().Equal(ibcexported.Active.String(), status) - }) - }) -} - // TestScheduleIBCUpgrade_Succeeds tests that a governance proposal to schedule an IBC software upgrade is successful. func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { t := s.T() From 371d0a471d4613615d2b09b46176aeda94bd99a7 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Sep 2023 17:55:34 +0200 Subject: [PATCH 06/16] add checks for scheduled plan --- e2e/tests/core/02-client/client_test.go | 18 ++++++++++- e2e/testsuite/grpc_query.go | 43 +++++++++++++++++++++---- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 47371b9d22c..52d492563fd 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -107,13 +107,29 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { authority.String(), types.Plan{ Name: "upgrade-client", - Height: int64(latestHeight + 50), + Height: int64(latestHeight + 30), }, upgradedClientState, ) s.Require().NoError(err) s.ExecuteGovProposalV1(ctx, scheduleUpgradeMsg, chainA, chainAWallet, 1) }) + + t.Run("check that IBC software upgrade has been scheduled successfully on chainA", func(t *testing.T) { + // checks there is an upgraded client state stored + cs, err := s.QueryUpgradedClientState(ctx, chainA, ibctesting.FirstClientID) + s.Require().NoError(err) + + upgradedClientState := cs.(*ibctm.ClientState) + upgradedClientState.TrustingPeriod = newTrustingPeriod + s.Require().Equal(newTrustingPeriod, upgradedClientState.TrustingPeriod) + + plan, err := s.QueryCurrentPlan(ctx, chainA) + s.Require().NoError(err) + + s.Assert().Equal("upgrade-client", plan.Name) + s.Assert().Equal(int64(500), plan.Height) + }) } // TestRecoverClient_Succeeds tests that a governance proposal to recover a client using a MsgRecoverClient is successful. diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index 03155feb408..a8e4b3a791f 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -12,6 +12,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -45,12 +47,13 @@ type GRPCClients struct { InterTxQueryClient intertxtypes.QueryClient // SDK query clients - GovQueryClient govtypesv1beta1.QueryClient - GovQueryClientV1 govtypesv1.QueryClient - GroupsQueryClient grouptypes.QueryClient - ParamsQueryClient paramsproposaltypes.QueryClient - AuthQueryClient authtypes.QueryClient - AuthZQueryClient authz.QueryClient + GovQueryClient govtypesv1beta1.QueryClient + GovQueryClientV1 govtypesv1.QueryClient + GroupsQueryClient grouptypes.QueryClient + ParamsQueryClient paramsproposaltypes.QueryClient + AuthQueryClient authtypes.QueryClient + AuthZQueryClient authz.QueryClient + UpgradeQueryClient upgradetypes.QueryClient ConsensusServiceClient cmtservice.ServiceClient } @@ -119,6 +122,23 @@ func (s *E2ETestSuite) QueryClientState(ctx context.Context, chain ibc.Chain, cl return clientState, nil } +// QueryUpgradedClientState queries the upgraded client state on the given chain for the provided clientID. +func (s *E2ETestSuite) QueryUpgradedClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) { + queryClient := s.GetChainGRCPClients(chain).ClientQueryClient + res, err := queryClient.UpgradedClientState(ctx, &clienttypes.QueryUpgradedClientStateRequest{}) + if err != nil { + return nil, err + } + + cfg := EncodingConfig() + var clientState ibcexported.ClientState + if err := cfg.InterfaceRegistry.UnpackAny(res.UpgradedClientState, &clientState); err != nil { + return nil, err + } + + return clientState, nil +} + // QueryClientStatus queries the status of the client by clientID func (s *E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { queryClient := s.GetChainGRCPClients(chain).ClientQueryClient @@ -132,6 +152,17 @@ func (s *E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, c return res.Status, nil } +// QueryCurrentPlan queries the currently scheduled plans, if any +func (s *E2ETestSuite) QueryCurrentPlan(ctx context.Context, chain ibc.Chain) (upgradetypes.Plan, error) { + queryClient := s.GetChainGRCPClients(chain).UpgradeQueryClient + res, err := queryClient.CurrentPlan(ctx, &upgradetypes.QueryCurrentPlanRequest{}) + if err != nil { + return upgradetypes.Plan{}, err + } + + return *res.Plan, nil +} + // QueryConnection queries the connection end using the given chain and connection id. func (s *E2ETestSuite) QueryConnection(ctx context.Context, chain ibc.Chain, connectionID string) (connectiontypes.ConnectionEnd, error) { queryClient := s.GetChainGRCPClients(chain).ConnectionQueryClient From c9872e96f707b8d9d2200cc425daf2f9a897b0bb Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Sep 2023 18:04:50 +0200 Subject: [PATCH 07/16] hook up upgrade query client --- e2e/testsuite/grpc_query.go | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index a8e4b3a791f..eb7f62db1a2 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -93,6 +93,7 @@ func (s *E2ETestSuite) InitGRPCClients(chain *cosmos.CosmosChain) { AuthQueryClient: authtypes.NewQueryClient(grpcConn), AuthZQueryClient: authz.NewQueryClient(grpcConn), ConsensusServiceClient: cmtservice.NewServiceClient(grpcConn), + UpgradeQueryClient: upgradetypes.NewQueryClient(grpcConn), } } From a71a3b54407c7c4fa5c389760784b8e6696cd2f7 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Sep 2023 18:07:20 +0200 Subject: [PATCH 08/16] plan height --- e2e/tests/core/02-client/client_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 52d492563fd..36c6253315d 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -100,14 +100,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { upgradedClientState := clientState.(*ibctm.ClientState) upgradedClientState.TrustingPeriod = newTrustingPeriod - latestHeight, err := chainA.Height(ctx) - s.Require().NoError(err) - scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( authority.String(), types.Plan{ Name: "upgrade-client", - Height: int64(latestHeight + 30), + Height: int64(75), }, upgradedClientState, ) @@ -128,7 +125,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) s.Assert().Equal("upgrade-client", plan.Name) - s.Assert().Equal(int64(500), plan.Height) + s.Assert().Equal(int64(75), plan.Height) }) } From ce48d0b01172035ffb508fd3e5d00d0119e43ec1 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Sep 2023 18:36:08 +0200 Subject: [PATCH 09/16] pr fixes --- e2e/tests/core/02-client/client_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 36c6253315d..2ebcb953239 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -84,6 +84,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { var ( originalTrustingPeriod time.Duration newTrustingPeriod time.Duration + planHeight int64 ) t.Run("send schedule IBC upgrade message", func(t *testing.T) { @@ -99,12 +100,13 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { upgradedClientState := clientState.(*ibctm.ClientState) upgradedClientState.TrustingPeriod = newTrustingPeriod + planHeight = int64(75) scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( authority.String(), types.Plan{ Name: "upgrade-client", - Height: int64(75), + Height: planHeight, }, upgradedClientState, ) @@ -118,14 +120,13 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) upgradedClientState := cs.(*ibctm.ClientState) - upgradedClientState.TrustingPeriod = newTrustingPeriod s.Require().Equal(newTrustingPeriod, upgradedClientState.TrustingPeriod) plan, err := s.QueryCurrentPlan(ctx, chainA) s.Require().NoError(err) s.Assert().Equal("upgrade-client", plan.Name) - s.Assert().Equal(int64(75), plan.Height) + s.Assert().Equal(planHeight, plan.Height) }) } From a39569142533f6e7a4e3209f1ba5a350e36e08a0 Mon Sep 17 00:00:00 2001 From: Charly Date: Fri, 8 Sep 2023 11:14:38 +0200 Subject: [PATCH 10/16] update test --- e2e/tests/core/02-client/client_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 2ebcb953239..eb049aa4cdc 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -82,9 +82,9 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) var ( - originalTrustingPeriod time.Duration - newTrustingPeriod time.Duration - planHeight int64 + originalChainId string + newChainId string + planHeight int64 ) t.Run("send schedule IBC upgrade message", func(t *testing.T) { @@ -95,11 +95,11 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) - originalTrustingPeriod = clientState.(*ibctm.ClientState).TrustingPeriod - newTrustingPeriod = originalTrustingPeriod + time.Duration(time.Hour*24) + originalChainId = clientState.(*ibctm.ClientState).ChainId + s.Assert().NotEqual(originalChainId, newChainId) upgradedClientState := clientState.(*ibctm.ClientState) - upgradedClientState.TrustingPeriod = newTrustingPeriod + upgradedClientState.ChainId = newChainId planHeight = int64(75) scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( @@ -120,7 +120,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) upgradedClientState := cs.(*ibctm.ClientState) - s.Require().Equal(newTrustingPeriod, upgradedClientState.TrustingPeriod) + s.Require().Equal(upgradedClientState.ChainId, newChainId) plan, err := s.QueryCurrentPlan(ctx, chainA) s.Require().NoError(err) From c52b67aeedd17adf0baa61db25c3066ab519f328 Mon Sep 17 00:00:00 2001 From: Charly Date: Fri, 8 Sep 2023 11:18:07 +0200 Subject: [PATCH 11/16] import space --- e2e/tests/core/02-client/client_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index eb049aa4cdc..4d5918c234d 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -10,6 +10,7 @@ import ( "time" "cosmossdk.io/x/upgrade/types" + "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" From 9a1fae9d0a72e9135d1d165cf75a9458c44a57a3 Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 11 Sep 2023 12:50:31 +0200 Subject: [PATCH 12/16] update newchainID value --- e2e/tests/core/02-client/client_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 4d5918c234d..0a1ed216f8d 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -97,6 +97,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) originalChainId = clientState.(*ibctm.ClientState).ChainId + newChainId = "new-chain-id" s.Assert().NotEqual(originalChainId, newChainId) upgradedClientState := clientState.(*ibctm.ClientState) From 16429756cacb69061e94562a8c0c02db6addea12 Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 11 Sep 2023 13:34:41 +0200 Subject: [PATCH 13/16] update clientID upgrade --- e2e/tests/core/02-client/client_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 0a1ed216f8d..899b7d4a8a3 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -82,27 +82,26 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { chainA, chainB := s.GetChains() chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - var ( - originalChainId string - newChainId string - planHeight int64 - ) + const planHeight = int64(75) + var newChainId string t.Run("send schedule IBC upgrade message", func(t *testing.T) { authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) - s.Require().NotNil(authority) + s.Assert().NotNil(authority) clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) - originalChainId = clientState.(*ibctm.ClientState).ChainId - newChainId = "new-chain-id" + originalChainId := clientState.(*ibctm.ClientState).ChainId + revisionNumber := clienttypes.ParseChainID(fmt.Sprintf("%s-%d", originalChainId, 1)) + // increment revision number even with new chain ID to prevent loss of misbehaviour detection support + newChainId, err = clienttypes.SetRevisionNumber(fmt.Sprintf("%s-%d", originalChainId, 1), revisionNumber+1) + s.Require().NoError(err) s.Assert().NotEqual(originalChainId, newChainId) upgradedClientState := clientState.(*ibctm.ClientState) upgradedClientState.ChainId = newChainId - planHeight = int64(75) scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( authority.String(), @@ -122,7 +121,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) upgradedClientState := cs.(*ibctm.ClientState) - s.Require().Equal(upgradedClientState.ChainId, newChainId) + s.Assert().Equal(upgradedClientState.ChainId, newChainId) plan, err := s.QueryCurrentPlan(ctx, chainA) s.Require().NoError(err) From ea7183a699f231990f4256c5237b970378761358 Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 11 Sep 2023 13:56:03 +0200 Subject: [PATCH 14/16] linter --- e2e/tests/core/02-client/client_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 899b7d4a8a3..b6d2ed8b71f 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -83,7 +83,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) const planHeight = int64(75) - var newChainId string + var newChainID string t.Run("send schedule IBC upgrade message", func(t *testing.T) { authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) @@ -93,15 +93,15 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID) s.Require().NoError(err) - originalChainId := clientState.(*ibctm.ClientState).ChainId - revisionNumber := clienttypes.ParseChainID(fmt.Sprintf("%s-%d", originalChainId, 1)) + originalChainID := clientState.(*ibctm.ClientState).ChainId + revisionNumber := clienttypes.ParseChainID(fmt.Sprintf("%s-%d", originalChainID, 1)) // increment revision number even with new chain ID to prevent loss of misbehaviour detection support - newChainId, err = clienttypes.SetRevisionNumber(fmt.Sprintf("%s-%d", originalChainId, 1), revisionNumber+1) + newChainID, err = clienttypes.SetRevisionNumber(fmt.Sprintf("%s-%d", originalChainID, 1), revisionNumber+1) s.Require().NoError(err) - s.Assert().NotEqual(originalChainId, newChainId) + s.Assert().NotEqual(originalChainID, newChainID) upgradedClientState := clientState.(*ibctm.ClientState) - upgradedClientState.ChainId = newChainId + upgradedClientState.ChainId = newChainID scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade( authority.String(), @@ -121,7 +121,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() { s.Require().NoError(err) upgradedClientState := cs.(*ibctm.ClientState) - s.Assert().Equal(upgradedClientState.ChainId, newChainId) + s.Assert().Equal(upgradedClientState.ChainId, newChainID) plan, err := s.QueryCurrentPlan(ctx, chainA) s.Require().NoError(err) From ab252600454ec72258de12a0509d61f5769680a5 Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 11 Sep 2023 14:41:50 +0200 Subject: [PATCH 15/16] gci --- e2e/tests/core/02-client/client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index b6d2ed8b71f..aa93b5df3ed 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -9,13 +9,13 @@ import ( "testing" "time" - "cosmossdk.io/x/upgrade/types" - "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" testifysuite "github.com/stretchr/testify/suite" + "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" From 871de62e87c125018c5c4177f62801968daa9e5d Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 11 Sep 2023 15:06:07 +0200 Subject: [PATCH 16/16] rm unnecessary event --- modules/core/02-client/keeper/events.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/modules/core/02-client/keeper/events.go b/modules/core/02-client/keeper/events.go index 608a121edae..4b8a875bddd 100644 --- a/modules/core/02-client/keeper/events.go +++ b/modules/core/02-client/keeper/events.go @@ -97,21 +97,6 @@ func emitRecoverClientEvent(ctx sdk.Context, clientID, clientType string) { }) } -// emitUpgradeClientProposalEvent emits an upgrade client proposal event -func emitUpgradeClientProposalEvent(ctx sdk.Context, title string, height int64) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUpgradeClientProposal, - sdk.NewAttribute(types.AttributeKeyUpgradePlanTitle, title), - sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, fmt.Sprintf("%d", height)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - // emitScheduleIBCSoftwareUpgradeEvent emits a schedule IBC software upgrade event func emitScheduleIBCSoftwareUpgradeEvent(ctx sdk.Context, title string, height int64, upgradeClientState exported.ClientState) { ctx.EventManager().EmitEvents(sdk.Events{