Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding CheckForMisbehaviour to ClientState interface #1197

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#1186](https://github.com/cosmos/ibc-go/pull/1186/files) Removing `GetRoot` function from ConsensusState interface in `02-client`. `GetRoot` is unused by core IBC.
* (modules/core/02-client) [\#1196](https://github.com/cosmos/ibc-go/pull/1196) Adding VerifyClientMessage to ClientState interface.
* (modules/core/02-client) [\#1170](https://github.com/cosmos/ibc-go/pull/1170) Updating `ClientUpdateProposal` to set client state in lightclient implementations `CheckSubstituteAndUpdateState` methods.
* (modules/core/02-client) [\#1197](https://github.com/cosmos/ibc-go/pull/1197) Adding `CheckForMisbehaviour` to `ClientState` interface.

### Features

Expand Down
5 changes: 5 additions & 0 deletions modules/core/02-client/legacy/v100/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ func (cs ClientState) ExportMetadata(_ sdk.KVStore) []exported.GenesisMetadata {
panic("legacy solo machine is deprecated!")
}

// CheckForMisbehaviour panics!
func (cs ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, msg exported.ClientMessage) bool {
panic("legacy solo machine is deprecated!")
}

// VerifyClientMessage panics!
func (cs *ClientState) VerifyClientMessage(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
Expand Down
3 changes: 3 additions & 0 deletions modules/core/exported/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type ClientState interface {
// Clients must return their status. Only Active clients are allowed to process packets.
Status(ctx sdk.Context, clientStore sdk.KVStore, cdc codec.BinaryCodec) Status

// Checks for evidence of a misbehaviour in Header or Misbehaviour type
CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, msg ClientMessage) bool

// Genesis function
ExportMetadata(sdk.KVStore) []GenesisMetadata

Expand Down
7 changes: 1 addition & 6 deletions modules/light-clients/07-tendermint/types/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,9 @@ func (suite *TendermintTestSuite) TestCheckForMisbehaviour() {
tc.malleate()

clientState := path.EndpointA.GetClientState()

// TODO: remove casting when 'UpdateState' is an interface function.
tmClientState, ok := clientState.(*types.ClientState)
suite.Require().True(ok)

clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID)

foundMisbehaviour := tmClientState.CheckForMisbehaviour(
foundMisbehaviour := clientState.CheckForMisbehaviour(
suite.chainA.GetContext(),
suite.chainA.App.AppCodec(),
clientStore, // pass in clientID prefixed clientStore
Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/09-localhost/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func (cs *ClientState) VerifyHeader(
// CheckForMisbehaviour returns false.
func (cs *ClientState) CheckForMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
) (bool, error) {
return false, nil
) bool {
return false
}

// UpdateState updates the localhost client. It only needs access to the context
Expand Down