Skip to content

Commit 68e076d

Browse files
authored
Remove legacy database migrations (#4919)
* Remove legacy db migrations * Fix tests * Remove migrations to/from v15 * Remove v16 migrations
1 parent d04e361 commit 68e076d

File tree

7 files changed

+5
-707
lines changed

7 files changed

+5
-707
lines changed

beacon_node/beacon_chain/src/schema_change.rs

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
//! Utilities for managing database schema changes.
2-
mod migration_schema_v12;
3-
mod migration_schema_v13;
4-
mod migration_schema_v14;
5-
mod migration_schema_v15;
6-
mod migration_schema_v16;
72
mod migration_schema_v17;
83
mod migration_schema_v18;
94

10-
use crate::beacon_chain::{BeaconChainTypes, ETH1_CACHE_DB_KEY};
11-
use crate::eth1_chain::SszEth1;
5+
use crate::beacon_chain::BeaconChainTypes;
126
use crate::types::ChainSpec;
13-
use slog::{warn, Logger};
7+
use slog::Logger;
148
use std::sync::Arc;
159
use store::hot_cold_store::{HotColdDB, HotColdDBError};
1610
use store::metadata::{SchemaVersion, CURRENT_SCHEMA_VERSION};
17-
use store::{Error as StoreError, StoreItem};
11+
use store::Error as StoreError;
1812

1913
/// Migrate the database from one schema version to another, applying all requisite mutations.
2014
#[allow(clippy::only_used_in_recursion)] // spec is not used but likely to be used in future
@@ -57,92 +51,8 @@ pub fn migrate_schema<T: BeaconChainTypes>(
5751
}
5852

5953
//
60-
// Migrations from before SchemaVersion(11) are deprecated.
54+
// Migrations from before SchemaVersion(16) are deprecated.
6155
//
62-
63-
// Upgrade from v11 to v12 to store richer metadata in the attestation op pool.
64-
(SchemaVersion(11), SchemaVersion(12)) => {
65-
let ops = migration_schema_v12::upgrade_to_v12::<T>(db.clone(), log)?;
66-
db.store_schema_version_atomically(to, ops)
67-
}
68-
// Downgrade from v12 to v11 to drop richer metadata from the attestation op pool.
69-
(SchemaVersion(12), SchemaVersion(11)) => {
70-
let ops = migration_schema_v12::downgrade_from_v12::<T>(db.clone(), log)?;
71-
db.store_schema_version_atomically(to, ops)
72-
}
73-
(SchemaVersion(12), SchemaVersion(13)) => {
74-
let mut ops = vec![];
75-
if let Some(persisted_eth1_v1) = db.get_item::<SszEth1>(&ETH1_CACHE_DB_KEY)? {
76-
let upgraded_eth1_cache =
77-
match migration_schema_v13::update_eth1_cache(persisted_eth1_v1) {
78-
Ok(upgraded_eth1) => upgraded_eth1,
79-
Err(e) => {
80-
warn!(log, "Failed to deserialize SszEth1CacheV1"; "error" => ?e);
81-
warn!(log, "Reinitializing eth1 cache");
82-
migration_schema_v13::reinitialized_eth1_cache_v13(
83-
deposit_contract_deploy_block,
84-
)
85-
}
86-
};
87-
ops.push(upgraded_eth1_cache.as_kv_store_op(ETH1_CACHE_DB_KEY));
88-
}
89-
90-
db.store_schema_version_atomically(to, ops)?;
91-
92-
Ok(())
93-
}
94-
(SchemaVersion(13), SchemaVersion(12)) => {
95-
let mut ops = vec![];
96-
if let Some(persisted_eth1_v13) = db.get_item::<SszEth1>(&ETH1_CACHE_DB_KEY)? {
97-
let downgraded_eth1_cache = match migration_schema_v13::downgrade_eth1_cache(
98-
persisted_eth1_v13,
99-
) {
100-
Ok(Some(downgraded_eth1)) => downgraded_eth1,
101-
Ok(None) => {
102-
warn!(log, "Unable to downgrade eth1 cache from newer version: reinitializing eth1 cache");
103-
migration_schema_v13::reinitialized_eth1_cache_v1(
104-
deposit_contract_deploy_block,
105-
)
106-
}
107-
Err(e) => {
108-
warn!(log, "Unable to downgrade eth1 cache from newer version: failed to deserialize SszEth1CacheV13"; "error" => ?e);
109-
warn!(log, "Reinitializing eth1 cache");
110-
migration_schema_v13::reinitialized_eth1_cache_v1(
111-
deposit_contract_deploy_block,
112-
)
113-
}
114-
};
115-
ops.push(downgraded_eth1_cache.as_kv_store_op(ETH1_CACHE_DB_KEY));
116-
}
117-
118-
db.store_schema_version_atomically(to, ops)?;
119-
120-
Ok(())
121-
}
122-
(SchemaVersion(13), SchemaVersion(14)) => {
123-
let ops = migration_schema_v14::upgrade_to_v14::<T>(db.clone(), log)?;
124-
db.store_schema_version_atomically(to, ops)
125-
}
126-
(SchemaVersion(14), SchemaVersion(13)) => {
127-
let ops = migration_schema_v14::downgrade_from_v14::<T>(db.clone(), log)?;
128-
db.store_schema_version_atomically(to, ops)
129-
}
130-
(SchemaVersion(14), SchemaVersion(15)) => {
131-
let ops = migration_schema_v15::upgrade_to_v15::<T>(db.clone(), log)?;
132-
db.store_schema_version_atomically(to, ops)
133-
}
134-
(SchemaVersion(15), SchemaVersion(14)) => {
135-
let ops = migration_schema_v15::downgrade_from_v15::<T>(db.clone(), log)?;
136-
db.store_schema_version_atomically(to, ops)
137-
}
138-
(SchemaVersion(15), SchemaVersion(16)) => {
139-
let ops = migration_schema_v16::upgrade_to_v16::<T>(db.clone(), log)?;
140-
db.store_schema_version_atomically(to, ops)
141-
}
142-
(SchemaVersion(16), SchemaVersion(15)) => {
143-
let ops = migration_schema_v16::downgrade_from_v16::<T>(db.clone(), log)?;
144-
db.store_schema_version_atomically(to, ops)
145-
}
14656
(SchemaVersion(16), SchemaVersion(17)) => {
14757
let ops = migration_schema_v17::upgrade_to_v17::<T>(db.clone(), log)?;
14858
db.store_schema_version_atomically(to, ops)

beacon_node/beacon_chain/src/schema_change/migration_schema_v12.rs

Lines changed: 0 additions & 222 deletions
This file was deleted.

0 commit comments

Comments
 (0)