trie: better error reporting (#25645)

This commit is contained in:
Martin Holst Swende 2022-09-01 08:41:10 +02:00 committed by GitHub
parent 95a2c221d4
commit d79bd2f0f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 11 deletions

View File

@ -63,7 +63,7 @@ func (t *Trie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) e
var err error var err error
tn, err = t.resolveHash(n, prefix) tn, err = t.resolveHash(n, prefix)
if err != nil { if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in Trie.Prove", "err", err)
return err return err
} }
default: default:

View File

@ -17,8 +17,6 @@
package trie package trie
import ( import (
"fmt"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -74,7 +72,7 @@ func NewStateTrie(owner common.Hash, root common.Hash, db *Database) (*StateTrie
func (t *StateTrie) Get(key []byte) []byte { func (t *StateTrie) Get(key []byte) []byte {
res, err := t.TryGet(key) res, err := t.TryGet(key)
if err != nil { if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in StateTrie.Get", "err", err)
} }
return res return res
} }
@ -129,7 +127,7 @@ func (t *StateTrie) TryGetNode(path []byte) ([]byte, int, error) {
// stored in the trie. // stored in the trie.
func (t *StateTrie) Update(key, value []byte) { func (t *StateTrie) Update(key, value []byte) {
if err := t.TryUpdate(key, value); err != nil { if err := t.TryUpdate(key, value); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in StateTrie.Update", "err", err)
} }
} }
@ -169,7 +167,7 @@ func (t *StateTrie) TryUpdateAccount(key []byte, acc *types.StateAccount) error
// Delete removes any existing value for key from the trie. // Delete removes any existing value for key from the trie.
func (t *StateTrie) Delete(key []byte) { func (t *StateTrie) Delete(key []byte) {
if err := t.TryDelete(key); err != nil { if err := t.TryDelete(key); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in StateTrie.Delete", "err", err)
} }
} }

View File

@ -21,7 +21,6 @@ import (
"bytes" "bytes"
"encoding/gob" "encoding/gob"
"errors" "errors"
"fmt"
"io" "io"
"sync" "sync"
@ -207,7 +206,7 @@ func (st *StackTrie) TryUpdate(key, value []byte) error {
func (st *StackTrie) Update(key, value []byte) { func (st *StackTrie) Update(key, value []byte) {
if err := st.TryUpdate(key, value); err != nil { if err := st.TryUpdate(key, value); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in StackTrie.Update", "err", err)
} }
} }

View File

@ -132,7 +132,7 @@ func (t *Trie) NodeIterator(start []byte) NodeIterator {
func (t *Trie) Get(key []byte) []byte { func (t *Trie) Get(key []byte) []byte {
res, err := t.TryGet(key) res, err := t.TryGet(key)
if err != nil { if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in Trie.Get", "err", err)
} }
return res return res
} }
@ -269,7 +269,7 @@ func (t *Trie) tryGetNode(origNode node, path []byte, pos int) (item []byte, new
// stored in the trie. // stored in the trie.
func (t *Trie) Update(key, value []byte) { func (t *Trie) Update(key, value []byte) {
if err := t.TryUpdate(key, value); err != nil { if err := t.TryUpdate(key, value); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in Trie.Update", "err", err)
} }
} }
@ -388,7 +388,7 @@ func (t *Trie) insert(n node, prefix, key []byte, value node) (bool, node, error
// Delete removes any existing value for key from the trie. // Delete removes any existing value for key from the trie.
func (t *Trie) Delete(key []byte) { func (t *Trie) Delete(key []byte) {
if err := t.TryDelete(key); err != nil { if err := t.TryDelete(key); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err)) log.Error("Unhandled trie error in Trie.Delete", "err", err)
} }
} }