Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit 02b6593

Browse files
rjl493456442Francesco4203
authored andcommitted
triedb/pathdb: fix panic in recoverable (#29107)
* triedb/pathdb: fix panic in recoverable * triedb/pathdb: add todo * triedb/pathdb: rename * triedb/pathdb: rename
1 parent 36c4706 commit 02b6593

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

core/rawdb/schema_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestResolveAccountTrieNodeKey(t *testing.T) {
9999
},
100100
{
101101
name: "storage prefixed",
102-
inputKey: append(trieNodeStoragePrefix, bytes4...),
102+
inputKey: append(TrieNodeStoragePrefix, bytes4...),
103103
expectedCheck: false,
104104
expectedKey: nil,
105105
},
@@ -175,7 +175,7 @@ func TestResolveStorageTrieNode(t *testing.T) {
175175
},
176176
{
177177
name: "storage prefixed hash 20 length 4",
178-
inputKey: append(append(trieNodeStoragePrefix, bytes20...), bytes4...),
178+
inputKey: append(append(TrieNodeStoragePrefix, bytes20...), bytes4...),
179179
expectedCheck: false,
180180
expectedHash: common.Hash{},
181181
expectedKey: nil,

trie/triedb/pathdb/database.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,18 +397,23 @@ func (db *Database) Recoverable(root common.Hash) bool {
397397
if *id >= dl.stateID() {
398398
return false
399399
}
400-
400+
// This is a temporary workaround for the unavailability of the freezer in
401+
// dev mode. As a consequence, the Pathdb loses the ability for deep reorg
402+
// in certain cases.
403+
// TODO(rjl493456442): Implement the in-memory ancient store.
404+
if db.freezer == nil {
405+
return false
406+
}
401407
// Ensure the requested state is a canonical state and all state
402408
// histories in range [id+1, disklayer.ID] are present and complete.
403-
parent := root
404409
return checkHistories(db.freezer, *id+1, dl.stateID()-*id, func(m *meta) error {
405-
if m.parent != parent {
410+
if m.parent != root {
406411
return errors.New("unexpected state history")
407412
}
408413
if len(m.incomplete) > 0 {
409414
return errors.New("incomplete state history")
410415
}
411-
parent = m.root
416+
root = m.root
412417
return nil
413418
}) == nil
414419
}

0 commit comments

Comments
 (0)