概述
轻客户端协议的目标,是获取某个近期区块哈希对应的提交结果,其中该提交包含来自上一个已知验证者集合的大多数签名。在此基础上,所有应用状态都可以通过 Merkle 证明进行验证。特性
- 你可以获得 CometBFT 完整的抵押安全性收益; 无需等待确认。
- 你可以获得 CometBFT 完整的速度优势;交易会立即提交。
- 你可以以非交互方式获取应用状态的最新版本 (无需向区块链提交任何内容)。例如,这意味着你可以从名称注册表中获取某个名称的最新值, 无需担心分叉审查攻击,也无需提交一次提交并等待确认。它快速、安全且免费。
从哪里获取可信高度与哈希
Trust Options 获取半可信哈希与高度的一种方式,是查询多个全节点并比较它们的哈希:将轻客户端作为 HTTP 代理服务器运行
CometBFT 内置了cometbft light 命令,可用于运行轻客户端代理服务器,并对 CometBFT RPC 进行验证。所有能够通过证明追溯到区块头的调用,都会在返回给调用方之前完成验证。除此之外,它提供的接口与完整的 CometBFT 节点相同。
你可以通过运行 cometbft light <chainID> 来启动轻客户端代理服务器,并使用多种标志来指定主节点、见证节点(用于交叉检查主节点提供的信息)、可信头的哈希与高度等。
例如:
cometbft light --help。
Light clients are an important part of the complete blockchain system for most applications. CometBFT provides unique speed and security properties for light client applications. See our light package.
Overview
The objective of the light client protocol is to get a commit for a recent block hash where the commit includes a majority of signatures from the last known validator set. From there, all the application state is verifiable with Merkle proofs.Properties
- You get the full collateralized security benefits of CometBFT; no need to wait for confirmations.
- You get the full speed benefits of CometBFT; transactions commit instantly.
- You can get the most recent version of the application state non-interactively (without committing anything to the blockchain). For example, this means that you can get the most recent value of a name from the name registry without worrying about fork censorship attacks, without posting a commit and waiting for confirmations. It’s fast, secure, and free!
Where to obtain trusted height & hash
Trust Options One way to obtain a semi-trusted hash & height is to query multiple full nodes and compare their hashes:Running a light client as an HTTP proxy server
CometBFT comes with a built-incometbft light command, which can be used
to run a light client proxy server, verifying CometBFT RPC. All calls that
can be tracked back to a block header by a proof will be verified before
passing them back to the caller. Other than that, it will present the same
interface as a full CometBFT node.
You can start the light client proxy server by running cometbft light <chainID>,
with a variety of flags to specify the primary node, the witness nodes (which cross-check
the information provided by the primary), the hash and height of the trusted header,
and more.
For example:
cometbft light --help.