Remove GetHeight from ConsensusState (#7274)

* remove height from tm consensus state

* various updates to removing dep on GetHeight

* inital addition of wrapper around consensus state with height

* fix tests

* remove GetHeight interface func

* wip test

* add test

* apply @AdityaSripal comments

* apply @fedekunze suggestions

Co-authored-by: Aditya <adityasripal@gmail.com>
This commit is contained in:
colin axnér 2020-09-14 20:16:42 +02:00 committed by GitHub
parent 7ae84898de
commit 813be217e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 883 additions and 540 deletions

View File

@ -6,7 +6,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
// IdentifiedClientState defines a client state with additional client
// IdentifiedClientState defines a client state with an additional client
// identifier field.
message IdentifiedClientState {
// client identifier
@ -15,13 +15,22 @@ message IdentifiedClientState {
google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""];
}
// ConsensusStateWithHeight defines a consensus state with an additional height field.
message ConsensusStateWithHeight {
// consensus state height
Height height = 1 [(gogoproto.nullable) = false];
// consensus state
google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml\"consensus_state\""];
}
// ClientConsensusStates defines all the stored consensus states for a given
// client.
message ClientConsensusStates {
// client identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// consensus states associated with the client
repeated google.protobuf.Any consensus_states = 2 [(gogoproto.moretags) = "yaml:\"consensus_states\""];
// consensus states and their heights associated with the client
repeated ConsensusStateWithHeight consensus_states = 2
[(gogoproto.moretags) = "yaml:\"consensus_states\"", (gogoproto.nullable) = false];
}
// ClientUpdateProposal is a governance proposal. If it passes, the client is

View File

