telescope
telescope copied to clipboard
broadcast doesn't work, because ABCI requires POST request, not query
https://github.com/cosmology-tech/interchain/blob/f636f775a1c4054d0bb3a03d76f9c98a68b89e97/packages/interchain/src/codegen/cosmos/tx/v1beta1/service.rpc.Service.ts#L12
@liujun93 will help add more color here
simulate()
works, but broadcast()
doesn't — is there a way to distinguish between the methods in this case in the protobufs? If not, we may need to add proto annoations in the Cosmos SDK before we can close this issue
I believe we need to look at get vs post in the service info
https://github.com/cosmos/cosmos-sdk/blob/35d2e48aea1773b2972940fd8a0b33d8f4e23179/proto/cosmos/tx/v1beta1/service.proto#L29
side note could be SDK bug (we should look at which messages in protos use post
): weird that simulate()
works via the get right now, but has post in the protos
Hi, @webmaster128
Recently we found broadcastTx function generated by Telescope is not working as expected, this’s how it’s generated originally:
const data = BroadcastTxRequest.encode(request).finish();
const promise = this.rpc.request("cosmos.tx.v1beta1.Service", "BroadcastTx", data);
return promise.then(data => BroadcastTxResponse.decode(new BinaryReader(data)));
Inside "this.rpc.request", tendermint client did ABCIQuery, and I’ve checked code of ABCIQuery of cosmos sdk, it can’t do broadcast, otherwise there’ll be an exception. And tendermint client provided broadcast functions other than ABCIQuery, so I guess we can use those for generating broadcastTx:
https://github.com/cosmology-tech/create-cosmos-app/blob/09b6e6cc7e61ee118003ff12a1301944dd5fad84/examples/telescope/src/codegen/cosmos/tx/v1beta1/service.rpc.Service.ts#L86C3-L86C14
So do you think this's a good way?
What kind of transport layer do you use here? Tendermint RPC, gRPC, gRPC-web, gRPC-proxy? For the first 3 there should not be any difference between GET or POST. You just send requests and get responses. CosmJS so far only uses Tendermint RPC where there is a dedicated RPC endpoint for broadcasting. It does not go through the services API.
gRPC-proxy I never worked with.
What kind of transport layer do you use here? Tendermint RPC, gRPC, gRPC-web, gRPC-proxy? For the first 3 there should not be any difference between GET or POST. You just send requests and get responses. CosmJS so far only uses Tendermint RPC where there is a dedicated RPC endpoint for broadcasting. It does not go through the services API.
gRPC-proxy I never worked with.
Hi, thanks for reply!
In this case, we're using Tendermint RPC. "this.rpc.request" will invoke "abciQuery" in "Tendermint34Client" from cosmjs. https://github.com/cosmos/cosmjs/blob/4e6d54b6cf5ef50bbf6f6c238980c4431ff7b401/packages/tendermint-rpc/src/tendermint34/tendermint34client.ts#L88C9-L88C9
I belive it'll eventually invoke abciQuery in cosmos-sdk, and I've checked the code of cosmos-sdk, there'll be an exception when a abciQuery trying to broadcastTx. https://github.com/cosmos/cosmos-sdk/blob/7bef0227f9ae68525a76b87b8109ec2d8be1f9ce/baseapp/abci.go#L196
So I guess we have to generate broadcastTx using broadcastTxSync or broadcastTxAsync, etc from "Tendermint34Client".
wdyt?