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 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
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