From d5969de5182d250a3a09ae79b0d32a7ff5afd87d Mon Sep 17 00:00:00 2001 From: CPerezz Date: Wed, 15 Apr 2026 22:50:04 +0200 Subject: [PATCH] trie/bintrie: use EmptyRef for zero-hash children in deserialization --- trie/bintrie/store_commit.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/trie/bintrie/store_commit.go b/trie/bintrie/store_commit.go index 516b42191c..8950359b92 100644 --- a/trie/bintrie/store_commit.go +++ b/trie/bintrie/store_commit.go @@ -156,8 +156,13 @@ func (s *NodeStore) deserializeNode(serialized []byte, depth int, hn common.Hash copy(leftHash[:], serialized[NodeTypeBytes:NodeTypeBytes+HashSize]) copy(rightHash[:], serialized[NodeTypeBytes+HashSize:]) - leftRef := s.newHashedRef(leftHash) - rightRef := s.newHashedRef(rightHash) + var leftRef, rightRef NodeRef + if leftHash != (common.Hash{}) { + leftRef = s.newHashedRef(leftHash) + } + if rightHash != (common.Hash{}) { + rightRef = s.newHashedRef(rightHash) + } ref := s.newInternalRef(depth) node := s.getInternal(ref.Index())