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

refactor: rename SelfClientValidator to ConsensusHost and mv tests #6018

Merged
merged 9 commits into from
Mar 20, 2024
126 changes: 0 additions & 126 deletions modules/core/02-client/keeper/client_validator.go

This file was deleted.

42 changes: 21 additions & 21 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import (
// Keeper represents a type that grants read and write permissions to any client
// state information
type Keeper struct {
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
router *types.Router
selfClientValidator types.SelfClientValidator
legacySubspace types.ParamSubspace
stakingKeeper types.StakingKeeper
upgradeKeeper types.UpgradeKeeper
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
router *types.Router
consensusHost types.ConsensusHost
legacySubspace types.ParamSubspace
stakingKeeper types.StakingKeeper
upgradeKeeper types.UpgradeKeeper
}

// NewKeeper creates a new NewKeeper instance
Expand All @@ -40,13 +40,13 @@ func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace ty
router.AddRoute(exported.Localhost, localhostModule)

return Keeper{
storeKey: key,
cdc: cdc,
router: router,
selfClientValidator: NewTendermintClientValidator(sk),
legacySubspace: legacySubspace,
stakingKeeper: sk,
upgradeKeeper: uk,
storeKey: key,
cdc: cdc,
router: router,
consensusHost: ibctm.NewConsensusHost(sk),
legacySubspace: legacySubspace,
stakingKeeper: sk,
upgradeKeeper: uk,
}
}

Expand Down Expand Up @@ -80,13 +80,13 @@ func (k Keeper) UpdateLocalhostClient(ctx sdk.Context, clientState exported.Clie
return clientModule.UpdateState(ctx, exported.LocalhostClientID, nil)
}

// SetSelfClientValidator sets a custom self client validation function.
func (k *Keeper) SetSelfClientValidator(selfClientValidator types.SelfClientValidator) {
if selfClientValidator == nil {
panic(fmt.Errorf("cannot set a nil self client validator"))
// SetSelfConsensusHost sets a custom ConsensusHost for self client state and consensus state validation.
func (k *Keeper) SetSelfConsensusHost(consensusHost types.ConsensusHost) {
if consensusHost == nil {
panic(fmt.Errorf("cannot set a nil self consensus host"))
}

k.selfClientValidator = selfClientValidator
k.consensusHost = consensusHost
}

// GenerateClientIdentifier returns the next client identifier.
Expand Down Expand Up @@ -309,15 +309,15 @@ func (k Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string)
// and returns the expected consensus state at that height.
// For now, can only retrieve self consensus states for the current revision
func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, error) {
return k.selfClientValidator.GetSelfConsensusState(ctx, height)
return k.consensusHost.GetSelfConsensusState(ctx, height)
}

// ValidateSelfClient validates the client parameters for a client of the running chain.
// This function is only used to validate the client state the counterparty stores for this chain.
// NOTE: If the client type is not of type Tendermint then delegate to a custom client validator function.
// This allows support for non-Tendermint clients, for example 08-wasm clients.
func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error {
return k.selfClientValidator.ValidateSelfClient(ctx, clientState)
return k.consensusHost.ValidateSelfClient(ctx, clientState)
}

// GetUpgradePlan executes the upgrade keeper GetUpgradePlan function.
Expand Down
Loading
Loading