From d3f0d83cef8337ea5951ef330f2a6197620fc4ae Mon Sep 17 00:00:00 2001 From: VM Date: Thu, 12 Sep 2024 17:11:00 +0800 Subject: [PATCH] test: fix pathdb unit test --- triedb/pathdb/database.go | 1 + triedb/pathdb/journal.go | 4 ++++ triedb/pathdb/nodebufferlist.go | 3 +++ 3 files changed, 8 insertions(+) diff --git a/triedb/pathdb/database.go b/triedb/pathdb/database.go index d2cd0b9975..b56154439f 100644 --- a/triedb/pathdb/database.go +++ b/triedb/pathdb/database.go @@ -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. diff --git a/triedb/pathdb/journal.go b/triedb/pathdb/journal.go index 586e2800e6..67fb5ceab1 100644 --- a/triedb/pathdb/journal.go +++ b/triedb/pathdb/journal.go @@ -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") @@ -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) diff --git a/triedb/pathdb/nodebufferlist.go b/triedb/pathdb/nodebufferlist.go index a35af5271a..056b48f74d 100644 --- a/triedb/pathdb/nodebufferlist.go +++ b/triedb/pathdb/nodebufferlist.go @@ -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,