core: nil-guard balTransitionStats in reportBALMetrics

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.
This commit is contained in:
CPerezz 2026-04-30 13:42:30 +02:00
parent 6b1ea9a498
commit 6951ad7c50
No known key found for this signature in database
GPG key ID: 62045F34B97177DD

View file

@ -328,11 +328,13 @@ func (s *ExecuteStats) reportBALMetrics() {
accountCommitTimer.Update(s.AccountCommits) // Account commits are complete, we can mark them accountCommitTimer.Update(s.AccountCommits) // Account commits are complete, we can mark them
storageCommitTimer.Update(s.StorageCommits) // Storage commits are complete, we can mark them storageCommitTimer.Update(s.StorageCommits) // Storage commits are complete, we can mark them
stateTriePrefetchTimer.Update(s.balTransitionStats.StatePrefetch) if m := s.balTransitionStats; m != nil {
accountTriesUpdateTimer.Update(s.balTransitionStats.AccountUpdate) stateTriePrefetchTimer.Update(m.StatePrefetch)
stateTrieUpdateTimer.Update(s.balTransitionStats.StateUpdate) accountTriesUpdateTimer.Update(m.AccountUpdate)
stateTrieHashTimer.Update(s.balTransitionStats.StateHash) stateTrieUpdateTimer.Update(m.StateUpdate)
stateRootComputeTimer.Update(s.balTransitionStats.AccountUpdate + s.balTransitionStats.StateUpdate + s.balTransitionStats.StateHash) stateTrieHashTimer.Update(m.StateHash)
stateRootComputeTimer.Update(m.AccountUpdate + m.StateUpdate + m.StateHash)
}
//blockExecutionTimer.Update(s.Execution) // The time spent on EVM processing //blockExecutionTimer.Update(s.Execution) // The time spent on EVM processing
// ^basically impossible to get this metric with parallel execution // ^basically impossible to get this metric with parallel execution