Skip to content

Commit 1eb3ef0

Browse files
committed
core/state/snapshot: use stackTrie for small tries
1 parent df33b73 commit 1eb3ef0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/state/snapshot/generate.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,14 @@ func (dl *diskLayer) proveRange(root common.Hash, tr *trie.Trie, prefix []byte,
260260
}
261261
// The snap state is exhausted, pass the entire key/val set for verification
262262
if origin == nil && !aborted {
263-
_, _, _, _, err := trie.VerifyRangeProof(root, nil, nil, keys, vals, nil)
264-
return &proofResult{keys: keys, vals: vals, cont: false, proofErr: err}, nil
263+
stackTr := trie.NewStackTrie(nil)
264+
for i, key := range keys {
265+
stackTr.TryUpdate(key, common.CopyBytes(vals[i]))
266+
}
267+
if gotRoot := stackTr.Hash(); gotRoot != root {
268+
return &proofResult{keys: keys, vals: vals, cont: false, proofErr: errors.New("wrong root")}, nil
269+
}
270+
return &proofResult{keys: keys, vals: vals, cont: false, proofErr: nil}, nil
265271
}
266272
// Snap state is chunked, generate edge proofs for verification.
267273
// Firstly find out the key of last iterated element.

0 commit comments

Comments
 (0)