Repository navigation
fix(storage): register the block_index table on the redb backend - #24
Merged
Merged
Conversation
ChainState::new opens block_index via BlockIndex::new, but redb only opens tables listed in get_table_def, so Storage::with_backend(.., Redb) failed with "Unknown table name: block_index". Adds tests/storage_redb_tests.rs: redb Storage opens and reopens, and every KNOWN_TREE_NAMES entry opens on redb except the IBD engine ckpt trees and rocksdb-test-only names. Both tests fail without the fix.
Bring #24 up to date with main while keeping block_index redb registration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Storage::with_backend(.., DatabaseBackend::Redb)fails onmain:ChainState::new(src/storage/chainstate.rs:91) opens theblock_indextree throughBlockIndex::new, but the redb backend only opens tables listed inredb_impl::get_table_def, andblock_indexisn't there. So any redb-backedStoragefails to open. This is the same kind of gap asblock_undo, fixed in de5dac8.It surfaced in #23's new
cargo test --features rocksdbCI step astest_storage_backend_interchangeability(tests/storage_rocksdb_integration_tests.rs:150).tests/storage_tidesdb_integration_tests.rs:122has the same pattern under--features tidesdb.Change
src/storage/database/mod.rs(redb only): addsBLOCK_INDEX_TABLEand registers it in both table-creation paths (new database and existing database) and inget_table_def. Opening an existing redb file creates the table if it's missing, so there's no migration. Other backends and consensus code are untouched.Other missing tables
I compared
KNOWN_TREE_NAMESagainst redb's table list. Besidesblock_index, redb is also missing:ibd_utxos_ckpt_a/ibd_utxos_ckpt_b: these are the IBD engine's ping-pong checkpoint trees. On redb today, a checkpoint export logs "failed to open" and continues, and resume falls back. Registering them would turn on engine checkpoints/resume for redb nodes, which changes IBD behaviour, so it's left for a separate change.test_tree,tree1,tree2,dynamic_tree_*: column families used only by the RocksDB tests.Tests
New
tests/storage_redb_tests.rs(#[cfg(feature = "redb")], andredbis a default feature):storage_opens_and_reopens_on_redb: opensStorageon redb, stores a block, then reopens the same datadir, which takes the existing-database path.redb_opens_every_known_tree: everyKNOWN_TREE_NAMESentry opens on redb, except the explicit list above. A tree added later without a redb table fails this test.Without the fix, both tests fail:
redb storage must open: Unknown table name: block_indexandredb has no table for: ["block_index"]. With the fix, both pass.