From 3d5732b4ea06b85bbe98a443c887f812e72aa958 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Wed, 20 Sep 2023 15:21:14 +0800 Subject: [PATCH] trie: address comments --- trie/sync.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trie/sync.go b/trie/sync.go index bc4470defe..8d3a54ec47 100644 --- a/trie/sync.go +++ b/trie/sync.go @@ -370,8 +370,6 @@ func (s *Sync) Commit(dbw ethdb.Batch) error { owner, inner := ResolvePath([]byte(path)) rawdb.DeleteTrieNode(dbw, owner, inner, common.Hash{} /* unused */, s.scheme) } - deletionGauge.Inc(int64(len(s.membatch.deletes))) - for hash, value := range s.membatch.codes { rawdb.WriteCode(dbw, hash, value) } @@ -452,6 +450,10 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) { // range of this internal path on disk. This would break the // guarantee for state healing. // + // While it's possible for this shortNode to overwrite a previously + // existing full node, the other branches of the fullNode can be + // retained as they remain untouched and complete. + // // This step is only necessary for path mode, as there is no deletion // in hash mode at all. if _, ok := node.Val.(hashNode); ok && s.scheme == rawdb.PathScheme { @@ -464,6 +466,7 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) { // overall performance. FIX IT(rjl493456442) if rawdb.HasTrieNodeInPath(s.database, owner, append(inner, key[:i]...)) { req.deletes = append(req.deletes, key[:i]) + deletionGauge.Inc(1) log.Info("Detected dangling node", "owner", owner, "path", append(inner, key[:i]...)) } }