cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

Implement Height Parameter for Queries

Open msteiner96 opened this issue 3 years ago • 3 comments

I suggest that we add another parameter to ALL querys, using which you can execute queries not automatically to the current blockheight but to a lower blockheight.

This needs an archive node, since most nodes only have 100 heights saved. Anyways, we can catch that error and it might be helpful.

Flags:
      --height int      Use a specific height to query state at (this can error if the node is pruning state)

msteiner96 avatar Feb 25 '22 08:02 msteiner96

First step is here: https://github.com/cosmos/cosmjs/issues/1250

webmaster128 avatar Sep 05 '22 13:09 webmaster128

@webmaster128 Hey, I am looking for this same functionality as well. I'm not sure that I follow how #1250 allows for querying with a block height? Or is there still some implementation needed for us to be able to do any query with a block height?

Appreciate any help that you can provide!

lovrobiljeskovic avatar Feb 24 '23 18:02 lovrobiljeskovic

Turns out the gRPC interface does not support height parameters directly. However, they can be passed as metadata. See https://docs.cosmos.network/v0.47/run-node/interact-node#query-for-historical-state-using-grpcurl and https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md.

In https://github.com/cosmos/cosmjs/pull/1378 you see a proof of concept how this can be added to our client to preserve and send it as part of the tendermint RPC request.

I dod not test that in a live system yet. If someone wants to explore this forther, have a look at #1378.

webmaster128 avatar Mar 06 '23 17:03 webmaster128