Skip to content

Commit

Permalink
test: fix pathdb unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Sep 12, 2024
1 parent 61faf4d commit d3f0d83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions triedb/pathdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func New(diskdb ethdb.Database, config *Config) *Database {
}
db.freezer = freezer
}
log.Info("New pathdb", "useBase", db.useBase, "fastRecovery", db.fastRecovery)

// Construct the layer tree by resolving the in-disk singleton state
// and in-memory layer journal.
Expand Down
4 changes: 4 additions & 0 deletions triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,11 @@ func (db *Database) loadLayers() layer {
stateID = rawdb.ReadPersistentStateID(db.diskdb)
)

log.Info("before recover", "buffer type", db.config.TrieNodeBufferType, "fastRecovery", db.fastRecovery,
"use base", db.useBase, "err", err)
if (errors.Is(err, errMissJournal) || errors.Is(err, errUnmatchedJournal)) && db.fastRecovery &&
db.config.TrieNodeBufferType == NodeBufferList && !db.useBase {
log.Info("in recover")
start := time.Now()
if db.freezer == nil {
log.Crit("Use unopened freezer db to recover node buffer list")
Expand All @@ -287,6 +290,7 @@ func (db *Database) loadLayers() layer {
}
}
if nb == nil || err != nil {
log.Info("Maybe failed to recover", "err", err)
// Return single layer with persistent state.
nb, err = NewTrieNodeBuffer(db.diskdb, db.config.TrieNodeBufferType, db.bufferSize, nil, 0,
db.config.ProposeBlockInterval, db.config.NotifyKeep, nil, false, db.useBase)
Expand Down
3 changes: 3 additions & 0 deletions triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,16 @@ func newNodeBufferList(
nf *nodebufferlist
err error
)
log.Info("newNodeBufferList 111111", "useBase", useBase, "fastRecovery", fastRecovery)
if !useBase && fastRecovery {
log.Info("Do recover")
nf, err = recoverNodeBufferList(db, freezer, base, limit, wpBlocks, rsevMdNum, dlInMd)
if err != nil {
log.Error("Failed to recover node buffer list", "error", err)
return nil, err
}
} else {
log.Info("Not recover")
ele := newMultiDifflayer(limit, 0, common.Hash{}, make(map[common.Hash]map[string]*trienode.Node), 0)
nf = &nodebufferlist{
db: db,
Expand Down

0 comments on commit d3f0d83

Please sign in to comment.