From 0f4aa89b5931881f7d49f328f3661eaf0d55c4fe Mon Sep 17 00:00:00 2001 From: Chris Li <271678682li@gmail.com> Date: Tue, 21 May 2024 12:07:01 +0800 Subject: [PATCH 1/2] fix: fix inspect database error --- core/rawdb/database.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/rawdb/database.go b/core/rawdb/database.go index a0e3147f2a..bdf6a09327 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -769,7 +769,9 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error { trieIter = db.StateStore().NewIterator(keyPrefix, nil) defer trieIter.Release() } - if db.BlockStore() != db { + + blockStore := db.BlockStore() + if _, ok := blockStore.(*freezerdb); !ok { blockIter = db.BlockStore().NewIterator(keyPrefix, nil) defer blockIter.Release() } From 27ab5a982fe462ffb2ff8646e11f20853d5bb9e4 Mon Sep 17 00:00:00 2001 From: Chris Li <271678682li@gmail.com> Date: Tue, 21 May 2024 14:35:03 +0800 Subject: [PATCH 2/2] fix: fix inspect database error --- core/rawdb/database.go | 11 +++++++++-- core/rawdb/table.go | 4 ++++ ethdb/database.go | 1 + ethdb/remotedb/remotedb.go | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/rawdb/database.go b/core/rawdb/database.go index bdf6a09327..29c70e6961 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -138,6 +138,10 @@ func (frdb *freezerdb) SetBlockStore(block ethdb.Database) { frdb.blockStore = block } +func (frdb *freezerdb) HasSeparateBlockStore() bool { + return frdb.blockStore != nil +} + // Freeze is a helper method used for external testing to trigger and block until // a freeze cycle completes, without having to sleep for a minute to trigger the // automatic background run. @@ -263,6 +267,10 @@ func (db *nofreezedb) SetBlockStore(block ethdb.Database) { db.blockStore = block } +func (db *nofreezedb) HasSeparateBlockStore() bool { + return db.blockStore != nil +} + func (db *nofreezedb) BlockStoreReader() ethdb.Reader { if db.blockStore != nil { return db.blockStore @@ -770,8 +778,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error { defer trieIter.Release() } - blockStore := db.BlockStore() - if _, ok := blockStore.(*freezerdb); !ok { + if db.HasSeparateBlockStore() { blockIter = db.BlockStore().NewIterator(keyPrefix, nil) defer blockIter.Release() } diff --git a/core/rawdb/table.go b/core/rawdb/table.go index 2dab09f869..c4a029bcad 100644 --- a/core/rawdb/table.go +++ b/core/rawdb/table.go @@ -43,6 +43,10 @@ func (t *table) SetBlockStore(block ethdb.Database) { panic("not implement") } +func (t *table) HasSeparateBlockStore() bool { + panic("not implement") +} + // NewTable returns a database object that prefixes all keys with a given string. func NewTable(db ethdb.Database, prefix string) ethdb.Database { return &table{ diff --git a/ethdb/database.go b/ethdb/database.go index daff198e32..e4bfbc95bc 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -183,6 +183,7 @@ type StateStoreReader interface { type BlockStore interface { BlockStore() Database SetBlockStore(block Database) + HasSeparateBlockStore() bool } type BlockStoreReader interface { diff --git a/ethdb/remotedb/remotedb.go b/ethdb/remotedb/remotedb.go index 18890f2227..2ba5807a32 100644 --- a/ethdb/remotedb/remotedb.go +++ b/ethdb/remotedb/remotedb.go @@ -44,6 +44,10 @@ func (db *Database) BlockStore() ethdb.Database { return db } +func (db *Database) HasSeparateBlockStore() bool { + return false +} + func (db *Database) SetBlockStore(block ethdb.Database) { panic("not supported") }