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

chore: CheckSubstituteAndUpdateState stores client state in lightclients impl #1170

Merged
Show file tree
Hide file tree
Changes from all 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 @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements
* [\#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.

### Features

Expand Down
1 change: 0 additions & 1 deletion modules/core/02-client/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
if err != nil {
return err
}
k.SetClientState(ctx, p.SubjectClientId, clientState)

k.Logger(ctx).Info("client updated after governance proposal passed", "client-id", p.SubjectClientId, "height", clientState.GetLatestHeight().String())

Expand Down
2 changes: 2 additions & 0 deletions modules/light-clients/06-solomachine/types/proposal_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ func (cs ClientState) CheckSubstituteAndUpdateState(
clientState.ConsensusState = substituteClientState.ConsensusState
clientState.IsFrozen = false

setClientState(subjectClientStore, cdc, clientState)

return clientState, nil
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package types_test

import (
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
"github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types"
ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
Expand Down Expand Up @@ -78,6 +80,10 @@ func (suite *SoloMachineTestSuite) TestCheckSubstituteAndUpdateState() {
suite.Require().Equal(substituteClientState.(*types.ClientState).ConsensusState, updatedClient.(*types.ClientState).ConsensusState)
suite.Require().Equal(substituteClientState.(*types.ClientState).Sequence, updatedClient.(*types.ClientState).Sequence)
suite.Require().Equal(false, updatedClient.(*types.ClientState).IsFrozen)

// ensure updated client state is set in store
bz := subjectClientStore.Get(host.ClientStateKey())
suite.Require().Equal(clienttypes.MustMarshalClientState(suite.chainA.Codec, updatedClient), bz)
} else {
suite.Require().Error(err)
suite.Require().Nil(updatedClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (cs ClientState) CheckSubstituteAndUpdateState(

// no validation is necessary since the substitute is verified to be Active
// in 02-client.
setClientState(subjectClientStore, cdc, &cs)

return &cs, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
"github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
Expand Down Expand Up @@ -299,6 +300,10 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() {
suite.Require().Equal(expectedIterationKey, subjectIterationKey)

suite.Require().Equal(newChainID, updatedClient.(*types.ClientState).ChainId)

// ensure updated client state is set in store
bz := subjectClientStore.Get(host.ClientStateKey())
suite.Require().Equal(clienttypes.MustMarshalClientState(suite.chainA.Codec, updatedClient), bz)
} else {
suite.Require().Error(err)
suite.Require().Nil(updatedClient)
Expand Down