Support for merkle proofs has been implemented as part of CosmJS by Ethan Frey, Will Clark and Simon Warta between June and August 2020.
In order to make this integration possible, a Cosmos SDK client that connects to Tendermint directly had to be implemented. This is available as a separate package @cosmjs/tendermint-rpc to be usable independent of a certain blockchain.
Building on top of Tendermint, there is a new package @cosmjs/stargate for connecting to Cosmos SDK 0.40+ blockchains. This package contains a high level StargateClient using a QueryClient.
QueryClient is the core of the query work. It only contains two methods queryUnverified
and queryVerified
but can be extended with module-specific queries. queryUnverified
submits a gRPC query and returns a result. Since this includes data processing, such queries cannot be verified. queryVerified
accessed Tendermit state directly and allows us to verify light client proofs provided by Tendermint using the ICS23 implementation by Confio.
The extension system for QueryClient works very similar to the one in @cosmjs/launchpad. You create a client with all the extensions you need, and have them available in a type safe way:
Extensions are implemented using auto-generated code from the Cosmos SDK .proto schemas. This makes the setup robust and maintainable. An example for an extension that shows one verified query and multiple gPRC queries is BankExtension.
Code generation from .proto files is powered by protobuf.js and provides a runtime implementation in JavaScript as well as TypeScript type definitions. The process works as follows:
import { cosmos, google } from "../codec";
The provable (raw) queries need to be manually writen after looking at the relevant Cosmos SDK implementations. We have done the following provable queries (which assert there is a proof to match the result to the AppHash in the header of height H+1):
The following work was done along with the milestone: