Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
47a7ee2
upgrade redb file format to v3
owanikin Aug 21, 2025
9f8a43f
WIP: migration_schema_v29 changes
owanikin Aug 28, 2025
04728b5
WIP: logging if migration happened successfully or not
owanikin Aug 28, 2025
e6806cd
WIP: migration_schema_v29 changes
owanikin Aug 29, 2025
4fe948d
fix formatting and linting issues
owanikin Aug 29, 2025
0a94f45
some hacking
eserilev Sep 3, 2025
86fa5bf
WIP: some hacking upgrade-reddb-v3
owanikin Sep 4, 2025
2c82eb3
Add ability to upgrade and check if redb
eserilev Sep 4, 2025
30c4666
cargo
eserilev Sep 4, 2025
7a6a492
Merge conflicts
eserilev Sep 4, 2025
798b6bf
upgradedredb v3
owanikin Sep 8, 2025
8beedc3
upgrade-redb-v3 cleanup
owanikin Sep 9, 2025
04c4641
fix ci issues
owanikin Sep 9, 2025
9f7fd90
Merge branch 'unstable' into upgrade-redb-v3
eserilev Sep 15, 2025
37ca640
Merge branch 'unstable' into upgrade-redb-v3
eserilev Oct 14, 2025
03583dd
Merge branch 'unstable' into upgrade-redb-v3
eserilev Nov 7, 2025
f268bac
fix: markdown lint table format (advanced_database)
owanikin Nov 19, 2025
63b7515
fix: markdown lint table format (api_vc_endpoints)
owanikin Nov 19, 2025
2062243
fix: markdown lint table format (archived_merge_migration)
owanikin Nov 19, 2025
86a7618
fix: markdownlint table formatting
owanikin Nov 19, 2025
89ff98c
Merge branch 'unstable' into upgrade-redb-v3
owanikin Nov 20, 2025
b249a79
Resolve merge conflicts
eserilev Dec 3, 2025
8a3eab9
Revert
eserilev Dec 3, 2025
fa2cbe4
Revert
eserilev Dec 3, 2025
5dab081
2.6.3
eserilev Dec 3, 2025
f3dee1b
2.6.3
eserilev Dec 3, 2025
43756dd
Merge branch 'unstable' into upgrade-redb-v3
eserilev Feb 10, 2026
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
9 changes: 9 additions & 0 deletions beacon_node/beacon_chain/src/schema_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod migration_schema_v25;
mod migration_schema_v26;
mod migration_schema_v27;
mod migration_schema_v28;
mod migration_schema_v29;

