Skip to content

Commit

Permalink
return error in 09-localhost VerifyClientMessage (#3115)
Browse files Browse the repository at this point in the history
* return an error from 09-localhost client VerifyClientMessage

* fix typo

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
damiannolan and crodriguezvega authored Feb 7, 2023
1 parent fdd332e commit 40ca344
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions modules/light-clients/09-localhost/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,17 @@ func (cs ClientState) VerifyNonMembership(
return nil
}

// VerifyClientMessage must verify a ClientMessage. A ClientMessage could be a Header, Misbehaviour, or batch update.
// It must handle each type of ClientMessage appropriately. Calls to CheckForMisbehaviour, UpdateState, and UpdateStateOnMisbehaviour
// will assume that the content of the ClientMessage has been verified and can be trusted. An error should be returned
// if the ClientMessage fails to verify.
// VerifyClientMessage is unsupported by the 09-localhost client type and returns an error.
func (cs ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, clientMsg exported.ClientMessage) error {
return nil
return sdkerrors.Wrap(clienttypes.ErrUpdateClientFailed, "client message verification is unsupported by the localhost client")
}

// Checks for evidence of a misbehaviour in Header or Misbehaviour type. It assumes the ClientMessage
// has already been verified.
// CheckForMisbehaviour is unsupported by the 09-localhost client type and performs a no-op, returning false.
func (cs ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, clientMsg exported.ClientMessage) bool {
return false
}

// UpdateStateOnMisbehaviour should perform appropriate state changes on a client state given that misbehaviour has been detected and verified.
// UpdateStateOnMisbehaviour is unsupported by the 09-localhost client type and performs a no-op.
func (cs ClientState) UpdateStateOnMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage) {
}

Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/09-localhost/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (suite *LocalhostTestSuite) TestVerifyNonMembership() {

func (suite *LocalhostTestSuite) TestVerifyClientMessage() {
clientState := localhost.NewClientState(clienttypes.NewHeight(1, 10))
suite.Require().Nil(clientState.VerifyClientMessage(suite.chain.GetContext(), nil, nil, nil))
suite.Require().Error(clientState.VerifyClientMessage(suite.chain.GetContext(), nil, nil, nil))
}

func (suite *LocalhostTestSuite) TestVerifyCheckForMisbehaviour() {
Expand Down

0 comments on commit 40ca344

Please sign in to comment.