Skip to content

Commit

Permalink
core/state/snapshot: use stackTrie for small tries
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Mar 16, 2021
1 parent df33b73 commit 1eb3ef0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/state/snapshot/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,14 @@ func (dl *diskLayer) proveRange(root common.Hash, tr *trie.Trie, prefix []byte,
}
// The snap state is exhausted, pass the entire key/val set for verification
if origin == nil && !aborted {
_, _, _, _, err := trie.VerifyRangeProof(root, nil, nil, keys, vals, nil)
return &proofResult{keys: keys, vals: vals, cont: false, proofErr: err}, nil
stackTr := trie.NewStackTrie(nil)
for i, key := range keys {
stackTr.TryUpdate(key, common.CopyBytes(vals[i]))
}
if gotRoot := stackTr.Hash(); gotRoot != root {
return &proofResult{keys: keys, vals: vals, cont: false, proofErr: errors.New("wrong root")}, nil
}
return &proofResult{keys: keys, vals: vals, cont: false, proofErr: nil}, nil
}
// Snap state is chunked, generate edge proofs for verification.
// Firstly find out the key of last iterated element.
Expand Down

0 comments on commit 1eb3ef0

Please sign in to comment.