Files
lighthouse/beacon_node/beacon_chain/src/schema_change.rs
Michael Sproul bd34bb1430 Remove schema migrations for v28 and earlier (#9031)
With LH v8.1.3 supporting Fulu-on-Gnosis, we no longer need these DB migrations. All Lighthouse nodes running in prod will soon be updated to LH v8.0.0+ and schema v28+.

This PR helps with Gloas fork choice changes, by allowing us to avoid updating old schema migrations when adding V29 for Gloas:

- https://github.com/sigp/lighthouse/pull/9025


  


Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
2026-03-26 02:10:34 +00:00

28 lines
1.1 KiB
Rust

//! Utilities for managing database schema changes.
use crate::beacon_chain::BeaconChainTypes;
use std::sync::Arc;
use store::Error as StoreError;
use store::hot_cold_store::{HotColdDB, HotColdDBError};
use store::metadata::{CURRENT_SCHEMA_VERSION, SchemaVersion};
/// Migrate the database from one schema version to another, applying all requisite mutations.
///
/// All migrations for schema versions up to and including v28 have been removed. Nodes on live
/// networks are already running v28, so only the current version check remains.
pub fn migrate_schema<T: BeaconChainTypes>(
_db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
from: SchemaVersion,
to: SchemaVersion,
) -> Result<(), StoreError> {
match (from, to) {
// Migrating from the current schema version to itself is always OK, a no-op.
(_, _) if from == to && to == CURRENT_SCHEMA_VERSION => Ok(()),
// Anything else is an error.
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {
target_version: to,
current_version: from,
}
.into()),
}
}