diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ceb250514..5506ddc1cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking * (light-clients/07-tendermint) [\#6276](https://github.com/cosmos/ibc-go/pull/6276) Fix: No-op to avoid panicking on `UpdateState` for invalid misbehaviour submissions. +* (light-clients/06-solomachine) [\#6313](https://github.com/cosmos/ibc-go/pull/6313) Fix: No-op to avoid panicking on `UpdateState` for invalid misbehaviour submissions. ### Improvements diff --git a/modules/light-clients/06-solomachine/light_client_module_test.go b/modules/light-clients/06-solomachine/light_client_module_test.go index d853cbf42d5..d80691462a8 100644 --- a/modules/light-clients/06-solomachine/light_client_module_test.go +++ b/modules/light-clients/06-solomachine/light_client_module_test.go @@ -1042,13 +1042,13 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { nil, }, { - "failure: invalid type misbehaviour", + "invalid type misbehaviour no-ops", func() { clientState = sm.ClientState() clientMsg = sm.CreateMisbehaviour() suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, clientState) }, - fmt.Errorf("unsupported ClientMessage: %T", sm.CreateMisbehaviour()), + nil, }, { "failure: cannot find client state", @@ -1092,6 +1092,11 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { newClientState := clienttypes.MustUnmarshalClientState(suite.chainA.Codec, clientStateBz) + if len(consensusHeights) == 0 { + suite.Require().Equal(clientState, newClientState) + return + } + suite.Require().Len(consensusHeights, 1) suite.Require().Equal(uint64(0), consensusHeights[0].GetRevisionNumber()) suite.Require().Equal(newClientState.(*solomachine.ClientState).Sequence, consensusHeights[0].GetRevisionHeight()) diff --git a/modules/light-clients/06-solomachine/update.go b/modules/light-clients/06-solomachine/update.go index 359bb118be4..53e4ef26ea2 100644 --- a/modules/light-clients/06-solomachine/update.go +++ b/modules/light-clients/06-solomachine/update.go @@ -1,8 +1,6 @@ package solomachine import ( - "fmt" - errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" @@ -79,10 +77,12 @@ func (cs ClientState) verifyHeader(cdc codec.BinaryCodec, header *Header) error // UpdateState updates the consensus state to the new public key and an incremented sequence. // A list containing the updated consensus height is returned. +// If the provided clientMsg is not of type Header, the handler will no-op and return an empty slice. func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) []exported.Height { smHeader, ok := clientMsg.(*Header) if !ok { - panic(fmt.Errorf("unsupported ClientMessage: %T", clientMsg)) + // clientMsg is invalid Misbehaviour, no update necessary + return []exported.Height{} } // create new solomachine ConsensusState