From 6951ad7c50bfedaefc10d0a060ef13e54e301dfe Mon Sep 17 00:00:00 2001 From: CPerezz Date: Thu, 30 Apr 2026 13:42:30 +0200 Subject: [PATCH] core: nil-guard balTransitionStats in reportBALMetrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors the nil-check already used in buildSlowBlockLog. The previous unguarded access was safe today only because parallel_state_processor short-circuits on error before the metrics path is reached, but the API contract was fragile — a future caller could reach reportBALMetrics without an established balTransitionStats and panic. --- core/blockchain_stats.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/blockchain_stats.go b/core/blockchain_stats.go index ee1bbee3cc..6332f8e22f 100644 --- a/core/blockchain_stats.go +++ b/core/blockchain_stats.go @@ -328,11 +328,13 @@ func (s *ExecuteStats) reportBALMetrics() { accountCommitTimer.Update(s.AccountCommits) // Account commits are complete, we can mark them storageCommitTimer.Update(s.StorageCommits) // Storage commits are complete, we can mark them - stateTriePrefetchTimer.Update(s.balTransitionStats.StatePrefetch) - accountTriesUpdateTimer.Update(s.balTransitionStats.AccountUpdate) - stateTrieUpdateTimer.Update(s.balTransitionStats.StateUpdate) - stateTrieHashTimer.Update(s.balTransitionStats.StateHash) - stateRootComputeTimer.Update(s.balTransitionStats.AccountUpdate + s.balTransitionStats.StateUpdate + s.balTransitionStats.StateHash) + if m := s.balTransitionStats; m != nil { + stateTriePrefetchTimer.Update(m.StatePrefetch) + accountTriesUpdateTimer.Update(m.AccountUpdate) + stateTrieUpdateTimer.Update(m.StateUpdate) + stateTrieHashTimer.Update(m.StateHash) + stateRootComputeTimer.Update(m.AccountUpdate + m.StateUpdate + m.StateHash) + } //blockExecutionTimer.Update(s.Execution) // The time spent on EVM processing // ^basically impossible to get this metric with parallel execution