trie: use explicit errors in stacktrie (instead of panic) (#28361)

This PR removes panics from stacktrie (mostly), and makes the Update return errors instead. While adding tests for this, I also found that one case of possible corruption was not caught, which is now fixed.
This commit is contained in:
Martin Holst Swende
2023-10-25 14:53:50 +02:00
committed by GitHub
parent 300df874d7
commit 96b75033c0
3 changed files with 31 additions and 4 deletions
+3 -1
View File
@@ -230,7 +230,9 @@ func (dl *diskLayer) proveRange(ctx *generatorContext, trieId *trie.ID, prefix [
if origin == nil && !diskMore {
stackTr := trie.NewStackTrie(nil)
for i, key := range keys {
stackTr.Update(key, vals[i])
if err := stackTr.Update(key, vals[i]); err != nil {
return nil, err
}
}
if gotRoot := stackTr.Hash(); gotRoot != root {
return &proofResult{