From a6a42657b9819f09b47c6ea474d6e389d74803b2 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 30 Aug 2023 18:36:43 +0300 Subject: [PATCH] Docu RecoverClient, add label, re-use error. --- modules/core/02-client/keeper/client.go | 10 +++++++++- modules/core/02-client/keeper/proposal.go | 2 +- modules/core/02-client/types/errors.go | 3 +-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/core/02-client/keeper/client.go b/modules/core/02-client/keeper/client.go index ebcd8c307ed..b5e49f7f077 100644 --- a/modules/core/02-client/keeper/client.go +++ b/modules/core/02-client/keeper/client.go @@ -150,6 +150,13 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e return nil } +// RecoverClient will retrieve the subject and substitute client. +// A callback will occur to the subject client state with the client +// prefixed store being provided for both the subject and the substitute client. +// The IBC client implementations are responsible for validating the parameters of the +// substitute (ensuring they match the subject's parameters) as well as copying +// the necessary consensus states from the substitute to the subject client +// store. The substitute must be Active and the subject must not be Active. func (k Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClientID string) error { subjectClientState, found := k.GetClientState(ctx, subjectClientID) if !found { @@ -184,11 +191,12 @@ func (k Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClient k.Logger(ctx).Info("client recovered", "client-id", subjectClientID) defer telemetry.IncrCounterWithLabels( - []string{"ibc", "client", "recover"}, + []string{"ibc", "client", "update"}, 1, []metrics.Label{ telemetry.NewLabel(types.LabelClientType, substituteClientState.ClientType()), telemetry.NewLabel(types.LabelClientID, subjectClientID), + telemetry.NewLabel(types.LabelUpdateType, "recovery"), }, ) diff --git a/modules/core/02-client/keeper/proposal.go b/modules/core/02-client/keeper/proposal.go index f35f00d616d..12f2685e299 100644 --- a/modules/core/02-client/keeper/proposal.go +++ b/modules/core/02-client/keeper/proposal.go @@ -28,7 +28,7 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo subjectClientStore := k.ClientStore(ctx, p.SubjectClientId) if status := k.GetClientStatus(ctx, subjectClientState, p.SubjectClientId); status == exported.Active { - return errorsmod.Wrap(types.ErrInvalidUpdateClientProposal, "cannot update Active subject client") + return errorsmod.Wrap(types.ErrInvalidRecoveryClient, "cannot update Active subject client") } substituteClientState, found := k.GetClientState(ctx, p.SubstituteClientId) diff --git a/modules/core/02-client/types/errors.go b/modules/core/02-client/types/errors.go index 7809f59d133..3a726378cbc 100644 --- a/modules/core/02-client/types/errors.go +++ b/modules/core/02-client/types/errors.go @@ -28,7 +28,7 @@ var ( ErrFailedNextSeqRecvVerification = errorsmod.Register(SubModuleName, 21, "next sequence receive verification failed") ErrSelfConsensusStateNotFound = errorsmod.Register(SubModuleName, 22, "self consensus state not found") ErrUpdateClientFailed = errorsmod.Register(SubModuleName, 23, "unable to update light client") - ErrInvalidUpdateClientProposal = errorsmod.Register(SubModuleName, 24, "invalid update client proposal") + ErrInvalidRecoveryClient = errorsmod.Register(SubModuleName, 24, "invalid recovery client") ErrInvalidUpgradeClient = errorsmod.Register(SubModuleName, 25, "invalid client upgrade") ErrInvalidHeight = errorsmod.Register(SubModuleName, 26, "invalid height") ErrInvalidSubstitute = errorsmod.Register(SubModuleName, 27, "invalid client state substitute") @@ -36,5 +36,4 @@ var ( ErrClientNotActive = errorsmod.Register(SubModuleName, 29, "client state is not active") ErrFailedMembershipVerification = errorsmod.Register(SubModuleName, 30, "membership verification failed") ErrFailedNonMembershipVerification = errorsmod.Register(SubModuleName, 31, "non-membership verification failed") - ErrInvalidRecoveryClient = errorsmod.Register(SubModuleName, 32, "invalid recovery client") )