|
|
|
@ -881,8 +881,12 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { |
|
|
|
|
if err := s.snaps.Update(root, parent, s.snapDestructs, s.snapAccounts, s.snapStorage); err != nil { |
|
|
|
|
log.Warn("Failed to update snapshot tree", "from", parent, "to", root, "err", err) |
|
|
|
|
} |
|
|
|
|
if err := s.snaps.Cap(root, 127); err != nil { // Persistent layer is 128th, the last available trie
|
|
|
|
|
log.Warn("Failed to cap snapshot tree", "root", root, "layers", 127, "err", err) |
|
|
|
|
// Keep 128 diff layers in the memory, persistent layer is 129th.
|
|
|
|
|
// - head layer is paired with HEAD state
|
|
|
|
|
// - head-1 layer is paired with HEAD-1 state
|
|
|
|
|
// - head-127 layer(bottom-most diff layer) is paired with HEAD-127 state
|
|
|
|
|
if err := s.snaps.Cap(root, 128); err != nil { |
|
|
|
|
log.Warn("Failed to cap snapshot tree", "root", root, "layers", 128, "err", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
s.snap, s.snapDestructs, s.snapAccounts, s.snapStorage = nil, nil, nil, nil |
|
|
|
|