From baf1994f8bd66e476fd7e2f4d0f86f26db016e7b Mon Sep 17 00:00:00 2001 From: CPerezz Date: Mon, 16 Mar 2026 23:56:25 +0100 Subject: [PATCH] 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. --- core/state/state_object.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/state/state_object.go b/core/state/state_object.go index dd30bb64a5..b743c9b979 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -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: