cmd, core/state, eth, tests, trie: improve state reader (#27428)
The state availability is checked during the creation of a state reader.
- In hash-based database, if the specified root node does not exist on disk disk, then
the state reader won't be created and an error will be returned.
- In path-based database, if the specified state layer is not available, then the
state reader won't be created and an error will be returned.
This change also contains a stricter semantics regarding the `Commit` operation: once it has been performed, the trie is no longer usable, and certain operations will return an error.
This commit is contained in:
@@ -1664,7 +1664,7 @@ func verifyTrie(db ethdb.KeyValueStore, root common.Hash, t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
accounts, slots := 0, 0
|
||||
accIt := trie.NewIterator(accTrie.NodeIterator(nil))
|
||||
accIt := trie.NewIterator(accTrie.MustNodeIterator(nil))
|
||||
for accIt.Next() {
|
||||
var acc struct {
|
||||
Nonce uint64
|
||||
@@ -1682,7 +1682,7 @@ func verifyTrie(db ethdb.KeyValueStore, root common.Hash, t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
storeIt := trie.NewIterator(storeTrie.NodeIterator(nil))
|
||||
storeIt := trie.NewIterator(storeTrie.MustNodeIterator(nil))
|
||||
for storeIt.Next() {
|
||||
slots++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user