triedb/pathdb: store the entire node value for nodes at top levels

This commit is contained in:
Gary Rong 2025-12-18 10:32:42 +08:00
parent f9f67599d2
commit f8049a0e6f

View file

@ -642,6 +642,12 @@ func (s *nodeSetWithOrigin) encodeNodeHistory(root common.Hash) (map[common.Hash
// encodeFullValue determines whether a node should be encoded // encodeFullValue determines whether a node should be encoded
// in full format with a pseudo-random probabilistic algorithm. // in full format with a pseudo-random probabilistic algorithm.
encodeFullValue = func(owner common.Hash, path string) bool { 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 := fnv.New32a()
h.Write(root.Bytes()) h.Write(root.Bytes())
h.Write(owner.Bytes()) h.Write(owner.Bytes())