可以通过治理提案使用替代客户端的状态来更新客户端。此类治理提案通常用于恢复已过期或已冻结的客户端,因为它能够恢复完整状态,因此也能恢复构建在该客户端之上的所有现有通道。应实现 RecoverClient 来处理该提案。

实现 RecoverClient

在 LightClientModule interface 中,可以看到:
/ RecoverClient must verify that the provided substitute 
/ may be used to update the subject client. The light client
/ must set the updated client and consensus states within
/ the clientStore for the subject client.
RecoverClient(
  ctx sdk.Context,
  clientID,
  substituteClientID string,
)

error
在更新之前,该函数必须验证:
  • 替代客户端与目标客户端属于相同类型。参考实现请见 Tendermint 轻客户端。
  • 提供的替代客户端可用于更新目标客户端。这可能意味着某些参数必须保持不变。例如,一个有效的 Tendermint 替代轻客户端不得更改 chain ID、trust level、max clock drift、unbonding period、proof specs 或 upgrade path。请注意,AllowUpdateAfterMisbehaviour 和 AllowUpdateAfterExpiry 已被弃用(更多信息参见 ADR 026)。
完成这些检查后,该函数必须在目标客户端的客户端存储中设置更新后的客户端状态与共识状态。 更多参考,请参阅 Tendermint 轻客户端实现。
It is possible to update the client with the state of the substitute client through a governance proposal. This type of governance proposal is typically used to recover an expired or frozen client, as it can recover the entire state and therefore all existing channels built on top of the client. RecoverClient should be implemented to handle the proposal.

Implementing RecoverClient

In the LightClientModule interface, we find:
/ RecoverClient must verify that the provided substitute 
/ may be used to update the subject client. The light client
/ must set the updated client and consensus states within
/ the clientStore for the subject client.
RecoverClient(
  ctx sdk.Context,
  clientID,
  substituteClientID string,
)

error
Prior to updating, this function must verify that:
  • the substitute client is the same type as the subject client. For a reference implementation, please see the Tendermint light client.
  • the provided substitute may be used to update the subject client. This may mean that certain parameters must remain unaltered. For example, a valid substitute Tendermint light client must NOT change the chain ID, trust level, max clock drift, unbonding period, proof specs or upgrade path. Please note that AllowUpdateAfterMisbehaviour and AllowUpdateAfterExpiry have been deprecated (see ADR 026 for more information).
After these checks are performed, the function must set the updated client and consensus states within the client store for the subject client. Please refer to the Tendermint light client implementation for reference.