From 82fa9a4268ff69674d7cce629b3a1e1bd2862a33 Mon Sep 17 00:00:00 2001 From: yyhrnk Date: Wed, 10 Dec 2025 14:45:54 +0200 Subject: [PATCH] core/stateless: cap witness depth metrics buckets --- core/stateless/stats.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/stateless/stats.go b/core/stateless/stats.go index 94f5587f99..c6be1f6520 100644 --- a/core/stateless/stats.go +++ b/core/stateless/stats.go @@ -62,10 +62,14 @@ func (s *WitnessStats) Add(nodes map[string][]byte, owner common.Hash) { // If current path is a prefix of the next path, it's not a leaf. // The last path is always a leaf. if i == len(paths)-1 || !strings.HasPrefix(paths[i+1], paths[i]) { + depth := len(path) + if depth >= len(s.accountTrieLeaves) { + depth = len(s.accountTrieLeaves) - 1 + } if owner == (common.Hash{}) { - s.accountTrieLeaves[len(path)] += 1 + s.accountTrieLeaves[depth] += 1 } else { - s.storageTrieLeaves[len(path)] += 1 + s.storageTrieLeaves[depth] += 1 } } }