diff --git a/.pending/bugfixes/_4891-Disable-queryi b/.pending/bugfixes/_4891-Disable-queryi new file mode 100644 index 000000000000..2878ce82b7e8 --- /dev/null +++ b/.pending/bugfixes/_4891-Disable-queryi @@ -0,0 +1 @@ +#4891 Disable querying with proofs enabled when the query height <= 1. diff --git a/client/context/query.go b/client/context/query.go index 87f96aece166..9e8ec0ae577e 100644 --- a/client/context/query.go +++ b/client/context/query.go @@ -74,13 +74,19 @@ func (ctx CLIContext) GetFromName() string { // query performs a query to a Tendermint node with the provided store name // and path. It returns the result and height of the query upon success -// or an error if the query fails. +// or an error if the query fails. In addition, it will verify the returned +// proof if TrustNode is disabled. If proof verification fails or the query +// height is invalid, an error will be returned. func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, height int64, err error) { node, err := ctx.GetNode() if err != nil { return res, height, err } + if ctx.Height <= 1 && !ctx.TrustNode { + return res, height, errors.New("cannot query with proof when height <= 1; please provide a valid height") + } + opts := rpcclient.ABCIQueryOptions{ Height: ctx.Height, Prove: !ctx.TrustNode, diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index c3f011e200f4..896b7dac4e42 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -402,7 +402,7 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery { } if res.Proof == nil || len(res.Proof.Ops) == 0 { - return errors.ErrInternal("substore proof was nil/empty when it should never be").QueryResult() + return errors.ErrInternal("proof is unexpectedly empty; ensure height has not been pruned").QueryResult() } commitInfo, errMsg := getCommitInfo(rs.db, res.Height)