From f8049a0e6f7147caa208c6dfaa6fa319ff8c470a Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Thu, 18 Dec 2025 10:32:42 +0800 Subject: [PATCH] triedb/pathdb: store the entire node value for nodes at top levels --- triedb/pathdb/nodes.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/triedb/pathdb/nodes.go b/triedb/pathdb/nodes.go index 0603500ad9..4eede439e4 100644 --- a/triedb/pathdb/nodes.go +++ b/triedb/pathdb/nodes.go @@ -642,6 +642,12 @@ func (s *nodeSetWithOrigin) encodeNodeHistory(root common.Hash) (map[common.Hash // encodeFullValue determines whether a node should be encoded // in full format with a pseudo-random probabilistic algorithm. encodeFullValue = func(owner common.Hash, path string) bool { + // For trie nodes at the first two levels of the account trie, it is very + // likely that all children are modified within a single state transition. + // In such cases, do not use diff mode. + if owner == (common.Hash{}) && len(path) < 2 { + return true + } h := fnv.New32a() h.Write(root.Bytes()) h.Write(owner.Bytes())