From e65921b3f6df9e4372e82bb5632e59c2a93ea36d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Tue, 23 Feb 2021 12:04:08 +0100
Subject: [PATCH 01/30] add zeroed custom fields check to tm client
---
.../07-tendermint/types/upgrade.go | 25 +++++-
.../07-tendermint/types/upgrade_test.go | 86 +++++++++++++++++++
2 files changed, 108 insertions(+), 3 deletions(-)
diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade.go b/x/ibc/light-clients/07-tendermint/types/upgrade.go
index 397e9cfd8374..d726a23d821b 100644
--- a/x/ibc/light-clients/07-tendermint/types/upgrade.go
+++ b/x/ibc/light-clients/07-tendermint/types/upgrade.go
@@ -2,6 +2,7 @@ package types
import (
"fmt"
+ "reflect"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -40,9 +41,8 @@ func (cs ClientState) VerifyUpgradeAndUpdateState(
upgradedClient.GetLatestHeight(), lastHeight)
}
- // counterparty chain must commit the upgraded client with all client-customizable fields zeroed out
- // at the upgrade path specified by current client
- // counterparty must also commit to the upgraded consensus state at a sub-path under the upgrade path specified
+ // upgraded client state and consensus state must be IBC tendermint client state and consensus state
+ // this may be modified in the future to upgrade to a new IBC tendermint type
tmUpgradeClient, ok := upgradedClient.(*ClientState)
if !ok {
return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "upgraded client must be Tendermint client. expected: %T got: %T",
@@ -54,6 +54,13 @@ func (cs ClientState) VerifyUpgradeAndUpdateState(
&ConsensusState{}, upgradedConsState)
}
+ // counterparty chain must commit the upgraded client with all client-customizable fields zeroed out
+ // at the upgrade path specified by current client
+ // counterparty must also commit to the upgraded consensus state at a sub-path under the upgrade path specified
+ if !ZeroedCustomFields(tmUpgradeClient) {
+ return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClient, "upgraded client has non-nil custom fields")
+ }
+
// unmarshal proofs
var merkleProofClient, merkleProofConsState commitmenttypes.MerkleProof
if err := cdc.UnmarshalBinaryBare(proofUpgradeClient, &merkleProofClient); err != nil {
@@ -154,3 +161,15 @@ func constructUpgradeConsStateMerklePath(upgradePath []string, lastHeight export
consPath = append(consPath, appendedKey)
return commitmenttypes.NewMerklePath(consPath...)
}
+
+// ZeroedCustomFields returns true if all the client state fields have
+// been zeroed out.
+func ZeroedCustomFields(clientStateA *ClientState) bool {
+ // construct a zeroed custom fields copy of the client state
+ clientStateB, ok := clientStateA.ZeroCustomFields().(*ClientState)
+ if !ok {
+ return false
+ }
+
+ return reflect.DeepEqual(clientStateA, clientStateB)
+}
diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
index 7be3a4943f33..29b948a0539a 100644
--- a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
+++ b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
@@ -113,6 +113,36 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
},
expPass: false,
},
+ {
+ name: "unsuccessful upgrade: committed client does not have zeroed custom fields",
+ setup: func() {
+
+ upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
+ upgradedConsState = &types.ConsensusState{
+ NextValidatorsHash: []byte("nextValsHash"),
+ }
+
+ // upgrade Height is at next block
+ lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
+
+ // zero custom fields and store in upgrade store
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+
+ // commit upgrade store changes and update clients
+
+ suite.coordinator.CommitBlock(suite.chainB)
+ err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
+ suite.Require().NoError(err)
+
+ cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
+ suite.Require().True(found)
+
+ proofUpgradedClient, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
+ proofUpgradedConsState, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
+ },
+ expPass: false,
+ },
{
name: "unsuccessful upgrade: chain-specified parameters do not match committed client",
setup: func() {
@@ -510,3 +540,59 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
}
}
}
+
+func (suite *TendermintTestSuite) TestZeroedCustomFields() {
+ var (
+ clientState *types.ClientState
+ )
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "client state is zeroed", func() {
+ }, true,
+ },
+ {
+ "client state has true Allow... booleans", func() {
+ clientState.ZeroCustomFields()
+ clientState.AllowUpdateAfterExpiry = true
+ clientState.AllowUpdateAfterMisbehaviour = true
+ }, false,
+ },
+ {
+ "client state has non-zero trusting period ", func() {
+ clientState.TrustingPeriod = 100
+ }, false,
+ },
+ {
+ "client state has non-zero max clock drift", func() {
+ clientState.MaxClockDrift = 100
+ }, false,
+ },
+ {
+ "client state has non-zero trust level", func() {
+ clientState.TrustLevel = types.DefaultTrustLevel
+ }, false,
+ },
+ }
+
+ for _, tc := range testCases {
+ tc := tc
+
+ suite.Run(tc.name, func() {
+ suite.SetupTest() // reset
+
+ client, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
+ clientState = suite.chainA.GetClientState(client).(*types.ClientState)
+ clientState = clientState.ZeroCustomFields().(*types.ClientState)
+
+ tc.malleate()
+
+ suite.Require().Equal(tc.expPass, types.ZeroedCustomFields(clientState))
+
+ })
+ }
+}
From 64b59fde198df1aad20f7837e241b3e9cff879e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Tue, 23 Feb 2021 12:32:50 +0100
Subject: [PATCH 02/30] remove custom fields function from x/upgrade and fix
tests
---
...4424a328627f9d10020d53a82765d6642a.address | 1 +
client/keys/home/keyring-test/keyname1.info | 1 +
x/ibc/core/02-client/keeper/client_test.go | 29 +-----
.../07-tendermint/types/upgrade_test.go | 99 ++-----------------
x/upgrade/keeper/keeper.go | 2 -
5 files changed, 16 insertions(+), 116 deletions(-)
create mode 100644 client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address
create mode 100644 client/keys/home/keyring-test/keyname1.info
diff --git a/client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address b/client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address
new file mode 100644
index 000000000000..ed20229c9734
--- /dev/null
+++ b/client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address
@@ -0,0 +1 @@
+eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMS0wMi0yMyAxMjoxMzo0NS4yNzk4NDI3MzYgKzAxMDAgQ0VUIG09KzEuMjU1NjQ5MzQ4IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiMmJ6dzRycnR3UTExUjlYeCJ9.lL598D1-f0Wu0TeDzzDrPI5eCw9YuzZzttJxvSSzV7BKO0_xHb3AfA.EVYF3gI9e9kF7uhD.uFr_NPauozej7jXACkFiUbsNMaYIZRl5oLWlnMQku5WNtkJfHhwUwvAMmcKns-ektwNg0LheOK8dz0ll2KREGfaHAG8ueBqUbzBhQnkBNFaNaF8zdDLPrOd1ZjZudt0W5GySopljcgywhEKJoBJPFm50QJRhH3hqaZq-7lBplJlGd1VR5Eft2vaCDJSflEYNP1mfKjJ-YvOEQpeKNPoOi8tlw6l7KHdUpWzwDmqkj8omCXvAHPvuMqIW.4qDFmmMKbWJqxy5OU-tikg
\ No newline at end of file
diff --git a/client/keys/home/keyring-test/keyname1.info b/client/keys/home/keyring-test/keyname1.info
new file mode 100644
index 000000000000..59fd4d26145d
--- /dev/null
+++ b/client/keys/home/keyring-test/keyname1.info
@@ -0,0 +1 @@
+eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMS0wMi0yMyAxMjoxMzo0NS4yNzM1Njk5NDcgKzAxMDAgQ0VUIG09KzEuMjQ5Mzc2NjMwIiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiS3cwSS1mYjRpTDBYbGRjTSJ9.tbq41Cr-G91jSm_W7CckAfIZUawiMCWUvv21NPQ7_xGLDu6N_Eupsg.IBR0-H44WKmZrUTD.eDx6gE9bHhWOty7FtsqR4nDx2072a-YxffTZ8nry8fTAjHawqX3X6P7B_L40cb0uJgOsiTqbGUIfAraHNolbOm9fRzwiBizdqCAofE5qun-mAxoTC1RiTdhjPWsDjKScXAvtQrpQtDx4jSGuimW7AF7jF0NkP8Xt4ETf3z9fAxTQsHK_TH_Y_UImLjtthRFY5PHTiPonmaKMLDyT9GP5CSCxP8NihAz1eYMHkKVOd1Yb96elXNEZViBLRbU2AlXvnKI1gjyKBEl_PxttY89svn2FUGXQlYIshqJ38l7oiazLjBkD8zMz8VJYLghKpICYObkP6PnPgGaXFWQv2f6NGFKWPOHQz6-EJPXRiPgSiQ.OgcE7RmQ9VQMtHU32SuyBw
\ No newline at end of file
diff --git a/x/ibc/core/02-client/keeper/client_test.go b/x/ibc/core/02-client/keeper/client_test.go
index 0cf5c1fe1d57..0c44142c4414 100644
--- a/x/ibc/core/02-client/keeper/client_test.go
+++ b/x/ibc/core/02-client/keeper/client_test.go
@@ -240,12 +240,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
{
name: "successful upgrade",
setup: func() {
-
- upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
- upgradedConsState = &ibctmtypes.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// last Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -270,12 +264,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
{
name: "client state not found",
setup: func() {
-
- upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
- upgradedConsState = &ibctmtypes.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// last Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -302,12 +290,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
{
name: "client state frozen",
setup: func() {
-
- upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
- upgradedConsState = &ibctmtypes.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// last Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -338,12 +320,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
{
name: "tendermint client VerifyUpgrade fails",
setup: func() {
-
- upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
- upgradedConsState = &ibctmtypes.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// last Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -371,6 +347,11 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
for _, tc := range testCases {
tc := tc
clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
+ upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
+ upgradedClient = upgradedClient.ZeroCustomFields()
+ upgradedConsState = &ibctmtypes.ConsensusState{
+ NextValidatorsHash: []byte("nextValsHash"),
+ }
tc.setup()
diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
index 29b948a0539a..c66f9f1c6659 100644
--- a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
+++ b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
@@ -25,12 +25,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "successful upgrade",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -57,9 +51,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
setup: func() {
upgradedHeight := clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+2))
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradedHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
+ upgradedClient = upgradedClient.ZeroCustomFields()
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -86,12 +78,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: upgrade height revision height is more than the current client revision height",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is 10 blocks from now
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+10))
@@ -116,11 +102,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: committed client does not have zeroed custom fields",
setup: func() {
-
+ // non-zeroed upgrade client
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -146,12 +129,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: chain-specified parameters do not match committed client",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -177,12 +154,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: client-specified parameters do not match previous client",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, lastHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// zero custom fields and store in upgrade store
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
@@ -205,12 +176,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: relayer-submitted consensus state does not match counterparty-committed consensus state",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -240,10 +205,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: client proof unmarshal failed",
setup: func() {
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
@@ -258,11 +219,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: consensus state proof unmarshal failed",
setup: func() {
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
@@ -277,11 +233,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: client proof verification failed",
setup: func() {
- // create but do not store upgraded client
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
+ // do not store upgraded client
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -299,11 +251,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: consensus state proof verification failed",
setup: func() {
- // create but do not store upgraded client
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
+ // do not store upgraded client
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -321,12 +269,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: upgrade path is empty",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -355,12 +297,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: upgraded height is not greater than current height",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -384,12 +320,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: consensus state for upgrade height cannot be found",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+100))
@@ -413,12 +343,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: client is expired",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, lastHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// zero custom fields and store in upgrade store
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
@@ -442,12 +366,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: updated unbonding period is equal to trusting period",
setup: func() {
-
- upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
-
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -471,12 +389,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: final client is not valid",
setup: func() {
-
// new client has smaller unbonding period such that old trusting period is no longer valid
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
- upgradedConsState = &types.ConsensusState{
- NextValidatorsHash: []byte("nextValsHash"),
- }
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
@@ -508,6 +422,11 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
suite.SetupTest()
clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
+ upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
+ upgradedClient = upgradedClient.ZeroCustomFields()
+ upgradedConsState = &types.ConsensusState{
+ NextValidatorsHash: []byte("nextValsHash"),
+ }
tc.setup()
diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go
index 1092885bcb3f..0745cb85197a 100644
--- a/x/upgrade/keeper/keeper.go
+++ b/x/upgrade/keeper/keeper.go
@@ -100,8 +100,6 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error {
func (k Keeper) SetUpgradedClient(ctx sdk.Context, planHeight int64, cs ibcexported.ClientState) error {
store := ctx.KVStore(k.storeKey)
- // zero out any custom fields before setting
- cs = cs.ZeroCustomFields()
bz, err := clienttypes.MarshalClientState(k.cdc, cs)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not marshal clientstate: %v", err)
From 12343831e2783aadd49c40a940d8046440893252 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Tue, 23 Feb 2021 13:08:29 +0100
Subject: [PATCH 03/30] use []byte in x/upgrade, move abci to 02-client
---
docs/core/proto-docs.md | 4 +-
proto/cosmos/upgrade/v1beta1/query.proto | 2 +-
proto/cosmos/upgrade/v1beta1/upgrade.proto | 2 +-
simapp/app.go | 2 +-
x/ibc/core/02-client/abci.go | 22 +++-
x/ibc/core/02-client/keeper/keeper.go | 14 ++-
.../core/02-client/types/expected_keepers.go | 7 ++
x/ibc/core/keeper/keeper.go | 5 +-
x/upgrade/abci.go | 16 ---
x/upgrade/keeper/grpc_query.go | 8 +-
x/upgrade/keeper/keeper.go | 40 ++-----
x/upgrade/types/plan.go | 25 +----
x/upgrade/types/plan_test.go | 16 +--
x/upgrade/types/proposal.go | 7 --
x/upgrade/types/proposal_test.go | 9 +-
x/upgrade/types/query.pb.go | 100 ++++++++---------
x/upgrade/types/upgrade.pb.go | 104 +++++++++---------
17 files changed, 165 insertions(+), 218 deletions(-)
diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md
index 6cd751f026bb..6ed2829be600 100644
--- a/docs/core/proto-docs.md
+++ b/docs/core/proto-docs.md
@@ -7507,7 +7507,7 @@ Plan specifies information about a planned upgrade and when it should occur.
| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | The time after which the upgrade must be performed. Leave set to its zero value to use a pre-defined Height instead. |
| `height` | [int64](#int64) | | The height at which the upgrade must be performed. Only used if Time is not set. |
| `info` | [string](#string) | | Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to |
-| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades |
+| `upgraded_client_state` | [bytes](#bytes) | | IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades |
@@ -7632,7 +7632,7 @@ RPC method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| `upgraded_consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | |
+| `upgraded_consensus_state` | [bytes](#bytes) | | |
diff --git a/proto/cosmos/upgrade/v1beta1/query.proto b/proto/cosmos/upgrade/v1beta1/query.proto
index 9eab27e76b44..50c7410d6f7a 100644
--- a/proto/cosmos/upgrade/v1beta1/query.proto
+++ b/proto/cosmos/upgrade/v1beta1/query.proto
@@ -64,5 +64,5 @@ message QueryUpgradedConsensusStateRequest {
// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState
// RPC method.
message QueryUpgradedConsensusStateResponse {
- google.protobuf.Any upgraded_consensus_state = 1;
+ bytes upgraded_consensus_state = 1;
}
diff --git a/proto/cosmos/upgrade/v1beta1/upgrade.proto b/proto/cosmos/upgrade/v1beta1/upgrade.proto
index 6d6839ca56c5..07232064b015 100644
--- a/proto/cosmos/upgrade/v1beta1/upgrade.proto
+++ b/proto/cosmos/upgrade/v1beta1/upgrade.proto
@@ -39,7 +39,7 @@ message Plan {
// so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
// previous version of the chain.
// This will allow IBC connections to persist smoothly across planned chain upgrades
- google.protobuf.Any upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];
+ bytes upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];
}
// SoftwareUpgradeProposal is a gov Content type for initiating a software
diff --git a/simapp/app.go b/simapp/app.go
index 388c8c50eb8a..02a98ac4a33f 100644
--- a/simapp/app.go
+++ b/simapp/app.go
@@ -299,7 +299,7 @@ func NewSimApp(
// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
- appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, scopedIBCKeeper,
+ appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
)
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authztypes.StoreKey], appCodec, app.BaseApp.MsgServiceRouter())
diff --git a/x/ibc/core/02-client/abci.go b/x/ibc/core/02-client/abci.go
index 3c56d90ad37a..106e04933b95 100644
--- a/x/ibc/core/02-client/abci.go
+++ b/x/ibc/core/02-client/abci.go
@@ -4,11 +4,31 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
+ ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
)
// BeginBlocker updates an existing localhost client with the latest block height.
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
- _, found := k.GetClientState(ctx, exported.Localhost)
+ plan, found := k.GetUpgradePlan(ctx)
+ if found {
+ // Once we are at the last block this chain will commit, set the upgraded consensus state
+ // so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
+ // headers on the next version of the chain.
+ // Set the time to the last block time of the current chain.
+ // In order for a client to upgrade successfully, the first block of the new chain must be committed
+ // within the trusting period of the last block time on this chain.
+ if plan.IsIBCPlan() && ctx.BlockHeight() == plan.Height-1 {
+ upgradedConsState := &ibctmtypes.ConsensusState{
+ Timestamp: ctx.BlockTime(),
+ NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
+ }
+ bz := k.MustMarshalConsensusState(upgradedConsState)
+
+ k.SetUpgradedConsensusState(ctx, plan.Height, bz)
+ }
+ }
+
+ _, found = k.GetClientState(ctx, exported.Localhost)
if !found {
return
}
diff --git a/x/ibc/core/02-client/keeper/keeper.go b/x/ibc/core/02-client/keeper/keeper.go
index 67c5c0658d40..9ed509fde3be 100644
--- a/x/ibc/core/02-client/keeper/keeper.go
+++ b/x/ibc/core/02-client/keeper/keeper.go
@@ -28,10 +28,11 @@ type Keeper struct {
cdc codec.BinaryMarshaler
paramSpace paramtypes.Subspace
stakingKeeper types.StakingKeeper
+ upgradeKeeper types.UpgradeKeeper
}
// NewKeeper creates a new NewKeeper instance
-func NewKeeper(cdc codec.BinaryMarshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace, sk types.StakingKeeper) Keeper {
+func NewKeeper(cdc codec.BinaryMarshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper {
// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
@@ -42,6 +43,7 @@ func NewKeeper(cdc codec.BinaryMarshaler, key sdk.StoreKey, paramSpace paramtype
cdc: cdc,
paramSpace: paramSpace,
stakingKeeper: sk,
+ upgradeKeeper: uk,
}
}
@@ -327,6 +329,16 @@ func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientS
return nil
}
+// GetUpgradePlan executes the upgrade keeper GetUpgradePlan function.
+func (k Keeper) GetUpgradePlan(ctx sdk.Context) (plan upgradetypes.Plan, havePlan bool) {
+ return k.upgradeKeeper.GetUpgradePlan(ctx)
+}
+
+// GetUpgradedConsensusState executes the upgrade keeper SetUpgradedConsensusState function.
+func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error {
+ return k.upgradeKeeper.SetUpgradedConsensusState(ctx, planHeight, bz)
+}
+
// IterateClients provides an iterator over all stored light client State
// objects. For each State object, cb will be called. If the cb returns true,
// the iterator will close and stop.
diff --git a/x/ibc/core/02-client/types/expected_keepers.go b/x/ibc/core/02-client/types/expected_keepers.go
index defc81506b1d..f960e6251ba7 100644
--- a/x/ibc/core/02-client/types/expected_keepers.go
+++ b/x/ibc/core/02-client/types/expected_keepers.go
@@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
+ upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
// StakingKeeper expected staking keeper
@@ -12,3 +13,9 @@ type StakingKeeper interface {
GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)
UnbondingTime(ctx sdk.Context) time.Duration
}
+
+// UpgradeKeeper expected upgrade keeper
+type UpgradeKeeper interface {
+ GetUpgradePlan(ctx sdk.Context) (plan upgradetypes.Plan, havePlan bool)
+ SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error
+}
diff --git a/x/ibc/core/keeper/keeper.go b/x/ibc/core/keeper/keeper.go
index 5f9abc382ecb..dab06caec27d 100644
--- a/x/ibc/core/keeper/keeper.go
+++ b/x/ibc/core/keeper/keeper.go
@@ -33,9 +33,10 @@ type Keeper struct {
// NewKeeper creates a new ibc Keeper
func NewKeeper(
cdc codec.BinaryMarshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace,
- stakingKeeper clienttypes.StakingKeeper, scopedKeeper capabilitykeeper.ScopedKeeper,
+ stakingKeeper clienttypes.StakingKeeper, upgradeKeeper clienttypes.UpgradeKeeper,
+ scopedKeeper capabilitykeeper.ScopedKeeper,
) *Keeper {
- clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper)
+ clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper, upgradeKeeper)
connectionKeeper := connectionkeeper.NewKeeper(cdc, key, clientKeeper)
portKeeper := portkeeper.NewKeeper(scopedKeeper)
channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper)
diff --git a/x/upgrade/abci.go b/x/upgrade/abci.go
index fa95c4c4aa63..d346decb023c 100644
--- a/x/upgrade/abci.go
+++ b/x/upgrade/abci.go
@@ -10,8 +10,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
-
- ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
)
// BeginBlock will check if there is a scheduled plan and if it is ready to be executed.
@@ -24,25 +22,11 @@ import (
// skipUpgradeHeightArray is a set of block heights for which the upgrade must be skipped
func BeginBlocker(k keeper.Keeper, ctx sdk.Context, _ abci.RequestBeginBlock) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
-
plan, found := k.GetUpgradePlan(ctx)
if !found {
return
}
- // Once we are at the last block this chain will commit, set the upgraded consensus state
- // so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
- // headers on the next version of the chain.
- // Set the time to the last block time of the current chain.
- // In order for a client to upgrade successfully, the first block of the new chain must be committed
- // within the trusting period of the last block time on this chain.
- if plan.IsIBCPlan() && ctx.BlockHeight() == plan.Height-1 {
- upgradedConsState := &ibctmtypes.ConsensusState{
- Timestamp: ctx.BlockTime(),
- NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
- }
- k.SetUpgradedConsensusState(ctx, plan.Height, upgradedConsState)
- }
// To make sure clear upgrade is executed at the same block
if plan.ShouldExecute(ctx) {
// If skip upgrade has been set for current height, we clear the upgrade plan
diff --git a/x/upgrade/keeper/grpc_query.go b/x/upgrade/keeper/grpc_query.go
index 26e7860c8627..262c32af1f20 100644
--- a/x/upgrade/keeper/grpc_query.go
+++ b/x/upgrade/keeper/grpc_query.go
@@ -4,7 +4,6 @@ import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
@@ -43,12 +42,7 @@ func (k Keeper) UpgradedConsensusState(c context.Context, req *types.QueryUpgrad
return nil, err
}
- cs, err := clienttypes.PackConsensusState(consState)
- if err != nil {
- return nil, err
- }
-
return &types.QueryUpgradedConsensusStateResponse{
- UpgradedConsensusState: cs,
+ UpgradedConsensusState: consState,
}, nil
}
diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go
index 0745cb85197a..f7e5c85a013a 100644
--- a/x/upgrade/keeper/keeper.go
+++ b/x/upgrade/keeper/keeper.go
@@ -16,8 +16,6 @@ import (
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
- ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
@@ -85,32 +83,22 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error {
if plan.IsIBCPlan() {
// Set UpgradedClientState in store
- clientState, err := clienttypes.UnpackClientState(plan.UpgradedClientState)
- if err != nil {
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not unpack clientstate: %v", err)
- }
// sets the new upgraded client in last height committed on this chain is at plan.Height,
// since the chain will panic at plan.Height and new chain will resume at plan.Height
- return k.SetUpgradedClient(ctx, plan.Height, clientState)
+ return k.SetUpgradedClient(ctx, plan.Height, plan.UpgradedClientState)
}
return nil
}
// SetUpgradedClient sets the expected upgraded client for the next version of this chain at the last height the current chain will commit.
-func (k Keeper) SetUpgradedClient(ctx sdk.Context, planHeight int64, cs ibcexported.ClientState) error {
+func (k Keeper) SetUpgradedClient(ctx sdk.Context, planHeight int64, bz []byte) error {
store := ctx.KVStore(k.storeKey)
-
- bz, err := clienttypes.MarshalClientState(k.cdc, cs)
- if err != nil {
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not marshal clientstate: %v", err)
- }
-
store.Set(types.UpgradedClientKey(planHeight), bz)
return nil
}
// GetUpgradedClient gets the expected upgraded client for the next version of this chain
-func (k Keeper) GetUpgradedClient(ctx sdk.Context, height int64) (ibcexported.ClientState, error) {
+func (k Keeper) GetUpgradedClient(ctx sdk.Context, height int64) ([]byte, error) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.UpgradedClientKey(height))
@@ -118,39 +106,27 @@ func (k Keeper) GetUpgradedClient(ctx sdk.Context, height int64) (ibcexported.Cl
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "upgraded client not found in store for height %d", height)
}
- clientState, err := clienttypes.UnmarshalClientState(k.cdc, bz)
- if err != nil {
- return nil, err
- }
- return clientState, nil
+ return bz, nil
}
// SetUpgradedConsensusState set the expected upgraded consensus state for the next version of this chain
// using the last height committed on this chain.
-func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, cs ibcexported.ConsensusState) error {
+func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error {
store := ctx.KVStore(k.storeKey)
- bz, err := clienttypes.MarshalConsensusState(k.cdc, cs)
- if err != nil {
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not marshal consensus state: %v", err)
- }
-
store.Set(types.UpgradedConsStateKey(planHeight), bz)
return nil
}
// GetUpgradedConsensusState set the expected upgraded consensus state for the next version of this chain
-func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, lastHeight int64) (ibcexported.ConsensusState, error) {
+func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, lastHeight int64) ([]byte, error) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.UpgradedConsStateKey(lastHeight))
if len(bz) == 0 {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "upgraded consensus state not found in store for height: %d", lastHeight)
}
- consState, err := clienttypes.UnmarshalConsensusState(k.cdc, bz)
- if err != nil {
- return nil, err
- }
- return consState, nil
+
+ return bz, nil
}
// GetDoneHeight returns the height at which the given upgrade was executed
diff --git a/x/upgrade/types/plan.go b/x/upgrade/types/plan.go
index aa1a0601ffca..e5a979299a01 100644
--- a/x/upgrade/types/plan.go
+++ b/x/upgrade/types/plan.go
@@ -5,24 +5,18 @@ import (
"strings"
"time"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
- ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
)
-var _ codectypes.UnpackInterfacesMessage = Plan{}
-
func (p Plan) String() string {
due := p.DueAt()
dueUp := strings.ToUpper(due[0:1]) + due[1:]
var upgradedClientStr string
- upgradedClient, err := clienttypes.UnpackClientState(p.UpgradedClientState)
- if err != nil {
+ if len(p.UpgradedClientState) == 0 {
upgradedClientStr = "no upgraded client provided"
} else {
- upgradedClientStr = upgradedClient.String()
+ upgradedClientStr = string(p.UpgradedClientState)
}
return fmt.Sprintf(`Upgrade Plan
Name: %s
@@ -45,7 +39,7 @@ func (p Plan) ValidateBasic() error {
if p.Time.Unix() > 0 && p.Height != 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "cannot set both time and height")
}
- if p.Time.Unix() > 0 && p.UpgradedClientState != nil {
+ if p.Time.Unix() > 0 && len(p.UpgradedClientState) != 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "IBC chain upgrades must only set height")
}
@@ -73,16 +67,5 @@ func (p Plan) DueAt() string {
// IsIBCPlan will return true if plan includes IBC client information
func (p Plan) IsIBCPlan() bool {
- return p.UpgradedClientState != nil
-}
-
-// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
-func (p Plan) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
- // UpgradedClientState may be nil
- if p.UpgradedClientState == nil {
- return nil
- }
-
- var clientState ibcexported.ClientState
- return unpacker.UnpackAny(p.UpgradedClientState, &clientState)
+ return len(p.UpgradedClientState) != 0
}
diff --git a/x/upgrade/types/plan_test.go b/x/upgrade/types/plan_test.go
index 436cb83a94e3..1438a390894a 100644
--- a/x/upgrade/types/plan_test.go
+++ b/x/upgrade/types/plan_test.go
@@ -10,8 +10,6 @@ import (
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
- ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -26,8 +24,7 @@ func mustParseTime(s string) time.Time {
}
func TestPlanString(t *testing.T) {
- cs, err := clienttypes.PackClientState(&ibctmtypes.ClientState{})
- require.NoError(t, err)
+ clientStateBz := []byte("IBC client state")
cases := map[string]struct {
p types.Plan
@@ -54,9 +51,9 @@ func TestPlanString(t *testing.T) {
Name: "by height",
Info: "https://foo.bar/baz",
Height: 7890,
- UpgradedClientState: cs,
+ UpgradedClientState: clientStateBz,
},
- expect: fmt.Sprintf("Upgrade Plan\n Name: by height\n Height: 7890\n Info: https://foo.bar/baz.\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{}),
+ expect: fmt.Sprintf("Upgrade Plan\n Name: by height\n Height: 7890\n Info: https://foo.bar/baz.\n Upgraded IBC Client: %s", clientStateBz),
},
"neither": {
@@ -77,8 +74,7 @@ func TestPlanString(t *testing.T) {
}
func TestPlanValid(t *testing.T) {
- cs, err := clienttypes.PackClientState(&ibctmtypes.ClientState{})
- require.NoError(t, err)
+ clientStateBz := []byte("IBC client state")
cases := map[string]struct {
p types.Plan
@@ -97,7 +93,7 @@ func TestPlanValid(t *testing.T) {
Name: "ibc-all-good",
Info: "some text here",
Height: 123450000,
- UpgradedClientState: cs,
+ UpgradedClientState: clientStateBz,
},
valid: true,
},
@@ -130,7 +126,7 @@ func TestPlanValid(t *testing.T) {
Name: "ibc-all-good",
Info: "some text here",
Time: mustParseTime("2019-07-08T11:33:55Z"),
- UpgradedClientState: cs,
+ UpgradedClientState: clientStateBz,
},
valid: false,
},
diff --git a/x/upgrade/types/proposal.go b/x/upgrade/types/proposal.go
index a8ea9b629062..38b2295556de 100644
--- a/x/upgrade/types/proposal.go
+++ b/x/upgrade/types/proposal.go
@@ -3,7 +3,6 @@ package types
import (
"fmt"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
)
@@ -18,7 +17,6 @@ func NewSoftwareUpgradeProposal(title, description string, plan Plan) gov.Conten
// Implements Proposal Interface
var _ gov.Content = &SoftwareUpgradeProposal{}
-var _ codectypes.UnpackInterfacesMessage = SoftwareUpgradeProposal{}
func init() {
gov.RegisterProposalType(ProposalTypeSoftwareUpgrade)
@@ -45,11 +43,6 @@ func (sup SoftwareUpgradeProposal) String() string {
`, sup.Title, sup.Description)
}
-// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
-func (sup SoftwareUpgradeProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
- return sup.Plan.UnpackInterfaces(unpacker)
-}
-
func NewCancelSoftwareUpgradeProposal(title, description string) gov.Content {
return &CancelSoftwareUpgradeProposal{title, description}
}
diff --git a/x/upgrade/types/proposal_test.go b/x/upgrade/types/proposal_test.go
index d39b89135c3d..110625bf3bbf 100644
--- a/x/upgrade/types/proposal_test.go
+++ b/x/upgrade/types/proposal_test.go
@@ -82,14 +82,13 @@ func TestContentAccessors(t *testing.T) {
// tests a software update proposal can be marshaled and unmarshaled, and the
// client state can be unpacked
func TestMarshalSoftwareUpdateProposal(t *testing.T) {
- cs, err := clienttypes.PackClientState(&ibctmtypes.ClientState{})
- require.NoError(t, err)
+ clientStateBz := []byte("IBC client state")
// create proposal
plan := types.Plan{
Name: "upgrade ibc",
Height: 1000,
- UpgradedClientState: cs,
+ UpgradedClientState: clientStateBz,
}
content := types.NewSoftwareUpgradeProposal("title", "description", plan)
sup, ok := content.(*types.SoftwareUpgradeProposal)
@@ -111,8 +110,4 @@ func TestMarshalSoftwareUpdateProposal(t *testing.T) {
newSup := &types.SoftwareUpgradeProposal{}
err = cdc.UnmarshalJSON(bz, newSup)
require.NoError(t, err)
-
- // unpack client state
- _, err = clienttypes.UnpackClientState(newSup.Plan.UpgradedClientState)
- require.NoError(t, err)
}
diff --git a/x/upgrade/types/query.pb.go b/x/upgrade/types/query.pb.go
index 40caf74e8f6d..43d531dbd3bd 100644
--- a/x/upgrade/types/query.pb.go
+++ b/x/upgrade/types/query.pb.go
@@ -6,7 +6,7 @@ package types
import (
context "context"
fmt "fmt"
- types "github.com/cosmos/cosmos-sdk/codec/types"
+ _ "github.com/cosmos/cosmos-sdk/codec/types"
grpc1 "github.com/gogo/protobuf/grpc"
proto "github.com/gogo/protobuf/proto"
_ "google.golang.org/genproto/googleapis/api/annotations"
@@ -259,7 +259,7 @@ func (m *QueryUpgradedConsensusStateRequest) GetLastHeight() int64 {
// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState
// RPC method.
type QueryUpgradedConsensusStateResponse struct {
- UpgradedConsensusState *types.Any `protobuf:"bytes,1,opt,name=upgraded_consensus_state,json=upgradedConsensusState,proto3" json:"upgraded_consensus_state,omitempty"`
+ UpgradedConsensusState []byte `protobuf:"bytes,1,opt,name=upgraded_consensus_state,json=upgradedConsensusState,proto3" json:"upgraded_consensus_state,omitempty"`
}
func (m *QueryUpgradedConsensusStateResponse) Reset() { *m = QueryUpgradedConsensusStateResponse{} }
@@ -295,7 +295,7 @@ func (m *QueryUpgradedConsensusStateResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryUpgradedConsensusStateResponse proto.InternalMessageInfo
-func (m *QueryUpgradedConsensusStateResponse) GetUpgradedConsensusState() *types.Any {
+func (m *QueryUpgradedConsensusStateResponse) GetUpgradedConsensusState() []byte {
if m != nil {
return m.UpgradedConsensusState
}
@@ -316,38 +316,37 @@ func init() {
}
var fileDescriptor_4a334d07ad8374f0 = []byte{
- // 487 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x41, 0x8b, 0x13, 0x31,
- 0x18, 0x6d, 0xb4, 0x2e, 0x98, 0xde, 0x82, 0xd4, 0x6e, 0x59, 0x46, 0x89, 0x8b, 0x08, 0x6e, 0x93,
- 0xdd, 0xee, 0x4d, 0x41, 0x5c, 0x17, 0x17, 0x0f, 0x22, 0x5a, 0xf1, 0xe2, 0xa5, 0xa4, 0x9d, 0x38,
- 0x1d, 0x9c, 0x26, 0xd9, 0x49, 0x22, 0x96, 0x65, 0x2f, 0xfe, 0x02, 0xc1, 0xbb, 0x37, 0x6f, 0xfe,
- 0x10, 0x8f, 0x0b, 0x5e, 0xf4, 0x26, 0xad, 0x3f, 0x44, 0x26, 0xc9, 0x48, 0x97, 0x76, 0x66, 0xc5,
- 0x53, 0x3b, 0x93, 0xf7, 0xbe, 0xf7, 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, 0x95, 0xe3, 0x45, 0xa4, 0xe9, 0x20, 0x1b, 0x3a,
+ 0x1a, 0xee, 0xfe, 0x3f, 0xa1, 0x88, 0x8d, 0x77, 0x3e, 0xfe, 0xf8, 0xf3, 0xf9, 0xd2, 0x6d, 0xb4,
+ 0x4d, 0x1a, 0xe6, 0x23, 0x2c, 0x48, 0x41, 0xde, 0x1a, 0xfa, 0x0a, 0x60, 0xaf, 0x52, 0xc1, 0x9a,
+ 0x80, 0xab, 0xdd, 0xae, 0x09, 0x58, 0xd3, 0x2e, 0xde, 0xb7, 0x01, 0x47, 0xe8, 0x6e, 0x53, 0x40,
+ 0x5a, 0x90, 0x6c, 0x40, 0x72, 0x92, 0x4f, 0xcb, 0x29, 0xfa, 0x05, 0x60, 0xbf, 0xbe, 0x2f, 0x74,
+ 0xbf, 0x35, 0x41, 0xeb, 0xac, 0x0c, 0x1f, 0x5c, 0x88, 0xeb, 0x36, 0x72, 0x68, 0x37, 0xf2, 0x08,
+ 0x3d, 0x24, 0xed, 0x37, 0x71, 0x65, 0x7c, 0xc8, 0x49, 0x65, 0x40, 0x4f, 0x9f, 0x1c, 0x7e, 0x5f,
+ 0x78, 0xe0, 0x6c, 0xe1, 0x81, 0xdf, 0x0b, 0x0f, 0x7c, 0x5a, 0x7a, 0x9d, 0xb3, 0xa5, 0xd7, 0xf9,
+ 0xb9, 0xf4, 0x3a, 0x6f, 0x76, 0xe2, 0x44, 0xcf, 0xcc, 0xd4, 0x0f, 0xc5, 0xbc, 0xf4, 0x28, 0x1e,
+ 0x23, 0x15, 0xbd, 0x23, 0x1f, 0xfe, 0x19, 0xea, 0x63, 0xc9, 0xd4, 0x74, 0xc3, 0xde, 0xf8, 0xfd,
+ 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x70, 0xe3, 0x27, 0x8e, 0x04, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -678,15 +677,10 @@ func (m *QueryUpgradedConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte)
_ = i
var l int
_ = l
- if m.UpgradedConsensusState != nil {
- {
- size, err := m.UpgradedConsensusState.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
+ if len(m.UpgradedConsensusState) > 0 {
+ i -= len(m.UpgradedConsensusState)
+ copy(dAtA[i:], m.UpgradedConsensusState)
+ i = encodeVarintQuery(dAtA, i, uint64(len(m.UpgradedConsensusState)))
i--
dAtA[i] = 0xa
}
@@ -769,8 +763,8 @@ func (m *QueryUpgradedConsensusStateResponse) Size() (n int) {
}
var l int
_ = l
- if m.UpgradedConsensusState != nil {
- l = m.UpgradedConsensusState.Size()
+ l = len(m.UpgradedConsensusState)
+ if l > 0 {
n += 1 + l + sovQuery(uint64(l))
}
return n
@@ -1171,7 +1165,7 @@ func (m *QueryUpgradedConsensusStateResponse) Unmarshal(dAtA []byte) error {
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UpgradedConsensusState", wireType)
}
- var msglen int
+ var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
@@ -1181,26 +1175,24 @@ func (m *QueryUpgradedConsensusStateResponse) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- msglen |= int(b&0x7F) << shift
+ byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
- if msglen < 0 {
+ if byteLen < 0 {
return ErrInvalidLengthQuery
}
- postIndex := iNdEx + msglen
+ postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
+ m.UpgradedConsensusState = append(m.UpgradedConsensusState[:0], dAtA[iNdEx:postIndex]...)
if m.UpgradedConsensusState == nil {
- m.UpgradedConsensusState = &types.Any{}
- }
- if err := m.UpgradedConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
+ m.UpgradedConsensusState = []byte{}
}
iNdEx = postIndex
default:
diff --git a/x/upgrade/types/upgrade.pb.go b/x/upgrade/types/upgrade.pb.go
index 642f4446fe28..144001a27ded 100644
--- a/x/upgrade/types/upgrade.pb.go
+++ b/x/upgrade/types/upgrade.pb.go
@@ -4,8 +4,9 @@
package types
import (
+ bytes "bytes"
fmt "fmt"
- types "github.com/cosmos/cosmos-sdk/codec/types"
+ _ "github.com/cosmos/cosmos-sdk/codec/types"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
@@ -52,7 +53,7 @@ type Plan struct {
// so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
// previous version of the chain.
// This will allow IBC connections to persist smoothly across planned chain upgrades
- UpgradedClientState *types.Any `protobuf:"bytes,5,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"`
+ UpgradedClientState []byte `protobuf:"bytes,5,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"`
}
func (m *Plan) Reset() { *m = Plan{} }
@@ -177,34 +178,34 @@ func init() {
}
var fileDescriptor_ccf2a7d4d7b48dca = []byte{
- // 426 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x31, 0x6f, 0xd4, 0x30,
- 0x18, 0x8d, 0x69, 0x5a, 0x51, 0xdf, 0x66, 0x8e, 0x12, 0x4e, 0xc5, 0x89, 0x4e, 0x0c, 0x37, 0x80,
- 0xa3, 0x16, 0x09, 0xa1, 0x6e, 0xa4, 0x3b, 0xaa, 0x52, 0x58, 0x90, 0x50, 0xe5, 0x24, 0xbe, 0x9c,
- 0xc1, 0xb1, 0xa3, 0xd8, 0x07, 0xe4, 0x57, 0xd0, 0x9f, 0xc0, 0xcf, 0xb9, 0xb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, 0xff, 0xf9, 0x58, 0xce, 0x3e, 0x7b, 0xb3,
+ 0xba, 0xc5, 0xde, 0xf5, 0x2d, 0xf6, 0x56, 0x6b, 0x0c, 0xae, 0xd6, 0x18, 0xfc, 0x58, 0x63, 0x70,
+ 0xb9, 0xc1, 0xde, 0xd5, 0x06, 0x7b, 0xd7, 0x1b, 0xec, 0xbd, 0x7b, 0x5e, 0x73, 0x33, 0x5f, 0x14,
+ 0xa4, 0x54, 0x4d, 0x3a, 0x7c, 0x46, 0xb7, 0xbc, 0xd0, 0xd5, 0x87, 0xf4, 0xf3, 0x9f, 0x9f, 0x69,
+ 0x96, 0x2d, 0xd3, 0xc5, 0x8e, 0x7d, 0xec, 0x97, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x2c,
+ 0xf5, 0x6e, 0xb8, 0x02, 0x00, 0x00,
}
func (this *Plan) Equal(that interface{}) bool {
@@ -238,7 +239,7 @@ func (this *Plan) Equal(that interface{}) bool {
if this.Info != that1.Info {
return false
}
- if !this.UpgradedClientState.Equal(that1.UpgradedClientState) {
+ if !bytes.Equal(this.UpgradedClientState, that1.UpgradedClientState) {
return false
}
return true
@@ -320,15 +321,10 @@ func (m *Plan) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
- if m.UpgradedClientState != nil {
- {
- size, err := m.UpgradedClientState.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintUpgrade(dAtA, i, uint64(size))
- }
+ if len(m.UpgradedClientState) > 0 {
+ i -= len(m.UpgradedClientState)
+ copy(dAtA[i:], m.UpgradedClientState)
+ i = encodeVarintUpgrade(dAtA, i, uint64(len(m.UpgradedClientState)))
i--
dAtA[i] = 0x2a
}
@@ -344,12 +340,12 @@ func (m *Plan) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x18
}
- n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):])
- if err2 != nil {
- return 0, err2
+ n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):])
+ if err1 != nil {
+ return 0, err1
}
- i -= n2
- i = encodeVarintUpgrade(dAtA, i, uint64(n2))
+ i -= n1
+ i = encodeVarintUpgrade(dAtA, i, uint64(n1))
i--
dAtA[i] = 0x12
if len(m.Name) > 0 {
@@ -476,8 +472,8 @@ func (m *Plan) Size() (n int) {
if l > 0 {
n += 1 + l + sovUpgrade(uint64(l))
}
- if m.UpgradedClientState != nil {
- l = m.UpgradedClientState.Size()
+ l = len(m.UpgradedClientState)
+ if l > 0 {
n += 1 + l + sovUpgrade(uint64(l))
}
return n
@@ -674,7 +670,7 @@ func (m *Plan) Unmarshal(dAtA []byte) error {
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UpgradedClientState", wireType)
}
- var msglen int
+ var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowUpgrade
@@ -684,26 +680,24 @@ func (m *Plan) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- msglen |= int(b&0x7F) << shift
+ byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
- if msglen < 0 {
+ if byteLen < 0 {
return ErrInvalidLengthUpgrade
}
- postIndex := iNdEx + msglen
+ postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthUpgrade
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
+ m.UpgradedClientState = append(m.UpgradedClientState[:0], dAtA[iNdEx:postIndex]...)
if m.UpgradedClientState == nil {
- m.UpgradedClientState = &types.Any{}
- }
- if err := m.UpgradedClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
+ m.UpgradedClientState = []byte{}
}
iNdEx = postIndex
default:
From c5c0d26b45c5f327c3e3f49ee6420faeeaa938c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Tue, 23 Feb 2021 13:14:57 +0100
Subject: [PATCH 04/30] remove x/ibc from types
---
x/upgrade/types/proposal_test.go | 4 ----
1 file changed, 4 deletions(-)
diff --git a/x/upgrade/types/proposal_test.go b/x/upgrade/types/proposal_test.go
index 110625bf3bbf..c9ca12ca8bab 100644
--- a/x/upgrade/types/proposal_test.go
+++ b/x/upgrade/types/proposal_test.go
@@ -9,8 +9,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
- ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
@@ -97,9 +95,7 @@ func TestMarshalSoftwareUpdateProposal(t *testing.T) {
// create codec
ir := codectypes.NewInterfaceRegistry()
types.RegisterInterfaces(ir)
- clienttypes.RegisterInterfaces(ir)
gov.RegisterInterfaces(ir)
- ibctmtypes.RegisterInterfaces(ir)
cdc := codec.NewProtoCodec(ir)
// marshal message
From 31ca56d56736b978e3b4c369ebec39a44d364e07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Tue, 23 Feb 2021 14:52:17 +0100
Subject: [PATCH 05/30] whoops, delete testing files
---
.../746b6a4424a328627f9d10020d53a82765d6642a.address | 1 -
client/keys/home/keyring-test/keyname1.info | 1 -
2 files changed, 2 deletions(-)
delete mode 100644 client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address
delete mode 100644 client/keys/home/keyring-test/keyname1.info
diff --git a/client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address b/client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address
deleted file mode 100644
index ed20229c9734..000000000000
--- a/client/keys/home/keyring-test/746b6a4424a328627f9d10020d53a82765d6642a.address
+++ /dev/null
@@ -1 +0,0 @@
-eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMS0wMi0yMyAxMjoxMzo0NS4yNzk4NDI3MzYgKzAxMDAgQ0VUIG09KzEuMjU1NjQ5MzQ4IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiMmJ6dzRycnR3UTExUjlYeCJ9.lL598D1-f0Wu0TeDzzDrPI5eCw9YuzZzttJxvSSzV7BKO0_xHb3AfA.EVYF3gI9e9kF7uhD.uFr_NPauozej7jXACkFiUbsNMaYIZRl5oLWlnMQku5WNtkJfHhwUwvAMmcKns-ektwNg0LheOK8dz0ll2KREGfaHAG8ueBqUbzBhQnkBNFaNaF8zdDLPrOd1ZjZudt0W5GySopljcgywhEKJoBJPFm50QJRhH3hqaZq-7lBplJlGd1VR5Eft2vaCDJSflEYNP1mfKjJ-YvOEQpeKNPoOi8tlw6l7KHdUpWzwDmqkj8omCXvAHPvuMqIW.4qDFmmMKbWJqxy5OU-tikg
\ No newline at end of file
diff --git a/client/keys/home/keyring-test/keyname1.info b/client/keys/home/keyring-test/keyname1.info
deleted file mode 100644
index 59fd4d26145d..000000000000
--- a/client/keys/home/keyring-test/keyname1.info
+++ /dev/null
@@ -1 +0,0 @@
-eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMS0wMi0yMyAxMjoxMzo0NS4yNzM1Njk5NDcgKzAxMDAgQ0VUIG09KzEuMjQ5Mzc2NjMwIiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiS3cwSS1mYjRpTDBYbGRjTSJ9.tbq41Cr-G91jSm_W7CckAfIZUawiMCWUvv21NPQ7_xGLDu6N_Eupsg.IBR0-H44WKmZrUTD.eDx6gE9bHhWOty7FtsqR4nDx2072a-YxffTZ8nry8fTAjHawqX3X6P7B_L40cb0uJgOsiTqbGUIfAraHNolbOm9fRzwiBizdqCAofE5qun-mAxoTC1RiTdhjPWsDjKScXAvtQrpQtDx4jSGuimW7AF7jF0NkP8Xt4ETf3z9fAxTQsHK_TH_Y_UImLjtthRFY5PHTiPonmaKMLDyT9GP5CSCxP8NihAz1eYMHkKVOd1Yb96elXNEZViBLRbU2AlXvnKI1gjyKBEl_PxttY89svn2FUGXQlYIshqJ38l7oiazLjBkD8zMz8VJYLghKpICYObkP6PnPgGaXFWQv2f6NGFKWPOHQz6-EJPXRiPgSiQ.OgcE7RmQ9VQMtHU32SuyBw
\ No newline at end of file
From 9ea85b821a67747c239e6b46ae13239844620e3f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Wed, 24 Feb 2021 13:11:39 +0100
Subject: [PATCH 06/30] fix upgrade tests
---
x/ibc/core/02-client/abci_test.go | 33 +++++++++++++++++++++++
x/upgrade/abci_test.go | 44 +++++++------------------------
x/upgrade/keeper/keeper_test.go | 39 +++++----------------------
3 files changed, 50 insertions(+), 66 deletions(-)
diff --git a/x/ibc/core/02-client/abci_test.go b/x/ibc/core/02-client/abci_test.go
index 3a296618b313..e2a31dd3eb74 100644
--- a/x/ibc/core/02-client/abci_test.go
+++ b/x/ibc/core/02-client/abci_test.go
@@ -4,12 +4,16 @@ import (
"testing"
"github.com/stretchr/testify/suite"
+ abci "github.com/tendermint/tendermint/abci/types"
+ tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
client "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client"
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
+ ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
localhosttypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/09-localhost/types"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
+ upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
type ClientTestSuite struct {
@@ -58,3 +62,32 @@ func (suite *ClientTestSuite) TestBeginBlocker() {
prevHeight = localHostClient.GetLatestHeight().(types.Height)
}
}
+
+func (suite *ClientTestSuite) TestBeginBlockerConsensusState() {
+ cs := []byte("IBC client state")
+ plan := &upgradetypes.Plan{
+ Name: "test",
+ Height: suite.chainA.GetContext().BlockHeight() + 1,
+ UpgradedClientState: cs,
+ }
+ store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
+ bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(plan)
+ store.Set(upgradetypes.PlanKey(), bz)
+
+ suite.T().Log("Verify that chain committed to consensus state on the last height it will commit")
+ nextValsHash := []byte("nextValsHash")
+ newCtx := suite.chainA.GetContext().WithBlockHeader(tmproto.Header{
+ Height: suite.chainA.GetContext().BlockHeight(),
+ NextValidatorsHash: nextValsHash,
+ })
+
+ req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()}
+ suite.chainA.App.BeginBlock(req)
+
+ // plan Height is at ctx.BlockHeight+1
+ consState, err := suite.chainA.App.UpgradeKeeper.GetUpgradedConsensusState(newCtx, suite.chainA.GetContext().BlockHeight()+1)
+ suite.Require().NoError(err)
+ bz, err = types.MarshalConsensusState(suite.chainA.App.AppCodec(), &ibctmtypes.ConsensusState{Timestamp: newCtx.BlockTime(), NextValidatorsHash: nextValsHash})
+ suite.Require().NoError(err)
+ suite.Require().Equal(bz, consState)
+}
diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go
index eb31857961bc..7b68ac9d0a21 100644
--- a/x/upgrade/abci_test.go
+++ b/x/upgrade/abci_test.go
@@ -21,8 +21,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/module"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
- ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
"github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
@@ -120,35 +118,19 @@ func TestCanOverwriteScheduleUpgrade(t *testing.T) {
VerifyDoUpgrade(t)
}
-func VerifyDoIBCLastBlock(t *testing.T) {
- t.Log("Verify that chain committed to consensus state on the last height it will commit")
- nextValsHash := []byte("nextValsHash")
- newCtx := s.ctx.WithBlockHeader(tmproto.Header{
- Height: s.ctx.BlockHeight(),
- NextValidatorsHash: nextValsHash,
- })
-
- req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()}
- s.module.BeginBlock(newCtx, req)
-
- // plan Height is at ctx.BlockHeight+1
- consState, err := s.keeper.GetUpgradedConsensusState(newCtx, s.ctx.BlockHeight()+1)
- require.NoError(t, err)
- require.Equal(t, &ibctmtypes.ConsensusState{Timestamp: newCtx.BlockTime(), NextValidatorsHash: nextValsHash}, consState)
-}
-
func VerifyDoIBCUpgrade(t *testing.T) {
t.Log("Verify that a panic happens at the upgrade time/height")
newCtx := s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1).WithBlockTime(time.Now())
+ consState := []byte("consensus state")
// Check IBC state is set before upgrade using last height: s.ctx.BlockHeight()
- cs, err := s.keeper.GetUpgradedClient(newCtx, s.ctx.BlockHeight())
+ cs, err := s.keeper.GetUpgradedClient(newCtx, s.ctx.BlockHeight()+1)
require.NoError(t, err, "could not retrieve upgraded client before upgrade plan is applied")
require.NotNil(t, cs, "IBC client is nil before upgrade")
- consState, err := s.keeper.GetUpgradedConsensusState(newCtx, s.ctx.BlockHeight())
- require.NoError(t, err, "could not retrieve upgraded consensus state before upgrade plan is applied")
- require.NotNil(t, consState, "IBC consensus state is nil before upgrade")
+ // set the consensus state since this happens in IBC 02-client begin blocker
+ err = s.keeper.SetUpgradedConsensusState(newCtx, s.ctx.BlockHeight(), consState)
+ require.NoError(t, err)
req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()}
require.Panics(t, func() {
@@ -280,9 +262,7 @@ func TestNoSpuriousUpgrades(t *testing.T) {
}
func TestPlanStringer(t *testing.T) {
- clientState := &ibctmtypes.ClientState{ChainId: "gaiachain"}
- cs, err := clienttypes.PackClientState(clientState)
- require.NoError(t, err)
+ cs := []byte("IBC client state")
ti, err := time.Parse(time.RFC3339, "2020-01-01T00:00:00Z")
require.Nil(t, err)
@@ -300,7 +280,7 @@ func TestPlanStringer(t *testing.T) {
Name: test
Height: 100
Info: .
- Upgraded IBC Client: %s`, clientState), types.Plan{Name: "test", Height: 100, UpgradedClientState: cs}.String())
+ Upgraded IBC Client: %s`, cs), types.Plan{Name: "test", Height: 100, UpgradedClientState: cs}.String())
}
func VerifyNotDone(t *testing.T, newCtx sdk.Context, name string) {
@@ -469,9 +449,8 @@ func TestUpgradeWithoutSkip(t *testing.T) {
func TestIBCUpgradeWithoutSkip(t *testing.T) {
s := setupTest(10, map[int64]bool{})
- cs, err := clienttypes.PackClientState(&ibctmtypes.ClientState{})
- require.NoError(t, err)
- err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{
+ cs := []byte("IBC client state")
+ err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{
Title: "prop",
Plan: types.Plan{
Name: "test",
@@ -481,10 +460,7 @@ func TestIBCUpgradeWithoutSkip(t *testing.T) {
})
require.Nil(t, err)
- t.Log("Verify if last height stores consensus state")
- VerifyDoIBCLastBlock(t)
-
- VerifyDoUpgrade(t)
+ VerifyDoIBCUpgrade(t)
VerifyDone(t, s.ctx, "test")
}
diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go
index 6e91ef3c2372..0df8c1a484b8 100644
--- a/x/upgrade/keeper/keeper_test.go
+++ b/x/upgrade/keeper/keeper_test.go
@@ -11,10 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
- commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"
- ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
- ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
@@ -61,17 +57,9 @@ func (s *KeeperTestSuite) TestReadUpgradeInfoFromDisk() {
}
func (s *KeeperTestSuite) TestScheduleUpgrade() {
- clientState := &ibctmtypes.ClientState{ChainId: "gaiachain"}
- cs, err := clienttypes.PackClientState(clientState)
- s.Require().NoError(err)
-
- altClientState := &ibctmtypes.ClientState{ChainId: "ethermint"}
- altCs, err := clienttypes.PackClientState(altClientState)
- s.Require().NoError(err)
+ cs := []byte("gaia IBC client state")
- consState := ibctmtypes.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("app_hash")), []byte("next_vals_hash"))
- consAny, err := clienttypes.PackConsensusState(consState)
- s.Require().NoError(err)
+ altCs := []byte("ethermint IBC client state")
cases := []struct {
name string
@@ -206,17 +194,6 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() {
},
expPass: false,
},
- {
- name: "unsuccessful IBC schedule: UpgradedClientState is not valid client state",
- plan: types.Plan{
- Name: "all-good",
- Info: "some text here",
- Height: 123450000,
- UpgradedClientState: consAny,
- },
- setup: func() {},
- expPass: false,
- },
}
for _, tc := range cases {
@@ -236,7 +213,7 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() {
if tc.plan.UpgradedClientState != nil {
got, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx, tc.plan.Height)
s.Require().NoError(err)
- s.Require().Equal(clientState, got, "upgradedClient not equal to expected value")
+ s.Require().Equal(tc.plan.UpgradedClientState, got, "upgradedClient not equal to expected value")
} else {
// check that upgraded client is empty if latest plan does not specify an upgraded client
got, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx, tc.plan.Height)
@@ -251,9 +228,8 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() {
}
func (s *KeeperTestSuite) TestSetUpgradedClient() {
- var (
- clientState ibcexported.ClientState
- )
+ cs := []byte("IBC client state")
+
cases := []struct {
name string
height int64
@@ -270,8 +246,7 @@ func (s *KeeperTestSuite) TestSetUpgradedClient() {
name: "success",
height: 10,
setup: func() {
- clientState = &ibctmtypes.ClientState{ChainId: "gaiachain"}
- s.app.UpgradeKeeper.SetUpgradedClient(s.ctx, 10, clientState)
+ s.app.UpgradeKeeper.SetUpgradedClient(s.ctx, 10, cs)
},
exists: true,
},
@@ -286,7 +261,7 @@ func (s *KeeperTestSuite) TestSetUpgradedClient() {
gotCs, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx, tc.height)
if tc.exists {
- s.Require().Equal(clientState, gotCs, "valid case: %s did not retrieve correct client state", tc.name)
+ s.Require().Equal(cs, gotCs, "valid case: %s did not retrieve correct client state", tc.name)
s.Require().NoError(err, "valid case: %s returned error")
} else {
s.Require().Nil(gotCs, "invalid case: %s retrieved valid client state", tc.name)
From 3449f66594df1109cdffd5a4fd64fdde7c175705 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Wed, 24 Feb 2021 13:34:59 +0100
Subject: [PATCH 07/30] fix tm tests
---
.../07-tendermint/types/upgrade_test.go | 63 +++++++++++--------
1 file changed, 38 insertions(+), 25 deletions(-)
diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
index c66f9f1c6659..fa571d4ba10e 100644
--- a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
+++ b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
@@ -15,6 +15,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight clienttypes.Height
clientA string
proofUpgradedClient, proofUpgradedConsState []byte
+ upgradedClientBz, upgradedConsStateBz []byte
+ err error
)
testCases := []struct {
@@ -29,8 +31,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -52,13 +54,15 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
upgradedHeight := clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+2))
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradedHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
upgradedClient = upgradedClient.ZeroCustomFields()
+ upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient)
+ suite.Require().NoError(err)
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -82,8 +86,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+10))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -104,13 +108,15 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
setup: func() {
// non-zeroed upgrade client
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
+ upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient)
+ suite.Require().NoError(err)
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -133,8 +139,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// change upgradedClient client-specified parameters
upgradedClient = types.NewClientState("wrongchainID", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, true)
@@ -155,8 +161,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
name: "unsuccessful upgrade: client-specified parameters do not match previous client",
setup: func() {
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// change upgradedClient client-specified parameters
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, lastHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false)
@@ -180,8 +186,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// change submitted upgradedConsensusState
upgradedConsState = &types.ConsensusState{
@@ -205,7 +211,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: client proof unmarshal failed",
setup: func() {
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
suite.Require().True(found)
@@ -219,7 +225,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
{
name: "unsuccessful upgrade: consensus state proof unmarshal failed",
setup: func() {
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
suite.Require().True(found)
@@ -238,7 +244,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
suite.Require().True(found)
@@ -256,7 +262,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
suite.Require().True(found)
@@ -273,7 +279,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
// commit upgrade store changes and update clients
@@ -301,7 +307,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
// commit upgrade store changes and update clients
@@ -324,7 +330,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+100))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
// commit upgrade store changes and update clients
@@ -344,7 +350,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
name: "unsuccessful upgrade: client is expired",
setup: func() {
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
// commit upgrade store changes and update clients
@@ -370,7 +376,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
// commit upgrade store changes and update clients
@@ -391,13 +397,15 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
setup: func() {
// new client has smaller unbonding period such that old trusting period is no longer valid
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
+ upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient)
+ suite.Require().NoError(err)
// upgrade Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -424,9 +432,14 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
upgradedClient = upgradedClient.ZeroCustomFields()
+ upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient)
+ suite.Require().NoError(err)
+
upgradedConsState = &types.ConsensusState{
NextValidatorsHash: []byte("nextValsHash"),
}
+ upgradedConsStateBz, err = clienttypes.MarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState)
+ suite.Require().NoError(err)
tc.setup()
From 01cc2d7e06944c5327569e17b715b5b9dd296ad5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Wed, 24 Feb 2021 14:06:23 +0100
Subject: [PATCH 08/30] fix tests
---
x/ibc/core/02-client/keeper/client_test.go | 25 ++++++++++++++--------
x/ibc/core/keeper/msg_server_test.go | 24 ++++++++++++++-------
2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/x/ibc/core/02-client/keeper/client_test.go b/x/ibc/core/02-client/keeper/client_test.go
index 0c44142c4414..9eb816adf919 100644
--- a/x/ibc/core/02-client/keeper/client_test.go
+++ b/x/ibc/core/02-client/keeper/client_test.go
@@ -230,6 +230,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
lastHeight exported.Height
clientA string
proofUpgradedClient, proofUpgradedConsState []byte
+ upgradedClientBz, upgradedConsStateBz []byte
+ err error
)
testCases := []struct {
@@ -244,8 +246,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -268,8 +270,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -294,8 +296,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
@@ -324,8 +326,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// change upgradedClient client-specified parameters
upgradedClient = ibctmtypes.NewClientState("wrongchainID", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, true, true)
@@ -349,16 +351,21 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
upgradedClient = upgradedClient.ZeroCustomFields()
+ upgradedClientBz, err = types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient)
+ suite.Require().NoError(err)
+
upgradedConsState = &ibctmtypes.ConsensusState{
NextValidatorsHash: []byte("nextValsHash"),
}
+ upgradedConsStateBz, err = types.MarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState)
+ suite.Require().NoError(err)
tc.setup()
// Call ZeroCustomFields on upgraded clients to clear any client-chosen parameters in test-case upgradedClient
upgradedClient = upgradedClient.ZeroCustomFields()
- err := suite.chainA.App.IBCKeeper.ClientKeeper.UpgradeClient(suite.chainA.GetContext(), clientA, upgradedClient, upgradedConsState, proofUpgradedClient, proofUpgradedConsState)
+ err = suite.chainA.App.IBCKeeper.ClientKeeper.UpgradeClient(suite.chainA.GetContext(), clientA, upgradedClient, upgradedConsState, proofUpgradedClient, proofUpgradedConsState)
if tc.expPass {
suite.Require().NoError(err, "verify upgrade failed on valid case: %s", tc.name)
diff --git a/x/ibc/core/keeper/msg_server_test.go b/x/ibc/core/keeper/msg_server_test.go
index 1af4cdc18eb0..1c4b60010f7a 100644
--- a/x/ibc/core/keeper/msg_server_test.go
+++ b/x/ibc/core/keeper/msg_server_test.go
@@ -639,14 +639,18 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
// last Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
+ upgradedClientBz, err := clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient)
+ suite.Require().NoError(err)
+ upgradedConsStateBz, err := clienttypes.MarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState)
+ suite.Require().NoError(err)
+
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
-
suite.coordinator.CommitBlock(suite.chainB)
- err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
+ err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
suite.Require().NoError(err)
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
@@ -676,14 +680,18 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
// last Height is at next block
lastHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
+ upgradedClientBz, err := clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient)
+ suite.Require().NoError(err)
+ upgradedConsStateBz, err := clienttypes.MarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState)
+ suite.Require().NoError(err)
+
// zero custom fields and store in upgrade store
- suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClient)
- suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsState)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedClientBz)
+ suite.chainB.App.UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz)
// commit upgrade store changes and update clients
-
suite.coordinator.CommitBlock(suite.chainB)
- err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
+ err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
suite.Require().NoError(err)
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradedConsState, nil, nil, suite.chainA.SenderAccount.GetAddress())
From 21fb511d6bafeeb80615582c50591c951d6314db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Wed, 24 Feb 2021 14:15:40 +0100
Subject: [PATCH 09/30] update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21c7a9ac67c4..4608f6d945f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/distribution) [\#8473](https://github.com/cosmos/cosmos-sdk/pull/8473) On genesis init, if the distribution module account balance, coming from bank module state, does not match the one in distribution module state, the initialization will panic.
* (client/keys) [\#8500](https://github.com/cosmos/cosmos-sdk/pull/8500) `InfoImporter` interface is removed from legacy keybase.
* [\#8629](https://github.com/cosmos/cosmos-sdk/pull/8629) Deprecated `SetFullFundraiserPath` from `Config` in favor of `SetPurpose` and `SetCoinType`.
+* (x/upgrade) [\#8673](https://github.com/cosmos/cosmos-sdk/pull/8673) Remove x/ibc imports from x/upgrade by replacing plan.UpgradedClient with a `[]byte` instead of using an `Any`. IBC upgrade begin blocker logic moved to the IBC module.
### State Machine Breaking
From 862dc3740a30e6a5c8aa737b609696f0f07ae2fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Wed, 24 Feb 2021 17:27:47 +0100
Subject: [PATCH 10/30] revert proto breakage, use reserved field cc @amaurym
---
proto/cosmos/upgrade/v1beta1/query.proto | 5 +-
proto/cosmos/upgrade/v1beta1/upgrade.proto | 5 +-
x/upgrade/types/query.pb.go | 69 +++++++++++-----------
x/upgrade/types/upgrade.pb.go | 63 ++++++++++----------
4 files changed, 75 insertions(+), 67 deletions(-)
diff --git a/proto/cosmos/upgrade/v1beta1/query.proto b/proto/cosmos/upgrade/v1beta1/query.proto
index 50c7410d6f7a..898a74febd85 100644
--- a/proto/cosmos/upgrade/v1beta1/query.proto
+++ b/proto/cosmos/upgrade/v1beta1/query.proto
@@ -64,5 +64,8 @@ message QueryUpgradedConsensusStateRequest {
// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState
// RPC method.
message QueryUpgradedConsensusStateResponse {
- bytes upgraded_consensus_state = 1;
+ reserved 1;
+ reserved "option";
+
+ bytes upgraded_consensus_state = 2;
}
diff --git a/proto/cosmos/upgrade/v1beta1/upgrade.proto b/proto/cosmos/upgrade/v1beta1/upgrade.proto
index 07232064b015..2a594112e1ac 100644
--- a/proto/cosmos/upgrade/v1beta1/upgrade.proto
+++ b/proto/cosmos/upgrade/v1beta1/upgrade.proto
@@ -34,12 +34,15 @@ message Plan {
// such as a git commit that validators could automatically upgrade to
string info = 4;
+ reserved 5;
+ reserved "option";
+
// IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan
// This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs,
// so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
// previous version of the chain.
// This will allow IBC connections to persist smoothly across planned chain upgrades
- bytes upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];
+ bytes upgraded_client_state = 6 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];
}
// SoftwareUpgradeProposal is a gov Content type for initiating a software
diff --git a/x/upgrade/types/query.pb.go b/x/upgrade/types/query.pb.go
index 43d531dbd3bd..f199bfdbfc7d 100644
--- a/x/upgrade/types/query.pb.go
+++ b/x/upgrade/types/query.pb.go
@@ -259,7 +259,7 @@ func (m *QueryUpgradedConsensusStateRequest) GetLastHeight() int64 {
// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState
// RPC method.
type QueryUpgradedConsensusStateResponse struct {
- UpgradedConsensusState []byte `protobuf:"bytes,1,opt,name=upgraded_consensus_state,json=upgradedConsensusState,proto3" json:"upgraded_consensus_state,omitempty"`
+ UpgradedConsensusState []byte `protobuf:"bytes,2,opt,name=upgraded_consensus_state,json=upgradedConsensusState,proto3" json:"upgraded_consensus_state,omitempty"`
}
func (m *QueryUpgradedConsensusStateResponse) Reset() { *m = QueryUpgradedConsensusStateResponse{} }
@@ -316,37 +316,38 @@ func init() {
}
var fileDescriptor_4a334d07ad8374f0 = []byte{
- // 478 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcd, 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0x72, 0x92, 0x4f, 0xcb, 0x29, 0xfa, 0x05, 0x60, 0xbf, 0xbe, 0x2f, 0x74,
- 0xbf, 0x35, 0x41, 0xeb, 0xac, 0x0c, 0x1f, 0x5c, 0x88, 0xeb, 0x36, 0x72, 0x68, 0x37, 0xf2, 0x08,
- 0x3d, 0x24, 0xed, 0x37, 0x71, 0x65, 0x7c, 0xc8, 0x49, 0x65, 0x40, 0x4f, 0x9f, 0x1c, 0x7e, 0x5f,
- 0x78, 0xe0, 0x6c, 0xe1, 0x81, 0xdf, 0x0b, 0x0f, 0x7c, 0x5a, 0x7a, 0x9d, 0xb3, 0xa5, 0xd7, 0xf9,
- 0xb9, 0xf4, 0x3a, 0x6f, 0x76, 0xe2, 0x44, 0xcf, 0xcc, 0xd4, 0x0f, 0xc5, 0xbc, 0xf4, 0x28, 0x1e,
- 0x23, 0x15, 0xbd, 0x23, 0x1f, 0xfe, 0x19, 0xea, 0x63, 0xc9, 0xd4, 0x74, 0xc3, 0xde, 0xf8, 0xfd,
- 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x70, 0xe3, 0x27, 0x8e, 0x04, 0x00, 0x00,
+ // 495 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcf, 0x6b, 0x13, 0x41,
+ 0x18, 0xcd, 0xc4, 0x18, 0x74, 0xe2, 0x41, 0xe6, 0x10, 0xd3, 0x50, 0xd6, 0x32, 0x16, 0x29, 0xd8,
+ 0xec, 0xb4, 0xe9, 0x45, 0x14, 0x44, 0x2d, 0x16, 0x11, 0x0f, 0xba, 0xe2, 0xc5, 0x4b, 0x98, 0x64,
+ 0xc7, 0xcd, 0xe2, 0x66, 0x66, 0xba, 0x33, 0x23, 0x96, 0xd2, 0x8b, 0x7f, 0x81, 0xe0, 0xdd, 0x9b,
+ 0x37, 0xff, 0x10, 0x8f, 0x05, 0x2f, 0x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xe4, 0xf1, 0xc1,
+ 0xf7, 0xb9, 0x07, 0x4e, 0xe7, 0x1e, 0xf8, 0x3d, 0xf7, 0xc0, 0xa7, 0x85, 0xd7, 0x38, 0x5d, 0x78,
+ 0x8d, 0x9f, 0x0b, 0xaf, 0xf1, 0x66, 0x3b, 0x8a, 0xf5, 0xd4, 0x8c, 0xfd, 0x89, 0x98, 0x2d, 0x35,
+ 0xf2, 0xc7, 0x40, 0x85, 0xef, 0xc8, 0x87, 0x7f, 0x82, 0xfa, 0x48, 0x32, 0x35, 0x6e, 0xdb, 0xfb,
+ 0xbf, 0xf7, 0x37, 0x00, 0x00, 0xff, 0xff, 0xff, 0xa5, 0x92, 0x77, 0x9c, 0x04, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -682,7 +683,7 @@ func (m *QueryUpgradedConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte)
copy(dAtA[i:], m.UpgradedConsensusState)
i = encodeVarintQuery(dAtA, i, uint64(len(m.UpgradedConsensusState)))
i--
- dAtA[i] = 0xa
+ dAtA[i] = 0x12
}
return len(dAtA) - i, nil
}
@@ -1161,7 +1162,7 @@ func (m *QueryUpgradedConsensusStateResponse) Unmarshal(dAtA []byte) error {
return fmt.Errorf("proto: QueryUpgradedConsensusStateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
- case 1:
+ case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UpgradedConsensusState", wireType)
}
diff --git a/x/upgrade/types/upgrade.pb.go b/x/upgrade/types/upgrade.pb.go
index 144001a27ded..1a680b38e547 100644
--- a/x/upgrade/types/upgrade.pb.go
+++ b/x/upgrade/types/upgrade.pb.go
@@ -53,7 +53,7 @@ type Plan struct {
// so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
// previous version of the chain.
// This will allow IBC connections to persist smoothly across planned chain upgrades
- UpgradedClientState []byte `protobuf:"bytes,5,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"`
+ UpgradedClientState []byte `protobuf:"bytes,6,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"`
}
func (m *Plan) Reset() { *m = Plan{} }
@@ -178,34 +178,35 @@ func init() {
}
var fileDescriptor_ccf2a7d4d7b48dca = []byte{
- // 422 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xb1, 0x6e, 0xd4, 0x30,
- 0x18, 0xc7, 0x63, 0x9a, 0x56, 0xd4, 0xc7, 0x64, 0x4a, 0x09, 0xa7, 0xe2, 0x44, 0x11, 0x43, 0x06,
- 0x70, 0xd4, 0x22, 0x21, 0xd4, 0x31, 0xdd, 0x51, 0x95, 0x96, 0x05, 0x09, 0x55, 0x4e, 0xe2, 0xcb,
- 0x59, 0x38, 0x76, 0x14, 0xfb, 0x80, 0x7b, 0x0a, 0xfa, 0x08, 0x3c, 0xce, 0x8d, 0x1d, 0x3b, 0xa0,
- 0x42, 0xef, 0x16, 0x66, 0x9e, 0x00, 0xc5, 0x4e, 0x10, 0x42, 0x1d, 0x99, 0xfc, 0x7d, 0x7f, 0xfd,
- 0xbe, 0xbf, 0xfd, 0xb7, 0x0d, 0x9f, 0x95, 0x4a, 0x37, 0x4a, 0xa7, 0x8b, 0xb6, 0xee, 0x68, 0xc5,
- 0xd2, 0x8f, 0x87, 0x05, 0x33, 0xf4, 0x70, 0xec, 0x49, 0xdb, 0x29, 0xa3, 0xd0, 0xbe, 0xa3, 0xc8,
- 0xa8, 0x0e, 0xd4, 0xf4, 0x49, 0xad, 0x54, 0x2d, 0x58, 0x6a, 0xa9, 0x62, 0x31, 0x4b, 0xa9, 0x5c,
- 0xba, 0x91, 0xe9, 0x5e, 0xad, 0x6a, 0x65, 0xcb, 0xb4, 0xaf, 0x06, 0x35, 0xfc, 0x77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0x3d, 0xcd, 0xc6, 0x02,
+ 0x00, 0x00,
}
func (this *Plan) Equal(that interface{}) bool {
@@ -326,7 +327,7 @@ func (m *Plan) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.UpgradedClientState)
i = encodeVarintUpgrade(dAtA, i, uint64(len(m.UpgradedClientState)))
i--
- dAtA[i] = 0x2a
+ dAtA[i] = 0x32
}
if len(m.Info) > 0 {
i -= len(m.Info)
@@ -666,7 +667,7 @@ func (m *Plan) Unmarshal(dAtA []byte) error {
}
m.Info = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
- case 5:
+ case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UpgradedClientState", wireType)
}
From dd180e8c73084f73a7bb6e1841152a04ab2a3321 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 13:21:04 +0100
Subject: [PATCH 11/30] add IBC Upgrade Proposal type
---
docs/core/proto-docs.md | 21 +-
proto/cosmos/upgrade/v1beta1/upgrade.proto | 9 +-
proto/ibc/core/client/v1/client.proto | 20 +
x/ibc/core/02-client/types/client.pb.go | 442 ++++++++++++++++++---
x/ibc/core/02-client/types/codec.go | 1 +
x/ibc/core/02-client/types/errors.go | 1 +
x/ibc/core/02-client/types/proposal.go | 80 +++-
x/upgrade/types/upgrade.pb.go | 110 ++---
8 files changed, 546 insertions(+), 138 deletions(-)
diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md
index 6ed2829be600..90445520a8a5 100644
--- a/docs/core/proto-docs.md
+++ b/docs/core/proto-docs.md
@@ -567,6 +567,7 @@
- [Height](#ibc.core.client.v1.Height)
- [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState)
- [Params](#ibc.core.client.v1.Params)
+ - [UpgradeProposal](#ibc.core.client.v1.UpgradeProposal)
- [ibc/applications/transfer/v1/tx.proto](#ibc/applications/transfer/v1/tx.proto)
- [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer)
@@ -7507,7 +7508,6 @@ Plan specifies information about a planned upgrade and when it should occur.
| `time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | The time after which the upgrade must be performed. Leave set to its zero value to use a pre-defined Height instead. |
| `height` | [int64](#int64) | | The height at which the upgrade must be performed. Only used if Time is not set. |
| `info` | [string](#string) | | Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to |
-| `upgraded_client_state` | [bytes](#bytes) | | IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades |
@@ -8161,6 +8161,25 @@ Params defines the set of IBC light client parameters.
+
+
+
+### UpgradeProposal
+UpgradeProposal is a gov Content type for initiating an IBC breaking
+upgrade.
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| `title` | [string](#string) | | |
+| `description` | [string](#string) | | |
+| `plan` | [cosmos.upgrade.v1beta1.Plan](#cosmos.upgrade.v1beta1.Plan) | | |
+| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | An UpgradedClientState must be provided to perform an IBC breaking upgrade. This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades |
+
+
+
+
+
diff --git a/proto/cosmos/upgrade/v1beta1/upgrade.proto b/proto/cosmos/upgrade/v1beta1/upgrade.proto
index 2a594112e1ac..76fb14e2d3ca 100644
--- a/proto/cosmos/upgrade/v1beta1/upgrade.proto
+++ b/proto/cosmos/upgrade/v1beta1/upgrade.proto
@@ -34,15 +34,10 @@ message Plan {
// such as a git commit that validators could automatically upgrade to
string info = 4;
+ // UpgradedClientState field has been deprecated. IBC upgrade logic has been
+ // moved to the IBC module in the sub module 02-client.
reserved 5;
reserved "option";
-
- // IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan
- // This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs,
- // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
- // previous version of the chain.
- // This will allow IBC connections to persist smoothly across planned chain upgrades
- bytes upgraded_client_state = 6 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];
}
// SoftwareUpgradeProposal is a gov Content type for initiating a software
diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto
index 4c6308bd5415..d8c0c28f498d 100644
--- a/proto/ibc/core/client/v1/client.proto
+++ b/proto/ibc/core/client/v1/client.proto
@@ -5,6 +5,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
+import "cosmos/upgrade/v1beta1/upgrade.proto";
// IdentifiedClientState defines a client state with an additional client
// identifier field.
@@ -52,6 +53,25 @@ message ClientUpdateProposal {
Height initial_height = 5 [(gogoproto.moretags) = "yaml:\"initial_height\"", (gogoproto.nullable) = false];
}
+// UpgradeProposal is a gov Content type for initiating an IBC breaking
+// upgrade.
+message UpgradeProposal {
+ option (gogoproto.goproto_getters) = false;
+ option (gogoproto.goproto_stringer) = false;
+ option (gogoproto.equal) = true;
+
+ string title = 1;
+ string description = 2;
+ cosmos.upgrade.v1beta1.Plan plan = 3 [(gogoproto.nullable) = false];
+
+ // An UpgradedClientState must be provided to perform an IBC breaking upgrade.
+ // This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs,
+ // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
+ // previous version of the chain.
+ // This will allow IBC connections to persist smoothly across planned chain upgrades
+ google.protobuf.Any upgraded_client_state = 4 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];
+}
+
// Height is a monotonically increasing data type
// that can be compared against another Height for the purposes of updating and
// freezing clients
diff --git a/x/ibc/core/02-client/types/client.pb.go b/x/ibc/core/02-client/types/client.pb.go
index 61bdd9bf804d..a9a799453900 100644
--- a/x/ibc/core/02-client/types/client.pb.go
+++ b/x/ibc/core/02-client/types/client.pb.go
@@ -6,6 +6,7 @@ package types
import (
fmt "fmt"
types "github.com/cosmos/cosmos-sdk/codec/types"
+ types1 "github.com/cosmos/cosmos-sdk/x/upgrade/types"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
@@ -242,6 +243,52 @@ func (m *ClientUpdateProposal) XXX_DiscardUnknown() {
var xxx_messageInfo_ClientUpdateProposal proto.InternalMessageInfo
+// UpgradeProposal is a gov Content type for initiating an IBC breaking
+// upgrade.
+type UpgradeProposal struct {
+ Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
+ Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
+ Plan types1.Plan `protobuf:"bytes,3,opt,name=plan,proto3" json:"plan"`
+ // An UpgradedClientState must be provided to perform an IBC breaking upgrade.
+ // This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs,
+ // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
+ // previous version of the chain.
+ // This will allow IBC connections to persist smoothly across planned chain upgrades
+ UpgradedClientState *types.Any `protobuf:"bytes,4,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"`
+}
+
+func (m *UpgradeProposal) Reset() { *m = UpgradeProposal{} }
+func (*UpgradeProposal) ProtoMessage() {}
+func (*UpgradeProposal) Descriptor() ([]byte, []int) {
+ return fileDescriptor_b6bc4c8185546947, []int{4}
+}
+func (m *UpgradeProposal) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *UpgradeProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_UpgradeProposal.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *UpgradeProposal) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_UpgradeProposal.Merge(m, src)
+}
+func (m *UpgradeProposal) XXX_Size() int {
+ return m.Size()
+}
+func (m *UpgradeProposal) XXX_DiscardUnknown() {
+ xxx_messageInfo_UpgradeProposal.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_UpgradeProposal proto.InternalMessageInfo
+
// Height is a monotonically increasing data type
// that can be compared against another Height for the purposes of updating and
// freezing clients
@@ -261,7 +308,7 @@ type Height struct {
func (m *Height) Reset() { *m = Height{} }
func (*Height) ProtoMessage() {}
func (*Height) Descriptor() ([]byte, []int) {
- return fileDescriptor_b6bc4c8185546947, []int{4}
+ return fileDescriptor_b6bc4c8185546947, []int{5}
}
func (m *Height) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@@ -300,7 +347,7 @@ func (m *Params) Reset() { *m = Params{} }
func (m *Params) String() string { return proto.CompactTextString(m) }
func (*Params) ProtoMessage() {}
func (*Params) Descriptor() ([]byte, []int) {
- return fileDescriptor_b6bc4c8185546947, []int{5}
+ return fileDescriptor_b6bc4c8185546947, []int{6}
}
func (m *Params) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@@ -341,6 +388,7 @@ func init() {
proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.core.client.v1.ConsensusStateWithHeight")
proto.RegisterType((*ClientConsensusStates)(nil), "ibc.core.client.v1.ClientConsensusStates")
proto.RegisterType((*ClientUpdateProposal)(nil), "ibc.core.client.v1.ClientUpdateProposal")
+ proto.RegisterType((*UpgradeProposal)(nil), "ibc.core.client.v1.UpgradeProposal")
proto.RegisterType((*Height)(nil), "ibc.core.client.v1.Height")
proto.RegisterType((*Params)(nil), "ibc.core.client.v1.Params")
}
@@ -348,50 +396,89 @@ func init() {
func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) }
var fileDescriptor_b6bc4c8185546947 = []byte{
- // 641 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xbf, 0x6e, 0xd3, 0x40,
- 0x1c, 0x8e, 0xd3, 0x34, 0x6a, 0x2e, 0x90, 0x14, 0x93, 0xd0, 0x34, 0x40, 0x2e, 0xba, 0x29, 0x03,
- 0xb5, 0x69, 0x18, 0x40, 0xdd, 0x48, 0x96, 0x76, 0x00, 0xb5, 0x87, 0x10, 0x88, 0x25, 0xf8, 0xcf,
- 0x35, 0x39, 0x70, 0x7c, 0x91, 0xef, 0x5c, 0x9a, 0x37, 0x60, 0x64, 0x64, 0x60, 0xe0, 0x09, 0x78,
- 0x0a, 0x86, 0x8e, 0x95, 0x58, 0x98, 0x2c, 0xd4, 0xbe, 0x81, 0x9f, 0x00, 0xf9, 0xee, 0x92, 0x36,
- 0x29, 0x15, 0x88, 0xc9, 0x3f, 0x7f, 0xf7, 0xfd, 0xbe, 0xdf, 0xf7, 0xfb, 0x74, 0x36, 0x80, 0xd4,
- 0xf5, 0x6c, 0x8f, 0x45, 0xc4, 0xf6, 0x02, 0x4a, 0x42, 0x61, 0x1f, 0x6d, 0xeb, 0xca, 0x9a, 0x44,
- 0x4c, 0x30, 0xd3, 0xa4, 0xae, 0x67, 0x65, 0x04, 0x4b, 0xc3, 0x47, 0xdb, 0xcd, 0xda, 0x90, 0x0d,
- 0x99, 0x3c, 0xb6, 0xb3, 0x4a, 0x31, 0x9b, 0x9b, 0x43, 0xc6, 0x86, 0x01, 0xb1, 0xe5, 0x9b, 0x1b,
- 0x1f, 0xda, 0x4e, 0x38, 0x55, 0x47, 0xe8, 0x8b, 0x01, 0xea, 0x7b, 0x3e, 0x09, 0x05, 0x3d, 0xa4,
- 0xc4, 0xef, 0x4b, 0xa1, 0x17, 0xc2, 0x11, 0xc4, 0xdc, 0x06, 0x25, 0xa5, 0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0x18, 0x28, 0xb7, 0x78, 0xa2,
+ 0x05, 0x00, 0xd4, 0x0b, 0x49, 0xe4, 0x59, 0x1c, 0x98, 0x23, 0x11, 0xc7, 0x96, 0xbe, 0x91, 0x24,
+ 0x39, 0x97, 0x29, 0x89, 0x38, 0x98, 0x95, 0xa4, 0x44, 0xf8, 0x14, 0x64, 0xbb, 0x86, 0x67, 0x0c,
+ 0x69, 0x44, 0x6c, 0x38, 0x0e, 0x79, 0x3b, 0x15, 0x49, 0x2b, 0x52, 0x7d, 0xa9, 0x91, 0x9b, 0x25,
+ 0x5e, 0x00, 0x40, 0xbd, 0x20, 0x22, 0x5c, 0x3f, 0x6d, 0xef, 0x9f, 0x9e, 0xd7, 0xa4, 0xb3, 0xf3,
+ 0x9a, 0xf4, 0xed, 0xbc, 0x26, 0xbd, 0xbf, 0xa8, 0xa5, 0xce, 0x2e, 0x6a, 0xa9, 0xaf, 0x17, 0xb5,
+ 0xd4, 0xab, 0x47, 0x7d, 0xcc, 0x06, 0xbe, 0xa9, 0x5a, 0x64, 0xa8, 0x89, 0x37, 0x9a, 0x7f, 0xb6,
+ 0xa9, 0xfd, 0x46, 0x3b, 0xd6, 0xa6, 0x7f, 0x87, 0xfb, 0xad, 0x6d, 0xf1, 0x83, 0x60, 0x93, 0x11,
+ 0xa2, 0x66, 0x36, 0x3e, 0x93, 0x07, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x66, 0x9c, 0xf8, 0xf8,
+ 0x40, 0x06, 0x00, 0x00,
+}
+
+func (this *UpgradeProposal) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*UpgradeProposal)
+ if !ok {
+ that2, ok := that.(UpgradeProposal)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if this.Title != that1.Title {
+ return false
+ }
+ if this.Description != that1.Description {
+ return false
+ }
+ if !this.Plan.Equal(&that1.Plan) {
+ return false
+ }
+ if !this.UpgradedClientState.Equal(that1.UpgradedClientState) {
+ return false
+ }
+ return true
}
-
func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@@ -584,6 +671,65 @@ func (m *ClientUpdateProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
+func (m *UpgradeProposal) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *UpgradeProposal) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *UpgradeProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.UpgradedClientState != nil {
+ {
+ size, err := m.UpgradedClientState.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintClient(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x22
+ }
+ {
+ size, err := m.Plan.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintClient(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x1a
+ if len(m.Description) > 0 {
+ i -= len(m.Description)
+ copy(dAtA[i:], m.Description)
+ i = encodeVarintClient(dAtA, i, uint64(len(m.Description)))
+ i--
+ dAtA[i] = 0x12
+ }
+ if len(m.Title) > 0 {
+ i -= len(m.Title)
+ copy(dAtA[i:], m.Title)
+ i = encodeVarintClient(dAtA, i, uint64(len(m.Title)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
func (m *Height) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@@ -738,6 +884,29 @@ func (m *ClientUpdateProposal) Size() (n int) {
return n
}
+func (m *UpgradeProposal) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.Title)
+ if l > 0 {
+ n += 1 + l + sovClient(uint64(l))
+ }
+ l = len(m.Description)
+ if l > 0 {
+ n += 1 + l + sovClient(uint64(l))
+ }
+ l = m.Plan.Size()
+ n += 1 + l + sovClient(uint64(l))
+ if m.UpgradedClientState != nil {
+ l = m.UpgradedClientState.Size()
+ n += 1 + l + sovClient(uint64(l))
+ }
+ return n
+}
+
func (m *Height) Size() (n int) {
if m == nil {
return 0
@@ -1338,6 +1507,189 @@ func (m *ClientUpdateProposal) Unmarshal(dAtA []byte) error {
}
return nil
}
+func (m *UpgradeProposal) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowClient
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: UpgradeProposal: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: UpgradeProposal: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowClient
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthClient
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthClient
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Title = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowClient
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthClient
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthClient
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Description = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Plan", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowClient
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthClient
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthClient
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if err := m.Plan.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field UpgradedClientState", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowClient
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthClient
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthClient
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.UpgradedClientState == nil {
+ m.UpgradedClientState = &types.Any{}
+ }
+ if err := m.UpgradedClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipClient(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthClient
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
func (m *Height) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
diff --git a/x/ibc/core/02-client/types/codec.go b/x/ibc/core/02-client/types/codec.go
index 59a15832bec1..8f8ab56112c7 100644
--- a/x/ibc/core/02-client/types/codec.go
+++ b/x/ibc/core/02-client/types/codec.go
@@ -37,6 +37,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*govtypes.Content)(nil),
&ClientUpdateProposal{},
+ &UpgradeProposal{},
)
registry.RegisterImplementations(
(*sdk.Msg)(nil),
diff --git a/x/ibc/core/02-client/types/errors.go b/x/ibc/core/02-client/types/errors.go
index 5b44cd522211..08bdbf121fb8 100644
--- a/x/ibc/core/02-client/types/errors.go
+++ b/x/ibc/core/02-client/types/errors.go
@@ -32,4 +32,5 @@ var (
ErrInvalidUpgradeClient = sdkerrors.Register(SubModuleName, 25, "invalid client upgrade")
ErrInvalidHeight = sdkerrors.Register(SubModuleName, 26, "invalid height")
ErrInvalidSubstitute = sdkerrors.Register(SubModuleName, 27, "invalid client state substitute")
+ ErrInvalidProposal = sdkerrors.Register(SubModuleName, 28, "invalid upgrade proposal")
)
diff --git a/x/ibc/core/02-client/types/proposal.go b/x/ibc/core/02-client/types/proposal.go
index 95b10aaf408e..5fe8c91ccc1e 100644
--- a/x/ibc/core/02-client/types/proposal.go
+++ b/x/ibc/core/02-client/types/proposal.go
@@ -1,19 +1,30 @@
package types
import (
+ "fmt"
+
+ codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
+ "github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
+ upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
const (
// ProposalTypeClientUpdate defines the type for a ClientUpdateProposal
ProposalTypeClientUpdate = "ClientUpdate"
+ ProposalTypeUpgrade = "IBCUpgrade"
)
-var _ govtypes.Content = &ClientUpdateProposal{}
+var (
+ _ govtypes.Content = &ClientUpdateProposal{}
+ _ govtypes.Content = &UpgradeProposal{}
+ _ codectypes.UnpackInterfacesMessage = &UpgradeProposal{}
+)
func init() {
govtypes.RegisterProposalType(ProposalTypeClientUpdate)
+ govtypes.RegisterProposalType(ProposalTypeUpgrade)
}
// NewClientUpdateProposal creates a new client update proposal.
@@ -62,3 +73,70 @@ func (cup *ClientUpdateProposal) ValidateBasic() error {
return nil
}
+
+// NewUpgradeProposal creates a new IBC breaking upgrade proposal.
+func NewUpgradeProposal(title, description string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (*UpgradeProposal, error) {
+ any, err := PackClientState(upgradedClientState)
+ if err != nil {
+ return nil, err
+ }
+
+ return &UpgradeProposal{
+ Title: title,
+ Description: description,
+ Plan: plan,
+ UpgradedClientState: any,
+ }, nil
+}
+
+// GetTitle returns the title of a client update proposal.
+func (up *UpgradeProposal) GetTitle() string { return up.Title }
+
+// GetDescription returns the description of a client update proposal.
+func (up *UpgradeProposal) GetDescription() string { return up.Description }
+
+// ProposalRoute returns the routing key of a client update proposal.
+func (up *UpgradeProposal) ProposalRoute() string { return RouterKey }
+
+// ProposalType returns the upgrade proposal type.
+func (up *UpgradeProposal) ProposalType() string { return ProposalTypeUpgrade }
+
+// ValidateBasic runs basic stateless validity checks
+func (up *UpgradeProposal) ValidateBasic() error {
+ if err := govtypes.ValidateAbstract(up); err != nil {
+ return err
+ }
+
+ if err := up.Plan.ValidateBasic(); err != nil {
+ return err
+ }
+
+ if up.Plan.Time.Unix() > 0 {
+ return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
+ }
+
+ return nil
+}
+
+// String
+func (up UpgradeProposal) String() string {
+ var upgradedClientStr string
+ upgradedClient, err := UnpackClientState(up.UpgradedClientState)
+ if err != nil {
+ upgradedClientStr = "invalid IBC Client State"
+ } else {
+ upgradedClientStr = upgradedClient.String()
+ }
+
+ return fmt.Sprintf(`IBC Upgrade Proposal:
+ Title: %s
+ Description: %s
+ Plan: %s
+ UpgradedClientState: %s
+`, up.Title, up.Description, up.Plan, upgradedClientStr)
+}
+
+// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
+func (up UpgradeProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
+ return unpacker.UnpackAny(up.UpgradedClientState, new(exported.ClientState))
+}
diff --git a/x/upgrade/types/upgrade.pb.go b/x/upgrade/types/upgrade.pb.go
index 1a680b38e547..c77d90f34df8 100644
--- a/x/upgrade/types/upgrade.pb.go
+++ b/x/upgrade/types/upgrade.pb.go
@@ -4,7 +4,6 @@
package types
import (
- bytes "bytes"
fmt "fmt"
_ "github.com/cosmos/cosmos-sdk/codec/types"
_ "github.com/gogo/protobuf/gogoproto"
@@ -48,12 +47,6 @@ type Plan struct {
// Any application specific upgrade info to be included on-chain
// such as a git commit that validators could automatically upgrade to
Info string `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"`
- // IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan
- // This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs,
- // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the
- // previous version of the chain.
- // This will allow IBC connections to persist smoothly across planned chain upgrades
- UpgradedClientState []byte `protobuf:"bytes,6,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"`
}
func (m *Plan) Reset() { *m = Plan{} }
@@ -178,35 +171,32 @@ func init() {
}
var fileDescriptor_ccf2a7d4d7b48dca = []byte{
- // 434 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x31, 0x6f, 0xd4, 0x30,
- 0x18, 0x8d, 0x69, 0x1a, 0xb5, 0x3e, 0x06, 0x64, 0x4a, 0x09, 0xa7, 0xe2, 0x44, 0x11, 0xc3, 0x0d,
- 0xe0, 0xa8, 0x45, 0x42, 0xa8, 0xe3, 0x75, 0x63, 0x40, 0x55, 0x5a, 0x16, 0x24, 0x54, 0xf9, 0x12,
- 0x5f, 0xce, 0xc2, 0xb1, 0xa3, 0xd8, 0x07, 0xdc, 0xaf, 0xa0, 0x3f, 0x81, 0x9f, 0x73, 0x63, 0xc7,
- 0x4e, 0x85, 0xde, 0x2d, 0x88, 0x91, 0x5f, 0x80, 0x62, 0x27, 0x08, 0xa1, 0x1b, 0x3b, 0xf9, 0x7d,
- 0x4f, 0xef, 0x3d, 0xdb, 0xcf, 0x86, 0xcf, 0x72, 0xa5, 0x2b, 0xa5, 0xd3, 0x79, 0x5d, 0x36, 0xb4,
- 0x60, 0xe9, 0xa7, 0xc3, 0x09, 0x33, 0xf4, 0xb0, 0x9f, 0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, 0xff, 0x9b,
+ 0x57, 0x9e, 0x92, 0x70, 0x02, 0x00, 0x00,
}
func (this *Plan) Equal(that interface{}) bool {
@@ -240,9 +230,6 @@ func (this *Plan) Equal(that interface{}) bool {
if this.Info != that1.Info {
return false
}
- if !bytes.Equal(this.UpgradedClientState, that1.UpgradedClientState) {
- return false
- }
return true
}
func (this *SoftwareUpgradeProposal) Equal(that interface{}) bool {
@@ -322,13 +309,6 @@ func (m *Plan) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
- if len(m.UpgradedClientState) > 0 {
- i -= len(m.UpgradedClientState)
- copy(dAtA[i:], m.UpgradedClientState)
- i = encodeVarintUpgrade(dAtA, i, uint64(len(m.UpgradedClientState)))
- i--
- dAtA[i] = 0x32
- }
if len(m.Info) > 0 {
i -= len(m.Info)
copy(dAtA[i:], m.Info)
@@ -473,10 +453,6 @@ func (m *Plan) Size() (n int) {
if l > 0 {
n += 1 + l + sovUpgrade(uint64(l))
}
- l = len(m.UpgradedClientState)
- if l > 0 {
- n += 1 + l + sovUpgrade(uint64(l))
- }
return n
}
@@ -667,40 +643,6 @@ func (m *Plan) Unmarshal(dAtA []byte) error {
}
m.Info = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field UpgradedClientState", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowUpgrade
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthUpgrade
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthUpgrade
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.UpgradedClientState = append(m.UpgradedClientState[:0], dAtA[iNdEx:postIndex]...)
- if m.UpgradedClientState == nil {
- m.UpgradedClientState = []byte{}
- }
- iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipUpgrade(dAtA[iNdEx:])
From 99f8a76f732babe0a05d0098d38e5d54741b30f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 13:54:45 +0100
Subject: [PATCH 12/30] remove IBC from upgrade types
---
x/ibc/core/02-client/types/proposal.go | 11 +-
x/ibc/core/02-client/types/proposal_test.go | 130 ++++++++++++++++++++
x/upgrade/types/plan.go | 17 +--
x/upgrade/types/plan_test.go | 39 +-----
x/upgrade/types/proposal_test.go | 10 +-
5 files changed, 145 insertions(+), 62 deletions(-)
diff --git a/x/ibc/core/02-client/types/proposal.go b/x/ibc/core/02-client/types/proposal.go
index 5fe8c91ccc1e..6c7ac3e27ad4 100644
--- a/x/ibc/core/02-client/types/proposal.go
+++ b/x/ibc/core/02-client/types/proposal.go
@@ -28,7 +28,7 @@ func init() {
}
// NewClientUpdateProposal creates a new client update proposal.
-func NewClientUpdateProposal(title, description, subjectClientID, substituteClientID string, initialHeight Height) *ClientUpdateProposal {
+func NewClientUpdateProposal(title, description, subjectClientID, substituteClientID string, initialHeight Height) govtypes.Content {
return &ClientUpdateProposal{
Title: title,
Description: description,
@@ -75,7 +75,7 @@ func (cup *ClientUpdateProposal) ValidateBasic() error {
}
// NewUpgradeProposal creates a new IBC breaking upgrade proposal.
-func NewUpgradeProposal(title, description string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (*UpgradeProposal, error) {
+func NewUpgradeProposal(title, description string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (govtypes.Content, error) {
any, err := PackClientState(upgradedClientState)
if err != nil {
return nil, err
@@ -115,10 +115,15 @@ func (up *UpgradeProposal) ValidateBasic() error {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
}
+ cs, err := UnpackClientState(up.UpgradedClientState)
+ if err != nil {
+ return sdkerrors.Wrap(err, "failed to unpack upgraded client state")
+ }
+
return nil
}
-// String
+// String returns the string representation of the UpgradeProposal.
func (up UpgradeProposal) String() string {
var upgradedClientStr string
upgradedClient, err := UnpackClientState(up.UpgradedClientState)
diff --git a/x/ibc/core/02-client/types/proposal_test.go b/x/ibc/core/02-client/types/proposal_test.go
index 597e5cf8f801..fad9256d98d1 100644
--- a/x/ibc/core/02-client/types/proposal_test.go
+++ b/x/ibc/core/02-client/types/proposal_test.go
@@ -1,12 +1,17 @@
package types_test
import (
+ "fmt"
+ "time"
+
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
+ ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
+ upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
func (suite *TypesTestSuite) TestValidateBasic() {
@@ -84,3 +89,128 @@ func (suite *TypesTestSuite) TestMarshalClientUpdateProposalProposal() {
err = cdc.UnmarshalJSON(bz, newProposal)
suite.Require().NoError(err)
}
+
+func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
+ var (
+ proposal govtypes.Content
+ err error
+ )
+
+ client, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
+ cs := suite.chainA.GetClientState(client)
+ plan := upgradetypes.Plan{
+ Name: "ibc upgrade",
+ Height: 1000,
+ }
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "success", func() {
+ proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, cs)
+ suite.Require().NoError(err)
+ }, true,
+ },
+ {
+ "fails validate abstract - empty title", func() {
+ proposal, err = types.NewUpgradeProposal("", ibctesting.Description, plan, cs)
+ suite.Require().NoError(err)
+
+ }, false,
+ },
+ {
+ "fails plan validate basic, height and time is 0", func() {
+ invalidPlan := upgradetypes.Plan{Name: "ibc upgrade"}
+ proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
+ suite.Require().NoError(err)
+ }, false,
+ },
+ {
+ "plan time is not set to 0", func() {
+ invalidPlan := upgradetypes.Plan{Name: "ibc upgrade", Time: time.Now()}
+ types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
+ suite.Require().NoError(err)
+
+ }, false,
+ },
+ {
+ "failed to unpack client state", func() {
+ any, err := types.PackConsensusState(&ibctmtypes.ConsensusState{})
+ suite.Require().NoError(err)
+
+ proposal = &types.UpgradeProposal{
+ Title: ibctesting.Title,
+ Description: ibctesting.Description,
+ Plan: plan,
+ UpgradedClientState: any,
+ }
+ }, false,
+ },
+ }
+
+ for _, tc := range testCases {
+
+ err := proposal.ValidateBasic()
+
+ if tc.expPass {
+ suite.Require().NoError(err, tc.name)
+ } else {
+ suite.Require().Error(err, tc.name)
+ }
+ }
+}
+
+// tests an upgrade proposal can be marshaled and unmarshaled, and the
+// client state can be unpacked
+func (suite *TypesTestSuite) TestMarshalSoftwareUpdateProposal() {
+ // create proposal
+ plan := upgradetypes.Plan{
+ Name: "upgrade ibc",
+ Height: 1000,
+ }
+ content, err := types.NewUpgradeProposal("title", "description", plan, &ibctmtypes.ClientState{})
+ suite.Require().NoError(err)
+
+ up, ok := content.(*types.UpgradeProposal)
+ suite.Require().True(ok)
+
+ // create codec
+ ir := codectypes.NewInterfaceRegistry()
+ types.RegisterInterfaces(ir)
+ types.RegisterInterfaces(ir)
+ govtypes.RegisterInterfaces(ir)
+ ibctmtypes.RegisterInterfaces(ir)
+ cdc := codec.NewProtoCodec(ir)
+
+ // marshal message
+ bz, err := cdc.MarshalJSON(up)
+ suite.Require().NoError(err)
+
+ // unmarshal proposal
+ newUp := &types.UpgradeProposal{}
+ err = cdc.UnmarshalJSON(bz, newUp)
+ suite.Require().NoError(err)
+
+ // unpack client state
+ _, err = types.UnpackClientState(newUp.UpgradedClientState)
+ suite.Require().NoError(err)
+
+}
+
+func (suite *TypesTestSuite) TestUpgradeString() {
+ plan := upgradetypes.Plan{
+ Name: "ibc upgrade",
+ Info: "https://foo.bar/baz",
+ Height: 1000,
+ }
+
+ proposal, err := types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, &ibctmtypes.ClientState{})
+ suite.Require().NoError(err)
+
+ expect := fmt.Sprintf("Upgrade Plan\n Name: ibc upgrade\n Height: 1000\n Info: https://foo.bar/baz.\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{})
+
+ suite.Require().Equal(expect, proposal.String())
+}
diff --git a/x/upgrade/types/plan.go b/x/upgrade/types/plan.go
index e5a979299a01..9b0c42aba748 100644
--- a/x/upgrade/types/plan.go
+++ b/x/upgrade/types/plan.go
@@ -12,17 +12,10 @@ import (
func (p Plan) String() string {
due := p.DueAt()
dueUp := strings.ToUpper(due[0:1]) + due[1:]
- var upgradedClientStr string
- if len(p.UpgradedClientState) == 0 {
- upgradedClientStr = "no upgraded client provided"
- } else {
- upgradedClientStr = string(p.UpgradedClientState)
- }
return fmt.Sprintf(`Upgrade Plan
Name: %s
%s
- Info: %s.
- Upgraded IBC Client: %s`, p.Name, dueUp, p.Info, upgradedClientStr)
+ Info: %s`, p.Name, dueUp, p.Info)
}
// ValidateBasic does basic validation of a Plan
@@ -39,9 +32,6 @@ func (p Plan) ValidateBasic() error {
if p.Time.Unix() > 0 && p.Height != 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "cannot set both time and height")
}
- if p.Time.Unix() > 0 && len(p.UpgradedClientState) != 0 {
- return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "IBC chain upgrades must only set height")
- }
return nil
}
@@ -64,8 +54,3 @@ func (p Plan) DueAt() string {
}
return fmt.Sprintf("height: %d", p.Height)
}
-
-// IsIBCPlan will return true if plan includes IBC client information
-func (p Plan) IsIBCPlan() bool {
- return len(p.UpgradedClientState) != 0
-}
diff --git a/x/upgrade/types/plan_test.go b/x/upgrade/types/plan_test.go
index 1438a390894a..61f2d84cd0b7 100644
--- a/x/upgrade/types/plan_test.go
+++ b/x/upgrade/types/plan_test.go
@@ -1,7 +1,6 @@
package types_test
import (
- "fmt"
"testing"
"time"
@@ -24,8 +23,6 @@ func mustParseTime(s string) time.Time {
}
func TestPlanString(t *testing.T) {
- clientStateBz := []byte("IBC client state")
-
cases := map[string]struct {
p types.Plan
expect string
@@ -36,7 +33,7 @@ func TestPlanString(t *testing.T) {
Info: "https://foo.bar",
Time: mustParseTime("2019-07-08T11:33:55Z"),
},
- expect: "Upgrade Plan\n Name: due_time\n Time: 2019-07-08T11:33:55Z\n Info: https://foo.bar.\n Upgraded IBC Client: no upgraded client provided",
+ expect: "Upgrade Plan\n Name: due_time\n Time: 2019-07-08T11:33:55Z\n Info: https://foo.bar",
},
"with height": {
p: types.Plan{
@@ -44,23 +41,13 @@ func TestPlanString(t *testing.T) {
Info: "https://foo.bar/baz",
Height: 7890,
},
- expect: "Upgrade Plan\n Name: by height\n Height: 7890\n Info: https://foo.bar/baz.\n Upgraded IBC Client: no upgraded client provided",
- },
- "with IBC client": {
- p: types.Plan{
- Name: "by height",
- Info: "https://foo.bar/baz",
- Height: 7890,
- UpgradedClientState: clientStateBz,
- },
- expect: fmt.Sprintf("Upgrade Plan\n Name: by height\n Height: 7890\n Info: https://foo.bar/baz.\n Upgraded IBC Client: %s", clientStateBz),
+ expect: "Upgrade Plan\n Name: by height\n Height: 7890\n Info: https://foo.bar/baz",
},
-
"neither": {
p: types.Plan{
Name: "almost-empty",
},
- expect: "Upgrade Plan\n Name: almost-empty\n Height: 0\n Info: .\n Upgraded IBC Client: no upgraded client provided",
+ expect: "Upgrade Plan\n Name: almost-empty\n Height: 0\n Info: ",
},
}
@@ -74,8 +61,6 @@ func TestPlanString(t *testing.T) {
}
func TestPlanValid(t *testing.T) {
- clientStateBz := []byte("IBC client state")
-
cases := map[string]struct {
p types.Plan
valid bool
@@ -88,15 +73,6 @@ func TestPlanValid(t *testing.T) {
},
valid: true,
},
- "proper ibc upgrade": {
- p: types.Plan{
- Name: "ibc-all-good",
- Info: "some text here",
- Height: 123450000,
- UpgradedClientState: clientStateBz,
- },
- valid: true,
- },
"proper by height": {
p: types.Plan{
Name: "all-good",
@@ -121,15 +97,6 @@ func TestPlanValid(t *testing.T) {
Height: -12345,
},
},
- "time due date defined for IBC plan": {
- p: types.Plan{
- Name: "ibc-all-good",
- Info: "some text here",
- Time: mustParseTime("2019-07-08T11:33:55Z"),
- UpgradedClientState: clientStateBz,
- },
- valid: false,
- },
}
for name, tc := range cases {
diff --git a/x/upgrade/types/proposal_test.go b/x/upgrade/types/proposal_test.go
index c9ca12ca8bab..4f5ed16a82fa 100644
--- a/x/upgrade/types/proposal_test.go
+++ b/x/upgrade/types/proposal_test.go
@@ -77,16 +77,12 @@ func TestContentAccessors(t *testing.T) {
}
}
-// tests a software update proposal can be marshaled and unmarshaled, and the
-// client state can be unpacked
+// tests a software update proposal can be marshaled and unmarshaled
func TestMarshalSoftwareUpdateProposal(t *testing.T) {
- clientStateBz := []byte("IBC client state")
-
// create proposal
plan := types.Plan{
- Name: "upgrade ibc",
- Height: 1000,
- UpgradedClientState: clientStateBz,
+ Name: "upgrade",
+ Height: 1000,
}
content := types.NewSoftwareUpgradeProposal("title", "description", plan)
sup, ok := content.(*types.SoftwareUpgradeProposal)
From 973cef5efd94b779108323ede51de21d68c7a3fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 14:22:34 +0100
Subject: [PATCH 13/30] add IBC upgrade logic to 02-client
---
x/ibc/core/02-client/abci.go | 3 +-
x/ibc/core/02-client/keeper/keeper.go | 7 +++-
x/ibc/core/02-client/keeper/proposal.go | 32 +++++++++++++++++++
x/ibc/core/02-client/proposal_handler.go | 2 ++
x/ibc/core/02-client/types/errors.go | 2 +-
.../core/02-client/types/expected_keepers.go | 4 +++
x/ibc/core/02-client/types/proposal.go | 2 +-
x/upgrade/keeper/grpc_query.go | 6 ++--
x/upgrade/keeper/keeper.go | 30 ++++-------------
9 files changed, 58 insertions(+), 30 deletions(-)
diff --git a/x/ibc/core/02-client/abci.go b/x/ibc/core/02-client/abci.go
index 106e04933b95..b83274c2e3b1 100644
--- a/x/ibc/core/02-client/abci.go
+++ b/x/ibc/core/02-client/abci.go
@@ -17,7 +17,8 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
// Set the time to the last block time of the current chain.
// In order for a client to upgrade successfully, the first block of the new chain must be committed
// within the trusting period of the last block time on this chain.
- if plan.IsIBCPlan() && ctx.BlockHeight() == plan.Height-1 {
+ _, exists := k.GetUpgradedClient(ctx, plan.Height-1)
+ if exists && ctx.BlockHeight() == plan.Height-1 {
upgradedConsState := &ibctmtypes.ConsensusState{
Timestamp: ctx.BlockTime(),
NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
diff --git a/x/ibc/core/02-client/keeper/keeper.go b/x/ibc/core/02-client/keeper/keeper.go
index 9ed509fde3be..43ac1feb3523 100644
--- a/x/ibc/core/02-client/keeper/keeper.go
+++ b/x/ibc/core/02-client/keeper/keeper.go
@@ -334,7 +334,12 @@ func (k Keeper) GetUpgradePlan(ctx sdk.Context) (plan upgradetypes.Plan, havePla
return k.upgradeKeeper.GetUpgradePlan(ctx)
}
-// GetUpgradedConsensusState executes the upgrade keeper SetUpgradedConsensusState function.
+// GetUpgradedClient executes the upgrade keeper GetUpgradeClient function.
+func (k Keeper) GetUpgradedClient(ctx sdk.Context, planHeight int64) ([]byte, bool) {
+ return k.upgradeKeeper.GetUpgradedClient(ctx, planHeight)
+}
+
+// SetUpgradedConsensusState executes the upgrade keeper SetUpgradedConsensusState function.
func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error {
return k.upgradeKeeper.SetUpgradedConsensusState(ctx, planHeight, bz)
}
diff --git a/x/ibc/core/02-client/keeper/proposal.go b/x/ibc/core/02-client/keeper/proposal.go
index 6d4ff350df32..7165a611f6c6 100644
--- a/x/ibc/core/02-client/keeper/proposal.go
+++ b/x/ibc/core/02-client/keeper/proposal.go
@@ -70,3 +70,35 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
return nil
}
+
+// UpgradeProposal sets the upgraded client state in the upgrade store. It clears
+// an IBC client state and consensus state if a previous plan was set. Then it
+// will schedule an upgrade and finally set the upgraded client state in upgrade
+// store.
+func (k Keeper) UpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) error {
+ // clear any old IBC state stored by previous plan
+ oldPlan, exists := k.GetUpgradePlan(ctx)
+ if exists {
+ k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height-1)
+ }
+
+ clientState, err := types.UnpackClientState(p.UpgradedClientState)
+ if err != nil {
+ return sdkerrors.Wrap(err, "could not unpack UpgradedClientState")
+ }
+
+ // zero out any custom fields before setting
+ cs := clientState.ZeroCustomFields()
+ bz, err := types.MarshalClientState(k.cdc, cs)
+ if err != nil {
+ return sdkerrors.Wrap(err, "could not marshal UpgradedClientState")
+ }
+
+ if err := k.upgradeKeeper.ScheduleUpgrade(ctx, p.Plan); err != nil {
+ return err
+ }
+
+ // sets the new upgraded client in last height committed on this chain is at plan.Height,
+ // since the chain will panic at plan.Height and new chain will resume at plan.Height
+ return k.upgradeKeeper.SetUpgradedClient(ctx, p.Plan.Height, bz)
+}
diff --git a/x/ibc/core/02-client/proposal_handler.go b/x/ibc/core/02-client/proposal_handler.go
index befa95df642f..2f8fb1b8a7b4 100644
--- a/x/ibc/core/02-client/proposal_handler.go
+++ b/x/ibc/core/02-client/proposal_handler.go
@@ -14,6 +14,8 @@ func NewClientUpdateProposalHandler(k keeper.Keeper) govtypes.Handler {
switch c := content.(type) {
case *types.ClientUpdateProposal:
return k.ClientUpdateProposal(ctx, c)
+ case *types.UpgradeProposal:
+ return k.UpgradeProposal(ctx, c)
default:
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized ibc proposal content type: %T", c)
diff --git a/x/ibc/core/02-client/types/errors.go b/x/ibc/core/02-client/types/errors.go
index 08bdbf121fb8..8a956f868730 100644
--- a/x/ibc/core/02-client/types/errors.go
+++ b/x/ibc/core/02-client/types/errors.go
@@ -32,5 +32,5 @@ var (
ErrInvalidUpgradeClient = sdkerrors.Register(SubModuleName, 25, "invalid client upgrade")
ErrInvalidHeight = sdkerrors.Register(SubModuleName, 26, "invalid height")
ErrInvalidSubstitute = sdkerrors.Register(SubModuleName, 27, "invalid client state substitute")
- ErrInvalidProposal = sdkerrors.Register(SubModuleName, 28, "invalid upgrade proposal")
+ ErrInvalidUpgradeProposal = sdkerrors.Register(SubModuleName, 28, "invalid upgrade proposal")
)
diff --git a/x/ibc/core/02-client/types/expected_keepers.go b/x/ibc/core/02-client/types/expected_keepers.go
index f960e6251ba7..ad007fb8011c 100644
--- a/x/ibc/core/02-client/types/expected_keepers.go
+++ b/x/ibc/core/02-client/types/expected_keepers.go
@@ -16,6 +16,10 @@ type StakingKeeper interface {
// UpgradeKeeper expected upgrade keeper
type UpgradeKeeper interface {
+ ClearIBCState(ctx sdk.Context, lastHeight int64)
GetUpgradePlan(ctx sdk.Context) (plan upgradetypes.Plan, havePlan bool)
+ GetUpgradedClient(ctx sdk.Context, height int64) ([]byte, bool)
SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error
+ SetUpgradedClient(ctx sdk.Context, planHeight int64, bz []byte) error
+ ScheduleUpgrade(ctx sdk.Context, plan upgradetypes.Plan) error
}
diff --git a/x/ibc/core/02-client/types/proposal.go b/x/ibc/core/02-client/types/proposal.go
index 6c7ac3e27ad4..8ec7f1db7da7 100644
--- a/x/ibc/core/02-client/types/proposal.go
+++ b/x/ibc/core/02-client/types/proposal.go
@@ -115,7 +115,7 @@ func (up *UpgradeProposal) ValidateBasic() error {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
}
- cs, err := UnpackClientState(up.UpgradedClientState)
+ _, err := UnpackClientState(up.UpgradedClientState)
if err != nil {
return sdkerrors.Wrap(err, "failed to unpack upgraded client state")
}
diff --git a/x/upgrade/keeper/grpc_query.go b/x/upgrade/keeper/grpc_query.go
index 262c32af1f20..a1fdbcd14762 100644
--- a/x/upgrade/keeper/grpc_query.go
+++ b/x/upgrade/keeper/grpc_query.go
@@ -37,9 +37,9 @@ func (k Keeper) AppliedPlan(c context.Context, req *types.QueryAppliedPlanReques
func (k Keeper) UpgradedConsensusState(c context.Context, req *types.QueryUpgradedConsensusStateRequest) (*types.QueryUpgradedConsensusStateResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
- consState, err := k.GetUpgradedConsensusState(ctx, req.LastHeight)
- if err != nil {
- return nil, err
+ consState, exists := k.GetUpgradedConsensusState(ctx, req.LastHeight)
+ if !exists {
+ return &types.QueryUpgradedConsensusStateResponse{}, nil
}
return &types.QueryUpgradedConsensusStateResponse{
diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go
index f7e5c85a013a..bb2d7d36d7c2 100644
--- a/x/upgrade/keeper/keeper.go
+++ b/x/upgrade/keeper/keeper.go
@@ -72,21 +72,9 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error {
store := ctx.KVStore(k.storeKey)
- // clear any old IBC state stored by previous plan
- oldPlan, exists := k.GetUpgradePlan(ctx)
- if exists && oldPlan.IsIBCPlan() {
- k.ClearIBCState(ctx, oldPlan.Height-1)
- }
-
bz := k.cdc.MustMarshalBinaryBare(&plan)
store.Set(types.PlanKey(), bz)
- if plan.IsIBCPlan() {
- // Set UpgradedClientState in store
- // sets the new upgraded client in last height committed on this chain is at plan.Height,
- // since the chain will panic at plan.Height and new chain will resume at plan.Height
- return k.SetUpgradedClient(ctx, plan.Height, plan.UpgradedClientState)
- }
return nil
}
@@ -98,15 +86,14 @@ func (k Keeper) SetUpgradedClient(ctx sdk.Context, planHeight int64, bz []byte)
}
// GetUpgradedClient gets the expected upgraded client for the next version of this chain
-func (k Keeper) GetUpgradedClient(ctx sdk.Context, height int64) ([]byte, error) {
+func (k Keeper) GetUpgradedClient(ctx sdk.Context, height int64) ([]byte, bool) {
store := ctx.KVStore(k.storeKey)
-
bz := store.Get(types.UpgradedClientKey(height))
if len(bz) == 0 {
- return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "upgraded client not found in store for height %d", height)
+ return nil, false
}
- return bz, nil
+ return bz, true
}
// SetUpgradedConsensusState set the expected upgraded consensus state for the next version of this chain
@@ -118,15 +105,14 @@ func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz
}
// GetUpgradedConsensusState set the expected upgraded consensus state for the next version of this chain
-func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, lastHeight int64) ([]byte, error) {
+func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, lastHeight int64) ([]byte, bool) {
store := ctx.KVStore(k.storeKey)
-
bz := store.Get(types.UpgradedConsStateKey(lastHeight))
if len(bz) == 0 {
- return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "upgraded consensus state not found in store for height: %d", lastHeight)
+ return nil, false
}
- return bz, nil
+ return bz, true
}
// GetDoneHeight returns the height at which the given upgrade was executed
@@ -197,9 +183,7 @@ func (k Keeper) ApplyUpgrade(ctx sdk.Context, plan types.Plan) {
// Must clear IBC state after upgrade is applied as it is stored separately from the upgrade plan.
// This will prevent resubmission of upgrade msg after upgrade is already completed.
- if plan.IsIBCPlan() {
- k.ClearIBCState(ctx, plan.Height-1)
- }
+ k.ClearIBCState(ctx, plan.Height-1)
k.ClearUpgradePlan(ctx)
k.setDone(ctx, plan.Name)
}
From c9e515bf75eb1cb123f0f041df48432a25eb8e55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 17:00:27 +0100
Subject: [PATCH 14/30] fix all tests for x/upgrade
---
proto/cosmos/upgrade/v1beta1/query.proto | 1 -
x/upgrade/abci_test.go | 65 ++---------------------
x/upgrade/keeper/keeper_test.go | 66 ++----------------------
x/upgrade/types/query.pb.go | 62 +++++++++++-----------
4 files changed, 37 insertions(+), 157 deletions(-)
diff --git a/proto/cosmos/upgrade/v1beta1/query.proto b/proto/cosmos/upgrade/v1beta1/query.proto
index 898a74febd85..0fc6fd856f8d 100644
--- a/proto/cosmos/upgrade/v1beta1/query.proto
+++ b/proto/cosmos/upgrade/v1beta1/query.proto
@@ -65,7 +65,6 @@ message QueryUpgradedConsensusStateRequest {
// RPC method.
message QueryUpgradedConsensusStateResponse {
reserved 1;
- reserved "option";
bytes upgraded_consensus_state = 2;
}
diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go
index 7b68ac9d0a21..45ae491799a8 100644
--- a/x/upgrade/abci_test.go
+++ b/x/upgrade/abci_test.go
@@ -118,43 +118,6 @@ func TestCanOverwriteScheduleUpgrade(t *testing.T) {
VerifyDoUpgrade(t)
}
-func VerifyDoIBCUpgrade(t *testing.T) {
- t.Log("Verify that a panic happens at the upgrade time/height")
- newCtx := s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1).WithBlockTime(time.Now())
- consState := []byte("consensus state")
-
- // Check IBC state is set before upgrade using last height: s.ctx.BlockHeight()
- cs, err := s.keeper.GetUpgradedClient(newCtx, s.ctx.BlockHeight()+1)
- require.NoError(t, err, "could not retrieve upgraded client before upgrade plan is applied")
- require.NotNil(t, cs, "IBC client is nil before upgrade")
-
- // set the consensus state since this happens in IBC 02-client begin blocker
- err = s.keeper.SetUpgradedConsensusState(newCtx, s.ctx.BlockHeight(), consState)
- require.NoError(t, err)
-
- req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()}
- require.Panics(t, func() {
- s.module.BeginBlock(newCtx, req)
- })
-
- t.Log("Verify that the upgrade can be successfully applied with a handler")
- s.keeper.SetUpgradeHandler("test", func(ctx sdk.Context, plan types.Plan) {})
- require.NotPanics(t, func() {
- s.module.BeginBlock(newCtx, req)
- })
-
- VerifyCleared(t, newCtx)
-
- // Check IBC state is cleared after upgrade using last height: s.ctx.BlockHeight()
- cs, err = s.keeper.GetUpgradedClient(newCtx, s.ctx.BlockHeight())
- require.Error(t, err, "retrieved upgraded client after upgrade plan is applied")
- require.Nil(t, cs, "IBC client is not-nil after upgrade")
-
- consState, err = s.keeper.GetUpgradedConsensusState(newCtx, s.ctx.BlockHeight())
- require.Error(t, err, "retrieved upgraded consensus state after upgrade plan is applied")
- require.Nil(t, consState, "IBC consensus state is not-nil after upgrade")
-}
-
func VerifyDoUpgrade(t *testing.T) {
t.Log("Verify that a panic happens at the upgrade time/height")
newCtx := s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1).WithBlockTime(time.Now())
@@ -262,25 +225,20 @@ func TestNoSpuriousUpgrades(t *testing.T) {
}
func TestPlanStringer(t *testing.T) {
- cs := []byte("IBC client state")
-
ti, err := time.Parse(time.RFC3339, "2020-01-01T00:00:00Z")
require.Nil(t, err)
require.Equal(t, `Upgrade Plan
Name: test
Time: 2020-01-01T00:00:00Z
- Info: .
- Upgraded IBC Client: no upgraded client provided`, types.Plan{Name: "test", Time: ti}.String())
+ Info: `, types.Plan{Name: "test", Time: ti}.String())
require.Equal(t, `Upgrade Plan
Name: test
Height: 100
- Info: .
- Upgraded IBC Client: no upgraded client provided`, types.Plan{Name: "test", Height: 100}.String())
+ Info: `, types.Plan{Name: "test", Height: 100}.String())
require.Equal(t, fmt.Sprintf(`Upgrade Plan
Name: test
Height: 100
- Info: .
- Upgraded IBC Client: %s`, cs), types.Plan{Name: "test", Height: 100, UpgradedClientState: cs}.String())
+ Info: `), types.Plan{Name: "test", Height: 100}.String())
}
func VerifyNotDone(t *testing.T, newCtx sdk.Context, name string) {
@@ -447,23 +405,6 @@ func TestUpgradeWithoutSkip(t *testing.T) {
VerifyDone(t, s.ctx, "test")
}
-func TestIBCUpgradeWithoutSkip(t *testing.T) {
- s := setupTest(10, map[int64]bool{})
- cs := []byte("IBC client state")
- err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{
- Title: "prop",
- Plan: types.Plan{
- Name: "test",
- Height: s.ctx.BlockHeight() + 1,
- UpgradedClientState: cs,
- },
- })
- require.Nil(t, err)
-
- VerifyDoIBCUpgrade(t)
- VerifyDone(t, s.ctx, "test")
-}
-
func TestDumpUpgradeInfoToFile(t *testing.T) {
s := setupTest(10, map[int64]bool{})
diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go
index 0df8c1a484b8..48f0301d3ff1 100644
--- a/x/upgrade/keeper/keeper_test.go
+++ b/x/upgrade/keeper/keeper_test.go
@@ -57,10 +57,6 @@ func (s *KeeperTestSuite) TestReadUpgradeInfoFromDisk() {
}
func (s *KeeperTestSuite) TestScheduleUpgrade() {
- cs := []byte("gaia IBC client state")
-
- altCs := []byte("ethermint IBC client state")
-
cases := []struct {
name string
plan types.Plan
@@ -87,17 +83,6 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() {
setup: func() {},
expPass: true,
},
- {
- name: "successful ibc schedule",
- plan: types.Plan{
- Name: "all-good",
- Info: "some text here",
- Height: 123450000,
- UpgradedClientState: cs,
- },
- setup: func() {},
- expPass: true,
- },
{
name: "successful overwrite",
plan: types.Plan{
@@ -114,41 +99,6 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() {
},
expPass: true,
},
- {
- name: "successful IBC overwrite",
- plan: types.Plan{
- Name: "all-good",
- Info: "some text here",
- Height: 123450000,
- UpgradedClientState: cs,
- },
- setup: func() {
- s.app.UpgradeKeeper.ScheduleUpgrade(s.ctx, types.Plan{
- Name: "alt-good",
- Info: "new text here",
- Height: 543210000,
- UpgradedClientState: altCs,
- })
- },
- expPass: true,
- },
- {
- name: "successful IBC overwrite with non IBC plan",
- plan: types.Plan{
- Name: "all-good",
- Info: "some text here",
- Height: 123450000,
- },
- setup: func() {
- s.app.UpgradeKeeper.ScheduleUpgrade(s.ctx, types.Plan{
- Name: "alt-good",
- Info: "new text here",
- Height: 543210000,
- UpgradedClientState: altCs,
- })
- },
- expPass: true,
- },
{
name: "unsuccessful schedule: invalid plan",
plan: types.Plan{
@@ -210,16 +160,6 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() {
if tc.expPass {
s.Require().NoError(err, "valid test case failed")
- if tc.plan.UpgradedClientState != nil {
- got, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx, tc.plan.Height)
- s.Require().NoError(err)
- s.Require().Equal(tc.plan.UpgradedClientState, got, "upgradedClient not equal to expected value")
- } else {
- // check that upgraded client is empty if latest plan does not specify an upgraded client
- got, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx, tc.plan.Height)
- s.Require().Error(err)
- s.Require().Nil(got)
- }
} else {
s.Require().Error(err, "invalid test case passed")
}
@@ -259,13 +199,13 @@ func (s *KeeperTestSuite) TestSetUpgradedClient() {
// setup test case
tc.setup()
- gotCs, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx, tc.height)
+ gotCs, exists := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx, tc.height)
if tc.exists {
s.Require().Equal(cs, gotCs, "valid case: %s did not retrieve correct client state", tc.name)
- s.Require().NoError(err, "valid case: %s returned error")
+ s.Require().True(exists, "valid case: %s did not retrieve client state", tc.name)
} else {
s.Require().Nil(gotCs, "invalid case: %s retrieved valid client state", tc.name)
- s.Require().Error(err, "invalid case: %s did not return error", tc.name)
+ s.Require().False(exists, "invalid case: %s retrieved valid client state", tc.name)
}
}
diff --git a/x/upgrade/types/query.pb.go b/x/upgrade/types/query.pb.go
index f199bfdbfc7d..936ad03b7055 100644
--- a/x/upgrade/types/query.pb.go
+++ b/x/upgrade/types/query.pb.go
@@ -316,38 +316,38 @@ func init() {
}
var fileDescriptor_4a334d07ad8374f0 = []byte{
- // 495 bytes of a gzipped FileDescriptorProto
+ // 490 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcf, 0x6b, 0x13, 0x41,
- 0x18, 0xcd, 0xc4, 0x18, 0x74, 0xe2, 0x41, 0xe6, 0x10, 0xd3, 0x50, 0xd6, 0x32, 0x16, 0x29, 0xd8,
- 0xec, 0xb4, 0xe9, 0x45, 0x14, 0x44, 0x2d, 0x16, 0x11, 0x0f, 0xba, 0xe2, 0xc5, 0x4b, 0x98, 0x64,
- 0xc7, 0xcd, 0xe2, 0x66, 0x66, 0xba, 0x33, 0x23, 0x96, 0xd2, 0x8b, 0x7f, 0x81, 0xe0, 0xdd, 0x9b,
- 0x37, 0xff, 0x10, 0x8f, 0x05, 0x2f, 0x7a, 0x93, 0xc4, 0x3f, 0x44, 0x76, 0x76, 0x22, 0x5b, 0xb2,
- 0xbb, 0x95, 0x9e, 0xf6, 0xc7, 0xf7, 0xde, 0xf7, 0xde, 0x37, 0xef, 0x1b, 0x88, 0x27, 0x42, 0xcd,
- 0x84, 0x22, 0x46, 0x46, 0x29, 0x0d, 0x19, 0x79, 0xbf, 0x3b, 0x66, 0x9a, 0xee, 0x92, 0x43, 0xc3,
- 0xd2, 0x23, 0x5f, 0xa6, 0x42, 0x0b, 0xd4, 0xcd, 0x31, 0xbe, 0xc3, 0xf8, 0x0e, 0xd3, 0x5f, 0x8b,
- 0x84, 0x88, 0x12, 0x46, 0x2c, 0x6a, 0x6c, 0xde, 0x12, 0xca, 0x1d, 0xa5, 0xbf, 0xee, 0x4a, 0x54,
- 0xc6, 0x84, 0x72, 0x2e, 0x34, 0xd5, 0xb1, 0xe0, 0xca, 0x55, 0x37, 0x2b, 0x44, 0x97, 0x02, 0x16,
- 0x85, 0xd7, 0xe0, 0x8d, 0x97, 0x99, 0x8b, 0x7d, 0x93, 0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x90, 0x43, 0x3b, 0xc8, 0x43, 0xf4, 0x80, 0xd4, 0xdf,
+ 0xc7, 0xa5, 0x25, 0x22, 0x27, 0x85, 0x35, 0x3d, 0x7d, 0x7c, 0xf8, 0x7d, 0xee, 0x81, 0xb3, 0xb9,
+ 0x07, 0x7e, 0xcf, 0x3d, 0xf0, 0x69, 0xe1, 0x35, 0xce, 0x16, 0x5e, 0xe3, 0xe7, 0xc2, 0x6b, 0xbc,
+ 0xd9, 0x09, 0x23, 0x3d, 0x35, 0x63, 0x7f, 0x22, 0x66, 0xb9, 0x46, 0xf6, 0xe8, 0xab, 0xe0, 0x1d,
+ 0xf9, 0xf0, 0x4f, 0x50, 0x1f, 0x4b, 0xa6, 0xc6, 0x6b, 0xf6, 0xde, 0xef, 0xff, 0x0d, 0x00, 0x00,
+ 0xff, 0xff, 0x32, 0x81, 0xe9, 0x7a, 0x94, 0x04, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
From 159083726d7839b0a346e6863b22a2744cc90bd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 17:18:49 +0100
Subject: [PATCH 15/30] Add CLI for IBC Upgrade Proposal
---
simapp/app.go | 4 +-
x/ibc/core/02-client/client/cli/tx.go | 90 +++++++++++++++++++
.../core/02-client/client/proposal_handler.go | 5 +-
x/ibc/core/02-client/proposal_handler.go | 4 +-
4 files changed, 99 insertions(+), 4 deletions(-)
diff --git a/simapp/app.go b/simapp/app.go
index a22ccea34008..4086585e684c 100644
--- a/simapp/app.go
+++ b/simapp/app.go
@@ -69,6 +69,7 @@ import (
ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"
ibc "github.com/cosmos/cosmos-sdk/x/ibc/core"
ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client"
+ ibcclientclient "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/client"
ibcclienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/types"
ibchost "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
@@ -120,6 +121,7 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
+ ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
@@ -310,7 +312,7 @@ func NewSimApp(
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
- AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientUpdateProposalHandler(app.IBCKeeper.ClientKeeper))
+ AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
diff --git a/x/ibc/core/02-client/client/cli/tx.go b/x/ibc/core/02-client/client/cli/tx.go
index bdaa53a8ae1e..51c78bb4e737 100644
--- a/x/ibc/core/02-client/client/cli/tx.go
+++ b/x/ibc/core/02-client/client/cli/tx.go
@@ -18,6 +18,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
+ upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
// NewCreateClientCmd defines the command to create a new IBC light client.
@@ -326,3 +327,92 @@ func NewCmdSubmitUpdateClientProposal() *cobra.Command {
return cmd
}
+
+// NewCmdSubmitUpgradeProposal implements a command handler for submitting an upgrade IBC client proposal transaction.
+func NewCmdSubmitUpgradeProposal() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "ibc-upgrade [name] [height] [path/to/upgraded_client_state.json] [flags]",
+ Args: cobra.ExactArgs(3),
+ Short: "Submit an IBC upgrade proposal",
+ Long: "Submit an IBC client breaking upgrade proposal along with an initial deposit.\n" +
+ "The client state specified is the upgraded client state representing the upgraded chain",
+ RunE: func(cmd *cobra.Command, args []string) error {
+ clientCtx, err := client.GetClientTxContext(cmd)
+ if err != nil {
+ return err
+ }
+ cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry)
+
+ title, err := cmd.Flags().GetString(govcli.FlagTitle)
+ if err != nil {
+ return err
+ }
+
+ description, err := cmd.Flags().GetString(govcli.FlagDescription)
+ if err != nil {
+ return err
+ }
+
+ name := args[0]
+
+ height, err := cmd.Flags().GetInt64(args[1])
+ if err != nil {
+ return err
+ }
+
+ plan := upgradetypes.Plan{
+ Name: name,
+ Height: height,
+ }
+
+ // attempt to unmarshal client state argument
+ var clientState exported.ClientState
+ clientContentOrFileName := args[2]
+ if err := cdc.UnmarshalInterfaceJSON([]byte(clientContentOrFileName), &clientState); err != nil {
+
+ // check for file path if JSON input is not provided
+ contents, err := ioutil.ReadFile(clientContentOrFileName)
+ if err != nil {
+ return errors.Wrap(err, "neither JSON input nor path to .json file for client state were provided")
+ }
+
+ if err := cdc.UnmarshalInterfaceJSON(contents, &clientState); err != nil {
+ return errors.Wrap(err, "error unmarshalling client state file")
+ }
+ }
+
+ content, err := types.NewUpgradeProposal(title, description, plan, clientState)
+ if err != nil {
+ return err
+ }
+
+ from := clientCtx.GetFromAddress()
+
+ depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit)
+ if err != nil {
+ return err
+ }
+ deposit, err := sdk.ParseCoinsNormalized(depositStr)
+ if err != nil {
+ return err
+ }
+
+ msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
+ if err != nil {
+ return err
+ }
+
+ if err = msg.ValidateBasic(); err != nil {
+ return err
+ }
+
+ return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
+ },
+ }
+
+ cmd.Flags().String(govcli.FlagTitle, "", "title of proposal")
+ cmd.Flags().String(govcli.FlagDescription, "", "description of proposal")
+ cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal")
+
+ return cmd
+}
diff --git a/x/ibc/core/02-client/client/proposal_handler.go b/x/ibc/core/02-client/client/proposal_handler.go
index 63585cbe50b2..c6225ed1b9f5 100644
--- a/x/ibc/core/02-client/client/proposal_handler.go
+++ b/x/ibc/core/02-client/client/proposal_handler.go
@@ -5,4 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/client/cli"
)
-var ProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdateClientProposal, nil)
+var (
+ UpdateClientProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdateClientProposal, nil)
+ UpgradeProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpgradeProposal, nil)
+)
diff --git a/x/ibc/core/02-client/proposal_handler.go b/x/ibc/core/02-client/proposal_handler.go
index 2f8fb1b8a7b4..56193d576040 100644
--- a/x/ibc/core/02-client/proposal_handler.go
+++ b/x/ibc/core/02-client/proposal_handler.go
@@ -8,8 +8,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
)
-// NewClientUpdateProposalHandler defines the client update proposal handler
-func NewClientUpdateProposalHandler(k keeper.Keeper) govtypes.Handler {
+// NewClientProposalHandler defines the 02-client proposal handler
+func NewClientProposalHandler(k keeper.Keeper) govtypes.Handler {
return func(ctx sdk.Context, content govtypes.Content) error {
switch c := content.(type) {
case *types.ClientUpdateProposal:
From 5295e586bddf68cd1a25c595f692a00ee9e1a076 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?colin=20axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 17:27:35 +0100
Subject: [PATCH 16/30] Update x/ibc/core/02-client/types/proposal_test.go
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
---
x/ibc/core/02-client/types/proposal_test.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/x/ibc/core/02-client/types/proposal_test.go b/x/ibc/core/02-client/types/proposal_test.go
index fad9256d98d1..685b7c758d07 100644
--- a/x/ibc/core/02-client/types/proposal_test.go
+++ b/x/ibc/core/02-client/types/proposal_test.go
@@ -180,7 +180,6 @@ func (suite *TypesTestSuite) TestMarshalSoftwareUpdateProposal() {
// create codec
ir := codectypes.NewInterfaceRegistry()
types.RegisterInterfaces(ir)
- types.RegisterInterfaces(ir)
govtypes.RegisterInterfaces(ir)
ibctmtypes.RegisterInterfaces(ir)
cdc := codec.NewProtoCodec(ir)
From 49924c896713830fbcaf5c847e005653c90d7601 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 17:42:48 +0100
Subject: [PATCH 17/30] add gRPC for upgraded client state
---
docs/core/proto-docs.md | 36 ++
proto/cosmos/bank/v1beta1/bank.proto | 2 +-
proto/ibc/core/client/v1/query.proto | 22 +
x/ibc/core/02-client/keeper/grpc_query.go | 43 ++
x/ibc/core/02-client/keeper/proposal.go | 4 +-
x/ibc/core/02-client/keeper/proposal_test.go | 8 +-
x/ibc/core/02-client/proposal_handler.go | 2 +-
x/ibc/core/02-client/types/query.pb.go | 541 +++++++++++++++++--
x/ibc/core/02-client/types/query.pb.gw.go | 116 ++++
9 files changed, 714 insertions(+), 60 deletions(-)
diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md
index be3342f4b446..c22e73152fe1 100644
--- a/docs/core/proto-docs.md
+++ b/docs/core/proto-docs.md
@@ -660,6 +660,8 @@
- [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse)
- [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest)
- [QueryConsensusStatesResponse](#ibc.core.client.v1.QueryConsensusStatesResponse)
+ - [QueryUpgradedClientStateRequest](#ibc.core.client.v1.QueryUpgradedClientStateRequest)
+ - [QueryUpgradedClientStateResponse](#ibc.core.client.v1.QueryUpgradedClientStateResponse)
- [Query](#ibc.core.client.v1.Query)
@@ -9548,6 +9550,39 @@ Query/ConsensusStates RPC method
+
+
+
+### QueryUpgradedClientStateRequest
+QueryUpgradedClientStateRequest is the request type for the Query/UpgradedClientState RPC
+method
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| `client_id` | [string](#string) | | client state unique identifier |
+| `plan_height` | [int64](#int64) | | plan height of the current chain must be sent in request as this is the height under which upgraded client state is stored |
+
+
+
+
+
+
+
+
+### QueryUpgradedClientStateResponse
+QueryUpgradedClientStateResponse is the response type for the Query/UpgradedClientState RPC
+method.
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | client state associated with the request identifier |
+
+
+
+
+
@@ -9567,6 +9602,7 @@ Query provides defines the gRPC querier service
| `ConsensusState` | [QueryConsensusStateRequest](#ibc.core.client.v1.QueryConsensusStateRequest) | [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse) | ConsensusState queries a consensus state associated with a client state at a given height. | GET|/ibc/core/client/v1beta1/consensus_states/{client_id}/revision/{revision_number}/height/{revision_height}|
| `ConsensusStates` | [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest) | [QueryConsensusStatesResponse](#ibc.core.client.v1.QueryConsensusStatesResponse) | ConsensusStates queries all the consensus state associated with a given client. | GET|/ibc/core/client/v1beta1/consensus_states/{client_id}|
| `ClientParams` | [QueryClientParamsRequest](#ibc.core.client.v1.QueryClientParamsRequest) | [QueryClientParamsResponse](#ibc.core.client.v1.QueryClientParamsResponse) | ClientParams queries all parameters of the ibc client. | GET|/ibc/client/v1beta1/params|
+| `UpgradedClientState` | [QueryUpgradedClientStateRequest](#ibc.core.client.v1.QueryUpgradedClientStateRequest) | [QueryUpgradedClientStateResponse](#ibc.core.client.v1.QueryUpgradedClientStateResponse) | UpgradedClientState queries an Upgraded IBC light client. | GET|/ibc/core/client/v1/upgraded_client_states/{client_id}|
diff --git a/proto/cosmos/bank/v1beta1/bank.proto b/proto/cosmos/bank/v1beta1/bank.proto
index fb9069214415..b60027c88629 100644
--- a/proto/cosmos/bank/v1beta1/bank.proto
+++ b/proto/cosmos/bank/v1beta1/bank.proto
@@ -86,5 +86,5 @@ message Metadata {
string name = 5;
// symbol is the token symbol usually shown on exchanges (eg: ATOM). This can
// be the same as the display.
- string symbol = 6;
+ string symbol = 6;
}
diff --git a/proto/ibc/core/client/v1/query.proto b/proto/ibc/core/client/v1/query.proto
index 97f3acd62752..078571dd2b2f 100644
--- a/proto/ibc/core/client/v1/query.proto
+++ b/proto/ibc/core/client/v1/query.proto
@@ -38,6 +38,11 @@ service Query {
rpc ClientParams(QueryClientParamsRequest) returns (QueryClientParamsResponse) {
option (google.api.http).get = "/ibc/client/v1beta1/params";
}
+
+ // UpgradedClientState queries an Upgraded IBC light client.
+ rpc UpgradedClientState(QueryUpgradedClientStateRequest) returns (QueryUpgradedClientStateResponse) {
+ option (google.api.http).get = "/ibc/core/client/v1/upgraded_client_states/{client_id}";
+ }
}
// QueryClientStateRequest is the request type for the Query/ClientState RPC
@@ -128,3 +133,20 @@ message QueryClientParamsResponse {
// params defines the parameters of the module.
Params params = 1;
}
+
+// QueryUpgradedClientStateRequest is the request type for the Query/UpgradedClientState RPC
+// method
+message QueryUpgradedClientStateRequest {
+ // client state unique identifier
+ string client_id = 1;
+ // plan height of the current chain must be sent in request
+ // as this is the height under which upgraded client state is stored
+ int64 plan_height = 2;
+}
+
+// QueryUpgradedClientStateResponse is the response type for the Query/UpgradedClientState RPC
+// method.
+message QueryUpgradedClientStateResponse {
+ // client state associated with the request identifier
+ google.protobuf.Any upgraded_client_state = 1;
+}
diff --git a/x/ibc/core/02-client/keeper/grpc_query.go b/x/ibc/core/02-client/keeper/grpc_query.go
index 2134427729ae..cc4b256d30e7 100644
--- a/x/ibc/core/02-client/keeper/grpc_query.go
+++ b/x/ibc/core/02-client/keeper/grpc_query.go
@@ -197,3 +197,46 @@ func (q Keeper) ClientParams(c context.Context, _ *types.QueryClientParamsReques
Params: ¶ms,
}, nil
}
+
+// UpgradedClientState implements the Query/UpgradedClientState gRPC method
+func (q Keeper) UpgradedClientState(c context.Context, req *types.QueryUpgradedClientStateRequest) (*types.QueryUpgradedClientStateResponse, error) {
+ if req == nil {
+ return nil, status.Error(codes.InvalidArgument, "empty request")
+ }
+
+ if err := host.ClientIdentifierValidator(req.ClientId); err != nil {
+ return nil, status.Error(codes.InvalidArgument, err.Error())
+ }
+
+ ctx := sdk.UnwrapSDKContext(c)
+ plan, found := q.GetUpgradePlan(ctx)
+ if !found {
+ return nil, status.Error(
+ codes.NotFound, "upgrade plan not found",
+ )
+ }
+
+ bz, found := q.GetUpgradedClient(ctx, plan.Height)
+ if !found {
+ return nil, status.Error(
+ codes.NotFound,
+ sdkerrors.Wrap(types.ErrClientNotFound, req.ClientId).Error(),
+ )
+ }
+
+ clientState, err := types.UnmarshalClientState(q.cdc, bz)
+ if err != nil {
+ return nil, status.Error(
+ codes.Internal, err.Error(),
+ )
+ }
+
+ any, err := types.PackClientState(clientState)
+ if err != nil {
+ return nil, status.Error(codes.Internal, err.Error())
+ }
+
+ return &types.QueryUpgradedClientStateResponse{
+ UpgradedClientState: any,
+ }, nil
+}
diff --git a/x/ibc/core/02-client/keeper/proposal.go b/x/ibc/core/02-client/keeper/proposal.go
index 7165a611f6c6..037bad71e7a4 100644
--- a/x/ibc/core/02-client/keeper/proposal.go
+++ b/x/ibc/core/02-client/keeper/proposal.go
@@ -71,11 +71,11 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
return nil
}
-// UpgradeProposal sets the upgraded client state in the upgrade store. It clears
+// HandleUpgradeProposal sets the upgraded client state in the upgrade store. It clears
// an IBC client state and consensus state if a previous plan was set. Then it
// will schedule an upgrade and finally set the upgraded client state in upgrade
// store.
-func (k Keeper) UpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) error {
+func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) error {
// clear any old IBC state stored by previous plan
oldPlan, exists := k.GetUpgradePlan(ctx)
if exists {
diff --git a/x/ibc/core/02-client/keeper/proposal_test.go b/x/ibc/core/02-client/keeper/proposal_test.go
index 8dbe43f7d7f7..3671dcb12221 100644
--- a/x/ibc/core/02-client/keeper/proposal_test.go
+++ b/x/ibc/core/02-client/keeper/proposal_test.go
@@ -1,7 +1,7 @@
package keeper_test
import (
- "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
+ govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
@@ -13,7 +13,7 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
subject, substitute string
subjectClientState, substituteClientState exported.ClientState
initialHeight clienttypes.Height
- content *types.ClientUpdateProposal
+ content govtypes.Content
err error
)
@@ -117,7 +117,9 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
tc.malleate()
- err = suite.chainA.App.IBCKeeper.ClientKeeper.ClientUpdateProposal(suite.chainA.GetContext(), content)
+ updateProp, ok := content.(*clienttypes.ClientUpdateProposal)
+ suite.Require().True(ok)
+ err = suite.chainA.App.IBCKeeper.ClientKeeper.ClientUpdateProposal(suite.chainA.GetContext(), updateProp)
if tc.expPass {
suite.Require().NoError(err)
diff --git a/x/ibc/core/02-client/proposal_handler.go b/x/ibc/core/02-client/proposal_handler.go
index 56193d576040..f035ca99a0cc 100644
--- a/x/ibc/core/02-client/proposal_handler.go
+++ b/x/ibc/core/02-client/proposal_handler.go
@@ -15,7 +15,7 @@ func NewClientProposalHandler(k keeper.Keeper) govtypes.Handler {
case *types.ClientUpdateProposal:
return k.ClientUpdateProposal(ctx, c)
case *types.UpgradeProposal:
- return k.UpgradeProposal(ctx, c)
+ return k.HandleUpgradeProposal(ctx, c)
default:
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized ibc proposal content type: %T", c)
diff --git a/x/ibc/core/02-client/types/query.pb.go b/x/ibc/core/02-client/types/query.pb.go
index 651becb899ae..27c5cb884140 100644
--- a/x/ibc/core/02-client/types/query.pb.go
+++ b/x/ibc/core/02-client/types/query.pb.go
@@ -583,6 +583,110 @@ func (m *QueryClientParamsResponse) GetParams() *Params {
return nil
}
+// QueryUpgradedClientStateRequest is the request type for the Query/UpgradedClientState RPC
+// method
+type QueryUpgradedClientStateRequest struct {
+ // client state unique identifier
+ ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
+ // plan height of the current chain must be sent in request
+ // as this is the height under which upgraded client state is stored
+ PlanHeight int64 `protobuf:"varint,2,opt,name=plan_height,json=planHeight,proto3" json:"plan_height,omitempty"`
+}
+
+func (m *QueryUpgradedClientStateRequest) Reset() { *m = QueryUpgradedClientStateRequest{} }
+func (m *QueryUpgradedClientStateRequest) String() string { return proto.CompactTextString(m) }
+func (*QueryUpgradedClientStateRequest) ProtoMessage() {}
+func (*QueryUpgradedClientStateRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_dc42cdfd1d52d76e, []int{10}
+}
+func (m *QueryUpgradedClientStateRequest) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *QueryUpgradedClientStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_QueryUpgradedClientStateRequest.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *QueryUpgradedClientStateRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_QueryUpgradedClientStateRequest.Merge(m, src)
+}
+func (m *QueryUpgradedClientStateRequest) XXX_Size() int {
+ return m.Size()
+}
+func (m *QueryUpgradedClientStateRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_QueryUpgradedClientStateRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_QueryUpgradedClientStateRequest proto.InternalMessageInfo
+
+func (m *QueryUpgradedClientStateRequest) GetClientId() string {
+ if m != nil {
+ return m.ClientId
+ }
+ return ""
+}
+
+func (m *QueryUpgradedClientStateRequest) GetPlanHeight() int64 {
+ if m != nil {
+ return m.PlanHeight
+ }
+ return 0
+}
+
+// QueryUpgradedClientStateResponse is the response type for the Query/UpgradedClientState RPC
+// method.
+type QueryUpgradedClientStateResponse struct {
+ // client state associated with the request identifier
+ UpgradedClientState *types.Any `protobuf:"bytes,1,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty"`
+}
+
+func (m *QueryUpgradedClientStateResponse) Reset() { *m = QueryUpgradedClientStateResponse{} }
+func (m *QueryUpgradedClientStateResponse) String() string { return proto.CompactTextString(m) }
+func (*QueryUpgradedClientStateResponse) ProtoMessage() {}
+func (*QueryUpgradedClientStateResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_dc42cdfd1d52d76e, []int{11}
+}
+func (m *QueryUpgradedClientStateResponse) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *QueryUpgradedClientStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_QueryUpgradedClientStateResponse.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *QueryUpgradedClientStateResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_QueryUpgradedClientStateResponse.Merge(m, src)
+}
+func (m *QueryUpgradedClientStateResponse) XXX_Size() int {
+ return m.Size()
+}
+func (m *QueryUpgradedClientStateResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_QueryUpgradedClientStateResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_QueryUpgradedClientStateResponse proto.InternalMessageInfo
+
+func (m *QueryUpgradedClientStateResponse) GetUpgradedClientState() *types.Any {
+ if m != nil {
+ return m.UpgradedClientState
+ }
+ return nil
+}
+
func init() {
proto.RegisterType((*QueryClientStateRequest)(nil), "ibc.core.client.v1.QueryClientStateRequest")
proto.RegisterType((*QueryClientStateResponse)(nil), "ibc.core.client.v1.QueryClientStateResponse")
@@ -594,64 +698,71 @@ func init() {
proto.RegisterType((*QueryConsensusStatesResponse)(nil), "ibc.core.client.v1.QueryConsensusStatesResponse")
proto.RegisterType((*QueryClientParamsRequest)(nil), "ibc.core.client.v1.QueryClientParamsRequest")
proto.RegisterType((*QueryClientParamsResponse)(nil), "ibc.core.client.v1.QueryClientParamsResponse")
+ proto.RegisterType((*QueryUpgradedClientStateRequest)(nil), "ibc.core.client.v1.QueryUpgradedClientStateRequest")
+ proto.RegisterType((*QueryUpgradedClientStateResponse)(nil), "ibc.core.client.v1.QueryUpgradedClientStateResponse")
}
func init() { proto.RegisterFile("ibc/core/client/v1/query.proto", fileDescriptor_dc42cdfd1d52d76e) }
var fileDescriptor_dc42cdfd1d52d76e = []byte{
- // 824 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x4f, 0xdb, 0x48,
- 0x18, 0xce, 0xf0, 0x25, 0x98, 0x04, 0xb2, 0x1a, 0xa1, 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82, 0x4d, 0xe2, 0x94, 0xdb, 0xb7, 0xba,
- 0x75, 0x72, 0xa6, 0x83, 0xd3, 0x33, 0x1d, 0x7c, 0x39, 0xd3, 0xc1, 0xd3, 0x73, 0x3d, 0x77, 0x7a,
- 0xae, 0xe7, 0x3e, 0x9e, 0xeb, 0xb9, 0x87, 0xcb, 0xae, 0x17, 0x34, 0x3a, 0x36, 0x76, 0x58, 0x93,
- 0xa8, 0xbf, 0x62, 0xf2, 0x67, 0x91, 0xd7, 0x77, 0xc9, 0xe3, 0x2b, 0x01, 0x96, 0x6a, 0x8b, 0xaa,
- 0x76, 0x70, 0xd0, 0xa2, 0xdc, 0x1e, 0x11, 0x1f, 0x81, 0x3f, 0xbf, 0x05, 0x00, 0x00, 0xff, 0xff,
- 0xa7, 0x0d, 0x7c, 0x62, 0xf5, 0x09, 0x00, 0x00,
+ // 909 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x8f, 0xdb, 0x44,
+ 0x18, 0xce, 0xec, 0x6e, 0xab, 0xed, 0x24, 0xdd, 0xa0, 0xe9, 0x02, 0xa9, 0xbb, 0x72, 0x22, 0x23,
+ 0xb5, 0x01, 0xba, 0x33, 0x4d, 0x5a, 0xba, 0x08, 0xa9, 0x48, 0x6c, 0xa5, 0xd2, 0x5e, 0xa0, 0x35,
+ 0x42, 0x48, 0x48, 0x28, 0xb2, 0x9d, 0x59, 0xc7, 0x6a, 0xe2, 0xf1, 0x7a, 0xec, 0x88, 0x55, 0xb5,
+ 0x97, 0xfe, 0x01, 0x90, 0x38, 0x72, 0xe5, 0xc4, 0x01, 0x21, 0x71, 0xe0, 0x86, 0x38, 0xa1, 0x1e,
+ 0x2b, 0xc1, 0x81, 0x13, 0xa0, 0xdd, 0xfe, 0x10, 0xe4, 0x99, 0x71, 0xd6, 0x93, 0x38, 0x5a, 0xb3,
+ 0xa2, 0xa7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6e, 0x2e, 0x4d, 0xb5, 0xfc, 0xec, 0x18,
+ 0xb7, 0xfe, 0x9b, 0x93, 0x82, 0xf9, 0xbe, 0x80, 0xf9, 0x2e, 0xba, 0x5d, 0xc2, 0x29, 0x29, 0x3d,
+ 0x32, 0x1a, 0xa9, 0xbb, 0x8f, 0x9e, 0x1d, 0x99, 0xe0, 0xf9, 0x91, 0x09, 0xfe, 0x39, 0x32, 0xc1,
+ 0xd7, 0xc7, 0x66, 0xed, 0xf9, 0xb1, 0x59, 0xfb, 0xf3, 0xd8, 0xac, 0x7d, 0xbe, 0xe3, 0x07, 0xc9,
+ 0x28, 0x75, 0xb1, 0xc7, 0x26, 0x44, 0xfd, 0x39, 0x96, 0x3f, 0xdb, 0x7c, 0xf8, 0x98, 0x7c, 0x79,
+ 0x92, 0xef, 0x46, 0x7f, 0x5b, 0xa5, 0x4c, 0x0e, 0x22, 0xca, 0xdd, 0xf3, 0xe2, 0x6c, 0xdd, 0xfc,
+ 0x37, 0x00, 0x00, 0xff, 0xff, 0x66, 0x42, 0x78, 0x90, 0x87, 0x0b, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -678,6 +789,8 @@ type QueryClient interface {
ConsensusStates(ctx context.Context, in *QueryConsensusStatesRequest, opts ...grpc.CallOption) (*QueryConsensusStatesResponse, error)
// ClientParams queries all parameters of the ibc client.
ClientParams(ctx context.Context, in *QueryClientParamsRequest, opts ...grpc.CallOption) (*QueryClientParamsResponse, error)
+ // UpgradedClientState queries an Upgraded IBC light client.
+ UpgradedClientState(ctx context.Context, in *QueryUpgradedClientStateRequest, opts ...grpc.CallOption) (*QueryUpgradedClientStateResponse, error)
}
type queryClient struct {
@@ -733,6 +846,15 @@ func (c *queryClient) ClientParams(ctx context.Context, in *QueryClientParamsReq
return out, nil
}
+func (c *queryClient) UpgradedClientState(ctx context.Context, in *QueryUpgradedClientStateRequest, opts ...grpc.CallOption) (*QueryUpgradedClientStateResponse, error) {
+ out := new(QueryUpgradedClientStateResponse)
+ err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Query/UpgradedClientState", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// QueryServer is the server API for Query service.
type QueryServer interface {
// ClientState queries an IBC light client.
@@ -747,6 +869,8 @@ type QueryServer interface {
ConsensusStates(context.Context, *QueryConsensusStatesRequest) (*QueryConsensusStatesResponse, error)
// ClientParams queries all parameters of the ibc client.
ClientParams(context.Context, *QueryClientParamsRequest) (*QueryClientParamsResponse, error)
+ // UpgradedClientState queries an Upgraded IBC light client.
+ UpgradedClientState(context.Context, *QueryUpgradedClientStateRequest) (*QueryUpgradedClientStateResponse, error)
}
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
@@ -768,6 +892,9 @@ func (*UnimplementedQueryServer) ConsensusStates(ctx context.Context, req *Query
func (*UnimplementedQueryServer) ClientParams(ctx context.Context, req *QueryClientParamsRequest) (*QueryClientParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ClientParams not implemented")
}
+func (*UnimplementedQueryServer) UpgradedClientState(ctx context.Context, req *QueryUpgradedClientStateRequest) (*QueryUpgradedClientStateResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method UpgradedClientState not implemented")
+}
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
s.RegisterService(&_Query_serviceDesc, srv)
@@ -863,6 +990,24 @@ func _Query_ClientParams_Handler(srv interface{}, ctx context.Context, dec func(
return interceptor(ctx, in, info, handler)
}
+func _Query_UpgradedClientState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(QueryUpgradedClientStateRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(QueryServer).UpgradedClientState(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/ibc.core.client.v1.Query/UpgradedClientState",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(QueryServer).UpgradedClientState(ctx, req.(*QueryUpgradedClientStateRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
var _Query_serviceDesc = grpc.ServiceDesc{
ServiceName: "ibc.core.client.v1.Query",
HandlerType: (*QueryServer)(nil),
@@ -887,6 +1032,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{
MethodName: "ClientParams",
Handler: _Query_ClientParams_Handler,
},
+ {
+ MethodName: "UpgradedClientState",
+ Handler: _Query_UpgradedClientState_Handler,
+ },
},
Streams: []grpc.StreamDesc{},
Metadata: "ibc/core/client/v1/query.proto",
@@ -1309,6 +1458,76 @@ func (m *QueryClientParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro
return len(dAtA) - i, nil
}
+func (m *QueryUpgradedClientStateRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *QueryUpgradedClientStateRequest) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *QueryUpgradedClientStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.PlanHeight != 0 {
+ i = encodeVarintQuery(dAtA, i, uint64(m.PlanHeight))
+ i--
+ dAtA[i] = 0x10
+ }
+ if len(m.ClientId) > 0 {
+ i -= len(m.ClientId)
+ copy(dAtA[i:], m.ClientId)
+ i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *QueryUpgradedClientStateResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *QueryUpgradedClientStateResponse) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *QueryUpgradedClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.UpgradedClientState != nil {
+ {
+ size, err := m.UpgradedClientState.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintQuery(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
offset -= sovQuery(v)
base := offset
@@ -1483,6 +1702,35 @@ func (m *QueryClientParamsResponse) Size() (n int) {
return n
}
+func (m *QueryUpgradedClientStateRequest) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.ClientId)
+ if l > 0 {
+ n += 1 + l + sovQuery(uint64(l))
+ }
+ if m.PlanHeight != 0 {
+ n += 1 + sovQuery(uint64(m.PlanHeight))
+ }
+ return n
+}
+
+func (m *QueryUpgradedClientStateResponse) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.UpgradedClientState != nil {
+ l = m.UpgradedClientState.Size()
+ n += 1 + l + sovQuery(uint64(l))
+ }
+ return n
+}
+
func sovQuery(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@@ -2597,6 +2845,193 @@ func (m *QueryClientParamsResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
+func (m *QueryUpgradedClientStateRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowQuery
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: QueryUpgradedClientStateRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: QueryUpgradedClientStateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowQuery
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthQuery
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthQuery
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ClientId = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PlanHeight", wireType)
+ }
+ m.PlanHeight = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowQuery
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.PlanHeight |= int64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipQuery(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthQuery
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *QueryUpgradedClientStateResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowQuery
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: QueryUpgradedClientStateResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: QueryUpgradedClientStateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field UpgradedClientState", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowQuery
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthQuery
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthQuery
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.UpgradedClientState == nil {
+ m.UpgradedClientState = &types.Any{}
+ }
+ if err := m.UpgradedClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipQuery(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthQuery
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
func skipQuery(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
diff --git a/x/ibc/core/02-client/types/query.pb.gw.go b/x/ibc/core/02-client/types/query.pb.gw.go
index 40bc6a85fdd0..9e36ecc18fde 100644
--- a/x/ibc/core/02-client/types/query.pb.gw.go
+++ b/x/ibc/core/02-client/types/query.pb.gw.go
@@ -327,6 +327,78 @@ func local_request_Query_ClientParams_0(ctx context.Context, marshaler runtime.M
}
+var (
+ filter_Query_UpgradedClientState_0 = &utilities.DoubleArray{Encoding: map[string]int{"client_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
+)
+
+func request_Query_UpgradedClientState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq QueryUpgradedClientStateRequest
+ var metadata runtime.ServerMetadata
+
+ var (
+ val string
+ ok bool
+ err error
+ _ = err
+ )
+
+ val, ok = pathParams["client_id"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id")
+ }
+
+ protoReq.ClientId, err = runtime.String(val)
+
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err)
+ }
+
+ if err := req.ParseForm(); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_UpgradedClientState_0); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UpgradedClientState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_Query_UpgradedClientState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq QueryUpgradedClientStateRequest
+ var metadata runtime.ServerMetadata
+
+ var (
+ val string
+ ok bool
+ err error
+ _ = err
+ )
+
+ val, ok = pathParams["client_id"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id")
+ }
+
+ protoReq.ClientId, err = runtime.String(val)
+
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err)
+ }
+
+ if err := req.ParseForm(); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_UpgradedClientState_0); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.UpgradedClientState(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -433,6 +505,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
})
+ mux.Handle("GET", pattern_Query_UpgradedClientState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_Query_UpgradedClientState_0(rctx, inboundMarshaler, server, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Query_UpgradedClientState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
return nil
}
@@ -574,6 +666,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
})
+ mux.Handle("GET", pattern_Query_UpgradedClientState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, mux, req)
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_Query_UpgradedClientState_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Query_UpgradedClientState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
return nil
}
@@ -587,6 +699,8 @@ var (
pattern_Query_ConsensusStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1beta1", "consensus_states", "client_id"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_ClientParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ibc", "client", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
+
+ pattern_Query_UpgradedClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "upgraded_client_states", "client_id"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
@@ -599,4 +713,6 @@ var (
forward_Query_ConsensusStates_0 = runtime.ForwardResponseMessage
forward_Query_ClientParams_0 = runtime.ForwardResponseMessage
+
+ forward_Query_UpgradedClientState_0 = runtime.ForwardResponseMessage
)
From d05fba108900672f93af2077e7501b0f7963563c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Thu, 25 Feb 2021 17:53:51 +0100
Subject: [PATCH 18/30] test fixes
---
x/ibc/core/02-client/abci.go | 2 +-
x/ibc/core/02-client/abci_test.go | 14 +++++++-------
x/ibc/core/02-client/proposal_handler_test.go | 2 +-
x/ibc/core/keeper/grpc_query.go | 5 +++++
4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/x/ibc/core/02-client/abci.go b/x/ibc/core/02-client/abci.go
index b83274c2e3b1..163e513327b8 100644
--- a/x/ibc/core/02-client/abci.go
+++ b/x/ibc/core/02-client/abci.go
@@ -17,7 +17,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
// Set the time to the last block time of the current chain.
// In order for a client to upgrade successfully, the first block of the new chain must be committed
// within the trusting period of the last block time on this chain.
- _, exists := k.GetUpgradedClient(ctx, plan.Height-1)
+ _, exists := k.GetUpgradedClient(ctx, plan.Height)
if exists && ctx.BlockHeight() == plan.Height-1 {
upgradedConsState := &ibctmtypes.ConsensusState{
Timestamp: ctx.BlockTime(),
diff --git a/x/ibc/core/02-client/abci_test.go b/x/ibc/core/02-client/abci_test.go
index e2a31dd3eb74..70150cbb322f 100644
--- a/x/ibc/core/02-client/abci_test.go
+++ b/x/ibc/core/02-client/abci_test.go
@@ -64,29 +64,29 @@ func (suite *ClientTestSuite) TestBeginBlocker() {
}
func (suite *ClientTestSuite) TestBeginBlockerConsensusState() {
- cs := []byte("IBC client state")
plan := &upgradetypes.Plan{
- Name: "test",
- Height: suite.chainA.GetContext().BlockHeight() + 1,
- UpgradedClientState: cs,
+ Name: "test",
+ Height: suite.chainA.GetContext().BlockHeight() + 1,
}
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(plan)
store.Set(upgradetypes.PlanKey(), bz)
- suite.T().Log("Verify that chain committed to consensus state on the last height it will commit")
nextValsHash := []byte("nextValsHash")
newCtx := suite.chainA.GetContext().WithBlockHeader(tmproto.Header{
Height: suite.chainA.GetContext().BlockHeight(),
NextValidatorsHash: nextValsHash,
})
+ err := suite.chainA.App.UpgradeKeeper.SetUpgradedClient(newCtx, plan.Height, []byte("client state"))
+ suite.Require().NoError(err)
+
req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()}
suite.chainA.App.BeginBlock(req)
// plan Height is at ctx.BlockHeight+1
- consState, err := suite.chainA.App.UpgradeKeeper.GetUpgradedConsensusState(newCtx, suite.chainA.GetContext().BlockHeight()+1)
- suite.Require().NoError(err)
+ consState, found := suite.chainA.App.UpgradeKeeper.GetUpgradedConsensusState(newCtx, plan.Height)
+ suite.Require().True(found)
bz, err = types.MarshalConsensusState(suite.chainA.App.AppCodec(), &ibctmtypes.ConsensusState{Timestamp: newCtx.BlockTime(), NextValidatorsHash: nextValsHash})
suite.Require().NoError(err)
suite.Require().Equal(bz, consState)
diff --git a/x/ibc/core/02-client/proposal_handler_test.go b/x/ibc/core/02-client/proposal_handler_test.go
index 41b893186d65..502da898e8a6 100644
--- a/x/ibc/core/02-client/proposal_handler_test.go
+++ b/x/ibc/core/02-client/proposal_handler_test.go
@@ -69,7 +69,7 @@ func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() {
tc.malleate()
- proposalHandler := client.NewClientUpdateProposalHandler(suite.chainA.App.IBCKeeper.ClientKeeper)
+ proposalHandler := client.NewClientProposalHandler(suite.chainA.App.IBCKeeper.ClientKeeper)
err = proposalHandler(suite.chainA.GetContext(), content)
diff --git a/x/ibc/core/keeper/grpc_query.go b/x/ibc/core/keeper/grpc_query.go
index f406d2e86f00..3db15d3c0bc7 100644
--- a/x/ibc/core/keeper/grpc_query.go
+++ b/x/ibc/core/keeper/grpc_query.go
@@ -33,6 +33,11 @@ func (q Keeper) ClientParams(c context.Context, req *clienttypes.QueryClientPara
return q.ClientKeeper.ClientParams(c, req)
}
+// UpgradedClientState implements the IBC QueryServer interface
+func (q Keeper) UpgradedClientState(c context.Context, req *clienttypes.QueryUpgradedClientStateRequest) (*clienttypes.QueryUpgradedClientStateResponse, error) {
+ return q.ClientKeeper.UpgradedClientState(c, req)
+}
+
// Connection implements the IBC QueryServer interface
func (q Keeper) Connection(c context.Context, req *connectiontypes.QueryConnectionRequest) (*connectiontypes.QueryConnectionResponse, error) {
return q.ConnectionKeeper.Connection(c, req)
From d86f0b0b645270581be0f549ec8116c96f65e1ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Fri, 26 Feb 2021 11:43:07 +0100
Subject: [PATCH 19/30] add HandleUpgradeProposal tests
---
x/ibc/core/02-client/abci_test.go | 1 +
x/ibc/core/02-client/keeper/proposal.go | 4 +-
x/ibc/core/02-client/keeper/proposal_test.go | 157 +++++++++++++++++--
3 files changed, 144 insertions(+), 18 deletions(-)
diff --git a/x/ibc/core/02-client/abci_test.go b/x/ibc/core/02-client/abci_test.go
index 70150cbb322f..3f1f6ebdc289 100644
--- a/x/ibc/core/02-client/abci_test.go
+++ b/x/ibc/core/02-client/abci_test.go
@@ -68,6 +68,7 @@ func (suite *ClientTestSuite) TestBeginBlockerConsensusState() {
Name: "test",
Height: suite.chainA.GetContext().BlockHeight() + 1,
}
+ // set upgrade plan in the upgrade store
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(plan)
store.Set(upgradetypes.PlanKey(), bz)
diff --git a/x/ibc/core/02-client/keeper/proposal.go b/x/ibc/core/02-client/keeper/proposal.go
index 037bad71e7a4..43252572697a 100644
--- a/x/ibc/core/02-client/keeper/proposal.go
+++ b/x/ibc/core/02-client/keeper/proposal.go
@@ -77,8 +77,8 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
// store.
func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) error {
// clear any old IBC state stored by previous plan
- oldPlan, exists := k.GetUpgradePlan(ctx)
- if exists {
+ oldPlan, found := k.GetUpgradePlan(ctx)
+ if found {
k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height-1)
}
diff --git a/x/ibc/core/02-client/keeper/proposal_test.go b/x/ibc/core/02-client/keeper/proposal_test.go
index 3671dcb12221..522c6959e625 100644
--- a/x/ibc/core/02-client/keeper/proposal_test.go
+++ b/x/ibc/core/02-client/keeper/proposal_test.go
@@ -2,17 +2,18 @@ package keeper_test
import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
- clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
+ "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
+ upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
func (suite *KeeperTestSuite) TestClientUpdateProposal() {
var (
subject, substitute string
subjectClientState, substituteClientState exported.ClientState
- initialHeight clienttypes.Height
+ initialHeight types.Height
content govtypes.Content
err error
)
@@ -24,7 +25,7 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
}{
{
"valid update client proposal", func() {
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
}, true,
},
{
@@ -35,52 +36,52 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
suite.Require().True(found)
newRevisionNumber := tmClientState.GetLatestHeight().GetRevisionNumber() + 1
- tmClientState.LatestHeight = clienttypes.NewHeight(newRevisionNumber, tmClientState.GetLatestHeight().GetRevisionHeight())
- initialHeight = clienttypes.NewHeight(newRevisionNumber, initialHeight.GetRevisionHeight())
+ tmClientState.LatestHeight = types.NewHeight(newRevisionNumber, tmClientState.GetLatestHeight().GetRevisionHeight())
+ initialHeight = types.NewHeight(newRevisionNumber, initialHeight.GetRevisionHeight())
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), substitute, tmClientState.LatestHeight, consState)
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), substitute, tmClientState)
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
}, true,
},
{
"cannot use localhost as subject", func() {
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, exported.Localhost, substitute, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, exported.Localhost, substitute, initialHeight)
}, false,
},
{
"cannot use localhost as substitute", func() {
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, exported.Localhost, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, exported.Localhost, initialHeight)
}, false,
},
{
"subject client does not exist", func() {
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, ibctesting.InvalidID, substitute, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, ibctesting.InvalidID, substitute, initialHeight)
}, false,
},
{
"substitute client does not exist", func() {
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, ibctesting.InvalidID, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, ibctesting.InvalidID, initialHeight)
}, false,
},
{
"subject and substitute have equal latest height", func() {
tmClientState, ok := subjectClientState.(*ibctmtypes.ClientState)
suite.Require().True(ok)
- tmClientState.LatestHeight = substituteClientState.GetLatestHeight().(clienttypes.Height)
+ tmClientState.LatestHeight = substituteClientState.GetLatestHeight().(types.Height)
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), subject, tmClientState)
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
}, false,
},
{
"update fails, client is not frozen or expired", func() {
tmClientState, ok := subjectClientState.(*ibctmtypes.ClientState)
suite.Require().True(ok)
- tmClientState.FrozenHeight = clienttypes.ZeroHeight()
+ tmClientState.FrozenHeight = types.ZeroHeight()
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), subject, tmClientState)
- content = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
+ content = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute, initialHeight)
}, false,
},
}
@@ -94,7 +95,7 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
subject, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
subjectClientState = suite.chainA.GetClientState(subject)
substitute, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
- initialHeight = clienttypes.NewHeight(subjectClientState.GetLatestHeight().GetRevisionNumber(), subjectClientState.GetLatestHeight().GetRevisionHeight()+1)
+ initialHeight = types.NewHeight(subjectClientState.GetLatestHeight().GetRevisionNumber(), subjectClientState.GetLatestHeight().GetRevisionHeight()+1)
// update substitute twice
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, substitute, exported.Tendermint)
@@ -117,7 +118,7 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
tc.malleate()
- updateProp, ok := content.(*clienttypes.ClientUpdateProposal)
+ updateProp, ok := content.(*types.ClientUpdateProposal)
suite.Require().True(ok)
err = suite.chainA.App.IBCKeeper.ClientKeeper.ClientUpdateProposal(suite.chainA.GetContext(), updateProp)
@@ -130,3 +131,127 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
}
}
+
+func (suite *KeeperTestSuite) TestHandleUpgradeProposal() {
+ var (
+ upgradedClientState *ibctmtypes.ClientState
+ oldPlan, plan upgradetypes.Plan
+ content govtypes.Content
+ err error
+ )
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "valid upgrade proposal", func() {
+ content, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, upgradedClientState)
+ suite.Require().NoError(err)
+ }, true,
+ },
+ {
+ "valid upgrade proposal with previous IBC state", func() {
+ oldPlan = upgradetypes.Plan{
+ Name: "upgrade IBC clients",
+ Height: 100,
+ }
+
+ content, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, upgradedClientState)
+ suite.Require().NoError(err)
+ }, true,
+ },
+ {
+ "cannot unpack client state", func() {
+ any, err := types.PackConsensusState(&ibctmtypes.ConsensusState{})
+ suite.Require().NoError(err)
+ content = &types.UpgradeProposal{
+ Title: ibctesting.Title,
+ Description: ibctesting.Description,
+ Plan: plan,
+ UpgradedClientState: any,
+ }
+ }, false,
+ },
+ {
+ "schedule upgrade fails - plan sets time and height", func() {
+ plan = upgradetypes.Plan{
+ Name: "invalid plan",
+ Height: 1000,
+ Time: suite.chainA.GetContext().BlockTime(),
+ }
+ content, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, upgradedClientState)
+ suite.Require().NoError(err)
+ }, false,
+ },
+ }
+
+ for _, tc := range testCases {
+ tc := tc
+
+ suite.Run(tc.name, func() {
+ suite.SetupTest() // reset
+ oldPlan.Height = 0 //reset
+
+ clientID, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
+ upgradedClientState = suite.chainA.GetClientState(clientID).ZeroCustomFields().(*ibctmtypes.ClientState)
+
+ // use height 1000 to distinguish from old plan
+ plan = upgradetypes.Plan{
+ Name: "upgrade IBC clients",
+ Height: 1000,
+ }
+
+ tc.malleate()
+
+ // set the old plan if it is not empty
+ if oldPlan.Height != 0 {
+ // set upgrade plan in the upgrade store
+ store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
+ bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(&oldPlan)
+ store.Set(upgradetypes.PlanKey(), bz)
+ }
+
+ upgradeProp, ok := content.(*types.UpgradeProposal)
+ suite.Require().True(ok)
+ err = suite.chainA.App.IBCKeeper.ClientKeeper.HandleUpgradeProposal(suite.chainA.GetContext(), upgradeProp)
+
+ if tc.expPass {
+ suite.Require().NoError(err)
+
+ // check that the correct plan is returned
+ storedPlan, found := suite.chainA.App.UpgradeKeeper.GetUpgradePlan(suite.chainA.GetContext())
+ suite.Require().True(found)
+ suite.Require().Equal(plan, storedPlan)
+
+ // check that client state was set
+ storedClientState, found := suite.chainA.App.UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), plan.Height)
+ suite.Require().True(found)
+ clientState, err := types.UnmarshalClientState(suite.chainA.App.AppCodec(), storedClientState)
+ suite.Require().NoError(err)
+ suite.Require().Equal(upgradedClientState, clientState)
+ } else {
+ suite.Require().Error(err)
+
+ // check that the new plan wasn't stored
+ storedPlan, found := suite.chainA.App.UpgradeKeeper.GetUpgradePlan(suite.chainA.GetContext())
+ if oldPlan.Height != 0 {
+ // NOTE: this is only true if the ScheduleUpgrade function
+ // returns an error before clearing the old plan
+ suite.Require().True(found)
+ suite.Require().Equal(oldPlan, storedPlan)
+ } else {
+ suite.Require().False(found)
+ suite.Require().Empty(storedPlan)
+ }
+
+ // check that client state was not set
+ _, found = suite.chainA.App.UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), plan.Height)
+ suite.Require().False(found)
+
+ }
+ })
+ }
+
+}
From 96bc1c8c79a5c893601d469544e1152cda19715f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Fri, 26 Feb 2021 12:19:09 +0100
Subject: [PATCH 20/30] update docs and remove unnecessary code
---
docs/ibc/upgrades/quick-guide.md | 8 +--
.../07-tendermint/types/upgrade.go | 20 -------
.../07-tendermint/types/upgrade_test.go | 56 -------------------
3 files changed, 4 insertions(+), 80 deletions(-)
diff --git a/docs/ibc/upgrades/quick-guide.md b/docs/ibc/upgrades/quick-guide.md
index 4717e52f44c1..d277de14faeb 100644
--- a/docs/ibc/upgrades/quick-guide.md
+++ b/docs/ibc/upgrades/quick-guide.md
@@ -30,10 +30,10 @@ Note: Since upgrades are only implemented for Tendermint clients, this doc only
If the IBC-connected chain is conducting an upgrade that will break counterparty clients, it must ensure that the upgrade is first supported by IBC using the list above and then execute the upgrade process described below in order to prevent counterparty clients from breaking.
-1. Create a `SoftwareUpgradeProposal` with an `UpgradePlan` that includes the new IBC ClientState in the `UpgradedClientState`. Note that the `UpgradePlan` must specify an upgrade height **only** (no upgrade time), and the `ClientState` should only include the fields common to all valid clients and zero out any client-customizable fields (such as TrustingPeriod).
-2. Vote on and pass the `SoftwareUpgradeProposal`
+1. Create an `UpgradeProposal` with an IBC ClientState in the `UpgradedClientState` field and a `UpgradePlan` in the `Plan` field. Note that the proposal `Plan` must specify an upgrade height **only** (no upgrade time), and the `ClientState` should only include the fields common to all valid clients and zero out any client-customizable fields (such as TrustingPeriod).
+2. Vote on and pass the `UpgradeProposal`
-Upon the `SoftwareUpgradeProposal` passing, the upgrade module will commit the UpgradedClient under the key: `upgrade/UpgradedIBCState/{upgradeHeight}/upgradedClient`. On the block right before the upgrade height, the upgrade module will also commit an initial consensus state for the next chain under the key: `upgrade/UpgradedIBCState/{upgradeHeight}/upgradedConsState`.
+Upon the `UpgradeProposal` passing, the upgrade module will commit the UpgradedClient under the key: `upgrade/UpgradedIBCState/{upgradeHeight}/upgradedClient`. On the block right before the upgrade height, the upgrade module will also commit an initial consensus state for the next chain under the key: `upgrade/UpgradedIBCState/{upgradeHeight}/upgradedConsState`.
Once the chain reaches the upgrade height and halts, a relayer can upgrade the counterparty clients to the last block of the old chain. They can then submit the proofs of the `UpgradedClient` and `UpgradedConsensusState` against this last block and upgrade the counterparty client.
@@ -51,4 +51,4 @@ Thus, the upgrade process for relayers trying to upgrade the counterparty client
The Tendermint client on the counterparty chain will verify that the upgrading chain did indeed commit to the upgraded client and upgraded consensus state at the upgrade height (since the upgrade height is included in the key). If the proofs are verified against the upgrade height, then the client will upgrade to the new client while retaining all of its client-customized fields. Thus, it will retain its old TrustingPeriod, TrustLevel, MaxClockDrift, etc; while adopting the new chain-specified fields such as UnbondingPeriod, ChainId, UpgradePath, etc. Note, this can lead to an invalid client since the old client-chosen fields may no longer be valid given the new chain-chosen fields. Upgrading chains should try to avoid these situations by not altering parameters that can break old clients. For an example, see the UnbondingPeriod example in the supported upgrades section.
-The upgraded consensus state will serve purely as a basis of trust for future `UpdateClientMsgs` and will not contain a consensus root to perform proof verification against. Thus, relayers must submit an `UpdateClientMsg` with a header from the new chain so that the connection can be used for proof verification again.
\ No newline at end of file
+The upgraded consensus state will serve purely as a basis of trust for future `UpdateClientMsgs` and will not contain a consensus root to perform proof verification against. Thus, relayers must submit an `UpdateClientMsg` with a header from the new chain so that the connection can be used for proof verification again.
diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade.go b/x/ibc/light-clients/07-tendermint/types/upgrade.go
index d726a23d821b..5cb8e17c2dcf 100644
--- a/x/ibc/light-clients/07-tendermint/types/upgrade.go
+++ b/x/ibc/light-clients/07-tendermint/types/upgrade.go
@@ -2,7 +2,6 @@ package types
import (
"fmt"
- "reflect"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -54,13 +53,6 @@ func (cs ClientState) VerifyUpgradeAndUpdateState(
&ConsensusState{}, upgradedConsState)
}
- // counterparty chain must commit the upgraded client with all client-customizable fields zeroed out
- // at the upgrade path specified by current client
- // counterparty must also commit to the upgraded consensus state at a sub-path under the upgrade path specified
- if !ZeroedCustomFields(tmUpgradeClient) {
- return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClient, "upgraded client has non-nil custom fields")
- }
-
// unmarshal proofs
var merkleProofClient, merkleProofConsState commitmenttypes.MerkleProof
if err := cdc.UnmarshalBinaryBare(proofUpgradeClient, &merkleProofClient); err != nil {
@@ -161,15 +153,3 @@ func constructUpgradeConsStateMerklePath(upgradePath []string, lastHeight export
consPath = append(consPath, appendedKey)
return commitmenttypes.NewMerklePath(consPath...)
}
-
-// ZeroedCustomFields returns true if all the client state fields have
-// been zeroed out.
-func ZeroedCustomFields(clientStateA *ClientState) bool {
- // construct a zeroed custom fields copy of the client state
- clientStateB, ok := clientStateA.ZeroCustomFields().(*ClientState)
- if !ok {
- return false
- }
-
- return reflect.DeepEqual(clientStateA, clientStateB)
-}
diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
index fa571d4ba10e..8a7623f94301 100644
--- a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
+++ b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go
@@ -472,59 +472,3 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
}
}
}
-
-func (suite *TendermintTestSuite) TestZeroedCustomFields() {
- var (
- clientState *types.ClientState
- )
-
- testCases := []struct {
- name string
- malleate func()
- expPass bool
- }{
- {
- "client state is zeroed", func() {
- }, true,
- },
- {
- "client state has true Allow... booleans", func() {
- clientState.ZeroCustomFields()
- clientState.AllowUpdateAfterExpiry = true
- clientState.AllowUpdateAfterMisbehaviour = true
- }, false,
- },
- {
- "client state has non-zero trusting period ", func() {
- clientState.TrustingPeriod = 100
- }, false,
- },
- {
- "client state has non-zero max clock drift", func() {
- clientState.MaxClockDrift = 100
- }, false,
- },
- {
- "client state has non-zero trust level", func() {
- clientState.TrustLevel = types.DefaultTrustLevel
- }, false,
- },
- }
-
- for _, tc := range testCases {
- tc := tc
-
- suite.Run(tc.name, func() {
- suite.SetupTest() // reset
-
- client, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
- clientState = suite.chainA.GetClientState(client).(*types.ClientState)
- clientState = clientState.ZeroCustomFields().(*types.ClientState)
-
- tc.malleate()
-
- suite.Require().Equal(tc.expPass, types.ZeroedCustomFields(clientState))
-
- })
- }
-}
From b1fc663ddbd3f9f8ebbc3b80494d2873c06729b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Fri, 26 Feb 2021 13:15:00 +0100
Subject: [PATCH 21/30] self review bug and test fixes
---
CHANGELOG.md | 2 +-
x/ibc/core/02-client/keeper/proposal.go | 2 +-
x/ibc/core/02-client/keeper/proposal_test.go | 8 ++++++++
x/ibc/core/02-client/types/proposal.go | 21 +++++++++++---------
x/ibc/core/02-client/types/proposal_test.go | 19 +++++++++++++++---
x/upgrade/keeper/keeper.go | 2 +-
6 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48762d15ffff..697e68f1c811 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,7 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/distribution) [\#8473](https://github.com/cosmos/cosmos-sdk/pull/8473) On genesis init, if the distribution module account balance, coming from bank module state, does not match the one in distribution module state, the initialization will panic.
* (client/keys) [\#8500](https://github.com/cosmos/cosmos-sdk/pull/8500) `InfoImporter` interface is removed from legacy keybase.
* [\#8629](https://github.com/cosmos/cosmos-sdk/pull/8629) Deprecated `SetFullFundraiserPath` from `Config` in favor of `SetPurpose` and `SetCoinType`.
-* (x/upgrade) [\#8673](https://github.com/cosmos/cosmos-sdk/pull/8673) Remove x/ibc imports from x/upgrade by replacing plan.UpgradedClient with a `[]byte` instead of using an `Any`. IBC upgrade begin blocker logic moved to the IBC module.
+* (x/upgrade) [\#8673](https://github.com/cosmos/cosmos-sdk/pull/8673) Remove IBC logic from x/upgrade. Deprecates IBC fields in an Upgrade Plan. IBC upgrade logic moved to 02-client and an IBC UpgradeProposal is added.
### State Machine Breaking
diff --git a/x/ibc/core/02-client/keeper/proposal.go b/x/ibc/core/02-client/keeper/proposal.go
index 43252572697a..1d15f7419dc5 100644
--- a/x/ibc/core/02-client/keeper/proposal.go
+++ b/x/ibc/core/02-client/keeper/proposal.go
@@ -79,7 +79,7 @@ func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal)
// clear any old IBC state stored by previous plan
oldPlan, found := k.GetUpgradePlan(ctx)
if found {
- k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height-1)
+ k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height)
}
clientState, err := types.UnpackClientState(p.UpgradedClientState)
diff --git a/x/ibc/core/02-client/keeper/proposal_test.go b/x/ibc/core/02-client/keeper/proposal_test.go
index 522c6959e625..82d7e120dbcf 100644
--- a/x/ibc/core/02-client/keeper/proposal_test.go
+++ b/x/ibc/core/02-client/keeper/proposal_test.go
@@ -211,6 +211,10 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() {
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(&oldPlan)
store.Set(upgradetypes.PlanKey(), bz)
+
+ bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState)
+ suite.Require().NoError(err)
+ suite.chainA.App.UpgradeKeeper.SetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height, bz)
}
upgradeProp, ok := content.(*types.UpgradeProposal)
@@ -225,6 +229,10 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() {
suite.Require().True(found)
suite.Require().Equal(plan, storedPlan)
+ // check that old upgraded client state is cleared
+ _, found = suite.chainA.App.UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height)
+ suite.Require().False(found)
+
// check that client state was set
storedClientState, found := suite.chainA.App.UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), plan.Height)
suite.Require().True(found)
diff --git a/x/ibc/core/02-client/types/proposal.go b/x/ibc/core/02-client/types/proposal.go
index 8ec7f1db7da7..efddfb2df8a4 100644
--- a/x/ibc/core/02-client/types/proposal.go
+++ b/x/ibc/core/02-client/types/proposal.go
@@ -89,13 +89,13 @@ func NewUpgradeProposal(title, description string, plan upgradetypes.Plan, upgra
}, nil
}
-// GetTitle returns the title of a client update proposal.
+// GetTitle returns the title of a upgrade proposal.
func (up *UpgradeProposal) GetTitle() string { return up.Title }
-// GetDescription returns the description of a client update proposal.
+// GetDescription returns the description of a upgrade proposal.
func (up *UpgradeProposal) GetDescription() string { return up.Description }
-// ProposalRoute returns the routing key of a client update proposal.
+// ProposalRoute returns the routing key of a upgrade proposal.
func (up *UpgradeProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the upgrade proposal type.
@@ -115,6 +115,10 @@ func (up *UpgradeProposal) ValidateBasic() error {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
}
+ if up.UpgradedClientState == nil {
+ return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "upgraded client state cannot be nil")
+ }
+
_, err := UnpackClientState(up.UpgradedClientState)
if err != nil {
return sdkerrors.Wrap(err, "failed to unpack upgraded client state")
@@ -133,12 +137,11 @@ func (up UpgradeProposal) String() string {
upgradedClientStr = upgradedClient.String()
}
- return fmt.Sprintf(`IBC Upgrade Proposal:
- Title: %s
- Description: %s
- Plan: %s
- UpgradedClientState: %s
-`, up.Title, up.Description, up.Plan, upgradedClientStr)
+ return fmt.Sprintf(`IBC Upgrade Proposal
+ Title: %s
+ Description: %s
+ %s
+ Upgraded IBC Client: %s`, up.Title, up.Description, up.Plan, upgradedClientStr)
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
diff --git a/x/ibc/core/02-client/types/proposal_test.go b/x/ibc/core/02-client/types/proposal_test.go
index 685b7c758d07..d4e58b3bed03 100644
--- a/x/ibc/core/02-client/types/proposal_test.go
+++ b/x/ibc/core/02-client/types/proposal_test.go
@@ -81,7 +81,8 @@ func (suite *TypesTestSuite) TestMarshalClientUpdateProposalProposal() {
cdc := codec.NewProtoCodec(ir)
// marshal message
- bz, err := cdc.MarshalJSON(proposal)
+ content := proposal.(*types.ClientUpdateProposal)
+ bz, err := cdc.MarshalJSON(content)
suite.Require().NoError(err)
// unmarshal proposal
@@ -131,11 +132,21 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
{
"plan time is not set to 0", func() {
invalidPlan := upgradetypes.Plan{Name: "ibc upgrade", Time: time.Now()}
- types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
+ proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
suite.Require().NoError(err)
}, false,
},
+ {
+ "client state is nil", func() {
+ proposal = &types.UpgradeProposal{
+ Title: ibctesting.Title,
+ Description: ibctesting.Description,
+ Plan: plan,
+ UpgradedClientState: nil,
+ }
+ }, false,
+ },
{
"failed to unpack client state", func() {
any, err := types.PackConsensusState(&ibctmtypes.ConsensusState{})
@@ -153,6 +164,8 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
for _, tc := range testCases {
+ tc.malleate()
+
err := proposal.ValidateBasic()
if tc.expPass {
@@ -209,7 +222,7 @@ func (suite *TypesTestSuite) TestUpgradeString() {
proposal, err := types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, &ibctmtypes.ClientState{})
suite.Require().NoError(err)
- expect := fmt.Sprintf("Upgrade Plan\n Name: ibc upgrade\n Height: 1000\n Info: https://foo.bar/baz.\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{})
+ expect := fmt.Sprintf("IBC Upgrade Proposal\n Title: title\n Description: description\n Upgrade Plan\n Name: ibc upgrade\n Height: 1000\n Info: https://foo.bar/baz\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{})
suite.Require().Equal(expect, proposal.String())
}
diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go
index bb2d7d36d7c2..feabd03a6ccb 100644
--- a/x/upgrade/keeper/keeper.go
+++ b/x/upgrade/keeper/keeper.go
@@ -183,7 +183,7 @@ func (k Keeper) ApplyUpgrade(ctx sdk.Context, plan types.Plan) {
// Must clear IBC state after upgrade is applied as it is stored separately from the upgrade plan.
// This will prevent resubmission of upgrade msg after upgrade is already completed.
- k.ClearIBCState(ctx, plan.Height-1)
+ k.ClearIBCState(ctx, plan.Height)
k.ClearUpgradePlan(ctx)
k.setDone(ctx, plan.Name)
}
From 2b2e0b07667eb548fdb922f2b176537def10b9ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Fri, 26 Feb 2021 13:21:55 +0100
Subject: [PATCH 22/30] neatness
---
x/ibc/core/02-client/types/proposal_test.go | 2 +-
x/ibc/light-clients/07-tendermint/types/upgrade.go | 1 +
x/upgrade/keeper/grpc_query.go | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/x/ibc/core/02-client/types/proposal_test.go b/x/ibc/core/02-client/types/proposal_test.go
index d4e58b3bed03..a37de749b815 100644
--- a/x/ibc/core/02-client/types/proposal_test.go
+++ b/x/ibc/core/02-client/types/proposal_test.go
@@ -178,7 +178,7 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
// tests an upgrade proposal can be marshaled and unmarshaled, and the
// client state can be unpacked
-func (suite *TypesTestSuite) TestMarshalSoftwareUpdateProposal() {
+func (suite *TypesTestSuite) TestMarshalUpgradeProposal() {
// create proposal
plan := upgradetypes.Plan{
Name: "upgrade ibc",
diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade.go b/x/ibc/light-clients/07-tendermint/types/upgrade.go
index 5cb8e17c2dcf..161b725da16e 100644
--- a/x/ibc/light-clients/07-tendermint/types/upgrade.go
+++ b/x/ibc/light-clients/07-tendermint/types/upgrade.go
@@ -42,6 +42,7 @@ func (cs ClientState) VerifyUpgradeAndUpdateState(
// upgraded client state and consensus state must be IBC tendermint client state and consensus state
// this may be modified in the future to upgrade to a new IBC tendermint type
+ // counterparty must also commit to the upgraded consensus state at a sub-path under the upgrade path specified
tmUpgradeClient, ok := upgradedClient.(*ClientState)
if !ok {
return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "upgraded client must be Tendermint client. expected: %T got: %T",
diff --git a/x/upgrade/keeper/grpc_query.go b/x/upgrade/keeper/grpc_query.go
index a1fdbcd14762..3806fcbb0480 100644
--- a/x/upgrade/keeper/grpc_query.go
+++ b/x/upgrade/keeper/grpc_query.go
@@ -37,8 +37,8 @@ func (k Keeper) AppliedPlan(c context.Context, req *types.QueryAppliedPlanReques
func (k Keeper) UpgradedConsensusState(c context.Context, req *types.QueryUpgradedConsensusStateRequest) (*types.QueryUpgradedConsensusStateResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
- consState, exists := k.GetUpgradedConsensusState(ctx, req.LastHeight)
- if !exists {
+ consState, found := k.GetUpgradedConsensusState(ctx, req.LastHeight)
+ if !found {
return &types.QueryUpgradedConsensusStateResponse{}, nil
}
From 7b281f46fddeeb70081b88c719ce88763d3e5cc4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Fri, 26 Feb 2021 17:04:24 +0100
Subject: [PATCH 23/30] construct empty rest handler
---
x/ibc/core/02-client/client/proposal_handler.go | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/x/ibc/core/02-client/client/proposal_handler.go b/x/ibc/core/02-client/client/proposal_handler.go
index c6225ed1b9f5..611136985e6c 100644
--- a/x/ibc/core/02-client/client/proposal_handler.go
+++ b/x/ibc/core/02-client/client/proposal_handler.go
@@ -1,11 +1,17 @@
package client
import (
+ "github.com/cosmos/cosmos-sdk/client"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
+ "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/client/cli"
)
var (
- UpdateClientProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdateClientProposal, nil)
- UpgradeProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpgradeProposal, nil)
+ UpdateClientProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdateClientProposal, emptyRestHandler)
+ UpgradeProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpgradeProposal, emptyRestHandler)
)
+
+func emptyRestHandler(client.Context) rest.ProposalRESTHandler {
+ return rest.ProposalRESTHandler{}
+}
From d771d4ff65cc5a0acb8c702cbe145e047101f6ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Fri, 26 Feb 2021 17:39:25 +0100
Subject: [PATCH 24/30] fix tests
---
x/gov/legacy/v040/migrate_test.go | 3 +--
x/ibc/core/02-client/client/proposal_handler.go | 14 +++++++++++---
x/upgrade/types/plan.go | 2 +-
x/upgrade/types/plan_test.go | 6 +++---
4 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/x/gov/legacy/v040/migrate_test.go b/x/gov/legacy/v040/migrate_test.go
index 049f5b885387..c28e43fdf2c9 100644
--- a/x/gov/legacy/v040/migrate_test.go
+++ b/x/gov/legacy/v040/migrate_test.go
@@ -176,8 +176,7 @@ func TestMigrate(t *testing.T) {
"height": "123",
"info": "foo_upgrade_info",
"name": "foo_upgrade_name",
- "time": "0001-01-01T00:00:00Z",
- "upgraded_client_state": null
+ "time": "0001-01-01T00:00:00Z"
},
"title": "foo_software_upgrade"
},
diff --git a/x/ibc/core/02-client/client/proposal_handler.go b/x/ibc/core/02-client/client/proposal_handler.go
index 611136985e6c..1f6f4065f0f1 100644
--- a/x/ibc/core/02-client/client/proposal_handler.go
+++ b/x/ibc/core/02-client/client/proposal_handler.go
@@ -1,9 +1,12 @@
package client
import (
+ "net/http"
+
"github.com/cosmos/cosmos-sdk/client"
+ "github.com/cosmos/cosmos-sdk/types/rest"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
- "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
+ govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/client/cli"
)
@@ -12,6 +15,11 @@ var (
UpgradeProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpgradeProposal, emptyRestHandler)
)
-func emptyRestHandler(client.Context) rest.ProposalRESTHandler {
- return rest.ProposalRESTHandler{}
+func emptyRestHandler(client.Context) govrest.ProposalRESTHandler {
+ return govrest.ProposalRESTHandler{
+ SubRoute: "unsupported-ibc-client",
+ Handler: func(w http.ResponseWriter, r *http.Request) {
+ rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for IBC proposals")
+ },
+ }
}
diff --git a/x/upgrade/types/plan.go b/x/upgrade/types/plan.go
index 9b0c42aba748..6088ecea15c4 100644
--- a/x/upgrade/types/plan.go
+++ b/x/upgrade/types/plan.go
@@ -15,7 +15,7 @@ func (p Plan) String() string {
return fmt.Sprintf(`Upgrade Plan
Name: %s
%s
- Info: %s`, p.Name, dueUp, p.Info)
+ Info: %s.`, p.Name, dueUp, p.Info)
}
// ValidateBasic does basic validation of a Plan
diff --git a/x/upgrade/types/plan_test.go b/x/upgrade/types/plan_test.go
index 61f2d84cd0b7..37f5f5c9abcb 100644
--- a/x/upgrade/types/plan_test.go
+++ b/x/upgrade/types/plan_test.go
@@ -33,7 +33,7 @@ func TestPlanString(t *testing.T) {
Info: "https://foo.bar",
Time: mustParseTime("2019-07-08T11:33:55Z"),
},
- expect: "Upgrade Plan\n Name: due_time\n Time: 2019-07-08T11:33:55Z\n Info: https://foo.bar",
+ expect: "Upgrade Plan\n Name: due_time\n Time: 2019-07-08T11:33:55Z\n Info: https://foo.bar.",
},
"with height": {
p: types.Plan{
@@ -41,13 +41,13 @@ func TestPlanString(t *testing.T) {
Info: "https://foo.bar/baz",
Height: 7890,
},
- expect: "Upgrade Plan\n Name: by height\n Height: 7890\n Info: https://foo.bar/baz",
+ expect: "Upgrade Plan\n Name: by height\n Height: 7890\n Info: https://foo.bar/baz.",
},
"neither": {
p: types.Plan{
Name: "almost-empty",
},
- expect: "Upgrade Plan\n Name: almost-empty\n Height: 0\n Info: ",
+ expect: "Upgrade Plan\n Name: almost-empty\n Height: 0\n Info: .",
},
}
From 07670fc4dc8640f8a55dadd48bac86b2ca6725b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Fri, 26 Feb 2021 17:50:45 +0100
Subject: [PATCH 25/30] fix stringer tests
---
x/ibc/core/02-client/types/proposal_test.go | 2 +-
x/upgrade/abci_test.go | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/x/ibc/core/02-client/types/proposal_test.go b/x/ibc/core/02-client/types/proposal_test.go
index a37de749b815..bc78252baf42 100644
--- a/x/ibc/core/02-client/types/proposal_test.go
+++ b/x/ibc/core/02-client/types/proposal_test.go
@@ -222,7 +222,7 @@ func (suite *TypesTestSuite) TestUpgradeString() {
proposal, err := types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, &ibctmtypes.ClientState{})
suite.Require().NoError(err)
- expect := fmt.Sprintf("IBC Upgrade Proposal\n Title: title\n Description: description\n Upgrade Plan\n Name: ibc upgrade\n Height: 1000\n Info: https://foo.bar/baz\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{})
+ expect := fmt.Sprintf("IBC Upgrade Proposal\n Title: title\n Description: description\n Upgrade Plan\n Name: ibc upgrade\n Height: 1000\n Info: https://foo.bar/baz.\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{})
suite.Require().Equal(expect, proposal.String())
}
diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go
index 45ae491799a8..9eb0fc1a7ab9 100644
--- a/x/upgrade/abci_test.go
+++ b/x/upgrade/abci_test.go
@@ -230,15 +230,15 @@ func TestPlanStringer(t *testing.T) {
require.Equal(t, `Upgrade Plan
Name: test
Time: 2020-01-01T00:00:00Z
- Info: `, types.Plan{Name: "test", Time: ti}.String())
+ Info: .`, types.Plan{Name: "test", Time: ti}.String())
require.Equal(t, `Upgrade Plan
Name: test
Height: 100
- Info: `, types.Plan{Name: "test", Height: 100}.String())
+ Info: .`, types.Plan{Name: "test", Height: 100}.String())
require.Equal(t, fmt.Sprintf(`Upgrade Plan
Name: test
Height: 100
- Info: `), types.Plan{Name: "test", Height: 100}.String())
+ Info: .`), types.Plan{Name: "test", Height: 100}.String())
}
func VerifyNotDone(t *testing.T, newCtx sdk.Context, name string) {
From d3ecf9e2f5c1d879af7b8e61f7552227fc62c7f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?colin=20axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Mon, 1 Mar 2021 12:16:46 +0100
Subject: [PATCH 26/30] Update docs/core/proto-docs.md
Co-authored-by: Christopher Goes
---
docs/core/proto-docs.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md
index c22e73152fe1..9c1f7110adc6 100644
--- a/docs/core/proto-docs.md
+++ b/docs/core/proto-docs.md
@@ -8178,7 +8178,7 @@ upgrade.
| `title` | [string](#string) | | |
| `description` | [string](#string) | | |
| `plan` | [cosmos.upgrade.v1beta1.Plan](#cosmos.upgrade.v1beta1.Plan) | | |
-| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | An UpgradedClientState must be provided to perform an IBC breaking upgrade. This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades |
+| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | An UpgradedClientState must be provided to perform an IBC breaking upgrade. This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connected chains can verify that the new upgraded client is valid by verifying a proof of the intended new client state on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades. |
@@ -10895,4 +10895,3 @@ that implements Misbehaviour interface expected by ICS-02
| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass |
| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) |
| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) |
-
From 2a6adb0d6036abae46be050171b4e9020ef6fcf2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Mon, 1 Mar 2021 12:42:59 +0100
Subject: [PATCH 27/30] add key in ibc store tracking ibc upgrade heights
Add a new Key to the IBC client store to track the IBC Upgrade Height. This allows IBC upgrades to correctly remove old IBC upgrade states
---
x/ibc/core/02-client/keeper/keeper.go | 18 ++++++++++++++++++
x/ibc/core/02-client/keeper/proposal.go | 7 +++++--
x/ibc/core/02-client/keeper/proposal_test.go | 1 +
x/ibc/core/02-client/types/keys.go | 4 ++++
x/ibc/core/02-client/types/proposal.go | 4 ++++
5 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/x/ibc/core/02-client/keeper/keeper.go b/x/ibc/core/02-client/keeper/keeper.go
index 43ac1feb3523..35975108bc8a 100644
--- a/x/ibc/core/02-client/keeper/keeper.go
+++ b/x/ibc/core/02-client/keeper/keeper.go
@@ -117,6 +117,24 @@ func (k Keeper) SetNextClientSequence(ctx sdk.Context, sequence uint64) {
store.Set([]byte(types.KeyNextClientSequence), bz)
}
+// GetUpgradePlanHeight gets the IBC upgrade plan height.
+func (k Keeper) GetUpgradePlanHeight(ctx sdk.Context) (uint64, bool) {
+ store := ctx.KVStore(k.storeKey)
+ bz := store.Get([]byte(types.KeyUpgradePlanHeight))
+ if bz == nil {
+ return 0, false
+ }
+
+ return sdk.BigEndianToUint64(bz), true
+}
+
+// SetUpgradePlanHeight sets the IBC upgrade plan height to the store.
+func (k Keeper) SetUpgradePlanHeight(ctx sdk.Context, height uint64) {
+ store := ctx.KVStore(k.storeKey)
+ bz := sdk.Uint64ToBigEndian(height)
+ store.Set([]byte(types.KeyUpgradePlanHeight), bz)
+}
+
// IterateConsensusStates provides an iterator over all stored consensus states.
// objects. For each State object, cb will be called. If the cb returns true,
// the iterator will close and stop.
diff --git a/x/ibc/core/02-client/keeper/proposal.go b/x/ibc/core/02-client/keeper/proposal.go
index 1d15f7419dc5..ce59973c7e8f 100644
--- a/x/ibc/core/02-client/keeper/proposal.go
+++ b/x/ibc/core/02-client/keeper/proposal.go
@@ -77,9 +77,9 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
// store.
func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) error {
// clear any old IBC state stored by previous plan
- oldPlan, found := k.GetUpgradePlan(ctx)
+ planHeight, found := k.GetUpgradePlanHeight(ctx)
if found {
- k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height)
+ k.upgradeKeeper.ClearIBCState(ctx, int64(planHeight))
}
clientState, err := types.UnpackClientState(p.UpgradedClientState)
@@ -98,6 +98,9 @@ func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal)
return err
}
+ // set the new IBC upgrade plan height
+ k.SetUpgradePlanHeight(ctx, uint64(p.Plan.Height))
+
// sets the new upgraded client in last height committed on this chain is at plan.Height,
// since the chain will panic at plan.Height and new chain will resume at plan.Height
return k.upgradeKeeper.SetUpgradedClient(ctx, p.Plan.Height, bz)
diff --git a/x/ibc/core/02-client/keeper/proposal_test.go b/x/ibc/core/02-client/keeper/proposal_test.go
index 82d7e120dbcf..51032abe1021 100644
--- a/x/ibc/core/02-client/keeper/proposal_test.go
+++ b/x/ibc/core/02-client/keeper/proposal_test.go
@@ -211,6 +211,7 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() {
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(&oldPlan)
store.Set(upgradetypes.PlanKey(), bz)
+ suite.chainA.App.IBCKeeper.ClientKeeper.SetUpgradePlanHeight(suite.chainA.GetContext(), uint64(oldPlan.Height))
bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState)
suite.Require().NoError(err)
diff --git a/x/ibc/core/02-client/types/keys.go b/x/ibc/core/02-client/types/keys.go
index 321f5e3ffa3c..62108f8476f5 100644
--- a/x/ibc/core/02-client/types/keys.go
+++ b/x/ibc/core/02-client/types/keys.go
@@ -23,6 +23,10 @@ const (
// KeyNextClientSequence is the key used to store the next client sequence in
// the keeper.
KeyNextClientSequence = "nextClientSequence"
+
+ // KeyUpgradePlanHeight is the key used to store the IBC upgrade plan
+ // height in the keeper.
+ KeyUpgradePlanHeight = "upgradePlanHeight"
)
// FormatClientIdentifier returns the client identifier with the sequence appended.
diff --git a/x/ibc/core/02-client/types/proposal.go b/x/ibc/core/02-client/types/proposal.go
index efddfb2df8a4..eec195e271d9 100644
--- a/x/ibc/core/02-client/types/proposal.go
+++ b/x/ibc/core/02-client/types/proposal.go
@@ -111,6 +111,10 @@ func (up *UpgradeProposal) ValidateBasic() error {
return err
}
+ if up.Plan.Height <= 0 {
+ return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must set a positive height")
+ }
+
if up.Plan.Time.Unix() > 0 {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
}
From d40e695be32ac188239141eb84e8b580cea1577a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Mon, 1 Mar 2021 12:59:51 +0100
Subject: [PATCH 28/30] update abci and tests
---
x/ibc/core/02-client/abci.go | 34 ++++++++++++---------
x/ibc/core/02-client/abci_test.go | 1 +
x/ibc/core/02-client/types/proposal.go | 8 ++---
x/ibc/core/02-client/types/proposal_test.go | 8 ++++-
4 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/x/ibc/core/02-client/abci.go b/x/ibc/core/02-client/abci.go
index 163e513327b8..7c2ceaccab8b 100644
--- a/x/ibc/core/02-client/abci.go
+++ b/x/ibc/core/02-client/abci.go
@@ -11,21 +11,27 @@ import (
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
plan, found := k.GetUpgradePlan(ctx)
if found {
- // Once we are at the last block this chain will commit, set the upgraded consensus state
- // so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
- // headers on the next version of the chain.
- // Set the time to the last block time of the current chain.
- // In order for a client to upgrade successfully, the first block of the new chain must be committed
- // within the trusting period of the last block time on this chain.
- _, exists := k.GetUpgradedClient(ctx, plan.Height)
- if exists && ctx.BlockHeight() == plan.Height-1 {
- upgradedConsState := &ibctmtypes.ConsensusState{
- Timestamp: ctx.BlockTime(),
- NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
- }
- bz := k.MustMarshalConsensusState(upgradedConsState)
+ planHeight, found := k.GetUpgradePlanHeight(ctx)
+ if found {
+ // Once we are at the last block this chain will commit, set the upgraded consensus state
+ // so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
+ // headers on the next version of the chain.
+ // Set the time to the last block time of the current chain.
+ // In order for a client to upgrade successfully, the first block of the new chain must be committed
+ // within the trusting period of the last block time on this chain.
+ //
+ // The upgrade plan must exist in x/upgrade, the plan must be an IBC upgrade, and the current height
+ // must be one before the scheduled IBC upgrade.
+ _, exists := k.GetUpgradedClient(ctx, int64(planHeight))
+ if exists && ctx.BlockHeight() == int64(planHeight)-1 && ctx.BlockHeight() == plan.Height-1 {
+ upgradedConsState := &ibctmtypes.ConsensusState{
+ Timestamp: ctx.BlockTime(),
+ NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
+ }
+ bz := k.MustMarshalConsensusState(upgradedConsState)
- k.SetUpgradedConsensusState(ctx, plan.Height, bz)
+ k.SetUpgradedConsensusState(ctx, plan.Height, bz)
+ }
}
}
diff --git a/x/ibc/core/02-client/abci_test.go b/x/ibc/core/02-client/abci_test.go
index 3f1f6ebdc289..3c9bf8a3c88e 100644
--- a/x/ibc/core/02-client/abci_test.go
+++ b/x/ibc/core/02-client/abci_test.go
@@ -72,6 +72,7 @@ func (suite *ClientTestSuite) TestBeginBlockerConsensusState() {
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(plan)
store.Set(upgradetypes.PlanKey(), bz)
+ suite.chainA.App.IBCKeeper.ClientKeeper.SetUpgradePlanHeight(suite.chainA.GetContext(), uint64(plan.Height))
nextValsHash := []byte("nextValsHash")
newCtx := suite.chainA.GetContext().WithBlockHeader(tmproto.Header{
diff --git a/x/ibc/core/02-client/types/proposal.go b/x/ibc/core/02-client/types/proposal.go
index eec195e271d9..ed67e45425c4 100644
--- a/x/ibc/core/02-client/types/proposal.go
+++ b/x/ibc/core/02-client/types/proposal.go
@@ -111,14 +111,14 @@ func (up *UpgradeProposal) ValidateBasic() error {
return err
}
- if up.Plan.Height <= 0 {
- return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must set a positive height")
- }
-
if up.Plan.Time.Unix() > 0 {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
}
+ if up.Plan.Height <= 0 {
+ return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must set a positive height")
+ }
+
if up.UpgradedClientState == nil {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "upgraded client state cannot be nil")
}
diff --git a/x/ibc/core/02-client/types/proposal_test.go b/x/ibc/core/02-client/types/proposal_test.go
index bc78252baf42..a7337081abd3 100644
--- a/x/ibc/core/02-client/types/proposal_test.go
+++ b/x/ibc/core/02-client/types/proposal_test.go
@@ -129,12 +129,18 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
suite.Require().NoError(err)
}, false,
},
+ {
+ "plan height is zero", func() {
+ invalidPlan := upgradetypes.Plan{Name: "ibc upgrade", Height: 0}
+ proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
+ suite.Require().NoError(err)
+ }, false,
+ },
{
"plan time is not set to 0", func() {
invalidPlan := upgradetypes.Plan{Name: "ibc upgrade", Time: time.Now()}
proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
suite.Require().NoError(err)
-
}, false,
},
{
From 95cb360554cba560fcd7ed83e1cedc597d936bd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Mon, 1 Mar 2021 17:10:56 +0100
Subject: [PATCH 29/30] revert key storage after discussion with @AdityaSripal
Revert using a key to track IBC upgrades. By clearing any IBC state using an old plan in ScheduleUpgrade, IBC upgrades do not need to be tracked by IBC. This reduces code complexity and reduces potential for bugs.
---
x/ibc/core/02-client/abci.go | 34 ++++++++------------
x/ibc/core/02-client/abci_test.go | 1 -
x/ibc/core/02-client/keeper/keeper.go | 18 -----------
x/ibc/core/02-client/keeper/proposal.go | 9 ------
x/ibc/core/02-client/keeper/proposal_test.go | 1 -
x/ibc/core/02-client/types/keys.go | 4 ---
x/upgrade/keeper/keeper.go | 6 ++++
7 files changed, 20 insertions(+), 53 deletions(-)
diff --git a/x/ibc/core/02-client/abci.go b/x/ibc/core/02-client/abci.go
index 7c2ceaccab8b..163e513327b8 100644
--- a/x/ibc/core/02-client/abci.go
+++ b/x/ibc/core/02-client/abci.go
@@ -11,27 +11,21 @@ import (
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
plan, found := k.GetUpgradePlan(ctx)
if found {
- planHeight, found := k.GetUpgradePlanHeight(ctx)
- if found {
- // Once we are at the last block this chain will commit, set the upgraded consensus state
- // so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
- // headers on the next version of the chain.
- // Set the time to the last block time of the current chain.
- // In order for a client to upgrade successfully, the first block of the new chain must be committed
- // within the trusting period of the last block time on this chain.
- //
- // The upgrade plan must exist in x/upgrade, the plan must be an IBC upgrade, and the current height
- // must be one before the scheduled IBC upgrade.
- _, exists := k.GetUpgradedClient(ctx, int64(planHeight))
- if exists && ctx.BlockHeight() == int64(planHeight)-1 && ctx.BlockHeight() == plan.Height-1 {
- upgradedConsState := &ibctmtypes.ConsensusState{
- Timestamp: ctx.BlockTime(),
- NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
- }
- bz := k.MustMarshalConsensusState(upgradedConsState)
-
- k.SetUpgradedConsensusState(ctx, plan.Height, bz)
+ // Once we are at the last block this chain will commit, set the upgraded consensus state
+ // so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
+ // headers on the next version of the chain.
+ // Set the time to the last block time of the current chain.
+ // In order for a client to upgrade successfully, the first block of the new chain must be committed
+ // within the trusting period of the last block time on this chain.
+ _, exists := k.GetUpgradedClient(ctx, plan.Height)
+ if exists && ctx.BlockHeight() == plan.Height-1 {
+ upgradedConsState := &ibctmtypes.ConsensusState{
+ Timestamp: ctx.BlockTime(),
+ NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
}
+ bz := k.MustMarshalConsensusState(upgradedConsState)
+
+ k.SetUpgradedConsensusState(ctx, plan.Height, bz)
}
}
diff --git a/x/ibc/core/02-client/abci_test.go b/x/ibc/core/02-client/abci_test.go
index 3c9bf8a3c88e..3f1f6ebdc289 100644
--- a/x/ibc/core/02-client/abci_test.go
+++ b/x/ibc/core/02-client/abci_test.go
@@ -72,7 +72,6 @@ func (suite *ClientTestSuite) TestBeginBlockerConsensusState() {
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(plan)
store.Set(upgradetypes.PlanKey(), bz)
- suite.chainA.App.IBCKeeper.ClientKeeper.SetUpgradePlanHeight(suite.chainA.GetContext(), uint64(plan.Height))
nextValsHash := []byte("nextValsHash")
newCtx := suite.chainA.GetContext().WithBlockHeader(tmproto.Header{
diff --git a/x/ibc/core/02-client/keeper/keeper.go b/x/ibc/core/02-client/keeper/keeper.go
index 35975108bc8a..43ac1feb3523 100644
--- a/x/ibc/core/02-client/keeper/keeper.go
+++ b/x/ibc/core/02-client/keeper/keeper.go
@@ -117,24 +117,6 @@ func (k Keeper) SetNextClientSequence(ctx sdk.Context, sequence uint64) {
store.Set([]byte(types.KeyNextClientSequence), bz)
}
-// GetUpgradePlanHeight gets the IBC upgrade plan height.
-func (k Keeper) GetUpgradePlanHeight(ctx sdk.Context) (uint64, bool) {
- store := ctx.KVStore(k.storeKey)
- bz := store.Get([]byte(types.KeyUpgradePlanHeight))
- if bz == nil {
- return 0, false
- }
-
- return sdk.BigEndianToUint64(bz), true
-}
-
-// SetUpgradePlanHeight sets the IBC upgrade plan height to the store.
-func (k Keeper) SetUpgradePlanHeight(ctx sdk.Context, height uint64) {
- store := ctx.KVStore(k.storeKey)
- bz := sdk.Uint64ToBigEndian(height)
- store.Set([]byte(types.KeyUpgradePlanHeight), bz)
-}
-
// IterateConsensusStates provides an iterator over all stored consensus states.
// objects. For each State object, cb will be called. If the cb returns true,
// the iterator will close and stop.
diff --git a/x/ibc/core/02-client/keeper/proposal.go b/x/ibc/core/02-client/keeper/proposal.go
index ce59973c7e8f..812df5e138de 100644
--- a/x/ibc/core/02-client/keeper/proposal.go
+++ b/x/ibc/core/02-client/keeper/proposal.go
@@ -76,12 +76,6 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
// will schedule an upgrade and finally set the upgraded client state in upgrade
// store.
func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) error {
- // clear any old IBC state stored by previous plan
- planHeight, found := k.GetUpgradePlanHeight(ctx)
- if found {
- k.upgradeKeeper.ClearIBCState(ctx, int64(planHeight))
- }
-
clientState, err := types.UnpackClientState(p.UpgradedClientState)
if err != nil {
return sdkerrors.Wrap(err, "could not unpack UpgradedClientState")
@@ -98,9 +92,6 @@ func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal)
return err
}
- // set the new IBC upgrade plan height
- k.SetUpgradePlanHeight(ctx, uint64(p.Plan.Height))
-
// sets the new upgraded client in last height committed on this chain is at plan.Height,
// since the chain will panic at plan.Height and new chain will resume at plan.Height
return k.upgradeKeeper.SetUpgradedClient(ctx, p.Plan.Height, bz)
diff --git a/x/ibc/core/02-client/keeper/proposal_test.go b/x/ibc/core/02-client/keeper/proposal_test.go
index 51032abe1021..82d7e120dbcf 100644
--- a/x/ibc/core/02-client/keeper/proposal_test.go
+++ b/x/ibc/core/02-client/keeper/proposal_test.go
@@ -211,7 +211,6 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() {
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(&oldPlan)
store.Set(upgradetypes.PlanKey(), bz)
- suite.chainA.App.IBCKeeper.ClientKeeper.SetUpgradePlanHeight(suite.chainA.GetContext(), uint64(oldPlan.Height))
bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState)
suite.Require().NoError(err)
diff --git a/x/ibc/core/02-client/types/keys.go b/x/ibc/core/02-client/types/keys.go
index 62108f8476f5..321f5e3ffa3c 100644
--- a/x/ibc/core/02-client/types/keys.go
+++ b/x/ibc/core/02-client/types/keys.go
@@ -23,10 +23,6 @@ const (
// KeyNextClientSequence is the key used to store the next client sequence in
// the keeper.
KeyNextClientSequence = "nextClientSequence"
-
- // KeyUpgradePlanHeight is the key used to store the IBC upgrade plan
- // height in the keeper.
- KeyUpgradePlanHeight = "upgradePlanHeight"
)
// FormatClientIdentifier returns the client identifier with the sequence appended.
diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go
index feabd03a6ccb..dfbfa33d9f4d 100644
--- a/x/upgrade/keeper/keeper.go
+++ b/x/upgrade/keeper/keeper.go
@@ -72,6 +72,12 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error {
store := ctx.KVStore(k.storeKey)
+ // clear any old IBC state stored by previous plan
+ oldPlan, found := k.GetUpgradePlan(ctx)
+ if found {
+ k.ClearIBCState(ctx, oldPlan.Height)
+ }
+
bz := k.cdc.MustMarshalBinaryBare(&plan)
store.Set(types.PlanKey(), bz)
From 5e20b2f7f1d24805c07748fd782222568348330c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Axn=C3=A9r?=
<25233464+colin-axner@users.noreply.github.com>
Date: Mon, 1 Mar 2021 17:16:23 +0100
Subject: [PATCH 30/30] clear IBC states on cancelled upgrades
---
x/upgrade/keeper/keeper.go | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go
index dfbfa33d9f4d..e366ae09198e 100644
--- a/x/upgrade/keeper/keeper.go
+++ b/x/upgrade/keeper/keeper.go
@@ -140,8 +140,14 @@ func (k Keeper) ClearIBCState(ctx sdk.Context, lastHeight int64) {
store.Delete(types.UpgradedConsStateKey(lastHeight))
}
-// ClearUpgradePlan clears any schedule upgrade
+// ClearUpgradePlan clears any schedule upgrade and associated IBC states.
func (k Keeper) ClearUpgradePlan(ctx sdk.Context) {
+ // clear IBC states everytime upgrade plan is removed
+ oldPlan, found := k.GetUpgradePlan(ctx)
+ if found {
+ k.ClearIBCState(ctx, oldPlan.Height)
+ }
+
store := ctx.KVStore(k.storeKey)
store.Delete(types.PlanKey())
}