From 584fa00081022d8eedd7ae06293acf7679df042a Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Fri, 21 Jan 2022 11:13:20 +0800 Subject: [PATCH] trie: fix range prover --- trie/proof.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trie/proof.go b/trie/proof.go index 51ecea0c39e6..9be3b62216a8 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -406,7 +406,7 @@ func unset(parent node, child node, key []byte, pos int, removeLeft bool) error } // hasRightElement returns the indicator whether there exists more elements -// in the right side of the given path. The given path can point to an existent +// on the right side of the given path. The given path can point to an existent // key or a non-existent one. This function has the assumption that the whole // path should already be resolved. func hasRightElement(node node, key []byte) bool { @@ -505,7 +505,7 @@ func VerifyRangeProof(rootHash common.Hash, firstKey []byte, lastKey []byte, key if val != nil || hasRightElement(root, firstKey) { return false, errors.New("more entries available") } - return hasRightElement(root, firstKey), nil + return false, nil } // Special case, there is only one element and two edge keys are same. // In this case, we can't construct two edge paths. So handle it here. @@ -563,7 +563,7 @@ func VerifyRangeProof(rootHash common.Hash, firstKey []byte, lastKey []byte, key if tr.Hash() != rootHash { return false, fmt.Errorf("invalid proof, want hash %x, got %x", rootHash, tr.Hash()) } - return hasRightElement(root, keys[len(keys)-1]), nil + return hasRightElement(tr.root, keys[len(keys)-1]), nil } // get returns the child of the given node. Return nil if the