From cdfad0d343cc54a3bbd6b11dc90900f3d5b763f0 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Thu, 30 Apr 2026 13:43:37 +0200 Subject: [PATCH] core/state: comment len(code) > 0 gate, drop dead OriginStorageLoadTime - Add a comment at the code-mutation gate explaining the deliberate len(code) > 0 (vs code != nil) match against non-BAL semantics; in devnet-3 BAL access lists, an empty []byte is non-nil but encodes "no code install". - Remove BALStateTransitionMetrics.OriginStorageLoadTime: declared but never assigned anywhere in the tree. The actual state-transition read time is captured by AccountReadTime/StorageReadTime added in the prior commit. --- core/state/bal_state_transition.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/state/bal_state_transition.go b/core/state/bal_state_transition.go index 6699fb6c5a..1924cc386c 100644 --- a/core/state/bal_state_transition.go +++ b/core/state/bal_state_transition.go @@ -86,11 +86,10 @@ func (s *BALStateTransition) WriteCounts() StateCounts { type BALStateTransitionMetrics struct { // trie hashing metrics - AccountUpdate time.Duration - StatePrefetch time.Duration - StateUpdate time.Duration - StateHash time.Duration - OriginStorageLoadTime time.Duration + AccountUpdate time.Duration + StatePrefetch time.Duration + StateUpdate time.Duration + StateHash time.Duration // commit metrics AccountCommits time.Duration @@ -522,6 +521,11 @@ func (s *BALStateTransition) IntermediateRoot(_ bool) common.Hash { } else { acct, code := s.updateAccount(mutatedAddr) + // Use len(code) > 0 (not code != nil) to match the non-BAL semantic + // at statedb.go (obj.dirtyCode && len(obj.code) > 0). In devnet-3 + // BAL access lists, an empty []byte is non-nil but encodes "no code + // install"; treating it as a code mutation would over-count and + // call UpdateContractCode with an empty payload. if len(code) > 0 { codeHash := crypto.Keccak256Hash(code) acct.CodeHash = codeHash.Bytes()