Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triedb/pathdb: fix copyNodeCache for asyncnodebuffer #2824

Merged
merged 1 commit into from
Dec 25, 2024
Merged
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
17 changes: 2 additions & 15 deletions triedb/pathdb/asyncnodebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ func (a *asyncnodebuffer) revertTo(db ethdb.KeyValueReader, nodes map[common.Has
return a.current.revertTo(db, nodes, accounts, storages)
}

// reset cleans up the disk cache.
func (a *asyncnodebuffer) reset() {
a.mux.Lock()
defer a.mux.Unlock()

a.current.reset()
a.background.reset()
}

// empty returns an indicator if nodebuffer contains any state transition inside.
func (a *asyncnodebuffer) empty() bool {
a.mux.RLock()
Expand All @@ -116,10 +107,6 @@ func (a *asyncnodebuffer) empty() bool {
return a.current.empty() && a.background.empty()
}

func (a *asyncnodebuffer) full() bool {
return a.current.full()
}

// flush persists the in-memory dirty trie node into the disk if the configured
// memory threshold is reached. Note, all data must be written atomically.
func (a *asyncnodebuffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, clean *fastcache.Cache, id uint64, force bool) error {
Expand All @@ -142,7 +129,7 @@ func (a *asyncnodebuffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWri
}
}

if !a.full() {
if !a.current.full() {
return nil
}

Expand Down Expand Up @@ -284,7 +271,7 @@ func copyNodeCache(n *nodecache) *nodecache {
if n == nil || n.buffer == nil {
return nil
}
nc := newNodeCache(int(n.limit), n.nodes, n.states, n.layers)
nc := newNodeCache(int(n.limit), nil, nil, n.layers)
nc.immutable = atomic.LoadUint64(&n.immutable)

for acc, subTree := range n.nodes.nodes {
Expand Down
3 changes: 0 additions & 3 deletions triedb/pathdb/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ type trienodebuffer interface {
// memory threshold is reached. Note, all data must be written atomically.
flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, clean *fastcache.Cache, id uint64, force bool) error

// reset cleans up the disk cache.
reset()

// empty returns an indicator if trienodebuffer contains any state transition inside.
empty() bool

Expand Down
Loading