Skip to content

Commit 03c2176

Browse files
authored
trie/triedb/pathdb: improve error log (#28177)
1 parent 4773dcb commit 03c2176

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

trie/triedb/pathdb/difflayer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (dl *diffLayer) node(owner common.Hash, path []byte, hash common.Hash, dept
114114
if n.Hash != hash {
115115
dirtyFalseMeter.Mark(1)
116116
log.Error("Unexpected trie node in diff layer", "owner", owner, "path", path, "expect", hash, "got", n.Hash)
117-
return nil, newUnexpectedNodeError("diff", hash, n.Hash, owner, path)
117+
return nil, newUnexpectedNodeError("diff", hash, n.Hash, owner, path, n.Blob)
118118
}
119119
dirtyHitMeter.Mark(1)
120120
dirtyNodeHitDepthHist.Update(int64(depth))

trie/triedb/pathdb/disklayer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (dl *diskLayer) Node(owner common.Hash, path []byte, hash common.Hash) ([]b
150150
if nHash != hash {
151151
diskFalseMeter.Mark(1)
152152
log.Error("Unexpected trie node in disk", "owner", owner, "path", path, "expect", hash, "got", nHash)
153-
return nil, newUnexpectedNodeError("disk", hash, nHash, owner, path)
153+
return nil, newUnexpectedNodeError("disk", hash, nHash, owner, path, nBlob)
154154
}
155155
if dl.cleans != nil && len(nBlob) > 0 {
156156
dl.cleans.Set(key, nBlob)

trie/triedb/pathdb/errors.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222

2323
"github.com/ethereum/go-ethereum/common"
24+
"github.com/ethereum/go-ethereum/common/hexutil"
2425
)
2526

2627
var (
@@ -46,6 +47,10 @@ var (
4647
errUnexpectedNode = errors.New("unexpected node")
4748
)
4849

49-
func newUnexpectedNodeError(loc string, expHash common.Hash, gotHash common.Hash, owner common.Hash, path []byte) error {
50-
return fmt.Errorf("%w, loc: %s, node: (%x %v), %x!=%x", errUnexpectedNode, loc, owner, path, expHash, gotHash)
50+
func newUnexpectedNodeError(loc string, expHash common.Hash, gotHash common.Hash, owner common.Hash, path []byte, blob []byte) error {
51+
blobHex := "nil"
52+
if len(blob) > 0 {
53+
blobHex = hexutil.Encode(blob)
54+
}
55+
return fmt.Errorf("%w, loc: %s, node: (%x %v), %x!=%x, blob: %s", errUnexpectedNode, loc, owner, path, expHash, gotHash, blobHex)
5156
}

trie/triedb/pathdb/nodebuffer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (b *nodebuffer) node(owner common.Hash, path []byte, hash common.Hash) (*tr
7171
if n.Hash != hash {
7272
dirtyFalseMeter.Mark(1)
7373
log.Error("Unexpected trie node in node buffer", "owner", owner, "path", path, "expect", hash, "got", n.Hash)
74-
return nil, newUnexpectedNodeError("dirty", hash, n.Hash, owner, path)
74+
return nil, newUnexpectedNodeError("dirty", hash, n.Hash, owner, path, n.Blob)
7575
}
7676
return n, nil
7777
}

0 commit comments

Comments
 (0)