Skip to content

Commit

Permalink
patch query tendermint proof helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-axner committed Jun 1, 2021
1 parent 7075c49 commit 7ba386f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions x/ibc/core/client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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--

This comment has been minimized.

Copy link
@jackzampolin

jackzampolin Aug 3, 2021

Member

the fix here would be height = height -1 right?

This comment has been minimized.

Copy link
@colin-axner

colin-axner Aug 3, 2021

Author Contributor

No, the issue is described in #9433 which I should have linked. The problem is this code wasn't updating the client context height. The client context height was being used for the query instead of the Height argument below. So doing height-- or height = height - 1 only changes the request argument and not the actual query 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,
}
Expand Down

0 comments on commit 7ba386f

Please sign in to comment.