Fix IBC Query cmds (#7648)

* fix query

* update comment
This commit is contained in:
colin axnér 2020-10-23 18:31:32 +02:00 committed by GitHub
parent 73e7dad713
commit c6cbe3a3db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,20 +18,25 @@ import (
// to perform the query should be set in the client context. The query will be
// performed at one below this height (at the IAVL version) in order to obtain
// the correct merkle proof. Proof queries at height less than or equal to 2 are
// not supported.
// not supported. Queries with a client context height of 0 will perform a query
// at the lastest state available.
// Issue: https://github.com/cosmos/cosmos-sdk/issues/6567
func QueryTendermintProof(clientCtx client.Context, key []byte) ([]byte, []byte, clienttypes.Height, error) {
height := clientCtx.Height
// ABCI queries at height less than or equal to 2 are not supported.
// ABCI queries at heights 1, 2 or less than or equal to 0 are not supported.
// Base app does not support queries for height less than or equal to 1.
// Therefore, a query at height 2 would be equivalent to a query at height 3
if clientCtx.Height <= 2 {
// Therefore, a query at height 2 would be equivalent to a query at height 3.
// A height of 0 will query with the lastest state.
if height != 0 && height <= 2 {
return nil, nil, clienttypes.Height{}, fmt.Errorf("proof queries at height <= 2 are not supported")
}
// Use the IAVL height if a valid tendermint height is passed in.
height--
// A height of 0 will query with the latest state.
if height != 0 {
height--
}
req := abci.RequestQuery{
Path: fmt.Sprintf("store/%s/key", host.StoreKey),