mirror of https://github.com/status-im/op-geth.git
core/state: fix an account resurrection issue
This commit is contained in:
parent
06d4470b41
commit
92ec07d63b
|
@ -297,18 +297,11 @@ func (s *stateObject) updateTrie(db Database) Trie {
|
|||
// Retrieve the snapshot storage map for the object
|
||||
var storage map[common.Hash][]byte
|
||||
if s.db.snap != nil {
|
||||
// Retrieve the old storage map, if available
|
||||
s.db.snapLock.RLock()
|
||||
// Retrieve the old storage map, if available, create a new one otherwise
|
||||
storage = s.db.snapStorage[s.addrHash]
|
||||
s.db.snapLock.RUnlock()
|
||||
|
||||
// If no old storage map was available, create a new one
|
||||
if storage == nil {
|
||||
storage = make(map[common.Hash][]byte)
|
||||
|
||||
s.db.snapLock.Lock()
|
||||
s.db.snapStorage[s.addrHash] = storage
|
||||
s.db.snapLock.Unlock()
|
||||
}
|
||||
}
|
||||
// Insert all the pending updates into the trie
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
@ -72,7 +71,6 @@ type StateDB struct {
|
|||
snap snapshot.Snapshot
|
||||
snapAccounts map[common.Hash][]byte
|
||||
snapStorage map[common.Hash]map[common.Hash][]byte
|
||||
snapLock sync.RWMutex // Lock for the concurrent storage updaters
|
||||
|
||||
// This map holds 'live' objects, which will get modified while processing a state transition.
|
||||
stateObjects map[common.Address]*stateObject
|
||||
|
@ -468,6 +466,10 @@ func (s *StateDB) updateStateObject(obj *stateObject) {
|
|||
|
||||
// If state snapshotting is active, cache the data til commit
|
||||
if s.snap != nil {
|
||||
// If the account is an empty resurrection, unmark the storage nil-ness
|
||||
if storage, ok := s.snapStorage[obj.addrHash]; storage == nil && ok {
|
||||
delete(s.snapStorage, obj.addrHash)
|
||||
}
|
||||
s.snapAccounts[obj.addrHash] = snapshot.AccountRLP(obj.data.Nonce, obj.data.Balance, obj.data.Root, obj.data.CodeHash)
|
||||
}
|
||||
}
|
||||
|
@ -484,10 +486,8 @@ func (s *StateDB) deleteStateObject(obj *stateObject) {
|
|||
|
||||
// If state snapshotting is active, cache the data til commit
|
||||
if s.snap != nil {
|
||||
s.snapLock.Lock()
|
||||
s.snapAccounts[obj.addrHash] = nil // We need to maintain account deletions explicitly
|
||||
s.snapStorage[obj.addrHash] = nil // We need to maintain storage deletions explicitly
|
||||
s.snapLock.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue