Skip to content

Commit

Permalink
remove client type check between client state and consensus state (#6137
Browse files Browse the repository at this point in the history
)
  • Loading branch information
crodriguezvega authored Apr 11, 2024
1 parent d57f8d4 commit 690f7c8
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 72 deletions.
8 changes: 1 addition & 7 deletions modules/core/02-client/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (gs GenesisState) Validate() error {

for _, cc := range gs.ClientsConsensus {
// check that consensus state is for a client in the genesis clients list
clientType, ok := validClients[cc.ClientId]
_, ok := validClients[cc.ClientId]
if !ok {
return fmt.Errorf("consensus state in genesis has a client id %s that does not map to a genesis client", cc.ClientId)
}
Expand All @@ -174,12 +174,6 @@ func (gs GenesisState) Validate() error {
if err := cs.ValidateBasic(); err != nil {
return fmt.Errorf("invalid client consensus state %v clientID %s index %d: %w", cs, cc.ClientId, i, err)
}

// ensure consensus state type matches client state type
if clientType != cs.ClientType() {
return fmt.Errorf("consensus state client type %s does not equal client state client type %s", cs.ClientType(), clientType)
}

}
}

Expand Down
52 changes: 0 additions & 52 deletions modules/core/02-client/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,34 +150,6 @@ func (suite *TypesTestSuite) TestValidateGenesis() {
),
expPass: false,
},
{
name: "consensus state client id does not match client id in genesis clients",
genState: types.NewGenesisState(
[]types.IdentifiedClientState{
types.NewIdentifiedClientState(
tmClientID0, ibctm.NewClientState(suite.chainA.ChainID, ibctm.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath),
),
},
[]types.ClientConsensusStates{
types.NewClientConsensusStates(
tmClientID1,
[]types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(
types.NewHeight(1, 1),
ibctm.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash,
),
),
},
),
},
nil,
types.NewParams(exported.Tendermint),
false,
0,
),
expPass: false,
},
{
name: "invalid consensus state height",
genState: types.NewGenesisState(
Expand Down Expand Up @@ -448,30 +420,6 @@ func (suite *TypesTestSuite) TestValidateGenesis() {
),
expPass: false,
},
{
name: "consensus state different than client state type",
genState: types.NewGenesisState(
[]types.IdentifiedClientState{},
[]types.ClientConsensusStates{
types.NewClientConsensusStates(
tmClientID0,
[]types.ConsensusStateWithHeight{
types.NewConsensusStateWithHeight(
header.GetHeight().(types.Height),
ibctm.NewConsensusState(
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash,
),
),
},
),
},
nil,
types.NewParams(exported.Tendermint),
false,
5,
),
expPass: false,
},
}

for _, tc := range testCases {
Expand Down
3 changes: 0 additions & 3 deletions modules/core/02-client/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ func (msg MsgCreateClient) ValidateBasic() error {
if err != nil {
return err
}
// if clientState.ClientType() != consensusState.ClientType() {
// return errorsmod.Wrap(ErrInvalidClientType, "client type for client state and consensus state do not match")
// }
if err := ValidateClientType(clientState.ClientType()); err != nil {
return errorsmod.Wrap(err, "client type does not meet naming constraints")
}
Expand Down
10 changes: 0 additions & 10 deletions modules/core/02-client/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,6 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
},
false,
},
// {
// "invalid - client state and consensus state client types do not match",
// func() {
// tendermintClient := ibctm.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath)
// soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2)
// msg, err = types.NewMsgCreateClient(tendermintClient, soloMachine.ConsensusState(), suite.chainA.SenderAccount.GetAddress().String())
// suite.Require().NoError(err)
// },
// false,
// },
}

for _, tc := range cases {
Expand Down

0 comments on commit 690f7c8

Please sign in to comment.