|
1 | 1 | //! 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; |
7 | 2 | mod migration_schema_v17;
|
8 | 3 | mod migration_schema_v18;
|
9 | 4 |
|
10 |
| -use crate::beacon_chain::{BeaconChainTypes, ETH1_CACHE_DB_KEY}; |
11 |
| -use crate::eth1_chain::SszEth1; |
| 5 | +use crate::beacon_chain::BeaconChainTypes; |
12 | 6 | use crate::types::ChainSpec;
|
13 |
| -use slog::{warn, Logger}; |
| 7 | +use slog::Logger; |
14 | 8 | use std::sync::Arc;
|
15 | 9 | use store::hot_cold_store::{HotColdDB, HotColdDBError};
|
16 | 10 | use store::metadata::{SchemaVersion, CURRENT_SCHEMA_VERSION};
|
17 |
| -use store::{Error as StoreError, StoreItem}; |
| 11 | +use store::Error as StoreError; |
18 | 12 |
|
19 | 13 | /// Migrate the database from one schema version to another, applying all requisite mutations.
|
20 | 14 | #[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>(
|
57 | 51 | }
|
58 | 52 |
|
59 | 53 | //
|
60 |
| - // Migrations from before SchemaVersion(11) are deprecated. |
| 54 | + // Migrations from before SchemaVersion(16) are deprecated. |
61 | 55 | //
|
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>(Ð1_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>(Ð1_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 |
| - } |
146 | 56 | (SchemaVersion(16), SchemaVersion(17)) => {
|
147 | 57 | let ops = migration_schema_v17::upgrade_to_v17::<T>(db.clone(), log)?;
|
148 | 58 | db.store_schema_version_atomically(to, ops)
|
|
0 commit comments