Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add message and rpc handler to recover clients using v1 governance proposals #3672

Closed
6 tasks done
Tracked by #3674 ...
crodriguezvega opened this issue May 28, 2023 · 1 comment
Closed
6 tasks done
Tracked by #3674 ...
Assignees
Labels
02-client change: api breaking Issues or PRs that break Go API (need to be release in a new major version)
Milestone

Comments

@crodriguezvega
Copy link
Contributor

crodriguezvega commented May 28, 2023

Part of #1282.

Overview of changes:

Protobuf

  • Add a new rpc handler to 02-client MsgService. Something like this:
rpc RecoverClient(MsgRecoverClient) returns (MsgRecoverClientResponse);

where MsgRecoverClient could look like this:

message MsgRecoverClient {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;
  option (cosmos.msg.v1.signer)      = "authority";

  // authority is the address of the governance account.
  string authority = 1;
  // the client identifier for the client to be updated if the proposal passes
  string subject_client_id = 2;
  // the substitute client identifier for the client standing in for the subject
  // client
  string substitute_client_id = 3;
}

and MsgRecoverClientResponse can be empty:

message MsgRecoverClientResponse {}

02-client

  • Add function RecoverClient to 02-client keeper with logic to recover client. The signature of the function could look like this:
func (k Keeper) RecoverClient(ctx sdk.Context, subjectClientId, substituteClientId string) error
  • Add implementation of RecoverClient, which could be similar to ClientUpdateProposal's implementation.

  • Implement sdk.Msg interface for MsgRecoverClient.

  • If it's possible to re-use the error code for ErrInvalidUpdateClientProposal, then rename the error to, for example, ErrInvalidRecoveryClient and adjust the error description to invalid recovery client.

Core

  • Add implementation of RecoverClient rpc handler in IBC core msg_server.go (modules/core/keeper/msg_server.go). The signature of the handler could look like this:
func (k Keeper) RecoverClient(
  goCtx context.Context, 
  msg *clienttypes.MsgRecoverClient
) (*clienttypes.MsgRecoverClientResponse, error)

and the implementation could look like this:

// check message signer matches authority set
if k.authority != msg.Signer {
  return nil, errorsmod.Wrapf(
    govtypes.ErrInvalidSigner, 
    "invalid authority: expected %s, got %s", k.authority, msg.Signer
  )
}

ctx := sdk.UnwrapSDKContext(goCtx)

err := k.ClientKeeper.RecoverClient(ctx, msg.SubjectClientId, msg.SubstituteClientId)
if err != nil {
  return nil, errorsmod(err, "client recovery failed")
}

return &types. MsgRecoverClientResponse{}, nil

CLI

Documentation

Break up the implementation in multiple PRs. One possible suggestion:

@crodriguezvega crodriguezvega added needs discussion Issues that need discussion before they can be worked on 02-client change: api breaking Issues or PRs that break Go API (need to be release in a new major version) labels May 28, 2023
@crodriguezvega crodriguezvega added this to the v8.0.0 milestone May 28, 2023
@crodriguezvega crodriguezvega moved this to Todo in ibc-go May 28, 2023
@crodriguezvega crodriguezvega removed the needs discussion Issues that need discussion before they can be worked on label Jun 26, 2023
@DimitrisJim DimitrisJim self-assigned this Aug 22, 2023
@DimitrisJim DimitrisJim moved this from Todo to In progress in ibc-go Aug 24, 2023
@colin-axner
Copy link
Contributor

Closed by all the linked issues!

@github-project-automation github-project-automation bot moved this from In progress to Done in ibc-go Sep 6, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
02-client change: api breaking Issues or PRs that break Go API (need to be release in a new major version)
Projects
Archived in project
Development

No branches or pull requests

3 participants