Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lite Client Query Height Fix #4895

Merged
merged 3 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pending/bugfixes/_4891-Disable-queryi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4891 Disable querying with proofs enabled when the query height <= 1.
8 changes: 7 additions & 1 deletion client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down