forked from cerc-io/plugeth
core, trie: rework trie committer (#25320)
* all: rework trie and trie committer * all: get rid of internal cache in trie * all: fixes * trie: polish * core, trie: address comments * trie: fix imports * core/state: address comments * core/state/snapshot: polish * trie: remove unused code * trie: update tests * trie: don't set db as nil * trie: address comments * trie: unskip test
This commit is contained in:
@@ -173,10 +173,13 @@ func (f *fuzzer) fuzz() int {
|
||||
return 0
|
||||
}
|
||||
// Flush trie -> database
|
||||
rootA, _, err := trieA.Commit(nil)
|
||||
rootA, nodes, err := trieA.Commit(false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if nodes != nil {
|
||||
dbA.Update(trie.NewWithNodeSet(nodes))
|
||||
}
|
||||
// Flush memdb -> disk (sponge)
|
||||
dbA.Commit(rootA, false, nil)
|
||||
|
||||
|
||||
@@ -51,9 +51,8 @@ const (
|
||||
opUpdate = iota
|
||||
opDelete
|
||||
opGet
|
||||
opCommit
|
||||
opHash
|
||||
opReset
|
||||
opCommit
|
||||
opItercheckhash
|
||||
opProve
|
||||
opMax // boundary value, not an actual op
|
||||
@@ -157,15 +156,18 @@ func runRandTest(rt randTest) error {
|
||||
if string(v) != want {
|
||||
rt[i].err = fmt.Errorf("mismatch for key %#x, got %#x want %#x", step.key, v, want)
|
||||
}
|
||||
case opCommit:
|
||||
_, _, rt[i].err = tr.Commit(nil)
|
||||
case opHash:
|
||||
tr.Hash()
|
||||
case opReset:
|
||||
hash, _, err := tr.Commit(nil)
|
||||
case opCommit:
|
||||
hash, nodes, err := tr.Commit(false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if nodes != nil {
|
||||
if err := triedb.Update(trie.NewWithNodeSet(nodes)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
newtr, err := trie.New(common.Hash{}, hash, triedb)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user