Skip to content

Commit

Permalink
Merge pull request #58 from rootulp/rp/init-consensus-state
Browse files Browse the repository at this point in the history
fix: setConsensusState when light client is initialized
  • Loading branch information
rootulp authored Dec 20, 2024
2 parents bb7f418 + fdd9030 commit 2746889
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ibc/lightclients/groth16/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,15 @@ func (cs ClientState) ZeroCustomFields() exported.ClientState {
}
}

// initialize will check that initial consensus state is a groth16 consensus state
// and will store ProcessedTime for initial consensus state as ctx.BlockTime()
func (cs ClientState) initialize(ctx context.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, consState exported.ConsensusState) error {
if _, ok := consState.(*ConsensusState); !ok {
return sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "invalid initial consensus state. expected type: %T, got: %T",
&ConsensusState{}, consState)
func (cs ClientState) initialize(ctx context.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, initialConsensusState exported.ConsensusState) error {
consensusState, ok := initialConsensusState.(*ConsensusState)
if !ok {
return sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "invalid initial consensus state. expected type: %T, got: %T", &ConsensusState{}, initialConsensusState)
}
// TODO: should we be setting consensus state? probably (nina)
height := cs.GetLatestClientHeight()
SetConsensusState(clientStore, cdc, consensusState, height)
setConsensusMetadata(ctx, clientStore, height)
setClientState(clientStore, cdc, &cs)
// set metadata for initial consensus state.
setConsensusMetadata(ctx, clientStore, cs.GetLatestClientHeight())
return nil
}

Expand Down

0 comments on commit 2746889

Please sign in to comment.