diff --git a/x/ibc/light-clients/solomachine/types/update.go b/x/ibc/light-clients/solomachine/types/update.go index 9dafb1247540..066b2baab96f 100644 --- a/x/ibc/light-clients/solomachine/types/update.go +++ b/x/ibc/light-clients/solomachine/types/update.go @@ -11,6 +11,8 @@ import ( // CheckHeaderAndUpdateState checks if the provided header is valid and updates // the consensus state if appropriate. It returns an error if: // - the client or header provided are not parseable to solo machine types +// - the header sequence does not match the current sequence +// - the header timestamp is less than the consensus state timestamp // - the currently registered public key did not provide the update signature func (cs ClientState) CheckHeaderAndUpdateState( ctx sdk.Context, cdc codec.BinaryMarshaler, clientStore sdk.KVStore, @@ -37,7 +39,15 @@ func checkHeader(cdc codec.BinaryMarshaler, clientState *ClientState, header *He if header.Sequence != clientState.Sequence { return sdkerrors.Wrapf( clienttypes.ErrInvalidHeader, - "sequence provided in the header does not match the client state sequence (%d != %d)", header.Sequence, clientState.Sequence, + "header sequence does not match the client state sequence (%d != %d)", header.Sequence, clientState.Sequence, + ) + } + + // assert update timestamp is not less than current consensus state timestamp + if header.Timestamp < clientState.ConsensusState.Timestamp { + return sdkerrors.Wrapf( + clienttypes.ErrInvalidHeader, + "header timestamp is less than to the consensus state timestamp (%d < %d)", header.Timestamp, clientState.ConsensusState.Timestamp, ) } diff --git a/x/ibc/light-clients/solomachine/types/update_test.go b/x/ibc/light-clients/solomachine/types/update_test.go index f58a740e6d44..f07ad69f51ee 100644 --- a/x/ibc/light-clients/solomachine/types/update_test.go +++ b/x/ibc/light-clients/solomachine/types/update_test.go @@ -54,6 +54,15 @@ func (suite *SoloMachineTestSuite) TestCheckHeaderAndUpdateState() { }, false, }, + { + "invalid timestamp in header", + func() { + clientState = suite.solomachine.ClientState() + h := suite.solomachine.CreateHeader() + h.Timestamp-- + header = h + }, false, + }, { "signature uses wrong sequence", func() {