From f3a490ddeaa3f731017478254f5bded137c3fc8f Mon Sep 17 00:00:00 2001 From: 0xbundler <124862913+0xbundler@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:49:46 +0800 Subject: [PATCH] pathdb: adaptor sync nodebuffer; inspectdb: opt inspect prune ancient scenario; --- core/rawdb/database.go | 2 +- ethdb/fullstatedb.go | 2 +- trie/trie.go | 2 +- trie/triedb/pathdb/asyncnodebuffer.go | 8 +++++--- trie/triedb/pathdb/nodebuffer.go | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/rawdb/database.go b/core/rawdb/database.go index 11e9580ad1..ded36e2780 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -777,7 +777,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error { // Inspect all registered append-only file store then. ancients, err := inspectFreezers(db) if err != nil { - return err + log.Error("inspectFreezers err", "err", err) } for _, ancient := range ancients { for _, table := range ancient.sizes { diff --git a/ethdb/fullstatedb.go b/ethdb/fullstatedb.go index ee1fc8dc97..90c5727781 100644 --- a/ethdb/fullstatedb.go +++ b/ethdb/fullstatedb.go @@ -86,7 +86,7 @@ func (f *FullStateRPCServer) GetStorageReviveProof(stateRoot common.Hash, accoun } // TODO(0xbundler): add timeout in flags? - ctx, cancelFunc := context.WithTimeout(context.Background(), 300*time.Millisecond) + ctx, cancelFunc := context.WithTimeout(context.Background(), 1000*time.Millisecond) defer cancelFunc() err := f.client.CallContext(ctx, &result, "eth_getStorageReviveProof", stateRoot, account, root, uncachedKeys, uncachedPrefixKeys) if err != nil { diff --git a/trie/trie.go b/trie/trie.go index 455f8c55ec..ac587ca47b 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -1654,7 +1654,7 @@ func (t *Trie) findExpiredSubTree(n node, path []byte, epoch types.StateEpoch, p path := common.CopyBytes(path) st.Schedule(func() { if err := t.findExpiredSubTree(resolve, path, epoch, pruner, st); err != nil { - log.Error("recursePruneExpiredNode err", "addr", t.owner, "path", path, "epoch", epoch, "err", err) + log.Error("findExpiredSubTree err", "addr", t.owner, "path", path, "epoch", epoch, "err", err) } }) return nil diff --git a/trie/triedb/pathdb/asyncnodebuffer.go b/trie/triedb/pathdb/asyncnodebuffer.go index c8c3921177..a21bf7cb6a 100644 --- a/trie/triedb/pathdb/asyncnodebuffer.go +++ b/trie/triedb/pathdb/asyncnodebuffer.go @@ -7,6 +7,8 @@ import ( "sync/atomic" "time" + "github.com/ethereum/go-ethereum/trie/epochmeta" + "github.com/VictoriaMetrics/fastcache" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" @@ -214,9 +216,9 @@ func (nc *nodecache) node(owner common.Hash, path []byte, hash common.Hash) (*tr if !ok { return nil, nil } - if n.Hash != hash { + if !epochmeta.IsEpochMetaPath(path) && n.Hash != hash { dirtyFalseMeter.Mark(1) - log.Error("Unexpected trie node in node buffer", "owner", owner, "path", path, "expect", hash, "got", n.Hash) + log.Debug("Unexpected trie node in node buffer", "owner", owner, "path", path, "expect", hash, "got", n.Hash) return nil, newUnexpectedNodeError("dirty", hash, n.Hash, owner, path, n.Blob) } return n, nil @@ -412,7 +414,7 @@ func (nc *nodecache) revert(db ethdb.KeyValueReader, nodes map[common.Hash]map[s _, nhash = rawdb.ReadStorageTrieNode(db, owner, []byte(path)) } // Ignore the clean node in the case described above. - if nhash == n.Hash { + if epochmeta.IsEpochMetaPath([]byte(path)) || nhash == n.Hash { continue } panic(fmt.Sprintf("non-existent node (%x %v) blob: %v", owner, path, crypto.Keccak256Hash(n.Blob).Hex())) diff --git a/trie/triedb/pathdb/nodebuffer.go b/trie/triedb/pathdb/nodebuffer.go index cc908c9676..f062dcc50e 100644 --- a/trie/triedb/pathdb/nodebuffer.go +++ b/trie/triedb/pathdb/nodebuffer.go @@ -164,7 +164,7 @@ func (b *nodebuffer) revert(db ethdb.KeyValueReader, nodes map[common.Hash]map[s _, nhash = rawdb.ReadStorageTrieNode(db, owner, []byte(path)) } // Ignore the clean node in the case described above. - if nhash == n.Hash { + if epochmeta.IsEpochMetaPath([]byte(path)) || nhash == n.Hash { continue } panic(fmt.Sprintf("non-existent node (%x %v) blob: %v", owner, path, crypto.Keccak256Hash(n.Blob).Hex()))