* require old chain halts before upgrade * Update proto/ibc/core/client/v1/client.proto Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * start address reviews * Apply suggestions from code review Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * address reviews * rework upgrade to ensure there is never more than one upgrade client in store * fix tests * fix conditional * make proto-gen * remove if statement skipping tests in upgrade keeper test * address reviews * correctly escape and unescape merkle keys * add small conditional check Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Colin Axner <colinaxner@berkeley.edu>
This commit is contained in:
parent
a87d6ea3ab
commit
31ab35ad72
@ -84,10 +84,12 @@ message MsgUpgradeClient {
|
||||
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
|
||||
// upgraded client state
|
||||
google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""];
|
||||
// height at which old chain halts and upgrades (i.e last block executed)
|
||||
Height upgrade_height = 3 [(gogoproto.moretags) = "yaml:\"upgrade_height\""];
|
||||
// proof that old chain committed to new client
|
||||
bytes proof_upgrade = 3 [(gogoproto.moretags) = "yaml:\"proof_upgrade\""];
|
||||
bytes proof_upgrade = 4 [(gogoproto.moretags) = "yaml:\"proof_upgrade\""];
|
||||
// signer address
|
||||
string signer = 4;
|
||||
string signer = 5;
|
||||
}
|
||||
|
||||
// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for
|
||||
|
||||
@ -42,7 +42,7 @@ message ClientState {
|
||||
repeated ics23.ProofSpec proof_specs = 8 [(gogoproto.moretags) = "yaml:\"proof_specs\""];
|
||||
|
||||
// Path at which next upgraded client will be committed
|
||||
ibc.core.commitment.v1.MerklePath upgrade_path = 9 [(gogoproto.moretags) = "yaml:\"upgrade_path\""];
|
||||
string upgrade_path = 9 [(gogoproto.moretags) = "yaml:\"upgrade_path\""];
|
||||
|
||||
// This flag, when set to true, will allow governance to recover a client
|
||||
// which has expired
|
||||
|
||||
@ -5,6 +5,7 @@ package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
@ -72,7 +73,7 @@ type ValidatorOutstandingRewardsRecord struct {
|
||||
// validator_address is the address of the validator.
|
||||
ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"`
|
||||
// outstanding_rewards represents the oustanding rewards of a validator.
|
||||
OutstandingRewards []types.DecCoin `protobuf:"bytes,2,rep,name=outstanding_rewards,json=outstandingRewards,proto3" json:"outstanding_rewards" yaml:"outstanding_rewards"`
|
||||
OutstandingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=outstanding_rewards,json=outstandingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"outstanding_rewards" yaml:"outstanding_rewards"`
|
||||
}
|
||||
|
||||
func (m *ValidatorOutstandingRewardsRecord) Reset() { *m = ValidatorOutstandingRewardsRecord{} }
|
||||
|
||||
@ -76,7 +76,7 @@ func HandleMsgUpgradeClient(ctx sdk.Context, k keeper.Keeper, msg *types.MsgUpgr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = k.UpgradeClient(ctx, msg.ClientId, upgradedClient, msg.ProofUpgrade); err != nil {
|
||||
if err = k.UpgradeClient(ctx, msg.ClientId, upgradedClient, msg.UpgradeHeight, msg.ProofUpgrade); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@ -84,10 +84,11 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
var (
|
||||
clientA string
|
||||
upgradedClient exported.ClientState
|
||||
upgradeHeight exported.Height
|
||||
msg *clienttypes.MsgUpgradeClient
|
||||
)
|
||||
|
||||
upgradeHeight := clienttypes.NewHeight(1, 1)
|
||||
newClientHeight := clienttypes.NewHeight(1, 1)
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
@ -98,9 +99,13 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
name: "successful upgrade",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -111,9 +116,9 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, proofUpgrade, suite.chainA.SenderAccount.GetAddress())
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradeHeight, proofUpgrade, suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
expPass: true,
|
||||
@ -125,13 +130,18 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
|
||||
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
|
||||
consState := ibctmtypes.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("app_hash")), []byte("next_vals_hash"))
|
||||
consAny, err := clienttypes.PackConsensusState(consState)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
msg = &types.MsgUpgradeClient{ClientId: clientA, ClientState: consAny, ProofUpgrade: proofUpgrade, Signer: suite.chainA.SenderAccount.GetAddress().String()}
|
||||
height, _ := upgradeHeight.(types.Height)
|
||||
|
||||
msg = &types.MsgUpgradeClient{ClientId: clientA, ClientState: consAny, UpgradeHeight: &height, ProofUpgrade: proofUpgrade, Signer: suite.chainA.SenderAccount.GetAddress().String()}
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -139,9 +149,13 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
name: "invalid clientstate",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
upgradedClient = ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -152,9 +166,9 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, proofUpgrade, suite.chainA.SenderAccount.GetAddress())
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradeHeight, proofUpgrade, suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
expPass: false,
|
||||
@ -163,9 +177,13 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
name: "VerifyUpgrade fails",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -173,7 +191,7 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, nil, suite.chainA.SenderAccount.GetAddress())
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradeHeight, nil, suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
expPass: false,
|
||||
|
||||
@ -82,7 +82,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
|
||||
|
||||
// UpgradeClient upgrades the client to a new client state if this new client was committed to
|
||||
// by the old client at the specified upgrade height
|
||||
func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient exported.ClientState, proofUpgrade []byte) error {
|
||||
func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient exported.ClientState, upgradeHeight exported.Height, proofUpgrade []byte) error {
|
||||
clientState, found := k.GetClientState(ctx, clientID)
|
||||
if !found {
|
||||
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID)
|
||||
@ -93,7 +93,7 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e
|
||||
return sdkerrors.Wrapf(types.ErrClientFrozen, "cannot update client with ID %s", clientID)
|
||||
}
|
||||
|
||||
err := clientState.VerifyUpgrade(ctx, k.cdc, k.ClientStore(ctx, clientID), upgradedClient, proofUpgrade)
|
||||
err := clientState.VerifyUpgrade(ctx, k.cdc, k.ClientStore(ctx, clientID), upgradedClient, upgradeHeight, proofUpgrade)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(err, "cannot upgrade client with ID: %s", clientID)
|
||||
}
|
||||
|
||||
@ -34,11 +34,11 @@ func (suite *KeeperTestSuite) TestCreateClient() {
|
||||
i := i
|
||||
if tc.expPanic {
|
||||
suite.Require().Panics(func() {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
suite.keeper.CreateClient(suite.ctx, tc.clientID, clientState, suite.consensusState)
|
||||
}, "Msg %d didn't panic: %s", i, tc.msg)
|
||||
} else {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
if tc.expPass {
|
||||
suite.Require().NotNil(clientState, "valid test case %d failed: %s", i, tc.msg)
|
||||
}
|
||||
@ -81,7 +81,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
expPass bool
|
||||
}{
|
||||
{"valid update", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
// store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height
|
||||
@ -99,7 +99,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
return err
|
||||
}, true},
|
||||
{"valid past update", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -132,7 +132,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
return nil
|
||||
}, false},
|
||||
{"consensus state not found", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
updateHeader = createFutureUpdateFn(suite)
|
||||
|
||||
@ -146,7 +146,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
return nil
|
||||
}, false},
|
||||
{"valid past update before client was frozen", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
clientState.FrozenHeight = types.NewHeight(0, testClientHeight.VersionHeight-1)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
suite.Require().NoError(err)
|
||||
@ -166,7 +166,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
return nil
|
||||
}, true},
|
||||
{"invalid header", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
suite.Require().NoError(err)
|
||||
updateHeader = createPastUpdateFn(suite)
|
||||
@ -237,6 +237,7 @@ func (suite *KeeperTestSuite) TestUpdateClientLocalhost() {
|
||||
func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
var (
|
||||
upgradedClient exported.ClientState
|
||||
upgradeHeight exported.Height
|
||||
clientA string
|
||||
proofUpgrade []byte
|
||||
)
|
||||
@ -250,9 +251,13 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
name: "successful upgrade",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -263,7 +268,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: true,
|
||||
},
|
||||
@ -271,9 +276,13 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
name: "client state not found",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -284,7 +293,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
|
||||
clientA = "wrongclientid"
|
||||
},
|
||||
@ -294,9 +303,13 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
name: "client state frozen",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -307,7 +320,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
|
||||
// set frozen client in store
|
||||
tmClient, ok := cs.(*ibctmtypes.ClientState)
|
||||
@ -321,12 +334,16 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
name: "tendermint client VerifyUpgrade fails",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = ibctmtypes.NewClientState("wrongchainID", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, true, true)
|
||||
upgradedClient = ibctmtypes.NewClientState("wrongchainID", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, true, true)
|
||||
|
||||
suite.coordinator.CommitBlock(suite.chainB)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
@ -335,7 +352,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -347,7 +364,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
|
||||
tc.setup()
|
||||
|
||||
err := suite.chainA.App.IBCKeeper.ClientKeeper.UpgradeClient(suite.chainA.GetContext(), clientA, upgradedClient, proofUpgrade)
|
||||
err := suite.chainA.App.IBCKeeper.ClientKeeper.UpgradeClient(suite.chainA.GetContext(), clientA, upgradedClient, upgradeHeight, proofUpgrade)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err, "verify upgrade failed on valid case: %s", tc.name)
|
||||
@ -402,7 +419,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = bothValsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
return err
|
||||
@ -419,7 +436,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
// store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height
|
||||
@ -446,7 +463,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
// store trusted consensus state for Header2
|
||||
@ -473,7 +490,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
// intermediate consensus state at height + 3 is not created
|
||||
return err
|
||||
@ -490,7 +507,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
// intermediate consensus state at height + 3 is not created
|
||||
return err
|
||||
@ -513,7 +530,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = bothValsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
clientState.FrozenHeight = types.NewHeight(0, 1)
|
||||
@ -532,7 +549,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
ClientId: testClientID,
|
||||
},
|
||||
func() error {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ func (suite *KeeperTestSuite) TestQueryClientState() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
|
||||
var err error
|
||||
@ -209,7 +209,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
|
||||
{
|
||||
"success latest height",
|
||||
func() {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
cs := ibctmtypes.NewConsensusState(
|
||||
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil,
|
||||
)
|
||||
|
||||
@ -2,6 +2,7 @@ package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
@ -251,10 +252,12 @@ func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientS
|
||||
tmClient.UnbondingPeriod, tmClient.TrustingPeriod)
|
||||
}
|
||||
|
||||
if tmClient.UpgradePath != nil {
|
||||
if tmClient.UpgradePath != "" {
|
||||
// For now, SDK IBC implementation assumes that upgrade path (if defined) is defined by SDK upgrade module
|
||||
expectedUpgradePath := fmt.Sprintf("/%s/%s", upgradetypes.StoreKey, upgradetypes.KeyUpgradedClient)
|
||||
if tmClient.UpgradePath.String() != expectedUpgradePath {
|
||||
// Must escape any merkle key before adding it to upgrade path
|
||||
upgradeKey := url.PathEscape(upgradetypes.KeyUpgradedClient)
|
||||
expectedUpgradePath := fmt.Sprintf("%s/%s", upgradetypes.StoreKey, upgradeKey)
|
||||
if tmClient.UpgradePath != expectedUpgradePath {
|
||||
return sdkerrors.Wrapf(types.ErrInvalidClient, "upgrade path must be the upgrade path defined by upgrade module. expected %s, got %s",
|
||||
expectedUpgradePath, tmClient.UpgradePath)
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ const (
|
||||
var (
|
||||
testClientHeight = types.NewHeight(0, 5)
|
||||
testClientHeightEpoch1 = types.NewHeight(1, 5)
|
||||
upgradeHeight = types.NewHeight(1, 1)
|
||||
newClientHeight = types.NewHeight(1, 1)
|
||||
)
|
||||
|
||||
type KeeperTestSuite struct {
|
||||
@ -120,7 +120,7 @@ func TestKeeperTestSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSetClientState() {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
|
||||
retrievedState, found := suite.keeper.GetClientState(suite.ctx, testClientID)
|
||||
@ -140,7 +140,6 @@ func (suite *KeeperTestSuite) TestSetClientConsensusState() {
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestValidateSelfClient() {
|
||||
badUpgradePath := commitmenttypes.NewMerklePath([]string{"bad", "upgrade", "path"})
|
||||
testCases := []struct {
|
||||
name string
|
||||
clientState exported.ClientState
|
||||
@ -148,12 +147,12 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() {
|
||||
}{
|
||||
{
|
||||
"success",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success with nil UpgradePath",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), nil, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), "", false, false),
|
||||
true,
|
||||
},
|
||||
{
|
||||
@ -163,47 +162,47 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() {
|
||||
},
|
||||
{
|
||||
"frozen client",
|
||||
&ibctmtypes.ClientState{testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false},
|
||||
&ibctmtypes.ClientState{testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"incorrect chainID",
|
||||
ibctmtypes.NewClientState("gaiatestnet", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState("gaiatestnet", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid client height",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.NewHeight(0, testClientHeight.VersionHeight+10), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.NewHeight(0, testClientHeight.VersionHeight+10), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid client version",
|
||||
ibctmtypes.NewClientState(testChainIDEpoch1, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeightEpoch1, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainIDEpoch1, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeightEpoch1, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid proof specs",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, nil, &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, nil, ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid trust level",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.Fraction{0, 1}, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.Fraction{0, 1}, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid unbonding period",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+10, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+10, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid trusting period",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, ubdPeriod+10, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, ubdPeriod+10, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid upgrade path",
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &badUpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), "bad/upgrade/path", false, false),
|
||||
false,
|
||||
},
|
||||
}
|
||||
@ -226,9 +225,9 @@ func (suite KeeperTestSuite) TestGetAllClients() {
|
||||
testClientID2, testClientID3, testClientID,
|
||||
}
|
||||
expClients := []exported.ClientState{
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
}
|
||||
|
||||
for i := range expClients {
|
||||
@ -250,9 +249,9 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() {
|
||||
testClientID2, testClientID3, testClientID,
|
||||
}
|
||||
expClients := []exported.ClientState{
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
}
|
||||
|
||||
expGenClients := make([]types.IdentifiedClientState, len(expClients))
|
||||
@ -300,7 +299,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() {
|
||||
|
||||
func (suite KeeperTestSuite) TestConsensusStateHelpers() {
|
||||
// initial setup
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState)
|
||||
|
||||
@ -334,10 +334,12 @@ type MsgUpgradeClient struct {
|
||||
ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"`
|
||||
// upgraded client state
|
||||
ClientState *types.Any `protobuf:"bytes,2,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"`
|
||||
// height at which old chain halts and upgrades (i.e last block executed)
|
||||
UpgradeHeight *Height `protobuf:"bytes,3,opt,name=upgrade_height,json=upgradeHeight,proto3" json:"upgrade_height,omitempty" yaml:"upgrade_height"`
|
||||
// proof that old chain committed to new client
|
||||
ProofUpgrade []byte `protobuf:"bytes,3,opt,name=proof_upgrade,json=proofUpgrade,proto3" json:"proof_upgrade,omitempty" yaml:"proof_upgrade"`
|
||||
ProofUpgrade []byte `protobuf:"bytes,4,opt,name=proof_upgrade,json=proofUpgrade,proto3" json:"proof_upgrade,omitempty" yaml:"proof_upgrade"`
|
||||
// signer address
|
||||
Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"`
|
||||
Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgUpgradeClient) Reset() { *m = MsgUpgradeClient{} }
|
||||
@ -387,6 +389,13 @@ func (m *MsgUpgradeClient) GetClientState() *types.Any {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MsgUpgradeClient) GetUpgradeHeight() *Height {
|
||||
if m != nil {
|
||||
return m.UpgradeHeight
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MsgUpgradeClient) GetProofUpgrade() []byte {
|
||||
if m != nil {
|
||||
return m.ProofUpgrade
|
||||
@ -508,51 +517,52 @@ func init() {
|
||||
func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) }
|
||||
|
||||
var fileDescriptor_b6bc4c8185546947 = []byte{
|
||||
// 691 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x3b, 0x4f, 0x1b, 0x31,
|
||||
0x1c, 0x8f, 0x93, 0x34, 0x22, 0x4e, 0x78, 0xe8, 0x9a, 0x40, 0xc8, 0x90, 0x8b, 0x3c, 0x31, 0xc0,
|
||||
0x5d, 0x49, 0x87, 0xa2, 0x48, 0x95, 0xda, 0xb0, 0x94, 0x81, 0x8a, 0x1e, 0xaa, 0xfa, 0x58, 0xd0,
|
||||
0x3d, 0xcc, 0xc5, 0x6a, 0x72, 0x8e, 0xce, 0x4e, 0x44, 0xbe, 0x41, 0xc7, 0x4a, 0xad, 0xaa, 0x0e,
|
||||
0x1d, 0x98, 0x3a, 0x76, 0xeb, 0x37, 0xe8, 0xc0, 0xc8, 0xd8, 0xe9, 0x54, 0xc1, 0xd2, 0xa9, 0x43,
|
||||
0x3e, 0x41, 0x75, 0xb6, 0x21, 0x39, 0x20, 0x14, 0x31, 0x31, 0x9d, 0xed, 0xff, 0xdf, 0x3f, 0xff,
|
||||
0x1e, 0x96, 0x0f, 0xea, 0xc4, 0x71, 0x4d, 0x97, 0x86, 0xd8, 0x74, 0x3b, 0x04, 0x07, 0xdc, 0x1c,
|
||||
0xac, 0xab, 0x91, 0xd1, 0x0b, 0x29, 0xa7, 0x9a, 0x46, 0x1c, 0xd7, 0x88, 0x1b, 0x0c, 0xb5, 0x3c,
|
||||
0x58, 0xaf, 0x96, 0x7c, 0xea, 0x53, 0x51, 0x36, 0xe3, 0x91, 0xec, 0xac, 0x2e, 0xfb, 0x94, 0xfa,
|
||||
0x1d, 0x6c, 0x8a, 0x99, 0xd3, 0xdf, 0x37, 0xed, 0x60, 0x28, 0x4b, 0xe8, 0x2b, 0x80, 0xe5, 0x2d,
|
||||
0x0f, 0x07, 0x9c, 0xec, 0x13, 0xec, 0x6d, 0x0a, 0xa0, 0x5d, 0x6e, 0x73, 0xac, 0xad, 0xc3, 0xbc,
|
||||
0xc4, 0xdd, 0x23, 0x5e, 0x05, 0xd4, 0xc1, 0x4a, 0xbe, 0x55, 0x1a, 0x45, 0xfa, 0xc2, 0xd0, 0xee,
|
||||
0x76, 0x9a, 0xe8, 0xbc, 0x84, 0xac, 0x19, 0x39, 0xde, 0xf2, 0xb4, 0x1d, 0x58, 0x54, 0xeb, 0x2c,
|
||||
0x86, 0xa8, 0xa4, 0xeb, 0x60, 0xa5, 0xd0, 0x28, 0x19, 0xf2, 0x78, 0xe3, 0xec, 0x78, 0xe3, 0x69,
|
||||
0x30, 0x6c, 0x2d, 0x8d, 0x22, 0xfd, 0x7e, 0x02, 0x4b, 0xec, 0x41, 0x56, 0xc1, 0x1d, 0x93, 0x40,
|
||||
0xdf, 0x01, 0xac, 0x6c, 0xd2, 0x80, 0xe1, 0x80, 0xf5, 0x99, 0x58, 0x7a, 0x45, 0x78, 0xfb, 0x19,
|
||||
0x26, 0x7e, 0x9b, 0x6b, 0x1b, 0x30, 0xd7, 0x16, 0x23, 0x41, 0xaf, 0xd0, 0xa8, 0x1a, 0x97, 0x1d,
|
||||
0x31, 0x64, 0x6f, 0x2b, 0x7b, 0x14, 0xe9, 0x29, 0x4b, 0xf5, 0x6b, 0xaf, 0xe1, 0xbc, 0x7b, 0x86,
|
||||
0x7a, 0x03, 0xae, 0xcb, 0xa3, 0x48, 0x2f, 0xc7, 0x5c, 0xd1, 0x85, 0x5d, 0xc8, 0x9a, 0x73, 0x13,
|
||||
0xec, 0xd0, 0x4f, 0x00, 0xcb, 0xd2, 0xc5, 0x24, 0x6d, 0x76, 0x1b, 0x3f, 0x0f, 0xe0, 0xc2, 0x85,
|
||||
0x03, 0x59, 0x25, 0x5d, 0xcf, 0xac, 0x14, 0x1a, 0xab, 0x57, 0x49, 0x9d, 0x66, 0x54, 0x4b, 0x8f,
|
||||
0xc5, 0x8f, 0x22, 0x7d, 0x49, 0x9d, 0x75, 0x01, 0x13, 0x59, 0xf3, 0x49, 0x15, 0x0c, 0xfd, 0x00,
|
||||
0xb0, 0x24, 0x65, 0xbc, 0xec, 0x79, 0x36, 0xc7, 0x3b, 0x21, 0xed, 0x51, 0x66, 0x77, 0xb4, 0x12,
|
||||
0xbc, 0xc7, 0x09, 0xef, 0x60, 0xa9, 0xc0, 0x92, 0x13, 0xad, 0x0e, 0x0b, 0x1e, 0x66, 0x6e, 0x48,
|
||||
0x7a, 0x9c, 0xd0, 0x40, 0x78, 0x99, 0xb7, 0x26, 0x97, 0x92, 0xea, 0x33, 0x37, 0x52, 0xbf, 0x1a,
|
||||
0xc7, 0x6b, 0x7b, 0x38, 0xac, 0x64, 0xa7, 0x67, 0x63, 0xa9, 0x9e, 0x66, 0xf6, 0xfd, 0xa1, 0x9e,
|
||||
0x42, 0x1f, 0xd3, 0x70, 0x7e, 0x9b, 0xf9, 0x9b, 0x21, 0xb6, 0x39, 0x96, 0x02, 0xee, 0xc4, 0x45,
|
||||
0xd6, 0xde, 0x5c, 0xbe, 0x71, 0x99, 0x6b, 0x40, 0xab, 0xa3, 0x48, 0x5f, 0xbc, 0x32, 0xad, 0x4b,
|
||||
0x57, 0x4e, 0x5b, 0x84, 0x39, 0x46, 0xfc, 0x40, 0xf9, 0x94, 0xb7, 0xd4, 0xac, 0x39, 0x13, 0x3b,
|
||||
0xf2, 0x27, 0x76, 0xe5, 0x13, 0x10, 0xae, 0xc8, 0x28, 0x6f, 0xef, 0xca, 0x38, 0x90, 0xf4, 0xff,
|
||||
0x03, 0x99, 0xa0, 0x95, 0x99, 0x42, 0xeb, 0x2f, 0x80, 0x0b, 0x82, 0x96, 0x1f, 0xda, 0xde, 0x9d,
|
||||
0x4a, 0xeb, 0x31, 0x9c, 0xed, 0x85, 0x94, 0xee, 0xef, 0xf5, 0x25, 0x37, 0x21, 0xa1, 0xd8, 0xaa,
|
||||
0x8c, 0x22, 0xbd, 0x24, 0x37, 0x27, 0xca, 0xc8, 0x2a, 0x8a, 0xb9, 0x52, 0x32, 0x2d, 0x11, 0xf4,
|
||||
0x0d, 0xc0, 0xf2, 0x36, 0xf3, 0x77, 0xfb, 0x4e, 0x97, 0xf0, 0x6d, 0xc2, 0x1c, 0xdc, 0xb6, 0x07,
|
||||
0x84, 0xf6, 0xc3, 0xdb, 0xa8, 0xde, 0x80, 0xc5, 0xee, 0x04, 0xc4, 0xb5, 0x99, 0x24, 0x3a, 0x6f,
|
||||
0x90, 0xcc, 0x67, 0x00, 0x73, 0xea, 0x91, 0x7d, 0x02, 0xe7, 0x06, 0x38, 0x64, 0x84, 0x06, 0x7b,
|
||||
0x41, 0xbf, 0xeb, 0xe0, 0x50, 0xd0, 0xcb, 0x8e, 0xdf, 0xc4, 0x26, 0x4a, 0xd6, 0x91, 0x35, 0xab,
|
||||
0x16, 0x9e, 0x8b, 0xf9, 0x24, 0x82, 0x7a, 0xae, 0xd3, 0xd3, 0x10, 0x64, 0x7d, 0x8c, 0x20, 0x39,
|
||||
0x48, 0x62, 0x5f, 0x0e, 0xf5, 0x54, 0xeb, 0xc5, 0xd1, 0x49, 0x0d, 0x1c, 0x9f, 0xd4, 0xc0, 0xef,
|
||||
0x93, 0x1a, 0xf8, 0x70, 0x5a, 0x4b, 0x1d, 0x9f, 0xd6, 0x52, 0xbf, 0x4e, 0x6b, 0xa9, 0xb7, 0x8f,
|
||||
0x7c, 0xc2, 0xdb, 0x7d, 0xc7, 0x70, 0x69, 0xd7, 0x74, 0x29, 0xeb, 0x52, 0xa6, 0x3e, 0x6b, 0xcc,
|
||||
0x7b, 0x67, 0x1e, 0x98, 0xe7, 0x7f, 0xd3, 0x07, 0x8d, 0x35, 0xf5, 0x43, 0xe5, 0xc3, 0x1e, 0x66,
|
||||
0x4e, 0x4e, 0x38, 0xf5, 0xf0, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0xe9, 0x8c, 0xf0, 0x70,
|
||||
0x07, 0x00, 0x00,
|
||||
// 718 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x3d, 0x4f, 0xdb, 0x4e,
|
||||
0x1c, 0x8e, 0x93, 0x10, 0x91, 0x4b, 0x78, 0x91, 0xff, 0x09, 0x84, 0x0c, 0x71, 0x74, 0x13, 0x03,
|
||||
0xd8, 0x7f, 0xd2, 0xa1, 0x28, 0x52, 0xa5, 0x36, 0x2c, 0x65, 0xa0, 0xa2, 0x46, 0x55, 0x5f, 0x54,
|
||||
0x29, 0xf2, 0xcb, 0xe1, 0x9c, 0x9a, 0xf8, 0x22, 0xdf, 0x25, 0x22, 0xdf, 0xa0, 0x63, 0xa5, 0x56,
|
||||
0x55, 0x87, 0x0e, 0x4c, 0x1d, 0xbb, 0xf5, 0x1b, 0x74, 0x60, 0xe8, 0xc0, 0xd8, 0xc9, 0xaa, 0x60,
|
||||
0xe9, 0x9c, 0x4f, 0x50, 0xf9, 0xee, 0x08, 0x36, 0x10, 0x40, 0x4c, 0x4c, 0xbe, 0xdf, 0xcb, 0x3d,
|
||||
0xf7, 0xfc, 0x9e, 0xe7, 0x74, 0x06, 0x1a, 0xb6, 0x1d, 0xc3, 0x21, 0x01, 0x32, 0x9c, 0x2e, 0x46,
|
||||
0x3e, 0x33, 0x86, 0x1b, 0x72, 0xa5, 0xf7, 0x03, 0xc2, 0x88, 0xaa, 0x62, 0xdb, 0xd1, 0xa3, 0x06,
|
||||
0x5d, 0xa6, 0x87, 0x1b, 0xd5, 0x92, 0x47, 0x3c, 0xc2, 0xcb, 0x46, 0xb4, 0x12, 0x9d, 0xd5, 0x15,
|
||||
0x8f, 0x10, 0xaf, 0x8b, 0x0c, 0x1e, 0xd9, 0x83, 0x7d, 0xc3, 0xf2, 0x47, 0xa2, 0x04, 0xbf, 0x2a,
|
||||
0xa0, 0xbc, 0xed, 0x22, 0x9f, 0xe1, 0x7d, 0x8c, 0xdc, 0x2d, 0x0e, 0xb4, 0xc7, 0x2c, 0x86, 0xd4,
|
||||
0x0d, 0x90, 0x17, 0xb8, 0x6d, 0xec, 0x56, 0x94, 0xba, 0xb2, 0x9a, 0x6f, 0x95, 0xc6, 0xa1, 0xb6,
|
||||
0x38, 0xb2, 0x7a, 0xdd, 0x26, 0x9c, 0x94, 0xa0, 0x39, 0x2b, 0xd6, 0xdb, 0xae, 0xba, 0x0b, 0x8a,
|
||||
0x32, 0x4f, 0x23, 0x88, 0x4a, 0xba, 0xae, 0xac, 0x16, 0x1a, 0x25, 0x5d, 0x1c, 0xaf, 0x9f, 0x1d,
|
||||
0xaf, 0x3f, 0xf1, 0x47, 0xad, 0xe5, 0x71, 0xa8, 0xfd, 0x97, 0xc0, 0xe2, 0x7b, 0xa0, 0x59, 0x70,
|
||||
0xce, 0x49, 0xc0, 0xef, 0x0a, 0xa8, 0x6c, 0x11, 0x9f, 0x22, 0x9f, 0x0e, 0x28, 0x4f, 0xbd, 0xc4,
|
||||
0xac, 0xf3, 0x14, 0x61, 0xaf, 0xc3, 0xd4, 0x4d, 0x90, 0xeb, 0xf0, 0x15, 0xa7, 0x57, 0x68, 0x54,
|
||||
0xf5, 0xcb, 0x8a, 0xe8, 0xa2, 0xb7, 0x95, 0x3d, 0x0a, 0xb5, 0x94, 0x29, 0xfb, 0xd5, 0x57, 0x60,
|
||||
0xc1, 0x39, 0x43, 0xbd, 0x05, 0xd7, 0x95, 0x71, 0xa8, 0x95, 0x23, 0xae, 0xf0, 0xc2, 0x2e, 0x68,
|
||||
0xce, 0x3b, 0x09, 0x76, 0xf0, 0xa7, 0x02, 0xca, 0x42, 0xc5, 0x24, 0x6d, 0x7a, 0x17, 0x3d, 0x0f,
|
||||
0xc0, 0xe2, 0x85, 0x03, 0x69, 0x25, 0x5d, 0xcf, 0xac, 0x16, 0x1a, 0x6b, 0x57, 0x8d, 0x3a, 0x4d,
|
||||
0xa8, 0x96, 0x16, 0x0d, 0x3f, 0x0e, 0xb5, 0x65, 0x79, 0xd6, 0x05, 0x4c, 0x68, 0x2e, 0x24, 0xa7,
|
||||
0xa0, 0xf0, 0x87, 0x02, 0x4a, 0x62, 0x8c, 0x17, 0x7d, 0xd7, 0x62, 0x68, 0x37, 0x20, 0x7d, 0x42,
|
||||
0xad, 0xae, 0x5a, 0x02, 0x33, 0x0c, 0xb3, 0x2e, 0x12, 0x13, 0x98, 0x22, 0x50, 0xeb, 0xa0, 0xe0,
|
||||
0x22, 0xea, 0x04, 0xb8, 0xcf, 0x30, 0xf1, 0xb9, 0x96, 0x79, 0x33, 0x9e, 0x4a, 0x4e, 0x9f, 0xb9,
|
||||
0xd5, 0xf4, 0x6b, 0x91, 0xbd, 0x96, 0x8b, 0x82, 0x4a, 0x76, 0xba, 0x37, 0xa6, 0xec, 0x69, 0x66,
|
||||
0xdf, 0x1f, 0x6a, 0x29, 0xf8, 0x31, 0x0d, 0x16, 0x76, 0xa8, 0xb7, 0x15, 0x20, 0x8b, 0x21, 0x31,
|
||||
0xc0, 0xbd, 0xb8, 0xc8, 0xea, 0xeb, 0xcb, 0x37, 0x2e, 0x73, 0x0d, 0x68, 0x75, 0x1c, 0x6a, 0x4b,
|
||||
0x57, 0xba, 0x75, 0xe9, 0xca, 0xa9, 0x4b, 0x20, 0x47, 0xb1, 0xe7, 0x4b, 0x9d, 0xf2, 0xa6, 0x8c,
|
||||
0x9a, 0xb3, 0x91, 0x22, 0x7f, 0x23, 0x55, 0x3e, 0x29, 0x5c, 0x15, 0x61, 0xe5, 0xdd, 0x55, 0x39,
|
||||
0x37, 0x24, 0x7d, 0xb3, 0x21, 0x31, 0x5a, 0x99, 0x29, 0xb4, 0x7e, 0xa5, 0xc1, 0x22, 0xa7, 0xe5,
|
||||
0x05, 0x96, 0x7b, 0xaf, 0xdc, 0x7a, 0x0b, 0xe6, 0x07, 0x82, 0x55, 0x5b, 0xbe, 0x30, 0x99, 0x1b,
|
||||
0x5f, 0x98, 0xc9, 0x23, 0xd1, 0x84, 0xc9, 0xbd, 0xd0, 0x9c, 0x93, 0x09, 0xf9, 0x6e, 0x3d, 0x02,
|
||||
0x73, 0xfd, 0x80, 0x90, 0xfd, 0xb6, 0x4c, 0x73, 0xdf, 0x8a, 0xad, 0xca, 0x38, 0xd4, 0x4a, 0x02,
|
||||
0x20, 0x51, 0x86, 0x66, 0x91, 0xc7, 0x52, 0xa7, 0x98, 0xb0, 0x33, 0x71, 0x61, 0xe1, 0x37, 0x05,
|
||||
0x94, 0x77, 0xa8, 0xb7, 0x37, 0xb0, 0x7b, 0x98, 0xed, 0x60, 0x6a, 0xa3, 0x8e, 0x35, 0xc4, 0x64,
|
||||
0x10, 0xdc, 0x45, 0xd3, 0x4d, 0x50, 0xec, 0xc5, 0x20, 0xae, 0x75, 0x3c, 0xd1, 0x79, 0x0b, 0xdf,
|
||||
0x3f, 0x2b, 0x20, 0x27, 0xa5, 0x78, 0x0c, 0xe6, 0x87, 0x28, 0xa0, 0x98, 0xf8, 0x6d, 0x7f, 0xd0,
|
||||
0xb3, 0x51, 0xc0, 0xe9, 0x65, 0xe3, 0x62, 0x26, 0xeb, 0xd0, 0x9c, 0x93, 0x89, 0x67, 0x3c, 0x8e,
|
||||
0x23, 0x48, 0xab, 0xd2, 0xd3, 0x10, 0x26, 0x76, 0xc8, 0x84, 0xe0, 0x20, 0x88, 0x7d, 0x39, 0xd4,
|
||||
0x52, 0xad, 0xe7, 0x47, 0x27, 0x35, 0xe5, 0xf8, 0xa4, 0xa6, 0xfc, 0x39, 0xa9, 0x29, 0x1f, 0x4e,
|
||||
0x6b, 0xa9, 0xe3, 0xd3, 0x5a, 0xea, 0xf7, 0x69, 0x2d, 0xf5, 0xe6, 0xa1, 0x87, 0x59, 0x67, 0x60,
|
||||
0xeb, 0x0e, 0xe9, 0x19, 0x0e, 0xa1, 0x3d, 0x42, 0xe5, 0x67, 0x9d, 0xba, 0xef, 0x8c, 0x03, 0x63,
|
||||
0xf2, 0xaf, 0xfe, 0xbf, 0xb1, 0x2e, 0x7f, 0xd7, 0x6c, 0xd4, 0x47, 0xd4, 0xce, 0x71, 0xa5, 0x1e,
|
||||
0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x1c, 0xf5, 0xf4, 0xce, 0x07, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) {
|
||||
@ -877,13 +887,25 @@ func (m *MsgUpgradeClient) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
copy(dAtA[i:], m.Signer)
|
||||
i = encodeVarintClient(dAtA, i, uint64(len(m.Signer)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
if len(m.ProofUpgrade) > 0 {
|
||||
i -= len(m.ProofUpgrade)
|
||||
copy(dAtA[i:], m.ProofUpgrade)
|
||||
i = encodeVarintClient(dAtA, i, uint64(len(m.ProofUpgrade)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if m.UpgradeHeight != nil {
|
||||
{
|
||||
size, err := m.UpgradeHeight.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintClient(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if m.ClientState != nil {
|
||||
@ -1137,6 +1159,10 @@ func (m *MsgUpgradeClient) Size() (n int) {
|
||||
l = m.ClientState.Size()
|
||||
n += 1 + l + sovClient(uint64(l))
|
||||
}
|
||||
if m.UpgradeHeight != nil {
|
||||
l = m.UpgradeHeight.Size()
|
||||
n += 1 + l + sovClient(uint64(l))
|
||||
}
|
||||
l = len(m.ProofUpgrade)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovClient(uint64(l))
|
||||
@ -2177,6 +2203,42 @@ func (m *MsgUpgradeClient) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field UpgradeHeight", 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.UpgradeHeight == nil {
|
||||
m.UpgradeHeight = &Height{}
|
||||
}
|
||||
if err := m.UpgradeHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ProofUpgrade", wireType)
|
||||
}
|
||||
@ -2210,7 +2272,7 @@ func (m *MsgUpgradeClient) Unmarshal(dAtA []byte) error {
|
||||
m.ProofUpgrade = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType)
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ func (suite *TypesTestSuite) TestPackClientState() {
|
||||
},
|
||||
{
|
||||
"tendermint client",
|
||||
ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
true,
|
||||
},
|
||||
{
|
||||
|
||||
@ -72,7 +72,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
genState: types.NewGenesisState(
|
||||
[]types.IdentifiedClientState{
|
||||
types.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight),
|
||||
@ -100,7 +100,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
genState: types.NewGenesisState(
|
||||
[]types.IdentifiedClientState{
|
||||
types.NewIdentifiedClientState(
|
||||
"/~@$*", ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
"/~@$*", ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight),
|
||||
@ -128,7 +128,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
genState: types.NewGenesisState(
|
||||
[]types.IdentifiedClientState{
|
||||
types.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(exported.Localhost, localhosttypes.NewClientState("chaindID", types.ZeroHeight())),
|
||||
},
|
||||
@ -142,7 +142,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
genState: types.NewGenesisState(
|
||||
[]types.IdentifiedClientState{
|
||||
types.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
@ -170,7 +170,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
genState: types.NewGenesisState(
|
||||
[]types.IdentifiedClientState{
|
||||
types.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
|
||||
@ -178,17 +178,23 @@ func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err
|
||||
|
||||
// NewMsgUpgradeClient creates a new MsgUpgradeClient instance
|
||||
// nolint: interfacer
|
||||
func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, proofUpgrade []byte, signer sdk.AccAddress) (*MsgUpgradeClient, error) {
|
||||
func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, upgradeHeight exported.Height, proofUpgrade []byte, signer sdk.AccAddress) (*MsgUpgradeClient, error) {
|
||||
anyClient, err := PackClientState(clientState)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
height, ok := upgradeHeight.(Height)
|
||||
if !ok {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "invalid height type. expected: %T, got: %T", &Height{}, upgradeHeight)
|
||||
}
|
||||
|
||||
return &MsgUpgradeClient{
|
||||
ClientId: clientID,
|
||||
ClientState: anyClient,
|
||||
ProofUpgrade: proofUpgrade,
|
||||
Signer: signer.String(),
|
||||
ClientId: clientID,
|
||||
ClientState: anyClient,
|
||||
ProofUpgrade: proofUpgrade,
|
||||
UpgradeHeight: &height,
|
||||
Signer: signer.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -214,6 +220,12 @@ func (msg MsgUpgradeClient) ValidateBasic() error {
|
||||
if len(msg.ProofUpgrade) == 0 {
|
||||
return sdkerrors.Wrap(ErrInvalidUpgradeClient, "proof of upgrade cannot be empty")
|
||||
}
|
||||
if msg.UpgradeHeight == nil {
|
||||
return sdkerrors.Wrap(ErrInvalidUpgradeClient, "upgrade height cannot be nil")
|
||||
}
|
||||
if msg.UpgradeHeight.IsZero() {
|
||||
return sdkerrors.Wrap(ErrInvalidUpgradeClient, "upgrade height cannot be zero")
|
||||
}
|
||||
_, err = sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err)
|
||||
|
||||
@ -56,7 +56,7 @@ func (suite *TypesTestSuite) TestMarshalMsgCreateClient() {
|
||||
},
|
||||
{
|
||||
"tendermint client", func() {
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CreateTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
@ -108,7 +108,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
|
||||
{
|
||||
"valid - tendermint client",
|
||||
func() {
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CreateTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
@ -132,7 +132,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
|
||||
{
|
||||
"failed to unpack consensus state",
|
||||
func() {
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CreateTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
msg.ConsensusState = nil
|
||||
@ -339,6 +339,8 @@ func (suite *TypesTestSuite) TestMarshalMsgUpgradeClient() {
|
||||
err error
|
||||
)
|
||||
|
||||
newClientHeight := types.NewHeight(1, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
malleate func()
|
||||
@ -346,8 +348,8 @@ func (suite *TypesTestSuite) TestMarshalMsgUpgradeClient() {
|
||||
{
|
||||
"client upgrades to new tendermint client",
|
||||
func() {
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
msg, err = types.NewMsgUpgradeClient("clientid", tendermintClient, []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress())
|
||||
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
msg, err = types.NewMsgUpgradeClient("clientid", tendermintClient, newClientHeight, []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
@ -355,7 +357,7 @@ func (suite *TypesTestSuite) TestMarshalMsgUpgradeClient() {
|
||||
"client upgrades to new solomachine client",
|
||||
func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 1)
|
||||
msg, err = types.NewMsgUpgradeClient("clientid", soloMachine.ClientState(), []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress())
|
||||
msg, err = types.NewMsgUpgradeClient("clientid", soloMachine.ClientState(), newClientHeight, []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
@ -410,6 +412,20 @@ func (suite *TypesTestSuite) TestMsgUpgradeClient_ValidateBasic() {
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "upgrade height is nil",
|
||||
malleate: func(msg *types.MsgUpgradeClient) {
|
||||
msg.UpgradeHeight = nil
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "upgrade height is zero",
|
||||
malleate: func(msg *types.MsgUpgradeClient) {
|
||||
msg.UpgradeHeight = &types.Height{}
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "unpacking clientstate fails",
|
||||
malleate: func(msg *types.MsgUpgradeClient) {
|
||||
@ -446,8 +462,9 @@ func (suite *TypesTestSuite) TestMsgUpgradeClient_ValidateBasic() {
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
|
||||
clientState := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false)
|
||||
msg, _ := types.NewMsgUpgradeClient("testclientid", clientState, []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress())
|
||||
clientState := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
|
||||
newClientHeight := types.NewHeight(1, 1)
|
||||
msg, _ := types.NewMsgUpgradeClient("testclientid", clientState, newClientHeight, []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress())
|
||||
|
||||
tc.malleate(msg)
|
||||
err := msg.ValidateBasic()
|
||||
|
||||
@ -101,7 +101,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
||||
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
||||
|
||||
clientState := ibctmtypes.NewClientState(
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false,
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false,
|
||||
)
|
||||
|
||||
// Pack consensus state into any to test unpacking error
|
||||
@ -113,7 +113,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
||||
|
||||
// invalidClientState fails validateBasic
|
||||
invalidClient := ibctmtypes.NewClientState(
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false,
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false,
|
||||
)
|
||||
provedID := ""
|
||||
|
||||
@ -155,7 +155,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
||||
func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
||||
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
||||
clientState := ibctmtypes.NewClientState(
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false,
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false,
|
||||
)
|
||||
|
||||
// Pack consensus state into any to test unpacking error
|
||||
@ -166,7 +166,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
||||
|
||||
// invalidClientState fails validateBasic
|
||||
invalidClient := ibctmtypes.NewClientState(
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false,
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false,
|
||||
)
|
||||
connectionID := "ibcconntest"
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ type ClientState interface {
|
||||
cdc codec.BinaryMarshaler,
|
||||
store sdk.KVStore,
|
||||
newClient ClientState,
|
||||
upgradeHeight Height,
|
||||
proofUpgrade []byte,
|
||||
) error
|
||||
// Utility function that zeroes out any client customizable fields in client state
|
||||
|
||||
@ -37,7 +37,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
||||
ClientGenesis: clienttypes.NewGenesisState(
|
||||
[]clienttypes.IdentifiedClientState{
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
@ -100,7 +100,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
||||
ClientGenesis: clienttypes.NewGenesisState(
|
||||
[]clienttypes.IdentifiedClientState{
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
exported.Localhost, localhosttypes.NewClientState("(chaindID)", clienttypes.ZeroHeight()),
|
||||
@ -169,7 +169,7 @@ func (suite *IBCTestSuite) TestInitGenesis() {
|
||||
ClientGenesis: clienttypes.NewGenesisState(
|
||||
[]clienttypes.IdentifiedClientState{
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), &ibctesting.UpgradePath, false, false),
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
),
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
|
||||
@ -79,7 +79,7 @@ func (cs ClientState) ZeroCustomFields() exported.ClientState {
|
||||
// VerifyUpgrade returns an error since solomachine client does not support upgrades
|
||||
func (cs ClientState) VerifyUpgrade(
|
||||
_ sdk.Context, _ codec.BinaryMarshaler, _ sdk.KVStore,
|
||||
_ exported.ClientState, _ []byte,
|
||||
_ exported.ClientState, _ exported.Height, _ []byte,
|
||||
) error {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade solomachine client")
|
||||
}
|
||||
|
||||
@ -120,12 +120,6 @@ func NewCreateClientCmd() *cobra.Command {
|
||||
allowUpdateAfterMisbehaviour, _ := cmd.Flags().GetBool(flagAllowUpdateAfterMisbehaviour)
|
||||
|
||||
upgradePath, _ := cmd.Flags().GetString(flagUpgradePath)
|
||||
keyPath := strings.Split(upgradePath, "/")
|
||||
if keyPath[0] == upgradePath {
|
||||
return fmt.Errorf("invalid merkle path %s", upgradePath)
|
||||
}
|
||||
|
||||
merklePath := commitmenttypes.NewMerklePath(keyPath)
|
||||
|
||||
// validate header
|
||||
if err := header.ValidateBasic(); err != nil {
|
||||
@ -136,7 +130,7 @@ func NewCreateClientCmd() *cobra.Command {
|
||||
|
||||
clientState := types.NewClientState(
|
||||
header.GetHeader().GetChainID(), trustLevel, trustingPeriod, ubdPeriod, maxClockDrift,
|
||||
height, specs, &merklePath, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour,
|
||||
height, specs, upgradePath, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour,
|
||||
)
|
||||
|
||||
consensusState := header.ConsensusState()
|
||||
|
||||
@ -28,7 +28,7 @@ func NewClientState(
|
||||
chainID string, trustLevel Fraction,
|
||||
trustingPeriod, ubdPeriod, maxClockDrift time.Duration,
|
||||
latestHeight clienttypes.Height, specs []*ics23.ProofSpec,
|
||||
upgradePath *commitmenttypes.MerklePath, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool,
|
||||
upgradePath string, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool,
|
||||
) *ClientState {
|
||||
return &ClientState{
|
||||
ChainId: chainID,
|
||||
@ -112,6 +112,14 @@ func (cs ClientState) Validate() error {
|
||||
return sdkerrors.Wrap(ErrInvalidProofSpecs, "proof spec cannot be nil")
|
||||
}
|
||||
}
|
||||
if cs.UpgradePath != "" {
|
||||
keys := strings.Split(cs.UpgradePath, "/")
|
||||
for _, k := range keys {
|
||||
if strings.TrimSpace(k) == "" {
|
||||
return sdkerrors.Wrapf(clienttypes.ErrInvalidUpgradeClient, "upgrade path contains an empty string when splitting by '/': %s", cs.UpgradePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -32,57 +32,57 @@ func (suite *TendermintTestSuite) TestValidate() {
|
||||
}{
|
||||
{
|
||||
name: "valid client",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: true,
|
||||
},
|
||||
{
|
||||
name: "valid client with nil upgrade path",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), nil, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), "", false, false),
|
||||
expPass: true,
|
||||
},
|
||||
{
|
||||
name: "invalid chainID",
|
||||
clientState: types.NewClientState(" ", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(" ", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "invalid trust level",
|
||||
clientState: types.NewClientState(chainID, types.Fraction{Numerator: 0, Denominator: 1}, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.Fraction{Numerator: 0, Denominator: 1}, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "invalid trusting period",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, 0, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, 0, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "invalid unbonding period",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, 0, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, 0, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "invalid max clock drift",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, 0, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, 0, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "invalid height",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "trusting period not less than unbonding period",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "proof specs is nil",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, nil, &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, nil, upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "proof specs contains nil",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, []*ics23.ProofSpec{ics23.TendermintSpec, nil}, &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, []*ics23.ProofSpec{ics23.TendermintSpec, nil}, upgradePath, false, false),
|
||||
expPass: false,
|
||||
},
|
||||
}
|
||||
@ -118,7 +118,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() {
|
||||
// },
|
||||
{
|
||||
name: "ApplyPrefix failed",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
consensusState: types.ConsensusState{
|
||||
Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()),
|
||||
},
|
||||
@ -127,7 +127,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() {
|
||||
},
|
||||
{
|
||||
name: "latest client height < height",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
consensusState: types.ConsensusState{
|
||||
Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()),
|
||||
},
|
||||
@ -145,7 +145,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() {
|
||||
},
|
||||
{
|
||||
name: "proof verification failed",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
consensusState: types.ConsensusState{
|
||||
Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()),
|
||||
NextValidatorsHash: suite.valsHash,
|
||||
|
||||
@ -53,7 +53,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
}{
|
||||
{
|
||||
"valid misbehavior misbehaviour",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -69,7 +69,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"valid misbehavior at height greater than last consensusState",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -85,7 +85,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"valid misbehaviour with different trusted heights",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
@ -101,7 +101,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"valid misbehaviour at a previous version",
|
||||
types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
@ -117,7 +117,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"valid misbehaviour at a future version",
|
||||
types.NewClientState(chainIDEpoch0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainIDEpoch0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
@ -133,7 +133,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"valid misbehaviour with trusted heights at a previous version",
|
||||
types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
@ -149,7 +149,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"consensus state's valset hash different from misbehaviour should still pass",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
@ -165,7 +165,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"invalid misbehavior misbehaviour from different chain",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -181,7 +181,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"invalid misbehavior misbehaviour with trusted height different from trusted consensus state",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
@ -197,7 +197,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"invalid misbehavior misbehaviour with trusted validators different from trusted consensus state",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash),
|
||||
@ -229,7 +229,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"trusted consensus state does not exist",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
nil, // consensus state for trusted height - 1 does not exist in store
|
||||
clienttypes.Height{},
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -245,7 +245,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"invalid tendermint misbehaviour",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -256,7 +256,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"rejected misbehaviour due to expired age duration",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -272,7 +272,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"rejected misbehaviour due to expired block duration",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(0, uint64(versionHeight+simapp.DefaultConsensusParams.Evidence.MaxAgeNumBlocks+1)), commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(0, uint64(versionHeight+simapp.DefaultConsensusParams.Evidence.MaxAgeNumBlocks+1)), commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -288,7 +288,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"provided height > header height",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -304,7 +304,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"unbonding period expired",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(time.Time{}, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
heightMinus1,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -320,7 +320,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"trusted validators is incorrect for given consensus state",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -336,7 +336,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"first valset has too much change",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -352,7 +352,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"second valset has too much change",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
@ -368,7 +368,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"both valsets have too much change",
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false),
|
||||
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
height,
|
||||
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
|
||||
|
||||
@ -52,7 +52,7 @@ type ClientState struct {
|
||||
// Proof specifications used in verifying counterparty state
|
||||
ProofSpecs []*_go.ProofSpec `protobuf:"bytes,8,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty" yaml:"proof_specs"`
|
||||
// Path at which next upgraded client will be committed
|
||||
UpgradePath *types1.MerklePath `protobuf:"bytes,9,opt,name=upgrade_path,json=upgradePath,proto3" json:"upgrade_path,omitempty" yaml:"upgrade_path"`
|
||||
UpgradePath string `protobuf:"bytes,9,opt,name=upgrade_path,json=upgradePath,proto3" json:"upgrade_path,omitempty" yaml:"upgrade_path"`
|
||||
// This flag, when set to true, will allow governance to recover a client
|
||||
// which has expired
|
||||
AllowUpdateAfterExpiry bool `protobuf:"varint,10,opt,name=allow_update_after_expiry,json=allowUpdateAfterExpiry,proto3" json:"allow_update_after_expiry,omitempty" yaml:"allow_update_after_expiry"`
|
||||
@ -317,76 +317,76 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_c6d6cf2b288949be = []byte{
|
||||
// 1101 bytes of a gzipped FileDescriptorProto
|
||||
// 1096 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x6f, 0xe3, 0x44,
|
||||
0x14, 0x6e, 0xda, 0xd2, 0xa6, 0x93, 0x74, 0x5b, 0xdc, 0xd2, 0x4d, 0x4b, 0x37, 0x8e, 0x0c, 0x5a,
|
||||
0x2a, 0xa4, 0xda, 0x24, 0x8b, 0x84, 0x54, 0x71, 0xc1, 0x2d, 0xa8, 0x45, 0xac, 0x54, 0xb9, 0xfc,
|
||||
0x90, 0x90, 0x58, 0x33, 0xb1, 0x27, 0xc9, 0xa8, 0xb6, 0xc7, 0x78, 0x26, 0x21, 0xe5, 0x2f, 0x00,
|
||||
0x89, 0xc3, 0x1e, 0x57, 0x9c, 0x38, 0xf0, 0x8f, 0x70, 0xdb, 0x63, 0x8f, 0x9c, 0x0c, 0x6a, 0xff,
|
||||
0x83, 0x1c, 0x39, 0xa1, 0xf9, 0xe1, 0x78, 0x9a, 0xed, 0x52, 0xed, 0x5e, 0xda, 0x79, 0xef, 0x7d,
|
||||
0xef, 0xfb, 0xec, 0x99, 0x97, 0x6f, 0x0c, 0x1c, 0xdc, 0x0d, 0x9c, 0x08, 0xf7, 0x07, 0x2c, 0x88,
|
||||
0x30, 0x4a, 0x18, 0x75, 0x18, 0x4a, 0x42, 0x94, 0xc5, 0x38, 0x61, 0xce, 0xa8, 0xad, 0x45, 0x76,
|
||||
0x9a, 0x11, 0x46, 0x8c, 0x26, 0xee, 0x06, 0xb6, 0xde, 0x60, 0x6b, 0x90, 0x51, 0x7b, 0xa7, 0xa5,
|
||||
0xf5, 0xb3, 0x8b, 0x14, 0x51, 0x67, 0x04, 0x23, 0x1c, 0x42, 0x46, 0x32, 0xc9, 0xb0, 0xb3, 0xfb,
|
||||
0x02, 0x42, 0xfc, 0x55, 0xd5, 0x8d, 0x80, 0x24, 0x3d, 0x4c, 0x9c, 0x34, 0x23, 0xa4, 0x57, 0x24,
|
||||
0x9b, 0x7d, 0x42, 0xfa, 0x11, 0x72, 0x44, 0xd4, 0x1d, 0xf6, 0x9c, 0x70, 0x98, 0x41, 0x86, 0x49,
|
||||
0xa2, 0xea, 0xe6, 0x6c, 0x9d, 0xe1, 0x18, 0x51, 0x06, 0xe3, 0xb4, 0x00, 0xf0, 0xd7, 0x0c, 0x48,
|
||||
0x86, 0x1c, 0xf9, 0xd4, 0xfc, 0xd5, 0xe4, 0x4a, 0x01, 0xde, 0x2b, 0x01, 0x24, 0x8e, 0x31, 0x8b,
|
||||
0x0b, 0xd0, 0x34, 0x52, 0xc0, 0xcd, 0x3e, 0xe9, 0x13, 0xb1, 0x74, 0xf8, 0x4a, 0x66, 0xad, 0x5f,
|
||||
0xab, 0xa0, 0x76, 0x28, 0xf8, 0xce, 0x18, 0x64, 0xc8, 0xd8, 0x06, 0xd5, 0x60, 0x00, 0x71, 0xe2,
|
||||
0xe3, 0xb0, 0x51, 0x69, 0x55, 0xf6, 0x56, 0xbc, 0x65, 0x11, 0x9f, 0x84, 0x06, 0x02, 0x35, 0x96,
|
||||
0x0d, 0x29, 0xf3, 0x23, 0x34, 0x42, 0x51, 0x63, 0xbe, 0x55, 0xd9, 0xab, 0x75, 0xf6, 0xec, 0xff,
|
||||
0xdf, 0x56, 0xfb, 0xb3, 0x0c, 0x06, 0xfc, 0x85, 0xdd, 0x9d, 0xe7, 0xb9, 0x39, 0x37, 0xc9, 0x4d,
|
||||
0xe3, 0x02, 0xc6, 0xd1, 0x81, 0xa5, 0x51, 0x59, 0x1e, 0x10, 0xd1, 0x17, 0x3c, 0x30, 0x7a, 0x60,
|
||||
0x4d, 0x44, 0x38, 0xe9, 0xfb, 0x29, 0xca, 0x30, 0x09, 0x1b, 0x0b, 0x42, 0x6a, 0xdb, 0x96, 0x9b,
|
||||
0x65, 0x17, 0x9b, 0x65, 0x1f, 0xa9, 0xcd, 0x74, 0x2d, 0xc5, 0xbd, 0xa5, 0x71, 0x97, 0xfd, 0xd6,
|
||||
0xb3, 0xbf, 0xcd, 0x8a, 0x77, 0xaf, 0xc8, 0x9e, 0x8a, 0xa4, 0x81, 0xc1, 0xfa, 0x30, 0xe9, 0x92,
|
||||
0x24, 0xd4, 0x84, 0x16, 0xef, 0x12, 0x7a, 0x47, 0x09, 0xdd, 0x97, 0x42, 0xb3, 0x04, 0x52, 0x69,
|
||||
0x6d, 0x9a, 0x56, 0x52, 0x08, 0xac, 0xc5, 0x70, 0xec, 0x07, 0x11, 0x09, 0xce, 0xfd, 0x30, 0xc3,
|
||||
0x3d, 0xd6, 0x78, 0xe3, 0x15, 0x5f, 0x69, 0xa6, 0x5f, 0x0a, 0xad, 0xc6, 0x70, 0x7c, 0xc8, 0x93,
|
||||
0x47, 0x3c, 0x67, 0x7c, 0x07, 0x56, 0x7b, 0x19, 0xf9, 0x09, 0x25, 0xfe, 0x00, 0xf1, 0x03, 0x69,
|
||||
0x2c, 0x09, 0x91, 0x1d, 0x71, 0x44, 0x7c, 0x44, 0x6c, 0x35, 0x39, 0xa3, 0xb6, 0x7d, 0x2c, 0x10,
|
||||
0xee, 0xae, 0x52, 0xd9, 0x94, 0x2a, 0x37, 0xda, 0x2d, 0xaf, 0x2e, 0x63, 0x89, 0xe5, 0xf4, 0x11,
|
||||
0x64, 0x88, 0xb2, 0x82, 0x7e, 0xf9, 0x55, 0xe9, 0x6f, 0xb4, 0x5b, 0x5e, 0x5d, 0xc6, 0x8a, 0xfe,
|
||||
0x04, 0xd4, 0xc4, 0x4f, 0xc7, 0xa7, 0x29, 0x0a, 0x68, 0xa3, 0xda, 0x5a, 0xd8, 0xab, 0x75, 0xd6,
|
||||
0x6d, 0x1c, 0xd0, 0xce, 0x23, 0xfb, 0x94, 0x57, 0xce, 0x52, 0x14, 0xb8, 0x5b, 0xe5, 0x08, 0x69,
|
||||
0x70, 0xcb, 0x03, 0x69, 0x01, 0xa1, 0xc6, 0x13, 0x50, 0x1f, 0xa6, 0xfd, 0x0c, 0x86, 0xc8, 0x4f,
|
||||
0x21, 0x1b, 0x34, 0x56, 0xc4, 0x83, 0x5a, 0xda, 0x83, 0x96, 0x3f, 0x8e, 0x51, 0xdb, 0x7e, 0x8c,
|
||||
0xb2, 0xf3, 0x08, 0x9d, 0x42, 0x36, 0x70, 0xef, 0x4f, 0x72, 0x73, 0x43, 0x9d, 0xad, 0xc6, 0x60,
|
||||
0x79, 0x35, 0x15, 0x72, 0x94, 0xe1, 0x83, 0x6d, 0x18, 0x45, 0xe4, 0x47, 0x7f, 0x98, 0x86, 0x90,
|
||||
0x21, 0x1f, 0xf6, 0x18, 0xca, 0x7c, 0x34, 0x4e, 0x71, 0x76, 0xd1, 0x00, 0xad, 0xca, 0x5e, 0xd5,
|
||||
0x7d, 0x77, 0x92, 0x9b, 0x2d, 0x49, 0xf4, 0x52, 0xa8, 0xe5, 0x6d, 0x89, 0xda, 0x57, 0xa2, 0xf4,
|
||||
0x09, 0xaf, 0x7c, 0x2a, 0x0a, 0xc6, 0x0f, 0xc0, 0xbc, 0xa5, 0x2b, 0xc6, 0xb4, 0x8b, 0x06, 0x70,
|
||||
0x84, 0xc9, 0x30, 0x6b, 0xd4, 0x84, 0xcc, 0xfb, 0x93, 0xdc, 0x7c, 0xf8, 0x52, 0x19, 0xbd, 0xc1,
|
||||
0xf2, 0x76, 0x67, 0xc5, 0x1e, 0x6b, 0xe5, 0x83, 0xc5, 0x9f, 0x7f, 0x37, 0xe7, 0xac, 0x3f, 0xe6,
|
||||
0xc1, 0xbd, 0x43, 0x92, 0x50, 0x94, 0xd0, 0x21, 0x95, 0x8e, 0xe0, 0x82, 0x95, 0xa9, 0x29, 0x09,
|
||||
0x4b, 0xe0, 0x47, 0x3e, 0x3b, 0xb6, 0x5f, 0x16, 0x08, 0xb7, 0xca, 0x8f, 0xfc, 0x29, 0x9f, 0xce,
|
||||
0xb2, 0xcd, 0xf8, 0x18, 0x2c, 0x66, 0x84, 0x30, 0xe5, 0x19, 0x77, 0x1c, 0x84, 0x47, 0x08, 0x73,
|
||||
0x17, 0x39, 0x8d, 0x27, 0xba, 0x8c, 0x5f, 0x2a, 0x60, 0x33, 0x41, 0x63, 0xe6, 0x4f, 0x0d, 0x99,
|
||||
0xfa, 0x03, 0x48, 0x07, 0xc2, 0x17, 0xea, 0xee, 0x37, 0x93, 0xdc, 0x7c, 0x5b, 0xee, 0xc1, 0x6d,
|
||||
0x28, 0xeb, 0xdf, 0xdc, 0xfc, 0xb0, 0x8f, 0xd9, 0x60, 0xd8, 0xe5, 0x72, 0xfa, 0x35, 0xa1, 0x2d,
|
||||
0x23, 0xdc, 0xa5, 0x4e, 0xf7, 0x82, 0x21, 0x6a, 0x1f, 0xa3, 0xb1, 0xcb, 0x17, 0x9e, 0xc1, 0xe9,
|
||||
0xbe, 0x9e, 0xb2, 0x1d, 0x43, 0x3a, 0x50, 0xdb, 0xf4, 0xe7, 0x3c, 0xa8, 0xeb, 0xbb, 0x67, 0xb4,
|
||||
0xc1, 0x8a, 0x1c, 0xfe, 0xa9, 0x6f, 0xba, 0x9b, 0x93, 0xdc, 0x5c, 0x97, 0x8f, 0x35, 0x2d, 0x59,
|
||||
0x5e, 0x55, 0xae, 0x4f, 0x42, 0xc3, 0xd6, 0x9c, 0x76, 0x5e, 0x74, 0x6c, 0x4c, 0x72, 0x73, 0x4d,
|
||||
0x75, 0xa8, 0x8a, 0x55, 0xda, 0x2f, 0x04, 0xd5, 0x01, 0x82, 0x21, 0xca, 0xfc, 0xb6, 0x32, 0xc4,
|
||||
0x87, 0x77, 0x79, 0xef, 0xb1, 0xc0, 0xbb, 0xcd, 0xab, 0xdc, 0x5c, 0x96, 0xeb, 0x76, 0x29, 0x51,
|
||||
0x90, 0x59, 0xde, 0xb2, 0x5c, 0xb6, 0x35, 0x89, 0x8e, 0xb2, 0xc2, 0xd7, 0x90, 0xe8, 0xbc, 0x20,
|
||||
0xd1, 0x99, 0x4a, 0x74, 0x0e, 0xaa, 0x7c, 0xff, 0x9e, 0xf1, 0x3d, 0xfc, 0x6d, 0x01, 0x2c, 0xc9,
|
||||
0x0e, 0x03, 0x82, 0x55, 0x8a, 0xfb, 0x09, 0x0a, 0x7d, 0x09, 0x53, 0x63, 0xd6, 0xd4, 0xb5, 0xe4,
|
||||
0x55, 0x7b, 0x26, 0x60, 0x4a, 0x74, 0xf7, 0x32, 0x37, 0x2b, 0xa5, 0xbb, 0xdc, 0xa0, 0xb0, 0xbc,
|
||||
0x3a, 0xd5, 0xb0, 0xdc, 0xbc, 0xa6, 0x73, 0xe1, 0x53, 0x54, 0x8c, 0xe2, 0x2d, 0x12, 0xd3, 0x03,
|
||||
0x3f, 0x43, 0xcc, 0x6d, 0x94, 0xf4, 0x37, 0xda, 0x2d, 0xaf, 0x3e, 0xd2, 0x70, 0xc6, 0xf7, 0x40,
|
||||
0x5e, 0x2f, 0x42, 0x5f, 0x98, 0xe3, 0xc2, 0x9d, 0xe6, 0xf8, 0x40, 0x99, 0xe3, 0x5b, 0xda, 0xa5,
|
||||
0x35, 0xed, 0xb7, 0xbc, 0x55, 0x95, 0x50, 0xf6, 0x18, 0x01, 0xa3, 0x40, 0x94, 0x03, 0xae, 0x4e,
|
||||
0xe9, 0xae, 0xb7, 0x78, 0x30, 0xc9, 0xcd, 0xed, 0x9b, 0x2a, 0x25, 0x87, 0xe5, 0xbd, 0xa9, 0x92,
|
||||
0xe5, 0xa8, 0x5b, 0x9f, 0x83, 0x6a, 0x71, 0x71, 0x1b, 0xbb, 0x60, 0x25, 0x19, 0xc6, 0x28, 0xe3,
|
||||
0x15, 0x71, 0x32, 0x0b, 0x5e, 0x99, 0x30, 0x5a, 0xa0, 0x16, 0xa2, 0x84, 0xc4, 0x38, 0x11, 0xf5,
|
||||
0x79, 0x51, 0xd7, 0x53, 0xee, 0x93, 0xe7, 0x57, 0xcd, 0xca, 0xe5, 0x55, 0xb3, 0xf2, 0xcf, 0x55,
|
||||
0xb3, 0xf2, 0xf4, 0xba, 0x39, 0x77, 0x79, 0xdd, 0x9c, 0xfb, 0xeb, 0xba, 0x39, 0xf7, 0xed, 0x91,
|
||||
0xf6, 0xb3, 0x0c, 0x08, 0x8d, 0x09, 0x55, 0xff, 0xf6, 0x69, 0x78, 0xee, 0x8c, 0xcb, 0x4f, 0xbc,
|
||||
0xfd, 0xe2, 0x1b, 0xef, 0x83, 0x8f, 0xf6, 0x67, 0x3f, 0xc2, 0xba, 0x4b, 0xc2, 0x85, 0x1e, 0xfd,
|
||||
0x17, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x30, 0xa4, 0x19, 0x12, 0x0a, 0x00, 0x00,
|
||||
0x14, 0x6e, 0xda, 0xb2, 0x4d, 0x27, 0xe9, 0x76, 0xf1, 0x96, 0x6e, 0x5a, 0xba, 0x71, 0x64, 0xd0,
|
||||
0x52, 0x21, 0xd5, 0x26, 0x59, 0x24, 0xa4, 0x8a, 0x0b, 0x6e, 0x41, 0x2d, 0x62, 0xa5, 0xca, 0xe5,
|
||||
0x87, 0x84, 0x04, 0x66, 0x62, 0x4f, 0x92, 0x51, 0x6d, 0x8f, 0xf1, 0x4c, 0x42, 0xca, 0x5f, 0x00,
|
||||
0xb7, 0x3d, 0xae, 0x38, 0x71, 0xe0, 0x1f, 0xe1, 0xb6, 0xc7, 0x1e, 0x39, 0x19, 0xd4, 0x5e, 0x38,
|
||||
0xe7, 0xc8, 0x09, 0xcd, 0x0f, 0xdb, 0xd3, 0x6c, 0x97, 0x6a, 0xb9, 0xb4, 0xf3, 0xde, 0xfb, 0xde,
|
||||
0xf7, 0x65, 0xde, 0xbc, 0x79, 0x63, 0xe0, 0xe0, 0x7e, 0xe0, 0x44, 0x78, 0x38, 0x62, 0x41, 0x84,
|
||||
0x51, 0xc2, 0xa8, 0xc3, 0x50, 0x12, 0xa2, 0x2c, 0xc6, 0x09, 0x73, 0x26, 0x5d, 0xcd, 0xb2, 0xd3,
|
||||
0x8c, 0x30, 0x62, 0xb4, 0x71, 0x3f, 0xb0, 0xf5, 0x04, 0x5b, 0x83, 0x4c, 0xba, 0xdb, 0x1d, 0x2d,
|
||||
0x9f, 0x9d, 0xa7, 0x88, 0x3a, 0x13, 0x18, 0xe1, 0x10, 0x32, 0x92, 0x49, 0x86, 0xed, 0x9d, 0x17,
|
||||
0x10, 0xe2, 0xaf, 0x8a, 0xde, 0x0f, 0x48, 0x32, 0xc0, 0xc4, 0x49, 0x33, 0x42, 0x06, 0x85, 0xb3,
|
||||
0x3d, 0x24, 0x64, 0x18, 0x21, 0x47, 0x58, 0xfd, 0xf1, 0xc0, 0x09, 0xc7, 0x19, 0x64, 0x98, 0x24,
|
||||
0x2a, 0x6e, 0xce, 0xc7, 0x19, 0x8e, 0x11, 0x65, 0x30, 0x4e, 0x0b, 0x00, 0xdf, 0x66, 0x40, 0x32,
|
||||
0xe4, 0xc8, 0x5f, 0xcd, 0xb7, 0x26, 0x57, 0x0a, 0xf0, 0x4e, 0x05, 0x20, 0x71, 0x8c, 0x59, 0x5c,
|
||||
0x80, 0x4a, 0x4b, 0x01, 0x37, 0x86, 0x64, 0x48, 0xc4, 0xd2, 0xe1, 0x2b, 0xe9, 0xb5, 0xfe, 0x5e,
|
||||
0x01, 0x8d, 0x03, 0xc1, 0x77, 0xca, 0x20, 0x43, 0xc6, 0x16, 0xa8, 0x07, 0x23, 0x88, 0x13, 0x1f,
|
||||
0x87, 0xad, 0x5a, 0xa7, 0xb6, 0xbb, 0xea, 0xad, 0x08, 0xfb, 0x38, 0x34, 0x10, 0x68, 0xb0, 0x6c,
|
||||
0x4c, 0x99, 0x1f, 0xa1, 0x09, 0x8a, 0x5a, 0x8b, 0x9d, 0xda, 0x6e, 0xa3, 0xb7, 0x6b, 0xff, 0x77,
|
||||
0x59, 0xed, 0x4f, 0x32, 0x18, 0xf0, 0x0d, 0xbb, 0xdb, 0xcf, 0x73, 0x73, 0x61, 0x96, 0x9b, 0xc6,
|
||||
0x39, 0x8c, 0xa3, 0x7d, 0x4b, 0xa3, 0xb2, 0x3c, 0x20, 0xac, 0xcf, 0xb8, 0x61, 0x0c, 0xc0, 0xba,
|
||||
0xb0, 0x70, 0x32, 0xf4, 0x53, 0x94, 0x61, 0x12, 0xb6, 0x96, 0x84, 0xd4, 0x96, 0x2d, 0x8b, 0x65,
|
||||
0x17, 0xc5, 0xb2, 0x0f, 0x55, 0x31, 0x5d, 0x4b, 0x71, 0x6f, 0x6a, 0xdc, 0x55, 0xbe, 0xf5, 0xec,
|
||||
0x4f, 0xb3, 0xe6, 0xdd, 0x2d, 0xbc, 0x27, 0xc2, 0x69, 0x60, 0x70, 0x6f, 0x9c, 0xf4, 0x49, 0x12,
|
||||
0x6a, 0x42, 0xcb, 0xb7, 0x09, 0xbd, 0xa5, 0x84, 0x1e, 0x48, 0xa1, 0x79, 0x02, 0xa9, 0xb4, 0x5e,
|
||||
0xba, 0x95, 0x14, 0x02, 0xeb, 0x31, 0x9c, 0xfa, 0x41, 0x44, 0x82, 0x33, 0x3f, 0xcc, 0xf0, 0x80,
|
||||
0xb5, 0x5e, 0x7b, 0xc5, 0x2d, 0xcd, 0xe5, 0x4b, 0xa1, 0xb5, 0x18, 0x4e, 0x0f, 0xb8, 0xf3, 0x90,
|
||||
0xfb, 0x8c, 0x6f, 0xc0, 0xda, 0x20, 0x23, 0x3f, 0xa2, 0xc4, 0x1f, 0x21, 0x7e, 0x20, 0xad, 0x3b,
|
||||
0x42, 0x64, 0x5b, 0x1c, 0x11, 0x6f, 0x11, 0x5b, 0x75, 0xce, 0xa4, 0x6b, 0x1f, 0x09, 0x84, 0xbb,
|
||||
0xa3, 0x54, 0x36, 0xa4, 0xca, 0xb5, 0x74, 0xcb, 0x6b, 0x4a, 0x5b, 0x62, 0x39, 0x7d, 0x04, 0x19,
|
||||
0xa2, 0xac, 0xa0, 0x5f, 0x79, 0x55, 0xfa, 0x6b, 0xe9, 0x96, 0xd7, 0x94, 0xb6, 0xa2, 0x3f, 0x06,
|
||||
0x0d, 0x71, 0x75, 0x7c, 0x9a, 0xa2, 0x80, 0xb6, 0xea, 0x9d, 0xa5, 0xdd, 0x46, 0xef, 0x9e, 0x8d,
|
||||
0x03, 0xda, 0x7b, 0x6c, 0x9f, 0xf0, 0xc8, 0x69, 0x8a, 0x02, 0x77, 0xb3, 0x6a, 0x21, 0x0d, 0x6e,
|
||||
0x79, 0x20, 0x2d, 0x20, 0xd4, 0xd8, 0x07, 0xcd, 0x71, 0x3a, 0xcc, 0x60, 0x88, 0xfc, 0x14, 0xb2,
|
||||
0x51, 0x6b, 0x95, 0x37, 0xb2, 0xfb, 0x60, 0x96, 0x9b, 0xf7, 0xd5, 0xb9, 0x69, 0x51, 0xcb, 0x6b,
|
||||
0x28, 0xf3, 0x04, 0xb2, 0x91, 0xe1, 0x83, 0x2d, 0x18, 0x45, 0xe4, 0x07, 0x7f, 0x9c, 0x86, 0x90,
|
||||
0x21, 0x1f, 0x0e, 0x18, 0xca, 0x7c, 0x34, 0x4d, 0x71, 0x76, 0xde, 0x02, 0x9d, 0xda, 0x6e, 0xdd,
|
||||
0x7d, 0x7b, 0x96, 0x9b, 0x1d, 0x49, 0xf4, 0x52, 0xa8, 0xe5, 0x6d, 0x8a, 0xd8, 0x17, 0x22, 0xf4,
|
||||
0x11, 0x8f, 0x7c, 0x2c, 0x02, 0xc6, 0xf7, 0xc0, 0xbc, 0x21, 0x2b, 0xc6, 0xb4, 0x8f, 0x46, 0x70,
|
||||
0x82, 0xc9, 0x38, 0x6b, 0x35, 0x84, 0xcc, 0xbb, 0xb3, 0xdc, 0x7c, 0xf4, 0x52, 0x19, 0x3d, 0xc1,
|
||||
0xf2, 0x76, 0xe6, 0xc5, 0x9e, 0x68, 0xe1, 0xfd, 0xe5, 0x9f, 0x7e, 0x35, 0x17, 0xac, 0xdf, 0x16,
|
||||
0xc1, 0xdd, 0x03, 0x92, 0x50, 0x94, 0xd0, 0x31, 0x95, 0xb7, 0xdd, 0x05, 0xab, 0xe5, 0xc0, 0x11,
|
||||
0xd7, 0x9d, 0x1f, 0xe7, 0x7c, 0x4b, 0x7e, 0x5e, 0x20, 0xdc, 0x3a, 0x3f, 0xce, 0xa7, 0xbc, 0xf3,
|
||||
0xaa, 0x34, 0xe3, 0x43, 0xb0, 0x9c, 0x11, 0xc2, 0xd4, 0x3c, 0xb0, 0xb4, 0x6e, 0xa8, 0x26, 0xd0,
|
||||
0xa4, 0x6b, 0x3f, 0x41, 0xd9, 0x59, 0x84, 0x3c, 0x42, 0x98, 0xbb, 0xcc, 0x69, 0x3c, 0x91, 0x65,
|
||||
0xfc, 0x5c, 0x03, 0x1b, 0x09, 0x9a, 0x32, 0xbf, 0x1c, 0xb6, 0xd4, 0x1f, 0x41, 0x3a, 0x12, 0x77,
|
||||
0xbe, 0xe9, 0x7e, 0x35, 0xcb, 0xcd, 0x37, 0x65, 0x0d, 0x6e, 0x42, 0x59, 0xff, 0xe4, 0xe6, 0xfb,
|
||||
0x43, 0xcc, 0x46, 0xe3, 0x3e, 0x97, 0xd3, 0x9f, 0x00, 0x6d, 0x19, 0xe1, 0x3e, 0x75, 0xfa, 0xe7,
|
||||
0x0c, 0x51, 0xfb, 0x08, 0x4d, 0x5d, 0xbe, 0xf0, 0x0c, 0x4e, 0xf7, 0x65, 0xc9, 0x76, 0x04, 0xe9,
|
||||
0x48, 0x95, 0xe9, 0xf7, 0x45, 0xd0, 0xd4, 0xab, 0x67, 0x74, 0xc1, 0xaa, 0x6c, 0xec, 0x72, 0x26,
|
||||
0xba, 0x1b, 0xb3, 0xdc, 0xbc, 0x27, 0x7f, 0x56, 0x19, 0xb2, 0xbc, 0xba, 0x5c, 0x1f, 0x87, 0x86,
|
||||
0xad, 0x4d, 0xd1, 0x45, 0x91, 0x71, 0x7f, 0x96, 0x9b, 0xeb, 0x2a, 0x43, 0x45, 0xac, 0x6a, 0xb4,
|
||||
0x42, 0x50, 0x1f, 0x21, 0x18, 0xa2, 0xcc, 0xef, 0xaa, 0x61, 0xf7, 0xe8, 0xb6, 0xb9, 0x7a, 0x24,
|
||||
0xf0, 0x6e, 0xfb, 0x32, 0x37, 0x57, 0xe4, 0xba, 0x5b, 0x49, 0x14, 0x64, 0x96, 0xb7, 0x22, 0x97,
|
||||
0x5d, 0x4d, 0xa2, 0xa7, 0xc6, 0xdc, 0xff, 0x90, 0xe8, 0xbd, 0x20, 0xd1, 0x2b, 0x25, 0x7a, 0xfb,
|
||||
0x75, 0x5e, 0xbf, 0x67, 0xbc, 0x86, 0xbf, 0x2c, 0x81, 0x3b, 0x32, 0xc3, 0x80, 0x60, 0x8d, 0xe2,
|
||||
0x61, 0x82, 0x42, 0x5f, 0xc2, 0x54, 0x9b, 0xb5, 0x75, 0x2d, 0xf9, 0x8c, 0x9e, 0x0a, 0x98, 0x12,
|
||||
0xdd, 0xb9, 0xc8, 0xcd, 0x5a, 0x35, 0x39, 0xae, 0x51, 0x58, 0x5e, 0x93, 0x6a, 0x58, 0x3e, 0x98,
|
||||
0xca, 0xbe, 0xf0, 0x29, 0x2a, 0x5a, 0xf1, 0x06, 0x89, 0xf2, 0xc0, 0x4f, 0x11, 0x73, 0x5b, 0x15,
|
||||
0xfd, 0xb5, 0x74, 0xcb, 0x6b, 0x4e, 0x34, 0x9c, 0xf1, 0x1d, 0x90, 0x4f, 0x87, 0xd0, 0x17, 0x83,
|
||||
0x6f, 0xe9, 0xd6, 0xc1, 0xf7, 0x50, 0x0d, 0xbe, 0x37, 0xb4, 0x07, 0xa9, 0xcc, 0xb7, 0xbc, 0x35,
|
||||
0xe5, 0x50, 0xa3, 0x2f, 0x02, 0x46, 0x81, 0xa8, 0x1a, 0x5c, 0x9d, 0xd2, 0x6d, 0xbb, 0x78, 0x38,
|
||||
0xcb, 0xcd, 0xad, 0xeb, 0x2a, 0x15, 0x87, 0xe5, 0xbd, 0xae, 0x9c, 0x55, 0xab, 0x5b, 0x9f, 0x82,
|
||||
0x7a, 0xf1, 0x28, 0x1b, 0x3b, 0x60, 0x35, 0x19, 0xc7, 0x28, 0xe3, 0x11, 0x71, 0x32, 0x4b, 0x5e,
|
||||
0xe5, 0x30, 0x3a, 0xa0, 0x11, 0xa2, 0x84, 0xc4, 0x38, 0x11, 0xf1, 0x45, 0x11, 0xd7, 0x5d, 0xee,
|
||||
0xb7, 0xcf, 0x2f, 0xdb, 0xb5, 0x8b, 0xcb, 0x76, 0xed, 0xaf, 0xcb, 0x76, 0xed, 0xe9, 0x55, 0x7b,
|
||||
0xe1, 0xe2, 0xaa, 0xbd, 0xf0, 0xc7, 0x55, 0x7b, 0xe1, 0xeb, 0x43, 0xed, 0x5a, 0x06, 0x84, 0xc6,
|
||||
0x84, 0xaa, 0x7f, 0x7b, 0x34, 0x3c, 0x73, 0xa6, 0xd5, 0xe7, 0xdb, 0x5e, 0xf1, 0xfd, 0xf6, 0xde,
|
||||
0x07, 0x7b, 0xf3, 0x1f, 0x58, 0xfd, 0x3b, 0x62, 0x0a, 0x3d, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff,
|
||||
0x6c, 0xfc, 0x74, 0x25, 0xee, 0x09, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *ClientState) Marshal() (dAtA []byte, err error) {
|
||||
@ -429,15 +429,10 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i--
|
||||
dAtA[i] = 0x50
|
||||
}
|
||||
if m.UpgradePath != nil {
|
||||
{
|
||||
size, err := m.UpgradePath.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(size))
|
||||
}
|
||||
if len(m.UpgradePath) > 0 {
|
||||
i -= len(m.UpgradePath)
|
||||
copy(dAtA[i:], m.UpgradePath)
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(len(m.UpgradePath)))
|
||||
i--
|
||||
dAtA[i] = 0x4a
|
||||
}
|
||||
@ -475,29 +470,29 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):])
|
||||
n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):])
|
||||
if err3 != nil {
|
||||
return 0, err3
|
||||
}
|
||||
i -= n3
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(n3))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):])
|
||||
if err4 != nil {
|
||||
return 0, err4
|
||||
}
|
||||
i -= n4
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(n4))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):])
|
||||
dAtA[i] = 0x22
|
||||
n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):])
|
||||
if err5 != nil {
|
||||
return 0, err5
|
||||
}
|
||||
i -= n5
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(n5))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):])
|
||||
if err6 != nil {
|
||||
return 0, err6
|
||||
}
|
||||
i -= n6
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(n6))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
{
|
||||
size, err := m.TrustLevel.MarshalToSizedBuffer(dAtA[:i])
|
||||
@ -556,12 +551,12 @@ func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):])
|
||||
if err9 != nil {
|
||||
return 0, err9
|
||||
n8, err8 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):])
|
||||
if err8 != nil {
|
||||
return 0, err8
|
||||
}
|
||||
i -= n9
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(n9))
|
||||
i -= n8
|
||||
i = encodeVarintTendermint(dAtA, i, uint64(n8))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
return len(dAtA) - i, nil
|
||||
@ -769,8 +764,8 @@ func (m *ClientState) Size() (n int) {
|
||||
n += 1 + l + sovTendermint(uint64(l))
|
||||
}
|
||||
}
|
||||
if m.UpgradePath != nil {
|
||||
l = m.UpgradePath.Size()
|
||||
l = len(m.UpgradePath)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTendermint(uint64(l))
|
||||
}
|
||||
if m.AllowUpdateAfterExpiry {
|
||||
@ -1165,7 +1160,7 @@ func (m *ClientState) Unmarshal(dAtA []byte) error {
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field UpgradePath", wireType)
|
||||
}
|
||||
var msglen int
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTendermint
|
||||
@ -1175,27 +1170,23 @@ func (m *ClientState) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTendermint
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTendermint
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.UpgradePath == nil {
|
||||
m.UpgradePath = &types1.MerklePath{}
|
||||
}
|
||||
if err := m.UpgradePath.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.UpgradePath = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 10:
|
||||
if wireType != 0 {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -14,11 +15,9 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
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"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
ibctestingmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
|
||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -32,9 +31,9 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
height = clienttypes.NewHeight(0, 4)
|
||||
upgradeHeight = clienttypes.NewHeight(1, 1)
|
||||
upgradePath = commitmenttypes.NewMerklePath([]string{"upgrade", upgradetypes.KeyUpgradedClient})
|
||||
height = clienttypes.NewHeight(0, 4)
|
||||
newClientHeight = clienttypes.NewHeight(1, 1)
|
||||
upgradePath = fmt.Sprintf("%s/%s", "upgrade", "upgradedClient")
|
||||
)
|
||||
|
||||
type TendermintTestSuite struct {
|
||||
|
||||
@ -57,7 +57,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "successful update with next height and same validator set",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
@ -67,7 +67,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "successful update with future height and different validator set",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus5, height, suite.headerTime, bothValSet, suite.valSet, bothSigners)
|
||||
currentTime = suite.now
|
||||
@ -77,7 +77,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "successful update with next height and different validator set",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), bothValSet.Hash())
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.headerTime, bothValSet, bothValSet, bothSigners)
|
||||
currentTime = suite.now
|
||||
@ -87,7 +87,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "successful update for a previous height",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
consStateHeight = heightMinus3
|
||||
newHeader = types.CreateTestHeader(chainID, heightMinus1, heightMinus3, suite.headerTime, bothValSet, suite.valSet, bothSigners)
|
||||
@ -98,7 +98,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "successful update for a previous version",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainIDEpoch0, height, heightMinus3, suite.headerTime, bothValSet, suite.valSet, bothSigners)
|
||||
currentTime = suite.now
|
||||
@ -108,7 +108,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update with incorrect header chain-id",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader("ethermint", heightPlus1, height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
@ -118,7 +118,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update to a future version",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainIDEpoch0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainIDEpoch0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainIDEpoch1, clienttypes.NewHeight(1, 1), height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
@ -128,7 +128,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update: header height version and trusted height version mismatch",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainIDEpoch1, clienttypes.NewHeight(1, 3), height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
@ -138,7 +138,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update with next height: update header mismatches nextValSetHash",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.headerTime, bothValSet, suite.valSet, bothSigners)
|
||||
currentTime = suite.now
|
||||
@ -148,7 +148,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update with next height: update header mismatches different nextValSetHash",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), bothValSet.Hash())
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.headerTime, suite.valSet, bothValSet, signers)
|
||||
currentTime = suite.now
|
||||
@ -158,7 +158,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update with future height: too much change in validator set",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus5, height, suite.headerTime, altValSet, suite.valSet, altSigners)
|
||||
currentTime = suite.now
|
||||
@ -168,7 +168,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful updates, passed in incorrect trusted validators for given consensus state",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus5, height, suite.headerTime, bothValSet, bothValSet, bothSigners)
|
||||
currentTime = suite.now
|
||||
@ -178,7 +178,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update: trusting period has passed since last client timestamp",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
// make current time pass trusting period from last timestamp on clientstate
|
||||
@ -189,7 +189,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update: header timestamp is past current timestamp",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
@ -199,7 +199,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update: header timestamp is not past last client timestamp",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.clientTime, suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
@ -209,7 +209,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "header basic validation failed",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
newHeader = types.CreateTestHeader(chainID, heightPlus1, height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
// cause new header to fail validatebasic by changing commit height to mismatch header height
|
||||
@ -221,7 +221,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "header height < consensus height",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, heightPlus5, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, heightPlus5, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
|
||||
// Make new header at height less than latest client state
|
||||
newHeader = types.CreateTestHeader(chainID, heightMinus1, height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -22,11 +25,22 @@ import (
|
||||
// and ProofSpecs do not match parameters set by committed client
|
||||
func (cs ClientState) VerifyUpgrade(
|
||||
ctx sdk.Context, cdc codec.BinaryMarshaler, clientStore sdk.KVStore,
|
||||
upgradedClient exported.ClientState, proofUpgrade []byte,
|
||||
upgradedClient exported.ClientState, upgradeHeight exported.Height, proofUpgrade []byte,
|
||||
) error {
|
||||
if cs.UpgradePath == nil {
|
||||
if cs.UpgradePath == "" {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade client, no upgrade path set")
|
||||
}
|
||||
upgradePath, err := constructUpgradeMerklePath(cs.UpgradePath, upgradeHeight)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade client, unescaping key with URL format failed: %v", err)
|
||||
}
|
||||
|
||||
// UpgradeHeight must be in same epoch as client state height
|
||||
if cs.GetLatestHeight().GetEpochNumber() != upgradeHeight.GetEpochNumber() {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "epoch at which upgrade occurs must be same as current client epoch. expected epoch %d, got %d",
|
||||
cs.GetLatestHeight().GetEpochNumber(), upgradeHeight.GetEpochNumber())
|
||||
}
|
||||
|
||||
tmClient, ok := upgradedClient.(*ClientState)
|
||||
if !ok {
|
||||
return sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "upgraded client must be Tendermint client. expected: %T got: %T",
|
||||
@ -34,7 +48,7 @@ func (cs ClientState) VerifyUpgrade(
|
||||
}
|
||||
|
||||
if !upgradedClient.GetLatestHeight().GT(cs.GetLatestHeight()) {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "upgrade client height %s must be greater than current client height %s",
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "upgraded client height %s must be greater than current client height %s",
|
||||
upgradedClient.GetLatestHeight(), cs.GetLatestHeight())
|
||||
}
|
||||
|
||||
@ -56,9 +70,11 @@ func (cs ClientState) VerifyUpgrade(
|
||||
}
|
||||
|
||||
// Must prove against latest consensus state to ensure we are verifying against latest upgrade plan
|
||||
consState, err := GetConsensusState(clientStore, cdc, cs.GetLatestHeight())
|
||||
// This verifies that upgrade is intended for the provided epoch, since committed client must exist
|
||||
// at this consensus state
|
||||
consState, err := GetConsensusState(clientStore, cdc, upgradeHeight)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrap(err, "could not retrieve latest consensus state")
|
||||
return sdkerrors.Wrap(err, "could not retrieve consensus state for upgradeHeight")
|
||||
}
|
||||
|
||||
if cs.IsExpired(consState.Timestamp, ctx.BlockTime()) {
|
||||
@ -85,5 +101,21 @@ func (cs ClientState) VerifyUpgrade(
|
||||
expectedClient, tmClient)
|
||||
}
|
||||
|
||||
return merkleProof.VerifyMembership(cs.ProofSpecs, consState.GetRoot(), *cs.UpgradePath, bz)
|
||||
return merkleProof.VerifyMembership(cs.ProofSpecs, consState.GetRoot(), upgradePath, bz)
|
||||
}
|
||||
|
||||
// construct MerklePath from upgradePath
|
||||
func constructUpgradeMerklePath(upgradePath string, upgradeHeight exported.Height) (commitmenttypes.MerklePath, error) {
|
||||
// assume that all keys here are separated by `/` and
|
||||
// any `/` within a merkle key is correctly escaped
|
||||
upgradeKeys := strings.Split(upgradePath, "/")
|
||||
// unescape the last key so that we can append `/{height}` to the last key
|
||||
lastKey, err := url.PathUnescape(upgradeKeys[len(upgradeKeys)-1])
|
||||
if err != nil {
|
||||
return commitmenttypes.MerklePath{}, err
|
||||
}
|
||||
// append upgradeHeight to last key in merkle path
|
||||
// this will create the IAVL key that is used to store client in upgrade store
|
||||
upgradeKeys[len(upgradeKeys)-1] = fmt.Sprintf("%s/%d", lastKey, upgradeHeight.GetEpochHeight())
|
||||
return commitmenttypes.NewMerklePath(upgradeKeys), nil
|
||||
}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
|
||||
@ -13,6 +12,7 @@ import (
|
||||
func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
var (
|
||||
upgradedClient exported.ClientState
|
||||
upgradeHeight clienttypes.Height
|
||||
clientA string
|
||||
proofUpgrade []byte
|
||||
)
|
||||
@ -26,9 +26,13 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
name: "successful upgrade",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -39,7 +43,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: true,
|
||||
},
|
||||
@ -47,12 +51,16 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
name: "successful upgrade with different client chosen parameters",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, true, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false)
|
||||
|
||||
suite.coordinator.CommitBlock(suite.chainB)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
@ -63,23 +71,26 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
|
||||
// Previous client-chosen parameters must be the same as upgraded client chosen parameters
|
||||
tmClient, _ := cs.(*types.ClientState)
|
||||
oldClient := types.NewClientState(tmClient.ChainId, types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, tmClient.LatestHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, true, false)
|
||||
oldClient := types.NewClientState(tmClient.ChainId, types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, tmClient.LatestHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false)
|
||||
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, oldClient)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: true,
|
||||
},
|
||||
{
|
||||
name: "unsuccessful upgrade: chain-specified paramaters do not match committed client",
|
||||
name: "unsuccessful upgrade: upgrade height epoch does not match current client epoch",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
// zero custom fields and store in upgrade store
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), upgradedClient)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = types.NewClientState("wrongchainID", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, true, true)
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = clienttypes.NewHeight(10, uint64(suite.chainB.GetContext().BlockHeight()+1))
|
||||
|
||||
// zero custom fields and store in upgrade store
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
suite.coordinator.CommitBlock(suite.chainB)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
@ -88,7 +99,33 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "unsuccessful upgrade: chain-specified paramaters do not match committed client",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = types.NewClientState("wrongchainID", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, true)
|
||||
|
||||
suite.coordinator.CommitBlock(suite.chainB)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -96,12 +133,12 @@ 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, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
// zero custom fields and store in upgrade store
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, true, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, upgradeHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false)
|
||||
|
||||
suite.coordinator.CommitBlock(suite.chainB)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
@ -110,14 +147,14 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "unsuccessful upgrade: proof is empty",
|
||||
setup: func() {
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
proofUpgrade = []byte{}
|
||||
},
|
||||
expPass: false,
|
||||
@ -125,7 +162,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
{
|
||||
name: "unsuccessful upgrade: proof unmarshal failed",
|
||||
setup: func() {
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
proofUpgrade = []byte("proof")
|
||||
},
|
||||
expPass: false,
|
||||
@ -134,23 +171,29 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
name: "unsuccessful upgrade: proof verification failed",
|
||||
setup: func() {
|
||||
// create but do not store upgraded client
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1))
|
||||
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
fmt.Printf("%#v\n", proofUpgrade)
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "unsuccessful upgrade: upgrade path is nil",
|
||||
name: "unsuccessful upgrade: upgrade path is empty",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -161,11 +204,41 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
|
||||
// SetClientState with empty upgrade path
|
||||
tmClient, _ := cs.(*types.ClientState)
|
||||
tmClient.UpgradePath = ""
|
||||
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, tmClient)
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
name: "unsuccessful upgrade: upgrade path is malformed and cannot be correctly unescaped",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
suite.coordinator.CommitBlock(suite.chainB)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
|
||||
// SetClientState with nil upgrade path
|
||||
tmClient, _ := cs.(*types.ClientState)
|
||||
tmClient.UpgradePath = nil
|
||||
tmClient.UpgradePath = "upgraded%Client"
|
||||
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, tmClient)
|
||||
},
|
||||
expPass: false,
|
||||
@ -174,9 +247,13 @@ 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)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -187,7 +264,32 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
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)
|
||||
|
||||
// upgrade Height is at next block
|
||||
upgradeHeight = 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(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
suite.coordinator.CommitBlock(suite.chainB)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -195,9 +297,9 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
name: "unsuccessful upgrade: client is expired",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), &upgradePath, false, false)
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
// zero custom fields and store in upgrade store
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -211,7 +313,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA)
|
||||
suite.Require().True(found)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -235,6 +337,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
suite.cdc,
|
||||
clientStore,
|
||||
upgradedClient,
|
||||
upgradeHeight,
|
||||
proofUpgrade,
|
||||
)
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ func (cs ClientState) CheckProposedHeaderAndUpdateState(
|
||||
// VerifyUpgrade returns an error since localhost cannot be upgraded
|
||||
func (cs ClientState) VerifyUpgrade(
|
||||
_ sdk.Context, _ codec.BinaryMarshaler, _ sdk.KVStore,
|
||||
_ exported.ClientState, _ []byte,
|
||||
_ exported.ClientState, _ exported.Height, _ []byte,
|
||||
) error {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade localhost client")
|
||||
}
|
||||
|
||||
@ -37,7 +37,6 @@ import (
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -71,7 +70,7 @@ var (
|
||||
TestHash = tmhash.Sum([]byte("TESTING HASH"))
|
||||
TestCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
|
||||
|
||||
UpgradePath = commitmenttypes.NewMerklePath([]string{"upgrade", upgradetypes.KeyUpgradedClient})
|
||||
UpgradePath = fmt.Sprintf("%s/%s", "upgrade", "upgradedClient")
|
||||
|
||||
ConnectionVersion = connectiontypes.GetCompatibleEncodedVersions()[0]
|
||||
|
||||
@ -206,7 +205,7 @@ func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, cl
|
||||
res := chain.App.Query(abci.RequestQuery{
|
||||
Path: "store/upgrade/key",
|
||||
Height: int64(height - 1),
|
||||
Data: upgradetypes.UpgradedClientKey(),
|
||||
Data: key,
|
||||
Prove: true,
|
||||
})
|
||||
|
||||
@ -421,7 +420,7 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client
|
||||
clientState = ibctmtypes.NewClientState(
|
||||
counterparty.ChainID, DefaultTrustLevel, TrustingPeriod, UnbondingPeriod, MaxClockDrift,
|
||||
height, commitmenttypes.GetSDKSpecs(),
|
||||
&UpgradePath, false, false,
|
||||
UpgradePath, false, false,
|
||||
)
|
||||
consensusState = counterparty.LastHeader.ConsensusState()
|
||||
case SoloMachine:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,8 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmos "github.com/tendermint/tendermint/libs/os"
|
||||
@ -74,24 +76,39 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error {
|
||||
}
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
bz := k.cdc.MustMarshalBinaryBare(&plan)
|
||||
store.Set(types.PlanKey(), bz)
|
||||
|
||||
if plan.UpgradedClientState != nil {
|
||||
clientState, err := clienttypes.UnpackClientState(plan.UpgradedClientState)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not unpack clientstate: %v", err)
|
||||
if plan.UpgradedClientState == nil {
|
||||
// if latest UpgradedClientState is nil, but upgraded client exists in store,
|
||||
// then delete client state from store.
|
||||
_, height, _ := k.GetUpgradedClient(ctx)
|
||||
if height != 0 {
|
||||
store.Delete(types.UpgradedClientKey(height))
|
||||
}
|
||||
return k.SetUpgradedClient(ctx, clientState)
|
||||
return nil
|
||||
}
|
||||
// delete upgraded client key to remove any upgraded client set by outdated plan
|
||||
store.Delete(types.UpgradedClientKey())
|
||||
return nil
|
||||
|
||||
// Set UpgradedClientState in store
|
||||
clientState, err := clienttypes.UnpackClientState(plan.UpgradedClientState)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not unpack clientstate: %v", err)
|
||||
}
|
||||
// deletes any previously stored upgraded client and sets the new upgraded client in
|
||||
return k.SetUpgradedClient(ctx, plan.Height, clientState)
|
||||
}
|
||||
|
||||
// SetUpgradedClient sets the expected upgraded client for the next version of this chain
|
||||
func (k Keeper) SetUpgradedClient(ctx sdk.Context, cs ibcexported.ClientState) error {
|
||||
func (k Keeper) SetUpgradedClient(ctx sdk.Context, upgradeHeight int64, cs ibcexported.ClientState) error {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
// delete any previously stored upgraded client before setting a new one
|
||||
// since there should only ever be one upgraded client in the store at any given time
|
||||
_, setHeight, _ := k.GetUpgradedClient(ctx)
|
||||
if setHeight != 0 {
|
||||
store.Delete(types.UpgradedClientKey(setHeight))
|
||||
}
|
||||
|
||||
// zero out any custom fields before setting
|
||||
cs = cs.ZeroCustomFields()
|
||||
bz, err := clienttypes.MarshalClientState(k.cdc, cs)
|
||||
@ -99,20 +116,49 @@ func (k Keeper) SetUpgradedClient(ctx sdk.Context, cs ibcexported.ClientState) e
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not marshal clientstate: %v", err)
|
||||
}
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(types.UpgradedClientKey(), bz)
|
||||
store.Set(types.UpgradedClientKey(upgradeHeight), bz)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUpgradedClient gets the expected upgraded client for the next version of this chain
|
||||
func (k Keeper) GetUpgradedClient(ctx sdk.Context) (ibcexported.ClientState, error) {
|
||||
// along with the planned upgrade height
|
||||
// Since there is only ever one upgraded client in store, we do not need to know key beforehand
|
||||
func (k Keeper) GetUpgradedClient(ctx sdk.Context) (ibcexported.ClientState, int64, error) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(types.UpgradedClientKey())
|
||||
if len(bz) == 0 {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "no upgraded client in store")
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte(types.KeyUpgradedClient))
|
||||
var (
|
||||
count, height int
|
||||
bz []byte
|
||||
)
|
||||
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
count++
|
||||
// we must panic if the upgraded clients in store is ever more than one since
|
||||
// that would break upgrade functionality and chain must halt and fix issue manually
|
||||
if count > 1 {
|
||||
panic("more than 1 upgrade client stored in state")
|
||||
}
|
||||
|
||||
keySplit := strings.Split(string(iterator.Key()), "/")
|
||||
var err error
|
||||
height, err = strconv.Atoi(keySplit[len(keySplit)-1])
|
||||
if err != nil {
|
||||
return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "could not parse upgrade height from key: %s", err)
|
||||
}
|
||||
|
||||
bz = iterator.Value()
|
||||
}
|
||||
|
||||
return clienttypes.UnmarshalClientState(k.cdc, bz)
|
||||
if count == 0 {
|
||||
return nil, 0, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "upgrade client not found in store")
|
||||
}
|
||||
|
||||
clientState, err := clienttypes.UnmarshalClientState(k.cdc, bz)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return clientState, int64(height), nil
|
||||
}
|
||||
|
||||
// GetDoneHeight returns the height at which the given upgrade was executed
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
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"
|
||||
@ -234,12 +235,13 @@ 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)
|
||||
got, height, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(tc.plan.Height, height, "upgradedClient not stored at correct upgrade height")
|
||||
s.Require().Equal(clientState, 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)
|
||||
got, _, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx)
|
||||
s.Require().Error(err)
|
||||
s.Require().Nil(got)
|
||||
}
|
||||
@ -250,6 +252,66 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *KeeperTestSuite) TestSetUpgradedClient() {
|
||||
var (
|
||||
clientState ibcexported.ClientState
|
||||
height int64
|
||||
)
|
||||
cases := []struct {
|
||||
name string
|
||||
setup func()
|
||||
exists bool
|
||||
}{
|
||||
{
|
||||
name: "no upgraded client exists",
|
||||
setup: func() {},
|
||||
exists: false,
|
||||
},
|
||||
{
|
||||
name: "success",
|
||||
setup: func() {
|
||||
clientState = &ibctmtypes.ClientState{ChainId: "gaiachain"}
|
||||
height = 10
|
||||
|
||||
s.app.UpgradeKeeper.SetUpgradedClient(s.ctx, 10, clientState)
|
||||
},
|
||||
exists: true,
|
||||
},
|
||||
{
|
||||
name: "successful overwrite",
|
||||
setup: func() {
|
||||
clientState = &ibctmtypes.ClientState{ChainId: "gaiachain"}
|
||||
altCs := &ibctmtypes.ClientState{ChainId: "ethermint"}
|
||||
height = 10
|
||||
|
||||
s.app.UpgradeKeeper.SetUpgradedClient(s.ctx, 50, altCs)
|
||||
s.app.UpgradeKeeper.SetUpgradedClient(s.ctx, 10, clientState)
|
||||
},
|
||||
exists: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
// reset suite
|
||||
s.SetupTest()
|
||||
|
||||
// setup test case
|
||||
tc.setup()
|
||||
|
||||
gotCs, gotHeight, err := s.app.UpgradeKeeper.GetUpgradedClient(s.ctx)
|
||||
if tc.exists {
|
||||
s.Require().Equal(clientState, gotCs, "valid case: %s did not retrieve correct client state", tc.name)
|
||||
s.Require().Equal(height, gotHeight, "valid case: %s did not retrieve correct upgrade height", 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)
|
||||
s.Require().Equal(int64(0), gotHeight, "invalid case: %s retrieved valid upgrade height", tc.name)
|
||||
s.Require().Error(err, "invalid case: %s did not return error", tc.name)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestKeeperTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(KeeperTestSuite))
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package types
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
// ModuleName is the name of this module
|
||||
ModuleName = "upgrade"
|
||||
@ -33,6 +35,6 @@ func PlanKey() []byte {
|
||||
// UpgradedClientKey is the key under which the upgraded client state is saved
|
||||
// Connecting IBC chains can verify against the upgraded client in this path before
|
||||
// upgrading their clients
|
||||
func UpgradedClientKey() []byte {
|
||||
return []byte(KeyUpgradedClient)
|
||||
func UpgradedClientKey(height int64) []byte {
|
||||
return []byte(fmt.Sprintf("%s/%d", KeyUpgradedClient, height))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user