forked from cerc-io/plugeth
core/state: avoid escape analysis fault when accessing cached state
This commit is contained in:
parent
cf6674539c
commit
80e887d7bf
@ -213,14 +213,14 @@ func (s *stateObject) GetCommittedState(db Database, key common.Hash) common.Has
|
|||||||
if _, destructed := s.db.snapDestructs[s.addrHash]; destructed {
|
if _, destructed := s.db.snapDestructs[s.addrHash]; destructed {
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
}
|
}
|
||||||
enc, err = s.db.snap.Storage(s.addrHash, crypto.Keccak256Hash(key[:]))
|
enc, err = s.db.snap.Storage(s.addrHash, crypto.Keccak256Hash(key.Bytes()))
|
||||||
}
|
}
|
||||||
// If snapshot unavailable or reading from it failed, load from the database
|
// If snapshot unavailable or reading from it failed, load from the database
|
||||||
if s.db.snap == nil || err != nil {
|
if s.db.snap == nil || err != nil {
|
||||||
if metrics.EnabledExpensive {
|
if metrics.EnabledExpensive {
|
||||||
defer func(start time.Time) { s.db.StorageReads += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.db.StorageReads += time.Since(start) }(time.Now())
|
||||||
}
|
}
|
||||||
if enc, err = s.getTrie(db).TryGet(key[:]); err != nil {
|
if enc, err = s.getTrie(db).TryGet(key.Bytes()); err != nil {
|
||||||
s.setError(err)
|
s.setError(err)
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
|
|||||||
defer func(start time.Time) { s.SnapshotAccountReads += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.SnapshotAccountReads += time.Since(start) }(time.Now())
|
||||||
}
|
}
|
||||||
var acc *snapshot.Account
|
var acc *snapshot.Account
|
||||||
if acc, err = s.snap.Account(crypto.Keccak256Hash(addr[:])); err == nil {
|
if acc, err = s.snap.Account(crypto.Keccak256Hash(addr.Bytes())); err == nil {
|
||||||
if acc == nil {
|
if acc == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -532,9 +532,9 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
|
|||||||
if metrics.EnabledExpensive {
|
if metrics.EnabledExpensive {
|
||||||
defer func(start time.Time) { s.AccountReads += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.AccountReads += time.Since(start) }(time.Now())
|
||||||
}
|
}
|
||||||
enc, err := s.trie.TryGet(addr[:])
|
enc, err := s.trie.TryGet(addr.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.setError(fmt.Errorf("getDeleteStateObject (%x) error: %v", addr[:], err))
|
s.setError(fmt.Errorf("getDeleteStateObject (%x) error: %v", addr.Bytes(), err))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(enc) == 0 {
|
if len(enc) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user