@ -107,7 +107,7 @@ message QueryConsensusStatesRequest {
// QueryConsensusStatesResponse is the response type for the Query/ConsensusStates RPC method
message QueryConsensusStatesResponse {
// consensus states associated with the identifier
repeated google.protobuf.Any consensus_states = 1;
repeated ConsensusStateWithHeight consensus_states = 1 [(gogoproto.nullable) = false];
// pagination response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

View File

@ -55,10 +55,8 @@ message ConsensusState {
// was stored.
google.protobuf.Timestamp timestamp = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// commitment root (i.e app hash)
ibc.commitment.MerkleRoot root = 2 [(gogoproto.nullable) = false];
// height at which the consensus state was stored.
ibc.client.Height height = 3 [(gogoproto.nullable) = false];
bytes next_validators_hash = 4 [
ibc.commitment.MerkleRoot root = 2 [(gogoproto.nullable) = false];
bytes next_validators_hash = 3 [
(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes",
(gogoproto.moretags) = "yaml:\"next_validators_hash\""
];

View File

@ -78,13 +78,13 @@ to the counterparty channel. Any timeout set to 0 is disabled.`),
// if the timeouts are not absolute, retrieve latest block height and block timestamp
// for the consensus state connected to the destination port/channel
if !absoluteTimeouts {
consensusState, _, err := channelutils.QueryLatestConsensusState(clientCtx, srcPort, srcChannel)
consensusState, height, _, err := channelutils.QueryLatestConsensusState(clientCtx, srcPort, srcChannel)
if err != nil {
return err
}
if !timeoutHeight.IsZero() {
absoluteHeight := consensusState.GetHeight().(clienttypes.Height)
absoluteHeight := height
absoluteHeight.EpochNumber += timeoutHeight.EpochNumber
absoluteHeight.EpochHeight += timeoutHeight.EpochHeight
timeoutHeight = absoluteHeight

View File

@ -1,6 +1,8 @@
package client
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
@ -23,12 +25,12 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
for _, cs := range gs.ClientsConsensus {
for _, consState := range cs.ConsensusStates {
consensusState, ok := consState.GetCachedValue().(exported.ConsensusState)
consensusState, ok := consState.ConsensusState.GetCachedValue().(exported.ConsensusState)
if !ok {
panic("invalid consensus state")
panic(fmt.Sprintf("invalid consensus state with client ID %s at height %s", cs.ClientId, consState.Height))
}
k.SetClientConsensusState(ctx, cs.ClientId, consensusState.GetHeight(), consensusState)
k.SetClientConsensusState(ctx, cs.ClientId, consState.Height, consensusState)
}
}

View File

@ -32,7 +32,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k keeper.Keeper, msg *types.MsgCreat
types.EventTypeCreateClient,
sdk.NewAttribute(types.AttributeKeyClientID, msg.ClientId),
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType().String()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusState.GetHeight().String()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()),
),
sdk.NewEvent(
sdk.EventTypeMessage,

View File

@ -27,7 +27,7 @@ func (k Keeper) CreateClient(
}
if consensusState != nil {
k.SetClientConsensusState(ctx, clientID, consensusState.GetHeight(), consensusState)
k.SetClientConsensusState(ctx, clientID, clientState.GetLatestHeight(), consensusState)
}
k.SetClientState(ctx, clientID, clientState)
@ -77,12 +77,12 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
// we don't set consensus state for localhost client
if header != nil && clientType != exported.Localhost {
k.SetClientConsensusState(ctx, clientID, header.GetHeight(), consensusState)
consensusHeight = consensusState.GetHeight()
consensusHeight = header.GetHeight()
} else {
consensusHeight = types.GetSelfHeight(ctx)
}
k.Logger(ctx).Info(fmt.Sprintf("client %s updated to height %d", clientID, clientState.GetLatestHeight()))
k.Logger(ctx).Info(fmt.Sprintf("client %s updated height %d", clientID, consensusHeight))
// emitting events in the keeper emits for both begin block and handler client updates
ctx.EventManager().EmitEvent(

View File

@ -84,7 +84,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
// store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height
incrementedClientHeight := testClientHeight.Increment()
intermediateConsState := &ibctmtypes.ConsensusState{
Height: incrementedClientHeight,
Timestamp: suite.now.Add(time.Minute),
NextValidatorsHash: suite.valSetHash,
}
@ -105,7 +104,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
// store previous consensus state
prevConsState := &ibctmtypes.ConsensusState{
Height: height1,
Timestamp: suite.past,
NextValidatorsHash: suite.valSetHash,
}
@ -115,7 +113,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
// store intermediate consensus state to check that trustedHeight does not need to be hightest consensus state before header height
intermediateConsState := &ibctmtypes.ConsensusState{
Height: height2,
Timestamp: suite.past.Add(time.Minute),
NextValidatorsHash: suite.valSetHash,
}
@ -169,7 +166,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
// store previous consensus state
prevConsState := &ibctmtypes.ConsensusState{
Height: height1,
Timestamp: suite.past,
NextValidatorsHash: suite.valSetHash,
}
@ -207,7 +203,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
suite.Require().NoError(err, err)
expConsensusState := &ibctmtypes.ConsensusState{
Height: updateHeader.GetHeight().(types.Height),
Timestamp: updateHeader.GetTime(),
Root: commitmenttypes.NewMerkleRoot(updateHeader.Header.GetAppHash()),
NextValidatorsHash: updateHeader.Header.NextValidatorsHash,
@ -314,7 +309,6 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
// store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height
intermediateConsState := &ibctmtypes.ConsensusState{
Height: heightPlus3,
Timestamp: suite.now.Add(time.Minute),
NextValidatorsHash: suite.valSetHash,
}
@ -342,7 +336,6 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
// store trusted consensus state for Header2
intermediateConsState := &ibctmtypes.ConsensusState{
Height: heightPlus3,
Timestamp: suite.now.Add(time.Minute),
NextValidatorsHash: bothValsHash,
}

View File

@ -7,7 +7,6 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -151,21 +150,21 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat
ctx := sdk.UnwrapSDKContext(c)
consensusStates := []*codectypes.Any{}
consensusStates := []types.ConsensusStateWithHeight{}
store := prefix.NewStore(ctx.KVStore(q.storeKey), host.FullKeyClientPath(req.ClientId, []byte("consensusState/")))
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
height, err := types.ParseHeight(string(key))
if err != nil {
return err
}
consensusState, err := q.UnmarshalConsensusState(value)
if err != nil {
return err
}
any, err := types.PackConsensusState(consensusState)
if err != nil {
return err
}
consensusStates = append(consensusStates, any)
consensusStates = append(consensusStates, types.NewConsensusStateWithHeight(height, consensusState))
return nil
})

View File

@ -210,10 +210,10 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
func() {
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
cs := ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), suite.consensusState.Height, nil,
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil,
)
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, suite.consensusState.GetHeight(), cs)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, cs)
var err error
expConsensusState, err = types.PackConsensusState(cs)
@ -230,7 +230,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
"success with height",
func() {
cs := ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), suite.consensusState.Height, nil,
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil,
)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, cs)
@ -272,7 +272,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
func (suite *KeeperTestSuite) TestQueryConsensusStates() {
var (
req *types.QueryConsensusStatesRequest
expConsensusStates = []*codectypes.Any(nil)
expConsensusStates = []types.ConsensusStateWithHeight{}
)
testCases := []struct {
@ -313,22 +313,20 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() {
"success",
func() {
cs := ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), suite.consensusState.Height, nil,
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil,
)
cs2 := ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp.Add(time.Second), commitmenttypes.NewMerkleRoot([]byte("hash2")), suite.consensusState.Height, nil,
suite.consensusState.Timestamp.Add(time.Second), commitmenttypes.NewMerkleRoot([]byte("hash2")), nil,
)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, cs)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight.Increment(), cs2)
any, err := types.PackConsensusState(cs)
suite.Require().NoError(err)
any2, err := types.PackConsensusState(cs2)
suite.Require().NoError(err)
// order is swapped because the res is sorted by client id
expConsensusStates = []*codectypes.Any{any, any2}
expConsensusStates = []types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(testClientHeight, cs),
types.NewConsensusStateWithHeight(testClientHeight.Increment(), cs2),
}
req = &types.QueryConsensusStatesRequest{
ClientId: testClientID,
Pagination: &query.PageRequest{
@ -356,7 +354,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() {
suite.Require().Equal(len(expConsensusStates), len(res.ConsensusStates))
for i := range expConsensusStates {
suite.Require().NotNil(res.ConsensusStates[i])
expConsensusStates[i].ClearCachedValue()
expConsensusStates[i].ConsensusState.ClearCachedValue()
suite.Require().Equal(expConsensusStates[i], res.ConsensusStates[i])
}
} else {

View File

@ -9,7 +9,6 @@ import (
"github.com/tendermint/tendermint/light"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -99,7 +98,7 @@ func (k Keeper) SetClientConsensusState(ctx sdk.Context, clientID string, height
// IterateConsensusStates provides an iterator over all stored consensus states.
// objects. For each State object, cb will be called. If the cb returns true,
// the iterator will close and stop.
func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, cs exported.ConsensusState) bool) {
func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, cs types.ConsensusStateWithHeight) bool) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, host.KeyClientStorePrefix)
@ -111,9 +110,12 @@ func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string,
continue
}
clientID := keySplit[1]
height := types.MustParseHeight(keySplit[3])
consensusState := k.MustUnmarshalConsensusState(iterator.Value())
if cb(clientID, consensusState) {
consensusStateWithHeight := types.NewConsensusStateWithHeight(height, consensusState)
if cb(clientID, consensusStateWithHeight) {
break
}
}
@ -133,18 +135,16 @@ func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusSta
clientConsStates := make(types.ClientsConsensusStates, 0)
mapClientIDToConsStateIdx := make(map[string]int)
k.IterateConsensusStates(ctx, func(clientID string, cs exported.ConsensusState) bool {
anyConsensusState := types.MustPackConsensusState(cs)
k.IterateConsensusStates(ctx, func(clientID string, cs types.ConsensusStateWithHeight) bool {
idx, ok := mapClientIDToConsStateIdx[clientID]
if ok {
clientConsStates[idx].ConsensusStates = append(clientConsStates[idx].ConsensusStates, anyConsensusState)
clientConsStates[idx].ConsensusStates = append(clientConsStates[idx].ConsensusStates, cs)
return false
}
clientConsState := types.ClientConsensusStates{
ClientId: clientID,
ConsensusStates: []*codectypes.Any{anyConsensusState},
ConsensusStates: []types.ConsensusStateWithHeight{cs},
}
clientConsStates = append(clientConsStates, clientConsState)
@ -205,7 +205,6 @@ func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (
}
consensusState := &ibctmtypes.ConsensusState{
Height: selfHeight,
Timestamp: histInfo.Header.Time,
Root: commitmenttypes.NewMerkleRoot(histInfo.Header.GetAppHash()),
NextValidatorsHash: histInfo.Header.NextValidatorsHash,

View File

@ -87,7 +87,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
suite.valSetHash = suite.valSet.Hash()
suite.header = ibctmtypes.CreateTestHeader(testChainID, height, height-1, now2, suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal})
suite.consensusState = ibctmtypes.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("hash")), testClientHeight, suite.valSetHash)
suite.consensusState = ibctmtypes.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("hash")), suite.valSetHash)
var validators stakingtypes.Validators
for i := 1; i < 11; i++ {
@ -289,7 +289,7 @@ func (suite KeeperTestSuite) TestConsensusStateHelpers() {
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState)
nextState := ibctmtypes.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("next")), types.NewHeight(0, height+5), suite.valSetHash)
nextState := ibctmtypes.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("next")), suite.valSetHash)
header := ibctmtypes.CreateTestHeader(testClientID, height+5, height, suite.header.Header.Time.Add(time.Minute),
suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal})
@ -309,31 +309,51 @@ func (suite KeeperTestSuite) TestConsensusStateHelpers() {
suite.Require().Equal(suite.consensusState, lte, "LTE helper function did not return latest client state below height: %d", height+3)
}
// 2 clients in total are created on chainA. The first client is updated so it contains an initial consensus state
// and a consensus state at the update height.
func (suite KeeperTestSuite) TestGetAllConsensusStates() {
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
clientState := suite.chainA.GetClientState(clientA)
expConsensusHeight0 := clientState.GetLatestHeight()
consensusState0, ok := suite.chainA.GetConsensusState(clientA, expConsensusHeight0)
suite.Require().True(ok)
// update client to create a second consensus state
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
suite.Require().NoError(err)
clientState = suite.chainA.GetClientState(clientA)
expConsensusHeight1 := clientState.GetLatestHeight()
suite.Require().True(expConsensusHeight1.GT(expConsensusHeight0))
consensusState1, ok := suite.chainA.GetConsensusState(clientA, expConsensusHeight1)
suite.Require().True(ok)
expConsensus := []exported.ConsensusState{
ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash")), suite.consensusState.Height, nil,
),
ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp.Add(time.Minute), commitmenttypes.NewMerkleRoot([]byte("app_hash")), suite.consensusState.Height.Increment(), nil,
),
consensusState0,
consensusState1,
}
expConsensus2 := []exported.ConsensusState{
ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp.Add(2*time.Minute), commitmenttypes.NewMerkleRoot([]byte("app_hash_2")), types.NewHeight(0, suite.consensusState.GetHeight().GetEpochHeight()+2), nil,
),
}
// create second client on chainA
clientA2, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
clientState = suite.chainA.GetClientState(clientA2)
expAnyConsensus := types.ClientsConsensusStates{
types.NewClientConsensusStates(testClientID, expConsensus),
types.NewClientConsensusStates(testClientID2, expConsensus2),
expConsensusHeight2 := clientState.GetLatestHeight()
consensusState2, ok := suite.chainA.GetConsensusState(clientA2, expConsensusHeight2)
suite.Require().True(ok)
expConsensus2 := []exported.ConsensusState{consensusState2}
expConsensusStates := types.ClientsConsensusStates{
types.NewClientConsensusStates(clientA, []types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(expConsensusHeight0.(types.Height), expConsensus[0]),
types.NewConsensusStateWithHeight(expConsensusHeight1.(types.Height), expConsensus[1]),
}),
types.NewClientConsensusStates(clientA2, []types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(expConsensusHeight2.(types.Height), expConsensus2[0]),
}),
}.Sort()
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, expConsensus[0].GetHeight(), expConsensus[0])
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, expConsensus[1].GetHeight(), expConsensus[1])
suite.keeper.SetClientConsensusState(suite.ctx, testClientID2, expConsensus2[0].GetHeight(), expConsensus2[0])
consStates := suite.keeper.GetAllConsensusStates(suite.ctx)
suite.Require().Equal(expAnyConsensus, consStates, "%s \n\n%s", expAnyConsensus, consStates)
consStates := suite.chainA.App.IBCKeeper.ClientKeeper.GetAllConsensusStates(suite.chainA.GetContext())
suite.Require().Equal(expConsensusStates, consStates, "%s \n\n%s", expConsensusStates, consStates)
}

View File

@ -27,7 +27,6 @@ func TestDecodeStore(t *testing.T) {
}
consState := &ibctmtypes.ConsensusState{
Height: height,
Timestamp: time.Now().UTC(),
}

View File

@ -9,7 +9,10 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
)
var _ codectypes.UnpackInterfacesMessage = IdentifiedClientState{}
var (
_ codectypes.UnpackInterfacesMessage = IdentifiedClientState{}
_ codectypes.UnpackInterfacesMessage = ConsensusStateWithHeight{}
)
// NewIdentifiedClientState creates a new IdentifiedClientState instance
func NewIdentifiedClientState(clientID string, clientState exported.ClientState) IdentifiedClientState {
@ -38,3 +41,31 @@ func (ics IdentifiedClientState) UnpackInterfaces(unpacker codectypes.AnyUnpacke
}
return nil
}
// NewConsensusStateWithHeight creates a new ConsensusStateWithHeight instance
func NewConsensusStateWithHeight(height Height, consensusState exported.ConsensusState) ConsensusStateWithHeight {
msg, ok := consensusState.(proto.Message)
if !ok {
panic(fmt.Errorf("cannot proto marshal %T", consensusState))
}
anyConsensusState, err := codectypes.NewAnyWithValue(msg)
if err != nil {
panic(err)
}
return ConsensusStateWithHeight{
Height: height,
ConsensusState: anyConsensusState,
}
}
// UnpackInterfaces implements UnpackInterfacesMesssage.UnpackInterfaces
func (cswh ConsensusStateWithHeight) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var consensusState exported.ConsensusState
err := unpacker.UnpackAny(cswh.ConsensusState, &consensusState)
if err != nil {
return err
}
return nil
}

View File

@ -25,7 +25,7 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// IdentifiedClientState defines a client state with additional client
// IdentifiedClientState defines a client state with an additional client
// identifier field.
type IdentifiedClientState struct {
// client identifier
@ -81,20 +81,75 @@ func (m *IdentifiedClientState) GetClientState() *types.Any {
return nil
}
// ConsensusStateWithHeight defines a consensus state with an additional height field.
type ConsensusStateWithHeight struct {
// consensus state height
Height Height `protobuf:"bytes,1,opt,name=height,proto3" json:"height"`
// consensus state
ConsensusState *types.Any `protobuf:"bytes,2,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml"consensus_state"`
}
func (m *ConsensusStateWithHeight) Reset() { *m = ConsensusStateWithHeight{} }
func (m *ConsensusStateWithHeight) String() string { return proto.CompactTextString(m) }
func (*ConsensusStateWithHeight) ProtoMessage() {}
func (*ConsensusStateWithHeight) Descriptor() ([]byte, []int) {
return fileDescriptor_226f80e576f20abd, []int{1}
}
func (m *ConsensusStateWithHeight) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ConsensusStateWithHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ConsensusStateWithHeight.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ConsensusStateWithHeight) XXX_Merge(src proto.Message) {
xxx_messageInfo_ConsensusStateWithHeight.Merge(m, src)
}
func (m *ConsensusStateWithHeight) XXX_Size() int {
return m.Size()
}
func (m *ConsensusStateWithHeight) XXX_DiscardUnknown() {
xxx_messageInfo_ConsensusStateWithHeight.DiscardUnknown(m)
}
var xxx_messageInfo_ConsensusStateWithHeight proto.InternalMessageInfo
func (m *ConsensusStateWithHeight) GetHeight() Height {
if m != nil {
return m.Height
}
return Height{}
}
func (m *ConsensusStateWithHeight) GetConsensusState() *types.Any {
if m != nil {
return m.ConsensusState
}
return nil
}
// ClientConsensusStates defines all the stored consensus states for a given
// client.
type ClientConsensusStates struct {
// client identifier
ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"`
// consensus states associated with the client
ConsensusStates []*types.Any `protobuf:"bytes,2,rep,name=consensus_states,json=consensusStates,proto3" json:"consensus_states,omitempty" yaml:"consensus_states"`
// consensus states and their heights associated with the client
ConsensusStates []ConsensusStateWithHeight `protobuf:"bytes,2,rep,name=consensus_states,json=consensusStates,proto3" json:"consensus_states" yaml:"consensus_states"`
}
func (m *ClientConsensusStates) Reset() { *m = ClientConsensusStates{} }
func (m *ClientConsensusStates) String() string { return proto.CompactTextString(m) }
func (*ClientConsensusStates) ProtoMessage() {}
func (*ClientConsensusStates) Descriptor() ([]byte, []int) {
return fileDescriptor_226f80e576f20abd, []int{1}
return fileDescriptor_226f80e576f20abd, []int{2}
}
func (m *ClientConsensusStates) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -130,7 +185,7 @@ func (m *ClientConsensusStates) GetClientId() string {
return ""
}
func (m *ClientConsensusStates) GetConsensusStates() []*types.Any {
func (m *ClientConsensusStates) GetConsensusStates() []ConsensusStateWithHeight {
if m != nil {
return m.ConsensusStates
}
@ -155,7 +210,7 @@ func (m *ClientUpdateProposal) Reset() { *m = ClientUpdateProposal{} }
func (m *ClientUpdateProposal) String() string { return proto.CompactTextString(m) }
func (*ClientUpdateProposal) ProtoMessage() {}
func (*ClientUpdateProposal) Descriptor() ([]byte, []int) {
return fileDescriptor_226f80e576f20abd, []int{2}
return fileDescriptor_226f80e576f20abd, []int{3}
}
func (m *ClientUpdateProposal) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -201,7 +256,7 @@ func (m *MsgCreateClient) Reset() { *m = MsgCreateClient{} }
func (m *MsgCreateClient) String() string { return proto.CompactTextString(m) }
func (*MsgCreateClient) ProtoMessage() {}
func (*MsgCreateClient) Descriptor() ([]byte, []int) {
return fileDescriptor_226f80e576f20abd, []int{3}
return fileDescriptor_226f80e576f20abd, []int{4}
}
func (m *MsgCreateClient) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -273,7 +328,7 @@ func (m *MsgUpdateClient) Reset() { *m = MsgUpdateClient{} }
func (m *MsgUpdateClient) String() string { return proto.CompactTextString(m) }
func (*MsgUpdateClient) ProtoMessage() {}
func (*MsgUpdateClient) Descriptor() ([]byte, []int) {
return fileDescriptor_226f80e576f20abd, []int{4}
return fileDescriptor_226f80e576f20abd, []int{5}
}
func (m *MsgUpdateClient) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -338,7 +393,7 @@ func (m *MsgSubmitMisbehaviour) Reset() { *m = MsgSubmitMisbehaviour{} }
func (m *MsgSubmitMisbehaviour) String() string { return proto.CompactTextString(m) }
func (*MsgSubmitMisbehaviour) ProtoMessage() {}
func (*MsgSubmitMisbehaviour) Descriptor() ([]byte, []int) {
return fileDescriptor_226f80e576f20abd, []int{5}
return fileDescriptor_226f80e576f20abd, []int{6}
}
func (m *MsgSubmitMisbehaviour) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -407,7 +462,7 @@ type Height struct {
func (m *Height) Reset() { *m = Height{} }
func (*Height) ProtoMessage() {}
func (*Height) Descriptor() ([]byte, []int) {
return fileDescriptor_226f80e576f20abd, []int{6}
return fileDescriptor_226f80e576f20abd, []int{7}
}
func (m *Height) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -438,6 +493,7 @@ var xxx_messageInfo_Height proto.InternalMessageInfo
func init() {
proto.RegisterType((*IdentifiedClientState)(nil), "ibc.client.IdentifiedClientState")
proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.client.ConsensusStateWithHeight")
proto.RegisterType((*ClientConsensusStates)(nil), "ibc.client.ClientConsensusStates")
proto.RegisterType((*ClientUpdateProposal)(nil), "ibc.client.ClientUpdateProposal")
proto.RegisterType((*MsgCreateClient)(nil), "ibc.client.MsgCreateClient")
@ -449,44 +505,48 @@ func init() {
func init() { proto.RegisterFile("ibc/client/client.proto", fileDescriptor_226f80e576f20abd) }
var fileDescriptor_226f80e576f20abd = []byte{
// 588 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xb1, 0x8f, 0x12, 0x4f,
0x14, 0x66, 0x38, 0x7e, 0xe4, 0x18, 0xc8, 0x8f, 0xcb, 0x0a, 0x82, 0x98, 0xec, 0x92, 0xad, 0xae,
0x90, 0x5d, 0x0f, 0x1b, 0x43, 0x07, 0x34, 0x92, 0x88, 0xb9, 0xec, 0xc5, 0x42, 0x63, 0x72, 0xd9,
0x9d, 0x9d, 0xdb, 0x9d, 0xc8, 0xee, 0x6c, 0x76, 0x66, 0x8d, 0xfc, 0x07, 0xc6, 0xca, 0xd2, 0xc2,
0xe2, 0x4a, 0xff, 0x01, 0x3b, 0xed, 0xed, 0xbc, 0xd2, 0x8a, 0x18, 0xf8, 0x0f, 0x28, 0xad, 0x0c,
0x33, 0x8b, 0xc0, 0xe5, 0x38, 0x0d, 0x5a, 0x58, 0xed, 0xbc, 0xf7, 0xe6, 0x7d, 0xef, 0xfb, 0xbe,
0x07, 0x03, 0x6b, 0xc4, 0x41, 0x26, 0x1a, 0x11, 0x1c, 0xf2, 0xf4, 0x63, 0x44, 0x31, 0xe5, 0x54,
0x81, 0xc4, 0x41, 0x86, 0xcc, 0x34, 0x2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c0, 0x12, 0x8e, 0x28, 0xf2, 0x4f, 0xc3, 0x24, 0x70, 0x70, 0x2c,
0x54, 0xe4, 0xd6, 0x7f, 0x7e, 0xeb, 0x55, 0xdd, 0x2a, 0x8a, 0xf0, 0x91, 0x88, 0x56, 0xbd, 0xbe,
0xc0, 0x12, 0x5a, 0xae, 0xe8, 0x95, 0xd5, 0x65, 0xaf, 0x9c, 0xdb, 0xd9, 0x5f, 0xfc, 0xb3, 0xde,
0x9e, 0x6b, 0x99, 0xde, 0xc3, 0xcf, 0x53, 0x15, 0x5c, 0x4c, 0x55, 0xf0, 0x6d, 0xaa, 0x82, 0x37,
0x33, 0x35, 0x73, 0x31, 0x53, 0x33, 0x5f, 0x67, 0x6a, 0xe6, 0x69, 0xfb, 0x5a, 0x75, 0x2f, 0xcd,
0xc5, 0x73, 0x7f, 0xb7, 0xdd, 0x4a, 0x5f, 0x7c, 0xa1, 0xd6, 0xc9, 0x0b, 0x07, 0xef, 0xfd, 0x08,
0x00, 0x00, 0xff, 0xff, 0x57, 0xd4, 0xed, 0x68, 0x0c, 0x06, 0x00, 0x00,
// 649 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x3f, 0x6f, 0xd3, 0x4e,
0x18, 0xce, 0x25, 0xf9, 0x45, 0xed, 0x25, 0xfa, 0xb5, 0x32, 0x09, 0x4d, 0x3b, 0xc4, 0xd1, 0x89,
0xa1, 0x03, 0xb5, 0xdb, 0xb0, 0xa0, 0x6c, 0x4d, 0x17, 0x2a, 0x51, 0x54, 0xb9, 0x42, 0xfc, 0x59,
0x2a, 0xfb, 0x7c, 0x75, 0x4e, 0xc4, 0x3e, 0xcb, 0x77, 0x46, 0xe4, 0x1b, 0x20, 0x26, 0x46, 0x06,
0x86, 0x4e, 0x7c, 0x03, 0xb6, 0xb2, 0x77, 0xa3, 0x23, 0x93, 0x85, 0xda, 0x6f, 0x90, 0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, 0x6a, 0xd2, 0xc1, 0x07, 0x3f, 0x03, 0x00, 0x00, 0xff,
0xff, 0xea, 0x4c, 0x79, 0x2a, 0xc9, 0x06, 0x00, 0x00,
}
func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) {
@ -531,6 +591,51 @@ func (m *IdentifiedClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *ConsensusStateWithHeight) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ConsensusStateWithHeight) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *ConsensusStateWithHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.ConsensusState != nil {
{
size, err := m.ConsensusState.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintClient(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
{
size, err := m.Height.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintClient(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
func (m *ClientConsensusStates) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -851,6 +956,21 @@ func (m *IdentifiedClientState) Size() (n int) {
return n
}
func (m *ConsensusStateWithHeight) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = m.Height.Size()
n += 1 + l + sovClient(uint64(l))
if m.ConsensusState != nil {
l = m.ConsensusState.Size()
n += 1 + l + sovClient(uint64(l))
}
return n
}
func (m *ClientConsensusStates) Size() (n int) {
if m == nil {
return 0
@ -1104,6 +1224,128 @@ func (m *IdentifiedClientState) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *ConsensusStateWithHeight) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowClient
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ConsensusStateWithHeight: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ConsensusStateWithHeight: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowClient
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthClient
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthClient
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", 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.ConsensusState == nil {
m.ConsensusState = &types.Any{}
}
if err := m.ConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipClient(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthClient
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthClient
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ClientConsensusStates) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -1194,7 +1436,7 @@ func (m *ClientConsensusStates) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ConsensusStates = append(m.ConsensusStates, &types.Any{})
m.ConsensusStates = append(m.ConsensusStates, ConsensusStateWithHeight{})
if err := m.ConsensusStates[len(m.ConsensusStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}

View File

@ -0,0 +1,56 @@
package types_test
import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
)
func (suite *TypesTestSuite) TestMarshalConsensusStateWithHeight() {
var (
cswh types.ConsensusStateWithHeight
)
testCases := []struct {
name string
malleate func()
}{
{
"solo machine client", func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
cswh = types.NewConsensusStateWithHeight(types.NewHeight(0, soloMachine.Sequence), soloMachine.ConsensusState())
},
},
{
"tendermint client", func() {
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
clientState := suite.chainA.GetClientState(clientA)
consensusState, ok := suite.chainA.GetConsensusState(clientA, clientState.GetLatestHeight())
suite.Require().True(ok)
cswh = types.NewConsensusStateWithHeight(clientState.GetLatestHeight().(types.Height), consensusState)
},
},
}
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupTest()
tc.malleate()
cdc := suite.chainA.App.AppCodec()
// marshal message
bz, err := cdc.MarshalJSON(&cswh)
suite.Require().NoError(err)
// unmarshal message
newCswh := &types.ConsensusStateWithHeight{}
err = cdc.UnmarshalJSON(bz, newCswh)
suite.Require().NoError(err)
})
}
}

View File

@ -25,7 +25,7 @@ func (suite *TypesTestSuite) TestPackClientState() {
}{
{
"solo machine client",
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").ClientState(),
ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "").ClientState(),
true,
},
{
@ -77,12 +77,12 @@ func (suite *TypesTestSuite) TestPackConsensusState() {
}{
{
"solo machine consensus",
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").ConsensusState(),
ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "").ConsensusState(),
true,
},
{
"tendermint consensus",
suite.chain.LastHeader.ConsensusState(),
suite.chainA.LastHeader.ConsensusState(),
true,
},
{
@ -123,12 +123,12 @@ func (suite *TypesTestSuite) TestPackHeader() {
}{
{
"solo machine header",
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").CreateHeader(),
ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "").CreateHeader(),
true,
},
{
"tendermint header",
suite.chain.LastHeader,
suite.chainA.LastHeader,
true,
},
{
@ -170,12 +170,12 @@ func (suite *TypesTestSuite) TestPackMisbehaviour() {
}{
{
"solo machine misbehaviour",
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").CreateMisbehaviour(),
ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "").CreateMisbehaviour(),
true,
},
{
"tendermint misbehaviour",
ibctmtypes.NewMisbehaviour("tendermint", suite.chain.ChainID, suite.chain.LastHeader, suite.chain.LastHeader),
ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.ChainID, suite.chainA.LastHeader, suite.chainA.LastHeader),
true,
},
{

View File

@ -47,25 +47,17 @@ func (ccs ClientsConsensusStates) UnpackInterfaces(unpacker codectypes.AnyUnpack
}
// NewClientConsensusStates creates a new ClientConsensusStates instance.
func NewClientConsensusStates(clientID string, consensusStates []exported.ConsensusState) ClientConsensusStates {
anyConsensusStates := make([]*codectypes.Any, len(consensusStates))
for i := range consensusStates {
anyConsensusStates[i] = MustPackConsensusState(consensusStates[i])
}
func NewClientConsensusStates(clientID string, consensusStates []ConsensusStateWithHeight) ClientConsensusStates {
return ClientConsensusStates{
ClientId: clientID,
ConsensusStates: anyConsensusStates,
ConsensusStates: consensusStates,
}
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (ccs ClientConsensusStates) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
for _, any := range ccs.ConsensusStates {
var consensusState exported.ConsensusState
err := unpacker.UnpackAny(any, &consensusState)
if err != nil {
for _, consStateWithHeight := range ccs.ConsensusStates {
if err := consStateWithHeight.UnpackInterfaces(unpacker); err != nil {
return err
}
}
@ -113,22 +105,26 @@ func (gs GenesisState) Validate() error {
clientState, ok := client.ClientState.GetCachedValue().(exported.ClientState)
if !ok {
return fmt.Errorf("invalid client state")
return fmt.Errorf("invalid client state with ID %s", client.ClientId)
}
if err := clientState.Validate(); err != nil {
return fmt.Errorf("invalid client %v index %d: %w", client, i, err)
}
}
for i, cs := range gs.ClientsConsensus {
if err := host.ClientIdentifierValidator(cs.ClientId); err != nil {
return fmt.Errorf("invalid client consensus state identifier %s index %d: %w", cs.ClientId, i, err)
for i, cc := range gs.ClientsConsensus {
if err := host.ClientIdentifierValidator(cc.ClientId); err != nil {
return fmt.Errorf("invalid client consensus state identifier %s index %d: %w", cc.ClientId, i, err)
}
for _, consensusState := range cs.ConsensusStates {
cs, ok := consensusState.GetCachedValue().(exported.ConsensusState)
for _, consensusState := range cc.ConsensusStates {
if consensusState.Height.IsZero() {
return fmt.Errorf("consensus state height cannot be zero")
}
cs, ok := consensusState.ConsensusState.GetCachedValue().(exported.ConsensusState)
if !ok {
return fmt.Errorf("invalid consensus state")
return fmt.Errorf("invalid consensus state with client ID %s at height %s", cc.ClientId, consensusState.Height)
}
if err := cs.ValidateBasic(); err != nil {

View File

@ -7,7 +7,9 @@ import (
"github.com/stretchr/testify/require"
tmtypes "github.com/tendermint/tendermint/types"
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
localhosttypes "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
@ -25,6 +27,22 @@ const (
var clientHeight = types.NewHeight(0, 10)
func (suite *TypesTestSuite) TestMarshalGenesisState() {
cdc := suite.chainA.App.AppCodec()
clientA, _, _, _, _, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED)
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
genesis := client.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.IBCKeeper.ClientKeeper)
bz, err := cdc.MarshalJSON(&genesis)
suite.Require().NoError(err)
suite.Require().NotNil(bz)
var gs types.GenesisState
err = cdc.UnmarshalJSON(bz, &gs)
suite.Require().NoError(err)
}
func TestValidateGenesis(t *testing.T) {
privVal := ibctestingmock.NewPV()
pubKey, err := privVal.GetPubKey()
@ -61,9 +79,12 @@ func TestValidateGenesis(t *testing.T) {
[]types.ClientConsensusStates{
types.NewClientConsensusStates(
clientID,
[]exported.ConsensusState{
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.GetHeight().(types.Height), header.Header.NextValidatorsHash,
[]types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(
header.GetHeight().(types.Height),
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash,
),
),
},
),
@ -86,9 +107,12 @@ func TestValidateGenesis(t *testing.T) {
[]types.ClientConsensusStates{
types.NewClientConsensusStates(
clientID,
[]exported.ConsensusState{
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.GetHeight().(types.Height), header.Header.NextValidatorsHash,
[]types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(
header.GetHeight().(types.Height),
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash,
),
),
},
),
@ -125,9 +149,12 @@ func TestValidateGenesis(t *testing.T) {
[]types.ClientConsensusStates{
types.NewClientConsensusStates(
"(CLIENTID2)",
[]exported.ConsensusState{
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), types.ZeroHeight(), header.Header.NextValidatorsHash,
[]types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(
types.ZeroHeight(),
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash,
),
),
},
),
@ -150,9 +177,12 @@ func TestValidateGenesis(t *testing.T) {
[]types.ClientConsensusStates{
types.NewClientConsensusStates(
clientID,
[]exported.ConsensusState{
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), types.ZeroHeight(), header.Header.NextValidatorsHash,
[]types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(
types.ZeroHeight(),
ibctmtypes.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash,
),
),
},
),

View File

@ -114,6 +114,17 @@ func (h Height) IsZero() bool {
return h.EpochNumber == 0 && h.EpochHeight == 0
}
// MustParseHeight will attempt to parse a string representation of a height and panic if
// parsing fails.
func MustParseHeight(heightStr string) Height {
height, err := ParseHeight(heightStr)
if err != nil {
panic(err)
}
return height
}
// ParseHeight is a utility function that takes a string representation of the height
// and returns a Height struct
func ParseHeight(heightStr string) (Height, error) {

View File

@ -79,3 +79,17 @@ func TestString(t *testing.T) {
require.NoError(t, err, "parse err")
require.Equal(t, types.NewHeight(3, 10), parse, "parse height returns wrong height")
}
func (suite *TypesTestSuite) TestMustParseHeight() {
suite.Require().Panics(func() {
types.MustParseHeight("height")
})
suite.Require().NotPanics(func() {
types.MustParseHeight("111-1")
})
suite.Require().NotPanics(func() {
types.MustParseHeight("0-0")
})
}

View File

@ -19,12 +19,16 @@ import (
type TypesTestSuite struct {
suite.Suite
chain *ibctesting.TestChain
coordinator *ibctesting.Coordinator
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain
}
func (suite *TypesTestSuite) SetupTest() {
coordinator := ibctesting.NewCoordinator(suite.T(), 1)
suite.chain = coordinator.GetChain(ibctesting.GetChainID(0))
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
}
func TestTypesTestSuite(t *testing.T) {
@ -45,15 +49,15 @@ func (suite *TypesTestSuite) TestMarshalMsgCreateClient() {
}{
{
"solo machine client", func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
},
{
"tendermint client", func() {
tendermintClient := ibctmtypes.NewClientState(suite.chain.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false)
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chain.CreateTMClientHeader().ConsensusState(), suite.chain.SenderAccount.GetAddress())
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false)
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CreateTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
},
@ -67,7 +71,7 @@ func (suite *TypesTestSuite) TestMarshalMsgCreateClient() {
tc.malleate()
cdc := suite.chain.App.AppCodec()
cdc := suite.chainA.App.AppCodec()
// marshal message
bz, err := cdc.MarshalJSON(msg)
@ -104,8 +108,8 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
{
"valid - tendermint client",
func() {
tendermintClient := ibctmtypes.NewClientState(suite.chain.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false)
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chain.CreateTMClientHeader().ConsensusState(), suite.chain.SenderAccount.GetAddress())
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false)
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CreateTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
true,
@ -113,7 +117,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
{
"invalid tendermint client",
func() {
msg, err = types.NewMsgCreateClient("tendermint", &ibctmtypes.ClientState{}, suite.chain.CreateTMClientHeader().ConsensusState(), suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgCreateClient("tendermint", &ibctmtypes.ClientState{}, suite.chainA.CreateTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -128,8 +132,8 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
{
"failed to unpack consensus state",
func() {
tendermintClient := ibctmtypes.NewClientState(suite.chain.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false)
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chain.CreateTMClientHeader().ConsensusState(), suite.chain.SenderAccount.GetAddress())
tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false)
msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CreateTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
msg.ConsensusState = nil
},
@ -145,8 +149,8 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
{
"valid - solomachine client",
func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
true,
@ -154,8 +158,8 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
{
"invalid solomachine client",
func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, &solomachinetypes.ClientState{}, soloMachine.ConsensusState(), suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, &solomachinetypes.ClientState{}, soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -163,8 +167,8 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
{
"invalid solomachine consensus state",
func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), &solomachinetypes.ConsensusState{}, suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), &solomachinetypes.ConsensusState{}, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -172,8 +176,8 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
{
"unsupported - localhost client",
func() {
localhostClient := localhosttypes.NewClientState(suite.chain.ChainID, types.NewHeight(0, uint64(suite.chain.LastHeader.Header.Height)))
msg, err = types.NewMsgCreateClient("localhost", localhostClient, suite.chain.LastHeader.ConsensusState(), suite.chain.SenderAccount.GetAddress())
localhostClient := localhosttypes.NewClientState(suite.chainA.ChainID, types.NewHeight(0, uint64(suite.chainA.LastHeader.Header.Height)))
msg, err = types.NewMsgCreateClient("localhost", localhostClient, suite.chainA.LastHeader.ConsensusState(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -205,14 +209,14 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() {
}{
{
"solo machine client", func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
},
{
"tendermint client", func() {
msg, err = types.NewMsgUpdateClient("tendermint", suite.chain.CreateTMClientHeader(), suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CreateTMClientHeader(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
@ -227,7 +231,7 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() {
tc.malleate()
cdc := suite.chain.App.AppCodec()
cdc := suite.chainA.App.AppCodec()
// marshal message
bz, err := cdc.MarshalJSON(msg)
@ -264,7 +268,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
{
"valid - tendermint header",
func() {
msg, err = types.NewMsgUpdateClient("tendermint", suite.chain.CreateTMClientHeader(), suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CreateTMClientHeader(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
true,
@ -272,7 +276,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
{
"invalid tendermint header",
func() {
msg, err = types.NewMsgUpdateClient("tendermint", &ibctmtypes.Header{}, suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgUpdateClient("tendermint", &ibctmtypes.Header{}, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -294,8 +298,8 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
{
"valid - solomachine header",
func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
true,
@ -303,7 +307,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
{
"invalid solomachine header",
func() {
msg, err = types.NewMsgUpdateClient("solomachine", &solomachinetypes.Header{}, suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgUpdateClient("solomachine", &solomachinetypes.Header{}, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -311,7 +315,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
{
"unsupported - localhost",
func() {
msg, err = types.NewMsgUpdateClient(exported.ClientTypeLocalHost, suite.chain.CreateTMClientHeader(), suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgUpdateClient(exported.ClientTypeLocalHost, suite.chainA.CreateTMClientHeader(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -343,18 +347,18 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() {
}{
{
"solo machine client", func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
},
{
"tendermint client", func() {
header1 := ibctmtypes.CreateTestHeader(suite.chain.ChainID, suite.chain.CurrentHeader.Height, suite.chain.CurrentHeader.Height-1, suite.chain.CurrentHeader.Time, suite.chain.Vals, suite.chain.Vals, suite.chain.Signers)
header2 := ibctmtypes.CreateTestHeader(suite.chain.ChainID, suite.chain.CurrentHeader.Height, suite.chain.CurrentHeader.Height-1, suite.chain.CurrentHeader.Time.Add(time.Minute), suite.chain.Vals, suite.chain.Vals, suite.chain.Signers)
header1 := ibctmtypes.CreateTestHeader(suite.chainA.ChainID, suite.chainA.CurrentHeader.Height, suite.chainA.CurrentHeader.Height-1, suite.chainA.CurrentHeader.Time, suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers)
header2 := ibctmtypes.CreateTestHeader(suite.chainA.ChainID, suite.chainA.CurrentHeader.Height, suite.chainA.CurrentHeader.Height-1, suite.chainA.CurrentHeader.Time.Add(time.Minute), suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers)
misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", suite.chain.ChainID, header1, header2)
msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chain.SenderAccount.GetAddress())
misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.ChainID, header1, header2)
msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
@ -369,7 +373,7 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() {
tc.malleate()
cdc := suite.chain.App.AppCodec()
cdc := suite.chainA.App.AppCodec()
// marshal message
bz, err := cdc.MarshalJSON(msg)
@ -406,11 +410,11 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
{
"valid - tendermint misbehaviour",
func() {
header1 := ibctmtypes.CreateTestHeader(suite.chain.ChainID, suite.chain.CurrentHeader.Height, suite.chain.CurrentHeader.Height-1, suite.chain.CurrentHeader.Time, suite.chain.Vals, suite.chain.Vals, suite.chain.Signers)
header2 := ibctmtypes.CreateTestHeader(suite.chain.ChainID, suite.chain.CurrentHeader.Height, suite.chain.CurrentHeader.Height-1, suite.chain.CurrentHeader.Time.Add(time.Minute), suite.chain.Vals, suite.chain.Vals, suite.chain.Signers)
header1 := ibctmtypes.CreateTestHeader(suite.chainA.ChainID, suite.chainA.CurrentHeader.Height, suite.chainA.CurrentHeader.Height-1, suite.chainA.CurrentHeader.Time, suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers)
header2 := ibctmtypes.CreateTestHeader(suite.chainA.ChainID, suite.chainA.CurrentHeader.Height, suite.chainA.CurrentHeader.Height-1, suite.chainA.CurrentHeader.Time.Add(time.Minute), suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers)
misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", suite.chain.ChainID, header1, header2)
msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chain.SenderAccount.GetAddress())
misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.ChainID, header1, header2)
msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
true,
@ -418,7 +422,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
{
"invalid tendermint misbehaviour",
func() {
msg, err = types.NewMsgSubmitMisbehaviour("tendermint", &ibctmtypes.Misbehaviour{}, suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgSubmitMisbehaviour("tendermint", &ibctmtypes.Misbehaviour{}, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -440,8 +444,8 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
{
"valid - solomachine misbehaviour",
func() {
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chain.SenderAccount.GetAddress())
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "")
msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
true,
@ -449,7 +453,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
{
"invalid solomachine misbehaviour",
func() {
msg, err = types.NewMsgSubmitMisbehaviour("solomachine", &solomachinetypes.Misbehaviour{}, suite.chain.SenderAccount.GetAddress())
msg, err = types.NewMsgSubmitMisbehaviour("solomachine", &solomachinetypes.Misbehaviour{}, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,
@ -457,8 +461,8 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
{
"client-id mismatch",
func() {
soloMachineMisbehaviour := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").CreateMisbehaviour()
msg, err = types.NewMsgSubmitMisbehaviour("external", soloMachineMisbehaviour, suite.chain.SenderAccount.GetAddress())
soloMachineMisbehaviour := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "").CreateMisbehaviour()
msg, err = types.NewMsgSubmitMisbehaviour("external", soloMachineMisbehaviour, suite.chainA.SenderAccount.GetAddress())
suite.Require().NoError(err)
},
false,

View File

@ -19,7 +19,7 @@ func (suite *TypesTestSuite) TestNewUpdateClientProposal() {
func (suite *TypesTestSuite) TestValidateBasic() {
// use solo machine header for testing
solomachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, clientID, "")
solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, clientID, "")
smHeader := solomachine.CreateHeader()
header, err := types.PackHeader(smHeader)
suite.Require().NoError(err)

View File

@ -461,7 +461,7 @@ func (m *QueryConsensusStatesRequest) GetPagination() *query.PageRequest {
// QueryConsensusStatesResponse is the response type for the Query/ConsensusStates RPC method
type QueryConsensusStatesResponse struct {
// consensus states associated with the identifier
ConsensusStates []*types.Any `protobuf:"bytes,1,rep,name=consensus_states,json=consensusStates,proto3" json:"consensus_states,omitempty"`
ConsensusStates []ConsensusStateWithHeight `protobuf:"bytes,1,rep,name=consensus_states,json=consensusStates,proto3" json:"consensus_states"`
// pagination response
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
@ -499,7 +499,7 @@ func (m *QueryConsensusStatesResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryConsensusStatesResponse proto.InternalMessageInfo
func (m *QueryConsensusStatesResponse) GetConsensusStates() []*types.Any {
func (m *QueryConsensusStatesResponse) GetConsensusStates() []ConsensusStateWithHeight {
if m != nil {
return m.ConsensusStates
}
@ -527,54 +527,54 @@ func init() {
func init() { proto.RegisterFile("ibc/client/query.proto", fileDescriptor_320a7d3a97b17345) }
var fileDescriptor_320a7d3a97b17345 = []byte{
// 741 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcf, 0x4f, 0x14, 0x4b,
0x10, 0xde, 0xe6, 0xc7, 0x0b, 0xd4, 0x0e, 0xf0, 0xd2, 0x21, 0x8f, 0x65, 0xe0, 0xad, 0xb0, 0x28,
0xac, 0x26, 0x4c, 0xc3, 0x1a, 0x7f, 0x24, 0xc6, 0x18, 0x31, 0x41, 0x49, 0x8c, 0xc1, 0xf1, 0xa6,
0x31, 0x64, 0x66, 0xb6, 0x99, 0x9d, 0x08, 0xd3, 0xc3, 0x76, 0xaf, 0x91, 0x10, 0x2e, 0x1c, 0x3c,
0x99, 0x68, 0xe2, 0xdd, 0x93, 0x07, 0x0f, 0xfe, 0x1b, 0x1a, 0x4e, 0x86, 0xc4, 0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 0xcb, 0x7c, 0x32, 0xb6, 0x89, 0x9a, 0x9d, 0xd4,
0xaa, 0x76, 0xdb, 0xf8, 0x0d, 0x82, 0xa1, 0x23, 0x3d, 0x89, 0x3b, 0x21, 0x3c, 0xe4, 0xb5, 0xdc,
0x39, 0x50, 0xd7, 0x72, 0x55, 0xd6, 0x52, 0xc1, 0x73, 0xbf, 0x5a, 0xcb, 0xc2, 0xdd, 0xdd, 0xfd,
0x22, 0xda, 0xdb, 0x2f, 0xa2, 0x6f, 0xfb, 0x45, 0xf4, 0xea, 0xa0, 0x98, 0xdb, 0x3b, 0x28, 0xe6,
0xbe, 0x1c, 0x14, 0x73, 0x0f, 0x2b, 0x61, 0x24, 0x6a, 0x0d, 0xdf, 0x09, 0xd8, 0x3a, 0xd1, 0xbf,
0x00, 0xea, 0x33, 0xcb, 0xab, 0x4f, 0xc8, 0x33, 0x99, 0x69, 0xae, 0x32, 0xab, 0x93, 0x89, 0xcd,
0x84, 0x72, 0xff, 0x1f, 0x39, 0x44, 0x17, 0x7f, 0x04, 0x00, 0x00, 0xff, 0xff, 0x35, 0x1e, 0xf8,
0x0d, 0x58, 0x08, 0x00, 0x00,
// 748 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xdf, 0x4b, 0x14, 0x41,
0x1c, 0xbf, 0xf1, 0x47, 0xe8, 0xdc, 0xaa, 0x31, 0x48, 0x9e, 0xab, 0x5d, 0x7a, 0x9a, 0x5e, 0x81,
0x3b, 0x7a, 0xd1, 0x0f, 0x88, 0x1e, 0x32, 0xb0, 0x84, 0x08, 0xdb, 0x88, 0xa0, 0x08, 0xd9, 0xdd,
0x1b, 0x77, 0x97, 0x74, 0x67, 0xbd, 0x99, 0x8b, 0x44, 0x7c, 0xf1, 0xa1, 0xa7, 0xa0, 0xa0, 0xf7,
0x9e, 0x7a, 0xec, 0x6f, 0xe8, 0xad, 0xf0, 0x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0xd1, 0x93, 0x4c, 0x38, 0x87, 0x46, 0x48, 0xa7, 0x09, 0x8b, 0x55, 0x80, 0x37, 0xf5,
0x45, 0xb2, 0x85, 0xe5, 0x8b, 0x4a, 0xac, 0xf2, 0xb4, 0x85, 0xde, 0x01, 0x38, 0x70, 0x68, 0x52,
0x51, 0x1e, 0xc2, 0x03, 0x5e, 0xab, 0xf9, 0x81, 0xaa, 0x97, 0x6b, 0xa2, 0x97, 0x1a, 0x9a, 0xfd,
0xd3, 0x5e, 0xe6, 0xef, 0xee, 0xec, 0x95, 0xc1, 0xee, 0x5e, 0x19, 0xfc, 0xd8, 0x2b, 0x83, 0x37,
0xfb, 0xe5, 0xc2, 0xee, 0x7e, 0xb9, 0xf0, 0x6d, 0xbf, 0x5c, 0x78, 0x5c, 0xf3, 0x43, 0x1e, 0x34,
0x5d, 0xcb, 0xa3, 0x6b, 0x58, 0xfd, 0x31, 0x90, 0x3f, 0x33, 0xac, 0xfe, 0x0c, 0xbf, 0x10, 0x95,
0x66, 0x6b, 0x33, 0xaa, 0x18, 0xdf, 0x88, 0x09, 0x73, 0x4f, 0x89, 0x95, 0x75, 0xe9, 0x57, 0x00,
0x00, 0x00, 0xff, 0xff, 0xeb, 0xcf, 0x28, 0xb5, 0x6e, 0x08, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -2307,7 +2307,7 @@ func (m *QueryConsensusStatesResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ConsensusStates = append(m.ConsensusStates, &types.Any{})
m.ConsensusStates = append(m.ConsensusStates, ConsensusStateWithHeight{})
if err := m.ConsensusStates[len(m.ConsensusStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}

View File

@ -142,19 +142,13 @@ func QueryConnectionConsensusState(
return nil, err
}
consensusState, err := clienttypes.UnpackConsensusState(res.ConsensusState)
if err != nil {
return nil, err
}
if prove {
consensusStateRes, err := clientutils.QueryConsensusStateABCI(clientCtx, res.ClientId, consensusState.GetHeight())
consensusStateRes, err := clientutils.QueryConsensusStateABCI(clientCtx, res.ClientId, height)
if err != nil {
return nil, err
}
consHeight := consensusState.GetHeight().(clienttypes.Height)
res = types.NewQueryConnectionConsensusStateResponse(res.ClientId, consensusStateRes.ConsensusState, consHeight, consensusStateRes.Proof, consensusStateRes.ProofHeight)
res = types.NewQueryConnectionConsensusStateResponse(res.ClientId, consensusStateRes.ConsensusState, height, consensusStateRes.Proof, consensusStateRes.ProofHeight)
}
return res, nil

View File

@ -175,5 +175,5 @@ func (q Keeper) ConnectionConsensusState(c context.Context, req *types.QueryConn
}
proofHeight := clienttypes.GetSelfHeight(ctx)
return types.NewQueryConnectionConsensusStateResponse(connection.ClientId, anyConsensusState, consensusState.GetHeight().(clienttypes.Height), nil, proofHeight), nil
return types.NewQueryConnectionConsensusStateResponse(connection.ClientId, anyConsensusState, height, nil, proofHeight), nil
}

View File

@ -380,8 +380,8 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: connA.ID,
EpochNumber: expConsensusState.GetHeight().GetEpochNumber(),
EpochHeight: expConsensusState.GetHeight().GetEpochHeight(),
EpochNumber: clientState.GetLatestHeight().GetEpochNumber(),
EpochHeight: clientState.GetLatestHeight().GetEpochHeight(),
}
},
true,

View File

@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
suite.Require().True(ok)
tmConsState.Timestamp = time.Now()
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientA, tmConsState.GetHeight(), tmConsState)
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientA, counterpartyClient.GetLatestHeight(), tmConsState)
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
suite.Require().NoError(err)
@ -210,12 +210,10 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
connectionKey := host.KeyConnection(connA.ID)
proofInit, proofHeight := suite.chainA.QueryProof(connectionKey)
// retrieve consensus state to provide proof for
consState, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(suite.chainA.GetContext(), clientA)
suite.Require().True(found)
if consensusHeight.IsZero() {
consensusHeight = consState.GetHeight()
// retrieve consensus state height to provide proof for
clientState := suite.chainA.GetClientState(clientA)
consensusHeight = clientState.GetLatestHeight()
}
consensusKey := host.FullKeyClientPath(clientA, host.KeyConsensusState(consensusHeight))
proofConsensus, _ := suite.chainA.QueryProof(consensusKey)
@ -435,7 +433,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
suite.Require().True(ok)
tmConsState.Timestamp = time.Now()
suite.chainB.App.IBCKeeper.ClientKeeper.SetClientConsensusState(suite.chainB.GetContext(), clientB, tmConsState.GetHeight(), tmConsState)
suite.chainB.App.IBCKeeper.ClientKeeper.SetClientConsensusState(suite.chainB.GetContext(), clientB, counterpartyClient.GetLatestHeight(), tmConsState)
err = suite.coordinator.ConnOpenTry(suite.chainB, suite.chainA, connB, connA)
suite.Require().NoError(err)
@ -457,12 +455,10 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
connectionKey := host.KeyConnection(connB.ID)
proofTry, proofHeight := suite.chainB.QueryProof(connectionKey)
// retrieve consensus state to provide proof for
consState, found := suite.chainB.App.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(suite.chainB.GetContext(), clientB)
suite.Require().True(found)
if consensusHeight.IsZero() {
consensusHeight = consState.GetHeight()
// retrieve consensus state height to provide proof for
clientState := suite.chainB.GetClientState(clientB)
consensusHeight = clientState.GetLatestHeight()
}
consensusKey := host.FullKeyClientPath(clientB, host.KeyConsensusState(consensusHeight))
proofConsensus, _ := suite.chainB.QueryProof(consensusKey)

View File

@ -97,6 +97,7 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() {
{"verification failed", func() {
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
clientB := connB.ClientID
clientState := suite.chainB.GetClientState(clientB)
// give chainB wrong consensus state for chainA
consState, found := suite.chainB.App.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(suite.chainB.GetContext(), clientB)
@ -106,7 +107,7 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() {
suite.Require().True(ok)
tmConsState.Timestamp = time.Now()
suite.chainB.App.IBCKeeper.ClientKeeper.SetClientConsensusState(suite.chainB.GetContext(), clientB, tmConsState.GetHeight(), tmConsState)
suite.chainB.App.IBCKeeper.ClientKeeper.SetClientConsensusState(suite.chainB.GetContext(), clientB, clientState.GetLatestHeight(), tmConsState)
suite.coordinator.CommitBlock(suite.chainB)
}, false},

View File

@ -112,7 +112,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
// Pack consensus state into any to test unpacking error
consState := ibctmtypes.NewConsensusState(
time.Now(), commitmenttypes.NewMerkleRoot([]byte("root")), clientHeight, []byte("nextValsHash"),
time.Now(), commitmenttypes.NewMerkleRoot([]byte("root")), []byte("nextValsHash"),
)
invalidAny := clienttypes.MustPackConsensusState(consState)
counterparty := types.NewCounterparty("connectiontotest", "clienttotest", prefix)
@ -184,7 +184,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
// Pack consensus state into any to test unpacking error
consState := ibctmtypes.NewConsensusState(
time.Now(), commitmenttypes.NewMerkleRoot([]byte("root")), clientHeight, []byte("nextValsHash"),
time.Now(), commitmenttypes.NewMerkleRoot([]byte("root")), []byte("nextValsHash"),
)
invalidAny := clienttypes.MustPackConsensusState(consState)

View File

@ -142,13 +142,8 @@ func QueryChannelConsensusState(
return nil, err
}
consensusState, err := clienttypes.UnpackConsensusState(res.ConsensusState)
if err != nil {
return nil, err
}
if prove {
consensusStateRes, err := clientutils.QueryConsensusStateABCI(clientCtx, res.ClientId, consensusState.GetHeight())
consensusStateRes, err := clientutils.QueryConsensusStateABCI(clientCtx, res.ClientId, height)
if err != nil {
return nil, err
}
@ -163,32 +158,32 @@ func QueryChannelConsensusState(
// latest ConsensusState given the source port ID and source channel ID.
func QueryLatestConsensusState(
clientCtx client.Context, portID, channelID string,
) (exported.ConsensusState, clienttypes.Height, error) {
) (exported.ConsensusState, clienttypes.Height, clienttypes.Height, error) {
clientRes, err := QueryChannelClientState(clientCtx, portID, channelID, false)
if err != nil {
return nil, clienttypes.Height{}, err
return nil, clienttypes.Height{}, clienttypes.Height{}, err
}
clientState, err := clienttypes.UnpackClientState(clientRes.IdentifiedClientState.ClientState)
if err != nil {
return nil, clienttypes.Height{}, err
return nil, clienttypes.Height{}, clienttypes.Height{}, err
}
clientHeight, ok := clientState.GetLatestHeight().(clienttypes.Height)
if !ok {
return nil, clienttypes.Height{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "invalid height type. expected type: %T, got: %T",
return nil, clienttypes.Height{}, clienttypes.Height{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "invalid height type. expected type: %T, got: %T",
clienttypes.Height{}, clientHeight)
}
res, err := QueryChannelConsensusState(clientCtx, portID, channelID, clientHeight, false)
if err != nil {
return nil, clienttypes.Height{}, err
return nil, clienttypes.Height{}, clienttypes.Height{}, err
}
consensusState, err := clienttypes.UnpackConsensusState(res.ConsensusState)
if err != nil {
return nil, clienttypes.Height{}, err
return nil, clienttypes.Height{}, clienttypes.Height{}, err
}
return consensusState, res.ProofHeight, nil
return consensusState, clientHeight, res.ProofHeight, nil
}
// QueryNextSequenceReceive returns the next sequence receive.

View File

@ -518,8 +518,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
req = &types.QueryChannelConsensusStateRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
EpochNumber: expConsensusState.GetHeight().GetEpochNumber(),
EpochHeight: expConsensusState.GetHeight().GetEpochHeight(),
EpochNumber: clientState.GetLatestHeight().GetEpochNumber(),
EpochHeight: clientState.GetLatestHeight().GetEpochHeight(),
}
},
true,

View File

@ -1123,7 +1123,7 @@ func (m *PacketAckCommitment) XXX_DiscardUnknown() {
var xxx_messageInfo_PacketAckCommitment proto.InternalMessageInfo
// Acknowledgement is the recommended acknowledgement format to be used by
// app-specifc protocols.
// app-specific protocols.
// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental
// conflicts with other protobuf message formats used for acknowledgements.
// The first byte of any message with this format will be the non-ASCII values

View File

@ -155,7 +155,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() {
tc := tc
err := tc.clientState.VerifyClientConsensusState(
nil, suite.cdc, tc.consensusState.Root, height, "chainA", tc.consensusState.GetHeight(), tc.prefix, tc.proof, tc.consensusState,
nil, suite.cdc, tc.consensusState.Root, height, "chainA", tc.clientState.LatestHeight, tc.prefix, tc.proof, tc.consensusState,
)
if tc.expPass {

View File

@ -14,13 +14,12 @@ import (
// NewConsensusState creates a new ConsensusState instance.
func NewConsensusState(
timestamp time.Time, root commitmenttypes.MerkleRoot, height clienttypes.Height,
timestamp time.Time, root commitmenttypes.MerkleRoot,
nextValsHash tmbytes.HexBytes,
) *ConsensusState {
return &ConsensusState{
Timestamp: timestamp,
Root: root,
Height: height,
NextValidatorsHash: nextValsHash,
}
}
@ -35,11 +34,6 @@ func (cs ConsensusState) GetRoot() exported.Root {
return cs.Root
}
// GetHeight returns the height for the specific consensus state
func (cs ConsensusState) GetHeight() exported.Height {
return cs.Height
}
// GetTimestamp returns block time in nanoseconds at which the consensus state was stored
func (cs ConsensusState) GetTimestamp() uint64 {
return uint64(cs.Timestamp.UnixNano())
@ -53,9 +47,6 @@ func (cs ConsensusState) ValidateBasic() error {
if err := tmtypes.ValidateHash(cs.NextValidatorsHash); err != nil {
return sdkerrors.Wrap(err, "next validators hash is invalid")
}
if cs.Height.EpochHeight == 0 {
return sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "tendermint epoch height cannot be zero")
}
if cs.Timestamp.IsZero() {
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "timestamp cannot be zero Unix time")
}

View File

@ -3,7 +3,6 @@ package types_test
import (
"time"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
@ -18,7 +17,6 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
{"success",
&types.ConsensusState{
Timestamp: suite.now,
Height: height,
Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")),
NextValidatorsHash: suite.valsHash,
},
@ -26,7 +24,6 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
{"root is nil",
&types.ConsensusState{
Timestamp: suite.now,
Height: height,
Root: commitmenttypes.MerkleRoot{},
NextValidatorsHash: suite.valsHash,
},
@ -34,7 +31,6 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
{"root is empty",
&types.ConsensusState{
Timestamp: suite.now,
Height: height,
Root: commitmenttypes.MerkleRoot{},
NextValidatorsHash: suite.valsHash,
},
@ -42,24 +38,14 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
{"nextvalshash is invalid",
&types.ConsensusState{
Timestamp: suite.now,
Height: height,
Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")),
NextValidatorsHash: []byte("hi"),
},
false},
{"height is 0",
&types.ConsensusState{
Timestamp: suite.now,
Height: clienttypes.NewHeight(0, 0),
Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")),
NextValidatorsHash: suite.valsHash,
},
false},
{"timestamp is zero",
&types.ConsensusState{
Timestamp: time.Time{},
Height: height,
Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")),
NextValidatorsHash: suite.valsHash,
},

View File

@ -22,7 +22,6 @@ func (h Header) ClientType() exported.ClientType {
// ConsensusState returns the updated consensus state associated with the header
func (h Header) ConsensusState() *ConsensusState {
return &ConsensusState{
Height: h.GetHeight().(clienttypes.Height),
Timestamp: h.GetTime(),
Root: commitmenttypes.NewMerkleRoot(h.Header.GetAppHash()),
NextValidatorsHash: h.Header.NextValidatorsHash,

View File

@ -43,7 +43,9 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
name string
clientState exported.ClientState
consensusState1 exported.ConsensusState
height1 clienttypes.Height
consensusState2 exported.ConsensusState
height2 clienttypes.Height
misbehaviour exported.Misbehaviour
timestamp time.Time
expPass bool
@ -51,8 +53,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"valid misbehavior misbehaviour",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -65,8 +69,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"valid misbehavior at height greater than last consensusState",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus1, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus1, bothValsHash),
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),
heightMinus1,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight-1, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight-1, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -79,8 +85,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"invalid misbehavior misbehaviour from different chain",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader("ethermint", int64(height.EpochHeight), int64(height.EpochHeight), suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader("ethermint", int64(height.EpochHeight), int64(height.EpochHeight), suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -93,8 +101,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"valid misbehavior misbehaviour with different trusted heights",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus1, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus3, suite.valsHash),
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(chainID, epochHeight, epochHeight-1, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight-3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
@ -107,8 +117,10 @@ 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(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, suite.valsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, suite.valsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, bothValSet, suite.valSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
@ -121,8 +133,10 @@ 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(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus1, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus3, suite.valsHash),
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(chainID, epochHeight, epochHeight-1, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
@ -135,8 +149,10 @@ 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(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus1, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus3, suite.valsHash),
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(chainID, epochHeight, epochHeight-1, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight-3, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -149,8 +165,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"already frozen client state",
&types.ClientState{FrozenHeight: clienttypes.NewHeight(0, 1)},
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -164,7 +182,9 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
"trusted consensus state does not exist",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
nil, // consensus state for trusted height - 1 does not exist in store
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
clienttypes.Height{},
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight-1, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -177,8 +197,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"invalid tendermint misbehaviour",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
nil,
suite.now,
false,
@ -186,8 +208,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"rejected misbehaviour due to expired age duration",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -200,8 +224,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"rejected misbehaviour due to expired block duration",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(0, uint64(epochHeight+simapp.DefaultConsensusParams.Evidence.MaxAgeNumBlocks+1)), commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -214,8 +240,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"provided height > header height",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight-1, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight-1, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -228,8 +256,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"unbonding period expired",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(time.Time{}, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), heightMinus1, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight-1, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -242,8 +272,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"trusted validators is incorrect for given consensus state",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, bothValSet, suite.valSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners),
@ -256,8 +288,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"first valset has too much change",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, altValSet, bothValSet, altSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
@ -270,8 +304,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"second valset has too much change",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, bothValSet, bothValSet, bothSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), altValSet, bothValSet, altSigners),
@ -284,8 +320,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
{
"both valsets have too much change",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), height, bothValsHash),
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),
height,
&types.Misbehaviour{
Header1: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now, altValSet, bothValSet, altSigners),
Header2: types.CreateTestHeader(chainID, epochHeight, epochHeight, suite.now.Add(time.Minute), altValSet, bothValSet, altSigners),
@ -310,10 +348,10 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
// Set trusted consensus states in client store
if tc.consensusState1 != nil {
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(ctx, clientID, tc.consensusState1.GetHeight(), tc.consensusState1)
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(ctx, clientID, tc.height1, tc.consensusState1)
}
if tc.consensusState2 != nil {
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(ctx, clientID, tc.consensusState2.GetHeight(), tc.consensusState2)
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(ctx, clientID, tc.height2, tc.consensusState2)
}
clientState, err := tc.clientState.CheckMisbehaviourAndUpdateState(

View File

@ -98,10 +98,8 @@ type ConsensusState struct {
// was stored.
Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"`
// commitment root (i.e app hash)
Root types1.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"`
// height at which the consensus state was stored.
Height types.Height `protobuf:"bytes,3,opt,name=height,proto3" json:"height"`
NextValidatorsHash github_com_tendermint_tendermint_libs_bytes.HexBytes `protobuf:"bytes,4,opt,name=next_validators_hash,json=nextValidatorsHash,proto3,casttype=github.com/tendermint/tendermint/libs/bytes.HexBytes" json:"next_validators_hash,omitempty" yaml:"next_validators_hash"`
Root types1.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"`
NextValidatorsHash github_com_tendermint_tendermint_libs_bytes.HexBytes `protobuf:"bytes,3,opt,name=next_validators_hash,json=nextValidatorsHash,proto3,casttype=github.com/tendermint/tendermint/libs/bytes.HexBytes" json:"next_validators_hash,omitempty" yaml:"next_validators_hash"`
}
func (m *ConsensusState) Reset() { *m = ConsensusState{} }
@ -315,72 +313,72 @@ func init() {
func init() { proto.RegisterFile("ibc/tendermint/tendermint.proto", fileDescriptor_76a953d5a747dd66) }
var fileDescriptor_76a953d5a747dd66 = []byte{
// 1039 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x4f, 0x6f, 0xe3, 0x44,
0x14, 0x6f, 0xda, 0xd2, 0xa6, 0x93, 0xf4, 0x0f, 0xb3, 0xa5, 0xeb, 0x96, 0x6c, 0x1c, 0x0d, 0x08,
0x55, 0x48, 0x6b, 0x6f, 0xb3, 0x2b, 0x90, 0x7a, 0xc3, 0x5d, 0x50, 0x8b, 0x58, 0xa9, 0xb8, 0x14,
0x10, 0x12, 0xb2, 0x1c, 0x7b, 0x92, 0x8c, 0x6a, 0x7b, 0x8c, 0x67, 0x52, 0x52, 0x3e, 0x01, 0x48,
0x1c, 0x56, 0x9c, 0xf6, 0x08, 0xdf, 0x66, 0x4f, 0xa8, 0x47, 0x4e, 0x06, 0xb5, 0xdf, 0x20, 0x47,
0x4e, 0xc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f, 0x63, 0xe6, 0x9f,
0x99, 0x63, 0x33, 0xfb, 0x51, 0xf1, 0xe4, 0xe3, 0xc7, 0xb3, 0x3f, 0x74, 0x7a, 0x4b, 0x62, 0xf2,
0x3c, 0xfd, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x00, 0xae, 0xae, 0x92, 0x56, 0x09, 0x00, 0x00,
// 1034 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x4f, 0x6f, 0xe3, 0xc4,
0x1b, 0xae, 0xdb, 0xfe, 0xda, 0x74, 0x92, 0xfe, 0xf9, 0xcd, 0x96, 0xae, 0x5b, 0xba, 0x71, 0x34,
0x20, 0x54, 0x21, 0xad, 0x4d, 0xb3, 0x2b, 0x90, 0x7a, 0xc3, 0x5d, 0x50, 0x8b, 0x58, 0xa9, 0xb8,
0x14, 0x10, 0x12, 0xb2, 0x1c, 0x7b, 0x92, 0x8c, 0x6a, 0x7b, 0x8c, 0x67, 0x52, 0x52, 0x3e, 0x01,
0x48, 0x1c, 0x56, 0x9c, 0xf6, 0xc0, 0x01, 0xbe, 0xcd, 0x1e, 0x7b, 0xe4, 0x64, 0x50, 0xfb, 0x0d,
0x72, 0xe4, 0x84, 0x3c, 0x33, 0xfe, 0x93, 0xb4, 0xd5, 0x2e, 0x97, 0x64, 0xe6, 0x7d, 0xde, 0xe7,
0x79, 0xe2, 0x77, 0xde, 0x79, 0x1d, 0x60, 0x90, 0x9e, 0x6f, 0x71, 0x1c, 0x07, 0x38, 0x8d, 0x48,
0xcc, 0x6b, 0x4b, 0x33, 0x49, 0x29, 0xa7, 0x70, 0x8d, 0xf4, 0x7c, 0xb3, 0x8a, 0xee, 0x74, 0xea,
0xc9, 0x97, 0x09, 0x66, 0xd6, 0x85, 0x17, 0x92, 0xc0, 0xe3, 0x34, 0x95, 0x8c, 0x9d, 0xdd, 0x5b,
0x19, 0xe2, 0x53, 0xa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, 0x0c, 0xa3, 0x85, 0x7b, 0x87, 0xd1, 0x23, 0x35, 0x8c, 0xde, 0xaa, 0xbd, 0x14,
0x4a, 0x1e, 0x72, 0x56, 0x55, 0x40, 0x8d, 0xa3, 0x10, 0xc0, 0x22, 0xa3, 0x6a, 0x5c, 0x75, 0x1a,
0xaf, 0xfb, 0xf5, 0x8f, 0x26, 0x99, 0xb1, 0x3d, 0xed, 0x52, 0x69, 0x20, 0xe7, 0xff, 0x2a, 0x58,
0xb5, 0x30, 0xfa, 0x0c, 0x34, 0x8a, 0x17, 0x23, 0xdc, 0x05, 0x2b, 0xf1, 0x28, 0xc2, 0x69, 0x8e,
0x88, 0x13, 0x59, 0x70, 0xaa, 0x00, 0xec, 0x80, 0x66, 0x80, 0x63, 0x1a, 0x91, 0x58, 0xe0, 0xf3,
0x02, 0xaf, 0x87, 0xec, 0x93, 0x57, 0xd7, 0x6d, 0xed, 0xea, 0xba, 0xad, 0xfd, 0x7d, 0xdd, 0xd6,
0x5e, 0xdc, 0xb4, 0xe7, 0xae, 0x6e, 0xda, 0x73, 0x7f, 0xde, 0xb4, 0xe7, 0xbe, 0xfd, 0xb0, 0x76,
0xdd, 0x7c, 0xca, 0x22, 0xca, 0xd4, 0xd7, 0x63, 0x16, 0x9c, 0x5b, 0x63, 0x2b, 0xff, 0x8b, 0xf0,
0xc1, 0x47, 0x8f, 0x67, 0xff, 0xb6, 0xf4, 0x96, 0xc4, 0x1c, 0x79, 0xf2, 0x6f, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf9, 0x7c, 0x92, 0x83, 0x24, 0x09, 0x00, 0x00,
}
func (m *ClientState) Marshal() (dAtA []byte, err error) {
@ -526,18 +524,8 @@ func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.NextValidatorsHash)
i = encodeVarintTendermint(dAtA, i, uint64(len(m.NextValidatorsHash)))
i--
dAtA[i] = 0x22
dAtA[i] = 0x1a
}
{
size, err := m.Height.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTendermint(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
{
size, err := m.Root.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
@ -548,12 +536,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
@ -780,8 +768,6 @@ func (m *ConsensusState) Size() (n int) {
n += 1 + l + sovTendermint(uint64(l))
l = m.Root.Size()
n += 1 + l + sovTendermint(uint64(l))
l = m.Height.Size()
n += 1 + l + sovTendermint(uint64(l))
l = len(m.NextValidatorsHash)
if l > 0 {
n += 1 + l + sovTendermint(uint64(l))
@ -1311,39 +1297,6 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error {
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTendermint
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTendermint
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTendermint
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field NextValidatorsHash", wireType)
}

View File

@ -63,14 +63,6 @@ func (cs ClientState) CheckHeaderAndUpdateState(
// checkTrustedHeader checks that consensus state matches trusted fields of Header
func checkTrustedHeader(header *Header, consState *ConsensusState) error {
if !header.TrustedHeight.EQ(consState.Height) {
return sdkerrors.Wrapf(
ErrInvalidHeaderHeight,
"trusted header height %d does not match consensus state height %d",
header.TrustedHeight, consState.Height,
)
}
tmTrustedValidators, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators)
if err != nil {
return sdkerrors.Wrap(err, "trusted validator set in not tendermint validator set type")
@ -115,17 +107,17 @@ func checkValidity(
}
// assert header height is newer than consensus state
if header.GetHeight().LTE(consState.Height) {
if header.GetHeight().LTE(header.TrustedHeight) {
return sdkerrors.Wrapf(
clienttypes.ErrInvalidHeader,
"header height ≤ consensus state height (%d ≤ %d)", header.GetHeight(), consState.Height,
"header height ≤ consensus state height (%d ≤ %d)", header.GetHeight(), header.TrustedHeight,
)
}
// Construct a trusted header using the fields in consensus state
// Only Height, Time, and NextValidatorsHash are necessary for verification
trustedHeader := tmtypes.Header{
Height: int64(consState.Height.EpochHeight),
Height: int64(header.TrustedHeight.EpochHeight),
Time: consState.Timestamp,
NextValidatorsHash: consState.NextValidatorsHash,
}
@ -156,7 +148,6 @@ func update(clientState *ClientState, header *Header) (*ClientState, *ConsensusS
clientState.LatestHeight = height
}
consensusState := &ConsensusState{
Height: height,
Timestamp: header.GetTime(),
Root: commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()),
NextValidatorsHash: header.Header.NextValidatorsHash,

View File

@ -13,10 +13,11 @@ import (
func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
var (
clientState *types.ClientState
consensusState *types.ConsensusState
newHeader *types.Header
currentTime time.Time
clientState *types.ClientState
consensusState *types.ConsensusState
consStateHeight clienttypes.Height
newHeader *types.Header
currentTime time.Time
)
// Setup different validators and signers for testing different types of updates
@ -52,7 +53,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.headerTime, suite.valSet, suite.valSet, signers)
currentTime = suite.now
},
@ -62,7 +63,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+5, epochHeight, suite.headerTime, bothValSet, suite.valSet, bothSigners)
currentTime = suite.now
},
@ -72,7 +73,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, bothValSet.Hash())
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), bothValSet.Hash())
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.headerTime, bothValSet, bothValSet, bothSigners)
currentTime = suite.now
},
@ -82,7 +83,8 @@ 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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), heightMinus3, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
consStateHeight = heightMinus3
newHeader = types.CreateTestHeader(chainID, epochHeight-1, epochHeight-3, suite.headerTime, bothValSet, suite.valSet, bothSigners)
currentTime = suite.now
},
@ -92,7 +94,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader("ethermint", int64(height.EpochHeight+1), int64(height.EpochHeight), suite.headerTime, suite.valSet, suite.valSet, signers)
currentTime = suite.now
},
@ -102,7 +104,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.headerTime, bothValSet, suite.valSet, bothSigners)
currentTime = suite.now
},
@ -112,7 +114,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, bothValSet.Hash())
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), bothValSet.Hash())
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.headerTime, suite.valSet, bothValSet, signers)
currentTime = suite.now
},
@ -122,7 +124,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+5, epochHeight, suite.headerTime, altValSet, suite.valSet, altSigners)
currentTime = suite.now
},
@ -132,7 +134,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+5, epochHeight, suite.headerTime, bothValSet, bothValSet, bothSigners)
currentTime = suite.now
},
@ -142,7 +144,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.headerTime, suite.valSet, suite.valSet, signers)
// make current time pass trusting period from last timestamp on clientstate
currentTime = suite.now.Add(trustingPeriod)
@ -153,7 +155,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers)
currentTime = suite.now
},
@ -163,7 +165,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(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.clientTime, suite.valSet, suite.valSet, signers)
currentTime = suite.now
},
@ -173,7 +175,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
name: "header basic validation failed",
setup: func() {
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash)
newHeader = types.CreateTestHeader(chainID, epochHeight+1, epochHeight, suite.headerTime, suite.valSet, suite.valSet, signers)
// cause new header to fail validatebasic by changing commit height to mismatch header height
newHeader.SignedHeader.Commit.Height = epochHeight - 1
@ -185,7 +187,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
name: "header height < consensus height",
setup: func() {
clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, heightPlus5, commitmenttypes.GetSDKSpecs(), false, false)
consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), height, suite.valsHash)
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, epochHeight-1, epochHeight, suite.headerTime, suite.valSet, suite.valSet, signers)
currentTime = suite.now
@ -196,6 +198,8 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
for i, tc := range testCases {
tc := tc
consStateHeight = height // must be explicitly changed
// setup test
tc.setup()
@ -203,11 +207,10 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() {
ctx := suite.chainA.GetContext().WithBlockTime(currentTime)
// Set trusted consensus state in client store
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(ctx, clientID, consensusState.GetHeight(), consensusState)
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientConsensusState(ctx, clientID, consStateHeight, consensusState)
height := newHeader.GetHeight()
expectedConsensus := &types.ConsensusState{
Height: height.(clienttypes.Height),
Timestamp: newHeader.GetTime(),
Root: commitmenttypes.NewMerkleRoot(newHeader.Header.GetAppHash()),
NextValidatorsHash: newHeader.Header.NextValidatorsHash,

View File

@ -116,9 +116,6 @@ type ClientState interface {
type ConsensusState interface {
ClientType() ClientType // Consensus kind
// GetHeight returns the height of the consensus state
GetHeight() Height
// GetRoot returns the commitment root of the consensus state,
// which is used for key-value pair verification.
GetRoot() Root

View File

@ -46,9 +46,12 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
[]clienttypes.ClientConsensusStates{
clienttypes.NewClientConsensusStates(
clientID,
[]exported.ConsensusState{
ibctmtypes.NewConsensusState(
suite.header.GetTime(), commitmenttypes.NewMerkleRoot(suite.header.Header.AppHash), suite.header.GetHeight().(clienttypes.Height), suite.header.Header.NextValidatorsHash,
[]clienttypes.ConsensusStateWithHeight{
clienttypes.NewConsensusStateWithHeight(
suite.header.GetHeight().(clienttypes.Height),
ibctmtypes.NewConsensusState(
suite.header.GetTime(), commitmenttypes.NewMerkleRoot(suite.header.Header.AppHash), suite.header.Header.NextValidatorsHash,
),
),
},
),
@ -175,9 +178,12 @@ func (suite *IBCTestSuite) TestInitGenesis() {
[]clienttypes.ClientConsensusStates{
clienttypes.NewClientConsensusStates(
clientID,
[]exported.ConsensusState{
ibctmtypes.NewConsensusState(
suite.header.GetTime(), commitmenttypes.NewMerkleRoot(suite.header.Header.AppHash), suite.header.GetHeight().(clienttypes.Height), suite.header.Header.NextValidatorsHash,
[]clienttypes.ConsensusStateWithHeight{
clienttypes.NewConsensusStateWithHeight(
suite.header.GetHeight().(clienttypes.Height),
ibctmtypes.NewConsensusState(
suite.header.GetTime(), commitmenttypes.NewMerkleRoot(suite.header.Header.AppHash), suite.header.Header.NextValidatorsHash,
),
),
},
),

View File

@ -18,12 +18,6 @@ func (ConsensusState) ClientType() exported.ClientType {
return exported.SoloMachine
}
// GetHeight satisfies the ConsensusState interface
// NOTE: this function will be deprecated.
func (cs ConsensusState) GetHeight() exported.Height {
return clienttypes.Height{}
}
// GetTimestamp returns zero.
func (cs ConsensusState) GetTimestamp() uint64 {
return cs.Timestamp

View File

@ -1,7 +1,6 @@
package types_test
import (
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
)
@ -10,7 +9,6 @@ func (suite *SoloMachineTestSuite) TestConsensusState() {
consensusState := suite.solomachine.ConsensusState()
suite.Require().Equal(exported.SoloMachine, consensusState.ClientType())
suite.Require().Equal(clienttypes.Height{}, consensusState.GetHeight())
suite.Require().Equal(suite.solomachine.Time, consensusState.GetTimestamp())
suite.Require().Nil(consensusState.GetRoot())
}