mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-14 03:56:36 +00:00
core/state: ignore the root returned in Commit function for simplicity (#34723)
StateDB.Commit first commits all storage changes into the storage trie, then updates the account metadata with the new storage root into the account trie. Within StateDB.Commit, the new storage trie root has already been computed and applied as the storage root. This PR explicitly skips the redundant storage trie root assignment for readability.
This commit is contained in:
parent
c9fea44616
commit
ef0f1f96f9
2 changed files with 5 additions and 7 deletions
|
|
@ -482,8 +482,9 @@ func (s *stateObject) commit() (*accountUpdate, *trienode.NodeSet, error) {
|
||||||
s.origin = s.data.Copy()
|
s.origin = s.data.Copy()
|
||||||
return op, nil, nil
|
return op, nil, nil
|
||||||
}
|
}
|
||||||
root, nodes := s.trie.Commit(false)
|
// The storage trie root is omitted, as it has already been updated in the
|
||||||
s.data.Root = root
|
// previous updateRoot step.
|
||||||
|
_, nodes := s.trie.Commit(false)
|
||||||
s.origin = s.data.Copy()
|
s.origin = s.data.Copy()
|
||||||
return op, nodes, nil
|
return op, nodes, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1162,7 +1162,7 @@ func (s *StateDB) commit(deleteEmptyObjects bool, noStorageWiping bool, blockNum
|
||||||
return nil, fmt.Errorf("commit aborted due to earlier error: %v", s.dbErr)
|
return nil, fmt.Errorf("commit aborted due to earlier error: %v", s.dbErr)
|
||||||
}
|
}
|
||||||
// Finalize any pending changes and merge everything into the tries
|
// Finalize any pending changes and merge everything into the tries
|
||||||
s.IntermediateRoot(deleteEmptyObjects)
|
root := s.IntermediateRoot(deleteEmptyObjects)
|
||||||
|
|
||||||
// Short circuit if any error occurs within the IntermediateRoot.
|
// Short circuit if any error occurs within the IntermediateRoot.
|
||||||
if s.dbErr != nil {
|
if s.dbErr != nil {
|
||||||
|
|
@ -1224,7 +1224,6 @@ func (s *StateDB) commit(deleteEmptyObjects bool, noStorageWiping bool, blockNum
|
||||||
// writes to run in parallel with the computations.
|
// writes to run in parallel with the computations.
|
||||||
var (
|
var (
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
root common.Hash
|
|
||||||
workers errgroup.Group
|
workers errgroup.Group
|
||||||
)
|
)
|
||||||
// Schedule the account trie first since that will be the biggest, so give
|
// Schedule the account trie first since that will be the biggest, so give
|
||||||
|
|
@ -1238,9 +1237,7 @@ func (s *StateDB) commit(deleteEmptyObjects bool, noStorageWiping bool, blockNum
|
||||||
// code didn't anticipate for.
|
// code didn't anticipate for.
|
||||||
workers.Go(func() error {
|
workers.Go(func() error {
|
||||||
// Write the account trie changes, measuring the amount of wasted time
|
// Write the account trie changes, measuring the amount of wasted time
|
||||||
newroot, set := s.trie.Commit(true)
|
_, set := s.trie.Commit(true)
|
||||||
root = newroot
|
|
||||||
|
|
||||||
if err := merge(set); err != nil {
|
if err := merge(set); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue