ConsensusState 是对手链的状态快照,IBC 客户端会使用它来验证证明(例如区块)。
随着多种类型的 IBC 轻客户端的进一步发展,以及这种泛化问题带来的复杂性(有关这一历史背景的更多信息,请参见 ADR-006),设计上决定由每种客户端自行跟踪并设置各自的 ClientState 和 ConsensusState,同时通过通用的 ClientMessage 接口简化客户端 ConsensusState 的更新。
下面的 ConsensusState 接口,是对 ConsensusState 可能包含的信息类型进行抽象后的通用接口。关于一个参考性的 ConsensusState 实现,请参见 Tendermint 轻客户端的 ConsensusState。
ClientType 方法
这是客户端共识状态的类型。它应当与对应的 ClientState 实现中 ClientType 的返回值保持一致。
GetTimestamp 方法
GetTimestamp 应返回共识状态快照的时间戳(以纳秒为单位)。该函数已被弃用,并将在未来版本中移除。
ValidateBasic 方法
ValidateBasic 应验证共识状态中的每个字段,并在任意值无效时返回错误。需要执行哪些校验,应由轻客户端实现者决定。
A
ConsensusState is the snapshot of the counterparty chain, that an IBC client uses to verify proofs (e.g. a block).
The further development of multiple types of IBC light clients and the difficulties presented by this generalization problem (see ADR-006 for more information about this historical context) led to the design decision of each client keeping track of and set its own ClientState and ConsensusState, as well as the simplification of client ConsensusState updates through the generalized ClientMessage interface.
The below ConsensusState interface is a generalized interface for the types of information a ConsensusState could contain. For a reference ConsensusState implementation, please see the Tendermint light client ConsensusState.
ClientType method
This is the type of client consensus. It should be the same as the ClientType return value for the corresponding ClientState implementation.
GetTimestamp method
GetTimestamp should return the timestamp (in nanoseconds) of the consensus state snapshot. This function has been deprecated and will be removed in a future release.
ValidateBasic method
ValidateBasic should validate every consensus state field and should return an error if any value is invalid. The light client implementer is in charge of determining which checks are required.