From fdd9030b947654b513c1523ba03efa1bae47c5af Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 20 Dec 2024 10:41:56 -0500 Subject: [PATCH] fix: setConsensusState when light client is initialized --- ibc/lightclients/groth16/client_state.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ibc/lightclients/groth16/client_state.go b/ibc/lightclients/groth16/client_state.go index 333b83f..929243b 100644 --- a/ibc/lightclients/groth16/client_state.go +++ b/ibc/lightclients/groth16/client_state.go @@ -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 }