Open liangping opened 2 years ago
thanks @liangping ! will be integrating this into our gRPC client class. Appreciate the help!
thanks @liangping ! will be integrating this into our gRPC client class. Appreciate the help!
Awesome! If so i would like to use this instead of the current LCD endpoint on ping.pub.
gRPCFTW
@sascha1337 @liangping does this look like a good reference implementation?
https://github.com/cosmos/cosmjs/blob/main/packages/stargate/src/modules/bank/queries.ts#L20-L59
It looks like they were actually using this? https://github.com/confio/cosmjs-types/blob/main/src/cosmos/bank/v1beta1/query.ts#L1079
I think we can improve it a bit?
Some ideas:
On protobuf, It's good reference.
It might be almost same, except this one:
const rpc = createProtobufRpcClient(base);
gRPC client need Http2(almost all web explorer(chrome, firefox) don't support it so far), we need implement it with WASM.
look at
export function createProtobufRpcClient(base: QueryClient): ProtobufRpcClient {
return {
request: (service: string, method: string, data: Uint8Array): Promise<Uint8Array> => {
const path = `/${service}/${method}`;
return base.queryUnverified(path, data);
},
};
}
seems that we can just simply re-implement this method.
public async queryUnverified(path: string, request: Uint8Array): Promise<Uint8Array> {
const response = await this.tmClient.abciQuery({
path: path,
data: request,
prove: false,
});
if (response.code) {
throw new Error(`Query failed with (${response.code}): ${response.log}`);
}
return response.value;
}
I confirm that tmclient is implemented based on http, not http2 https://github.com/cosmos/cosmjs/blob/b63075aca18538a0c9f312dfaf43be271f5d39aa/packages/tendermint-rpc/src/tendermint34/tendermint34client.ts#L17
thank you @liangping 🙌🏻
this is great to have all the information we need for this issue in one place.
I confirm that tmclient is implemented based on http, not http2 https://github.com/cosmos/cosmjs/blob/b63075aca18538a0c9f312dfaf43be271f5d39aa/packages/tendermint-rpc/src/tendermint34/tendermint34client.ts#L17
I think secret.js uses this for http2 https://github.com/improbable-eng/grpc-web
Should we look at what secret is doing? https://github.com/scrtlabs/secret.js/blob/master/src/secret_network_client.ts#L636-L723
I think we are almost there. Secret did amazing works. We can improve it. In this implementation, we need a gRPC proxy which is not friendly to users. That's why I want to use WASM.
Looking at more clients out there, found this one: https://github.com/deeplay-io/nice-grpc
Sometimes GitHub ui sucks, using mobile GitHub app now, i see meantion and comments that completely were kinda hidden on desktop 🤦♂️
I've worked a lot on grpc / introspection methods and solutions lately, if combined with cosmology repo // chain registry api's, this is really powerful stuff, need and built this for myself, so time to get that wrapped and packed to npm sers.
Also check efficiency // references here on bottom
NOTE: This might not strongly related to telescope.
Currently, most of web apps have to use Javascript/Typescript to connect with light client server, since most web explorers don’t support gRPC and http2.
It's very useful to build a gRPC client with Web assembly and http2. Once it is built, developers can easily invoke gRPC services underlying the Rest services. and it is smaller, faster, laser resources consumed.
With Telescope, This could be much earlier.
List all services
List Methods of a service:
invoke gRPC calls:
Call
cosmos.base.tendermint.v1beta1.Service.GetLatestBlock
return proto message.Therefore, We can call all services directly via gRPC