Skip to content

Commit

Permalink
pathdb: adaptor sync nodebuffer;
Browse files Browse the repository at this point in the history
inspectdb: opt inspect prune ancient scenario;
  • Loading branch information
0xbundler committed Nov 28, 2023
1 parent f028b30 commit f3a490d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ethdb/fullstatedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions trie/triedb/pathdb/asyncnodebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()))
Expand Down
2 changes: 1 addition & 1 deletion trie/triedb/pathdb/nodebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit f3a490d

Please sign in to comment.