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

fix: noop on UpdateState for invalid misbehaviour #6276

Merged
merged 6 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion modules/light-clients/07-tendermint/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ func (cs *ClientState) verifyHeader(
func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) []exported.Height {
header, ok := clientMsg.(*Header)
if !ok {
panic(fmt.Errorf("expected type %T, got %T", &Header{}, clientMsg))
// clientMsg is invalid Misbehaviour and handler should noop
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
return []exported.Height{}
}

cs.pruneOldestConsensusState(ctx, cdc, clientStore)
Expand Down
9 changes: 6 additions & 3 deletions modules/light-clients/07-tendermint/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,12 @@ func (suite *TendermintTestSuite) TestUpdateState() {
suite.Require().Equal(expConsensusState, updatedConsensusState)

} else {
suite.Require().Panics(func() {
clientState.UpdateState(suite.chainA.GetContext(), suite.chainA.App.AppCodec(), clientStore, clientMessage)
})
consensusHeights = clientState.UpdateState(suite.chainA.GetContext(), suite.chainA.App.AppCodec(), clientStore, clientMessage)
suite.Require().Empty(consensusHeights)

consensusState, found := suite.chainA.GetSimApp().GetIBCKeeper().ClientKeeper.GetClientConsensusState(suite.chainA.GetContext(), path.EndpointA.ClientID, clienttypes.NewHeight(1, uint64(suite.chainB.GetContext().BlockHeight())))
suite.Require().False(found)
suite.Require().Nil(consensusState)
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
}

// perform custom checks
Expand Down
Loading