use crate::beacon_chain::BeaconChainTypes;
use std::sync::Arc;
Expand Down Expand Up @@ -88,6 +89,14 @@ pub fn migrate_schema<T: BeaconChainTypes>(
let ops = migration_schema_v28::downgrade_from_v28::<T>(db.clone())?;
db.store_schema_version_atomically(to, ops)
}
(SchemaVersion(28), SchemaVersion(29)) => {
let ops = migration_schema_v29::upgrade_to_v29::<T>(db.clone())?;
db.store_schema_version_atomically(to, ops)
}
(SchemaVersion(29), SchemaVersion(28)) => {
let ops = migration_schema_v29::downgrade_from_v29::<T>(db.clone())?;
db.store_schema_version_atomically(to, ops)
}
// Anything else is an error.
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {
target_version: to,
Expand Down
21 changes: 21 additions & 0 deletions beacon_node/beacon_chain/src/schema_change/migration_schema_v29.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use crate::BeaconChainTypes;
use std::sync::Arc;
use store::{Error, HotColdDB, KeyValueStoreOp};

pub fn upgrade_to_v29<T: BeaconChainTypes>(
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
) -> Result<Vec<KeyValueStoreOp>, Error> {
db.upgrade()?;
Ok(vec![])
}

pub fn downgrade_from_v29<T: BeaconChainTypes>(
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
) -> Result<Vec<KeyValueStoreOp>, Error> {
if db.is_redb() {
return Err(Error::MigrationError(
"Downgrade from v29 not supported for Redb".into(),
));
}
Ok(vec![])
}
2 changes: 1 addition & 1 deletion beacon_node/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ lru = { workspace = true }
metrics = { workspace = true }
milhouse = { workspace = true }
parking_lot = { workspace = true }
redb = { version = "2.1.3", optional = true }
redb = { version = "2.6.3", optional = true }
safe_arith = { workspace = true }
serde = { workspace = true }
smallvec = { workspace = true }
Expand Down
26 changes: 26 additions & 0 deletions beacon_node/store/src/database/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{ColumnIter, ColumnKeyIter, DBColumn, Error, ItemStore, Key, KeyValue
use crate::{KeyValueStoreOp, StoreConfig, config::DatabaseBackend};
use std::collections::HashSet;
use std::path::Path;
use tracing::info;
use types::EthSpec;

pub enum BeaconNodeBackend<E: EthSpec> {
Expand Down Expand Up @@ -169,6 +170,31 @@ impl<E: EthSpec> KeyValueStore<E> for BeaconNodeBackend<E> {
}
}

fn upgrade(&self) -> Result<(), Error> {
match self {
#[cfg(feature = "leveldb")]
BeaconNodeBackend::LevelDb(_) => {
info!("LevelDB, no upgrade required");
Ok(())
}
#[cfg(feature = "redb")]
BeaconNodeBackend::Redb(redb) => {
info!("Updating Redb file format to v3");
redb.upgrade()?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note thta upgrade returns true is successful and false if its already in the v3 format

https://docs.rs/redb/2.6.2/redb/struct.Database.html#method.upgrade

In all other failure cases it will raise an error

Ok(())
}
}
}

fn is_redb(&self) -> bool {
match self {
#[cfg(feature = "leveldb")]
BeaconNodeBackend::LevelDb(_level_db) => false,
#[cfg(feature = "redb")]
BeaconNodeBackend::Redb(_redb) => true,
}
}

fn delete_if(
&self,
column: DBColumn,
Expand Down
5 changes: 5 additions & 0 deletions beacon_node/store/src/database/redb_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ impl<E: EthSpec> Redb<E> {
})
}

pub fn upgrade(&self) -> Result<(), Error> {
self.db.write().upgrade()?;
Ok(())
}

fn create_table(db: &redb::Database, table_name: &str) -> Result<(), Error> {
let table_definition: TableDefinition<'_, &[u8], &[u8]> = TableDefinition::new(table_name);
let tx = db.begin_write()?;
Expand Down
9 changes: 9 additions & 0 deletions beacon_node/store/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ pub enum Error {
LevelDbError(LevelDBError),
#[cfg(feature = "redb")]
RedbError(Box<redb::Error>),
#[cfg(feature = "redb")]
RedbUpgrade(redb::UpgradeError),
CacheBuildError(EpochCacheError),
RandaoMixOutOfBounds,
MilhouseError(milhouse::Error),
Expand Down Expand Up @@ -233,6 +235,13 @@ impl From<redb::CompactionError> for Error {
}
}

#[cfg(feature = "redb")]
impl From<redb::UpgradeError> for Error {
fn from(e: redb::UpgradeError) -> Self {
Error::RedbUpgrade(e)
}
}

impl From<EpochCacheError> for Error {
fn from(e: EpochCacheError) -> Error {
Error::CacheBuildError(e)
Expand Down
10 changes: 10 additions & 0 deletions beacon_node/store/src/hot_cold_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,16 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
}
}

pub fn upgrade(&self) -> Result<(), Error> {
self.hot_db.upgrade()?;
self.cold_db.upgrade()?;
Ok(())
}

pub fn is_redb(&self) -> bool {
self.hot_db.is_redb()
}

pub fn update_finalized_state(
&self,
state_root: Hash256,
Expand Down
4 changes: 4 additions & 0 deletions beacon_node/store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ pub trait KeyValueStore<E: EthSpec>: Sync + Send + Sized + 'static {

fn delete_batch(&self, column: DBColumn, ops: HashSet<&[u8]>) -> Result<(), Error>;

// TODO(migration-v29) can delete these functions once db migration v29 is deprecated
fn upgrade(&self) -> Result<(), Error>;
fn is_redb(&self) -> bool;

fn delete_if(
&self,
column: DBColumn,
Expand Down
8 changes: 8 additions & 0 deletions beacon_node/store/src/memory_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ impl<E: EthSpec> KeyValueStore<E> for MemoryStore<E> {
});
Ok(())
}

fn upgrade(&self) -> Result<(), Error> {
Ok(())
}

fn is_redb(&self) -> bool {
false
}
}

impl<E: EthSpec> ItemStore<E> for MemoryStore<E> {}
2 changes: 1 addition & 1 deletion beacon_node/store/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ssz::{Decode, Encode};
use ssz_derive::{Decode, Encode};
use types::{Hash256, Slot};

pub const CURRENT_SCHEMA_VERSION: SchemaVersion = SchemaVersion(28);
pub const CURRENT_SCHEMA_VERSION: SchemaVersion = SchemaVersion(29);

// All the keys that get stored under the `BeaconMeta` column.
//
Expand Down