eth: fix trie DB reference dereferenced in traceChain, close XFN-85 #1731

This commit is contained in:
Daniel Liu 2025-11-20 15:40:52 +08:00 committed by benjamin202410
parent e3c4d4923c
commit 26fb93513d

View file

@ -356,12 +356,16 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl
break
}
// Reference the trie twice, once for us, once for the trancer
database.TrieDB().Reference(root, common.Hash{})
if number >= origin {
if number < end.NumberU64() { // Skip the last iteration
database.TrieDB().Reference(root, common.Hash{})
if number >= origin {
database.TrieDB().Reference(root, common.Hash{})
}
}
// Dereference all past tries we ourselves are done working with
database.TrieDB().Dereference(proot)
if proot != (common.Hash{}) { // Skip the first iteration
database.TrieDB().Dereference(proot)
}
proot = root
}
}()