mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
core/state: short-circuit GetCommittedState for nil origin accounts
When the account has never been persisted (origin is nil) and was not destructed in the current block, all storage slots are implicitly empty. Return early and cache the negative result to avoid unnecessary trie lookups for newly created contracts.
This commit is contained in:
parent
98b13f342f
commit
baf1994f8b
1 changed files with 9 additions and 0 deletions
|
|
@ -188,6 +188,15 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
|
|||
if value, cached := s.originStorage[key]; cached {
|
||||
return value
|
||||
}
|
||||
// If the account has no on-disk origin and was not destructed in this
|
||||
// block (which requires the reader call for the access list), all
|
||||
// storage slots are empty.
|
||||
if s.origin == nil {
|
||||
if _, destructed := s.db.stateObjectsDestruct[s.address]; !destructed {
|
||||
s.originStorage[key] = common.Hash{}
|
||||
return common.Hash{}
|
||||
}
|
||||
}
|
||||
// If the object was destructed in *this* block (and potentially resurrected),
|
||||
// the storage has been cleared out, and we should *not* consult the previous
|
||||
// database about any storage values. The only possible alternatives are:
|
||||
|
|
|
|||
Loading…
Reference in a new issue