diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index e4711f006e..387809bbe2 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -35,7 +35,6 @@ use primitives::VaultCurrencyPair; use crate::types::{ BalanceOf, BtcAddress, CurrencyId, DefaultSystemVault, RichSystemVault, RichVault, SignedInner, UnsignedFixedPoint, - Version, }; use crate::types::DefaultVaultCurrencyPair; @@ -86,8 +85,12 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + #[pallet::pallet] #[pallet::generate_store(trait Store)] + #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] // vault struct contains vec which doesn't implement MaxEncodedLen pub struct Pallet(_); @@ -142,7 +145,14 @@ pub mod pallet { } fn on_runtime_upgrade() -> frame_support::weights::Weight { - crate::types::v1::migrate_v1_to_v6::() + let _ = frame_support::migration::clear_storage_prefix( + >::name().as_bytes(), + b"StorageVersion", + b"", + None, + None, + ); + T::DbWeight::get().reads_writes(0, 1) } } @@ -638,16 +648,6 @@ pub mod pallet { pub(super) type TotalUserVaultCollateral = StorageMap<_, Blake2_128Concat, DefaultVaultCurrencyPair, BalanceOf, ValueQuery>; - #[pallet::type_value] - pub(super) fn DefaultForStorageVersion() -> Version { - Version::V6 - } - - /// Pallet storage version - #[pallet::storage] - #[pallet::getter(fn storage_version)] - pub(super) type StorageVersion = StorageValue<_, Version, ValueQuery, DefaultForStorageVersion>; - #[pallet::genesis_config] pub struct GenesisConfig { pub minimum_collateral_vault: Vec<(CurrencyId, BalanceOf)>, @@ -691,7 +691,6 @@ pub mod pallet { for (currency_pair, threshold) in self.liquidation_collateral_threshold.iter() { LiquidationCollateralThreshold::::insert(currency_pair, threshold); } - StorageVersion::::put(Version::V3); } } } diff --git a/crates/vault-registry/src/types.rs b/crates/vault-registry/src/types.rs index bb93b36587..01e1aecd2c 100644 --- a/crates/vault-registry/src/types.rs +++ b/crates/vault-registry/src/types.rs @@ -19,25 +19,6 @@ use mocktopus::macros::mockable; pub use bitcoin::{Address as BtcAddress, PublicKey as BtcPublicKey}; -/// Storage version. -#[derive(Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum Version { - /// Initial version. - V0, - /// BtcAddress type with script format. - V1, - /// added replace_collateral to vault, changed vaultStatus enum - V2, - /// moved public_key out of the vault struct - V3, - /// Fixed liquidation vault - V4, - /// Added custom pervault secure collateral threshold - V5, - /// Removed wallet - V6, -} - #[derive(Debug, PartialEq)] pub enum CurrencySource { /// Used by vault to back issued tokens @@ -111,21 +92,6 @@ pub type DefaultVaultId = VaultId<::AccountId, Cur pub type DefaultVaultCurrencyPair = VaultCurrencyPair>; -pub mod v1 { - use super::*; - - pub fn migrate_v1_to_v6() -> frame_support::weights::Weight { - // kintsugi is on V6 but interlay is still on V1 - if !matches!(crate::StorageVersion::::get(), Version::V1) { - log::info!("Not running vault storage migration"); - return T::DbWeight::get().reads(1); // already upgraded; don't run migration - } - // nothing to do other than update version - crate::StorageVersion::::put(Version::V6); - T::DbWeight::get().reads_writes(0, 1) - } -} - #[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, Debug, TypeInfo, MaxEncodedLen)] pub enum VaultStatus { /// Vault is active - bool=true indicates that the vault accepts new issue requests