rename epoch to version (#7483)
* rename epoch to version * Apply suggestions from code review Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
1f211aad57
commit
ac9aebf4af
@ -29,7 +29,7 @@ func NewTransferTxCmd() *cobra.Command {
|
||||
Short: "Transfer a fungible token through IBC",
|
||||
Long: strings.TrimSpace(`Transfer a fungible token through IBC. Timeouts can be specified
|
||||
as absolute or relative using the "absolute-timeouts" flag. Timeout height can be set by passing in the height string
|
||||
in the form {epoch}-{height} using the "packet-timeout-height" flag. Relative timeouts are added to
|
||||
in the form {version}-{height} using the "packet-timeout-height" flag. Relative timeouts are added to
|
||||
the block height and block timestamp queried from the latest consensus state corresponding
|
||||
to the counterparty channel. Any timeout set to 0 is disabled.`),
|
||||
Example: fmt.Sprintf("%s tx ibc-transfer transfer [src-port] [src-channel] [receiver] [amount]", version.AppName),
|
||||
|
||||
@ -78,8 +78,8 @@ func QueryConsensusState(
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryConsensusStateRequest{
|
||||
ClientId: clientID,
|
||||
VersionNumber: height.GetEpochNumber(),
|
||||
VersionHeight: height.GetEpochHeight(),
|
||||
VersionNumber: height.GetVersionNumber(),
|
||||
VersionHeight: height.GetVersionHeight(),
|
||||
LatestHeight: latestHeight,
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -116,7 +116,7 @@ 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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradeHeight, proofUpgrade, suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
@ -133,7 +133,7 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
// 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())
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
|
||||
consState := ibctmtypes.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("app_hash")), []byte("next_vals_hash"))
|
||||
consAny, err := clienttypes.PackConsensusState(consState)
|
||||
@ -155,7 +155,7 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -166,7 +166,7 @@ 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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ := suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
|
||||
msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradeHeight, proofUpgrade, suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
@ -183,7 +183,7 @@ func (suite *ClientTestSuite) TestUpgradeClient() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
|
||||
@ -57,15 +57,15 @@ func (suite *KeeperTestSuite) TestCreateClient() {
|
||||
func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
// Must create header creation functions since suite.header gets recreated on each test case
|
||||
createFutureUpdateFn := func(s *KeeperTestSuite) *ibctmtypes.Header {
|
||||
heightPlus3 := clienttypes.NewHeight(suite.header.GetHeight().GetEpochNumber(), suite.header.GetHeight().GetEpochHeight()+3)
|
||||
heightPlus3 := clienttypes.NewHeight(suite.header.GetHeight().GetVersionNumber(), suite.header.GetHeight().GetVersionHeight()+3)
|
||||
height := suite.header.GetHeight().(clienttypes.Height)
|
||||
|
||||
return ibctmtypes.CreateTestHeader(testChainID, heightPlus3, height, suite.header.Header.Time.Add(time.Hour),
|
||||
suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal})
|
||||
}
|
||||
createPastUpdateFn := func(s *KeeperTestSuite) *ibctmtypes.Header {
|
||||
heightMinus2 := clienttypes.NewHeight(suite.header.GetHeight().GetEpochNumber(), suite.header.GetHeight().GetEpochHeight()-2)
|
||||
heightMinus4 := clienttypes.NewHeight(suite.header.GetHeight().GetEpochNumber(), suite.header.GetHeight().GetEpochHeight()-4)
|
||||
heightMinus2 := clienttypes.NewHeight(suite.header.GetHeight().GetVersionNumber(), suite.header.GetHeight().GetVersionHeight()-2)
|
||||
heightMinus4 := clienttypes.NewHeight(suite.header.GetHeight().GetVersionNumber(), suite.header.GetHeight().GetVersionHeight()-4)
|
||||
|
||||
return ibctmtypes.CreateTestHeader(testChainID, heightMinus2, heightMinus4, suite.header.Header.Time,
|
||||
suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal})
|
||||
@ -257,7 +257,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -268,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: true,
|
||||
},
|
||||
@ -282,7 +282,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -293,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
|
||||
clientA = "wrongclientid"
|
||||
},
|
||||
@ -309,7 +309,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -320,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
|
||||
// set frozen client in store
|
||||
tmClient, ok := cs.(*ibctmtypes.ClientState)
|
||||
@ -340,7 +340,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = ibctmtypes.NewClientState("wrongchainID", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, true, true)
|
||||
@ -352,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
|
||||
@ -182,7 +182,7 @@ func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (
|
||||
}
|
||||
// check that height version matches chainID version
|
||||
version := types.ParseChainID(ctx.ChainID())
|
||||
if version != height.GetEpochNumber() {
|
||||
if version != height.GetVersionNumber() {
|
||||
return nil, false
|
||||
}
|
||||
histInfo, found := k.stakingKeeper.GetHistoricalInfo(ctx, int64(selfHeight.VersionHeight))
|
||||
|
||||
@ -27,8 +27,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
testChainID = "gaiahub-0"
|
||||
testChainIDEpoch1 = "gaiahub-1"
|
||||
testChainID = "gaiahub-0"
|
||||
testChainIDVersion1 = "gaiahub-1"
|
||||
|
||||
testClientID = "gaiachain"
|
||||
testClientID2 = "ethbridge"
|
||||
@ -42,9 +42,9 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
testClientHeight = types.NewHeight(0, 5)
|
||||
testClientHeightEpoch1 = types.NewHeight(1, 5)
|
||||
newClientHeight = types.NewHeight(1, 1)
|
||||
testClientHeight = types.NewHeight(0, 5)
|
||||
testClientHeightVersion1 = types.NewHeight(1, 5)
|
||||
newClientHeight = types.NewHeight(1, 1)
|
||||
)
|
||||
|
||||
type KeeperTestSuite struct {
|
||||
@ -181,7 +181,7 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() {
|
||||
},
|
||||
{
|
||||
"invalid client version",
|
||||
ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeightEpoch1, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeightVersion1, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
|
||||
@ -13,10 +13,10 @@ import (
|
||||
|
||||
var _ exported.Height = (*Height)(nil)
|
||||
|
||||
// IsEpochFormat checks if a chainID is in the format required for parsing epochs
|
||||
// IsVersionFormat checks if a chainID is in the format required for parsing versions
|
||||
// The chainID must be in the form: `{chainID}-{version}
|
||||
// 24-host may enforce stricter checks on chainID
|
||||
var IsEpochFormat = regexp.MustCompile(`^.+[^-]-{1}[1-9][0-9]*$`).MatchString
|
||||
var IsVersionFormat = regexp.MustCompile(`^.+[^-]-{1}[1-9][0-9]*$`).MatchString
|
||||
|
||||
// ZeroHeight is a helper function which returns an uninitialized height.
|
||||
func ZeroHeight() Height {
|
||||
@ -31,13 +31,13 @@ func NewHeight(versionNumber, versionHeight uint64) Height {
|
||||
}
|
||||
}
|
||||
|
||||
// GetEpochNumber returns the version-number of the height
|
||||
func (h Height) GetEpochNumber() uint64 {
|
||||
// GetVersionNumber returns the version-number of the height
|
||||
func (h Height) GetVersionNumber() uint64 {
|
||||
return h.VersionNumber
|
||||
}
|
||||
|
||||
// GetEpochHeight returns the version-height of the height
|
||||
func (h Height) GetEpochHeight() uint64 {
|
||||
// GetVersionHeight returns the version-height of the height
|
||||
func (h Height) GetVersionHeight() uint64 {
|
||||
return h.VersionHeight
|
||||
}
|
||||
|
||||
@ -149,10 +149,10 @@ func ParseHeight(heightStr string) (Height, error) {
|
||||
return NewHeight(versionNumber, versionHeight), nil
|
||||
}
|
||||
|
||||
// SetEpochNumber takes a chainID in valid version format and swaps the version number
|
||||
// SetVersionNumber takes a chainID in valid version format and swaps the version number
|
||||
// in the chainID with the given version number.
|
||||
func SetEpochNumber(chainID string, version uint64) (string, error) {
|
||||
if !IsEpochFormat(chainID) {
|
||||
func SetVersionNumber(chainID string, version uint64) (string, error) {
|
||||
if !IsVersionFormat(chainID) {
|
||||
return "", sdkerrors.Wrapf(
|
||||
sdkerrors.ErrInvalidChainID, "chainID is not in version format: %s", chainID,
|
||||
)
|
||||
@ -166,10 +166,10 @@ func SetEpochNumber(chainID string, version uint64) (string, error) {
|
||||
|
||||
// ParseChainID is a utility function that returns an version number from the given ChainID.
|
||||
// ParseChainID attempts to parse a chain id in the format: `{chainID}-{version}`
|
||||
// and return the epochnumber as a uint64.
|
||||
// and return the versionnumber as a uint64.
|
||||
// If the chainID is not in the expected format, a default version value of 0 is returned.
|
||||
func ParseChainID(chainID string) uint64 {
|
||||
if !IsEpochFormat(chainID) {
|
||||
if !IsVersionFormat(chainID) {
|
||||
// chainID is not in version format, return 0 as default
|
||||
return 0
|
||||
}
|
||||
@ -183,7 +183,7 @@ func ParseChainID(chainID string) uint64 {
|
||||
}
|
||||
|
||||
// GetSelfHeight is a utility function that returns self height given context
|
||||
// Epoch number is retrieved from ctx.ChainID()
|
||||
// Version number is retrieved from ctx.ChainID()
|
||||
func GetSelfHeight(ctx sdk.Context) Height {
|
||||
version := ParseChainID(ctx.ChainID())
|
||||
return NewHeight(version, uint64(ctx.BlockHeight()))
|
||||
|
||||
@ -111,7 +111,7 @@ func TestParseChainID(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
require.Equal(t, tc.formatted, types.IsEpochFormat(tc.chainID), "case %d does not match expected format", i)
|
||||
require.Equal(t, tc.formatted, types.IsVersionFormat(tc.chainID), "case %d does not match expected format", i)
|
||||
|
||||
version := types.ParseChainID(tc.chainID)
|
||||
require.Equal(t, tc.version, version, "case %d returns incorrect version", i)
|
||||
@ -119,16 +119,16 @@ func TestParseChainID(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestSetEpochNumber(t *testing.T) {
|
||||
// Test SetEpochNumber
|
||||
chainID, err := types.SetEpochNumber("gaiamainnet", 3)
|
||||
require.Error(t, err, "invalid version format passed SetEpochNumber")
|
||||
require.Equal(t, "", chainID, "invalid version format returned non-empty string on SetEpochNumber")
|
||||
func TestSetVersionNumber(t *testing.T) {
|
||||
// Test SetVersionNumber
|
||||
chainID, err := types.SetVersionNumber("gaiamainnet", 3)
|
||||
require.Error(t, err, "invalid version format passed SetVersionNumber")
|
||||
require.Equal(t, "", chainID, "invalid version format returned non-empty string on SetVersionNumber")
|
||||
chainID = "gaiamainnet-3"
|
||||
|
||||
chainID, err = types.SetEpochNumber(chainID, 4)
|
||||
require.NoError(t, err, "valid version format failed SetEpochNumber")
|
||||
require.Equal(t, "gaiamainnet-4", chainID, "valid version format returned incorrect string on SetEpochNumber")
|
||||
chainID, err = types.SetVersionNumber(chainID, 4)
|
||||
require.NoError(t, err, "valid version format failed SetVersionNumber")
|
||||
require.Equal(t, "gaiamainnet-4", chainID, "valid version format returned incorrect string on SetVersionNumber")
|
||||
}
|
||||
|
||||
func (suite *TypesTestSuite) TestSelfHeight() {
|
||||
|
||||
@ -380,8 +380,8 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
|
||||
|
||||
req = &types.QueryConnectionConsensusStateRequest{
|
||||
ConnectionId: connA.ID,
|
||||
VersionNumber: clientState.GetLatestHeight().GetEpochNumber(),
|
||||
VersionHeight: clientState.GetLatestHeight().GetEpochHeight(),
|
||||
VersionNumber: clientState.GetLatestHeight().GetVersionNumber(),
|
||||
VersionHeight: clientState.GetLatestHeight().GetVersionHeight(),
|
||||
}
|
||||
},
|
||||
true,
|
||||
|
||||
@ -479,5 +479,5 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
|
||||
}
|
||||
|
||||
func malleateHeight(height exported.Height, diff uint64) exported.Height {
|
||||
return clienttypes.NewHeight(height.GetEpochNumber(), height.GetEpochHeight()+diff)
|
||||
return clienttypes.NewHeight(height.GetVersionNumber(), height.GetVersionHeight()+diff)
|
||||
}
|
||||
|
||||
@ -518,8 +518,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
|
||||
req = &types.QueryChannelConsensusStateRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
VersionNumber: clientState.GetLatestHeight().GetEpochNumber(),
|
||||
VersionHeight: clientState.GetLatestHeight().GetEpochHeight(),
|
||||
VersionNumber: clientState.GetLatestHeight().GetVersionNumber(),
|
||||
VersionHeight: clientState.GetLatestHeight().GetVersionHeight(),
|
||||
}
|
||||
},
|
||||
true,
|
||||
|
||||
@ -800,5 +800,5 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() {
|
||||
}
|
||||
|
||||
func malleateHeight(height exported.Height, diff uint64) exported.Height {
|
||||
return clienttypes.NewHeight(height.GetEpochNumber(), height.GetEpochHeight()+diff)
|
||||
return clienttypes.NewHeight(height.GetVersionNumber(), height.GetVersionHeight()+diff)
|
||||
}
|
||||
|
||||
@ -11,11 +11,11 @@ import (
|
||||
)
|
||||
|
||||
// CommitPacket returns a packet commitment bytes. The commitment consists of:
|
||||
// hash(timeout_timestamp + timeout_epoch + timeout_height + data) from a given packet.
|
||||
// hash(timeout_timestamp + timeout_version_number + timeout_version_height + data) from a given packet.
|
||||
func CommitPacket(packet exported.PacketI) []byte {
|
||||
buf := sdk.Uint64ToBigEndian(packet.GetTimeoutTimestamp())
|
||||
buf = append(buf, sdk.Uint64ToBigEndian(packet.GetTimeoutHeight().GetEpochNumber())...)
|
||||
buf = append(buf, sdk.Uint64ToBigEndian(packet.GetTimeoutHeight().GetEpochHeight())...)
|
||||
buf = append(buf, sdk.Uint64ToBigEndian(packet.GetTimeoutHeight().GetVersionNumber())...)
|
||||
buf = append(buf, sdk.Uint64ToBigEndian(packet.GetTimeoutHeight().GetVersionHeight())...)
|
||||
buf = append(buf, packet.GetData()...)
|
||||
return tmhash.Sum(buf)
|
||||
}
|
||||
|
||||
@ -173,8 +173,8 @@ type Height interface {
|
||||
EQ(Height) bool
|
||||
GT(Height) bool
|
||||
GTE(Height) bool
|
||||
GetEpochNumber() uint64
|
||||
GetEpochHeight() uint64
|
||||
GetVersionNumber() uint64
|
||||
GetVersionHeight() uint64
|
||||
Decrement() (Height, bool)
|
||||
String() string
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ the `VersionNumber` will get incremented. This allows IBC clients to distinguish
|
||||
block-height `n` of a previous version of the chain (at version `p`) and block-height `n` of the current
|
||||
version of the chain (at version `e`).
|
||||
|
||||
`Heights` that share the same version number can be compared by simply comparing their respective `EpochHeights`.
|
||||
Heights that do not share the same version number will only be compared using their respective `EpochNumbers`.
|
||||
`Heights` that share the same version number can be compared by simply comparing their respective `VersionHeights`.
|
||||
Heights that do not share the same version number will only be compared using their respective `VersionNumbers`.
|
||||
Thus a height `h` with version number `e+1` will always be greater than a height `g` with version number `e`,
|
||||
**REGARDLESS** of the difference in version heights.
|
||||
|
||||
@ -43,7 +43,7 @@ given by the chain's chainID, and the version height given by the Tendermint blo
|
||||
and resets its block-height, it is responsible for updating its chain-id to increment the version number.
|
||||
IBC Tendermint clients then verifies the version number against their `ChainId` and treat the `VersionHeight` as the Tendermint block-height.
|
||||
|
||||
Tendermint chains wishing to use epochs to maintain persistent IBC connections even across height-resetting upgrades must format their chain-ids
|
||||
Tendermint chains wishing to use versions to maintain persistent IBC connections even across height-resetting upgrades must format their chain-ids
|
||||
in the following manner: `{chainID}-{version_number}`. On any height-resetting upgrade, the chainID **MUST** be updated with a higher version number
|
||||
than the previous value.
|
||||
|
||||
@ -52,7 +52,7 @@ Ex:
|
||||
- Before upgrade ChainID: `gaiamainnet-3`
|
||||
- After upgrade ChainID: `gaiamainnet-4`
|
||||
|
||||
Clients that do not require epochs, such as the solo-machine client, simply hardcode `0` into the version number whenever they
|
||||
Clients that do not require versions, such as the solo-machine client, simply hardcode `0` into the version number whenever they
|
||||
need to return an IBC height when implementing IBC interfaces and use the `VersionHeight` exclusively.
|
||||
|
||||
Other client-types may implement their own logic to verify the IBC Heights that relayers provide in their `Update`, `Misbehavior`, and
|
||||
|
||||
@ -35,7 +35,7 @@ func (cs ClientState) ClientType() string {
|
||||
|
||||
// GetLatestHeight returns the latest sequence number.
|
||||
// Return exported.Height to satisfy ClientState interface
|
||||
// Epoch number is always 0 for a solo-machine.
|
||||
// Version number is always 0 for a solo-machine.
|
||||
func (cs ClientState) GetLatestHeight() exported.Height {
|
||||
return clienttypes.NewHeight(0, cs.Sequence)
|
||||
}
|
||||
@ -47,7 +47,7 @@ func (cs ClientState) IsFrozen() bool {
|
||||
|
||||
// GetFrozenHeight returns the frozen sequence of the client.
|
||||
// Return exported.Height to satisfy interface
|
||||
// Epoch number is always 0 for a solo-machine
|
||||
// Version number is always 0 for a solo-machine
|
||||
func (cs ClientState) GetFrozenHeight() exported.Height {
|
||||
return clienttypes.NewHeight(0, cs.FrozenSequence)
|
||||
}
|
||||
@ -396,11 +396,11 @@ func produceVerificationArgs(
|
||||
prefix exported.Prefix,
|
||||
proof []byte,
|
||||
) (signing.SignatureData, uint64, uint64, error) {
|
||||
if version := height.GetEpochNumber(); version != 0 {
|
||||
if version := height.GetVersionNumber(); version != 0 {
|
||||
return nil, 0, 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "version must be 0 for solomachine, got version-number: %d", version)
|
||||
}
|
||||
// sequence is encoded in the version height of height struct
|
||||
sequence := height.GetEpochHeight()
|
||||
sequence := height.GetVersionHeight()
|
||||
if cs.IsFrozen() {
|
||||
return nil, 0, 0, clienttypes.ErrClientFrozen
|
||||
}
|
||||
@ -438,7 +438,7 @@ func produceVerificationArgs(
|
||||
return nil, 0, 0, sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be empty")
|
||||
}
|
||||
|
||||
latestSequence := cs.GetLatestHeight().GetEpochHeight()
|
||||
latestSequence := cs.GetLatestHeight().GetVersionHeight()
|
||||
if latestSequence < sequence {
|
||||
return nil, 0, 0, sdkerrors.Wrapf(
|
||||
sdkerrors.ErrInvalidHeight,
|
||||
|
||||
@ -19,7 +19,7 @@ func (Header) ClientType() string {
|
||||
|
||||
// GetHeight returns the current sequence number as the height.
|
||||
// Return clientexported.Height to satisfy interface
|
||||
// Epoch number is always 0 for a solo-machine
|
||||
// Version number is always 0 for a solo-machine
|
||||
func (h Header) GetHeight() exported.Height {
|
||||
return clienttypes.NewHeight(0, h.Sequence)
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ func (misbehaviour Misbehaviour) String() string {
|
||||
|
||||
// GetHeight returns the sequence at which misbehaviour occurred.
|
||||
// Return exported.Height to satisfy interface
|
||||
// Epoch number is always 0 for a solo-machine
|
||||
// Version number is always 0 for a solo-machine
|
||||
func (misbehaviour Misbehaviour) GetHeight() exported.Height {
|
||||
return clienttypes.NewHeight(0, misbehaviour.Sequence)
|
||||
}
|
||||
|
||||
@ -10,8 +10,8 @@ func (suite *SoloMachineTestSuite) TestMisbehaviour() {
|
||||
|
||||
suite.Require().Equal(types.SoloMachine, misbehaviour.ClientType())
|
||||
suite.Require().Equal(suite.solomachine.ClientID, misbehaviour.GetClientID())
|
||||
suite.Require().Equal(uint64(0), misbehaviour.GetHeight().GetEpochNumber())
|
||||
suite.Require().Equal(suite.solomachine.Sequence, misbehaviour.GetHeight().GetEpochHeight())
|
||||
suite.Require().Equal(uint64(0), misbehaviour.GetHeight().GetVersionNumber())
|
||||
suite.Require().Equal(suite.solomachine.Sequence, misbehaviour.GetHeight().GetVersionHeight())
|
||||
}
|
||||
|
||||
func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() {
|
||||
|
||||
@ -72,7 +72,7 @@ func (suite *SoloMachineTestSuite) TestCheckProposedHeaderAndUpdateState() {
|
||||
suite.Require().Equal(smHeader.GetPubKey(), smConsState.GetPubKey())
|
||||
suite.Require().Equal(smHeader.NewDiversifier, smConsState.Diversifier)
|
||||
suite.Require().Equal(smHeader.Timestamp, smConsState.Timestamp)
|
||||
suite.Require().Equal(smHeader.GetHeight().GetEpochHeight(), cs.(*types.ClientState).Sequence)
|
||||
suite.Require().Equal(smHeader.GetHeight().GetVersionHeight(), cs.(*types.ClientState).Sequence)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Nil(cs)
|
||||
|
||||
@ -55,7 +55,7 @@ func (suite *SoloMachineTestSuite) GetSequenceFromStore() uint64 {
|
||||
var clientState exported.ClientState
|
||||
err := codec.UnmarshalAny(suite.chainA.Codec, &clientState, bz)
|
||||
suite.Require().NoError(err)
|
||||
return clientState.GetLatestHeight().GetEpochHeight()
|
||||
return clientState.GetLatestHeight().GetVersionHeight()
|
||||
}
|
||||
|
||||
func (suite *SoloMachineTestSuite) GetInvalidProof() []byte {
|
||||
|
||||
@ -56,10 +56,10 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState(
|
||||
ageDuration := ctx.BlockTime().Sub(infractionTime)
|
||||
|
||||
var ageBlocks int64
|
||||
if tmMisbehaviour.GetHeight().GetEpochNumber() == cs.LatestHeight.VersionNumber {
|
||||
if tmMisbehaviour.GetHeight().GetVersionNumber() == cs.LatestHeight.VersionNumber {
|
||||
// if the misbehaviour is in the same version as the client then
|
||||
// perform expiry check using block height in addition to time
|
||||
infractionHeight := tmMisbehaviour.GetHeight().GetEpochHeight()
|
||||
infractionHeight := tmMisbehaviour.GetHeight().GetVersionHeight()
|
||||
ageBlocks = int64(cs.LatestHeight.VersionHeight - infractionHeight)
|
||||
} else {
|
||||
// if the misbehaviour is from a different version, then the version-height
|
||||
@ -133,8 +133,8 @@ func checkMisbehaviourHeader(
|
||||
chainID := clientState.GetChainID()
|
||||
// If chainID is in version format, then set version number of chainID with the version number
|
||||
// of the misbehaviour header
|
||||
if clienttypes.IsEpochFormat(chainID) {
|
||||
chainID, _ = clienttypes.SetEpochNumber(chainID, header.GetHeight().GetEpochNumber())
|
||||
if clienttypes.IsVersionFormat(chainID) {
|
||||
chainID, _ = clienttypes.SetVersionNumber(chainID, header.GetHeight().GetVersionNumber())
|
||||
}
|
||||
|
||||
// - ValidatorSet must have 2/3 similarity with trusted FromValidatorSet
|
||||
|
||||
@ -102,15 +102,15 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"valid misbehaviour at a previous version",
|
||||
types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), ibctesting.DefaultConsensusParams, 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),
|
||||
heightMinus3,
|
||||
&types.Misbehaviour{
|
||||
Header1: types.CreateTestHeader(chainIDEpoch0, height, heightMinus1, suite.now, bothValSet, bothValSet, bothSigners),
|
||||
Header2: types.CreateTestHeader(chainIDEpoch0, height, heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
|
||||
ChainId: chainIDEpoch0,
|
||||
Header1: types.CreateTestHeader(chainIDVersion0, height, heightMinus1, suite.now, bothValSet, bothValSet, bothSigners),
|
||||
Header2: types.CreateTestHeader(chainIDVersion0, height, heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
|
||||
ChainId: chainIDVersion0,
|
||||
ClientId: chainID,
|
||||
},
|
||||
suite.now,
|
||||
@ -118,15 +118,15 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
},
|
||||
{
|
||||
"valid misbehaviour at a future version",
|
||||
types.NewClientState(chainIDEpoch0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewClientState(chainIDVersion0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, 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),
|
||||
heightMinus3,
|
||||
&types.Misbehaviour{
|
||||
Header1: types.CreateTestHeader(chainIDEpoch0, clienttypes.NewHeight(1, 3), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners),
|
||||
Header2: types.CreateTestHeader(chainIDEpoch0, clienttypes.NewHeight(1, 3), heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
|
||||
ChainId: chainIDEpoch0,
|
||||
Header1: types.CreateTestHeader(chainIDVersion0, clienttypes.NewHeight(1, 3), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners),
|
||||
Header2: types.CreateTestHeader(chainIDVersion0, clienttypes.NewHeight(1, 3), heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
|
||||
ChainId: chainIDVersion0,
|
||||
ClientId: chainID,
|
||||
},
|
||||
suite.now,
|
||||
@ -134,15 +134,15 @@ 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), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
|
||||
types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), ibctesting.DefaultConsensusParams, 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),
|
||||
heightMinus3,
|
||||
&types.Misbehaviour{
|
||||
Header1: types.CreateTestHeader(chainIDEpoch1, clienttypes.NewHeight(1, 1), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners),
|
||||
Header2: types.CreateTestHeader(chainIDEpoch1, clienttypes.NewHeight(1, 1), heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
|
||||
ChainId: chainIDEpoch1,
|
||||
Header1: types.CreateTestHeader(chainIDVersion1, clienttypes.NewHeight(1, 1), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners),
|
||||
Header2: types.CreateTestHeader(chainIDVersion1, clienttypes.NewHeight(1, 1), heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
|
||||
ChainId: chainIDVersion1,
|
||||
ClientId: chainID,
|
||||
},
|
||||
suite.now,
|
||||
|
||||
@ -213,13 +213,13 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() {
|
||||
},
|
||||
func(misbehaviour *types.Misbehaviour) error {
|
||||
// voteSet contains only altVal which is less than 2/3 of total power (height/1height)
|
||||
wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header1.GetHeight().GetEpochHeight()), 1, tmproto.PrecommitType, altValSet)
|
||||
wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header1.GetHeight().GetVersionHeight()), 1, tmproto.PrecommitType, altValSet)
|
||||
blockID, err := tmtypes.BlockIDFromProto(&misbehaviour.Header1.Commit.BlockID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmCommit, err := tmtypes.MakeCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetEpochHeight()), misbehaviour.Header1.Commit.Round, wrongVoteSet, altSigners, suite.now)
|
||||
tmCommit, err := tmtypes.MakeCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetVersionHeight()), misbehaviour.Header1.Commit.Round, wrongVoteSet, altSigners, suite.now)
|
||||
misbehaviour.Header1.Commit = tmCommit.ToProto()
|
||||
return err
|
||||
},
|
||||
@ -235,13 +235,13 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() {
|
||||
},
|
||||
func(misbehaviour *types.Misbehaviour) error {
|
||||
// voteSet contains only altVal which is less than 2/3 of total power (height/1height)
|
||||
wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header2.GetHeight().GetEpochHeight()), 1, tmproto.PrecommitType, altValSet)
|
||||
wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header2.GetHeight().GetVersionHeight()), 1, tmproto.PrecommitType, altValSet)
|
||||
blockID, err := tmtypes.BlockIDFromProto(&misbehaviour.Header2.Commit.BlockID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmCommit, err := tmtypes.MakeCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetEpochHeight()), misbehaviour.Header2.Commit.Round, wrongVoteSet, altSigners, suite.now)
|
||||
tmCommit, err := tmtypes.MakeCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetVersionHeight()), misbehaviour.Header2.Commit.Round, wrongVoteSet, altSigners, suite.now)
|
||||
misbehaviour.Header2.Commit = tmCommit.ToProto()
|
||||
return err
|
||||
},
|
||||
|
||||
@ -21,13 +21,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
chainID = "gaia"
|
||||
chainIDEpoch0 = "gaia-version-0"
|
||||
chainIDEpoch1 = "gaia-version-1"
|
||||
clientID = "gaiamainnet"
|
||||
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
||||
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
||||
maxClockDrift time.Duration = time.Second * 10
|
||||
chainID = "gaia"
|
||||
chainIDVersion0 = "gaia-version-0"
|
||||
chainIDVersion1 = "gaia-version-1"
|
||||
clientID = "gaiamainnet"
|
||||
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
||||
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
||||
maxClockDrift time.Duration = time.Second * 10
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@ -96,11 +96,11 @@ func checkValidity(
|
||||
|
||||
// UpdateClient only accepts updates with a header at the same version
|
||||
// as the trusted consensus state
|
||||
if header.GetHeight().GetEpochNumber() != header.TrustedHeight.VersionNumber {
|
||||
if header.GetHeight().GetVersionNumber() != header.TrustedHeight.VersionNumber {
|
||||
return sdkerrors.Wrapf(
|
||||
ErrInvalidHeaderHeight,
|
||||
"header height version %d does not match trusted header version %d",
|
||||
header.GetHeight().GetEpochNumber(), header.TrustedHeight.VersionNumber,
|
||||
header.GetHeight().GetVersionNumber(), header.TrustedHeight.VersionNumber,
|
||||
)
|
||||
}
|
||||
|
||||
@ -133,9 +133,9 @@ func checkValidity(
|
||||
// This is useful if the update is at a previous version rather than an update to the latest version
|
||||
// of the client.
|
||||
// The chainID must be set correctly for the previous version before attempting verification.
|
||||
// Updates for previous epochs are not supported if the chainID is not in version format.
|
||||
if clienttypes.IsEpochFormat(chainID) {
|
||||
chainID, _ = clienttypes.SetEpochNumber(chainID, header.GetHeight().GetEpochNumber())
|
||||
// Updates for previous versions are not supported if the chainID is not in version format.
|
||||
if clienttypes.IsVersionFormat(chainID) {
|
||||
chainID, _ = clienttypes.SetVersionNumber(chainID, header.GetHeight().GetVersionNumber())
|
||||
}
|
||||
|
||||
// Construct a trusted header using the fields in consensus state
|
||||
|
||||
@ -99,9 +99,9 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "successful update for a previous version",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainIDEpoch1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, 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)
|
||||
newHeader = types.CreateTestHeader(chainIDVersion0, height, heightMinus3, suite.headerTime, bothValSet, suite.valSet, bothSigners)
|
||||
currentTime = suite.now
|
||||
},
|
||||
expPass: true,
|
||||
@ -119,9 +119,9 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
{
|
||||
name: "unsuccessful update to a future version",
|
||||
setup: func() {
|
||||
clientState = types.NewClientState(chainIDEpoch0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainIDVersion0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, 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)
|
||||
newHeader = types.CreateTestHeader(chainIDVersion1, clienttypes.NewHeight(1, 1), height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
},
|
||||
expPass: false,
|
||||
@ -129,9 +129,9 @@ 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), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
clientState = types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), ibctesting.DefaultConsensusParams, 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)
|
||||
newHeader = types.CreateTestHeader(chainIDVersion1, clienttypes.NewHeight(1, 3), height, suite.headerTime, suite.valSet, suite.valSet, signers)
|
||||
currentTime = suite.now
|
||||
},
|
||||
expPass: false,
|
||||
|
||||
@ -35,10 +35,10 @@ func (cs ClientState) VerifyUpgrade(
|
||||
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())
|
||||
// UpgradeHeight must be in same version as client state height
|
||||
if cs.GetLatestHeight().GetVersionNumber() != upgradeHeight.GetVersionNumber() {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "version at which upgrade occurs must be same as current client version. expected version %d, got %d",
|
||||
cs.GetLatestHeight().GetVersionNumber(), upgradeHeight.GetVersionNumber())
|
||||
}
|
||||
|
||||
tmClient, ok := upgradedClient.(*ClientState)
|
||||
@ -70,7 +70,7 @@ func (cs ClientState) VerifyUpgrade(
|
||||
}
|
||||
|
||||
// Must prove against latest consensus state to ensure we are verifying against latest upgrade plan
|
||||
// This verifies that upgrade is intended for the provided epoch, since committed client must exist
|
||||
// This verifies that upgrade is intended for the provided version, since committed client must exist
|
||||
// at this consensus state
|
||||
consState, err := GetConsensusState(clientStore, cdc, upgradeHeight)
|
||||
if err != nil {
|
||||
@ -116,6 +116,6 @@ func constructUpgradeMerklePath(upgradePath string, upgradeHeight exported.Heigh
|
||||
}
|
||||
// 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())
|
||||
upgradeKeys[len(upgradeKeys)-1] = fmt.Sprintf("%s/%d", lastKey, upgradeHeight.GetVersionHeight())
|
||||
return commitmenttypes.NewMerklePath(upgradeKeys), nil
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -43,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: true,
|
||||
},
|
||||
@ -57,7 +57,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, false)
|
||||
@ -74,12 +74,12 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
oldClient := types.NewClientState(tmClient.ChainId, types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, tmClient.LatestHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, false)
|
||||
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, oldClient)
|
||||
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: true,
|
||||
},
|
||||
{
|
||||
name: "unsuccessful upgrade: upgrade height epoch does not match current client epoch",
|
||||
name: "unsuccessful upgrade: upgrade height version does not match current client version",
|
||||
setup: func() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
@ -88,7 +88,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -99,7 +99,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -113,7 +113,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = types.NewClientState("wrongchainID", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, true)
|
||||
@ -125,7 +125,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -135,7 +135,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
// zero custom fields and store in upgrade store
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// change upgradedClient client-specified parameters
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, upgradeHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, false)
|
||||
@ -147,7 +147,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -179,7 +179,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -193,7 +193,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -204,7 +204,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
|
||||
// SetClientState with empty upgrade path
|
||||
tmClient, _ := cs.(*types.ClientState)
|
||||
@ -223,7 +223,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -234,7 +234,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
|
||||
// SetClientState with nil upgrade path
|
||||
tmClient, _ := cs.(*types.ClientState)
|
||||
@ -253,7 +253,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -264,7 +264,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -278,7 +278,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
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)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -289,7 +289,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
@ -299,7 +299,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() {
|
||||
|
||||
upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false)
|
||||
// zero custom fields and store in upgrade store
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetEpochHeight()), upgradedClient)
|
||||
suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient)
|
||||
|
||||
// commit upgrade store changes and update clients
|
||||
|
||||
@ -313,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(int64(upgradeHeight.GetEpochHeight())), cs.GetLatestHeight().GetEpochHeight())
|
||||
proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight())
|
||||
},
|
||||
expPass: false,
|
||||
},
|
||||
|
||||
@ -123,8 +123,8 @@ func (suite *LocalhostTestSuite) TestCheckHeaderAndUpdateState() {
|
||||
clientState := types.NewClientState("chainID", clientHeight)
|
||||
cs, _, err := clientState.CheckHeaderAndUpdateState(suite.ctx, nil, nil, nil)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().Equal(uint64(0), cs.GetLatestHeight().GetEpochNumber())
|
||||
suite.Require().Equal(suite.ctx.BlockHeight(), int64(cs.GetLatestHeight().GetEpochHeight()))
|
||||
suite.Require().Equal(uint64(0), cs.GetLatestHeight().GetVersionNumber())
|
||||
suite.Require().Equal(suite.ctx.BlockHeight(), int64(cs.GetLatestHeight().GetVersionHeight()))
|
||||
suite.Require().Equal(suite.ctx.BlockHeader().ChainID, clientState.ChainId)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user