Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ func (db *Database) loadJournal(diskRoot common.Hash) (layer, error) {
// Load the disk layer from the journal
base, err := db.loadDiskLayer(r)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to load disk layer from journal: %w", err)
}
// Load all the diff layers from the journal
head, err := db.loadDiffLayer(base, r)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to load diff layers from journal: %w", err)
}
log.Debug("Loaded layer journal", "diskroot", diskRoot, "diffhead", head.rootHash())
return head, nil
Expand Down Expand Up @@ -202,12 +202,12 @@ func (db *Database) loadDiskLayer(r *rlp.Stream) (layer, error) {
// Resolve nodes cached in aggregated buffer
var nodes nodeSet
if err := nodes.decode(r); err != nil {
return nil, err
return nil, fmt.Errorf("failed to decode nodes from journal: %w", err)
}
// Resolve flat state sets in aggregated buffer
var states stateSet
if err := states.decode(r); err != nil {
return nil, err
return nil, fmt.Errorf("failed to decode states from journal: %w", err)
}
return newDiskLayer(root, id, db, nil, nil, newBuffer(db.config.WriteBufferSize, &nodes, &states, id-stored), nil), nil
}
Expand All @@ -231,12 +231,12 @@ func (db *Database) loadDiffLayer(parent layer, r *rlp.Stream) (layer, error) {
// Read in-memory trie nodes from journal
var nodes nodeSetWithOrigin
if err := nodes.decode(r); err != nil {
return nil, err
return nil, fmt.Errorf("failed to decode nodes with origin from journal: %w", err)
}
// Read flat states set (with original value attached) from journal
var stateSet StateSetWithOrigin
if err := stateSet.decode(r); err != nil {
return nil, err
return nil, fmt.Errorf("failed to decode state set with origin from journal: %w", err)
}
return db.loadDiffLayer(newDiffLayer(parent, root, parent.stateID()+1, block, &nodes, &stateSet), r)
}
Expand Down
14 changes: 7 additions & 7 deletions triedb/pathdb/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type reader struct {
func (r *reader) Node(owner common.Hash, path []byte, hash common.Hash) ([]byte, error) {
blob, got, loc, err := r.layer.node(owner, path, 0)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to retrieve node for owner %x, path %x: %w", owner, path, err)
}
// Error out if the local one is inconsistent with the target.
if !r.noHashCheck && got != hash {
Expand Down Expand Up @@ -102,7 +102,7 @@ func (r *reader) Node(owner common.Hash, path []byte, hash common.Hash) ([]byte,
func (r *reader) AccountRLP(hash common.Hash) ([]byte, error) {
l, err := r.db.tree.lookupAccount(hash, r.state)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to lookup account %x: %w", hash, err)
}
// If the located layer is stale, fall back to the slow path to retrieve
// the account data. This is an edge case where the located layer is the
Expand All @@ -129,7 +129,7 @@ func (r *reader) AccountRLP(hash common.Hash) ([]byte, error) {
func (r *reader) Account(hash common.Hash) (*types.SlimAccount, error) {
blob, err := r.AccountRLP(hash)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to retrieve account RLP for %x: %w", hash, err)
}
if len(blob) == 0 {
return nil, nil
Expand All @@ -151,7 +151,7 @@ func (r *reader) Account(hash common.Hash) (*types.SlimAccount, error) {
func (r *reader) Storage(accountHash, storageHash common.Hash) ([]byte, error) {
l, err := r.db.tree.lookupStorage(accountHash, storageHash, r.state)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to lookup storage for account %x, storage %x: %w", accountHash, storageHash, err)
}
// If the located layer is stale, fall back to the slow path to retrieve
// the storage data. This is an edge case where the located layer is the
Expand Down Expand Up @@ -263,7 +263,7 @@ func (r *HistoricalStateReader) AccountRLP(address common.Address) ([]byte, erro
hash := crypto.Keccak256Hash(address.Bytes())
latest, err := dl.account(hash, 0)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to retrieve latest account for address %x: %w", address, err)
}
return r.reader.read(newAccountIdentQuery(address, hash), r.id, dl.stateID(), latest)
}
Expand All @@ -276,7 +276,7 @@ func (r *HistoricalStateReader) AccountRLP(address common.Address) ([]byte, erro
func (r *HistoricalStateReader) Account(address common.Address) (*types.SlimAccount, error) {
blob, err := r.AccountRLP(address)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to retrieve account RLP for address %x: %w", address, err)
}
if len(blob) == 0 {
return nil, nil
Expand Down Expand Up @@ -314,7 +314,7 @@ func (r *HistoricalStateReader) Storage(address common.Address, key common.Hash)
keyHash := crypto.Keccak256Hash(key.Bytes())
latest, err := dl.storage(addrHash, keyHash, 0)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to retrieve latest storage for address %x, key %x: %w", address, key, err)
}
return r.reader.read(newStorageIdentQuery(address, addrHash, key, keyHash), r.id, dl.stateID(), latest)
}