From a15a0ea2887e25503f7be9c7dcc6a725dd80412f Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 15 Sep 2021 07:52:25 -0700 Subject: [PATCH] Fix query height issue with IBC proofs --- modules/core/client/query.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/core/client/query.go b/modules/core/client/query.go index 4b954189f11..f21586d5ba2 100644 --- a/modules/core/client/query.go +++ b/modules/core/client/query.go @@ -22,25 +22,23 @@ import ( // 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 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. // A height of 0 will query with the lastest state. - if height != 0 && height <= 2 { + if clientCtx.Height != 0 && clientCtx.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. // A height of 0 will query with the latest state. - if height != 0 { - height-- + if clientCtx.Height != 0 { + clientCtx.Height = clientCtx.Height - 1 } req := abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", host.StoreKey), - Height: height, + Height: clientCtx.Height, Data: key, Prove: true, }