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: add 668 functions to localhost client #908

Merged
Merged
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
28 changes: 28 additions & 0 deletions modules/light-clients/09-localhost/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ func (cs ClientState) ExportMetadata(_ sdk.KVStore) []exported.GenesisMetadata {

// CheckHeaderAndUpdateState updates the localhost client. It only needs access to the context
func (cs *ClientState) CheckHeaderAndUpdateState(
ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, header exported.Header,
) (exported.ClientState, exported.ConsensusState, error) {
return cs.UpdateState(ctx, cdc, clientStore, header)
}

// VerifyHeader is a no-op.
func (cs *ClientState) VerifyHeader(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (exported.ClientState, exported.ConsensusState, error) {
return cs, nil, nil
}

// CheckForMisbehaviour returns false.
func (cs *ClientState) CheckForMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (bool, error) {
return false, nil
}

// UpdateState updates the localhost client. It only needs access to the context
func (cs *ClientState) UpdateState(
ctx sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (exported.ClientState, exported.ConsensusState, error) {
// use the chain ID from context since the localhost client is from the running chain (i.e self).
Expand All @@ -88,6 +109,13 @@ func (cs *ClientState) CheckHeaderAndUpdateState(
return cs, nil, nil
}

// UpdateStateOnMisbehaviour returns an error (no misbehaviour case).
func (cs *ClientState) UpdateStateOnMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (*ClientState, error) {
return nil, sdkerrors.Wrapf(clienttypes.ErrUpdateClientFailed, "cannot update localhost client on misbehaviour")
}

// CheckMisbehaviourAndUpdateState implements ClientState
// Since localhost is the client of the running chain, misbehaviour cannot be submitted to it
// Thus, CheckMisbehaviourAndUpdateState returns an error for localhost
Expand Down